Skip to content

Commit

Permalink
Add functionality to ztest to change dnodesize
Browse files Browse the repository at this point in the history
This change adds a new test to the ztest test suite, for changing a
dataset's dnodesize to a randomly chosen valid value.

Signed-off-by: Prakash Surya <[email protected]>
  • Loading branch information
Prakash Surya authored and nedbass committed Jul 7, 2015
1 parent 6f56f91 commit 71acdca
Showing 1 changed file with 51 additions and 6 deletions.
57 changes: 51 additions & 6 deletions cmd/ztest/ztest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -4764,6 +4768,47 @@ 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);

(void) rw_rdlock(&ztest_name_lock);

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);
goto out;
} 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);

out:
(void) rw_unlock(&ztest_name_lock);
}

/* ARGSUSED */
void
ztest_dsl_prop_get_set(ztest_ds_t *zd, uint64_t id)
Expand Down

0 comments on commit 71acdca

Please sign in to comment.