Re: [PATCH 4/4] fsnotify: optimize the case of no marks of any type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 03, 2021 at 09:03:44PM +0300, Amir Goldstein wrote:
> Add a simple check in the inline helpers to avoid calling fsnotify()
> and __fsnotify_parent() in case there are no marks of any type
> (inode/sb/mount) for an inode's sb, so there can be no objects
> of any type interested in the event.
> 
> Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>

LGTM.

Reviewed-by: Matthew Bobrowski <repnop@xxxxxxxxxx>

> ---
>  include/linux/fsnotify.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
> index f8acddcf54fb..12d3a7d308ab 100644
> --- a/include/linux/fsnotify.h
> +++ b/include/linux/fsnotify.h
> @@ -30,6 +30,9 @@ static inline void fsnotify_name(struct inode *dir, __u32 mask,
>  				 struct inode *child,
>  				 const struct qstr *name, u32 cookie)
>  {
> +	if (atomic_long_read(&dir->i_sb->s_fsnotify_connectors) == 0)
> +		return;
> +
>  	fsnotify(mask, child, FSNOTIFY_EVENT_INODE, dir, name, NULL, cookie);
>  }
>  
> @@ -41,6 +44,9 @@ static inline void fsnotify_dirent(struct inode *dir, struct dentry *dentry,
>  
>  static inline void fsnotify_inode(struct inode *inode, __u32 mask)
>  {
> +	if (atomic_long_read(&inode->i_sb->s_fsnotify_connectors) == 0)
> +		return;
> +
>  	if (S_ISDIR(inode->i_mode))
>  		mask |= FS_ISDIR;
>  
> @@ -53,6 +59,9 @@ static inline int fsnotify_parent(struct dentry *dentry, __u32 mask,
>  {
>  	struct inode *inode = d_inode(dentry);
>  
> +	if (atomic_long_read(&inode->i_sb->s_fsnotify_connectors) == 0)
> +		return 0;
> +
>  	if (S_ISDIR(inode->i_mode)) {
>  		mask |= FS_ISDIR;
>  
> -- 
> 2.25.1
> 
/M



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux