Print this page
2619 asynchronous destruction of ZFS file systems
2747 SPA versioning with zfs feature flags
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <gwilson@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Dan Kruchinin <dan.kruchinin@gmail.com>
Approved by: Dan McDonald <danmcd@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/ztest/ztest.c
          +++ new/usr/src/cmd/ztest/ztest.c
↓ open down ↓ 98 lines elided ↑ open up ↑
  99   99  #include <sys/zil_impl.h>
 100  100  #include <sys/vdev_impl.h>
 101  101  #include <sys/vdev_file.h>
 102  102  #include <sys/spa_impl.h>
 103  103  #include <sys/metaslab_impl.h>
 104  104  #include <sys/dsl_prop.h>
 105  105  #include <sys/dsl_dataset.h>
 106  106  #include <sys/dsl_scan.h>
 107  107  #include <sys/zio_checksum.h>
 108  108  #include <sys/refcount.h>
      109 +#include <sys/zfeature.h>
 109  110  #include <stdio.h>
 110  111  #include <stdio_ext.h>
 111  112  #include <stdlib.h>
 112  113  #include <unistd.h>
 113  114  #include <signal.h>
 114  115  #include <umem.h>
 115  116  #include <dlfcn.h>
 116  117  #include <ctype.h>
 117  118  #include <math.h>
 118  119  #include <sys/fs/zfs.h>
↓ open down ↓ 5446 lines elided ↑ open up ↑
5565 5566                  (void) sprintf(timebuf, "%llum%02llus", m, s);
5566 5567          else
5567 5568                  (void) sprintf(timebuf, "%llus", s);
5568 5569  }
5569 5570  
5570 5571  static nvlist_t *
5571 5572  make_random_props()
5572 5573  {
5573 5574          nvlist_t *props;
5574 5575  
5575      -        if (ztest_random(2) == 0)
5576      -                return (NULL);
5577      -
5578 5576          VERIFY(nvlist_alloc(&props, NV_UNIQUE_NAME, 0) == 0);
     5577 +        if (ztest_random(2) == 0)
     5578 +                return (props);
5579 5579          VERIFY(nvlist_add_uint64(props, "autoreplace", 1) == 0);
5580 5580  
5581 5581          return (props);
5582 5582  }
5583 5583  
5584 5584  /*
5585 5585   * Create a storage pool with the given name and initial vdev size.
5586 5586   * Then test spa_freeze() functionality.
5587 5587   */
5588 5588  static void
↓ open down ↓ 10 lines elided ↑ open up ↑
5599 5599          /*
5600 5600           * Create the storage pool.
5601 5601           */
5602 5602          (void) spa_destroy(ztest_opts.zo_pool);
5603 5603          ztest_shared->zs_vdev_next_leaf = 0;
5604 5604          zs->zs_splits = 0;
5605 5605          zs->zs_mirrors = ztest_opts.zo_mirrors;
5606 5606          nvroot = make_vdev_root(NULL, NULL, ztest_opts.zo_vdev_size, 0,
5607 5607              0, ztest_opts.zo_raidz, zs->zs_mirrors, 1);
5608 5608          props = make_random_props();
     5609 +        for (int i = 0; i < SPA_FEATURES; i++) {
     5610 +                char buf[1024];
     5611 +                (void) snprintf(buf, sizeof (buf), "feature@%s",
     5612 +                    spa_feature_table[i].fi_uname);
     5613 +                VERIFY3U(0, ==, nvlist_add_uint64(props, buf, 0));
     5614 +        }
5609 5615          VERIFY3U(0, ==, spa_create(ztest_opts.zo_pool, nvroot, props,
5610 5616              NULL, NULL));
5611 5617          nvlist_free(nvroot);
5612 5618  
5613 5619          VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG));
5614 5620          zs->zs_metaslab_sz =
5615 5621              1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift;
     5622 +
