aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-07-08 21:20:11 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-20 01:44:26 -0400
commita9049376ee05bf966bfe2b081b5071326856890a (patch)
treeefb3cbfc7760537f201bb28dacbb0d39ec39f04c
parent0c1aa9a952c3608eb17bf990466f1491d1ee8b6c (diff)
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>
-rw-r--r--fs/btrfs/inode.c8
-rw-r--r--fs/dcache.c3
-rw-r--r--fs/efs/namei.c7
-rw-r--r--fs/exofs/namei.c7
-rw-r--r--fs/ext2/namei.c14
-rw-r--r--fs/ext3/namei.c14
-rw-r--r--fs/ext4/namei.c14
-rw-r--r--fs/fat/namei_msdos.c29
-rw-r--r--fs/isofs/namei.c11
-rw-r--r--fs/jffs2/dir.c4
-rw-r--r--fs/jfs/namei.c4
-rw-r--r--fs/logfs/dir.c4
-rw-r--r--fs/nilfs2/namei.c7
-rw-r--r--fs/squashfs/namei.c5
-rw-r--r--fs/ufs/namei.c2
15 files changed, 39 insertions, 94 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ecf0fac712d6..bcb20a9a3b93 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4079,13 +4079,7 @@ static int btrfs_dentry_delete(const struct dentry *dentry)
4079static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry, 4079static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry,
4080 struct nameidata *nd) 4080 struct nameidata *nd)
4081{ 4081{
4082 struct inode *inode; 4082 return d_splice_alias(btrfs_lookup_dentry(dir, dentry), dentry);
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);
4089} 4083}
4090 4084
4091unsigned char btrfs_filetype_table[] = { 4085unsigned char btrfs_filetype_table[] = {
diff --git a/fs/dcache.c b/fs/dcache.c
index c61edd0318c3..41e2085d430b 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1652,6 +1652,9 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
1652{ 1652{
1653 struct dentry *new = NULL; 1653 struct dentry *new = NULL;
1654 1654
1655 if (IS_ERR(inode))
1656 return ERR_CAST(inode);
1657
1655 if (inode && S_ISDIR(inode->i_mode)) { 1658 if (inode && S_ISDIR(inode->i_mode)) {
1656 spin_lock(&inode->i_lock); 1659 spin_lock(&inode->i_lock);
1657 new = __d_find_alias(inode, 1); 1660 new = __d_find_alias(inode, 1);
diff --git a/fs/efs/namei.c b/fs/efs/namei.c
index 1511bf9e5f80..832b10ded82f 100644
--- a/fs/efs/namei.c
+++ b/fs/efs/namei.c
@@ -60,14 +60,11 @@ static efs_ino_t efs_find_entry(struct inode *inode, const char *name, int len)
60 60
61struct dentry *efs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) { 61struct dentry *efs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) {
62 efs_ino_t inodenum; 62 efs_ino_t inodenum;
63 struct inode * inode = NULL; 63 struct inode *inode = NULL;
64 64
65 inodenum = efs_find_entry(dir, dentry->d_name.name, dentry->d_name.len); 65 inodenum = efs_find_entry(dir, dentry->d_name.name, dentry->d_name.len);
66 if (inodenum) { 66 if (inodenum)
67 inode = efs_iget(dir->i_sb, inodenum); 67 inode = efs_iget(dir->i_sb, inodenum);
68 if (IS_ERR(inode))
69 return ERR_CAST(inode);
70 }
71 68
72 return d_splice_alias(inode, dentry); 69 return d_splice_alias(inode, dentry);
73} 70}
diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c
index 4d70db110cfc..b54c43775f17 100644
--- a/fs/exofs/namei.c
+++ b/fs/exofs/namei.c
@@ -55,12 +55,7 @@ static struct dentry *exofs_lookup(struct inode *dir, struct dentry *dentry,
55 return ERR_PTR(-ENAMETOOLONG); 55 return ERR_PTR(-ENAMETOOLONG);
56 56
57 ino = exofs_inode_by_name(dir, dentry); 57 ino = exofs_inode_by_name(dir, dentry);
58 inode = NULL; 58 inode = ino ? exofs_iget(dir->i_sb, ino) : NULL;
59 if (ino) {
60 inode = exofs_iget(dir->i_sb, ino);
61 if (IS_ERR(inode))
62 return ERR_CAST(inode);
63 }
64 return d_splice_alias(inode, dentry); 59 return d_splice_alias(inode, dentry);
65} 60}
66 61
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index ed5c5d496ee9..d60b7099e2db 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -67,15 +67,11 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str
67 inode = NULL; 67 inode = NULL;
68 if (ino) { 68 if (ino) {
69 inode = ext2_iget(dir->i_sb, ino); 69 inode = ext2_iget(dir->i_sb, ino);
70 if (IS_ERR(inode)) { 70 if (inode == ERR_PTR(-ESTALE)) {
71 if (PTR_ERR(inode) == -ESTALE) { 71 ext2_error(dir->i_sb, __func__,
72 ext2_error(dir->i_sb, __func__, 72 "deleted inode referenced: %lu",
73 "deleted inode referenced: %lu", 73 (unsigned long) ino);
74 (unsigned long) ino); 74 return ERR_PTR(-EIO);
75 return ERR_PTR(-EIO);
76 } else {
77 return ERR_CAST(inode);
78 }
79 } 75 }
80 } 76 }
81 return d_splice_alias(inode, dentry); 77 return d_splice_alias(inode, dentry);
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 34b6d9bfc48a..c095cf5640c7 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -1038,15 +1038,11 @@ static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry, str
1038 return ERR_PTR(-EIO); 1038 return ERR_PTR(-EIO);
1039 } 1039 }
1040 inode = ext3_iget(dir->i_sb, ino); 1040 inode = ext3_iget(dir->i_sb, ino);
1041 if (IS_ERR(inode)) { 1041 if (inode == ERR_PTR(-ESTALE)) {
1042 if (PTR_ERR(inode) == -ESTALE) { 1042 ext3_error(dir->i_sb, __func__,
1043 ext3_error(dir->i_sb, __func__, 1043 "deleted inode referenced: %lu",
1044 "deleted inode referenced: %lu", 1044 ino);
1045 ino); 1045 return ERR_PTR(-EIO);
1046 return ERR_PTR(-EIO);
1047 } else {
1048 return ERR_CAST(inode);
1049 }
1050 } 1046 }
1051 } 1047 }
1052 return d_splice_alias(inode, dentry); 1048 return d_splice_alias(inode, dentry);
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index b754b7721f51..707d605bf769 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1037,15 +1037,11 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru
1037 return ERR_PTR(-EIO); 1037 return ERR_PTR(-EIO);
1038 } 1038 }
1039 inode = ext4_iget(dir->i_sb, ino); 1039 inode = ext4_iget(dir->i_sb, ino);
1040 if (IS_ERR(inode)) { 1040 if (inode == ERR_PTR(-ESTALE)) {
1041 if (PTR_ERR(inode) == -ESTALE) { 1041 EXT4_ERROR_INODE(dir,
1042 EXT4_ERROR_INODE(dir, 1042 "deleted inode referenced: %u",
1043 "deleted inode referenced: %u", 1043 ino);
1044 ino); 1044 return ERR_PTR(-EIO);
1045 return ERR_PTR(-EIO);
1046 } else {
1047 return ERR_CAST(inode);
1048 }
1049 } 1045 }
1050 } 1046 }
1051 return d_splice_alias(inode, dentry); 1047 return d_splice_alias(inode, dentry);
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index 3b222dafd15b..66e83b845455 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -209,29 +209,20 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
209 int err; 209 int err;
210 210
211 lock_super(sb); 211 lock_super(sb);
212
213 err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo); 212 err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
214 if (err) { 213 switch (err) {
215 if (err == -ENOENT) { 214 case -ENOENT:
216 inode = NULL; 215 inode = NULL;
217 goto out; 216 break;
218 } 217 case 0:
219 goto error; 218 inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
220 } 219 brelse(sinfo.bh);
221 220 break;
222 inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos); 221 default:
223 brelse(sinfo.bh); 222 inode = ERR_PTR(err);
224 if (IS_ERR(inode)) {
225 err = PTR_ERR(inode);
226 goto error;
227 } 223 }
228out:
229 unlock_super(sb); 224 unlock_super(sb);
230 return d_splice_alias(inode, dentry); 225 return d_splice_alias(inode, dentry);
231
232error:
233 unlock_super(sb);
234 return ERR_PTR(err);
235} 226}
236 227
237/***** Creates a directory entry (name is already formatted). */ 228/***** Creates a directory entry (name is already formatted). */
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c
index 4fb3e8074fd4..68fa503d877e 100644
--- a/fs/isofs/namei.c
+++ b/fs/isofs/namei.c
@@ -183,14 +183,9 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam
183 1024 + page_address(page)); 183 1024 + page_address(page));
184 __free_page(page); 184 __free_page(page);
185 185
186 inode = NULL; 186 inode = found ? isofs_iget(dir->i_sb, block, offset) : NULL;
187 if (found) { 187
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 }
194 mutex_unlock(&sbi->s_mutex); 188 mutex_unlock(&sbi->s_mutex);
189
195 return d_splice_alias(inode, dentry); 190 return d_splice_alias(inode, dentry);
196} 191}
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 4bca6a2e5c07..8f40ce4f1777 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -102,10 +102,8 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target,
102 mutex_unlock(&dir_f->sem); 102 mutex_unlock(&dir_f->sem);
103 if (ino) { 103 if (ino) {
104 inode = jffs2_iget(dir_i->i_sb, ino); 104 inode = jffs2_iget(dir_i->i_sb, ino);
105 if (IS_ERR(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_CAST(inode);
108 }
109 } 107 }
110 108
111 return d_splice_alias(inode, target); 109 return d_splice_alias(inode, target);
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 1da0dc799286..247331551992 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -1481,10 +1481,8 @@ static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, struc
1481 } 1481 }
1482 1482
1483 ip = jfs_iget(dip->i_sb, inum); 1483 ip = jfs_iget(dip->i_sb, inum);
1484 if (IS_ERR(ip)) { 1484 if (IS_ERR(ip))
1485 jfs_err("jfs_lookup: iget failed on inum %d", (uint) inum); 1485 jfs_err("jfs_lookup: iget failed on inum %d", (uint) inum);
1486 return ERR_CAST(ip);
1487 }
1488 1486
1489 return d_splice_alias(ip, dentry); 1487 return d_splice_alias(ip, dentry);
1490} 1488}
diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
index 1afae26cf236..b3ff3d894165 100644
--- a/fs/logfs/dir.c
+++ b/fs/logfs/dir.c
@@ -371,11 +371,9 @@ static struct dentry *logfs_lookup(struct inode *dir, struct dentry *dentry,
371 page_cache_release(page); 371 page_cache_release(page);
372 372
373 inode = logfs_iget(dir->i_sb, ino); 373 inode = logfs_iget(dir->i_sb, ino);
374 if (IS_ERR(inode)) { 374 if (IS_ERR(inode))
375 printk(KERN_ERR"LogFS: Cannot read inode #%llx for dentry (%lx, %lx)n", 375 printk(KERN_ERR"LogFS: Cannot read inode #%llx for dentry (%lx, %lx)n",
376 ino, dir->i_ino, index); 376 ino, dir->i_ino, index);
377 return ERR_CAST(inode);
378 }
379 return d_splice_alias(inode, dentry); 377 return d_splice_alias(inode, dentry);
380} 378}
381 379
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index 546849b3e88f..a3141990061e 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -72,12 +72,7 @@ nilfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
72 return ERR_PTR(-ENAMETOOLONG); 72 return ERR_PTR(-ENAMETOOLONG);
73 73
74 ino = nilfs_inode_by_name(dir, &dentry->d_name); 74 ino = nilfs_inode_by_name(dir, &dentry->d_name);
75 inode = NULL; 75 inode = ino ? nilfs_iget(dir->i_sb, NILFS_I(dir)->i_root, ino) : 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 }
81 return d_splice_alias(inode, dentry); 76 return d_splice_alias(inode, dentry);
82} 77}
83 78
diff --git a/fs/squashfs/namei.c b/fs/squashfs/namei.c
index 51b36958492b..0682b38d7e31 100644
--- a/fs/squashfs/namei.c
+++ b/fs/squashfs/namei.c
@@ -220,11 +220,6 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry,
220 blk, off, ino_num); 220 blk, off, ino_num);
221 221
222 inode = squashfs_iget(dir->i_sb, ino, ino_num); 222 inode = squashfs_iget(dir->i_sb, ino, ino_num);
223 if (IS_ERR(inode)) {
224 err = PTR_ERR(inode);
225 goto failed;
226 }
227
228 goto exit_lookup; 223 goto exit_lookup;
229 } 224 }
230 } 225 }
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index b57aab9a1184..639d49162241 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -59,8 +59,6 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, stru
59 if (ino) 59 if (ino)
60 inode = ufs_iget(dir->i_sb, ino); 60 inode = ufs_iget(dir->i_sb, ino);
61 unlock_ufs(dir->i_sb); 61 unlock_ufs(dir->i_sb);
62 if (IS_ERR(inode))
63 return ERR_CAST(inode);
64 return d_splice_alias(inode, dentry); 62 return d_splice_alias(inode, dentry);
65} 63}
66 64