mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
libzpool: tunable-based option interface for zdb/ztest
Removes the old dlsym() based option setter and adds a new function handle_tunable_option() that can set, get and list all the tunables in the system. And then wire it up to zdb and ztest. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17537
This commit is contained in:
committed by
Brian Behlendorf
parent
cb9742e532
commit
fce18e04d5
+12
-4
@@ -797,8 +797,8 @@ usage(void)
|
||||
"[default is 200]\n");
|
||||
(void) fprintf(stderr, " -K --key=KEY "
|
||||
"decryption key for encrypted dataset\n");
|
||||
(void) fprintf(stderr, " -o --option=\"OPTION=INTEGER\" "
|
||||
"set global variable to an unsigned 32-bit integer\n");
|
||||
(void) fprintf(stderr, " -o --option=\"NAME=VALUE\" "
|
||||
"set the named tunable to the given value\n");
|
||||
(void) fprintf(stderr, " -p --path==PATH "
|
||||
"use one or more with -e to specify path to vdev dir\n");
|
||||
(void) fprintf(stderr, " -P --parseable "
|
||||
@@ -9377,9 +9377,11 @@ main(int argc, char **argv)
|
||||
while (*optarg != '\0') { *optarg++ = '*'; }
|
||||
break;
|
||||
case 'o':
|
||||
error = set_global_var(optarg);
|
||||
dump_opt[c]++;
|
||||
dump_all = 0;
|
||||
error = handle_tunable_option(optarg, B_FALSE);
|
||||
if (error != 0)
|
||||
usage();
|
||||
zdb_exit(1);
|
||||
break;
|
||||
case 'p':
|
||||
if (searchdirs == NULL) {
|
||||
@@ -9545,6 +9547,12 @@ main(int argc, char **argv)
|
||||
error = 0;
|
||||
goto fini;
|
||||
}
|
||||
if (dump_opt['o'])
|
||||
/*
|
||||
* Avoid blasting tunable options off the top of the
|
||||
* screen.
|
||||
*/
|
||||
zdb_exit(1);
|
||||
usage();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -809,8 +809,8 @@ static ztest_option_t option_table[] = {
|
||||
{ 'X', "raidz-expansion", NULL,
|
||||
"Perform a dedicated raidz expansion test",
|
||||
NO_DEFAULT, NULL},
|
||||
{ 'o', "option", "\"OPTION=INTEGER\"",
|
||||
"Set global variable to an unsigned 32-bit integer value",
|
||||
{ 'o', "option", "\"NAME=VALUE\"",
|
||||
"Set the named tunable to the given value",
|
||||
NO_DEFAULT, NULL},
|
||||
{ 'G', "dump-debug-msg", NULL,
|
||||
"Dump zfs_dbgmsg buffer before exiting due to an error",
|
||||
@@ -7069,7 +7069,7 @@ ztest_set_global_vars(void)
|
||||
char *kv = ztest_opts.zo_gvars[i];
|
||||
VERIFY3U(strlen(kv), <=, ZO_GVARS_MAX_ARGLEN);
|
||||
VERIFY3U(strlen(kv), >, 0);
|
||||
int err = set_global_var(kv);
|
||||
int err = handle_tunable_option(kv, B_TRUE);
|
||||
if (ztest_opts.zo_verbose > 0) {
|
||||
(void) printf("setting global var %s ... %s\n", kv,
|
||||
err ? "failed" : "ok");
|
||||
|
||||
Reference in New Issue
Block a user