[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOQ4uxh-4dRSWQZr0Y7WrVmQc1ZLo=WXhmqD3DDMrWn0CgSC-A@mail.gmail.com>
Date: Wed, 16 Jun 2021 10:49:10 +0300
From: Amir Goldstein <amir73il@...il.com>
To: Gabriel Krisman Bertazi <krisman@...labora.com>
Cc: kernel@...labora.com, "Darrick J. Wong" <djwong@...nel.org>,
Theodore Tso <tytso@....edu>,
Dave Chinner <david@...morbit.com>, Jan Kara <jack@...e.com>,
David Howells <dhowells@...hat.com>,
Khazhismel Kumykov <khazhy@...gle.com>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Ext4 <linux-ext4@...r.kernel.org>
Subject: Re: [PATCH v2 01/14] fsnotify: Don't call insert hook for overflow events
On Wed, Jun 16, 2021 at 2:56 AM Gabriel Krisman Bertazi
<krisman@...labora.com> wrote:
>
> Overflow events are not mergeable, so they are not hashed_events. But,
> when failing inside fsnotify_add_event, for lack of space,
> fsnotify_add_event() still calls the insert hook, which adds the
> overflow event to the merge list.
>
> Avoid calling the insert hook when adding an overflow event.
>
> Fixes: 94e00d28a680 ("fsnotify: use hash table for faster events merge")
> Signed-off-by: Gabriel Krisman Bertazi <krisman@...labora.com>
> ---
> fs/notify/notification.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/fs/notify/notification.c b/fs/notify/notification.c
> index 32f45543b9c6..033294669e07 100644
> --- a/fs/notify/notification.c
> +++ b/fs/notify/notification.c
> @@ -106,6 +106,11 @@ int fsnotify_add_event(struct fsnotify_group *group,
> return ret;
> }
> event = group->overflow_event;
> + /*
> + * Since overflow events are not mergeable, don't insert
> + * them in the merge hash.
> + */
> + insert = NULL;
> goto queue;
> }
>
Hmm, the fix looks correct, but a bit fragile.
While it makes sense that @insert is the counterpart of @merge
there is nothing in the API that mandates it.
Therefore, it would be more robust IMO to add a check
fanotify_is_hashed_event(mask) in fanotify_insert_event()
to match fanotify_is_hashed_event(mask) in get_one_event().
If we do that, we can also simplify:
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -779,8 +779,7 @@ static int fanotify_handle_event(struct
fsnotify_group *group, u32 mask,
fsn_event = &event->fse;
ret = fsnotify_add_event(group, fsn_event, fanotify_merge,
- fanotify_is_hashed_event(mask) ?
- fanotify_insert_event : NULL);
+ fanotify_insert_event);
Thanks,
Amir.
Powered by blists - more mailing lists