Skip to content

Commit

Permalink
Replication functionality check-in. (#4)
Browse files Browse the repository at this point in the history
[ZoL#62] Replication functionality check-in
Signed-off-by: satbir <[email protected]>
  • Loading branch information
satbirchhikara authored and vishnuitta committed Mar 7, 2018
1 parent 399d4f2 commit 1d06753
Show file tree
Hide file tree
Showing 20 changed files with 1,636 additions and 28 deletions.
3 changes: 2 additions & 1 deletion cmd/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SUBDIRS = zfs zpool zdb zhack zinject zstreamdump ztest uzfs_test zpios
SUBDIRS = zfs zpool zdb zhack zinject zstreamdump ztest zrepl uzfs_test zpios
SUBDIRS += mount_zfs fsck_zfs zvol_id vdev_id arcstat dbufstat zed
SUBDIRS += arc_summary raidz_test zgenhostid tgt dmu_io_test

37 changes: 31 additions & 6 deletions cmd/uzfs_test/uzfs_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <uzfs_io.h>
#include <uzfs_test.h>
#include <math.h>
#include <zrepl_mgmt.h>

int total_time_in_sec = 60;
int log_device = 0;
Expand Down Expand Up @@ -261,7 +262,9 @@ void
unit_test_create_pool_ds(void)
{
void *spa1, *spa2, *spa3, *spa4, *spa;
void *zv1, *zv2, *zv3, *zv4, *zv5, *zv;
void *zv1 = NULL; void *zv3 = NULL;
void *zv2 = NULL; void *zv4 = NULL;
void *zv5 = NULL; void *zv = NULL;
int err, err1, err2, err3, err4, err5;

err1 = uzfs_create_pool(pool, "/tmp/uztest.xyz", &spa1);
Expand Down Expand Up @@ -498,16 +501,23 @@ static void process_options(int argc, char **argv)
printf("total run time in seconds: %d\n", total_time_in_sec);
}
}

void
open_pool_ds(void **spa, void **zv)
open_pool(void **spa)
{
int err;
err = uzfs_open_pool(pool, spa);
if (err != 0) {
printf("pool open errored.. %d\n", err);
exit(1);
}
err = uzfs_open_dataset(*spa, ds, zv);
}

void
open_ds(void *spa, void **zv)
{
int err;
err = uzfs_open_dataset(spa, ds, zv);
if (err != 0) {
printf("ds open errored.. %d\n", err);
exit(1);
Expand All @@ -520,11 +530,13 @@ unit_test_fn(void *arg)
void *spa, *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;
zvol_info_t *zinfo = NULL;
worker_args_t reader1_args, writer_args[3];

mutex_init(&mtx, NULL, MUTEX_DEFAULT, NULL);
Expand All @@ -535,7 +547,13 @@ unit_test_fn(void *arg)
unit_test_create_pool_ds();
}

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

reader1_args.zv = zv;
reader1_args.threads_done = &threads_done;
Expand Down Expand Up @@ -570,8 +588,15 @@ unit_test_fn(void *arg)
cv_destroy(&cv);
mutex_destroy(&mtx);

uzfs_close_dataset(zv);
uzfs_close_pool(spa);
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);
uzfs_close_pool(spa);
}
}

int
Expand Down
31 changes: 27 additions & 4 deletions cmd/uzfs_test/uzfs_test_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <uzfs_io.h>
#include <uzfs_test.h>
#include <math.h>
#include <zrepl_mgmt.h>

int
verify_fn(void *zv, char *buf, int block_size)
Expand Down Expand Up @@ -140,6 +141,8 @@ void
replay_fn(void *arg)
{
void *spa, *zv;
char name[MAXNAMELEN];
zvol_info_t *zinfo = NULL;

zfs_txg_timeout = 30;

Expand All @@ -148,9 +151,22 @@ replay_fn(void *arg)
setup_unit_test();
unit_test_create_pool_ds();
}
open_pool_ds(&spa, &zv);

open_pool(&spa);
if (create == 1) {
open_ds(spa, &zv);
} else {
zinfo = uzfs_zinfo_lookup(ds);
zv = zinfo->zv;
}
} else if (verify != 0) {
open_pool_ds(&spa, &zv);
open_pool(&spa);
if (create == 1) {
open_ds(spa, &zv);
} else {
zinfo = uzfs_zinfo_lookup(ds);
zv = zinfo->zv;
}
} else {
printf("exiting program..\n");
uzfs_fini();
Expand All @@ -162,8 +178,15 @@ replay_fn(void *arg)
if (verify != 0)
if (silent == 0)
printf("verify error: %d\n", verify_err);
uzfs_close_dataset(zv);
uzfs_close_pool(spa);
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);
uzfs_close_pool(spa);
}

if (verify_err)
exit(verify_err);
Expand Down
3 changes: 2 additions & 1 deletion cmd/uzfs_test/uzfs_txg_diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ uzfs_txg_diff_verifcation_test(void *arg)

setup_unit_test();
unit_test_create_pool_ds();
open_pool_ds(&spa, &zvol);
open_pool(&spa);
open_ds(spa, &zvol);

vol_blocks = active_size / block_size;
buf = umem_alloc(block_size, UMEM_NOFAIL);
Expand Down
3 changes: 2 additions & 1 deletion cmd/uzfs_test/uzfs_zvol_zap.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ uzfs_zvol_zap_operation(void *arg)

setup_unit_test();
unit_test_create_pool_ds();
open_pool_ds(&spa, &zvol);
open_pool(&spa);
open_ds(spa, &zvol);

while (i++ < test_iterations) {
zap_count = uzfs_random(16) + 1;
Expand Down
22 changes: 22 additions & 0 deletions cmd/zrepl/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
include $(top_srcdir)/config/Rules.am

# -Wnoformat-truncation to get rid of compiler warning for unchecked
# truncating snprintfs on gcc 7.1.1.
AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN) $(NO_FORMAT_TRUNCATION)
AM_CPPFLAGS += -DDEBUG

DEFAULT_INCLUDES += \
-I$(top_srcdir)/include \
-I$(top_srcdir)/lib/libspl/include

sbin_PROGRAMS = zrepl

zrepl_SOURCES = \
zrepl.c

zrepl_LDADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
$(top_builddir)/lib/libuutil/libuutil.la \
$(top_builddir)/lib/libzpool/libzpool.la \
$(top_builddir)/lib/libzfs/libzfs.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la
Loading

0 comments on commit 1d06753

Please sign in to comment.