Skip to content

Commit e42e277

Browse files
committed
inotify/dnotify: should_send_event shouldn't match on FS_EVENT_ON_CHILD
inotify and dnotify will both indicate that they want any event which came from a child inode. The fix is to mask off FS_EVENT_ON_CHILD when deciding if inotify or dnotify is interested in a given event. Signed-off-by: Eric Paris <eparis@redhat.com>
1 parent ce61856 commit e42e277

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

fs/notify/dnotify/dnotify.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ static bool dnotify_should_send_event(struct fsnotify_group *group,
153153
if (!entry)
154154
return false;
155155

156+
mask = (mask & ~FS_EVENT_ON_CHILD);
156157
send = (mask & entry->mask);
157158

158159
fsnotify_put_mark(entry); /* matches fsnotify_find_mark_entry */

fs/notify/fsnotify.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,16 @@ void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const
137137
struct fsnotify_group *group;
138138
struct fsnotify_event *event = NULL;
139139
int idx;
140+
/* global tests shouldn't care about events on child only the specific event */
141+
__u32 test_mask = (mask & ~FS_EVENT_ON_CHILD);
140142

141143
if (list_empty(&fsnotify_groups))
142144
return;
143145

144-
if (!(mask & fsnotify_mask))
146+
if (!(test_mask & fsnotify_mask))
145147
return;
146148

147-
if (!(mask & to_tell->i_fsnotify_mask))
149+
if (!(test_mask & to_tell->i_fsnotify_mask))
148150
return;
149151
/*
150152
* SRCU!! the groups list is very very much read only and the path is
@@ -153,7 +155,7 @@ void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const
153155
*/
154156
idx = srcu_read_lock(&fsnotify_grp_srcu);
155157
list_for_each_entry_rcu(group, &fsnotify_groups, group_list) {
156-
if (mask & group->mask) {
158+
if (test_mask & group->mask) {
157159
if (!group->ops->should_send_event(group, to_tell, mask))
158160
continue;
159161
if (!event) {

fs/notify/inotify/inotify_fsnotify.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ static bool inotify_should_send_event(struct fsnotify_group *group, struct inode
9595
if (!entry)
9696
return false;
9797

98+
mask = (mask & ~FS_EVENT_ON_CHILD);
9899
send = (entry->mask & mask);
99100

100101
/* find took a reference */

0 commit comments

Comments
 (0)