Commit 0925fecc authored by Darrick J. Wong's avatar Darrick J. Wong

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: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 0e2af929
...@@ -1021,7 +1021,8 @@ xfs_growfs_rt( ...@@ -1021,7 +1021,8 @@ xfs_growfs_rt(
((sbp->sb_rextents & ((1 << mp->m_blkbit_log) - 1)) != 0); ((sbp->sb_rextents & ((1 << mp->m_blkbit_log) - 1)) != 0);
bmbno < nrbmblocks; bmbno < nrbmblocks;
bmbno++) { bmbno++) {
xfs_trans_t *tp; struct xfs_trans *tp;
xfs_rfsblock_t nrblocks_step;
*nmp = *mp; *nmp = *mp;
nsbp = &nmp->m_sb; nsbp = &nmp->m_sb;
...@@ -1030,10 +1031,9 @@ xfs_growfs_rt( ...@@ -1030,10 +1031,9 @@ xfs_growfs_rt(
*/ */
nsbp->sb_rextsize = in->extsize; nsbp->sb_rextsize = in->extsize;
nsbp->sb_rbmblocks = bmbno + 1; nsbp->sb_rbmblocks = bmbno + 1;
nsbp->sb_rblocks = nrblocks_step = (bmbno + 1) * NBBY * nsbp->sb_blocksize *
XFS_RTMIN(nrblocks, nsbp->sb_rextsize;
nsbp->sb_rbmblocks * NBBY * nsbp->sb_rblocks = min(nrblocks, nrblocks_step);
nsbp->sb_blocksize * nsbp->sb_rextsize);
nsbp->sb_rextents = nsbp->sb_rblocks; nsbp->sb_rextents = nsbp->sb_rblocks;
do_div(nsbp->sb_rextents, nsbp->sb_rextsize); do_div(nsbp->sb_rextents, nsbp->sb_rextsize);
ASSERT(nsbp->sb_rextents != 0); ASSERT(nsbp->sb_rextents != 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment