Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/openzfs/cmd/ztest/ztest.c
Context not available. | |||||
cmd = umem_alloc(MAXPATHLEN, UMEM_NOFAIL); | cmd = umem_alloc(MAXPATHLEN, UMEM_NOFAIL); | ||||
realaltdir = umem_alloc(MAXPATHLEN, UMEM_NOFAIL); | realaltdir = umem_alloc(MAXPATHLEN, UMEM_NOFAIL); | ||||
VERIFY(NULL != realpath(getexecname(), cmd)); | VERIFY3P(NULL, !=, realpath(getexecname(), cmd)); | ||||
if (0 != access(altdir, F_OK)) { | if (0 != access(altdir, F_OK)) { | ||||
ztest_dump_core = B_FALSE; | ztest_dump_core = B_FALSE; | ||||
fatal(B_TRUE, "invalid alternate ztest path: %s", | fatal(B_TRUE, "invalid alternate ztest path: %s", | ||||
altdir); | altdir); | ||||
} | } | ||||
VERIFY(NULL != realpath(altdir, realaltdir)); | VERIFY3P(NULL, !=, realpath(altdir, realaltdir)); | ||||
/* | /* | ||||
* 'cmd' should be of the form "<anything>/usr/bin/<isa>/ztest". | * 'cmd' should be of the form "<anything>/usr/bin/<isa>/ztest". | ||||
Context not available. | |||||
(void) close(fd); | (void) close(fd); | ||||
} | } | ||||
VERIFY0(nvlist_alloc(&file, NV_UNIQUE_NAME, 0)); | file = fnvlist_alloc(); | ||||
VERIFY0(nvlist_add_string(file, ZPOOL_CONFIG_TYPE, | fnvlist_add_string(file, ZPOOL_CONFIG_TYPE, | ||||
draid_spare ? VDEV_TYPE_DRAID_SPARE : VDEV_TYPE_FILE)); | draid_spare ? VDEV_TYPE_DRAID_SPARE : VDEV_TYPE_FILE); | ||||
VERIFY0(nvlist_add_string(file, ZPOOL_CONFIG_PATH, path)); | fnvlist_add_string(file, ZPOOL_CONFIG_PATH, path); | ||||
VERIFY0(nvlist_add_uint64(file, ZPOOL_CONFIG_ASHIFT, ashift)); | fnvlist_add_uint64(file, ZPOOL_CONFIG_ASHIFT, ashift); | ||||
umem_free(pathbuf, MAXPATHLEN); | umem_free(pathbuf, MAXPATHLEN); | ||||
return (file); | return (file); | ||||
Context not available. | |||||
for (c = 0; c < r; c++) | for (c = 0; c < r; c++) | ||||
child[c] = make_vdev_file(path, aux, pool, size, ashift); | child[c] = make_vdev_file(path, aux, pool, size, ashift); | ||||
VERIFY0(nvlist_alloc(&raid, NV_UNIQUE_NAME, 0)); | raid = fnvlist_alloc(); | ||||
VERIFY0(nvlist_add_string(raid, ZPOOL_CONFIG_TYPE, | fnvlist_add_string(raid, ZPOOL_CONFIG_TYPE, | ||||
ztest_opts.zo_raid_type)); | ztest_opts.zo_raid_type); | ||||
VERIFY0(nvlist_add_uint64(raid, ZPOOL_CONFIG_NPARITY, | fnvlist_add_uint64(raid, ZPOOL_CONFIG_NPARITY, | ||||
ztest_opts.zo_raid_parity)); | ztest_opts.zo_raid_parity); | ||||
VERIFY0(nvlist_add_nvlist_array(raid, ZPOOL_CONFIG_CHILDREN, | fnvlist_add_nvlist_array(raid, ZPOOL_CONFIG_CHILDREN, child, r); | ||||
child, r)); | |||||
if (strcmp(ztest_opts.zo_raid_type, VDEV_TYPE_DRAID) == 0) { | if (strcmp(ztest_opts.zo_raid_type, VDEV_TYPE_DRAID) == 0) { | ||||
uint64_t ndata = ztest_opts.zo_draid_data; | uint64_t ndata = ztest_opts.zo_draid_data; | ||||
Context not available. | |||||
} | } | ||||
for (c = 0; c < r; c++) | for (c = 0; c < r; c++) | ||||
nvlist_free(child[c]); | fnvlist_free(child[c]); | ||||
umem_free(child, r * sizeof (nvlist_t *)); | umem_free(child, r * sizeof (nvlist_t *)); | ||||
Context not available. | |||||
for (c = 0; c < m; c++) | for (c = 0; c < m; c++) | ||||
child[c] = make_vdev_raid(path, aux, pool, size, ashift, r); | child[c] = make_vdev_raid(path, aux, pool, size, ashift, r); | ||||
VERIFY(nvlist_alloc(&mirror, NV_UNIQUE_NAME, 0) == 0); | mirror = fnvlist_alloc(); | ||||
VERIFY(nvlist_add_string(mirror, ZPOOL_CONFIG_TYPE, | fnvlist_add_string(mirror, ZPOOL_CONFIG_TYPE, VDEV_TYPE_MIRROR); | ||||
VDEV_TYPE_MIRROR) == 0); | fnvlist_add_nvlist_array(mirror, ZPOOL_CONFIG_CHILDREN, child, m); | ||||
VERIFY(nvlist_add_nvlist_array(mirror, ZPOOL_CONFIG_CHILDREN, | |||||
child, m) == 0); | |||||
for (c = 0; c < m; c++) | for (c = 0; c < m; c++) | ||||
nvlist_free(child[c]); | fnvlist_free(child[c]); | ||||
umem_free(child, m * sizeof (nvlist_t *)); | umem_free(child, m * sizeof (nvlist_t *)); | ||||
Context not available. | |||||
int c; | int c; | ||||
boolean_t log; | boolean_t log; | ||||
ASSERT(t > 0); | ASSERT3S(t, >, 0); | ||||
log = (class != NULL && strcmp(class, "log") == 0); | log = (class != NULL && strcmp(class, "log") == 0); | ||||
Context not available. | |||||
for (c = 0; c < t; c++) { | for (c = 0; c < t; c++) { | ||||
child[c] = make_vdev_mirror(path, aux, pool, size, ashift, | child[c] = make_vdev_mirror(path, aux, pool, size, ashift, | ||||
r, m); | r, m); | ||||
VERIFY(nvlist_add_uint64(child[c], ZPOOL_CONFIG_IS_LOG, | fnvlist_add_uint64(child[c], ZPOOL_CONFIG_IS_LOG, log); | ||||
log) == 0); | |||||
if (class != NULL && class[0] != '\0') { | if (class != NULL && class[0] != '\0') { | ||||
ASSERT(m > 1 || log); /* expecting a mirror */ | ASSERT(m > 1 || log); /* expecting a mirror */ | ||||
VERIFY(nvlist_add_string(child[c], | fnvlist_add_string(child[c], | ||||
ZPOOL_CONFIG_ALLOCATION_BIAS, class) == 0); | ZPOOL_CONFIG_ALLOCATION_BIAS, class); | ||||
} | } | ||||
} | } | ||||
VERIFY(nvlist_alloc(&root, NV_UNIQUE_NAME, 0) == 0); | root = fnvlist_alloc(); | ||||
VERIFY(nvlist_add_string(root, ZPOOL_CONFIG_TYPE, VDEV_TYPE_ROOT) == 0); | fnvlist_add_string(root, ZPOOL_CONFIG_TYPE, VDEV_TYPE_ROOT); | ||||
VERIFY(nvlist_add_nvlist_array(root, aux ? aux : ZPOOL_CONFIG_CHILDREN, | fnvlist_add_nvlist_array(root, aux ? aux : ZPOOL_CONFIG_CHILDREN, | ||||
child, t) == 0); | child, t); | ||||
for (c = 0; c < t; c++) | for (c = 0; c < t; c++) | ||||
nvlist_free(child[c]); | fnvlist_free(child[c]); | ||||
umem_free(child, t * sizeof (nvlist_t *)); | umem_free(child, t * sizeof (nvlist_t *)); | ||||
Context not available. | |||||
static int | static int | ||||
ztest_random_blocksize(void) | ztest_random_blocksize(void) | ||||
{ | { | ||||
ASSERT(ztest_spa->spa_max_ashift != 0); | ASSERT3U(ztest_spa->spa_max_ashift, !=, 0); | ||||
/* | /* | ||||
* Choose a block size >= the ashift. | * Choose a block size >= the ashift. | ||||
Context not available. | |||||
vdev_t *rvd = spa->spa_root_vdev; | vdev_t *rvd = spa->spa_root_vdev; | ||||
vdev_t *tvd; | vdev_t *tvd; | ||||
ASSERT(spa_config_held(spa, SCL_ALL, RW_READER) != 0); | ASSERT3U(spa_config_held(spa, SCL_ALL, RW_READER), !=, 0); | ||||
do { | do { | ||||
top = ztest_random(rvd->vdev_children); | top = ztest_random(rvd->vdev_children); | ||||
Context not available. | |||||
nvlist_t *props = NULL; | nvlist_t *props = NULL; | ||||
int error; | int error; | ||||
VERIFY(nvlist_alloc(&props, NV_UNIQUE_NAME, 0) == 0); | props = fnvlist_alloc(); | ||||
VERIFY(nvlist_add_uint64(props, zpool_prop_to_name(prop), value) == 0); | fnvlist_add_uint64(props, zpool_prop_to_name(prop), value); | ||||
error = spa_prop_set(spa, props); | error = spa_prop_set(spa, props); | ||||
nvlist_free(props); | fnvlist_free(props); | ||||
if (error == ENOSPC) { | if (error == ENOSPC) { | ||||
ztest_record_enospc(FTAG); | ztest_record_enospc(FTAG); | ||||
Context not available. | |||||
static void | static void | ||||
ztest_rll_destroy(rll_t *rll) | ztest_rll_destroy(rll_t *rll) | ||||
{ | { | ||||
ASSERT(rll->rll_writer == NULL); | ASSERT3P(rll->rll_writer, ==, NULL); | ||||
ASSERT(rll->rll_readers == 0); | ASSERT0(rll->rll_readers); | ||||
mutex_destroy(&rll->rll_lock); | mutex_destroy(&rll->rll_lock); | ||||
cv_destroy(&rll->rll_cv); | cv_destroy(&rll->rll_cv); | ||||
} | } | ||||
Context not available. | |||||
mutex_enter(&rll->rll_lock); | mutex_enter(&rll->rll_lock); | ||||
if (rll->rll_writer) { | if (rll->rll_writer) { | ||||
ASSERT(rll->rll_readers == 0); | ASSERT0(rll->rll_readers); | ||||
rll->rll_writer = NULL; | rll->rll_writer = NULL; | ||||
} else { | } else { | ||||
ASSERT(rll->rll_readers != 0); | ASSERT3S(rll->rll_readers, >, 0); | ||||
ASSERT(rll->rll_writer == NULL); | ASSERT3P(rll->rll_writer, ==, NULL); | ||||
rll->rll_readers--; | rll->rll_readers--; | ||||
} | } | ||||
Context not available. | |||||
error = dmu_tx_assign(tx, txg_how); | error = dmu_tx_assign(tx, txg_how); | ||||
if (error) { | if (error) { | ||||
if (error == ERESTART) { | if (error == ERESTART) { | ||||
ASSERT(txg_how == TXG_NOWAIT); | ASSERT3U(txg_how, ==, TXG_NOWAIT); | ||||
dmu_tx_wait(tx); | dmu_tx_wait(tx); | ||||
} else { | } else { | ||||
ASSERT3U(error, ==, ENOSPC); | ASSERT3U(error, ==, ENOSPC); | ||||
Context not available. | |||||
return (0); | return (0); | ||||
} | } | ||||
txg = dmu_tx_get_txg(tx); | txg = dmu_tx_get_txg(tx); | ||||
ASSERT(txg != 0); | ASSERT3U(txg, !=, 0); | ||||
return (txg); | return (txg); | ||||
} | } | ||||
Context not available. | |||||
if (byteswap) | if (byteswap) | ||||
byteswap_uint64_array(lr, sizeof (*lr)); | byteswap_uint64_array(lr, sizeof (*lr)); | ||||
ASSERT(lr->lr_doid == ZTEST_DIROBJ); | ASSERT3U(lr->lr_doid, ==, ZTEST_DIROBJ); | ||||
ASSERT(name[0] != '\0'); | ASSERT3S(name[0], !=, '\0'); | ||||
tx = dmu_tx_create(os); | tx = dmu_tx_create(os); | ||||
Context not available. | |||||
if (txg == 0) | if (txg == 0) | ||||
return (ENOSPC); | return (ENOSPC); | ||||
ASSERT(dmu_objset_zil(os)->zl_replay == !!lr->lr_foid); | ASSERT3U(dmu_objset_zil(os)->zl_replay, ==, !!lr->lr_foid); | ||||
bonuslen = DN_BONUS_SIZE(lr->lrz_dnodesize); | bonuslen = DN_BONUS_SIZE(lr->lrz_dnodesize); | ||||
if (lr->lrz_type == DMU_OT_ZAP_OTHER) { | if (lr->lrz_type == DMU_OT_ZAP_OTHER) { | ||||
Context not available. | |||||
return (error); | return (error); | ||||
} | } | ||||
ASSERT(lr->lr_foid != 0); | ASSERT3U(lr->lr_foid, !=, 0); | ||||
if (lr->lrz_type != DMU_OT_ZAP_OTHER) | if (lr->lrz_type != DMU_OT_ZAP_OTHER) | ||||
VERIFY3U(0, ==, dmu_object_set_blocksize(os, lr->lr_foid, | VERIFY0(dmu_object_set_blocksize(os, lr->lr_foid, | ||||
lr->lrz_blocksize, lr->lrz_ibshift, tx)); | lr->lrz_blocksize, lr->lrz_ibshift, tx)); | ||||
VERIFY3U(0, ==, dmu_bonus_hold(os, lr->lr_foid, FTAG, &db)); | VERIFY0(dmu_bonus_hold(os, lr->lr_foid, FTAG, &db)); | ||||
bbt = ztest_bt_bonus(db); | bbt = ztest_bt_bonus(db); | ||||
dmu_buf_will_dirty(db, tx); | dmu_buf_will_dirty(db, tx); | ||||
ztest_bt_generate(bbt, os, lr->lr_foid, lr->lrz_dnodesize, -1ULL, | ztest_bt_generate(bbt, os, lr->lr_foid, lr->lrz_dnodesize, -1ULL, | ||||
Context not available. | |||||
ztest_fill_unused_bonus(db, bbt, lr->lr_foid, os, lr->lr_gen); | ztest_fill_unused_bonus(db, bbt, lr->lr_foid, os, lr->lr_gen); | ||||
dmu_buf_rele(db, FTAG); | dmu_buf_rele(db, FTAG); | ||||
VERIFY3U(0, ==, zap_add(os, lr->lr_doid, name, sizeof (uint64_t), 1, | VERIFY0(zap_add(os, lr->lr_doid, name, sizeof (uint64_t), 1, | ||||
&lr->lr_foid, tx)); | &lr->lr_foid, tx)); | ||||
(void) ztest_log_create(zd, tx, lr); | (void) ztest_log_create(zd, tx, lr); | ||||
Context not available. | |||||
if (byteswap) | if (byteswap) | ||||
byteswap_uint64_array(lr, sizeof (*lr)); | byteswap_uint64_array(lr, sizeof (*lr)); | ||||
ASSERT(lr->lr_doid == ZTEST_DIROBJ); | ASSERT3U(lr->lr_doid, ==, ZTEST_DIROBJ); | ||||
ASSERT(name[0] != '\0'); | ASSERT3S(name[0], !=, '\0'); | ||||
VERIFY3U(0, ==, | VERIFY0( | ||||
zap_lookup(os, lr->lr_doid, name, sizeof (object), 1, &object)); | zap_lookup(os, lr->lr_doid, name, sizeof (object), 1, &object)); | ||||
ASSERT(object != 0); | ASSERT3U(object, !=, 0); | ||||
ztest_object_lock(zd, object, RL_WRITER); | ztest_object_lock(zd, object, RL_WRITER); | ||||
VERIFY3U(0, ==, dmu_object_info(os, object, &doi)); | VERIFY0(dmu_object_info(os, object, &doi)); | ||||
tx = dmu_tx_create(os); | tx = dmu_tx_create(os); | ||||
Context not available. | |||||
} | } | ||||
if (doi.doi_type == DMU_OT_ZAP_OTHER) { | if (doi.doi_type == DMU_OT_ZAP_OTHER) { | ||||
VERIFY3U(0, ==, zap_destroy(os, object, tx)); | VERIFY0(zap_destroy(os, object, tx)); | ||||
} else { | } else { | ||||
VERIFY3U(0, ==, dmu_object_free(os, object, tx)); | VERIFY0(dmu_object_free(os, object, tx)); | ||||
} | } | ||||
VERIFY3U(0, ==, zap_remove(os, lr->lr_doid, name, tx)); | VERIFY0(zap_remove(os, lr->lr_doid, name, tx)); | ||||
(void) ztest_log_remove(zd, tx, lr, object); | (void) ztest_log_remove(zd, tx, lr, object); | ||||
Context not available. | |||||
ztest_object_lock(zd, lr->lr_foid, RL_READER); | ztest_object_lock(zd, lr->lr_foid, RL_READER); | ||||
rl = ztest_range_lock(zd, lr->lr_foid, offset, length, RL_WRITER); | rl = ztest_range_lock(zd, lr->lr_foid, offset, length, RL_WRITER); | ||||
VERIFY3U(0, ==, dmu_bonus_hold(os, lr->lr_foid, FTAG, &db)); | VERIFY0(dmu_bonus_hold(os, lr->lr_foid, FTAG, &db)); | ||||
dmu_object_info_from_db(db, &doi); | dmu_object_info_from_db(db, &doi); | ||||
Context not available. | |||||
* but not always, because we also want to verify correct | * but not always, because we also want to verify correct | ||||
* behavior when the data was not recently read into cache. | * behavior when the data was not recently read into cache. | ||||
*/ | */ | ||||
ASSERT(offset % doi.doi_data_block_size == 0); | ASSERT0(offset % doi.doi_data_block_size); | ||||
if (ztest_random(4) != 0) { | if (ztest_random(4) != 0) { | ||||
int prefetch = ztest_random(2) ? | int prefetch = ztest_random(2) ? | ||||
DMU_READ_PREFETCH : DMU_READ_NO_PREFETCH; | DMU_READ_PREFETCH : DMU_READ_NO_PREFETCH; | ||||
Context not available. | |||||
return (ENOSPC); | return (ENOSPC); | ||||
} | } | ||||
VERIFY(dmu_free_range(os, lr->lr_foid, lr->lr_offset, | VERIFY0(dmu_free_range(os, lr->lr_foid, lr->lr_offset, | ||||
lr->lr_length, tx) == 0); | lr->lr_length, tx)); | ||||
(void) ztest_log_truncate(zd, tx, lr); | (void) ztest_log_truncate(zd, tx, lr); | ||||
Context not available. | |||||
ztest_object_lock(zd, lr->lr_foid, RL_WRITER); | ztest_object_lock(zd, lr->lr_foid, RL_WRITER); | ||||
VERIFY3U(0, ==, dmu_bonus_hold(os, lr->lr_foid, FTAG, &db)); | VERIFY0(dmu_bonus_hold(os, lr->lr_foid, FTAG, &db)); | ||||
tx = dmu_tx_create(os); | tx = dmu_tx_create(os); | ||||
dmu_tx_hold_bonus(tx, lr->lr_foid); | dmu_tx_hold_bonus(tx, lr->lr_foid); | ||||
Context not available. | |||||
dnodesize = bbt->bt_dnodesize; | dnodesize = bbt->bt_dnodesize; | ||||
if (zd->zd_zilog->zl_replay) { | if (zd->zd_zilog->zl_replay) { | ||||
ASSERT(lr->lr_size != 0); | ASSERT3U(lr->lr_size, !=, 0); | ||||
ASSERT(lr->lr_mode != 0); | ASSERT3U(lr->lr_mode, !=, 0); | ||||
ASSERT(lrtxg != 0); | ASSERT3U(lrtxg, !=, 0); | ||||
} else { | } else { | ||||
/* | /* | ||||
* Randomly change the size and increment the generation. | * Randomly change the size and increment the generation. | ||||
Context not available. | |||||
lr->lr_size = (ztest_random(db->db_size / sizeof (*bbt)) + 1) * | lr->lr_size = (ztest_random(db->db_size / sizeof (*bbt)) + 1) * | ||||
sizeof (*bbt); | sizeof (*bbt); | ||||
lr->lr_mode = bbt->bt_gen + 1; | lr->lr_mode = bbt->bt_gen + 1; | ||||
ASSERT(lrtxg == 0); | ASSERT0(lrtxg); | ||||
} | } | ||||
/* | /* | ||||
Context not available. | |||||
error = dmu_read(os, object, offset, size, buf, | error = dmu_read(os, object, offset, size, buf, | ||||
DMU_READ_NO_PREFETCH); | DMU_READ_NO_PREFETCH); | ||||
ASSERT(error == 0); | ASSERT0(error); | ||||
} else { | } else { | ||||
size = doi.doi_data_block_size; | size = doi.doi_data_block_size; | ||||
if (ISP2(size)) { | if (ISP2(size)) { | ||||
offset = P2ALIGN(offset, size); | offset = P2ALIGN(offset, size); | ||||
} else { | } else { | ||||
ASSERT(offset < size); | ASSERT3U(offset, <, size); | ||||
offset = 0; | offset = 0; | ||||
} | } | ||||
Context not available. | |||||
zgd->zgd_db = db; | zgd->zgd_db = db; | ||||
zgd->zgd_bp = bp; | zgd->zgd_bp = bp; | ||||
ASSERT(db->db_offset == offset); | ASSERT3U(db->db_offset, ==, offset); | ||||
ASSERT(db->db_size == size); | ASSERT3U(db->db_size, ==, size); | ||||
error = dmu_sync(zio, lr->lr_common.lrc_txg, | error = dmu_sync(zio, lr->lr_common.lrc_txg, | ||||
ztest_get_done, zgd); | ztest_get_done, zgd); | ||||
Context not available. | |||||
error = zap_lookup(zd->zd_os, od->od_dir, od->od_name, | error = zap_lookup(zd->zd_os, od->od_dir, od->od_name, | ||||
sizeof (uint64_t), 1, &od->od_object); | sizeof (uint64_t), 1, &od->od_object); | ||||
if (error) { | if (error) { | ||||
ASSERT(error == ENOENT); | ASSERT3S(error, ==, ENOENT); | ||||
ASSERT(od->od_object == 0); | ASSERT0(od->od_object); | ||||
missing++; | missing++; | ||||
} else { | } else { | ||||
dmu_buf_t *db; | dmu_buf_t *db; | ||||
ztest_block_tag_t *bbt; | ztest_block_tag_t *bbt; | ||||
dmu_object_info_t doi; | dmu_object_info_t doi; | ||||
ASSERT(od->od_object != 0); | ASSERT3U(od->od_object, !=, 0); | ||||
ASSERT(missing == 0); /* there should be no gaps */ | ASSERT0(missing); /* there should be no gaps */ | ||||
ztest_object_lock(zd, od->od_object, RL_READER); | ztest_object_lock(zd, od->od_object, RL_READER); | ||||
VERIFY3U(0, ==, dmu_bonus_hold(zd->zd_os, | VERIFY0(dmu_bonus_hold(zd->zd_os, od->od_object, | ||||
od->od_object, FTAG, &db)); | FTAG, &db)); | ||||
dmu_object_info_from_db(db, &doi); | dmu_object_info_from_db(db, &doi); | ||||
bbt = ztest_bt_bonus(db); | bbt = ztest_bt_bonus(db); | ||||
ASSERT3U(bbt->bt_magic, ==, BT_MAGIC); | ASSERT3U(bbt->bt_magic, ==, BT_MAGIC); | ||||
Context not available. | |||||
lr->lr_crtime[0] = time(NULL); | lr->lr_crtime[0] = time(NULL); | ||||
if (ztest_replay_create(zd, lr, B_FALSE) != 0) { | if (ztest_replay_create(zd, lr, B_FALSE) != 0) { | ||||
ASSERT(missing == 0); | ASSERT0(missing); | ||||
od->od_object = 0; | od->od_object = 0; | ||||
missing++; | missing++; | ||||
} else { | } else { | ||||
Context not available. | |||||
od->od_type = od->od_crtype; | od->od_type = od->od_crtype; | ||||
od->od_blocksize = od->od_crblocksize; | od->od_blocksize = od->od_crblocksize; | ||||
od->od_gen = od->od_crgen; | od->od_gen = od->od_crgen; | ||||
ASSERT(od->od_object != 0); | ASSERT3U(od->od_object, !=, 0); | ||||
} | } | ||||
ztest_lr_free(lr, sizeof (*lr), od->od_name); | ztest_lr_free(lr, sizeof (*lr), od->od_name); | ||||
Context not available. | |||||
uint64_t blocksize; | uint64_t blocksize; | ||||
void *data; | void *data; | ||||
VERIFY(dmu_object_info(zd->zd_os, object, &doi) == 0); | VERIFY0(dmu_object_info(zd->zd_os, object, &doi)); | ||||
blocksize = doi.doi_data_block_size; | blocksize = doi.doi_data_block_size; | ||||
data = umem_alloc(blocksize, UMEM_NOFAIL); | data = umem_alloc(blocksize, UMEM_NOFAIL); | ||||
Context not available. | |||||
* will verify that the log really does contain this record. | * will verify that the log really does contain this record. | ||||
*/ | */ | ||||
mutex_enter(&zilog->zl_lock); | mutex_enter(&zilog->zl_lock); | ||||
ASSERT(zd->zd_shared != NULL); | ASSERT3P(zd->zd_shared, !=, NULL); | ||||
ASSERT3U(zd->zd_shared->zd_seq, <=, zilog->zl_commit_lr_seq); | ASSERT3U(zd->zd_shared->zd_seq, <=, zilog->zl_commit_lr_seq); | ||||
zd->zd_shared->zd_seq = zilog->zl_commit_lr_seq; | zd->zd_shared->zd_seq = zilog->zl_commit_lr_seq; | ||||
mutex_exit(&zilog->zl_lock); | mutex_exit(&zilog->zl_lock); | ||||
Context not available. | |||||
zil_close(zd->zd_zilog); | zil_close(zd->zd_zilog); | ||||
/* zfsvfs_setup() */ | /* zfsvfs_setup() */ | ||||
VERIFY(zil_open(os, ztest_get_data) == zd->zd_zilog); | VERIFY3P(zil_open(os, ztest_get_data), ==, zd->zd_zilog); | ||||
zil_replay(os, zd, ztest_replay_vector); | zil_replay(os, zd, ztest_replay_vector); | ||||
(void) pthread_rwlock_unlock(&zd->zd_zilog_lock); | (void) pthread_rwlock_unlock(&zd->zd_zilog_lock); | ||||
Context not available. | |||||
nvroot = make_vdev_root("/dev/bogus", NULL, NULL, 0, 0, NULL, 0, 0, 1); | nvroot = make_vdev_root("/dev/bogus", NULL, NULL, 0, 0, NULL, 0, 0, 1); | ||||
VERIFY3U(ENOENT, ==, | VERIFY3U(ENOENT, ==, | ||||
spa_create("ztest_bad_file", nvroot, NULL, NULL, NULL)); | spa_create("ztest_bad_file", nvroot, NULL, NULL, NULL)); | ||||
nvlist_free(nvroot); | fnvlist_free(nvroot); | ||||
/* | /* | ||||
* Attempt to create using a bad mirror. | * Attempt to create using a bad mirror. | ||||
Context not available. | |||||
nvroot = make_vdev_root("/dev/bogus", NULL, NULL, 0, 0, NULL, 0, 2, 1); | nvroot = make_vdev_root("/dev/bogus", NULL, NULL, 0, 0, NULL, 0, 2, 1); | ||||
VERIFY3U(ENOENT, ==, | VERIFY3U(ENOENT, ==, | ||||
spa_create("ztest_bad_mirror", nvroot, NULL, NULL, NULL)); | spa_create("ztest_bad_mirror", nvroot, NULL, NULL, NULL)); | ||||
nvlist_free(nvroot); | fnvlist_free(nvroot); | ||||
/* | /* | ||||
* Attempt to create an existing pool. It shouldn't matter | * Attempt to create an existing pool. It shouldn't matter | ||||
Context not available. | |||||
nvroot = make_vdev_root("/dev/bogus", NULL, NULL, 0, 0, NULL, 0, 0, 1); | nvroot = make_vdev_root("/dev/bogus", NULL, NULL, 0, 0, NULL, 0, 0, 1); | ||||
VERIFY3U(EEXIST, ==, | VERIFY3U(EEXIST, ==, | ||||
spa_create(zo->zo_pool, nvroot, NULL, NULL, NULL)); | spa_create(zo->zo_pool, nvroot, NULL, NULL, NULL)); | ||||
nvlist_free(nvroot); | fnvlist_free(nvroot); | ||||
/* | /* | ||||
* We open a reference to the spa and then we try to export it | * We open a reference to the spa and then we try to export it | ||||
Context not available. | |||||
* For the case that there is another ztest thread doing | * For the case that there is another ztest thread doing | ||||
* an export concurrently. | * an export concurrently. | ||||
*/ | */ | ||||
VERIFY3U(0, ==, spa_open(zo->zo_pool, &spa, FTAG)); | VERIFY0(spa_open(zo->zo_pool, &spa, FTAG)); | ||||
int error = spa_destroy(zo->zo_pool); | int error = spa_destroy(zo->zo_pool); | ||||
if (error != EBUSY && error != ZFS_ERR_EXPORT_IN_PROGRESS) { | if (error != EBUSY && error != ZFS_ERR_EXPORT_IN_PROGRESS) { | ||||
fatal(0, "spa_destroy(%s) returned unexpected value %d", | fatal(0, "spa_destroy(%s) returned unexpected value %d", | ||||
Context not available. | |||||
props = fnvlist_alloc(); | props = fnvlist_alloc(); | ||||
fnvlist_add_uint64(props, | fnvlist_add_uint64(props, | ||||
zpool_prop_to_name(ZPOOL_PROP_VERSION), version); | zpool_prop_to_name(ZPOOL_PROP_VERSION), version); | ||||
VERIFY3S(spa_create(name, nvroot, props, NULL, NULL), ==, 0); | VERIFY0(spa_create(name, nvroot, props, NULL, NULL)); | ||||
fnvlist_free(nvroot); | fnvlist_free(nvroot); | ||||
fnvlist_free(props); | fnvlist_free(props); | ||||
VERIFY3S(spa_open(name, &spa, FTAG), ==, 0); | VERIFY0(spa_open(name, &spa, FTAG)); | ||||
VERIFY3U(spa_version(spa), ==, version); | VERIFY3U(spa_version(spa), ==, version); | ||||
newversion = ztest_random_spa_version(version + 1); | newversion = ztest_random_spa_version(version + 1); | ||||
Context not available. | |||||
1); | 1); | ||||
error = spa_vdev_add(spa, nvroot); | error = spa_vdev_add(spa, nvroot); | ||||
nvlist_free(nvroot); | fnvlist_free(nvroot); | ||||
switch (error) { | switch (error) { | ||||
case 0: | case 0: | ||||
Context not available. | |||||
class, ztest_opts.zo_raid_children, zs->zs_mirrors, 1); | class, ztest_opts.zo_raid_children, zs->zs_mirrors, 1); | ||||
error = spa_vdev_add(spa, nvroot); | error = spa_vdev_add(spa, nvroot); | ||||
nvlist_free(nvroot); | fnvlist_free(nvroot); | ||||
if (error == ENOSPC) | if (error == ENOSPC) | ||||
ztest_record_enospc("spa_vdev_add"); | ztest_record_enospc("spa_vdev_add"); | ||||
Context not available. | |||||
default: | default: | ||||
fatal(0, "spa_vdev_add(%p) = %d", nvroot, error); | fatal(0, "spa_vdev_add(%p) = %d", nvroot, error); | ||||
} | } | ||||
nvlist_free(nvroot); | fnvlist_free(nvroot); | ||||
} else { | } else { | ||||
/* | /* | ||||
* Remove an existing device. Sometimes, dirty its | * Remove an existing device. Sometimes, dirty its | ||||
Context not available. | |||||
/* generate a config from the existing config */ | /* generate a config from the existing config */ | ||||
mutex_enter(&spa->spa_props_lock); | mutex_enter(&spa->spa_props_lock); | ||||
VERIFY(nvlist_lookup_nvlist(spa->spa_config, ZPOOL_CONFIG_VDEV_TREE, | tree = fnvlist_lookup_nvlist(spa->spa_config, ZPOOL_CONFIG_VDEV_TREE); | ||||
&tree) == 0); | |||||
mutex_exit(&spa->spa_props_lock); | mutex_exit(&spa->spa_props_lock); | ||||
VERIFY(nvlist_lookup_nvlist_array(tree, ZPOOL_CONFIG_CHILDREN, &child, | VERIFY0(nvlist_lookup_nvlist_array(tree, ZPOOL_CONFIG_CHILDREN, | ||||
&children) == 0); | &child, &children)); | ||||
schild = malloc(rvd->vdev_children * sizeof (nvlist_t *)); | schild = malloc(rvd->vdev_children * sizeof (nvlist_t *)); | ||||
for (c = 0; c < children; c++) { | for (c = 0; c < children; c++) { | ||||
Context not available. | |||||
uint_t mchildren; | uint_t mchildren; | ||||
if (tvd->vdev_islog || tvd->vdev_ops == &vdev_hole_ops) { | if (tvd->vdev_islog || tvd->vdev_ops == &vdev_hole_ops) { | ||||
VERIFY(nvlist_alloc(&schild[schildren], NV_UNIQUE_NAME, | schild[schildren] = fnvlist_alloc(); | ||||
0) == 0); | fnvlist_add_string(schild[schildren], | ||||
VERIFY(nvlist_add_string(schild[schildren], | ZPOOL_CONFIG_TYPE, VDEV_TYPE_HOLE); | ||||
ZPOOL_CONFIG_TYPE, VDEV_TYPE_HOLE) == 0); | fnvlist_add_uint64(schild[schildren], | ||||
VERIFY(nvlist_add_uint64(schild[schildren], | ZPOOL_CONFIG_IS_HOLE, 1); | ||||
ZPOOL_CONFIG_IS_HOLE, 1) == 0); | |||||
if (lastlogid == 0) | if (lastlogid == 0) | ||||
lastlogid = schildren; | lastlogid = schildren; | ||||
++schildren; | ++schildren; | ||||
continue; | continue; | ||||
} | } | ||||
lastlogid = 0; | lastlogid = 0; | ||||
VERIFY(nvlist_lookup_nvlist_array(child[c], | VERIFY0(nvlist_lookup_nvlist_array(child[c], | ||||
ZPOOL_CONFIG_CHILDREN, &mchild, &mchildren) == 0); | ZPOOL_CONFIG_CHILDREN, &mchild, &mchildren)); | ||||
VERIFY(nvlist_dup(mchild[0], &schild[schildren++], 0) == 0); | schild[schildren++] = fnvlist_dup(mchild[0]); | ||||
} | } | ||||
/* OK, create a config that can be used to split */ | /* OK, create a config that can be used to split */ | ||||
VERIFY(nvlist_alloc(&split, NV_UNIQUE_NAME, 0) == 0); | split = fnvlist_alloc(); | ||||
VERIFY(nvlist_add_string(split, ZPOOL_CONFIG_TYPE, | fnvlist_add_string(split, ZPOOL_CONFIG_TYPE, VDEV_TYPE_ROOT); | ||||
VDEV_TYPE_ROOT) == 0); | fnvlist_add_nvlist_array(split, ZPOOL_CONFIG_CHILDREN, schild, | ||||
VERIFY(nvlist_add_nvlist_array(split, ZPOOL_CONFIG_CHILDREN, schild, | lastlogid != 0 ? lastlogid : schildren); | ||||
lastlogid != 0 ? lastlogid : schildren) == 0); | |||||
VERIFY(nvlist_alloc(&config, NV_UNIQUE_NAME, 0) == 0); | config = fnvlist_alloc(); | ||||
VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, split) == 0); | fnvlist_add_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, split); | ||||
for (c = 0; c < schildren; c++) | for (c = 0; c < schildren; c++) | ||||
nvlist_free(schild[c]); | fnvlist_free(schild[c]); | ||||
free(schild); | free(schild); | ||||
nvlist_free(split); | fnvlist_free(split); | ||||
spa_config_exit(spa, SCL_VDEV, FTAG); | spa_config_exit(spa, SCL_VDEV, FTAG); | ||||
Context not available. | |||||
error = spa_vdev_split_mirror(spa, "splitp", config, NULL, B_FALSE); | error = spa_vdev_split_mirror(spa, "splitp", config, NULL, B_FALSE); | ||||
(void) pthread_rwlock_unlock(&ztest_name_lock); | (void) pthread_rwlock_unlock(&ztest_name_lock); | ||||
nvlist_free(config); | fnvlist_free(config); | ||||
if (error == 0) { | if (error == 0) { | ||||
(void) printf("successful split - results:\n"); | (void) printf("successful split - results:\n"); | ||||
Context not available. | |||||
/* pick a child from the mirror */ | /* pick a child from the mirror */ | ||||
if (zs->zs_mirrors >= 1) { | if (zs->zs_mirrors >= 1) { | ||||
ASSERT(oldvd->vdev_ops == &vdev_mirror_ops); | ASSERT3P(oldvd->vdev_ops, ==, &vdev_mirror_ops); | ||||
ASSERT(oldvd->vdev_children >= zs->zs_mirrors); | ASSERT3U(oldvd->vdev_children, >=, zs->zs_mirrors); | ||||
oldvd = oldvd->vdev_child[leaf / ztest_opts.zo_raid_children]; | oldvd = oldvd->vdev_child[leaf / ztest_opts.zo_raid_children]; | ||||
} | } | ||||
/* pick a child out of the raidz group */ | /* pick a child out of the raidz group */ | ||||
if (ztest_opts.zo_raid_children > 1) { | if (ztest_opts.zo_raid_children > 1) { | ||||
if (strcmp(oldvd->vdev_ops->vdev_op_type, "raidz") == 0) | if (strcmp(oldvd->vdev_ops->vdev_op_type, "raidz") == 0) | ||||
ASSERT(oldvd->vdev_ops == &vdev_raidz_ops); | ASSERT3P(oldvd->vdev_ops, ==, &vdev_raidz_ops); | ||||
else | else | ||||
ASSERT(oldvd->vdev_ops == &vdev_draid_ops); | ASSERT3P(oldvd->vdev_ops, ==, &vdev_draid_ops); | ||||
ASSERT(oldvd->vdev_children == ztest_opts.zo_raid_children); | ASSERT3U(oldvd->vdev_children, ==, ztest_opts.zo_raid_children); | ||||
oldvd = oldvd->vdev_child[leaf % ztest_opts.zo_raid_children]; | oldvd = oldvd->vdev_child[leaf % ztest_opts.zo_raid_children]; | ||||
} | } | ||||
Context not available. | |||||
*/ | */ | ||||
while (oldvd->vdev_children != 0) { | while (oldvd->vdev_children != 0) { | ||||
oldvd_has_siblings = B_TRUE; | oldvd_has_siblings = B_TRUE; | ||||
ASSERT(oldvd->vdev_children >= 2); | ASSERT3U(oldvd->vdev_children, >=, 2); | ||||
oldvd = oldvd->vdev_child[ztest_random(oldvd->vdev_children)]; | oldvd = oldvd->vdev_child[ztest_random(oldvd->vdev_children)]; | ||||
} | } | ||||
Context not available. | |||||
error = spa_vdev_attach(spa, oldguid, root, replacing, rebuilding); | error = spa_vdev_attach(spa, oldguid, root, replacing, rebuilding); | ||||
nvlist_free(root); | fnvlist_free(root); | ||||
/* | /* | ||||
* If our parent was the replacing vdev, but the replace completed, | * If our parent was the replacing vdev, but the replace completed, | ||||
Context not available. | |||||
size_t fsize; | size_t fsize; | ||||
int fd; | int fd; | ||||
ASSERT(spa_config_held(spa, SCL_STATE, RW_READER) == SCL_STATE); | ASSERT3S(spa_config_held(spa, SCL_STATE, RW_READER), ==, SCL_STATE); | ||||
ASSERT(vd->vdev_ops->vdev_op_leaf); | ASSERT(vd->vdev_ops->vdev_op_leaf); | ||||
if ((fd = open(vd->vdev_path, O_RDWR)) == -1) | if ((fd = open(vd->vdev_path, O_RDWR)) == -1) | ||||
return (vd); | return (vd); | ||||
fsize = lseek(fd, 0, SEEK_END); | fsize = lseek(fd, 0, SEEK_END); | ||||
VERIFY(ftruncate(fd, *newsize) == 0); | VERIFY0(ftruncate(fd, *newsize)); | ||||
if (ztest_opts.zo_verbose >= 6) { | if (ztest_opts.zo_verbose >= 6) { | ||||
(void) printf("%s grew from %lu to %lu bytes\n", | (void) printf("%s grew from %lu to %lu bytes\n", | ||||
Context not available. | |||||
vdev_state_t newstate = VDEV_STATE_UNKNOWN; | vdev_state_t newstate = VDEV_STATE_UNKNOWN; | ||||
int error; | int error; | ||||
ASSERT(spa_config_held(spa, SCL_STATE, RW_READER) == SCL_STATE); | ASSERT3S(spa_config_held(spa, SCL_STATE, RW_READER), ==, SCL_STATE); | ||||
ASSERT(vd->vdev_ops->vdev_op_leaf); | ASSERT(vd->vdev_ops->vdev_op_leaf); | ||||
/* Calling vdev_online will initialize the new metaslabs */ | /* Calling vdev_online will initialize the new metaslabs */ | ||||
Context not available. | |||||
mutex_exit(&ztest_checkpoint_lock); | mutex_exit(&ztest_checkpoint_lock); | ||||
return; | return; | ||||
} | } | ||||
ASSERT(psize > 0); | ASSERT3U(psize, >, 0); | ||||
newsize = psize + MAX(psize / 8, SPA_MAXBLOCKSIZE); | newsize = psize + MAX(psize / 8, SPA_MAXBLOCKSIZE); | ||||
ASSERT3U(newsize, >, psize); | ASSERT3U(newsize, >, psize); | ||||
Context not available. | |||||
/* | /* | ||||
* Create the objects common to all ztest datasets. | * Create the objects common to all ztest datasets. | ||||
*/ | */ | ||||
VERIFY(zap_create_claim(os, ZTEST_DIROBJ, | VERIFY0(zap_create_claim(os, ZTEST_DIROBJ, | ||||
DMU_OT_ZAP_OTHER, DMU_OT_NONE, 0, tx) == 0); | DMU_OT_ZAP_OTHER, DMU_OT_NONE, 0, tx)); | ||||
} | } | ||||
static int | static int | ||||
Context not available. | |||||
/* | /* | ||||
* Verify that we can hold an objset that is also owned. | * Verify that we can hold an objset that is also owned. | ||||
*/ | */ | ||||
VERIFY3U(0, ==, dmu_objset_hold(name, FTAG, &os2)); | VERIFY0(dmu_objset_hold(name, FTAG, &os2)); | ||||
dmu_objset_rele(os2, FTAG); | dmu_objset_rele(os2, FTAG); | ||||
/* | /* | ||||
Context not available. | |||||
bigobj = od[0].od_object; | bigobj = od[0].od_object; | ||||
packobj = od[1].od_object; | packobj = od[1].od_object; | ||||
chunksize = od[0].od_gen; | chunksize = od[0].od_gen; | ||||
ASSERT(chunksize == od[1].od_gen); | ASSERT3U(chunksize, ==, od[1].od_gen); | ||||
/* | /* | ||||
* Prefetch a random chunk of the big object. | * Prefetch a random chunk of the big object. | ||||
Context not available. | |||||
/* LINTED */ | /* LINTED */ | ||||
bigT = (bufwad_t *)((char *)bigH + chunksize) - 1; | bigT = (bufwad_t *)((char *)bigH + chunksize) - 1; | ||||
ASSERT((uintptr_t)bigH - (uintptr_t)bigbuf < bigsize); | ASSERT3U((uintptr_t)bigH - (uintptr_t)bigbuf, <, bigsize); | ||||
ASSERT((uintptr_t)bigT - (uintptr_t)bigbuf < bigsize); | ASSERT3U((uintptr_t)bigT - (uintptr_t)bigbuf, <, bigsize); | ||||
if (pack->bw_txg > txg) | if (pack->bw_txg > txg) | ||||
fatal(0, "future leak: got %llx, open txg is %llx", | fatal(0, "future leak: got %llx, open txg is %llx", | ||||
Context not available. | |||||
(u_longlong_t)bigsize, | (u_longlong_t)bigsize, | ||||
(u_longlong_t)txg); | (u_longlong_t)txg); | ||||
} | } | ||||
VERIFY(0 == dmu_free_range(os, bigobj, bigoff, bigsize, tx)); | VERIFY0(dmu_free_range(os, bigobj, bigoff, bigsize, tx)); | ||||
} else { | } else { | ||||
if (ztest_opts.zo_verbose >= 7) { | if (ztest_opts.zo_verbose >= 7) { | ||||
(void) printf("writing offset %llx size %llx" | (void) printf("writing offset %llx size %llx" | ||||
Context not available. | |||||
void *packcheck = umem_alloc(packsize, UMEM_NOFAIL); | void *packcheck = umem_alloc(packsize, UMEM_NOFAIL); | ||||
void *bigcheck = umem_alloc(bigsize, UMEM_NOFAIL); | void *bigcheck = umem_alloc(bigsize, UMEM_NOFAIL); | ||||
VERIFY(0 == dmu_read(os, packobj, packoff, | VERIFY0(dmu_read(os, packobj, packoff, | ||||
packsize, packcheck, DMU_READ_PREFETCH)); | packsize, packcheck, DMU_READ_PREFETCH)); | ||||
VERIFY(0 == dmu_read(os, bigobj, bigoff, | VERIFY0(dmu_read(os, bigobj, bigoff, | ||||
bigsize, bigcheck, DMU_READ_PREFETCH)); | bigsize, bigcheck, DMU_READ_PREFETCH)); | ||||
ASSERT(bcmp(packbuf, packcheck, packsize) == 0); | ASSERT0(bcmp(packbuf, packcheck, packsize)); | ||||
ASSERT(bcmp(bigbuf, bigcheck, bigsize) == 0); | ASSERT0(bcmp(bigbuf, bigcheck, bigsize)); | ||||
umem_free(packcheck, packsize); | umem_free(packcheck, packsize); | ||||
umem_free(bigcheck, bigsize); | umem_free(bigcheck, bigsize); | ||||
Context not available. | |||||
/* LINTED */ | /* LINTED */ | ||||
bigT = (bufwad_t *)((char *)bigH + chunksize) - 1; | bigT = (bufwad_t *)((char *)bigH + chunksize) - 1; | ||||
ASSERT((uintptr_t)bigH - (uintptr_t)bigbuf < bigsize); | ASSERT3U((uintptr_t)bigH - (uintptr_t)bigbuf, <, bigsize); | ||||
ASSERT((uintptr_t)bigT - (uintptr_t)bigbuf < bigsize); | ASSERT3U((uintptr_t)bigT - (uintptr_t)bigbuf, <, bigsize); | ||||
if (pack->bw_txg > txg) | if (pack->bw_txg > txg) | ||||
fatal(0, "future leak: got %llx, open txg is %llx", | fatal(0, "future leak: got %llx, open txg is %llx", | ||||
Context not available. | |||||
packobj = od[1].od_object; | packobj = od[1].od_object; | ||||
blocksize = od[0].od_blocksize; | blocksize = od[0].od_blocksize; | ||||
chunksize = blocksize; | chunksize = blocksize; | ||||
ASSERT(chunksize == od[1].od_gen); | ASSERT3U(chunksize, ==, od[1].od_gen); | ||||
VERIFY(dmu_object_info(os, bigobj, &doi) == 0); | VERIFY0(dmu_object_info(os, bigobj, &doi)); | ||||
VERIFY(ISP2(doi.doi_data_block_size)); | VERIFY(ISP2(doi.doi_data_block_size)); | ||||
VERIFY(chunksize == doi.doi_data_block_size); | VERIFY3U(chunksize, ==, doi.doi_data_block_size); | ||||
VERIFY(chunksize >= 2 * sizeof (bufwad_t)); | VERIFY3U(chunksize, >=, 2 * sizeof (bufwad_t)); | ||||
/* | /* | ||||
* Pick a random index and compute the offsets into packobj and bigobj. | * Pick a random index and compute the offsets into packobj and bigobj. | ||||
Context not available. | |||||
packbuf = umem_zalloc(packsize, UMEM_NOFAIL); | packbuf = umem_zalloc(packsize, UMEM_NOFAIL); | ||||
bigbuf = umem_zalloc(bigsize, UMEM_NOFAIL); | bigbuf = umem_zalloc(bigsize, UMEM_NOFAIL); | ||||
VERIFY3U(0, ==, dmu_bonus_hold(os, bigobj, FTAG, &bonus_db)); | VERIFY0(dmu_bonus_hold(os, bigobj, FTAG, &bonus_db)); | ||||
bigbuf_arcbufs = umem_zalloc(2 * s * sizeof (arc_buf_t *), UMEM_NOFAIL); | bigbuf_arcbufs = umem_zalloc(2 * s * sizeof (arc_buf_t *), UMEM_NOFAIL); | ||||
Context not available. | |||||
goto out; | goto out; | ||||
for (i = 0; i < 2; i++) { | for (i = 0; i < 2; i++) { | ||||
value[i] = i; | value[i] = i; | ||||
VERIFY3U(0, ==, zap_add(os, object, hc[i], sizeof (uint64_t), | VERIFY0(zap_add(os, object, hc[i], sizeof (uint64_t), | ||||
1, &value[i], tx)); | 1, &value[i], tx)); | ||||
} | } | ||||
for (i = 0; i < 2; i++) { | for (i = 0; i < 2; i++) { | ||||
VERIFY3U(EEXIST, ==, zap_add(os, object, hc[i], | VERIFY3U(EEXIST, ==, zap_add(os, object, hc[i], | ||||
sizeof (uint64_t), 1, &value[i], tx)); | sizeof (uint64_t), 1, &value[i], tx)); | ||||
VERIFY3U(0, ==, | VERIFY0( | ||||
zap_length(os, object, hc[i], &zl_intsize, &zl_ints)); | zap_length(os, object, hc[i], &zl_intsize, &zl_ints)); | ||||
ASSERT3U(zl_intsize, ==, sizeof (uint64_t)); | ASSERT3U(zl_intsize, ==, sizeof (uint64_t)); | ||||
ASSERT3U(zl_ints, ==, 1); | ASSERT3U(zl_ints, ==, 1); | ||||
} | } | ||||
for (i = 0; i < 2; i++) { | for (i = 0; i < 2; i++) { | ||||
VERIFY3U(0, ==, zap_remove(os, object, hc[i], tx)); | VERIFY0(zap_remove(os, object, hc[i], tx)); | ||||
} | } | ||||
dmu_tx_commit(tx); | dmu_tx_commit(tx); | ||||
Context not available. | |||||
ASSERT3U(zl_intsize, ==, sizeof (uint64_t)); | ASSERT3U(zl_intsize, ==, sizeof (uint64_t)); | ||||
ASSERT3U(zl_ints, ==, 1); | ASSERT3U(zl_ints, ==, 1); | ||||
VERIFY(zap_lookup(os, object, txgname, zl_intsize, | VERIFY0(zap_lookup(os, object, txgname, zl_intsize, | ||||
zl_ints, &last_txg) == 0); | zl_ints, &last_txg)); | ||||
VERIFY(zap_length(os, object, propname, &zl_intsize, | VERIFY0(zap_length(os, object, propname, &zl_intsize, | ||||
&zl_ints) == 0); | &zl_ints)); | ||||
ASSERT3U(zl_intsize, ==, sizeof (uint64_t)); | ASSERT3U(zl_intsize, ==, sizeof (uint64_t)); | ||||
ASSERT3U(zl_ints, ==, ints); | ASSERT3U(zl_ints, ==, ints); | ||||
VERIFY(zap_lookup(os, object, propname, zl_intsize, | VERIFY0(zap_lookup(os, object, propname, zl_intsize, | ||||
zl_ints, value) == 0); | zl_ints, value)); | ||||
for (i = 0; i < ints; i++) { | for (i = 0; i < ints; i++) { | ||||
ASSERT3U(value[i], ==, last_txg + object + i); | ASSERT3U(value[i], ==, last_txg + object + i); | ||||
Context not available. | |||||
for (i = 0; i < ints; i++) | for (i = 0; i < ints; i++) | ||||
value[i] = txg + object + i; | value[i] = txg + object + i; | ||||
VERIFY3U(0, ==, zap_update(os, object, txgname, sizeof (uint64_t), | VERIFY0(zap_update(os, object, txgname, sizeof (uint64_t), | ||||
1, &txg, tx)); | 1, &txg, tx)); | ||||
VERIFY3U(0, ==, zap_update(os, object, propname, sizeof (uint64_t), | VERIFY0(zap_update(os, object, propname, sizeof (uint64_t), | ||||
ints, value, tx)); | ints, value, tx)); | ||||
dmu_tx_commit(tx); | dmu_tx_commit(tx); | ||||
Context not available. | |||||
txg = ztest_tx_assign(tx, TXG_MIGHTWAIT, FTAG); | txg = ztest_tx_assign(tx, TXG_MIGHTWAIT, FTAG); | ||||
if (txg == 0) | if (txg == 0) | ||||
goto out; | goto out; | ||||
VERIFY3U(0, ==, zap_remove(os, object, txgname, tx)); | VERIFY0(zap_remove(os, object, txgname, tx)); | ||||
VERIFY3U(0, ==, zap_remove(os, object, propname, tx)); | VERIFY0(zap_remove(os, object, propname, tx)); | ||||
dmu_tx_commit(tx); | dmu_tx_commit(tx); | ||||
out: | out: | ||||
umem_free(od, sizeof (ztest_od_t)); | umem_free(od, sizeof (ztest_od_t)); | ||||
Context not available. | |||||
count = -1ULL; | count = -1ULL; | ||||
VERIFY0(zap_count(os, object, &count)); | VERIFY0(zap_count(os, object, &count)); | ||||
ASSERT(count != -1ULL); | ASSERT3S(count, !=, -1ULL); | ||||
/* | /* | ||||
* Select an operation: length, lookup, add, update, remove. | * Select an operation: length, lookup, add, update, remove. | ||||
Context not available. | |||||
break; | break; | ||||
case 3: | case 3: | ||||
VERIFY(zap_update(os, object, name, wsize, wc, data, tx) == 0); | VERIFY0(zap_update(os, object, name, wsize, wc, data, tx)); | ||||
break; | break; | ||||
case 4: | case 4: | ||||
Context not available. | |||||
ztest_cb_data_t *data = arg; | ztest_cb_data_t *data = arg; | ||||
uint64_t synced_txg; | uint64_t synced_txg; | ||||
VERIFY(data != NULL); | VERIFY3P(data, !=, NULL); | ||||
VERIFY3S(data->zcd_expected_err, ==, error); | VERIFY3S(data->zcd_expected_err, ==, error); | ||||
VERIFY(!data->zcd_called); | VERIFY(!data->zcd_called); | ||||
Context not available. | |||||
/* | /* | ||||
* Read existing data to make sure there isn't a future leak. | * Read existing data to make sure there isn't a future leak. | ||||
*/ | */ | ||||
VERIFY(0 == dmu_read(os, od->od_object, 0, sizeof (uint64_t), | VERIFY0(dmu_read(os, od->od_object, 0, sizeof (uint64_t), | ||||
&old_txg, DMU_READ_PREFETCH)); | &old_txg, DMU_READ_PREFETCH)); | ||||
if (old_txg > txg) | if (old_txg > txg) | ||||
Context not available. | |||||
if (ztest_opts.zo_verbose >= 6) | if (ztest_opts.zo_verbose >= 6) | ||||
dump_nvlist(props, 4); | dump_nvlist(props, 4); | ||||
nvlist_free(props); | fnvlist_free(props); | ||||
(void) pthread_rwlock_unlock(&ztest_name_lock); | (void) pthread_rwlock_unlock(&ztest_name_lock); | ||||
} | } | ||||
Context not available. | |||||
mirror_save = zs->zs_mirrors; | mirror_save = zs->zs_mirrors; | ||||
mutex_exit(&ztest_vdev_lock); | mutex_exit(&ztest_vdev_lock); | ||||
ASSERT(leaves >= 1); | ASSERT3U(leaves, >=, 1); | ||||
/* | /* | ||||
* While ztest is running the number of leaves will not change. This | * While ztest is running the number of leaves will not change. This | ||||
Context not available. | |||||
if (islog) | if (islog) | ||||
(void) pthread_rwlock_wrlock(&ztest_name_lock); | (void) pthread_rwlock_wrlock(&ztest_name_lock); | ||||
VERIFY(vdev_offline(spa, guid0, flags) != EBUSY); | VERIFY3U(vdev_offline(spa, guid0, flags), !=, EBUSY); | ||||
if (islog) | if (islog) | ||||
(void) pthread_rwlock_unlock(&ztest_name_lock); | (void) pthread_rwlock_unlock(&ztest_name_lock); | ||||
Context not available. | |||||
return; | return; | ||||
} | } | ||||
VERIFY(realpath(getexecname(), bin) != NULL); | VERIFY3P(realpath(getexecname(), bin), !=, NULL); | ||||
if (strstr(bin, "/ztest/")) { | if (strstr(bin, "/ztest/")) { | ||||
strstr(bin, "/ztest/")[0] = '\0'; /* In-tree */ | strstr(bin, "/ztest/")[0] = '\0'; /* In-tree */ | ||||
strcat(bin, "/zdb/zdb"); | strcat(bin, "/zdb/zdb"); | ||||
Context not available. | |||||
eligible[eligible_idx++] = cvd; | eligible[eligible_idx++] = cvd; | ||||
} | } | ||||
} | } | ||||
VERIFY(eligible_idx > 0); | VERIFY3S(eligible_idx, >, 0); | ||||
uint64_t child_no = ztest_random(eligible_idx); | uint64_t child_no = ztest_random(eligible_idx); | ||||
return (ztest_random_concrete_vdev_leaf(eligible[child_no])); | return (ztest_random_concrete_vdev_leaf(eligible[child_no])); | ||||
Context not available. | |||||
/* | /* | ||||
* Get the pool's configuration and guid. | * Get the pool's configuration and guid. | ||||
*/ | */ | ||||
VERIFY3U(0, ==, spa_open(oldname, &spa, FTAG)); | VERIFY0(spa_open(oldname, &spa, FTAG)); | ||||
/* | /* | ||||
* Kick off a scrub to tickle scrub/export races. | * Kick off a scrub to tickle scrub/export races. | ||||
Context not available. | |||||
/* | /* | ||||
* Export it. | * Export it. | ||||
*/ | */ | ||||
VERIFY3U(0, ==, spa_export(oldname, &config, B_FALSE, B_FALSE)); | VERIFY0(spa_export(oldname, &config, B_FALSE, B_FALSE)); | ||||
ztest_walk_pool_directory("pools after export"); | ztest_walk_pool_directory("pools after export"); | ||||
Context not available. | |||||
* Try to import it. | * Try to import it. | ||||
*/ | */ | ||||
newconfig = spa_tryimport(config); | newconfig = spa_tryimport(config); | ||||
ASSERT(newconfig != NULL); | ASSERT3P(newconfig, !=, NULL); | ||||
nvlist_free(newconfig); | fnvlist_free(newconfig); | ||||
/* | /* | ||||
* Import it under the new name. | * Import it under the new name. | ||||
Context not available. | |||||
/* | /* | ||||
* Verify that we can open and close the pool using the new name. | * Verify that we can open and close the pool using the new name. | ||||
*/ | */ | ||||
VERIFY3U(0, ==, spa_open(newname, &spa, FTAG)); | VERIFY0(spa_open(newname, &spa, FTAG)); | ||||
ASSERT(pool_guid == spa_guid(spa)); | ASSERT3U(pool_guid, ==, spa_guid(spa)); | ||||
spa_close(spa, FTAG); | spa_close(spa, FTAG); | ||||
nvlist_free(config); | fnvlist_free(config); | ||||
} | } | ||||
static void | static void | ||||
Context not available. | |||||
* That's because zap_count() returns the open-context value, | * That's because zap_count() returns the open-context value, | ||||
* while dmu_objset_space() returns the rootbp fill count. | * while dmu_objset_space() returns the rootbp fill count. | ||||
*/ | */ | ||||
VERIFY3U(0, ==, zap_count(zd->zd_os, ZTEST_DIROBJ, &dirobjs)); | VERIFY0(zap_count(zd->zd_os, ZTEST_DIROBJ, &dirobjs)); | ||||
dmu_objset_space(zd->zd_os, &scratch, &scratch, &usedobjs, &scratch); | dmu_objset_space(zd->zd_os, &scratch, &scratch, &usedobjs, &scratch); | ||||
ASSERT3U(dirobjs + 1, ==, usedobjs); | ASSERT3U(dirobjs + 1, ==, usedobjs); | ||||
} | } | ||||
Context not available. | |||||
(void) printf("testing spa_freeze()...\n"); | (void) printf("testing spa_freeze()...\n"); | ||||
kernel_init(SPA_MODE_READ | SPA_MODE_WRITE); | kernel_init(SPA_MODE_READ | SPA_MODE_WRITE); | ||||
VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG)); | VERIFY0(spa_open(ztest_opts.zo_pool, &spa, FTAG)); | ||||
VERIFY3U(0, ==, ztest_dataset_open(0)); | VERIFY0(ztest_dataset_open(0)); | ||||
ztest_spa = spa; | ztest_spa = spa; | ||||
/* | /* | ||||
Context not available. | |||||
* Open and close the pool and dataset to induce log replay. | * Open and close the pool and dataset to induce log replay. | ||||
*/ | */ | ||||
kernel_init(SPA_MODE_READ | SPA_MODE_WRITE); | kernel_init(SPA_MODE_READ | SPA_MODE_WRITE); | ||||
VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG)); | VERIFY0(spa_open(ztest_opts.zo_pool, &spa, FTAG)); | ||||
ASSERT(spa_freeze_txg(spa) == UINT64_MAX); | ASSERT3U(spa_freeze_txg(spa), ==, UINT64_MAX); | ||||
VERIFY3U(0, ==, ztest_dataset_open(0)); | VERIFY0(ztest_dataset_open(0)); | ||||
ztest_spa = spa; | ztest_spa = spa; | ||||
txg_wait_synced(spa_get_dsl(spa), 0); | txg_wait_synced(spa_get_dsl(spa), 0); | ||||
ztest_dataset_close(0); | ztest_dataset_close(0); | ||||
Context not available. | |||||
{ | { | ||||
nvlist_t *props; | nvlist_t *props; | ||||
VERIFY0(nvlist_alloc(&props, NV_UNIQUE_NAME, 0)); | props = fnvlist_alloc(); | ||||
if (ztest_random(2) == 0) | if (ztest_random(2) == 0) | ||||
return (props); | return (props); | ||||
VERIFY0(nvlist_add_uint64(props, | fnvlist_add_uint64(props, | ||||
zpool_prop_to_name(ZPOOL_PROP_AUTOREPLACE), 1)); | zpool_prop_to_name(ZPOOL_PROP_AUTOREPLACE), 1); | ||||
return (props); | return (props); | ||||
} | } | ||||
Context not available. | |||||
* in which case ztest_fault_inject() temporarily takes away | * in which case ztest_fault_inject() temporarily takes away | ||||
* the only valid replica. | * the only valid replica. | ||||
*/ | */ | ||||
VERIFY0(nvlist_add_uint64(props, | fnvlist_add_uint64(props, | ||||
zpool_prop_to_name(ZPOOL_PROP_FAILUREMODE), | zpool_prop_to_name(ZPOOL_PROP_FAILUREMODE), | ||||
MAXFAULTS(zs) ? ZIO_FAILURE_MODE_PANIC : ZIO_FAILURE_MODE_WAIT)); | MAXFAULTS(zs) ? ZIO_FAILURE_MODE_PANIC : ZIO_FAILURE_MODE_WAIT); | ||||
for (i = 0; i < SPA_FEATURES; i++) { | for (i = 0; i < SPA_FEATURES; i++) { | ||||
char *buf; | char *buf; | ||||
Context not available. | |||||
VERIFY3S(-1, !=, asprintf(&buf, "feature@%s", | VERIFY3S(-1, !=, asprintf(&buf, "feature@%s", | ||||
spa_feature_table[i].fi_uname)); | spa_feature_table[i].fi_uname)); | ||||
VERIFY3U(0, ==, nvlist_add_uint64(props, buf, 0)); | fnvlist_add_uint64(props, buf, 0); | ||||
free(buf); | free(buf); | ||||
} | } | ||||
VERIFY0(spa_create(ztest_opts.zo_pool, nvroot, props, NULL, NULL)); | VERIFY0(spa_create(ztest_opts.zo_pool, nvroot, props, NULL, NULL)); | ||||
nvlist_free(nvroot); | fnvlist_free(nvroot); | ||||
nvlist_free(props); | fnvlist_free(props); | ||||
VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG)); | VERIFY0(spa_open(ztest_opts.zo_pool, &spa, FTAG)); | ||||
zs->zs_metaslab_sz = | zs->zs_metaslab_sz = | ||||
1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift; | 1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift; | ||||
spa_close(spa, FTAG); | spa_close(spa, FTAG); | ||||
Context not available. | |||||
hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()), | hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()), | ||||
PROT_READ | PROT_WRITE, MAP_SHARED, ztest_fd_data, 0); | PROT_READ | PROT_WRITE, MAP_SHARED, ztest_fd_data, 0); | ||||
ASSERT(hdr != MAP_FAILED); | ASSERT3P(hdr, !=, MAP_FAILED); | ||||
VERIFY3U(0, ==, ftruncate(ztest_fd_data, sizeof (ztest_shared_hdr_t))); | VERIFY0(ftruncate(ztest_fd_data, sizeof (ztest_shared_hdr_t))); | ||||
hdr->zh_hdr_size = sizeof (ztest_shared_hdr_t); | hdr->zh_hdr_size = sizeof (ztest_shared_hdr_t); | ||||
hdr->zh_opts_size = sizeof (ztest_shared_opts_t); | hdr->zh_opts_size = sizeof (ztest_shared_opts_t); | ||||
Context not available. | |||||
hdr->zh_ds_count = ztest_opts.zo_datasets; | hdr->zh_ds_count = ztest_opts.zo_datasets; | ||||
size = shared_data_size(hdr); | size = shared_data_size(hdr); | ||||
VERIFY3U(0, ==, ftruncate(ztest_fd_data, size)); | VERIFY0(ftruncate(ztest_fd_data, size)); | ||||
(void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize())); | (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize())); | ||||
} | } | ||||
Context not available. | |||||
hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()), | hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()), | ||||
PROT_READ, MAP_SHARED, ztest_fd_data, 0); | PROT_READ, MAP_SHARED, ztest_fd_data, 0); | ||||
ASSERT(hdr != MAP_FAILED); | ASSERT3P(hdr, !=, MAP_FAILED); | ||||
size = shared_data_size(hdr); | size = shared_data_size(hdr); | ||||
(void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize())); | (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize())); | ||||
hdr = ztest_shared_hdr = (void *)mmap(0, P2ROUNDUP(size, getpagesize()), | hdr = ztest_shared_hdr = (void *)mmap(0, P2ROUNDUP(size, getpagesize()), | ||||
PROT_READ | PROT_WRITE, MAP_SHARED, ztest_fd_data, 0); | PROT_READ | PROT_WRITE, MAP_SHARED, ztest_fd_data, 0); | ||||
ASSERT(hdr != MAP_FAILED); | ASSERT3P(hdr, !=, MAP_FAILED); | ||||
buf = (uint8_t *)hdr; | buf = (uint8_t *)hdr; | ||||
offset = hdr->zh_hdr_size; | offset = hdr->zh_hdr_size; | ||||
Context not available. | |||||
(void) setrlimit(RLIMIT_NOFILE, &rl); | (void) setrlimit(RLIMIT_NOFILE, &rl); | ||||
(void) close(ztest_fd_rand); | (void) close(ztest_fd_rand); | ||||
VERIFY(11 >= snprintf(fd_data_str, 12, "%d", ztest_fd_data)); | VERIFY3S(11, >=, | ||||
VERIFY(0 == setenv("ZTEST_FD_DATA", fd_data_str, 1)); | snprintf(fd_data_str, 12, "%d", ztest_fd_data)); | ||||
VERIFY0(setenv("ZTEST_FD_DATA", fd_data_str, 1)); | |||||
(void) enable_extended_FILE_stdio(-1, -1); | (void) enable_extended_FILE_stdio(-1, -1); | ||||
if (libpath != NULL) | if (libpath != NULL) | ||||
VERIFY(0 == setenv("LD_LIBRARY_PATH", libpath, 1)); | VERIFY0(setenv("LD_LIBRARY_PATH", libpath, 1)); | ||||
(void) execv(cmd, emptyargv); | (void) execv(cmd, emptyargv); | ||||
ztest_dump_core = B_FALSE; | ztest_dump_core = B_FALSE; | ||||
fatal(B_TRUE, "exec failed: %s", cmd); | fatal(B_TRUE, "exec failed: %s", cmd); | ||||
Context not available. | |||||
ASSERT3U(ztest_opts.zo_datasets, ==, ztest_shared_hdr->zh_ds_count); | ASSERT3U(ztest_opts.zo_datasets, ==, ztest_shared_hdr->zh_ds_count); | ||||
/* Override location of zpool.cache */ | /* Override location of zpool.cache */ | ||||
VERIFY(asprintf((char **)&spa_config_path, "%s/zpool.cache", | VERIFY3S(asprintf((char **)&spa_config_path, "%s/zpool.cache", | ||||
ztest_opts.zo_dir) != -1); | ztest_opts.zo_dir), !=, -1); | ||||
ztest_ds = umem_alloc(ztest_opts.zo_datasets * sizeof (ztest_ds_t), | ztest_ds = umem_alloc(ztest_opts.zo_datasets * sizeof (ztest_ds_t), | ||||
UMEM_NOFAIL); | UMEM_NOFAIL); | ||||
Context not available. |