Skip to content

Commit badae9c

Browse files
naotakdave
authored andcommitted
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: 169e0da ("btrfs: zoned: track unusable bytes for zones") Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Naohiro Aota <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent d734492 commit badae9c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fs/btrfs/free-space-cache.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2555,7 +2555,12 @@ static int __btrfs_add_free_space_zoned(struct btrfs_block_group *block_group,
25552555
to_unusable = size - to_free;
25562556

25572557
ctl->free_space += to_free;
2558-
block_group->zone_unusable += to_unusable;
2558+
/*
2559+
* If the block group is read-only, we should account freed space into
2560+
* bytes_readonly.
2561+
*/
2562+
if (!block_group->ro)
2563+
block_group->zone_unusable += to_unusable;
25592564
spin_unlock(&ctl->tree_lock);
25602565
if (!used) {
25612566
spin_lock(&block_group->lock);

0 commit comments

Comments
 (0)