[PATCH v2 18/18] autofs: change get_next_positive_dentry() to NOT accept NULL for start-up

NeilBrown <[email protected]>
Newsgroups org.kernel.vger.ceph-devel,org.kernel.vger.autofs,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-nfs
Message-ID <[email protected]>
From: NeilBrown <[email protected]>

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 <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.