Skip to content

Commit

Permalink
pool/volume create/import/destroy for uzfs (#43)
Browse files Browse the repository at this point in the history
* pool/volume create/import/destroy/export for uzfs
* testcase to do IOs on imported pools
* CLI tests for target IP address
* owning dataset in uZFS during handshake with target

Signed-off-by: Vishnu Itta <[email protected]>
  • Loading branch information
vishnuitta authored and Jan Kryl committed Jun 26, 2018
1 parent 3afc5cd commit 5540385
Show file tree
Hide file tree
Showing 23 changed files with 857 additions and 1,097 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ before_install:
# packages for tests
- sudo apt-get install --yes -qq parted lsscsi ksh attr acl nfs-kernel-server fio
- sudo apt-get install --yes -qq libgtest-dev cmake
# packages for debugging
- sudo apt-get install gdb
# use gcc-6 by default
- sudo unlink /usr/bin/gcc && sudo ln -s /usr/bin/gcc-6 /usr/bin/gcc
- sudo unlink /usr/bin/g++ && sudo ln -s /usr/bin/g++-6 /usr/bin/g++
Expand Down Expand Up @@ -68,7 +70,6 @@ script:
# run ztest and test supported zio backends
# XXX enable the ztest when ticket #152 is fixed
- if [ $ZFS_BUILD_TAGS = 0 ]; then
sudo mkdir /etc/zfs;
export FIO_SRCDIR=$PWD/../fio;
travis_wait 60 sudo bash ./tests/cbtest/script/test_uzfs.sh -T all || travis_terminate 1;
else
Expand Down
24 changes: 5 additions & 19 deletions cmd/uzfs_test/uzfs_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,14 +654,15 @@ open_pool(spa_t **spa)
}

void
open_ds(spa_t *spa, zvol_state_t **zv)
open_ds(spa_t *spa, char *ds, zvol_state_t **zv)
{
int err;
err = uzfs_open_dataset(spa, ds, zv);
if (err != 0) {
printf("ds open errored.. %d\n", err);
exit(1);
}
uzfs_hold_dataset(*zv);
}

void
Expand All @@ -671,14 +672,12 @@ unit_test_fn(void *arg)
zvol_state_t *zv;
kthread_t *reader1;
kthread_t *writer[3];
char name[MAXNAMELEN];
int i;
kmutex_t mtx;
kcondvar_t cv;
int threads_done = 0;
int num_threads = 0;
uint64_t total_ios = 0;
zvol_info_t *zinfo = NULL;
worker_args_t reader1_args;
worker_args_t writer_args[3];

Expand All @@ -691,12 +690,7 @@ unit_test_fn(void *arg)
}

open_pool(&spa);
if (create == 1) {
open_ds(spa, &zv);
} else {
zinfo = uzfs_zinfo_lookup(ds);
zv = zinfo->zv;
}
open_ds(spa, ds, &zv);

if (uzfs_test_id == 2) {
reader1_args.zv = zv;
Expand Down Expand Up @@ -741,16 +735,8 @@ unit_test_fn(void *arg)

cv_destroy(&cv);
mutex_destroy(&mtx);

if (create == 1) {
uzfs_close_dataset(zv);
uzfs_close_pool(spa);
} else {
strlcpy(name, zinfo->name, MAXNAMELEN);
uzfs_zinfo_drop_refcnt(zinfo, 0);
uzfs_zinfo_destroy(name, NULL);
uzfs_close_pool(spa);
}
uzfs_close_dataset(zv);
uzfs_close_pool(spa);
}

void
Expand Down
31 changes: 9 additions & 22 deletions cmd/uzfs_test/uzfs_test_rebuilding.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,7 @@ replica_writer_thread(void *arg)
}

static void
open_pool_and_dataset(spa_t **spa, zvol_info_t **zinfo, char *pool_name,
char *ds_name)
open_pool_and_dataset(spa_t **spa, char *pool_name, char *ds_name)
{
int err;

Expand All @@ -545,23 +544,12 @@ open_pool_and_dataset(spa_t **spa, zvol_info_t **zinfo, char *pool_name,
printf("pool(%s) open errored.. %d\n", pool_name, err);
exit(1);
}

*zinfo = uzfs_zinfo_lookup(ds_name);
if (*zinfo == NULL) {
uzfs_close_pool(*spa);
printf("failed to lookup dataset(%s)\n", ds_name);
exit(1);
}
}

static void
close_pool_and_dataset(spa_t *spa, zvol_info_t *zinfo)
close_pool_and_dataset(spa_t *spa, zvol_state_t *zvol)
{
char name[MAXNAMELEN];

strlcpy(name, zinfo->name, MAXNAMELEN);
uzfs_zinfo_drop_refcnt(zinfo, 0);
uzfs_zinfo_destroy(name, NULL);
uzfs_close_dataset(zvol);
uzfs_close_pool(spa);
}

