Skip to content

Commit fc233f1

Browse files
Christoph HellwigDarrick J. Wong
authored andcommitted
xfs: use xfs_growfs_rt_alloc_fake_mount in xfs_growfs_rt_alloc_blocks
Use xfs_growfs_rt_alloc_fake_mount instead of manually recalculating the RT bitmap geometry. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 1029f08 commit fc233f1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

fs/xfs/xfs_rtalloc.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -935,10 +935,10 @@ xfs_growfs_rt_alloc_blocks(
935935
struct xfs_mount *mp = rtg_mount(rtg);
936936
struct xfs_inode *rbmip = rtg->rtg_inodes[XFS_RTGI_BITMAP];
937937
struct xfs_inode *rsumip = rtg->rtg_inodes[XFS_RTGI_SUMMARY];
938-
xfs_rtxnum_t nrextents = div_u64(nrblocks, rextsize);
939938
xfs_extlen_t orbmblocks;
940939
xfs_extlen_t orsumblocks;
941940
xfs_extlen_t nrsumblocks;
941+
struct xfs_mount *nmp;
942942
int error;
943943

944944
/*
@@ -948,9 +948,13 @@ xfs_growfs_rt_alloc_blocks(
948948
orbmblocks = XFS_B_TO_FSB(mp, rbmip->i_disk_size);
949949
orsumblocks = XFS_B_TO_FSB(mp, rsumip->i_disk_size);
950950

951-
*nrbmblocks = xfs_rtbitmap_blockcount(mp, nrextents);
952-
nrsumblocks = xfs_rtsummary_blockcount(mp,
953-
xfs_compute_rextslog(nrextents) + 1, *nrbmblocks);
951+
nmp = xfs_growfs_rt_alloc_fake_mount(mp, nrblocks, rextsize);
952+
if (!nmp)
953+
return -ENOMEM;
954+
955+
*nrbmblocks = nmp->m_sb.sb_rbmblocks;
956+
nrsumblocks = nmp->m_rsumblocks;
957+
kfree(nmp);
954958

955959
error = xfs_rtfile_initialize_blocks(rtg, XFS_RTGI_BITMAP, orbmblocks,
956960
*nrbmblocks, NULL);

0 commit comments

Comments
 (0)