]> git.karo-electronics.de Git - linux-beck.git/commitdiff
make d_splice_alias(ERR_PTR(err), dentry) = ERR_PTR(err)
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 9 Jul 2011 01:20:11 +0000 (21:20 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 20 Jul 2011 05:44:26 +0000 (01:44 -0400)
... and simplify the living hell out of callers

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 files changed:
fs/btrfs/inode.c
fs/dcache.c
fs/efs/namei.c
fs/exofs/namei.c
fs/ext2/namei.c
fs/ext3/namei.c
fs/ext4/namei.c
fs/fat/namei_msdos.c
fs/isofs/namei.c
fs/jffs2/dir.c
fs/jfs/namei.c
fs/logfs/dir.c
fs/nilfs2/namei.c
fs/squashfs/namei.c
fs/ufs/namei.c

index ecf0fac712d680657452378c7341e1d650ce3189..bcb20a9a3b9366a14bbb0f2ef669c8b1baa335ac 100644 (file)
@@ -4079,13 +4079,7 @@ static int btrfs_dentry_delete(const struct dentry *dentry)
 static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry,
                                   struct nameidata *nd)
 {
-       struct inode *inode;
-
-       inode = btrfs_lookup_dentry(dir, dentry);
-       if (IS_ERR(inode))
-               return ERR_CAST(inode);
-
-       return d_splice_alias(inode, dentry);
+       return d_splice_alias(btrfs_lookup_dentry(dir, dentry), dentry);
 }
 
 unsigned char btrfs_filetype_table[] = {
index c61edd0318c3aa1c73605d3a8487e9f62e4f2458..41e2085d430bd3aa16c53d608335ffc1aee487fd 100644 (file)
@@ -1652,6 +1652,9 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
 {
        struct dentry *new = NULL;
 
+       if (IS_ERR(inode))
+               return ERR_CAST(inode);
+
        if (inode && S_ISDIR(inode->i_mode)) {
                spin_lock(&inode->i_lock);
                new = __d_find_alias(inode, 1);
index 1511bf9e5f80b524117dac9870c99a60ba9a72e4..832b10ded82f599c27569801bf00ee8f95beff14 100644 (file)
@@ -60,14 +60,11 @@ static efs_ino_t efs_find_entry(struct inode *inode, const char *name, int len)
 
 struct dentry *efs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) {
        efs_ino_t inodenum;
-       struct inode * inode = NULL;
+       struct inode *inode = NULL;
 
        inodenum = efs_find_entry(dir, dentry->d_name.name, dentry->d_name.len);
-       if (inodenum) {
+       if (inodenum)
                inode = efs_iget(dir->i_sb, inodenum);
-               if (IS_ERR(inode))
-                       return ERR_CAST(inode);
-       }
 
        return d_splice_alias(inode, dentry);
 }
index 4d70db110cfc4d8585bf77f1f02061f66fab4127..b54c43775f17850bc0397089c179363aa2547274 100644 (file)
@@ -55,12 +55,7 @@ static struct dentry *exofs_lookup(struct inode *dir, struct dentry *dentry,
                return ERR_PTR(-ENAMETOOLONG);
 
        ino = exofs_inode_by_name(dir, dentry);
-       inode = NULL;
-       if (ino) {
-               inode = exofs_iget(dir->i_sb, ino);
-               if (IS_ERR(inode))
-                       return ERR_CAST(inode);
-       }
+       inode = ino ? exofs_iget(dir->i_sb, ino) : NULL;
        return d_splice_alias(inode, dentry);
 }
 
index ed5c5d496ee914aacd5e0d3ea6c7dcd98d319794..d60b7099e2db3c649be7707924575891bd3d77d1 100644 (file)
@@ -67,15 +67,11 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str
        inode = NULL;
        if (ino) {
                inode = ext2_iget(dir->i_sb, ino);
-               if (IS_ERR(inode)) {
-                       if (PTR_ERR(inode) == -ESTALE) {
-                               ext2_error(dir->i_sb, __func__,
-                                               "deleted inode referenced: %lu",
-                                               (unsigned long) ino);
-                               return ERR_PTR(-EIO);
-                       } else {
-                               return ERR_CAST(inode);
-                       }
+               if (inode == ERR_PTR(-ESTALE)) {
+                       ext2_error(dir->i_sb, __func__,
+                                       "deleted inode referenced: %lu",
+                                       (unsigned long) ino);
+                       return ERR_PTR(-EIO);
                }
        }
        return d_splice_alias(inode, dentry);
index 34b6d9bfc48a511de1a4e52bbb778cdd10a519b6..c095cf5640c79c4462ed0a60cd7aed5fd8c5472f 100644 (file)
@@ -1038,15 +1038,11 @@ static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry, str
                        return ERR_PTR(-EIO);
                }
                inode = ext3_iget(dir->i_sb, ino);
-               if (IS_ERR(inode)) {
-                       if (PTR_ERR(inode) == -ESTALE) {
-                               ext3_error(dir->i_sb, __func__,
-                                               "deleted inode referenced: %lu",
-                                               ino);
-                               return ERR_PTR(-EIO);
-                       } else {
-                               return ERR_CAST(inode);
-                       }
+               if (inode == ERR_PTR(-ESTALE)) {
+                       ext3_error(dir->i_sb, __func__,
+                                       "deleted inode referenced: %lu",
+                                       ino);
+                       return ERR_PTR(-EIO);
                }
        }
        return d_splice_alias(inode, dentry);
index b754b7721f51fea4dd943a68e436fe5677f301a0..707d605bf76985dfe0b873b8fccda9c6459682b1 100644 (file)
@@ -1037,15 +1037,11 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru
                        return ERR_PTR(-EIO);
                }
                inode = ext4_iget(dir->i_sb, ino);
-               if (IS_ERR(inode)) {
-                       if (PTR_ERR(inode) == -ESTALE) {
-                               EXT4_ERROR_INODE(dir,
-                                                "deleted inode referenced: %u",
-                                                ino);
-                               return ERR_PTR(-EIO);
-                       } else {
-                               return ERR_CAST(inode);
-                       }
+               if (inode == ERR_PTR(-ESTALE)) {
+                       EXT4_ERROR_INODE(dir,
+                                        "deleted inode referenced: %u",
+                                        ino);
+                       return ERR_PTR(-EIO);
                }
        }
        return d_splice_alias(inode, dentry);
index 3b222dafd15b7eb6fa8f8b425a407f8a70dc7a19..66e83b84545572d86e07ee7c8a3470f2641a007f 100644 (file)
@@ -209,29 +209,20 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
        int err;
 
        lock_super(sb);
-
        err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
-       if (err) {
-               if (err == -ENOENT) {
-                       inode = NULL;
-                       goto out;
-               }
-               goto error;
-       }
-
-       inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
-       brelse(sinfo.bh);
-       if (IS_ERR(inode)) {
-               err = PTR_ERR(inode);
-               goto error;
+       switch (err) {
+       case -ENOENT:
+               inode = NULL;
+               break;
+       case 0:
+               inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
+               brelse(sinfo.bh);
+               break;
+       default:
+               inode = ERR_PTR(err);
        }
-out:
        unlock_super(sb);
        return d_splice_alias(inode, dentry);
-
-error:
-       unlock_super(sb);
-       return ERR_PTR(err);
 }
 
 /***** Creates a directory entry (name is already formatted). */
index 4fb3e8074fd46619d3fa3ec554a148039b49ce4a..68fa503d877e0c515c09d906aac176bfd33dc4c4 100644 (file)
@@ -183,14 +183,9 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam
                                1024 + page_address(page));
        __free_page(page);
 
