Skip to contentSkip to conversation

btrfs: zoned: fix incorrect ASSERT in btrfs_zoned_reserve_data_reloc_bg

PATCH In review Johannes Thumshirn 3 participants 3 messages Sep 5, 2025 – Sep 9, 2025 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: zoned: fix incorrect ASSERT in btrfs_zoned_reserve_data_reloc_bg

From: Johannes Thumshirn <[email protected]>

When moving a block-group to the dedicated data relocation space-info in btrfs_zoned_reserve_data_reloc_bg() it is ASSERT()ed that the newly created block-group for data relocation does not contain any zone_unusable bytes.

But on disks with zone_capacity < zone_size, the difference between zone_size and zone_capacity is accounted as zone_unusable.

Instead of ASSERT()ing that the block-group does not contain any zone_unusable bytes, remove them from the block-groups total size.

---
 fs/btrfs/zoned.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/zoned.c +1 -1
index 6e66ec491181..ba444e412613 100644
@@ -2588,9 +2588,9 @@ void btrfs_zoned_reserve_data_reloc_bg(struct btrfs_fs_info *fs_info)
 			spin_lock(&space_info->lock);
 			space_info->total_bytes -= bg->length;
 			space_info->disk_total -= bg->length * factor;
+			space_info->disk_total -= bg->zone_unusable;
 			/* There is no allocation ever happened. */
 			ASSERT(bg->used == 0);
-			ASSERT(bg->zone_unusable == 0);
 			/* No super block in a block group on the zoned setup. */
 			ASSERT(bg->bytes_super == 0);
 			spin_unlock(&space_info->lock);
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Johannes Thumshirn

From: Johannes Thumshirn <[email protected]>

When moving a block-group to the dedicated data relocation space-info in btrfs_zoned_reserve_data_reloc_bg() it is ASSERT()ed that the newly created block-group for data relocation does not contain any zone_unusable bytes.

But on disks with zone_capacity < zone_size, the difference between zone_size and zone_capacity is accounted as zone_unusable.

Quoted 7 lines

Instead of ASSERT()ing that the block-group does not contain any zone_unusable bytes, remove them from the block-groups total size.

Tested-by
#2 lore raw
Quoted 15 lines · Naohiro Aota
Quoted 13 lines · Johannes Thumshirn

From: Johannes Thumshirn <[email protected]>

When moving a block-group to the dedicated data relocation space-info in btrfs_zoned_reserve_data_reloc_bg() it is ASSERT()ed that the newly created block-group for data relocation does not contain any zone_unusable bytes.

But on disks with zone_capacity < zone_size, the difference between zone_size and zone_capacity is accounted as zone_unusable.

Instead of ASSERT()ing that the block-group does not contain any zone_unusable bytes, remove them from the block-groups total size.

Quoted 6 lines
Quoted 4 lines

Thanks for the patch:

Signature · 2 lines
Best Regards,
  Yi Zhang