diff mbox series

[5/6] mkfs: round log size down if rounding log start up causes overflow

Message ID 165176673695.248587.16584045364969444033.stgit@magnolia (mailing list archive)
State Accepted
Headers show
Series mkfs: various bug fixes | expand

Commit Message

Darrick J. Wong May 5, 2022, 4:05 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

If rounding the log start up to the next stripe unit would cause the log
to overrun the end of the AG, round the log size down by a stripe unit.
We already ensured that logblocks was small enough to fit inside the AG,
so the minor adjustment should suffice.

This can be reproduced with:
mkfs.xfs -dsu=44k,sw=1,size=300m,file,name=fsfile -m rmapbt=0
and:
mkfs.xfs -dsu=48k,sw=1,size=512m,file,name=fsfile -m rmapbt=0

Reported-by: Eric Sandeen <sandeen@sandeen.net>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 mkfs/xfs_mkfs.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Christoph Hellwig May 10, 2022, 12:55 p.m. UTC | #1
On Thu, May 05, 2022 at 09:05:36AM -0700, Darrick J. Wong wrote:
> +	/*
> +	 * If the end of the log has been rounded past the end of the AG,
> +	 * reduce logblocks by a stripe unit to try to get it back under EOAG.
> +	 */
> +	if (!libxfs_verify_fsbext(mp, cfg->logstart, cfg->logblocks) &&
> +	    cfg->logblocks > sunit) {
> +		cfg->logblocks -= sunit;
> +	}

The curly braces look a little out of place here, but otherwise this
looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index b932acaa..01d2e8ca 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3234,6 +3234,15 @@  _("Due to stripe alignment, the internal log start (%lld) cannot be aligned\n"
 	/* round up/down the log size now */
 	align_log_size(cfg, sunit, max_logblocks);
 
+	/*
+	 * If the end of the log has been rounded past the end of the AG,
+	 * reduce logblocks by a stripe unit to try to get it back under EOAG.
+	 */
+	if (!libxfs_verify_fsbext(mp, cfg->logstart, cfg->logblocks) &&
+	    cfg->logblocks > sunit) {
+		cfg->logblocks -= sunit;
+	}
+
 	/* check the aligned log still starts and ends in the same AG. */
 	if (!libxfs_verify_fsbext(mp, cfg->logstart, cfg->logblocks)) {
 		fprintf(stderr,