[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOQ4uxhj7tQ1E4TmMbjodfiJtuosPdGp4B9WZQ2Qc76zs=g6sg@mail.gmail.com>
Date: Wed, 13 Nov 2024 19:33:30 +0100
From: Amir Goldstein <amir73il@...il.com>
To: Josef Bacik <josef@...icpanda.com>
Cc: kernel-team@...com, linux-fsdevel@...r.kernel.org, jack@...e.cz,
brauner@...nel.org, torvalds@...ux-foundation.org, linux-xfs@...r.kernel.org,
linux-btrfs@...r.kernel.org, linux-mm@...ck.org, linux-ext4@...r.kernel.org
Subject: Re: [PATCH v7 12/18] fanotify: add a helper to check for pre content events
On Tue, Nov 12, 2024 at 6:56 PM Josef Bacik <josef@...icpanda.com> wrote:
>
> We want to emit events during page fault, and calling into fanotify
> could be expensive, so add a helper to allow us to skip calling into
> fanotify from page fault. This will also be used to disable readahead
> for content watched files which will be handled in a subsequent patch.
>
> Signed-off-by: Josef Bacik <josef@...icpanda.com>
> ---
> fs/notify/fsnotify.c | 12 ++++++++++++
> include/linux/fsnotify_backend.h | 26 ++++++++++++++++++++++++++
> 2 files changed, 38 insertions(+)
>
> diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
> index cab5a1a16e57..17047c44cf91 100644
> --- a/fs/notify/fsnotify.c
> +++ b/fs/notify/fsnotify.c
> @@ -203,6 +203,18 @@ static inline bool fsnotify_object_watched(struct inode *inode, __u32 mnt_mask,
> return mask & marks_mask & ALL_FSNOTIFY_EVENTS;
> }
>
> +#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
> +bool fsnotify_file_object_watched(struct file *file, __u32 mask)
> +{
> + struct inode *inode = file_inode(file);
> + __u32 mnt_mask = real_mount(file->f_path.mnt)->mnt_fsnotify_mask;
> +
> + return fsnotify_object_watched(inode, mnt_mask, mask);
> +}
> +EXPORT_SYMBOL_GPL(fsnotify_file_object_watched);
> +#endif
> +
FYI, I was going to use this helper to set the FMODE_ flags, but
I noticed that it is missing the check for parent watching pre content
events.
The other user of fsnotify_object_watched(), __fsnotify_parent()
explicitly checks the fsnotify_inode_watches_children() mask.
I will need to add this.
Thanks,
Amir.
Powered by blists - more mailing lists