Commit 0e2af929 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: improve FSGROWFSRT precondition checking

Improve the checking at the start of a realtime grow operation so that
we avoid accidentally set a new extent size that is too large and avoid
adding an rt volume to a filesystem with rmap or reflink because we
don't support rt rmap or reflink yet.

While we're at it, separate the checks so that we're only testing one
aspect at a time.
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 5aa5b278
...@@ -923,16 +923,41 @@ xfs_growfs_rt( ...@@ -923,16 +923,41 @@ xfs_growfs_rt(
uint8_t *rsum_cache; /* old summary cache */ uint8_t *rsum_cache; /* old summary cache */
sbp = &mp->m_sb; sbp = &mp->m_sb;
/*
* Initial error checking.
*/
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
if (mp->m_rtdev_targp == NULL || mp->m_rbmip == NULL ||
(nrblocks = in->newblocks) <= sbp->sb_rblocks || /* Needs to have been mounted with an rt device. */
(sbp->sb_rblocks && (in->extsize != sbp->sb_rextsize))) if (!XFS_IS_REALTIME_MOUNT(mp))
return -EINVAL;
/*
* Mount should fail if the rt bitmap/summary files don't load, but
* we'll check anyway.
*/
if (!mp->m_rbmip || !mp->m_rsumip)
return -EINVAL;
/* Shrink not supported. */
if (in->newblocks <= sbp->sb_rblocks)
return -EINVAL;
/* Can only change rt extent size when adding rt volume. */
if (sbp->sb_rblocks > 0 && in->extsize != sbp->sb_rextsize)
return -EINVAL;
/* Range check the extent size. */
if (XFS_FSB_TO_B(mp, in->extsize) > XFS_MAX_RTEXTSIZE ||
XFS_FSB_TO_B(mp, in->extsize) < XFS_MIN_RTEXTSIZE)
return -EINVAL; return -EINVAL;
if ((error = xfs_sb_validate_fsb_count(sbp, nrblocks)))
/* Unsupported realtime features. */
if (xfs_sb_version_hasrmapbt(&mp->m_sb) ||
xfs_sb_version_hasreflink(&mp->m_sb))
return -EOPNOTSUPP;
nrblocks = in->newblocks;
error = xfs_sb_validate_fsb_count(sbp, nrblocks);
if (error)
return error; return error;
/* /*
* Read in the last block of the device, make sure it exists. * Read in the last block of the device, make sure it exists.
......
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