]> granicus.if.org Git - zfs/blobdiff - cmd/ztest/ztest.c
ztest: reduce gangblock creation
[zfs] / cmd / ztest / ztest.c
index 983bc0dfe03685ee7385202e49225f69cd48dbad..1ad87bb30cdf45d26dd9d1af59eeb5cf21cce723 100644 (file)
 #include <sys/fs/zfs.h>
 #include <zfs_fletcher.h>
 #include <libnvpair.h>
-#include <libzfs.h>
+#include <libzutil.h>
 #include <sys/crypto/icp.h>
 #ifdef __GLIBC__
 #include <execinfo.h> /* for backtrace() */
@@ -201,7 +201,7 @@ static const ztest_shared_opts_t ztest_opts_defaults = {
        .zo_init = 1,
        .zo_time = 300,                 /* 5 minutes */
        .zo_maxloops = 50,              /* max loops during spa_freeze() */
-       .zo_metaslab_force_ganging = 32 << 10,
+       .zo_metaslab_force_ganging = 64 << 10,
        .zo_special_vdevs = ZTEST_VDEV_CLASS_RND,
 };
 
@@ -3549,6 +3549,15 @@ ztest_device_removal(ztest_ds_t *zd, uint64_t id)
                ztest_device_removal_active = B_TRUE;
                mutex_exit(&ztest_vdev_lock);
 
+               /*
+                * spa->spa_vdev_removal is created in a sync task that
+                * is initiated via dsl_sync_task_nowait(). Since the
+                * task may not run before spa_vdev_remove() returns, we
+                * must wait at least 1 txg to ensure that the removal
+                * struct has been created.
+                */
+               txg_wait_synced(spa_get_dsl(spa), 0);
+
                while (spa->spa_vdev_removal != NULL)
                        txg_wait_synced(spa_get_dsl(spa), 0);
        } else {
@@ -7056,7 +7065,6 @@ make_random_props(void)
 static void
 ztest_import(ztest_shared_t *zs)
 {
-       libzfs_handle_t *hdl;
        importargs_t args = { 0 };
        spa_t *spa;
        nvlist_t *cfg = NULL;
@@ -7071,14 +7079,14 @@ ztest_import(ztest_shared_t *zs)
        VERIFY0(pthread_rwlock_init(&ztest_name_lock, NULL));
 
        kernel_init(FREAD | FWRITE);
-       hdl = libzfs_init();
 
        searchdirs[0] = ztest_opts.zo_dir;
        args.paths = nsearch;
        args.path = searchdirs;
        args.can_be_active = B_FALSE;
 
-       error = zpool_tryimport(hdl, name, &cfg, &args);
+       error = zpool_find_config(NULL, name, &cfg, &args,
+           &libzpool_config_ops);
        if (error)
                (void) fatal(0, "No pools found\n");
 
@@ -7088,7 +7096,6 @@ ztest_import(ztest_shared_t *zs)
            1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift;
        spa_close(spa, FTAG);
 
-       libzfs_fini(hdl);
        kernel_fini();
 
        if (!ztest_opts.zo_mmp_test) {