summaryrefslogtreecommitdiffstats
path: root/fs/super.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-10-27 08:40:01 +0200
committerChristian Brauner <brauner@kernel.org>2023-11-18 14:59:24 +0100
commit24c372d58223b83d0be5230c1a0e9370b60fb0ea (patch)
tree860fe0162b9cdfa92b7e81f4003d5f23f30eec4e /fs/super.c
parentext4: simplify device handling (diff)
downloadlinux-24c372d58223b83d0be5230c1a0e9370b60fb0ea.tar.xz
linux-24c372d58223b83d0be5230c1a0e9370b60fb0ea.zip
fs: streamline thaw_super_locked
Add a new out_unlock label to share code that just releases s_umount and returns an error, and rename and reuse the out label that deactivates the sb for one more case. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20231027064001.GA9469@lst.de Reviewed-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.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/fs/super.c b/fs/super.c
index 18b42281ebe2..faeab453e6e9 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -2070,34 +2070,28 @@ EXPORT_SYMBOL(freeze_super);
*/
static int thaw_super_locked(struct super_block *sb, enum freeze_holder who)
{
- int error;
+ int error = -EINVAL;
- if (sb->s_writers.frozen == SB_FREEZE_COMPLETE) {
- if (!(sb->s_writers.freeze_holders & who)) {
- super_unlock_excl(sb);
- return -EINVAL;
- }
+ if (sb->s_writers.frozen != SB_FREEZE_COMPLETE)
+ goto out_unlock;
+ if (!(sb->s_writers.freeze_holders & who))
+ goto out_unlock;
- /*
- * Freeze is shared with someone else. Release our hold and
- * drop the active ref that freeze_super assigned to the
- * freezer.
- */
- if (sb->s_writers.freeze_holders & ~who) {
- sb->s_writers.freeze_holders &= ~who;
- deactivate_locked_super(sb);
- return 0;
- }
- } else {
- super_unlock_excl(sb);
- return -EINVAL;
+ /*
+ * Freeze is shared with someone else. Release our hold and drop the
+ * active ref that freeze_super assigned to the freezer.
+ */
+ error = 0;
+ if (sb->s_writers.freeze_holders & ~who) {
+ sb->s_writers.freeze_holders &= ~who;
+ goto out_deactivate;
}
if (sb_rdonly(sb)) {
sb->s_writers.freeze_holders &= ~who;
sb->s_writers.frozen = SB_UNFROZEN;
wake_up_var(&sb->s_writers.frozen);
- goto out;
+ goto out_deactivate;
}
lockdep_sb_freeze_acquire(sb);
@@ -2107,8 +2101,7 @@ static int thaw_super_locked(struct super_block *sb, enum freeze_holder who)
if (error) {
printk(KERN_ERR "VFS:Filesystem thaw failed\n");
lockdep_sb_freeze_release(sb);
- super_unlock_excl(sb);
- return error;
+ goto out_unlock;
}
}
@@ -2116,9 +2109,13 @@ static int thaw_super_locked(struct super_block *sb, enum freeze_holder who)
sb->s_writers.frozen = SB_UNFROZEN;
wake_up_var(&sb->s_writers.frozen);
sb_freeze_unlock(sb, SB_FREEZE_FS);
-out:
+out_deactivate:
deactivate_locked_super(sb);
return 0;
+
+out_unlock:
+ super_unlock_excl(sb);
+ return error;
}
/**