[PATCH v2 12/18] autofs: don't hold ->lookup_lock in get_next_positive_*

From: NeilBrown

Date: Sat Aug 15 2026 - 00:31:08 EST


From: NeilBrown <neil@xxxxxxxxxx>

get_next_positive_subdir() and get_next_positive_dentry() currently hold
->lookup_lock while walking the d_children list, which a subsequent
patch will add schedule points to. So this spinlock will be a problem.

The only data structures that a protected by ->lookup_lock are the
sbi->expiring and sbi->active_list
lists of inodes. Neither of these are accessed in these functions,
so the lock cannot be needed.

I think the presence of these locks is a hold-over from a previous
locking scheme.

Signed-Off-By: NeilBrown <neil@xxxxxxxxxx>
---
fs/autofs/expire.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/fs/autofs/expire.c b/fs/autofs/expire.c
index ba1a3a2bfc9a..b6937c5936a5 100644
--- a/fs/autofs/expire.c
+++ b/fs/autofs/expire.c
@@ -90,12 +90,9 @@ static struct dentry *positive_after(struct dentry *p, struct dentry *child)
static struct dentry *get_next_positive_subdir(struct dentry *prev,
struct dentry *root)
{
- struct autofs_sb_info *sbi = autofs_sbi(root->d_sb);
struct dentry *q;

- spin_lock(&sbi->lookup_lock);
q = positive_after(root, prev);
- spin_unlock(&sbi->lookup_lock);
dput(prev);
return q;
}
@@ -106,13 +103,11 @@ static struct dentry *get_next_positive_subdir(struct dentry *prev,
static struct dentry *get_next_positive_dentry(struct dentry *prev,
struct dentry *root)
{
- struct autofs_sb_info *sbi = autofs_sbi(root->d_sb);
struct dentry *p = prev, *ret = NULL, *d = NULL;

if (prev == NULL)
return dget(root);

- spin_lock(&sbi->lookup_lock);
while (1) {
struct dentry *parent;

@@ -123,7 +118,6 @@ static struct dentry *get_next_positive_dentry(struct dentry *prev,
d = p;
p = parent;
}
- spin_unlock(&sbi->lookup_lock);
dput(prev);
return ret;
}
--
2.50.0.107.gf914562f5916.dirty