Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs: zoned: handle RAID profiles in btrfs_can_activate_zone()
@ 2026-08-24 16:19 Johannes Thumshirn
  2026-08-31 21:58 ` Boris Burkov
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Thumshirn @ 2026-08-24 16:19 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Naohiro Aota, Johannes Thumshirn

btrfs_can_activate_zone() only accounts for the single and DUP profiles.
For a RAID0, RAID1, RAID1C3, RAID1C4 or RAID10 block group the profile
switch matches no case, so 'ret' stays false and the function reports
that no zone can be activated, even when the devices have plenty of
active zones left.

As a side effect BTRFS_FS_NEED_ZONE_FINISH gets set and, since
btrfs_can_activate_zone() bails out early once that bit is set, data
allocations will fail permanently: writers loop on -EAGAIN and hang in
btrfs_new_extent_direct() waiting for the bit to clear.

Each of these profiles needs one active zone per device, just like
single, so handle them the same way.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/zoned.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 9d448cdd60c4..107833fcf2be 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -2689,6 +2689,11 @@ bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags)
 
 		switch (flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
 		case 0: /* single */
+		case BTRFS_BLOCK_GROUP_RAID0:
+		case BTRFS_BLOCK_GROUP_RAID1:
+		case BTRFS_BLOCK_GROUP_RAID1C3:
+		case BTRFS_BLOCK_GROUP_RAID1C4:
+		case BTRFS_BLOCK_GROUP_RAID10:
 			ret = (atomic_read(&zinfo->active_zones_left) >= (1 + reserved));
 			break;
 		case BTRFS_BLOCK_GROUP_DUP:
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs: zoned: handle RAID profiles in btrfs_can_activate_zone()
  2026-08-24 16:19 [PATCH] btrfs: zoned: handle RAID profiles in btrfs_can_activate_zone() Johannes Thumshirn
@ 2026-08-31 21:58 ` Boris Burkov
  0 siblings, 0 replies; 2+ messages in thread
From: Boris Burkov @ 2026-08-31 21:58 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: linux-btrfs, Naohiro Aota

On Mon, Aug 24, 2026 at 06:19:10PM +0200, Johannes Thumshirn wrote:
> btrfs_can_activate_zone() only accounts for the single and DUP profiles.
> For a RAID0, RAID1, RAID1C3, RAID1C4 or RAID10 block group the profile
> switch matches no case, so 'ret' stays false and the function reports
> that no zone can be activated, even when the devices have plenty of
> active zones left.
> 
> As a side effect BTRFS_FS_NEED_ZONE_FINISH gets set and, since
> btrfs_can_activate_zone() bails out early once that bit is set, data
> allocations will fail permanently: writers loop on -EAGAIN and hang in
> btrfs_new_extent_direct() waiting for the bit to clear.
> 
> Each of these profiles needs one active zone per device, just like
> single, so handle them the same way.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Boris Burkov <boris@bur.io>
> ---
>  fs/btrfs/zoned.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index 9d448cdd60c4..107833fcf2be 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -2689,6 +2689,11 @@ bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags)
>  
>  		switch (flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
>  		case 0: /* single */
> +		case BTRFS_BLOCK_GROUP_RAID0:
> +		case BTRFS_BLOCK_GROUP_RAID1:
> +		case BTRFS_BLOCK_GROUP_RAID1C3:
> +		case BTRFS_BLOCK_GROUP_RAID1C4:
> +		case BTRFS_BLOCK_GROUP_RAID10:
>  			ret = (atomic_read(&zinfo->active_zones_left) >= (1 + reserved));
>  			break;
>  		case BTRFS_BLOCK_GROUP_DUP:
> -- 
> 2.55.0
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-31 21:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-24 16:19 [PATCH] btrfs: zoned: handle RAID profiles in btrfs_can_activate_zone() Johannes Thumshirn
2026-08-31 21:58 ` Boris Burkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox