]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: refactor xfs_rtsummary_blockcount
authorChristoph Hellwig <hch@lst.de>
Mon, 23 Sep 2024 20:41:16 +0000 (13:41 -0700)
committerChristoph Hellwig <hch@lst.de>
Wed, 9 Oct 2024 13:55:39 +0000 (15:55 +0200)
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>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/libxfs/xfs_rtbitmap.c
fs/xfs/libxfs/xfs_rtbitmap.h
fs/xfs/scrub/rtsummary.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_rtalloc.c

index e9b80ef166c0e87bde3b303a9bbfd87ae7191828..54079edfe10feb44b7951162abb6963f284ab8bc 100644 (file)
@@ -20,6 +20,7 @@
 #include "xfs_error.h"
 #include "xfs_rtbitmap.h"
 #include "xfs_health.h"
+#include "xfs_sb.h"
 
 /*
  * Realtime allocator bitmap functions shared with userspace.
@@ -1166,16 +1167,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__ */
index 0a6b7902a04cbbcaf8470850185f812dc0671eea..4125883c6da080082bc0b781b9163487f0b39748 100644 (file)
@@ -102,14 +102,10 @@ xchk_setup_rtsummary(
         */
        xchk_rtgroup_lock(&sc->sr, XFS_RTGLOCK_BITMAP);
        if (mp->m_sb.sb_rblocks) {
-               int             rextslog;
-
                rts->rextents = xfs_rtb_to_rtx(mp, mp->m_sb.sb_rblocks);
-               rextslog = xfs_compute_rextslog(mp->m_sb.sb_rextents);
-               rts->rsumlevels = rextslog + 1;
                rts->rbmblocks = xfs_rtbitmap_blockcount(mp);
-               rts->rsumblocks = xfs_rtsummary_blockcount(mp, rts->rsumlevels,
-                               rts->rbmblocks);
+               rts->rsumblocks =
+                       xfs_rtsummary_blockcount(mp, &rts->rsumlevels);
        }
 
        return 0;
index f07c91b3225cf9d8477fc26b5fded512e34c101f..85b1dfcfb505228f4bb9b47d56c4f8b49a398741 100644 (file)
@@ -143,7 +143,7 @@ typedef struct xfs_mount {
        uint                    m_allocsize_blocks; /* min write size blocks */
        int                     m_logbufs;      /* number of log buffers */
        int                     m_logbsize;     /* size of each log buffer */
-       uint                    m_rsumlevels;   /* rt summary levels */
+       unsigned int            m_rsumlevels;   /* rt summary levels */
        xfs_filblks_t           m_rsumblocks;   /* size of rt summary, FSBs */
        uint32_t                m_rgblocks;     /* size of rtgroup in rtblocks */
        int                     m_fixedfsid[2]; /* unchanged for life of FS */
index 858013d6f5187d215816ad12af01c6e46ad06fc1..1fe12d22bc4c2b97699596539b2623fe323e7c28 100644 (file)
@@ -751,9 +751,7 @@ xfs_growfs_rt_alloc_fake_mount(
        nmp->m_sb.sb_rextents = xfs_rtb_to_rtx(nmp, nmp->m_sb.sb_rblocks);
        nmp->m_sb.sb_rbmblocks = xfs_rtbitmap_blockcount(nmp);
        nmp->m_sb.sb_rextslog = xfs_compute_rextslog(nmp->m_sb.sb_rextents);
-       nmp->m_rsumlevels = nmp->m_sb.sb_rextslog + 1;
-       nmp->m_rsumblocks = xfs_rtsummary_blockcount(nmp, nmp->m_rsumlevels,
-                       nmp->m_sb.sb_rbmblocks);
+       nmp->m_rsumblocks = xfs_rtsummary_blockcount(nmp, &nmp->m_rsumlevels);
 
        if (rblocks > 0)
                nmp->m_features |= XFS_FEAT_REALTIME;
@@ -1138,21 +1136,18 @@ xfs_rtmount_init(
        struct xfs_mount        *mp)    /* file system mount structure */
 {
        struct xfs_buf          *bp;    /* buffer for last block of subvolume */
-       struct xfs_sb           *sbp;   /* filesystem superblock copy in mount */
        xfs_daddr_t             d;      /* address of last block of subvolume */
        int                     error;
 
-       sbp = &mp->m_sb;
-       if (sbp->sb_rblocks == 0)
+       if (mp->m_sb.sb_rblocks == 0)
                return 0;
        if (mp->m_rtdev_targp == NULL) {
                xfs_warn(mp,
        "Filesystem has a realtime volume, use rtdev=device option");
                return -ENODEV;
        }
-       mp->m_rsumlevels = sbp->sb_rextslog + 1;
-       mp->m_rsumblocks = xfs_rtsummary_blockcount(mp, mp->m_rsumlevels,
-                       mp->m_sb.sb_rbmblocks);
+
+       mp->m_rsumblocks = xfs_rtsummary_blockcount(mp, &mp->m_rsumlevels);
 
        /*
         * Check that the realtime section is an ok size.