Skip to content

Commit 514b687

Browse files
neilbrownbrauner
authored andcommitted
VFS/autofs: try_lookup_one_len() does not need any locks
try_lookup_one_len() is identical to lookup_one_unlocked() except that it doesn't include the call to lookup_slow(). The latter doesn't need the inode to be locked, so the former cannot either. So fix the documentation, remove the WARN_ON and fix the only caller to not take the lock. Signed-off-by: NeilBrown <neilb@suse.de> Link: https://lore.kernel.org/r/174190517441.9342.5956460781380903128@noble.neil.brown.name Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 6118510 commit 514b687

2 files changed

Lines changed: 2 additions & 6 deletions

File tree

fs/autofs/dev-ioctl.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,6 @@ static int autofs_dev_ioctl_timeout(struct file *fp,
442442
sbi->exp_timeout = timeout * HZ;
443443
} else {
444444
struct dentry *base = fp->f_path.dentry;
445-
struct inode *inode = base->d_inode;
446445
int path_len = param->size - AUTOFS_DEV_IOCTL_SIZE - 1;
447446
struct dentry *dentry;
448447
struct autofs_info *ino;
@@ -460,9 +459,7 @@ static int autofs_dev_ioctl_timeout(struct file *fp,
460459
"the parent autofs mount timeout which could "
461460
"prevent shutdown\n");
462461

463-
inode_lock_shared(inode);
464462
dentry = try_lookup_one_len(param->path, base, path_len);
465-
inode_unlock_shared(inode);
466463
if (IS_ERR_OR_NULL(dentry))
467464
return dentry ? PTR_ERR(dentry) : -ENOENT;
468465
ino = autofs_dentry_ino(dentry);

fs/namei.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,15 +2864,14 @@ static int lookup_one_common(struct mnt_idmap *idmap,
28642864
* Note that this routine is purely a helper for filesystem usage and should
28652865
* not be called by generic code.
28662866
*
2867-
* The caller must hold base->i_mutex.
2867+
* No locks need be held - only a counted reference to @base is needed.
2868+
*
28682869
*/
28692870
struct dentry *try_lookup_one_len(const char *name, struct dentry *base, int len)
28702871
{
28712872
struct qstr this;
28722873
int err;
28732874

2874-
WARN_ON_ONCE(!inode_is_locked(base->d_inode));
2875-
28762875
err = lookup_one_common(&nop_mnt_idmap, name, base, len, &this);
28772876
if (err)
28782877
return ERR_PTR(err);

0 commit comments

Comments
 (0)