Merge branch 'work.lookup' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull more ->lookup() cleanups from Al Viro: "Some ->lookup() instances are still overcomplicating the life for themselves, open-coding the stuff that would be handled by d_splice_alias() just fine. Simplify a couple of such cases caught this cycle and document d_splice_alias() intended use" * 'work.lookup' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: Document d_splice_alias() calling conventions for ->lookup() users. simplify btrfs_lookup() clean erofs_lookup()
This commit is contained in:
commit
4ba9628fe5
|
@ -622,3 +622,14 @@ in your dentry operations instead.
|
||||||
alloc_file_clone(file, flags, ops) does not affect any caller's references.
|
alloc_file_clone(file, flags, ops) does not affect any caller's references.
|
||||||
On success you get a new struct file sharing the mount/dentry with the
|
On success you get a new struct file sharing the mount/dentry with the
|
||||||
original, on failure - ERR_PTR().
|
original, on failure - ERR_PTR().
|
||||||
|
--
|
||||||
|
[recommended]
|
||||||
|
->lookup() instances doing an equivalent of
|
||||||
|
if (IS_ERR(inode))
|
||||||
|
return ERR_CAST(inode);
|
||||||
|
return d_splice_alias(inode, dentry);
|
||||||
|
don't need to bother with the check - d_splice_alias() will do the
|
||||||
|
right thing when given ERR_PTR(...) as inode. Moreover, passing NULL
|
||||||
|
inode to d_splice_alias() will also do the right thing (equivalent of
|
||||||
|
d_add(dentry, NULL); return NULL;), so that kind of special cases
|
||||||
|
also doesn't need a separate treatment.
|
||||||
|
|
|
@ -223,18 +223,13 @@ static struct dentry *erofs_lookup(struct inode *dir,
|
||||||
if (err == -ENOENT) {
|
if (err == -ENOENT) {
|
||||||
/* negative dentry */
|
/* negative dentry */
|
||||||
inode = NULL;
|
inode = NULL;
|
||||||
goto negative_out;
|
} else if (unlikely(err)) {
|
||||||
} else if (unlikely(err))
|
inode = ERR_PTR(err);
|
||||||
return ERR_PTR(err);
|
} else {
|
||||||
|
|
||||||
debugln("%s, %s (nid %llu) found, d_type %u", __func__,
|
debugln("%s, %s (nid %llu) found, d_type %u", __func__,
|
||||||
dentry->d_name.name, nid, d_type);
|
dentry->d_name.name, nid, d_type);
|
||||||
|
|
||||||
inode = erofs_iget(dir->i_sb, nid, d_type == EROFS_FT_DIR);
|
inode = erofs_iget(dir->i_sb, nid, d_type == EROFS_FT_DIR);
|
||||||
if (IS_ERR(inode))
|
}
|
||||||
return ERR_CAST(inode);
|
|
||||||
|
|
||||||
negative_out:
|
|
||||||
return d_splice_alias(inode, dentry);
|
return d_splice_alias(inode, dentry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5764,16 +5764,10 @@ 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,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct inode *inode;
|
struct inode *inode = btrfs_lookup_dentry(dir, dentry);
|
||||||
|
|
||||||
inode = btrfs_lookup_dentry(dir, dentry);
|
if (inode == ERR_PTR(-ENOENT))
|
||||||
if (IS_ERR(inode)) {
|
|
||||||
if (PTR_ERR(inode) == -ENOENT)
|
|
||||||
inode = NULL;
|
inode = NULL;
|
||||||
else
|
|
||||||
return ERR_CAST(inode);
|
|
||||||
}
|
|
||||||
|
|
||||||
return d_splice_alias(inode, dentry);
|
return d_splice_alias(inode, dentry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue