Re: [PATCH RFC v2 21/28] fsnotify: export fsnotify_recalc_mask()

Jeff Layton
2025-06-03T20:17:04Z

On Tue, 2025-06-03 at 22:13 +0200, Jan Kara wrote:
> On Mon 02-06-25 10:02:04, Jeff Layton wrote:
> > nfsd needs to call this when new directory delegations are set or unset.
> >
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
>
> So fsnotify_recalc_mask() is not a great API to export because it depends
> on lifetime rules of mark connector - in particular the caller has to make
> sure the connector stays alive while fsnotify_recalc_mask() is running. So
> far the knowledge was internal in fsnotify subsystem but now NFSD needs to
> know as well.
>
> Generally you need to recalculate the mask when you modify events you
> listen to in a mark. So perhaps we should provide an API like:
>
> int fsnotify_modify_mark_mask(struct fsnotify_mark *mark, __u32 mask_clear,
> __u32 mask_set);
>
> which could be used to modify mark mask without having to care about
> details like cached masks and connector locking rules?
>

That sounds like a reasonable thing to do. I'll plan to do something
along those lines. Thanks for the review!

>
> > ---
> > fs/notify/mark.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/fs/notify/mark.c b/fs/notify/mark.c
> > index 798340db69d761dd05c1b361c251818dee89b9cf..ff21409c3ca3ad948557225afc586da3728f7cbe 100644
> > --- a/fs/notify/mark.c
> > +++ b/fs/notify/mark.c
> > @@ -308,6 +308,7 @@ void fsnotify_recalc_mask(struct fsnotify_mark_connector *conn)
> > if (update_children)
> > fsnotify_conn_set_children_dentry_flags(conn);
> > }
> > +EXPORT_SYMBOL_GPL(fsnotify_recalc_mask);
> >
> > /* Free all connectors queued for freeing once SRCU period ends */
> > static void fsnotify_connector_destroy_workfn(struct work_struct *work)
> >
> > --
> > 2.49.0
> >

--
Jeff Layton <jlayton@kernel.org>