aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaohiro Aota <naohiro.aota@wdc.com>2021-03-03 17:55:48 +0900
committerDavid Sterba <dsterba@suse.com>2021-03-04 16:16:58 +0100
commitbadae9c86979c459bd7d895d6d7ddc7a01131ff7 (patch)
tree6b067f50bdc3d6faacead81b56c416da7ef8ebb2
parentbtrfs: zoned: use sector_t for zone sectors (diff)
downloadlinux-dev-badae9c86979c459bd7d895d6d7ddc7a01131ff7.tar.xz
linux-dev-badae9c86979c459bd7d895d6d7ddc7a01131ff7.zip
btrfs: zoned: do not account freed region of read-only block group as zone_unusable
We migrate zone unusable bytes to read-only bytes when a block group is set to read-only, and account all the free region as bytes_readonly. Thus, we should not increase block_group->zone_unusable when the block group is read-only. Fixes: 169e0da91a21 ("btrfs: zoned: track unusable bytes for zones") Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/free-space-cache.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 711a6a751ae9..9988decd5717 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -2555,7 +2555,12 @@ static int __btrfs_add_free_space_zoned(struct btrfs_block_group *block_group,
to_unusable = size - to_free;
ctl->free_space += to_free;
- block_group->zone_unusable += to_unusable;
+ /*
+ * If the block group is read-only, we should account freed space into
+ * bytes_readonly.
+ */
+ if (!block_group->ro)
+ block_group->zone_unusable += to_unusable;
spin_unlock(&ctl->tree_lock);
if (!used) {
spin_lock(&block_group->lock);