]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: add a xfs_rtgroup_raw_size helper
authorChristoph Hellwig <hch@lst.de>
Wed, 14 Jan 2026 06:53:25 +0000 (07:53 +0100)
committerCarlos Maiolino <cem@kernel.org>
Wed, 21 Jan 2026 11:57:17 +0000 (12:57 +0100)
Add a helper to figure the on-disk size of a group, accounting for the
XFS_SB_FEAT_INCOMPAT_ZONE_GAPS feature if needed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/libxfs/xfs_rtgroup.h

index 73cace4d25c7917e8d8d52d73bcb76314193267f..c0b9f9f2c4131b3f742a4565e4c61ad43f4aa322 100644 (file)
@@ -371,4 +371,19 @@ xfs_rtgs_to_rfsbs(
        return xfs_groups_to_rfsbs(mp, nr_groups, XG_TYPE_RTG);
 }
 
+/*
+ * Return the "raw" size of a group on the hardware device.  This includes the
+ * daddr gaps present for XFS_SB_FEAT_INCOMPAT_ZONE_GAPS file systems.
+ */
+static inline xfs_rgblock_t
+xfs_rtgroup_raw_size(
+       struct xfs_mount        *mp)
+{
+       struct xfs_groups       *g = &mp->m_groups[XG_TYPE_RTG];
+
+       if (g->has_daddr_gaps)
+               return 1U << g->blklog;
+       return g->blocks;
+}
+
 #endif /* __LIBXFS_RTGROUP_H */