public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: sandeen@sandeen.net
Cc: Catherine Hoang <catherine.hoang@oracle.com>, linux-xfs@vger.kernel.org
Subject: [PATCH 6/4] mkfs: round log size down if rounding log start up causes overflow
Date: Fri, 15 Apr 2022 16:57:58 -0700	[thread overview]
Message-ID: <20220415235758.GE17025@magnolia> (raw)
In-Reply-To: <164996213753.226891.14458233911347178679.stgit@magnolia>

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.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 mkfs/xfs_mkfs.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index b932acaa..cfa38f17 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3219,9 +3219,19 @@ align_internal_log(
 	int			max_logblocks)
 {
 	/* round up log start if necessary */
-	if ((cfg->logstart % sunit) != 0)
+	if ((cfg->logstart % sunit) != 0) {
 		cfg->logstart = ((cfg->logstart + (sunit - 1)) / sunit) * sunit;
 
+		/*
+		 * If rounding up logstart to a stripe boundary moves the end
+		 * of the log past the end of the AG, reduce logblocks to get
+		 * it back under EOAG.
+		 */
+		if (!libxfs_verify_fsbext(mp, cfg->logstart, cfg->logblocks) &&
+		    cfg->logblocks > sunit)
+			cfg->logblocks -= sunit;
+	}
+
 	/* If our log start overlaps the next AG's metadata, fail. */
 	if (!libxfs_verify_fsbno(mp, cfg->logstart)) {
 		fprintf(stderr,

  parent reply	other threads:[~2022-04-15 23:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-14 18:48 [PATCHSET 0/4] mkfs: various bug fixes Darrick J. Wong
2022-04-14 18:49 ` [PATCH 1/4] mkfs: fix missing validation of -l size against maximum internal log size Darrick J. Wong
2022-04-24  5:41   ` Christoph Hellwig
2022-04-14 18:49 ` [PATCH 2/4] mkfs: reduce internal log size when log stripe units are in play Darrick J. Wong
2022-04-24  5:41   ` Christoph Hellwig
2022-04-14 18:49 ` [PATCH 3/4] mkfs: don't let internal logs bump the root dir inode chunk to AG 1 Darrick J. Wong
2022-04-24  5:42   ` Christoph Hellwig
2022-04-14 18:49 ` [PATCH 4/4] mkfs: don't trample the gid set in the protofile Darrick J. Wong
2022-04-15 16:43   ` Catherine Hoang
2022-04-24  5:43   ` Christoph Hellwig
2022-04-15 23:57 ` [PATCH 5/4] mkfs: improve log extent validation Darrick J. Wong
2022-04-24  5:43   ` Christoph Hellwig
2022-04-15 23:57 ` Darrick J. Wong [this message]
2022-04-20 17:27   ` [PATCH 6/4] mkfs: round log size down if rounding log start up causes overflow Darrick J. Wong
2022-04-20 17:29 ` [PATCH v1.1 " Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220415235758.GE17025@magnolia \
    --to=djwong@kernel.org \
    --cc=catherine.hoang@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox