Skip to content

Commit 74bd284

Browse files
committed
fsnotify: Shutdown fsnotify before destroying sb's dcache
Currently fsnotify_sb_delete() was called after we have evicted superblock's dcache and inode cache. This was done mainly so that we iterate as few inodes as possible when removing inode marks. However, as Jakub reported, this is problematic because for some filesystems encoding of file handles uses sb->s_root which gets cleared as part of dcache eviction. And either delayed fsnotify events or reading fdinfo for fsnotify group with marks on fs being unmounted may trigger encoding of file handles during unmount. So move shutdown of fsnotify subsystem before shrinking of dcache. Link: https://lore.kernel.org/linux-fsdevel/CAOQ4uxgXvwumYvJm3cLDFfx-TsU3g5-yVsTiG=6i8KS48dn0mQ@mail.gmail.com/ Reported-by: Jakub Acs <acsjakub@amazon.de> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent a05fc7e commit 74bd284

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ void generic_shutdown_super(struct super_block *sb)
618618
const struct super_operations *sop = sb->s_op;
619619

620620
if (sb->s_root) {
621+
fsnotify_sb_delete(sb);
621622
shrink_dcache_for_umount(sb);
622623
sync_filesystem(sb);
623624
sb->s_flags &= ~SB_ACTIVE;
@@ -629,9 +630,8 @@ void generic_shutdown_super(struct super_block *sb)
629630

630631
/*
631632
* Clean up and evict any inodes that still have references due
632-
* to fsnotify or the security policy.
633+
* to the security policy.
633634
*/
634-
fsnotify_sb_delete(sb);
635635
security_sb_delete(sb);
636636

637637
if (sb->s_dio_done_wq) {

0 commit comments

Comments
 (0)