From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com ([74.125.82.67]:36263 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751519AbeDENR3 (ORCPT ); Thu, 5 Apr 2018 09:17:29 -0400 Received: by mail-wm0-f67.google.com with SMTP id x82so7043340wmg.1 for ; Thu, 05 Apr 2018 06:17:29 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: Miklos Szeredi , Marko Rauhamaa , linux-fsdevel@vger.kernel.org Subject: [PATCH v2 18/20] fsnotify: send path type events to group with super block marks Date: Thu, 5 Apr 2018 16:18:19 +0300 Message-Id: <1522934301-6520-19-git-send-email-amir73il@gmail.com> In-Reply-To: <1522934301-6520-1-git-send-email-amir73il@gmail.com> References: <1522934301-6520-1-git-send-email-amir73il@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Send events to group if super block mark mask matches the event and unless the same group has an ignore mask on the vfsmount or the inode on which the event occurred. Soon, fanotify backend is going to support super block marks and fanotify currently only supports path type events. Signed-off-by: Amir Goldstein --- fs/notify/fsnotify.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index 2ef97bc27e20..f507d12a9e99 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -320,15 +320,18 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, const unsigned char *file_name, u32 cookie) { struct fsnotify_iter_info iter_info = {}; - struct mount *mnt; + struct super_block *sb = NULL; + struct mount *mnt = NULL; + __u32 mnt_or_sb_mask = 0; int ret = 0; /* global tests shouldn't care about events on child only the specific event */ __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); - if (data_is == FSNOTIFY_EVENT_PATH) + if (data_is == FSNOTIFY_EVENT_PATH) { mnt = real_mount(((const struct path *)data)->mnt); - else - mnt = NULL; + sb = mnt->mnt.mnt_sb; + mnt_or_sb_mask = mnt->mnt_fsnotify.mask | sb->s_fsnotify.mask; + } /* * Optimization: srcu_read_lock() has a memory barrier which can @@ -338,7 +341,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, * need SRCU to keep them "alive". */ if (!to_tell->i_fsnotify.marks && - (!mnt || !mnt->mnt_fsnotify.marks)) + (!mnt || (!mnt->mnt_fsnotify.marks && !sb->s_fsnotify.marks))) return 0; /* * if this is a modify event we may need to clear the ignored masks @@ -347,7 +350,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, */ if (!(mask & FS_MODIFY) && !(test_mask & to_tell->i_fsnotify.mask) && - !(mnt && test_mask & mnt->mnt_fsnotify.mask)) + !(mnt && (test_mask & mnt_or_sb_mask))) return 0; iter_info.srcu_idx = srcu_read_lock(&fsnotify_mark_srcu); @@ -359,11 +362,15 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, } if (mnt && ((mask & FS_MODIFY) || - (test_mask & mnt->mnt_fsnotify.mask))) { + (test_mask & mnt_or_sb_mask))) { fsnotify_iter_set_inode_mark(&iter_info, fsnotify_first_mark(&to_tell->i_fsnotify.marks)); fsnotify_iter_set_vfsmount_mark(&iter_info, fsnotify_first_mark(&mnt->mnt_fsnotify.marks)); + if ((mask & FS_MODIFY) || + (test_mask & sb->s_fsnotify.mask)) + fsnotify_iter_set_sb_mark(&iter_info, + fsnotify_first_mark(&sb->s_fsnotify.marks)); } /* -- 2.7.4