Skip to content

Commit 468e28d

Browse files
committed
Merge tag 'v6.6-vfs.super.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull superblock fixes from Christian Brauner: "Two follow-up fixes for the super work this cycle: - Move a misplaced lockep assertion before we potentially free the object containing the lock. - Ensure that filesystems which match superblocks in sget{_fc}() based on sb->s_fs_info are guaranteed to see a valid sb->s_fs_info as long as a superblock still appears on the filesystem type's superblock list. What we want as a proper solution for next cycle is to split sb->free_sb() out of sb->kill_sb() so that we can simply call kill_super_notify() after sb->kill_sb() but before sb->free_sb(). Currently, this is lumped together in sb->kill_sb()" * tag 'v6.6-vfs.super.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: super: ensure valid info super: move lockdep assert
2 parents bd6c11b + dc3216b commit 468e28d

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

fs/super.c

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,33 @@ void put_super(struct super_block *sb)
434434
spin_unlock(&sb_lock);
435435
}
436436

437+
static void kill_super_notify(struct super_block *sb)
438+
{
439+
lockdep_assert_not_held(&sb->s_umount);
440+
441+
/* already notified earlier */
442+
if (sb->s_flags & SB_DEAD)
443+
return;
444+
445+
/*
446+
* Remove it from @fs_supers so it isn't found by new
447+
* sget{_fc}() walkers anymore. Any concurrent mounter still
448+
* managing to grab a temporary reference is guaranteed to
449+
* already see SB_DYING and will wait until we notify them about
450+
* SB_DEAD.
451+
*/
452+
spin_lock(&sb_lock);
453+
hlist_del_init(&sb->s_instances);
454+
spin_unlock(&sb_lock);
455+
456+
/*
457+
* Let concurrent mounts know that this thing is really dead.
458+
* We don't need @sb->s_umount here as every concurrent caller
459+
* will see SB_DYING and either discard the superblock or wait
460+
* for SB_DEAD.
461+
*/
462+
super_wake(sb, SB_DEAD);
463+
}
437464

438465
/**
439466
* deactivate_locked_super - drop an active reference to superblock
@@ -453,6 +480,8 @@ void deactivate_locked_super(struct super_block *s)
453480
unregister_shrinker(&s->s_shrink);
454481
fs->kill_sb(s);
455482

483+
kill_super_notify(s);
484+
456485
/*
457486
* Since list_lru_destroy() may sleep, we cannot call it from
458487
* put_super(), where we hold the sb_lock. Therefore we destroy
@@ -461,25 +490,6 @@ void deactivate_locked_super(struct super_block *s)
461490
list_lru_destroy(&s->s_dentry_lru);
462491
list_lru_destroy(&s->s_inode_lru);
463492

464-
/*
465-
* Remove it from @fs_supers so it isn't found by new
466-
* sget{_fc}() walkers anymore. Any concurrent mounter still
467-
* managing to grab a temporary reference is guaranteed to
468-
* already see SB_DYING and will wait until we notify them about
469-
* SB_DEAD.
470-
*/
471-
spin_lock(&sb_lock);
472-
hlist_del_init(&s->s_instances);
473-
spin_unlock(&sb_lock);
474-
475-
/*
476-
* Let concurrent mounts know that this thing is really dead.
477-
* We don't need @sb->s_umount here as every concurrent caller
478-
* will see SB_DYING and either discard the superblock or wait
479-
* for SB_DEAD.
480-
*/
481-
super_wake(s, SB_DEAD);
482-
483493
put_filesystem(fs);
484494
put_super(s);
485495
} else {
@@ -570,8 +580,8 @@ static bool grab_super_dead(struct super_block *sb)
570580
return true;
571581
}
572582
wait_var_event(&sb->s_flags, wait_dead(sb));
573-
put_super(sb);
574583
lockdep_assert_not_held(&sb->s_umount);
584+
put_super(sb);
575585
return false;
576586
}
577587

@@ -1278,6 +1288,7 @@ void kill_anon_super(struct super_block *sb)
12781288
{
12791289
dev_t dev = sb->s_dev;
12801290
generic_shutdown_super(sb);
1291+
kill_super_notify(sb);
12811292
free_anon_bdev(dev);
12821293
}
12831294
EXPORT_SYMBOL(kill_anon_super);

0 commit comments

Comments
 (0)