Skip to contentSkip to conversation

xfsprogs: generate mkfs.xfs config files

PATCH New Darrick J. Wong 2 participants 14 messages Aug 31 – Sep 3

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 xfsprogs: generate mkfs.xfs config files

Hi all,

Every year, we generate a new mkfs.xfs configuration file to match the stable feature set of that year's LTS kernel. Right now I just do this by copying the old configuration file and tweaking the values by hand.

Instead, let's create some library code that can emit the same configuration variables that we've been shipping for some years now, and hook that up to mkfs/xfs_db/xfs_spaceman so that we can generate them either from the mkfs defaults or pre-existing filesystems.

If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.

With a bit of luck, this should all go splendidly. Comments and questions are, as always, welcome.

--D

xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=generate-cfgfiles
---
Commits in this patchset:
* mkfs: automatically upgrade autofsck earlier
* mkfs: print config file for a given mkfs configuration
* xfs_db: print configuration file for mounted filesystems
* xfs_spaceman: print configuration file for mounted filesystems
* xfs_admin: print configuration file for mounted filesystems

---
 libfrog/fsgeom.h        |    3 
 db/info.c               |  193 ++++++++++++++++++++++++
 db/xfs_admin.sh         |   15 ++
 libfrog/fsgeom.c        |  376 +++++++++++++++++++++++++++++++++++++++++++++++
 man/man8/mkfs.xfs.8.in  |    6 +
 man/man8/xfs_admin.8    |    7 +
 man/man8/xfs_db.8       |    6 +
 man/man8/xfs_spaceman.8 |    6 +
 mkfs/xfs_mkfs.c         |   62 +++++++-
 spaceman/info.c         |  136 +++++++++++++++++
 10 files changed, 798 insertions(+), 12 deletions(-)
#1 lore raw

PATCH 1/5 mkfs: automatically upgrade autofsck earlier

From: Darrick J. Wong <[email protected]>

Move this chunk of code earlier in mkfs.xfs because a subsequent patch will need the final value of cli.autofsck at the point where we do the dry run reporting stuff. Nobody changes cli.autofsck after validate_sb_features().

---
 mkfs/xfs_mkfs.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
mkfs/xfs_mkfs.c +9 -9
index a4864c37a8821b..74bbb677eee2b6 100644
@@ -6106,6 +6106,15 @@ main(
 	validate_zoned(&cfg, &cli, &dft, &zt);
 	validate_sb_features(&cfg, &cli);
 
+	/*
+	 * If the filesystem has full backreferences and the user didn't
+	 * express an autofsck preference, enable online repair because they
+	 * might as well get some useful functionality from the extra metadata.
+	 */
+	if (cli.autofsck == FSPROP_AUTOFSCK_UNSET &&
+	    cli.sb_feat.rmapbt && cli.sb_feat.parent_pointers)
+		cli.autofsck = FSPROP_AUTOFSCK_REPAIR;
+
 	/*
 	 * we've now completed basic validation of the features, sector and
 	 * block sizes, so from this point onwards we use the values found in
@@ -6297,15 +6306,6 @@ main(
 	if (mp->m_sb.sb_agcount > 1)
 		rewrite_secondary_superblocks(mp);
 
-	/*
-	 * If the filesystem has full backreferences and the user didn't
-	 * express an autofsck preference, enable online repair because they
-	 * might as well get some useful functionality from the extra metadata.
-	 */
-	if (cli.autofsck == FSPROP_AUTOFSCK_UNSET &&
-	    cli.sb_feat.rmapbt && cli.sb_feat.parent_pointers)
-		cli.autofsck = FSPROP_AUTOFSCK_REPAIR;
-
 	if (cli.autofsck != FSPROP_AUTOFSCK_UNSET)
 		set_autofsck(mp, &cli);
 
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] mkfs: automatically upgrade autofsck earlier

Quoted 11 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Move this chunk of code earlier in mkfs.xfs because a subsequent patch will need the final value of cli.autofsck at the point where we do the dry run reporting stuff. Nobody changes cli.autofsck after validate_sb_features().

