Re: [PATCH 6/6] eventfs: clean up dentry ops and add revalidate function

From: Al Viro
Date: Tue Jan 30 2024 - 23:29:03 EST


On Tue, Jan 30, 2024 at 07:39:55PM -0800, Linus Torvalds wrote:

> Why don't we, btw? It would be so much better if we did the
> d_release() from __d_free(). We have all that smarts in fs/dcache.c to
> decide if we need to RCU-delay it or not, and then we don't let
> filesystems use it.

Because we want to give filesystems a chance to do something useful
in it? Something that might need access to the parent. Or superblock,
for that matter... By the time we are past the RCU delay there's
very little left; if you want to look at some per-superblock data,
you would have to do something like putting it into a refcounted
structure, with each dentry holding a counting reference, with obvious
effects...

We could add a separate method just for freeing stuff, but... we already
have 4 of them related to that path (->d_delete(), ->d_prune(), ->d_iput(),
->d_release()) and the things are pretty confusing as it is, without
throwing another one into the mix.

I'll look through the RCU pathwalk fixes (will repost the rebased set in
a couple of days, need to finish the re-audit of that stuff) and see how
much would such a method simplify, but I don't think it would buy us
a lot.

> So I guess the "make low-level filesystems do their own kfree_rcu() is
> what we're doing.
>
> In this case it's as simple as doing that
>
> - kfree(ei);
> + kfree_rcu(ei, rcu);
>
> and we'd just make the rcu entry a union with something that isn't
> that 'is_freed' field so that it doesn't take more space.