From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Christian Brauner <brauner@kernel.org>, Chris Mason <clm@fb.com>,
Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH v2 2/3] fanotify: report the most specific fsid for btrfs
Date: Thu, 26 Oct 2023 18:52:23 +0300 [thread overview]
Message-ID: <20231026155224.129326-3-amir73il@gmail.com> (raw)
In-Reply-To: <20231026155224.129326-1-amir73il@gmail.com>
With btrfs, a marked inode and marked sb may have a different fsid.
If both inode and sb are marked with a specific event type in mask,
report the more specific fsid (i.e. of the inode) in the event.
This is needed to support fanotify marks in btrfs sub-volumes.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/notify/fanotify/fanotify.c | 2 ++
include/linux/fsnotify_backend.h | 5 +++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index aff1ab3c32aa..3053606d7ff5 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -840,6 +840,8 @@ static struct fanotify_event *fanotify_alloc_event(
/*
* Get cached fsid of the filesystem containing the object from any mark.
* All marks are supposed to have the same fsid, but we do not verify that here.
+ * With btrfs, a marked inode and marked sb may have a different fsid.
+ * In this case, we will return the more specific fsid (i.e. of the inode).
*/
static __kernel_fsid_t fanotify_get_fsid(struct fsnotify_iter_info *iter_info)
{
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index a80b525ca653..f329375bef22 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -372,13 +372,14 @@ static inline struct fs_error_report *fsnotify_data_error_report(
* the other way around, because an event can match different watched objects
* of the same object type.
* For example, both parent and child are watching an object of type inode.
+ * The order of iteration is from most specific (inode) to most general (sb).
*/
enum fsnotify_iter_type {
FSNOTIFY_ITER_TYPE_INODE,
+ FSNOTIFY_ITER_TYPE_INODE2,
+ FSNOTIFY_ITER_TYPE_PARENT,
FSNOTIFY_ITER_TYPE_VFSMOUNT,
FSNOTIFY_ITER_TYPE_SB,
- FSNOTIFY_ITER_TYPE_PARENT,
- FSNOTIFY_ITER_TYPE_INODE2,
FSNOTIFY_ITER_TYPE_COUNT
};
--
2.34.1
next prev parent reply other threads:[~2023-10-26 15:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 15:52 [PATCH v2 0/3] fanotify support for btrfs sub-volumes Amir Goldstein
2023-10-26 15:52 ` [PATCH v2 1/3] fanotify: store fsid in mark instead of in connector Amir Goldstein
2023-10-26 15:52 ` Amir Goldstein [this message]
2023-10-26 15:52 ` [PATCH v2 3/3] fanotify: support setting marks in btrfs sub-volumes Amir Goldstein
2023-10-26 16:09 ` [PATCH v2 0/3] fanotify support for " Jan Kara
2023-10-27 5:46 ` Christoph Hellwig
2023-10-27 6:03 ` Amir Goldstein
2023-10-27 6:08 ` Christoph Hellwig
2023-10-27 6:33 ` Amir Goldstein
2023-10-27 7:30 ` Christoph Hellwig
2023-10-27 15: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=20231026155224.129326-3-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=jack@suse.cz \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).