Skip to content

Commit 36fddeb

Browse files
committed
fsnotify: initialize the group->num_marks in a better place
Currently the comments say that group->num_marks is held because the group is on the fsnotify_group list. This isn't strictly the case, we really just hold the num_marks for the life of the group (any time group->refcnt is != 0) This patch moves the initialization stuff and makes it clear when it is really being held. Signed-off-by: Eric Paris <eparis@redhat.com>
1 parent 19c2a0e commit 36fddeb

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎fs/notify/group.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ static void fsnotify_add_group(struct fsnotify_group *group)
8282
BUG_ON(!mutex_is_locked(&fsnotify_grp_mutex));
8383

8484
group->on_inode_group_list = 1;
85-
/* being on the fsnotify_groups list holds one num_marks */
86-
atomic_inc(&group->num_marks);
87-
8885
list_add_tail_rcu(&group->inode_group_list, &fsnotify_inode_groups);
8986
}
9087

@@ -183,7 +180,14 @@ struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops)
183180
if (!group)
184181
return ERR_PTR(-ENOMEM);
185182

183+
/* set to 0 when there a no external references to this group */
186184
atomic_set(&group->refcnt, 1);
185+
/*
186+
* hits 0 when there are no external references AND no marks for
187+
* this group
188+
*/
189+
atomic_set(&group->num_marks, 1);
190+
187191

188192
mutex_init(&group->notification_mutex);
189193
INIT_LIST_HEAD(&group->notification_list);

0 commit comments

Comments
 (0)