Skip to content

Commit 621dd7b

Browse files
grwilsonbehlendorf
authored andcommitted
Illumos #3949, #3950, #3952, #3953
3949 ztest fault injection should avoid resilvering devices 3950 ztest: deadman fires when we're doing a scan 3951 ztest hang when running dedup test 3952 ztest: ztest_reguid test and ztest_fault_inject don't place nice together Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Adam Leventhal <ahl@delphix.com> Approved by: Richard Lowe <richlowe@richlowe.net> References: https://www.illumos.org/issues/3949 https://www.illumos.org/issues/3950 https://www.illumos.org/issues/3951 https://www.illumos.org/issues/3952 illumos/illumos-gate@2c1e2b4 Ported-by: Richard Yao <ryao@gentoo.org> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue #1775 Porting notes: 1. The deadman thread was removed from ztest during the original port because it depended on Solaris thr_create() interface. This functionality should be reintroduced using the more portable pthreads.
1 parent 383fc4a commit 621dd7b

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

cmd/ztest/ztest.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ ztest_info_t ztest_info[] = {
366366
{ ztest_fault_inject, 1, &zopt_sometimes },
367367
{ ztest_ddt_repair, 1, &zopt_sometimes },
368368
{ ztest_dmu_snapshot_hold, 1, &zopt_sometimes },
369-
{ ztest_reguid, 1, &zopt_sometimes },
369+
{ ztest_reguid, 1, &zopt_rarely },
370370
{ ztest_spa_rename, 1, &zopt_rarely },
371371
{ ztest_scrub, 1, &zopt_rarely },
372372
{ ztest_spa_upgrade, 1, &zopt_rarely },
@@ -4913,6 +4913,14 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
49134913

49144914
ASSERT(leaves >= 1);
49154915

4916+
/*
4917+
* Grab the name lock as reader. There are some operations
4918+
* which don't like to have their vdevs changed while
4919+
* they are in progress (i.e. spa_change_guid). Those
4920+
* operations will have grabbed the name lock as writer.
4921+
*/
4922+
(void) rw_enter(&ztest_name_lock, RW_READER);
4923+
49164924
/*
49174925
* We need SCL_STATE here because we're going to look at vd0->vdev_tsd.
49184926
*/
@@ -4942,7 +4950,14 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
49424950
if (vd0 != NULL && vd0->vdev_top->vdev_islog)
49434951
islog = B_TRUE;
49444952

4945-
if (vd0 != NULL && maxfaults != 1) {
4953+
/*
4954+
* If the top-level vdev needs to be resilvered
4955+
* then we only allow faults on the device that is
4956+
* resilvering.
4957+
*/
4958+
if (vd0 != NULL && maxfaults != 1 &&
4959+
(!vdev_resilver_needed(vd0->vdev_top, NULL, NULL) ||
4960+
vd0->vdev_resilvering)) {
49464961
/*
49474962
* Make vd0 explicitly claim to be unreadable,
49484963
* or unwriteable, or reach behind its back
@@ -4973,6 +4988,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
49734988

49744989
if (sav->sav_count == 0) {
49754990
spa_config_exit(spa, SCL_STATE, FTAG);
4991+
(void) rw_exit(&ztest_name_lock);
49764992
goto out;
49774993
}
49784994
vd0 = sav->sav_vdevs[ztest_random(sav->sav_count)];
@@ -4986,6 +5002,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
49865002
}
49875003

49885004
spa_config_exit(spa, SCL_STATE, FTAG);
5005+
(void) rw_exit(&ztest_name_lock);
49895006

49905007
/*
49915008
* If we can tolerate two or more faults, or we're dealing

module/zfs/spa.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ spa_change_guid(spa_t *spa)
752752
int error;
753753
uint64_t guid;
754754

755+
mutex_enter(&spa->spa_vdev_top_lock);
755756
mutex_enter(&spa_namespace_lock);
756757
guid = spa_generate_guid(NULL);
757758

@@ -764,6 +765,7 @@ spa_change_guid(spa_t *spa)
764765
}
765766

766767
mutex_exit(&spa_namespace_lock);
768+
mutex_exit(&spa->spa_vdev_top_lock);
767769

768770
return (error);
769771
}
@@ -4737,7 +4739,6 @@ spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid, int replace_done)
47374739
if (pvd->vdev_ops == &vdev_spare_ops)
47384740
cvd->vdev_unspare = B_FALSE;
47394741
vdev_remove_parent(cvd);
4740-
cvd->vdev_resilvering = B_FALSE;
47414742
}
47424743

47434744

@@ -5369,6 +5370,13 @@ spa_vdev_resilver_done_hunt(vdev_t *vd)
53695370
return (oldvd);
53705371
}
53715372

5373+
if (vd->vdev_resilvering && vdev_dtl_empty(vd, DTL_MISSING) &&
5374+
vdev_dtl_empty(vd, DTL_OUTAGE)) {
5375+
ASSERT(vd->vdev_ops->vdev_op_leaf);
5376+
vd->vdev_resilvering = B_FALSE;
5377+
vdev_config_dirty(vd->vdev_top);
5378+
}
5379+
53725380
/*
53735381
* Check for a completed replacement. We always consider the first
53745382
* vdev in the list to be the oldest vdev, and the last one to be

module/zfs/vdev_file.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ vdev_file_io_strategy(void *arg)
162162
static int
163163
vdev_file_io_start(zio_t *zio)
164164
{
165-
spa_t *spa = zio->io_spa;
166165
vdev_t *vd = zio->io_vd;
167166
vdev_file_t *vf = vd->vdev_tsd;
168167

@@ -185,8 +184,8 @@ vdev_file_io_start(zio_t *zio)
185184
return (ZIO_PIPELINE_CONTINUE);
186185
}
187186

188-
spa_taskq_dispatch_ent(spa, ZIO_TYPE_FREE, ZIO_TASKQ_ISSUE,
189-
vdev_file_io_strategy, zio, 0, &zio->io_tqent);
187+
VERIFY3U(taskq_dispatch(system_taskq, vdev_file_io_strategy, zio,
188+
TQ_SLEEP), !=, 0);
190189

191190
return (ZIO_PIPELINE_STOP);
192191
}

0 commit comments

Comments
 (0)