Skip to content

Commit d4db710

Browse files
committed
Merge patch series "Minor cleanup preparation for some dir-locking API changes"
NeilBrown <[email protected]> says: The following 4 patches provide further cleanup that serves as preparation for some dir-locking API changes that I want to make. * patches from https://lore.kernel.org/[email protected]: exportfs: use lookup_one_unlocked() coda: use iterate_dir() in coda_readdir() VFS: Minor fixes for porting.rst VFS: merge lookup_one_qstr_excl_raw() back into lookup_one_qstr_excl() Link: https://lore.kernel.org/[email protected] Signed-off-by: Christian Brauner <[email protected]>
2 parents 19272b3 + ce34900 commit d4db710

File tree

4 files changed

+17
-39
lines changed

4 files changed

+17
-39
lines changed

Documentation/filesystems/porting.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,9 +1224,6 @@ lookup_noperm_unlocked(), lookup_noperm_positive_unlocked(). They now
12241224
take a qstr instead of separate name and length. QSTR() can be used
12251225
when strlen() is needed for the length.
12261226

1227-
For try_lookup_noperm() a reference to the qstr is passed in case the
1228-
hash might subsequently be needed.
1229-
12301227
These function no longer do any permission checking - they previously
12311228
checked that the caller has 'X' permission on the parent. They must
12321229
ONLY be used internally by a filesystem on itself when it knows that

fs/coda/dir.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -429,17 +429,9 @@ static int coda_readdir(struct file *coda_file, struct dir_context *ctx)
429429
cfi = coda_ftoc(coda_file);
430430
host_file = cfi->cfi_container;
431431

432-
if (host_file->f_op->iterate_shared) {
433-
struct inode *host_inode = file_inode(host_file);
434-
ret = -ENOENT;
435-
if (!IS_DEADDIR(host_inode)) {
436-
inode_lock_shared(host_inode);
437-
ret = host_file->f_op->iterate_shared(host_file, ctx);
438-
file_accessed(host_file);
439-
inode_unlock_shared(host_inode);
440-
}
432+
ret = iterate_dir(host_file, ctx);
433+
if (ret != -ENOTDIR)
441434
return ret;
442-
}
443435
/* Venus: we must read Venus dirents from a file */
444436
return coda_venus_readdir(coda_file, ctx);
445437
}

fs/exportfs/expfs.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,15 +549,13 @@ exportfs_decode_fh_raw(struct vfsmount *mnt, struct fid *fid, int fh_len,
549549
goto err_result;
550550
}
551551

552-
inode_lock(target_dir->d_inode);
553-
nresult = lookup_one(mnt_idmap(mnt), &QSTR(nbuf), target_dir);
552+
nresult = lookup_one_unlocked(mnt_idmap(mnt), &QSTR(nbuf), target_dir);
554553
if (!IS_ERR(nresult)) {
555554
if (unlikely(nresult->d_inode != result->d_inode)) {
556555
dput(nresult);
557556
nresult = ERR_PTR(-ESTALE);
558557
}
559558
}
560-
inode_unlock(target_dir->d_inode);
561559
/*
562560
* At this point we are done with the parent, but it's pinned
563561
* by the child dentry anyway.

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)