Deleted Added
full compact
ztest.c (236143) ztest.c (236884)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 93 unchanged lines hidden (view full) ---

102#include <sys/vdev_file.h>
103#include <sys/spa_impl.h>
104#include <sys/metaslab_impl.h>
105#include <sys/dsl_prop.h>
106#include <sys/dsl_dataset.h>
107#include <sys/dsl_scan.h>
108#include <sys/zio_checksum.h>
109#include <sys/refcount.h>
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 93 unchanged lines hidden (view full) ---

102#include <sys/vdev_file.h>
103#include <sys/spa_impl.h>
104#include <sys/metaslab_impl.h>
105#include <sys/dsl_prop.h>
106#include <sys/dsl_dataset.h>
107#include <sys/dsl_scan.h>
108#include <sys/zio_checksum.h>
109#include <sys/refcount.h>
110#include <sys/zfeature.h>
110#include <stdio.h>
111#include <stdio_ext.h>
112#include <stdlib.h>
113#include <unistd.h>
114#include <signal.h>
115#include <umem.h>
116#include <dlfcn.h>
117#include <ctype.h>

--- 5452 unchanged lines hidden (view full) ---

5570 (void) sprintf(timebuf, "%llus", s);
5571}
5572
5573static nvlist_t *
5574make_random_props()
5575{
5576 nvlist_t *props;
5577
111#include <stdio.h>
112#include <stdio_ext.h>
113#include <stdlib.h>
114#include <unistd.h>
115#include <signal.h>
116#include <umem.h>
117#include <dlfcn.h>
118#include <ctype.h>

--- 5452 unchanged lines hidden (view full) ---

5571 (void) sprintf(timebuf, "%llus", s);
5572}
5573
5574static nvlist_t *
5575make_random_props()
5576{
5577 nvlist_t *props;
5578
5578 if (ztest_random(2) == 0)
5579 return (NULL);
5580
5581 VERIFY(nvlist_alloc(&props, NV_UNIQUE_NAME, 0) == 0);
5579 VERIFY(nvlist_alloc(&props, NV_UNIQUE_NAME, 0) == 0);
5580 if (ztest_random(2) == 0)
5581 return (props);
5582 VERIFY(nvlist_add_uint64(props, "autoreplace", 1) == 0);
5583
5584 return (props);
5585}
5586
5587/*
5588 * Create a storage pool with the given name and initial vdev size.
5589 * Then test spa_freeze() functionality.

--- 14 unchanged lines hidden (view full) ---

5604 */
5605 (void) spa_destroy(ztest_opts.zo_pool);
5606 ztest_shared->zs_vdev_next_leaf = 0;
5607 zs->zs_splits = 0;
5608 zs->zs_mirrors = ztest_opts.zo_mirrors;
5609 nvroot = make_vdev_root(NULL, NULL, ztest_opts.zo_vdev_size, 0,
5610 0, ztest_opts.zo_raidz, zs->zs_mirrors, 1);
5611 props = make_random_props();
5582 VERIFY(nvlist_add_uint64(props, "autoreplace", 1) == 0);
5583
5584 return (props);
5585}
5586
5587/*
5588 * Create a storage pool with the given name and initial vdev size.
5589 * Then test spa_freeze() functionality.

--- 14 unchanged lines hidden (view full) ---

5604 */
5605 (void) spa_destroy(ztest_opts.zo_pool);
5606 ztest_shared->zs_vdev_next_leaf = 0;
5607 zs->zs_splits = 0;
5608 zs->zs_mirrors = ztest_opts.zo_mirrors;
5609 nvroot = make_vdev_root(NULL, NULL, ztest_opts.zo_vdev_size, 0,
5610 0, ztest_opts.zo_raidz, zs->zs_mirrors, 1);
5611 props = make_random_props();
5612 for (int i = 0; i < SPA_FEATURES; i++) {
5613 char buf[1024];
5614 (void) snprintf(buf, sizeof (buf), "feature@%s",
5615 spa_feature_table[i].fi_uname);
5616 VERIFY3U(0, ==, nvlist_add_uint64(props, buf, 0));
5617 }
5612 VERIFY3U(0, ==, spa_create(ztest_opts.zo_pool, nvroot, props,
5613 NULL, NULL));
5614 nvlist_free(nvroot);
5615
5616 VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG));
5617 zs->zs_metaslab_sz =
5618 1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift;
5618 VERIFY3U(0, ==, spa_create(ztest_opts.zo_pool, nvroot, props,
5619 NULL, NULL));
5620 nvlist_free(nvroot);
5621
5622 VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG));
5623 zs->zs_metaslab_sz =
5624 1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift;
5625
5619 spa_close(spa, FTAG);
5620
5621 kernel_fini();
5622
5623 ztest_run_zdb(ztest_opts.zo_pool);
5624
5625 ztest_freeze();
5626

--- 22 unchanged lines hidden (view full) ---

5649 fd = mkstemp(tmp);
5650 ASSERT3U(fd, ==, ZTEST_FD_DATA);
5651#endif
5652
5653 fd = open("/dev/urandom", O_RDONLY);
5654 ASSERT3U(fd, ==, ZTEST_FD_RAND);
5655}
5656
5626 spa_close(spa, FTAG);
5627
5628 kernel_fini();
5629
5630 ztest_run_zdb(ztest_opts.zo_pool);
5631
5632 ztest_freeze();
5633

