]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: replace m_rsumsize with m_rsumblocks
authorChristoph Hellwig <hch@lst.de>
Mon, 21 Oct 2024 00:10:44 +0000 (17:10 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 31 Oct 2024 22:45:03 +0000 (15:45 -0700)
Source kernel commit: 33912286cb1956920712aba8cb6f38e434824357

Track the RT summary file size in blocks, just like the RT bitmap
file.  While we have users of both units, blocks are used slightly
more often and this matches the bitmap file for consistency.

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>
db/check.c
include/xfs_mount.h
libxfs/init.c
libxfs/xfs_rtbitmap.c
libxfs/xfs_trans_resv.c
mkfs/proto.c
repair/dinode.c
repair/phase6.c
repair/rt.c

index 00ef3c1d4b508c4ac9b1790d5eb5b0e7715b3407..0e91fded0c423657a0149445680e6fa174490e22 100644 (file)
@@ -1958,7 +1958,7 @@ init(
 
                dbmap[c] = xcalloc(mp->m_sb.sb_rblocks, sizeof(**dbmap));
                inomap[c] = xcalloc(mp->m_sb.sb_rblocks, sizeof(**inomap));
-               words = mp->m_rsumsize >> XFS_WORDLOG;
+               words = XFS_FSB_TO_B(mp, mp->m_rsumblocks) >> XFS_WORDLOG;
                sumfile = xcalloc(words, sizeof(union xfs_suminfo_raw));
                sumcompute = xcalloc(words, sizeof(union xfs_suminfo_raw));
        }
index a60474a8db3f22036d377db29f9d52fa4d100c53..7571df12fba3f80082414b63fe2e1241c50df346 100644 (file)
@@ -50,7 +50,7 @@ typedef struct xfs_mount {
        xfs_agnumber_t          m_maxagi;       /* highest inode alloc group */
         struct xfs_ino_geometry        m_ino_geo;      /* inode geometry */
        uint                    m_rsumlevels;   /* rt summary levels */
-       uint                    m_rsumsize;     /* size of rt summary, bytes */
+       xfs_filblks_t           m_rsumblocks;   /* size of rt summary, FSBs */
        /*
         * Optional cache of rt summary level per bitmap block with the
         * invariant that m_rsum_cache[bbno] <= the minimum i for which
index 90a539e04161bbbdf82899426a9d985d7555c885..6ab5ef54bb69cb59df75cddddcf960dc30be8322 100644 (file)
@@ -293,7 +293,6 @@ 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)
@@ -319,9 +318,8 @@ rtmount_init(
                return -1;
        }
        mp->m_rsumlevels = mp->m_sb.sb_rextslog + 1;
-       rsumblocks = xfs_rtsummary_blockcount(mp, mp->m_rsumlevels,
+       mp->m_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 1c657da907132ea9e9757f7c47dcdfefaf520b8b..cff3030d1662b7ae69f40c02b4714aa8cb601818 100644 (file)
@@ -160,7 +160,7 @@ xfs_rtsummary_read_buf(
 {
        struct xfs_mount                *mp = args->mp;
 
-       if (XFS_IS_CORRUPT(mp, block >= XFS_B_TO_FSB(mp, mp->m_rsumsize))) {
+       if (XFS_IS_CORRUPT(mp, block >= mp->m_rsumblocks)) {
                xfs_rt_mark_sick(args->mp, XFS_SICK_RT_SUMMARY);
                return -EFSCORRUPTED;
        }
index 6b87bf4d554c6ac0c32efce9884793aefebd60a7..156f9578d281a04ae6544f0fbc29386152963c60 100644 (file)
@@ -915,7 +915,7 @@ xfs_calc_growrtfree_reservation(
        return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
                xfs_calc_inode_res(mp, 2) +
                xfs_calc_buf_res(1, mp->m_sb.sb_blocksize) +
-               xfs_calc_buf_res(1, mp->m_rsumsize);
+               xfs_calc_buf_res(1, XFS_FSB_TO_B(mp, mp->m_rsumblocks));
 }
 
 /*
index 42ac3e10929b5238b1f79c196d0d25f0150718e0..06010980c5b313d14411f56ea71ecf2ed6bc8d9d 100644 (file)
@@ -813,7 +813,7 @@ rtsummary_create(
 {
        struct xfs_mount        *mp = ip->i_mount;
 
-       ip->i_disk_size = mp->m_rsumsize;
+       ip->i_disk_size = mp->m_rsumblocks * mp->m_sb.sb_blocksize;
 
        mp->m_sb.sb_rsumino = ip->i_ino;
        mp->m_rsumip = ip;
@@ -874,25 +874,23 @@ rtsummary_init(
        struct xfs_trans        *tp;
        struct xfs_bmbt_irec    *ep;
        xfs_fileoff_t           bno;
-       xfs_extlen_t            nsumblocks;
        uint                    blocks;
        int                     i;
        int                     nmap;
        int                     error;
 
-       nsumblocks = mp->m_rsumsize >> mp->m_sb.sb_blocklog;
-       blocks = nsumblocks + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1;
+       blocks = mp->m_rsumblocks + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1;
        error = -libxfs_trans_alloc_rollable(mp, blocks, &tp);
        if (error)
                res_failed(error);
        libxfs_trans_ijoin(tp, mp->m_rsumip, 0);
 
        bno = 0;
-       while (bno < nsumblocks) {
+       while (bno < mp->m_rsumblocks) {
                nmap = XFS_BMAP_MAX_NMAP;
                error = -libxfs_bmapi_write(tp, mp->m_rsumip, bno,
-                               (xfs_extlen_t)(nsumblocks - bno),
-                               0, nsumblocks, map, &nmap);
+                               (xfs_extlen_t)(mp->m_rsumblocks - bno),
+                               0, mp->m_rsumblocks, map, &nmap);
                if (error)
                        fail(_("Allocation of the realtime summary failed"),
                                error);
index e36de9bf1a1be042fdd660f4ac29e50ddd5f6419..aae3cb7a40b9810beaf51fc0485afbbedd4f66fe 100644 (file)
@@ -1736,10 +1736,11 @@ _("realtime bitmap inode %" PRIu64 " has bad size %" PRId64 " (should be %" PRIu
                break;
 
        case XR_INO_RTSUM:
-               if (size != mp->m_rsumsize)  {
+               if (size != XFS_FSB_TO_B(mp, mp->m_rsumblocks))  {
                        do_warn(
-_("realtime summary inode %" PRIu64 " has bad size %" PRId64 " (should be %d)\n"),
-                               lino, size, mp->m_rsumsize);
+_("realtime summary inode %" PRIu64 " has bad size %" PRIu64 " (should be %" PRIu64 ")\n"),
+                               lino, size,
+                               XFS_FSB_TO_B(mp, mp->m_rsumblocks));
                        return 1;
                }
                break;
index b48f18b06a5c817e6370a35cd6c0bc7f10195d19..c96b50cf6a69ddc6febb47a9d7bdd822598bf657 100644 (file)
@@ -633,12 +633,10 @@ fill_rsumino(xfs_mount_t *mp)
        int             nmap;
        int             error;
        xfs_fileoff_t   bno;
-       xfs_fileoff_t   end_bno;
        xfs_bmbt_irec_t map;
 
        smp = sumcompute;
        bno = 0;
-       end_bno = mp->m_rsumsize >> mp->m_sb.sb_blocklog;
 
        error = -libxfs_trans_alloc_rollable(mp, 10, &tp);
        if (error)
@@ -651,7 +649,7 @@ fill_rsumino(xfs_mount_t *mp)
                        error);
        }
 
-       while (bno < end_bno)  {
+       while (bno < mp->m_rsumblocks)  {
                struct xfs_rtalloc_args args = {
                        .mp             = mp,
                        .tp             = tp,
@@ -711,7 +709,6 @@ mk_rsumino(xfs_mount_t *mp)
        int             i;
        int             nmap;
        int             error;
-       int             nsumblocks;
        xfs_fileoff_t   bno;
        xfs_bmbt_irec_t map[XFS_BMAP_MAX_NMAP];
        uint            blocks;
@@ -732,7 +729,7 @@ mk_rsumino(xfs_mount_t *mp)
 
        /* Reset the rt summary inode. */
        reset_sbroot_ino(tp, S_IFREG, ip);
-       ip->i_disk_size = mp->m_rsumsize;
+       ip->i_disk_size = mp->m_rsumblocks * mp->m_sb.sb_blocksize;
        libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
        error = -libxfs_trans_commit(tp);
        if (error)
@@ -742,19 +739,18 @@ mk_rsumino(xfs_mount_t *mp)
         * then allocate blocks for file and fill with zeroes (stolen
         * from mkfs)
         */
-       nsumblocks = mp->m_rsumsize >> mp->m_sb.sb_blocklog;
-       blocks = nsumblocks + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1;
+       blocks = mp->m_rsumblocks + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1;
        error = -libxfs_trans_alloc_rollable(mp, blocks, &tp);
        if (error)
                res_failed(error);
 
        libxfs_trans_ijoin(tp, ip, 0);
        bno = 0;
-       while (bno < nsumblocks) {
+       while (bno < mp->m_rsumblocks) {
                nmap = XFS_BMAP_MAX_NMAP;
                error = -libxfs_bmapi_write(tp, ip, bno,
-                         (xfs_extlen_t)(nsumblocks - bno),
-                         0, nsumblocks, map, &nmap);
+                         (xfs_extlen_t)(mp->m_rsumblocks - bno),
+                         0, mp->m_rsumblocks, map, &nmap);
                if (error) {
                        do_error(
                _("couldn't allocate realtime summary inode, error = %d\n"),
index 879946ab0b154e0a4f0a0f02cb7b71a560b08dc4..721c363cc1dd10a6fc92bb3c43ec71c715683a90 100644 (file)
@@ -33,7 +33,7 @@ rtinit(xfs_mount_t *mp)
                do_error(
        _("couldn't allocate memory for incore realtime bitmap.\n"));
 
-       wordcnt = mp->m_rsumsize >> XFS_WORDLOG;
+       wordcnt = XFS_FSB_TO_B(mp, mp->m_rsumblocks) >> XFS_WORDLOG;
        sumcompute = calloc(wordcnt, sizeof(union xfs_suminfo_raw));
        if (!sumcompute)
                do_error(
@@ -228,5 +228,5 @@ check_rtsummary(
                return;
 
        check_rtfile_contents(mp, "rtsummary", mp->m_sb.sb_rsumino, sumcompute,
-                       XFS_B_TO_FSB(mp, mp->m_rsumsize));
+                       mp->m_rsumblocks);
 }