|
@@ -77,15 +77,6 @@ void fsnotify_recalc_group_mask(struct fsnotify_group *group)
|
|
fsnotify_recalc_global_mask();
|
|
fsnotify_recalc_global_mask();
|
|
}
|
|
}
|
|
|
|
|
|
-/*
|
|
|
|
- * Take a reference to a group so things found under the fsnotify_grp_mutex
|
|
|
|
- * can't get freed under us
|
|
|
|
- */
|
|
|
|
-static void fsnotify_get_group(struct fsnotify_group *group)
|
|
|
|
-{
|
|
|
|
- atomic_inc(&group->refcnt);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* Final freeing of a group
|
|
* Final freeing of a group
|
|
*/
|
|
*/
|
|
@@ -170,41 +161,15 @@ void fsnotify_put_group(struct fsnotify_group *group)
|
|
fsnotify_destroy_group(group);
|
|
fsnotify_destroy_group(group);
|
|
}
|
|
}
|
|
|
|
|
|
-/*
|
|
|
|
- * Simply run the fsnotify_groups list and find a group which matches
|
|
|
|
- * the given parameters. If a group is found we take a reference to that
|
|
|
|
- * group.
|
|
|
|
- */
|
|
|
|
-static struct fsnotify_group *fsnotify_find_group(unsigned int group_num, __u32 mask,
|
|
|
|
- const struct fsnotify_ops *ops)
|
|
|
|
-{
|
|
|
|
- struct fsnotify_group *group_iter;
|
|
|
|
- struct fsnotify_group *group = NULL;
|
|
|
|
-
|
|
|
|
- BUG_ON(!mutex_is_locked(&fsnotify_grp_mutex));
|
|
|
|
-
|
|
|
|
- list_for_each_entry_rcu(group_iter, &fsnotify_groups, group_list) {
|
|
|
|
- if (group_iter->group_num == group_num) {
|
|
|
|
- if ((group_iter->mask == mask) &&
|
|
|
|
- (group_iter->ops == ops)) {
|
|
|
|
- fsnotify_get_group(group_iter);
|
|
|
|
- group = group_iter;
|
|
|
|
- } else
|
|
|
|
- group = ERR_PTR(-EEXIST);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return group;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* Either finds an existing group which matches the group_num, mask, and ops or
|
|
* Either finds an existing group which matches the group_num, mask, and ops or
|
|
* creates a new group and adds it to the global group list. In either case we
|
|
* creates a new group and adds it to the global group list. In either case we
|
|
* take a reference for the group returned.
|
|
* take a reference for the group returned.
|
|
*/
|
|
*/
|
|
-struct fsnotify_group *fsnotify_obtain_group(unsigned int group_num, __u32 mask,
|
|
|
|
|
|
+struct fsnotify_group *fsnotify_obtain_group(__u32 mask,
|
|
const struct fsnotify_ops *ops)
|
|
const struct fsnotify_ops *ops)
|
|
{
|
|
{
|
|
- struct fsnotify_group *group, *tgroup;
|
|
|
|
|
|
+ struct fsnotify_group *group;
|
|
|
|
|
|
/* very low use, simpler locking if we just always alloc */
|
|
/* very low use, simpler locking if we just always alloc */
|
|
group = kzalloc(sizeof(struct fsnotify_group), GFP_KERNEL);
|
|
group = kzalloc(sizeof(struct fsnotify_group), GFP_KERNEL);
|
|
@@ -214,7 +179,6 @@ struct fsnotify_group *fsnotify_obtain_group(unsigned int group_num, __u32 mask,
|
|
atomic_set(&group->refcnt, 1);
|
|
atomic_set(&group->refcnt, 1);
|
|
|
|
|
|
group->on_group_list = 0;
|
|
group->on_group_list = 0;
|
|
- group->group_num = group_num;
|
|
|
|
group->mask = mask;
|
|
group->mask = mask;
|
|
|
|
|
|
mutex_init(&group->notification_mutex);
|
|
mutex_init(&group->notification_mutex);
|
|
@@ -230,14 +194,6 @@ struct fsnotify_group *fsnotify_obtain_group(unsigned int group_num, __u32 mask,
|
|
group->ops = ops;
|
|
group->ops = ops;
|
|
|
|
|
|
mutex_lock(&fsnotify_grp_mutex);
|
|
mutex_lock(&fsnotify_grp_mutex);
|
|
- tgroup = fsnotify_find_group(group_num, mask, ops);
|
|
|
|
- if (tgroup) {
|
|
|
|
- /* group already exists */
|
|
|
|
- mutex_unlock(&fsnotify_grp_mutex);
|
|
|
|
- /* destroy the new one we made */
|
|
|
|
- fsnotify_put_group(group);
|
|
|
|
- return tgroup;
|
|
|
|
- }
|
|
|
|
|
|
|
|
/* group not found, add a new one */
|
|
/* group not found, add a new one */
|
|
list_add_rcu(&group->group_list, &fsnotify_groups);
|
|
list_add_rcu(&group->group_list, &fsnotify_groups);
|