Skip to content

Commit f115815

Browse files
amir73iljankara
authored andcommitted
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 <[email protected]> Signed-off-by: Jan Kara <[email protected]> Message-Id: <[email protected]>
1 parent d2f277e commit f115815

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

fs/notify/fsnotify.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ static inline struct super_block *fsnotify_conn_sb(
2727
return container_of(conn->obj, struct super_block, s_fsnotify_marks);
2828
}
2929

30+
static inline struct super_block *fsnotify_object_sb(void *obj,
31+
enum fsnotify_obj_type obj_type)
32+
{
33+
switch (obj_type) {
34+
case FSNOTIFY_OBJ_TYPE_INODE:
35+
return ((struct inode *)obj)->i_sb;
36+
case FSNOTIFY_OBJ_TYPE_VFSMOUNT:
37+
return ((struct vfsmount *)obj)->mnt_sb;
38+
case FSNOTIFY_OBJ_TYPE_SB:
39+
return (struct super_block *)obj;
40+
default:
41+
return NULL;
42+
}
43+
}
44+
3045
static inline struct super_block *fsnotify_connector_sb(
3146
struct fsnotify_mark_connector *conn)
3247
{

fs/notify/mark.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,21 @@ void fsnotify_get_mark(struct fsnotify_mark *mark)
9797
refcount_inc(&mark->refcnt);
9898
}
9999

100+
static fsnotify_connp_t *fsnotify_object_connp(void *obj,
101+
enum fsnotify_obj_type obj_type)
102+
{
103+
switch (obj_type) {
104+
case FSNOTIFY_OBJ_TYPE_INODE:
105+
return &((struct inode *)obj)->i_fsnotify_marks;
106+
case FSNOTIFY_OBJ_TYPE_VFSMOUNT:
107+
return &real_mount(obj)->mnt_fsnotify_marks;
108+
case FSNOTIFY_OBJ_TYPE_SB:
109+
return &((struct super_block *)obj)->s_fsnotify_marks;
110+
default:
111+
return NULL;
112+
}
113+
}
114+
100115
static __u32 *fsnotify_conn_mask_p(struct fsnotify_mark_connector *conn)
101116
{
102117
if (conn->type == FSNOTIFY_OBJ_TYPE_INODE)

0 commit comments

Comments
 (0)