From a2d88f778a31111fcf98ecf3a690888bab07055e Mon Sep 17 00:00:00 2001 From: Tom Caputi Date: Wed, 7 Nov 2018 18:46:50 -0500 Subject: [PATCH] Fix !zilog_is_dirty() assert during ztest ztest occasionally hits an assert that !zilog_is_dirty() during zil_close(). This is caused by an interaction between 2 threads. First, ztest_run() waits for each test thread to complete and closes the associated dataset as soon as the thread joins. At the same time, the ztest_vdev_add_remove() test may attempt to remove the slog, which will open, dirty, and reset the logs on every dataset in the pool (including those of other threads). This patch simply ensures that we always join all of the test threads before closing any datasets. Reviewed-by: Matthew Ahrens Reviewed-by: Brian Behlendorf Signed-off-by: Tom Caputi Closes #8094 --- cmd/ztest/ztest.c | 12 +++++++++--- 1 file 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); }