[PATCH v1 06/12] libfs: change scan_positives() to use d_for_each_positive_child_continue()
NeilBrown <[email protected]> Mon, 3 Aug 2026 11:21:15 +1000
| Newsgroups | org.kernel.vger.autofs,org.kernel.vger.ceph-devel,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-nfs |
|---|---|
| Message-ID | <[email protected]> |
From: NeilBrown <[email protected]> Using d_for_each_positive_child_continue() simplifies this code slightly and make is easier to read. Signed-off-by: NeilBrown <[email protected]> --- fs/libfs.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index 080ca615593c..c2369ea9196f 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -109,17 +109,9 @@ static struct dentry *scan_positives(struct dentry *cursor, loff_t count) { struct dentry *dentry = cursor->d_parent, *found = NULL; - struct dentry *next; + struct dentry *d = last; - spin_lock(&dentry->d_lock); - next = last ? d_next_sibling(last) : d_first_child(dentry); - while (next) { - struct dentry *d = next; - - next = d_next_sibling(next); - // we must at least skip cursors, to avoid livelocks - if (d->d_flags & DCACHE_DENTRY_CURSOR) - continue; + d_for_each_positive_child_continue(d, dentry) { if (simple_positive(d) && !--count) { spin_lock_nested(&d->d_lock, DENTRY_D_LOCK_NESTED); if (simple_positive(d)) @@ -133,13 +125,12 @@ static struct dentry *scan_positives(struct dentry *cursor, if (!hlist_unhashed(&cursor->d_sib)) __hlist_del(&cursor->d_sib); hlist_add_behind(&cursor->d_sib, &d->d_sib); + d = cursor; spin_unlock(&dentry->d_lock); cond_resched(); spin_lock(&dentry->d_lock); - next = d_next_sibling(cursor); } } - spin_unlock(&dentry->d_lock); dput(last); return found; } -- 2.50.0.107.gf914562f5916.dirty