Skip to contentSkip to conversation

improve a few messages in mkfs and xfs_copy

PATCH New Christoph Hellwig 2 participants 5 messages Oct 22, 2025

lore
Share & tools
lore
#0 lore raw

Hi all,

these patches have been in my stash for a while and improve messages that confused me when I ran into them to be a bit more useful.

#1 lore raw

PATCH 1/3 xfs_copy: improve the error message when mkfs is in progress

Indicate the correct reason for the failure instead of the same message as for the generic error condition just above.

---
 copy/xfs_copy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
copy/xfs_copy.c +1 -1
index 07957e007812..3ba9a07e4469 100644
@@ -759,7 +759,7 @@ main(int argc, char **argv)
 			"%s: Aborting.\n"), progname, source_name, progname);
 		exit(1);
 	} else if (mp->m_sb.sb_inprogress)  {
-		do_log(_("%s %s filesystem failed to initialize\n"
+		do_log(_("%s mkfs for %s filesystem still in progress\n"
 			"%s: Aborting.\n"), progname, source_name, progname);
 		exit(1);
 	} else if (mp->m_sb.sb_logstart == 0)  {
Signature · 1 line
2.47.3
#2 lore raw

PATCH 2/3 mkfs: improve the error message from check_device_type

In reply to Christoph Hellwig

Tell the user what device is missing.

---
 mkfs/xfs_mkfs.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
mkfs/xfs_mkfs.c +8 -4
index bc6a28b63c24..e66f71b903eb 100644
@@ -1333,6 +1333,7 @@ check_device_type(
 	struct libxfs_dev	*dev,
 	bool			no_size,
 	bool			dry_run,
+	const char		*device_type,
 	const char		*optname)
 {
 	struct stat statbuf;
@@ -1345,7 +1346,8 @@ check_device_type(
 	}
 
 	if (!dev->name) {
-		fprintf(stderr, _("No device name specified\n"));
+		fprintf(stderr, _("No %s device name specified\n"),
+				device_type);
 		usage();
 	}
 
@@ -2376,11 +2378,13 @@ validate_sectorsize(
 	 * Before anything else, verify that we are correctly operating on
 	 * files or block devices and set the control parameters correctly.
 	 */
-	check_device_type(&cli->xi->data, !cli->dsize, dry_run, "d");
+	check_device_type(&cli->xi->data, !cli->dsize, dry_run, "data", "d");
 	if (!cli->loginternal)
-		check_device_type(&cli->xi->log, !cli->logsize, dry_run, "l");
+		check_device_type(&cli->xi->log, !cli->logsize, dry_run, "log",
+				"l");
 	if (cli->xi->rt.name)
-		check_device_type(&cli->xi->rt, !cli->rtsize, dry_run, "r");
+		check_device_type(&cli->xi->rt, !cli->rtsize, dry_run, "RT",
+				"r");
 
 	/*
 	 * Explicitly disable direct IO for image files so we don't error out on
Signature · 1 line
2.47.3
#3 lore raw

PATCH 3/3 mkfs: improve the error message in adjust_nr_zones

In reply to Christoph Hellwig

Print the zone counts to help the user to understand the problem.

---
 mkfs/xfs_mkfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mkfs/xfs_mkfs.c +3 -3
index e66f71b903eb..cb7c20e3aa18 100644
@@ -4552,11 +4552,11 @@ adjust_nr_zones(
 	if (!cli->rgcount)
 		cfg->rgcount += XFS_RESERVED_ZONES;
 	if (cfg->rgcount > max_zones) {
-		cfg->rgcount = max_zones;
 		fprintf(stderr,
-_("Warning: not enough zones for backing requested rt size due to\n"
+_("Warning: not enough zones (%lu/%u) for backing requested rt size due to\n"
   "over-provisioning needs, writable size will be less than %s\n"),
-			cli->rtsize);
+			cfg->rgcount, max_zones, cli->rtsize);
+		cfg->rgcount = max_zones;
 	}
 	new_rtblocks = (cfg->rgcount * cfg->rgsize);
 	slack = (new_rtblocks - cfg->rtblocks) % cfg->rgsize;
Signature · 1 line
2.47.3