super: skip dying superblocks early
authorChristian Brauner <brauner@kernel.org>
Sat, 29 Mar 2025 08:42:16 +0000 (09:42 +0100)
committerChristian Brauner <brauner@kernel.org>
Mon, 7 Apr 2025 07:37:16 +0000 (09:37 +0200)
Make all iterators uniform by performing an early check whether the
superblock is dying.

Link: https://lore.kernel.org/r/20250329-work-freeze-v2-3-a47af37ecc3d@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/super.c

index b1acfc38ba0c698d1949ea9d3be84e21e490fccb..c67ea3cdda41237e4399117ed3bb6d6c9cb81e78 100644 (file)
@@ -925,6 +925,9 @@ void iterate_supers(void (*f)(struct super_block *, void *), void *arg)
        list_for_each_entry(sb, &super_blocks, s_list) {
                bool locked;
 
+               if (super_flags(sb, SB_DYING))
+                       continue;
+
                sb->s_count++;
                spin_unlock(&sb_lock);
 
@@ -962,6 +965,9 @@ void iterate_supers_type(struct file_system_type *type,
        hlist_for_each_entry(sb, &type->fs_supers, s_instances) {
                bool locked;
 
+               if (super_flags(sb, SB_DYING))
+                       continue;
+
                sb->s_count++;
                spin_unlock(&sb_lock);