[PATCH v2 18/18] autofs: change get_next_positive_dentry() to NOT accept NULL for start-up
From: NeilBrown
Date: Sat Aug 15 2026 - 00:37:04 EST
From: NeilBrown <neil@xxxxxxxxxx>
Rather than passing NULL to get_next_positive_dentry() to first time
round, change callers to use a for loop which does the dget() explicitly
to start the loop.
I think this makes the code clearer. Looking at
get_next_positive_dentry() it isn't immediately obvious what that code
is doing there.
Signed-off-by: NeilBrown <neil@xxxxxxxxxx>
---
fs/autofs/expire.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/fs/autofs/expire.c b/fs/autofs/expire.c
index 277d9129754e..2a1844ba48c6 100644
--- a/fs/autofs/expire.c
+++ b/fs/autofs/expire.c
@@ -83,9 +83,6 @@ static struct dentry *get_next_positive_dentry(struct dentry *prev,
{
struct dentry *ret = NULL;
- if (prev == NULL)
- return dget(root);
-
while ((ret = d_scan_positives(prev, ret, 0)) == NULL &&
prev != root) {
ret = prev;
@@ -148,7 +145,7 @@ static int autofs_tree_busy(struct vfsmount *mnt,
return 1;
p = NULL;
- while ((p = get_next_positive_dentry(p, top))) {
+ for (p = dget(top); p; p = get_next_positive_dentry(p, top)) {
pr_debug("dentry %p %pd\n", p, p);
/*
@@ -201,8 +198,7 @@ static struct dentry *autofs_check_leaves(struct vfsmount *mnt,
pr_debug("parent %p %pd\n", parent, parent);
- p = NULL;
- while ((p = get_next_positive_dentry(p, parent))) {
+ for (p = dget(parent); p; p = get_next_positive_dentry(p, parent)) {
pr_debug("dentry %p %pd\n", p, p);
if (d_mountpoint(p)) {
--
2.50.0.107.gf914562f5916.dirty