diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index 642cab5f2f33..23aae207e644 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -322,6 +322,7 @@ ztest_func_t ztest_dmu_prealloc; ztest_func_t ztest_fzap; ztest_func_t ztest_dmu_snapshot_create_destroy; ztest_func_t ztest_dsl_prop_get_set; +ztest_func_t ztest_dsl_dnodesize_get_set; ztest_func_t ztest_spa_prop_get_set; ztest_func_t ztest_spa_create_destroy; ztest_func_t ztest_fault_inject; @@ -363,6 +364,7 @@ ztest_info_t ztest_info[] = { ZTI_INIT(ztest_dmu_read_write_zcopy, 1, &zopt_often), ZTI_INIT(ztest_dmu_objset_create_destroy, 1, &zopt_often), ZTI_INIT(ztest_dsl_prop_get_set, 1, &zopt_often), + ZTI_INIT(ztest_dsl_dnodesize_get_set, 1, &zopt_always), ZTI_INIT(ztest_spa_prop_get_set, 1, &zopt_sometimes), #if 0 ZTI_INIT(ztest_dmu_prealloc, 1, &zopt_sometimes), @@ -1368,7 +1370,7 @@ ztest_bt_bonus(dmu_buf_t *db) #define lrz_blocksize lr_uid #define lrz_ibshift lr_gid #define lrz_bonustype lr_rdev -#define lrz_bonuslen lr_crtime[1] +#define lrz_count lr_crtime[1] static void ztest_log_create(ztest_ds_t *zd, dmu_tx_t *tx, lr_create_t *lr) @@ -1510,21 +1512,21 @@ ztest_replay_create(ztest_ds_t *zd, lr_create_t *lr, boolean_t byteswap) if (lr->lr_foid == 0) { lr->lr_foid = zap_create(os, lr->lrz_type, lr->lrz_bonustype, - lr->lrz_bonuslen, tx); + DN_BONUS_SIZE(lr->lrz_count), tx); } else { error = zap_create_claim(os, lr->lr_foid, lr->lrz_type, lr->lrz_bonustype, - lr->lrz_bonuslen, tx); + DN_BONUS_SIZE(lr->lrz_count), tx); } } else { if (lr->lr_foid == 0) { lr->lr_foid = dmu_object_alloc(os, lr->lrz_type, 0, lr->lrz_bonustype, - lr->lrz_bonuslen, tx); + DN_BONUS_SIZE(lr->lrz_count), tx); } else { error = dmu_object_claim(os, lr->lr_foid, lr->lrz_type, 0, lr->lrz_bonustype, - lr->lrz_bonuslen, tx); + DN_BONUS_SIZE(lr->lrz_count), tx); } } @@ -2065,7 +2067,7 @@ ztest_create(ztest_ds_t *zd, ztest_od_t *od, int count) lr->lrz_blocksize = od->od_crblocksize; lr->lrz_ibshift = ztest_random_ibshift(); lr->lrz_bonustype = DMU_OT_UINT64_OTHER; - lr->lrz_bonuslen = dmu_bonus_max(); + lr->lrz_count = zd->zd_os->os_dn_count; lr->lr_gen = od->od_crgen; lr->lr_crtime[0] = time(NULL); @@ -3629,6 +3631,8 @@ ztest_dmu_object_alloc_free(ztest_ds_t *zd, uint64_t id) int size; int b; + ztest_dsl_dnodesize_get_set(zd, id); + size = sizeof (ztest_od_t) * OD_ARRAY_SIZE; od = umem_alloc(size, UMEM_NOFAIL); batchsize = OD_ARRAY_SIZE; @@ -4764,6 +4768,45 @@ ztest_dmu_commit_callbacks(ztest_ds_t *zd, uint64_t id) umem_free(od, sizeof (ztest_od_t)); } +/* ARGSUSED */ +void +ztest_dsl_dnodesize_get_set(ztest_ds_t *zd, uint64_t id) +{ + const char *propname = zfs_prop_to_name(ZFS_PROP_DNODESIZE); + char *setpoint; + uint64_t rand, size, curval; + int error; + + rand = ztest_random(DNODE_MAX_SIZE - DNODE_MIN_SIZE); + size = (DNODE_MIN_SIZE + rand) - (rand % DNODE_MIN_SIZE); + + ASSERT3S(size, >=, DNODE_MIN_SIZE); + ASSERT3S(size, <=, DNODE_MAX_SIZE); + ASSERT0(size % DNODE_MIN_SIZE); + + error = dsl_prop_set_int(zd->zd_name, propname, + (ztest_random(2) ? ZPROP_SRC_NONE : ZPROP_SRC_LOCAL), size); + + if (error == ENOSPC) { + ztest_record_enospc(FTAG); + return; + } else if (error == EXDEV) { + /* Dataset not in pool due to concurrent destroy. */ + return; + } else { + ASSERT0(error); + } + + setpoint = umem_alloc(MAXPATHLEN, UMEM_NOFAIL); + VERIFY0(dsl_prop_get_integer(zd->zd_name, propname, &curval, setpoint)); + + if (ztest_opts.zo_verbose >= 6) + (void) printf("%s %s = %lu at '%s'\n", + zd->zd_name, propname, curval, setpoint); + + umem_free(setpoint, MAXPATHLEN); +} + /* ARGSUSED */ void ztest_dsl_prop_get_set(ztest_ds_t *zd, uint64_t id)