All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	Marko Rauhamaa <marko.rauhamaa@f-secure.com>,
	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	[thread overview]
Message-ID: <1522934301-6520-19-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1522934301-6520-1-git-send-email-amir73il@gmail.com>

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 <amir73il@gmail.com>
---
 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

  parent reply	other threads:[~2018-04-05 13:17 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-05 13:18 [PATCH v2 00/20] fanotify: super block mark Amir Goldstein
2018-04-05 13:18 ` [PATCH v2 01/20] fanotify: fix logic of events on child Amir Goldstein
2018-04-09  3:37   ` Sasha Levin
2018-04-13 13:50   ` Jan Kara
2018-04-05 13:18 ` [PATCH v2 02/20] fsnotify: fix ignore mask logic in send_to_group() Amir Goldstein
2018-04-13 13:53   ` Jan Kara
2018-04-05 13:18 ` [PATCH v2 03/20] fsnotify: fix typo in a comment about mark->g_list Amir Goldstein
2018-04-13 13:56   ` Jan Kara
2018-04-05 13:18 ` [PATCH v2 04/20] MAINTAINERS: add an entry for FSNOTIFY infrastructure Amir Goldstein
2018-04-13 13:56   ` Jan Kara
2018-04-05 13:18 ` [PATCH v2 05/20] fsnotify: use type id to identify connector object type Amir Goldstein
2018-04-17 16:26   ` Jan Kara
2018-04-17 17:45     ` Amir Goldstein
2018-04-05 13:18 ` [PATCH v2 06/20] fsnotify: remove redundant arguments to handle_event() Amir Goldstein
2018-04-17 16:33   ` Jan Kara
2018-04-17 17:59     ` Amir Goldstein
2018-04-05 13:18 ` [PATCH v2 07/20] fsnotify: introduce marks iteration helpers Amir Goldstein
2018-04-17 16:38   ` Jan Kara
2018-04-17 18:37     ` Amir Goldstein
2018-04-05 13:18 ` [PATCH v2 08/20] fsnotify: generalize iteration of marks by object type Amir Goldstein
2018-04-17 17:01   ` Jan Kara
2018-04-17 19:11     ` Amir Goldstein
2018-04-18  8:34       ` Jan Kara
2018-04-18 12:31         ` Amir Goldstein
2018-04-05 13:18 ` [PATCH v2 09/20] fsnotify: generalize send_to_group() Amir Goldstein
2018-04-05 13:18 ` [PATCH v2 10/20] fanotify: generalize fanotify_should_send_event() Amir Goldstein
2018-04-05 13:18 ` [PATCH v2 11/20] fsnotify: add fsnotify_add_inode_mark() wrappers Amir Goldstein
2018-04-05 13:18 ` [PATCH v2 12/20] fsnotify: introduce prototype struct fsnotify_obj Amir Goldstein
2018-04-19 12:14   ` Jan Kara
2018-04-05 13:18 ` [PATCH v2 13/20] fsnotify: pass fsnotify_obj instead of **connp argument Amir Goldstein
2018-04-05 13:18 ` [PATCH v2 14/20] fsnotify: pass object and object type to fsnotify_add_mark() Amir Goldstein
2018-04-19 12:23   ` Jan Kara
2018-04-19 14:28     ` Amir Goldstein
2018-04-05 13:18 ` [PATCH v2 15/20] fsnotify: make fsnotify_recalc_mask() unaware of object type Amir Goldstein
2018-04-06  9:03   ` kbuild test robot
2018-04-05 13:18 ` [PATCH v2 16/20] fsnotify: generalize fsnotify_detach_connector_from_object() Amir Goldstein
2018-04-19 13:59   ` Jan Kara
2018-04-19 14:07     ` Amir Goldstein
2018-04-05 13:18 ` [PATCH v2 17/20] fsnotify: add super block object type Amir Goldstein
2018-04-06  6:01   ` kbuild test robot
2018-04-06 11:04     ` Amir Goldstein
2018-04-19 12:41       ` Jan Kara
2018-04-19 14:27         ` Amir Goldstein
2018-04-19 12:39   ` Jan Kara
2018-04-05 13:18 ` Amir Goldstein [this message]
2018-04-19 13:49   ` [PATCH v2 18/20] fsnotify: send path type events to group with super block marks Jan Kara
2018-04-19 14:19     ` Amir Goldstein
2018-04-05 13:18 ` [PATCH v2 19/20] fanotify: factor out helpers to add/remove mark Amir Goldstein
2018-04-05 13:18 ` [PATCH v2 20/20] fanotify: add API to attach/detach super block mark Amir Goldstein

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=1522934301-6520-19-git-send-email-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=marko.rauhamaa@f-secure.com \
    --cc=miklos@szeredi.hu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.