aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/cmd/ztest.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/openzfs/cmd/ztest.c')
-rw-r--r--sys/contrib/openzfs/cmd/ztest.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/sys/contrib/openzfs/cmd/ztest.c b/sys/contrib/openzfs/cmd/ztest.c
index 89264c97ff10..2e88ae3e7994 100644
--- a/sys/contrib/openzfs/cmd/ztest.c
+++ b/sys/contrib/openzfs/cmd/ztest.c
@@ -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",
@@ -919,7 +919,7 @@ ztest_parse_name_value(const char *input, ztest_shared_opts_t *zo)
{
char name[32];
char *value;
- int state = ZTEST_VDEV_CLASS_RND;
+ int state;
(void) strlcpy(name, input, sizeof (name));
@@ -3882,7 +3882,7 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
* If newvd is too small, it should fail with EOVERFLOW.
*
* If newvd is a distributed spare and it's being attached to a
- * dRAID which is not its parent it should fail with EINVAL.
+ * dRAID which is not its parent it should fail with ENOTSUP.
*/
if (pvd->vdev_ops != &vdev_mirror_ops &&
pvd->vdev_ops != &vdev_root_ops && (!replacing ||
@@ -3901,7 +3901,7 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
else if (ashift > oldvd->vdev_top->vdev_ashift)
expected_error = EDOM;
else if (newvd_is_dspare && pvd != vdev_draid_spare_get_parent(newvd))
- expected_error = EINVAL;
+ expected_error = ENOTSUP;
else
expected_error = 0;
@@ -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");
@@ -7813,6 +7813,9 @@ ztest_dataset_open(int d)
ztest_dataset_name(name, ztest_opts.zo_pool, d);
+ if (ztest_opts.zo_verbose >= 6)
+ (void) printf("Opening %s\n", name);
+
(void) pthread_rwlock_rdlock(&ztest_name_lock);
error = ztest_dataset_create(name);
@@ -8308,41 +8311,44 @@ static void
ztest_generic_run(ztest_shared_t *zs, spa_t *spa)
{
kthread_t **run_threads;
- int t;
+ int i, ndatasets;
run_threads = umem_zalloc(ztest_opts.zo_threads * sizeof (kthread_t *),
UMEM_NOFAIL);
/*
- * Kick off all the tests that run in parallel.
+ * Actual number of datasets to be used.
*/
- for (t = 0; t < ztest_opts.zo_threads; t++) {
- if (t < ztest_opts.zo_datasets && ztest_dataset_open(t) != 0) {
- umem_free(run_threads, ztest_opts.zo_threads *
- sizeof (kthread_t *));
- return;
- }
+ ndatasets = MIN(ztest_opts.zo_datasets, ztest_opts.zo_threads);
- run_threads[t] = thread_create(NULL, 0, ztest_thread,
- (void *)(uintptr_t)t, 0, NULL, TS_RUN | TS_JOINABLE,
+ /*
+ * Prepare the datasets first.
+ */
+ for (i = 0; i < ndatasets; i++)
+ VERIFY0(ztest_dataset_open(i));
+
+ /*
+ * Kick off all the tests that run in parallel.
+ */
+ for (i = 0; i < ztest_opts.zo_threads; i++) {
+ run_threads[i] = thread_create(NULL, 0, ztest_thread,
+ (void *)(uintptr_t)i, 0, NULL, TS_RUN | TS_JOINABLE,
defclsyspri);
}
/*
* Wait for all of the tests to complete.
*/
- for (t = 0; t < ztest_opts.zo_threads; t++)
- VERIFY0(thread_join(run_threads[t]));
+ for (i = 0; i < ztest_opts.zo_threads; i++)
+ VERIFY0(thread_join(run_threads[i]));
/*
* Close all datasets. This must be done after all the threads
* are joined so we can be sure none of the datasets are in-use
* by any of the threads.
*/
- for (t = 0; t < ztest_opts.zo_threads; t++) {
- if (t < ztest_opts.zo_datasets)
- ztest_dataset_close(t);
- }
+ for (i = 0; i < ndatasets; i++)
+ ztest_dataset_close(i);
txg_wait_synced(spa_get_dsl(spa), 0);
@@ -8465,6 +8471,7 @@ ztest_run(ztest_shared_t *zs)
int d = ztest_random(ztest_opts.zo_datasets);
ztest_dataset_destroy(d);
+ txg_wait_synced(spa_get_dsl(spa), 0);
}
zs->zs_enospc_count = 0;