···199199 if (dn_mark->dn == NULL)200200 fsnotify_destroy_mark(fsn_mark);201201202202- fsnotify_recalc_group_mask(dnotify_group);203203-204202 mutex_unlock(&dnotify_mark_mutex);205203206204 fsnotify_put_mark(fsn_mark);···382384383385 if (destroy)384386 fsnotify_destroy_mark(fsn_mark);385385-386386- fsnotify_recalc_group_mask(dnotify_group);387387388388 mutex_unlock(&dnotify_mark_mutex);389389 fsnotify_put_mark(fsn_mark);
+5-18
fs/notify/fanotify/fanotify_user.c
···496496497497 removed = fanotify_mark_remove_from_mask(fsn_mark, mask, flags);498498 fsnotify_put_mark(fsn_mark);499499- if (removed & group->mask)500500- fsnotify_recalc_group_mask(group);501499 if (removed & mnt->mnt_fsnotify_mask)502500 fsnotify_recalc_vfsmount_mask(mnt);503501···516518 removed = fanotify_mark_remove_from_mask(fsn_mark, mask, flags);517519 /* matches the fsnotify_find_inode_mark() */518520 fsnotify_put_mark(fsn_mark);519519-520520- if (removed & group->mask)521521- fsnotify_recalc_group_mask(group);522521 if (removed & inode->i_fsnotify_mask)523522 fsnotify_recalc_inode_mask(inode);524523···567572 }568573 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags);569574 fsnotify_put_mark(fsn_mark);570570- if (added) {571571- if (added & ~group->mask)572572- fsnotify_recalc_group_mask(group);573573- if (added & ~mnt->mnt_fsnotify_mask)574574- fsnotify_recalc_vfsmount_mask(mnt);575575- }575575+ if (added & ~mnt->mnt_fsnotify_mask)576576+ fsnotify_recalc_vfsmount_mask(mnt);577577+576578 return 0;577579}578580···599607 }600608 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags);601609 fsnotify_put_mark(fsn_mark);602602- if (added) {603603- if (added & ~group->mask)604604- fsnotify_recalc_group_mask(group);605605- if (added & ~inode->i_fsnotify_mask)606606- fsnotify_recalc_inode_mask(inode);607607- }610610+ if (added & ~inode->i_fsnotify_mask)611611+ fsnotify_recalc_inode_mask(inode);608612 return 0;609613}610614···722734 fsnotify_clear_vfsmount_marks_by_group(group);723735 else724736 fsnotify_clear_inode_marks_by_group(group);725725- fsnotify_recalc_group_mask(group);726737 break;727738 default:728739 ret = -EINVAL;
-16
fs/notify/group.c
···3535/* all groups registered to receive mount point filesystem notifications */3636LIST_HEAD(fsnotify_vfsmount_groups);37373838-/*3939- * Update the group->mask by running all of the marks associated with this4040- * group and finding the bitwise | of all of the mark->mask.4141- */4242-void fsnotify_recalc_group_mask(struct fsnotify_group *group)4343-{4444- __u32 mask = 0;4545- struct fsnotify_mark *mark;4646-4747- spin_lock(&group->mark_lock);4848- list_for_each_entry(mark, &group->marks_list, g_list)4949- mask |= mark->mask;5050- group->mask = mask;5151- spin_unlock(&group->mark_lock);5252-}5353-5438void fsnotify_add_vfsmount_group(struct fsnotify_group *group)5539{5640 struct fsnotify_group *group_iter;
-9
fs/notify/inotify/inotify_user.c
···606606 int dropped = (old_mask & ~new_mask);607607 /* more bits in this fsn_mark than the inode's mask? */608608 int do_inode = (new_mask & ~inode->i_fsnotify_mask);609609- /* more bits in this fsn_mark than the group? */610610- int do_group = (new_mask & ~group->mask);611609612610 /* update the inode with this new fsn_mark */613611 if (dropped || do_inode)614612 fsnotify_recalc_inode_mask(inode);615613616616- /* update the group mask with the new mask */617617- if (dropped || do_group)618618- fsnotify_recalc_group_mask(group);619614 }620615621616 /* return the wd */···667672668673 /* return the watch descriptor for this new mark */669674 ret = tmp_i_mark->wd;670670-671671- /* if this mark added a new event update the group mask */672672- if (mask & ~group->mask)673673- fsnotify_recalc_group_mask(group);674675675676out_err:676677 /* match the ref from fsnotify_init_mark() */
-11
include/linux/fsnotify_backend.h
···120120 struct list_head vfsmount_group_list;121121122122 /*123123- * Defines all of the event types in which this group is interested.124124- * This mask is a bitwise OR of the FS_* events from above. Each time125125- * this mask changes for a group (if it changes) the correct functions126126- * must be called to update the global structures which indicate global127127- * interest in event types.128128- */129129- __u32 mask;130130-131131- /*132123 * How the refcnt is used is up to each group. When the refcnt hits 0133124 * fsnotify will clean up all of the resources associated with this group.134125 * As an example, the dnotify group will always have a refcnt=1 and that···358367359368/* get a reference to an existing or create a new group */360369extern struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops);361361-/* run all marks associated with this group and update group->mask */362362-extern void fsnotify_recalc_group_mask(struct fsnotify_group *group);363370/* drop reference on a group from fsnotify_alloc_group */364371extern void fsnotify_put_group(struct fsnotify_group *group);365372
-8
kernel/audit_watch.c
···164164 return ERR_PTR(ret);165165 }166166167167- fsnotify_recalc_group_mask(audit_watch_group);168168-169167 return parent;170168}171169···350352 mutex_unlock(&audit_filter_mutex);351353352354 fsnotify_destroy_mark(&parent->mark);353353-354354- fsnotify_recalc_group_mask(audit_watch_group);355355-356355}357356358357/* Get path information necessary for adding watches. */···500505 audit_put_parent(parent);501506 }502507 }503503-504504- fsnotify_recalc_group_mask(audit_watch_group);505505-506508}507509508510static bool audit_watch_should_send_event(struct fsnotify_group *group, struct inode *inode,