---
 mkfs/xfs_mkfs.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Looks good to me

Signature · 1 line
- Andrey
#3 lore raw

PATCH 2/5 mkfs: print config file for a given mkfs configuration

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add a -c makecfg= switch to mkfs to emit a mkfs.xfs configuration file documenting the user-visible filesystem featuresets of the configured filesystem. This can be used to emit default configuration files as we do once a year for each LTS.

Note that geometry information is not written to the configuration file.

---
 libfrog/fsgeom.h       |    3 
 libfrog/fsgeom.c       |  376 ++++++++++++++++++++++++++++++++++++++++++++++++
 man/man8/mkfs.xfs.8.in |    6 +
 mkfs/xfs_mkfs.c        |   44 +++++-
 4 files changed, 428 insertions(+), 1 deletion(-)
libfrog/fsgeom.h +3 -0
index b851b9bbf36a58..1109dd2bcdb4cc 100644
@@ -217,4 +217,7 @@ bytes_per_rtgroup(
 		fsgeo->blocksize;
 }
 
+int xfrog_write_mkfs_config(const struct xfs_fsop_geom *fsgeo,
+		const struct fsxattr *fsx, int autofsck, FILE *fp);
+
 #endif /* __LIBFROG_FSGEOM_H__ */
libfrog/fsgeom.c +376 -0

385 lines not on this page · raw message

man/man8/mkfs.xfs.8.in +6 -0
index c4dee4fe07ae83..264457c3c283f1 100644
@@ -163,6 +163,12 @@ .SH OPTIONS
 This option can be use either an absolute or relative path to the configuration
 file to be read.
 Sample configuration files can be found in @mkfs_cfg_dir@.
+.TP
+.BI makecfg= value
+Write a configuration file to the given path that can be re-read by mkfs.xfs
+for a future filesystem format attempt.
+This file will contain only user-visible features.
+If no path is given, the configuration will be printed on standard output.
 .RE
 .PP
 .PD 0
mkfs/xfs_mkfs.c +43 -1

92 lines not on this page · raw message

Reviewed-by on v1 2/5
#4 lore raw

Re: [PATCH 2/5] mkfs: print config file for a given mkfs configuration

Quoted 59 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add a -c makecfg= switch to mkfs to emit a mkfs.xfs configuration file documenting the user-visible filesystem featuresets of the configured filesystem. This can be used to emit default configuration files as we do once a year for each LTS.

Note that geometry information is not written to the configuration file.

---
 libfrog/fsgeom.h       |    3 
 libfrog/fsgeom.c       |  376 ++++++++++++++++++++++++++++++++++++++++++++++++
 man/man8/mkfs.xfs.8.in |    6 +
 mkfs/xfs_mkfs.c        |   44 +++++-
 4 files changed, 428 insertions(+), 1 deletion(-)

...

