summaryrefslogtreecommitdiff
path: root/usr/src/cmd/ztest/ztest.c
diff options
context:
space:
mode:
authorGeorge Wilson <george.wilson@delphix.com>2012-08-22 08:03:38 -0700
committerGeorge Wilson <george.wilson@delphix.com>2012-08-22 08:03:38 -0700
commitdfbb943217bf8ab22a1a9d2e9dca01d4da95ee0b (patch)
tree07a8d056aa67372833aee9a16300021984d91c1a /usr/src/cmd/ztest/ztest.c
parentce636f8b38e8c9ff484e880d9abb27251a882860 (diff)
downloadillumos-joyent-dfbb943217bf8ab22a1a9d2e9dca01d4da95ee0b.tar.gz
3090 vdev_reopen() during reguid causes vdev to be treated as corrupt
3102 vdev_uberblock_load() and vdev_validate() may read the wrong label Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Christopher Siden <chris.siden@delphix.com> Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Eric Schrock <Eric.Schrock@delphix.com>
Diffstat (limited to 'usr/src/cmd/ztest/ztest.c')
-rw-r--r--usr/src/cmd/ztest/ztest.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/usr/src/cmd/ztest/ztest.c b/usr/src/cmd/ztest/ztest.c
index f196601057..bb6398cbda 100644
--- a/usr/src/cmd/ztest/ztest.c
+++ b/usr/src/cmd/ztest/ztest.c
@@ -362,7 +362,7 @@ ztest_info_t ztest_info[] = {
{ 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 },
@@ -413,6 +413,13 @@ static spa_t *ztest_spa = NULL;
static ztest_ds_t *ztest_ds;
static mutex_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 rwlock_t ztest_name_lock;
static boolean_t ztest_dump_core = B_TRUE;
@@ -4854,10 +4861,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_wrlock(&ztest_name_lock);
+ error = spa_change_guid(spa);
+ (void) rw_unlock(&ztest_name_lock);
+
+ if (error != 0)
return;
if (ztest_opts.zo_verbose >= 3) {
@@ -5536,6 +5549,12 @@ ztest_freeze(void)
ASSERT(spa_freeze_txg(spa) == UINT64_MAX);
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();
}