5616 5623          spa_close(spa, FTAG);
5617 5624  
5618 5625          kernel_fini();
5619 5626  
5620 5627          ztest_run_zdb(ztest_opts.zo_pool);
5621 5628  
5622 5629          ztest_freeze();
5623 5630  
5624 5631          ztest_run_zdb(ztest_opts.zo_pool);
5625 5632  
↓ open down ↓ 9 lines elided ↑ open up ↑
5635 5642          char *tmp = tempnam(NULL, NULL);
5636 5643          fd = open(tmp, O_RDWR | O_CREAT, 0700);
5637 5644          ASSERT3U(fd, ==, ZTEST_FD_DATA);
5638 5645          (void) unlink(tmp);
5639 5646          free(tmp);
5640 5647  
5641 5648          fd = open("/dev/urandom", O_RDONLY);
5642 5649          ASSERT3U(fd, ==, ZTEST_FD_RAND);
5643 5650  }
5644 5651  
     5652 +static int
     5653 +shared_data_size(ztest_shared_hdr_t *hdr)
     5654 +{
     5655 +        int size;
     5656 +
     5657 +        size = hdr->zh_hdr_size;
     5658 +        size += hdr->zh_opts_size;
     5659 +        size += hdr->zh_size;
     5660 +        size += hdr->zh_stats_size * hdr->zh_stats_count;
     5661 +        size += hdr->zh_ds_size * hdr->zh_ds_count;
     5662 +
     5663 +        return (size);
     5664 +}
     5665 +
5645 5666  static void
5646 5667  setup_hdr(void)
5647 5668  {
     5669 +        int size;
5648 5670          ztest_shared_hdr_t *hdr;
5649 5671  
5650 5672          hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()),
5651 5673              PROT_READ | PROT_WRITE, MAP_SHARED, ZTEST_FD_DATA, 0);
5652 5674          ASSERT(hdr != MAP_FAILED);
5653 5675  
     5676 +        VERIFY3U(0, ==, ftruncate(ZTEST_FD_DATA, sizeof (ztest_shared_hdr_t)));
     5677 +
5654 5678          hdr->zh_hdr_size = sizeof (ztest_shared_hdr_t);
5655 5679          hdr->zh_opts_size = sizeof (ztest_shared_opts_t);
5656 5680          hdr->zh_size = sizeof (ztest_shared_t);
5657 5681          hdr->zh_stats_size = sizeof (ztest_shared_callstate_t);
5658 5682          hdr->zh_stats_count = ZTEST_FUNCS;
5659 5683          hdr->zh_ds_size = sizeof (ztest_shared_ds_t);
5660 5684          hdr->zh_ds_count = ztest_opts.zo_datasets;
5661 5685  
     5686 +        size = shared_data_size(hdr);
     5687 +        VERIFY3U(0, ==, ftruncate(ZTEST_FD_DATA, size));
     5688 +
5662 5689          (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
5663 5690  }
5664 5691  
5665 5692  static void
5666 5693  setup_data(void)
5667 5694  {
5668 5695          int size, offset;
5669 5696          ztest_shared_hdr_t *hdr;
5670 5697          uint8_t *buf;
5671 5698  
5672 5699          hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()),
5673 5700              PROT_READ, MAP_SHARED, ZTEST_FD_DATA, 0);
5674 5701          ASSERT(hdr != MAP_FAILED);
5675 5702  
5676      -        size = hdr->zh_hdr_size;
5677      -        size += hdr->zh_opts_size;
5678      -        size += hdr->zh_size;
5679      -        size += hdr->zh_stats_size * hdr->zh_stats_count;
5680      -        size += hdr->zh_ds_size * hdr->zh_ds_count;
     5703 +        size = shared_data_size(hdr);
5681 5704  
5682 5705          (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
5683 5706          hdr = ztest_shared_hdr = (void *)mmap(0, P2ROUNDUP(size, getpagesize()),
5684 5707              PROT_READ | PROT_WRITE, MAP_SHARED, ZTEST_FD_DATA, 0);
5685 5708          ASSERT(hdr != MAP_FAILED);
5686 5709          buf = (uint8_t *)hdr;
5687 5710  
5688 5711          offset = hdr->zh_hdr_size;
5689 5712          ztest_shared_opts = (void *)&buf[offset];
5690 5713          offset += hdr->zh_opts_size;
↓ open down ↓ 297 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX