Skip to content

Commit 9154b50

Browse files
Christoph HellwigDarrick J. Wong
authored andcommitted
xfs: factor out a xfs_growfs_rt_alloc_blocks helper
Split out a helper to allocate or grow the rtbitmap and rtsummary files in preparation of per-RT group bitmap and summary files. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent cd8d049 commit 9154b50

File tree

1 file changed

+39
-17
lines changed

1 file changed

+39
-17
lines changed

fs/xfs/xfs_rtalloc.c

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,43 @@ xfs_last_rt_bmblock(
875875
return bmbno;
876876
}
877877

878+
/*
879+
* Allocate space to the bitmap and summary files, as necessary.
880+
*/
881+
static int
882+
xfs_growfs_rt_alloc_blocks(
883+
struct xfs_mount *mp,
884+
xfs_rfsblock_t nrblocks,
885+
xfs_agblock_t rextsize,
886+
xfs_extlen_t *nrbmblocks)
887+
{
888+
struct xfs_inode *rbmip = mp->m_rbmip;
889+
struct xfs_inode *rsumip = mp->m_rsumip;
890+
xfs_rtxnum_t nrextents = div_u64(nrblocks, rextsize);
891+
xfs_extlen_t orbmblocks;
892+
xfs_extlen_t orsumblocks;
893+
xfs_extlen_t nrsumblocks;
894+
int error;
895+
896+
/*
897+
* Get the old block counts for bitmap and summary inodes.
898+
* These can't change since other growfs callers are locked out.
899+
*/
900+
orbmblocks = XFS_B_TO_FSB(mp, rbmip->i_disk_size);
901+
orsumblocks = XFS_B_TO_FSB(mp, rsumip->i_disk_size);
902+
903+
*nrbmblocks = xfs_rtbitmap_blockcount(mp, nrextents);
904+
nrsumblocks = xfs_rtsummary_blockcount(mp,
905+
xfs_compute_rextslog(nrextents) + 1, *nrbmblocks);
906+
907+
error = xfs_rtfile_initialize_blocks(rbmip, orbmblocks,
908+
*nrbmblocks, NULL);
909+
if (error)
910+
return error;
911+
return xfs_rtfile_initialize_blocks(rsumip, orsumblocks,
912+
nrsumblocks, NULL);
913+
}
914+
878915
/*
879916
* Grow the realtime area of the filesystem.
880917
*/
@@ -889,8 +926,6 @@ xfs_growfs_rt(
889926
xfs_extlen_t nrbmblocks; /* new number of rt bitmap blocks */
890927
xfs_rtxnum_t nrextents; /* new number of realtime extents */
891928
xfs_extlen_t nrsumblocks; /* new number of summary blocks */
892-
xfs_extlen_t rbmblocks; /* current number of rt bitmap blocks */
893-
xfs_extlen_t rsumblocks; /* current number of rt summary blks */
894929
uint8_t *rsum_cache; /* old summary cache */
895930
xfs_agblock_t old_rextsize = mp->m_sb.sb_rextsize;
896931

@@ -963,21 +998,8 @@ xfs_growfs_rt(
963998
goto out_unlock;
964999
}
9651000

966-
/*
967-
* Get the old block counts for bitmap and summary inodes.
968-
* These can't change since other growfs callers are locked out.
969-
*/
970-
rbmblocks = XFS_B_TO_FSB(mp, mp->m_rbmip->i_disk_size);
971-
rsumblocks = XFS_B_TO_FSB(mp, mp->m_rsumip->i_disk_size);
972-
/*
973-
* Allocate space to the bitmap and summary files, as necessary.
974-
*/
975-
error = xfs_rtfile_initialize_blocks(mp->m_rbmip, rbmblocks,
976-
nrbmblocks, NULL);
977-
if (error)
978-
goto out_unlock;
979-
error = xfs_rtfile_initialize_blocks(mp->m_rsumip, rsumblocks,
980-
nrsumblocks, NULL);
1001+
error = xfs_growfs_rt_alloc_blocks(mp, in->newblocks, in->extsize,
1002+
&nrbmblocks);
9811003
if (error)
9821004
goto out_unlock;
9831005

0 commit comments

Comments
 (0)