[PATCH RFC/RFT v3 00/11] Fix easy bits of the negative dentry problem

From: NeilBrown

Date: Tue Aug 25 2026 - 18:15:59 EST


Here is v3 which I hope will be the last RFC. I'd like to submit this
for inclusion in a couple of weeks.
This version:
- drops the changes to libfs.c. They aren't strictly needed here
and serve to bloat the series. I still want to pursue those but
will do it separately.
- revises the first fsnotify patch to be more cautious about what I take
outside of existing locks
- fixes the nfs i_lock problem Chuck reported
- fixes a few things sashiko.dev found

Thanks for any review and/or testing.

NeilBrown

Original intro - slightly revised:

I was reading about the negative dentry problem in
https://lwn.net/Articles/1079407/ and thought I would have ago at the
easy bits. Given how involved some of that was I'm glad I didn't try
the tricky bits!

So I didn't try to reduce the number of negative dentries or handle
them differently to positive dentries. I just tried to address
specific symptoms.

This series addresses two reported symptoms.
1/ refcounts on parents can potentially overflow if there are billions
of (negative) children. This was the easiest easy bit. The first
patch is all that is needed.

2/ Walking the ->d_children list can take arbitrarily long and can
trigger soft lockups. I haven't addresses the "arbitrarily long"
part, but the "soft lockups" only takes another 11 patches.
With these in place I would feel more confident addressing
the "arbitrarily long" part.

The core idea is to use a common helper for all walking of
->d_children, and teach it to drop the lock and schedule when needed,
inserting a cursor to keep its place.
This simple idea requires:
- nothing should be holding any other lock while walking ->d_children
- dentries shouldn't be moved around needlessly, else things might
get missed.

so I have probably missed some bits and would be very happy to be told
what I have missed.
I would also be very happy if someone who can trigger the soft lockups
can try this code and confirm that the locks are gone, and nothing bad
happens.
I have done some basic testing including the "notify" parts of
ltp, but that is all.

I haven't addressed d_walk() or scan_positives() in this series - I
thought it was big enough for now. There are already some
cond_reshed() calls in this code so it isn't clear it *needs* fixing.


[PATCH v3 01/11] VFS: don't count references through ->d_parent
[PATCH v3 02/11] autofs: change positive_after() so it takes d_lock
[PATCH v3 03/11] coda: don't take rcu_read_lock() in
[PATCH v3 04/11] nfs: separate locked regions in
[PATCH v3 05/11] Add and use d_for_each_positive_child family of
[PATCH v3 06/11] fsnotify: don't hold a spin_lock across
[PATCH v3 07/11] fsnotify: don't hold i_lock while walking d_children
[PATCH v3 08/11] nfs: Don't hold i_lock while walking ->d_children
[PATCH v3 09/11] autofs: don't hold ->lookup_lock in
[PATCH v3 10/11] VFS: don't move dentries in d_sib list when they
[PATCH v3 11/11] Call cond_reshed() as needed in