-       inode = NULL;
-       if (found) {
-               inode = isofs_iget(dir->i_sb, block, offset);
-               if (IS_ERR(inode)) {
-                       mutex_unlock(&sbi->s_mutex);
-                       return ERR_CAST(inode);
-               }
-       }
+       inode = found ? isofs_iget(dir->i_sb, block, offset) : NULL;
+
        mutex_unlock(&sbi->s_mutex);
+
        return d_splice_alias(inode, dentry);
 }
index 4bca6a2e5c07431628b5acb9c201bb4daf56ba55..8f40ce4f1777c62ef593f0168510ed06859fa34a 100644 (file)
@@ -102,10 +102,8 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target,
        mutex_unlock(&dir_f->sem);
        if (ino) {
                inode = jffs2_iget(dir_i->i_sb, ino);
-               if (IS_ERR(inode)) {
+               if (IS_ERR(inode))
                        printk(KERN_WARNING "iget() failed for ino #%u\n", ino);
-                       return ERR_CAST(inode);
-               }
        }
 
        return d_splice_alias(inode, target);
index 1da0dc7992863858cd7c2fbcefd4c756aecf37de..247331551992bec8b1876f3c745f66e0c0dd0e7b 100644 (file)
@@ -1481,10 +1481,8 @@ static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, struc
        }
 
        ip = jfs_iget(dip->i_sb, inum);
