ztest: update ztest_dmu_snapshot_create_destroy()
ECHRNG is returned when the channel program encounters a runtime error. For example, this can happen when a snapshot doesn't exist. We handle this error the same way as the existing EEXIST and ENOENT error checks. Additionally, improve the internal debug message to include the error describing why a pool couldn't be opened. Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #14351
This commit is contained in:
parent
549aafb7c8
commit
0c8fbe5b6a
15
cmd/ztest.c
15
cmd/ztest.c
|
@ -4299,7 +4299,7 @@ ztest_snapshot_create(char *osname, uint64_t id)
|
||||||
ztest_record_enospc(FTAG);
|
ztest_record_enospc(FTAG);
|
||||||
return (B_FALSE);
|
return (B_FALSE);
|
||||||
}
|
}
|
||||||
if (error != 0 && error != EEXIST) {
|
if (error != 0 && error != EEXIST && error != ECHRNG) {
|
||||||
fatal(B_FALSE, "ztest_snapshot_create(%s@%s) = %d", osname,
|
fatal(B_FALSE, "ztest_snapshot_create(%s@%s) = %d", osname,
|
||||||
snapname, error);
|
snapname, error);
|
||||||
}
|
}
|
||||||
|
@ -4316,7 +4316,7 @@ ztest_snapshot_destroy(char *osname, uint64_t id)
|
||||||
osname, id);
|
osname, id);
|
||||||
|
|
||||||
error = dsl_destroy_snapshot(snapname, B_FALSE);
|
error = dsl_destroy_snapshot(snapname, B_FALSE);
|
||||||
if (error != 0 && error != ENOENT)
|
if (error != 0 && error != ENOENT && error != ECHRNG)
|
||||||
fatal(B_FALSE, "ztest_snapshot_destroy(%s) = %d",
|
fatal(B_FALSE, "ztest_snapshot_destroy(%s) = %d",
|
||||||
snapname, error);
|
snapname, error);
|
||||||
return (B_TRUE);
|
return (B_TRUE);
|
||||||
|
@ -4365,9 +4365,16 @@ ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Verify that the destroyed dataset is no longer in the namespace.
|
* Verify that the destroyed dataset is no longer in the namespace.
|
||||||
|
* It may still be present if the destroy above fails with ENOSPC.
|
||||||
*/
|
*/
|
||||||
VERIFY3U(ENOENT, ==, ztest_dmu_objset_own(name, DMU_OST_OTHER, B_TRUE,
|
error = ztest_dmu_objset_own(name, DMU_OST_OTHER, B_TRUE, B_TRUE,
|
||||||
B_TRUE, FTAG, &os));
|
FTAG, &os);
|
||||||
|
if (error == 0) {
|
||||||
|
dmu_objset_disown(os, B_TRUE, FTAG);
|
||||||
|
ztest_record_enospc(FTAG);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
VERIFY3U(ENOENT, ==, error);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Verify that we can create a new dataset.
|
* Verify that we can create a new dataset.
|
||||||
|
|
|
@ -958,12 +958,12 @@ zcp_eval_impl(dmu_tx_t *tx, zcp_run_info_t *ri)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zcp_pool_error(zcp_run_info_t *ri, const char *poolname)
|
zcp_pool_error(zcp_run_info_t *ri, const char *poolname, int error)
|
||||||
{
|
{
|
||||||
ri->zri_result = SET_ERROR(ECHRNG);
|
ri->zri_result = SET_ERROR(ECHRNG);
|
||||||
lua_settop(ri->zri_state, 0);
|
lua_settop(ri->zri_state, 0);
|
||||||
(void) lua_pushfstring(ri->zri_state, "Could not open pool: %s",
|
(void) lua_pushfstring(ri->zri_state, "Could not open pool: %s "
|
||||||
poolname);
|
"errno: %d", poolname, error);
|
||||||
zcp_convert_return_values(ri->zri_state, ri->zri_outnvl,
|
zcp_convert_return_values(ri->zri_state, ri->zri_outnvl,
|
||||||
ZCP_RET_ERROR, &ri->zri_result);
|
ZCP_RET_ERROR, &ri->zri_result);
|
||||||
|
|
||||||
|
@ -1013,7 +1013,7 @@ zcp_eval_open(zcp_run_info_t *ri, const char *poolname)
|
||||||
|
|
||||||
error = dsl_pool_hold(poolname, FTAG, &dp);
|
error = dsl_pool_hold(poolname, FTAG, &dp);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
zcp_pool_error(ri, poolname);
|
zcp_pool_error(ri, poolname, error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1159,7 +1159,7 @@ zcp_eval(const char *poolname, const char *program, boolean_t sync,
|
||||||
err = dsl_sync_task_sig(poolname, NULL, zcp_eval_sync,
|
err = dsl_sync_task_sig(poolname, NULL, zcp_eval_sync,
|
||||||
zcp_eval_sig, &runinfo, 0, ZFS_SPACE_CHECK_ZCP_EVAL);
|
zcp_eval_sig, &runinfo, 0, ZFS_SPACE_CHECK_ZCP_EVAL);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
zcp_pool_error(&runinfo, poolname);
|
zcp_pool_error(&runinfo, poolname, err);
|
||||||
} else {
|
} else {
|
||||||
zcp_eval_open(&runinfo, poolname);
|
zcp_eval_open(&runinfo, poolname);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue