fsnotify: Provide framework for dropping SRCU lock in ->handle_event
[sfrench/cifs-2.6.git] / fs / notify / group.c
index fbe3cbebec1671247231ba80b79694ef5b03157e..79439cdf16e076adb1c42c2221e5c62bfa203729 100644 (file)
@@ -66,14 +66,16 @@ void fsnotify_destroy_group(struct fsnotify_group *group)
         */
        fsnotify_group_stop_queueing(group);
 
-       /* clear all inode marks for this group, attach them to destroy_list */
+       /* Clear all marks for this group and queue them for destruction */
        fsnotify_detach_group_marks(group);
 
        /*
-        * Wait for fsnotify_mark_srcu period to end and free all marks in
-        * destroy_list
+        * Wait until all marks get really destroyed. We could actually destroy
+        * them ourselves instead of waiting for worker to do it, however that
+        * would be racy as worker can already be processing some marks before
+        * we even entered fsnotify_destroy_group().
         */
-       fsnotify_mark_destroy_list();
+       fsnotify_wait_marks_destroyed();
 
        /*
         * Since we have waited for fsnotify_mark_srcu in
@@ -124,6 +126,7 @@ struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops)
        /* set to 0 when there a no external references to this group */
        atomic_set(&group->refcnt, 1);
        atomic_set(&group->num_marks, 0);
+       atomic_set(&group->user_waits, 0);
 
        spin_lock_init(&group->notification_lock);
        INIT_LIST_HEAD(&group->notification_list);