Re: [RFC PATCH v2 4/4] get rid of busy-waiting in shrink_dcache_tree()

Al Viro
2026-04-02T23:13:09Z

On Thu, Apr 02, 2026 at 03:49:39PM -0700, Linus Torvalds wrote:

> In fact, the __hlist_del() *without* the init part would work fine for
> me with the comment.
>
> But it was really the added
>
> if (likely(!hlist_unhashed(&dentry->d_alias)))
>
> that made me go "why is _that_ needed?"
>
> Afaik, it's a perfectly find hlist entry at that point, and no need to
> add the hlist_unhashed() check. No?

The incremental I've got right now is

diff --git a/fs/dcache.c b/fs/dcache.c
index 09a80f7f3d05..b83c279f34a0 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -455,8 +455,15 @@ static void dentry_unlink_inode(struct dentry * dentry)

raw_write_seqcount_begin(&dentry->d_seq);
__d_clear_type_and_inode(dentry);
- if (likely(!hlist_unhashed(&dentry->d_alias)))
- __hlist_del(&dentry->d_alias);
+ hlist_del_init(&dentry->d_alias);
+ /*
+ * dentry becomes negative, so the space occupied by ->d_alias
+ * belongs to ->waiters now; we could use __hlist_del() instead
+ * of hlist_del_init(), if not for the stunt pulled by nfs
+ * dummy root dentries - positive dentry *not* included into
+ * the alias list of its inode. Open-coding hlist_del_init()
+ * and removing zeroing would be too clumsy...
+ */
dentry->waiters = NULL;
raw_write_seqcount_end(&dentry->d_seq);
spin_unlock(&dentry->d_lock);