Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/viro/vfs-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
  AFS: Use i_generation not i_version for the vnode uniquifier
  AFS: Set s_id in the superblock to the volume name
  vfs: Fix data corruption after failed write in __block_write_begin()
  afs: afs_fill_page reads too much, or wrong data
  VFS: Fix vfsmount overput on simultaneous automount
  fix wrong iput on d_inode introduced by e6bc45d
  Delay struct net freeing while there's a sysfs instance refering to it
  afs: fix sget() races, close leak on umount
  ubifs: fix sget races
  ubifs: split allocation of ubifs_info into a separate function
  fix leak in proc_set_super()
  • Loading branch information
torvalds committed Jun 16, 2011
2 parents f8f44f0 + d6e43f7 commit 8dac6be
Show file tree
Hide file tree
Showing 17 changed files with 210 additions and 213 deletions.
8 changes: 4 additions & 4 deletions fs/afs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,11 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,

success:
d_add(dentry, inode);
_leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%llu }",
_leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%u }",
fid.vnode,
fid.unique,
dentry->d_inode->i_ino,
(unsigned long long)dentry->d_inode->i_version);
dentry->d_inode->i_generation);

return NULL;
}
Expand Down Expand Up @@ -671,10 +671,10 @@ static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
* been deleted and replaced, and the original vnode ID has
* been reused */
if (fid.unique != vnode->fid.unique) {
_debug("%s: file deleted (uq %u -> %u I:%llu)",
_debug("%s: file deleted (uq %u -> %u I:%u)",
dentry->d_name.name, fid.unique,
vnode->fid.unique,
(unsigned long long)dentry->d_inode->i_version);
dentry->d_inode->i_generation);
spin_lock(&vnode->lock);
set_bit(AFS_VNODE_DELETED, &vnode->flags);
spin_unlock(&vnode->lock);
Expand Down
3 changes: 2 additions & 1 deletion fs/afs/fsclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp,
i_size_write(&vnode->vfs_inode, size);
vnode->vfs_inode.i_uid = status->owner;
vnode->vfs_inode.i_gid = status->group;
vnode->vfs_inode.i_version = vnode->fid.unique;
vnode->vfs_inode.i_generation = vnode->fid.unique;
vnode->vfs_inode.i_nlink = status->nlink;

mode = vnode->vfs_inode.i_mode;
Expand All @@ -102,6 +102,7 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp,
vnode->vfs_inode.i_ctime.tv_sec = status->mtime_server;
vnode->vfs_inode.i_mtime = vnode->vfs_inode.i_ctime;
vnode->vfs_inode.i_atime = vnode->vfs_inode.i_ctime;
vnode->vfs_inode.i_version = data_version;
}

expected_version = status->data_version;
Expand Down
10 changes: 5 additions & 5 deletions fs/afs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ static int afs_inode_map_status(struct afs_vnode *vnode, struct key *key)
inode->i_ctime.tv_nsec = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime;
inode->i_blocks = 0;
inode->i_version = vnode->fid.unique;
inode->i_generation = vnode->fid.unique;
inode->i_version = vnode->status.data_version;
inode->i_mapping->a_ops = &afs_fs_aops;

/* check to see whether a symbolic link is really a mountpoint */
Expand All @@ -100,7 +101,7 @@ static int afs_iget5_test(struct inode *inode, void *opaque)
struct afs_iget_data *data = opaque;

return inode->i_ino == data->fid.vnode &&
inode->i_version == data->fid.unique;
inode->i_generation == data->fid.unique;
}

/*
Expand All @@ -122,7 +123,7 @@ static int afs_iget5_set(struct inode *inode, void *opaque)
struct afs_vnode *vnode = AFS_FS_I(inode);

inode->i_ino = data->fid.vnode;
inode->i_version = data->fid.unique;
inode->i_generation = data->fid.unique;
vnode->fid = data->fid;
vnode->volume = data->volume;

Expand Down Expand Up @@ -380,8 +381,7 @@ int afs_getattr(struct vfsmount *mnt, struct dentry *dentry,

inode = dentry->d_inode;

_enter("{ ino=%lu v=%llu }", inode->i_ino,
(unsigned long long)inode->i_version);
_enter("{ ino=%lu v=%u }", inode->i_ino, inode->i_generation);

generic_fillattr(inode, stat);
return 0;
Expand Down
74 changes: 33 additions & 41 deletions fs/afs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
static void afs_i_init_once(void *foo);
static struct dentry *afs_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data);
static void afs_kill_super(struct super_block *sb);
static struct inode *afs_alloc_inode(struct super_block *sb);
static void afs_put_super(struct super_block *sb);
static void afs_destroy_inode(struct inode *inode);
static int afs_statfs(struct dentry *dentry, struct kstatfs *buf);

struct file_system_type afs_fs_type = {
.owner = THIS_MODULE,
.name = "afs",
.mount = afs_mount,
.kill_sb = kill_anon_super,
.kill_sb = afs_kill_super,
.fs_flags = 0,
};

Expand All @@ -50,7 +50,6 @@ static const struct super_operations afs_super_ops = {
.drop_inode = afs_drop_inode,
.destroy_inode = afs_destroy_inode,
.evict_inode = afs_evict_inode,
.put_super = afs_put_super,
.show_options = generic_show_options,
};

Expand Down Expand Up @@ -282,51 +281,47 @@ static int afs_parse_device_name(struct afs_mount_params *params,
*/
static int afs_test_super(struct super_block *sb, void *data)
{
struct afs_mount_params *params = data;
struct afs_super_info *as1 = data;
struct afs_super_info *as = sb->s_fs_info;

return as->volume == params->volume;
return as->volume == as1->volume;
}

static int afs_set_super(struct super_block *sb, void *data)
{
sb->s_fs_info = data;
return set_anon_super(sb, NULL);
}