Expand All @@ -579,7 +567,6 @@ uzfs_rebuild_test(void *arg)
char *pooldup = strdup(pool);
char *dsdup = strdup(ds);
char *pool1, *pool2, *ds1, *ds2;
zvol_info_t *zinfo1, *zinfo2;
printf("starting %s\n", test_info->name);

pool1 = strtok(pooldup, ",");
Expand All @@ -589,11 +576,11 @@ uzfs_rebuild_test(void *arg)
if (!ds2)
ds2 = ds1;

open_pool_and_dataset(&spa1, &zinfo1, pool1, ds1);
open_pool_and_dataset(&spa2, &zinfo2, pool2, ds2);
open_pool_and_dataset(&spa1, pool1, ds1);
open_pool_and_dataset(&spa2, pool2, ds2);

zvol1 = zinfo1->zv;
zvol2 = zinfo2->zv;
open_ds(spa1, ds1, &zvol1);
open_ds(spa2, ds2, &zvol2);

while (n++ < test_iterations) {
mutex_init(&mtx, NULL, MUTEX_DEFAULT, NULL);
Expand Down Expand Up @@ -671,8 +658,8 @@ uzfs_rebuild_test(void *arg)
printf("%s pass:%d\n", test_info->name, n);
}

close_pool_and_dataset(spa1, zinfo1);
close_pool_and_dataset(spa2, zinfo2);
close_pool_and_dataset(spa1, zvol1);
close_pool_and_dataset(spa2, zvol2);
free(pooldup);
free(dsdup);
}
28 changes: 4 additions & 24 deletions cmd/uzfs_test/uzfs_test_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ replay_fn(void *arg)
{
spa_t *spa;
zvol_state_t *zv;
char name[MAXNAMELEN];
zvol_info_t *zinfo = NULL;

zfs_txg_timeout = 30;

Expand All @@ -163,20 +161,10 @@ replay_fn(void *arg)
}

open_pool(&spa);
if (create == 1)
open_ds(spa, &zv);
else {
zinfo = uzfs_zinfo_lookup(ds);
zv = zinfo->zv;
}
open_ds(spa, ds, &zv);
} else if (verify != 0) {
open_pool(&spa);
if (create == 1) {
open_ds(spa, &zv);
} else {
zinfo = uzfs_zinfo_lookup(ds);
zv = zinfo->zv;
}
open_ds(spa, ds, &zv);
} else {
printf("exiting program..\n");
uzfs_fini();
Expand All @@ -188,16 +176,8 @@ replay_fn(void *arg)
if (verify != 0)
if (silent == 0)
printf("verify error: %d\n", verify_err);
if (create == 1) {
uzfs_close_dataset(zv);
uzfs_close_pool(spa);
} else {
strlcpy(name, zinfo->name, MAXNAMELEN);
uzfs_zinfo_drop_refcnt(zinfo, 0);
uzfs_zinfo_destroy(name, NULL);
uzfs_close_pool(spa);
}

uzfs_close_dataset(zv);
uzfs_close_pool(spa);
if (verify_err)
exit(verify_err);
}
9 changes: 2 additions & 7 deletions cmd/uzfs_test/uzfs_zvol_zap.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ uzfs_zvol_zap_operation(void *arg)
{
uzfs_test_info_t *test_info = (uzfs_test_info_t *)arg;
int i = 0;
char name[MAXNAMELEN];
hrtime_t end, now;
spa_t *spa;
zvol_state_t *zvol;
Expand All @@ -124,11 +123,9 @@ uzfs_zvol_zap_operation(void *arg)
uint64_t txg1, txg2, txg3, txg4;
struct timespec ts;
int err1, err2;
zvol_info_t *zinfo = NULL;

open_pool(&spa);
zinfo = uzfs_zinfo_lookup(ds);
zvol = zinfo->zv;
open_ds(spa, ds, &zvol);
if (!zvol) {
printf("couldn't find zvol\n");
uzfs_close_pool(spa);
Expand Down Expand Up @@ -227,8 +224,6 @@ uzfs_zvol_zap_operation(void *arg)
break;
}

strlcpy(name, zinfo->name, MAXNAMELEN);
uzfs_zinfo_drop_refcnt(zinfo, 0);
uzfs_zinfo_destroy(name, NULL);
uzfs_close_dataset(zvol);
uzfs_close_pool(spa);
}
Loading

0 comments on commit 5540385

Please sign in to comment.