Re: [PATCH v6 0/5] Fix easy bits of the negative dentry problem

From: NeilBrown

Date: Tue Nov 24 2026 - 01:42:23 EST


On Tue, 24 Nov 2026, NeilBrown wrote:
> This v6:
> - fixes the autofs changes in 1/5

Sashiko says this is racy. I think it is but the original code was just
as racy. Maybe the race isn't relevant. I haven't properly understood
it yet.

> - updates d_duplicate() in 1/5

The fix was seriously broken. Sorry.

> - uses a new version of 2/5 from Amir

Sashiko has something to say about this

Can clearing FSNOTIFY_CONN_FLAG_UPDATE_CHILDREN and dropping conn->lock
before fsnotify_set_children_dentry_flags() finishes allow a concurrent
watch-adding syscall to return to userspace before the children's
DCACHE_FSNOTIFY_PARENT_WATCHED flags have been set?

Thoughts?

thanks,
NeilBrown



> - Fixes the skipping of cursors in 4/5

At least this bit seems to be ok :-)

>
> Thanks,
> NeilBrown
>
> Original intro - revised:
>
> I was reading about the negative dentry problem in
> https://lwn.net/Articles/1079407/ and thought I would have a go 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" is relatively easy.
> With this in place I would feel more confident addressing
> the "arbitrarily long" part if that seemed worth while.
>
> 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 that
> nothing should be holding any other lock while walking ->d_children
>
>
> [PATCH v6 1/5] VFS: don't count references through ->d_parent
> [PATCH v6 2/5] fsnotify: update children flags only when parent
> [PATCH v6 3/5] fsnotify: don't hold i_lock while walking d_children
> [PATCH v6 4/5] Add d_for_each_positive_child family of iterators
> [PATCH v6 5/5] Use d_for_each_positive_child() in fsnotify.
>
>