]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: use xfs_growfs_rt_alloc_fake_mount in xfs_growfs_rt_alloc_blocks
authorChristoph Hellwig <hch@lst.de>
Fri, 2 Aug 2024 03:50:41 +0000 (05:50 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 6 Aug 2024 13:05:12 +0000 (06:05 -0700)
Use xfs_growfs_rt_alloc_fake_mount instead of manually recalculating
the RT bitmap geometry.

Signed-off-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_rtalloc.c

index d4dc66e9e200147764da0613a9052672308a7be5..7085bba8c006b27291905b51435f0d8f8c409ddf 100644 (file)
@@ -899,10 +899,10 @@ xfs_growfs_rt_alloc_blocks(
        struct xfs_mount        *mp = rtg->rtg_mount;
        struct xfs_inode        *rbmip = rtg->rtg_inodes[XFS_RTG_BITMAP];
        struct xfs_inode        *rsumip = rtg->rtg_inodes[XFS_RTG_SUMMARY];
-       xfs_rtxnum_t            nrextents = div_u64(nrblocks, rextsize);
        xfs_extlen_t            orbmblocks;
        xfs_extlen_t            orsumblocks;
        xfs_extlen_t            nrsumblocks;
+       struct xfs_mount        *nmp;
        int                     error;
 
        /*
@@ -912,9 +912,13 @@ xfs_growfs_rt_alloc_blocks(
        orbmblocks = XFS_B_TO_FSB(mp, rbmip->i_disk_size);
        orsumblocks = XFS_B_TO_FSB(mp, rsumip->i_disk_size);
 
-       *nrbmblocks = xfs_rtbitmap_blockcount(mp, nrextents);
-       nrsumblocks = xfs_rtsummary_blockcount(mp,
-               xfs_compute_rextslog(nrextents) + 1, *nrbmblocks);
+       nmp = xfs_growfs_rt_alloc_fake_mount(mp, nrblocks, rextsize);
+       if (!nmp)
+               return -ENOMEM;
+
+       *nrbmblocks = nmp->m_sb.sb_rbmblocks;
+       nrsumblocks = nmp->m_rsumblocks;
+       kfree(nmp);
 
        error = xfs_rtfile_initialize_blocks(rtg, XFS_RTG_BITMAP, orbmblocks,
                        *nrbmblocks, NULL);