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

NeilBrown <[email protected]> Mon, 3 Aug 2026 11:21:18 +1000
Newsgroups org.kernel.vger.linux-nfs,org.kernel.vger.autofs,org.kernel.vger.ceph-devel,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
From: NeilBrown <[email protected]>

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.

Signed-Off-By: NeilBrown <[email protected]>
---
 fs/autofs/expire.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/fs/autofs/expire.c b/fs/autofs/expire.c
index 7b0a22629415..704d5394cbb8 100644
--- a/fs/autofs/expire.c
+++ b/fs/autofs/expire.c
@@ -91,12 +91,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;
 }
@@ -107,13 +104,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;
 
@@ -124,7 +119,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