]> err.no Git - linux-2.6/commitdiff
iget: stop AFFS from using iget() and read_inode()
authorDavid Howells <dhowells@redhat.com>
Thu, 7 Feb 2008 08:15:29 +0000 (00:15 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Thu, 7 Feb 2008 16:42:27 +0000 (08:42 -0800)
Stop the AFFS filesystem from using iget() and read_inode().  Replace
affs_read_inode() with affs_iget(), and call that instead of iget().
affs_iget() then uses iget_locked() directly and returns a proper error code
instead of an inode in the event of an error.

affs_fill_super() returns any error incurred when getting the root inode
instead of EINVAL.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Roman Zippel <zippel@linux-m68k.org>
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>
fs/affs/affs.h
fs/affs/amigaffs.c
fs/affs/inode.c
fs/affs/namei.c
fs/affs/super.c

index 232c694936836f123cecb5f5ab670ffed2d69657..d5bd497ab9cbd5154ade0781ed3bffbe3d83aeb7 100644 (file)
@@ -174,7 +174,8 @@ extern void                  affs_put_inode(struct inode *inode);
 extern void                     affs_drop_inode(struct inode *inode);
 extern void                     affs_delete_inode(struct inode *inode);
 extern void                     affs_clear_inode(struct inode *inode);
-extern void                     affs_read_inode(struct inode *inode);
+extern struct inode            *affs_iget(struct super_block *sb,
+                                       unsigned long ino);
 extern int                      affs_write_inode(struct inode *inode, int);
 extern int                      affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s32 type);
 
index f4de4b98004fa1f9f08cbe2c6310eb805aaafd1d..805573005de66614cec77f00f83593c61fa1f027 100644 (file)
@@ -170,9 +170,11 @@ affs_remove_link(struct dentry *dentry)
                if (!link_bh)
                        goto done;
 
-               dir = iget(sb, be32_to_cpu(AFFS_TAIL(sb, link_bh)->parent));
-               if (!dir)
+               dir = affs_iget(sb, be32_to_cpu(AFFS_TAIL(sb, link_bh)->parent));
+               if (IS_ERR(dir)) {
+                       retval = PTR_ERR(dir);
                        goto done;
+               }
 
                affs_lock_dir(dir);
                affs_fix_dcache(dentry, link_ino);
index 4609a6c13fe917552b6121a5b964767e8ba76800..27fe6cbe43ae84bc1582f8e86131cebb1566eb1e 100644 (file)
 extern const struct inode_operations affs_symlink_inode_operations;
 extern struct timezone sys_tz;
 
-void
-affs_read_inode(struct inode *inode)
+struct inode *affs_iget(struct super_block *sb, unsigned long ino)
 {
-       struct super_block      *sb = inode->i_sb;
        struct affs_sb_info     *sbi = AFFS_SB(sb);
        struct buffer_head      *bh;
        struct affs_head        *head;
        struct affs_tail        *tail;
+       struct inode            *inode;
        u32                      block;
        u32                      size;
        u32                      prot;
        u16                      id;
 
-       pr_debug("AFFS: read_inode(%lu)\n",inode->i_ino);
+       inode = iget_locked(sb, ino);
+       if (!inode)
+               return ERR_PTR(-ENOMEM);
+       if (!(inode->i_state & I_NEW))
+               return inode;
+
+       pr_debug("AFFS: affs_iget(%lu)\n", inode->i_ino);
 
        block = inode->i_ino;
        bh = affs_bread(sb, block);
@@ -154,12 +159,13 @@ affs_read_inode(struct inode *inode)
                         sys_tz.tz_minuteswest * 60;
        inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_atime.tv_nsec = 0;
        affs_brelse(bh);
-       return;
+       unlock_new_inode(inode);
+       return inode;
 
 bad_inode:
-       make_bad_inode(inode);
        affs_brelse(bh);
-       return;
+       iget_failed(inode);
+       return ERR_PTR(-EIO);
 }
 
 int
index b407e9eea3fbf96a290255b4c881705f4e03c372..2218f1ee71ce1c2cc146ccd876d614c78fce94cd 100644 (file)
@@ -208,9 +208,8 @@ affs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
        affs_lock_dir(dir);
        bh = affs_find_entry(dir, dentry);
        affs_unlock_dir(dir);
-       if (IS_ERR(bh)) {
+       if (IS_ERR(bh))
                return ERR_CAST(bh);
-       }
        if (bh) {
                u32 ino = bh->b_blocknr;
 
@@ -223,10 +222,9 @@ affs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
                        ino = be32_to_cpu(AFFS_TAIL(sb, bh)->original);
                }
                affs_brelse(bh);
-               inode = iget(sb, ino);
-               if (!inode) {
-                       return ERR_PTR(-EACCES);
-               }
+               inode = affs_iget(sb, ino);
+               if (IS_ERR(inode))
+                       return ERR_PTR(PTR_ERR(inode));
        }
        dentry->d_op = AFFS_SB(sb)->s_flags & SF_INTL ? &affs_intl_dentry_operations : &affs_dentry_operations;
        d_add(dentry, inode);
index b53e5d0ec65c4b3fd52417dab5c85cdd176ebb76..3c45d49c0d26046780c79e9d15da0a1e39550f68 100644 (file)
@@ -113,7 +113,6 @@ static void destroy_inodecache(void)
 static const struct super_operations affs_sops = {
        .alloc_inode    = affs_alloc_inode,
        .destroy_inode  = affs_destroy_inode,
-       .read_inode     = affs_read_inode,
        .write_inode    = affs_write_inode,
        .put_inode      = affs_put_inode,
        .drop_inode     = affs_drop_inode,
@@ -271,6 +270,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
        unsigned long            mount_flags;
        int                      tmp_flags;     /* fix remount prototype... */
        u8                       sig[4];
+       int                      ret = -EINVAL;
 
        pr_debug("AFFS: read_super(%s)\n",data ? (const char *)data : "no options");
 
@@ -444,7 +444,12 @@ got_root:
 
        /* set up enough so that it can read an inode */
 
-       root_inode = iget(sb, root_block);
+       root_inode = affs_iget(sb, root_block);
+       if (IS_ERR(root_inode)) {
+               ret = PTR_ERR(root_inode);
+               goto out_error_noinode;
+       }
+
        sb->s_root = d_alloc_root(root_inode);
        if (!sb->s_root) {
                printk(KERN_ERR "AFFS: Get root inode failed\n");
@@ -461,12 +466,13 @@ got_root:
 out_error:
        if (root_inode)
                iput(root_inode);
+out_error_noinode:
        kfree(sbi->s_bitmap);
        affs_brelse(root_bh);
        kfree(sbi->s_prefix);
        kfree(sbi);
        sb->s_fs_info = NULL;
-       return -EINVAL;
+       return ret;
 }
 
 static int