Commit a9049376 authored by Al Viro's avatar Al Viro

make d_splice_alias(ERR_PTR(err), dentry) = ERR_PTR(err)

... and simplify the living hell out of callers
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 0c1aa9a9
...@@ -4079,13 +4079,7 @@ static int btrfs_dentry_delete(const struct dentry *dentry) ...@@ -4079,13 +4079,7 @@ static int btrfs_dentry_delete(const struct dentry *dentry)
static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry, static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry,
struct nameidata *nd) struct nameidata *nd)
{ {
struct inode *inode; return d_splice_alias(btrfs_lookup_dentry(dir, dentry), dentry);
inode = btrfs_lookup_dentry(dir, dentry);
if (IS_ERR(inode))
return ERR_CAST(inode);
return d_splice_alias(inode, dentry);
} }
unsigned char btrfs_filetype_table[] = { unsigned char btrfs_filetype_table[] = {
......
...@@ -1652,6 +1652,9 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) ...@@ -1652,6 +1652,9 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
{ {
struct dentry *new = NULL; struct dentry *new = NULL;
if (IS_ERR(inode))
return ERR_CAST(inode);
if (inode && S_ISDIR(inode->i_mode)) { if (inode && S_ISDIR(inode->i_mode)) {
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
new = __d_find_alias(inode, 1); new = __d_find_alias(inode, 1);
......
...@@ -60,14 +60,11 @@ static efs_ino_t efs_find_entry(struct inode *inode, const char *name, int len) ...@@ -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) { struct dentry *efs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) {
efs_ino_t inodenum; 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); inodenum = efs_find_entry(dir, dentry->d_name.name, dentry->d_name.len);
if (inodenum) { if (inodenum)
inode = efs_iget(dir->i_sb, inodenum); inode = efs_iget(dir->i_sb, inodenum);
if (IS_ERR(inode))
return ERR_CAST(inode);
}
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
} }
......
...@@ -55,12 +55,7 @@ static struct dentry *exofs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -55,12 +55,7 @@ static struct dentry *exofs_lookup(struct inode *dir, struct dentry *dentry,
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
ino = exofs_inode_by_name(dir, dentry); ino = exofs_inode_by_name(dir, dentry);
inode = NULL; inode = ino ? exofs_iget(dir->i_sb, ino) : NULL;
if (ino) {
inode = exofs_iget(dir->i_sb, ino);
if (IS_ERR(inode))
return ERR_CAST(inode);
}
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
} }
......
...@@ -67,15 +67,11 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str ...@@ -67,15 +67,11 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str
inode = NULL; inode = NULL;
if (ino) { if (ino) {
inode = ext2_iget(dir->i_sb, ino); inode = ext2_iget(dir->i_sb, ino);
if (IS_ERR(inode)) { if (inode == ERR_PTR(-ESTALE)) {
if (PTR_ERR(inode) == -ESTALE) { ext2_error(dir->i_sb, __func__,
ext2_error(dir->i_sb, __func__, "deleted inode referenced: %lu",
"deleted inode referenced: %lu", (unsigned long) ino);
(unsigned long) ino); return ERR_PTR(-EIO);
return ERR_PTR(-EIO);
} else {
return ERR_CAST(inode);
}
} }
} }
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
......
...@@ -1038,15 +1038,11 @@ static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry, str ...@@ -1038,15 +1038,11 @@ static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry, str
return ERR_PTR(-EIO); return ERR_PTR(-EIO);
} }
inode = ext3_iget(dir->i_sb, ino); inode = ext3_iget(dir->i_sb, ino);
if (IS_ERR(inode)) { if (inode == ERR_PTR(-ESTALE)) {
if (PTR_ERR(inode) == -ESTALE) { ext3_error(dir->i_sb, __func__,
ext3_error(dir->i_sb, __func__, "deleted inode referenced: %lu",
"deleted inode referenced: %lu", ino);
ino); return ERR_PTR(-EIO);
return ERR_PTR(-EIO);
} else {
return ERR_CAST(inode);
}
} }
} }
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
......
...@@ -1037,15 +1037,11 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru ...@@ -1037,15 +1037,11 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru
return ERR_PTR(-EIO); return ERR_PTR(-EIO);
} }
inode = ext4_iget(dir->i_sb, ino); inode = ext4_iget(dir->i_sb, ino);
if (IS_ERR(inode)) { if (inode == ERR_PTR(-ESTALE)) {
if (PTR_ERR(inode) == -ESTALE) { EXT4_ERROR_INODE(dir,
EXT4_ERROR_INODE(dir, "deleted inode referenced: %u",
"deleted inode referenced: %u", ino);
ino); return ERR_PTR(-EIO);
return ERR_PTR(-EIO);
} else {
return ERR_CAST(inode);
}
} }
} }
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
......
...@@ -209,29 +209,20 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry, ...@@ -209,29 +209,20 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
int err; int err;
lock_super(sb); lock_super(sb);
err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo); err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
if (err) { switch (err) {
if (err == -ENOENT) { case -ENOENT:
inode = NULL; inode = NULL;
goto out; break;
} case 0:
goto error; inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
} brelse(sinfo.bh);
break;
inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos); default:
brelse(sinfo.bh); inode = ERR_PTR(err);
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
goto error;
} }
out:
unlock_super(sb); unlock_super(sb);
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
error:
unlock_super(sb);
return ERR_PTR(err);
} }
/***** Creates a directory entry (name is already formatted). */ /***** Creates a directory entry (name is already formatted). */
......
...@@ -183,14 +183,9 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam ...@@ -183,14 +183,9 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam
1024 + page_address(page)); 1024 + page_address(page));
__free_page(page); __free_page(page);
inode = NULL; inode = found ? isofs_iget(dir->i_sb, block, offset) : NULL;
if (found) {
inode = isofs_iget(dir->i_sb, block, offset);
if (IS_ERR(inode)) {
mutex_unlock(&sbi->s_mutex);
return ERR_CAST(inode);
}
}
mutex_unlock(&sbi->s_mutex); mutex_unlock(&sbi->s_mutex);
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
} }
...@@ -102,10 +102,8 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, ...@@ -102,10 +102,8 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target,
mutex_unlock(&dir_f->sem); mutex_unlock(&dir_f->sem);
if (ino) { if (ino) {
inode = jffs2_iget(dir_i->i_sb, 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); printk(KERN_WARNING "iget() failed for ino #%u\n", ino);
return ERR_CAST(inode);
}
} }
return d_splice_alias(inode, target); return d_splice_alias(inode, target);
......
...@@ -1481,10 +1481,8 @@ static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, struc ...@@ -1481,10 +1481,8 @@ static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, struc
} }
ip = jfs_iget(dip->i_sb, inum); 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); jfs_err("jfs_lookup: iget failed on inum %d", (uint) inum);
return ERR_CAST(ip);
}
return d_splice_alias(ip, dentry); return d_splice_alias(ip, dentry);
} }
......
...@@ -371,11 +371,9 @@ static struct dentry *logfs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -371,11 +371,9 @@ static struct dentry *logfs_lookup(struct inode *dir, struct dentry *dentry,
page_cache_release(page); page_cache_release(page);
inode = logfs_iget(dir->i_sb, ino); 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", printk(KERN_ERR"LogFS: Cannot read inode #%llx for dentry (%lx, %lx)n",
ino, dir->i_ino, index); ino, dir->i_ino, index);
return ERR_CAST(inode);
}
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
} }
......
...@@ -72,12 +72,7 @@ nilfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) ...@@ -72,12 +72,7 @@ nilfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
ino = nilfs_inode_by_name(dir, &dentry->d_name); ino = nilfs_inode_by_name(dir, &dentry->d_name);
inode = NULL; inode = ino ? nilfs_iget(dir->i_sb, NILFS_I(dir)->i_root, ino) : NULL;
if (ino) {
inode = nilfs_iget(dir->i_sb, NILFS_I(dir)->i_root, ino);
if (IS_ERR(inode))
return ERR_CAST(inode);
}
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
} }
......
...@@ -220,11 +220,6 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -220,11 +220,6 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry,
blk, off, ino_num); blk, off, ino_num);
inode = squashfs_iget(dir->i_sb, ino, ino_num); inode = squashfs_iget(dir->i_sb, ino, ino_num);
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
goto failed;
}
goto exit_lookup; goto exit_lookup;
} }
} }
......
...@@ -59,8 +59,6 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, stru ...@@ -59,8 +59,6 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, stru
if (ino) if (ino)
inode = ufs_iget(dir->i_sb, ino); inode = ufs_iget(dir->i_sb, ino);
unlock_ufs(dir->i_sb); unlock_ufs(dir->i_sb);
if (IS_ERR(inode))
return ERR_CAST(inode);
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment