Commit a9049376ee05bf966bfe2b081b5071326856890a
1 parent
0c1aa9a952
Exists in
master
and in
38 other branches
make d_splice_alias(ERR_PTR(err), dentry) = ERR_PTR(err)
... and simplify the living hell out of callers Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 15 changed files with 39 additions and 94 deletions Side-by-side Diff
fs/btrfs/inode.c
... | ... | @@ -4079,13 +4079,7 @@ |
4079 | 4079 | static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry, |
4080 | 4080 | struct nameidata *nd) |
4081 | 4081 | { |
4082 | - struct inode *inode; | |
4083 | - | |
4084 | - inode = btrfs_lookup_dentry(dir, dentry); | |
4085 | - if (IS_ERR(inode)) | |
4086 | - return ERR_CAST(inode); | |
4087 | - | |
4088 | - return d_splice_alias(inode, dentry); | |
4082 | + return d_splice_alias(btrfs_lookup_dentry(dir, dentry), dentry); | |
4089 | 4083 | } |
4090 | 4084 | |
4091 | 4085 | unsigned char btrfs_filetype_table[] = { |
fs/dcache.c
fs/efs/namei.c
... | ... | @@ -60,14 +60,11 @@ |
60 | 60 | |
61 | 61 | struct dentry *efs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) { |
62 | 62 | efs_ino_t inodenum; |
63 | - struct inode * inode = NULL; | |
63 | + struct inode *inode = NULL; | |
64 | 64 | |
65 | 65 | inodenum = efs_find_entry(dir, dentry->d_name.name, dentry->d_name.len); |
66 | - if (inodenum) { | |
66 | + if (inodenum) | |
67 | 67 | inode = efs_iget(dir->i_sb, inodenum); |
68 | - if (IS_ERR(inode)) | |
69 | - return ERR_CAST(inode); | |
70 | - } | |
71 | 68 | |
72 | 69 | return d_splice_alias(inode, dentry); |
73 | 70 | } |
fs/exofs/namei.c
... | ... | @@ -55,12 +55,7 @@ |
55 | 55 | return ERR_PTR(-ENAMETOOLONG); |
56 | 56 | |
57 | 57 | ino = exofs_inode_by_name(dir, dentry); |
58 | - inode = NULL; | |
59 | - if (ino) { | |
60 | - inode = exofs_iget(dir->i_sb, ino); | |
61 | - if (IS_ERR(inode)) | |
62 | - return ERR_CAST(inode); | |
63 | - } | |
58 | + inode = ino ? exofs_iget(dir->i_sb, ino) : NULL; | |
64 | 59 | return d_splice_alias(inode, dentry); |
65 | 60 | } |
66 | 61 |
fs/ext2/namei.c
... | ... | @@ -67,15 +67,11 @@ |
67 | 67 | inode = NULL; |
68 | 68 | if (ino) { |
69 | 69 | inode = ext2_iget(dir->i_sb, ino); |
70 | - if (IS_ERR(inode)) { | |
71 | - if (PTR_ERR(inode) == -ESTALE) { | |
72 | - ext2_error(dir->i_sb, __func__, | |
73 | - "deleted inode referenced: %lu", | |
74 | - (unsigned long) ino); | |
75 | - return ERR_PTR(-EIO); | |
76 | - } else { | |
77 | - return ERR_CAST(inode); | |
78 | - } | |
70 | + if (inode == ERR_PTR(-ESTALE)) { | |
71 | + ext2_error(dir->i_sb, __func__, | |
72 | + "deleted inode referenced: %lu", | |
73 | + (unsigned long) ino); | |
74 | + return ERR_PTR(-EIO); | |
79 | 75 | } |
80 | 76 | } |
81 | 77 | return d_splice_alias(inode, dentry); |
fs/ext3/namei.c
... | ... | @@ -1038,15 +1038,11 @@ |
1038 | 1038 | return ERR_PTR(-EIO); |
1039 | 1039 | } |
1040 | 1040 | inode = ext3_iget(dir->i_sb, ino); |
1041 | - if (IS_ERR(inode)) { | |
1042 | - if (PTR_ERR(inode) == -ESTALE) { | |
1043 | - ext3_error(dir->i_sb, __func__, | |
1044 | - "deleted inode referenced: %lu", | |
1045 | - ino); | |
1046 | - return ERR_PTR(-EIO); | |
1047 | - } else { | |
1048 | - return ERR_CAST(inode); | |
1049 | - } | |
1041 | + if (inode == ERR_PTR(-ESTALE)) { | |
1042 | + ext3_error(dir->i_sb, __func__, | |
1043 | + "deleted inode referenced: %lu", | |
1044 | + ino); | |
1045 | + return ERR_PTR(-EIO); | |
1050 | 1046 | } |
1051 | 1047 | } |
1052 | 1048 | return d_splice_alias(inode, dentry); |
fs/ext4/namei.c
... | ... | @@ -1037,15 +1037,11 @@ |
1037 | 1037 | return ERR_PTR(-EIO); |
1038 | 1038 | } |
1039 | 1039 | inode = ext4_iget(dir->i_sb, ino); |
1040 | - if (IS_ERR(inode)) { | |
1041 | - if (PTR_ERR(inode) == -ESTALE) { | |
1042 | - EXT4_ERROR_INODE(dir, | |
1043 | - "deleted inode referenced: %u", | |
1044 | - ino); | |
1045 | - return ERR_PTR(-EIO); | |
1046 | - } else { | |
1047 | - return ERR_CAST(inode); | |
1048 | - } | |
1040 | + if (inode == ERR_PTR(-ESTALE)) { | |
1041 | + EXT4_ERROR_INODE(dir, | |
1042 | + "deleted inode referenced: %u", | |
1043 | + ino); | |
1044 | + return ERR_PTR(-EIO); | |
1049 | 1045 | } |
1050 | 1046 | } |
1051 | 1047 | return d_splice_alias(inode, dentry); |
fs/fat/namei_msdos.c
... | ... | @@ -209,29 +209,20 @@ |
209 | 209 | int err; |
210 | 210 | |
211 | 211 | lock_super(sb); |
212 | - | |
213 | 212 | err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo); |
214 | - if (err) { | |
215 | - if (err == -ENOENT) { | |
216 | - inode = NULL; | |
217 | - goto out; | |
218 | - } | |
219 | - goto error; | |
213 | + switch (err) { | |
214 | + case -ENOENT: | |
215 | + inode = NULL; | |
216 | + break; | |
217 | + case 0: | |
218 | + inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos); | |
219 | + brelse(sinfo.bh); | |
220 | + break; | |
221 | + default: | |
222 | + inode = ERR_PTR(err); | |
220 | 223 | } |
221 | - | |
222 | - inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos); | |
223 | - brelse(sinfo.bh); | |
224 | - if (IS_ERR(inode)) { | |
225 | - err = PTR_ERR(inode); | |
226 | - goto error; | |
227 | - } | |
228 | -out: | |
229 | 224 | unlock_super(sb); |
230 | 225 | return d_splice_alias(inode, dentry); |
231 | - | |
232 | -error: | |
233 | - unlock_super(sb); | |
234 | - return ERR_PTR(err); | |
235 | 226 | } |
236 | 227 | |
237 | 228 | /***** Creates a directory entry (name is already formatted). */ |
fs/isofs/namei.c
... | ... | @@ -183,15 +183,10 @@ |
183 | 183 | 1024 + page_address(page)); |
184 | 184 | __free_page(page); |
185 | 185 | |
186 | - inode = NULL; | |
187 | - if (found) { | |
188 | - inode = isofs_iget(dir->i_sb, block, offset); | |
189 | - if (IS_ERR(inode)) { | |
190 | - mutex_unlock(&sbi->s_mutex); | |
191 | - return ERR_CAST(inode); | |
192 | - } | |
193 | - } | |
186 | + inode = found ? isofs_iget(dir->i_sb, block, offset) : NULL; | |
187 | + | |
194 | 188 | mutex_unlock(&sbi->s_mutex); |
189 | + | |
195 | 190 | return d_splice_alias(inode, dentry); |
196 | 191 | } |
fs/jffs2/dir.c
... | ... | @@ -102,10 +102,8 @@ |
102 | 102 | mutex_unlock(&dir_f->sem); |
103 | 103 | if (ino) { |
104 | 104 | inode = jffs2_iget(dir_i->i_sb, ino); |
105 | - if (IS_ERR(inode)) { | |
105 | + if (IS_ERR(inode)) | |
106 | 106 | printk(KERN_WARNING "iget() failed for ino #%u\n", ino); |
107 | - return ERR_CAST(inode); | |
108 | - } | |
109 | 107 | } |
110 | 108 | |
111 | 109 | return d_splice_alias(inode, target); |
fs/jfs/namei.c
... | ... | @@ -1481,10 +1481,8 @@ |
1481 | 1481 | } |
1482 | 1482 | |
1483 | 1483 | ip = jfs_iget(dip->i_sb, inum); |
1484 | - if (IS_ERR(ip)) { | |
1484 | + if (IS_ERR(ip)) | |
1485 | 1485 | jfs_err("jfs_lookup: iget failed on inum %d", (uint) inum); |
1486 | - return ERR_CAST(ip); | |
1487 | - } | |
1488 | 1486 | |
1489 | 1487 | return d_splice_alias(ip, dentry); |
1490 | 1488 | } |
fs/logfs/dir.c
... | ... | @@ -371,11 +371,9 @@ |
371 | 371 | page_cache_release(page); |
372 | 372 | |
373 | 373 | inode = logfs_iget(dir->i_sb, ino); |
374 | - if (IS_ERR(inode)) { | |
374 | + if (IS_ERR(inode)) | |
375 | 375 | printk(KERN_ERR"LogFS: Cannot read inode #%llx for dentry (%lx, %lx)n", |
376 | 376 | ino, dir->i_ino, index); |
377 | - return ERR_CAST(inode); | |
378 | - } | |
379 | 377 | return d_splice_alias(inode, dentry); |
380 | 378 | } |
381 | 379 |
fs/nilfs2/namei.c
... | ... | @@ -72,12 +72,7 @@ |
72 | 72 | return ERR_PTR(-ENAMETOOLONG); |
73 | 73 | |
74 | 74 | ino = nilfs_inode_by_name(dir, &dentry->d_name); |
75 | - inode = NULL; | |
76 | - if (ino) { | |
77 | - inode = nilfs_iget(dir->i_sb, NILFS_I(dir)->i_root, ino); | |
78 | - if (IS_ERR(inode)) | |
79 | - return ERR_CAST(inode); | |
80 | - } | |
75 | + inode = ino ? nilfs_iget(dir->i_sb, NILFS_I(dir)->i_root, ino) : NULL; | |
81 | 76 | return d_splice_alias(inode, dentry); |
82 | 77 | } |
83 | 78 |
fs/squashfs/namei.c