]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: create helpers for rtsummary block/wordcount computations
authorDarrick J. Wong <djwong@kernel.org>
Thu, 15 Feb 2024 08:25:48 +0000 (09:25 +0100)
committerCarlos Maiolino <cem@kernel.org>
Thu, 15 Feb 2024 11:56:43 +0000 (12:56 +0100)
Source kernel commit: bd85af280de66a946022775a876edf0c553e3f35

Create helper functions that compute the number of blocks or words
necessary to store the rt summary file.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
libxfs/xfs_rtbitmap.c
libxfs/xfs_rtbitmap.h

index f7be9ea5fe85ac7701aa2f8e3b35ec09161beb2f..44064b6b3ecc0d39b3d5af10be9bd468c7a80702 100644 (file)
@@ -1148,3 +1148,32 @@ xfs_rtbitmap_wordcount(
        blocks = xfs_rtbitmap_blockcount(mp, rtextents);
        return XFS_FSB_TO_B(mp, blocks) >> XFS_WORDLOG;
 }
+
+/* Compute the number of rtsummary blocks 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 long long      rsumwords;
+
+       rsumwords = (unsigned long long)rsumlevels * rbmblocks;
+       return XFS_B_TO_FSB(mp, rsumwords << XFS_WORDLOG);
+}
+
+/*
+ * Compute the number of rtsummary info words needed to populate every block of
+ * a summary file that is large enough to track the given rt space.
+ */
+unsigned long long
+xfs_rtsummary_wordcount(
+       struct xfs_mount        *mp,
+       unsigned int            rsumlevels,
+       xfs_extlen_t            rbmblocks)
+{
+       xfs_filblks_t           blocks;
+
+       blocks = xfs_rtsummary_blockcount(mp, rsumlevels, rbmblocks);
+       return XFS_FSB_TO_B(mp, blocks) >> XFS_WORDLOG;
+}
index 02ee57f87d99e90cb9c84de79fd61015d13d6e75..62138df6d1a3f5e25f68f7008e257b04f20eb44c 100644 (file)
@@ -311,6 +311,11 @@ xfs_filblks_t xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t
                rtextents);
 unsigned long long xfs_rtbitmap_wordcount(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 long long xfs_rtsummary_wordcount(struct xfs_mount *mp,
+               unsigned int rsumlevels, xfs_extlen_t rbmblocks);
 #else /* CONFIG_XFS_RT */
 # define xfs_rtfree_extent(t,b,l)                      (-ENOSYS)
 # define xfs_rtfree_blocks(t,rb,rl)                    (-ENOSYS)
@@ -325,6 +330,8 @@ xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t rtextents)
        return 0;
 }
 # define xfs_rtbitmap_wordcount(mp, r)                 (0)
+# define xfs_rtsummary_blockcount(mp, l, b)            (0)
+# define xfs_rtsummary_wordcount(mp, l, b)             (0)
 #endif /* CONFIG_XFS_RT */
 
 #endif /* __XFS_RTBITMAP_H__ */