aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs/block-group.c
diff options
context:
space:
mode:
authorGravatar Naohiro Aota <naohiro.aota@wdc.com> 2021-02-04 19:21:56 +0900
committerGravatar David Sterba <dsterba@suse.com> 2021-02-09 02:46:04 +0100
commitdcba6e48b518e5e48522e9ea2b73b60827c93146 (patch)
treec792078c2e5abb52dc23f73fd302f57d033ea106 /fs/btrfs/block-group.c
parentbtrfs: zoned: advance allocation pointer after tree log node (diff)
downloadlinux-dcba6e48b518e5e48522e9ea2b73b60827c93146.tar.gz
linux-dcba6e48b518e5e48522e9ea2b73b60827c93146.tar.bz2
linux-dcba6e48b518e5e48522e9ea2b73b60827c93146.zip
btrfs: zoned: reset zones of unused block groups
We must reset the zones of a deleted unused block group to rewind the zones' write pointers to the zones' start. To do this, we can use the DISCARD_SYNC code to do the reset when the filesystem is running on zoned devices. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/block-group.c')
-rw-r--r--fs/btrfs/block-group.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 63093cfb807e..70a0c0f8f99f 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1408,8 +1408,12 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
if (!async_trim_enabled && btrfs_test_opt(fs_info, DISCARD_ASYNC))
goto flip_async;
- /* DISCARD can flip during remount */
- trimming = btrfs_test_opt(fs_info, DISCARD_SYNC);
+ /*
+ * DISCARD can flip during remount. On zoned filesystems, we
+ * need to reset sequential-required zones.
+ */
+ trimming = btrfs_test_opt(fs_info, DISCARD_SYNC) ||
+ btrfs_is_zoned(fs_info);
/* Implicit trim during transaction commit. */
if (trimming)