diff mbox series

[25/43] FIXUP: xfs: support zone gaps

Message ID 20250414053629.360672-26-hch@lst.de (mailing list archive)
State New
Headers show
Series [01/43] xfs: generalize the freespace and reserved blocks handling | expand

Commit Message

Christoph Hellwig April 14, 2025, 5:36 a.m. UTC
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 db/convert.c        | 6 +++++-
 include/xfs_mount.h | 9 +++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/db/convert.c b/db/convert.c
index 47d3e86fdc4e..3eec4f224f51 100644
--- a/db/convert.c
+++ b/db/convert.c
@@ -44,10 +44,14 @@  xfs_daddr_to_rgno(
 	struct xfs_mount	*mp,
 	xfs_daddr_t		daddr)
 {
+	struct xfs_groups	*g = &mp->m_groups[XG_TYPE_RTG];
+
 	if (!xfs_has_rtgroups(mp))
 		return 0;
 
-	return XFS_BB_TO_FSBT(mp, daddr) / mp->m_groups[XG_TYPE_RTG].blocks;
+	if (g->has_daddr_gaps)
+		return XFS_BB_TO_FSBT(mp, daddr) / (1 << g->blklog);
+	return XFS_BB_TO_FSBT(mp, daddr) / g->blocks;
 }
 
 typedef enum {
diff --git a/include/xfs_mount.h b/include/xfs_mount.h
index bf9ebc25fc79..5a714333c16e 100644
--- a/include/xfs_mount.h
+++ b/include/xfs_mount.h
@@ -47,6 +47,15 @@  struct xfs_groups {
 	 */
 	uint8_t			blklog;
 
+	/*
+	 * Zoned devices can have gaps beyoned the usable capacity of a zone
+	 * and the end in the LBA/daddr address space.  In other words, the
+	 * hardware equivalent to the RT groups already takes care of the power
+	 * of 2 alignment for us.  In this case the sparse FSB/RTB address space
+	 * maps 1:1 to the device address space.
+	 */
+	bool			has_daddr_gaps;
+
 	/*
 	 * Mask to extract the group-relative block number from a FSB.
 	 * For a pre-rtgroups filesystem we pretend to have one very large