Skip to content

Commit f09b04a

Browse files
committed
fsnotify: Remove special handling of mark destruction on group shutdown
Currently we queue all marks for destruction on group shutdown and then destroy them from fsnotify_destroy_group() instead from a worker thread which is the usual path. However worker can already be processing some list of marks to destroy so this does not make 100% all marks are really destroyed by the time group is shut down. This isn't a big problem as each mark holds group reference and thus group stays partially alive until all marks are really freed but there's no point in complicating our lives - just wait for the delayed work to be finished instead. Reviewed-by: Miklos Szeredi <mszeredi@redhat.com> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 6b3f05d commit f09b04a

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

‎fs/notify/fsnotify.h‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ static inline void fsnotify_clear_marks_by_mount(struct vfsmount *mnt)
3636
}
3737
/* prepare for freeing all marks associated with given group */
3838
extern void fsnotify_detach_group_marks(struct fsnotify_group *group);
39-
/*
40-
* wait for fsnotify_mark_srcu period to end and free all marks in destroy_list
41-
*/
42-
extern void fsnotify_mark_destroy_list(void);
39+
/* Wait until all marks queued for destruction are destroyed */
40+
extern void fsnotify_wait_marks_destroyed(void);
4341

4442
/*
4543
* update the dentry->d_flags of all of inode's children to indicate if inode cares

‎fs/notify/group.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,16 @@ void fsnotify_destroy_group(struct fsnotify_group *group)
6666
*/
6767
fsnotify_group_stop_queueing(group);
6868

69-
/* clear all inode marks for this group, attach them to destroy_list */
69+
/* Clear all marks for this group and queue them for destruction */
7070
fsnotify_detach_group_marks(group);
7171

7272
/*
73-
* Wait for fsnotify_mark_srcu period to end and free all marks in
74-
* destroy_list
73+
* Wait until all marks get really destroyed. We could actually destroy
74+
* them ourselves instead of waiting for worker to do it, however that
75+
* would be racy as worker can already be processing some marks before
76+
* we even entered fsnotify_destroy_group().
7577
*/
76-
fsnotify_mark_destroy_list();
78+
fsnotify_wait_marks_destroyed();
7779

7880
/*
7981
* Since we have waited for fsnotify_mark_srcu in

‎fs/notify/mark.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,
703703
* Destroy all marks in destroy_list, waits for SRCU period to finish before
704704
* actually freeing marks.
705705
*/
706-
void fsnotify_mark_destroy_list(void)
706+
static void fsnotify_mark_destroy_workfn(struct work_struct *work)
707707
{
708708
struct fsnotify_mark *mark, *next;
709709
struct list_head private_destroy_list;
@@ -721,7 +721,8 @@ void fsnotify_mark_destroy_list(void)
721721
}
722722
}
723723

724-
static void fsnotify_mark_destroy_workfn(struct work_struct *work)
724+
/* Wait for all marks queued for destruction to be actually destroyed */
725+
void fsnotify_wait_marks_destroyed(void)
725726
{
726-
fsnotify_mark_destroy_list();
727+
flush_delayed_work(&reaper_work);
727728
}

0 commit comments

Comments
 (0)