X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fztest%2Fztest.c;h=9b7adc7264fb83cb718be20af021797eb7f4a43d;hb=3bc7e0fb0f3904eaf41e0b9768ebe2d042ae98aa;hp=bc2f56fb878b27e233158521e94c12194fdb652e;hpb=facbbe436670b4910475fb937a26468f7178b541;p=zfs.git diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index bc2f56f..9b7adc7 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -109,6 +109,7 @@ #include #include #include +#include #include #include #include @@ -360,17 +361,11 @@ ztest_info_t ztest_info[] = { { ztest_fault_inject, 1, &zopt_sometimes }, { ztest_ddt_repair, 1, &zopt_sometimes }, { ztest_dmu_snapshot_hold, 1, &zopt_sometimes }, - /* - * The reguid test is currently broken. Disable it until - * we get around to fixing it. - */ -#if 0 { ztest_reguid, 1, &zopt_sometimes }, -#endif { ztest_spa_rename, 1, &zopt_rarely }, { ztest_scrub, 1, &zopt_rarely }, { ztest_dsl_dataset_promote_busy, 1, &zopt_rarely }, - { ztest_vdev_attach_detach, 1, &zopt_rarely }, + { ztest_vdev_attach_detach, 1, &zopt_rarely }, { ztest_vdev_LUN_growth, 1, &zopt_rarely }, { ztest_vdev_add_remove, 1, &ztest_opts.zo_vdevtime }, @@ -421,6 +416,13 @@ static spa_t *ztest_spa = NULL; static ztest_ds_t *ztest_ds; static kmutex_t ztest_vdev_lock; + +/* + * The ztest_name_lock protects the pool and dataset namespace used by + * the individual tests. To modify the namespace, consumers must grab + * this lock as writer. Grabbing the lock as reader will ensure that the + * namespace does not change while the lock is held. + */ static krwlock_t ztest_name_lock; static boolean_t ztest_dump_core = B_TRUE; @@ -729,14 +731,17 @@ process_options(int argc, char **argv) UINT64_MAX >> 2); if (strlen(altdir) > 0) { - char cmd[MAXNAMELEN]; - char realaltdir[MAXNAMELEN]; + char *cmd; + char *realaltdir; char *bin; char *ztest; char *isa; int isalen; - (void) realpath(getexecname(), cmd); + cmd = umem_alloc(MAXPATHLEN, UMEM_NOFAIL); + realaltdir = umem_alloc(MAXPATHLEN, UMEM_NOFAIL); + + VERIFY(NULL != realpath(getexecname(), cmd)); if (0 != access(altdir, F_OK)) { ztest_dump_core = B_FALSE; fatal(B_TRUE, "invalid alternate ztest path: %s", @@ -767,6 +772,9 @@ process_options(int argc, char **argv) fatal(B_TRUE, "invalid alternate lib directory %s", zo->zo_alt_libpath); } + + umem_free(cmd, MAXPATHLEN); + umem_free(realaltdir, MAXPATHLEN); } } @@ -5033,10 +5041,16 @@ ztest_reguid(ztest_ds_t *zd, uint64_t id) { spa_t *spa = ztest_spa; uint64_t orig, load; + int error; orig = spa_guid(spa); load = spa_load_guid(spa); - if (spa_change_guid(spa) != 0) + + (void) rw_enter(&ztest_name_lock, RW_WRITER); + error = spa_change_guid(spa); + (void) rw_exit(&ztest_name_lock); + + if (error != 0) return; if (ztest_opts.zo_verbose >= 3) { @@ -5283,11 +5297,13 @@ ztest_resume_thread(void *arg) #define GRACE 300 +#if 0 static void ztest_deadman_alarm(int sig) { fatal(0, "failed to complete within %d seconds of deadline", GRACE); } +#endif static void ztest_execute(int test, ztest_info_t *zi, uint64_t id) @@ -5544,11 +5560,13 @@ ztest_run(ztest_shared_t *zs) (thread_func_t)ztest_resume_thread, spa, TS_RUN, NULL, 0, 0, PTHREAD_CREATE_JOINABLE)), !=, NULL); +#if 0 /* * Set a deadman alarm to abort() if we hang. */ signal(SIGALRM, ztest_deadman_alarm); alarm((zs->zs_thread_stop - zs->zs_thread_start) / NANOSEC + GRACE); +#endif /* * Verify that we can safely inquire about about any object, @@ -5727,6 +5745,12 @@ ztest_freeze(void) VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG)); VERIFY3U(0, ==, ztest_dataset_open(0)); ztest_dataset_close(0); + + spa->spa_debug = B_TRUE; + ztest_spa = spa; + txg_wait_synced(spa_get_dsl(spa), 0); + ztest_reguid(NULL, 0); + spa_close(spa, FTAG); kernel_fini(); } @@ -5761,10 +5785,9 @@ make_random_props(void) { nvlist_t *props; - if (ztest_random(2) == 0) - return (NULL); - VERIFY(nvlist_alloc(&props, NV_UNIQUE_NAME, 0) == 0); + if (ztest_random(2) == 0) + return (props); VERIFY(nvlist_add_uint64(props, "autoreplace", 1) == 0); return (props); @@ -5779,6 +5802,7 @@ ztest_init(ztest_shared_t *zs) { spa_t *spa; nvlist_t *nvroot, *props; + int i; mutex_init(&ztest_vdev_lock, NULL, MUTEX_DEFAULT, NULL); rw_init(&ztest_name_lock, NULL, RW_DEFAULT, NULL); @@ -5795,6 +5819,13 @@ ztest_init(ztest_shared_t *zs) nvroot = make_vdev_root(NULL, NULL, ztest_opts.zo_vdev_size, 0, 0, ztest_opts.zo_raidz, zs->zs_mirrors, 1); props = make_random_props(); + for (i = 0; i < SPA_FEATURES; i++) { + char *buf; + VERIFY3S(-1, !=, asprintf(&buf, "feature@%s", + spa_feature_table[i].fi_uname)); + VERIFY3U(0, ==, nvlist_add_uint64(props, buf, 0)); + free(buf); + } VERIFY3U(0, ==, spa_create(ztest_opts.zo_pool, nvroot, props, NULL, NULL)); nvlist_free(nvroot); @@ -6030,8 +6061,8 @@ main(int argc, char **argv) ASSERT3U(ztest_opts.zo_datasets, ==, ztest_shared_hdr->zh_ds_count); /* Override location of zpool.cache */ - (void) asprintf((char **)&spa_config_path, "%s/zpool.cache", - ztest_opts.zo_dir); + VERIFY(asprintf((char **)&spa_config_path, "%s/zpool.cache", + ztest_opts.zo_dir) != -1); ztest_ds = umem_alloc(ztest_opts.zo_datasets * sizeof (ztest_ds_t), UMEM_NOFAIL);