From 28eb00705530a78a408f1acd15aaccf3f8a79e6f Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Mon, 6 May 2002 17:19:32 +0000 Subject: [PATCH] Merge irix6.5f:irix:118221a Fix the way mkfs round downs the device when the last AG is maller than the minimum AG size. --- mkfs/xfs_mkfs.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index e6d711e48..b1801b32e 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -1395,13 +1395,14 @@ main(int argc, char **argv) } /* - * if user set the AG size, and if the last AG is too small, - * reduce the filesystem size and drop the blocks. + * If the last AG is too small, reduce the filesystem size + * and drop the blocks. */ - if (!daflag && - (dblocks % agsize < XFS_AG_MIN_BLOCKS(blocklog))) { - dblocks -= dblocks % agsize; + if ( dblocks % agsize != 0 && + (dblocks % agsize < XFS_AG_MIN_BLOCKS(blocklog))) { + dblocks = (xfs_drfsbno_t)((agcount - 1) * agsize); agcount--; + ASSERT(agcount != 0); } /* @@ -1411,14 +1412,17 @@ main(int argc, char **argv) if (!daflag && !dasize && (agsize > XFS_AG_BEST_BLOCKS(blocklog,dblocks))) { agsize = XFS_AG_BEST_BLOCKS(blocklog,dblocks); + agcount = dblocks / agsize + (dblocks % agsize != 0); /* * If the last AG is too small, reduce the filesystem size * and drop the blocks. */ - if (dblocks % agsize < XFS_AG_MIN_BLOCKS(blocklog)) { - dblocks -= dblocks % agsize; + if ( dblocks % agsize != 0 && + (dblocks % agsize < XFS_AG_MIN_BLOCKS(blocklog))) { + dblocks = (xfs_drfsbno_t)((agcount - 1) * agsize); + agcount--; + ASSERT(agcount != 0); } - agcount = dblocks / agsize + (dblocks % agsize != 0); } /* -- 2.47.2