Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH v3] btrfs: zoned: don't release active zone reservations for conventional zones
@ 2026-11-10  8:09 Johannes Thumshirn
  2026-11-10 15:08 ` Jochen Philipp
  2026-11-13 16:16 ` Martin Škoda
  0 siblings, 2 replies; 13+ messages in thread
From: Johannes Thumshirn @ 2026-11-10  8:09 UTC (permalink / raw)
  To: linux-btrfs
  Cc: David Sterba, Naohiro Aota, Jochen Philipp, Dongjiang Zhu,
	Johannes Thumshirn

On mount, btrfs_check_active_zone_reservation() releases a reserved
active zone for each stripe of an active metadata or system block-group.
Stripes on conventional zones usually hold no active zone on the device,
so they use up the reservation. Once metadata moves to a sequential
block-group, its activation fails and the transaction commit aborts
with -EAGAIN.

Only release reservations for stripes holding an active zone, matching
what finishing the zone gives back.

Fixes: a7e1ac7bdc5a ("btrfs: zoned: reserve zones for an active metadata/system block group")
Reported-by: Jochen Philipp <a2jphilipp@gmail.com>
Link: https://lore.kernel.org/linux-btrfs/CAD=K2o-BBqh+ikgfD732Cb3M1Xx48QGw3kTFsP5iSgH1mkr0wA@mail.gmail.com/
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
Changes to v2:
- Only decrement reservation for zones marked as active (Shashiko) 

 fs/btrfs/zoned.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 3192b86669b9..81489fa4a42d 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -3115,8 +3115,15 @@ void btrfs_check_active_zone_reservation(struct btrfs_fs_info *fs_info)
 		      (BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_SYSTEM)))
 			continue;
 
-		for (int i = 0; i < map->num_stripes; i++)
-			map->stripes[i].dev->zone_info->reserved_active_zones--;
+		for (int i = 0; i < map->num_stripes; i++) {
+			struct btrfs_zoned_device_info *zinfo = map->stripes[i].dev->zone_info;
+			u64 physical = map->stripes[i].physical;
+
+			if (!test_bit(physical >> zinfo->zone_size_shift, zinfo->active_zones))
+				continue;
+
+			zinfo->reserved_active_zones--;
+		}
 	}
 	spin_unlock(&fs_info->zone_active_bgs_lock);
 }
-- 
2.56.0


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

end of thread, other threads:[~2026-11-16 15:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10  8:09 [PATCH v3] btrfs: zoned: don't release active zone reservations for conventional zones Johannes Thumshirn
2026-11-10 15:08 ` Jochen Philipp
2026-11-13 10:09   ` Dongjiang Zhu
2026-11-13 10:14     ` Jochen Philipp
2026-11-13 12:40       ` Jochen Philipp
2026-11-13 14:00         ` Jochen Philipp
2026-11-13 14:45           ` Johannes Thumshirn
2026-11-13 14:55             ` Jochen Philipp
2026-11-13 16:16 ` Martin Škoda
2026-11-13 17:13   ` Jochen Philipp
2026-11-16  6:59     ` Johannes Thumshirn
2026-11-16  8:56       ` Dongjiang Zhu
2026-11-16 15:08   ` Mark Korenberg

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