mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-08 14:02:37 -04:00
xfs: factor out a xfs_growfs_check_rtgeom helper
Split the check that the rtsummary fits into the log into a separate helper, and use xfs_growfs_rt_alloc_fake_mount to calculate the new RT geometry. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> [djwong: avoid division for the 0-rtx growfs check] Signed-off-by: Darrick J. Wong <djwong@kernel.org>
This commit is contained in:
committed by
Darrick J. Wong
parent
fc233f1fb0
commit
bde86b42d2
@@ -1023,6 +1023,31 @@ xfs_growfs_rtg(
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
xfs_growfs_check_rtgeom(
|
||||
const struct xfs_mount *mp,
|
||||
xfs_rfsblock_t rblocks,
|
||||
xfs_extlen_t rextsize)
|
||||
{
|
||||
struct xfs_mount *nmp;
|
||||
int error = 0;
|
||||
|
||||
nmp = xfs_growfs_rt_alloc_fake_mount(mp, rblocks, rextsize);
|
||||
if (!nmp)
|
||||
return -ENOMEM;
|
||||
|
||||
/*
|
||||
* New summary size can't be more than half the size of the log. This
|
||||
* prevents us from getting a log overflow, since we'll log basically
|
||||
* the whole summary file at once.
|
||||
*/
|
||||
if (nmp->m_rsumblocks > (mp->m_sb.sb_logblocks >> 1))
|
||||
error = -EINVAL;
|
||||
|
||||
kfree(nmp);
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Grow the realtime area of the filesystem.
|
||||
*/
|
||||
@@ -1031,9 +1056,6 @@ xfs_growfs_rt(
|
||||
xfs_mount_t *mp, /* mount point for filesystem */
|
||||
xfs_growfs_rt_t *in) /* growfs rt input struct */
|
||||
{
|
||||
xfs_rtxnum_t nrextents;
|
||||
xfs_extlen_t nrbmblocks;
|
||||
xfs_extlen_t nrsumblocks;
|
||||
struct xfs_buf *bp;
|
||||
xfs_agblock_t old_rextsize = mp->m_sb.sb_rextsize;
|
||||
int error;
|
||||
@@ -1082,20 +1104,13 @@ xfs_growfs_rt(
|
||||
/*
|
||||
* Calculate new parameters. These are the final values to be reached.
|
||||
*/
|
||||
nrextents = div_u64(in->newblocks, in->extsize);
|
||||
error = -EINVAL;
|
||||
if (nrextents == 0)
|
||||
if (in->newblocks < in->extsize)
|
||||
goto out_unlock;
|
||||
nrbmblocks = xfs_rtbitmap_blockcount(mp, nrextents);
|
||||
nrsumblocks = xfs_rtsummary_blockcount(mp,
|
||||
xfs_compute_rextslog(nrextents) + 1, nrbmblocks);
|
||||
|
||||
/*
|
||||
* New summary size can't be more than half the size of
|
||||
* the log. This prevents us from getting a log overflow,
|
||||
* since we'll log basically the whole summary file at once.
|
||||
*/
|
||||
if (nrsumblocks > (mp->m_sb.sb_logblocks >> 1))
|
||||
/* Make sure the new fs size won't cause problems with the log. */
|
||||
error = xfs_growfs_check_rtgeom(mp, in->newblocks, in->extsize);
|
||||
if (error)
|
||||
goto out_unlock;
|
||||
|
||||
error = xfs_growfs_rtg(mp, in->newblocks, in->extsize);
|
||||
|
||||
Reference in New Issue
Block a user