/*
* fill in the superblock
*/
static int afs_fill_super(struct super_block *sb, void *data)
static int afs_fill_super(struct super_block *sb,
struct afs_mount_params *params)
{
struct afs_mount_params *params = data;
struct afs_super_info *as = NULL;
struct afs_super_info *as = sb->s_fs_info;
struct afs_fid fid;
struct dentry *root = NULL;
struct inode *inode = NULL;
int ret;

_enter("");

/* allocate a superblock info record */
as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
if (!as) {
_leave(" = -ENOMEM");
return -ENOMEM;
}

afs_get_volume(params->volume);
as->volume = params->volume;

/* fill in the superblock */
sb->s_blocksize = PAGE_CACHE_SIZE;
sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
sb->s_magic = AFS_FS_MAGIC;
sb->s_op = &afs_super_ops;
sb->s_fs_info = as;
sb->s_bdi = &as->volume->bdi;
strlcpy(sb->s_id, as->volume->vlocation->vldb.name, sizeof(sb->s_id));

/* allocate the root inode and dentry */
fid.vid = as->volume->vid;
fid.vnode = 1;
fid.unique = 1;
inode = afs_iget(sb, params->key, &fid, NULL, NULL);
if (IS_ERR(inode))
goto error_inode;
return PTR_ERR(inode);

if (params->autocell)
set_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(inode)->flags);
Expand All @@ -342,16 +337,8 @@ static int afs_fill_super(struct super_block *sb, void *data)
_leave(" = 0");
return 0;

error_inode:
ret = PTR_ERR(inode);
inode = NULL;
error:
iput(inode);
afs_put_volume(as->volume);
kfree(as);

sb->s_fs_info = NULL;

_leave(" = %d", ret);
return ret;
}
Expand All @@ -367,6 +354,7 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,
struct afs_volume *vol;
struct key *key;
char *new_opts = kstrdup(options, GFP_KERNEL);
struct afs_super_info *as;
int ret;

_enter(",,%s,%p", dev_name, options);
Expand Down Expand Up @@ -399,12 +387,22 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,
ret = PTR_ERR(vol);
goto error;
}
params.volume = vol;

/* allocate a superblock info record */
as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
if (!as) {
ret = -ENOMEM;
afs_put_volume(vol);
goto error;
}
as->volume = vol;

/* allocate a deviceless superblock */
sb = sget(fs_type, afs_test_super, set_anon_super, &params);
sb = sget(fs_type, afs_test_super, afs_set_super, as);
if (IS_ERR(sb)) {
ret = PTR_ERR(sb);
afs_put_volume(vol);
kfree(as);
goto error;
}

Expand All @@ -422,35 +420,29 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,
} else {
_debug("reuse");
ASSERTCMP(sb->s_flags, &, MS_ACTIVE);
afs_put_volume(vol);
kfree(as);
}

afs_put_volume(params.volume);
afs_put_cell(params.cell);
kfree(new_opts);
_leave(" = 0 [%p]", sb);
return dget(sb->s_root);

error:
afs_put_volume(params.volume);
afs_put_cell(params.cell);
key_put(params.key);
kfree(new_opts);
_leave(" = %d", ret);
return ERR_PTR(ret);
}

/*
* finish the unmounting process on the superblock
*/
static void afs_put_super(struct super_block *sb)
static void afs_kill_super(struct super_block *sb)
{
struct afs_super_info *as = sb->s_fs_info;

_enter("");

kill_anon_super(sb);
afs_put_volume(as->volume);

_leave("");
kfree(as);
}

/*
Expand Down
21 changes: 9 additions & 12 deletions fs/afs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,21 @@ void afs_put_writeback(struct afs_writeback *wb)
* partly or wholly fill a page that's under preparation for writing
*/
static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
loff_t pos, unsigned len, struct page *page)
loff_t pos, struct page *page)
{
loff_t i_size;
unsigned eof;
int ret;
int len;

_enter(",,%llu,%u", (unsigned long long)pos, len);

ASSERTCMP(len, <=, PAGE_CACHE_SIZE);
_enter(",,%llu", (unsigned long long)pos);

i_size = i_size_read(&vnode->vfs_inode);
if (pos + len > i_size)
eof = i_size;
if (pos + PAGE_CACHE_SIZE > i_size)
len = i_size - pos;
else
eof = PAGE_CACHE_SIZE;
len = PAGE_CACHE_SIZE;

ret = afs_vnode_fetch_data(vnode, key, 0, eof, page);
ret = afs_vnode_fetch_data(vnode, key, pos, len, page);
if (ret < 0) {
if (ret == -ENOENT) {
_debug("got NOENT from server"
Expand Down Expand Up @@ -153,9 +151,8 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
*pagep = page;
/* page won't leak in error case: it eventually gets cleaned off LRU */

if (!PageUptodate(page)) {
_debug("not up to date");
ret = afs_fill_page(vnode, key, pos, len, page);
if (!PageUptodate(page) && len != PAGE_CACHE_SIZE) {
ret = afs_fill_page(vnode, key, index << PAGE_CACHE_SHIFT, page);
if (ret < 0) {
kfree(candidate);
_leave(" = %d [prep]", ret);
Expand Down
4 changes: 1 addition & 3 deletions fs/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1902,10 +1902,8 @@ int __block_write_begin(struct page *page, loff_t pos, unsigned len,
if (!buffer_uptodate(*wait_bh))
err = -EIO;
}
if (unlikely(err)) {
if (unlikely(err))
page_zero_new_buffers(page, from, to);
ClearPageUptodate(page);
}
return err;
}
EXPORT_SYMBOL(__block_write_begin);
Expand Down
Loading

0 comments on commit 8dac6be

Please sign in to comment.