Add option to use default config file.
v2 cover Add option to use default config file.
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.exampleSignature · 1 line
2.54.0
RFC PATCH v2 1/5 xfsprogs: mkfs.xfs Add buildtime default cli_params as global variable
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.
--- mkfs/xfs_mkfs.c | 116 +++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 66 deletions(-)
mkfs/xfs_mkfs.c +50 -66
@@ -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 voidvalidate_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 voidvalidate_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 voidvalidate_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);/*
Signature · 1 line
2.54.0
Re: [RFC PATCH v2 1/5] xfsprogs: mkfs.xfs Add buildtime default cli_params as global variable
Quoted 20 lines · Lukas Herbolt
This patch unites the settings of
cli_paramsandmkfs_default_paramsinto 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 <[email protected]>--- mkfs/xfs_mkfs.c | 116 +++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 66 deletions(-)mkfs/xfs_mkfs.c +0
-2@@ -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 */
mkfs/xfs_mkfs.c struct mkfs_params { · line 1193
Quoted 10 lines
mkfs/xfs_mkfs.c +1
-9- -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.
Quoted 154 lines
mkfs/xfs_mkfs.c +45
-51+ .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 voidvalidate_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 voidvalidate_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 voidvalidate_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) {
mkfs/xfs_mkfs.c main( · line 6081
Quoted 7 lines
mkfs/xfs_mkfs.c +2
-2@@ -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
Quoted 17 lines
mkfs/xfs_mkfs.c +2
-2/* * 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);/* Signature · 1 line
2.54.0
Re: [RFC PATCH v2 1/5] xfsprogs: mkfs.xfs Add buildtime default cli_params as global variable
Quoted 36 lines · Darrick J. Wong
Quoted 22 lines · Lukas Herbolt
This patch unites the settings of
cli_paramsandmkfs_default_paramsinto 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 <[email protected]>--- mkfs/xfs_mkfs.c | 116 +++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 66 deletions(-)mkfs/xfs_mkfs.c +0
-0@@ -1190,17 +1190,44 @@ struct mkfs_params {* values directly - they are inputs to the mkfs geometry validation and
* calculations.
*/mkfs/xfs_mkfs.c +0
-2-struct mkfs_default_params { -char *source;/* where the defaults came from */ mkfs/xfs_mkfs.c struct mkfs_params { · line 1193
Quoted 10 lines
mkfs/xfs_mkfs.c +1
-9- -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?
Quoted 3 lines
and please spell out "
build_default", we are no longer being charged by the byte for source code.
Thanks noted!
Signature · 1 line
-lhe
RFC PATCH v2 2/5 xfsprogs: mkfs.xfs add default configuration file.
In reply to Lukas HerboltVarious 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.
--- 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
include/builddefs.in +1 -0
@@ -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
mkfs/Makefile +2 -0
@@ -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)
mkfs/default.conf.example new file +10 -0
@@ -0,0 +1,10 @@ +# Default config file example. +#[metadata] +#bigtime=1 +#crc=1 + +#[inode] +#sparse=1 + +#[naming] +#parent=1
mkfs/xfs_mkfs.c +95 -18
148 lines not on this page · raw message
Signature · 1 line
2.54.0
Re: [RFC PATCH v2 2/5] xfsprogs: mkfs.xfs add default configuration file.
Quoted 80 lines · 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 <[email protected]>--- 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.exampleinclude/builddefs.in +1
-0@@ -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.stampmkfs/Makefile +2
-0@@ -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)mkfs/default.conf.example new file +10
-0@@ -0,0 +1,10 @@ +# Default config file example. +#[metadata] +#bigtime=1 +#crc=1 + +#[inode] +#sparse=1 + +#[naming] +#parent=1mkfs/xfs_mkfs.c +5
-0@@ -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().
mkfs/xfs_mkfs.c cfgfile_parse( · line 5808
Quoted 5 lines
mkfs/xfs_mkfs.c +1
-1@@ -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.
Quoted 17 lines
mkfs/xfs_mkfs.c +10
-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)) {
mkfs/xfs_mkfs.c check_rt_meta_prealloc( · line 5980
Quoted 10 lines
mkfs/xfs_mkfs.c +10
-0+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...
mkfs/xfs_mkfs.c check_rt_meta_prealloc( · line 5992
Quoted 12 lines
mkfs/xfs_mkfs.c +12
-0+ } + +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...
mkfs/xfs_mkfs.c check_rt_meta_prealloc( · line 5997
Quoted 5 lines
mkfs/xfs_mkfs.c +5
-0+ } + +if (strcmp (section,"block" ) ==0 &&strcmp (key,"size" ) ==0 ) { + dflt->blocksize =1 <<XFS_DFL_BLOCKSIZE_LOG ; + need_warn = true;
...and here.
mkfs/xfs_mkfs.c check_rt_meta_prealloc( · line 6004
Quoted 7 lines
mkfs/xfs_mkfs.c +7
-0+ } + +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?
Quoted 62 lines
mkfs/xfs_mkfs.c +29
-14+ +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.
mkfs/xfs_mkfs.c main( · line 6085
Quoted 10 lines
mkfs/xfs_mkfs.c +7
-3-* -* 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?
mkfs/xfs_mkfs.c main( · line 6091
Quoted 6 lines
mkfs/xfs_mkfs.c +6
-0+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
Quoted 10 lines
mkfs/xfs_mkfs.c +3
-0+ 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 ) {Signature · 1 line
2.54.0
Re: [RFC PATCH v2 2/5] xfsprogs: mkfs.xfs add default configuration file.
Quoted 146 lines · Darrick J. Wong
Quoted 84 lines · 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 <[email protected]>--- 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.exampleinclude/builddefs.in +1
-0@@ -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
mkfs/Makefile +2
-1@@ -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)mkfs/default.conf.example new file +10
-0@@ -0,0 +1,10 @@ +# Default config file example. +#[metadata] +#bigtime=1 +#crc=1 + +#[inode] +#sparse=1 + +#[naming] +#parent=1mkfs/xfs_mkfs.c +5
-0@@ -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().mkfs/xfs_mkfs.c cfgfile_parse( · line 5808
Quoted 5 lines
mkfs/xfs_mkfs.c +1
-1@@ -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.
Quoted 17 lines
mkfs/xfs_mkfs.c +10
-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)) {mkfs/xfs_mkfs.c check_rt_meta_prealloc( · line 5980
Quoted 10 lines
mkfs/xfs_mkfs.c +10
-0+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...
mkfs/xfs_mkfs.c check_rt_meta_prealloc( · line 5992
Quoted 12 lines
mkfs/xfs_mkfs.c +12
-0+ } + +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...
mkfs/xfs_mkfs.c check_rt_meta_prealloc( · line 5997
Quoted 5 lines
mkfs/xfs_mkfs.c +5
-0+ } + +if (strcmp (section,"block" ) ==0 &&strcmp (key,"size" ) ==0 ) { + dflt->blocksize =1 <<XFS_DFL_BLOCKSIZE_LOG ; + need_warn = true;...and here.
Quoted 12 lines
mkfs/xfs_mkfs.c check_rt_meta_prealloc( · line 6004
Quoted 7 lines
mkfs/xfs_mkfs.c +7
-0+ } + +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!
Signature · 1 line
-lhe
RFC PATCH v2 3/5 xfsprogs: mkfs.xfs add auto|autodetect value for -d/l/r concurrency
In reply to Lukas HerboltAdd autodetect|auto value for concurrency option to restore the current default behavior concurrency detection on SSDs.
--- mkfs/xfs_mkfs.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
mkfs/xfs_mkfs.c +10 -1
@@ -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);
Signature · 1 line
2.54.0
Re: [RFC PATCH v2 3/5] xfsprogs: mkfs.xfs add auto|autodetect value for -d/l/r concurrency
Quoted 6 lines · Lukas Herbolt
Add autodetect|auto value for concurrency option to restore the current default behavior concurrency detection on SSDs.
Signed-off-by Lukas Herbolt <[email protected]>--- 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
Quoted 51 lines
1 file changed, 10 insertions(+), 1 deletion(-)mkfs/xfs_mkfs.c +10
-1@@ -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);Signature · 1 line
2.54.0
Re: [RFC PATCH v2 3/5] xfsprogs: mkfs.xfs add auto|autodetect value for -d/l/r concurrency
Quoted 9 lines · Darrick J. Wong
Quoted 6 lines · Lukas Herbolt
Add autodetect|auto value for concurrency option to restore the current default behavior concurrency detection on SSDs.
Signed-off-by Lukas Herbolt <[email protected]>--- mkfs/xfs_mkfs.c | 11 ++++++++++-Needs a manual page change to note that you can say -d concurrency=auto.
Thanks I will add it.
Signature · 1 line
-lhe
RFC PATCH v2 4/5 xfs_admin: add -d option to manage default mkfs config file
In reply to Lukas HerboltAdd -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.
---
.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%).gitignore +3 -0
@@ -89,3 +89,6 @@ cscope.* # docs /man/man8/mkfs.xfs.8 /man/man8/xfs_scrub_all.8 + +#generated bash +db/xfs_admin.sh
db/Makefile +9 -2
@@ -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)
db/xfs_admin.sh.in renamed from db/xfs_admin.sh +28 -2
@@ -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 ;;
Signature · 1 line
2.54.0
Re: [RFC PATCH v2 4/5] xfs_admin: add -d option to manage default mkfs config file
Quoted 68 lines · 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.shis now generated from xfs_admin.sh.in to set the default config file location bsed on the ./configure.Signed-off-by Lukas Herbolt <[email protected]>--- .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%).gitignore +3
-0@@ -89,3 +89,6 @@ cscope.* # docs /man/man8/mkfs.xfs.8 /man/man8/xfs_scrub_all.8 + +#generated bash +db/xfs_admin.shdb/Makefile +9
-2@@ -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)db/xfs_admin.sh.in renamed from db/xfs_admin.sh +0
-0@@ -13,11 +13,37 @@ REPAIR_OPTS="" IO_OPTS="" REPAIR_DEV_OPTS="" LOG_OPTS=""
db/xfs_admin.sh.in REPAIR_OPTS="" · line 23
Quoted 10 lines
db/xfs_admin.sh.in renamed from db/xfs_admin.sh +5
-2-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.
db/xfs_admin.sh.in REPAIR_OPTS="" · line 33
Quoted 10 lines
db/xfs_admin.sh.in renamed from db/xfs_admin.sh +10
-0+ 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
Quoted 20 lines
db/xfs_admin.sh.in renamed from db/xfs_admin.sh +13
-0+ 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 ;;Signature · 1 line
2.54.0
RFC PATCH v2 5/5 xfsprogs: mkfs.xfs clean up unused dft option in various validators
In reply to Lukas HerboltThe 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.
--- mkfs/xfs_mkfs.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
mkfs/xfs_mkfs.c +11 -13
@@ -2392,7 +2392,6 @@ static voidvalidate_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 voidvalidate_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);/*
Signature · 1 line
2.54.0
Re: [RFC PATCH v2 5/5] xfsprogs: mkfs.xfs clean up unused dft option in various validators
Quoted 6 lines · Lukas Herbolt
The struct
cli_paramsdft was only used invalidate_blocksize(). Now the cli.blocksize is always set either overbld_dfltorfile_dfltor from command line/config file. All the other functions are not accessing the dft in their body.Signed-off-by Lukas Herbolt <[email protected]>
I wish this had come first, but oh well whatever.
--D
Quoted 84 lines
--- mkfs/xfs_mkfs.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)mkfs/xfs_mkfs.c +11
-13@@ -2392,7 +2392,6 @@ static voidvalidate_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 voidvalidate_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);/* Signature · 1 line
2.54.0
Quoted 10 lines · 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.
Quoted 4 lines
I moved setting of some values in
cli_paramsand setting ofmkfs_default_paramsinto newbld_dftstruct 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
Quoted 23 lines
Lukas Herbolt (5):
xfsprogs: mkfs.xfs Add buildtime defaultcli_paramsas 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.exampleSignature · 1 line
2.54.0
Quoted 29 lines · Darrick J. Wong
Quoted 10 lines · 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.
Quoted 4 lines
I moved setting of some values in
cli_paramsand setting ofmkfs_default_paramsinto newbld_dftstruct 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 ...
Quoted 5 lines
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?
Quoted 6 lines
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.
Quoted 9 lines
# 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_adminoption 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?
Signature · 1 line
-lhe
Quoted 39 lines · Lukas Herbolt
Quoted 32 lines · Darrick J. Wong
Quoted 10 lines · 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.
Quoted 7 lines
I moved setting of some values in
cli_paramsand setting ofmkfs_default_params
into newbld_dftstruct 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 ...Quoted 5 lines
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.
Quoted 7 lines
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 callingusage()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).
Quoted 10 lines
Quoted 10 lines
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 ...
Quoted 8 lines
Quoted 4 lines
(maybe add an
xfs_adminoption to call xfs_{db,info} too?)What do you think?
I guess xfs_{db,info} option which would be used in
xfs_adminmakes 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