Linux XFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] mkfs: Emit a clearer message if too-small log is due to AG geometry
@ 2026-08-27  3:42 Eric Sandeen
  2026-08-27  3:49 ` [PATCH V2] " Eric Sandeen
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Sandeen @ 2026-08-27  3:42 UTC (permalink / raw)
  To: linux-xfs; +Cc: Eric Sandeen

There is a constraint in mkfs.xfs that logs must not be smaller than
64MiB. We can arrive at a too-small log without specifying its size,
though, if we specify so many AGs (or such small AGs) that a single
AG cannot hold the minimum-sized log. This leads to confusing output:

$ truncate --size=500m testfile
$ mkfs.xfs -dagcount=10 testfile
Log size must be at least 64MiB.
Usage: mkfs.xfs
...

because the user did not specify the log size at all! If this error
occurs due to the AG geometry specification, make that clear with a
better error message.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 mkfs/xfs_mkfs.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index a4864c37..0c72422c 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3456,8 +3456,25 @@ validate_supported(
 	 */
 	if (mp->m_sb.sb_logblocks <
 			XFS_MIN_REALISTIC_LOG_BLOCKS(mp->m_sb.sb_blocklog)) {
-		fprintf(stderr,
+		/*
+		 * An internal log must fit within a single allocation group.
+		 * If the user constrained the AG geometry but didn't ask for a
+		 * specific log size, the undersized log is a consequence of
+		 * allocation groups that are too small, not a log size the user
+		 * chose.  Point them at the real cause.
+		 */
+		if (!cli_opt_set(&lopts, L_SIZE) &&
+		    (cli_opt_set(&dopts, D_AGCOUNT) ||
+		     cli_opt_set(&dopts, D_AGSIZE))) {
+			fprintf(stderr,
+ _("Allocation group size (%lld MiB) is too small to hold the minimum 64MiB log.\n"
+   "Specify fewer or larger allocation groups, or use a larger data device.\n"),
+				((long long)mp->m_sb.sb_agblocks <<
+					mp->m_sb.sb_blocklog) >> 20);
+		} else {
+			fprintf(stderr,
  _("Log size must be at least 64MiB.\n"));
+		}
 		usage();
 	}
 
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-27 14:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-27  3:42 [PATCH] mkfs: Emit a clearer message if too-small log is due to AG geometry Eric Sandeen
2026-08-27  3:49 ` [PATCH V2] " Eric Sandeen
2026-08-27  5:01   ` Darrick J. Wong
2026-08-27 13:19     ` Eric Sandeen
2026-08-27 14:38       ` Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox