]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_{db,repair}: use helpers for rtsummary block/wordcount computations
authorDarrick J. Wong <djwong@kernel.org>
Mon, 15 Apr 2024 23:07:30 +0000 (16:07 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 17 Apr 2024 21:06:23 +0000 (14:06 -0700)
Port xfs_db and xfs_repair to use the new 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>
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
db/check.c
libxfs/init.c
libxfs/libxfs_api_defs.h
repair/rt.c

index 3b3f90e5e0c9219eee545b587596b779b9165db4..6e916f335b14cee3df4bab6bc15cc294bba0362f 100644 (file)
@@ -1944,10 +1944,14 @@ init(
                inodata[c] = xcalloc(inodata_hash_size, sizeof(**inodata));
        }
        if (rt) {
+               unsigned long long      words;
+
                dbmap[c] = xcalloc(mp->m_sb.sb_rblocks, sizeof(**dbmap));
                inomap[c] = xcalloc(mp->m_sb.sb_rblocks, sizeof(**inomap));
-               sumfile = xcalloc(mp->m_rsumsize, 1);
-               sumcompute = xcalloc(mp->m_rsumsize, 1);
+               words = libxfs_rtsummary_wordcount(mp, mp->m_rsumlevels,
+                               mp->m_sb.sb_rbmblocks);
+               sumfile = xcalloc(words, sizeof(xfs_suminfo_t));
+               sumcompute = xcalloc(words, sizeof(xfs_suminfo_t));
        }
        nflag = sflag = tflag = verbose = optind = 0;
        while ((c = getopt(argc, argv, "b:i:npstv")) != EOF) {
index 63c506a69964166b8c827c621d28fa2bcd4bcc5f..c903d60707b76dcdc09a7b0c195066c24dcbc867 100644 (file)
@@ -284,6 +284,7 @@ rtmount_init(
 {
        struct xfs_buf  *bp;    /* buffer for last block of subvolume */
        xfs_daddr_t     d;      /* address of last block of subvolume */
+       unsigned int    rsumblocks;
        int             error;
 
        if (mp->m_sb.sb_rblocks == 0)
@@ -309,10 +310,9 @@ rtmount_init(
                return -1;
        }
        mp->m_rsumlevels = mp->m_sb.sb_rextslog + 1;
-       mp->m_rsumsize =
-               (uint)sizeof(xfs_suminfo_t) * mp->m_rsumlevels *
-               mp->m_sb.sb_rbmblocks;
-       mp->m_rsumsize = roundup(mp->m_rsumsize, mp->m_sb.sb_blocksize);
+       rsumblocks = xfs_rtsummary_blockcount(mp, mp->m_rsumlevels,
+                       mp->m_sb.sb_rbmblocks);
+       mp->m_rsumsize = XFS_FSB_TO_B(mp, rsumblocks);
        mp->m_rbmip = mp->m_rsumip = NULL;
 
        /*
index feecc05c4ecc20901402b9b053034dd76856d092..e87195cb1ac9c72488010a83988a4ea0b3e42d3d 100644 (file)
 #define xfs_rtbitmap_setword           libxfs_rtbitmap_setword
 #define xfs_rtbitmap_wordcount         libxfs_rtbitmap_wordcount
 
+#define xfs_rtsummary_wordcount                libxfs_rtsummary_wordcount
+
 #define xfs_rtfree_extent              libxfs_rtfree_extent
 #define xfs_rtfree_blocks              libxfs_rtfree_blocks
 #define xfs_sb_from_disk               libxfs_sb_from_disk
index 213f0812250e2203e3b3bb37cc1aeb10c95285cc..6ab709a000cb565206ac47c266d97a031f329624 100644 (file)
@@ -34,7 +34,10 @@ rtinit(xfs_mount_t *mp)
                do_error(
        _("couldn't allocate memory for incore realtime bitmap.\n"));
 
-       if ((sumcompute = calloc(mp->m_rsumsize, 1)) == NULL)
+       wordcnt = libxfs_rtsummary_wordcount(mp, mp->m_rsumlevels,
+                       mp->m_sb.sb_rbmblocks);
+       sumcompute = calloc(wordcnt, sizeof(xfs_suminfo_t));
+       if (!sumcompute)
                do_error(
        _("couldn't allocate memory for incore realtime summary info.\n"));
 }