btrfs: move one shot mount option clearing to super.c
authorJosef Bacik <josef@toxicpanda.com>
Wed, 22 Nov 2023 17:17:53 +0000 (12:17 -0500)
committerDavid Sterba <dsterba@suse.com>
Fri, 15 Dec 2023 19:27:04 +0000 (20:27 +0100)
There's no reason this has to happen in open_ctree, and in fact in the
old mount API we had to call this from remount.  Move this to super.c,
unexport it, and call it from both mount and reconfigure.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Acked-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c
fs/btrfs/disk-io.h
fs/btrfs/super.c

index 42e6d818a5a89c0d227ebe7bd50be06deb114b56..12daa8a36ba163bee82515f47e5618703e863129 100644 (file)
@@ -2946,18 +2946,6 @@ out:
        return err;
 }
 
-/*
- * Some options only have meaning at mount time and shouldn't persist across
- * remounts, or be displayed. Clear these at the end of mount and remount
- * code paths.
- */
-void btrfs_clear_oneshot_options(struct btrfs_fs_info *fs_info)
-{
-       btrfs_clear_opt(fs_info->mount_opt, USEBACKUPROOT);
-       btrfs_clear_opt(fs_info->mount_opt, CLEAR_CACHE);
-       btrfs_clear_opt(fs_info->mount_opt, NOSPACECACHE);
-}
-
 /*
  * Mounting logic specific to read-write file systems. Shared by open_ctree
  * and btrfs_remount when remounting from read-only to read-write.
@@ -3535,7 +3523,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
        }
 
        if (sb_rdonly(sb))
-               goto clear_oneshot;
+               return 0;
 
        ret = btrfs_start_pre_rw_mount(fs_info);
        if (ret) {
@@ -3563,8 +3551,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
        if (test_bit(BTRFS_FS_UNFINISHED_DROPS, &fs_info->flags))
                wake_up_process(fs_info->cleaner_kthread);
 
-clear_oneshot:
-       btrfs_clear_oneshot_options(fs_info);
        return 0;
 
 fail_qgroup:
index e589359e6a687256ef5c78e165abc2c55e564606..9413726b329bb123202a66cf341320ca2d99e410 100644 (file)
@@ -37,7 +37,6 @@ struct extent_buffer *btrfs_find_create_tree_block(
                                                struct btrfs_fs_info *fs_info,
                                                u64 bytenr, u64 owner_root,
                                                int level);
-void btrfs_clear_oneshot_options(struct btrfs_fs_info *fs_info);
 int btrfs_start_pre_rw_mount(struct btrfs_fs_info *fs_info);
 int btrfs_check_super_csum(struct btrfs_fs_info *fs_info,
                           const struct btrfs_super_block *disk_sb);
index f9488161bf836b0334556872bdc9331d8011793c..95d6392a1acf8b6eb6512cb1acc82bddbc202618 100644 (file)
@@ -631,6 +631,18 @@ static int btrfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
        return 0;
 }
 
+/*
+ * Some options only have meaning at mount time and shouldn't persist across
+ * remounts, or be displayed. Clear these at the end of mount and remount code
+ * paths.
+ */
+static void btrfs_clear_oneshot_options(struct btrfs_fs_info *fs_info)
+{
+       btrfs_clear_opt(fs_info->mount_opt, USEBACKUPROOT);
+       btrfs_clear_opt(fs_info->mount_opt, CLEAR_CACHE);
+       btrfs_clear_opt(fs_info->mount_opt, NOSPACECACHE);
+}
+
 static bool check_ro_option(struct btrfs_fs_info *fs_info,
                            unsigned long mount_opt, unsigned long opt,
                            const char *opt_name)
@@ -1865,6 +1877,8 @@ static int btrfs_get_tree_super(struct fs_context *fc)
                return ret;
        }
 
+       btrfs_clear_oneshot_options(fs_info);
+
        fc->root = dget(sb->s_root);
        return 0;