summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2024-03-17 21:41:46 +0300
committerJan Kara <jack@suse.cz>2024-04-04 17:23:46 +0300
commitf115815d75332f9dabb0d7c29c8f67b0f26889c5 (patch)
tree6a5a3ed58e82a5e9e8e651f4d7530889dbd55fc5
parentd2f277e26f521ccf6fb438463b41dba6123caabe (diff)
downloadlinux-f115815d75332f9dabb0d7c29c8f67b0f26889c5.tar.xz
fsnotify: create helpers to get sb and connp from object
In preparation to passing an object pointer to add/remove/find mark helpers, create helpers to get sb and connp by object type. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz> Message-Id: <20240317184154.1200192-3-amir73il@gmail.com>
-rw-r--r--fs/notify/fsnotify.h15
-rw-r--r--fs/notify/mark.c15
2 files changed, 30 insertions, 0 deletions
diff --git a/fs/notify/fsnotify.h b/fs/notify/fsnotify.h
index fde74eb333cc..6d9951aac449 100644
--- a/fs/notify/fsnotify.h
+++ b/fs/notify/fsnotify.h
@@ -27,6 +27,21 @@ static inline struct super_block *fsnotify_conn_sb(
return container_of(conn->obj, struct super_block, s_fsnotify_marks);
}
+static inline struct super_block *fsnotify_object_sb(void *obj,
+ enum fsnotify_obj_type obj_type)
+{
+ switch (obj_type) {
+ case FSNOTIFY_OBJ_TYPE_INODE:
+ return ((struct inode *)obj)->i_sb;
+ case FSNOTIFY_OBJ_TYPE_VFSMOUNT:
+ return ((struct vfsmount *)obj)->mnt_sb;
+ case FSNOTIFY_OBJ_TYPE_SB:
+ return (struct super_block *)obj;
+ default:
+ return NULL;
+ }
+}
+
static inline struct super_block *fsnotify_connector_sb(
struct fsnotify_mark_connector *conn)
{
diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index 3bcce2671bd5..d9977af25832 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -97,6 +97,21 @@ void fsnotify_get_mark(struct fsnotify_mark *mark)
refcount_inc(&mark->refcnt);
}
+static fsnotify_connp_t *fsnotify_object_connp(void *obj,
+ enum fsnotify_obj_type obj_type)
+{
+ switch (obj_type) {
+ case FSNOTIFY_OBJ_TYPE_INODE:
+ return &((struct inode *)obj)->i_fsnotify_marks;
+ case FSNOTIFY_OBJ_TYPE_VFSMOUNT:
+ return &real_mount(obj)->mnt_fsnotify_marks;
+ case FSNOTIFY_OBJ_TYPE_SB:
+ return &((struct super_block *)obj)->s_fsnotify_marks;
+ default:
+ return NULL;
+ }
+}
+
static __u32 *fsnotify_conn_mask_p(struct fsnotify_mark_connector *conn)
{
if (conn->type == FSNOTIFY_OBJ_TYPE_INODE)