-       if (IS_ERR(ip)) {
+       if (IS_ERR(ip))
                jfs_err("jfs_lookup: iget failed on inum %d", (uint) inum);
-               return ERR_CAST(ip);
-       }
 
        return d_splice_alias(ip, dentry);
 }
index 1afae26cf2364936d3053801c41f12cbb06f29d9..b3ff3d894165f6ae0ef2108e656f9eef904f4fa8 100644 (file)
@@ -371,11 +371,9 @@ static struct dentry *logfs_lookup(struct inode *dir, struct dentry *dentry,
        page_cache_release(page);
 
        inode = logfs_iget(dir->i_sb, ino);
-       if (IS_ERR(inode)) {
+       if (IS_ERR(inode))
                printk(KERN_ERR"LogFS: Cannot read inode #%llx for dentry (%lx, %lx)n",
                                ino, dir->i_ino, index);
-               return ERR_CAST(inode);
-       }
        return d_splice_alias(inode, dentry);
 }
 
index 546849b3e88f1935585067628e158f4233631d17..a3141990061e28ec19b8997b132f2d3eb4bcc63b 100644 (file)
@@ -72,12 +72,7 @@ nilfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
                return ERR_PTR(-ENAMETOOLONG);
 
        ino = nilfs_inode_by_name(dir, &dentry->d_name);
-       inode = NULL;
-       if (ino) {
-               inode = nilfs_iget(dir->i_sb, NILFS_I(dir)->i_root, ino);
-               if (IS_ERR(inode))
-                       return ERR_CAST(inode);
-       }
+       inode = ino ? nilfs_iget(dir->i_sb, NILFS_I(dir)->i_root, ino) : NULL;
        return d_splice_alias(inode, dentry);
 }
 
index 51b36958492b0e335ab5a4fadd6cef7026643504..0682b38d7e316beecc2c8ffe0a5c29b5e4997288 100644 (file)
@@ -220,11 +220,6 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry,
                                        blk, off, ino_num);
 
                                inode = squashfs_iget(dir->i_sb, ino, ino_num);
-                               if (IS_ERR(inode)) {
-                                       err = PTR_ERR(inode);
-                                       goto failed;
-                               }
-
                                goto exit_lookup;
                        }
                }
index b57aab9a1184719a027715d16786a54cdbd43d70..639d49162241f6bddd190d1cf73d3ec5e579da94 100644 (file)
@@ -59,8 +59,6 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, stru
        if (ino)
                inode = ufs_iget(dir->i_sb, ino);
        unlock_ufs(dir->i_sb);
-       if (IS_ERR(inode))
-               return ERR_CAST(inode);
        return d_splice_alias(inode, dentry);
 }