* [RFC PATCH v2 0/5] Add option to use default config file.
@ 2026-05-25 7:57 Lukas Herbolt
2026-05-25 7:57 ` [RFC PATCH v2 1/5] xfsprogs: mkfs.xfs Add buildtime default cli_params as global variable Lukas Herbolt
` (5 more replies)
0 siblings, 6 replies; 17+ messages in thread
From: Lukas Herbolt @ 2026-05-25 7:57 UTC (permalink / raw)
To: djwong, sandeen, aalbersh, dgc; +Cc: linux-xfs, Lukas Herbolt
Hi,
Sending a v2 version trying to implement the changes suggested by
Carlos, Darrick, Eric and Dave. The default.conf is not installed
automatically but there is simple example file.
The order is now build-time < default-file < command line settings.
Some values like uuid,sunit,swidth sector size and block size are not
allowed to be set in the default config file and if set user is warned
about it and the value is reset to build-time default.
I moved setting of some values in cli_params and setting of mkfs_default_params
into new bld_dft struct as If I get it correctly we were basically setting
some of the default values on two places. It also resulted in cleanup of
unused parameters from some validate_* functions.
Lukas Herbolt (5):
xfsprogs: mkfs.xfs Add buildtime default cli_params as global variable
xfsprogs: mkfs.xfs add default configuration file.
xfsprogs: mkfs.xfs add auto|autodetect value for -d/l/r concurrency
xfs_admin: add -d option to manage default mkfs config file
xfsprogs: mkfs.xfs clean up unused dft option in various validators
.gitignore | 3 +
db/Makefile | 11 +-
db/{xfs_admin.sh => xfs_admin.sh.in} | 30 +++-
include/builddefs.in | 1 +
mkfs/Makefile | 2 +
mkfs/default.conf.example | 10 ++
mkfs/xfs_mkfs.c | 240 +++++++++++++++++----------
7 files changed, 207 insertions(+), 90 deletions(-)
rename db/{xfs_admin.sh => xfs_admin.sh.in} (70%)
create mode 100644 mkfs/default.conf.example
--
2.54.0
^ permalink raw reply [flat|nested] 17+ messages in thread
* [RFC PATCH v2 1/5] xfsprogs: mkfs.xfs Add buildtime default cli_params as global variable
2026-05-25 7:57 [RFC PATCH v2 0/5] Add option to use default config file Lukas Herbolt
@ 2026-05-25 7:57 ` Lukas Herbolt
2026-05-28 4:50 ` Darrick J. Wong
2026-05-25 7:57 ` [RFC PATCH v2 2/5] xfsprogs: mkfs.xfs add default configuration file Lukas Herbolt
` (4 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Lukas Herbolt @ 2026-05-25 7:57 UTC (permalink / raw)
To: djwong, sandeen, aalbersh, dgc; +Cc: linux-xfs, Lukas Herbolt
This patch unites the settings of cli_params and mkfs_default_params
into one global variable and then it copies its value into cli.
The behavior should remain unchanged. It is preparation for next patch
implementing the default config file.
Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
---
mkfs/xfs_mkfs.c | 116 +++++++++++++++++++++---------------------------
1 file changed, 50 insertions(+), 66 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index dd8a48c3633e..349afe65c9fc 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1190,17 +1190,44 @@ struct mkfs_params {
* values directly - they are inputs to the mkfs geometry validation and
* calculations.
*/
-struct mkfs_default_params {
- char *source; /* where the defaults came from */
-
- int sectorsize;
- int blocksize;
-
- /* feature flags that are set */
- struct sb_feat_args sb_feat;
-
- /* root inode characteristics */
- struct fsxattr fsx;
+struct cli_params bld_dft = {
+ .sectorsize = XFS_MIN_SECTORSIZE,
+ .blocksize = 1 << XFS_DFL_BLOCKSIZE_LOG,
+
+ .loginternal = 1,
+ .is_supported = 1,
+ .data_concurrency = -1, /* auto detect non-mechanical storage */
+ .log_concurrency = -1, /* auto detect non-mechanical ddev */
+ .rtvol_concurrency = -1, /* auto detect non-mechanical rtdev */
+ .autofsck = FSPROP_AUTOFSCK_UNSET,
+ .imaxpct = -1, /* set sb_imax_pct automatically */
+
+ .sb_feat = {
+ .log_version = 2,
+ .attr_version = 2,
+ .dir_version = 2,
+ .inode_align = true,
+ .nci = false,
+ .lazy_sb_counters = true,
+ .projid32bit = true,
+ .crcs_enabled = true,
+ .dirftype = true,
+ .finobt = true,
+ .spinodes = true,
+ .rmapbt = true,
+ .reflink = true,
+ .inobtcnt = true,
+ .parent_pointers = true,
+ .nodalign = false,
+ .nortalign = false,
+ .bigtime = true,
+ .nrext64 = true,
+ .exchrange = true,
+ /*
+ * When we decide to enable a new feature by default,
+ * please remember to update the mkfs conf files.
+ */
+ },
};
static void __attribute__((noreturn))
@@ -2351,7 +2378,7 @@ static void
validate_sectorsize(
struct mkfs_params *cfg,
struct cli_params *cli,
- struct mkfs_default_params *dft,
+ struct cli_params *dft,
struct fs_topology *ft,
int dry_run,
int force_overwrite)
@@ -2441,7 +2468,7 @@ static void
validate_blocksize(
struct mkfs_params *cfg,
struct cli_params *cli,
- struct mkfs_default_params *dft)
+ struct cli_params *dft)
{
/*
* Blocksize and sectorsize first, other things depend on them
@@ -2481,7 +2508,7 @@ static void
validate_log_sectorsize(
struct mkfs_params *cfg,
struct cli_params *cli,
- struct mkfs_default_params *dft,
+ struct cli_params *dft,
struct fs_topology *ft)
{
@@ -2673,7 +2700,7 @@ static void
validate_zoned(
struct mkfs_params *cfg,
struct cli_params *cli,
- struct mkfs_default_params *dft,
+ struct cli_params *dft,
struct zone_topology *zt)
{
if (!cli->xi->data.isfile) {
@@ -5949,17 +5976,8 @@ main(
struct xfs_sb *sbp = &mp->m_sb;
struct xfs_dsb *dsb;
struct fs_topology ft = {};
- struct cli_params cli = {
- .xi = &xi,
- .loginternal = 1,
- .is_supported = 1,
- .data_concurrency = -1, /* auto detect non-mechanical storage */
- .log_concurrency = -1, /* auto detect non-mechanical ddev */
- .rtvol_concurrency = -1, /* auto detect non-mechanical rtdev */
- .autofsck = FSPROP_AUTOFSCK_UNSET,
- .imaxpct = -1, /* set sb_imax_pct automatically */
- };
struct mkfs_params cfg = {};
+ struct cli_params cli;
struct option long_options[] = {
{
@@ -5971,43 +5989,13 @@ main(
{NULL, 0, NULL, 0 },
};
int option_index = 0;
-
- /* build time defaults */
- struct mkfs_default_params dft = {
- .source = _("package build definitions"),
- .sectorsize = XFS_MIN_SECTORSIZE,
- .blocksize = 1 << XFS_DFL_BLOCKSIZE_LOG,
- .sb_feat = {
- .log_version = 2,
- .attr_version = 2,
- .dir_version = 2,
- .inode_align = true,
- .nci = false,
- .lazy_sb_counters = true,
- .projid32bit = true,
- .crcs_enabled = true,
- .dirftype = true,
- .finobt = true,
- .spinodes = true,
- .rmapbt = true,
- .reflink = true,
- .inobtcnt = true,
- .parent_pointers = true,
- .nodalign = false,
- .nortalign = false,
- .bigtime = true,
- .nrext64 = true,
- .exchrange = true,
- /*
- * When we decide to enable a new feature by default,
- * please remember to update the mkfs conf files.
- */
- },
- };
struct zone_topology zt = {};
struct list_head buffer_list;
int error;
+ /* copy builtin defaults into CLI parsing structure */
+ memcpy(&cli, &bld_dft, sizeof(cli));
+ cli.xi = ξ
platform_uuid_generate(&cli.uuid);
progname = basename(argv[0]);
setlocale(LC_ALL, "");
@@ -6028,10 +6016,6 @@ main(
* printf(_("Default configuration sourced from %s\n"), dft.source);
*/
- /* copy new defaults into CLI parsing structure */
- memcpy(&cli.sb_feat, &dft.sb_feat, sizeof(cli.sb_feat));
- memcpy(&cli.fsx, &dft.fsx, sizeof(cli.fsx));
-
while ((c = getopt_long(argc, argv, "b:c:d:i:l:L:m:n:KNp:qr:s:CfV",
long_options, &option_index)) != EOF) {
switch (c) {
@@ -6093,8 +6077,8 @@ main(
* Extract as much of the valid config as we can from the CLI input
* before opening the libxfs devices.
*/
- validate_blocksize(&cfg, &cli, &dft);
- validate_sectorsize(&cfg, &cli, &dft, &ft, dry_run, force_overwrite);
+ validate_blocksize(&cfg, &cli, &bld_dft);
+ validate_sectorsize(&cfg, &cli, &bld_dft, &ft, dry_run, force_overwrite);
/*
* XXX: we still need to set block size and sector size global variables
@@ -6103,8 +6087,8 @@ main(
blocksize = cfg.blocksize;
sectorsize = cfg.sectorsize;
- validate_log_sectorsize(&cfg, &cli, &dft, &ft);
- validate_zoned(&cfg, &cli, &dft, &zt);
+ validate_log_sectorsize(&cfg, &cli, &bld_dft, &ft);
+ validate_zoned(&cfg, &cli, &bld_dft, &zt);
validate_sb_features(&cfg, &cli);
/*
--
2.54.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 2/5] xfsprogs: mkfs.xfs add default configuration file.
2026-05-25 7:57 [RFC PATCH v2 0/5] Add option to use default config file Lukas Herbolt
2026-05-25 7:57 ` [RFC PATCH v2 1/5] xfsprogs: mkfs.xfs Add buildtime default cli_params as global variable Lukas Herbolt
@ 2026-05-25 7:57 ` Lukas Herbolt
2026-05-28 4:56 ` Darrick J. Wong
2026-05-25 7:57 ` [RFC PATCH v2 3/5] xfsprogs: mkfs.xfs add auto|autodetect value for -d/l/r concurrency Lukas Herbolt
` (3 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Lukas Herbolt @ 2026-05-25 7:57 UTC (permalink / raw)
To: djwong, sandeen, aalbersh, dgc; +Cc: linux-xfs, Lukas Herbolt
Various users may prefer different default values. Having a default config
file will allow them to utilize it without the need specifying configuration
file on command line. The behavior is: build time options are overwritten
by the default config file and this options can be overwritten either by
command line options or by config file.
Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
---
include/builddefs.in | 1 +
mkfs/Makefile | 2 +
mkfs/default.conf.example | 10 ++++
mkfs/xfs_mkfs.c | 113 ++++++++++++++++++++++++++++++++------
4 files changed, 108 insertions(+), 18 deletions(-)
create mode 100644 mkfs/default.conf.example
diff --git a/include/builddefs.in b/include/builddefs.in
index 3b52d1afd703..bafea70af8ea 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -59,6 +59,7 @@ PKG_DOC_DIR = @datadir@/doc/@pkg_name@
PKG_LOCALE_DIR = @datadir@/locale
PKG_DATA_DIR = @datadir@/@pkg_name@
MKFS_CFG_DIR = @datadir@/@pkg_name@/mkfs
+MKFS_SYSCFG_DIR = @sysconfdir@/mkfs.xfs.d
PKG_STATE_DIR = @localstatedir@/lib/@pkg_name@
XFS_SCRUB_ALL_AUTO_MEDIA_SCAN_STAMP=$(PKG_STATE_DIR)/xfs_scrub_all_media.stamp
diff --git a/mkfs/Makefile b/mkfs/Makefile
index fb1473324cde..468d2ab7896e 100644
--- a/mkfs/Makefile
+++ b/mkfs/Makefile
@@ -11,6 +11,7 @@ XFS_PROTOFILE = xfs_protofile.py
HFILES =
CFILES = proto.c xfs_mkfs.c
CFGFILES = \
+ default.conf.example \
dax_x86_64.conf \
lts_4.19.conf \
lts_5.4.conf \
@@ -21,6 +22,7 @@ CFGFILES = \
lts_6.12.conf \
lts_6.18.conf
+LCFLAGS += -DMKFS_CFG_DIR=\"$(MKFS_CFG_DIR)\" -DMKFS_SYSCFG_DIR=\"$(MKFS_SYSCFG_DIR)\"
LLDLIBS += $(LIBXFS) $(LIBXCMD) $(LIBFROG) $(LIBRT) $(LIBBLKID) \
$(LIBUUID) $(LIBINIH) $(LIBURCU) $(LIBPTHREAD)
LTDEPENDENCIES += $(LIBXFS) $(LIBXCMD) $(LIBFROG)
diff --git a/mkfs/default.conf.example b/mkfs/default.conf.example
new file mode 100644
index 000000000000..ab418eab000d
--- /dev/null
+++ b/mkfs/default.conf.example
@@ -0,0 +1,10 @@
+# Default config file example.
+#[metadata]
+#bigtime=1
+#crc=1
+
+#[inode]
+#sparse=1
+
+#[naming]
+#parent=1
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 349afe65c9fc..bff7d078901c 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -44,6 +44,11 @@
*/
#define WHACK_SIZE (128 * 1024)
+/*
+ * Default configuration file which can keep distro specific values.
+ */
+#define MKFS_DEFAULT_CFGFILE MKFS_SYSCFG_DIR "/default.conf"
+
/*
* XXX: The configured block and sector sizes are defined as global variables so
* that they don't need to be passed to getnum/cvtnum().
@@ -5800,7 +5805,8 @@ cfgfile_parse(
}
exit(1);
}
- printf(_("Parameters parsed from config file %s successfully\n"),
+ if (strcmp(cli->cfgfile, MKFS_DEFAULT_CFGFILE) != 0)
+ printf(_("Parameters parsed from config file %s successfully.\n"),
cli->cfgfile);
}
@@ -5953,6 +5959,75 @@ check_rt_meta_prealloc(
mp->m_finobt_nores = false;
}
+static void
+check_ignored_opt(
+ struct cli_params *dflt,
+ const char *section,
+ const char *key)
+{
+ bool need_warn = false;
+ if (strcmp(section, "metadata") == 0 && strcmp(key, "uuid") == 0) {
+ if (!platform_uuid_is_null(&dflt->uuid)) {
+ platform_uuid_clear(&dflt->uuid);
+ need_warn = true;
+ }
+ }
+
+ if (strcmp(section, "data") == 0) {
+ if (strcmp(key, "sunit") == 0 || strcmp(key, "su") == 0) {
+ dflt->dsunit = 0;
+ dflt->dsu = NULL;
+ need_warn = true;
+ }
+
+ if (strcmp(key, "swidth") == 0 || strcmp(key, "sw") == 0) {
+ dflt->dswidth = 0;
+ dflt->dsw = 0;
+ need_warn = true;
+ }
+ }
+
+ if (strcmp(section, "sector") == 0 && strcmp(key, "size") == 0) {
+ dflt->sectorsize = XFS_MIN_SECTORSIZE;
+ need_warn = true;
+ }
+
+ if (strcmp(section, "block") == 0 && strcmp(key, "size") == 0) {
+ dflt->blocksize = 1 << XFS_DFL_BLOCKSIZE_LOG;
+ need_warn = true;
+ }
+
+ if (need_warn)
+ fprintf(stderr,
+ _("'%s' in section '%s' ignored in default config file\n"),
+ key, section);
+}
+
+static void
+reset_opts_seen(
+ struct cli_params *dflt)
+{
+ struct subopts *sop;
+ struct subopt_param *sp;
+ int i;
+
+ for (sop = &subopt_tab[0]; sop->opts; sop++) {
+ if (sop->opts->ini_section[0] == '\0')
+ continue;
+ for (i = 0; i < MAX_SUBOPTS; i++) {
+ if (!sop->opts->subopts[i])
+ break;
+ sp = &sop->opts->subopt_params[i];
+ if (sp->seen || sp->str_seen)
+ check_ignored_opt(dflt, sop->opts->ini_section,
+ sop->opts->subopts[i]);
+ sp->seen = false;
+ sp->str_seen = false;
+ }
+ }
+}
+
+
int
main(
int argc,
@@ -5978,6 +6053,7 @@ main(
struct fs_topology ft = {};
struct mkfs_params cfg = {};
struct cli_params cli;
+ struct cli_params file_dft;
struct option long_options[] = {
{
@@ -5993,28 +6069,29 @@ main(
struct list_head buffer_list;
int error;
- /* copy builtin defaults into CLI parsing structure */
- memcpy(&cli, &bld_dft, sizeof(cli));
- cli.xi = ξ
- platform_uuid_generate(&cli.uuid);
+ /* copy builtin defaults into file_dft parsing structure */
+ memcpy(&file_dft, &bld_dft, sizeof(cli));
progname = basename(argv[0]);
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- /*
- * TODO: Sourcing defaults from a config file
- *
- * Before anything else, see if there's a config file with different
- * defaults. If a file exists in <package location>, read in the new
- * default values and overwrite them in the &dft structure. This way the
- * new defaults will apply before we parse the CLI, and the CLI will
- * still be able to override them. When more than one source is
- * implemented, emit a message to indicate where the defaults being
- * used came from.
- *
- * printf(_("Default configuration sourced from %s\n"), dft.source);
- */
+ if (access(MKFS_DEFAULT_CFGFILE, F_OK) == 0){
+ /*
+ * We need to reset some values that were loaded from
+ * build time and set the cfgfile to default value
+ */
+ file_dft.cfgfile = MKFS_DEFAULT_CFGFILE;
+ cfgfile_parse(&file_dft);
+ reset_opts_seen(&file_dft);
+ printf(_("Default configuration sourced from %s\n"),
+ MKFS_DEFAULT_CFGFILE);
+ }
+
+ memcpy(&cli, &file_dft, sizeof(cli));
+ cli.cfgfile = NULL;
+ cli.xi = ξ
+ platform_uuid_generate(&cli.uuid);
while ((c = getopt_long(argc, argv, "b:c:d:i:l:L:m:n:KNp:qr:s:CfV",
long_options, &option_index)) != EOF) {
--
2.54.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 3/5] xfsprogs: mkfs.xfs add auto|autodetect value for -d/l/r concurrency
2026-05-25 7:57 [RFC PATCH v2 0/5] Add option to use default config file Lukas Herbolt
2026-05-25 7:57 ` [RFC PATCH v2 1/5] xfsprogs: mkfs.xfs Add buildtime default cli_params as global variable Lukas Herbolt
2026-05-25 7:57 ` [RFC PATCH v2 2/5] xfsprogs: mkfs.xfs add default configuration file Lukas Herbolt
@ 2026-05-25 7:57 ` Lukas Herbolt
2026-05-28 4:57 ` Darrick J. Wong
2026-05-25 7:57 ` [RFC PATCH v2 4/5] xfs_admin: add -d option to manage default mkfs config file Lukas Herbolt
` (2 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Lukas Herbolt @ 2026-05-25 7:57 UTC (permalink / raw)
To: djwong, sandeen, aalbersh, dgc; +Cc: linux-xfs, Lukas Herbolt
Add autodetect|auto value for concurrency option to restore the current
default behavior concurrency detection on SSDs.
Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
---
mkfs/xfs_mkfs.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index bff7d078901c..cb9c528021d6 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1838,9 +1838,12 @@ set_data_concurrency(
/*
* "nr_cpus" or "1" means set the concurrency level to the CPU count.
* If this cannot be determined, fall back to the default AG geometry.
+ * "auto" or "autodetect" means auto-detect based on storage type.
*/
if (!value || !strcmp(value, "nr_cpus"))
optnum = 1;
+ else if (!strcmp(value, "auto") || !strcmp(value, "autodetect"))
+ optnum = -1;
else
optnum = getnum(value, opts, subopt);
@@ -1986,9 +1989,12 @@ set_log_concurrency(
/*
* "nr_cpus" or 1 means set the concurrency level to the CPU count. If
* this cannot be determined, fall back to the default computation.
+ * "auto" or "autodetect" means auto-detect based on storage type.
*/
if (!value || !strcmp(value, "nr_cpus"))
optnum = 1;
+ else if (!strcmp(value, "auto") || !strcmp(value, "autodetect"))
+ optnum = -1;
else
optnum = getnum(value, opts, subopt);
@@ -2206,10 +2212,13 @@ set_rtvol_concurrency(
/*
* "nr_cpus" or "1" means set the concurrency level to the CPU count.
* If this cannot be determined, fall back to the default rtgroup
- * geometry.
+ * geometry. * "auto" or "autodetect" means auto-detect based on
+ * storage type.
*/
if (!value || !strcmp(value, "nr_cpus"))
optnum = 1;
+ else if (!strcmp(value, "auto") || !strcmp(value, "autodetect"))
+ optnum = -1;
else
optnum = getnum(value, opts, subopt);
--
2.54.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 4/5] xfs_admin: add -d option to manage default mkfs config file
2026-05-25 7:57 [RFC PATCH v2 0/5] Add option to use default config file Lukas Herbolt
` (2 preceding siblings ...)
2026-05-25 7:57 ` [RFC PATCH v2 3/5] xfsprogs: mkfs.xfs add auto|autodetect value for -d/l/r concurrency Lukas Herbolt
@ 2026-05-25 7:57 ` Lukas Herbolt
2026-05-28 5:00 ` Darrick J. Wong
2026-05-25 7:57 ` [RFC PATCH v2 5/5] xfsprogs: mkfs.xfs clean up unused dft option in various validators Lukas Herbolt
2026-05-28 5:10 ` [RFC PATCH v2 0/5] Add option to use default config file Darrick J. Wong
5 siblings, 1 reply; 17+ messages in thread
From: Lukas Herbolt @ 2026-05-25 7:57 UTC (permalink / raw)
To: djwong, sandeen, aalbersh, dgc; +Cc: linux-xfs, Lukas Herbolt
Add -d <file> to install a config file as the system-wide mkfs.xfs
default, and -d clear to remove it. The default config directory is
substituted at build time from the configured sysconfdir. The
xfs_admin.sh is now generated from xfs_admin.sh.in to set the default
config file location bsed on the ./configure.
Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
---
.gitignore | 3 +++
db/Makefile | 11 ++++++++--
db/{xfs_admin.sh => xfs_admin.sh.in} | 30 ++++++++++++++++++++++++++--
3 files changed, 40 insertions(+), 4 deletions(-)
rename db/{xfs_admin.sh => xfs_admin.sh.in} (70%)
diff --git a/.gitignore b/.gitignore
index eb3decd108be..fc695dbbd0b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -89,3 +89,6 @@ cscope.*
# docs
/man/man8/mkfs.xfs.8
/man/man8/xfs_scrub_all.8
+
+#generated bash
+db/xfs_admin.sh
diff --git a/db/Makefile b/db/Makefile
index e36e775eee60..b9016d2a057b 100644
--- a/db/Makefile
+++ b/db/Makefile
@@ -67,7 +67,8 @@ CFILES = $(HFILES:.h=.c) \
iunlink.c \
rdump.c \
timelimit.c
-LSRCFILES = xfs_admin.sh xfs_ncheck.sh xfs_metadump.sh
+LSRCFILES = xfs_admin.sh.in xfs_ncheck.sh xfs_metadump.sh
+LDIRT = xfs_admin.sh
LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBFROG) $(LIBUUID) $(LIBRT) $(LIBURCU) \
$(LIBPTHREAD)
@@ -79,10 +80,16 @@ LLDLIBS += $(LIBEDITLINE) $(LIBTERMCAP)
CFLAGS += -DENABLE_EDITLINE
endif
-default: depend $(LTCOMMAND)
+default: depend $(LTCOMMAND) xfs_admin.sh
include $(BUILDRULES)
+xfs_admin.sh: xfs_admin.sh.in $(TOPDIR)/include/builddefs
+ @echo " [SED] $@"
+ $(Q)$(SED) -e "s|@mkfs_syscfg_dir@|$(MKFS_SYSCFG_DIR)|g" \
+ < $< > $@
+ $(Q)chmod a+x $@
+
install: default
$(INSTALL) -m 755 -d $(PKG_SBIN_DIR)
$(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_SBIN_DIR)
diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh.in
similarity index 70%
rename from db/xfs_admin.sh
rename to db/xfs_admin.sh.in
index 52a658ba4a54..e87a64467662 100755
--- a/db/xfs_admin.sh
+++ b/db/xfs_admin.sh.in
@@ -13,11 +13,37 @@ REPAIR_OPTS=""
IO_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]"
+MKFS_DEFAULT_CFGDIR="@mkfs_syscfg_dir@"
+MKFS_DEFAULT_CFGFILE="$MKFS_DEFAULT_CFGDIR/default.conf"
+USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-d file|clear] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]"
-while getopts "c:efjlL:O:pr:uU:V" c
+while getopts "c:d:efjlL:O:pr:uU:V" c
do
case $c in
+ d) if [ "$OPTARG" = "clear" ]; then
+ rm -f "$MKFS_DEFAULT_CFGFILE"
+ status=$?
+ if [ $status -eq 0 ]; then
+ echo "Removed $MKFS_DEFAULT_CFGFILE"
+ else
+ echo "xfs_admin: failed to remove $MKFS_DEFAULT_CFGFILE" 1>&2
+ fi
+ else
+ if [ ! -f "$OPTARG" ]; then
+ echo "xfs_admin: cannot read '$OPTARG'" 1>&2
+ exit 2
+ fi
+ mkdir -p "$MKFS_DEFAULT_CFGDIR" &&
+ cp "$OPTARG" "$MKFS_DEFAULT_CFGFILE"
+ status=$?
+ if [ $status -eq 0 ]; then
+ echo "Installed $OPTARG as $MKFS_DEFAULT_CFGFILE"
+ else
+ echo "xfs_admin: failed to install $MKFS_DEFAULT_CFGFILE" 1>&2
+ fi
+ fi
+ exit $status
+ ;;
c) REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG
require_offline=1
;;
--
2.54.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 5/5] xfsprogs: mkfs.xfs clean up unused dft option in various validators
2026-05-25 7:57 [RFC PATCH v2 0/5] Add option to use default config file Lukas Herbolt
` (3 preceding siblings ...)
2026-05-25 7:57 ` [RFC PATCH v2 4/5] xfs_admin: add -d option to manage default mkfs config file Lukas Herbolt
@ 2026-05-25 7:57 ` Lukas Herbolt
2026-05-28 5:01 ` Darrick J. Wong
2026-05-28 5:10 ` [RFC PATCH v2 0/5] Add option to use default config file Darrick J. Wong
5 siblings, 1 reply; 17+ messages in thread
From: Lukas Herbolt @ 2026-05-25 7:57 UTC (permalink / raw)
To: djwong, sandeen, aalbersh, dgc; +Cc: linux-xfs, Lukas Herbolt
The struct cli_params dft was only used in validate_blocksize().
Now the cli.blocksize is always set either over bld_dflt or
file_dflt or from command line/config file. All the other functions
are not accessing the dft in their body.
Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
---
mkfs/xfs_mkfs.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index cb9c528021d6..5d1d27235a72 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2392,7 +2392,6 @@ static void
validate_sectorsize(
struct mkfs_params *cfg,
struct cli_params *cli,
- struct cli_params *dft,
struct fs_topology *ft,
int dry_run,
int force_overwrite)
@@ -2481,18 +2480,19 @@ _("block size %d cannot be smaller than sector size %d\n"),
static void
validate_blocksize(
struct mkfs_params *cfg,
- struct cli_params *cli,
- struct cli_params *dft)
+ struct cli_params *cli)
{
/*
* Blocksize and sectorsize first, other things depend on them
* For RAID4/5/6 we want to align sector size and block size,
* so we need to start with the device geometry extraction too.
+ *
+ * The cli->blocksize size is already set from the bld_dflt
+ * or from file_dflt or via command line. We just need to check
+ * if the value is within our limits.
*/
- if (!cli->blocksize)
- cfg->blocksize = dft->blocksize;
- else
- cfg->blocksize = cli->blocksize;
+
+ cfg->blocksize = cli->blocksize;
cfg->blocklog = libxfs_highbit32(cfg->blocksize);
/* validate block sizes are in range */
@@ -2522,7 +2522,6 @@ static void
validate_log_sectorsize(
struct mkfs_params *cfg,
struct cli_params *cli,
- struct cli_params *dft,
struct fs_topology *ft)
{
@@ -2714,7 +2713,6 @@ static void
validate_zoned(
struct mkfs_params *cfg,
struct cli_params *cli,
- struct cli_params *dft,
struct zone_topology *zt)
{
if (!cli->xi->data.isfile) {
@@ -6163,8 +6161,8 @@ main(
* Extract as much of the valid config as we can from the CLI input
* before opening the libxfs devices.
*/
- validate_blocksize(&cfg, &cli, &bld_dft);
- validate_sectorsize(&cfg, &cli, &bld_dft, &ft, dry_run, force_overwrite);
+ validate_blocksize(&cfg, &cli);
+ validate_sectorsize(&cfg, &cli, &ft, dry_run, force_overwrite);
/*
* XXX: we still need to set block size and sector size global variables
@@ -6173,8 +6171,8 @@ main(
blocksize = cfg.blocksize;
sectorsize = cfg.sectorsize;
- validate_log_sectorsize(&cfg, &cli, &bld_dft, &ft);
- validate_zoned(&cfg, &cli, &bld_dft, &zt);
+ validate_log_sectorsize(&cfg, &cli, &ft);
+ validate_zoned(&cfg, &cli, &zt);
validate_sb_features(&cfg, &cli);
/*
--
2.54.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [RFC PATCH v2 1/5] xfsprogs: mkfs.xfs Add buildtime default cli_params as global variable
2026-05-25 7:57 ` [RFC PATCH v2 1/5] xfsprogs: mkfs.xfs Add buildtime default cli_params as global variable Lukas Herbolt
@ 2026-05-28 4:50 ` Darrick J. Wong
2026-05-29 18:02 ` Lukas Herbolt
0 siblings, 1 reply; 17+ messages in thread
From: Darrick J. Wong @ 2026-05-28 4:50 UTC (permalink / raw)
To: Lukas Herbolt; +Cc: sandeen, aalbersh, dgc, linux-xfs
On Mon, May 25, 2026 at 09:57:48AM +0200, Lukas Herbolt wrote:
> This patch unites the settings of cli_params and mkfs_default_params
> into one global variable and then it copies its value into cli.
> The behavior should remain unchanged. It is preparation for next patch
> implementing the default config file.
>
> Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
> ---
> mkfs/xfs_mkfs.c | 116 +++++++++++++++++++++---------------------------
> 1 file changed, 50 insertions(+), 66 deletions(-)
>
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index dd8a48c3633e..349afe65c9fc 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -1190,17 +1190,44 @@ struct mkfs_params {
> * values directly - they are inputs to the mkfs geometry validation and
> * calculations.
> */
> -struct mkfs_default_params {
> - char *source; /* where the defaults came from */
> -
> - int sectorsize;
> - int blocksize;
> -
> - /* feature flags that are set */
> - struct sb_feat_args sb_feat;
> -
> - /* root inode characteristics */
> - struct fsxattr fsx;
> +struct cli_params bld_dft = {
static const?
and please spell out "build_default", we are no longer being charged by
the byte for source code.
> + .sectorsize = XFS_MIN_SECTORSIZE,
> + .blocksize = 1 << XFS_DFL_BLOCKSIZE_LOG,
> +
> + .loginternal = 1,
> + .is_supported = 1,
> + .data_concurrency = -1, /* auto detect non-mechanical storage */
> + .log_concurrency = -1, /* auto detect non-mechanical ddev */
> + .rtvol_concurrency = -1, /* auto detect non-mechanical rtdev */
> + .autofsck = FSPROP_AUTOFSCK_UNSET,
> + .imaxpct = -1, /* set sb_imax_pct automatically */
> +
> + .sb_feat = {
> + .log_version = 2,
> + .attr_version = 2,
> + .dir_version = 2,
> + .inode_align = true,
> + .nci = false,
> + .lazy_sb_counters = true,
> + .projid32bit = true,
> + .crcs_enabled = true,
> + .dirftype = true,
> + .finobt = true,
> + .spinodes = true,
> + .rmapbt = true,
> + .reflink = true,
> + .inobtcnt = true,
> + .parent_pointers = true,
> + .nodalign = false,
> + .nortalign = false,
> + .bigtime = true,
> + .nrext64 = true,
> + .exchrange = true,
> + /*
> + * When we decide to enable a new feature by default,
> + * please remember to update the mkfs conf files.
> + */
> + },
> };
>
> static void __attribute__((noreturn))
> @@ -2351,7 +2378,7 @@ static void
> validate_sectorsize(
> struct mkfs_params *cfg,
> struct cli_params *cli,
> - struct mkfs_default_params *dft,
> + struct cli_params *dft,
> struct fs_topology *ft,
> int dry_run,
> int force_overwrite)
> @@ -2441,7 +2468,7 @@ static void
> validate_blocksize(
> struct mkfs_params *cfg,
> struct cli_params *cli,
> - struct mkfs_default_params *dft)
> + struct cli_params *dft)
> {
> /*
> * Blocksize and sectorsize first, other things depend on them
> @@ -2481,7 +2508,7 @@ static void
> validate_log_sectorsize(
> struct mkfs_params *cfg,
> struct cli_params *cli,
> - struct mkfs_default_params *dft,
> + struct cli_params *dft,
> struct fs_topology *ft)
> {
>
> @@ -2673,7 +2700,7 @@ static void
> validate_zoned(
> struct mkfs_params *cfg,
> struct cli_params *cli,
> - struct mkfs_default_params *dft,
> + struct cli_params *dft,
> struct zone_topology *zt)
> {
> if (!cli->xi->data.isfile) {
> @@ -5949,17 +5976,8 @@ main(
> struct xfs_sb *sbp = &mp->m_sb;
> struct xfs_dsb *dsb;
> struct fs_topology ft = {};
> - struct cli_params cli = {
> - .xi = &xi,
> - .loginternal = 1,
> - .is_supported = 1,
> - .data_concurrency = -1, /* auto detect non-mechanical storage */
> - .log_concurrency = -1, /* auto detect non-mechanical ddev */
> - .rtvol_concurrency = -1, /* auto detect non-mechanical rtdev */
> - .autofsck = FSPROP_AUTOFSCK_UNSET,
> - .imaxpct = -1, /* set sb_imax_pct automatically */
> - };
> struct mkfs_params cfg = {};
> + struct cli_params cli;
>
> struct option long_options[] = {
> {
> @@ -5971,43 +5989,13 @@ main(
> {NULL, 0, NULL, 0 },
> };
> int option_index = 0;
> -
> - /* build time defaults */
> - struct mkfs_default_params dft = {
> - .source = _("package build definitions"),
> - .sectorsize = XFS_MIN_SECTORSIZE,
> - .blocksize = 1 << XFS_DFL_BLOCKSIZE_LOG,
> - .sb_feat = {
> - .log_version = 2,
> - .attr_version = 2,
> - .dir_version = 2,
> - .inode_align = true,
> - .nci = false,
> - .lazy_sb_counters = true,
> - .projid32bit = true,
> - .crcs_enabled = true,
> - .dirftype = true,
> - .finobt = true,
> - .spinodes = true,
> - .rmapbt = true,
> - .reflink = true,
> - .inobtcnt = true,
> - .parent_pointers = true,
> - .nodalign = false,
> - .nortalign = false,
> - .bigtime = true,
> - .nrext64 = true,
> - .exchrange = true,
> - /*
> - * When we decide to enable a new feature by default,
> - * please remember to update the mkfs conf files.
> - */
> - },
> - };
> struct zone_topology zt = {};
> struct list_head buffer_list;
> int error;
>
> + /* copy builtin defaults into CLI parsing structure */
> + memcpy(&cli, &bld_dft, sizeof(cli));
> + cli.xi = ξ
> platform_uuid_generate(&cli.uuid);
> progname = basename(argv[0]);
> setlocale(LC_ALL, "");
> @@ -6028,10 +6016,6 @@ main(
> * printf(_("Default configuration sourced from %s\n"), dft.source);
> */
>
> - /* copy new defaults into CLI parsing structure */
> - memcpy(&cli.sb_feat, &dft.sb_feat, sizeof(cli.sb_feat));
> - memcpy(&cli.fsx, &dft.fsx, sizeof(cli.fsx));
> -
> while ((c = getopt_long(argc, argv, "b:c:d:i:l:L:m:n:KNp:qr:s:CfV",
> long_options, &option_index)) != EOF) {
> switch (c) {
> @@ -6093,8 +6077,8 @@ main(
> * Extract as much of the valid config as we can from the CLI input
> * before opening the libxfs devices.
> */
> - validate_blocksize(&cfg, &cli, &dft);
> - validate_sectorsize(&cfg, &cli, &dft, &ft, dry_run, force_overwrite);
> + validate_blocksize(&cfg, &cli, &bld_dft);
> + validate_sectorsize(&cfg, &cli, &bld_dft, &ft, dry_run, force_overwrite);
Why is it necessary to pass &cli and &bld_dft into these validate
functions, since you already memcpy'd the defaults from bld_dft into
cli?
--D
> /*
> * XXX: we still need to set block size and sector size global variables
> @@ -6103,8 +6087,8 @@ main(
> blocksize = cfg.blocksize;
> sectorsize = cfg.sectorsize;
>
> - validate_log_sectorsize(&cfg, &cli, &dft, &ft);
> - validate_zoned(&cfg, &cli, &dft, &zt);
> + validate_log_sectorsize(&cfg, &cli, &bld_dft, &ft);
> + validate_zoned(&cfg, &cli, &bld_dft, &zt);
> validate_sb_features(&cfg, &cli);
>
> /*
> --
> 2.54.0
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC PATCH v2 2/5] xfsprogs: mkfs.xfs add default configuration file.
2026-05-25 7:57 ` [RFC PATCH v2 2/5] xfsprogs: mkfs.xfs add default configuration file Lukas Herbolt
@ 2026-05-28 4:56 ` Darrick J. Wong
2026-05-29 18:06 ` Lukas Herbolt
0 siblings, 1 reply; 17+ messages in thread
From: Darrick J. Wong @ 2026-05-28 4:56 UTC (permalink / raw)
To: Lukas Herbolt; +Cc: sandeen, aalbersh, dgc, linux-xfs
On Mon, May 25, 2026 at 09:57:49AM +0200, Lukas Herbolt wrote:
> Various users may prefer different default values. Having a default config
> file will allow them to utilize it without the need specifying configuration
> file on command line. The behavior is: build time options are overwritten
> by the default config file and this options can be overwritten either by
> command line options or by config file.
>
> Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
> ---
> include/builddefs.in | 1 +
> mkfs/Makefile | 2 +
> mkfs/default.conf.example | 10 ++++
> mkfs/xfs_mkfs.c | 113 ++++++++++++++++++++++++++++++++------
> 4 files changed, 108 insertions(+), 18 deletions(-)
> create mode 100644 mkfs/default.conf.example
>
> diff --git a/include/builddefs.in b/include/builddefs.in
> index 3b52d1afd703..bafea70af8ea 100644
> --- a/include/builddefs.in
> +++ b/include/builddefs.in
> @@ -59,6 +59,7 @@ PKG_DOC_DIR = @datadir@/doc/@pkg_name@
> PKG_LOCALE_DIR = @datadir@/locale
> PKG_DATA_DIR = @datadir@/@pkg_name@
> MKFS_CFG_DIR = @datadir@/@pkg_name@/mkfs
> +MKFS_SYSCFG_DIR = @sysconfdir@/mkfs.xfs.d
> PKG_STATE_DIR = @localstatedir@/lib/@pkg_name@
>
> XFS_SCRUB_ALL_AUTO_MEDIA_SCAN_STAMP=$(PKG_STATE_DIR)/xfs_scrub_all_media.stamp
> diff --git a/mkfs/Makefile b/mkfs/Makefile
> index fb1473324cde..468d2ab7896e 100644
> --- a/mkfs/Makefile
> +++ b/mkfs/Makefile
> @@ -11,6 +11,7 @@ XFS_PROTOFILE = xfs_protofile.py
> HFILES =
> CFILES = proto.c xfs_mkfs.c
> CFGFILES = \
> + default.conf.example \
> dax_x86_64.conf \
> lts_4.19.conf \
> lts_5.4.conf \
> @@ -21,6 +22,7 @@ CFGFILES = \
> lts_6.12.conf \
> lts_6.18.conf
>
> +LCFLAGS += -DMKFS_CFG_DIR=\"$(MKFS_CFG_DIR)\" -DMKFS_SYSCFG_DIR=\"$(MKFS_SYSCFG_DIR)\"
> LLDLIBS += $(LIBXFS) $(LIBXCMD) $(LIBFROG) $(LIBRT) $(LIBBLKID) \
> $(LIBUUID) $(LIBINIH) $(LIBURCU) $(LIBPTHREAD)
> LTDEPENDENCIES += $(LIBXFS) $(LIBXCMD) $(LIBFROG)
> diff --git a/mkfs/default.conf.example b/mkfs/default.conf.example
> new file mode 100644
> index 000000000000..ab418eab000d
> --- /dev/null
> +++ b/mkfs/default.conf.example
> @@ -0,0 +1,10 @@
> +# Default config file example.
> +#[metadata]
> +#bigtime=1
> +#crc=1
> +
> +#[inode]
> +#sparse=1
> +
> +#[naming]
> +#parent=1
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 349afe65c9fc..bff7d078901c 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -44,6 +44,11 @@
> */
> #define WHACK_SIZE (128 * 1024)
>
> +/*
> + * Default configuration file which can keep distro specific values.
> + */
> +#define MKFS_DEFAULT_CFGFILE MKFS_SYSCFG_DIR "/default.conf"
> +
> /*
> * XXX: The configured block and sector sizes are defined as global variables so
> * that they don't need to be passed to getnum/cvtnum().
> @@ -5800,7 +5805,8 @@ cfgfile_parse(
> }
> exit(1);
> }
> - printf(_("Parameters parsed from config file %s successfully\n"),
> + if (strcmp(cli->cfgfile, MKFS_DEFAULT_CFGFILE) != 0)
No need ^^ for double spaces here.
> + printf(_("Parameters parsed from config file %s successfully.\n"),
> cli->cfgfile);
> }
>
> @@ -5953,6 +5959,75 @@ check_rt_meta_prealloc(
> mp->m_finobt_nores = false;
> }
>
> +static void
> +check_ignored_opt(
> + struct cli_params *dflt,
> + const char *section,
> + const char *key)
> +{
> + bool need_warn = false;
> + if (strcmp(section, "metadata") == 0 && strcmp(key, "uuid") == 0) {
> + if (!platform_uuid_is_null(&dflt->uuid)) {
> + platform_uuid_clear(&dflt->uuid);
> + need_warn = true;
> + }
> + }
> +
> + if (strcmp(section, "data") == 0) {
> + if (strcmp(key, "sunit") == 0 || strcmp(key, "su") == 0) {
> + dflt->dsunit = 0;
> + dflt->dsu = NULL;
> + need_warn = true;
Weird indenting here...
> + }
> +
> + if (strcmp(key, "swidth") == 0 || strcmp(key, "sw") == 0) {
> + dflt->dswidth = 0;
> + dflt->dsw = 0;
> + need_warn = true;
> + }
> + }
> +
> + if (strcmp(section, "sector") == 0 && strcmp(key, "size") == 0) {
> + dflt->sectorsize = XFS_MIN_SECTORSIZE;
> + need_warn = true;
...and here...
> + }
> +
> + if (strcmp(section, "block") == 0 && strcmp(key, "size") == 0) {
> + dflt->blocksize = 1 << XFS_DFL_BLOCKSIZE_LOG;
> + need_warn = true;
...and here.
> + }
> +
> + if (need_warn)
> + fprintf(stderr,
> + _("'%s' in section '%s' ignored in default config file\n"),
> + key, section);
> +}
Why do the disk geometry options get a specific warning vs. all the
other parameters that one might set in the defaults config file and then
override?
> +
> +static void
> +reset_opts_seen(
> + struct cli_params *dflt)
> +{
> + struct subopts *sop;
> + struct subopt_param *sp;
> + int i;
> +
> + for (sop = &subopt_tab[0]; sop->opts; sop++) {
> + if (sop->opts->ini_section[0] == '\0')
> + continue;
> + for (i = 0; i < MAX_SUBOPTS; i++) {
> + if (!sop->opts->subopts[i])
> + break;
> + sp = &sop->opts->subopt_params[i];
> + if (sp->seen || sp->str_seen)
> + check_ignored_opt(dflt, sop->opts->ini_section,
> + sop->opts->subopts[i]);
> + sp->seen = false;
> + sp->str_seen = false;
> + }
> + }
> +}
> +
> +
> int
> main(
> int argc,
> @@ -5978,6 +6053,7 @@ main(
> struct fs_topology ft = {};
> struct mkfs_params cfg = {};
> struct cli_params cli;
> + struct cli_params file_dft;
>
> struct option long_options[] = {
> {
> @@ -5993,28 +6069,29 @@ main(
> struct list_head buffer_list;
> int error;
>
> - /* copy builtin defaults into CLI parsing structure */
> - memcpy(&cli, &bld_dft, sizeof(cli));
> - cli.xi = ξ
> - platform_uuid_generate(&cli.uuid);
> + /* copy builtin defaults into file_dft parsing structure */
> + memcpy(&file_dft, &bld_dft, sizeof(cli));
> progname = basename(argv[0]);
> setlocale(LC_ALL, "");
> bindtextdomain(PACKAGE, LOCALEDIR);
> textdomain(PACKAGE);
>
> - /*
> - * TODO: Sourcing defaults from a config file
> - *
> - * Before anything else, see if there's a config file with different
> - * defaults. If a file exists in <package location>, read in the new
> - * default values and overwrite them in the &dft structure. This way the
> - * new defaults will apply before we parse the CLI, and the CLI will
> - * still be able to override them. When more than one source is
> - * implemented, emit a message to indicate where the defaults being
> - * used came from.
> - *
> - * printf(_("Default configuration sourced from %s\n"), dft.source);
> - */
> + if (access(MKFS_DEFAULT_CFGFILE, F_OK) == 0){
> + /*
> + * We need to reset some values that were loaded from
> + * build time and set the cfgfile to default value
> + */
> + file_dft.cfgfile = MKFS_DEFAULT_CFGFILE;
> + cfgfile_parse(&file_dft);
What happens if MKFS_DEFAULT_CFGFILE disappears between the access()
call and the cfgfile_parse?
> + reset_opts_seen(&file_dft);
> + printf(_("Default configuration sourced from %s\n"),
> + MKFS_DEFAULT_CFGFILE);
> + }
> +
> + memcpy(&cli, &file_dft, sizeof(cli));
Why have a separate file_dft and cli structure? build_dft gets copied
into file_dft, file_dft is (possibly) mutated and then copied into cli,
and afer that neither file_dft nor build_dft are used again.
--D
> + cli.cfgfile = NULL;
> + cli.xi = ξ
> + platform_uuid_generate(&cli.uuid);
>
> while ((c = getopt_long(argc, argv, "b:c:d:i:l:L:m:n:KNp:qr:s:CfV",
> long_options, &option_index)) != EOF) {
> --
> 2.54.0
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC PATCH v2 3/5] xfsprogs: mkfs.xfs add auto|autodetect value for -d/l/r concurrency
2026-05-25 7:57 ` [RFC PATCH v2 3/5] xfsprogs: mkfs.xfs add auto|autodetect value for -d/l/r concurrency Lukas Herbolt
@ 2026-05-28 4:57 ` Darrick J. Wong
2026-05-29 18:07 ` Lukas Herbolt
0 siblings, 1 reply; 17+ messages in thread
From: Darrick J. Wong @ 2026-05-28 4:57 UTC (permalink / raw)
To: Lukas Herbolt; +Cc: sandeen, aalbersh, dgc, linux-xfs
On Mon, May 25, 2026 at 09:57:50AM +0200, Lukas Herbolt wrote:
> Add autodetect|auto value for concurrency option to restore the current
> default behavior concurrency detection on SSDs.
>
> Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
> ---
> mkfs/xfs_mkfs.c | 11 ++++++++++-
Needs a manual page change to note that you can say -d concurrency=auto.
Otherwise the logic and comment changes look good to me.
--D
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index bff7d078901c..cb9c528021d6 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -1838,9 +1838,12 @@ set_data_concurrency(
> /*
> * "nr_cpus" or "1" means set the concurrency level to the CPU count.
> * If this cannot be determined, fall back to the default AG geometry.
> + * "auto" or "autodetect" means auto-detect based on storage type.
> */
> if (!value || !strcmp(value, "nr_cpus"))
> optnum = 1;
> + else if (!strcmp(value, "auto") || !strcmp(value, "autodetect"))
> + optnum = -1;
> else
> optnum = getnum(value, opts, subopt);
>
> @@ -1986,9 +1989,12 @@ set_log_concurrency(
> /*
> * "nr_cpus" or 1 means set the concurrency level to the CPU count. If
> * this cannot be determined, fall back to the default computation.
> + * "auto" or "autodetect" means auto-detect based on storage type.
> */
> if (!value || !strcmp(value, "nr_cpus"))
> optnum = 1;
> + else if (!strcmp(value, "auto") || !strcmp(value, "autodetect"))
> + optnum = -1;
> else
> optnum = getnum(value, opts, subopt);
>
> @@ -2206,10 +2212,13 @@ set_rtvol_concurrency(
> /*
> * "nr_cpus" or "1" means set the concurrency level to the CPU count.
> * If this cannot be determined, fall back to the default rtgroup
> - * geometry.
> + * geometry. * "auto" or "autodetect" means auto-detect based on
> + * storage type.
> */
> if (!value || !strcmp(value, "nr_cpus"))
> optnum = 1;
> + else if (!strcmp(value, "auto") || !strcmp(value, "autodetect"))
> + optnum = -1;
> else
> optnum = getnum(value, opts, subopt);
>
> --
> 2.54.0
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC PATCH v2 4/5] xfs_admin: add -d option to manage default mkfs config file
2026-05-25 7:57 ` [RFC PATCH v2 4/5] xfs_admin: add -d option to manage default mkfs config file Lukas Herbolt
@ 2026-05-28 5:00 ` Darrick J. Wong
0 siblings, 0 replies; 17+ messages in thread
From: Darrick J. Wong @ 2026-05-28 5:00 UTC (permalink / raw)
To: Lukas Herbolt; +Cc: sandeen, aalbersh, dgc, linux-xfs
On Mon, May 25, 2026 at 09:57:51AM +0200, Lukas Herbolt wrote:
> Add -d <file> to install a config file as the system-wide mkfs.xfs
> default, and -d clear to remove it. The default config directory is
> substituted at build time from the configured sysconfdir. The
> xfs_admin.sh is now generated from xfs_admin.sh.in to set the default
> config file location bsed on the ./configure.
>
> Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
> ---
> .gitignore | 3 +++
> db/Makefile | 11 ++++++++--
> db/{xfs_admin.sh => xfs_admin.sh.in} | 30 ++++++++++++++++++++++++++--
> 3 files changed, 40 insertions(+), 4 deletions(-)
> rename db/{xfs_admin.sh => xfs_admin.sh.in} (70%)
>
> diff --git a/.gitignore b/.gitignore
> index eb3decd108be..fc695dbbd0b1 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -89,3 +89,6 @@ cscope.*
> # docs
> /man/man8/mkfs.xfs.8
> /man/man8/xfs_scrub_all.8
> +
> +#generated bash
> +db/xfs_admin.sh
> diff --git a/db/Makefile b/db/Makefile
> index e36e775eee60..b9016d2a057b 100644
> --- a/db/Makefile
> +++ b/db/Makefile
> @@ -67,7 +67,8 @@ CFILES = $(HFILES:.h=.c) \
> iunlink.c \
> rdump.c \
> timelimit.c
> -LSRCFILES = xfs_admin.sh xfs_ncheck.sh xfs_metadump.sh
> +LSRCFILES = xfs_admin.sh.in xfs_ncheck.sh xfs_metadump.sh
> +LDIRT = xfs_admin.sh
>
> LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBFROG) $(LIBUUID) $(LIBRT) $(LIBURCU) \
> $(LIBPTHREAD)
> @@ -79,10 +80,16 @@ LLDLIBS += $(LIBEDITLINE) $(LIBTERMCAP)
> CFLAGS += -DENABLE_EDITLINE
> endif
>
> -default: depend $(LTCOMMAND)
> +default: depend $(LTCOMMAND) xfs_admin.sh
>
> include $(BUILDRULES)
>
> +xfs_admin.sh: xfs_admin.sh.in $(TOPDIR)/include/builddefs
> + @echo " [SED] $@"
> + $(Q)$(SED) -e "s|@mkfs_syscfg_dir@|$(MKFS_SYSCFG_DIR)|g" \
> + < $< > $@
> + $(Q)chmod a+x $@
> +
> install: default
> $(INSTALL) -m 755 -d $(PKG_SBIN_DIR)
> $(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_SBIN_DIR)
> diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh.in
> similarity index 70%
> rename from db/xfs_admin.sh
> rename to db/xfs_admin.sh.in
> index 52a658ba4a54..e87a64467662 100755
> --- a/db/xfs_admin.sh
> +++ b/db/xfs_admin.sh.in
> @@ -13,11 +13,37 @@ REPAIR_OPTS=""
> IO_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]"
> +MKFS_DEFAULT_CFGDIR="@mkfs_syscfg_dir@"
> +MKFS_DEFAULT_CFGFILE="$MKFS_DEFAULT_CFGDIR/default.conf"
> +USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-d file|clear] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]"
>
> -while getopts "c:efjlL:O:pr:uU:V" c
> +while getopts "c:d:efjlL:O:pr:uU:V" c
> do
> case $c in
> + d) if [ "$OPTARG" = "clear" ]; then
I wish this were a long option (e.g. xfs_admin --set-defaults /root/my.cfg)
but I don't have a clue how to do this in bash.
> + rm -f "$MKFS_DEFAULT_CFGFILE"
> + status=$?
> + if [ $status -eq 0 ]; then
> + echo "Removed $MKFS_DEFAULT_CFGFILE"
> + else
> + echo "xfs_admin: failed to remove $MKFS_DEFAULT_CFGFILE" 1>&2
> + fi
> + else
> + if [ ! -f "$OPTARG" ]; then
> + echo "xfs_admin: cannot read '$OPTARG'" 1>&2
Shouldn't this be -r(eadable) not -f(ile path exists) given the error
message?
This new functionality also needs a manpage update.
--D
> + exit 2
> + fi
> + mkdir -p "$MKFS_DEFAULT_CFGDIR" &&
> + cp "$OPTARG" "$MKFS_DEFAULT_CFGFILE"
> + status=$?
> + if [ $status -eq 0 ]; then
> + echo "Installed $OPTARG as $MKFS_DEFAULT_CFGFILE"
> + else
> + echo "xfs_admin: failed to install $MKFS_DEFAULT_CFGFILE" 1>&2
> + fi
> + fi
> + exit $status
> + ;;
> c) REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG
> require_offline=1
> ;;
> --
> 2.54.0
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC PATCH v2 5/5] xfsprogs: mkfs.xfs clean up unused dft option in various validators
2026-05-25 7:57 ` [RFC PATCH v2 5/5] xfsprogs: mkfs.xfs clean up unused dft option in various validators Lukas Herbolt
@ 2026-05-28 5:01 ` Darrick J. Wong
0 siblings, 0 replies; 17+ messages in thread
From: Darrick J. Wong @ 2026-05-28 5:01 UTC (permalink / raw)
To: Lukas Herbolt; +Cc: sandeen, aalbersh, dgc, linux-xfs
On Mon, May 25, 2026 at 09:57:52AM +0200, Lukas Herbolt wrote:
> The struct cli_params dft was only used in validate_blocksize().
> Now the cli.blocksize is always set either over bld_dflt or
> file_dflt or from command line/config file. All the other functions
> are not accessing the dft in their body.
>
> Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
I wish this had come first, but oh well whatever.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> mkfs/xfs_mkfs.c | 24 +++++++++++-------------
> 1 file changed, 11 insertions(+), 13 deletions(-)
>
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index cb9c528021d6..5d1d27235a72 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -2392,7 +2392,6 @@ static void
> validate_sectorsize(
> struct mkfs_params *cfg,
> struct cli_params *cli,
> - struct cli_params *dft,
> struct fs_topology *ft,
> int dry_run,
> int force_overwrite)
> @@ -2481,18 +2480,19 @@ _("block size %d cannot be smaller than sector size %d\n"),
> static void
> validate_blocksize(
> struct mkfs_params *cfg,
> - struct cli_params *cli,
> - struct cli_params *dft)
> + struct cli_params *cli)
> {
> /*
> * Blocksize and sectorsize first, other things depend on them
> * For RAID4/5/6 we want to align sector size and block size,
> * so we need to start with the device geometry extraction too.
> + *
> + * The cli->blocksize size is already set from the bld_dflt
> + * or from file_dflt or via command line. We just need to check
> + * if the value is within our limits.
> */
> - if (!cli->blocksize)
> - cfg->blocksize = dft->blocksize;
> - else
> - cfg->blocksize = cli->blocksize;
> +
> + cfg->blocksize = cli->blocksize;
> cfg->blocklog = libxfs_highbit32(cfg->blocksize);
>
> /* validate block sizes are in range */
> @@ -2522,7 +2522,6 @@ static void
> validate_log_sectorsize(
> struct mkfs_params *cfg,
> struct cli_params *cli,
> - struct cli_params *dft,
> struct fs_topology *ft)
> {
>
> @@ -2714,7 +2713,6 @@ static void
> validate_zoned(
> struct mkfs_params *cfg,
> struct cli_params *cli,
> - struct cli_params *dft,
> struct zone_topology *zt)
> {
> if (!cli->xi->data.isfile) {
> @@ -6163,8 +6161,8 @@ main(
> * Extract as much of the valid config as we can from the CLI input
> * before opening the libxfs devices.
> */
> - validate_blocksize(&cfg, &cli, &bld_dft);
> - validate_sectorsize(&cfg, &cli, &bld_dft, &ft, dry_run, force_overwrite);
> + validate_blocksize(&cfg, &cli);
> + validate_sectorsize(&cfg, &cli, &ft, dry_run, force_overwrite);
>
> /*
> * XXX: we still need to set block size and sector size global variables
> @@ -6173,8 +6171,8 @@ main(
> blocksize = cfg.blocksize;
> sectorsize = cfg.sectorsize;
>
> - validate_log_sectorsize(&cfg, &cli, &bld_dft, &ft);
> - validate_zoned(&cfg, &cli, &bld_dft, &zt);
> + validate_log_sectorsize(&cfg, &cli, &ft);
> + validate_zoned(&cfg, &cli, &zt);
> validate_sb_features(&cfg, &cli);
>
> /*
> --
> 2.54.0
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC PATCH v2 0/5] Add option to use default config file.
2026-05-25 7:57 [RFC PATCH v2 0/5] Add option to use default config file Lukas Herbolt
` (4 preceding siblings ...)
2026-05-25 7:57 ` [RFC PATCH v2 5/5] xfsprogs: mkfs.xfs clean up unused dft option in various validators Lukas Herbolt
@ 2026-05-28 5:10 ` Darrick J. Wong
2026-05-29 18:01 ` Lukas Herbolt
5 siblings, 1 reply; 17+ messages in thread
From: Darrick J. Wong @ 2026-05-28 5:10 UTC (permalink / raw)
To: Lukas Herbolt; +Cc: sandeen, aalbersh, dgc, linux-xfs
On Mon, May 25, 2026 at 09:57:47AM +0200, Lukas Herbolt wrote:
> Hi,
> Sending a v2 version trying to implement the changes suggested by
> Carlos, Darrick, Eric and Dave. The default.conf is not installed
> automatically but there is simple example file.
>
> The order is now build-time < default-file < command line settings.
> Some values like uuid,sunit,swidth sector size and block size are not
> allowed to be set in the default config file and if set user is warned
> about it and the value is reset to build-time default.
>
> I moved setting of some values in cli_params and setting of mkfs_default_params
> into new bld_dft struct as If I get it correctly we were basically setting
> some of the default values on two places. It also resulted in cleanup of
> unused parameters from some validate_* functions.
This looks mostly good, but I have a couple of suggestions to improve
the ergonomics for distributors:
1. Make it so that mkfs.xfs itself can spit out a configuration file
based on the "bld_dft" object. Then we can always generate the
"default.conf" file with something as simple as:
$ mkfs.xfs --write-defaults /root/my.conf
$ cat /root/my.conf
[metadata]
rmapbt=1
...
Obviously this requires some careful thought about what exactly the
printing function will actually emit -- my guess is that the only things
worth printing are filesystem features and the default fsxattr values
that get written into the rootdir, since the device geometry will
change.
2. Make xfs_db/xfs_info emit a similar configuration file based on an
existing filesystem. Anyone needing to create many feature-for-feature
replicas of an existing filesystem will now have a much easier time than
encoding options into a shell script.
# xfs_info -c 'writecfg' /my/rad/fs > /root/rad.conf
# mkfs.xfs -c options=/root/rad.conf /dev/sda
# mkfs.xfs -c options=/root/rad.conf /dev/sdb
...
(maybe add an xfs_admin option to call xfs_{db,info} too?)
What do you think?
--D
>
> Lukas Herbolt (5):
> xfsprogs: mkfs.xfs Add buildtime default cli_params as global variable
> xfsprogs: mkfs.xfs add default configuration file.
> xfsprogs: mkfs.xfs add auto|autodetect value for -d/l/r concurrency
> xfs_admin: add -d option to manage default mkfs config file
> xfsprogs: mkfs.xfs clean up unused dft option in various validators
>
> .gitignore | 3 +
> db/Makefile | 11 +-
> db/{xfs_admin.sh => xfs_admin.sh.in} | 30 +++-
> include/builddefs.in | 1 +
> mkfs/Makefile | 2 +
> mkfs/default.conf.example | 10 ++
> mkfs/xfs_mkfs.c | 240 +++++++++++++++++----------
> 7 files changed, 207 insertions(+), 90 deletions(-)
> rename db/{xfs_admin.sh => xfs_admin.sh.in} (70%)
> create mode 100644 mkfs/default.conf.example
>
> --
> 2.54.0
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC PATCH v2 0/5] Add option to use default config file.
2026-05-28 5:10 ` [RFC PATCH v2 0/5] Add option to use default config file Darrick J. Wong
@ 2026-05-29 18:01 ` Lukas Herbolt
2026-06-02 4:55 ` Darrick J. Wong
0 siblings, 1 reply; 17+ messages in thread
From: Lukas Herbolt @ 2026-05-29 18:01 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: sandeen, aalbersh, dgc, linux-xfs
On 2026-05-28 07:10, Darrick J. Wong wrote:
> On Mon, May 25, 2026 at 09:57:47AM +0200, Lukas Herbolt wrote:
>> Hi,
>> Sending a v2 version trying to implement the changes suggested by
>> Carlos, Darrick, Eric and Dave. The default.conf is not installed
>> automatically but there is simple example file.
>>
>> The order is now build-time < default-file < command line settings.
>> Some values like uuid,sunit,swidth sector size and block size are not
>> allowed to be set in the default config file and if set user is warned
>> about it and the value is reset to build-time default.
>>
>> I moved setting of some values in cli_params and setting of
>> mkfs_default_params
>> into new bld_dft struct as If I get it correctly we were basically
>> setting
>> some of the default values on two places. It also resulted in cleanup
>> of
>> unused parameters from some validate_* functions.
>
> This looks mostly good, but I have a couple of suggestions to improve
> the ergonomics for distributors:
>
> 1. Make it so that mkfs.xfs itself can spit out a configuration file
> based on the "bld_dft" object. Then we can always generate the
> "default.conf" file with something as simple as:
>
> $ mkfs.xfs --write-defaults /root/my.conf
> $ cat /root/my.conf
> [metadata]
> rmapbt=1
> ...
>
> Obviously this requires some careful thought about what exactly the
> printing function will actually emit -- my guess is that the only
> things
> worth printing are filesystem features and the default fsxattr values
> that get written into the rootdir, since the device geometry will
> change.
Make sense, but I would then remove the example file, also this comes to
the
fact while some (HW geometry) stuff are ignored in the default file. I
would
not allow user to set sector size sunit/swidth from the default file.
The question
is should we just exit with some info and calling usage() or set it to
default
and warn about it?
>
> 2. Make xfs_db/xfs_info emit a similar configuration file based on an
> existing filesystem. Anyone needing to create many feature-for-feature
> replicas of an existing filesystem will now have a much easier time
> than
> encoding options into a shell script.
>
> # xfs_info -c 'writecfg' /my/rad/fs > /root/rad.conf
> # mkfs.xfs -c options=/root/rad.conf /dev/sda
> # mkfs.xfs -c options=/root/rad.conf /dev/sdb
> ...
>
> (maybe add an xfs_admin option to call xfs_{db,info} too?)
>
> What do you think?
>
I guess xfs_{db,info} option which would be used in xfs_admin makes
sense.
But again here comes a question should we emit exact copy or leave HW
geometry aside?
--
-lhe
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC PATCH v2 1/5] xfsprogs: mkfs.xfs Add buildtime default cli_params as global variable
2026-05-28 4:50 ` Darrick J. Wong
@ 2026-05-29 18:02 ` Lukas Herbolt
0 siblings, 0 replies; 17+ messages in thread
From: Lukas Herbolt @ 2026-05-29 18:02 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: sandeen, aalbersh, dgc, linux-xfs
On 2026-05-28 06:50, Darrick J. Wong wrote:
> On Mon, May 25, 2026 at 09:57:48AM +0200, Lukas Herbolt wrote:
>> This patch unites the settings of cli_params and mkfs_default_params
>> into one global variable and then it copies its value into cli.
>> The behavior should remain unchanged. It is preparation for next patch
>> implementing the default config file.
>>
>> Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
>> ---
>> mkfs/xfs_mkfs.c | 116
>> +++++++++++++++++++++---------------------------
>> 1 file changed, 50 insertions(+), 66 deletions(-)
>>
>> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
>> index dd8a48c3633e..349afe65c9fc 100644
>> --- a/mkfs/xfs_mkfs.c
>> +++ b/mkfs/xfs_mkfs.c
>> @@ -1190,17 +1190,44 @@ struct mkfs_params {
>> * values directly - they are inputs to the mkfs geometry validation
>> and
>> * calculations.
>> */
>> -struct mkfs_default_params {
>> - char *source; /* where the defaults came from */
>> -
>> - int sectorsize;
>> - int blocksize;
>> -
>> - /* feature flags that are set */
>> - struct sb_feat_args sb_feat;
>> -
>> - /* root inode characteristics */
>> - struct fsxattr fsx;
>> +struct cli_params bld_dft = {
>
> static const?
>
> and please spell out "build_default", we are no longer being charged by
> the byte for source code.
>
Thanks noted!
--
-lhe
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC PATCH v2 2/5] xfsprogs: mkfs.xfs add default configuration file.
2026-05-28 4:56 ` Darrick J. Wong
@ 2026-05-29 18:06 ` Lukas Herbolt
0 siblings, 0 replies; 17+ messages in thread
From: Lukas Herbolt @ 2026-05-29 18:06 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: sandeen, aalbersh, dgc, linux-xfs
On 2026-05-28 06:56, Darrick J. Wong wrote:
> On Mon, May 25, 2026 at 09:57:49AM +0200, Lukas Herbolt wrote:
>> Various users may prefer different default values. Having a default
>> config
>> file will allow them to utilize it without the need specifying
>> configuration
>> file on command line. The behavior is: build time options are
>> overwritten
>> by the default config file and this options can be overwritten either
>> by
>> command line options or by config file.
>>
>> Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
>> ---
>> include/builddefs.in | 1 +
>> mkfs/Makefile | 2 +
>> mkfs/default.conf.example | 10 ++++
>> mkfs/xfs_mkfs.c | 113
>> ++++++++++++++++++++++++++++++++------
>> 4 files changed, 108 insertions(+), 18 deletions(-)
>> create mode 100644 mkfs/default.conf.example
>>
>> diff --git a/include/builddefs.in b/include/builddefs.in
>> index 3b52d1afd703..bafea70af8ea 100644
>> --- a/include/builddefs.in
>> +++ b/include/builddefs.in
>> @@ -59,6 +59,7 @@ PKG_DOC_DIR = @datadir@/doc/@pkg_name@
>> PKG_LOCALE_DIR = @datadir@/locale
>> PKG_DATA_DIR = @datadir@/@pkg_name@
>> MKFS_CFG_DIR = @datadir@/@pkg_name@/mkfs
>> +MKFS_SYSCFG_DIR = @sysconfdir@/mkfs.xfs.d
>> PKG_STATE_DIR = @localstatedir@/lib/@pkg_name@
>>
>>
>> XFS_SCRUB_ALL_AUTO_MEDIA_SCAN_STAMP=$(PKG_STATE_DIR)/xfs_scrub_all_media.stamp
>> diff --git a/mkfs/Makefile b/mkfs/Makefile
>> index fb1473324cde..468d2ab7896e 100644
>> --- a/mkfs/Makefile
>> +++ b/mkfs/Makefile
>> @@ -11,6 +11,7 @@ XFS_PROTOFILE = xfs_protofile.py
>> HFILES =
>> CFILES = proto.c xfs_mkfs.c
>> CFGFILES = \
>> + default.conf.example \
>> dax_x86_64.conf \
>> lts_4.19.conf \
>> lts_5.4.conf \
>> @@ -21,6 +22,7 @@ CFGFILES = \
>> lts_6.12.conf \
>> lts_6.18.conf
>>
>> +LCFLAGS += -DMKFS_CFG_DIR=\"$(MKFS_CFG_DIR)\"
>> -DMKFS_SYSCFG_DIR=\"$(MKFS_SYSCFG_DIR)\"
>> LLDLIBS += $(LIBXFS) $(LIBXCMD) $(LIBFROG) $(LIBRT) $(LIBBLKID) \
>> $(LIBUUID) $(LIBINIH) $(LIBURCU) $(LIBPTHREAD)
>> LTDEPENDENCIES += $(LIBXFS) $(LIBXCMD) $(LIBFROG)
>> diff --git a/mkfs/default.conf.example b/mkfs/default.conf.example
>> new file mode 100644
>> index 000000000000..ab418eab000d
>> --- /dev/null
>> +++ b/mkfs/default.conf.example
>> @@ -0,0 +1,10 @@
>> +# Default config file example.
>> +#[metadata]
>> +#bigtime=1
>> +#crc=1
>> +
>> +#[inode]
>> +#sparse=1
>> +
>> +#[naming]
>> +#parent=1
>> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
>> index 349afe65c9fc..bff7d078901c 100644
>> --- a/mkfs/xfs_mkfs.c
>> +++ b/mkfs/xfs_mkfs.c
>> @@ -44,6 +44,11 @@
>> */
>> #define WHACK_SIZE (128 * 1024)
>>
>> +/*
>> + * Default configuration file which can keep distro specific values.
>> + */
>> +#define MKFS_DEFAULT_CFGFILE MKFS_SYSCFG_DIR "/default.conf"
>> +
>> /*
>> * XXX: The configured block and sector sizes are defined as global
>> variables so
>> * that they don't need to be passed to getnum/cvtnum().
>> @@ -5800,7 +5805,8 @@ cfgfile_parse(
>> }
>> exit(1);
>> }
>> - printf(_("Parameters parsed from config file %s successfully\n"),
>> + if (strcmp(cli->cfgfile, MKFS_DEFAULT_CFGFILE) != 0)
>
> No need ^^ for double spaces here.
>
>> + printf(_("Parameters parsed from config file %s successfully.\n"),
>> cli->cfgfile);
>> }
>>
>> @@ -5953,6 +5959,75 @@ check_rt_meta_prealloc(
>> mp->m_finobt_nores = false;
>> }
>>
>> +static void
>> +check_ignored_opt(
>> + struct cli_params *dflt,
>> + const char *section,
>> + const char *key)
>> +{
>> + bool need_warn = false;
>> + if (strcmp(section, "metadata") == 0 && strcmp(key, "uuid") == 0) {
>> + if (!platform_uuid_is_null(&dflt->uuid)) {
>> + platform_uuid_clear(&dflt->uuid);
>> + need_warn = true;
>> + }
>> + }
>> +
>> + if (strcmp(section, "data") == 0) {
>> + if (strcmp(key, "sunit") == 0 || strcmp(key, "su") == 0) {
>> + dflt->dsunit = 0;
>> + dflt->dsu = NULL;
>> + need_warn = true;
>
> Weird indenting here...
>
>> + }
>> +
>> + if (strcmp(key, "swidth") == 0 || strcmp(key, "sw") == 0) {
>> + dflt->dswidth = 0;
>> + dflt->dsw = 0;
>> + need_warn = true;
>> + }
>> + }
>> +
>> + if (strcmp(section, "sector") == 0 && strcmp(key, "size") == 0) {
>> + dflt->sectorsize = XFS_MIN_SECTORSIZE;
>> + need_warn = true;
>
> ...and here...
>
>> + }
>> +
>> + if (strcmp(section, "block") == 0 && strcmp(key, "size") == 0) {
>> + dflt->blocksize = 1 << XFS_DFL_BLOCKSIZE_LOG;
>> + need_warn = true;
>
> ...and here.
>
>> + }
>> +
>> + if (need_warn)
>> + fprintf(stderr,
>> + _("'%s' in section '%s' ignored in default config file\n"),
>> + key, section);
>> +}
>
> Why do the disk geometry options get a specific warning vs. all the
> other parameters that one might set in the defaults config file and
> then
> override?
>
Mostly motivated by Dave's reply. I think we should just inform the user
that some things cannot be set in the default file, but that's for
discussion.
Thank you for indentation fixes!
--
-lhe
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC PATCH v2 3/5] xfsprogs: mkfs.xfs add auto|autodetect value for -d/l/r concurrency
2026-05-28 4:57 ` Darrick J. Wong
@ 2026-05-29 18:07 ` Lukas Herbolt
0 siblings, 0 replies; 17+ messages in thread
From: Lukas Herbolt @ 2026-05-29 18:07 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: sandeen, aalbersh, dgc, linux-xfs
On 2026-05-28 06:57, Darrick J. Wong wrote:
> On Mon, May 25, 2026 at 09:57:50AM +0200, Lukas Herbolt wrote:
>> Add autodetect|auto value for concurrency option to restore the
>> current
>> default behavior concurrency detection on SSDs.
>>
>> Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
>> ---
>> mkfs/xfs_mkfs.c | 11 ++++++++++-
>
> Needs a manual page change to note that you can say -d
> concurrency=auto.
Thanks I will add it.
--
-lhe
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC PATCH v2 0/5] Add option to use default config file.
2026-05-29 18:01 ` Lukas Herbolt
@ 2026-06-02 4:55 ` Darrick J. Wong
0 siblings, 0 replies; 17+ messages in thread
From: Darrick J. Wong @ 2026-06-02 4:55 UTC (permalink / raw)
To: Lukas Herbolt; +Cc: sandeen, aalbersh, dgc, linux-xfs
On Fri, May 29, 2026 at 08:01:55PM +0200, Lukas Herbolt wrote:
> On 2026-05-28 07:10, Darrick J. Wong wrote:
> > On Mon, May 25, 2026 at 09:57:47AM +0200, Lukas Herbolt wrote:
> > > Hi,
> > > Sending a v2 version trying to implement the changes suggested by
> > > Carlos, Darrick, Eric and Dave. The default.conf is not installed
> > > automatically but there is simple example file.
> > >
> > > The order is now build-time < default-file < command line settings.
> > > Some values like uuid,sunit,swidth sector size and block size are not
> > > allowed to be set in the default config file and if set user is warned
> > > about it and the value is reset to build-time default.
> > >
> > > I moved setting of some values in cli_params and setting of
> > > mkfs_default_params
> > > into new bld_dft struct as If I get it correctly we were basically
> > > setting
> > > some of the default values on two places. It also resulted in
> > > cleanup of
> > > unused parameters from some validate_* functions.
> >
> > This looks mostly good, but I have a couple of suggestions to improve
> > the ergonomics for distributors:
> >
> > 1. Make it so that mkfs.xfs itself can spit out a configuration file
> > based on the "bld_dft" object. Then we can always generate the
> > "default.conf" file with something as simple as:
> >
> > $ mkfs.xfs --write-defaults /root/my.conf
> > $ cat /root/my.conf
> > [metadata]
> > rmapbt=1
> > ...
> >
> > Obviously this requires some careful thought about what exactly the
> > printing function will actually emit -- my guess is that the only things
> > worth printing are filesystem features and the default fsxattr values
> > that get written into the rootdir, since the device geometry will
> > change.
>
> Make sense, but I would then remove the example file, also this comes to the
> fact while some (HW geometry) stuff are ignored in the default file. I would
> not allow user to set sector size sunit/swidth from the default file. The
> question
> is should we just exit with some info and calling usage() or set it to
> default
> and warn about it?
AFAICT, the config file parser currently allows you to provide fs
geometry options (e.g. sunit) in the config file. I think we should
continue adding /any/ option that came from a config file, because if
that makes for an invalid geometry then mkfs will just complain about it
and error out.
But I wouldn't have a program that generates a config file capture
geometry information, at least not without a special switch (e.g.
--capture-exact-config).
> > 2. Make xfs_db/xfs_info emit a similar configuration file based on an
> > existing filesystem. Anyone needing to create many feature-for-feature
> > replicas of an existing filesystem will now have a much easier time than
> > encoding options into a shell script.
> >
> > # xfs_info -c 'writecfg' /my/rad/fs > /root/rad.conf
> > # mkfs.xfs -c options=/root/rad.conf /dev/sda
> > # mkfs.xfs -c options=/root/rad.conf /dev/sdb
> > ...
> >
> > (maybe add an xfs_admin option to call xfs_{db,info} too?)
> >
> > What do you think?
> >
>
> I guess xfs_{db,info} option which would be used in xfs_admin makes sense.
> But again here comes a question should we emit exact copy or leave HW
> geometry aside?
I'd only write out user-visible filesystem features since (at least in
our experience at $employer) customers usually require either specific
features or compatibility with an older kernel.
If someone really wants hw geometry then we can add that later. ;)
--D
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2026-06-02 4:55 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-25 7:57 [RFC PATCH v2 0/5] Add option to use default config file Lukas Herbolt
2026-05-25 7:57 ` [RFC PATCH v2 1/5] xfsprogs: mkfs.xfs Add buildtime default cli_params as global variable Lukas Herbolt
2026-05-28 4:50 ` Darrick J. Wong
2026-05-29 18:02 ` Lukas Herbolt
2026-05-25 7:57 ` [RFC PATCH v2 2/5] xfsprogs: mkfs.xfs add default configuration file Lukas Herbolt
2026-05-28 4:56 ` Darrick J. Wong
2026-05-29 18:06 ` Lukas Herbolt
2026-05-25 7:57 ` [RFC PATCH v2 3/5] xfsprogs: mkfs.xfs add auto|autodetect value for -d/l/r concurrency Lukas Herbolt
2026-05-28 4:57 ` Darrick J. Wong
2026-05-29 18:07 ` Lukas Herbolt
2026-05-25 7:57 ` [RFC PATCH v2 4/5] xfs_admin: add -d option to manage default mkfs config file Lukas Herbolt
2026-05-28 5:00 ` Darrick J. Wong
2026-05-25 7:57 ` [RFC PATCH v2 5/5] xfsprogs: mkfs.xfs clean up unused dft option in various validators Lukas Herbolt
2026-05-28 5:01 ` Darrick J. Wong
2026-05-28 5:10 ` [RFC PATCH v2 0/5] Add option to use default config file Darrick J. Wong
2026-05-29 18:01 ` Lukas Herbolt
2026-06-02 4:55 ` 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