Skip to content

Commit 3a9b16b

Browse files
committed
fsnotify: send fsnotify_mark to groups in event handling functions
With the change of fsnotify to use srcu walking the marks list instead of walking the global groups list we now know the mark in question. The code can send the mark to the group's handling functions and the groups won't have to find those marks themselves. Signed-off-by: Eric Paris <eparis@redhat.com>
1 parent 8778abb commit 3a9b16b

7 files changed

Lines changed: 37 additions & 25 deletions

File tree

‎fs/notify/dnotify/dnotify.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static void dnotify_recalc_inode_mask(struct fsnotify_mark *fsn_mark)
8383
* events.
8484
*/
8585
static int dnotify_handle_event(struct fsnotify_group *group,
86+
struct fsnotify_mark *mark,
8687
struct fsnotify_event *event)
8788
{
8889
struct fsnotify_mark *fsn_mark = NULL;
@@ -130,7 +131,8 @@ static int dnotify_handle_event(struct fsnotify_group *group,
130131
*/
131132
static bool dnotify_should_send_event(struct fsnotify_group *group,
132133
struct inode *inode, struct vfsmount *mnt,
133-
__u32 mask, void *data, int data_type)
134+
struct fsnotify_mark *mark, __u32 mask,
135+
void *data, int data_type)
134136
{
135137
struct fsnotify_mark *fsn_mark;
136138
bool send;

‎fs/notify/fanotify/fanotify.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ static int fanotify_get_response_from_access(struct fsnotify_group *group,
114114
}
115115
#endif
116116

117-
static int fanotify_handle_event(struct fsnotify_group *group, struct fsnotify_event *event)
117+
static int fanotify_handle_event(struct fsnotify_group *group,
118+
struct fsnotify_mark *mark,
119+
struct fsnotify_event *event)
118120
{
119121
int ret = 0;
120122
struct fsnotify_event *notify_event = NULL;
@@ -214,8 +216,8 @@ static bool should_send_inode_event(struct fsnotify_group *group, struct inode *
214216
}
215217

216218
static bool fanotify_should_send_event(struct fsnotify_group *group, struct inode *to_tell,
217-
struct vfsmount *mnt, __u32 mask, void *data,
218-
int data_type)
219+
struct vfsmount *mnt, struct fsnotify_mark *mark,
220+
__u32 mask, void *data, int data_type)
219221
{
220222
pr_debug("%s: group=%p to_tell=%p mnt=%p mask=%x data=%p data_type=%d\n",
221223
__func__, group, to_tell, mnt, mask, data, data_type);

‎fs/notify/fsnotify.c‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,16 @@ void __fsnotify_flush_ignored_mask(struct inode *inode, void *data, int data_is)
171171
}
172172

173173
static int send_to_group(struct fsnotify_group *group, struct inode *to_tell,
174-
struct vfsmount *mnt, __u32 mask, void *data,
175-
int data_is, u32 cookie, const unsigned char *file_name,
174+
struct vfsmount *mnt, struct fsnotify_mark *mark,
175+
__u32 mask, void *data, int data_is, u32 cookie,
176+
const unsigned char *file_name,
176177
struct fsnotify_event **event)
177178
{
178-
pr_debug("%s: group=%p to_tell=%p mnt=%p mask=%x data=%p data_is=%d"
179-
" cookie=%d event=%p\n", __func__, group, to_tell, mnt,
180-
mask, data, data_is, cookie, *event);
179+
pr_debug("%s: group=%p to_tell=%p mnt=%p mark=%p mask=%x data=%p"
180+
" data_is=%d cookie=%d event=%p\n", __func__, group, to_tell,
181+
mnt, mark, mask, data, data_is, cookie, *event);
181182

182-
if (!group->ops->should_send_event(group, to_tell, mnt, mask,
183+
if (!group->ops->should_send_event(group, to_tell, mnt, mark, mask,
183184
data, data_is))
184185
return 0;
185186
if (!*event) {
@@ -189,7 +190,7 @@ static int send_to_group(struct fsnotify_group *group, struct inode *to_tell,
189190
if (!*event)
190191
return -ENOMEM;
191192
}
192-
return group->ops->handle_event(group, *event);
193+
return group->ops->handle_event(group, mark, *event);
193194
}
194195

195196
static bool needed_by_vfsmount(__u32 test_mask, struct vfsmount *mnt)
@@ -252,7 +253,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
252253
group = mark->group;
253254
if (!group)
254255
continue;
255-
ret = send_to_group(group, to_tell, NULL, mask,
256+
ret = send_to_group(group, to_tell, NULL, mark, mask,
256257
data, data_is, cookie, file_name,
257258
&event);
258259
if (ret)
@@ -271,7 +272,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
271272
group = mark->group;
272273
if (!group)
273274
continue;
274-
ret = send_to_group(group, to_tell, mnt, mask,
275+
ret = send_to_group(group, to_tell, mnt, mark, mask,
275276
data, data_is, cookie, file_name,
276277
&event);
277278
if (ret)

‎fs/notify/inotify/inotify_fsnotify.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ static struct fsnotify_event *inotify_merge(struct list_head *list,
8989
return last_event;
9090
}
9191

92-
static int inotify_handle_event(struct fsnotify_group *group, struct fsnotify_event *event)
92+
static int inotify_handle_event(struct fsnotify_group *group,
93+
struct fsnotify_mark *mark,
94+
struct fsnotify_event *event)
9395
{
9496
struct fsnotify_mark *fsn_mark;
9597
struct inotify_inode_mark *i_mark;
@@ -148,8 +150,8 @@ static void inotify_freeing_mark(struct fsnotify_mark *fsn_mark, struct fsnotify
148150
}
149151

150152
static bool inotify_should_send_event(struct fsnotify_group *group, struct inode *inode,
151-
struct vfsmount *mnt, __u32 mask, void *data,
152-
int data_type)
153+
struct vfsmount *mnt, struct fsnotify_mark *mark,
154+
__u32 mask, void *data, int data_type)
153155
{
154156
struct fsnotify_mark *fsn_mark;
155157
bool send;

‎include/linux/fsnotify_backend.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ struct fsnotify_event_private_data;
9292
*/
9393
struct fsnotify_ops {
9494
bool (*should_send_event)(struct fsnotify_group *group, struct inode *inode,
95-
struct vfsmount *mnt, __u32 mask, void *data,
96-
int data_type);
97-
int (*handle_event)(struct fsnotify_group *group, struct fsnotify_event *event);
95+
struct vfsmount *mnt, struct fsnotify_mark *mark,
96+
__u32 mask, void *data, int data_type);
97+
int (*handle_event)(struct fsnotify_group *group, struct fsnotify_mark *mark,
98+
struct fsnotify_event *event);
9899
void (*free_group_priv)(struct fsnotify_group *group);
99100
void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group);
100101
void (*free_event_priv)(struct fsnotify_event_private_data *priv);

‎kernel/audit_tree.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,9 @@ static void evict_chunk(struct audit_chunk *chunk)
903903
mutex_unlock(&audit_filter_mutex);
904904
}
905905

906-
static int audit_tree_handle_event(struct fsnotify_group *group, struct fsnotify_event *event)
906+
static int audit_tree_handle_event(struct fsnotify_group *group,
907+
struct fsnotify_mark *mark,
908+
struct fsnotify_event *event)
907909
{
908910
BUG();
909911
return -EOPNOTSUPP;
@@ -918,8 +920,8 @@ static void audit_tree_freeing_mark(struct fsnotify_mark *entry, struct fsnotify
918920
}
919921

920922
static bool audit_tree_send_event(struct fsnotify_group *group, struct inode *inode,
921-
struct vfsmount *mnt, __u32 mask, void *data,
922-
int data_type)
923+
struct vfsmount *mnt, struct fsnotify_mark *mark,
924+
__u32 mask, void *data, int data_type)
923925
{
924926
return 0;
925927
}

‎kernel/audit_watch.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,8 @@ void audit_remove_watch_rule(struct audit_krule *krule)
511511
}
512512

513513
static bool audit_watch_should_send_event(struct fsnotify_group *group, struct inode *inode,
514-
struct vfsmount *mnt, __u32 mask, void *data,
515-
int data_type)
514+
struct vfsmount *mnt, struct fsnotify_mark *mark,
515+
__u32 mask, void *data, int data_type)
516516
{
517517
struct fsnotify_mark *entry;
518518
bool send;
@@ -531,7 +531,9 @@ static bool audit_watch_should_send_event(struct fsnotify_group *group, struct i
531531
}
532532

533533
/* Update watch data in audit rules based on fsnotify events. */
534-
static int audit_watch_handle_event(struct fsnotify_group *group, struct fsnotify_event *event)
534+
static int audit_watch_handle_event(struct fsnotify_group *group,
535+
struct fsnotify_mark *mark,
536+
struct fsnotify_event *event)
535537
{
536538
struct inode *inode;
537539
__u32 mask = event->mask;

0 commit comments

Comments
 (0)