6767 * - The fs the inode is on is unmounted. (fsnotify_inode_delete/fsnotify_unmount_inodes)
6868 * - Something explicitly requests that it be removed. (fsnotify_destroy_mark)
6969 * - The fsnotify_group associated with the mark is going away and all such marks
70- * need to be cleaned up. (fsnotify_detach_group_marks )
70+ * need to be cleaned up. (fsnotify_clear_marks_by_group )
7171 *
7272 * This has the very interesting property of being able to run concurrently with
7373 * any (or all) other directions.
@@ -651,7 +651,13 @@ void fsnotify_clear_marks_by_group(struct fsnotify_group *group,
651651{
652652 struct fsnotify_mark * lmark , * mark ;
653653 LIST_HEAD (to_free );
654+ struct list_head * head = & to_free ;
654655
656+ /* Skip selection step if we want to clear all marks. */
657+ if (type == FSNOTIFY_OBJ_ALL_TYPES ) {
658+ head = & group -> marks_list ;
659+ goto clear ;
660+ }
655661 /*
656662 * We have to be really careful here. Anytime we drop mark_mutex, e.g.
657663 * fsnotify_clear_marks_by_inode() can come and free marks. Even in our
@@ -668,13 +674,14 @@ void fsnotify_clear_marks_by_group(struct fsnotify_group *group,
668674 }
669675 mutex_unlock (& group -> mark_mutex );
670676
677+ clear :
671678 while (1 ) {
672679 mutex_lock_nested (& group -> mark_mutex , SINGLE_DEPTH_NESTING );
673- if (list_empty (& to_free )) {
680+ if (list_empty (head )) {
674681 mutex_unlock (& group -> mark_mutex );
675682 break ;
676683 }
677- mark = list_first_entry (& to_free , struct fsnotify_mark , g_list );
684+ mark = list_first_entry (head , struct fsnotify_mark , g_list );
678685 fsnotify_get_mark (mark );
679686 fsnotify_detach_mark (mark );
680687 mutex_unlock (& group -> mark_mutex );
@@ -683,38 +690,6 @@ void fsnotify_clear_marks_by_group(struct fsnotify_group *group,
683690 }
684691}
685692
686- /*
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
690- * ended.
691- */
692- void fsnotify_detach_group_marks (struct fsnotify_group * group )
693- {
694- struct fsnotify_mark * mark ;
695-
696- while (1 ) {
697- mutex_lock_nested (& group -> mark_mutex , SINGLE_DEPTH_NESTING );
698- if (list_empty (& group -> marks_list )) {
699- mutex_unlock (& group -> mark_mutex );
700- break ;
701- }
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 );
709- }
710- /*
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.
714- */
715- wait_event (group -> notification_waitq , !atomic_read (& group -> user_waits ));
716- }
717-
718693/* Destroy all marks attached to inode / vfsmount */
719694void fsnotify_destroy_marks (struct fsnotify_mark_connector __rcu * * connp )
720695{
0 commit comments