All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Matthew Bobrowski <mbobrowski@mbobrowski.org>,
	linux-fsdevel@vger.kernel.org
Subject: [PATCH v2 5/5] fsnotify: send event type FSNOTIFY_EVENT_DENTRY to super block mark
Date: Wed, 14 Nov 2018 19:43:44 +0200	[thread overview]
Message-ID: <20181114174344.17530-6-amir73il@gmail.com> (raw)
In-Reply-To: <20181114174344.17530-1-amir73il@gmail.com>

So far, existence of super block marks could be checked only on events
with data type FSNOTIFY_EVENT_PATH. Use d_sb field of dentry from events
with data type FSNOTIFY_EVENT_DENTRY to send event on super block mark.

This change has no effect on current backends. Soon, this will allow
fanotify backend to receive dentry events on a super block mark.

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

diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index 6a120b7f8b94..c9d673f0cbdc 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -338,6 +338,9 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
 		mnt = real_mount(((const struct path *)data)->mnt);
 		sb = mnt->mnt.mnt_sb;
 		mnt_or_sb_mask = mnt->mnt_fsnotify_mask | sb->s_fsnotify_mask;
+	} else if (data_is == FSNOTIFY_EVENT_DENTRY) {
+		sb = ((const struct dentry *)data)->d_sb;
+		mnt_or_sb_mask = sb->s_fsnotify_mask;
 	}
 	/* An event "on child" is not intended for a mount/sb mark */
 	if (mask & FS_EVENT_ON_CHILD)
@@ -350,8 +353,8 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
 	 * SRCU because we have no references to any objects and do not
 	 * need SRCU to keep them "alive".
 	 */
-	if (!to_tell->i_fsnotify_marks &&
-	    (!mnt || (!mnt->mnt_fsnotify_marks && !sb->s_fsnotify_marks)))
+	if (!to_tell->i_fsnotify_marks && (!mnt || !mnt->mnt_fsnotify_marks) &&
+	    (!sb || !sb->s_fsnotify_marks))
 		return 0;
 	/*
 	 * if this is a modify event we may need to clear the ignored masks
@@ -369,6 +372,8 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
 	if (mnt) {
 		iter_info.marks[FSNOTIFY_OBJ_TYPE_VFSMOUNT] =
 			fsnotify_first_mark(&mnt->mnt_fsnotify_marks);
+	}
+	if (sb) {
 		iter_info.marks[FSNOTIFY_OBJ_TYPE_SB] =
 			fsnotify_first_mark(&sb->s_fsnotify_marks);
 	}
-- 
2.17.1

      parent reply	other threads:[~2018-11-15  3:48 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-14 17:43 [PATCH v2 0/5] fsnotify prep work for fanotify dentry events Amir Goldstein
2018-11-14 17:43 ` [PATCH v2 1/5] fsnotify: pass dentry instead of inode when available Amir Goldstein
2018-11-20 11:32   ` Jan Kara
2018-11-20 14:36     ` Amir Goldstein
2018-11-21 12:51       ` Jan Kara
2018-11-21 16:13         ` Amir Goldstein
2018-11-22  9:52           ` Jan Kara
2018-11-22 12:36             ` Amir Goldstein
2018-11-22 13:26               ` Jan Kara
2018-11-22 15:18                 ` Amir Goldstein
2018-11-22 19:42                   ` Amir Goldstein
2018-11-23 12:56                     ` Jan Kara
2018-11-23 13:42                       ` Amir Goldstein
2018-11-23 12:52                   ` Btrfs and fanotify filesystem watches Jan Kara
2018-11-23 13:34                     ` Amir Goldstein
2018-11-23 17:53                       ` Amir Goldstein
2018-11-27  8:35                         ` Jan Kara
2018-11-14 17:43 ` [PATCH v2 2/5] fsnotify: annotate filename events Amir Goldstein
2018-11-20 11:59   ` Jan Kara
2018-11-20 14:58     ` Amir Goldstein
2018-11-21 13:18       ` Jan Kara
2018-11-21 15:40         ` Amir Goldstein
2018-11-22  7:45           ` Amir Goldstein
2018-11-22  9:33             ` Jan Kara
2018-11-22  8:40     ` Amir Goldstein
2018-11-14 17:43 ` [PATCH v2 3/5] fsnotify: simplify API for " Amir Goldstein
2018-11-14 17:43 ` [PATCH v2 4/5] fsnotify: make MOVED_FROM a dentry event Amir Goldstein
2018-11-20 12:45   ` Jan Kara
2018-11-14 17:43 ` Amir Goldstein [this message]

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=20181114174344.17530-6-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mbobrowski@mbobrowski.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.