* [PATCH] btrfs: zoned: fix incorrect ASSERT in btrfs_zoned_reserve_data_reloc_bg
@ 2025-09-05 13:54 Johannes Thumshirn
2025-09-09 4:40 ` Naohiro Aota
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Thumshirn @ 2025-09-05 13:54 UTC (permalink / raw)
To: linux-btrfs
Cc: David Sterba, Naohiro Aota, Shinichiro Kawasaki,
Johannes Thumshirn, Yi Zhang
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
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.
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Link: https://lore.kernel.org/linux-block/CAHj4cs8-cS2E+-xQ-d2Bj6vMJZ+CwT_cbdWBTju4BV35LsvEYw@mail.gmail.com/
Fixes: daa0fde322350 ("btrfs: zoned: fix data relocation block group reservation")
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
fs/btrfs/zoned.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 6e66ec491181..ba444e412613 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -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);
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: zoned: fix incorrect ASSERT in btrfs_zoned_reserve_data_reloc_bg
2025-09-05 13:54 [PATCH] btrfs: zoned: fix incorrect ASSERT in btrfs_zoned_reserve_data_reloc_bg Johannes Thumshirn
@ 2025-09-09 4:40 ` Naohiro Aota
2025-09-09 8:35 ` Yi Zhang
0 siblings, 1 reply; 3+ messages in thread
From: Naohiro Aota @ 2025-09-09 4:40 UTC (permalink / raw)
To: Johannes Thumshirn, linux-btrfs@vger.kernel.org
Cc: David Sterba, Naohiro Aota, Shinichiro Kawasaki,
Johannes Thumshirn, Yi Zhang
On Fri Sep 5, 2025 at 10:54 PM JST, Johannes Thumshirn wrote:
> From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>
> 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.
>
> Reported-by: Yi Zhang <yi.zhang@redhat.com>
> Link: https://lore.kernel.org/linux-block/CAHj4cs8-cS2E+-xQ-d2Bj6vMJZ+CwT_cbdWBTju4BV35LsvEYw@mail.gmail.com/
> Fixes: daa0fde322350 ("btrfs: zoned: fix data relocation block group reservation")
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: zoned: fix incorrect ASSERT in btrfs_zoned_reserve_data_reloc_bg
2025-09-09 4:40 ` Naohiro Aota
@ 2025-09-09 8:35 ` Yi Zhang
0 siblings, 0 replies; 3+ messages in thread
From: Yi Zhang @ 2025-09-09 8:35 UTC (permalink / raw)
To: Naohiro Aota
Cc: Johannes Thumshirn, linux-btrfs@vger.kernel.org, David Sterba,
Shinichiro Kawasaki, Johannes Thumshirn
On Tue, Sep 9, 2025 at 12:42 PM Naohiro Aota <Naohiro.Aota@wdc.com> wrote:
>
> On Fri Sep 5, 2025 at 10:54 PM JST, Johannes Thumshirn wrote:
> > From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> >
> > 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.
> >
> > Reported-by: Yi Zhang <yi.zhang@redhat.com>
> > Link: https://lore.kernel.org/linux-block/CAHj4cs8-cS2E+-xQ-d2Bj6vMJZ+CwT_cbdWBTju4BV35LsvEYw@mail.gmail.com/
> > Fixes: daa0fde322350 ("btrfs: zoned: fix data relocation block group reservation")
> > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>
> Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
Thanks for the patch:
Tested-by: Yi Zhang <yi.zhang@redhat.com>
--
Best Regards,
Yi Zhang
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-09 8:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-05 13:54 [PATCH] btrfs: zoned: fix incorrect ASSERT in btrfs_zoned_reserve_data_reloc_bg Johannes Thumshirn
2025-09-09 4:40 ` Naohiro Aota
2025-09-09 8:35 ` Yi Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox