linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Gabriel Krisman Bertazi <krisman@collabora.com>
Cc: kernel@collabora.com, "Darrick J. Wong" <djwong@kernel.org>,
	Theodore Tso <tytso@mit.edu>, Dave Chinner <david@fromorbit.com>,
	Jan Kara <jack@suse.com>, David Howells <dhowells@redhat.com>,
	Khazhismel Kumykov <khazhy@google.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Ext4 <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH v2 01/14] fsnotify: Don't call insert hook for overflow events
Date: Wed, 16 Jun 2021 10:49:10 +0300	[thread overview]
Message-ID: <CAOQ4uxh-4dRSWQZr0Y7WrVmQc1ZLo=WXhmqD3DDMrWn0CgSC-A@mail.gmail.com> (raw)
In-Reply-To: <20210615235556.970928-2-krisman@collabora.com>

On Wed, Jun 16, 2021 at 2:56 AM Gabriel Krisman Bertazi
<krisman@collabora.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@collabora.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.

  reply	other threads:[~2021-06-16  7:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-15 23:55 [PATCH v2 00/14] File system wide monitoring Gabriel Krisman Bertazi
2021-06-15 23:55 ` [PATCH v2 01/14] fsnotify: Don't call insert hook for overflow events Gabriel Krisman Bertazi
2021-06-16  7:49   ` Amir Goldstein [this message]
2021-06-15 23:55 ` [PATCH v2 02/14] fanotify: Fold event size calculation to its own function Gabriel Krisman Bertazi
2021-06-15 23:55 ` [PATCH v2 03/14] fanotify: Split fsid check from other fid mode checks Gabriel Krisman Bertazi
2021-06-16  8:07   ` Amir Goldstein
2021-06-15 23:55 ` [PATCH v2 04/14] fanotify: Split superblock marks out to a new cache Gabriel Krisman Bertazi
2021-06-16  9:16   ` Amir Goldstein
2021-06-15 23:55 ` [PATCH v2 05/14] inotify: Don't force FS_IN_IGNORED Gabriel Krisman Bertazi
2021-06-15 23:55 ` [PATCH v2 06/14] fsnotify: Add helper to detect overflow_event Gabriel Krisman Bertazi
2021-06-16  9:23   ` Amir Goldstein
2021-06-15 23:55 ` [PATCH v2 07/14] fsnotify: pass arguments of fsnotify() in struct fsnotify_event_info Gabriel Krisman Bertazi
2021-06-16  9:26   ` Amir Goldstein
2021-06-16 10:11   ` kernel test robot
2021-06-15 23:55 ` [PATCH v2 08/14] fsnotify: Support passing argument to insert callback on add_event Gabriel Krisman Bertazi
2021-06-15 23:55 ` [PATCH v2 09/14] fsnotify: Support FS_ERROR event type Gabriel Krisman Bertazi
2021-06-16  9:29   ` Amir Goldstein
2021-06-15 23:55 ` [PATCH v2 10/14] fsnotify: Introduce helpers to send error_events Gabriel Krisman Bertazi
2021-06-16  9:38   ` Amir Goldstein
2021-06-15 23:55 ` [PATCH v2 11/14] fanotify: Introduce FAN_FS_ERROR event Gabriel Krisman Bertazi
2021-06-16 11:02   ` Amir Goldstein
2021-06-15 23:55 ` [PATCH v2 12/14] ext4: Send notifications on error Gabriel Krisman Bertazi
2021-06-15 23:55 ` [PATCH v2 13/14] samples: Add fs error monitoring example Gabriel Krisman Bertazi
2021-06-16 13:04   ` kernel test robot
2021-06-15 23:55 ` [PATCH v2 14/14] Documentation: Document the FAN_FS_ERROR event Gabriel Krisman Bertazi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOQ4uxh-4dRSWQZr0Y7WrVmQc1ZLo=WXhmqD3DDMrWn0CgSC-A@mail.gmail.com' \
    --to=amir73il@gmail.com \
    --cc=david@fromorbit.com \
    --cc=dhowells@redhat.com \
    --cc=djwong@kernel.org \
    --cc=jack@suse.com \
    --cc=kernel@collabora.com \
    --cc=khazhy@google.com \
    --cc=krisman@collabora.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).