Skip to content

Commit 41d46b2

Browse files
josefbacikkdave
authored andcommitted
btrfs: move the device specific mount options to super.c
We add these mount options based on the fs_devices settings, which can be set once we've opened the fs_devices. Move these into their own helper and call it from get_tree_super. Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Anand Jain <[email protected]> Acked-by: Christian Brauner <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent ad21f15 commit 41d46b2

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

fs/btrfs/disk-io.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3510,29 +3510,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
35103510
goto fail_cleaner;
35113511
}
35123512

3513-
if (!btrfs_test_opt(fs_info, NOSSD) &&
3514-
!fs_info->fs_devices->rotating) {
3515-
btrfs_set_and_info(fs_info, SSD, "enabling ssd optimizations");
3516-
}
3517-
3518-
/*
3519-
* For devices supporting discard turn on discard=async automatically,
3520-
* unless it's already set or disabled. This could be turned off by
3521-
* nodiscard for the same mount.
3522-
*
3523-
* The zoned mode piggy backs on the discard functionality for
3524-
* resetting a zone. There is no reason to delay the zone reset as it is
3525-
* fast enough. So, do not enable async discard for zoned mode.
3526-
*/
3527-
if (!(btrfs_test_opt(fs_info, DISCARD_SYNC) ||
3528-
btrfs_test_opt(fs_info, DISCARD_ASYNC) ||
3529-
btrfs_test_opt(fs_info, NODISCARD)) &&
3530-
fs_info->fs_devices->discardable &&
3531-
!btrfs_is_zoned(fs_info)) {
3532-
btrfs_set_and_info(fs_info, DISCARD_ASYNC,
3533-
"auto enabling async discard");
3534-
}
3535-
35363513
ret = btrfs_read_qgroup_config(fs_info);
35373514
if (ret)
35383515
goto fail_trans_kthread;

fs/btrfs/super.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,29 @@ void btrfs_set_free_space_cache_settings(struct btrfs_fs_info *fs_info)
828828
btrfs_set_opt(fs_info->mount_opt, SPACE_CACHE);
829829
}
830830

831+
static void set_device_specific_options(struct btrfs_fs_info *fs_info)
832+
{
833+
if (!btrfs_test_opt(fs_info, NOSSD) &&
834+
!fs_info->fs_devices->rotating)
835+
btrfs_set_opt(fs_info->mount_opt, SSD);
836+
837+
/*
838+
* For devices supporting discard turn on discard=async automatically,
839+
* unless it's already set or disabled. This could be turned off by
840+
* nodiscard for the same mount.
841+
*
842+
* The zoned mode piggy backs on the discard functionality for
843+
* resetting a zone. There is no reason to delay the zone reset as it is
844+
* fast enough. So, do not enable async discard for zoned mode.
845+
*/
846+
if (!(btrfs_test_opt(fs_info, DISCARD_SYNC) ||
847+
btrfs_test_opt(fs_info, DISCARD_ASYNC) ||
848+
btrfs_test_opt(fs_info, NODISCARD)) &&
849+
fs_info->fs_devices->discardable &&
850+
!btrfs_is_zoned(fs_info))
851+
btrfs_set_opt(fs_info->mount_opt, DISCARD_ASYNC);
852+
}
853+
831854
static int parse_rescue_options(struct btrfs_fs_info *info, const char *options)
832855
{
833856
char *opts;
@@ -2876,6 +2899,8 @@ static int btrfs_get_tree_super(struct fs_context *fc)
28762899
goto error;
28772900
}
28782901

2902+
set_device_specific_options(fs_info);
2903+
28792904
if (sb->s_root) {
28802905
btrfs_close_devices(fs_devices);
28812906
if ((fc->sb_flags ^ sb->s_flags) & SB_RDONLY)

0 commit comments

Comments
 (0)