]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_{db,repair}: use m_blockwsize instead of sb_blocksize for rt blocks
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)
In preparation to add block headers to rt bitmap and summary blocks,
convert all the relevant calculations in the userspace tools to use the
per-block word count instead of the raw blocksize.  This is key to
adding this support outside of libxfs.

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
repair/phase6.c
repair/rt.c

index 103ea4022c3b3bb37ad8df6263c64f3ea83c0bc9..2f2fbc7cbd818972b7a7affb093e87af17108097 100644 (file)
@@ -3630,7 +3630,7 @@ process_rtbitmap(
        int             t;
        xfs_rtword_t    *words;
 
-       bitsperblock = mp->m_sb.sb_blocksize * NBBY;
+       bitsperblock = mp->m_blockwsize << XFS_NBWORDLOG;
        words = malloc(mp->m_blockwsize << XFS_WORDLOG);
        if (!words) {
                dbprintf(_("could not allocate rtwords buffer\n"));
@@ -3749,7 +3749,7 @@ process_rtsummary(
 
                args.sumbp = iocur_top->bp;
                ondisk = xfs_rsumblock_infoptr(&args, 0);
-               memcpy(sfile, ondisk, mp->m_sb.sb_blocksize);
+               memcpy(sfile, ondisk, mp->m_blockwsize << XFS_WORDLOG);
                pop_cur();
                sfile += mp->m_blockwsize;
        }
index 0818ee1a1501adcccc18ddcca823e8cbd8b32319..fcb26d594b108df373245de91bf615d985e8e29d 100644 (file)
@@ -626,7 +626,7 @@ _("can't access block %" PRIu64 " (fsbno %" PRIu64 ") of realtime bitmap inode %
 
                args.rbmbp = bp;
                ondisk = xfs_rbmblock_wordptr(&args, 0);
-               memcpy(ondisk, bmp, mp->m_sb.sb_blocksize);
+               memcpy(ondisk, bmp, mp->m_blockwsize << XFS_WORDLOG);
 
                libxfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1);
 
@@ -705,7 +705,7 @@ _("can't access block %" PRIu64 " (fsbno %" PRIu64 ") of realtime summary inode
 
                args.sumbp = bp;
                ondisk = xfs_rsumblock_infoptr(&args, 0);
-               memcpy(ondisk, smp, mp->m_sb.sb_blocksize);
+               memcpy(ondisk, smp, mp->m_blockwsize << XFS_WORDLOG);
 
                libxfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1);
 
index 9aff5a0d3d58e57545e6f7a5c6bf95efaf2db8d5..e49487829af22696f34ca239d8cf56e7b1a98d7f 100644 (file)
@@ -25,8 +25,9 @@ rtinit(xfs_mount_t *mp)
                return;
 
        /*
-        * realtime init -- blockmap initialization is
-        * handled by incore_init()
+        * Allocate buffers for formatting the collected rt free space
+        * information.  The rtbitmap buffer must be large enough to compare
+        * against any unused bytes in the last block of the file.
         */
        wordcnt = libxfs_rtbitmap_wordcount(mp, mp->m_sb.sb_rextents);
        btmcompute = calloc(wordcnt, sizeof(union xfs_rtword_raw));
@@ -87,7 +88,7 @@ generate_rtinfo(
 
        ASSERT(mp->m_rbmip == NULL);
 
-       bitsperblock = mp->m_sb.sb_blocksize * NBBY;
+       bitsperblock = mp->m_blockwsize << XFS_NBWORDLOG;
        extno = start_ext = 0;
        bmbno = in_extent = start_bmbno = 0;
 
@@ -199,7 +200,7 @@ check_rtfile_contents(
                        break;
                }
 
-               if (memcmp(bp->b_addr, buf, mp->m_sb.sb_blocksize))
+               if (memcmp(bp->b_addr, buf, mp->m_blockwsize << XFS_WORDLOG))
                        do_warn(_("discrepancy in %s at dblock 0x%llx\n"),
                                        filename, (unsigned long long)bno);