aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-02-07 03:15:43 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:28 -0500
commiteab1df71a0ef6d333b9b826deaa0d0eb4b4f69dc (patch)
tree70d73e349ab1af57b1975762d9c1170f43de3562
parent5451f79f5f817880958ed063864ad268d94ccd1f (diff)
iget: stop JFS from using iget() and read_inode()
Stop the JFS filesystem from using iget() and read_inode(). Replace jfs_read_inode() with jfs_iget(), and call that instead of iget(). jfs_iget() then uses iget_locked() directly and returns a proper error code instead of an inode in the event of an error. jfs_fill_super() returns any error incurred when getting the root inode instead of EINVAL. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com> Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/jfs/inode.c20
-rw-r--r--fs/jfs/jfs_inode.h2
-rw-r--r--fs/jfs/namei.c34
-rw-r--r--fs/jfs/super.c15
4 files changed, 40 insertions, 31 deletions
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
34void jfs_read_inode(struct inode *inode) 34struct 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);
24extern int jfs_fsync(struct file *, struct dentry *, int); 24extern int jfs_fsync(struct file *, struct dentry *, int);
25extern int jfs_ioctl(struct inode *, struct file *, 25extern int jfs_ioctl(struct inode *, struct file *,
26 unsigned int, unsigned long); 26 unsigned int, unsigned long);
27extern void jfs_read_inode(struct inode *); 27extern struct inode *jfs_iget(struct super_block *, unsigned long);
28extern int jfs_commit_inode(struct inode *, int); 28extern int jfs_commit_inode(struct inode *, int);
29extern int jfs_write_inode(struct inode*, int); 29extern int jfs_write_inode(struct inode*, int);
30extern void jfs_delete_inode(struct inode *); 30extern 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
542static void jfs_write_super_lockfs(struct super_block *sb) 546static void jfs_write_super_lockfs(struct super_block *sb)
@@ -726,7 +730,6 @@ out:
726static const struct super_operations jfs_super_operations = { 730static 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,