All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Eric Paris <eparis@redhat.com>, linux-fsdevel@vger.kernel.org
Subject: [RFC][PATCH 2/4] fsnotify: helper to update marks ignored_mask
Date: Tue, 27 Dec 2016 21:32:26 +0200	[thread overview]
Message-ID: <1482867148-31497-3-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1482867148-31497-1-git-send-email-amir73il@gmail.com>

Factor out a helper update_ignored_mask() to update ignored_mask
of inode and vfsmount marks and calculate their combined mask.

With this change, in should_send_to_group() the inode mark mask
is masked with the combined ignored mask, instead of just its own
ignored mask, just like the vfsmount mark mask.

This behavior is similar to the test in fanotify_should_send_event(),
so it does not have any visible effect.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/notify/fsnotify.c | 38 ++++++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index 138e066..b631df5 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -122,6 +122,30 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask
 }
 EXPORT_SYMBOL_GPL(__fsnotify_parent);
 
+static __u32 update_ignored_mask(struct fsnotify_mark *inode_mark,
+				 struct fsnotify_mark *vfsmount_mark,
+				 __u32 mask)
+{
+	__u32 ignored_mask = 0;
+
+	/* clear ignored on inode modification */
+	if (mask & FS_MODIFY) {
+		if (inode_mark &&
+		    !(inode_mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY))
+			inode_mark->ignored_mask = 0;
+		if (vfsmount_mark &&
+		    !(vfsmount_mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY))
+			vfsmount_mark->ignored_mask = 0;
+	}
+
+	if (inode_mark)
+		ignored_mask |= inode_mark->ignored_mask;
+	if (vfsmount_mark)
+		ignored_mask |= vfsmount_mark->ignored_mask;
+
+	return ignored_mask;
+}
+
 static int send_to_group(struct inode *to_tell,
 			 struct fsnotify_mark *inode_mark,
 			 struct fsnotify_mark *vfsmount_mark,
@@ -132,29 +156,20 @@ static int send_to_group(struct inode *to_tell,
 	struct fsnotify_group *group = NULL;
 	__u32 inode_test_mask = 0;
 	__u32 vfsmount_test_mask = 0;
-	__u32 ignored_mask = 0;
+	__u32 ignored_mask;
 
 	if (unlikely(!inode_mark && !vfsmount_mark)) {
 		BUG();
 		return 0;
 	}
 
-	/* clear ignored on inode modification */
-	if (mask & FS_MODIFY) {
-		if (inode_mark &&
-		    !(inode_mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY))
-			inode_mark->ignored_mask = 0;
-		if (vfsmount_mark &&
-		    !(vfsmount_mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY))
-			vfsmount_mark->ignored_mask = 0;
-	}
+	ignored_mask = update_ignored_mask(inode_mark, vfsmount_mark, mask);
 
 	/* does the inode mark tell us to do something? */
 	if (inode_mark) {
 		group = inode_mark->group;
 		inode_test_mask = (mask & ~FS_EVENT_ON_CHILD);
 		inode_test_mask &= inode_mark->mask;
-		ignored_mask |= inode_mark->ignored_mask;
 		inode_test_mask &= ~ignored_mask;
 	}
 
@@ -163,7 +178,6 @@ static int send_to_group(struct inode *to_tell,
 		vfsmount_test_mask = (mask & ~FS_EVENT_ON_CHILD);
 		group = vfsmount_mark->group;
 		vfsmount_test_mask &= vfsmount_mark->mask;
-		ignored_mask |= vfsmount_mark->ignored_mask;
 		vfsmount_test_mask &= ~ignored_mask;
 	}
 
-- 
2.7.4


  parent reply	other threads:[~2016-12-27 19:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-27 19:32 [RFC][PATCH 0/4] fsnotify: pass single mark to handle_event() Amir Goldstein
2016-12-27 19:32 ` [RFC][PATCH 1/4] fsnotify: process inode/vfsmount marks independently Amir Goldstein
2016-12-27 19:32 ` Amir Goldstein [this message]
2016-12-27 19:32 ` [RFC][PATCH 3/4] fsnotify: return FSNOTIFY_DROPPED when handle_event() dropped event Amir Goldstein
2016-12-27 19:32 ` [RFC][PATCH 4/4] fsnotify: pass single mark to handle_event() Amir Goldstein
2017-01-04  8:28 ` [RFC][PATCH 0/4] " Jan Kara
2017-01-04  9:57   ` Amir Goldstein
2017-01-04 10:39     ` Jan Kara
2017-01-04 10:45       ` Amir Goldstein
2017-01-04 11:47         ` Jan Kara

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=1482867148-31497-3-git-send-email-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=eparis@redhat.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    /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.