Skip to content

Commit 140d418

Browse files
naotakdave
authored andcommitted
btrfs: zoned: fix conventional zone capacity calculation
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: stable@vger.kernel.org # v6.12+ Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 67d8b3a commit 140d418

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
@@ -1317,6 +1317,7 @@ static int btrfs_load_zone_info(struct btrfs_fs_info *fs_info, int zone_idx,
13171317
if (!btrfs_dev_is_sequential(device, info->physical)) {
13181318
up_read(&dev_replace->rwsem);
13191319
info->alloc_offset = WP_CONVENTIONAL;
1320+
info->capacity = device->zone_info->zone_size;
13201321
return 0;
13211322
}
13221323

@@ -1683,8 +1684,6 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
16831684
set_bit(BLOCK_GROUP_FLAG_SEQUENTIAL_ZONE, &cache->runtime_flags);
16841685

16851686
if (num_conventional > 0) {
1686-
/* Zone capacity is always zone size in emulation */
1687-
cache->zone_capacity = cache->length;
16881687
ret = calculate_alloc_pointer(cache, &last_alloc, new);
16891688
if (ret) {
16901689
btrfs_err(fs_info,
@@ -1693,6 +1692,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
16931692
goto out;
16941693
} else if (map->num_stripes == num_conventional) {
16951694
cache->alloc_offset = last_alloc;
1695+
cache->zone_capacity = cache->length;
16961696
set_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE, &cache->runtime_flags);
16971697
goto out;
16981698
}

0 commit comments

Comments
 (0)