Skip to content

Commit 0925fec

Browse files
author
Darrick J. Wong
committed
xfs: fix an integer overflow error in xfs_growfs_rt
During a realtime grow operation, we run a single transaction for each rt bitmap block added to the filesystem. This means that each step has to be careful to increase sb_rblocks appropriately. Fix the integer overflow error in this calculation that can happen when the extent size is very large. Found by running growfs to add a rt volume to a filesystem formatted with a 1g rt extent size. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 0e2af92 commit 0925fec

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fs/xfs/xfs_rtalloc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,8 @@ xfs_growfs_rt(
10211021
((sbp->sb_rextents & ((1 << mp->m_blkbit_log) - 1)) != 0);
10221022
bmbno < nrbmblocks;
10231023
bmbno++) {
1024-
xfs_trans_t *tp;
1024+
struct xfs_trans *tp;
1025+
xfs_rfsblock_t nrblocks_step;
10251026

10261027
*nmp = *mp;
10271028
nsbp = &nmp->m_sb;
@@ -1030,10 +1031,9 @@ xfs_growfs_rt(
10301031
*/
10311032
nsbp->sb_rextsize = in->extsize;
10321033
nsbp->sb_rbmblocks = bmbno + 1;
1033-
nsbp->sb_rblocks =
1034-
XFS_RTMIN(nrblocks,
1035-
nsbp->sb_rbmblocks * NBBY *
1036-
nsbp->sb_blocksize * nsbp->sb_rextsize);
1034+
nrblocks_step = (bmbno + 1) * NBBY * nsbp->sb_blocksize *
1035+
nsbp->sb_rextsize;
1036+
nsbp->sb_rblocks = min(nrblocks, nrblocks_step);
10371037
nsbp->sb_rextents = nsbp->sb_rblocks;
10381038
do_div(nsbp->sb_rextents, nsbp->sb_rextsize);
10391039
ASSERT(nsbp->sb_rextents != 0);

0 commit comments

Comments
 (0)