diff options
author | mm <mm@FreeBSD.org> | 2012-06-11 11:35:22 +0000 |
---|---|---|
committer | mm <mm@FreeBSD.org> | 2012-06-11 11:35:22 +0000 |
commit | cc61ab2f133566dca51970d44cc49a4355039b5d (patch) | |
tree | a0efb9ad759cc8c8f8ec6f2cbabe6b3305a334e9 /cddl/contrib/opensolaris/cmd/ztest | |
parent | 2cecdd81d885af2868172221b5068c523eade78c (diff) | |
download | FreeBSD-src-cc61ab2f133566dca51970d44cc49a4355039b5d.zip FreeBSD-src-cc61ab2f133566dca51970d44cc49a4355039b5d.tar.gz |
Introduce "feature flags" for ZFS pools (bump SPA version to 5000).
Add first feature "com.delphix:async_destroy" (asynchronous destroy
of ZFS datasets).
Implement features support in ZFS boot code.
Illumos revisions merged:
13700:2889e2596bd6
13701:1949b688d5fb
2619 asynchronous destruction of ZFS file systems
2747 SPA versioning with zfs feature flags
References:
https://www.illumos.org/issues/2619
https://www.illumos.org/issues/2747
Obtained from: illumos (issue #2619, #2747)
MFC after: 1 month
Diffstat (limited to 'cddl/contrib/opensolaris/cmd/ztest')
-rw-r--r-- | cddl/contrib/opensolaris/cmd/ztest/ztest.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/cddl/contrib/opensolaris/cmd/ztest/ztest.c b/cddl/contrib/opensolaris/cmd/ztest/ztest.c index 487f95a..db373e1 100644 --- a/cddl/contrib/opensolaris/cmd/ztest/ztest.c +++ b/cddl/contrib/opensolaris/cmd/ztest/ztest.c @@ -107,6 +107,7 @@ #include <sys/dsl_scan.h> #include <sys/zio_checksum.h> #include <sys/refcount.h> +#include <sys/zfeature.h> #include <stdio.h> #include <stdio_ext.h> #include <stdlib.h> @@ -5575,10 +5576,9 @@ make_random_props() { nvlist_t *props; - if (ztest_random(2) == 0) - return (NULL); - VERIFY(nvlist_alloc(&props, NV_UNIQUE_NAME, 0) == 0); + if (ztest_random(2) == 0) + return (props); VERIFY(nvlist_add_uint64(props, "autoreplace", 1) == 0); return (props); @@ -5609,6 +5609,12 @@ ztest_init(ztest_shared_t *zs) nvroot = make_vdev_root(NULL, NULL, ztest_opts.zo_vdev_size, 0, 0, ztest_opts.zo_raidz, zs->zs_mirrors, 1); props = make_random_props(); + for (int i = 0; i < SPA_FEATURES; i++) { + char buf[1024]; + (void) snprintf(buf, sizeof (buf), "feature@%s", + spa_feature_table[i].fi_uname); + VERIFY3U(0, ==, nvlist_add_uint64(props, buf, 0)); + } VERIFY3U(0, ==, spa_create(ztest_opts.zo_pool, nvroot, props, NULL, NULL)); nvlist_free(nvroot); @@ -5616,6 +5622,7 @@ ztest_init(ztest_shared_t *zs) VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG)); zs->zs_metaslab_sz = 1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift; + spa_close(spa, FTAG); kernel_fini(); @@ -5654,9 +5661,24 @@ setup_fds(void) ASSERT3U(fd, ==, ZTEST_FD_RAND); } +static int +shared_data_size(ztest_shared_hdr_t *hdr) +{ + int size; + + size = hdr->zh_hdr_size; + size += hdr->zh_opts_size; + size += hdr->zh_size; + size += hdr->zh_stats_size * hdr->zh_stats_count; + size += hdr->zh_ds_size * hdr->zh_ds_count; + + return (size); +} + static void setup_hdr(void) { + int size; ztest_shared_hdr_t *hdr; #ifndef illumos @@ -5667,6 +5689,8 @@ setup_hdr(void) PROT_READ | PROT_WRITE, MAP_SHARED, ZTEST_FD_DATA, 0); ASSERT(hdr != MAP_FAILED); + VERIFY3U(0, ==, ftruncate(ZTEST_FD_DATA, 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_size = sizeof (ztest_shared_t); @@ -5675,6 +5699,9 @@ setup_hdr(void) hdr->zh_ds_size = sizeof (ztest_shared_ds_t); hdr->zh_ds_count = ztest_opts.zo_datasets; + size = shared_data_size(hdr); + VERIFY3U(0, ==, ftruncate(ZTEST_FD_DATA, size)); + (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize())); } @@ -5689,11 +5716,7 @@ setup_data(void) PROT_READ, MAP_SHARED, ZTEST_FD_DATA, 0); ASSERT(hdr != MAP_FAILED); - size = hdr->zh_hdr_size; - size += hdr->zh_opts_size; - size += hdr->zh_size; - size += hdr->zh_stats_size * hdr->zh_stats_count; - size += hdr->zh_ds_size * hdr->zh_ds_count; + size = shared_data_size(hdr); (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize())); hdr = ztest_shared_hdr = (void *)mmap(0, P2ROUNDUP(size, getpagesize()), |