Skip to content

Commit 8dac6be

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/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()
2 parents f8f44f0 + d6e43f7 commit 8dac6be

17 files changed

Lines changed: 210 additions & 213 deletions

File tree

‎fs/afs/dir.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,11 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
584584

585585
success:
586586
d_add(dentry, inode);
587-
_leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%llu }",
587+
_leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%u }",
588588
fid.vnode,
589589
fid.unique,
590590
dentry->d_inode->i_ino,
591-
(unsigned long long)dentry->d_inode->i_version);
591+
dentry->d_inode->i_generation);
592592

593593
return NULL;
594594
}
@@ -671,10 +671,10 @@ static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
671671
* been deleted and replaced, and the original vnode ID has
672672
* been reused */
673673
if (fid.unique != vnode->fid.unique) {
674-
_debug("%s: file deleted (uq %u -> %u I:%llu)",
674+
_debug("%s: file deleted (uq %u -> %u I:%u)",
675675
dentry->d_name.name, fid.unique,
676676
vnode->fid.unique,
677-
(unsigned long long)dentry->d_inode->i_version);
677+
dentry->d_inode->i_generation);
678678
spin_lock(&vnode->lock);
679679
set_bit(AFS_VNODE_DELETED, &vnode->flags);
680680
spin_unlock(&vnode->lock);

‎fs/afs/fsclient.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp,
8989
i_size_write(&vnode->vfs_inode, size);
9090
vnode->vfs_inode.i_uid = status->owner;
9191
vnode->vfs_inode.i_gid = status->group;
92-
vnode->vfs_inode.i_version = vnode->fid.unique;
92+
vnode->vfs_inode.i_generation = vnode->fid.unique;
9393
vnode->vfs_inode.i_nlink = status->nlink;
9494

9595
mode = vnode->vfs_inode.i_mode;
@@ -102,6 +102,7 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp,
102102
vnode->vfs_inode.i_ctime.tv_sec = status->mtime_server;
103103
vnode->vfs_inode.i_mtime = vnode->vfs_inode.i_ctime;
104104
vnode->vfs_inode.i_atime = vnode->vfs_inode.i_ctime;
105+
vnode->vfs_inode.i_version = data_version;
105106
}
106107

107108
expected_version = status->data_version;

‎fs/afs/inode.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ static int afs_inode_map_status(struct afs_vnode *vnode, struct key *key)
7575
inode->i_ctime.tv_nsec = 0;
7676
inode->i_atime = inode->i_mtime = inode->i_ctime;
7777
inode->i_blocks = 0;
78-
inode->i_version = vnode->fid.unique;
78+
inode->i_generation = vnode->fid.unique;
79+
inode->i_version = vnode->status.data_version;
7980
inode->i_mapping->a_ops = &afs_fs_aops;
8081

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

102103
return inode->i_ino == data->fid.vnode &&
103-
inode->i_version == data->fid.unique;
104+
inode->i_generation == data->fid.unique;
104105
}
105106

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

124125
inode->i_ino = data->fid.vnode;
125-
inode->i_version = data->fid.unique;
126+
inode->i_generation = data->fid.unique;
126127
vnode->fid = data->fid;
127128
vnode->volume = data->volume;
128129

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

381382
inode = dentry->d_inode;
382383

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

386386
generic_fillattr(inode, stat);
387387
return 0;

‎fs/afs/super.c‎

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@
3131
static void afs_i_init_once(void *foo);
3232
static struct dentry *afs_mount(struct file_system_type *fs_type,
3333
int flags, const char *dev_name, void *data);
34+
static void afs_kill_super(struct super_block *sb);
3435
static struct inode *afs_alloc_inode(struct super_block *sb);
35-
static void afs_put_super(struct super_block *sb);
3636
static void afs_destroy_inode(struct inode *inode);
3737
static int afs_statfs(struct dentry *dentry, struct kstatfs *buf);
3838

3939
struct file_system_type afs_fs_type = {
4040
.owner = THIS_MODULE,
4141
.name = "afs",
4242
.mount = afs_mount,
43-
.kill_sb = kill_anon_super,
43+
.kill_sb = afs_kill_super,
4444
.fs_flags = 0,
4545
};
4646

@@ -50,7 +50,6 @@ static const struct super_operations afs_super_ops = {
5050
.drop_inode = afs_drop_inode,
5151
.destroy_inode = afs_destroy_inode,
5252
.evict_inode = afs_evict_inode,
53-
.put_super = afs_put_super,
5453
.show_options = generic_show_options,
5554
};
5655

@@ -282,51 +281,47 @@ static int afs_parse_device_name(struct afs_mount_params *params,
282281
*/
283282
static int afs_test_super(struct super_block *sb, void *data)
284283
{
285-
struct afs_mount_params *params = data;
284+
struct afs_super_info *as1 = data;
286285
struct afs_super_info *as = sb->s_fs_info;
287286

288-
return as->volume == params->volume;
287+
return as->volume == as1->volume;
288+
}
289+
290+
static int afs_set_super(struct super_block *sb, void *data)
291+
{
292+
sb->s_fs_info = data;
293+
return set_anon_super(sb, NULL);
289294
}
290295

291296
/*
292297
* fill in the superblock
293298
*/
294-
static int afs_fill_super(struct super_block *sb, void *data)
299+
static int afs_fill_super(struct super_block *sb,
300+
struct afs_mount_params *params)
295301
{
296-
struct afs_mount_params *params = data;
297-
struct afs_super_info *as = NULL;
302+
struct afs_super_info *as = sb->s_fs_info;
298303
struct afs_fid fid;
299304
struct dentry *root = NULL;
300305
struct inode *inode = NULL;
301306
int ret;
302307

303308
_enter("");
304309

305-
/* allocate a superblock info record */
306-
as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
307-
if (!as) {
308-
_leave(" = -ENOMEM");
309-
return -ENOMEM;
310-
}
311-
312-
afs_get_volume(params->volume);
313-
as->volume = params->volume;
314-
315310
/* fill in the superblock */
316311
sb->s_blocksize = PAGE_CACHE_SIZE;
317312
sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
318313
sb->s_magic = AFS_FS_MAGIC;
319314
sb->s_op = &afs_super_ops;
320-
sb->s_fs_info = as;
321315
sb->s_bdi = &as->volume->bdi;
316+
strlcpy(sb->s_id, as->volume->vlocation->vldb.name, sizeof(sb->s_id));
322317

323318
/* allocate the root inode and dentry */
324319
fid.vid = as->volume->vid;
325320
fid.vnode = 1;
326321
fid.unique = 1;
327322
inode = afs_iget(sb, params->key, &fid, NULL, NULL);
328323
if (IS_ERR(inode))
329-
goto error_inode;
324+
return PTR_ERR(inode);
330325

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

345-
error_inode:
346-
ret = PTR_ERR(inode);
347-
inode = NULL;
348340
error:
349341
iput(inode);
350-
afs_put_volume(as->volume);
351-
kfree(as);
352-
353-
sb->s_fs_info = NULL;
354-
355342
_leave(" = %d", ret);
356343
return ret;
357344
}
@@ -367,6 +354,7 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,
367354
struct afs_volume *vol;
368355
struct key *key;
369356
char *new_opts = kstrdup(options, GFP_KERNEL);
357+
struct afs_super_info *as;
370358
int ret;
371359

372360
_enter(",,%s,%p", dev_name, options);
@@ -399,12 +387,22 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,
399387
ret = PTR_ERR(vol);
400388
goto error;
401389
}
402-
params.volume = vol;
390+
391+
/* allocate a superblock info record */
392+
as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
393+
if (!as) {
394+
ret = -ENOMEM;
395+
afs_put_volume(vol);
396+
goto error;
397+
}
398+
as->volume = vol;
403399

404400
/* allocate a deviceless superblock */
405-
sb = sget(fs_type, afs_test_super, set_anon_super, &params);
401+
sb = sget(fs_type, afs_test_super, afs_set_super, as);
406402
if (IS_ERR(sb)) {
407403
ret = PTR_ERR(sb);
404+
afs_put_volume(vol);
405+
kfree(as);
408406
goto error;
409407
}
410408

@@ -422,35 +420,29 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,
422420
} else {
423421
_debug("reuse");
424422
ASSERTCMP(sb->s_flags, &, MS_ACTIVE);
423+
afs_put_volume(vol);
424+
kfree(as);
425425
}
426426

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

433432
error:
434-
afs_put_volume(params.volume);
435433
afs_put_cell(params.cell);
436434
key_put(params.key);
437435
kfree(new_opts);
438436
_leave(" = %d", ret);
439437
return ERR_PTR(ret);
440438
}
441439

442-
/*
443-
* finish the unmounting process on the superblock
444-
*/
445-
static void afs_put_super(struct super_block *sb)
440+
static void afs_kill_super(struct super_block *sb)
446441
{
447442
struct afs_super_info *as = sb->s_fs_info;
448-
449-
_enter("");
450-
443+
kill_anon_super(sb);
451444
afs_put_volume(as->volume);
452-
453-
_leave("");
445+
kfree(as);
454446
}
455447

456448
/*

‎fs/afs/write.c‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,21 @@ void afs_put_writeback(struct afs_writeback *wb)
8484
* partly or wholly fill a page that's under preparation for writing
8585
*/
8686
static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
87-
loff_t pos, unsigned len, struct page *page)
87+
loff_t pos, struct page *page)
8888
{
8989
loff_t i_size;
90-
unsigned eof;
9190
int ret;
91+
int len;
9292

93-
_enter(",,%llu,%u", (unsigned long long)pos, len);
94-
95-
ASSERTCMP(len, <=, PAGE_CACHE_SIZE);
93+
_enter(",,%llu", (unsigned long long)pos);
9694

9795
i_size = i_size_read(&vnode->vfs_inode);
98-
if (pos + len > i_size)
99-
eof = i_size;
96+
if (pos + PAGE_CACHE_SIZE > i_size)
97+
len = i_size - pos;
10098
else
101-
eof = PAGE_CACHE_SIZE;
99+
len = PAGE_CACHE_SIZE;
102100

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

156-
if (!PageUptodate(page)) {
157-
_debug("not up to date");
158-
ret = afs_fill_page(vnode, key, pos, len, page);
154+
if (!PageUptodate(page) && len != PAGE_CACHE_SIZE) {
155+
ret = afs_fill_page(vnode, key, index << PAGE_CACHE_SHIFT, page);
159156
if (ret < 0) {
160157
kfree(candidate);
161158
_leave(" = %d [prep]", ret);

‎fs/buffer.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,10 +1902,8 @@ int __block_write_begin(struct page *page, loff_t pos, unsigned len,
19021902
if (!buffer_uptodate(*wait_bh))
19031903
err = -EIO;
19041904
}
1905-
if (unlikely(err)) {
1905+
if (unlikely(err))
19061906
page_zero_new_buffers(page, from, to);
1907-
ClearPageUptodate(page);
1908-
}
19091907
return err;
19101908
}
19111909
EXPORT_SYMBOL(__block_write_begin);

0 commit comments

Comments
 (0)