2 * Copyright (C) 2008 Red Hat, Inc., Eric Paris <eparis@redhat.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; see the file COPYING. If not, write to
16 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 * fsnotify inode mark locking/lifetime/and refcnting
23 * The group->recnt and mark->refcnt tell how many "things" in the kernel
24 * currently are referencing the objects. Both kind of objects typically will
25 * live inside the kernel with a refcnt of 2, one for its creation and one for
26 * the reference a group and a mark hold to each other.
27 * If you are holding the appropriate locks, you can take a reference and the
28 * object itself is guaranteed to survive until the reference is dropped.
31 * There are 3 locks involved with fsnotify inode marks and they MUST be taken
32 * in order as follows:
36 * mark->connector->lock
38 * group->mark_mutex protects the marks_list anchored inside a given group and
39 * each mark is hooked via the g_list. It also protects the groups private
40 * data (i.e group limits).
42 * mark->lock protects the marks attributes like its masks and flags.
43 * Furthermore it protects the access to a reference of the group that the mark
44 * is assigned to as well as the access to a reference of the inode/vfsmount
45 * that is being watched by the mark.
47 * mark->connector->lock protects the list of marks anchored inside an
48 * inode / vfsmount and each mark is hooked via the i_list.
50 * A list of notification marks relating to inode / mnt is contained in
51 * fsnotify_mark_connector. That structure is alive as long as there are any
52 * marks in the list and is also protected by fsnotify_mark_srcu. A mark gets
53 * detached from fsnotify_mark_connector when last reference to the mark is
54 * dropped. Thus having mark reference is enough to protect mark->connector
55 * pointer and to make sure fsnotify_mark_connector cannot disappear. Also
56 * because we remove mark from g_list before dropping mark reference associated
57 * with that, any mark found through g_list is guaranteed to have
58 * mark->connector set until we drop group->mark_mutex.
61 * Inode marks survive between when they are added to an inode and when their
62 * refcnt==0. Marks are also protected by fsnotify_mark_srcu.
64 * The inode mark can be cleared for a number of different reasons including:
65 * - The inode is unlinked for the last time. (fsnotify_inode_remove)
66 * - The inode is being evicted from cache. (fsnotify_inode_delete)
67 * - The fs the inode is on is unmounted. (fsnotify_inode_delete/fsnotify_unmount_inodes)
68 * - Something explicitly requests that it be removed. (fsnotify_destroy_mark)
69 * - The fsnotify_group associated with the mark is going away and all such marks
70 * need to be cleaned up. (fsnotify_detach_group_marks)
72 * This has the very interesting property of being able to run concurrently with
73 * any (or all) other directions.
77 #include <linux/init.h>
78 #include <linux/kernel.h>
79 #include <linux/kthread.h>
80 #include <linux/module.h>
81 #include <linux/mutex.h>
82 #include <linux/slab.h>
83 #include <linux/spinlock.h>
84 #include <linux/srcu.h>
86 #include <linux/atomic.h>
88 #include <linux/fsnotify_backend.h>
91 #define FSNOTIFY_REAPER_DELAY (1) /* 1 jiffy */
93 struct srcu_struct fsnotify_mark_srcu;
94 struct kmem_cache *fsnotify_mark_connector_cachep;
96 static DEFINE_SPINLOCK(destroy_lock);
97 static LIST_HEAD(destroy_list);
98 static struct fsnotify_mark_connector *connector_destroy_list;
100 static void fsnotify_mark_destroy_workfn(struct work_struct *work);
101 static DECLARE_DELAYED_WORK(reaper_work, fsnotify_mark_destroy_workfn);
103 static void fsnotify_connector_destroy_workfn(struct work_struct *work);
104 static DECLARE_WORK(connector_reaper_work, fsnotify_connector_destroy_workfn);
106 void fsnotify_get_mark(struct fsnotify_mark *mark)
108 WARN_ON_ONCE(!atomic_read(&mark->refcnt));
109 atomic_inc(&mark->refcnt);
113 * Get mark reference when we found the mark via lockless traversal of object
114 * list. Mark can be already removed from the list by now and on its way to be
115 * destroyed once SRCU period ends.
117 static bool fsnotify_get_mark_safe(struct fsnotify_mark *mark)
119 return atomic_inc_not_zero(&mark->refcnt);
122 static void __fsnotify_recalc_mask(struct fsnotify_mark_connector *conn)
125 struct fsnotify_mark *mark;
127 assert_spin_locked(&conn->lock);
128 hlist_for_each_entry(mark, &conn->list, obj_list) {
129 if (mark->flags & FSNOTIFY_MARK_FLAG_ATTACHED)
130 new_mask |= mark->mask;
132 if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE)
133 conn->inode->i_fsnotify_mask = new_mask;
134 else if (conn->flags & FSNOTIFY_OBJ_TYPE_VFSMOUNT)
135 real_mount(conn->mnt)->mnt_fsnotify_mask = new_mask;
139 * Calculate mask of events for a list of marks. The caller must make sure
140 * connector and connector->inode cannot disappear under us. Callers achieve
141 * this by holding a mark->lock or mark->group->mark_mutex for a mark on this
144 void fsnotify_recalc_mask(struct fsnotify_mark_connector *conn)
149 spin_lock(&conn->lock);
150 __fsnotify_recalc_mask(conn);
151 spin_unlock(&conn->lock);
152 if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE)
153 __fsnotify_update_child_dentry_flags(conn->inode);
156 /* Free all connectors queued for freeing once SRCU period ends */
157 static void fsnotify_connector_destroy_workfn(struct work_struct *work)
159 struct fsnotify_mark_connector *conn, *free;
161 spin_lock(&destroy_lock);
162 conn = connector_destroy_list;
163 connector_destroy_list = NULL;
164 spin_unlock(&destroy_lock);
166 synchronize_srcu(&fsnotify_mark_srcu);
169 conn = conn->destroy_next;
170 kmem_cache_free(fsnotify_mark_connector_cachep, free);
174 static struct inode *fsnotify_detach_connector_from_object(
175 struct fsnotify_mark_connector *conn)
177 struct inode *inode = NULL;
179 if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE) {
181 rcu_assign_pointer(inode->i_fsnotify_marks, NULL);
182 inode->i_fsnotify_mask = 0;
184 conn->flags &= ~FSNOTIFY_OBJ_TYPE_INODE;
185 } else if (conn->flags & FSNOTIFY_OBJ_TYPE_VFSMOUNT) {
186 rcu_assign_pointer(real_mount(conn->mnt)->mnt_fsnotify_marks,
188 real_mount(conn->mnt)->mnt_fsnotify_mask = 0;
190 conn->flags &= ~FSNOTIFY_OBJ_TYPE_VFSMOUNT;
196 static void fsnotify_final_mark_destroy(struct fsnotify_mark *mark)
199 fsnotify_put_group(mark->group);
200 mark->free_mark(mark);
203 void fsnotify_put_mark(struct fsnotify_mark *mark)
205 struct fsnotify_mark_connector *conn;
206 struct inode *inode = NULL;
207 bool free_conn = false;
209 /* Catch marks that were actually never attached to object */
210 if (!mark->connector) {
211 if (atomic_dec_and_test(&mark->refcnt))
212 fsnotify_final_mark_destroy(mark);
217 * We have to be careful so that traversals of obj_list under lock can
218 * safely grab mark reference.
220 if (!atomic_dec_and_lock(&mark->refcnt, &mark->connector->lock))
223 conn = mark->connector;
224 hlist_del_init_rcu(&mark->obj_list);
225 if (hlist_empty(&conn->list)) {
226 inode = fsnotify_detach_connector_from_object(conn);
229 __fsnotify_recalc_mask(conn);
231 mark->connector = NULL;
232 spin_unlock(&conn->lock);
237 spin_lock(&destroy_lock);
238 conn->destroy_next = connector_destroy_list;
239 connector_destroy_list = conn;
240 spin_unlock(&destroy_lock);
241 queue_work(system_unbound_wq, &connector_reaper_work);
244 * Note that we didn't update flags telling whether inode cares about
245 * what's happening with children. We update these flags from
246 * __fsnotify_parent() lazily when next event happens on one of our
249 spin_lock(&destroy_lock);
250 list_add(&mark->g_list, &destroy_list);
251 spin_unlock(&destroy_lock);
252 queue_delayed_work(system_unbound_wq, &reaper_work,
253 FSNOTIFY_REAPER_DELAY);
256 bool fsnotify_prepare_user_wait(struct fsnotify_iter_info *iter_info)
258 struct fsnotify_group *group;
260 if (WARN_ON_ONCE(!iter_info->inode_mark && !iter_info->vfsmount_mark))
263 if (iter_info->inode_mark)
264 group = iter_info->inode_mark->group;
266 group = iter_info->vfsmount_mark->group;
269 * Since acquisition of mark reference is an atomic op as well, we can
270 * be sure this inc is seen before any effect of refcount increment.
272 atomic_inc(&group->user_waits);
274 if (iter_info->inode_mark) {
275 /* This can fail if mark is being removed */
276 if (!fsnotify_get_mark_safe(iter_info->inode_mark))
279 if (iter_info->vfsmount_mark) {
280 if (!fsnotify_get_mark_safe(iter_info->vfsmount_mark))
285 * Now that both marks are pinned by refcount in the inode / vfsmount
286 * lists, we can drop SRCU lock, and safely resume the list iteration
287 * once userspace returns.
289 srcu_read_unlock(&fsnotify_mark_srcu, iter_info->srcu_idx);
293 if (iter_info->inode_mark)
294 fsnotify_put_mark(iter_info->inode_mark);
296 if (atomic_dec_and_test(&group->user_waits) && group->shutdown)
297 wake_up(&group->notification_waitq);
301 void fsnotify_finish_user_wait(struct fsnotify_iter_info *iter_info)
303 struct fsnotify_group *group = NULL;
305 iter_info->srcu_idx = srcu_read_lock(&fsnotify_mark_srcu);
306 if (iter_info->inode_mark) {
307 group = iter_info->inode_mark->group;
308 fsnotify_put_mark(iter_info->inode_mark);
310 if (iter_info->vfsmount_mark) {
311 group = iter_info->vfsmount_mark->group;
312 fsnotify_put_mark(iter_info->vfsmount_mark);
315 * We abuse notification_waitq on group shutdown for waiting for all
316 * marks pinned when waiting for userspace.
318 if (atomic_dec_and_test(&group->user_waits) && group->shutdown)
319 wake_up(&group->notification_waitq);
323 * Mark mark as detached, remove it from group list. Mark still stays in object
324 * list until its last reference is dropped. Note that we rely on mark being
325 * removed from group list before corresponding reference to it is dropped. In
326 * particular we rely on mark->connector being valid while we hold
327 * group->mark_mutex if we found the mark through g_list.
329 * Must be called with group->mark_mutex held. The caller must either hold
330 * reference to the mark or be protected by fsnotify_mark_srcu.
332 void fsnotify_detach_mark(struct fsnotify_mark *mark)
334 struct fsnotify_group *group = mark->group;
336 WARN_ON_ONCE(!mutex_is_locked(&group->mark_mutex));
337 WARN_ON_ONCE(!srcu_read_lock_held(&fsnotify_mark_srcu) &&
338 atomic_read(&mark->refcnt) < 1 +
339 !!(mark->flags & FSNOTIFY_MARK_FLAG_ATTACHED));
341 spin_lock(&mark->lock);
342 /* something else already called this function on this mark */
343 if (!(mark->flags & FSNOTIFY_MARK_FLAG_ATTACHED)) {
344 spin_unlock(&mark->lock);
347 mark->flags &= ~FSNOTIFY_MARK_FLAG_ATTACHED;
348 list_del_init(&mark->g_list);
349 spin_unlock(&mark->lock);
351 atomic_dec(&group->num_marks);
353 /* Drop mark reference acquired in fsnotify_add_mark_locked() */
354 fsnotify_put_mark(mark);
358 * Free fsnotify mark. The mark is actually only marked as being freed. The
359 * freeing is actually happening only once last reference to the mark is
360 * dropped from a workqueue which first waits for srcu period end.
362 * Caller must have a reference to the mark or be protected by
363 * fsnotify_mark_srcu.
365 void fsnotify_free_mark(struct fsnotify_mark *mark)
367 struct fsnotify_group *group = mark->group;
369 spin_lock(&mark->lock);
370 /* something else already called this function on this mark */
371 if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE)) {
372 spin_unlock(&mark->lock);
375 mark->flags &= ~FSNOTIFY_MARK_FLAG_ALIVE;
376 spin_unlock(&mark->lock);
379 * Some groups like to know that marks are being freed. This is a
380 * callback to the group function to let it know that this mark
383 if (group->ops->freeing_mark)
384 group->ops->freeing_mark(mark, group);
387 void fsnotify_destroy_mark(struct fsnotify_mark *mark,
388 struct fsnotify_group *group)
390 mutex_lock_nested(&group->mark_mutex, SINGLE_DEPTH_NESTING);
391 fsnotify_detach_mark(mark);
392 mutex_unlock(&group->mark_mutex);
393 fsnotify_free_mark(mark);
397 * Sorting function for lists of fsnotify marks.
399 * Fanotify supports different notification classes (reflected as priority of
400 * notification group). Events shall be passed to notification groups in
401 * decreasing priority order. To achieve this marks in notification lists for
402 * inodes and vfsmounts are sorted so that priorities of corresponding groups
405 * Furthermore correct handling of the ignore mask requires processing inode
406 * and vfsmount marks of each group together. Using the group address as
407 * further sort criterion provides a unique sorting order and thus we can
408 * merge inode and vfsmount lists of marks in linear time and find groups
409 * present in both lists.
411 * A return value of 1 signifies that b has priority over a.
412 * A return value of 0 signifies that the two marks have to be handled together.
413 * A return value of -1 signifies that a has priority over b.
415 int fsnotify_compare_groups(struct fsnotify_group *a, struct fsnotify_group *b)
423 if (a->priority < b->priority)
425 if (a->priority > b->priority)
432 static int fsnotify_attach_connector_to_object(
433 struct fsnotify_mark_connector __rcu **connp,
435 struct vfsmount *mnt)
437 struct fsnotify_mark_connector *conn;
439 conn = kmem_cache_alloc(fsnotify_mark_connector_cachep, GFP_KERNEL);
442 spin_lock_init(&conn->lock);
443 INIT_HLIST_HEAD(&conn->list);
445 conn->flags = FSNOTIFY_OBJ_TYPE_INODE;
446 conn->inode = igrab(inode);
448 conn->flags = FSNOTIFY_OBJ_TYPE_VFSMOUNT;
452 * cmpxchg() provides the barrier so that readers of *connp can see
453 * only initialized structure
455 if (cmpxchg(connp, NULL, conn)) {
456 /* Someone else created list structure for us */
459 kmem_cache_free(fsnotify_mark_connector_cachep, conn);
466 * Get mark connector, make sure it is alive and return with its lock held.
467 * This is for users that get connector pointer from inode or mount. Users that
468 * hold reference to a mark on the list may directly lock connector->lock as
469 * they are sure list cannot go away under them.
471 static struct fsnotify_mark_connector *fsnotify_grab_connector(
472 struct fsnotify_mark_connector __rcu **connp)
474 struct fsnotify_mark_connector *conn;
477 idx = srcu_read_lock(&fsnotify_mark_srcu);
478 conn = srcu_dereference(*connp, &fsnotify_mark_srcu);
481 spin_lock(&conn->lock);
482 if (!(conn->flags & (FSNOTIFY_OBJ_TYPE_INODE |
483 FSNOTIFY_OBJ_TYPE_VFSMOUNT))) {
484 spin_unlock(&conn->lock);
485 srcu_read_unlock(&fsnotify_mark_srcu, idx);
489 srcu_read_unlock(&fsnotify_mark_srcu, idx);
494 * Add mark into proper place in given list of marks. These marks may be used
495 * for the fsnotify backend to determine which event types should be delivered
496 * to which group and for which inodes. These marks are ordered according to
497 * priority, highest number first, and then by the group's location in memory.
499 static int fsnotify_add_mark_list(struct fsnotify_mark *mark,
500 struct inode *inode, struct vfsmount *mnt,
503 struct fsnotify_mark *lmark, *last = NULL;
504 struct fsnotify_mark_connector *conn;
505 struct fsnotify_mark_connector __rcu **connp;
509 if (WARN_ON(!inode && !mnt))
512 connp = &inode->i_fsnotify_marks;
514 connp = &real_mount(mnt)->mnt_fsnotify_marks;
516 spin_lock(&mark->lock);
517 conn = fsnotify_grab_connector(connp);
519 spin_unlock(&mark->lock);
520 err = fsnotify_attach_connector_to_object(connp, inode, mnt);
526 /* is mark the first mark? */
527 if (hlist_empty(&conn->list)) {
528 hlist_add_head_rcu(&mark->obj_list, &conn->list);
532 /* should mark be in the middle of the current list? */
533 hlist_for_each_entry(lmark, &conn->list, obj_list) {
536 if ((lmark->group == mark->group) &&
537 (lmark->flags & FSNOTIFY_MARK_FLAG_ATTACHED) &&
543 cmp = fsnotify_compare_groups(lmark->group, mark->group);
545 hlist_add_before_rcu(&mark->obj_list, &lmark->obj_list);
550 BUG_ON(last == NULL);
551 /* mark should be the last entry. last is the current last entry */
552 hlist_add_behind_rcu(&mark->obj_list, &last->obj_list);
554 mark->connector = conn;
556 spin_unlock(&conn->lock);
557 spin_unlock(&mark->lock);
562 * Attach an initialized mark to a given group and fs object.
563 * These marks may be used for the fsnotify backend to determine which
564 * event types should be delivered to which group.
566 int fsnotify_add_mark_locked(struct fsnotify_mark *mark,
567 struct fsnotify_group *group, struct inode *inode,
568 struct vfsmount *mnt, int allow_dups)
572 BUG_ON(inode && mnt);
573 BUG_ON(!inode && !mnt);
574 BUG_ON(!mutex_is_locked(&group->mark_mutex));
580 * mark->connector->lock
582 spin_lock(&mark->lock);
583 mark->flags |= FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_ATTACHED;
585 fsnotify_get_group(group);
587 list_add(&mark->g_list, &group->marks_list);
588 atomic_inc(&group->num_marks);
589 fsnotify_get_mark(mark); /* for g_list */
590 spin_unlock(&mark->lock);
592 ret = fsnotify_add_mark_list(mark, inode, mnt, allow_dups);
597 fsnotify_recalc_mask(mark->connector);
601 mark->flags &= ~(FSNOTIFY_MARK_FLAG_ALIVE |
602 FSNOTIFY_MARK_FLAG_ATTACHED);
603 list_del_init(&mark->g_list);
604 atomic_dec(&group->num_marks);
605 spin_unlock(&mark->lock);
607 fsnotify_put_mark(mark);
611 int fsnotify_add_mark(struct fsnotify_mark *mark, struct fsnotify_group *group,
612 struct inode *inode, struct vfsmount *mnt, int allow_dups)
615 mutex_lock(&group->mark_mutex);
616 ret = fsnotify_add_mark_locked(mark, group, inode, mnt, allow_dups);
617 mutex_unlock(&group->mark_mutex);
622 * Given a list of marks, find the mark associated with given group. If found
623 * take a reference to that mark and return it, else return NULL.
625 struct fsnotify_mark *fsnotify_find_mark(
626 struct fsnotify_mark_connector __rcu **connp,
627 struct fsnotify_group *group)
629 struct fsnotify_mark_connector *conn;
630 struct fsnotify_mark *mark;
632 conn = fsnotify_grab_connector(connp);
636 hlist_for_each_entry(mark, &conn->list, obj_list) {
637 if (mark->group == group &&
638 (mark->flags & FSNOTIFY_MARK_FLAG_ATTACHED)) {
639 fsnotify_get_mark(mark);
640 spin_unlock(&conn->lock);
644 spin_unlock(&conn->lock);
648 /* Clear any marks in a group with given type */
649 void fsnotify_clear_marks_by_group(struct fsnotify_group *group,
652 struct fsnotify_mark *lmark, *mark;
656 * We have to be really careful here. Anytime we drop mark_mutex, e.g.
657 * fsnotify_clear_marks_by_inode() can come and free marks. Even in our
658 * to_free list so we have to use mark_mutex even when accessing that
659 * list. And freeing mark requires us to drop mark_mutex. So we can
660 * reliably free only the first mark in the list. That's why we first
661 * move marks to free to to_free list in one go and then free marks in
662 * to_free list one by one.
664 mutex_lock_nested(&group->mark_mutex, SINGLE_DEPTH_NESTING);
665 list_for_each_entry_safe(mark, lmark, &group->marks_list, g_list) {
666 if (mark->connector->flags & type)
667 list_move(&mark->g_list, &to_free);
669 mutex_unlock(&group->mark_mutex);
672 mutex_lock_nested(&group->mark_mutex, SINGLE_DEPTH_NESTING);
673 if (list_empty(&to_free)) {
674 mutex_unlock(&group->mark_mutex);
677 mark = list_first_entry(&to_free, struct fsnotify_mark, g_list);
678 fsnotify_get_mark(mark);
679 fsnotify_detach_mark(mark);
680 mutex_unlock(&group->mark_mutex);
681 fsnotify_free_mark(mark);
682 fsnotify_put_mark(mark);
687 * Given a group, prepare for freeing all the marks associated with that group.
688 * The marks are attached to the list of marks prepared for destruction, the
689 * caller is responsible for freeing marks in that list after SRCU period has
692 void fsnotify_detach_group_marks(struct fsnotify_group *group)
694 struct fsnotify_mark *mark;
697 mutex_lock_nested(&group->mark_mutex, SINGLE_DEPTH_NESTING);
698 if (list_empty(&group->marks_list)) {
699 mutex_unlock(&group->mark_mutex);
702 mark = list_first_entry(&group->marks_list,
703 struct fsnotify_mark, g_list);
704 fsnotify_get_mark(mark);
705 fsnotify_detach_mark(mark);
706 mutex_unlock(&group->mark_mutex);
707 fsnotify_free_mark(mark);
708 fsnotify_put_mark(mark);
711 * Some marks can still be pinned when waiting for response from
712 * userspace. Wait for those now. fsnotify_prepare_user_wait() will
713 * not succeed now so this wait is race-free.
715 wait_event(group->notification_waitq, !atomic_read(&group->user_waits));
718 /* Destroy all marks attached to inode / vfsmount */
719 void fsnotify_destroy_marks(struct fsnotify_mark_connector __rcu **connp)
721 struct fsnotify_mark_connector *conn;
722 struct fsnotify_mark *mark, *old_mark = NULL;
725 conn = fsnotify_grab_connector(connp);
729 * We have to be careful since we can race with e.g.
730 * fsnotify_clear_marks_by_group() and once we drop the conn->lock, the
731 * list can get modified. However we are holding mark reference and
732 * thus our mark cannot be removed from obj_list so we can continue
733 * iteration after regaining conn->lock.
735 hlist_for_each_entry(mark, &conn->list, obj_list) {
736 fsnotify_get_mark(mark);
737 spin_unlock(&conn->lock);
739 fsnotify_put_mark(old_mark);
741 fsnotify_destroy_mark(mark, mark->group);
742 spin_lock(&conn->lock);
745 * Detach list from object now so that we don't pin inode until all
746 * mark references get dropped. It would lead to strange results such
747 * as delaying inode deletion or blocking unmount.
749 inode = fsnotify_detach_connector_from_object(conn);
750 spin_unlock(&conn->lock);
752 fsnotify_put_mark(old_mark);
757 * Nothing fancy, just initialize lists and locks and counters.
759 void fsnotify_init_mark(struct fsnotify_mark *mark,
760 void (*free_mark)(struct fsnotify_mark *mark))
762 memset(mark, 0, sizeof(*mark));
763 spin_lock_init(&mark->lock);
764 atomic_set(&mark->refcnt, 1);
765 mark->free_mark = free_mark;
769 * Destroy all marks in destroy_list, waits for SRCU period to finish before
770 * actually freeing marks.
772 static void fsnotify_mark_destroy_workfn(struct work_struct *work)
774 struct fsnotify_mark *mark, *next;
775 struct list_head private_destroy_list;
777 spin_lock(&destroy_lock);
778 /* exchange the list head */
779 list_replace_init(&destroy_list, &private_destroy_list);
780 spin_unlock(&destroy_lock);
782 synchronize_srcu(&fsnotify_mark_srcu);
784 list_for_each_entry_safe(mark, next, &private_destroy_list, g_list) {
785 list_del_init(&mark->g_list);
786 fsnotify_final_mark_destroy(mark);
790 /* Wait for all marks queued for destruction to be actually destroyed */
791 void fsnotify_wait_marks_destroyed(void)
793 flush_delayed_work(&reaper_work);