Skip to content

Commit 95ca659

Browse files
naotakdave
authored andcommitted
btrfs: zoned: do not enable async discard
The zoned mode need to reset a zone before using it. We rely on btrfs's original discard functionality (discarding unused block group range) to do the resetting. While the commit 63a7cb1 ("btrfs: auto enable discard=async when possible") made the discard done in an async manner, a zoned reset do not need to be async, as it is fast enough. Even worth, delaying zone rests prevents using those zones again. So, let's disable async discard on the zoned mode. Fixes: 63a7cb1 ("btrfs: auto enable discard=async when possible") CC: stable@vger.kernel.org # 6.3+ Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Reviewed-by: David Sterba <dsterba@suse.com> [ update message text ] Signed-off-by: David Sterba <dsterba@suse.com>
1 parent aa84ce8 commit 95ca659

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

fs/btrfs/disk-io.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3438,11 +3438,16 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
34383438
* For devices supporting discard turn on discard=async automatically,
34393439
* unless it's already set or disabled. This could be turned off by
34403440
* nodiscard for the same mount.
3441+
*
3442+
* The zoned mode piggy backs on the discard functionality for
3443+
* resetting a zone. There is no reason to delay the zone reset as it is
3444+
* fast enough. So, do not enable async discard for zoned mode.
34413445
*/
34423446
if (!(btrfs_test_opt(fs_info, DISCARD_SYNC) ||
34433447
btrfs_test_opt(fs_info, DISCARD_ASYNC) ||
34443448
btrfs_test_opt(fs_info, NODISCARD)) &&
3445-
fs_info->fs_devices->discardable) {
3449+
fs_info->fs_devices->discardable &&
3450+
!btrfs_is_zoned(fs_info)) {
34463451
btrfs_set_and_info(fs_info, DISCARD_ASYNC,
34473452
"auto enabling async discard");
34483453
}

fs/btrfs/zoned.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,9 @@ int btrfs_check_mountopts_zoned(struct btrfs_fs_info *info)
805805
return -EINVAL;
806806
}
807807

808+
btrfs_clear_and_info(info, DISCARD_ASYNC,
809+
"zoned: async discard ignored and disabled for zoned mode");
810+
808811
return 0;
809812
}
810813

0 commit comments

Comments
 (0)