Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+2 -48
-5
fs/notify/fsnotify.c
··· 227 227 if (mask & FS_MODIFY) 228 228 __fsnotify_flush_ignored_mask(to_tell, data, data_is); 229 229 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 - 235 230 if (data_is == FSNOTIFY_EVENT_FILE) 236 231 mnt = ((struct file *)data)->f_path.mnt; 237 232
-4
fs/notify/fsnotify.h
··· 10 10 extern struct list_head fsnotify_inode_groups; 11 11 /* all groups which receive vfsmount fsnotify events */ 12 12 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; 17 13 18 14 /* destroy all events sitting in this groups notification queue */ 19 15 extern void fsnotify_flush_notify(struct fsnotify_group *group);
+2 -37
fs/notify/group.c
··· 34 34 LIST_HEAD(fsnotify_inode_groups); 35 35 /* all groups registered to receive mount point filesystem notifications */ 36 36 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 - } 63 37 64 38 /* 65 39 * 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. 69 41 */ 70 42 void fsnotify_recalc_group_mask(struct fsnotify_group *group) 71 43 { 72 44 __u32 mask = 0; 73 - __u32 old_mask = group->mask; 74 45 struct fsnotify_mark *mark; 75 46 76 47 spin_lock(&group->mark_lock); 77 48 list_for_each_entry(mark, &group->marks_list, g_list) 78 49 mask |= mark->mask; 79 - spin_unlock(&group->mark_lock); 80 - 81 50 group->mask = mask; 82 - 83 - if (old_mask != mask) 84 - fsnotify_recalc_global_mask(); 51 + spin_unlock(&group->mark_lock); 85 52 } 86 53 87 54 void fsnotify_add_vfsmount_group(struct fsnotify_group *group) ··· 184 217 185 218 mutex_unlock(&fsnotify_grp_mutex); 186 219 187 - /* and now it is really dead. _Nothing_ could be seeing it */ 188 - fsnotify_recalc_global_mask(); 189 220 fsnotify_destroy_group(group); 190 221 } 191 222
-2
include/linux/fsnotify_backend.h
··· 365 365 366 366 /* called from fsnotify listeners, such as fanotify or dnotify */ 367 367 368 - /* must call when a group changes its ->mask */ 369 - extern void fsnotify_recalc_global_mask(void); 370 368 /* get a reference to an existing or create a new group */ 371 369 extern struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops); 372 370 /* run all marks associated with this group and update group->mask */