Skip to content

Commit 92f06ab

Browse files
naotagregkh
authored andcommitted
btrfs: zoned: fix conventional zone capacity calculation
commit 94f5492 upstream. When a block group contains both conventional zone and sequential zone, the capacity of the block group is wrongly set to the block group's full length. The capacity should be calculated in btrfs_load_block_group_* using the last allocation offset. Fixes: 568220f ("btrfs: zoned: support RAID0/1/10 on top of raid stripe tree") CC: [email protected] # v6.12+ Signed-off-by: Naohiro Aota <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 862b0e6 commit 92f06ab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/btrfs/zoned.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,7 @@ static int btrfs_load_zone_info(struct btrfs_fs_info *fs_info, int zone_idx,
13001300
if (!btrfs_dev_is_sequential(device, info->physical)) {
13011301
up_read(&dev_replace->rwsem);
13021302
info->alloc_offset = WP_CONVENTIONAL;
1303+
info->capacity = device->zone_info->zone_size;
13031304
return 0;
13041305
}
13051306

@@ -1598,8 +1599,6 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
15981599
set_bit(BLOCK_GROUP_FLAG_SEQUENTIAL_ZONE, &cache->runtime_flags);
15991600

16001601
if (num_conventional > 0) {
1601-
/* Zone capacity is always zone size in emulation */
1602-
cache->zone_capacity = cache->length;
16031602
ret = calculate_alloc_pointer(cache, &last_alloc, new);
16041603
if (ret) {
16051604
btrfs_err(fs_info,
@@ -1608,6 +1607,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
16081607
goto out;
16091608
} else if (map->num_stripes == num_conventional) {
16101609
cache->alloc_offset = last_alloc;
1610+
cache->zone_capacity = cache->length;
16111611
set_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE, &cache->runtime_flags);
16121612
goto out;
16131613
}

0 commit comments

Comments
 (0)