--- 22 unchanged lines hidden (view full) ---

5656 fd = mkstemp(tmp);
5657 ASSERT3U(fd, ==, ZTEST_FD_DATA);
5658#endif
5659
5660 fd = open("/dev/urandom", O_RDONLY);
5661 ASSERT3U(fd, ==, ZTEST_FD_RAND);
5662}
5663
5664static int
5665shared_data_size(ztest_shared_hdr_t *hdr)
5666{
5667 int size;
5668
5669 size = hdr->zh_hdr_size;
5670 size += hdr->zh_opts_size;
5671 size += hdr->zh_size;
5672 size += hdr->zh_stats_size * hdr->zh_stats_count;
5673 size += hdr->zh_ds_size * hdr->zh_ds_count;
5674
5675 return (size);
5676}
5677
5657static void
5658setup_hdr(void)
5659{
5678static void
5679setup_hdr(void)
5680{
5681 int size;
5660 ztest_shared_hdr_t *hdr;
5661
5662#ifndef illumos
5663 pwrite(ZTEST_FD_DATA, "", 1, 0);
5664#endif
5665
5666 hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()),
5667 PROT_READ | PROT_WRITE, MAP_SHARED, ZTEST_FD_DATA, 0);
5668 ASSERT(hdr != MAP_FAILED);
5669
5682 ztest_shared_hdr_t *hdr;
5683
5684#ifndef illumos
5685 pwrite(ZTEST_FD_DATA, "", 1, 0);
5686#endif
5687
5688 hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()),
5689 PROT_READ | PROT_WRITE, MAP_SHARED, ZTEST_FD_DATA, 0);
5690 ASSERT(hdr != MAP_FAILED);
5691
5692 VERIFY3U(0, ==, ftruncate(ZTEST_FD_DATA, sizeof (ztest_shared_hdr_t)));
5693
5670 hdr->zh_hdr_size = sizeof (ztest_shared_hdr_t);
5671 hdr->zh_opts_size = sizeof (ztest_shared_opts_t);
5672 hdr->zh_size = sizeof (ztest_shared_t);
5673 hdr->zh_stats_size = sizeof (ztest_shared_callstate_t);
5674 hdr->zh_stats_count = ZTEST_FUNCS;
5675 hdr->zh_ds_size = sizeof (ztest_shared_ds_t);
5676 hdr->zh_ds_count = ztest_opts.zo_datasets;
5677
5694 hdr->zh_hdr_size = sizeof (ztest_shared_hdr_t);
5695 hdr->zh_opts_size = sizeof (ztest_shared_opts_t);
5696 hdr->zh_size = sizeof (ztest_shared_t);
5697 hdr->zh_stats_size = sizeof (ztest_shared_callstate_t);
5698 hdr->zh_stats_count = ZTEST_FUNCS;
5699 hdr->zh_ds_size = sizeof (ztest_shared_ds_t);
5700 hdr->zh_ds_count = ztest_opts.zo_datasets;
5701
5702 size = shared_data_size(hdr);
5703 VERIFY3U(0, ==, ftruncate(ZTEST_FD_DATA, size));
5704
5678 (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
5679}
5680
5681static void
5682setup_data(void)
5683{
5684 int size, offset;
5685 ztest_shared_hdr_t *hdr;
5686 uint8_t *buf;
5687
5688 hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()),
5689 PROT_READ, MAP_SHARED, ZTEST_FD_DATA, 0);
5690 ASSERT(hdr != MAP_FAILED);
5691
5705 (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
5706}
5707
5708static void
5709setup_data(void)
5710{
5711 int size, offset;
5712 ztest_shared_hdr_t *hdr;
5713 uint8_t *buf;
5714
5715 hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()),
5716 PROT_READ, MAP_SHARED, ZTEST_FD_DATA, 0);
5717 ASSERT(hdr != MAP_FAILED);
5718
5692 size = hdr->zh_hdr_size;
5693 size += hdr->zh_opts_size;
5694 size += hdr->zh_size;
5695 size += hdr->zh_stats_size * hdr->zh_stats_count;
5696 size += hdr->zh_ds_size * hdr->zh_ds_count;
5719 size = shared_data_size(hdr);
5697
5698 (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
5699 hdr = ztest_shared_hdr = (void *)mmap(0, P2ROUNDUP(size, getpagesize()),
5700 PROT_READ | PROT_WRITE, MAP_SHARED, ZTEST_FD_DATA, 0);
5701 ASSERT(hdr != MAP_FAILED);
5702 buf = (uint8_t *)hdr;
5703
5704 offset = hdr->zh_hdr_size;

--- 303 unchanged lines hidden ---
5720
5721 (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
5722 hdr = ztest_shared_hdr = (void *)mmap(0, P2ROUNDUP(size, getpagesize()),
5723 PROT_READ | PROT_WRITE, MAP_SHARED, ZTEST_FD_DATA, 0);
5724 ASSERT(hdr != MAP_FAILED);
5725 buf = (uint8_t *)hdr;
5726
5727 offset = hdr->zh_hdr_size;

--- 303 unchanged lines hidden ---