Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More ztest fixes #8061

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 59 additions & 11 deletions cmd/ztest/ztest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1304,19 +1304,18 @@ ztest_dmu_objset_own(const char *name, dmu_objset_type_t type,
boolean_t readonly, boolean_t decrypt, void *tag, objset_t **osp)
{
int err;
char *cp = NULL;
char ddname[ZFS_MAX_DATASET_NAME_LEN];

strcpy(ddname, name);
cp = strchr(ddname, '@');
if (cp != NULL)
*cp = '\0';

err = dmu_objset_own(name, type, readonly, decrypt, tag, osp);
if (decrypt && err == EACCES) {
char ddname[ZFS_MAX_DATASET_NAME_LEN];
while (decrypt && err == EACCES) {
dsl_crypto_params_t *dcp;
nvlist_t *crypto_args = fnvlist_alloc();
char *cp = NULL;

/* spa_keystore_load_wkey() expects a dsl dir name */
strcpy(ddname, name);
cp = strchr(ddname, '@');
if (cp != NULL)
*cp = '\0';

fnvlist_add_uint8_array(crypto_args, "wkeydata",
(uint8_t *)ztest_wkeydata, WRAPPING_KEY_LEN);
Expand All @@ -1326,10 +1325,26 @@ ztest_dmu_objset_own(const char *name, dmu_objset_type_t type,
dsl_crypto_params_free(dcp, B_FALSE);
fnvlist_free(crypto_args);

if (err != 0)
return (err);
if (err == EINVAL) {
/*
* We couldn't load a key for this dataset so try
* the parent. This loop will eventually hit the
* encryption root since ztest only makes clones
* as children of their origin datasets.
*/
cp = strrchr(ddname, '/');
if (cp == NULL)
return (err);

*cp = '\0';
err = EACCES;
continue;
} else if (err != 0) {
break;
}

err = dmu_objset_own(name, type, readonly, decrypt, tag, osp);
break;
}

return (err);
Expand Down Expand Up @@ -6744,6 +6759,34 @@ ztest_dataset_close(int d)
ztest_zd_fini(zd);
}

/* ARGSUSED */
static int
ztest_replay_zil_cb(const char *name, void *arg)
{
objset_t *os;
ztest_ds_t *zdtmp;

VERIFY0(ztest_dmu_objset_own(name, DMU_OST_ANY, B_TRUE,
B_TRUE, FTAG, &os));

if (dmu_objset_zil(os)->zl_parse_lr_count != 0 &&
ztest_opts.zo_verbose >= 4) {
(void) printf("replaying logs for '%s' (%llu records)\n", name,
(unsigned long long)dmu_objset_zil(os)->zl_parse_lr_count);
}

zdtmp = umem_alloc(sizeof (ztest_ds_t), UMEM_NOFAIL);

ztest_zd_init(zdtmp, NULL, os);
zil_replay(os, zdtmp, ztest_replay_vector);
ztest_zd_fini(zdtmp);

umem_free(zdtmp, sizeof (ztest_ds_t));

dmu_objset_disown(os, B_TRUE, FTAG);
return (0);
}

/*
* Kick off threads to run tests on all datasets in parallel.
*/
Expand Down Expand Up @@ -6845,6 +6888,11 @@ ztest_run(ztest_shared_t *zs)
if (ztest_opts.zo_verbose >= 4)
(void) printf("starting main threads...\n");


/* Replay all logs of all datasets in the pool */
(void) dmu_objset_find(ztest_opts.zo_pool, ztest_replay_zil_cb,
NULL, DS_FIND_CHILDREN);

/*
* Kick off all the tests that run in parallel.
*/
Expand Down
9 changes: 8 additions & 1 deletion module/zfs/dsl_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ spa_keystore_load_wkey(const char *dsname, dsl_crypto_params_t *dcp,
dsl_crypto_key_t *dck = NULL;
dsl_wrapping_key_t *wkey = dcp->cp_wkey;
dsl_pool_t *dp = NULL;
uint64_t keyformat, salt, iters;
uint64_t rddobj, keyformat, salt, iters;

/*
* We don't validate the wrapping key's keyformat, salt, or iters
Expand Down Expand Up @@ -786,6 +786,13 @@ spa_keystore_load_wkey(const char *dsname, dsl_crypto_params_t *dcp,
goto error;
}

/* confirm that dd is the encryption root */
ret = dsl_dir_get_encryption_root_ddobj(dd, &rddobj);
if (ret != 0 || rddobj != dd->dd_object) {
ret = (SET_ERROR(EINVAL));
goto error;
}

/* initialize the wkey's ddobj */
wkey->wk_ddobj = dd->dd_object;

Expand Down
11 changes: 9 additions & 2 deletions module/zfs/vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2603,7 +2603,7 @@ vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg, int scrub_done)
* DTLs then reset its resilvering flag and dirty
* the top level so that we persist the change.
*/
if (vd->vdev_resilver_txg != 0 &&
if (txg != 0 && vd->vdev_resilver_txg != 0 &&
range_tree_is_empty(vd->vdev_dtl[DTL_MISSING]) &&
range_tree_is_empty(vd->vdev_dtl[DTL_OUTAGE])) {
vd->vdev_resilver_txg = 0;
Expand Down Expand Up @@ -4598,7 +4598,14 @@ vdev_deadman(vdev_t *vd, char *tag)
void
vdev_set_deferred_resilver(spa_t *spa, vdev_t *vd)
{
ASSERT(vd->vdev_ops->vdev_op_leaf);
for (uint64_t i = 0; i < vd->vdev_children; i++) {
vdev_set_deferred_resilver(spa, vd->vdev_child[i]);
}

if (!vd->vdev_ops->vdev_op_leaf || !vdev_writeable(vd) ||
range_tree_is_empty(vd->vdev_dtl[DTL_MISSING]))
return;

vd->vdev_resilver_deferred = B_TRUE;
spa->spa_resilver_deferred = B_TRUE;
}
Expand Down
9 changes: 8 additions & 1 deletion module/zfs/vdev_indirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,8 @@ vdev_indirect_splits_enumerate_randomly(indirect_vsd_t *iv, zio_t *zio)
static int
vdev_indirect_splits_damage(indirect_vsd_t *iv, zio_t *zio)
{
int error;

/* Presume all the copies are unique for initial selection. */
for (indirect_split_t *is = list_head(&iv->iv_splits);
is != NULL; is = list_next(&iv->iv_splits, is)) {
Expand All @@ -1599,13 +1601,18 @@ vdev_indirect_splits_damage(indirect_vsd_t *iv, zio_t *zio)
list_insert_tail(&is->is_unique_child, ic);
}
}

if (list_is_empty(&is->is_unique_child)) {
error = SET_ERROR(EIO);
goto out;
}
}

/*
* Set each is_good_child to a randomly-selected child which
* is known to contain validated data.
*/
int error = vdev_indirect_splits_enumerate_randomly(iv, zio);
error = vdev_indirect_splits_enumerate_randomly(iv, zio);
if (error)
goto out;

Expand Down
15 changes: 6 additions & 9 deletions module/zfs/vdev_removal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,19 +1115,16 @@ vdev_remove_replace_with_indirect(vdev_t *vd, uint64_t txg)

ASSERT(!list_link_active(&vd->vdev_state_dirty_node));

tx = dmu_tx_create_assigned(spa->spa_dsl_pool, txg);
dsl_sync_task_nowait(spa->spa_dsl_pool, vdev_remove_complete_sync, svr,
0, ZFS_SPACE_CHECK_NONE, tx);
dmu_tx_commit(tx);

/*
* Indicate that this thread has exited.
* After this, we can not use svr.
*/
mutex_enter(&svr->svr_lock);
svr->svr_thread = NULL;
cv_broadcast(&svr->svr_cv);
mutex_exit(&svr->svr_lock);

/* After this, we can not use svr. */
tx = dmu_tx_create_assigned(spa->spa_dsl_pool, txg);
dsl_sync_task_nowait(spa->spa_dsl_pool, vdev_remove_complete_sync, svr,
0, ZFS_SPACE_CHECK_NONE, tx);
dmu_tx_commit(tx);
}

/*
Expand Down
17 changes: 10 additions & 7 deletions module/zfs/zthr.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,19 @@ zthr_cancel(zthr_t *t)
void
zthr_resume(zthr_t *t)
{
ASSERT3P(t->zthr_thread, ==, NULL);

mutex_enter(&t->zthr_lock);

ASSERT3P(&t->zthr_checkfunc, !=, NULL);
ASSERT3P(&t->zthr_func, !=, NULL);
ASSERT(!t->zthr_cancel);
ASSERT3P(t->zthr_checkfunc, !=, NULL);
ASSERT3P(t->zthr_func, !=, NULL);

t->zthr_thread = thread_create(NULL, 0, zthr_procedure, t,
0, &p0, TS_RUN, minclsyspri);
/* Wait for any in-progress cancellations */
while (t->zthr_cancel)
cv_wait(&t->zthr_cv, &t->zthr_lock);

if (t->zthr_thread == NULL) {
t->zthr_thread = thread_create(NULL, 0, zthr_procedure,
t, 0, &p0, TS_RUN, minclsyspri);
}

mutex_exit(&t->zthr_lock);
}
Expand Down
2 changes: 0 additions & 2 deletions tests/test-runner/bin/zts-report.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@
'cli_root/zdb/zdb_006_pos': ['FAIL', known_reason],
'cli_root/zfs_get/zfs_get_004_pos': ['FAIL', known_reason],
'cli_root/zfs_get/zfs_get_009_pos': ['SKIP', '5479'],
'cli_root/zfs_rename/zfs_rename_006_pos': ['FAIL', '5647'],
'cli_root/zfs_rename/zfs_rename_009_neg': ['FAIL', '5648'],
'cli_root/zfs_rollback/zfs_rollback_001_pos': ['FAIL', '6415'],
'cli_root/zfs_rollback/zfs_rollback_002_pos': ['FAIL', '6416'],
'cli_root/zfs_share/setup': ['SKIP', share_reason],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ rename_dataset ${vol}-new $vol

clone=$TESTPOOL/${snap}_clone
create_clone $vol@$snap $clone
block_device_wait

#verify data integrity
for input in $VOL_R_PATH $ZVOL_RDEVDIR/$clone; do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@

#
# DESCRIPTION:
# A snapshot already exists with the new name, then none of the
# snapshots is renamed.
# When renaming a set of snapshots, if a snapshot already exists with
# the new name, then none of the snapshots is renamed.
#
# STRATEGY:
# 1. Create snapshot for a set of datasets.
# 1. Create a snapshot for a set of datasets.
# 2. Create a new snapshot for one of datasets.
# 3. Using rename -r command with exists snapshot name.
# 3. Attempt to "zfs rename -r" with the second snapshot's name.
# 4. Verify none of the snapshots is renamed.
#

Expand All @@ -54,7 +54,7 @@ function cleanup
done
}

log_assert "zfs rename -r failed, when snapshot name is already existing."
log_assert "Verify zfs rename -r failed when the snapshot name already exists."
log_onexit cleanup

set -A datasets $TESTPOOL $TESTPOOL/$TESTCTR \
Expand All @@ -71,7 +71,7 @@ while ((i < ${#datasets[@]})); do
log_mustnot zfs rename -r ${TESTPOOL}@snap ${TESTPOOL}@snap2
log_must zfs destroy ${datasets[$i]}@snap2

# Check datasets, make sure none of them was renamed.
# Check datasets, make sure none of them have snap2.
typeset -i j=0
while ((j < ${#datasets[@]})); do
if datasetexists ${datasets[$j]}@snap2 ; then
Expand All @@ -83,4 +83,4 @@ while ((i < ${#datasets[@]})); do
((i += 1))
done

log_pass "zfs rename -r failed, when snapshot name is already existing passed."
log_pass "zfs rename -r failed when the snapshot name already exists."