Skip to content

Commit 0393097

Browse files
committed
fsnotify: remove the global masks
Because we walk the object->fsnotify_marks list instead of the global fsnotify groups list we don't need the fsnotify_inode_mask and fsnotify_vfsmount_mask as these were simply shortcuts in fsnotify() for performance. They are now extra checks, rip them out. Signed-off-by: Eric Paris <eparis@redhat.com>
1 parent 2612abb commit 0393097

4 files changed

Lines changed: 2 additions & 48 deletions

File tree

‎fs/notify/fsnotify.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,6 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
227227
if (mask & FS_MODIFY)
228228
__fsnotify_flush_ignored_mask(to_tell, data, data_is);
229229

230-
/* if none of the directed listeners or vfsmount listeners care */
231-
if (!(test_mask & fsnotify_inode_mask) &&
232-
!(test_mask & fsnotify_vfsmount_mask))
233-
return 0;
234-
235230
if (data_is == FSNOTIFY_EVENT_FILE)
236231
mnt = ((struct file *)data)->f_path.mnt;
237232

‎fs/notify/fsnotify.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
extern struct list_head fsnotify_inode_groups;
1111
/* all groups which receive vfsmount fsnotify events */
1212
extern struct list_head fsnotify_vfsmount_groups;
13-
/* all bitwise OR of all event types (FS_*) for all fsnotify_inode_groups */
14-
extern __u32 fsnotify_inode_mask;
15-
/* all bitwise OR of all event types (FS_*) for all fsnotify_vfsmount_groups */
16-
extern __u32 fsnotify_vfsmount_mask;
1713

1814
/* destroy all events sitting in this groups notification queue */
1915
extern void fsnotify_flush_notify(struct fsnotify_group *group);

‎fs/notify/group.c‎

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -34,54 +34,21 @@ static DEFINE_MUTEX(fsnotify_grp_mutex);
3434
LIST_HEAD(fsnotify_inode_groups);
3535
/* all groups registered to receive mount point filesystem notifications */
3636
LIST_HEAD(fsnotify_vfsmount_groups);
37-
/* bitwise OR of all events (FS_*) interesting to some group on this system */
38-
__u32 fsnotify_inode_mask;
39-
/* bitwise OR of all events (FS_*) interesting to some group on this system */
40-
__u32 fsnotify_vfsmount_mask;
41-
42-
/*
43-
* When a new group registers or changes it's set of interesting events
44-
* this function updates the fsnotify_mask to contain all interesting events
45-
*/
46-
void fsnotify_recalc_global_mask(void)
47-
{
48-
struct fsnotify_group *group;
49-
__u32 inode_mask = 0;
50-
__u32 vfsmount_mask = 0;
51-
52-
mutex_lock(&fsnotify_grp_mutex);
53-
list_for_each_entry_rcu(group, &fsnotify_inode_groups, inode_group_list)
54-
inode_mask |= group->mask;
55-
list_for_each_entry_rcu(group, &fsnotify_vfsmount_groups, vfsmount_group_list)
56-
vfsmount_mask |= group->mask;
57-
58-
fsnotify_inode_mask = inode_mask;
59-
fsnotify_vfsmount_mask = vfsmount_mask;
60-
61-
mutex_unlock(&fsnotify_grp_mutex);
62-
}
6337

6438
/*
6539
* Update the group->mask by running all of the marks associated with this
66-
* group and finding the bitwise | of all of the mark->mask. If we change
67-
* the group->mask we need to update the global mask of events interesting
68-
* to the system.
40+
* group and finding the bitwise | of all of the mark->mask.
6941
*/
7042
void fsnotify_recalc_group_mask(struct fsnotify_group *group)
7143
{
7244
__u32 mask = 0;
73-
__u32 old_mask = group->mask;
7445
struct fsnotify_mark *mark;
7546

7647
spin_lock(&group->mark_lock);
7748
list_for_each_entry(mark, &group->marks_list, g_list)
7849
mask |= mark->mask;
79-
spin_unlock(&group->mark_lock);
80-
8150
group->mask = mask;
82-
83-
if (old_mask != mask)
84-
fsnotify_recalc_global_mask();
51+
spin_unlock(&group->mark_lock);
8552
}
8653

8754
void fsnotify_add_vfsmount_group(struct fsnotify_group *group)
@@ -217,8 +184,6 @@ void fsnotify_put_group(struct fsnotify_group *group)
217184

218185
mutex_unlock(&fsnotify_grp_mutex);
219186

220-
/* and now it is really dead. _Nothing_ could be seeing it */
221-
fsnotify_recalc_global_mask();
222187
fsnotify_destroy_group(group);
223188
}
224189

‎include/linux/fsnotify_backend.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,6 @@ static inline void __fsnotify_d_instantiate(struct dentry *dentry, struct inode
365365

366366
/* called from fsnotify listeners, such as fanotify or dnotify */
367367

368-
/* must call when a group changes its ->mask */
369-
extern void fsnotify_recalc_global_mask(void);
370368
/* get a reference to an existing or create a new group */
371369
extern struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops);
372370
/* run all marks associated with this group and update group->mask */

0 commit comments

Comments
 (0)