Message ID | 657f50e37d6d8f908c13f652129bcdd34ed7f4a9.1731684329.git.josef@toxicpanda.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | fanotify: add pre-content hooks | expand |
On Fri 15-11-24 10:30:26, Josef Bacik wrote: > From: Amir Goldstein <amir73il@gmail.com> > > 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@toxicpanda.com> > Signed-off-by: Amir Goldstein <amir73il@gmail.com> > --- > include/linux/fsnotify.h | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h > index 08893429a818..d5a0d8648000 100644 > --- a/include/linux/fsnotify.h > +++ b/include/linux/fsnotify.h > @@ -178,6 +178,11 @@ static inline void file_set_fsnotify_mode(struct file *file) > } > } > > +static inline bool fsnotify_file_has_pre_content_watches(struct file *file) > +{ > + return file && unlikely(FMODE_FSNOTIFY_HSM(file->f_mode)); > +} > + I was pondering about this and since we are trying to make these quick checks more explicit, I'll probably drop this helper. Also the 'file &&' part looks strange (I understand page_cache_[a]sync_ra() need it but I'd rather handle it explicitely there). Honza
On Wed, Nov 20, 2024 at 4:44 PM Jan Kara <jack@suse.cz> wrote: > > On Fri 15-11-24 10:30:26, Josef Bacik wrote: > > From: Amir Goldstein <amir73il@gmail.com> > > > > 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@toxicpanda.com> > > Signed-off-by: Amir Goldstein <amir73il@gmail.com> > > --- > > include/linux/fsnotify.h | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h > > index 08893429a818..d5a0d8648000 100644 > > --- a/include/linux/fsnotify.h > > +++ b/include/linux/fsnotify.h > > @@ -178,6 +178,11 @@ static inline void file_set_fsnotify_mode(struct file *file) > > } > > } > > > > +static inline bool fsnotify_file_has_pre_content_watches(struct file *file) > > +{ > > + return file && unlikely(FMODE_FSNOTIFY_HSM(file->f_mode)); > > +} > > + > > I was pondering about this and since we are trying to make these quick > checks more explicit, I'll probably drop this helper. Also the 'file &&' > part looks strange (I understand page_cache_[a]sync_ra() need it but I'd > rather handle it explicitely there). Makes sense. Thanks, Amir.
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index 08893429a818..d5a0d8648000 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h @@ -178,6 +178,11 @@ static inline void file_set_fsnotify_mode(struct file *file) } } +static inline bool fsnotify_file_has_pre_content_watches(struct file *file) +{ + return file && unlikely(FMODE_FSNOTIFY_HSM(file->f_mode)); +} + /* * fsnotify_file_area_perm - permission hook before access to file range */ @@ -264,6 +269,11 @@ static inline void file_set_fsnotify_mode(struct file *file) { } +static inline bool fsnotify_file_has_pre_content_watches(struct file *file) +{ + return false; +} + static inline int fsnotify_file_area_perm(struct file *file, int perm_mask, const loff_t *ppos, size_t count) {