mkfs/xfs_mkfs.c +7 -0
index 74bbb677eee2b6..212e17a354d8be 100644
@@ -61,6 +61,7 @@ enum {
 
 enum {
 	C_OPTFILE = 0,
+	C_MAKECFG,
 	C_MAX_OPTS,
 };
 
@@ -312,6 +313,7 @@ static struct opt_params copts = {
 	.name = 'c',
 	.subopts = {
 		[C_OPTFILE] = "options",
+		[C_MAKECFG] = "makecfg",
 		[C_MAX_OPTS] = NULL,
 	},
 	.subopt_params = {
@@ -319,6 +321,10 @@ static struct opt_params copts = {
 		  .conflicts = { { NULL, LAST_CONFLICT } },
 		  .defaultval = SUBOPT_NEEDS_VAL,
 		},
+		{ .index = C_MAKECFG,
+		  .conflicts = { { NULL, LAST_CONFLICT } },
+		  .defaultval = 1,
+		},
 	},
 };
 
@@ -1072,6 +1078,7 @@ struct cli_params {
 
 	char	*cfgfile;
 	char	*protofile;
+	char	*makecfg;
 
 	enum fsprop_autofsck autofsck;
 

mkfs/xfs_mkfs.c usage( void ) · line 1217

Quoted 5 lines
mkfs/xfs_mkfs.c +1 -1
@@ -1207,7 +1214,7 @@ usage( void )
 {
 	fprintf(stderr, _("Usage: %s\n\
 /* blocksize */		[-b size=num]\n\
-/* config file */	[-c options=xxx]\n\
+/* config file */	[-c options=xxx,makecfg=0|1]\n\

Shouldn't this be makecfg=xxx?

Otherwise, looks good to me

Signature · 1 line
- Andrey
#5 lore raw

Re: [PATCH 2/5] mkfs: print config file for a given mkfs configuration

Quoted 59 lines · Andrey Albershteyn
Quoted 58 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add a -c makecfg= switch to mkfs to emit a mkfs.xfs configuration file documenting the user-visible filesystem featuresets of the configured filesystem. This can be used to emit default configuration files as we do once a year for each LTS.

Note that geometry information is not written to the configuration file.

---
 libfrog/fsgeom.h       |    3 
 libfrog/fsgeom.c       |  376 ++++++++++++++++++++++++++++++++++++++++++++++++
 man/man8/mkfs.xfs.8.in |    6 +
 mkfs/xfs_mkfs.c        |   44 +++++-
 4 files changed, 428 insertions(+), 1 deletion(-)

...

mkfs/xfs_mkfs.c +7 -0
index 74bbb677eee2b6..212e17a354d8be 100644
@@ -61,6 +61,7 @@ enum {
 
 enum {
 	C_OPTFILE = 0,
+	C_MAKECFG,
 	C_MAX_OPTS,
 };
 
@@ -312,6 +313,7 @@ static struct opt_params copts = {
 	.name = 'c',
 	.subopts = {
 		[C_OPTFILE] = "options",
+		[C_MAKECFG] = "makecfg",
 		[C_MAX_OPTS] = NULL,
 	},
 	.subopt_params = {
@@ -319,6 +321,10 @@ static struct opt_params copts = {
 		  .conflicts = { { NULL, LAST_CONFLICT } },
 		  .defaultval = SUBOPT_NEEDS_VAL,
 		},
+		{ .index = C_MAKECFG,
+		  .conflicts = { { NULL, LAST_CONFLICT } },
+		  .defaultval = 1,
+		},
 	},
 };
 
@@ -1072,6 +1078,7 @@ struct cli_params {
 
 	char	*cfgfile;
 	char	*protofile;
+	char	*makecfg;
 
 	enum fsprop_autofsck autofsck;
 
Quoted 8 lines

mkfs/xfs_mkfs.c usage( void ) · line 1217

Quoted 6 lines
mkfs/xfs_mkfs.c +1 -1
@@ -1207,7 +1214,7 @@ usage( void )
 {
 	fprintf(stderr, _("Usage: %s\n\
 /* blocksize */		[-b size=num]\n\
-/* config file */	[-c options=xxx]\n\
+/* config file */	[-c options=xxx,makecfg=0|1]\n\

Shouldn't this be makecfg=xxx?

I think they all should be "=path" because they take file paths specifically. I'll amend this patch to change this to

/* config file */ [-c options=path,makecfg=path]\n\

Quoted 2 lines

Otherwise, looks good to me

Thanks for reviewing! A Sashiko review (I can run that internally now) generated some complaints about xfrog_write_mkfs_config not handling the quota mkfs options on metadir filesystems, and that there are a couple of V4 options that it should emit. I'll resend the series with those two pieces of new functionality.

--D

Quoted 3 lines
Signature · 1 line
- Andrey
#6 lore raw

PATCH 3/5 xfs_db: print configuration file for mounted filesystems

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Teach xfs_db to emit a mkfs.xfs config file for an unmounted filesystem. This can be used to create a new filesystem based on an existing image.

---
 db/info.c         |  193 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 man/man8/xfs_db.8 |    6 ++
 2 files changed, 199 insertions(+)
db/info.c +193 -0
index 9c233c9c0e6602..e4c026a2c4f429 100644
@@ -9,6 +9,7 @@
 #include "output.h"
 #include "libfrog/fsgeom.h"
 #include "libfrog/logging.h"
+#include "libfrog/fsproperties.h"
 
 static void
 info_help(void)
@@ -276,10 +277,202 @@ static const struct cmdinfo rgresv_cmd = {
 	.help =		rgresv_help,
 };
 
+static void
+makecfg_help(void)
+{
+	dbprintf(_(
+"\n"
+" Print a mkfs.xfs configuration file for user-visible filesystem features\n"
+" of the current filesystem.  Geometry information are not printed.\n"
+"\n"
+));
+
+}
+static void
+fill_fsxattr(
+	struct xfs_inode	*ip,
+	struct fsxattr		*fa)
+{
+	struct xfs_mount	*mp = ip->i_mount;
+	struct xfs_ifork	*ifp = xfs_ifork_ptr(ip, XFS_DATA_FORK);
+
+	fa->fsx_xflags = xfs_ip2xflags(ip);
+
+	if (ip->i_diflags & XFS_DIFLAG_EXTSIZE) {
+		fa->fsx_extsize = ip->i_extsize;
+	} else if (ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) {
+		/*
+		 * Don't let a misaligned extent size hint on a directory
+		 * escape to userspace if it won't pass the setattr checks
+		 * later.
+		 */
+		if ((ip->i_diflags & XFS_DIFLAG_RTINHERIT) &&
+		    xfs_extlen_to_rtxmod(mp, ip->i_extsize) > 0) {
+			fa->fsx_xflags &= ~(FS_XFLAG_EXTSIZE |
+					    FS_XFLAG_EXTSZINHERIT);
+			fa->fsx_extsize = 0;
+		} else {
+			fa->fsx_extsize = ip->i_extsize;
+		}
+	}
+
+	if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) {
+		/*
+		 * Don't let a misaligned CoW extent size hint on a directory
+		 * escape to userspace if it won't pass the setattr checks
+		 * later.
+		 */
+		if ((ip->i_diflags & XFS_DIFLAG_RTINHERIT) &&
+		    ip->i_cowextsize % mp->m_sb.sb_rextsize > 0) {
+			fa->fsx_xflags &= ~FS_XFLAG_COWEXTSIZE;
+			fa->fsx_cowextsize = 0;
+		} else {
+			fa->fsx_cowextsize = ip->i_cowextsize;
+		}
+	}
+
+	fa->fsx_projid = ip->i_projid;
+	if (ifp && !xfs_need_iread_extents(ifp))
+		fa->fsx_nextents = xfs_iext_count(ifp);
+	else
+		fa->fsx_nextents = xfs_ifork_nextents(ifp);
+}
+
+static int
+get_autofsck(
+	struct xfs_inode	*ip,
+	enum fsprop_autofsck	*autofsck)
+{
+	char			value[FSPROP_MAX_VALUELEN + 1];
+	struct xfs_da_args	args = {
+		.dp		= ip,
+		.geo		= mp->m_attr_geo,
+		.whichfork	= XFS_ATTR_FORK,
+		.op_flags	= XFS_DA_OP_OKNOENT,
+		.attr_filter	= LIBXFS_ATTR_ROOT,
+		.owner		= mp->m_sb.sb_rootino,
+		.value		= value,
+		.valuelen	= sizeof(value),
+	};
+	char			*p;
+	int			error;
+
+	*autofsck = FSPROP_AUTOFSCK_UNSET;
+
+	error = fsprop_name_to_attr_name(FSPROP_AUTOFSCK_NAME, &p);
+	if (error < 0)
+		return ENOMEM;
+
+	args.namelen = error;
+	args.name = (const uint8_t *)p;
+
+	libxfs_attr_sethash(&args);
+
+	error = -libxfs_attr_get(&args);
+	if (error == ENODATA) {
+		error = 0;
+		goto out_p;
+	}
+	if (error)
+		goto out_p;
+	if (!args.valuelen)
+		return 0;
+
+	/* raw xattr value is not terminated */
+	value[args.valuelen] = 0;
+	*autofsck = fsprop_autofsck_read(value);
+
+out_p:
+	free(p);
+	return error;
+}
+
+static int
+makecfg_f(
+	int			argc,
+	char			**argv)
+{
+	struct xfs_fsop_geom	geo;
+	struct fsxattr		fsx = { };
+	struct xfs_inode	*ip;
+	FILE			*fp;
+	bool			close_fp = false;
+	enum fsprop_autofsck	autofsck;
+	int			c;
+	int			error;
+
+	while ((c = getopt(argc, argv, "")) != EOF) {
+		switch (c) {
+		default:
+			dbprintf(_("bad option for makecfg command\n"));
+			return 0;
+		}
+	}
+
+	if (optind != argc && optind != argc - 1) {
+		dbprintf(_("bad option for makecfg command\n"));
+		return 0;
+	}
+
+	error = -libxfs_iget(mp, NULL, mp->m_sb.sb_rootino, 0, &ip);
+	if (error) {
+		fprintf(stderr, "root: %s\n", strerror(error));
+		return 1;
+	}
+
+	error = get_autofsck(ip, &autofsck);
+	if (error) {
+		fprintf(stderr, "autofsck: %s\n", strerror(error));
+		error = 1;
+		goto out_ip;
+	}
+
+	fill_fsxattr(ip, &fsx);
+	libxfs_fs_geometry(mp, &geo, XFS_FS_GEOM_MAX_STRUCT_VER);
+
+	if (optind == argc) {
+		fp = stdout;
+	} else {
+		fp = fopen(argv[optind], "w");
+		if (!fp) {
+			perror(argv[optind]);
+			error = 1;
+			goto out_ip;
+		}
+		close_fp = true;
+	}
+
+	error = xfrog_write_mkfs_config(&geo, &fsx, autofsck, fp);
+	if (error) {
+		if (close_fp)
+			perror(argv[optind]);
+		else
+			perror("makecfg");
+	}
+
+	if (close_fp)
+		fclose(fp);
+out_ip:
+	libxfs_irele(ip);
+	return error;
+}
+
+static const struct cmdinfo makecfg_cmd = {
+	.name =		"makecfg",
+	.cfunc =	makecfg_f,
+	.argmin =	0,
+	.argmax =	1,
+	.canpush =	0,
+	.args =		NULL,
+	.oneline =	N_("print mkfs.xfs configuration file"),
+	.help =		makecfg_help,
+};
+
 void
 info_init(void)
 {
 	add_command(&info_cmd);
 	add_command(&agresv_cmd);
 	add_command(&rgresv_cmd);
+	add_command(&makecfg_cmd);
 }
man/man8/xfs_db.8 +6 -0
index ba2a68211ef21f..b602c9d399ece7 100644
@@ -959,6 +959,12 @@ .SH COMMANDS
 .BI "help [" command ]
 Print help for one or all commands.
 .TP
+.BI "makecfg [" path ]
+Write a configuration file to the given path that can be re-read by mkfs.xfs
+for a future filesystem format attempt.
+This file will contain only user-visible features.
+If no path is given, the configuration will be printed on standard output.
+.TP
 .B info
 Displays selected geometry information about the filesystem.
 The output will have the same format that
Reviewed-by on v1 3/5
#7 lore raw

Re: [PATCH 3/5] xfs_db: print configuration file for mounted filesystems

Quoted 6 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Teach xfs_db to emit a mkfs.xfs config file for an unmounted filesystem. This can be used to create a new filesystem based on an existing image.

Looks good to me

Signature · 1 line
- Andrey
#8 lore raw

PATCH 4/5 xfs_spaceman: print configuration file for mounted filesystems

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Teach xfs_spaceman to emit a mkfs.xfs config file for a mounted filesystem.

---
 man/man8/xfs_spaceman.8 |    6 ++
 spaceman/info.c         |  136 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+)
man/man8/xfs_spaceman.8 +6 -0
index 7d2d1ff94eeb55..26ff35ab59f2ec 100644
@@ -84,6 +84,12 @@ .SH COMMANDS
 .PD
 .RE
 .TP
+.BI "makecfg [" path ]
+Write a configuration file to the given path that can be re-read by mkfs.xfs
+for a future filesystem format attempt.
+This file will contain only user-visible features.
+If no path is given, the configuration will be printed on standard output.
+.TP
 .B info
 Displays selected geometry information about the filesystem.
 The opened file must be a mount point of a XFS filesystem.
spaceman/info.c +136 -0

150 lines not on this page · raw message

Reviewed-by on v1 4/5
#9 lore raw

Re: [PATCH 4/5] xfs_spaceman: print configuration file for mounted filesystems

Quoted 10 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Teach xfs_spaceman to emit a mkfs.xfs config file for a mounted filesystem.

---
 man/man8/xfs_spaceman.8 |    6 ++
 spaceman/info.c         |  136 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+)

Looks good to me

Signature · 1 line
- Andrey
#10 lore raw

PATCH 5/5 xfs_admin: print configuration file for mounted filesystems

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Teach xfs_admin to emit a mkfs.xfs config file for a mounted or unmounted filesystem.

-

---
 db/xfs_admin.sh      |   15 +++++++++++++--
 man/man8/xfs_admin.8 |    7 +++++++
 2 files changed, 20 insertions(+), 2 deletions(-)
db/xfs_admin.sh +13 -2
index 52a658ba4a540f..13a876ad8d1377 100755
@@ -11,16 +11,20 @@ DB_OPTS=""
 DB_DEV_OPTS=""
 REPAIR_OPTS=""
 IO_OPTS=""
+SPACEMAN_OPTS=""
 REPAIR_DEV_OPTS=""
 LOG_OPTS=""
-USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]"
+USAGE="Usage: xfs_admin [-efjlpuV] [-C cfgfile] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]"
 
-while getopts "c:efjlL:O:pr:uU:V" c
+while getopts "C:c:efjlL:O:pr:uU:V" c
 do
 	case $c in
 	c)	REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG
 		require_offline=1
 		;;
+	C)	DB_OPTS=$DB_OPTS" -c 'makecfg "$OPTARG"'"
+		SPACEMAN_OPTS=$SPACEMAN_OPTS" -c 'makecfg "$OPTARG"'"
+		;;
 	e)	DB_OPTS=$DB_OPTS" -c 'version extflg'"
 		require_offline=1
 		;;
