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

fsnotify: remove group->mask

group->mask is now useless. It was originally a shortcut for fsnotify to
save on performance. These checks are now redundant, so we remove them.

Signed-off-by: Eric Paris <eparis@redhat.com>

+5 -66
-4
fs/notify/dnotify/dnotify.c
··· 199 199 if (dn_mark->dn == NULL) 200 200 fsnotify_destroy_mark(fsn_mark); 201 201 202 - fsnotify_recalc_group_mask(dnotify_group); 203 - 204 202 mutex_unlock(&dnotify_mark_mutex); 205 203 206 204 fsnotify_put_mark(fsn_mark); ··· 382 384 383 385 if (destroy) 384 386 fsnotify_destroy_mark(fsn_mark); 385 - 386 - fsnotify_recalc_group_mask(dnotify_group); 387 387 388 388 mutex_unlock(&dnotify_mark_mutex); 389 389 fsnotify_put_mark(fsn_mark);
+5 -18
fs/notify/fanotify/fanotify_user.c
··· 496 496 497 497 removed = fanotify_mark_remove_from_mask(fsn_mark, mask, flags); 498 498 fsnotify_put_mark(fsn_mark); 499 - if (removed & group->mask) 500 - fsnotify_recalc_group_mask(group); 501 499 if (removed & mnt->mnt_fsnotify_mask) 502 500 fsnotify_recalc_vfsmount_mask(mnt); 503 501 ··· 516 518 removed = fanotify_mark_remove_from_mask(fsn_mark, mask, flags); 517 519 /* matches the fsnotify_find_inode_mark() */ 518 520 fsnotify_put_mark(fsn_mark); 519 - 520 - if (removed & group->mask) 521 - fsnotify_recalc_group_mask(group); 522 521 if (removed & inode->i_fsnotify_mask) 523 522 fsnotify_recalc_inode_mask(inode); 524 523 ··· 567 572 } 568 573 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags); 569 574 fsnotify_put_mark(fsn_mark); 570 - if (added) { 571 - if (added & ~group->mask) 572 - fsnotify_recalc_group_mask(group); 573 - if (added & ~mnt->mnt_fsnotify_mask) 574 - fsnotify_recalc_vfsmount_mask(mnt); 575 - } 575 + if (added & ~mnt->mnt_fsnotify_mask) 576 + fsnotify_recalc_vfsmount_mask(mnt); 577 + 576 578 return 0; 577 579 } 578 580 ··· 599 607 } 600 608 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags); 601 609 fsnotify_put_mark(fsn_mark); 602 - if (added) { 603 - if (added & ~group->mask) 604 - fsnotify_recalc_group_mask(group); 605 - if (added & ~inode->i_fsnotify_mask) 606 - fsnotify_recalc_inode_mask(inode); 607 - } 610 + if (added & ~inode->i_fsnotify_mask) 611 + fsnotify_recalc_inode_mask(inode); 608 612 return 0; 609 613 } 610 614 ··· 722 734 fsnotify_clear_vfsmount_marks_by_group(group); 723 735 else 724 736 fsnotify_clear_inode_marks_by_group(group); 725 - fsnotify_recalc_group_mask(group); 726 737 break; 727 738 default: 728 739 ret = -EINVAL;
-16
fs/notify/group.c
··· 35 35 /* all groups registered to receive mount point filesystem notifications */ 36 36 LIST_HEAD(fsnotify_vfsmount_groups); 37 37 38 - /* 39 - * Update the group->mask by running all of the marks associated with this 40 - * group and finding the bitwise | of all of the mark->mask. 41 - */ 42 - void fsnotify_recalc_group_mask(struct fsnotify_group *group) 43 - { 44 - __u32 mask = 0; 45 - struct fsnotify_mark *mark; 46 - 47 - spin_lock(&group->mark_lock); 48 - list_for_each_entry(mark, &group->marks_list, g_list) 49 - mask |= mark->mask; 50 - group->mask = mask; 51 - spin_unlock(&group->mark_lock); 52 - } 53 - 54 38 void fsnotify_add_vfsmount_group(struct fsnotify_group *group) 55 39 { 56 40 struct fsnotify_group *group_iter;
-9
fs/notify/inotify/inotify_user.c
··· 606 606 int dropped = (old_mask & ~new_mask); 607 607 /* more bits in this fsn_mark than the inode's mask? */ 608 608 int do_inode = (new_mask & ~inode->i_fsnotify_mask); 609 - /* more bits in this fsn_mark than the group? */ 610 - int do_group = (new_mask & ~group->mask); 611 609 612 610 /* update the inode with this new fsn_mark */ 613 611 if (dropped || do_inode) 614 612 fsnotify_recalc_inode_mask(inode); 615 613 616 - /* update the group mask with the new mask */ 617 - if (dropped || do_group) 618 - fsnotify_recalc_group_mask(group); 619 614 } 620 615 621 616 /* return the wd */ ··· 667 672 668 673 /* return the watch descriptor for this new mark */ 669 674 ret = tmp_i_mark->wd; 670 - 671 - /* if this mark added a new event update the group mask */ 672 - if (mask & ~group->mask) 673 - fsnotify_recalc_group_mask(group); 674 675 675 676 out_err: 676 677 /* match the ref from fsnotify_init_mark() */
-11
include/linux/fsnotify_backend.h
··· 120 120 struct list_head vfsmount_group_list; 121 121 122 122 /* 123 - * Defines all of the event types in which this group is interested. 124 - * This mask is a bitwise OR of the FS_* events from above. Each time 125 - * this mask changes for a group (if it changes) the correct functions 126 - * must be called to update the global structures which indicate global 127 - * interest in event types. 128 - */ 129 - __u32 mask; 130 - 131 - /* 132 123 * How the refcnt is used is up to each group. When the refcnt hits 0 133 124 * fsnotify will clean up all of the resources associated with this group. 134 125 * As an example, the dnotify group will always have a refcnt=1 and that ··· 358 367 359 368 /* get a reference to an existing or create a new group */ 360 369 extern struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops); 361 - /* run all marks associated with this group and update group->mask */ 362 - extern void fsnotify_recalc_group_mask(struct fsnotify_group *group); 363 370 /* drop reference on a group from fsnotify_alloc_group */ 364 371 extern void fsnotify_put_group(struct fsnotify_group *group); 365 372
-8
kernel/audit_watch.c
··· 164 164 return ERR_PTR(ret); 165 165 } 166 166 167 - fsnotify_recalc_group_mask(audit_watch_group); 168 - 169 167 return parent; 170 168 } 171 169 ··· 350 352 mutex_unlock(&audit_filter_mutex); 351 353 352 354 fsnotify_destroy_mark(&parent->mark); 353 - 354 - fsnotify_recalc_group_mask(audit_watch_group); 355 - 356 355 } 357 356 358 357 /* Get path information necessary for adding watches. */ ··· 500 505 audit_put_parent(parent); 501 506 } 502 507 } 503 - 504 - fsnotify_recalc_group_mask(audit_watch_group); 505 - 506 508 } 507 509 508 510 static bool audit_watch_should_send_event(struct fsnotify_group *group, struct inode *inode,