summaryrefslogtreecommitdiffstats
path: root/cmd/ztest/ztest.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/ztest/ztest.c')
-rw-r--r--cmd/ztest/ztest.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c
index 36647c4ff..eab8940fb 100644
--- a/cmd/ztest/ztest.c
+++ b/cmd/ztest/ztest.c
@@ -6918,11 +6918,17 @@ ztest_run(ztest_shared_t *zs)
}
/*
- * Wait for all of the tests to complete. We go in reverse order
- * so we don't close datasets while threads are still using them.
+ * Wait for all of the tests to complete.
*/
- for (t = ztest_opts.zo_threads - 1; t >= 0; t--) {
+ for (t = 0; t < ztest_opts.zo_threads; t++)
VERIFY0(thread_join(run_threads[t]));
+
+ /*
+ * 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);
}