@@ -72,6 +76,13 @@ case $# in
 				exit 2
 			fi
 
+			if [ -n "$SPACEMAN_OPTS" ]; then
+				eval xfs_spaceman -p xfs_admin $SPACEMAN_OPTS "$mntpt"
+				res=$?
+				test $res -ne 0 && exit $res
+				test -n "$IO_OPTS" || exit $res
+			fi
+
 			if [ -n "$IO_OPTS" ]; then
 				eval xfs_io -p xfs_admin $IO_OPTS "$mntpt"
 				exit $?
man/man8/xfs_admin.8 +7 -0
index 63f8ee90307b30..d2652c0598f551 100644
@@ -8,6 +8,8 @@ .SH SYNOPSIS
 ] [
 .BI \-O " featurelist"
 ] [
+.BR "\-C " cfgfile
+] [
 .BR "\-c 0" | 1
 ] [
 .B \-L
@@ -85,6 +87,11 @@ .SH OPTIONS
 .B \-u
 Print the current filesystem UUID (Universally Unique IDentifier).
 .TP
+.BI "\-C " path
+Write a configuration file to the given path that can be re-read by mkfs.xfs
+for a future filesystem format attempt.
+This file will contain only user-visible features.
+.TP
 .BR "\-c 0" | 1
 Enable (1) or disable (0) lazy-counters in the filesystem.
 .IP
Reviewed-by on v1 5/5
#11 lore raw

Re: [PATCH 5/5] xfs_admin: print configuration file for mounted filesystems

Quoted 11 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Teach xfs_admin to emit a mkfs.xfs config file for a mounted or unmounted filesystem.

-

---
 db/xfs_admin.sh      |   15 +++++++++++++--
 man/man8/xfs_admin.8 |    7 +++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

Looks good to me

Signature · 1 line
- Andrey
#12 lore raw

RFC PATCH 1/1 xfs: test mkfs.xfs config file generation

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Test configuration file generation via mkfs, xfs_db, and xfs_spaceman.

---
 tests/xfs/1909     |  123 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/1909.out |    2 +
 2 files changed, 125 insertions(+)
 create mode 100755 tests/xfs/1909
 create mode 100644 tests/xfs/1909.out
tests/xfs/1909 new file +123 -0
new file mode 100755
index 00000000000000..d405064c3e3d1d
@@ -0,0 +1,123 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Oracle.  All Rights Reserved.
+#
+# FS QA Test 1909
+#
+# Functional testing for mkfs.xfs config file generation.
+#
+. ./common/preamble
+_begin_fstest auto mkfs
+
+# . ./common/filter
+
+_require_scratch
+_require_xfs_mkfs_cfgfile
+_require_xfs_spaceman_command "makecfg"
+_require_xfs_db_command "makecfg"
+_require_command "$XFS_ADMIN_PROG" "xfs_admin"
+
+# t1: Make sure all three tools generate the same config file
+_scratch_mkfs >> $seqres.full
+_scratch_mount
+$XFS_SPACEMAN_PROG -c "makecfg $tmp.spaceman1" $SCRATCH_MNT
+$XFS_ADMIN_PROG -C $tmp.onadmin1 $SCRATCH_MNT
+_scratch_unmount
+# strip out deprecation warnings (e.g. v4 filesystems)
+_scratch_mkfs -c makecfg=$tmp.mkfs1
+_scratch_xfs_db -c "makecfg $tmp.db1"
+_scratch_xfs_admin -C $tmp.offadmin1
+
+cmp -s $tmp.mkfs1 $tmp.spaceman1 || echo "mkfs config1 does not match spaceman?"
+cmp -s $tmp.db1 $tmp.spaceman1 || echo "db config1 does not match spaceman?"
+cmp -s $tmp.db1 $tmp.mkfs1 || echo "db config1 does not match mkfs?"
+cmp -s $tmp.onadmin1 $tmp.mkfs1 || echo "online admin config1 does not match mkfs?"
+cmp -s $tmp.offadmin1 $tmp.mkfs1 || echo "offline admin config1 does not match mkfs?"
+
+echo "*** spaceman config1" >> $seqres.full
+cat $tmp.spaceman1 >> $seqres.full
+echo "*** mkfs config1" >> $seqres.full
+cat $tmp.mkfs1 >> $seqres.full
+echo "*** db config1" >> $seqres.full
+cat $tmp.db1 >> $seqres.full
+echo "*** online admin config1" >> $seqres.full
+cat $tmp.onadmin1 >> $seqres.full
+echo "*** offline admin config1" >> $seqres.full
+cat $tmp.offadmin1 >> $seqres.full
+
+# t2: Make sure the output changes if we set a new rootdir inherit option
+_scratch_mount
+$XFS_IO_PROG -c 'chattr +P' -c 'chproj 33' $SCRATCH_MNT
+$XFS_SPACEMAN_PROG -c "makecfg $tmp.spaceman2" $SCRATCH_MNT
+_scratch_unmount
+_scratch_xfs_db -c "makecfg $tmp.db2"
+
+cmp -s $tmp.db2 $tmp.spaceman2 || echo "db config2 does not match spaceman?"
+cmp -s $tmp.db1 $tmp.db2 && echo "db config1 should be different from db config2"
+
+echo "*** spaceman config2" >> $seqres.full
+cat $tmp.spaceman2 >> $seqres.full
+echo "*** db config2" >> $seqres.full
+cat $tmp.db2 >> $seqres.full
+
+# t3: Format with t2 config file, make sure the results match t2 and not t1
+_scratch_mkfs -c options=$tmp.db2 >> $seqres.full
+_scratch_mount
+$XFS_SPACEMAN_PROG -c "makecfg $tmp.spaceman3" $SCRATCH_MNT
+_scratch_unmount
+_scratch_xfs_db -c "makecfg $tmp.db3"
+
+cmp -s $tmp.db3 $tmp.spaceman3 || echo "db config3 does not match spaceman?"
+cmp -s $tmp.db3 $tmp.db1 && echo "db config3 should be different from db config1"
+cmp -s $tmp.db3 $tmp.db2 || echo "db config3 does not match db config2?"
+
+echo "*** spaceman config3" >> $seqres.full
+cat $tmp.spaceman3 >> $seqres.full
+echo "*** db config3" >> $seqres.full
+cat $tmp.db3 >> $seqres.full
+
+# t4: Set autofsck filesystem property, make sure that gets reflected
+autofsck="$(grep 'autofsck=' $tmp.spaceman3 | sed -e 's/^.*autofsck=//g')"
+case "$autofsck" in
+"")
+	if grep -q 'crc=1' $tmp.spaceman3; then
+		new_autofsck=check
+	fi
+	;;
+repair) new_autofsck=check;;
+*)	new_autofsck=repair;;
+esac
+if [ -n "$new_autofsck" ]; then
+	$XFS_PROPERTY_PROG $SCRATCH_DEV set "autofsck=$new_autofsck" >> $seqres.full
+	_scratch_mount
+	$XFS_SPACEMAN_PROG -c "makecfg $tmp.spaceman4" $SCRATCH_MNT
+	_scratch_unmount
+	_scratch_xfs_db -c "makecfg $tmp.db4"
+
+	cmp -s $tmp.db4 $tmp.spaceman4 || echo "db config4 does not match spaceman?"
+	cmp -s $tmp.db4 $tmp.db3 && echo "db config4 should be different from db config3"
+
+	echo "*** spaceman config4" >> $seqres.full
+	cat $tmp.spaceman4 >> $seqres.full
+	echo "*** db config4" >> $seqres.full
+	cat $tmp.db4 >> $seqres.full
+
+	_scratch_mkfs -c options=$tmp.db4 >> $seqres.full
+	_scratch_mount
+	$XFS_SPACEMAN_PROG -c "makecfg $tmp.spaceman4a" $SCRATCH_MNT
+	_scratch_unmount
+	_scratch_xfs_db -c "makecfg $tmp.db4a"
+
+	cmp -s $tmp.db4a $tmp.spaceman4a || echo "db config4a does not match spaceman?"
+	cmp -s $tmp.db4a $tmp.db3 && echo "db config4a should be different from db config3"
+	cmp -s $tmp.db4a $tmp.db4 || echo "db config4a does not match db config4?"
+
+	echo "*** spaceman config4a" >> $seqres.full
+	cat $tmp.spaceman4a >> $seqres.full
+	echo "*** db config4a" >> $seqres.full
+	cat $tmp.db4a >> $seqres.full
+
+fi
+
+echo Silence is golden
+_exit 0
tests/xfs/1909.out new file +2 -0
new file mode 100644
index 00000000000000..c17c5522d48db4
@@ -0,0 +1,2 @@
+QA output created by 1909
+Silence is golden
Reviewed-by on v1 1/1
#13 lore raw

Re: [PATCH RFC] xfs: test mkfs.xfs config file generation

Quoted 11 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Test configuration file generation via mkfs, xfs_db, and xfs_spaceman.

---
 tests/xfs/1909     |  123 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/1909.out |    2 +
 2 files changed, 125 insertions(+)
 create mode 100755 tests/xfs/1909
 create mode 100644 tests/xfs/1909.out

Looks good to me

Signature · 1 line
- Andrey