diff options
author | Christian Brauner <brauner@kernel.org> | 2023-08-22 13:32:50 +0200 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2023-08-22 13:32:50 +0200 |
commit | 051178c366bbc1bf8b4aba5ca5519d7da453c95f (patch) | |
tree | aa1102f335fff30f7d3930c08418c3fdcd10f553 /fs/super.c | |
parent | super: wait until we passed kill super (diff) | |
download | linux-051178c366bbc1bf8b4aba5ca5519d7da453c95f.tar.xz linux-051178c366bbc1bf8b4aba5ca5519d7da453c95f.zip |
super: use higher-level helper for {freeze,thaw}
It's not necessary to use low-level locking helpers here. Use the
higher-level locking helpers and log if the superblock is dying. Since
the caller is assumed to already hold an active reference it isn't
possible to observe a dying superblock.
Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/super.c')
-rw-r--r-- | fs/super.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/super.c b/fs/super.c index 2f604a6494fb..a284052ebab2 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1873,8 +1873,13 @@ int freeze_super(struct super_block *sb) { int ret; + /* Since the caller must already have an active reference... */ atomic_inc(&sb->s_active); - __super_lock_excl(sb); + + /* ...@sb definitely can't be dying. */ + if (!super_lock_excl(sb)) + WARN(1, "Dying superblock while freezing!"); + if (sb->s_writers.frozen != SB_UNFROZEN) { deactivate_locked_super(sb); return -EBUSY; @@ -1896,7 +1901,10 @@ int freeze_super(struct super_block *sb) /* Release s_umount to preserve sb_start_write -> s_umount ordering */ super_unlock_excl(sb); sb_wait_write(sb, SB_FREEZE_WRITE); - __super_lock_excl(sb); + + /* We're still holding an active reference. */ + if (!super_lock_excl(sb)) + WARN(1, "Dying superblock while freezing!"); /* Now we go and block page faults... */ sb->s_writers.frozen = SB_FREEZE_PAGEFAULT; @@ -1979,7 +1987,8 @@ out: */ int thaw_super(struct super_block *sb) { - __super_lock_excl(sb); + if (!super_lock_excl(sb)) + WARN(1, "Dying superblock while thawing!"); return thaw_super_locked(sb); } EXPORT_SYMBOL(thaw_super); |