]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: refactor xfs_rtsummary_blockcount
authorChristoph Hellwig <hch@lst.de>
Mon, 5 Aug 2024 18:30:26 +0000 (11:30 -0700)
committerChristoph Hellwig <hch@lst.de>
Tue, 6 Aug 2024 12:53:49 +0000 (05:53 -0700)
Source kernel commit: 650c7d4d4e0b4a461c2b21bd7ba697514d473bb3

Make xfs_rtsummary_blockcount take all the required information from
the mount structure and return the number of summary levels from it
as well.  This cleans up many of the callers and prepares for making the
rtsummary files per-rtgroup where they need to look at different value.

This means we recalculate some values in some callers, but as all these
calculations are outside the fast path and cheap that seems like a price
worth paying.

Signed-off-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_rtbitmap.c
libxfs/xfs_rtbitmap.h

index a1bb99a2858eff50ed045f86efc05f890cf9f15c..7bc943593cea750dce245a6f1337a8287ecd1706 100644 (file)
@@ -18,6 +18,7 @@
 #include "xfs_trans.h"
 #include "xfs_rtbitmap.h"
 #include "xfs_health.h"
+#include "xfs_sb.h"
 
 /*
  * Realtime allocator bitmap functions shared with userspace.
@@ -1164,16 +1165,20 @@ xfs_rtbitmap_blockcount(
        return xfs_rtbitmap_blockcount_len(mp, mp->m_sb.sb_rextents);
 }
 
-/* Compute the number of rtsummary blocks needed to track the given rt space. */
+/*
+ * Compute the geometry of the rtsummary file needed to track the given rt
+ * space.
+ */
 xfs_filblks_t
 xfs_rtsummary_blockcount(
        struct xfs_mount        *mp,
-       unsigned int            rsumlevels,
-       xfs_extlen_t            rbmblocks)
+       unsigned int            *rsumlevels)
 {
        unsigned long long      rsumwords;
 
-       rsumwords = (unsigned long long)rsumlevels * rbmblocks;
+       *rsumlevels = xfs_compute_rextslog(mp->m_sb.sb_rextents) + 1;
+
+       rsumwords = xfs_rtbitmap_blockcount(mp) * (*rsumlevels);
        return XFS_B_TO_FSB(mp, rsumwords << XFS_WORDLOG);
 }
 
index 58672863053a94e2b1d586ad4b425e6b23a7029a..776cca9e41bf05d737ba151aac572bc3de1ff59f 100644 (file)
@@ -311,7 +311,7 @@ xfs_filblks_t xfs_rtbitmap_blockcount(struct xfs_mount *mp);
 xfs_filblks_t xfs_rtbitmap_blockcount_len(struct xfs_mount *mp,
                xfs_rtbxlen_t rtextents);
 xfs_filblks_t xfs_rtsummary_blockcount(struct xfs_mount *mp,
-               unsigned int rsumlevels, xfs_extlen_t rbmblocks);
+               unsigned int *rsumlevels);
 
 int xfs_rtfile_initialize_blocks(struct xfs_rtgroup *rtg,
                enum xfs_rtg_inodes type, xfs_fileoff_t offset_fsb,
@@ -342,7 +342,6 @@ xfs_rtbitmap_blockcount_len(struct xfs_mount *mp, xfs_rtbxlen_t rtextents)
        /* shut up gcc */
        return 0;
 }
-# define xfs_rtsummary_blockcount(mp, l, b)            (0)
 #endif /* CONFIG_XFS_RT */
 
 #endif /* __XFS_RTBITMAP_H__ */