Skip to content

Commit 2b07a5a

Browse files
neilbrownbrauner
authored andcommitted
VFS: merge lookup_one_qstr_excl_raw() back into lookup_one_qstr_excl()
The effect of lookup_one_qstr_excl_raw() can be achieved by passing LOOKUP_CREATE() to lookup_one_qstr_excl() - we don't need a separate function. Signed-off-by: NeilBrown <[email protected]> Link: https://lore.kernel.org/[email protected] Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 19272b3 commit 2b07a5a

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

fs/namei.c

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,17 +1665,25 @@ static struct dentry *lookup_dcache(const struct qstr *name,
16651665
return dentry;
16661666
}
16671667

1668-
static struct dentry *lookup_one_qstr_excl_raw(const struct qstr *name,
1669-
struct dentry *base,
1670-
unsigned int flags)
1668+
/*
1669+
* Parent directory has inode locked exclusive. This is one
1670+
* and only case when ->lookup() gets called on non in-lookup
1671+
* dentries - as the matter of fact, this only gets called
1672+
* when directory is guaranteed to have no in-lookup children
1673+
* at all.
1674+
* Will return -ENOENT if name isn't found and LOOKUP_CREATE wasn't passed.
1675+
* Will return -EEXIST if name is found and LOOKUP_EXCL was passed.
1676+
*/
1677+
struct dentry *lookup_one_qstr_excl(const struct qstr *name,
1678+
struct dentry *base, unsigned int flags)
16711679
{
16721680
struct dentry *dentry;
16731681
struct dentry *old;
16741682
struct inode *dir;
16751683

16761684
dentry = lookup_dcache(name, base, flags);
16771685
if (dentry)
1678-
return dentry;
1686+
goto found;
16791687

16801688
/* Don't create child dentry for a dead directory. */
16811689
dir = base->d_inode;
@@ -1691,24 +1699,7 @@ static struct dentry *lookup_one_qstr_excl_raw(const struct qstr *name,
16911699
dput(dentry);
16921700
dentry = old;
16931701
}
1694-
return dentry;
1695-
}
1696-
1697-
/*
1698-
* Parent directory has inode locked exclusive. This is one
1699-
* and only case when ->lookup() gets called on non in-lookup
1700-
* dentries - as the matter of fact, this only gets called
1701-
* when directory is guaranteed to have no in-lookup children
1702-
* at all.
1703-
* Will return -ENOENT if name isn't found and LOOKUP_CREATE wasn't passed.
1704-
* Will return -EEXIST if name is found and LOOKUP_EXCL was passed.
1705-
*/
1706-
struct dentry *lookup_one_qstr_excl(const struct qstr *name,
1707-
struct dentry *base, unsigned int flags)
1708-
{
1709-
struct dentry *dentry;
1710-
1711-
dentry = lookup_one_qstr_excl_raw(name, base, flags);
1702+
found:
17121703
if (IS_ERR(dentry))
17131704
return dentry;
17141705
if (d_is_negative(dentry) && !(flags & LOOKUP_CREATE)) {
@@ -2790,7 +2781,7 @@ struct dentry *kern_path_locked_negative(const char *name, struct path *path)
27902781
if (unlikely(type != LAST_NORM))
27912782
return ERR_PTR(-EINVAL);
27922783
inode_lock_nested(parent_path.dentry->d_inode, I_MUTEX_PARENT);
2793-
d = lookup_one_qstr_excl_raw(&last, parent_path.dentry, 0);
2784+
d = lookup_one_qstr_excl(&last, parent_path.dentry, LOOKUP_CREATE);
27942785
if (IS_ERR(d)) {
27952786
inode_unlock(parent_path.dentry->d_inode);
27962787
return d;

0 commit comments

Comments
 (0)