diff options
Diffstat (limited to 'fs')
101 files changed, 1190 insertions, 790 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 5c5137c11484..6a28842052ea 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -573,7 +573,7 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | |||
573 | v9ses = v9fs_inode2v9ses(dir); | 573 | v9ses = v9fs_inode2v9ses(dir); |
574 | dfid = v9fs_fid_lookup(dentry->d_parent); | 574 | dfid = v9fs_fid_lookup(dentry->d_parent); |
575 | if (IS_ERR(dfid)) | 575 | if (IS_ERR(dfid)) |
576 | return ERR_PTR(PTR_ERR(dfid)); | 576 | return ERR_CAST(dfid); |
577 | 577 | ||
578 | name = (char *) dentry->d_name.name; | 578 | name = (char *) dentry->d_name.name; |
579 | fid = p9_client_walk(dfid, 1, &name, 1); | 579 | fid = p9_client_walk(dfid, 1, &name, 1); |
diff --git a/fs/Kconfig b/fs/Kconfig index ea5b35947623..3bf6ace1720c 100644 --- a/fs/Kconfig +++ b/fs/Kconfig | |||
@@ -463,40 +463,18 @@ config OCFS2_DEBUG_FS | |||
463 | this option for debugging only as it is likely to decrease | 463 | this option for debugging only as it is likely to decrease |
464 | performance of the filesystem. | 464 | performance of the filesystem. |
465 | 465 | ||
466 | config MINIX_FS | 466 | endif # BLOCK |
467 | tristate "Minix fs support" | ||
468 | help | ||
469 | Minix is a simple operating system used in many classes about OS's. | ||
470 | The minix file system (method to organize files on a hard disk | ||
471 | partition or a floppy disk) was the original file system for Linux, | ||
472 | but has been superseded by the second extended file system ext2fs. | ||
473 | You don't want to use the minix file system on your hard disk | ||
474 | because of certain built-in restrictions, but it is sometimes found | ||
475 | on older Linux floppy disks. This option will enlarge your kernel | ||
476 | by about 28 KB. If unsure, say N. | ||
477 | |||
478 | To compile this file system support as a module, choose M here: the | ||
479 | module will be called minix. Note that the file system of your root | ||
480 | partition (the one containing the directory /) cannot be compiled as | ||
481 | a module. | ||
482 | |||
483 | config ROMFS_FS | ||
484 | tristate "ROM file system support" | ||
485 | ---help--- | ||
486 | This is a very small read-only file system mainly intended for | ||
487 | initial ram disks of installation disks, but it could be used for | ||
488 | other read-only media as well. Read | ||
489 | <file:Documentation/filesystems/romfs.txt> for details. | ||
490 | |||
491 | To compile this file system support as a module, choose M here: the | ||
492 | module will be called romfs. Note that the file system of your | ||
493 | root partition (the one containing the directory /) cannot be a | ||
494 | module. | ||
495 | 467 | ||
496 | If you don't know whether you need it, then you don't need it: | 468 | config DNOTIFY |
497 | answer N. | 469 | bool "Dnotify support" |
470 | default y | ||
471 | help | ||
472 | Dnotify is a directory-based per-fd file change notification system | ||
473 | that uses signals to communicate events to user-space. There exist | ||
474 | superior alternatives, but some applications may still rely on | ||
475 | dnotify. | ||
498 | 476 | ||
499 | endif | 477 | If unsure, say Y. |
500 | 478 | ||
501 | config INOTIFY | 479 | config INOTIFY |
502 | bool "Inotify file change notification support" | 480 | bool "Inotify file change notification support" |
@@ -577,17 +555,6 @@ config QUOTACTL | |||
577 | depends on XFS_QUOTA || QUOTA | 555 | depends on XFS_QUOTA || QUOTA |
578 | default y | 556 | default y |
579 | 557 | ||
580 | config DNOTIFY | ||
581 | bool "Dnotify support" | ||
582 | default y | ||
583 | help | ||
584 | Dnotify is a directory-based per-fd file change notification system | ||
585 | that uses signals to communicate events to user-space. There exist | ||
586 | superior alternatives, but some applications may still rely on | ||
587 | dnotify. | ||
588 | |||
589 | If unsure, say Y. | ||
590 | |||
591 | config AUTOFS_FS | 558 | config AUTOFS_FS |
592 | tristate "Kernel automounter support" | 559 | tristate "Kernel automounter support" |
593 | help | 560 | help |
@@ -713,7 +680,7 @@ config UDF_NLS | |||
713 | depends on (UDF_FS=m && NLS) || (UDF_FS=y && NLS=y) | 680 | depends on (UDF_FS=m && NLS) || (UDF_FS=y && NLS=y) |
714 | 681 | ||
715 | endmenu | 682 | endmenu |
716 | endif | 683 | endif # BLOCK |
717 | 684 | ||
718 | if BLOCK | 685 | if BLOCK |
719 | menu "DOS/FAT/NT Filesystems" | 686 | menu "DOS/FAT/NT Filesystems" |
@@ -896,7 +863,7 @@ config NTFS_RW | |||
896 | It is perfectly safe to say N here. | 863 | It is perfectly safe to say N here. |
897 | 864 | ||
898 | endmenu | 865 | endmenu |
899 | endif | 866 | endif # BLOCK |
900 | 867 | ||
901 | menu "Pseudo filesystems" | 868 | menu "Pseudo filesystems" |
902 | 869 | ||
@@ -1417,6 +1384,24 @@ config VXFS_FS | |||
1417 | To compile this as a module, choose M here: the module will be | 1384 | To compile this as a module, choose M here: the module will be |
1418 | called freevxfs. If unsure, say N. | 1385 | called freevxfs. If unsure, say N. |
1419 | 1386 | ||
1387 | config MINIX_FS | ||
1388 | tristate "Minix file system support" | ||
1389 | depends on BLOCK | ||
1390 | help | ||
1391 | Minix is a simple operating system used in many classes about OS's. | ||
1392 | The minix file system (method to organize files on a hard disk | ||
1393 | partition or a floppy disk) was the original file system for Linux, | ||
1394 | but has been superseded by the second extended file system ext2fs. | ||
1395 | You don't want to use the minix file system on your hard disk | ||
1396 | because of certain built-in restrictions, but it is sometimes found | ||
1397 | on older Linux floppy disks. This option will enlarge your kernel | ||
1398 | by about 28 KB. If unsure, say N. | ||
1399 | |||
1400 | To compile this file system support as a module, choose M here: the | ||
1401 | module will be called minix. Note that the file system of your root | ||
1402 | partition (the one containing the directory /) cannot be compiled as | ||
1403 | a module. | ||
1404 | |||
1420 | 1405 | ||
1421 | config HPFS_FS | 1406 | config HPFS_FS |
1422 | tristate "OS/2 HPFS file system support" | 1407 | tristate "OS/2 HPFS file system support" |
@@ -1434,7 +1419,6 @@ config HPFS_FS | |||
1434 | module will be called hpfs. If unsure, say N. | 1419 | module will be called hpfs. If unsure, say N. |
1435 | 1420 | ||
1436 | 1421 | ||
1437 | |||
1438 | config QNX4FS_FS | 1422 | config QNX4FS_FS |
1439 | tristate "QNX4 file system support (read only)" | 1423 | tristate "QNX4 file system support (read only)" |
1440 | depends on BLOCK | 1424 | depends on BLOCK |
@@ -1461,6 +1445,22 @@ config QNX4FS_RW | |||
1461 | It's currently broken, so for now: | 1445 | It's currently broken, so for now: |
1462 | answer N. | 1446 | answer N. |
1463 | 1447 | ||
1448 | config ROMFS_FS | ||
1449 | tristate "ROM file system support" | ||
1450 | depends on BLOCK | ||
1451 | ---help--- | ||
1452 | This is a very small read-only file system mainly intended for | ||
1453 | initial ram disks of installation disks, but it could be used for | ||
1454 | other read-only media as well. Read | ||
1455 | <file:Documentation/filesystems/romfs.txt> for details. | ||
1456 | |||
1457 | To compile this file system support as a module, choose M here: the | ||
1458 | module will be called romfs. Note that the file system of your | ||
1459 | root partition (the one containing the directory /) cannot be a | ||
1460 | module. | ||
1461 | |||
1462 | If you don't know whether you need it, then you don't need it: | ||
1463 | answer N. | ||
1464 | 1464 | ||
1465 | 1465 | ||
1466 | config SYSV_FS | 1466 | config SYSV_FS |
@@ -1501,7 +1501,6 @@ config SYSV_FS | |||
1501 | If you haven't heard about all of this before, it's safe to say N. | 1501 | If you haven't heard about all of this before, it's safe to say N. |
1502 | 1502 | ||
1503 | 1503 | ||
1504 | |||
1505 | config UFS_FS | 1504 | config UFS_FS |
1506 | tristate "UFS file system support (read only)" | 1505 | tristate "UFS file system support (read only)" |
1507 | depends on BLOCK | 1506 | depends on BLOCK |
diff --git a/fs/affs/affs.h b/fs/affs/affs.h index 232c69493683..d5bd497ab9cb 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h | |||
@@ -174,7 +174,8 @@ extern void affs_put_inode(struct inode *inode); | |||
174 | extern void affs_drop_inode(struct inode *inode); | 174 | extern void affs_drop_inode(struct inode *inode); |
175 | extern void affs_delete_inode(struct inode *inode); | 175 | extern void affs_delete_inode(struct inode *inode); |
176 | extern void affs_clear_inode(struct inode *inode); | 176 | extern void affs_clear_inode(struct inode *inode); |
177 | extern void affs_read_inode(struct inode *inode); | 177 | extern struct inode *affs_iget(struct super_block *sb, |
178 | unsigned long ino); | ||
178 | extern int affs_write_inode(struct inode *inode, int); | 179 | extern int affs_write_inode(struct inode *inode, int); |
179 | extern int affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s32 type); | 180 | extern int affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s32 type); |
180 | 181 | ||
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c index f4de4b98004f..805573005de6 100644 --- a/fs/affs/amigaffs.c +++ b/fs/affs/amigaffs.c | |||
@@ -170,9 +170,11 @@ affs_remove_link(struct dentry *dentry) | |||
170 | if (!link_bh) | 170 | if (!link_bh) |
171 | goto done; | 171 | goto done; |
172 | 172 | ||
173 | dir = iget(sb, be32_to_cpu(AFFS_TAIL(sb, link_bh)->parent)); | 173 | dir = affs_iget(sb, be32_to_cpu(AFFS_TAIL(sb, link_bh)->parent)); |
174 | if (!dir) | 174 | if (IS_ERR(dir)) { |
175 | retval = PTR_ERR(dir); | ||
175 | goto done; | 176 | goto done; |
177 | } | ||
176 | 178 | ||
177 | affs_lock_dir(dir); | 179 | affs_lock_dir(dir); |
178 | affs_fix_dcache(dentry, link_ino); | 180 | affs_fix_dcache(dentry, link_ino); |
diff --git a/fs/affs/inode.c b/fs/affs/inode.c index 4609a6c13fe9..27fe6cbe43ae 100644 --- a/fs/affs/inode.c +++ b/fs/affs/inode.c | |||
@@ -15,20 +15,25 @@ | |||
15 | extern const struct inode_operations affs_symlink_inode_operations; | 15 | extern const struct inode_operations affs_symlink_inode_operations; |
16 | extern struct timezone sys_tz; | 16 | extern struct timezone sys_tz; |
17 | 17 | ||
18 | void | 18 | struct inode *affs_iget(struct super_block *sb, unsigned long ino) |
19 | affs_read_inode(struct inode *inode) | ||
20 | { | 19 | { |
21 | struct super_block *sb = inode->i_sb; | ||
22 | struct affs_sb_info *sbi = AFFS_SB(sb); | 20 | struct affs_sb_info *sbi = AFFS_SB(sb); |
23 | struct buffer_head *bh; | 21 | struct buffer_head *bh; |
24 | struct affs_head *head; | 22 | struct affs_head *head; |
25 | struct affs_tail *tail; | 23 | struct affs_tail *tail; |
24 | struct inode *inode; | ||
26 | u32 block; | 25 | u32 block; |
27 | u32 size; | 26 | u32 size; |
28 | u32 prot; | 27 | u32 prot; |
29 | u16 id; | 28 | u16 id; |
30 | 29 | ||
31 | pr_debug("AFFS: read_inode(%lu)\n",inode->i_ino); | 30 | inode = iget_locked(sb, ino); |
31 | if (!inode) | ||
32 | return ERR_PTR(-ENOMEM); | ||
33 | if (!(inode->i_state & I_NEW)) | ||
34 | return inode; | ||
35 | |||
36 | pr_debug("AFFS: affs_iget(%lu)\n", inode->i_ino); | ||
32 | 37 | ||
33 | block = inode->i_ino; | 38 | block = inode->i_ino; |
34 | bh = affs_bread(sb, block); | 39 | bh = affs_bread(sb, block); |
@@ -154,12 +159,13 @@ affs_read_inode(struct inode *inode) | |||
154 | sys_tz.tz_minuteswest * 60; | 159 | sys_tz.tz_minuteswest * 60; |
155 | inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_atime.tv_nsec = 0; | 160 | inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_atime.tv_nsec = 0; |
156 | affs_brelse(bh); | 161 | affs_brelse(bh); |
157 | return; | 162 | unlock_new_inode(inode); |
163 | return inode; | ||
158 | 164 | ||
159 | bad_inode: | 165 | bad_inode: |
160 | make_bad_inode(inode); | ||
161 | affs_brelse(bh); | 166 | affs_brelse(bh); |
162 | return; | 167 | iget_failed(inode); |
168 | return ERR_PTR(-EIO); | ||
163 | } | 169 | } |
164 | 170 | ||
165 | int | 171 | int |
diff --git a/fs/affs/namei.c b/fs/affs/namei.c index a42143ca0169..2218f1ee71ce 100644 --- a/fs/affs/namei.c +++ b/fs/affs/namei.c | |||
@@ -208,9 +208,8 @@ affs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | |||
208 | affs_lock_dir(dir); | 208 | affs_lock_dir(dir); |
209 | bh = affs_find_entry(dir, dentry); | 209 | bh = affs_find_entry(dir, dentry); |
210 | affs_unlock_dir(dir); | 210 | affs_unlock_dir(dir); |
211 | if (IS_ERR(bh)) { | 211 | if (IS_ERR(bh)) |
212 | return ERR_PTR(PTR_ERR(bh)); | 212 | return ERR_CAST(bh); |
213 | } | ||
214 | if (bh) { | 213 | if (bh) { |
215 | u32 ino = bh->b_blocknr; | 214 | u32 ino = bh->b_blocknr; |
216 | 215 | ||
@@ -223,10 +222,9 @@ affs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | |||
223 | ino = be32_to_cpu(AFFS_TAIL(sb, bh)->original); | 222 | ino = be32_to_cpu(AFFS_TAIL(sb, bh)->original); |
224 | } | 223 | } |
225 | affs_brelse(bh); | 224 | affs_brelse(bh); |
226 | inode = iget(sb, ino); | 225 | inode = affs_iget(sb, ino); |
227 | if (!inode) { | 226 | if (IS_ERR(inode)) |
228 | return ERR_PTR(-EACCES); | 227 | return ERR_PTR(PTR_ERR(inode)); |
229 | } | ||
230 | } | 228 | } |
231 | dentry->d_op = AFFS_SB(sb)->s_flags & SF_INTL ? &affs_intl_dentry_operations : &affs_dentry_operations; | 229 | dentry->d_op = AFFS_SB(sb)->s_flags & SF_INTL ? &affs_intl_dentry_operations : &affs_dentry_operations; |
232 | d_add(dentry, inode); | 230 | d_add(dentry, inode); |
diff --git a/fs/affs/super.c b/fs/affs/super.c index b53e5d0ec65c..3c45d49c0d26 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c | |||
@@ -113,7 +113,6 @@ static void destroy_inodecache(void) | |||
113 | static const struct super_operations affs_sops = { | 113 | static const struct super_operations affs_sops = { |
114 | .alloc_inode = affs_alloc_inode, | 114 | .alloc_inode = affs_alloc_inode, |
115 | .destroy_inode = affs_destroy_inode, | 115 | .destroy_inode = affs_destroy_inode, |
116 | .read_inode = affs_read_inode, | ||
117 | .write_inode = affs_write_inode, | 116 | .write_inode = affs_write_inode, |
118 | .put_inode = affs_put_inode, | 117 | .put_inode = affs_put_inode, |
119 | .drop_inode = affs_drop_inode, | 118 | .drop_inode = affs_drop_inode, |
@@ -271,6 +270,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) | |||
271 | unsigned long mount_flags; | 270 | unsigned long mount_flags; |
272 | int tmp_flags; /* fix remount prototype... */ | 271 | int tmp_flags; /* fix remount prototype... */ |
273 | u8 sig[4]; | 272 | u8 sig[4]; |
273 | int ret = -EINVAL; | ||
274 | 274 | ||
275 | pr_debug("AFFS: read_super(%s)\n",data ? (const char *)data : "no options"); | 275 | pr_debug("AFFS: read_super(%s)\n",data ? (const char *)data : "no options"); |
276 | 276 | ||
@@ -444,7 +444,12 @@ got_root: | |||
444 | 444 | ||
445 | /* set up enough so that it can read an inode */ | 445 | /* set up enough so that it can read an inode */ |
446 | 446 | ||
447 | root_inode = iget(sb, root_block); | 447 | root_inode = affs_iget(sb, root_block); |
448 | if (IS_ERR(root_inode)) { | ||
449 | ret = PTR_ERR(root_inode); | ||
450 | goto out_error_noinode; | ||
451 | } | ||
452 | |||
448 | sb->s_root = d_alloc_root(root_inode); | 453 | sb->s_root = d_alloc_root(root_inode); |
449 | if (!sb->s_root) { | 454 | if (!sb->s_root) { |
450 | printk(KERN_ERR "AFFS: Get root inode failed\n"); | 455 | printk(KERN_ERR "AFFS: Get root inode failed\n"); |
@@ -461,12 +466,13 @@ got_root: | |||
461 | out_error: | 466 | out_error: |
462 | if (root_inode) | 467 | if (root_inode) |
463 | iput(root_inode); | 468 | iput(root_inode); |
469 | out_error_noinode: | ||
464 | kfree(sbi->s_bitmap); | 470 | kfree(sbi->s_bitmap); |
465 | affs_brelse(root_bh); | 471 | affs_brelse(root_bh); |
466 | kfree(sbi->s_prefix); | 472 | kfree(sbi->s_prefix); |
467 | kfree(sbi); | 473 | kfree(sbi); |
468 | sb->s_fs_info = NULL; | 474 | sb->s_fs_info = NULL; |
469 | return -EINVAL; | 475 | return ret; |
470 | } | 476 | } |
471 | 477 | ||
472 | static int | 478 | static int |
diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 0cc3597c1197..b58af8f18bc4 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c | |||
@@ -512,7 +512,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, | |||
512 | key = afs_request_key(vnode->volume->cell); | 512 | key = afs_request_key(vnode->volume->cell); |
513 | if (IS_ERR(key)) { | 513 | if (IS_ERR(key)) { |
514 | _leave(" = %ld [key]", PTR_ERR(key)); | 514 | _leave(" = %ld [key]", PTR_ERR(key)); |
515 | return ERR_PTR(PTR_ERR(key)); | 515 | return ERR_CAST(key); |
516 | } | 516 | } |
517 | 517 | ||
518 | ret = afs_validate(vnode, key); | 518 | ret = afs_validate(vnode, key); |
@@ -540,7 +540,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, | |||
540 | key_put(key); | 540 | key_put(key); |
541 | if (IS_ERR(inode)) { | 541 | if (IS_ERR(inode)) { |
542 | _leave(" = %ld", PTR_ERR(inode)); | 542 | _leave(" = %ld", PTR_ERR(inode)); |
543 | return ERR_PTR(PTR_ERR(inode)); | 543 | return ERR_CAST(inode); |
544 | } | 544 | } |
545 | 545 | ||
546 | dentry->d_op = &afs_fs_dentry_operations; | 546 | dentry->d_op = &afs_fs_dentry_operations; |
diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 84750c8e9f95..08db82e1343a 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c | |||
@@ -196,10 +196,7 @@ struct inode *afs_iget(struct super_block *sb, struct key *key, | |||
196 | 196 | ||
197 | /* failure */ | 197 | /* failure */ |
198 | bad_inode: | 198 | bad_inode: |
199 | make_bad_inode(inode); | 199 | iget_failed(inode); |
200 | unlock_new_inode(inode); | ||
201 | iput(inode); | ||
202 | |||
203 | _leave(" = %d [bad]", ret); | 200 | _leave(" = %d [bad]", ret); |
204 | return ERR_PTR(ret); | 201 | return ERR_PTR(ret); |
205 | } | 202 | } |
diff --git a/fs/afs/security.c b/fs/afs/security.c index 566fe712c682..9446a1fd108a 100644 --- a/fs/afs/security.c +++ b/fs/afs/security.c | |||
@@ -95,7 +95,7 @@ static struct afs_vnode *afs_get_auth_inode(struct afs_vnode *vnode, | |||
95 | auth_inode = afs_iget(vnode->vfs_inode.i_sb, key, | 95 | auth_inode = afs_iget(vnode->vfs_inode.i_sb, key, |
96 | &vnode->status.parent, NULL, NULL); | 96 | &vnode->status.parent, NULL, NULL); |
97 | if (IS_ERR(auth_inode)) | 97 | if (IS_ERR(auth_inode)) |
98 | return ERR_PTR(PTR_ERR(auth_inode)); | 98 | return ERR_CAST(auth_inode); |
99 | } | 99 | } |
100 | 100 | ||
101 | auth_vnode = AFS_FS_I(auth_inode); | 101 | auth_vnode = AFS_FS_I(auth_inode); |
diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h index 8b4cca3c4705..901a3e67ec45 100644 --- a/fs/autofs/autofs_i.h +++ b/fs/autofs/autofs_i.h | |||
@@ -150,6 +150,7 @@ extern const struct file_operations autofs_root_operations; | |||
150 | 150 | ||
151 | int autofs_fill_super(struct super_block *, void *, int); | 151 | int autofs_fill_super(struct super_block *, void *, int); |
152 | void autofs_kill_sb(struct super_block *sb); | 152 | void autofs_kill_sb(struct super_block *sb); |
153 | struct inode *autofs_iget(struct super_block *, unsigned long); | ||
153 | 154 | ||
154 | /* Queue management functions */ | 155 | /* Queue management functions */ |
155 | 156 | ||
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 45f5992a0957..708bdb89fea1 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c | |||
@@ -52,10 +52,7 @@ out_kill_sb: | |||
52 | kill_anon_super(sb); | 52 | kill_anon_super(sb); |
53 | } | 53 | } |
54 | 54 | ||
55 | static void autofs_read_inode(struct inode *inode); | ||
56 | |||
57 | static const struct super_operations autofs_sops = { | 55 | static const struct super_operations autofs_sops = { |
58 | .read_inode = autofs_read_inode, | ||
59 | .statfs = simple_statfs, | 56 | .statfs = simple_statfs, |
60 | }; | 57 | }; |
61 | 58 | ||
@@ -164,7 +161,9 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) | |||
164 | s->s_time_gran = 1; | 161 | s->s_time_gran = 1; |
165 | sbi->sb = s; | 162 | sbi->sb = s; |
166 | 163 | ||
167 | root_inode = iget(s, AUTOFS_ROOT_INO); | 164 | root_inode = autofs_iget(s, AUTOFS_ROOT_INO); |
165 | if (IS_ERR(root_inode)) | ||
166 | goto fail_free; | ||
168 | root = d_alloc_root(root_inode); | 167 | root = d_alloc_root(root_inode); |
169 | pipe = NULL; | 168 | pipe = NULL; |
170 | 169 | ||
@@ -230,11 +229,17 @@ fail_unlock: | |||
230 | return -EINVAL; | 229 | return -EINVAL; |
231 | } | 230 | } |
232 | 231 | ||
233 | static void autofs_read_inode(struct inode *inode) | 232 | struct inode *autofs_iget(struct super_block *sb, unsigned long ino) |
234 | { | 233 | { |
235 | ino_t ino = inode->i_ino; | ||
236 | unsigned int n; | 234 | unsigned int n; |
237 | struct autofs_sb_info *sbi = autofs_sbi(inode->i_sb); | 235 | struct autofs_sb_info *sbi = autofs_sbi(sb); |
236 | struct inode *inode; | ||
237 | |||
238 | inode = iget_locked(sb, ino); | ||
239 | if (!inode) | ||
240 | return ERR_PTR(-ENOMEM); | ||
241 | if (!(inode->i_state & I_NEW)) | ||
242 | return inode; | ||
238 | 243 | ||
239 | /* Initialize to the default case (stub directory) */ | 244 | /* Initialize to the default case (stub directory) */ |
240 | 245 | ||
@@ -250,7 +255,7 @@ static void autofs_read_inode(struct inode *inode) | |||
250 | inode->i_op = &autofs_root_inode_operations; | 255 | inode->i_op = &autofs_root_inode_operations; |
251 | inode->i_fop = &autofs_root_operations; | 256 | inode->i_fop = &autofs_root_operations; |
252 | inode->i_uid = inode->i_gid = 0; /* Changed in read_super */ | 257 | inode->i_uid = inode->i_gid = 0; /* Changed in read_super */ |
253 | return; | 258 | goto done; |
254 | } | 259 | } |
255 | 260 | ||
256 | inode->i_uid = inode->i_sb->s_root->d_inode->i_uid; | 261 | inode->i_uid = inode->i_sb->s_root->d_inode->i_uid; |
@@ -263,7 +268,7 @@ static void autofs_read_inode(struct inode *inode) | |||
263 | n = ino - AUTOFS_FIRST_SYMLINK; | 268 | n = ino - AUTOFS_FIRST_SYMLINK; |
264 | if (n >= AUTOFS_MAX_SYMLINKS || !test_bit(n,sbi->symlink_bitmap)) { | 269 | if (n >= AUTOFS_MAX_SYMLINKS || !test_bit(n,sbi->symlink_bitmap)) { |
265 | printk("autofs: Looking for bad symlink inode %u\n", (unsigned int) ino); | 270 | printk("autofs: Looking for bad symlink inode %u\n", (unsigned int) ino); |
266 | return; | 271 | goto done; |
267 | } | 272 | } |
268 | 273 | ||
269 | inode->i_op = &autofs_symlink_inode_operations; | 274 | inode->i_op = &autofs_symlink_inode_operations; |
@@ -275,4 +280,8 @@ static void autofs_read_inode(struct inode *inode) | |||
275 | inode->i_size = sl->len; | 280 | inode->i_size = sl->len; |
276 | inode->i_nlink = 1; | 281 | inode->i_nlink = 1; |
277 | } | 282 | } |
283 | |||
284 | done: | ||
285 | unlock_new_inode(inode); | ||
286 | return inode; | ||
278 | } | 287 | } |
diff --git a/fs/autofs/root.c b/fs/autofs/root.c index 5efff3c0d886..8aacade56956 100644 --- a/fs/autofs/root.c +++ b/fs/autofs/root.c | |||
@@ -114,8 +114,8 @@ static int try_to_fill_dentry(struct dentry *dentry, struct super_block *sb, str | |||
114 | dentry->d_time = (unsigned long) ent; | 114 | dentry->d_time = (unsigned long) ent; |
115 | 115 | ||
116 | if (!dentry->d_inode) { | 116 | if (!dentry->d_inode) { |
117 | inode = iget(sb, ent->ino); | 117 | inode = autofs_iget(sb, ent->ino); |
118 | if (!inode) { | 118 | if (IS_ERR(inode)) { |
119 | /* Failed, but leave pending for next time */ | 119 | /* Failed, but leave pending for next time */ |
120 | return 1; | 120 | return 1; |
121 | } | 121 | } |
@@ -274,6 +274,7 @@ static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const c | |||
274 | unsigned int n; | 274 | unsigned int n; |
275 | int slsize; | 275 | int slsize; |
276 | struct autofs_symlink *sl; | 276 | struct autofs_symlink *sl; |
277 | struct inode *inode; | ||
277 | 278 | ||
278 | DPRINTK(("autofs_root_symlink: %s <- ", symname)); | 279 | DPRINTK(("autofs_root_symlink: %s <- ", symname)); |
279 | autofs_say(dentry->d_name.name,dentry->d_name.len); | 280 | autofs_say(dentry->d_name.name,dentry->d_name.len); |
@@ -331,7 +332,12 @@ static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const c | |||
331 | ent->dentry = NULL; /* We don't keep the dentry for symlinks */ | 332 | ent->dentry = NULL; /* We don't keep the dentry for symlinks */ |
332 | 333 | ||
333 | autofs_hash_insert(dh,ent); | 334 | autofs_hash_insert(dh,ent); |
334 | d_instantiate(dentry, iget(dir->i_sb,ent->ino)); | 335 | |
336 | inode = autofs_iget(dir->i_sb, ent->ino); | ||
337 | if (IS_ERR(inode)) | ||
338 | return PTR_ERR(inode); | ||
339 | |||
340 | d_instantiate(dentry, inode); | ||
335 | unlock_kernel(); | 341 | unlock_kernel(); |
336 | return 0; | 342 | return 0; |
337 | } | 343 | } |
@@ -428,6 +434,7 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
428 | struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb); | 434 | struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb); |
429 | struct autofs_dirhash *dh = &sbi->dirhash; | 435 | struct autofs_dirhash *dh = &sbi->dirhash; |
430 | struct autofs_dir_ent *ent; | 436 | struct autofs_dir_ent *ent; |
437 | struct inode *inode; | ||
431 | ino_t ino; | 438 | ino_t ino; |
432 | 439 | ||
433 | lock_kernel(); | 440 | lock_kernel(); |
@@ -469,7 +476,14 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
469 | autofs_hash_insert(dh,ent); | 476 | autofs_hash_insert(dh,ent); |
470 | 477 | ||
471 | inc_nlink(dir); | 478 | inc_nlink(dir); |
472 | d_instantiate(dentry, iget(dir->i_sb,ino)); | 479 | |
480 | inode = autofs_iget(dir->i_sb, ino); | ||
481 | if (IS_ERR(inode)) { | ||
482 | drop_nlink(dir); | ||
483 | return PTR_ERR(inode); | ||
484 | } | ||
485 | |||
486 | d_instantiate(dentry, inode); | ||
473 | unlock_kernel(); | 487 | unlock_kernel(); |
474 | 488 | ||
475 | return 0; | 489 | return 0; |
diff --git a/fs/bad_inode.c b/fs/bad_inode.c index 521ff7caadbd..f1c2ea8342f5 100644 --- a/fs/bad_inode.c +++ b/fs/bad_inode.c | |||
@@ -359,3 +359,17 @@ int is_bad_inode(struct inode *inode) | |||
359 | } | 359 | } |
360 | 360 | ||
361 | EXPORT_SYMBOL(is_bad_inode); | 361 | EXPORT_SYMBOL(is_bad_inode); |
362 | |||
363 | /** | ||
364 | * iget_failed - Mark an under-construction inode as dead and release it | ||
365 | * @inode: The inode to discard | ||
366 | * | ||
367 | * Mark an under-construction inode as dead and release it. | ||
368 | */ | ||
369 | void iget_failed(struct inode *inode) | ||
370 | { | ||
371 | make_bad_inode(inode); | ||
372 | unlock_new_inode(inode); | ||
373 | iput(inode); | ||
374 | } | ||
375 | EXPORT_SYMBOL(iget_failed); | ||
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index b28a20e61b80..403fe661c144 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c | |||
@@ -35,7 +35,7 @@ static int befs_get_block(struct inode *, sector_t, struct buffer_head *, int); | |||
35 | static int befs_readpage(struct file *file, struct page *page); | 35 | static int befs_readpage(struct file *file, struct page *page); |
36 | static sector_t befs_bmap(struct address_space *mapping, sector_t block); | 36 | static sector_t befs_bmap(struct address_space *mapping, sector_t block); |
37 | static struct dentry *befs_lookup(struct inode *, struct dentry *, struct nameidata *); | 37 | static struct dentry *befs_lookup(struct inode *, struct dentry *, struct nameidata *); |
38 | static void befs_read_inode(struct inode *ino); | 38 | static struct inode *befs_iget(struct super_block *, unsigned long); |
39 | static struct inode *befs_alloc_inode(struct super_block *sb); | 39 | static struct inode *befs_alloc_inode(struct super_block *sb); |
40 | static void befs_destroy_inode(struct inode *inode); | 40 | static void befs_destroy_inode(struct inode *inode); |
41 | static int befs_init_inodecache(void); | 41 | static int befs_init_inodecache(void); |
@@ -52,7 +52,6 @@ static int befs_statfs(struct dentry *, struct kstatfs *); | |||
52 | static int parse_options(char *, befs_mount_options *); | 52 | static int parse_options(char *, befs_mount_options *); |
53 | 53 | ||
54 | static const struct super_operations befs_sops = { | 54 | static const struct super_operations befs_sops = { |
55 | .read_inode = befs_read_inode, /* initialize & read inode */ | ||
56 | .alloc_inode = befs_alloc_inode, /* allocate a new inode */ | 55 | .alloc_inode = befs_alloc_inode, /* allocate a new inode */ |
57 | .destroy_inode = befs_destroy_inode, /* deallocate an inode */ | 56 | .destroy_inode = befs_destroy_inode, /* deallocate an inode */ |
58 | .put_super = befs_put_super, /* uninit super */ | 57 | .put_super = befs_put_super, /* uninit super */ |
@@ -198,9 +197,9 @@ befs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | |||
198 | return ERR_PTR(-ENODATA); | 197 | return ERR_PTR(-ENODATA); |
199 | } | 198 | } |
200 | 199 | ||
201 | inode = iget(dir->i_sb, (ino_t) offset); | 200 | inode = befs_iget(dir->i_sb, (ino_t) offset); |
202 | if (!inode) | 201 | if (IS_ERR(inode)) |
203 | return ERR_PTR(-EACCES); | 202 | return ERR_CAST(inode); |
204 | 203 | ||
205 | d_add(dentry, inode); | 204 | d_add(dentry, inode); |
206 | 205 | ||
@@ -296,17 +295,23 @@ static void init_once(struct kmem_cache *cachep, void *foo) | |||
296 | inode_init_once(&bi->vfs_inode); | 295 | inode_init_once(&bi->vfs_inode); |
297 | } | 296 | } |
298 | 297 | ||
299 | static void | 298 | static struct inode *befs_iget(struct super_block *sb, unsigned long ino) |
300 | befs_read_inode(struct inode *inode) | ||
301 | { | 299 | { |
302 | struct buffer_head *bh = NULL; | 300 | struct buffer_head *bh = NULL; |
303 | befs_inode *raw_inode = NULL; | 301 | befs_inode *raw_inode = NULL; |
304 | 302 | ||
305 | struct super_block *sb = inode->i_sb; | ||
306 | befs_sb_info *befs_sb = BEFS_SB(sb); | 303 | befs_sb_info *befs_sb = BEFS_SB(sb); |
307 | befs_inode_info *befs_ino = NULL; | 304 | befs_inode_info *befs_ino = NULL; |
305 | struct inode *inode; | ||
306 | long ret = -EIO; | ||
308 | 307 | ||
309 | befs_debug(sb, "---> befs_read_inode() " "inode = %lu", inode->i_ino); | 308 | befs_debug(sb, "---> befs_read_inode() " "inode = %lu", ino); |
309 | |||
310 | inode = iget_locked(sb, ino); | ||
311 | if (IS_ERR(inode)) | ||
312 | return inode; | ||
313 | if (!(inode->i_state & I_NEW)) | ||
314 | return inode; | ||
310 | 315 | ||
311 | befs_ino = BEFS_I(inode); | 316 | befs_ino = BEFS_I(inode); |
312 | 317 | ||
@@ -402,15 +407,16 @@ befs_read_inode(struct inode *inode) | |||
402 | 407 | ||
403 | brelse(bh); | 408 | brelse(bh); |
404 | befs_debug(sb, "<--- befs_read_inode()"); | 409 | befs_debug(sb, "<--- befs_read_inode()"); |
405 | return; | 410 | unlock_new_inode(inode); |
411 | return inode; | ||
406 | 412 | ||
407 | unacquire_bh: | 413 | unacquire_bh: |
408 | brelse(bh); | 414 | brelse(bh); |
409 | 415 | ||
410 | unacquire_none: | 416 | unacquire_none: |
411 | make_bad_inode(inode); | 417 | iget_failed(inode); |
412 | befs_debug(sb, "<--- befs_read_inode() - Bad inode"); | 418 | befs_debug(sb, "<--- befs_read_inode() - Bad inode"); |
413 | return; | 419 | return ERR_PTR(ret); |
414 | } | 420 | } |
415 | 421 | ||
416 | /* Initialize the inode cache. Called at fs setup. | 422 | /* Initialize the inode cache. Called at fs setup. |
@@ -752,6 +758,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent) | |||
752 | befs_sb_info *befs_sb; | 758 | befs_sb_info *befs_sb; |
753 | befs_super_block *disk_sb; | 759 | befs_super_block *disk_sb; |
754 | struct inode *root; | 760 | struct inode *root; |
761 | long ret = -EINVAL; | ||
755 | 762 | ||
756 | const unsigned long sb_block = 0; | 763 | const unsigned long sb_block = 0; |
757 | const off_t x86_sb_off = 512; | 764 | const off_t x86_sb_off = 512; |
@@ -833,7 +840,11 @@ befs_fill_super(struct super_block *sb, void *data, int silent) | |||
833 | /* Set real blocksize of fs */ | 840 | /* Set real blocksize of fs */ |
834 | sb_set_blocksize(sb, (ulong) befs_sb->block_size); | 841 | sb_set_blocksize(sb, (ulong) befs_sb->block_size); |
835 | sb->s_op = (struct super_operations *) &befs_sops; | 842 | sb->s_op = (struct super_operations *) &befs_sops; |
836 | root = iget(sb, iaddr2blockno(sb, &(befs_sb->root_dir))); | 843 | root = befs_iget(sb, iaddr2blockno(sb, &(befs_sb->root_dir))); |
844 | if (IS_ERR(root)) { | ||
845 | ret = PTR_ERR(root); | ||
846 | goto unacquire_priv_sbp; | ||
847 | } | ||
837 | sb->s_root = d_alloc_root(root); | 848 | sb->s_root = d_alloc_root(root); |
838 | if (!sb->s_root) { | 849 | if (!sb->s_root) { |
839 | iput(root); | 850 | iput(root); |
@@ -868,7 +879,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent) | |||
868 | 879 | ||
869 | unacquire_none: | 880 | unacquire_none: |
870 | sb->s_fs_info = NULL; | 881 | sb->s_fs_info = NULL; |
871 | return -EINVAL; | 882 | return ret; |
872 | } | 883 | } |
873 | 884 | ||
874 | static int | 885 | static int |
diff --git a/fs/bfs/bfs.h b/fs/bfs/bfs.h index ac7a8b1d6c3a..71faf4d23908 100644 --- a/fs/bfs/bfs.h +++ b/fs/bfs/bfs.h | |||
@@ -44,6 +44,8 @@ static inline struct bfs_inode_info *BFS_I(struct inode *inode) | |||
44 | #define printf(format, args...) \ | 44 | #define printf(format, args...) \ |
45 | printk(KERN_ERR "BFS-fs: %s(): " format, __FUNCTION__, ## args) | 45 | printk(KERN_ERR "BFS-fs: %s(): " format, __FUNCTION__, ## args) |
46 | 46 | ||
47 | /* inode.c */ | ||
48 | extern struct inode *bfs_iget(struct super_block *sb, unsigned long ino); | ||
47 | 49 | ||
48 | /* file.c */ | 50 | /* file.c */ |
49 | extern const struct inode_operations bfs_file_inops; | 51 | extern const struct inode_operations bfs_file_inops; |
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c index 1fd056d0fc3d..034950cb3cbe 100644 --- a/fs/bfs/dir.c +++ b/fs/bfs/dir.c | |||
@@ -148,10 +148,10 @@ static struct dentry *bfs_lookup(struct inode *dir, struct dentry *dentry, | |||
148 | if (bh) { | 148 | if (bh) { |
149 | unsigned long ino = (unsigned long)le16_to_cpu(de->ino); | 149 | unsigned long ino = (unsigned long)le16_to_cpu(de->ino); |
150 | brelse(bh); | 150 | brelse(bh); |
151 | inode = iget(dir->i_sb, ino); | 151 | inode = bfs_iget(dir->i_sb, ino); |
152 | if (!inode) { | 152 | if (IS_ERR(inode)) { |
153 | unlock_kernel(); | 153 | unlock_kernel(); |
154 | return ERR_PTR(-EACCES); | 154 | return ERR_CAST(inode); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | unlock_kernel(); | 157 | unlock_kernel(); |
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index a64a71d444f5..8db623838b50 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c | |||
@@ -32,17 +32,22 @@ MODULE_LICENSE("GPL"); | |||
32 | 32 | ||
33 | void dump_imap(const char *prefix, struct super_block *s); | 33 | void dump_imap(const char *prefix, struct super_block *s); |
34 | 34 | ||
35 | static void bfs_read_inode(struct inode *inode) | 35 | struct inode *bfs_iget(struct super_block *sb, unsigned long ino) |
36 | { | 36 | { |
37 | unsigned long ino = inode->i_ino; | ||
38 | struct bfs_inode *di; | 37 | struct bfs_inode *di; |
38 | struct inode *inode; | ||
39 | struct buffer_head *bh; | 39 | struct buffer_head *bh; |
40 | int block, off; | 40 | int block, off; |
41 | 41 | ||
42 | inode = iget_locked(sb, ino); | ||
43 | if (IS_ERR(inode)) | ||
44 | return ERR_PTR(-ENOMEM); | ||
45 | if (!(inode->i_state & I_NEW)) | ||
46 | return inode; | ||
47 | |||
42 | if ((ino < BFS_ROOT_INO) || (ino > BFS_SB(inode->i_sb)->si_lasti)) { | 48 | if ((ino < BFS_ROOT_INO) || (ino > BFS_SB(inode->i_sb)->si_lasti)) { |
43 | printf("Bad inode number %s:%08lx\n", inode->i_sb->s_id, ino); | 49 | printf("Bad inode number %s:%08lx\n", inode->i_sb->s_id, ino); |
44 | make_bad_inode(inode); | 50 | goto error; |
45 | return; | ||
46 | } | 51 | } |
47 | 52 | ||
48 | block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; | 53 | block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; |
@@ -50,8 +55,7 @@ static void bfs_read_inode(struct inode *inode) | |||
50 | if (!bh) { | 55 | if (!bh) { |
51 | printf("Unable to read inode %s:%08lx\n", inode->i_sb->s_id, | 56 | printf("Unable to read inode %s:%08lx\n", inode->i_sb->s_id, |
52 | ino); | 57 | ino); |
53 | make_bad_inode(inode); | 58 | goto error; |
54 | return; | ||
55 | } | 59 | } |
56 | 60 | ||
57 | off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; | 61 | off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; |
@@ -85,6 +89,12 @@ static void bfs_read_inode(struct inode *inode) | |||
85 | inode->i_ctime.tv_nsec = 0; | 89 | inode->i_ctime.tv_nsec = 0; |
86 | 90 | ||
87 | brelse(bh); | 91 | brelse(bh); |
92 | unlock_new_inode(inode); | ||
93 | return inode; | ||
94 | |||
95 | error: | ||
96 | iget_failed(inode); | ||
97 | return ERR_PTR(-EIO); | ||
88 | } | 98 | } |
89 | 99 | ||
90 | static int bfs_write_inode(struct inode *inode, int unused) | 100 | static int bfs_write_inode(struct inode *inode, int unused) |
@@ -276,7 +286,6 @@ static void destroy_inodecache(void) | |||
276 | static const struct super_operations bfs_sops = { | 286 | static const struct super_operations bfs_sops = { |
277 | .alloc_inode = bfs_alloc_inode, | 287 | .alloc_inode = bfs_alloc_inode, |
278 | .destroy_inode = bfs_destroy_inode, | 288 | .destroy_inode = bfs_destroy_inode, |
279 | .read_inode = bfs_read_inode, | ||
280 | .write_inode = bfs_write_inode, | 289 | .write_inode = bfs_write_inode, |
281 | .delete_inode = bfs_delete_inode, | 290 | .delete_inode = bfs_delete_inode, |
282 | .put_super = bfs_put_super, | 291 | .put_super = bfs_put_super, |
@@ -312,6 +321,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
312 | struct inode *inode; | 321 | struct inode *inode; |
313 | unsigned i, imap_len; | 322 | unsigned i, imap_len; |
314 | struct bfs_sb_info *info; | 323 | struct bfs_sb_info *info; |
324 | long ret = -EINVAL; | ||
315 | 325 | ||
316 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 326 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
317 | if (!info) | 327 | if (!info) |
@@ -346,14 +356,16 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
346 | set_bit(i, info->si_imap); | 356 | set_bit(i, info->si_imap); |
347 | 357 | ||
348 | s->s_op = &bfs_sops; | 358 | s->s_op = &bfs_sops; |
349 | inode = iget(s, BFS_ROOT_INO); | 359 | inode = bfs_iget(s, BFS_ROOT_INO); |
350 | if (!inode) { | 360 | if (IS_ERR(inode)) { |
361 | ret = PTR_ERR(inode); | ||
351 | kfree(info->si_imap); | 362 | kfree(info->si_imap); |
352 | goto out; | 363 | goto out; |
353 | } | 364 | } |
354 | s->s_root = d_alloc_root(inode); | 365 | s->s_root = d_alloc_root(inode); |
355 | if (!s->s_root) { | 366 | if (!s->s_root) { |
356 | iput(inode); | 367 | iput(inode); |
368 | ret = -ENOMEM; | ||
357 | kfree(info->si_imap); | 369 | kfree(info->si_imap); |
358 | goto out; | 370 | goto out; |
359 | } | 371 | } |
@@ -404,7 +416,7 @@ out: | |||
404 | brelse(bh); | 416 | brelse(bh); |
405 | kfree(info); | 417 | kfree(info); |
406 | s->s_fs_info = NULL; | 418 | s->s_fs_info = NULL; |
407 | return -EINVAL; | 419 | return ret; |
408 | } | 420 | } |
409 | 421 | ||
410 | static int bfs_get_sb(struct file_system_type *fs_type, | 422 | static int bfs_get_sb(struct file_system_type *fs_type, |
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index 7596e1e94cde..7f65e71bf859 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c | |||
@@ -115,7 +115,7 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, u | |||
115 | current->flags |= PF_DUMPCORE; | 115 | current->flags |= PF_DUMPCORE; |
116 | strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm)); | 116 | strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm)); |
117 | #ifndef __sparc__ | 117 | #ifndef __sparc__ |
118 | dump.u_ar0 = (void *)(((unsigned long)(&dump.regs)) - ((unsigned long)(&dump))); | 118 | dump.u_ar0 = offsetof(struct user, regs); |
119 | #endif | 119 | #endif |
120 | dump.signal = signr; | 120 | dump.signal = signr; |
121 | dump_thread(regs, &dump); | 121 | dump_thread(regs, &dump); |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index e9f4ec701092..fcc434227691 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -147,10 +147,11 @@ cifs_read_super(struct super_block *sb, void *data, | |||
147 | #endif | 147 | #endif |
148 | sb->s_blocksize = CIFS_MAX_MSGSIZE; | 148 | sb->s_blocksize = CIFS_MAX_MSGSIZE; |
149 | sb->s_blocksize_bits = 14; /* default 2**14 = CIFS_MAX_MSGSIZE */ | 149 | sb->s_blocksize_bits = 14; /* default 2**14 = CIFS_MAX_MSGSIZE */ |
150 | inode = iget(sb, ROOT_I); | 150 | inode = cifs_iget(sb, ROOT_I); |
151 | 151 | ||
152 | if (!inode) { | 152 | if (IS_ERR(inode)) { |
153 | rc = -ENOMEM; | 153 | rc = PTR_ERR(inode); |
154 | inode = NULL; | ||
154 | goto out_no_root; | 155 | goto out_no_root; |
155 | } | 156 | } |
156 | 157 | ||
@@ -520,7 +521,6 @@ static int cifs_remount(struct super_block *sb, int *flags, char *data) | |||
520 | } | 521 | } |
521 | 522 | ||
522 | static const struct super_operations cifs_super_ops = { | 523 | static const struct super_operations cifs_super_ops = { |
523 | .read_inode = cifs_read_inode, | ||
524 | .put_super = cifs_put_super, | 524 | .put_super = cifs_put_super, |
525 | .statfs = cifs_statfs, | 525 | .statfs = cifs_statfs, |
526 | .alloc_inode = cifs_alloc_inode, | 526 | .alloc_inode = cifs_alloc_inode, |
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index 195b14de5567..68978306c3ca 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h | |||
@@ -44,6 +44,7 @@ extern void cifs_read_inode(struct inode *); | |||
44 | 44 | ||
45 | /* Functions related to inodes */ | 45 | /* Functions related to inodes */ |
46 | extern const struct inode_operations cifs_dir_inode_ops; | 46 | extern const struct inode_operations cifs_dir_inode_ops; |
47 | extern struct inode *cifs_iget(struct super_block *, unsigned long); | ||
47 | extern int cifs_create(struct inode *, struct dentry *, int, | 48 | extern int cifs_create(struct inode *, struct dentry *, int, |
48 | struct nameidata *); | 49 | struct nameidata *); |
49 | extern struct dentry *cifs_lookup(struct inode *, struct dentry *, | 50 | extern struct dentry *cifs_lookup(struct inode *, struct dentry *, |
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 47f2621001e4..b1a4a65eaa08 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -586,10 +586,18 @@ static const struct inode_operations cifs_ipc_inode_ops = { | |||
586 | }; | 586 | }; |
587 | 587 | ||
588 | /* gets root inode */ | 588 | /* gets root inode */ |
589 | void cifs_read_inode(struct inode *inode) | 589 | struct inode *cifs_iget(struct super_block *sb, unsigned long ino) |
590 | { | 590 | { |
591 | int xid, rc; | 591 | int xid; |
592 | struct cifs_sb_info *cifs_sb; | 592 | struct cifs_sb_info *cifs_sb; |
593 | struct inode *inode; | ||
594 | long rc; | ||
595 | |||
596 | inode = iget_locked(sb, ino); | ||
597 | if (!inode) | ||
598 | return ERR_PTR(-ENOMEM); | ||
599 | if (!(inode->i_state & I_NEW)) | ||
600 | return inode; | ||
593 | 601 | ||
594 | cifs_sb = CIFS_SB(inode->i_sb); | 602 | cifs_sb = CIFS_SB(inode->i_sb); |
595 | xid = GetXid(); | 603 | xid = GetXid(); |
@@ -606,10 +614,18 @@ void cifs_read_inode(struct inode *inode) | |||
606 | inode->i_fop = &simple_dir_operations; | 614 | inode->i_fop = &simple_dir_operations; |
607 | inode->i_uid = cifs_sb->mnt_uid; | 615 | inode->i_uid = cifs_sb->mnt_uid; |
608 | inode->i_gid = cifs_sb->mnt_gid; | 616 | inode->i_gid = cifs_sb->mnt_gid; |
617 | _FreeXid(xid); | ||
618 | iget_failed(inode); | ||
619 | return ERR_PTR(rc); | ||
609 | } | 620 | } |
610 | 621 | ||
611 | /* can not call macro FreeXid here since in a void func */ | 622 | unlock_new_inode(inode); |
623 | |||
624 | /* can not call macro FreeXid here since in a void func | ||
625 | * TODO: This is no longer true | ||
626 | */ | ||
612 | _FreeXid(xid); | 627 | _FreeXid(xid); |
628 | return inode; | ||
613 | } | 629 | } |
614 | 630 | ||
615 | int cifs_unlink(struct inode *inode, struct dentry *direntry) | 631 | int cifs_unlink(struct inode *inode, struct dentry *direntry) |
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index ffdc022cae64..614bd75b5a4a 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -2986,7 +2986,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | |||
2986 | } | 2986 | } |
2987 | 2987 | ||
2988 | do_ioctl: | 2988 | do_ioctl: |
2989 | error = vfs_ioctl(filp, fd, cmd, arg); | 2989 | error = do_vfs_ioctl(filp, fd, cmd, arg); |
2990 | out_fput: | 2990 | out_fput: |
2991 | fput_light(filp, fput_needed); | 2991 | fput_light(filp, fput_needed); |
2992 | out: | 2992 | out: |
diff --git a/fs/efs/inode.c b/fs/efs/inode.c index 174696f9bf14..627c3026946d 100644 --- a/fs/efs/inode.c +++ b/fs/efs/inode.c | |||
@@ -45,17 +45,26 @@ static inline void extent_copy(efs_extent *src, efs_extent *dst) { | |||
45 | return; | 45 | return; |
46 | } | 46 | } |
47 | 47 | ||
48 | void efs_read_inode(struct inode *inode) | 48 | struct inode *efs_iget(struct super_block *super, unsigned long ino) |
49 | { | 49 | { |
50 | int i, inode_index; | 50 | int i, inode_index; |
51 | dev_t device; | 51 | dev_t device; |
52 | u32 rdev; | 52 | u32 rdev; |
53 | struct buffer_head *bh; | 53 | struct buffer_head *bh; |
54 | struct efs_sb_info *sb = SUPER_INFO(inode->i_sb); | 54 | struct efs_sb_info *sb = SUPER_INFO(super); |
55 | struct efs_inode_info *in = INODE_INFO(inode); | 55 | struct efs_inode_info *in; |
56 | efs_block_t block, offset; | 56 | efs_block_t block, offset; |
57 | struct efs_dinode *efs_inode; | 57 | struct efs_dinode *efs_inode; |
58 | 58 | struct inode *inode; | |
59 | |||
60 | inode = iget_locked(super, ino); | ||
61 | if (IS_ERR(inode)) | ||
62 | return ERR_PTR(-ENOMEM); | ||
63 | if (!(inode->i_state & I_NEW)) | ||
64 | return inode; | ||
65 | |||
66 | in = INODE_INFO(inode); | ||
67 | |||
59 | /* | 68 | /* |
60 | ** EFS layout: | 69 | ** EFS layout: |
61 | ** | 70 | ** |
@@ -159,13 +168,13 @@ void efs_read_inode(struct inode *inode) | |||
159 | break; | 168 | break; |
160 | } | 169 | } |
161 | 170 | ||
162 | return; | 171 | unlock_new_inode(inode); |
172 | return inode; | ||
163 | 173 | ||
164 | read_inode_error: | 174 | read_inode_error: |
165 | printk(KERN_WARNING "EFS: failed to read inode %lu\n", inode->i_ino); | 175 | printk(KERN_WARNING "EFS: failed to read inode %lu\n", inode->i_ino); |
166 | make_bad_inode(inode); | 176 | iget_failed(inode); |
167 | 177 | return ERR_PTR(-EIO); | |
168 | return; | ||
169 | } | 178 | } |
170 | 179 | ||
171 | static inline efs_block_t | 180 | static inline efs_block_t |
diff --git a/fs/efs/namei.c b/fs/efs/namei.c index f7f407075be1..e26704742d41 100644 --- a/fs/efs/namei.c +++ b/fs/efs/namei.c | |||
@@ -66,9 +66,10 @@ struct dentry *efs_lookup(struct inode *dir, struct dentry *dentry, struct namei | |||
66 | lock_kernel(); | 66 | lock_kernel(); |
67 | inodenum = efs_find_entry(dir, dentry->d_name.name, dentry->d_name.len); | 67 | inodenum = efs_find_entry(dir, dentry->d_name.name, dentry->d_name.len); |
68 | if (inodenum) { | 68 | if (inodenum) { |
69 | if (!(inode = iget(dir->i_sb, inodenum))) { | 69 | inode = efs_iget(dir->i_sb, inodenum); |
70 | if (IS_ERR(inode)) { | ||
70 | unlock_kernel(); | 71 | unlock_kernel(); |
71 | return ERR_PTR(-EACCES); | 72 | return ERR_CAST(inode); |
72 | } | 73 | } |
73 | } | 74 | } |
74 | unlock_kernel(); | 75 | unlock_kernel(); |
@@ -84,12 +85,11 @@ static struct inode *efs_nfs_get_inode(struct super_block *sb, u64 ino, | |||
84 | 85 | ||
85 | if (ino == 0) | 86 | if (ino == 0) |
86 | return ERR_PTR(-ESTALE); | 87 | return ERR_PTR(-ESTALE); |
87 | inode = iget(sb, ino); | 88 | inode = efs_iget(sb, ino); |
88 | if (inode == NULL) | 89 | if (IS_ERR(inode)) |
89 | return ERR_PTR(-ENOMEM); | 90 | return ERR_CAST(inode); |
90 | 91 | ||
91 | if (is_bad_inode(inode) || | 92 | if (generation && inode->i_generation != generation) { |
92 | (generation && inode->i_generation != generation)) { | ||
93 | iput(inode); | 93 | iput(inode); |
94 | return ERR_PTR(-ESTALE); | 94 | return ERR_PTR(-ESTALE); |
95 | } | 95 | } |
@@ -116,7 +116,7 @@ struct dentry *efs_get_parent(struct dentry *child) | |||
116 | struct dentry *parent; | 116 | struct dentry *parent; |
117 | struct inode *inode; | 117 | struct inode *inode; |
118 | efs_ino_t ino; | 118 | efs_ino_t ino; |
119 | int error; | 119 | long error; |
120 | 120 | ||
121 | lock_kernel(); | 121 | lock_kernel(); |
122 | 122 | ||
@@ -125,10 +125,11 @@ struct dentry *efs_get_parent(struct dentry *child) | |||
125 | if (!ino) | 125 | if (!ino) |
126 | goto fail; | 126 | goto fail; |
127 | 127 | ||
128 | error = -EACCES; | 128 | inode = efs_iget(child->d_inode->i_sb, ino); |
129 | inode = iget(child->d_inode->i_sb, ino); | 129 | if (IS_ERR(inode)) { |
130 | if (!inode) | 130 | error = PTR_ERR(inode); |
131 | goto fail; | 131 | goto fail; |
132 | } | ||
132 | 133 | ||
133 | error = -ENOMEM; | 134 | error = -ENOMEM; |
134 | parent = d_alloc_anon(inode); | 135 | parent = d_alloc_anon(inode); |
diff --git a/fs/efs/super.c b/fs/efs/super.c index c79bc627f107..14082405cdd1 100644 --- a/fs/efs/super.c +++ b/fs/efs/super.c | |||
@@ -107,7 +107,6 @@ static int efs_remount(struct super_block *sb, int *flags, char *data) | |||
107 | static const struct super_operations efs_superblock_operations = { | 107 | static const struct super_operations efs_superblock_operations = { |
108 | .alloc_inode = efs_alloc_inode, | 108 | .alloc_inode = efs_alloc_inode, |
109 | .destroy_inode = efs_destroy_inode, | 109 | .destroy_inode = efs_destroy_inode, |
110 | .read_inode = efs_read_inode, | ||
111 | .put_super = efs_put_super, | 110 | .put_super = efs_put_super, |
112 | .statfs = efs_statfs, | 111 | .statfs = efs_statfs, |
113 | .remount_fs = efs_remount, | 112 | .remount_fs = efs_remount, |
@@ -247,6 +246,7 @@ static int efs_fill_super(struct super_block *s, void *d, int silent) | |||
247 | struct efs_sb_info *sb; | 246 | struct efs_sb_info *sb; |
248 | struct buffer_head *bh; | 247 | struct buffer_head *bh; |
249 | struct inode *root; | 248 | struct inode *root; |
249 | int ret = -EINVAL; | ||
250 | 250 | ||
251 | sb = kzalloc(sizeof(struct efs_sb_info), GFP_KERNEL); | 251 | sb = kzalloc(sizeof(struct efs_sb_info), GFP_KERNEL); |
252 | if (!sb) | 252 | if (!sb) |
@@ -303,12 +303,18 @@ static int efs_fill_super(struct super_block *s, void *d, int silent) | |||
303 | } | 303 | } |
304 | s->s_op = &efs_superblock_operations; | 304 | s->s_op = &efs_superblock_operations; |
305 | s->s_export_op = &efs_export_ops; | 305 | s->s_export_op = &efs_export_ops; |
306 | root = iget(s, EFS_ROOTINODE); | 306 | root = efs_iget(s, EFS_ROOTINODE); |
307 | if (IS_ERR(root)) { | ||
308 | printk(KERN_ERR "EFS: get root inode failed\n"); | ||
309 | ret = PTR_ERR(root); | ||
310 | goto out_no_fs; | ||
311 | } | ||
312 | |||
307 | s->s_root = d_alloc_root(root); | 313 | s->s_root = d_alloc_root(root); |
308 | |||
309 | if (!(s->s_root)) { | 314 | if (!(s->s_root)) { |
310 | printk(KERN_ERR "EFS: get root inode failed\n"); | 315 | printk(KERN_ERR "EFS: get root dentry failed\n"); |
311 | iput(root); | 316 | iput(root); |
317 | ret = -ENOMEM; | ||
312 | goto out_no_fs; | 318 | goto out_no_fs; |
313 | } | 319 | } |
314 | 320 | ||
@@ -318,7 +324,7 @@ out_no_fs_ul: | |||
318 | out_no_fs: | 324 | out_no_fs: |
319 | s->s_fs_info = NULL; | 325 | s->s_fs_info = NULL; |
320 | kfree(sb); | 326 | kfree(sb); |
321 | return -EINVAL; | 327 | return ret; |
322 | } | 328 | } |
323 | 329 | ||
324 | static int efs_statfs(struct dentry *dentry, struct kstatfs *buf) { | 330 | static int efs_statfs(struct dentry *dentry, struct kstatfs *buf) { |
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index bb9948cdd50f..f1e5705e75f1 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h | |||
@@ -124,7 +124,7 @@ extern void ext2_check_inodes_bitmap (struct super_block *); | |||
124 | extern unsigned long ext2_count_free (struct buffer_head *, unsigned); | 124 | extern unsigned long ext2_count_free (struct buffer_head *, unsigned); |
125 | 125 | ||
126 | /* inode.c */ | 126 | /* inode.c */ |
127 | extern void ext2_read_inode (struct inode *); | 127 | extern struct inode *ext2_iget (struct super_block *, unsigned long); |
128 | extern int ext2_write_inode (struct inode *, int); | 128 | extern int ext2_write_inode (struct inode *, int); |
129 | extern void ext2_put_inode (struct inode *); | 129 | extern void ext2_put_inode (struct inode *); |
130 | extern void ext2_delete_inode (struct inode *); | 130 | extern void ext2_delete_inode (struct inode *); |
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 03978ec2a91c..c62006805427 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c | |||
@@ -1181,22 +1181,33 @@ void ext2_get_inode_flags(struct ext2_inode_info *ei) | |||
1181 | ei->i_flags |= EXT2_DIRSYNC_FL; | 1181 | ei->i_flags |= EXT2_DIRSYNC_FL; |
1182 | } | 1182 | } |
1183 | 1183 | ||
1184 | void ext2_read_inode (struct inode * inode) | 1184 | struct inode *ext2_iget (struct super_block *sb, unsigned long ino) |
1185 | { | 1185 | { |
1186 | struct ext2_inode_info *ei = EXT2_I(inode); | 1186 | struct ext2_inode_info *ei; |
1187 | ino_t ino = inode->i_ino; | ||
1188 | struct buffer_head * bh; | 1187 | struct buffer_head * bh; |
1189 | struct ext2_inode * raw_inode = ext2_get_inode(inode->i_sb, ino, &bh); | 1188 | struct ext2_inode *raw_inode; |
1189 | struct inode *inode; | ||
1190 | long ret = -EIO; | ||
1190 | int n; | 1191 | int n; |
1191 | 1192 | ||
1193 | inode = iget_locked(sb, ino); | ||
1194 | if (!inode) | ||
1195 | return ERR_PTR(-ENOMEM); | ||
1196 | if (!(inode->i_state & I_NEW)) | ||
1197 | return inode; | ||
1198 | |||
1199 | ei = EXT2_I(inode); | ||
1192 | #ifdef CONFIG_EXT2_FS_POSIX_ACL | 1200 | #ifdef CONFIG_EXT2_FS_POSIX_ACL |
1193 | ei->i_acl = EXT2_ACL_NOT_CACHED; | 1201 | ei->i_acl = EXT2_ACL_NOT_CACHED; |
1194 | ei->i_default_acl = EXT2_ACL_NOT_CACHED; | 1202 | ei->i_default_acl = EXT2_ACL_NOT_CACHED; |
1195 | #endif | 1203 | #endif |
1196 | ei->i_block_alloc_info = NULL; | 1204 | ei->i_block_alloc_info = NULL; |
1197 | 1205 | ||
1198 | if (IS_ERR(raw_inode)) | 1206 | raw_inode = ext2_get_inode(inode->i_sb, ino, &bh); |
1207 | if (IS_ERR(raw_inode)) { | ||
1208 | ret = PTR_ERR(raw_inode); | ||
1199 | goto bad_inode; | 1209 | goto bad_inode; |
1210 | } | ||
1200 | 1211 | ||
1201 | inode->i_mode = le16_to_cpu(raw_inode->i_mode); | 1212 | inode->i_mode = le16_to_cpu(raw_inode->i_mode); |
1202 | inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low); | 1213 | inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low); |
@@ -1220,6 +1231,7 @@ void ext2_read_inode (struct inode * inode) | |||
1220 | if (inode->i_nlink == 0 && (inode->i_mode == 0 || ei->i_dtime)) { | 1231 | if (inode->i_nlink == 0 && (inode->i_mode == 0 || ei->i_dtime)) { |
1221 | /* this inode is deleted */ | 1232 | /* this inode is deleted */ |
1222 | brelse (bh); | 1233 | brelse (bh); |
1234 | ret = -ESTALE; | ||
1223 | goto bad_inode; | 1235 | goto bad_inode; |
1224 | } | 1236 | } |
1225 | inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); | 1237 | inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); |
@@ -1286,11 +1298,12 @@ void ext2_read_inode (struct inode * inode) | |||
1286 | } | 1298 | } |
1287 | brelse (bh); | 1299 | brelse (bh); |
1288 | ext2_set_inode_flags(inode); | 1300 | ext2_set_inode_flags(inode); |
1289 | return; | 1301 | unlock_new_inode(inode); |
1302 | return inode; | ||
1290 | 1303 | ||
1291 | bad_inode: | 1304 | bad_inode: |
1292 | make_bad_inode(inode); | 1305 | iget_failed(inode); |
1293 | return; | 1306 | return ERR_PTR(ret); |
1294 | } | 1307 | } |
1295 | 1308 | ||
1296 | static int ext2_update_inode(struct inode * inode, int do_sync) | 1309 | static int ext2_update_inode(struct inode * inode, int do_sync) |
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index e69beed839ac..80c97fd8c571 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c | |||
@@ -63,9 +63,9 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str | |||
63 | ino = ext2_inode_by_name(dir, dentry); | 63 | ino = ext2_inode_by_name(dir, dentry); |
64 | inode = NULL; | 64 | inode = NULL; |
65 | if (ino) { | 65 | if (ino) { |
66 | inode = iget(dir->i_sb, ino); | 66 | inode = ext2_iget(dir->i_sb, ino); |
67 | if (!inode) | 67 | if (IS_ERR(inode)) |
68 | return ERR_PTR(-EACCES); | 68 | return ERR_CAST(inode); |
69 | } | 69 | } |
70 | return d_splice_alias(inode, dentry); | 70 | return d_splice_alias(inode, dentry); |
71 | } | 71 | } |
@@ -83,10 +83,10 @@ struct dentry *ext2_get_parent(struct dentry *child) | |||
83 | ino = ext2_inode_by_name(child->d_inode, &dotdot); | 83 | ino = ext2_inode_by_name(child->d_inode, &dotdot); |
84 | if (!ino) | 84 | if (!ino) |
85 | return ERR_PTR(-ENOENT); | 85 | return ERR_PTR(-ENOENT); |
86 | inode = iget(child->d_inode->i_sb, ino); | 86 | inode = ext2_iget(child->d_inode->i_sb, ino); |
87 | 87 | ||
88 | if (!inode) | 88 | if (IS_ERR(inode)) |
89 | return ERR_PTR(-EACCES); | 89 | return ERR_CAST(inode); |
90 | parent = d_alloc_anon(inode); | 90 | parent = d_alloc_anon(inode); |
91 | if (!parent) { | 91 | if (!parent) { |
92 | iput(inode); | 92 | iput(inode); |
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 1ba18b72d43a..22f1010bf79f 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -296,7 +296,6 @@ static ssize_t ext2_quota_write(struct super_block *sb, int type, const char *da | |||
296 | static const struct super_operations ext2_sops = { | 296 | static const struct super_operations ext2_sops = { |
297 | .alloc_inode = ext2_alloc_inode, | 297 | .alloc_inode = ext2_alloc_inode, |
298 | .destroy_inode = ext2_destroy_inode, | 298 | .destroy_inode = ext2_destroy_inode, |
299 | .read_inode = ext2_read_inode, | ||
300 | .write_inode = ext2_write_inode, | 299 | .write_inode = ext2_write_inode, |
301 | .delete_inode = ext2_delete_inode, | 300 | .delete_inode = ext2_delete_inode, |
302 | .put_super = ext2_put_super, | 301 | .put_super = ext2_put_super, |
@@ -326,11 +325,10 @@ static struct inode *ext2_nfs_get_inode(struct super_block *sb, | |||
326 | * it might be "neater" to call ext2_get_inode first and check | 325 | * it might be "neater" to call ext2_get_inode first and check |
327 | * if the inode is valid..... | 326 | * if the inode is valid..... |
328 | */ | 327 | */ |
329 | inode = iget(sb, ino); | 328 | inode = ext2_iget(sb, ino); |
330 | if (inode == NULL) | 329 | if (IS_ERR(inode)) |
331 | return ERR_PTR(-ENOMEM); | 330 | return ERR_CAST(inode); |
332 | if (is_bad_inode(inode) || | 331 | if (generation && inode->i_generation != generation) { |
333 | (generation && inode->i_generation != generation)) { | ||
334 | /* we didn't find the right inode.. */ | 332 | /* we didn't find the right inode.. */ |
335 | iput(inode); | 333 | iput(inode); |
336 | return ERR_PTR(-ESTALE); | 334 | return ERR_PTR(-ESTALE); |
@@ -746,6 +744,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
746 | unsigned long logic_sb_block; | 744 | unsigned long logic_sb_block; |
747 | unsigned long offset = 0; | 745 | unsigned long offset = 0; |
748 | unsigned long def_mount_opts; | 746 | unsigned long def_mount_opts; |
747 | long ret = -EINVAL; | ||
749 | int blocksize = BLOCK_SIZE; | 748 | int blocksize = BLOCK_SIZE; |
750 | int db_count; | 749 | int db_count; |
751 | int i, j; | 750 | int i, j; |
@@ -1041,19 +1040,24 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
1041 | sb->s_op = &ext2_sops; | 1040 | sb->s_op = &ext2_sops; |
1042 | sb->s_export_op = &ext2_export_ops; | 1041 | sb->s_export_op = &ext2_export_ops; |
1043 | sb->s_xattr = ext2_xattr_handlers; | 1042 | sb->s_xattr = ext2_xattr_handlers; |
1044 | root = iget(sb, EXT2_ROOT_INO); | 1043 | root = ext2_iget(sb, EXT2_ROOT_INO); |
1045 | sb->s_root = d_alloc_root(root); | 1044 | if (IS_ERR(root)) { |
1046 | if (!sb->s_root) { | 1045 | ret = PTR_ERR(root); |
1047 | iput(root); | ||
1048 | printk(KERN_ERR "EXT2-fs: get root inode failed\n"); | ||
1049 | goto failed_mount3; | 1046 | goto failed_mount3; |
1050 | } | 1047 | } |
1051 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { | 1048 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { |
1052 | dput(sb->s_root); | 1049 | iput(root); |
1053 | sb->s_root = NULL; | ||
1054 | printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n"); | 1050 | printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n"); |
1055 | goto failed_mount3; | 1051 | goto failed_mount3; |
1056 | } | 1052 | } |
1053 | |||
1054 | sb->s_root = d_alloc_root(root); | ||
1055 | if (!sb->s_root) { | ||
1056 | iput(root); | ||
1057 | printk(KERN_ERR "EXT2-fs: get root inode failed\n"); | ||
1058 | ret = -ENOMEM; | ||
1059 | goto failed_mount3; | ||
1060 | } | ||
1057 | if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) | 1061 | if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) |
1058 | ext2_warning(sb, __FUNCTION__, | 1062 | ext2_warning(sb, __FUNCTION__, |
1059 | "mounting ext3 filesystem as ext2"); | 1063 | "mounting ext3 filesystem as ext2"); |
@@ -1080,7 +1084,7 @@ failed_mount: | |||
1080 | failed_sbi: | 1084 | failed_sbi: |
1081 | sb->s_fs_info = NULL; | 1085 | sb->s_fs_info = NULL; |
1082 | kfree(sbi); | 1086 | kfree(sbi); |
1083 | return -EINVAL; | 1087 | return ret; |
1084 | } | 1088 | } |
1085 | 1089 | ||
1086 | static void ext2_commit_super (struct super_block * sb, | 1090 | static void ext2_commit_super (struct super_block * sb, |
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index 1bc8cd89c51d..58ae2f943f12 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c | |||
@@ -642,14 +642,15 @@ struct inode *ext3_orphan_get(struct super_block *sb, unsigned long ino) | |||
642 | unsigned long max_ino = le32_to_cpu(EXT3_SB(sb)->s_es->s_inodes_count); | 642 | unsigned long max_ino = le32_to_cpu(EXT3_SB(sb)->s_es->s_inodes_count); |
643 | unsigned long block_group; | 643 | unsigned long block_group; |
644 | int bit; | 644 | int bit; |
645 | struct buffer_head *bitmap_bh = NULL; | 645 | struct buffer_head *bitmap_bh; |
646 | struct inode *inode = NULL; | 646 | struct inode *inode = NULL; |
647 | long err = -EIO; | ||
647 | 648 | ||
648 | /* Error cases - e2fsck has already cleaned up for us */ | 649 | /* Error cases - e2fsck has already cleaned up for us */ |
649 | if (ino > max_ino) { | 650 | if (ino > max_ino) { |
650 | ext3_warning(sb, __FUNCTION__, | 651 | ext3_warning(sb, __FUNCTION__, |
651 | "bad orphan ino %lu! e2fsck was run?", ino); | 652 | "bad orphan ino %lu! e2fsck was run?", ino); |
652 | goto out; | 653 | goto error; |
653 | } | 654 | } |
654 | 655 | ||
655 | block_group = (ino - 1) / EXT3_INODES_PER_GROUP(sb); | 656 | block_group = (ino - 1) / EXT3_INODES_PER_GROUP(sb); |
@@ -658,38 +659,49 @@ struct inode *ext3_orphan_get(struct super_block *sb, unsigned long ino) | |||
658 | if (!bitmap_bh) { | 659 | if (!bitmap_bh) { |
659 | ext3_warning(sb, __FUNCTION__, | 660 | ext3_warning(sb, __FUNCTION__, |
660 | "inode bitmap error for orphan %lu", ino); | 661 | "inode bitmap error for orphan %lu", ino); |
661 | goto out; | 662 | goto error; |
662 | } | 663 | } |
663 | 664 | ||
664 | /* Having the inode bit set should be a 100% indicator that this | 665 | /* Having the inode bit set should be a 100% indicator that this |
665 | * is a valid orphan (no e2fsck run on fs). Orphans also include | 666 | * is a valid orphan (no e2fsck run on fs). Orphans also include |
666 | * inodes that were being truncated, so we can't check i_nlink==0. | 667 | * inodes that were being truncated, so we can't check i_nlink==0. |
667 | */ | 668 | */ |
668 | if (!ext3_test_bit(bit, bitmap_bh->b_data) || | 669 | if (!ext3_test_bit(bit, bitmap_bh->b_data)) |
669 | !(inode = iget(sb, ino)) || is_bad_inode(inode) || | 670 | goto bad_orphan; |
670 | NEXT_ORPHAN(inode) > max_ino) { | 671 | |
671 | ext3_warning(sb, __FUNCTION__, | 672 | inode = ext3_iget(sb, ino); |
672 | "bad orphan inode %lu! e2fsck was run?", ino); | 673 | if (IS_ERR(inode)) |
673 | printk(KERN_NOTICE "ext3_test_bit(bit=%d, block=%llu) = %d\n", | 674 | goto iget_failed; |
674 | bit, (unsigned long long)bitmap_bh->b_blocknr, | 675 | |
675 | ext3_test_bit(bit, bitmap_bh->b_data)); | 676 | if (NEXT_ORPHAN(inode) > max_ino) |
676 | printk(KERN_NOTICE "inode=%p\n", inode); | 677 | goto bad_orphan; |
677 | if (inode) { | 678 | brelse(bitmap_bh); |
678 | printk(KERN_NOTICE "is_bad_inode(inode)=%d\n", | 679 | return inode; |
679 | is_bad_inode(inode)); | 680 | |
680 | printk(KERN_NOTICE "NEXT_ORPHAN(inode)=%u\n", | 681 | iget_failed: |
681 | NEXT_ORPHAN(inode)); | 682 | err = PTR_ERR(inode); |
682 | printk(KERN_NOTICE "max_ino=%lu\n", max_ino); | 683 | inode = NULL; |
683 | } | 684 | bad_orphan: |
685 | ext3_warning(sb, __FUNCTION__, | ||
686 | "bad orphan inode %lu! e2fsck was run?", ino); | ||
687 | printk(KERN_NOTICE "ext3_test_bit(bit=%d, block=%llu) = %d\n", | ||
688 | bit, (unsigned long long)bitmap_bh->b_blocknr, | ||
689 | ext3_test_bit(bit, bitmap_bh->b_data)); | ||
690 | printk(KERN_NOTICE "inode=%p\n", inode); | ||
691 | if (inode) { | ||
692 | printk(KERN_NOTICE "is_bad_inode(inode)=%d\n", | ||
693 | is_bad_inode(inode)); | ||
694 | printk(KERN_NOTICE "NEXT_ORPHAN(inode)=%u\n", | ||
695 | NEXT_ORPHAN(inode)); | ||
696 | printk(KERN_NOTICE "max_ino=%lu\n", max_ino); | ||
684 | /* Avoid freeing blocks if we got a bad deleted inode */ | 697 | /* Avoid freeing blocks if we got a bad deleted inode */ |
685 | if (inode && inode->i_nlink == 0) | 698 | if (inode->i_nlink == 0) |
686 | inode->i_blocks = 0; | 699 | inode->i_blocks = 0; |
687 | iput(inode); | 700 | iput(inode); |
688 | inode = NULL; | ||
689 | } | 701 | } |
690 | out: | ||
691 | brelse(bitmap_bh); | 702 | brelse(bitmap_bh); |
692 | return inode; | 703 | error: |
704 | return ERR_PTR(err); | ||
693 | } | 705 | } |
694 | 706 | ||
695 | unsigned long ext3_count_free_inodes (struct super_block * sb) | 707 | unsigned long ext3_count_free_inodes (struct super_block * sb) |
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index 8a9ce2d09bde..eb95670a27eb 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c | |||
@@ -2654,21 +2654,31 @@ void ext3_get_inode_flags(struct ext3_inode_info *ei) | |||
2654 | ei->i_flags |= EXT3_DIRSYNC_FL; | 2654 | ei->i_flags |= EXT3_DIRSYNC_FL; |
2655 | } | 2655 | } |
2656 | 2656 | ||
2657 | void ext3_read_inode(struct inode * inode) | 2657 | struct inode *ext3_iget(struct super_block *sb, unsigned long ino) |
2658 | { | 2658 | { |
2659 | struct ext3_iloc iloc; | 2659 | struct ext3_iloc iloc; |
2660 | struct ext3_inode *raw_inode; | 2660 | struct ext3_inode *raw_inode; |
2661 | struct ext3_inode_info *ei = EXT3_I(inode); | 2661 | struct ext3_inode_info *ei; |
2662 | struct buffer_head *bh; | 2662 | struct buffer_head *bh; |
2663 | struct inode *inode; | ||
2664 | long ret; | ||
2663 | int block; | 2665 | int block; |
2664 | 2666 | ||
2667 | inode = iget_locked(sb, ino); | ||
2668 | if (!inode) | ||
2669 | return ERR_PTR(-ENOMEM); | ||
2670 | if (!(inode->i_state & I_NEW)) | ||
2671 | return inode; | ||
2672 | |||
2673 | ei = EXT3_I(inode); | ||
2665 | #ifdef CONFIG_EXT3_FS_POSIX_ACL | 2674 | #ifdef CONFIG_EXT3_FS_POSIX_ACL |
2666 | ei->i_acl = EXT3_ACL_NOT_CACHED; | 2675 | ei->i_acl = EXT3_ACL_NOT_CACHED; |
2667 | ei->i_default_acl = EXT3_ACL_NOT_CACHED; | 2676 | ei->i_default_acl = EXT3_ACL_NOT_CACHED; |
2668 | #endif | 2677 | #endif |
2669 | ei->i_block_alloc_info = NULL; | 2678 | ei->i_block_alloc_info = NULL; |
2670 | 2679 | ||
2671 | if (__ext3_get_inode_loc(inode, &iloc, 0)) | 2680 | ret = __ext3_get_inode_loc(inode, &iloc, 0); |
2681 | if (ret < 0) | ||
2672 | goto bad_inode; | 2682 | goto bad_inode; |
2673 | bh = iloc.bh; | 2683 | bh = iloc.bh; |
2674 | raw_inode = ext3_raw_inode(&iloc); | 2684 | raw_inode = ext3_raw_inode(&iloc); |
@@ -2699,6 +2709,7 @@ void ext3_read_inode(struct inode * inode) | |||
2699 | !(EXT3_SB(inode->i_sb)->s_mount_state & EXT3_ORPHAN_FS)) { | 2709 | !(EXT3_SB(inode->i_sb)->s_mount_state & EXT3_ORPHAN_FS)) { |
2700 | /* this inode is deleted */ | 2710 | /* this inode is deleted */ |
2701 | brelse (bh); | 2711 | brelse (bh); |
2712 | ret = -ESTALE; | ||
2702 | goto bad_inode; | 2713 | goto bad_inode; |
2703 | } | 2714 | } |
2704 | /* The only unlinked inodes we let through here have | 2715 | /* The only unlinked inodes we let through here have |
@@ -2742,6 +2753,7 @@ void ext3_read_inode(struct inode * inode) | |||
2742 | if (EXT3_GOOD_OLD_INODE_SIZE + ei->i_extra_isize > | 2753 | if (EXT3_GOOD_OLD_INODE_SIZE + ei->i_extra_isize > |
2743 | EXT3_INODE_SIZE(inode->i_sb)) { | 2754 | EXT3_INODE_SIZE(inode->i_sb)) { |
2744 | brelse (bh); | 2755 | brelse (bh); |
2756 | ret = -EIO; | ||
2745 | goto bad_inode; | 2757 | goto bad_inode; |
2746 | } | 2758 | } |
2747 | if (ei->i_extra_isize == 0) { | 2759 | if (ei->i_extra_isize == 0) { |
@@ -2783,11 +2795,12 @@ void ext3_read_inode(struct inode * inode) | |||
2783 | } | 2795 | } |
2784 | brelse (iloc.bh); | 2796 | brelse (iloc.bh); |
2785 | ext3_set_inode_flags(inode); | 2797 | ext3_set_inode_flags(inode); |
2786 | return; | 2798 | unlock_new_inode(inode); |
2799 | return inode; | ||
2787 | 2800 | ||
2788 | bad_inode: | 2801 | bad_inode: |
2789 | make_bad_inode(inode); | 2802 | iget_failed(inode); |
2790 | return; | 2803 | return ERR_PTR(ret); |
2791 | } | 2804 | } |
2792 | 2805 | ||
2793 | /* | 2806 | /* |
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 92b83b004dd8..dec3e0d88ab1 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c | |||
@@ -1037,17 +1037,11 @@ static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry, str | |||
1037 | if (!ext3_valid_inum(dir->i_sb, ino)) { | 1037 | if (!ext3_valid_inum(dir->i_sb, ino)) { |
1038 | ext3_error(dir->i_sb, "ext3_lookup", | 1038 | ext3_error(dir->i_sb, "ext3_lookup", |
1039 | "bad inode number: %lu", ino); | 1039 | "bad inode number: %lu", ino); |
1040 | inode = NULL; | 1040 | return ERR_PTR(-EIO); |
1041 | } else | ||
1042 | inode = iget(dir->i_sb, ino); | ||
1043 | |||
1044 | if (!inode) | ||
1045 | return ERR_PTR(-EACCES); | ||
1046 | |||
1047 | if (is_bad_inode(inode)) { | ||
1048 | iput(inode); | ||
1049 | return ERR_PTR(-ENOENT); | ||
1050 | } | 1041 | } |
1042 | inode = ext3_iget(dir->i_sb, ino); | ||
1043 | if (IS_ERR(inode)) | ||
1044 | return ERR_CAST(inode); | ||
1051 | } | 1045 | } |
1052 | return d_splice_alias(inode, dentry); | 1046 | return d_splice_alias(inode, dentry); |
1053 | } | 1047 | } |
@@ -1076,18 +1070,13 @@ struct dentry *ext3_get_parent(struct dentry *child) | |||
1076 | if (!ext3_valid_inum(child->d_inode->i_sb, ino)) { | 1070 | if (!ext3_valid_inum(child->d_inode->i_sb, ino)) { |
1077 | ext3_error(child->d_inode->i_sb, "ext3_get_parent", | 1071 | ext3_error(child->d_inode->i_sb, "ext3_get_parent", |
1078 | "bad inode number: %lu", ino); | 1072 | "bad inode number: %lu", ino); |
1079 | inode = NULL; | 1073 | return ERR_PTR(-EIO); |
1080 | } else | ||
1081 | inode = iget(child->d_inode->i_sb, ino); | ||
1082 | |||
1083 | if (!inode) | ||
1084 | return ERR_PTR(-EACCES); | ||
1085 | |||
1086 | if (is_bad_inode(inode)) { | ||
1087 | iput(inode); | ||
1088 | return ERR_PTR(-ENOENT); | ||
1089 | } | 1074 | } |
1090 | 1075 | ||
1076 | inode = ext3_iget(child->d_inode->i_sb, ino); | ||
1077 | if (IS_ERR(inode)) | ||
1078 | return ERR_CAST(inode); | ||
1079 | |||
1091 | parent = d_alloc_anon(inode); | 1080 | parent = d_alloc_anon(inode); |
1092 | if (!parent) { | 1081 | if (!parent) { |
1093 | iput(inode); | 1082 | iput(inode); |
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c index 44de1453c301..ebc05af7343a 100644 --- a/fs/ext3/resize.c +++ b/fs/ext3/resize.c | |||
@@ -795,12 +795,11 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input) | |||
795 | "No reserved GDT blocks, can't resize"); | 795 | "No reserved GDT blocks, can't resize"); |
796 | return -EPERM; | 796 | return -EPERM; |
797 | } | 797 | } |
798 | inode = iget(sb, EXT3_RESIZE_INO); | 798 | inode = ext3_iget(sb, EXT3_RESIZE_INO); |
799 | if (!inode || is_bad_inode(inode)) { | 799 | if (IS_ERR(inode)) { |
800 | ext3_warning(sb, __FUNCTION__, | 800 | ext3_warning(sb, __FUNCTION__, |
801 | "Error opening resize inode"); | 801 | "Error opening resize inode"); |
802 | iput(inode); | 802 | return PTR_ERR(inode); |
803 | return -ENOENT; | ||
804 | } | 803 | } |
805 | } | 804 | } |
806 | 805 | ||
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 343677e8c350..cf2a2c3660ec 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -649,11 +649,10 @@ static struct inode *ext3_nfs_get_inode(struct super_block *sb, | |||
649 | * Currently we don't know the generation for parent directory, so | 649 | * Currently we don't know the generation for parent directory, so |
650 | * a generation of 0 means "accept any" | 650 | * a generation of 0 means "accept any" |
651 | */ | 651 | */ |
652 | inode = iget(sb, ino); | 652 | inode = ext3_iget(sb, ino); |
653 | if (inode == NULL) | 653 | if (IS_ERR(inode)) |
654 | return ERR_PTR(-ENOMEM); | 654 | return ERR_CAST(inode); |
655 | if (is_bad_inode(inode) || | 655 | if (generation && inode->i_generation != generation) { |
656 | (generation && inode->i_generation != generation)) { | ||
657 | iput(inode); | 656 | iput(inode); |
658 | return ERR_PTR(-ESTALE); | 657 | return ERR_PTR(-ESTALE); |
659 | } | 658 | } |
@@ -722,7 +721,6 @@ static struct quotactl_ops ext3_qctl_operations = { | |||
722 | static const struct super_operations ext3_sops = { | 721 | static const struct super_operations ext3_sops = { |
723 | .alloc_inode = ext3_alloc_inode, | 722 | .alloc_inode = ext3_alloc_inode, |
724 | .destroy_inode = ext3_destroy_inode, | 723 | .destroy_inode = ext3_destroy_inode, |
725 | .read_inode = ext3_read_inode, | ||
726 | .write_inode = ext3_write_inode, | 724 | .write_inode = ext3_write_inode, |
727 | .dirty_inode = ext3_dirty_inode, | 725 | .dirty_inode = ext3_dirty_inode, |
728 | .delete_inode = ext3_delete_inode, | 726 | .delete_inode = ext3_delete_inode, |
@@ -1378,8 +1376,8 @@ static void ext3_orphan_cleanup (struct super_block * sb, | |||
1378 | while (es->s_last_orphan) { | 1376 | while (es->s_last_orphan) { |
1379 | struct inode *inode; | 1377 | struct inode *inode; |
1380 | 1378 | ||
1381 | if (!(inode = | 1379 | inode = ext3_orphan_get(sb, le32_to_cpu(es->s_last_orphan)); |
1382 | ext3_orphan_get(sb, le32_to_cpu(es->s_last_orphan)))) { | 1380 | if (IS_ERR(inode)) { |
1383 | es->s_last_orphan = 0; | 1381 | es->s_last_orphan = 0; |
1384 | break; | 1382 | break; |
1385 | } | 1383 | } |
@@ -1508,6 +1506,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1508 | int db_count; | 1506 | int db_count; |
1509 | int i; | 1507 | int i; |
1510 | int needs_recovery; | 1508 | int needs_recovery; |
1509 | int ret = -EINVAL; | ||
1511 | __le32 features; | 1510 | __le32 features; |
1512 | int err; | 1511 | int err; |
1513 | 1512 | ||
@@ -1877,19 +1876,24 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1877 | * so we can safely mount the rest of the filesystem now. | 1876 | * so we can safely mount the rest of the filesystem now. |
1878 | */ | 1877 | */ |
1879 | 1878 | ||
1880 | root = iget(sb, EXT3_ROOT_INO); | 1879 | root = ext3_iget(sb, EXT3_ROOT_INO); |
1881 | sb->s_root = d_alloc_root(root); | 1880 | if (IS_ERR(root)) { |
1882 | if (!sb->s_root) { | ||
1883 | printk(KERN_ERR "EXT3-fs: get root inode failed\n"); | 1881 | printk(KERN_ERR "EXT3-fs: get root inode failed\n"); |
1884 | iput(root); | 1882 | ret = PTR_ERR(root); |
1885 | goto failed_mount4; | 1883 | goto failed_mount4; |
1886 | } | 1884 | } |
1887 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { | 1885 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { |
1888 | dput(sb->s_root); | 1886 | iput(root); |
1889 | sb->s_root = NULL; | ||
1890 | printk(KERN_ERR "EXT3-fs: corrupt root inode, run e2fsck\n"); | 1887 | printk(KERN_ERR "EXT3-fs: corrupt root inode, run e2fsck\n"); |
1891 | goto failed_mount4; | 1888 | goto failed_mount4; |
1892 | } | 1889 | } |
1890 | sb->s_root = d_alloc_root(root); | ||
1891 | if (!sb->s_root) { | ||
1892 | printk(KERN_ERR "EXT3-fs: get root dentry failed\n"); | ||
1893 | iput(root); | ||
1894 | ret = -ENOMEM; | ||
1895 | goto failed_mount4; | ||
1896 | } | ||
1893 | 1897 | ||
1894 | ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY); | 1898 | ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY); |
1895 | /* | 1899 | /* |
@@ -1941,7 +1945,7 @@ out_fail: | |||
1941 | sb->s_fs_info = NULL; | 1945 | sb->s_fs_info = NULL; |
1942 | kfree(sbi); | 1946 | kfree(sbi); |
1943 | lock_kernel(); | 1947 | lock_kernel(); |
1944 | return -EINVAL; | 1948 | return ret; |
1945 | } | 1949 | } |
1946 | 1950 | ||
1947 | /* | 1951 | /* |
@@ -1977,8 +1981,8 @@ static journal_t *ext3_get_journal(struct super_block *sb, | |||
1977 | * things happen if we iget() an unused inode, as the subsequent | 1981 | * things happen if we iget() an unused inode, as the subsequent |
1978 | * iput() will try to delete it. */ | 1982 | * iput() will try to delete it. */ |
1979 | 1983 | ||
1980 | journal_inode = iget(sb, journal_inum); | 1984 | journal_inode = ext3_iget(sb, journal_inum); |
1981 | if (!journal_inode) { | 1985 | if (IS_ERR(journal_inode)) { |
1982 | printk(KERN_ERR "EXT3-fs: no journal found.\n"); | 1986 | printk(KERN_ERR "EXT3-fs: no journal found.\n"); |
1983 | return NULL; | 1987 | return NULL; |
1984 | } | 1988 | } |
@@ -1991,7 +1995,7 @@ static journal_t *ext3_get_journal(struct super_block *sb, | |||
1991 | 1995 | ||
1992 | jbd_debug(2, "Journal inode found at %p: %Ld bytes\n", | 1996 | jbd_debug(2, "Journal inode found at %p: %Ld bytes\n", |
1993 | journal_inode, journal_inode->i_size); | 1997 | journal_inode, journal_inode->i_size); |
1994 | if (is_bad_inode(journal_inode) || !S_ISREG(journal_inode->i_mode)) { | 1998 | if (!S_ISREG(journal_inode->i_mode)) { |
1995 | printk(KERN_ERR "EXT3-fs: invalid journal inode.\n"); | 1999 | printk(KERN_ERR "EXT3-fs: invalid journal inode.\n"); |
1996 | iput(journal_inode); | 2000 | iput(journal_inode); |
1997 | return NULL; | 2001 | return NULL; |
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 575b5215c808..da18a74b966a 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
@@ -782,14 +782,15 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino) | |||
782 | unsigned long max_ino = le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count); | 782 | unsigned long max_ino = le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count); |
783 | ext4_group_t block_group; | 783 | ext4_group_t block_group; |
784 | int bit; | 784 | int bit; |
785 | struct buffer_head *bitmap_bh = NULL; | 785 | struct buffer_head *bitmap_bh; |
786 | struct inode *inode = NULL; | 786 | struct inode *inode = NULL; |
787 | long err = -EIO; | ||
787 | 788 | ||
788 | /* Error cases - e2fsck has already cleaned up for us */ | 789 | /* Error cases - e2fsck has already cleaned up for us */ |
789 | if (ino > max_ino) { | 790 | if (ino > max_ino) { |
790 | ext4_warning(sb, __FUNCTION__, | 791 | ext4_warning(sb, __FUNCTION__, |
791 | "bad orphan ino %lu! e2fsck was run?", ino); | 792 | "bad orphan ino %lu! e2fsck was run?", ino); |
792 | goto out; | 793 | goto error; |
793 | } | 794 | } |
794 | 795 | ||
795 | block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb); | 796 | block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb); |
@@ -798,38 +799,49 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino) | |||
798 | if (!bitmap_bh) { | 799 | if (!bitmap_bh) { |
799 | ext4_warning(sb, __FUNCTION__, | 800 | ext4_warning(sb, __FUNCTION__, |
800 | "inode bitmap error for orphan %lu", ino); | 801 | "inode bitmap error for orphan %lu", ino); |
801 | goto out; | 802 | goto error; |
802 | } | 803 | } |
803 | 804 | ||
804 | /* Having the inode bit set should be a 100% indicator that this | 805 | /* Having the inode bit set should be a 100% indicator that this |
805 | * is a valid orphan (no e2fsck run on fs). Orphans also include | 806 | * is a valid orphan (no e2fsck run on fs). Orphans also include |
806 | * inodes that were being truncated, so we can't check i_nlink==0. | 807 | * inodes that were being truncated, so we can't check i_nlink==0. |
807 | */ | 808 | */ |
808 | if (!ext4_test_bit(bit, bitmap_bh->b_data) || | 809 | if (!ext4_test_bit(bit, bitmap_bh->b_data)) |
809 | !(inode = iget(sb, ino)) || is_bad_inode(inode) || | 810 | goto bad_orphan; |
810 | NEXT_ORPHAN(inode) > max_ino) { | 811 | |
811 | ext4_warning(sb, __FUNCTION__, | 812 | inode = ext4_iget(sb, ino); |
812 | "bad orphan inode %lu! e2fsck was run?", ino); | 813 | if (IS_ERR(inode)) |
813 | printk(KERN_NOTICE "ext4_test_bit(bit=%d, block=%llu) = %d\n", | 814 | goto iget_failed; |
814 | bit, (unsigned long long)bitmap_bh->b_blocknr, | 815 | |
815 | ext4_test_bit(bit, bitmap_bh->b_data)); | 816 | if (NEXT_ORPHAN(inode) > max_ino) |
816 | printk(KERN_NOTICE "inode=%p\n", inode); | 817 | goto bad_orphan; |
817 | if (inode) { | 818 | brelse(bitmap_bh); |
818 | printk(KERN_NOTICE "is_bad_inode(inode)=%d\n", | 819 | return inode; |
819 | is_bad_inode(inode)); | 820 | |
820 | printk(KERN_NOTICE "NEXT_ORPHAN(inode)=%u\n", | 821 | iget_failed: |
821 | NEXT_ORPHAN(inode)); | 822 | err = PTR_ERR(inode); |
822 | printk(KERN_NOTICE "max_ino=%lu\n", max_ino); | 823 | inode = NULL; |
823 | } | 824 | bad_orphan: |
825 | ext4_warning(sb, __FUNCTION__, | ||
826 | "bad orphan inode %lu! e2fsck was run?", ino); | ||
827 | printk(KERN_NOTICE "ext4_test_bit(bit=%d, block=%llu) = %d\n", | ||
828 | bit, (unsigned long long)bitmap_bh->b_blocknr, | ||
829 | ext4_test_bit(bit, bitmap_bh->b_data)); | ||
830 | printk(KERN_NOTICE "inode=%p\n", inode); | ||
831 | if (inode) { | ||
832 | printk(KERN_NOTICE "is_bad_inode(inode)=%d\n", | ||
833 | is_bad_inode(inode)); | ||
834 | printk(KERN_NOTICE "NEXT_ORPHAN(inode)=%u\n", | ||
835 | NEXT_ORPHAN(inode)); | ||
836 | printk(KERN_NOTICE "max_ino=%lu\n", max_ino); | ||
824 | /* Avoid freeing blocks if we got a bad deleted inode */ | 837 | /* Avoid freeing blocks if we got a bad deleted inode */ |
825 | if (inode && inode->i_nlink == 0) | 838 | if (inode->i_nlink == 0) |
826 | inode->i_blocks = 0; | 839 | inode->i_blocks = 0; |
827 | iput(inode); | 840 | iput(inode); |
828 | inode = NULL; | ||
829 | } | 841 | } |
830 | out: | ||
831 | brelse(bitmap_bh); | 842 | brelse(bitmap_bh); |
832 | return inode; | 843 | error: |
844 | return ERR_PTR(err); | ||
833 | } | 845 | } |
834 | 846 | ||
835 | unsigned long ext4_count_free_inodes (struct super_block * sb) | 847 | unsigned long ext4_count_free_inodes (struct super_block * sb) |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 0e9055cf700e..f4e387452246 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -2680,21 +2680,31 @@ static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode, | |||
2680 | } | 2680 | } |
2681 | } | 2681 | } |
2682 | 2682 | ||
2683 | void ext4_read_inode(struct inode * inode) | 2683 | struct inode *ext4_iget(struct super_block *sb, unsigned long ino) |
2684 | { | 2684 | { |
2685 | struct ext4_iloc iloc; | 2685 | struct ext4_iloc iloc; |
2686 | struct ext4_inode *raw_inode; | 2686 | struct ext4_inode *raw_inode; |
2687 | struct ext4_inode_info *ei = EXT4_I(inode); | 2687 | struct ext4_inode_info *ei; |
2688 | struct buffer_head *bh; | 2688 | struct buffer_head *bh; |
2689 | struct inode *inode; | ||
2690 | long ret; | ||
2689 | int block; | 2691 | int block; |
2690 | 2692 | ||
2693 | inode = iget_locked(sb, ino); | ||
2694 | if (!inode) | ||
2695 | return ERR_PTR(-ENOMEM); | ||
2696 | if (!(inode->i_state & I_NEW)) | ||
2697 | return inode; | ||
2698 | |||
2699 | ei = EXT4_I(inode); | ||
2691 | #ifdef CONFIG_EXT4DEV_FS_POSIX_ACL | 2700 | #ifdef CONFIG_EXT4DEV_FS_POSIX_ACL |
2692 | ei->i_acl = EXT4_ACL_NOT_CACHED; | 2701 | ei->i_acl = EXT4_ACL_NOT_CACHED; |
2693 | ei->i_default_acl = EXT4_ACL_NOT_CACHED; | 2702 | ei->i_default_acl = EXT4_ACL_NOT_CACHED; |
2694 | #endif | 2703 | #endif |
2695 | ei->i_block_alloc_info = NULL; | 2704 | ei->i_block_alloc_info = NULL; |
2696 | 2705 | ||
2697 | if (__ext4_get_inode_loc(inode, &iloc, 0)) | 2706 | ret = __ext4_get_inode_loc(inode, &iloc, 0); |
2707 | if (ret < 0) | ||
2698 | goto bad_inode; | 2708 | goto bad_inode; |
2699 | bh = iloc.bh; | 2709 | bh = iloc.bh; |
2700 | raw_inode = ext4_raw_inode(&iloc); | 2710 | raw_inode = ext4_raw_inode(&iloc); |
@@ -2720,6 +2730,7 @@ void ext4_read_inode(struct inode * inode) | |||
2720 | !(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS)) { | 2730 | !(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS)) { |
2721 | /* this inode is deleted */ | 2731 | /* this inode is deleted */ |
2722 | brelse (bh); | 2732 | brelse (bh); |
2733 | ret = -ESTALE; | ||
2723 | goto bad_inode; | 2734 | goto bad_inode; |
2724 | } | 2735 | } |
2725 | /* The only unlinked inodes we let through here have | 2736 | /* The only unlinked inodes we let through here have |
@@ -2758,6 +2769,7 @@ void ext4_read_inode(struct inode * inode) | |||
2758 | if (EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize > | 2769 | if (EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize > |
2759 | EXT4_INODE_SIZE(inode->i_sb)) { | 2770 | EXT4_INODE_SIZE(inode->i_sb)) { |
2760 | brelse (bh); | 2771 | brelse (bh); |
2772 | ret = -EIO; | ||
2761 | goto bad_inode; | 2773 | goto bad_inode; |
2762 | } | 2774 | } |
2763 | if (ei->i_extra_isize == 0) { | 2775 | if (ei->i_extra_isize == 0) { |
@@ -2811,11 +2823,12 @@ void ext4_read_inode(struct inode * inode) | |||
2811 | } | 2823 | } |
2812 | brelse (iloc.bh); | 2824 | brelse (iloc.bh); |
2813 | ext4_set_inode_flags(inode); | 2825 | ext4_set_inode_flags(inode); |
2814 | return; | 2826 | unlock_new_inode(inode); |
2827 | return inode; | ||
2815 | 2828 | ||
2816 | bad_inode: | 2829 | bad_inode: |
2817 | make_bad_inode(inode); | 2830 | iget_failed(inode); |
2818 | return; | 2831 | return ERR_PTR(ret); |
2819 | } | 2832 | } |
2820 | 2833 | ||
2821 | static int ext4_inode_blocks_set(handle_t *handle, | 2834 | static int ext4_inode_blocks_set(handle_t *handle, |
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 67b6d8a1ceff..d153bb5922fc 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -1039,17 +1039,11 @@ static struct dentry *ext4_lookup(struct inode * dir, struct dentry *dentry, str | |||
1039 | if (!ext4_valid_inum(dir->i_sb, ino)) { | 1039 | if (!ext4_valid_inum(dir->i_sb, ino)) { |
1040 | ext4_error(dir->i_sb, "ext4_lookup", | 1040 | ext4_error(dir->i_sb, "ext4_lookup", |
1041 | "bad inode number: %lu", ino); | 1041 | "bad inode number: %lu", ino); |
1042 | inode = NULL; | 1042 | return ERR_PTR(-EIO); |
1043 | } else | ||
1044 | inode = iget(dir->i_sb, ino); | ||
1045 | |||
1046 | if (!inode) | ||
1047 | return ERR_PTR(-EACCES); | ||
1048 | |||
1049 | if (is_bad_inode(inode)) { | ||
1050 | iput(inode); | ||
1051 | return ERR_PTR(-ENOENT); | ||
1052 | } | 1043 | } |
1044 | inode = ext4_iget(dir->i_sb, ino); | ||
1045 | if (IS_ERR(inode)) | ||
1046 | return ERR_CAST(inode); | ||
1053 | } | 1047 | } |
1054 | return d_splice_alias(inode, dentry); | 1048 | return d_splice_alias(inode, dentry); |
1055 | } | 1049 | } |
@@ -1078,18 +1072,13 @@ struct dentry *ext4_get_parent(struct dentry *child) | |||
1078 | if (!ext4_valid_inum(child->d_inode->i_sb, ino)) { | 1072 | if (!ext4_valid_inum(child->d_inode->i_sb, ino)) { |
1079 | ext4_error(child->d_inode->i_sb, "ext4_get_parent", | 1073 | ext4_error(child->d_inode->i_sb, "ext4_get_parent", |
1080 | "bad inode number: %lu", ino); | 1074 | "bad inode number: %lu", ino); |
1081 | inode = NULL; | 1075 | return ERR_PTR(-EIO); |
1082 | } else | ||
1083 | inode = iget(child->d_inode->i_sb, ino); | ||
1084 | |||
1085 | if (!inode) | ||
1086 | return ERR_PTR(-EACCES); | ||
1087 | |||
1088 | if (is_bad_inode(inode)) { | ||
1089 | iput(inode); | ||
1090 | return ERR_PTR(-ENOENT); | ||
1091 | } | 1076 | } |
1092 | 1077 | ||
1078 | inode = ext4_iget(child->d_inode->i_sb, ino); | ||
1079 | if (IS_ERR(inode)) | ||
1080 | return ERR_CAST(inode); | ||
1081 | |||
1093 | parent = d_alloc_anon(inode); | 1082 | parent = d_alloc_anon(inode); |
1094 | if (!parent) { | 1083 | if (!parent) { |
1095 | iput(inode); | 1084 | iput(inode); |
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 4fbba60816f4..9477a2bd6ff2 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
@@ -779,12 +779,11 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input) | |||
779 | "No reserved GDT blocks, can't resize"); | 779 | "No reserved GDT blocks, can't resize"); |
780 | return -EPERM; | 780 | return -EPERM; |
781 | } | 781 | } |
782 | inode = iget(sb, EXT4_RESIZE_INO); | 782 | inode = ext4_iget(sb, EXT4_RESIZE_INO); |
783 | if (!inode || is_bad_inode(inode)) { | 783 | if (IS_ERR(inode)) { |
784 | ext4_warning(sb, __FUNCTION__, | 784 | ext4_warning(sb, __FUNCTION__, |
785 | "Error opening resize inode"); | 785 | "Error opening resize inode"); |
786 | iput(inode); | 786 | return PTR_ERR(inode); |
787 | return -ENOENT; | ||
788 | } | 787 | } |
789 | } | 788 | } |
790 | 789 | ||
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index c89bb8797765..93beb865c20d 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -777,11 +777,10 @@ static struct inode *ext4_nfs_get_inode(struct super_block *sb, | |||
777 | * Currently we don't know the generation for parent directory, so | 777 | * Currently we don't know the generation for parent directory, so |
778 | * a generation of 0 means "accept any" | 778 | * a generation of 0 means "accept any" |
779 | */ | 779 | */ |
780 | inode = iget(sb, ino); | 780 | inode = ext4_iget(sb, ino); |
781 | if (inode == NULL) | 781 | if (IS_ERR(inode)) |
782 | return ERR_PTR(-ENOMEM); | 782 | return ERR_CAST(inode); |
783 | if (is_bad_inode(inode) || | 783 | if (generation && inode->i_generation != generation) { |
784 | (generation && inode->i_generation != generation)) { | ||
785 | iput(inode); | 784 | iput(inode); |
786 | return ERR_PTR(-ESTALE); | 785 | return ERR_PTR(-ESTALE); |
787 | } | 786 | } |
@@ -850,7 +849,6 @@ static struct quotactl_ops ext4_qctl_operations = { | |||
850 | static const struct super_operations ext4_sops = { | 849 | static const struct super_operations ext4_sops = { |
851 | .alloc_inode = ext4_alloc_inode, | 850 | .alloc_inode = ext4_alloc_inode, |
852 | .destroy_inode = ext4_destroy_inode, | 851 | .destroy_inode = ext4_destroy_inode, |
853 | .read_inode = ext4_read_inode, | ||
854 | .write_inode = ext4_write_inode, | 852 | .write_inode = ext4_write_inode, |
855 | .dirty_inode = ext4_dirty_inode, | 853 | .dirty_inode = ext4_dirty_inode, |
856 | .delete_inode = ext4_delete_inode, | 854 | .delete_inode = ext4_delete_inode, |
@@ -1805,6 +1803,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent) | |||
1805 | unsigned long journal_devnum = 0; | 1803 | unsigned long journal_devnum = 0; |
1806 | unsigned long def_mount_opts; | 1804 | unsigned long def_mount_opts; |
1807 | struct inode *root; | 1805 | struct inode *root; |
1806 | int ret = -EINVAL; | ||
1808 | int blocksize; | 1807 | int blocksize; |
1809 | int db_count; | 1808 | int db_count; |
1810 | int i; | 1809 | int i; |
@@ -2237,19 +2236,24 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent) | |||
2237 | * so we can safely mount the rest of the filesystem now. | 2236 | * so we can safely mount the rest of the filesystem now. |
2238 | */ | 2237 | */ |
2239 | 2238 | ||
2240 | root = iget(sb, EXT4_ROOT_INO); | 2239 | root = ext4_iget(sb, EXT4_ROOT_INO); |
2241 | sb->s_root = d_alloc_root(root); | 2240 | if (IS_ERR(root)) { |
2242 | if (!sb->s_root) { | ||
2243 | printk(KERN_ERR "EXT4-fs: get root inode failed\n"); | 2241 | printk(KERN_ERR "EXT4-fs: get root inode failed\n"); |
2244 | iput(root); | 2242 | ret = PTR_ERR(root); |
2245 | goto failed_mount4; | 2243 | goto failed_mount4; |
2246 | } | 2244 | } |
2247 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { | 2245 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { |
2248 | dput(sb->s_root); | 2246 | iput(root); |
2249 | sb->s_root = NULL; | ||
2250 | printk(KERN_ERR "EXT4-fs: corrupt root inode, run e2fsck\n"); | 2247 | printk(KERN_ERR "EXT4-fs: corrupt root inode, run e2fsck\n"); |
2251 | goto failed_mount4; | 2248 | goto failed_mount4; |
2252 | } | 2249 | } |
2250 | sb->s_root = d_alloc_root(root); | ||
2251 | if (!sb->s_root) { | ||
2252 | printk(KERN_ERR "EXT4-fs: get root dentry failed\n"); | ||
2253 | iput(root); | ||
2254 | ret = -ENOMEM; | ||
2255 | goto failed_mount4; | ||
2256 | } | ||
2253 | 2257 | ||
2254 | ext4_setup_super (sb, es, sb->s_flags & MS_RDONLY); | 2258 | ext4_setup_super (sb, es, sb->s_flags & MS_RDONLY); |
2255 | 2259 | ||
@@ -2330,7 +2334,7 @@ out_fail: | |||
2330 | sb->s_fs_info = NULL; | 2334 | sb->s_fs_info = NULL; |
2331 | kfree(sbi); | 2335 | kfree(sbi); |
2332 | lock_kernel(); | 2336 | lock_kernel(); |
2333 | return -EINVAL; | 2337 | return ret; |
2334 | } | 2338 | } |
2335 | 2339 | ||
2336 | /* | 2340 | /* |
@@ -2366,8 +2370,8 @@ static journal_t *ext4_get_journal(struct super_block *sb, | |||
2366 | * things happen if we iget() an unused inode, as the subsequent | 2370 | * things happen if we iget() an unused inode, as the subsequent |
2367 | * iput() will try to delete it. */ | 2371 | * iput() will try to delete it. */ |
2368 | 2372 | ||
2369 | journal_inode = iget(sb, journal_inum); | 2373 | journal_inode = ext4_iget(sb, journal_inum); |
2370 | if (!journal_inode) { | 2374 | if (IS_ERR(journal_inode)) { |
2371 | printk(KERN_ERR "EXT4-fs: no journal found.\n"); | 2375 | printk(KERN_ERR "EXT4-fs: no journal found.\n"); |
2372 | return NULL; | 2376 | return NULL; |
2373 | } | 2377 | } |
@@ -2380,7 +2384,7 @@ static journal_t *ext4_get_journal(struct super_block *sb, | |||
2380 | 2384 | ||
2381 | jbd_debug(2, "Journal inode found at %p: %Ld bytes\n", | 2385 | jbd_debug(2, "Journal inode found at %p: %Ld bytes\n", |
2382 | journal_inode, journal_inode->i_size); | 2386 | journal_inode, journal_inode->i_size); |
2383 | if (is_bad_inode(journal_inode) || !S_ISREG(journal_inode->i_mode)) { | 2387 | if (!S_ISREG(journal_inode->i_mode)) { |
2384 | printk(KERN_ERR "EXT4-fs: invalid journal inode.\n"); | 2388 | printk(KERN_ERR "EXT4-fs: invalid journal inode.\n"); |
2385 | iput(journal_inode); | 2389 | iput(journal_inode); |
2386 | return NULL; | 2390 | return NULL; |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 24c0aaa5ae80..085269e07fb3 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -634,8 +634,6 @@ static const struct super_operations fat_sops = { | |||
634 | .clear_inode = fat_clear_inode, | 634 | .clear_inode = fat_clear_inode, |
635 | .remount_fs = fat_remount, | 635 | .remount_fs = fat_remount, |
636 | 636 | ||
637 | .read_inode = make_bad_inode, | ||
638 | |||
639 | .show_options = fat_show_options, | 637 | .show_options = fat_show_options, |
640 | }; | 638 | }; |
641 | 639 | ||
@@ -663,8 +661,8 @@ static struct dentry *fat_fh_to_dentry(struct super_block *sb, | |||
663 | if (fh_len < 5 || fh_type != 3) | 661 | if (fh_len < 5 || fh_type != 3) |
664 | return NULL; | 662 | return NULL; |
665 | 663 | ||
666 | inode = iget(sb, fh[0]); | 664 | inode = ilookup(sb, fh[0]); |
667 | if (!inode || is_bad_inode(inode) || inode->i_generation != fh[1]) { | 665 | if (!inode || inode->i_generation != fh[1]) { |
668 | if (inode) | 666 | if (inode) |
669 | iput(inode); | 667 | iput(inode); |
670 | inode = NULL; | 668 | inode = NULL; |
@@ -760,7 +758,7 @@ static struct dentry *fat_get_parent(struct dentry *child) | |||
760 | inode = fat_build_inode(child->d_sb, de, i_pos); | 758 | inode = fat_build_inode(child->d_sb, de, i_pos); |
761 | brelse(bh); | 759 | brelse(bh); |
762 | if (IS_ERR(inode)) { | 760 | if (IS_ERR(inode)) { |
763 | parent = ERR_PTR(PTR_ERR(inode)); | 761 | parent = ERR_CAST(inode); |
764 | goto out; | 762 | goto out; |
765 | } | 763 | } |
766 | parent = d_alloc_anon(inode); | 764 | parent = d_alloc_anon(inode); |
diff --git a/fs/freevxfs/vxfs_extern.h b/fs/freevxfs/vxfs_extern.h index 91ccee8723f7..2b46064f66b2 100644 --- a/fs/freevxfs/vxfs_extern.h +++ b/fs/freevxfs/vxfs_extern.h | |||
@@ -58,7 +58,7 @@ extern struct inode * vxfs_get_fake_inode(struct super_block *, | |||
58 | extern void vxfs_put_fake_inode(struct inode *); | 58 | extern void vxfs_put_fake_inode(struct inode *); |
59 | extern struct vxfs_inode_info * vxfs_blkiget(struct super_block *, u_long, ino_t); | 59 | extern struct vxfs_inode_info * vxfs_blkiget(struct super_block *, u_long, ino_t); |
60 | extern struct vxfs_inode_info * vxfs_stiget(struct super_block *, ino_t); | 60 | extern struct vxfs_inode_info * vxfs_stiget(struct super_block *, ino_t); |
61 | extern void vxfs_read_inode(struct inode *); | 61 | extern struct inode * vxfs_iget(struct super_block *, ino_t); |
62 | extern void vxfs_clear_inode(struct inode *); | 62 | extern void vxfs_clear_inode(struct inode *); |
63 | 63 | ||
64 | /* vxfs_lookup.c */ | 64 | /* vxfs_lookup.c */ |
diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c index d1f7c5b5b3c3..ad88d2364bc2 100644 --- a/fs/freevxfs/vxfs_inode.c +++ b/fs/freevxfs/vxfs_inode.c | |||
@@ -129,7 +129,7 @@ fail: | |||
129 | * Description: | 129 | * Description: |
130 | * Search the for inode number @ino in the filesystem | 130 | * Search the for inode number @ino in the filesystem |
131 | * described by @sbp. Use the specified inode table (@ilistp). | 131 | * described by @sbp. Use the specified inode table (@ilistp). |
132 | * Returns the matching VxFS inode on success, else a NULL pointer. | 132 | * Returns the matching VxFS inode on success, else an error code. |
133 | */ | 133 | */ |
134 | static struct vxfs_inode_info * | 134 | static struct vxfs_inode_info * |
135 | __vxfs_iget(ino_t ino, struct inode *ilistp) | 135 | __vxfs_iget(ino_t ino, struct inode *ilistp) |
@@ -157,12 +157,12 @@ __vxfs_iget(ino_t ino, struct inode *ilistp) | |||
157 | } | 157 | } |
158 | 158 | ||
159 | printk(KERN_WARNING "vxfs: error on page %p\n", pp); | 159 | printk(KERN_WARNING "vxfs: error on page %p\n", pp); |
160 | return NULL; | 160 | return ERR_CAST(pp); |
161 | 161 | ||
162 | fail: | 162 | fail: |
163 | printk(KERN_WARNING "vxfs: unable to read inode %ld\n", (unsigned long)ino); | 163 | printk(KERN_WARNING "vxfs: unable to read inode %ld\n", (unsigned long)ino); |
164 | vxfs_put_page(pp); | 164 | vxfs_put_page(pp); |
165 | return NULL; | 165 | return ERR_PTR(-ENOMEM); |
166 | } | 166 | } |
167 | 167 | ||
168 | /** | 168 | /** |
@@ -178,7 +178,10 @@ fail: | |||
178 | struct vxfs_inode_info * | 178 | struct vxfs_inode_info * |
179 | vxfs_stiget(struct super_block *sbp, ino_t ino) | 179 | vxfs_stiget(struct super_block *sbp, ino_t ino) |
180 | { | 180 | { |
181 | return __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_stilist); | 181 | struct vxfs_inode_info *vip; |
182 | |||
183 | vip = __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_stilist); | ||
184 | return IS_ERR(vip) ? NULL : vip; | ||
182 | } | 185 | } |
183 | 186 | ||
184 | /** | 187 | /** |
@@ -282,23 +285,32 @@ vxfs_put_fake_inode(struct inode *ip) | |||
282 | } | 285 | } |
283 | 286 | ||
284 | /** | 287 | /** |
285 | * vxfs_read_inode - fill in inode information | 288 | * vxfs_iget - get an inode |
286 | * @ip: inode pointer to fill | 289 | * @sbp: the superblock to get the inode for |
290 | * @ino: the number of the inode to get | ||
287 | * | 291 | * |
288 | * Description: | 292 | * Description: |
289 | * vxfs_read_inode reads the disk inode for @ip and fills | 293 | * vxfs_read_inode creates an inode, reads the disk inode for @ino and fills |
290 | * in all relevant fields in @ip. | 294 | * in all relevant fields in the new inode. |
291 | */ | 295 | */ |
292 | void | 296 | struct inode * |
293 | vxfs_read_inode(struct inode *ip) | 297 | vxfs_iget(struct super_block *sbp, ino_t ino) |
294 | { | 298 | { |
295 | struct super_block *sbp = ip->i_sb; | ||
296 | struct vxfs_inode_info *vip; | 299 | struct vxfs_inode_info *vip; |
297 | const struct address_space_operations *aops; | 300 | const struct address_space_operations *aops; |
298 | ino_t ino = ip->i_ino; | 301 | struct inode *ip; |
299 | 302 | ||
300 | if (!(vip = __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_ilist))) | 303 | ip = iget_locked(sbp, ino); |
301 | return; | 304 | if (!ip) |
305 | return ERR_PTR(-ENOMEM); | ||
306 | if (!(ip->i_state & I_NEW)) | ||
307 | return ip; | ||
308 | |||
309 | vip = __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_ilist); | ||
310 | if (IS_ERR(vip)) { | ||
311 | iget_failed(ip); | ||
312 | return ERR_CAST(vip); | ||
313 | } | ||
302 | 314 | ||
303 | vxfs_iinit(ip, vip); | 315 | vxfs_iinit(ip, vip); |
304 | 316 | ||
@@ -323,7 +335,8 @@ vxfs_read_inode(struct inode *ip) | |||
323 | } else | 335 | } else |
324 | init_special_inode(ip, ip->i_mode, old_decode_dev(vip->vii_rdev)); | 336 | init_special_inode(ip, ip->i_mode, old_decode_dev(vip->vii_rdev)); |
325 | 337 | ||
326 | return; | 338 | unlock_new_inode(ip); |
339 | return ip; | ||
327 | } | 340 | } |
328 | 341 | ||
329 | /** | 342 | /** |
diff --git a/fs/freevxfs/vxfs_lookup.c b/fs/freevxfs/vxfs_lookup.c index bf86e5444ea6..aee049cb9f84 100644 --- a/fs/freevxfs/vxfs_lookup.c +++ b/fs/freevxfs/vxfs_lookup.c | |||
@@ -213,10 +213,10 @@ vxfs_lookup(struct inode *dip, struct dentry *dp, struct nameidata *nd) | |||
213 | lock_kernel(); | 213 | lock_kernel(); |
214 | ino = vxfs_inode_by_name(dip, dp); | 214 | ino = vxfs_inode_by_name(dip, dp); |
215 | if (ino) { | 215 | if (ino) { |
216 | ip = iget(dip->i_sb, ino); | 216 | ip = vxfs_iget(dip->i_sb, ino); |
217 | if (!ip) { | 217 | if (IS_ERR(ip)) { |
218 | unlock_kernel(); | 218 | unlock_kernel(); |
219 | return ERR_PTR(-EACCES); | 219 | return ERR_CAST(ip); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | unlock_kernel(); | 222 | unlock_kernel(); |
diff --git a/fs/freevxfs/vxfs_super.c b/fs/freevxfs/vxfs_super.c index 4f95572d2722..1dacda831577 100644 --- a/fs/freevxfs/vxfs_super.c +++ b/fs/freevxfs/vxfs_super.c | |||
@@ -60,7 +60,6 @@ static int vxfs_statfs(struct dentry *, struct kstatfs *); | |||
60 | static int vxfs_remount(struct super_block *, int *, char *); | 60 | static int vxfs_remount(struct super_block *, int *, char *); |
61 | 61 | ||
62 | static const struct super_operations vxfs_super_ops = { | 62 | static const struct super_operations vxfs_super_ops = { |
63 | .read_inode = vxfs_read_inode, | ||
64 | .clear_inode = vxfs_clear_inode, | 63 | .clear_inode = vxfs_clear_inode, |
65 | .put_super = vxfs_put_super, | 64 | .put_super = vxfs_put_super, |
66 | .statfs = vxfs_statfs, | 65 | .statfs = vxfs_statfs, |
@@ -153,6 +152,7 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) | |||
153 | struct buffer_head *bp = NULL; | 152 | struct buffer_head *bp = NULL; |
154 | u_long bsize; | 153 | u_long bsize; |
155 | struct inode *root; | 154 | struct inode *root; |
155 | int ret = -EINVAL; | ||
156 | 156 | ||
157 | sbp->s_flags |= MS_RDONLY; | 157 | sbp->s_flags |= MS_RDONLY; |
158 | 158 | ||
@@ -219,7 +219,11 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) | |||
219 | } | 219 | } |
220 | 220 | ||
221 | sbp->s_op = &vxfs_super_ops; | 221 | sbp->s_op = &vxfs_super_ops; |
222 | root = iget(sbp, VXFS_ROOT_INO); | 222 | root = vxfs_iget(sbp, VXFS_ROOT_INO); |
223 | if (IS_ERR(root)) { | ||
224 | ret = PTR_ERR(root); | ||
225 | goto out; | ||
226 | } | ||
223 | sbp->s_root = d_alloc_root(root); | 227 | sbp->s_root = d_alloc_root(root); |
224 | if (!sbp->s_root) { | 228 | if (!sbp->s_root) { |
225 | iput(root); | 229 | iput(root); |
@@ -236,7 +240,7 @@ out_free_ilist: | |||
236 | out: | 240 | out: |
237 | brelse(bp); | 241 | brelse(bp); |
238 | kfree(infp); | 242 | kfree(infp); |
239 | return -EINVAL; | 243 | return ret; |
240 | } | 244 | } |
241 | 245 | ||
242 | /* | 246 | /* |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index f56f91bd38be..7fb514b6d852 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -269,12 +269,12 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, | |||
269 | 269 | ||
270 | req = fuse_get_req(fc); | 270 | req = fuse_get_req(fc); |
271 | if (IS_ERR(req)) | 271 | if (IS_ERR(req)) |
272 | return ERR_PTR(PTR_ERR(req)); | 272 | return ERR_CAST(req); |
273 | 273 | ||
274 | forget_req = fuse_get_req(fc); | 274 | forget_req = fuse_get_req(fc); |
275 | if (IS_ERR(forget_req)) { | 275 | if (IS_ERR(forget_req)) { |
276 | fuse_put_request(fc, req); | 276 | fuse_put_request(fc, req); |
277 | return ERR_PTR(PTR_ERR(forget_req)); | 277 | return ERR_CAST(forget_req); |
278 | } | 278 | } |
279 | 279 | ||
280 | attr_version = fuse_get_attr_version(fc); | 280 | attr_version = fuse_get_attr_version(fc); |
@@ -1006,7 +1006,7 @@ static char *read_link(struct dentry *dentry) | |||
1006 | char *link; | 1006 | char *link; |
1007 | 1007 | ||
1008 | if (IS_ERR(req)) | 1008 | if (IS_ERR(req)) |
1009 | return ERR_PTR(PTR_ERR(req)); | 1009 | return ERR_CAST(req); |
1010 | 1010 | ||
1011 | link = (char *) __get_free_page(GFP_KERNEL); | 1011 | link = (char *) __get_free_page(GFP_KERNEL); |
1012 | if (!link) { | 1012 | if (!link) { |
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index c90f633d0b57..574707409bbf 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -76,11 +76,6 @@ static void fuse_destroy_inode(struct inode *inode) | |||
76 | kmem_cache_free(fuse_inode_cachep, inode); | 76 | kmem_cache_free(fuse_inode_cachep, inode); |
77 | } | 77 | } |
78 | 78 | ||
79 | static void fuse_read_inode(struct inode *inode) | ||
80 | { | ||
81 | /* No op */ | ||
82 | } | ||
83 | |||
84 | void fuse_send_forget(struct fuse_conn *fc, struct fuse_req *req, | 79 | void fuse_send_forget(struct fuse_conn *fc, struct fuse_req *req, |
85 | unsigned long nodeid, u64 nlookup) | 80 | unsigned long nodeid, u64 nlookup) |
86 | { | 81 | { |
@@ -515,7 +510,6 @@ static struct inode *get_root_inode(struct super_block *sb, unsigned mode) | |||
515 | static const struct super_operations fuse_super_operations = { | 510 | static const struct super_operations fuse_super_operations = { |
516 | .alloc_inode = fuse_alloc_inode, | 511 | .alloc_inode = fuse_alloc_inode, |
517 | .destroy_inode = fuse_destroy_inode, | 512 | .destroy_inode = fuse_destroy_inode, |
518 | .read_inode = fuse_read_inode, | ||
519 | .clear_inode = fuse_clear_inode, | 513 | .clear_inode = fuse_clear_inode, |
520 | .drop_inode = generic_delete_inode, | 514 | .drop_inode = generic_delete_inode, |
521 | .remount_fs = fuse_remount_fs, | 515 | .remount_fs = fuse_remount_fs, |
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 57e2ed932adc..c34709512b19 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c | |||
@@ -1498,7 +1498,7 @@ struct inode *gfs2_dir_search(struct inode *dir, const struct qstr *name) | |||
1498 | dent = gfs2_dirent_search(dir, name, gfs2_dirent_find, &bh); | 1498 | dent = gfs2_dirent_search(dir, name, gfs2_dirent_find, &bh); |
1499 | if (dent) { | 1499 | if (dent) { |
1500 | if (IS_ERR(dent)) | 1500 | if (IS_ERR(dent)) |
1501 | return ERR_PTR(PTR_ERR(dent)); | 1501 | return ERR_CAST(dent); |
1502 | inode = gfs2_inode_lookup(dir->i_sb, | 1502 | inode = gfs2_inode_lookup(dir->i_sb, |
1503 | be16_to_cpu(dent->de_type), | 1503 | be16_to_cpu(dent->de_type), |
1504 | be64_to_cpu(dent->de_inum.no_addr), | 1504 | be64_to_cpu(dent->de_inum.no_addr), |
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 80e09c50590a..7175a4d06435 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
@@ -334,7 +334,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, | |||
334 | gl->gl_state = LM_ST_UNLOCKED; | 334 | gl->gl_state = LM_ST_UNLOCKED; |
335 | gl->gl_demote_state = LM_ST_EXCLUSIVE; | 335 | gl->gl_demote_state = LM_ST_EXCLUSIVE; |
336 | gl->gl_hash = hash; | 336 | gl->gl_hash = hash; |
337 | gl->gl_owner_pid = 0; | 337 | gl->gl_owner_pid = NULL; |
338 | gl->gl_ip = 0; | 338 | gl->gl_ip = 0; |
339 | gl->gl_ops = glops; | 339 | gl->gl_ops = glops; |
340 | gl->gl_req_gh = NULL; | 340 | gl->gl_req_gh = NULL; |
@@ -399,7 +399,7 @@ void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, unsigned flags, | |||
399 | INIT_LIST_HEAD(&gh->gh_list); | 399 | INIT_LIST_HEAD(&gh->gh_list); |
400 | gh->gh_gl = gl; | 400 | gh->gh_gl = gl; |
401 | gh->gh_ip = (unsigned long)__builtin_return_address(0); | 401 | gh->gh_ip = (unsigned long)__builtin_return_address(0); |
402 | gh->gh_owner_pid = current->pid; | 402 | gh->gh_owner_pid = get_pid(task_pid(current)); |
403 | gh->gh_state = state; | 403 | gh->gh_state = state; |
404 | gh->gh_flags = flags; | 404 | gh->gh_flags = flags; |
405 | gh->gh_error = 0; | 405 | gh->gh_error = 0; |
@@ -433,6 +433,7 @@ void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder * | |||
433 | 433 | ||
434 | void gfs2_holder_uninit(struct gfs2_holder *gh) | 434 | void gfs2_holder_uninit(struct gfs2_holder *gh) |
435 | { | 435 | { |
436 | put_pid(gh->gh_owner_pid); | ||
436 | gfs2_glock_put(gh->gh_gl); | 437 | gfs2_glock_put(gh->gh_gl); |
437 | gh->gh_gl = NULL; | 438 | gh->gh_gl = NULL; |
438 | gh->gh_ip = 0; | 439 | gh->gh_ip = 0; |
@@ -631,7 +632,7 @@ static void gfs2_glmutex_lock(struct gfs2_glock *gl) | |||
631 | wait_on_holder(&gh); | 632 | wait_on_holder(&gh); |
632 | gfs2_holder_uninit(&gh); | 633 | gfs2_holder_uninit(&gh); |
633 | } else { | 634 | } else { |
634 | gl->gl_owner_pid = current->pid; | 635 | gl->gl_owner_pid = get_pid(task_pid(current)); |
635 | gl->gl_ip = (unsigned long)__builtin_return_address(0); | 636 | gl->gl_ip = (unsigned long)__builtin_return_address(0); |
636 | spin_unlock(&gl->gl_spin); | 637 | spin_unlock(&gl->gl_spin); |
637 | } | 638 | } |
@@ -652,7 +653,7 @@ static int gfs2_glmutex_trylock(struct gfs2_glock *gl) | |||
652 | if (test_and_set_bit(GLF_LOCK, &gl->gl_flags)) { | 653 | if (test_and_set_bit(GLF_LOCK, &gl->gl_flags)) { |
653 | acquired = 0; | 654 | acquired = 0; |
654 | } else { | 655 | } else { |
655 | gl->gl_owner_pid = current->pid; | 656 | gl->gl_owner_pid = get_pid(task_pid(current)); |
656 | gl->gl_ip = (unsigned long)__builtin_return_address(0); | 657 | gl->gl_ip = (unsigned long)__builtin_return_address(0); |
657 | } | 658 | } |
658 | spin_unlock(&gl->gl_spin); | 659 | spin_unlock(&gl->gl_spin); |
@@ -668,12 +669,17 @@ static int gfs2_glmutex_trylock(struct gfs2_glock *gl) | |||
668 | 669 | ||
669 | static void gfs2_glmutex_unlock(struct gfs2_glock *gl) | 670 | static void gfs2_glmutex_unlock(struct gfs2_glock *gl) |
670 | { | 671 | { |
672 | struct pid *pid; | ||
673 | |||
671 | spin_lock(&gl->gl_spin); | 674 | spin_lock(&gl->gl_spin); |
672 | clear_bit(GLF_LOCK, &gl->gl_flags); | 675 | clear_bit(GLF_LOCK, &gl->gl_flags); |
673 | gl->gl_owner_pid = 0; | 676 | pid = gl->gl_owner_pid; |
677 | gl->gl_owner_pid = NULL; | ||
674 | gl->gl_ip = 0; | 678 | gl->gl_ip = 0; |
675 | run_queue(gl); | 679 | run_queue(gl); |
676 | spin_unlock(&gl->gl_spin); | 680 | spin_unlock(&gl->gl_spin); |
681 | |||
682 | put_pid(pid); | ||
677 | } | 683 | } |
678 | 684 | ||
679 | /** | 685 | /** |
@@ -1045,7 +1051,7 @@ static int glock_wait_internal(struct gfs2_holder *gh) | |||
1045 | } | 1051 | } |
1046 | 1052 | ||
1047 | static inline struct gfs2_holder * | 1053 | static inline struct gfs2_holder * |
1048 | find_holder_by_owner(struct list_head *head, pid_t pid) | 1054 | find_holder_by_owner(struct list_head *head, struct pid *pid) |
1049 | { | 1055 | { |
1050 | struct gfs2_holder *gh; | 1056 | struct gfs2_holder *gh; |
1051 | 1057 | ||
@@ -1082,7 +1088,7 @@ static void add_to_queue(struct gfs2_holder *gh) | |||
1082 | struct gfs2_glock *gl = gh->gh_gl; | 1088 | struct gfs2_glock *gl = gh->gh_gl; |
1083 | struct gfs2_holder *existing; | 1089 | struct gfs2_holder *existing; |
1084 | 1090 | ||
1085 | BUG_ON(!gh->gh_owner_pid); | 1091 | BUG_ON(gh->gh_owner_pid == NULL); |
1086 | if (test_and_set_bit(HIF_WAIT, &gh->gh_iflags)) | 1092 | if (test_and_set_bit(HIF_WAIT, &gh->gh_iflags)) |
1087 | BUG(); | 1093 | BUG(); |
1088 | 1094 | ||
@@ -1092,12 +1098,14 @@ static void add_to_queue(struct gfs2_holder *gh) | |||
1092 | if (existing) { | 1098 | if (existing) { |
1093 | print_symbol(KERN_WARNING "original: %s\n", | 1099 | print_symbol(KERN_WARNING "original: %s\n", |
1094 | existing->gh_ip); | 1100 | existing->gh_ip); |
1095 | printk(KERN_INFO "pid : %d\n", existing->gh_owner_pid); | 1101 | printk(KERN_INFO "pid : %d\n", |
1102 | pid_nr(existing->gh_owner_pid)); | ||
1096 | printk(KERN_INFO "lock type : %d lock state : %d\n", | 1103 | printk(KERN_INFO "lock type : %d lock state : %d\n", |
1097 | existing->gh_gl->gl_name.ln_type, | 1104 | existing->gh_gl->gl_name.ln_type, |
1098 | existing->gh_gl->gl_state); | 1105 | existing->gh_gl->gl_state); |
1099 | print_symbol(KERN_WARNING "new: %s\n", gh->gh_ip); | 1106 | print_symbol(KERN_WARNING "new: %s\n", gh->gh_ip); |
1100 | printk(KERN_INFO "pid : %d\n", gh->gh_owner_pid); | 1107 | printk(KERN_INFO "pid : %d\n", |
1108 | pid_nr(gh->gh_owner_pid)); | ||
1101 | printk(KERN_INFO "lock type : %d lock state : %d\n", | 1109 | printk(KERN_INFO "lock type : %d lock state : %d\n", |
1102 | gl->gl_name.ln_type, gl->gl_state); | 1110 | gl->gl_name.ln_type, gl->gl_state); |
1103 | BUG(); | 1111 | BUG(); |
@@ -1798,8 +1806,9 @@ static int dump_holder(struct glock_iter *gi, char *str, | |||
1798 | 1806 | ||
1799 | print_dbg(gi, " %s\n", str); | 1807 | print_dbg(gi, " %s\n", str); |
1800 | if (gh->gh_owner_pid) { | 1808 | if (gh->gh_owner_pid) { |
1801 | print_dbg(gi, " owner = %ld ", (long)gh->gh_owner_pid); | 1809 | print_dbg(gi, " owner = %ld ", |
1802 | gh_owner = find_task_by_pid(gh->gh_owner_pid); | 1810 | (long)pid_nr(gh->gh_owner_pid)); |
1811 | gh_owner = pid_task(gh->gh_owner_pid, PIDTYPE_PID); | ||
1803 | if (gh_owner) | 1812 | if (gh_owner) |
1804 | print_dbg(gi, "(%s)\n", gh_owner->comm); | 1813 | print_dbg(gi, "(%s)\n", gh_owner->comm); |
1805 | else | 1814 | else |
@@ -1877,13 +1886,13 @@ static int dump_glock(struct glock_iter *gi, struct gfs2_glock *gl) | |||
1877 | print_dbg(gi, " gl_ref = %d\n", atomic_read(&gl->gl_ref)); | 1886 | print_dbg(gi, " gl_ref = %d\n", atomic_read(&gl->gl_ref)); |
1878 | print_dbg(gi, " gl_state = %u\n", gl->gl_state); | 1887 | print_dbg(gi, " gl_state = %u\n", gl->gl_state); |
1879 | if (gl->gl_owner_pid) { | 1888 | if (gl->gl_owner_pid) { |
1880 | gl_owner = find_task_by_pid(gl->gl_owner_pid); | 1889 | gl_owner = pid_task(gl->gl_owner_pid, PIDTYPE_PID); |
1881 | if (gl_owner) | 1890 | if (gl_owner) |
1882 | print_dbg(gi, " gl_owner = pid %d (%s)\n", | 1891 | print_dbg(gi, " gl_owner = pid %d (%s)\n", |
1883 | gl->gl_owner_pid, gl_owner->comm); | 1892 | pid_nr(gl->gl_owner_pid), gl_owner->comm); |
1884 | else | 1893 | else |
1885 | print_dbg(gi, " gl_owner = %d (ended)\n", | 1894 | print_dbg(gi, " gl_owner = %d (ended)\n", |
1886 | gl->gl_owner_pid); | 1895 | pid_nr(gl->gl_owner_pid)); |
1887 | } else | 1896 | } else |
1888 | print_dbg(gi, " gl_owner = -1\n"); | 1897 | print_dbg(gi, " gl_owner = -1\n"); |
1889 | print_dbg(gi, " gl_ip = %lu\n", gl->gl_ip); | 1898 | print_dbg(gi, " gl_ip = %lu\n", gl->gl_ip); |
diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index b16f604eea9f..2f9c6d136b37 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h | |||
@@ -36,11 +36,13 @@ static inline int gfs2_glock_is_locked_by_me(struct gfs2_glock *gl) | |||
36 | { | 36 | { |
37 | struct gfs2_holder *gh; | 37 | struct gfs2_holder *gh; |
38 | int locked = 0; | 38 | int locked = 0; |
39 | struct pid *pid; | ||
39 | 40 | ||
40 | /* Look in glock's list of holders for one with current task as owner */ | 41 | /* Look in glock's list of holders for one with current task as owner */ |
41 | spin_lock(&gl->gl_spin); | 42 | spin_lock(&gl->gl_spin); |
43 | pid = task_pid(current); | ||
42 | list_for_each_entry(gh, &gl->gl_holders, gh_list) { | 44 | list_for_each_entry(gh, &gl->gl_holders, gh_list) { |
43 | if (gh->gh_owner_pid == current->pid) { | 45 | if (gh->gh_owner_pid == pid) { |
44 | locked = 1; | 46 | locked = 1; |
45 | break; | 47 | break; |
46 | } | 48 | } |
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 513aaf0dc0ab..525dcae352d6 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -151,7 +151,7 @@ struct gfs2_holder { | |||
151 | struct list_head gh_list; | 151 | struct list_head gh_list; |
152 | 152 | ||
153 | struct gfs2_glock *gh_gl; | 153 | struct gfs2_glock *gh_gl; |
154 | pid_t gh_owner_pid; | 154 | struct pid *gh_owner_pid; |
155 | unsigned int gh_state; | 155 | unsigned int gh_state; |
156 | unsigned gh_flags; | 156 | unsigned gh_flags; |
157 | 157 | ||
@@ -182,7 +182,7 @@ struct gfs2_glock { | |||
182 | unsigned int gl_hash; | 182 | unsigned int gl_hash; |
183 | unsigned int gl_demote_state; /* state requested by remote node */ | 183 | unsigned int gl_demote_state; /* state requested by remote node */ |
184 | unsigned long gl_demote_time; /* time of first demote request */ | 184 | unsigned long gl_demote_time; /* time of first demote request */ |
185 | pid_t gl_owner_pid; | 185 | struct pid *gl_owner_pid; |
186 | unsigned long gl_ip; | 186 | unsigned long gl_ip; |
187 | struct list_head gl_holders; | 187 | struct list_head gl_holders; |
188 | struct list_head gl_waiters1; /* HIF_MUTEX */ | 188 | struct list_head gl_waiters1; /* HIF_MUTEX */ |
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 728d3169e7bd..37725ade3c51 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -240,7 +240,7 @@ fail_put: | |||
240 | ip->i_gl->gl_object = NULL; | 240 | ip->i_gl->gl_object = NULL; |
241 | gfs2_glock_put(ip->i_gl); | 241 | gfs2_glock_put(ip->i_gl); |
242 | fail: | 242 | fail: |
243 | iput(inode); | 243 | iget_failed(inode); |
244 | return ERR_PTR(error); | 244 | return ERR_PTR(error); |
245 | } | 245 | } |
246 | 246 | ||
diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index b9da62348a87..334c7f85351b 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c | |||
@@ -143,7 +143,7 @@ static struct dentry *gfs2_get_parent(struct dentry *child) | |||
143 | * have to return that as a(n invalid) pointer to dentry. | 143 | * have to return that as a(n invalid) pointer to dentry. |
144 | */ | 144 | */ |
145 | if (IS_ERR(inode)) | 145 | if (IS_ERR(inode)) |
146 | return ERR_PTR(PTR_ERR(inode)); | 146 | return ERR_CAST(inode); |
147 | 147 | ||
148 | dentry = d_alloc_anon(inode); | 148 | dentry = d_alloc_anon(inode); |
149 | if (!dentry) { | 149 | if (!dentry) { |
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index 9f71372c1757..e87412902bed 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c | |||
@@ -111,7 +111,7 @@ static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry, | |||
111 | 111 | ||
112 | inode = gfs2_lookupi(dir, &dentry->d_name, 0, nd); | 112 | inode = gfs2_lookupi(dir, &dentry->d_name, 0, nd); |
113 | if (inode && IS_ERR(inode)) | 113 | if (inode && IS_ERR(inode)) |
114 | return ERR_PTR(PTR_ERR(inode)); | 114 | return ERR_CAST(inode); |
115 | 115 | ||
116 | if (inode) { | 116 | if (inode) { |
117 | struct gfs2_glock *gl = GFS2_I(inode)->i_gl; | 117 | struct gfs2_glock *gl = GFS2_I(inode)->i_gl; |
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c index 050d29c0a5b5..bb5433608a42 100644 --- a/fs/hfsplus/btree.c +++ b/fs/hfsplus/btree.c | |||
@@ -22,6 +22,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id) | |||
22 | struct hfs_btree *tree; | 22 | struct hfs_btree *tree; |
23 | struct hfs_btree_header_rec *head; | 23 | struct hfs_btree_header_rec *head; |
24 | struct address_space *mapping; | 24 | struct address_space *mapping; |
25 | struct inode *inode; | ||
25 | struct page *page; | 26 | struct page *page; |
26 | unsigned int size; | 27 | unsigned int size; |
27 | 28 | ||
@@ -33,9 +34,10 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id) | |||
33 | spin_lock_init(&tree->hash_lock); | 34 | spin_lock_init(&tree->hash_lock); |
34 | tree->sb = sb; | 35 | tree->sb = sb; |
35 | tree->cnid = id; | 36 | tree->cnid = id; |
36 | tree->inode = iget(sb, id); | 37 | inode = hfsplus_iget(sb, id); |
37 | if (!tree->inode) | 38 | if (IS_ERR(inode)) |
38 | goto free_tree; | 39 | goto free_tree; |
40 | tree->inode = inode; | ||
39 | 41 | ||
40 | mapping = tree->inode->i_mapping; | 42 | mapping = tree->inode->i_mapping; |
41 | page = read_mapping_page(mapping, 0, NULL); | 43 | page = read_mapping_page(mapping, 0, NULL); |
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index 1955ee61251c..29683645fa0a 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c | |||
@@ -97,9 +97,9 @@ again: | |||
97 | goto fail; | 97 | goto fail; |
98 | } | 98 | } |
99 | hfs_find_exit(&fd); | 99 | hfs_find_exit(&fd); |
100 | inode = iget(dir->i_sb, cnid); | 100 | inode = hfsplus_iget(dir->i_sb, cnid); |
101 | if (!inode) | 101 | if (IS_ERR(inode)) |
102 | return ERR_PTR(-EACCES); | 102 | return ERR_CAST(inode); |
103 | if (S_ISREG(inode->i_mode)) | 103 | if (S_ISREG(inode->i_mode)) |
104 | HFSPLUS_I(inode).dev = linkid; | 104 | HFSPLUS_I(inode).dev = linkid; |
105 | out: | 105 | out: |
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h index d9f5eda6d039..d72d0a8b25aa 100644 --- a/fs/hfsplus/hfsplus_fs.h +++ b/fs/hfsplus/hfsplus_fs.h | |||
@@ -345,6 +345,9 @@ int hfsplus_parse_options(char *, struct hfsplus_sb_info *); | |||
345 | void hfsplus_fill_defaults(struct hfsplus_sb_info *); | 345 | void hfsplus_fill_defaults(struct hfsplus_sb_info *); |
346 | int hfsplus_show_options(struct seq_file *, struct vfsmount *); | 346 | int hfsplus_show_options(struct seq_file *, struct vfsmount *); |
347 | 347 | ||
348 | /* super.c */ | ||
349 | struct inode *hfsplus_iget(struct super_block *, unsigned long); | ||
350 | |||
348 | /* tables.c */ | 351 | /* tables.c */ |
349 | extern u16 hfsplus_case_fold_table[]; | 352 | extern u16 hfsplus_case_fold_table[]; |
350 | extern u16 hfsplus_decompose_table[]; | 353 | extern u16 hfsplus_decompose_table[]; |
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index ecf70dafb643..b0f9ad362d1d 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c | |||
@@ -20,11 +20,18 @@ static void hfsplus_destroy_inode(struct inode *inode); | |||
20 | 20 | ||
21 | #include "hfsplus_fs.h" | 21 | #include "hfsplus_fs.h" |
22 | 22 | ||
23 | static void hfsplus_read_inode(struct inode *inode) | 23 | struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino) |
24 | { | 24 | { |
25 | struct hfs_find_data fd; | 25 | struct hfs_find_data fd; |
26 | struct hfsplus_vh *vhdr; | 26 | struct hfsplus_vh *vhdr; |
27 | int err; | 27 | struct inode *inode; |
28 | long err = -EIO; | ||
29 | |||
30 | inode = iget_locked(sb, ino); | ||
31 | if (!inode) | ||
32 | return ERR_PTR(-ENOMEM); | ||
33 | if (!(inode->i_state & I_NEW)) | ||
34 | return inode; | ||
28 | 35 | ||
29 | INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list); | 36 | INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list); |
30 | init_MUTEX(&HFSPLUS_I(inode).extents_lock); | 37 | init_MUTEX(&HFSPLUS_I(inode).extents_lock); |
@@ -41,7 +48,7 @@ static void hfsplus_read_inode(struct inode *inode) | |||
41 | hfs_find_exit(&fd); | 48 | hfs_find_exit(&fd); |
42 | if (err) | 49 | if (err) |
43 | goto bad_inode; | 50 | goto bad_inode; |
44 | return; | 51 | goto done; |
45 | } | 52 | } |
46 | vhdr = HFSPLUS_SB(inode->i_sb).s_vhdr; | 53 | vhdr = HFSPLUS_SB(inode->i_sb).s_vhdr; |
47 | switch(inode->i_ino) { | 54 | switch(inode->i_ino) { |
@@ -70,10 +77,13 @@ static void hfsplus_read_inode(struct inode *inode) | |||
70 | goto bad_inode; | 77 | goto bad_inode; |
71 | } | 78 | } |
72 | 79 | ||
73 | return; | 80 | done: |
81 | unlock_new_inode(inode); | ||
82 | return inode; | ||
74 | 83 | ||
75 | bad_inode: | 84 | bad_inode: |
76 | make_bad_inode(inode); | 85 | iget_failed(inode); |
86 | return ERR_PTR(err); | ||
77 | } | 87 | } |
78 | 88 | ||
79 | static int hfsplus_write_inode(struct inode *inode, int unused) | 89 | static int hfsplus_write_inode(struct inode *inode, int unused) |
@@ -262,7 +272,6 @@ static int hfsplus_remount(struct super_block *sb, int *flags, char *data) | |||
262 | static const struct super_operations hfsplus_sops = { | 272 | static const struct super_operations hfsplus_sops = { |
263 | .alloc_inode = hfsplus_alloc_inode, | 273 | .alloc_inode = hfsplus_alloc_inode, |
264 | .destroy_inode = hfsplus_destroy_inode, | 274 | .destroy_inode = hfsplus_destroy_inode, |
265 | .read_inode = hfsplus_read_inode, | ||
266 | .write_inode = hfsplus_write_inode, | 275 | .write_inode = hfsplus_write_inode, |
267 | .clear_inode = hfsplus_clear_inode, | 276 | .clear_inode = hfsplus_clear_inode, |
268 | .put_super = hfsplus_put_super, | 277 | .put_super = hfsplus_put_super, |
@@ -278,7 +287,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
278 | struct hfsplus_sb_info *sbi; | 287 | struct hfsplus_sb_info *sbi; |
279 | hfsplus_cat_entry entry; | 288 | hfsplus_cat_entry entry; |
280 | struct hfs_find_data fd; | 289 | struct hfs_find_data fd; |
281 | struct inode *root; | 290 | struct inode *root, *inode; |
282 | struct qstr str; | 291 | struct qstr str; |
283 | struct nls_table *nls = NULL; | 292 | struct nls_table *nls = NULL; |
284 | int err = -EINVAL; | 293 | int err = -EINVAL; |
@@ -366,18 +375,25 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
366 | goto cleanup; | 375 | goto cleanup; |
367 | } | 376 | } |
368 | 377 | ||
369 | HFSPLUS_SB(sb).alloc_file = iget(sb, HFSPLUS_ALLOC_CNID); | 378 | inode = hfsplus_iget(sb, HFSPLUS_ALLOC_CNID); |
370 | if (!HFSPLUS_SB(sb).alloc_file) { | 379 | if (IS_ERR(inode)) { |
371 | printk(KERN_ERR "hfs: failed to load allocation file\n"); | 380 | printk(KERN_ERR "hfs: failed to load allocation file\n"); |
381 | err = PTR_ERR(inode); | ||
372 | goto cleanup; | 382 | goto cleanup; |
373 | } | 383 | } |
384 | HFSPLUS_SB(sb).alloc_file = inode; | ||
374 | 385 | ||
375 | /* Load the root directory */ | 386 | /* Load the root directory */ |
376 | root = iget(sb, HFSPLUS_ROOT_CNID); | 387 | root = hfsplus_iget(sb, HFSPLUS_ROOT_CNID); |
388 | if (IS_ERR(root)) { | ||
389 | printk(KERN_ERR "hfs: failed to load root directory\n"); | ||
390 | err = PTR_ERR(root); | ||
391 | goto cleanup; | ||
392 | } | ||
377 | sb->s_root = d_alloc_root(root); | 393 | sb->s_root = d_alloc_root(root); |
378 | if (!sb->s_root) { | 394 | if (!sb->s_root) { |
379 | printk(KERN_ERR "hfs: failed to load root directory\n"); | ||
380 | iput(root); | 395 | iput(root); |
396 | err = -ENOMEM; | ||
381 | goto cleanup; | 397 | goto cleanup; |
382 | } | 398 | } |
383 | sb->s_root->d_op = &hfsplus_dentry_operations; | 399 | sb->s_root->d_op = &hfsplus_dentry_operations; |
@@ -390,9 +406,12 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
390 | hfs_find_exit(&fd); | 406 | hfs_find_exit(&fd); |
391 | if (entry.type != cpu_to_be16(HFSPLUS_FOLDER)) | 407 | if (entry.type != cpu_to_be16(HFSPLUS_FOLDER)) |
392 | goto cleanup; | 408 | goto cleanup; |
393 | HFSPLUS_SB(sb).hidden_dir = iget(sb, be32_to_cpu(entry.folder.id)); | 409 | inode = hfsplus_iget(sb, be32_to_cpu(entry.folder.id)); |
394 | if (!HFSPLUS_SB(sb).hidden_dir) | 410 | if (IS_ERR(inode)) { |
411 | err = PTR_ERR(inode); | ||
395 | goto cleanup; | 412 | goto cleanup; |
413 | } | ||
414 | HFSPLUS_SB(sb).hidden_dir = inode; | ||
396 | } else | 415 | } else |
397 | hfs_find_exit(&fd); | 416 | hfs_find_exit(&fd); |
398 | 417 | ||
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 8966b050196e..2b9b35733aac 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c | |||
@@ -202,7 +202,7 @@ static char *follow_link(char *link) | |||
202 | return ERR_PTR(n); | 202 | return ERR_PTR(n); |
203 | } | 203 | } |
204 | 204 | ||
205 | static int read_inode(struct inode *ino) | 205 | static int hostfs_read_inode(struct inode *ino) |
206 | { | 206 | { |
207 | char *name; | 207 | char *name; |
208 | int err = 0; | 208 | int err = 0; |
@@ -233,6 +233,25 @@ static int read_inode(struct inode *ino) | |||
233 | return err; | 233 | return err; |
234 | } | 234 | } |
235 | 235 | ||
236 | static struct inode *hostfs_iget(struct super_block *sb) | ||
237 | { | ||
238 | struct inode *inode; | ||
239 | long ret; | ||
240 | |||
241 | inode = iget_locked(sb, 0); | ||
242 | if (!inode) | ||
243 | return ERR_PTR(-ENOMEM); | ||
244 | if (inode->i_state & I_NEW) { | ||
245 | ret = hostfs_read_inode(inode); | ||
246 | if (ret < 0) { | ||
247 | iget_failed(inode); | ||
248 | return ERR_PTR(ret); | ||
249 | } | ||
250 | unlock_new_inode(inode); | ||
251 | } | ||
252 | return inode; | ||
253 | } | ||
254 | |||
236 | int hostfs_statfs(struct dentry *dentry, struct kstatfs *sf) | 255 | int hostfs_statfs(struct dentry *dentry, struct kstatfs *sf) |
237 | { | 256 | { |
238 | /* | 257 | /* |
@@ -303,17 +322,11 @@ static void hostfs_destroy_inode(struct inode *inode) | |||
303 | kfree(HOSTFS_I(inode)); | 322 | kfree(HOSTFS_I(inode)); |
304 | } | 323 | } |
305 | 324 | ||
306 | static void hostfs_read_inode(struct inode *inode) | ||
307 | { | ||
308 | read_inode(inode); | ||
309 | } | ||
310 | |||
311 | static const struct super_operations hostfs_sbops = { | 325 | static const struct super_operations hostfs_sbops = { |
312 | .alloc_inode = hostfs_alloc_inode, | 326 | .alloc_inode = hostfs_alloc_inode, |
313 | .drop_inode = generic_delete_inode, | 327 | .drop_inode = generic_delete_inode, |
314 | .delete_inode = hostfs_delete_inode, | 328 | .delete_inode = hostfs_delete_inode, |
315 | .destroy_inode = hostfs_destroy_inode, | 329 | .destroy_inode = hostfs_destroy_inode, |
316 | .read_inode = hostfs_read_inode, | ||
317 | .statfs = hostfs_statfs, | 330 | .statfs = hostfs_statfs, |
318 | }; | 331 | }; |
319 | 332 | ||
@@ -571,10 +584,11 @@ int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
571 | char *name; | 584 | char *name; |
572 | int error, fd; | 585 | int error, fd; |
573 | 586 | ||
574 | error = -ENOMEM; | 587 | inode = hostfs_iget(dir->i_sb); |
575 | inode = iget(dir->i_sb, 0); | 588 | if (IS_ERR(inode)) { |
576 | if (inode == NULL) | 589 | error = PTR_ERR(inode); |
577 | goto out; | 590 | goto out; |
591 | } | ||
578 | 592 | ||
579 | error = init_inode(inode, dentry); | 593 | error = init_inode(inode, dentry); |
580 | if (error) | 594 | if (error) |
@@ -615,10 +629,11 @@ struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry, | |||
615 | char *name; | 629 | char *name; |
616 | int err; | 630 | int err; |
617 | 631 | ||
618 | err = -ENOMEM; | 632 | inode = hostfs_iget(ino->i_sb); |
619 | inode = iget(ino->i_sb, 0); | 633 | if (IS_ERR(inode)) { |
620 | if (inode == NULL) | 634 | err = PTR_ERR(inode); |
621 | goto out; | 635 | goto out; |
636 | } | ||
622 | 637 | ||
623 | err = init_inode(inode, dentry); | 638 | err = init_inode(inode, dentry); |
624 | if (err) | 639 | if (err) |
@@ -736,11 +751,13 @@ int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) | |||
736 | { | 751 | { |
737 | struct inode *inode; | 752 | struct inode *inode; |
738 | char *name; | 753 | char *name; |
739 | int err = -ENOMEM; | 754 | int err; |
740 | 755 | ||
741 | inode = iget(dir->i_sb, 0); | 756 | inode = hostfs_iget(dir->i_sb); |
742 | if (inode == NULL) | 757 | if (IS_ERR(inode)) { |
758 | err = PTR_ERR(inode); | ||
743 | goto out; | 759 | goto out; |
760 | } | ||
744 | 761 | ||
745 | err = init_inode(inode, dentry); | 762 | err = init_inode(inode, dentry); |
746 | if (err) | 763 | if (err) |
@@ -952,9 +969,11 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent) | |||
952 | 969 | ||
953 | sprintf(host_root_path, "%s/%s", root_ino, req_root); | 970 | sprintf(host_root_path, "%s/%s", root_ino, req_root); |
954 | 971 | ||
955 | root_inode = iget(sb, 0); | 972 | root_inode = hostfs_iget(sb); |
956 | if (root_inode == NULL) | 973 | if (IS_ERR(root_inode)) { |
974 | err = PTR_ERR(root_inode); | ||
957 | goto out_free; | 975 | goto out_free; |
976 | } | ||
958 | 977 | ||
959 | err = init_inode(root_inode, NULL); | 978 | err = init_inode(root_inode, NULL); |
960 | if (err) | 979 | if (err) |
@@ -972,7 +991,7 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent) | |||
972 | if (sb->s_root == NULL) | 991 | if (sb->s_root == NULL) |
973 | goto out_put; | 992 | goto out_put; |
974 | 993 | ||
975 | err = read_inode(root_inode); | 994 | err = hostfs_read_inode(root_inode); |
976 | if (err) { | 995 | if (err) { |
977 | /* No iput in this case because the dput does that for us */ | 996 | /* No iput in this case because the dput does that for us */ |
978 | dput(sb->s_root); | 997 | dput(sb->s_root); |
diff --git a/fs/hppfs/hppfs_kern.c b/fs/hppfs/hppfs_kern.c index affb7412125e..a1e1f0f61aa5 100644 --- a/fs/hppfs/hppfs_kern.c +++ b/fs/hppfs/hppfs_kern.c | |||
@@ -155,6 +155,20 @@ static void hppfs_read_inode(struct inode *ino) | |||
155 | ino->i_blocks = proc_ino->i_blocks; | 155 | ino->i_blocks = proc_ino->i_blocks; |
156 | } | 156 | } |
157 | 157 | ||
158 | static struct inode *hppfs_iget(struct super_block *sb) | ||
159 | { | ||
160 | struct inode *inode; | ||
161 | |||
162 | inode = iget_locked(sb, 0); | ||
163 | if (!inode) | ||
164 | return ERR_PTR(-ENOMEM); | ||
165 | if (inode->i_state & I_NEW) { | ||
166 | hppfs_read_inode(inode); | ||
167 | unlock_new_inode(inode); | ||
168 | } | ||
169 | return inode; | ||
170 | } | ||
171 | |||
158 | static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry, | 172 | static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry, |
159 | struct nameidata *nd) | 173 | struct nameidata *nd) |
160 | { | 174 | { |
@@ -190,9 +204,11 @@ static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry, | |||
190 | if(IS_ERR(proc_dentry)) | 204 | if(IS_ERR(proc_dentry)) |
191 | return(proc_dentry); | 205 | return(proc_dentry); |
192 | 206 | ||
193 | inode = iget(ino->i_sb, 0); | 207 | inode = hppfs_iget(ino->i_sb); |
194 | if(inode == NULL) | 208 | if (IS_ERR(inode)) { |
209 | err = PTR_ERR(inode); | ||
195 | goto out_dput; | 210 | goto out_dput; |
211 | } | ||
196 | 212 | ||
197 | err = init_inode(inode, proc_dentry); | 213 | err = init_inode(inode, proc_dentry); |
198 | if(err) | 214 | if(err) |
@@ -652,7 +668,6 @@ static void hppfs_destroy_inode(struct inode *inode) | |||
652 | static const struct super_operations hppfs_sbops = { | 668 | static const struct super_operations hppfs_sbops = { |
653 | .alloc_inode = hppfs_alloc_inode, | 669 | .alloc_inode = hppfs_alloc_inode, |
654 | .destroy_inode = hppfs_destroy_inode, | 670 | .destroy_inode = hppfs_destroy_inode, |
655 | .read_inode = hppfs_read_inode, | ||
656 | .delete_inode = hppfs_delete_inode, | 671 | .delete_inode = hppfs_delete_inode, |
657 | .statfs = hppfs_statfs, | 672 | .statfs = hppfs_statfs, |
658 | }; | 673 | }; |
@@ -745,9 +760,11 @@ static int hppfs_fill_super(struct super_block *sb, void *d, int silent) | |||
745 | sb->s_magic = HPPFS_SUPER_MAGIC; | 760 | sb->s_magic = HPPFS_SUPER_MAGIC; |
746 | sb->s_op = &hppfs_sbops; | 761 | sb->s_op = &hppfs_sbops; |
747 | 762 | ||
748 | root_inode = iget(sb, 0); | 763 | root_inode = hppfs_iget(sb); |
749 | if(root_inode == NULL) | 764 | if (IS_ERR(root_inode)) { |
765 | err = PTR_ERR(root_inode); | ||
750 | goto out; | 766 | goto out; |
767 | } | ||
751 | 768 | ||
752 | err = init_inode(root_inode, proc_sb->s_root); | 769 | err = init_inode(root_inode, proc_sb->s_root); |
753 | if(err) | 770 | if(err) |
diff --git a/fs/inode.c b/fs/inode.c index 276ffd6b6fdd..53245ffcf93d 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -928,8 +928,6 @@ EXPORT_SYMBOL(ilookup); | |||
928 | * @set: callback used to initialize a new struct inode | 928 | * @set: callback used to initialize a new struct inode |
929 | * @data: opaque data pointer to pass to @test and @set | 929 | * @data: opaque data pointer to pass to @test and @set |
930 | * | 930 | * |
931 | * This is iget() without the read_inode() portion of get_new_inode(). | ||
932 | * | ||
933 | * iget5_locked() uses ifind() to search for the inode specified by @hashval | 931 | * iget5_locked() uses ifind() to search for the inode specified by @hashval |
934 | * and @data in the inode cache and if present it is returned with an increased | 932 | * and @data in the inode cache and if present it is returned with an increased |
935 | * reference count. This is a generalized version of iget_locked() for file | 933 | * reference count. This is a generalized version of iget_locked() for file |
@@ -966,8 +964,6 @@ EXPORT_SYMBOL(iget5_locked); | |||
966 | * @sb: super block of file system | 964 | * @sb: super block of file system |
967 | * @ino: inode number to get | 965 | * @ino: inode number to get |
968 | * | 966 | * |
969 | * This is iget() without the read_inode() portion of get_new_inode_fast(). | ||
970 | * | ||
971 | * iget_locked() uses ifind_fast() to search for the inode specified by @ino in | 967 | * iget_locked() uses ifind_fast() to search for the inode specified by @ino in |
972 | * the inode cache and if present it is returned with an increased reference | 968 | * the inode cache and if present it is returned with an increased reference |
973 | * count. This is for file systems where the inode number is sufficient for | 969 | * count. This is for file systems where the inode number is sufficient for |
diff --git a/fs/ioctl.c b/fs/ioctl.c index c2a773e8620b..683002fefa55 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c | |||
@@ -12,12 +12,24 @@ | |||
12 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
13 | #include <linux/security.h> | 13 | #include <linux/security.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/uaccess.h> | ||
15 | 16 | ||
16 | #include <asm/uaccess.h> | ||
17 | #include <asm/ioctls.h> | 17 | #include <asm/ioctls.h> |
18 | 18 | ||
19 | static long do_ioctl(struct file *filp, unsigned int cmd, | 19 | /** |
20 | unsigned long arg) | 20 | * vfs_ioctl - call filesystem specific ioctl methods |
21 | * @filp: [in] open file to invoke ioctl method on | ||
22 | * @cmd: [in] ioctl command to execute | ||
23 | * @arg: [in/out] command-specific argument for ioctl | ||
24 | * | ||
25 | * Invokes filesystem specific ->unlocked_ioctl, if one exists; otherwise | ||
26 | * invokes * filesystem specific ->ioctl method. If neither method exists, | ||
27 | * returns -ENOTTY. | ||
28 | * | ||
29 | * Returns 0 on success, -errno on error. | ||
30 | */ | ||
31 | long vfs_ioctl(struct file *filp, unsigned int cmd, | ||
32 | unsigned long arg) | ||
21 | { | 33 | { |
22 | int error = -ENOTTY; | 34 | int error = -ENOTTY; |
23 | 35 | ||
@@ -40,123 +52,148 @@ static long do_ioctl(struct file *filp, unsigned int cmd, | |||
40 | return error; | 52 | return error; |
41 | } | 53 | } |
42 | 54 | ||
55 | static int ioctl_fibmap(struct file *filp, int __user *p) | ||
56 | { | ||
57 | struct address_space *mapping = filp->f_mapping; | ||
58 | int res, block; | ||
59 | |||
60 | /* do we support this mess? */ | ||
61 | if (!mapping->a_ops->bmap) | ||
62 | return -EINVAL; | ||
63 | if (!capable(CAP_SYS_RAWIO)) | ||
64 | return -EPERM; | ||
65 | res = get_user(block, p); | ||
66 | if (res) | ||
67 | return res; | ||
68 | lock_kernel(); | ||
69 | res = mapping->a_ops->bmap(mapping, block); | ||
70 | unlock_kernel(); | ||
71 | return put_user(res, p); | ||
72 | } | ||
73 | |||
43 | static int file_ioctl(struct file *filp, unsigned int cmd, | 74 | static int file_ioctl(struct file *filp, unsigned int cmd, |
44 | unsigned long arg) | 75 | unsigned long arg) |
45 | { | 76 | { |
46 | int error; | 77 | struct inode *inode = filp->f_path.dentry->d_inode; |
47 | int block; | ||
48 | struct inode * inode = filp->f_path.dentry->d_inode; | ||
49 | int __user *p = (int __user *)arg; | 78 | int __user *p = (int __user *)arg; |
50 | 79 | ||
51 | switch (cmd) { | 80 | switch (cmd) { |
52 | case FIBMAP: | 81 | case FIBMAP: |
53 | { | 82 | return ioctl_fibmap(filp, p); |
54 | struct address_space *mapping = filp->f_mapping; | 83 | case FIGETBSZ: |
55 | int res; | 84 | return put_user(inode->i_sb->s_blocksize, p); |
56 | /* do we support this mess? */ | 85 | case FIONREAD: |
57 | if (!mapping->a_ops->bmap) | 86 | return put_user(i_size_read(inode) - filp->f_pos, p); |
58 | return -EINVAL; | 87 | } |
59 | if (!capable(CAP_SYS_RAWIO)) | ||
60 | return -EPERM; | ||
61 | if ((error = get_user(block, p)) != 0) | ||
62 | return error; | ||
63 | 88 | ||
89 | return vfs_ioctl(filp, cmd, arg); | ||
90 | } | ||
91 | |||
92 | static int ioctl_fionbio(struct file *filp, int __user *argp) | ||
93 | { | ||
94 | unsigned int flag; | ||
95 | int on, error; | ||
96 | |||
97 | error = get_user(on, argp); | ||
98 | if (error) | ||
99 | return error; | ||
100 | flag = O_NONBLOCK; | ||
101 | #ifdef __sparc__ | ||
102 | /* SunOS compatibility item. */ | ||
103 | if (O_NONBLOCK != O_NDELAY) | ||
104 | flag |= O_NDELAY; | ||
105 | #endif | ||
106 | if (on) | ||
107 | filp->f_flags |= flag; | ||
108 | else | ||
109 | filp->f_flags &= ~flag; | ||
110 | return error; | ||
111 | } | ||
112 | |||
113 | static int ioctl_fioasync(unsigned int fd, struct file *filp, | ||
114 | int __user *argp) | ||
115 | { | ||
116 | unsigned int flag; | ||
117 | int on, error; | ||
118 | |||
119 | error = get_user(on, argp); | ||
120 | if (error) | ||
121 | return error; | ||
122 | flag = on ? FASYNC : 0; | ||
123 | |||
124 | /* Did FASYNC state change ? */ | ||
125 | if ((flag ^ filp->f_flags) & FASYNC) { | ||
126 | if (filp->f_op && filp->f_op->fasync) { | ||
64 | lock_kernel(); | 127 | lock_kernel(); |
65 | res = mapping->a_ops->bmap(mapping, block); | 128 | error = filp->f_op->fasync(fd, filp, on); |
66 | unlock_kernel(); | 129 | unlock_kernel(); |
67 | return put_user(res, p); | 130 | } else |
68 | } | 131 | error = -ENOTTY; |
69 | case FIGETBSZ: | ||
70 | return put_user(inode->i_sb->s_blocksize, p); | ||
71 | case FIONREAD: | ||
72 | return put_user(i_size_read(inode) - filp->f_pos, p); | ||
73 | } | 132 | } |
133 | if (error) | ||
134 | return error; | ||
74 | 135 | ||
75 | return do_ioctl(filp, cmd, arg); | 136 | if (on) |
137 | filp->f_flags |= FASYNC; | ||
138 | else | ||
139 | filp->f_flags &= ~FASYNC; | ||
140 | return error; | ||
76 | } | 141 | } |
77 | 142 | ||
78 | /* | 143 | /* |
79 | * When you add any new common ioctls to the switches above and below | 144 | * When you add any new common ioctls to the switches above and below |
80 | * please update compat_sys_ioctl() too. | 145 | * please update compat_sys_ioctl() too. |
81 | * | 146 | * |
82 | * vfs_ioctl() is not for drivers and not intended to be EXPORT_SYMBOL()'d. | 147 | * do_vfs_ioctl() is not for drivers and not intended to be EXPORT_SYMBOL()'d. |
83 | * It's just a simple helper for sys_ioctl and compat_sys_ioctl. | 148 | * It's just a simple helper for sys_ioctl and compat_sys_ioctl. |
84 | */ | 149 | */ |
85 | int vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned long arg) | 150 | int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, |
151 | unsigned long arg) | ||
86 | { | 152 | { |
87 | unsigned int flag; | 153 | int error = 0; |
88 | int on, error = 0; | 154 | int __user *argp = (int __user *)arg; |
89 | 155 | ||
90 | switch (cmd) { | 156 | switch (cmd) { |
91 | case FIOCLEX: | 157 | case FIOCLEX: |
92 | set_close_on_exec(fd, 1); | 158 | set_close_on_exec(fd, 1); |
93 | break; | 159 | break; |
94 | 160 | ||
95 | case FIONCLEX: | 161 | case FIONCLEX: |
96 | set_close_on_exec(fd, 0); | 162 | set_close_on_exec(fd, 0); |
97 | break; | 163 | break; |
98 | 164 | ||
99 | case FIONBIO: | 165 | case FIONBIO: |
100 | if ((error = get_user(on, (int __user *)arg)) != 0) | 166 | error = ioctl_fionbio(filp, argp); |
101 | break; | 167 | break; |
102 | flag = O_NONBLOCK; | 168 | |
103 | #ifdef __sparc__ | 169 | case FIOASYNC: |
104 | /* SunOS compatibility item. */ | 170 | error = ioctl_fioasync(fd, filp, argp); |
105 | if(O_NONBLOCK != O_NDELAY) | 171 | break; |
106 | flag |= O_NDELAY; | 172 | |
107 | #endif | 173 | case FIOQSIZE: |
108 | if (on) | 174 | if (S_ISDIR(filp->f_path.dentry->d_inode->i_mode) || |
109 | filp->f_flags |= flag; | 175 | S_ISREG(filp->f_path.dentry->d_inode->i_mode) || |
110 | else | 176 | S_ISLNK(filp->f_path.dentry->d_inode->i_mode)) { |
111 | filp->f_flags &= ~flag; | 177 | loff_t res = |
112 | break; | 178 | inode_get_bytes(filp->f_path.dentry->d_inode); |
113 | 179 | error = copy_to_user((loff_t __user *)arg, &res, | |
114 | case FIOASYNC: | 180 | sizeof(res)) ? -EFAULT : 0; |
115 | if ((error = get_user(on, (int __user *)arg)) != 0) | 181 | } else |
116 | break; | 182 | error = -ENOTTY; |
117 | flag = on ? FASYNC : 0; | 183 | break; |
118 | 184 | default: | |
119 | /* Did FASYNC state change ? */ | 185 | if (S_ISREG(filp->f_path.dentry->d_inode->i_mode)) |
120 | if ((flag ^ filp->f_flags) & FASYNC) { | 186 | error = file_ioctl(filp, cmd, arg); |
121 | if (filp->f_op && filp->f_op->fasync) { | 187 | else |
122 | lock_kernel(); | 188 | error = vfs_ioctl(filp, cmd, arg); |
123 | error = filp->f_op->fasync(fd, filp, on); | 189 | break; |
124 | unlock_kernel(); | ||
125 | } | ||
126 | else error = -ENOTTY; | ||
127 | } | ||
128 | if (error != 0) | ||
129 | break; | ||
130 | |||
131 | if (on) | ||
132 | filp->f_flags |= FASYNC; | ||
133 | else | ||
134 | filp->f_flags &= ~FASYNC; | ||
135 | break; | ||
136 | |||
137 | case FIOQSIZE: | ||
138 | if (S_ISDIR(filp->f_path.dentry->d_inode->i_mode) || | ||
139 | S_ISREG(filp->f_path.dentry->d_inode->i_mode) || | ||
140 | S_ISLNK(filp->f_path.dentry->d_inode->i_mode)) { | ||
141 | loff_t res = inode_get_bytes(filp->f_path.dentry->d_inode); | ||
142 | error = copy_to_user((loff_t __user *)arg, &res, sizeof(res)) ? -EFAULT : 0; | ||
143 | } | ||
144 | else | ||
145 | error = -ENOTTY; | ||
146 | break; | ||
147 | default: | ||
148 | if (S_ISREG(filp->f_path.dentry->d_inode->i_mode)) | ||
149 | error = file_ioctl(filp, cmd, arg); | ||
150 | else | ||
151 | error = do_ioctl(filp, cmd, arg); | ||
152 | break; | ||
153 | } | 190 | } |
154 | return error; | 191 | return error; |
155 | } | 192 | } |
156 | 193 | ||
157 | asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | 194 | asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
158 | { | 195 | { |
159 | struct file * filp; | 196 | struct file *filp; |
160 | int error = -EBADF; | 197 | int error = -EBADF; |
161 | int fput_needed; | 198 | int fput_needed; |
162 | 199 | ||
@@ -168,7 +205,7 @@ asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
168 | if (error) | 205 | if (error) |
169 | goto out_fput; | 206 | goto out_fput; |
170 | 207 | ||
171 | error = vfs_ioctl(filp, fd, cmd, arg); | 208 | error = do_vfs_ioctl(filp, fd, cmd, arg); |
172 | out_fput: | 209 | out_fput: |
173 | fput_light(filp, fput_needed); | 210 | fput_light(filp, fput_needed); |
174 | out: | 211 | out: |
diff --git a/fs/isofs/export.c b/fs/isofs/export.c index 29f9753ae5e5..bb219138331a 100644 --- a/fs/isofs/export.c +++ b/fs/isofs/export.c | |||
@@ -26,11 +26,9 @@ isofs_export_iget(struct super_block *sb, | |||
26 | if (block == 0) | 26 | if (block == 0) |
27 | return ERR_PTR(-ESTALE); | 27 | return ERR_PTR(-ESTALE); |
28 | inode = isofs_iget(sb, block, offset); | 28 | inode = isofs_iget(sb, block, offset); |
29 | if (inode == NULL) | 29 | if (IS_ERR(inode)) |
30 | return ERR_PTR(-ENOMEM); | 30 | return ERR_CAST(inode); |
31 | if (is_bad_inode(inode) | 31 | if (generation && inode->i_generation != generation) { |
32 | || (generation && inode->i_generation != generation)) | ||
33 | { | ||
34 | iput(inode); | 32 | iput(inode); |
35 | return ERR_PTR(-ESTALE); | 33 | return ERR_PTR(-ESTALE); |
36 | } | 34 | } |
@@ -110,8 +108,10 @@ static struct dentry *isofs_export_get_parent(struct dentry *child) | |||
110 | parent_inode = isofs_iget(child_inode->i_sb, | 108 | parent_inode = isofs_iget(child_inode->i_sb, |
111 | parent_block, | 109 | parent_block, |
112 | parent_offset); | 110 | parent_offset); |
113 | if (parent_inode == NULL) { | 111 | if (IS_ERR(parent_inode)) { |
114 | rv = ERR_PTR(-EACCES); | 112 | rv = ERR_CAST(parent_inode); |
113 | if (rv != ERR_PTR(-ENOMEM)) | ||
114 | rv = ERR_PTR(-EACCES); | ||
115 | goto out; | 115 | goto out; |
116 | } | 116 | } |
117 | 117 | ||
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 09e3d306e96f..875d37fb6c70 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c | |||
@@ -54,7 +54,7 @@ static void isofs_put_super(struct super_block *sb) | |||
54 | return; | 54 | return; |
55 | } | 55 | } |
56 | 56 | ||
57 | static void isofs_read_inode(struct inode *); | 57 | static int isofs_read_inode(struct inode *); |
58 | static int isofs_statfs (struct dentry *, struct kstatfs *); | 58 | static int isofs_statfs (struct dentry *, struct kstatfs *); |
59 | 59 | ||
60 | static struct kmem_cache *isofs_inode_cachep; | 60 | static struct kmem_cache *isofs_inode_cachep; |
@@ -107,7 +107,6 @@ static int isofs_remount(struct super_block *sb, int *flags, char *data) | |||
107 | static const struct super_operations isofs_sops = { | 107 | static const struct super_operations isofs_sops = { |
108 | .alloc_inode = isofs_alloc_inode, | 108 | .alloc_inode = isofs_alloc_inode, |
109 | .destroy_inode = isofs_destroy_inode, | 109 | .destroy_inode = isofs_destroy_inode, |
110 | .read_inode = isofs_read_inode, | ||
111 | .put_super = isofs_put_super, | 110 | .put_super = isofs_put_super, |
112 | .statfs = isofs_statfs, | 111 | .statfs = isofs_statfs, |
113 | .remount_fs = isofs_remount, | 112 | .remount_fs = isofs_remount, |
@@ -552,7 +551,7 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) | |||
552 | int joliet_level = 0; | 551 | int joliet_level = 0; |
553 | int iso_blknum, block; | 552 | int iso_blknum, block; |
554 | int orig_zonesize; | 553 | int orig_zonesize; |
555 | int table; | 554 | int table, error = -EINVAL; |
556 | unsigned int vol_desc_start; | 555 | unsigned int vol_desc_start; |
557 | 556 | ||
558 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 557 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
@@ -810,6 +809,8 @@ root_found: | |||
810 | * we then decide whether to use the Joliet descriptor. | 809 | * we then decide whether to use the Joliet descriptor. |
811 | */ | 810 | */ |
812 | inode = isofs_iget(s, sbi->s_firstdatazone, 0); | 811 | inode = isofs_iget(s, sbi->s_firstdatazone, 0); |
812 | if (IS_ERR(inode)) | ||
813 | goto out_no_root; | ||
813 | 814 | ||
814 | /* | 815 | /* |
815 | * If this disk has both Rock Ridge and Joliet on it, then we | 816 | * If this disk has both Rock Ridge and Joliet on it, then we |
@@ -829,6 +830,8 @@ root_found: | |||
829 | "ISOFS: changing to secondary root\n"); | 830 | "ISOFS: changing to secondary root\n"); |
830 | iput(inode); | 831 | iput(inode); |
831 | inode = isofs_iget(s, sbi->s_firstdatazone, 0); | 832 | inode = isofs_iget(s, sbi->s_firstdatazone, 0); |
833 | if (IS_ERR(inode)) | ||
834 | goto out_no_root; | ||
832 | } | 835 | } |
833 | } | 836 | } |
834 | 837 | ||
@@ -842,8 +845,6 @@ root_found: | |||
842 | sbi->s_joliet_level = joliet_level; | 845 | sbi->s_joliet_level = joliet_level; |
843 | 846 | ||
844 | /* check the root inode */ | 847 | /* check the root inode */ |
845 | if (!inode) | ||
846 | goto out_no_root; | ||
847 | if (!inode->i_op) | 848 | if (!inode->i_op) |
848 | goto out_bad_root; | 849 | goto out_bad_root; |
849 | 850 | ||
@@ -876,11 +877,14 @@ root_found: | |||
876 | */ | 877 | */ |
877 | out_bad_root: | 878 | out_bad_root: |
878 | printk(KERN_WARNING "%s: root inode not initialized\n", __func__); | 879 | printk(KERN_WARNING "%s: root inode not initialized\n", __func__); |
879 | goto out_iput; | ||
880 | out_no_root: | ||
881 | printk(KERN_WARNING "%s: get root inode failed\n", __func__); | ||
882 | out_iput: | 880 | out_iput: |
883 | iput(inode); | 881 | iput(inode); |
882 | goto out_no_inode; | ||
883 | out_no_root: | ||
884 | error = PTR_ERR(inode); | ||
885 | if (error != -ENOMEM) | ||
886 | printk(KERN_WARNING "%s: get root inode failed\n", __func__); | ||
887 | out_no_inode: | ||
884 | #ifdef CONFIG_JOLIET | 888 | #ifdef CONFIG_JOLIET |
885 | if (sbi->s_nls_iocharset) | 889 | if (sbi->s_nls_iocharset) |
886 | unload_nls(sbi->s_nls_iocharset); | 890 | unload_nls(sbi->s_nls_iocharset); |
@@ -908,7 +912,7 @@ out_freesbi: | |||
908 | kfree(opt.iocharset); | 912 | kfree(opt.iocharset); |
909 | kfree(sbi); | 913 | kfree(sbi); |
910 | s->s_fs_info = NULL; | 914 | s->s_fs_info = NULL; |
911 | return -EINVAL; | 915 | return error; |
912 | } | 916 | } |
913 | 917 | ||
914 | static int isofs_statfs (struct dentry *dentry, struct kstatfs *buf) | 918 | static int isofs_statfs (struct dentry *dentry, struct kstatfs *buf) |
@@ -930,7 +934,7 @@ static int isofs_statfs (struct dentry *dentry, struct kstatfs *buf) | |||
930 | /* | 934 | /* |
931 | * Get a set of blocks; filling in buffer_heads if already allocated | 935 | * Get a set of blocks; filling in buffer_heads if already allocated |
932 | * or getblk() if they are not. Returns the number of blocks inserted | 936 | * or getblk() if they are not. Returns the number of blocks inserted |
933 | * (0 == error.) | 937 | * (-ve == error.) |
934 | */ | 938 | */ |
935 | int isofs_get_blocks(struct inode *inode, sector_t iblock_s, | 939 | int isofs_get_blocks(struct inode *inode, sector_t iblock_s, |
936 | struct buffer_head **bh, unsigned long nblocks) | 940 | struct buffer_head **bh, unsigned long nblocks) |
@@ -940,11 +944,12 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s, | |||
940 | unsigned int firstext; | 944 | unsigned int firstext; |
941 | unsigned long nextblk, nextoff; | 945 | unsigned long nextblk, nextoff; |
942 | long iblock = (long)iblock_s; | 946 | long iblock = (long)iblock_s; |
943 | int section, rv; | 947 | int section, rv, error; |
944 | struct iso_inode_info *ei = ISOFS_I(inode); | 948 | struct iso_inode_info *ei = ISOFS_I(inode); |
945 | 949 | ||
946 | lock_kernel(); | 950 | lock_kernel(); |
947 | 951 | ||
952 | error = -EIO; | ||
948 | rv = 0; | 953 | rv = 0; |
949 | if (iblock < 0 || iblock != iblock_s) { | 954 | if (iblock < 0 || iblock != iblock_s) { |
950 | printk(KERN_DEBUG "%s: block number too large\n", __func__); | 955 | printk(KERN_DEBUG "%s: block number too large\n", __func__); |
@@ -983,8 +988,10 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s, | |||
983 | 988 | ||
984 | offset += sect_size; | 989 | offset += sect_size; |
985 | ninode = isofs_iget(inode->i_sb, nextblk, nextoff); | 990 | ninode = isofs_iget(inode->i_sb, nextblk, nextoff); |
986 | if (!ninode) | 991 | if (IS_ERR(ninode)) { |
992 | error = PTR_ERR(ninode); | ||
987 | goto abort; | 993 | goto abort; |
994 | } | ||
988 | firstext = ISOFS_I(ninode)->i_first_extent; | 995 | firstext = ISOFS_I(ninode)->i_first_extent; |
989 | sect_size = ISOFS_I(ninode)->i_section_size >> ISOFS_BUFFER_BITS(ninode); | 996 | sect_size = ISOFS_I(ninode)->i_section_size >> ISOFS_BUFFER_BITS(ninode); |
990 | nextblk = ISOFS_I(ninode)->i_next_section_block; | 997 | nextblk = ISOFS_I(ninode)->i_next_section_block; |
@@ -1015,9 +1022,10 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s, | |||
1015 | rv++; | 1022 | rv++; |
1016 | } | 1023 | } |
1017 | 1024 | ||
1025 | error = 0; | ||
1018 | abort: | 1026 | abort: |
1019 | unlock_kernel(); | 1027 | unlock_kernel(); |
1020 | return rv; | 1028 | return rv != 0 ? rv : error; |
1021 | } | 1029 | } |
1022 | 1030 | ||
1023 | /* | 1031 | /* |
@@ -1026,12 +1034,15 @@ abort: | |||
1026 | static int isofs_get_block(struct inode *inode, sector_t iblock, | 1034 | static int isofs_get_block(struct inode *inode, sector_t iblock, |
1027 | struct buffer_head *bh_result, int create) | 1035 | struct buffer_head *bh_result, int create) |
1028 | { | 1036 | { |
1037 | int ret; | ||
1038 | |||
1029 | if (create) { | 1039 | if (create) { |
1030 | printk(KERN_DEBUG "%s: Kernel tries to allocate a block\n", __func__); | 1040 | printk(KERN_DEBUG "%s: Kernel tries to allocate a block\n", __func__); |
1031 | return -EROFS; | 1041 | return -EROFS; |
1032 | } | 1042 | } |
1033 | 1043 | ||
1034 | return isofs_get_blocks(inode, iblock, &bh_result, 1) ? 0 : -EIO; | 1044 | ret = isofs_get_blocks(inode, iblock, &bh_result, 1); |
1045 | return ret < 0 ? ret : 0; | ||
1035 | } | 1046 | } |
1036 | 1047 | ||
1037 | static int isofs_bmap(struct inode *inode, sector_t block) | 1048 | static int isofs_bmap(struct inode *inode, sector_t block) |
@@ -1186,7 +1197,7 @@ out_toomany: | |||
1186 | goto out; | 1197 | goto out; |
1187 | } | 1198 | } |
1188 | 1199 | ||
1189 | static void isofs_read_inode(struct inode *inode) | 1200 | static int isofs_read_inode(struct inode *inode) |
1190 | { | 1201 | { |
1191 | struct super_block *sb = inode->i_sb; | 1202 | struct super_block *sb = inode->i_sb; |
1192 | struct isofs_sb_info *sbi = ISOFS_SB(sb); | 1203 | struct isofs_sb_info *sbi = ISOFS_SB(sb); |
@@ -1199,6 +1210,7 @@ static void isofs_read_inode(struct inode *inode) | |||
1199 | unsigned int de_len; | 1210 | unsigned int de_len; |
1200 | unsigned long offset; | 1211 | unsigned long offset; |
1201 | struct iso_inode_info *ei = ISOFS_I(inode); | 1212 | struct iso_inode_info *ei = ISOFS_I(inode); |
1213 | int ret = -EIO; | ||
1202 | 1214 | ||
1203 | block = ei->i_iget5_block; | 1215 | block = ei->i_iget5_block; |
1204 | bh = sb_bread(inode->i_sb, block); | 1216 | bh = sb_bread(inode->i_sb, block); |
@@ -1216,6 +1228,7 @@ static void isofs_read_inode(struct inode *inode) | |||
1216 | tmpde = kmalloc(de_len, GFP_KERNEL); | 1228 | tmpde = kmalloc(de_len, GFP_KERNEL); |
1217 | if (tmpde == NULL) { | 1229 | if (tmpde == NULL) { |
1218 | printk(KERN_INFO "%s: out of memory\n", __func__); | 1230 | printk(KERN_INFO "%s: out of memory\n", __func__); |
1231 | ret = -ENOMEM; | ||
1219 | goto fail; | 1232 | goto fail; |
1220 | } | 1233 | } |
1221 | memcpy(tmpde, bh->b_data + offset, frag1); | 1234 | memcpy(tmpde, bh->b_data + offset, frag1); |
@@ -1259,8 +1272,10 @@ static void isofs_read_inode(struct inode *inode) | |||
1259 | 1272 | ||
1260 | ei->i_section_size = isonum_733(de->size); | 1273 | ei->i_section_size = isonum_733(de->size); |
1261 | if (de->flags[-high_sierra] & 0x80) { | 1274 | if (de->flags[-high_sierra] & 0x80) { |
1262 | if(isofs_read_level3_size(inode)) | 1275 | ret = isofs_read_level3_size(inode); |
1276 | if (ret < 0) | ||
1263 | goto fail; | 1277 | goto fail; |
1278 | ret = -EIO; | ||
1264 | } else { | 1279 | } else { |
1265 | ei->i_next_section_block = 0; | 1280 | ei->i_next_section_block = 0; |
1266 | ei->i_next_section_offset = 0; | 1281 | ei->i_next_section_offset = 0; |
@@ -1346,16 +1361,16 @@ static void isofs_read_inode(struct inode *inode) | |||
1346 | /* XXX - parse_rock_ridge_inode() had already set i_rdev. */ | 1361 | /* XXX - parse_rock_ridge_inode() had already set i_rdev. */ |
1347 | init_special_inode(inode, inode->i_mode, inode->i_rdev); | 1362 | init_special_inode(inode, inode->i_mode, inode->i_rdev); |
1348 | 1363 | ||
1364 | ret = 0; | ||
1349 | out: | 1365 | out: |
1350 | kfree(tmpde); | 1366 | kfree(tmpde); |
1351 | if (bh) | 1367 | if (bh) |
1352 | brelse(bh); | 1368 | brelse(bh); |
1353 | return; | 1369 | return ret; |
1354 | 1370 | ||
1355 | out_badread: | 1371 | out_badread: |
1356 | printk(KERN_WARNING "ISOFS: unable to read i-node block\n"); | 1372 | printk(KERN_WARNING "ISOFS: unable to read i-node block\n"); |
1357 | fail: | 1373 | fail: |
1358 | make_bad_inode(inode); | ||
1359 | goto out; | 1374 | goto out; |
1360 | } | 1375 | } |
1361 | 1376 | ||
@@ -1394,9 +1409,10 @@ struct inode *isofs_iget(struct super_block *sb, | |||
1394 | unsigned long hashval; | 1409 | unsigned long hashval; |
1395 | struct inode *inode; | 1410 | struct inode *inode; |
1396 | struct isofs_iget5_callback_data data; | 1411 | struct isofs_iget5_callback_data data; |
1412 | long ret; | ||
1397 | 1413 | ||
1398 | if (offset >= 1ul << sb->s_blocksize_bits) | 1414 | if (offset >= 1ul << sb->s_blocksize_bits) |
1399 | return NULL; | 1415 | return ERR_PTR(-EINVAL); |
1400 | 1416 | ||
1401 | data.block = block; | 1417 | data.block = block; |
1402 | data.offset = offset; | 1418 | data.offset = offset; |
@@ -1406,9 +1422,17 @@ struct inode *isofs_iget(struct super_block *sb, | |||
1406 | inode = iget5_locked(sb, hashval, &isofs_iget5_test, | 1422 | inode = iget5_locked(sb, hashval, &isofs_iget5_test, |
1407 | &isofs_iget5_set, &data); | 1423 | &isofs_iget5_set, &data); |
1408 | 1424 | ||
1409 | if (inode && (inode->i_state & I_NEW)) { | 1425 | if (!inode) |
1410 | sb->s_op->read_inode(inode); | 1426 | return ERR_PTR(-ENOMEM); |
1411 | unlock_new_inode(inode); | 1427 | |
1428 | if (inode->i_state & I_NEW) { | ||
1429 | ret = isofs_read_inode(inode); | ||
1430 | if (ret < 0) { | ||
1431 | iget_failed(inode); | ||
1432 | inode = ERR_PTR(ret); | ||
1433 | } else { | ||
1434 | unlock_new_inode(inode); | ||
1435 | } | ||
1412 | } | 1436 | } |
1413 | 1437 | ||
1414 | return inode; | 1438 | return inode; |
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c index e2b4dad39ca9..344b247bc29a 100644 --- a/fs/isofs/namei.c +++ b/fs/isofs/namei.c | |||
@@ -179,9 +179,9 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam | |||
179 | inode = NULL; | 179 | inode = NULL; |
180 | if (found) { | 180 | if (found) { |
181 | inode = isofs_iget(dir->i_sb, block, offset); | 181 | inode = isofs_iget(dir->i_sb, block, offset); |
182 | if (!inode) { | 182 | if (IS_ERR(inode)) { |
183 | unlock_kernel(); | 183 | unlock_kernel(); |
184 | return ERR_PTR(-EACCES); | 184 | return ERR_CAST(inode); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | unlock_kernel(); | 187 | unlock_kernel(); |
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c index f3a1db3098de..6bd48f0a7047 100644 --- a/fs/isofs/rock.c +++ b/fs/isofs/rock.c | |||
@@ -474,8 +474,10 @@ repeat: | |||
474 | isofs_iget(inode->i_sb, | 474 | isofs_iget(inode->i_sb, |
475 | ISOFS_I(inode)->i_first_extent, | 475 | ISOFS_I(inode)->i_first_extent, |
476 | 0); | 476 | 0); |
477 | if (!reloc) | 477 | if (IS_ERR(reloc)) { |
478 | ret = PTR_ERR(reloc); | ||
478 | goto out; | 479 | goto out; |
480 | } | ||
479 | inode->i_mode = reloc->i_mode; | 481 | inode->i_mode = reloc->i_mode; |
480 | inode->i_nlink = reloc->i_nlink; | 482 | inode->i_nlink = reloc->i_nlink; |
481 | inode->i_uid = reloc->i_uid; | 483 | inode->i_uid = reloc->i_uid; |
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c index 77fc5838609c..4c80404a9aba 100644 --- a/fs/jffs2/acl.c +++ b/fs/jffs2/acl.c | |||
@@ -176,7 +176,7 @@ static void jffs2_iset_acl(struct inode *inode, struct posix_acl **i_acl, struct | |||
176 | spin_unlock(&inode->i_lock); | 176 | spin_unlock(&inode->i_lock); |
177 | } | 177 | } |
178 | 178 | ||
179 | struct posix_acl *jffs2_get_acl(struct inode *inode, int type) | 179 | static struct posix_acl *jffs2_get_acl(struct inode *inode, int type) |
180 | { | 180 | { |
181 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); | 181 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); |
182 | struct posix_acl *acl; | 182 | struct posix_acl *acl; |
@@ -345,8 +345,10 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode) | |||
345 | if (!clone) | 345 | if (!clone) |
346 | return -ENOMEM; | 346 | return -ENOMEM; |
347 | rc = posix_acl_create_masq(clone, (mode_t *)i_mode); | 347 | rc = posix_acl_create_masq(clone, (mode_t *)i_mode); |
348 | if (rc < 0) | 348 | if (rc < 0) { |
349 | posix_acl_release(clone); | ||
349 | return rc; | 350 | return rc; |
351 | } | ||
350 | if (rc > 0) | 352 | if (rc > 0) |
351 | jffs2_iset_acl(inode, &f->i_acl_access, clone); | 353 | jffs2_iset_acl(inode, &f->i_acl_access, clone); |
352 | 354 | ||
diff --git a/fs/jffs2/acl.h b/fs/jffs2/acl.h index 76c6ebd1acd9..0bb7f003fd80 100644 --- a/fs/jffs2/acl.h +++ b/fs/jffs2/acl.h | |||
@@ -28,7 +28,6 @@ struct jffs2_acl_header { | |||
28 | 28 | ||
29 | #define JFFS2_ACL_NOT_CACHED ((void *)-1) | 29 | #define JFFS2_ACL_NOT_CACHED ((void *)-1) |
30 | 30 | ||
31 | extern struct posix_acl *jffs2_get_acl(struct inode *inode, int type); | ||
32 | extern int jffs2_permission(struct inode *, int, struct nameidata *); | 31 | extern int jffs2_permission(struct inode *, int, struct nameidata *); |
33 | extern int jffs2_acl_chmod(struct inode *); | 32 | extern int jffs2_acl_chmod(struct inode *); |
34 | extern int jffs2_init_acl_pre(struct inode *, struct inode *, int *); | 33 | extern int jffs2_init_acl_pre(struct inode *, struct inode *, int *); |
@@ -40,7 +39,6 @@ extern struct xattr_handler jffs2_acl_default_xattr_handler; | |||
40 | 39 | ||
41 | #else | 40 | #else |
42 | 41 | ||
43 | #define jffs2_get_acl(inode, type) (NULL) | ||
44 | #define jffs2_permission (NULL) | 42 | #define jffs2_permission (NULL) |
45 | #define jffs2_acl_chmod(inode) (0) | 43 | #define jffs2_acl_chmod(inode) (0) |
46 | #define jffs2_init_acl_pre(dir_i,inode,mode) (0) | 44 | #define jffs2_init_acl_pre(dir_i,inode,mode) (0) |
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index 787e392ffd41..f948f7e6ec82 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c | |||
@@ -101,10 +101,10 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, | |||
101 | ino = fd->ino; | 101 | ino = fd->ino; |
102 | up(&dir_f->sem); | 102 | up(&dir_f->sem); |
103 | if (ino) { | 103 | if (ino) { |
104 | inode = iget(dir_i->i_sb, ino); | 104 | inode = jffs2_iget(dir_i->i_sb, ino); |
105 | if (!inode) { | 105 | if (IS_ERR(inode)) { |
106 | printk(KERN_WARNING "iget() failed for ino #%u\n", ino); | 106 | printk(KERN_WARNING "iget() failed for ino #%u\n", ino); |
107 | return (ERR_PTR(-EIO)); | 107 | return ERR_CAST(inode); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index d2e06f7ea96f..e26ea78c7892 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c | |||
@@ -97,11 +97,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
97 | ri->gid = cpu_to_je16((ivalid & ATTR_GID)?iattr->ia_gid:inode->i_gid); | 97 | ri->gid = cpu_to_je16((ivalid & ATTR_GID)?iattr->ia_gid:inode->i_gid); |
98 | 98 | ||
99 | if (ivalid & ATTR_MODE) | 99 | if (ivalid & ATTR_MODE) |
100 | if (iattr->ia_mode & S_ISGID && | 100 | ri->mode = cpu_to_jemode(iattr->ia_mode); |
101 | !in_group_p(je16_to_cpu(ri->gid)) && !capable(CAP_FSETID)) | ||
102 | ri->mode = cpu_to_jemode(iattr->ia_mode & ~S_ISGID); | ||
103 | else | ||
104 | ri->mode = cpu_to_jemode(iattr->ia_mode); | ||
105 | else | 101 | else |
106 | ri->mode = cpu_to_jemode(inode->i_mode); | 102 | ri->mode = cpu_to_jemode(inode->i_mode); |
107 | 103 | ||
@@ -230,16 +226,23 @@ void jffs2_clear_inode (struct inode *inode) | |||
230 | jffs2_do_clear_inode(c, f); | 226 | jffs2_do_clear_inode(c, f); |
231 | } | 227 | } |
232 | 228 | ||
233 | void jffs2_read_inode (struct inode *inode) | 229 | struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) |
234 | { | 230 | { |
235 | struct jffs2_inode_info *f; | 231 | struct jffs2_inode_info *f; |
236 | struct jffs2_sb_info *c; | 232 | struct jffs2_sb_info *c; |
237 | struct jffs2_raw_inode latest_node; | 233 | struct jffs2_raw_inode latest_node; |
238 | union jffs2_device_node jdev; | 234 | union jffs2_device_node jdev; |
235 | struct inode *inode; | ||
239 | dev_t rdev = 0; | 236 | dev_t rdev = 0; |
240 | int ret; | 237 | int ret; |
241 | 238 | ||
242 | D1(printk(KERN_DEBUG "jffs2_read_inode(): inode->i_ino == %lu\n", inode->i_ino)); | 239 | D1(printk(KERN_DEBUG "jffs2_iget(): ino == %lu\n", ino)); |
240 | |||
241 | inode = iget_locked(sb, ino); | ||
242 | if (!inode) | ||
243 | return ERR_PTR(-ENOMEM); | ||
244 | if (!(inode->i_state & I_NEW)) | ||
245 | return inode; | ||
243 | 246 | ||
244 | f = JFFS2_INODE_INFO(inode); | 247 | f = JFFS2_INODE_INFO(inode); |
245 | c = JFFS2_SB_INFO(inode->i_sb); | 248 | c = JFFS2_SB_INFO(inode->i_sb); |
@@ -250,9 +253,9 @@ void jffs2_read_inode (struct inode *inode) | |||
250 | ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node); | 253 | ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node); |
251 | 254 | ||
252 | if (ret) { | 255 | if (ret) { |
253 | make_bad_inode(inode); | ||
254 | up(&f->sem); | 256 | up(&f->sem); |
255 | return; | 257 | iget_failed(inode); |
258 | return ERR_PTR(ret); | ||
256 | } | 259 | } |
257 | inode->i_mode = jemode_to_cpu(latest_node.mode); | 260 | inode->i_mode = jemode_to_cpu(latest_node.mode); |
258 | inode->i_uid = je16_to_cpu(latest_node.uid); | 261 | inode->i_uid = je16_to_cpu(latest_node.uid); |
@@ -303,19 +306,14 @@ void jffs2_read_inode (struct inode *inode) | |||
303 | if (f->metadata->size != sizeof(jdev.old) && | 306 | if (f->metadata->size != sizeof(jdev.old) && |
304 | f->metadata->size != sizeof(jdev.new)) { | 307 | f->metadata->size != sizeof(jdev.new)) { |
305 | printk(KERN_NOTICE "Device node has strange size %d\n", f->metadata->size); | 308 | printk(KERN_NOTICE "Device node has strange size %d\n", f->metadata->size); |
306 | up(&f->sem); | 309 | goto error_io; |
307 | jffs2_do_clear_inode(c, f); | ||
308 | make_bad_inode(inode); | ||
309 | return; | ||
310 | } | 310 | } |
311 | D1(printk(KERN_DEBUG "Reading device numbers from flash\n")); | 311 | D1(printk(KERN_DEBUG "Reading device numbers from flash\n")); |
312 | if (jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size) < 0) { | 312 | ret = jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size); |
313 | if (ret < 0) { | ||
313 | /* Eep */ | 314 | /* Eep */ |
314 | printk(KERN_NOTICE "Read device numbers for inode %lu failed\n", (unsigned long)inode->i_ino); | 315 | printk(KERN_NOTICE "Read device numbers for inode %lu failed\n", (unsigned long)inode->i_ino); |
315 | up(&f->sem); | 316 | goto error; |
316 | jffs2_do_clear_inode(c, f); | ||
317 | make_bad_inode(inode); | ||
318 | return; | ||
319 | } | 317 | } |
320 | if (f->metadata->size == sizeof(jdev.old)) | 318 | if (f->metadata->size == sizeof(jdev.old)) |
321 | rdev = old_decode_dev(je16_to_cpu(jdev.old)); | 319 | rdev = old_decode_dev(je16_to_cpu(jdev.old)); |
@@ -335,6 +333,16 @@ void jffs2_read_inode (struct inode *inode) | |||
335 | up(&f->sem); | 333 | up(&f->sem); |
336 | 334 | ||
337 | D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n")); | 335 | D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n")); |
336 | unlock_new_inode(inode); | ||
337 | return inode; | ||
338 | |||
339 | error_io: | ||
340 | ret = -EIO; | ||
341 | error: | ||
342 | up(&f->sem); | ||
343 | jffs2_do_clear_inode(c, f); | ||
344 | iget_failed(inode); | ||
345 | return ERR_PTR(ret); | ||
338 | } | 346 | } |
339 | 347 | ||
340 | void jffs2_dirty_inode(struct inode *inode) | 348 | void jffs2_dirty_inode(struct inode *inode) |
@@ -522,15 +530,16 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
522 | if ((ret = jffs2_do_mount_fs(c))) | 530 | if ((ret = jffs2_do_mount_fs(c))) |
523 | goto out_inohash; | 531 | goto out_inohash; |
524 | 532 | ||
525 | ret = -EINVAL; | ||
526 | |||
527 | D1(printk(KERN_DEBUG "jffs2_do_fill_super(): Getting root inode\n")); | 533 | D1(printk(KERN_DEBUG "jffs2_do_fill_super(): Getting root inode\n")); |
528 | root_i = iget(sb, 1); | 534 | root_i = jffs2_iget(sb, 1); |
529 | if (is_bad_inode(root_i)) { | 535 | if (IS_ERR(root_i)) { |
530 | D1(printk(KERN_WARNING "get root inode failed\n")); | 536 | D1(printk(KERN_WARNING "get root inode failed\n")); |
531 | goto out_root_i; | 537 | ret = PTR_ERR(root_i); |
538 | goto out_root; | ||
532 | } | 539 | } |
533 | 540 | ||
541 | ret = -ENOMEM; | ||
542 | |||
534 | D1(printk(KERN_DEBUG "jffs2_do_fill_super(): d_alloc_root()\n")); | 543 | D1(printk(KERN_DEBUG "jffs2_do_fill_super(): d_alloc_root()\n")); |
535 | sb->s_root = d_alloc_root(root_i); | 544 | sb->s_root = d_alloc_root(root_i); |
536 | if (!sb->s_root) | 545 | if (!sb->s_root) |
@@ -546,6 +555,7 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
546 | 555 | ||
547 | out_root_i: | 556 | out_root_i: |
548 | iput(root_i); | 557 | iput(root_i); |
558 | out_root: | ||
549 | jffs2_free_ino_caches(c); | 559 | jffs2_free_ino_caches(c); |
550 | jffs2_free_raw_node_refs(c); | 560 | jffs2_free_raw_node_refs(c); |
551 | if (jffs2_blocks_use_vmalloc(c)) | 561 | if (jffs2_blocks_use_vmalloc(c)) |
@@ -615,9 +625,9 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, | |||
615 | jffs2_do_unlink() would need the alloc_sem and we have it. | 625 | jffs2_do_unlink() would need the alloc_sem and we have it. |
616 | Just iget() it, and if read_inode() is necessary that's OK. | 626 | Just iget() it, and if read_inode() is necessary that's OK. |
617 | */ | 627 | */ |
618 | inode = iget(OFNI_BS_2SFFJ(c), inum); | 628 | inode = jffs2_iget(OFNI_BS_2SFFJ(c), inum); |
619 | if (!inode) | 629 | if (IS_ERR(inode)) |
620 | return ERR_PTR(-ENOMEM); | 630 | return ERR_CAST(inode); |
621 | } | 631 | } |
622 | if (is_bad_inode(inode)) { | 632 | if (is_bad_inode(inode)) { |
623 | printk(KERN_NOTICE "Eep. read_inode() failed for ino #%u. nlink %d\n", | 633 | printk(KERN_NOTICE "Eep. read_inode() failed for ino #%u. nlink %d\n", |
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c index 4bf86088b3ae..87c6f555e1a0 100644 --- a/fs/jffs2/nodelist.c +++ b/fs/jffs2/nodelist.c | |||
@@ -32,15 +32,18 @@ void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new | |||
32 | if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) { | 32 | if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) { |
33 | /* Duplicate. Free one */ | 33 | /* Duplicate. Free one */ |
34 | if (new->version < (*prev)->version) { | 34 | if (new->version < (*prev)->version) { |
35 | dbg_dentlist("Eep! Marking new dirent node is obsolete, old is \"%s\", ino #%u\n", | 35 | dbg_dentlist("Eep! Marking new dirent node obsolete, old is \"%s\", ino #%u\n", |
36 | (*prev)->name, (*prev)->ino); | 36 | (*prev)->name, (*prev)->ino); |
37 | jffs2_mark_node_obsolete(c, new->raw); | 37 | jffs2_mark_node_obsolete(c, new->raw); |
38 | jffs2_free_full_dirent(new); | 38 | jffs2_free_full_dirent(new); |
39 | } else { | 39 | } else { |
40 | dbg_dentlist("marking old dirent \"%s\", ino #%u bsolete\n", | 40 | dbg_dentlist("marking old dirent \"%s\", ino #%u obsolete\n", |
41 | (*prev)->name, (*prev)->ino); | 41 | (*prev)->name, (*prev)->ino); |
42 | new->next = (*prev)->next; | 42 | new->next = (*prev)->next; |
43 | jffs2_mark_node_obsolete(c, ((*prev)->raw)); | 43 | /* It may have been a 'placeholder' deletion dirent, |
44 | if jffs2_can_mark_obsolete() (see jffs2_do_unlink()) */ | ||
45 | if ((*prev)->raw) | ||
46 | jffs2_mark_node_obsolete(c, ((*prev)->raw)); | ||
44 | jffs2_free_full_dirent(*prev); | 47 | jffs2_free_full_dirent(*prev); |
45 | *prev = new; | 48 | *prev = new; |
46 | } | 49 | } |
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h index bf64686cf098..1b10d2594092 100644 --- a/fs/jffs2/os-linux.h +++ b/fs/jffs2/os-linux.h | |||
@@ -175,7 +175,7 @@ extern const struct inode_operations jffs2_symlink_inode_operations; | |||
175 | /* fs.c */ | 175 | /* fs.c */ |
176 | int jffs2_setattr (struct dentry *, struct iattr *); | 176 | int jffs2_setattr (struct dentry *, struct iattr *); |
177 | int jffs2_do_setattr (struct inode *, struct iattr *); | 177 | int jffs2_do_setattr (struct inode *, struct iattr *); |
178 | void jffs2_read_inode (struct inode *); | 178 | struct inode *jffs2_iget(struct super_block *, unsigned long); |
179 | void jffs2_clear_inode (struct inode *); | 179 | void jffs2_clear_inode (struct inode *); |
180 | void jffs2_dirty_inode(struct inode *inode); | 180 | void jffs2_dirty_inode(struct inode *inode); |
181 | struct inode *jffs2_new_inode (struct inode *dir_i, int mode, | 181 | struct inode *jffs2_new_inode (struct inode *dir_i, int mode, |
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index 6c1ba3566f58..e512a93d6249 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c | |||
@@ -37,23 +37,24 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info | |||
37 | 37 | ||
38 | BUG_ON(tn->csize == 0); | 38 | BUG_ON(tn->csize == 0); |
39 | 39 | ||
40 | if (!jffs2_is_writebuffered(c)) | ||
41 | goto adj_acc; | ||
42 | |||
43 | /* Calculate how many bytes were already checked */ | 40 | /* Calculate how many bytes were already checked */ |
44 | ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode); | 41 | ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode); |
45 | len = ofs % c->wbuf_pagesize; | 42 | len = tn->csize; |
46 | if (likely(len)) | 43 | |
47 | len = c->wbuf_pagesize - len; | 44 | if (jffs2_is_writebuffered(c)) { |
48 | 45 | int adj = ofs % c->wbuf_pagesize; | |
49 | if (len >= tn->csize) { | 46 | if (likely(adj)) |
50 | dbg_readinode("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n", | 47 | adj = c->wbuf_pagesize - adj; |
51 | ref_offset(ref), tn->csize, ofs); | 48 | |
52 | goto adj_acc; | 49 | if (adj >= tn->csize) { |
53 | } | 50 | dbg_readinode("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n", |
51 | ref_offset(ref), tn->csize, ofs); | ||
52 | goto adj_acc; | ||
53 | } | ||
54 | 54 | ||
55 | ofs += len; | 55 | ofs += adj; |
56 | len = tn->csize - len; | 56 | len -= adj; |
57 | } | ||
57 | 58 | ||
58 | dbg_readinode("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n", | 59 | dbg_readinode("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n", |
59 | ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len); | 60 | ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len); |
@@ -63,7 +64,7 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info | |||
63 | * adding and jffs2_flash_read_end() interface. */ | 64 | * adding and jffs2_flash_read_end() interface. */ |
64 | if (c->mtd->point) { | 65 | if (c->mtd->point) { |
65 | err = c->mtd->point(c->mtd, ofs, len, &retlen, &buffer); | 66 | err = c->mtd->point(c->mtd, ofs, len, &retlen, &buffer); |
66 | if (!err && retlen < tn->csize) { | 67 | if (!err && retlen < len) { |
67 | JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize); | 68 | JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize); |
68 | c->mtd->unpoint(c->mtd, buffer, ofs, retlen); | 69 | c->mtd->unpoint(c->mtd, buffer, ofs, retlen); |
69 | } else if (err) | 70 | } else if (err) |
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index ffa447511e6a..4677355996cc 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c | |||
@@ -65,7 +65,6 @@ static const struct super_operations jffs2_super_operations = | |||
65 | { | 65 | { |
66 | .alloc_inode = jffs2_alloc_inode, | 66 | .alloc_inode = jffs2_alloc_inode, |
67 | .destroy_inode =jffs2_destroy_inode, | 67 | .destroy_inode =jffs2_destroy_inode, |
68 | .read_inode = jffs2_read_inode, | ||
69 | .put_super = jffs2_put_super, | 68 | .put_super = jffs2_put_super, |
70 | .write_super = jffs2_write_super, | 69 | .write_super = jffs2_write_super, |
71 | .statfs = jffs2_statfs, | 70 | .statfs = jffs2_statfs, |
diff --git a/fs/jffs2/write.c b/fs/jffs2/write.c index 147e2cbee9e4..776f13cbf2b5 100644 --- a/fs/jffs2/write.c +++ b/fs/jffs2/write.c | |||
@@ -177,7 +177,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
177 | void *hold_err = fn->raw; | 177 | void *hold_err = fn->raw; |
178 | /* Release the full_dnode which is now useless, and return */ | 178 | /* Release the full_dnode which is now useless, and return */ |
179 | jffs2_free_full_dnode(fn); | 179 | jffs2_free_full_dnode(fn); |
180 | return ERR_PTR(PTR_ERR(hold_err)); | 180 | return ERR_CAST(hold_err); |
181 | } | 181 | } |
182 | fn->ofs = je32_to_cpu(ri->offset); | 182 | fn->ofs = je32_to_cpu(ri->offset); |
183 | fn->size = je32_to_cpu(ri->dsize); | 183 | fn->size = je32_to_cpu(ri->dsize); |
@@ -313,7 +313,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
313 | void *hold_err = fd->raw; | 313 | void *hold_err = fd->raw; |
314 | /* Release the full_dirent which is now useless, and return */ | 314 | /* Release the full_dirent which is now useless, and return */ |
315 | jffs2_free_full_dirent(fd); | 315 | jffs2_free_full_dirent(fd); |
316 | return ERR_PTR(PTR_ERR(hold_err)); | 316 | return ERR_CAST(hold_err); |
317 | } | 317 | } |
318 | 318 | ||
319 | if (retried) { | 319 | if (retried) { |
@@ -582,7 +582,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
582 | jffs2_add_fd_to_list(c, fd, &dir_f->dents); | 582 | jffs2_add_fd_to_list(c, fd, &dir_f->dents); |
583 | up(&dir_f->sem); | 583 | up(&dir_f->sem); |
584 | } else { | 584 | } else { |
585 | struct jffs2_full_dirent **prev = &dir_f->dents; | 585 | struct jffs2_full_dirent *fd = dir_f->dents; |
586 | uint32_t nhash = full_name_hash(name, namelen); | 586 | uint32_t nhash = full_name_hash(name, namelen); |
587 | 587 | ||
588 | /* We don't actually want to reserve any space, but we do | 588 | /* We don't actually want to reserve any space, but we do |
@@ -590,21 +590,22 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
590 | down(&c->alloc_sem); | 590 | down(&c->alloc_sem); |
591 | down(&dir_f->sem); | 591 | down(&dir_f->sem); |
592 | 592 | ||
593 | while ((*prev) && (*prev)->nhash <= nhash) { | 593 | for (fd = dir_f->dents; fd; fd = fd->next) { |
594 | if ((*prev)->nhash == nhash && | 594 | if (fd->nhash == nhash && |
595 | !memcmp((*prev)->name, name, namelen) && | 595 | !memcmp(fd->name, name, namelen) && |
596 | !(*prev)->name[namelen]) { | 596 | !fd->name[namelen]) { |
597 | struct jffs2_full_dirent *this = *prev; | ||
598 | 597 | ||
599 | D1(printk(KERN_DEBUG "Marking old dirent node (ino #%u) @%08x obsolete\n", | 598 | D1(printk(KERN_DEBUG "Marking old dirent node (ino #%u) @%08x obsolete\n", |
600 | this->ino, ref_offset(this->raw))); | 599 | fd->ino, ref_offset(fd->raw))); |
601 | 600 | jffs2_mark_node_obsolete(c, fd->raw); | |
602 | *prev = this->next; | 601 | /* We don't want to remove it from the list immediately, |
603 | jffs2_mark_node_obsolete(c, (this->raw)); | 602 | because that screws up getdents()/seek() semantics even |
604 | jffs2_free_full_dirent(this); | 603 | more than they're screwed already. Turn it into a |
604 | node-less deletion dirent instead -- a placeholder */ | ||
605 | fd->raw = NULL; | ||
606 | fd->ino = 0; | ||
605 | break; | 607 | break; |
606 | } | 608 | } |
607 | prev = &((*prev)->next); | ||
608 | } | 609 | } |
609 | up(&dir_f->sem); | 610 | up(&dir_f->sem); |
610 | } | 611 | } |
@@ -630,7 +631,8 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
630 | D1(printk(KERN_DEBUG "Removing deletion dirent for \"%s\" from dir ino #%u\n", | 631 | D1(printk(KERN_DEBUG "Removing deletion dirent for \"%s\" from dir ino #%u\n", |
631 | fd->name, dead_f->inocache->ino)); | 632 | fd->name, dead_f->inocache->ino)); |
632 | } | 633 | } |
633 | jffs2_mark_node_obsolete(c, fd->raw); | 634 | if (fd->raw) |
635 | jffs2_mark_node_obsolete(c, fd->raw); | ||
634 | jffs2_free_full_dirent(fd); | 636 | jffs2_free_full_dirent(fd); |
635 | } | 637 | } |
636 | } | 638 | } |
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c index 4672013802e1..210339784b56 100644 --- a/fs/jfs/inode.c +++ b/fs/jfs/inode.c | |||
@@ -31,11 +31,21 @@ | |||
31 | #include "jfs_debug.h" | 31 | #include "jfs_debug.h" |
32 | 32 | ||
33 | 33 | ||
34 | void jfs_read_inode(struct inode *inode) | 34 | struct inode *jfs_iget(struct super_block *sb, unsigned long ino) |
35 | { | 35 | { |
36 | if (diRead(inode)) { | 36 | struct inode *inode; |
37 | make_bad_inode(inode); | 37 | int ret; |
38 | return; | 38 | |
39 | inode = iget_locked(sb, ino); | ||
40 | if (!inode) | ||
41 | return ERR_PTR(-ENOMEM); | ||
42 | if (!(inode->i_state & I_NEW)) | ||
43 | return inode; | ||
44 | |||
45 | ret = diRead(inode); | ||
46 | if (ret < 0) { | ||
47 | iget_failed(inode); | ||
48 | return ERR_PTR(ret); | ||
39 | } | 49 | } |
40 | 50 | ||
41 | if (S_ISREG(inode->i_mode)) { | 51 | if (S_ISREG(inode->i_mode)) { |
@@ -55,6 +65,8 @@ void jfs_read_inode(struct inode *inode) | |||
55 | inode->i_op = &jfs_file_inode_operations; | 65 | inode->i_op = &jfs_file_inode_operations; |
56 | init_special_inode(inode, inode->i_mode, inode->i_rdev); | 66 | init_special_inode(inode, inode->i_mode, inode->i_rdev); |
57 | } | 67 | } |
68 | unlock_new_inode(inode); | ||
69 | return inode; | ||
58 | } | 70 | } |
59 | 71 | ||
60 | /* | 72 | /* |
diff --git a/fs/jfs/jfs_inode.h b/fs/jfs/jfs_inode.h index 8e2cf2cde185..95a6a11425e5 100644 --- a/fs/jfs/jfs_inode.h +++ b/fs/jfs/jfs_inode.h | |||
@@ -24,7 +24,7 @@ extern struct inode *ialloc(struct inode *, umode_t); | |||
24 | extern int jfs_fsync(struct file *, struct dentry *, int); | 24 | extern int jfs_fsync(struct file *, struct dentry *, int); |
25 | extern int jfs_ioctl(struct inode *, struct file *, | 25 | extern int jfs_ioctl(struct inode *, struct file *, |
26 | unsigned int, unsigned long); | 26 | unsigned int, unsigned long); |
27 | extern void jfs_read_inode(struct inode *); | 27 | extern struct inode *jfs_iget(struct super_block *, unsigned long); |
28 | extern int jfs_commit_inode(struct inode *, int); | 28 | extern int jfs_commit_inode(struct inode *, int); |
29 | extern int jfs_write_inode(struct inode*, int); | 29 | extern int jfs_write_inode(struct inode*, int); |
30 | extern void jfs_delete_inode(struct inode *); | 30 | extern void jfs_delete_inode(struct inode *); |
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index f8718de3505e..403cfc24c6fe 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c | |||
@@ -1462,12 +1462,10 @@ static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, struc | |||
1462 | } | 1462 | } |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | ip = iget(dip->i_sb, inum); | 1465 | ip = jfs_iget(dip->i_sb, inum); |
1466 | if (ip == NULL || is_bad_inode(ip)) { | 1466 | if (IS_ERR(ip)) { |
1467 | jfs_err("jfs_lookup: iget failed on inum %d", (uint) inum); | 1467 | jfs_err("jfs_lookup: iget failed on inum %d", (uint) inum); |
1468 | if (ip) | 1468 | return ERR_CAST(ip); |
1469 | iput(ip); | ||
1470 | return ERR_PTR(-EACCES); | ||
1471 | } | 1469 | } |
1472 | 1470 | ||
1473 | dentry = d_splice_alias(ip, dentry); | 1471 | dentry = d_splice_alias(ip, dentry); |
@@ -1485,12 +1483,11 @@ static struct inode *jfs_nfs_get_inode(struct super_block *sb, | |||
1485 | 1483 | ||
1486 | if (ino == 0) | 1484 | if (ino == 0) |
1487 | return ERR_PTR(-ESTALE); | 1485 | return ERR_PTR(-ESTALE); |
1488 | inode = iget(sb, ino); | 1486 | inode = jfs_iget(sb, ino); |
1489 | if (inode == NULL) | 1487 | if (IS_ERR(inode)) |
1490 | return ERR_PTR(-ENOMEM); | 1488 | return ERR_CAST(inode); |
1491 | 1489 | ||
1492 | if (is_bad_inode(inode) || | 1490 | if (generation && inode->i_generation != generation) { |
1493 | (generation && inode->i_generation != generation)) { | ||
1494 | iput(inode); | 1491 | iput(inode); |
1495 | return ERR_PTR(-ESTALE); | 1492 | return ERR_PTR(-ESTALE); |
1496 | } | 1493 | } |
@@ -1521,17 +1518,14 @@ struct dentry *jfs_get_parent(struct dentry *dentry) | |||
1521 | 1518 | ||
1522 | parent_ino = | 1519 | parent_ino = |
1523 | le32_to_cpu(JFS_IP(dentry->d_inode)->i_dtroot.header.idotdot); | 1520 | le32_to_cpu(JFS_IP(dentry->d_inode)->i_dtroot.header.idotdot); |
1524 | inode = iget(sb, parent_ino); | 1521 | inode = jfs_iget(sb, parent_ino); |
1525 | if (inode) { | 1522 | if (IS_ERR(inode)) { |
1526 | if (is_bad_inode(inode)) { | 1523 | parent = ERR_CAST(inode); |
1524 | } else { | ||
1525 | parent = d_alloc_anon(inode); | ||
1526 | if (!parent) { | ||
1527 | parent = ERR_PTR(-ENOMEM); | ||
1527 | iput(inode); | 1528 | iput(inode); |
1528 | parent = ERR_PTR(-EACCES); | ||
1529 | } else { | ||
1530 | parent = d_alloc_anon(inode); | ||
1531 | if (!parent) { | ||
1532 | parent = ERR_PTR(-ENOMEM); | ||
1533 | iput(inode); | ||
1534 | } | ||
1535 | } | 1529 | } |
1536 | } | 1530 | } |
1537 | 1531 | ||
diff --git a/fs/jfs/super.c b/fs/jfs/super.c index 70a14001c98f..50ea65451732 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c | |||
@@ -414,7 +414,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) | |||
414 | struct inode *inode; | 414 | struct inode *inode; |
415 | int rc; | 415 | int rc; |
416 | s64 newLVSize = 0; | 416 | s64 newLVSize = 0; |
417 | int flag; | 417 | int flag, ret = -EINVAL; |
418 | 418 | ||
419 | jfs_info("In jfs_read_super: s_flags=0x%lx", sb->s_flags); | 419 | jfs_info("In jfs_read_super: s_flags=0x%lx", sb->s_flags); |
420 | 420 | ||
@@ -461,8 +461,10 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) | |||
461 | * Initialize direct-mapping inode/address-space | 461 | * Initialize direct-mapping inode/address-space |
462 | */ | 462 | */ |
463 | inode = new_inode(sb); | 463 | inode = new_inode(sb); |
464 | if (inode == NULL) | 464 | if (inode == NULL) { |
465 | ret = -ENOMEM; | ||
465 | goto out_kfree; | 466 | goto out_kfree; |
467 | } | ||
466 | inode->i_ino = 0; | 468 | inode->i_ino = 0; |
467 | inode->i_nlink = 1; | 469 | inode->i_nlink = 1; |
468 | inode->i_size = sb->s_bdev->bd_inode->i_size; | 470 | inode->i_size = sb->s_bdev->bd_inode->i_size; |
@@ -494,9 +496,11 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) | |||
494 | 496 | ||
495 | sb->s_magic = JFS_SUPER_MAGIC; | 497 | sb->s_magic = JFS_SUPER_MAGIC; |
496 | 498 | ||
497 | inode = iget(sb, ROOT_I); | 499 | inode = jfs_iget(sb, ROOT_I); |
498 | if (!inode || is_bad_inode(inode)) | 500 | if (IS_ERR(inode)) { |
501 | ret = PTR_ERR(inode); | ||
499 | goto out_no_root; | 502 | goto out_no_root; |
503 | } | ||
500 | sb->s_root = d_alloc_root(inode); | 504 | sb->s_root = d_alloc_root(inode); |
501 | if (!sb->s_root) | 505 | if (!sb->s_root) |
502 | goto out_no_root; | 506 | goto out_no_root; |
@@ -536,7 +540,7 @@ out_kfree: | |||
536 | if (sbi->nls_tab) | 540 | if (sbi->nls_tab) |
537 | unload_nls(sbi->nls_tab); | 541 | unload_nls(sbi->nls_tab); |
538 | kfree(sbi); | 542 | kfree(sbi); |
539 | return -EINVAL; | 543 | return ret; |
540 | } | 544 | } |
541 | 545 | ||
542 | static void jfs_write_super_lockfs(struct super_block *sb) | 546 | static void jfs_write_super_lockfs(struct super_block *sb) |
@@ -726,7 +730,6 @@ out: | |||
726 | static const struct super_operations jfs_super_operations = { | 730 | static const struct super_operations jfs_super_operations = { |
727 | .alloc_inode = jfs_alloc_inode, | 731 | .alloc_inode = jfs_alloc_inode, |
728 | .destroy_inode = jfs_destroy_inode, | 732 | .destroy_inode = jfs_destroy_inode, |
729 | .read_inode = jfs_read_inode, | ||
730 | .dirty_inode = jfs_dirty_inode, | 733 | .dirty_inode = jfs_dirty_inode, |
731 | .write_inode = jfs_write_inode, | 734 | .write_inode = jfs_write_inode, |
732 | .delete_inode = jfs_delete_inode, | 735 | .delete_inode = jfs_delete_inode, |
diff --git a/fs/minix/inode.c b/fs/minix/inode.c index bf4cd316af81..84f6242ba6fc 100644 --- a/fs/minix/inode.c +++ b/fs/minix/inode.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/highuid.h> | 18 | #include <linux/highuid.h> |
19 | #include <linux/vfs.h> | 19 | #include <linux/vfs.h> |
20 | 20 | ||
21 | static void minix_read_inode(struct inode * inode); | ||
22 | static int minix_write_inode(struct inode * inode, int wait); | 21 | static int minix_write_inode(struct inode * inode, int wait); |
23 | static int minix_statfs(struct dentry *dentry, struct kstatfs *buf); | 22 | static int minix_statfs(struct dentry *dentry, struct kstatfs *buf); |
24 | static int minix_remount (struct super_block * sb, int * flags, char * data); | 23 | static int minix_remount (struct super_block * sb, int * flags, char * data); |
@@ -96,7 +95,6 @@ static void destroy_inodecache(void) | |||
96 | static const struct super_operations minix_sops = { | 95 | static const struct super_operations minix_sops = { |
97 | .alloc_inode = minix_alloc_inode, | 96 | .alloc_inode = minix_alloc_inode, |
98 | .destroy_inode = minix_destroy_inode, | 97 | .destroy_inode = minix_destroy_inode, |
99 | .read_inode = minix_read_inode, | ||
100 | .write_inode = minix_write_inode, | 98 | .write_inode = minix_write_inode, |
101 | .delete_inode = minix_delete_inode, | 99 | .delete_inode = minix_delete_inode, |
102 | .put_super = minix_put_super, | 100 | .put_super = minix_put_super, |
@@ -149,6 +147,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent) | |||
149 | unsigned long i, block; | 147 | unsigned long i, block; |
150 | struct inode *root_inode; | 148 | struct inode *root_inode; |
151 | struct minix_sb_info *sbi; | 149 | struct minix_sb_info *sbi; |
150 | int ret = -EINVAL; | ||
152 | 151 | ||
153 | sbi = kzalloc(sizeof(struct minix_sb_info), GFP_KERNEL); | 152 | sbi = kzalloc(sizeof(struct minix_sb_info), GFP_KERNEL); |
154 | if (!sbi) | 153 | if (!sbi) |
@@ -246,10 +245,13 @@ static int minix_fill_super(struct super_block *s, void *data, int silent) | |||
246 | 245 | ||
247 | /* set up enough so that it can read an inode */ | 246 | /* set up enough so that it can read an inode */ |
248 | s->s_op = &minix_sops; | 247 | s->s_op = &minix_sops; |
249 | root_inode = iget(s, MINIX_ROOT_INO); | 248 | root_inode = minix_iget(s, MINIX_ROOT_INO); |
250 | if (!root_inode || is_bad_inode(root_inode)) | 249 | if (IS_ERR(root_inode)) { |
250 | ret = PTR_ERR(root_inode); | ||
251 | goto out_no_root; | 251 | goto out_no_root; |
252 | } | ||
252 | 253 | ||
254 | ret = -ENOMEM; | ||
253 | s->s_root = d_alloc_root(root_inode); | 255 | s->s_root = d_alloc_root(root_inode); |
254 | if (!s->s_root) | 256 | if (!s->s_root) |
255 | goto out_iput; | 257 | goto out_iput; |
@@ -290,6 +292,7 @@ out_freemap: | |||
290 | goto out_release; | 292 | goto out_release; |
291 | 293 | ||
292 | out_no_map: | 294 | out_no_map: |
295 | ret = -ENOMEM; | ||
293 | if (!silent) | 296 | if (!silent) |
294 | printk("MINIX-fs: can't allocate map\n"); | 297 | printk("MINIX-fs: can't allocate map\n"); |
295 | goto out_release; | 298 | goto out_release; |
@@ -316,7 +319,7 @@ out_bad_sb: | |||
316 | out: | 319 | out: |
317 | s->s_fs_info = NULL; | 320 | s->s_fs_info = NULL; |
318 | kfree(sbi); | 321 | kfree(sbi); |
319 | return -EINVAL; | 322 | return ret; |
320 | } | 323 | } |
321 | 324 | ||
322 | static int minix_statfs(struct dentry *dentry, struct kstatfs *buf) | 325 | static int minix_statfs(struct dentry *dentry, struct kstatfs *buf) |
@@ -409,7 +412,7 @@ void minix_set_inode(struct inode *inode, dev_t rdev) | |||
409 | /* | 412 | /* |
410 | * The minix V1 function to read an inode. | 413 | * The minix V1 function to read an inode. |
411 | */ | 414 | */ |
412 | static void V1_minix_read_inode(struct inode * inode) | 415 | static struct inode *V1_minix_iget(struct inode *inode) |
413 | { | 416 | { |
414 | struct buffer_head * bh; | 417 | struct buffer_head * bh; |
415 | struct minix_inode * raw_inode; | 418 | struct minix_inode * raw_inode; |
@@ -418,8 +421,8 @@ static void V1_minix_read_inode(struct inode * inode) | |||
418 | 421 | ||
419 | raw_inode = minix_V1_raw_inode(inode->i_sb, inode->i_ino, &bh); | 422 | raw_inode = minix_V1_raw_inode(inode->i_sb, inode->i_ino, &bh); |
420 | if (!raw_inode) { | 423 | if (!raw_inode) { |
421 | make_bad_inode(inode); | 424 | iget_failed(inode); |
422 | return; | 425 | return ERR_PTR(-EIO); |
423 | } | 426 | } |
424 | inode->i_mode = raw_inode->i_mode; | 427 | inode->i_mode = raw_inode->i_mode; |
425 | inode->i_uid = (uid_t)raw_inode->i_uid; | 428 | inode->i_uid = (uid_t)raw_inode->i_uid; |
@@ -435,12 +438,14 @@ static void V1_minix_read_inode(struct inode * inode) | |||
435 | minix_inode->u.i1_data[i] = raw_inode->i_zone[i]; | 438 | minix_inode->u.i1_data[i] = raw_inode->i_zone[i]; |
436 | minix_set_inode(inode, old_decode_dev(raw_inode->i_zone[0])); | 439 | minix_set_inode(inode, old_decode_dev(raw_inode->i_zone[0])); |
437 | brelse(bh); | 440 | brelse(bh); |
441 | unlock_new_inode(inode); | ||
442 | return inode; | ||
438 | } | 443 | } |
439 | 444 | ||
440 | /* | 445 | /* |
441 | * The minix V2 function to read an inode. | 446 | * The minix V2 function to read an inode. |
442 | */ | 447 | */ |
443 | static void V2_minix_read_inode(struct inode * inode) | 448 | static struct inode *V2_minix_iget(struct inode *inode) |
444 | { | 449 | { |
445 | struct buffer_head * bh; | 450 | struct buffer_head * bh; |
446 | struct minix2_inode * raw_inode; | 451 | struct minix2_inode * raw_inode; |
@@ -449,8 +454,8 @@ static void V2_minix_read_inode(struct inode * inode) | |||
449 | 454 | ||
450 | raw_inode = minix_V2_raw_inode(inode->i_sb, inode->i_ino, &bh); | 455 | raw_inode = minix_V2_raw_inode(inode->i_sb, inode->i_ino, &bh); |
451 | if (!raw_inode) { | 456 | if (!raw_inode) { |
452 | make_bad_inode(inode); | 457 | iget_failed(inode); |
453 | return; | 458 | return ERR_PTR(-EIO); |
454 | } | 459 | } |
455 | inode->i_mode = raw_inode->i_mode; | 460 | inode->i_mode = raw_inode->i_mode; |
456 | inode->i_uid = (uid_t)raw_inode->i_uid; | 461 | inode->i_uid = (uid_t)raw_inode->i_uid; |
@@ -468,17 +473,27 @@ static void V2_minix_read_inode(struct inode * inode) | |||
468 | minix_inode->u.i2_data[i] = raw_inode->i_zone[i]; | 473 | minix_inode->u.i2_data[i] = raw_inode->i_zone[i]; |
469 | minix_set_inode(inode, old_decode_dev(raw_inode->i_zone[0])); | 474 | minix_set_inode(inode, old_decode_dev(raw_inode->i_zone[0])); |
470 | brelse(bh); | 475 | brelse(bh); |
476 | unlock_new_inode(inode); | ||
477 | return inode; | ||
471 | } | 478 | } |
472 | 479 | ||
473 | /* | 480 | /* |
474 | * The global function to read an inode. | 481 | * The global function to read an inode. |
475 | */ | 482 | */ |
476 | static void minix_read_inode(struct inode * inode) | 483 | struct inode *minix_iget(struct super_block *sb, unsigned long ino) |
477 | { | 484 | { |
485 | struct inode *inode; | ||
486 | |||
487 | inode = iget_locked(sb, ino); | ||
488 | if (!inode) | ||
489 | return ERR_PTR(-ENOMEM); | ||
490 | if (!(inode->i_state & I_NEW)) | ||
491 | return inode; | ||
492 | |||
478 | if (INODE_VERSION(inode) == MINIX_V1) | 493 | if (INODE_VERSION(inode) == MINIX_V1) |
479 | V1_minix_read_inode(inode); | 494 | return V1_minix_iget(inode); |
480 | else | 495 | else |
481 | V2_minix_read_inode(inode); | 496 | return V2_minix_iget(inode); |
482 | } | 497 | } |
483 | 498 | ||
484 | /* | 499 | /* |
diff --git a/fs/minix/minix.h b/fs/minix/minix.h index ac5d3a75cb0d..326edfe96108 100644 --- a/fs/minix/minix.h +++ b/fs/minix/minix.h | |||
@@ -45,6 +45,7 @@ struct minix_sb_info { | |||
45 | unsigned short s_version; | 45 | unsigned short s_version; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | extern struct inode *minix_iget(struct super_block *, unsigned long); | ||
48 | extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **); | 49 | extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **); |
49 | extern struct minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **); | 50 | extern struct minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **); |
50 | extern struct inode * minix_new_inode(const struct inode * dir, int * error); | 51 | extern struct inode * minix_new_inode(const struct inode * dir, int * error); |
diff --git a/fs/minix/namei.c b/fs/minix/namei.c index f4aa7a939040..102241bc9c79 100644 --- a/fs/minix/namei.c +++ b/fs/minix/namei.c | |||
@@ -54,10 +54,9 @@ static struct dentry *minix_lookup(struct inode * dir, struct dentry *dentry, st | |||
54 | 54 | ||
55 | ino = minix_inode_by_name(dentry); | 55 | ino = minix_inode_by_name(dentry); |
56 | if (ino) { | 56 | if (ino) { |
57 | inode = iget(dir->i_sb, ino); | 57 | inode = minix_iget(dir->i_sb, ino); |
58 | 58 | if (IS_ERR(inode)) | |
59 | if (!inode) | 59 | return ERR_CAST(inode); |
60 | return ERR_PTR(-EACCES); | ||
61 | } | 60 | } |
62 | d_add(dentry, inode); | 61 | d_add(dentry, inode); |
63 | return NULL; | 62 | return NULL; |
diff --git a/fs/nfs/getroot.c b/fs/nfs/getroot.c index e6242cdbaf91..fae97196daad 100644 --- a/fs/nfs/getroot.c +++ b/fs/nfs/getroot.c | |||
@@ -96,7 +96,7 @@ struct dentry *nfs_get_root(struct super_block *sb, struct nfs_fh *mntfh) | |||
96 | inode = nfs_fhget(sb, mntfh, fsinfo.fattr); | 96 | inode = nfs_fhget(sb, mntfh, fsinfo.fattr); |
97 | if (IS_ERR(inode)) { | 97 | if (IS_ERR(inode)) { |
98 | dprintk("nfs_get_root: get root inode failed\n"); | 98 | dprintk("nfs_get_root: get root inode failed\n"); |
99 | return ERR_PTR(PTR_ERR(inode)); | 99 | return ERR_CAST(inode); |
100 | } | 100 | } |
101 | 101 | ||
102 | error = nfs_superblock_set_dummy_root(sb, inode); | 102 | error = nfs_superblock_set_dummy_root(sb, inode); |
@@ -266,7 +266,7 @@ struct dentry *nfs4_get_root(struct super_block *sb, struct nfs_fh *mntfh) | |||
266 | inode = nfs_fhget(sb, mntfh, &fattr); | 266 | inode = nfs_fhget(sb, mntfh, &fattr); |
267 | if (IS_ERR(inode)) { | 267 | if (IS_ERR(inode)) { |
268 | dprintk("nfs_get_root: get root inode failed\n"); | 268 | dprintk("nfs_get_root: get root inode failed\n"); |
269 | return ERR_PTR(PTR_ERR(inode)); | 269 | return ERR_CAST(inode); |
270 | } | 270 | } |
271 | 271 | ||
272 | error = nfs_superblock_set_dummy_root(sb, inode); | 272 | error = nfs_superblock_set_dummy_root(sb, inode); |
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 79b4bf812960..346570f6d848 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c | |||
@@ -1218,13 +1218,13 @@ static struct svc_export *exp_find(struct auth_domain *clp, int fsid_type, | |||
1218 | struct svc_export *exp; | 1218 | struct svc_export *exp; |
1219 | struct svc_expkey *ek = exp_find_key(clp, fsid_type, fsidv, reqp); | 1219 | struct svc_expkey *ek = exp_find_key(clp, fsid_type, fsidv, reqp); |
1220 | if (IS_ERR(ek)) | 1220 | if (IS_ERR(ek)) |
1221 | return ERR_PTR(PTR_ERR(ek)); | 1221 | return ERR_CAST(ek); |
1222 | 1222 | ||
1223 | exp = exp_get_by_name(clp, ek->ek_mnt, ek->ek_dentry, reqp); | 1223 | exp = exp_get_by_name(clp, ek->ek_mnt, ek->ek_dentry, reqp); |
1224 | cache_put(&ek->h, &svc_expkey_cache); | 1224 | cache_put(&ek->h, &svc_expkey_cache); |
1225 | 1225 | ||
1226 | if (IS_ERR(exp)) | 1226 | if (IS_ERR(exp)) |
1227 | return ERR_PTR(PTR_ERR(exp)); | 1227 | return ERR_CAST(exp); |
1228 | return exp; | 1228 | return exp; |
1229 | } | 1229 | } |
1230 | 1230 | ||
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c index 6b7ff1618945..d17b4fd204e1 100644 --- a/fs/openpromfs/inode.c +++ b/fs/openpromfs/inode.c | |||
@@ -38,6 +38,8 @@ struct op_inode_info { | |||
38 | union op_inode_data u; | 38 | union op_inode_data u; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | static struct inode *openprom_iget(struct super_block *sb, ino_t ino); | ||
42 | |||
41 | static inline struct op_inode_info *OP_I(struct inode *inode) | 43 | static inline struct op_inode_info *OP_I(struct inode *inode) |
42 | { | 44 | { |
43 | return container_of(inode, struct op_inode_info, vfs_inode); | 45 | return container_of(inode, struct op_inode_info, vfs_inode); |
@@ -226,10 +228,10 @@ static struct dentry *openpromfs_lookup(struct inode *dir, struct dentry *dentry | |||
226 | return ERR_PTR(-ENOENT); | 228 | return ERR_PTR(-ENOENT); |
227 | 229 | ||
228 | found: | 230 | found: |
229 | inode = iget(dir->i_sb, ino); | 231 | inode = openprom_iget(dir->i_sb, ino); |
230 | mutex_unlock(&op_mutex); | 232 | mutex_unlock(&op_mutex); |
231 | if (!inode) | 233 | if (IS_ERR(inode)) |
232 | return ERR_PTR(-EINVAL); | 234 | return ERR_CAST(inode); |
233 | ent_oi = OP_I(inode); | 235 | ent_oi = OP_I(inode); |
234 | ent_oi->type = ent_type; | 236 | ent_oi->type = ent_type; |
235 | ent_oi->u = ent_data; | 237 | ent_oi->u = ent_data; |
@@ -348,14 +350,23 @@ static void openprom_destroy_inode(struct inode *inode) | |||
348 | kmem_cache_free(op_inode_cachep, OP_I(inode)); | 350 | kmem_cache_free(op_inode_cachep, OP_I(inode)); |
349 | } | 351 | } |
350 | 352 | ||
351 | static void openprom_read_inode(struct inode * inode) | 353 | static struct inode *openprom_iget(struct super_block *sb, ino_t ino) |
352 | { | 354 | { |
353 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; | 355 | struct inode *inode; |
354 | if (inode->i_ino == OPENPROM_ROOT_INO) { | 356 | |
355 | inode->i_op = &openprom_inode_operations; | 357 | inode = iget_locked(sb, ino); |
356 | inode->i_fop = &openprom_operations; | 358 | if (!inode) |
357 | inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; | 359 | return ERR_PTR(-ENOMEM); |
360 | if (inode->i_state & I_NEW) { | ||
361 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; | ||
362 | if (inode->i_ino == OPENPROM_ROOT_INO) { | ||
363 | inode->i_op = &openprom_inode_operations; | ||
364 | inode->i_fop = &openprom_operations; | ||
365 | inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; | ||
366 | } | ||
367 | unlock_new_inode(inode); | ||
358 | } | 368 | } |
369 | return inode; | ||
359 | } | 370 | } |
360 | 371 | ||
361 | static int openprom_remount(struct super_block *sb, int *flags, char *data) | 372 | static int openprom_remount(struct super_block *sb, int *flags, char *data) |
@@ -367,7 +378,6 @@ static int openprom_remount(struct super_block *sb, int *flags, char *data) | |||
367 | static const struct super_operations openprom_sops = { | 378 | static const struct super_operations openprom_sops = { |
368 | .alloc_inode = openprom_alloc_inode, | 379 | .alloc_inode = openprom_alloc_inode, |
369 | .destroy_inode = openprom_destroy_inode, | 380 | .destroy_inode = openprom_destroy_inode, |
370 | .read_inode = openprom_read_inode, | ||
371 | .statfs = simple_statfs, | 381 | .statfs = simple_statfs, |
372 | .remount_fs = openprom_remount, | 382 | .remount_fs = openprom_remount, |
373 | }; | 383 | }; |
@@ -376,6 +386,7 @@ static int openprom_fill_super(struct super_block *s, void *data, int silent) | |||
376 | { | 386 | { |
377 | struct inode *root_inode; | 387 | struct inode *root_inode; |
378 | struct op_inode_info *oi; | 388 | struct op_inode_info *oi; |
389 | int ret; | ||
379 | 390 | ||
380 | s->s_flags |= MS_NOATIME; | 391 | s->s_flags |= MS_NOATIME; |
381 | s->s_blocksize = 1024; | 392 | s->s_blocksize = 1024; |
@@ -383,9 +394,11 @@ static int openprom_fill_super(struct super_block *s, void *data, int silent) | |||
383 | s->s_magic = OPENPROM_SUPER_MAGIC; | 394 | s->s_magic = OPENPROM_SUPER_MAGIC; |
384 | s->s_op = &openprom_sops; | 395 | s->s_op = &openprom_sops; |
385 | s->s_time_gran = 1; | 396 | s->s_time_gran = 1; |
386 | root_inode = iget(s, OPENPROM_ROOT_INO); | 397 | root_inode = openprom_iget(s, OPENPROM_ROOT_INO); |
387 | if (!root_inode) | 398 | if (IS_ERR(root_inode)) { |
399 | ret = PTR_ERR(root_inode); | ||
388 | goto out_no_root; | 400 | goto out_no_root; |
401 | } | ||
389 | 402 | ||
390 | oi = OP_I(root_inode); | 403 | oi = OP_I(root_inode); |
391 | oi->type = op_inode_node; | 404 | oi->type = op_inode_node; |
@@ -393,13 +406,15 @@ static int openprom_fill_super(struct super_block *s, void *data, int silent) | |||
393 | 406 | ||
394 | s->s_root = d_alloc_root(root_inode); | 407 | s->s_root = d_alloc_root(root_inode); |
395 | if (!s->s_root) | 408 | if (!s->s_root) |
396 | goto out_no_root; | 409 | goto out_no_root_dentry; |
397 | return 0; | 410 | return 0; |
398 | 411 | ||
412 | out_no_root_dentry: | ||
413 | iput(root_inode); | ||
414 | ret = -ENOMEM; | ||
399 | out_no_root: | 415 | out_no_root: |
400 | printk("openprom_fill_super: get root inode failed\n"); | 416 | printk("openprom_fill_super: get root inode failed\n"); |
401 | iput(root_inode); | 417 | return ret; |
402 | return -ENOMEM; | ||
403 | } | 418 | } |
404 | 419 | ||
405 | static int openprom_get_sb(struct file_system_type *fs_type, | 420 | static int openprom_get_sb(struct file_system_type *fs_type, |
diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 1a551d92e1d8..6ecf6396f072 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c | |||
@@ -73,11 +73,6 @@ static void proc_delete_inode(struct inode *inode) | |||
73 | 73 | ||
74 | struct vfsmount *proc_mnt; | 74 | struct vfsmount *proc_mnt; |
75 | 75 | ||
76 | static void proc_read_inode(struct inode * inode) | ||
77 | { | ||
78 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; | ||
79 | } | ||
80 | |||
81 | static struct kmem_cache * proc_inode_cachep; | 76 | static struct kmem_cache * proc_inode_cachep; |
82 | 77 | ||
83 | static struct inode *proc_alloc_inode(struct super_block *sb) | 78 | static struct inode *proc_alloc_inode(struct super_block *sb) |
@@ -128,7 +123,6 @@ static int proc_remount(struct super_block *sb, int *flags, char *data) | |||
128 | static const struct super_operations proc_sops = { | 123 | static const struct super_operations proc_sops = { |
129 | .alloc_inode = proc_alloc_inode, | 124 | .alloc_inode = proc_alloc_inode, |
130 | .destroy_inode = proc_destroy_inode, | 125 | .destroy_inode = proc_destroy_inode, |
131 | .read_inode = proc_read_inode, | ||
132 | .drop_inode = generic_delete_inode, | 126 | .drop_inode = generic_delete_inode, |
133 | .delete_inode = proc_delete_inode, | 127 | .delete_inode = proc_delete_inode, |
134 | .statfs = simple_statfs, | 128 | .statfs = simple_statfs, |
@@ -401,39 +395,41 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, | |||
401 | if (de != NULL && !try_module_get(de->owner)) | 395 | if (de != NULL && !try_module_get(de->owner)) |
402 | goto out_mod; | 396 | goto out_mod; |
403 | 397 | ||
404 | inode = iget(sb, ino); | 398 | inode = iget_locked(sb, ino); |
405 | if (!inode) | 399 | if (!inode) |
406 | goto out_ino; | 400 | goto out_ino; |
407 | 401 | if (inode->i_state & I_NEW) { | |
408 | PROC_I(inode)->fd = 0; | 402 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; |
409 | PROC_I(inode)->pde = de; | 403 | PROC_I(inode)->fd = 0; |
410 | if (de) { | 404 | PROC_I(inode)->pde = de; |
411 | if (de->mode) { | 405 | if (de) { |
412 | inode->i_mode = de->mode; | 406 | if (de->mode) { |
413 | inode->i_uid = de->uid; | 407 | inode->i_mode = de->mode; |
414 | inode->i_gid = de->gid; | 408 | inode->i_uid = de->uid; |
415 | } | 409 | inode->i_gid = de->gid; |
416 | if (de->size) | 410 | } |
417 | inode->i_size = de->size; | 411 | if (de->size) |
418 | if (de->nlink) | 412 | inode->i_size = de->size; |
419 | inode->i_nlink = de->nlink; | 413 | if (de->nlink) |
420 | if (de->proc_iops) | 414 | inode->i_nlink = de->nlink; |
421 | inode->i_op = de->proc_iops; | 415 | if (de->proc_iops) |
422 | if (de->proc_fops) { | 416 | inode->i_op = de->proc_iops; |
423 | if (S_ISREG(inode->i_mode)) { | 417 | if (de->proc_fops) { |
418 | if (S_ISREG(inode->i_mode)) { | ||
424 | #ifdef CONFIG_COMPAT | 419 | #ifdef CONFIG_COMPAT |
425 | if (!de->proc_fops->compat_ioctl) | 420 | if (!de->proc_fops->compat_ioctl) |
426 | inode->i_fop = | 421 | inode->i_fop = |
427 | &proc_reg_file_ops_no_compat; | 422 | &proc_reg_file_ops_no_compat; |
428 | else | 423 | else |
429 | #endif | 424 | #endif |
430 | inode->i_fop = &proc_reg_file_ops; | 425 | inode->i_fop = &proc_reg_file_ops; |
426 | } else { | ||
427 | inode->i_fop = de->proc_fops; | ||
428 | } | ||
431 | } | 429 | } |
432 | else | ||
433 | inode->i_fop = de->proc_fops; | ||
434 | } | 430 | } |
431 | unlock_new_inode(inode); | ||
435 | } | 432 | } |
436 | |||
437 | return inode; | 433 | return inode; |
438 | 434 | ||
439 | out_ino: | 435 | out_ino: |
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c index 638bdb963213..b31ab78052b3 100644 --- a/fs/qnx4/inode.c +++ b/fs/qnx4/inode.c | |||
@@ -125,7 +125,6 @@ static int qnx4_write_inode(struct inode *inode, int unused) | |||
125 | static void qnx4_put_super(struct super_block *sb); | 125 | static void qnx4_put_super(struct super_block *sb); |
126 | static struct inode *qnx4_alloc_inode(struct super_block *sb); | 126 | static struct inode *qnx4_alloc_inode(struct super_block *sb); |
127 | static void qnx4_destroy_inode(struct inode *inode); | 127 | static void qnx4_destroy_inode(struct inode *inode); |
128 | static void qnx4_read_inode(struct inode *); | ||
129 | static int qnx4_remount(struct super_block *sb, int *flags, char *data); | 128 | static int qnx4_remount(struct super_block *sb, int *flags, char *data); |
130 | static int qnx4_statfs(struct dentry *, struct kstatfs *); | 129 | static int qnx4_statfs(struct dentry *, struct kstatfs *); |
131 | 130 | ||
@@ -133,7 +132,6 @@ static const struct super_operations qnx4_sops = | |||
133 | { | 132 | { |
134 | .alloc_inode = qnx4_alloc_inode, | 133 | .alloc_inode = qnx4_alloc_inode, |
135 | .destroy_inode = qnx4_destroy_inode, | 134 | .destroy_inode = qnx4_destroy_inode, |
136 | .read_inode = qnx4_read_inode, | ||
137 | .put_super = qnx4_put_super, | 135 | .put_super = qnx4_put_super, |
138 | .statfs = qnx4_statfs, | 136 | .statfs = qnx4_statfs, |
139 | .remount_fs = qnx4_remount, | 137 | .remount_fs = qnx4_remount, |
@@ -357,6 +355,7 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent) | |||
357 | struct inode *root; | 355 | struct inode *root; |
358 | const char *errmsg; | 356 | const char *errmsg; |
359 | struct qnx4_sb_info *qs; | 357 | struct qnx4_sb_info *qs; |
358 | int ret = -EINVAL; | ||
360 | 359 | ||
361 | qs = kzalloc(sizeof(struct qnx4_sb_info), GFP_KERNEL); | 360 | qs = kzalloc(sizeof(struct qnx4_sb_info), GFP_KERNEL); |
362 | if (!qs) | 361 | if (!qs) |
@@ -396,12 +395,14 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent) | |||
396 | } | 395 | } |
397 | 396 | ||
398 | /* does root not have inode number QNX4_ROOT_INO ?? */ | 397 | /* does root not have inode number QNX4_ROOT_INO ?? */ |
399 | root = iget(s, QNX4_ROOT_INO * QNX4_INODES_PER_BLOCK); | 398 | root = qnx4_iget(s, QNX4_ROOT_INO * QNX4_INODES_PER_BLOCK); |
400 | if (!root) { | 399 | if (IS_ERR(root)) { |
401 | printk("qnx4: get inode failed\n"); | 400 | printk("qnx4: get inode failed\n"); |
401 | ret = PTR_ERR(root); | ||
402 | goto out; | 402 | goto out; |
403 | } | 403 | } |
404 | 404 | ||
405 | ret = -ENOMEM; | ||
405 | s->s_root = d_alloc_root(root); | 406 | s->s_root = d_alloc_root(root); |
406 | if (s->s_root == NULL) | 407 | if (s->s_root == NULL) |
407 | goto outi; | 408 | goto outi; |
@@ -417,7 +418,7 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent) | |||
417 | outnobh: | 418 | outnobh: |
418 | kfree(qs); | 419 | kfree(qs); |
419 | s->s_fs_info = NULL; | 420 | s->s_fs_info = NULL; |
420 | return -EINVAL; | 421 | return ret; |
421 | } | 422 | } |
422 | 423 | ||
423 | static void qnx4_put_super(struct super_block *sb) | 424 | static void qnx4_put_super(struct super_block *sb) |
@@ -462,29 +463,38 @@ static const struct address_space_operations qnx4_aops = { | |||
462 | .bmap = qnx4_bmap | 463 | .bmap = qnx4_bmap |
463 | }; | 464 | }; |
464 | 465 | ||
465 | static void qnx4_read_inode(struct inode *inode) | 466 | struct inode *qnx4_iget(struct super_block *sb, unsigned long ino) |
466 | { | 467 | { |
467 | struct buffer_head *bh; | 468 | struct buffer_head *bh; |
468 | struct qnx4_inode_entry *raw_inode; | 469 | struct qnx4_inode_entry *raw_inode; |
469 | int block, ino; | 470 | int block; |
470 | struct super_block *sb = inode->i_sb; | 471 | struct qnx4_inode_entry *qnx4_inode; |
471 | struct qnx4_inode_entry *qnx4_inode = qnx4_raw_inode(inode); | 472 | struct inode *inode; |
472 | 473 | ||
473 | ino = inode->i_ino; | 474 | inode = iget_locked(sb, ino); |
475 | if (!inode) | ||
476 | return ERR_PTR(-ENOMEM); | ||
477 | if (!(inode->i_state & I_NEW)) | ||
478 | return inode; | ||
479 | |||
480 | qnx4_inode = qnx4_raw_inode(inode); | ||
474 | inode->i_mode = 0; | 481 | inode->i_mode = 0; |
475 | 482 | ||
476 | QNX4DEBUG(("Reading inode : [%d]\n", ino)); | 483 | QNX4DEBUG(("Reading inode : [%d]\n", ino)); |
477 | if (!ino) { | 484 | if (!ino) { |
478 | printk("qnx4: bad inode number on dev %s: %d is out of range\n", | 485 | printk(KERN_ERR "qnx4: bad inode number on dev %s: %lu is " |
486 | "out of range\n", | ||
479 | sb->s_id, ino); | 487 | sb->s_id, ino); |
480 | return; | 488 | iget_failed(inode); |
489 | return ERR_PTR(-EIO); | ||
481 | } | 490 | } |
482 | block = ino / QNX4_INODES_PER_BLOCK; | 491 | block = ino / QNX4_INODES_PER_BLOCK; |
483 | 492 | ||
484 | if (!(bh = sb_bread(sb, block))) { | 493 | if (!(bh = sb_bread(sb, block))) { |
485 | printk("qnx4: major problem: unable to read inode from dev " | 494 | printk("qnx4: major problem: unable to read inode from dev " |
486 | "%s\n", sb->s_id); | 495 | "%s\n", sb->s_id); |
487 | return; | 496 | iget_failed(inode); |
497 | return ERR_PTR(-EIO); | ||
488 | } | 498 | } |
489 | raw_inode = ((struct qnx4_inode_entry *) bh->b_data) + | 499 | raw_inode = ((struct qnx4_inode_entry *) bh->b_data) + |
490 | (ino % QNX4_INODES_PER_BLOCK); | 500 | (ino % QNX4_INODES_PER_BLOCK); |
@@ -515,9 +525,16 @@ static void qnx4_read_inode(struct inode *inode) | |||
515 | inode->i_op = &page_symlink_inode_operations; | 525 | inode->i_op = &page_symlink_inode_operations; |
516 | inode->i_mapping->a_ops = &qnx4_aops; | 526 | inode->i_mapping->a_ops = &qnx4_aops; |
517 | qnx4_i(inode)->mmu_private = inode->i_size; | 527 | qnx4_i(inode)->mmu_private = inode->i_size; |
518 | } else | 528 | } else { |
519 | printk("qnx4: bad inode %d on dev %s\n",ino,sb->s_id); | 529 | printk(KERN_ERR "qnx4: bad inode %lu on dev %s\n", |
530 | ino, sb->s_id); | ||
531 | iget_failed(inode); | ||
532 | brelse(bh); | ||
533 | return ERR_PTR(-EIO); | ||
534 | } | ||
520 | brelse(bh); | 535 | brelse(bh); |
536 | unlock_new_inode(inode); | ||
537 | return inode; | ||
521 | } | 538 | } |
522 | 539 | ||
523 | static struct kmem_cache *qnx4_inode_cachep; | 540 | static struct kmem_cache *qnx4_inode_cachep; |
diff --git a/fs/qnx4/namei.c b/fs/qnx4/namei.c index 733cdf01d645..775eed3a4085 100644 --- a/fs/qnx4/namei.c +++ b/fs/qnx4/namei.c | |||
@@ -128,10 +128,12 @@ struct dentry * qnx4_lookup(struct inode *dir, struct dentry *dentry, struct nam | |||
128 | } | 128 | } |
129 | brelse(bh); | 129 | brelse(bh); |
130 | 130 | ||
131 | if ((foundinode = iget(dir->i_sb, ino)) == NULL) { | 131 | foundinode = qnx4_iget(dir->i_sb, ino); |
132 | if (IS_ERR(foundinode)) { | ||
132 | unlock_kernel(); | 133 | unlock_kernel(); |
133 | QNX4DEBUG(("qnx4: lookup->iget -> NULL\n")); | 134 | QNX4DEBUG(("qnx4: lookup->iget -> error %ld\n", |
134 | return ERR_PTR(-EACCES); | 135 | PTR_ERR(foundinode))); |
136 | return ERR_CAST(foundinode); | ||
135 | } | 137 | } |
136 | out: | 138 | out: |
137 | unlock_kernel(); | 139 | unlock_kernel(); |
diff --git a/fs/quota.c b/fs/quota.c index 99b24b52bfc8..84f28dd72116 100644 --- a/fs/quota.c +++ b/fs/quota.c | |||
@@ -341,11 +341,11 @@ static inline struct super_block *quotactl_block(const char __user *special) | |||
341 | char *tmp = getname(special); | 341 | char *tmp = getname(special); |
342 | 342 | ||
343 | if (IS_ERR(tmp)) | 343 | if (IS_ERR(tmp)) |
344 | return ERR_PTR(PTR_ERR(tmp)); | 344 | return ERR_CAST(tmp); |
345 | bdev = lookup_bdev(tmp); | 345 | bdev = lookup_bdev(tmp); |
346 | putname(tmp); | 346 | putname(tmp); |
347 | if (IS_ERR(bdev)) | 347 | if (IS_ERR(bdev)) |
348 | return ERR_PTR(PTR_ERR(bdev)); | 348 | return ERR_CAST(bdev); |
349 | sb = get_super(bdev); | 349 | sb = get_super(bdev); |
350 | bdput(bdev); | 350 | bdput(bdev); |
351 | if (!sb) | 351 | if (!sb) |
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index 195309857e63..57917932212e 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
@@ -1536,7 +1536,7 @@ static struct dentry *reiserfs_get_dentry(struct super_block *sb, | |||
1536 | if (!inode) | 1536 | if (!inode) |
1537 | inode = ERR_PTR(-ESTALE); | 1537 | inode = ERR_PTR(-ESTALE); |
1538 | if (IS_ERR(inode)) | 1538 | if (IS_ERR(inode)) |
1539 | return ERR_PTR(PTR_ERR(inode)); | 1539 | return ERR_CAST(inode); |
1540 | result = d_alloc_anon(inode); | 1540 | result = d_alloc_anon(inode); |
1541 | if (!result) { | 1541 | if (!result) { |
1542 | iput(inode); | 1542 | iput(inode); |
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c index a5bd23ce0e46..eba037b3338f 100644 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c | |||
@@ -155,7 +155,7 @@ static struct dentry *get_xa_file_dentry(const struct inode *inode, | |||
155 | 155 | ||
156 | xadir = open_xa_dir(inode, flags); | 156 | xadir = open_xa_dir(inode, flags); |
157 | if (IS_ERR(xadir)) { | 157 | if (IS_ERR(xadir)) { |
158 | return ERR_PTR(PTR_ERR(xadir)); | 158 | return ERR_CAST(xadir); |
159 | } else if (xadir && !xadir->d_inode) { | 159 | } else if (xadir && !xadir->d_inode) { |
160 | dput(xadir); | 160 | dput(xadir); |
161 | return ERR_PTR(-ENODATA); | 161 | return ERR_PTR(-ENODATA); |
@@ -164,7 +164,7 @@ static struct dentry *get_xa_file_dentry(const struct inode *inode, | |||
164 | xafile = lookup_one_len(name, xadir, strlen(name)); | 164 | xafile = lookup_one_len(name, xadir, strlen(name)); |
165 | if (IS_ERR(xafile)) { | 165 | if (IS_ERR(xafile)) { |
166 | dput(xadir); | 166 | dput(xadir); |
167 | return ERR_PTR(PTR_ERR(xafile)); | 167 | return ERR_CAST(xafile); |
168 | } | 168 | } |
169 | 169 | ||
170 | if (xafile->d_inode) { /* file exists */ | 170 | if (xafile->d_inode) { /* file exists */ |
diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c index a49cf5b9a195..00b6f0a518c8 100644 --- a/fs/romfs/inode.c +++ b/fs/romfs/inode.c | |||
@@ -84,6 +84,8 @@ struct romfs_inode_info { | |||
84 | struct inode vfs_inode; | 84 | struct inode vfs_inode; |
85 | }; | 85 | }; |
86 | 86 | ||
87 | static struct inode *romfs_iget(struct super_block *, unsigned long); | ||
88 | |||
87 | /* instead of private superblock data */ | 89 | /* instead of private superblock data */ |
88 | static inline unsigned long romfs_maxsize(struct super_block *sb) | 90 | static inline unsigned long romfs_maxsize(struct super_block *sb) |
89 | { | 91 | { |
@@ -117,7 +119,7 @@ static int romfs_fill_super(struct super_block *s, void *data, int silent) | |||
117 | struct buffer_head *bh; | 119 | struct buffer_head *bh; |
118 | struct romfs_super_block *rsb; | 120 | struct romfs_super_block *rsb; |
119 | struct inode *root; | 121 | struct inode *root; |
120 | int sz; | 122 | int sz, ret = -EINVAL; |
121 | 123 | ||
122 | /* I would parse the options here, but there are none.. :) */ | 124 | /* I would parse the options here, but there are none.. :) */ |
123 | 125 | ||
@@ -157,10 +159,13 @@ static int romfs_fill_super(struct super_block *s, void *data, int silent) | |||
157 | & ROMFH_MASK; | 159 | & ROMFH_MASK; |
158 | 160 | ||
159 | s->s_op = &romfs_ops; | 161 | s->s_op = &romfs_ops; |
160 | root = iget(s, sz); | 162 | root = romfs_iget(s, sz); |
161 | if (!root) | 163 | if (IS_ERR(root)) { |
164 | ret = PTR_ERR(root); | ||
162 | goto out; | 165 | goto out; |
166 | } | ||
163 | 167 | ||
168 | ret = -ENOMEM; | ||
164 | s->s_root = d_alloc_root(root); | 169 | s->s_root = d_alloc_root(root); |
165 | if (!s->s_root) | 170 | if (!s->s_root) |
166 | goto outiput; | 171 | goto outiput; |
@@ -173,7 +178,7 @@ outiput: | |||
173 | out: | 178 | out: |
174 | brelse(bh); | 179 | brelse(bh); |
175 | outnobh: | 180 | outnobh: |
176 | return -EINVAL; | 181 | return ret; |
177 | } | 182 | } |
178 | 183 | ||
179 | /* That's simple too. */ | 184 | /* That's simple too. */ |
@@ -389,8 +394,11 @@ romfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | |||
389 | if ((be32_to_cpu(ri.next) & ROMFH_TYPE) == ROMFH_HRD) | 394 | if ((be32_to_cpu(ri.next) & ROMFH_TYPE) == ROMFH_HRD) |
390 | offset = be32_to_cpu(ri.spec) & ROMFH_MASK; | 395 | offset = be32_to_cpu(ri.spec) & ROMFH_MASK; |
391 | 396 | ||
392 | if ((inode = iget(dir->i_sb, offset))) | 397 | inode = romfs_iget(dir->i_sb, offset); |
393 | goto outi; | 398 | if (IS_ERR(inode)) { |
399 | res = PTR_ERR(inode); | ||
400 | goto out; | ||
401 | } | ||
394 | 402 | ||
395 | /* | 403 | /* |
396 | * it's a bit funky, _lookup needs to return an error code | 404 | * it's a bit funky, _lookup needs to return an error code |
@@ -402,7 +410,7 @@ romfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | |||
402 | */ | 410 | */ |
403 | 411 | ||
404 | out0: inode = NULL; | 412 | out0: inode = NULL; |
405 | outi: res = 0; | 413 | res = 0; |
406 | d_add (dentry, inode); | 414 | d_add (dentry, inode); |
407 | 415 | ||
408 | out: unlock_kernel(); | 416 | out: unlock_kernel(); |
@@ -478,20 +486,29 @@ static mode_t romfs_modemap[] = | |||
478 | S_IFBLK+0600, S_IFCHR+0600, S_IFSOCK+0644, S_IFIFO+0644 | 486 | S_IFBLK+0600, S_IFCHR+0600, S_IFSOCK+0644, S_IFIFO+0644 |
479 | }; | 487 | }; |
480 | 488 | ||
481 | static void | 489 | static struct inode * |
482 | romfs_read_inode(struct inode *i) | 490 | romfs_iget(struct super_block *sb, unsigned long ino) |
483 | { | 491 | { |
484 | int nextfh, ino; | 492 | int nextfh; |
485 | struct romfs_inode ri; | 493 | struct romfs_inode ri; |
494 | struct inode *i; | ||
495 | |||
496 | ino &= ROMFH_MASK; | ||
497 | i = iget_locked(sb, ino); | ||
498 | if (!i) | ||
499 | return ERR_PTR(-ENOMEM); | ||
500 | if (!(i->i_state & I_NEW)) | ||
501 | return i; | ||
486 | 502 | ||
487 | ino = i->i_ino & ROMFH_MASK; | ||
488 | i->i_mode = 0; | 503 | i->i_mode = 0; |
489 | 504 | ||
490 | /* Loop for finding the real hard link */ | 505 | /* Loop for finding the real hard link */ |
491 | for(;;) { | 506 | for(;;) { |
492 | if (romfs_copyfrom(i, &ri, ino, ROMFH_SIZE) <= 0) { | 507 | if (romfs_copyfrom(i, &ri, ino, ROMFH_SIZE) <= 0) { |
493 | printk("romfs: read error for inode 0x%x\n", ino); | 508 | printk(KERN_ERR "romfs: read error for inode 0x%lx\n", |
494 | return; | 509 | ino); |
510 | iget_failed(i); | ||
511 | return ERR_PTR(-EIO); | ||
495 | } | 512 | } |
496 | /* XXX: do romfs_checksum here too (with name) */ | 513 | /* XXX: do romfs_checksum here too (with name) */ |
497 | 514 | ||
@@ -548,6 +565,8 @@ romfs_read_inode(struct inode *i) | |||
548 | init_special_inode(i, ino, | 565 | init_special_inode(i, ino, |
549 | MKDEV(nextfh>>16,nextfh&0xffff)); | 566 | MKDEV(nextfh>>16,nextfh&0xffff)); |
550 | } | 567 | } |
568 | unlock_new_inode(i); | ||
569 | return i; | ||
551 | } | 570 | } |
552 | 571 | ||
553 | static struct kmem_cache * romfs_inode_cachep; | 572 | static struct kmem_cache * romfs_inode_cachep; |
@@ -599,7 +618,6 @@ static int romfs_remount(struct super_block *sb, int *flags, char *data) | |||
599 | static const struct super_operations romfs_ops = { | 618 | static const struct super_operations romfs_ops = { |
600 | .alloc_inode = romfs_alloc_inode, | 619 | .alloc_inode = romfs_alloc_inode, |
601 | .destroy_inode = romfs_destroy_inode, | 620 | .destroy_inode = romfs_destroy_inode, |
602 | .read_inode = romfs_read_inode, | ||
603 | .statfs = romfs_statfs, | 621 | .statfs = romfs_statfs, |
604 | .remount_fs = romfs_remount, | 622 | .remount_fs = romfs_remount, |
605 | }; | 623 | }; |
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c index 81ec6c548c07..c5d60de0658f 100644 --- a/fs/sysv/inode.c +++ b/fs/sysv/inode.c | |||
@@ -169,20 +169,27 @@ void sysv_set_inode(struct inode *inode, dev_t rdev) | |||
169 | init_special_inode(inode, inode->i_mode, rdev); | 169 | init_special_inode(inode, inode->i_mode, rdev); |
170 | } | 170 | } |
171 | 171 | ||
172 | static void sysv_read_inode(struct inode *inode) | 172 | struct inode *sysv_iget(struct super_block *sb, unsigned int ino) |
173 | { | 173 | { |
174 | struct super_block * sb = inode->i_sb; | ||
175 | struct sysv_sb_info * sbi = SYSV_SB(sb); | 174 | struct sysv_sb_info * sbi = SYSV_SB(sb); |
176 | struct buffer_head * bh; | 175 | struct buffer_head * bh; |
177 | struct sysv_inode * raw_inode; | 176 | struct sysv_inode * raw_inode; |
178 | struct sysv_inode_info * si; | 177 | struct sysv_inode_info * si; |
179 | unsigned int block, ino = inode->i_ino; | 178 | struct inode *inode; |
179 | unsigned int block; | ||
180 | 180 | ||
181 | if (!ino || ino > sbi->s_ninodes) { | 181 | if (!ino || ino > sbi->s_ninodes) { |
182 | printk("Bad inode number on dev %s: %d is out of range\n", | 182 | printk("Bad inode number on dev %s: %d is out of range\n", |
183 | inode->i_sb->s_id, ino); | 183 | sb->s_id, ino); |
184 | goto bad_inode; | 184 | return ERR_PTR(-EIO); |
185 | } | 185 | } |
186 | |||
187 | inode = iget_locked(sb, ino); | ||
188 | if (!inode) | ||
189 | return ERR_PTR(-ENOMEM); | ||
190 | if (!(inode->i_state & I_NEW)) | ||
191 | return inode; | ||
192 | |||
186 | raw_inode = sysv_raw_inode(sb, ino, &bh); | 193 | raw_inode = sysv_raw_inode(sb, ino, &bh); |
187 | if (!raw_inode) { | 194 | if (!raw_inode) { |
188 | printk("Major problem: unable to read inode from dev %s\n", | 195 | printk("Major problem: unable to read inode from dev %s\n", |
@@ -214,11 +221,12 @@ static void sysv_read_inode(struct inode *inode) | |||
214 | old_decode_dev(fs32_to_cpu(sbi, si->i_data[0]))); | 221 | old_decode_dev(fs32_to_cpu(sbi, si->i_data[0]))); |
215 | else | 222 | else |
216 | sysv_set_inode(inode, 0); | 223 | sysv_set_inode(inode, 0); |
217 | return; | 224 | unlock_new_inode(inode); |
225 | return inode; | ||
218 | 226 | ||
219 | bad_inode: | 227 | bad_inode: |
220 | make_bad_inode(inode); | 228 | iget_failed(inode); |
221 | return; | 229 | return ERR_PTR(-EIO); |
222 | } | 230 | } |
223 | 231 | ||
224 | static struct buffer_head * sysv_update_inode(struct inode * inode) | 232 | static struct buffer_head * sysv_update_inode(struct inode * inode) |
@@ -328,7 +336,6 @@ static void init_once(struct kmem_cache *cachep, void *p) | |||
328 | const struct super_operations sysv_sops = { | 336 | const struct super_operations sysv_sops = { |
329 | .alloc_inode = sysv_alloc_inode, | 337 | .alloc_inode = sysv_alloc_inode, |
330 | .destroy_inode = sysv_destroy_inode, | 338 | .destroy_inode = sysv_destroy_inode, |
331 | .read_inode = sysv_read_inode, | ||
332 | .write_inode = sysv_write_inode, | 339 | .write_inode = sysv_write_inode, |
333 | .delete_inode = sysv_delete_inode, | 340 | .delete_inode = sysv_delete_inode, |
334 | .put_super = sysv_put_super, | 341 | .put_super = sysv_put_super, |
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c index 6bd850b7641a..a1f1ef33e81c 100644 --- a/fs/sysv/namei.c +++ b/fs/sysv/namei.c | |||
@@ -53,9 +53,9 @@ static struct dentry *sysv_lookup(struct inode * dir, struct dentry * dentry, st | |||
53 | ino = sysv_inode_by_name(dentry); | 53 | ino = sysv_inode_by_name(dentry); |
54 | 54 | ||
55 | if (ino) { | 55 | if (ino) { |
56 | inode = iget(dir->i_sb, ino); | 56 | inode = sysv_iget(dir->i_sb, ino); |
57 | if (!inode) | 57 | if (IS_ERR(inode)) |
58 | return ERR_PTR(-EACCES); | 58 | return ERR_CAST(inode); |
59 | } | 59 | } |
60 | d_add(dentry, inode); | 60 | d_add(dentry, inode); |
61 | return NULL; | 61 | return NULL; |
diff --git a/fs/sysv/super.c b/fs/sysv/super.c index 6f9707a1b954..5a903da54551 100644 --- a/fs/sysv/super.c +++ b/fs/sysv/super.c | |||
@@ -332,8 +332,8 @@ static int complete_read_super(struct super_block *sb, int silent, int size) | |||
332 | sb->s_magic = SYSV_MAGIC_BASE + sbi->s_type; | 332 | sb->s_magic = SYSV_MAGIC_BASE + sbi->s_type; |
333 | /* set up enough so that it can read an inode */ | 333 | /* set up enough so that it can read an inode */ |
334 | sb->s_op = &sysv_sops; | 334 | sb->s_op = &sysv_sops; |
335 | root_inode = iget(sb,SYSV_ROOT_INO); | 335 | root_inode = sysv_iget(sb, SYSV_ROOT_INO); |
336 | if (!root_inode || is_bad_inode(root_inode)) { | 336 | if (IS_ERR(root_inode)) { |
337 | printk("SysV FS: get root inode failed\n"); | 337 | printk("SysV FS: get root inode failed\n"); |
338 | return 0; | 338 | return 0; |
339 | } | 339 | } |
diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h index 64c03bdf06a5..42d51d1c05cd 100644 --- a/fs/sysv/sysv.h +++ b/fs/sysv/sysv.h | |||
@@ -141,6 +141,7 @@ extern int __sysv_write_begin(struct file *file, struct address_space *mapping, | |||
141 | struct page **pagep, void **fsdata); | 141 | struct page **pagep, void **fsdata); |
142 | 142 | ||
143 | /* inode.c */ | 143 | /* inode.c */ |
144 | extern struct inode *sysv_iget(struct super_block *, unsigned int); | ||
144 | extern int sysv_write_inode(struct inode *, int); | 145 | extern int sysv_write_inode(struct inode *, int); |
145 | extern int sysv_sync_inode(struct inode *); | 146 | extern int sysv_sync_inode(struct inode *); |
146 | extern int sysv_sync_file(struct file *, struct dentry *, int); | 147 | extern int sysv_sync_file(struct file *, struct dentry *, int); |
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 4320782761ae..489f26bc26d9 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c | |||
@@ -714,26 +714,30 @@ static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode) | |||
714 | return 0; | 714 | return 0; |
715 | } | 715 | } |
716 | 716 | ||
717 | void ufs_read_inode(struct inode * inode) | 717 | struct inode *ufs_iget(struct super_block *sb, unsigned long ino) |
718 | { | 718 | { |
719 | struct ufs_inode_info *ufsi = UFS_I(inode); | 719 | struct ufs_inode_info *ufsi; |
720 | struct super_block * sb; | 720 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; |
721 | struct ufs_sb_private_info * uspi; | ||
722 | struct buffer_head * bh; | 721 | struct buffer_head * bh; |
722 | struct inode *inode; | ||
723 | int err; | 723 | int err; |
724 | 724 | ||
725 | UFSD("ENTER, ino %lu\n", inode->i_ino); | 725 | UFSD("ENTER, ino %lu\n", ino); |
726 | |||
727 | sb = inode->i_sb; | ||
728 | uspi = UFS_SB(sb)->s_uspi; | ||
729 | 726 | ||
730 | if (inode->i_ino < UFS_ROOTINO || | 727 | if (ino < UFS_ROOTINO || ino > (uspi->s_ncg * uspi->s_ipg)) { |
731 | inode->i_ino > (uspi->s_ncg * uspi->s_ipg)) { | ||
732 | ufs_warning(sb, "ufs_read_inode", "bad inode number (%lu)\n", | 728 | ufs_warning(sb, "ufs_read_inode", "bad inode number (%lu)\n", |
733 | inode->i_ino); | 729 | ino); |
734 | goto bad_inode; | 730 | return ERR_PTR(-EIO); |
735 | } | 731 | } |
736 | 732 | ||
733 | inode = iget_locked(sb, ino); | ||
734 | if (!inode) | ||
735 | return ERR_PTR(-ENOMEM); | ||
736 | if (!(inode->i_state & I_NEW)) | ||
737 | return inode; | ||
738 | |||
739 | ufsi = UFS_I(inode); | ||
740 | |||
737 | bh = sb_bread(sb, uspi->s_sbbase + ufs_inotofsba(inode->i_ino)); | 741 | bh = sb_bread(sb, uspi->s_sbbase + ufs_inotofsba(inode->i_ino)); |
738 | if (!bh) { | 742 | if (!bh) { |
739 | ufs_warning(sb, "ufs_read_inode", "unable to read inode %lu\n", | 743 | ufs_warning(sb, "ufs_read_inode", "unable to read inode %lu\n", |
@@ -765,10 +769,12 @@ void ufs_read_inode(struct inode * inode) | |||
765 | brelse(bh); | 769 | brelse(bh); |
766 | 770 | ||
767 | UFSD("EXIT\n"); | 771 | UFSD("EXIT\n"); |
768 | return; | 772 | unlock_new_inode(inode); |
773 | return inode; | ||
769 | 774 | ||
770 | bad_inode: | 775 | bad_inode: |
771 | make_bad_inode(inode); | 776 | iget_failed(inode); |
777 | return ERR_PTR(-EIO); | ||
772 | } | 778 | } |
773 | 779 | ||
774 | static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode) | 780 | static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode) |
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index d8bfbee2fe2b..747a4de6c695 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c | |||
@@ -57,10 +57,10 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, stru | |||
57 | lock_kernel(); | 57 | lock_kernel(); |
58 | ino = ufs_inode_by_name(dir, dentry); | 58 | ino = ufs_inode_by_name(dir, dentry); |
59 | if (ino) { | 59 | if (ino) { |
60 | inode = iget(dir->i_sb, ino); | 60 | inode = ufs_iget(dir->i_sb, ino); |
61 | if (!inode) { | 61 | if (IS_ERR(inode)) { |
62 | unlock_kernel(); | 62 | unlock_kernel(); |
63 | return ERR_PTR(-EACCES); | 63 | return ERR_CAST(inode); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | unlock_kernel(); | 66 | unlock_kernel(); |
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 0072cb33ebec..73deff475e63 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
@@ -633,6 +633,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
633 | unsigned block_size, super_block_size; | 633 | unsigned block_size, super_block_size; |
634 | unsigned flags; | 634 | unsigned flags; |
635 | unsigned super_block_offset; | 635 | unsigned super_block_offset; |
636 | int ret = -EINVAL; | ||
636 | 637 | ||
637 | uspi = NULL; | 638 | uspi = NULL; |
638 | ubh = NULL; | 639 | ubh = NULL; |
@@ -1065,12 +1066,16 @@ magic_found: | |||
1065 | uspi->s_maxsymlinklen = | 1066 | uspi->s_maxsymlinklen = |
1066 | fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen); | 1067 | fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen); |
1067 | 1068 | ||
1068 | inode = iget(sb, UFS_ROOTINO); | 1069 | inode = ufs_iget(sb, UFS_ROOTINO); |
1069 | if (!inode || is_bad_inode(inode)) | 1070 | if (IS_ERR(inode)) { |
1071 | ret = PTR_ERR(inode); | ||
1070 | goto failed; | 1072 | goto failed; |
1073 | } | ||
1071 | sb->s_root = d_alloc_root(inode); | 1074 | sb->s_root = d_alloc_root(inode); |
1072 | if (!sb->s_root) | 1075 | if (!sb->s_root) { |
1076 | ret = -ENOMEM; | ||
1073 | goto dalloc_failed; | 1077 | goto dalloc_failed; |
1078 | } | ||
1074 | 1079 | ||
1075 | ufs_setup_cstotal(sb); | 1080 | ufs_setup_cstotal(sb); |
1076 | /* | 1081 | /* |
@@ -1092,7 +1097,7 @@ failed: | |||
1092 | kfree(sbi); | 1097 | kfree(sbi); |
1093 | sb->s_fs_info = NULL; | 1098 | sb->s_fs_info = NULL; |
1094 | UFSD("EXIT (FAILED)\n"); | 1099 | UFSD("EXIT (FAILED)\n"); |
1095 | return -EINVAL; | 1100 | return ret; |
1096 | 1101 | ||
1097 | failed_nomem: | 1102 | failed_nomem: |
1098 | UFSD("EXIT (NOMEM)\n"); | 1103 | UFSD("EXIT (NOMEM)\n"); |
@@ -1326,7 +1331,6 @@ static ssize_t ufs_quota_write(struct super_block *, int, const char *, size_t, | |||
1326 | static const struct super_operations ufs_super_ops = { | 1331 | static const struct super_operations ufs_super_ops = { |
1327 | .alloc_inode = ufs_alloc_inode, | 1332 | .alloc_inode = ufs_alloc_inode, |
1328 | .destroy_inode = ufs_destroy_inode, | 1333 | .destroy_inode = ufs_destroy_inode, |
1329 | .read_inode = ufs_read_inode, | ||
1330 | .write_inode = ufs_write_inode, | 1334 | .write_inode = ufs_write_inode, |
1331 | .delete_inode = ufs_delete_inode, | 1335 | .delete_inode = ufs_delete_inode, |
1332 | .put_super = ufs_put_super, | 1336 | .put_super = ufs_put_super, |
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h index 7faa4cd71a27..fcb9231bb9ed 100644 --- a/fs/ufs/ufs.h +++ b/fs/ufs/ufs.h | |||
@@ -106,7 +106,7 @@ extern void ufs_free_inode (struct inode *inode); | |||
106 | extern struct inode * ufs_new_inode (struct inode *, int); | 106 | extern struct inode * ufs_new_inode (struct inode *, int); |
107 | 107 | ||
108 | /* inode.c */ | 108 | /* inode.c */ |
109 | extern void ufs_read_inode (struct inode *); | 109 | extern struct inode *ufs_iget(struct super_block *, unsigned long); |
110 | extern void ufs_put_inode (struct inode *); | 110 | extern void ufs_put_inode (struct inode *); |
111 | extern int ufs_write_inode (struct inode *, int); | 111 | extern int ufs_write_inode (struct inode *, int); |
112 | extern int ufs_sync_inode (struct inode *); | 112 | extern int ufs_sync_inode (struct inode *); |
diff --git a/fs/vfat/namei.c b/fs/vfat/namei.c index c28add2fbe95..cd450bea9f1a 100644 --- a/fs/vfat/namei.c +++ b/fs/vfat/namei.c | |||
@@ -705,7 +705,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, | |||
705 | brelse(sinfo.bh); | 705 | brelse(sinfo.bh); |
706 | if (IS_ERR(inode)) { | 706 | if (IS_ERR(inode)) { |
707 | unlock_kernel(); | 707 | unlock_kernel(); |
708 | return ERR_PTR(PTR_ERR(inode)); | 708 | return ERR_CAST(inode); |
709 | } | 709 | } |
710 | alias = d_find_alias(inode); | 710 | alias = d_find_alias(inode); |
711 | if (alias) { | 711 | if (alias) { |