Print this page
NEX-19083 backport OS-7314 zil_commit should omit cache thrash
9962 zil_commit should omit cache thrash
Reviewed by: Matt Ahrens <matt@delphix.com>
Reviewed by: Brad Lewis <brad.lewis@delphix.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Approved by: Joshua M. Clulow <josh@sysmgr.org>
NEX-18069 Unable to get/set VDEV_PROP_RESILVER_MAXACTIVE/VDEV_PROP_RESILVER_MINACTIVE props
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-9752 backport illumos 6950 ARC should cache compressed data
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
6950 ARC should cache compressed data
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Don Brady <don.brady@intel.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
NEX-5802 ztest: assertion failed for thread 0xe092a240, thread-id 1173: error == 0 (0x16 == 0x0), file ../ztest.c, line 4816
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-5318 Cleanup specialclass property (obsolete, not used) and fix related meta-to-special case
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
NEX-4582 update wrc test cases for allow to use write back cache per tree of datasets
Reviewed by: Steve Peng <steve.peng@nexenta.com>
Reviewed by: Alex Aizman <alex.aizman@nexenta.com>
5960 zfs recv should prefetch indirect blocks
5925 zfs receive -o origin=
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
5818 zfs {ref}compressratio is incorrect with 4k sector size
Reviewed by: Alex Reece <alex@delphix.com>
Reviewed by: George Wilson <george@delphix.com>
Reviewed by: Richard Elling <richard.elling@richardelling.com>
Reviewed by: Steven Hartland <killing@multiplay.co.uk>
Reviewed by: Don Brady <dev.fs.zfs@gmail.com>
Approved by: Albert Lee <trisk@omniti.com>
NEX-3079 port illumos ARC improvements
OS-115 Heap leaks related to OS-114 and SUP-577
OS-114 Heap leak when exporting/destroying pools with CoS
OS-103 handle CoS descriptor persistent references across vdev operations
OS-102 add man page info and tests for vdev/CoS properties and ZFS meta features
OS-80 support for vdev and CoS properties for the new I/O scheduler
OS-95 lint warning introduced by OS-61
Remaining fixes for the illumos merge
Make special vdev subtree topology the same as regular vdev subtree to simplify testcase setup
Fixup merge issues
Issue #38: various ztest failures
Fixup merge results
re 13748 added zpool export -c option
zpool export -c command exports specified pool while keeping its latest
configuration in the cache file for subsequent zpool import -c.
re #13232 rb4433 ztest assertion failed: oldvd->vdev_ops == &vdev_raidz_ops
re #8279 rb3915 need a mechanism to notify NMS about ZFS config changes (fix lint -courtesy of Yuri Pankov)
re #12584 rb4049 zfsxx latest code merge (fix lint - courtesy of Yuri Pankov)
re #12585 rb4049 ZFS++ work port - refactoring to improve separation of open/closed code, bug fixes, performance improvements - open code

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/ztest/ztest.c
          +++ new/usr/src/cmd/ztest/ztest.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
  24      - * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
       24 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  25   25   * Copyright (c) 2013 Steven Hartland. All rights reserved.
  26   26   * Copyright (c) 2014 Integros [integros.com]
  27   27   * Copyright 2017 Joyent, Inc.
  28   28   * Copyright 2017 RackTop Systems.
  29   29   */
  30   30  
  31   31  /*
  32   32   * The objective of this program is to provide a DMU/ZAP/SPA stress test
  33   33   * that runs entirely in userland, is easy to use, and easy to extend.
  34   34   *
↓ open down ↓ 71 lines elided ↑ open up ↑
 106  106  #include <sys/spa_impl.h>
 107  107  #include <sys/metaslab_impl.h>
 108  108  #include <sys/dsl_prop.h>
 109  109  #include <sys/dsl_dataset.h>
 110  110  #include <sys/dsl_destroy.h>
 111  111  #include <sys/dsl_scan.h>
 112  112  #include <sys/zio_checksum.h>
 113  113  #include <sys/refcount.h>
 114  114  #include <sys/zfeature.h>
 115  115  #include <sys/dsl_userhold.h>
      116 +#include <libzfs.h>
 116  117  #include <sys/abd.h>
 117  118  #include <stdio.h>
 118  119  #include <stdio_ext.h>
 119  120  #include <stdlib.h>
 120  121  #include <unistd.h>
 121  122  #include <signal.h>
 122  123  #include <umem.h>
 123  124  #include <dlfcn.h>
 124  125  #include <ctype.h>
 125  126  #include <math.h>
 126  127  #include <sys/fs/zfs.h>
 127  128  #include <libnvpair.h>
 128  129  #include <libcmdutils.h>
 129  130  
      131 +#include <sys/special.h>
      132 +
 130  133  static int ztest_fd_data = -1;
 131  134  static int ztest_fd_rand = -1;
 132  135  
 133  136  typedef struct ztest_shared_hdr {
 134  137          uint64_t        zh_hdr_size;
 135  138          uint64_t        zh_opts_size;
 136  139          uint64_t        zh_size;
 137  140          uint64_t        zh_stats_size;
 138  141          uint64_t        zh_stats_count;
 139  142          uint64_t        zh_ds_size;
↓ open down ↓ 181 lines elided ↑ open up ↑
 321  324  ztest_func_t ztest_zap_parallel;
 322  325  ztest_func_t ztest_zil_commit;
 323  326  ztest_func_t ztest_zil_remount;
 324  327  ztest_func_t ztest_dmu_read_write_zcopy;
 325  328  ztest_func_t ztest_dmu_objset_create_destroy;
 326  329  ztest_func_t ztest_dmu_prealloc;
 327  330  ztest_func_t ztest_fzap;
 328  331  ztest_func_t ztest_dmu_snapshot_create_destroy;
 329  332  ztest_func_t ztest_dsl_prop_get_set;
 330  333  ztest_func_t ztest_spa_prop_get_set;
      334 +ztest_func_t ztest_vdev_prop_get_set;
      335 +ztest_func_t ztest_cos_prop_get_set;
 331  336  ztest_func_t ztest_spa_create_destroy;
 332  337  ztest_func_t ztest_fault_inject;
 333  338  ztest_func_t ztest_ddt_repair;
 334  339  ztest_func_t ztest_dmu_snapshot_hold;
 335  340  ztest_func_t ztest_spa_rename;
 336  341  ztest_func_t ztest_scrub;
 337  342  ztest_func_t ztest_dsl_dataset_promote_busy;
 338  343  ztest_func_t ztest_vdev_attach_detach;
 339  344  ztest_func_t ztest_vdev_LUN_growth;
 340  345  ztest_func_t ztest_vdev_add_remove;
 341  346  ztest_func_t ztest_vdev_aux_add_remove;
 342  347  ztest_func_t ztest_split_pool;
 343  348  ztest_func_t ztest_reguid;
 344  349  ztest_func_t ztest_spa_upgrade;
 345      -ztest_func_t ztest_device_removal;
 346      -ztest_func_t ztest_remap_blocks;
 347  350  
 348  351  uint64_t zopt_always = 0ULL * NANOSEC;          /* all the time */
 349  352  uint64_t zopt_incessant = 1ULL * NANOSEC / 10;  /* every 1/10 second */
 350  353  uint64_t zopt_often = 1ULL * NANOSEC;           /* every second */
 351  354  uint64_t zopt_sometimes = 10ULL * NANOSEC;      /* every 10 seconds */
 352  355  uint64_t zopt_rarely = 60ULL * NANOSEC;         /* every 60 seconds */
 353  356  
 354  357  ztest_info_t ztest_info[] = {
 355  358          { ztest_dmu_read_write,                 1,      &zopt_always    },
 356  359          { ztest_dmu_write_parallel,             10,     &zopt_always    },
↓ open down ↓ 1 lines elided ↑ open up ↑
 358  361          { ztest_dmu_commit_callbacks,           1,      &zopt_always    },
 359  362          { ztest_zap,                            30,     &zopt_always    },
 360  363          { ztest_zap_parallel,                   100,    &zopt_always    },
 361  364          { ztest_split_pool,                     1,      &zopt_always    },
 362  365          { ztest_zil_commit,                     1,      &zopt_incessant },
 363  366          { ztest_zil_remount,                    1,      &zopt_sometimes },
 364  367          { ztest_dmu_read_write_zcopy,           1,      &zopt_often     },
 365  368          { ztest_dmu_objset_create_destroy,      1,      &zopt_often     },
 366  369          { ztest_dsl_prop_get_set,               1,      &zopt_often     },
 367  370          { ztest_spa_prop_get_set,               1,      &zopt_sometimes },
      371 +        { ztest_vdev_prop_get_set,              1,      &zopt_often     },
      372 +        { ztest_cos_prop_get_set,               1,      &zopt_often     },
 368  373  #if 0
 369  374          { ztest_dmu_prealloc,                   1,      &zopt_sometimes },
 370  375  #endif
 371  376          { ztest_fzap,                           1,      &zopt_sometimes },
 372  377          { ztest_dmu_snapshot_create_destroy,    1,      &zopt_sometimes },
 373  378          { ztest_spa_create_destroy,             1,      &zopt_sometimes },
 374  379          { ztest_fault_inject,                   1,      &zopt_sometimes },
 375  380          { ztest_ddt_repair,                     1,      &zopt_sometimes },
 376  381          { ztest_dmu_snapshot_hold,              1,      &zopt_sometimes },
 377  382          { ztest_reguid,                         1,      &zopt_rarely    },
 378  383          { ztest_spa_rename,                     1,      &zopt_rarely    },
 379  384          { ztest_scrub,                          1,      &zopt_rarely    },
 380  385          { ztest_spa_upgrade,                    1,      &zopt_rarely    },
 381  386          { ztest_dsl_dataset_promote_busy,       1,      &zopt_rarely    },
 382  387          { ztest_vdev_attach_detach,             1,      &zopt_sometimes },
 383  388          { ztest_vdev_LUN_growth,                1,      &zopt_rarely    },
 384  389          { ztest_vdev_add_remove,                1,
 385  390              &ztest_opts.zo_vdevtime                             },
 386  391          { ztest_vdev_aux_add_remove,            1,
 387  392              &ztest_opts.zo_vdevtime                             },
 388      -        { ztest_device_removal,                 1,      &zopt_sometimes },
 389      -        { ztest_remap_blocks,                   1,      &zopt_sometimes }
 390  393  };
 391  394  
 392  395  #define ZTEST_FUNCS     (sizeof (ztest_info) / sizeof (ztest_info_t))
 393  396  
 394  397  /*
 395  398   * The following struct is used to hold a list of uncalled commit callbacks.
 396  399   * The callbacks are ordered by txg number.
 397  400   */
 398  401  typedef struct ztest_cb_list {
 399  402          kmutex_t zcl_callbacks_lock;
↓ open down ↓ 27 lines elided ↑ open up ↑
 427  430  static char ztest_dev_template[] = "%s/%s.%llua";
 428  431  static char ztest_aux_template[] = "%s/%s.%s.%llu";
 429  432  ztest_shared_t *ztest_shared;
 430  433  
 431  434  static spa_t *ztest_spa = NULL;
 432  435  static ztest_ds_t *ztest_ds;
 433  436  
 434  437  static kmutex_t ztest_vdev_lock;
 435  438  
 436  439  /*
      440 + * Make sure the "set/get/test" test does not interfere with other
      441 + * concurrent tests on the same vdev/cos property
      442 + */
      443 +static kmutex_t ztest_props_lock;
      444 +
      445 +/*
 437  446   * The ztest_name_lock protects the pool and dataset namespace used by
 438  447   * the individual tests. To modify the namespace, consumers must grab
 439  448   * this lock as writer. Grabbing the lock as reader will ensure that the
 440  449   * namespace does not change while the lock is held.
 441  450   */
 442  451  static krwlock_t ztest_name_lock;
 443  452  
 444  453  static boolean_t ztest_dump_core = B_TRUE;
 445  454  static boolean_t ztest_exiting;
 446  455  
↓ open down ↓ 335 lines elided ↑ open up ↑
 782  791  }
 783  792  
 784  793  static void
 785  794  ztest_kill(ztest_shared_t *zs)
 786  795  {
 787  796          zs->zs_alloc = metaslab_class_get_alloc(spa_normal_class(ztest_spa));
 788  797          zs->zs_space = metaslab_class_get_space(spa_normal_class(ztest_spa));
 789  798  
 790  799          /*
 791  800           * Before we kill off ztest, make sure that the config is updated.
 792      -         * See comment above spa_write_cachefile().
      801 +         * See comment above spa_config_sync().
 793  802           */
 794  803          mutex_enter(&spa_namespace_lock);
 795      -        spa_write_cachefile(ztest_spa, B_FALSE, B_FALSE);
      804 +        spa_config_sync(ztest_spa, B_FALSE, B_FALSE);
 796  805          mutex_exit(&spa_namespace_lock);
 797  806  
 798  807          zfs_dbgmsg_print(FTAG);
 799  808          (void) kill(getpid(), SIGKILL);
 800  809  }
 801  810  
 802  811  static uint64_t
 803  812  ztest_random(uint64_t range)
 804  813  {
 805  814          uint64_t r;
↓ open down ↓ 18 lines elided ↑ open up ↑
 824  833  
 825  834  static uint64_t
 826  835  ztest_get_ashift(void)
 827  836  {
 828  837          if (ztest_opts.zo_ashift == 0)
 829  838                  return (SPA_MINBLOCKSHIFT + ztest_random(5));
 830  839          return (ztest_opts.zo_ashift);
 831  840  }
 832  841  
 833  842  static nvlist_t *
 834      -make_vdev_file(char *path, char *aux, char *pool, size_t size, uint64_t ashift)
      843 +make_vdev_file(char *path, char *aux, char *pool, size_t size,
      844 +    uint64_t ashift, boolean_t is_special)
 835  845  {
 836  846          char pathbuf[MAXPATHLEN];
 837  847          uint64_t vdev;
 838  848          nvlist_t *file;
 839  849  
 840  850          if (ashift == 0)
 841  851                  ashift = ztest_get_ashift();
 842  852  
 843  853          if (path == NULL) {
 844  854                  path = pathbuf;
↓ open down ↓ 10 lines elided ↑ open up ↑
 855  865                              ztest_dev_template, ztest_opts.zo_dir,
 856  866                              pool == NULL ? ztest_opts.zo_pool : pool, vdev);
 857  867                  }
 858  868          }
 859  869  
 860  870          if (size != 0) {
 861  871                  int fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666);
 862  872                  if (fd == -1)
 863  873                          fatal(1, "can't open %s", path);
 864  874                  if (ftruncate(fd, size) != 0)
 865      -                        fatal(1, "can't ftruncate %s", path);
      875 +                        fatal(1, "can't ftruncate %s to %lld", path, size);
 866  876                  (void) close(fd);
 867  877          }
 868  878  
 869  879          VERIFY(nvlist_alloc(&file, NV_UNIQUE_NAME, 0) == 0);
 870  880          VERIFY(nvlist_add_string(file, ZPOOL_CONFIG_TYPE, VDEV_TYPE_FILE) == 0);
 871  881          VERIFY(nvlist_add_string(file, ZPOOL_CONFIG_PATH, path) == 0);
 872  882          VERIFY(nvlist_add_uint64(file, ZPOOL_CONFIG_ASHIFT, ashift) == 0);
 873      -
      883 +        VERIFY(nvlist_add_uint64(file, ZPOOL_CONFIG_IS_SPECIAL, is_special)
      884 +            == 0);
 874  885          return (file);
 875  886  }
 876  887  
 877  888  static nvlist_t *
 878  889  make_vdev_raidz(char *path, char *aux, char *pool, size_t size,
 879      -    uint64_t ashift, int r)
      890 +    uint64_t ashift, int r, boolean_t is_special)
 880  891  {
 881  892          nvlist_t *raidz, **child;
 882  893          int c;
 883  894  
 884  895          if (r < 2)
 885      -                return (make_vdev_file(path, aux, pool, size, ashift));
      896 +                return (make_vdev_file(path, aux, pool, size, ashift,
      897 +                    is_special));
 886  898          child = umem_alloc(r * sizeof (nvlist_t *), UMEM_NOFAIL);
 887  899  
 888  900          for (c = 0; c < r; c++)
 889      -                child[c] = make_vdev_file(path, aux, pool, size, ashift);
      901 +                child[c] = make_vdev_file(path, aux, pool, size, ashift,
      902 +                    B_FALSE);
 890  903  
 891  904          VERIFY(nvlist_alloc(&raidz, NV_UNIQUE_NAME, 0) == 0);
 892  905          VERIFY(nvlist_add_string(raidz, ZPOOL_CONFIG_TYPE,
 893  906              VDEV_TYPE_RAIDZ) == 0);
 894  907          VERIFY(nvlist_add_uint64(raidz, ZPOOL_CONFIG_NPARITY,
 895  908              ztest_opts.zo_raidz_parity) == 0);
 896  909          VERIFY(nvlist_add_nvlist_array(raidz, ZPOOL_CONFIG_CHILDREN,
 897  910              child, r) == 0);
 898  911  
 899  912          for (c = 0; c < r; c++)
 900  913                  nvlist_free(child[c]);
 901  914  
 902  915          umem_free(child, r * sizeof (nvlist_t *));
 903  916  
 904  917          return (raidz);
 905  918  }
 906  919  
 907  920  static nvlist_t *
 908  921  make_vdev_mirror(char *path, char *aux, char *pool, size_t size,
 909      -    uint64_t ashift, int r, int m)
      922 +    uint64_t ashift, int r, int m, boolean_t is_special)
 910  923  {
 911  924          nvlist_t *mirror, **child;
 912  925          int c;
 913  926  
 914  927          if (m < 1)
 915      -                return (make_vdev_raidz(path, aux, pool, size, ashift, r));
      928 +                return (make_vdev_raidz(path, aux, pool, size, ashift, r,
      929 +                    is_special));
 916  930  
 917  931          child = umem_alloc(m * sizeof (nvlist_t *), UMEM_NOFAIL);
 918  932  
 919  933          for (c = 0; c < m; c++)
 920      -                child[c] = make_vdev_raidz(path, aux, pool, size, ashift, r);
      934 +                child[c] = make_vdev_raidz(path, aux, pool, size, ashift,
      935 +                    r, B_FALSE);
 921  936  
 922  937          VERIFY(nvlist_alloc(&mirror, NV_UNIQUE_NAME, 0) == 0);
 923  938          VERIFY(nvlist_add_string(mirror, ZPOOL_CONFIG_TYPE,
 924  939              VDEV_TYPE_MIRROR) == 0);
 925  940          VERIFY(nvlist_add_nvlist_array(mirror, ZPOOL_CONFIG_CHILDREN,
 926  941              child, m) == 0);
      942 +        VERIFY(nvlist_add_uint64(mirror, ZPOOL_CONFIG_IS_SPECIAL, is_special)
      943 +            == 0);
 927  944  
 928  945          for (c = 0; c < m; c++)
 929  946                  nvlist_free(child[c]);
 930  947  
 931  948          umem_free(child, m * sizeof (nvlist_t *));
 932  949  
 933  950          return (mirror);
 934  951  }
 935  952  
 936  953  static nvlist_t *
 937  954  make_vdev_root(char *path, char *aux, char *pool, size_t size, uint64_t ashift,
 938      -    int log, int r, int m, int t)
      955 +    int log, int r, int m, int t, boolean_t special)
 939  956  {
 940  957          nvlist_t *root, **child;
 941  958          int c;
 942  959  
 943  960          ASSERT(t > 0);
 944  961  
 945  962          child = umem_alloc(t * sizeof (nvlist_t *), UMEM_NOFAIL);
 946  963  
 947  964          for (c = 0; c < t; c++) {
 948  965                  child[c] = make_vdev_mirror(path, aux, pool, size, ashift,
 949      -                    r, m);
      966 +                    r, m, special);
 950  967                  VERIFY(nvlist_add_uint64(child[c], ZPOOL_CONFIG_IS_LOG,
 951  968                      log) == 0);
 952  969          }
 953  970  
 954  971          VERIFY(nvlist_alloc(&root, NV_UNIQUE_NAME, 0) == 0);
 955  972          VERIFY(nvlist_add_string(root, ZPOOL_CONFIG_TYPE, VDEV_TYPE_ROOT) == 0);
 956  973          VERIFY(nvlist_add_nvlist_array(root, aux ? aux : ZPOOL_CONFIG_CHILDREN,
 957  974              child, t) == 0);
 958  975  
 959  976          for (c = 0; c < t; c++)
 960  977                  nvlist_free(child[c]);
 961  978  
 962  979          umem_free(child, t * sizeof (nvlist_t *));
 963  980  
 964  981          return (root);
 965  982  }
 966  983  
 967  984  /*
      985 + * Add special top-level vdev(s) to the vdev tree
      986 + */
      987 +static void
      988 +add_special_vdevs(nvlist_t *root, size_t size, int r, int m, int t)
      989 +{
      990 +        nvlist_t **child = NULL, **prev_child = NULL, **new_child = NULL;
      991 +        int c = 0, new = 0;
      992 +        unsigned int prev = 0;
      993 +
      994 +        if ((m == 0) || (t == 0))
      995 +                return;
      996 +
      997 +        child = umem_alloc(t * sizeof (nvlist_t *), UMEM_NOFAIL);
      998 +
      999 +        /*
     1000 +         * special flag that is added to the top-level vdevs
     1001 +         */
     1002 +        for (c = 0; c < t; c++) {
     1003 +                child[c] = make_vdev_mirror(NULL, NULL, NULL, size, 0, r, m,
     1004 +                    B_TRUE);
     1005 +        }
     1006 +
     1007 +        /*
     1008 +         * Extend the children's array in the root"
     1009 +         *  - get previously added children
     1010 +         *  - allocate new array
     1011 +         *  - and copy the previous and new children there
     1012 +         *  - replace the children nvlist adday with the new one
     1013 +         */
     1014 +        VERIFY(nvlist_lookup_nvlist_array(root, ZPOOL_CONFIG_CHILDREN,
     1015 +            &prev_child, &prev) == 0);
     1016 +
     1017 +        new = prev + t;
     1018 +
     1019 +        new_child = umem_alloc(new * sizeof (nvlist_t *),
     1020 +            UMEM_NOFAIL);
     1021 +        for (c = 0; c < prev; c++) {
     1022 +                VERIFY(nvlist_dup(prev_child[c], &new_child[c], 0) == 0);
     1023 +        }
     1024 +        for (; c < new; c++) {
     1025 +                new_child[c] = child[c-prev];
     1026 +        }
     1027 +
     1028 +        VERIFY(nvlist_add_nvlist_array(root, ZPOOL_CONFIG_CHILDREN,
     1029 +            new_child, new) == 0);
     1030 +
     1031 +        /* free children */
     1032 +        for (c = 0; c < new; c++) {
     1033 +                nvlist_free(new_child[c]);
     1034 +        }
     1035 +        umem_free(child, t * sizeof (nvlist_t *));
     1036 +
     1037 +        umem_free(new_child, new * sizeof (nvlist_t *));
     1038 +}
     1039 +
     1040 +/*
 968 1041   * Find a random spa version. Returns back a random spa version in the
 969 1042   * range [initial_version, SPA_VERSION_FEATURES].
 970 1043   */
 971 1044  static uint64_t
 972 1045  ztest_random_spa_version(uint64_t initial_version)
 973 1046  {
 974 1047          uint64_t version = initial_version;
 975 1048  
 976 1049          if (version <= SPA_VERSION_BEFORE_FEATURES) {
 977 1050                  version = version +
↓ open down ↓ 34 lines elided ↑ open up ↑
1012 1085  {
1013 1086          uint64_t top;
1014 1087          vdev_t *rvd = spa->spa_root_vdev;
1015 1088          vdev_t *tvd;
1016 1089  
1017 1090          ASSERT(spa_config_held(spa, SCL_ALL, RW_READER) != 0);
1018 1091  
1019 1092          do {
1020 1093                  top = ztest_random(rvd->vdev_children);
1021 1094                  tvd = rvd->vdev_child[top];
1022      -        } while (!vdev_is_concrete(tvd) || (tvd->vdev_islog && !log_ok) ||
     1095 +        } while (tvd->vdev_ishole || (tvd->vdev_islog && !log_ok) ||
1023 1096              tvd->vdev_mg == NULL || tvd->vdev_mg->mg_class == NULL);
1024 1097  
1025 1098          return (top);
1026 1099  }
1027 1100  
1028 1101  static uint64_t
1029 1102  ztest_random_dsl_prop(zfs_prop_t prop)
1030 1103  {
1031 1104          uint64_t value;
1032 1105  
↓ open down ↓ 794 lines elided ↑ open up ↑
1827 1900          NULL,                   /* TX_MKDIR_ACL */
1828 1901          NULL,                   /* TX_MKDIR_ATTR */
1829 1902          NULL,                   /* TX_MKDIR_ACL_ATTR */
1830 1903          NULL,                   /* TX_WRITE2 */
1831 1904  };
1832 1905  
1833 1906  /*
1834 1907   * ZIL get_data callbacks
1835 1908   */
1836 1909  
     1910 +/* ARGSUSED */
1837 1911  static void
1838 1912  ztest_get_done(zgd_t *zgd, int error)
1839 1913  {
1840 1914          ztest_ds_t *zd = zgd->zgd_private;
1841 1915          uint64_t object = zgd->zgd_rl->rl_object;
1842 1916  
1843 1917          if (zgd->zgd_db)
1844 1918                  dmu_buf_rele(zgd->zgd_db, zgd);
1845 1919  
1846 1920          ztest_range_unlock(zgd->zgd_rl);
1847 1921          ztest_object_unlock(zd, object);
1848 1922  
1849      -        if (error == 0 && zgd->zgd_bp)
1850      -                zil_lwb_add_block(zgd->zgd_lwb, zgd->zgd_bp);
1851      -
1852 1923          umem_free(zgd, sizeof (*zgd));
1853 1924  }
1854 1925  
1855 1926  static int
1856 1927  ztest_get_data(void *arg, lr_write_t *lr, char *buf, struct lwb *lwb,
1857 1928      zio_t *zio)
1858 1929  {
1859 1930          ztest_ds_t *zd = arg;
1860 1931          objset_t *os = zd->zd_os;
1861 1932          uint64_t object = lr->lr_foid;
↓ open down ↓ 507 lines elided ↑ open up ↑
2369 2440  void
2370 2441  ztest_spa_create_destroy(ztest_ds_t *zd, uint64_t id)
2371 2442  {
2372 2443          ztest_shared_opts_t *zo = &ztest_opts;
2373 2444          spa_t *spa;
2374 2445          nvlist_t *nvroot;
2375 2446  
2376 2447          /*
2377 2448           * Attempt to create using a bad file.
2378 2449           */
2379      -        nvroot = make_vdev_root("/dev/bogus", NULL, NULL, 0, 0, 0, 0, 0, 1);
     2450 +        nvroot = make_vdev_root("/dev/bogus", NULL, NULL, 0, 0, 0, 0, 0, 1,
     2451 +            B_FALSE);
2380 2452          VERIFY3U(ENOENT, ==,
2381 2453              spa_create("ztest_bad_file", nvroot, NULL, NULL));
2382 2454          nvlist_free(nvroot);
2383 2455  
2384 2456          /*
2385 2457           * Attempt to create using a bad mirror.
2386 2458           */
2387      -        nvroot = make_vdev_root("/dev/bogus", NULL, NULL, 0, 0, 0, 0, 2, 1);
     2459 +        nvroot = make_vdev_root("/dev/bogus", NULL, NULL, 0, 0, 0, 0, 2, 1,
     2460 +            B_FALSE);
2388 2461          VERIFY3U(ENOENT, ==,
2389 2462              spa_create("ztest_bad_mirror", nvroot, NULL, NULL));
2390 2463          nvlist_free(nvroot);
2391 2464  
2392 2465          /*
2393 2466           * Attempt to create an existing pool.  It shouldn't matter
2394 2467           * what's in the nvroot; we should fail with EEXIST.
2395 2468           */
2396 2469          rw_enter(&ztest_name_lock, RW_READER);
2397      -        nvroot = make_vdev_root("/dev/bogus", NULL, NULL, 0, 0, 0, 0, 0, 1);
     2470 +        nvroot = make_vdev_root("/dev/bogus", NULL, NULL, 0, 0, 0, 0, 0, 1,
     2471 +            B_FALSE);
2398 2472          VERIFY3U(EEXIST, ==, spa_create(zo->zo_pool, nvroot, NULL, NULL));
2399 2473          nvlist_free(nvroot);
2400 2474          VERIFY3U(0, ==, spa_open(zo->zo_pool, &spa, FTAG));
2401 2475          VERIFY3U(EBUSY, ==, spa_destroy(zo->zo_pool));
2402 2476          spa_close(spa, FTAG);
2403 2477  
2404 2478          rw_exit(&ztest_name_lock);
2405 2479  }
2406 2480  
2407 2481  /* ARGSUSED */
↓ open down ↓ 8 lines elided ↑ open up ↑
2416 2490  
2417 2491          mutex_enter(&ztest_vdev_lock);
2418 2492          name = kmem_asprintf("%s_upgrade", ztest_opts.zo_pool);
2419 2493  
2420 2494          /*
2421 2495           * Clean up from previous runs.
2422 2496           */
2423 2497          (void) spa_destroy(name);
2424 2498  
2425 2499          nvroot = make_vdev_root(NULL, NULL, name, ztest_opts.zo_vdev_size, 0,
2426      -            0, ztest_opts.zo_raidz, ztest_opts.zo_mirrors, 1);
     2500 +            0, ztest_opts.zo_raidz, ztest_opts.zo_mirrors, 1, B_FALSE);
2427 2501  
2428 2502          /*
2429 2503           * If we're configuring a RAIDZ device then make sure that the
2430 2504           * the initial version is capable of supporting that feature.
2431 2505           */
2432 2506          switch (ztest_opts.zo_raidz_parity) {
2433 2507          case 0:
2434 2508          case 1:
2435 2509                  initial_version = SPA_VERSION_INITIAL;
2436 2510                  break;
↓ open down ↓ 123 lines elided ↑ open up ↑
2560 2634                          fatal(0, "spa_vdev_remove() = %d", error);
2561 2635          } else {
2562 2636                  spa_config_exit(spa, SCL_VDEV, FTAG);
2563 2637  
2564 2638                  /*
2565 2639                   * Make 1/4 of the devices be log devices.
2566 2640                   */
2567 2641                  nvroot = make_vdev_root(NULL, NULL, NULL,
2568 2642                      ztest_opts.zo_vdev_size, 0,
2569 2643                      ztest_random(4) == 0, ztest_opts.zo_raidz,
2570      -                    zs->zs_mirrors, 1);
     2644 +                    zs->zs_mirrors, 1, B_FALSE);
2571 2645  
2572 2646                  error = spa_vdev_add(spa, nvroot);
2573 2647                  nvlist_free(nvroot);
2574 2648  
2575 2649                  if (error == ENOSPC)
2576 2650                          ztest_record_enospc("spa_vdev_add");
2577 2651                  else if (error != 0)
2578 2652                          fatal(0, "spa_vdev_add() = %d", error);
2579 2653          }
2580 2654  
↓ open down ↓ 54 lines elided ↑ open up ↑
2635 2709                  }
2636 2710          }
2637 2711  
2638 2712          spa_config_exit(spa, SCL_VDEV, FTAG);
2639 2713  
2640 2714          if (guid == 0) {
2641 2715                  /*
2642 2716                   * Add a new device.
2643 2717                   */
2644 2718                  nvlist_t *nvroot = make_vdev_root(NULL, aux, NULL,
2645      -                    (ztest_opts.zo_vdev_size * 5) / 4, 0, 0, 0, 0, 1);
     2719 +                    (ztest_opts.zo_vdev_size * 5) / 4, 0, 0, 0, 0, 1, B_FALSE);
2646 2720                  error = spa_vdev_add(spa, nvroot);
2647 2721                  if (error != 0)
2648 2722                          fatal(0, "spa_vdev_add(%p) = %d", nvroot, error);
2649 2723                  nvlist_free(nvroot);
2650 2724          } else {
2651 2725                  /*
2652 2726                   * Remove an existing device.  Sometimes, dirty its
2653 2727                   * vdev state first to make sure we handle removal
2654 2728                   * of devices that have pending state changes.
2655 2729                   */
↓ open down ↓ 125 lines elided ↑ open up ↑
2781 2855          char oldpath[MAXPATHLEN], newpath[MAXPATHLEN];
2782 2856          int replacing;
2783 2857          int oldvd_has_siblings = B_FALSE;
2784 2858          int newvd_is_spare = B_FALSE;
2785 2859          int oldvd_is_log;
2786 2860          int error, expected_error;
2787 2861  
2788 2862          mutex_enter(&ztest_vdev_lock);
2789 2863          leaves = MAX(zs->zs_mirrors, 1) * ztest_opts.zo_raidz;
2790 2864  
2791      -        spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
     2865 +        spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER);
2792 2866  
2793 2867          /*
2794      -         * If a vdev is in the process of being removed, its removal may
2795      -         * finish while we are in progress, leading to an unexpected error
2796      -         * value.  Don't bother trying to attach while we are in the middle
2797      -         * of removal.
2798      -         */
2799      -        if (spa->spa_vdev_removal != NULL) {
2800      -                spa_config_exit(spa, SCL_ALL, FTAG);
2801      -                mutex_exit(&ztest_vdev_lock);
2802      -                return;
2803      -        }
2804      -
2805      -        /*
2806 2868           * Decide whether to do an attach or a replace.
2807 2869           */
2808 2870          replacing = ztest_random(2);
2809 2871  
2810 2872          /*
2811 2873           * Pick a random top-level vdev.
2812 2874           */
2813 2875          top = ztest_random_vdev_top(spa, B_TRUE);
2814 2876  
2815 2877          /*
↓ open down ↓ 30 lines elided ↑ open up ↑
2846 2908          oldsize = vdev_get_min_asize(oldvd);
2847 2909          oldvd_is_log = oldvd->vdev_top->vdev_islog;
2848 2910          (void) strcpy(oldpath, oldvd->vdev_path);
2849 2911          pvd = oldvd->vdev_parent;
2850 2912          pguid = pvd->vdev_guid;
2851 2913  
2852 2914          /*
2853 2915           * If oldvd has siblings, then half of the time, detach it.
2854 2916           */
2855 2917          if (oldvd_has_siblings && ztest_random(2) == 0) {
2856      -                spa_config_exit(spa, SCL_ALL, FTAG);
     2918 +                spa_config_exit(spa, SCL_VDEV, FTAG);
2857 2919                  error = spa_vdev_detach(spa, oldguid, pguid, B_FALSE);
2858 2920                  if (error != 0 && error != ENODEV && error != EBUSY &&
2859 2921                      error != ENOTSUP)
2860 2922                          fatal(0, "detach (%s) returned %d", oldpath, error);
2861 2923                  mutex_exit(&ztest_vdev_lock);
2862 2924                  return;
2863 2925          }
2864 2926  
2865 2927          /*
2866 2928           * For the new vdev, choose with equal probability between the two
↓ open down ↓ 6 lines elided ↑ open up ↑
2873 2935          } else {
2874 2936                  (void) snprintf(newpath, sizeof (newpath), ztest_dev_template,
2875 2937                      ztest_opts.zo_dir, ztest_opts.zo_pool,
2876 2938                      top * leaves + leaf);
2877 2939                  if (ztest_random(2) == 0)
2878 2940                          newpath[strlen(newpath) - 1] = 'b';
2879 2941                  newvd = vdev_lookup_by_path(rvd, newpath);
2880 2942          }
2881 2943  
2882 2944          if (newvd) {
2883      -                /*
2884      -                 * Reopen to ensure the vdev's asize field isn't stale.
2885      -                 */
2886      -                vdev_reopen(newvd);
2887 2945                  newsize = vdev_get_min_asize(newvd);
2888 2946          } else {
2889 2947                  /*
2890 2948                   * Make newsize a little bigger or smaller than oldsize.
2891 2949                   * If it's smaller, the attach should fail.
2892 2950                   * If it's larger, and we're doing a replace,
2893 2951                   * we should get dynamic LUN growth when we're done.
2894 2952                   */
2895 2953                  newsize = 10 * oldsize / (9 + ztest_random(3));
2896 2954          }
↓ open down ↓ 17 lines elided ↑ open up ↑
2914 2972                  expected_error = replacing ? 0 : EBUSY;
2915 2973          else if (vdev_lookup_by_path(rvd, newpath) != NULL)
2916 2974                  expected_error = EBUSY;
2917 2975          else if (newsize < oldsize)
2918 2976                  expected_error = EOVERFLOW;
2919 2977          else if (ashift > oldvd->vdev_top->vdev_ashift)
2920 2978                  expected_error = EDOM;
2921 2979          else
2922 2980                  expected_error = 0;
2923 2981  
2924      -        spa_config_exit(spa, SCL_ALL, FTAG);
     2982 +        spa_config_exit(spa, SCL_VDEV, FTAG);
2925 2983  
2926 2984          /*
2927 2985           * Build the nvlist describing newpath.
2928 2986           */
2929 2987          root = make_vdev_root(newpath, NULL, NULL, newvd == NULL ? newsize : 0,
2930      -            ashift, 0, 0, 0, 1);
     2988 +            ashift, 0, 0, 0, 1, replacing ? oldvd->vdev_isspecial : B_FALSE);
2931 2989  
2932 2990          error = spa_vdev_attach(spa, oldguid, root, replacing);
2933 2991  
2934 2992          nvlist_free(root);
2935 2993  
2936 2994          /*
2937 2995           * If our parent was the replacing vdev, but the replace completed,
2938 2996           * then instead of failing with ENOTSUP we may either succeed,
2939 2997           * fail with ENODEV, or fail with EOVERFLOW.
2940 2998           */
↓ open down ↓ 11 lines elided ↑ open up ↑
2952 3010          if (error != expected_error && expected_error != EBUSY) {
2953 3011                  fatal(0, "attach (%s %llu, %s %llu, %d) "
2954 3012                      "returned %d, expected %d",
2955 3013                      oldpath, oldsize, newpath,
2956 3014                      newsize, replacing, error, expected_error);
2957 3015          }
2958 3016  
2959 3017          mutex_exit(&ztest_vdev_lock);
2960 3018  }
2961 3019  
2962      -/* ARGSUSED */
2963      -void
2964      -ztest_device_removal(ztest_ds_t *zd, uint64_t id)
2965      -{
2966      -        spa_t *spa = ztest_spa;
2967      -        vdev_t *vd;
2968      -        uint64_t guid;
2969      -
2970      -        mutex_enter(&ztest_vdev_lock);
2971      -
2972      -        spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER);
2973      -        vd = vdev_lookup_top(spa, ztest_random_vdev_top(spa, B_FALSE));
2974      -        guid = vd->vdev_guid;
2975      -        spa_config_exit(spa, SCL_VDEV, FTAG);
2976      -
2977      -        (void) spa_vdev_remove(spa, guid, B_FALSE);
2978      -
2979      -        mutex_exit(&ztest_vdev_lock);
2980      -}
2981      -
2982 3020  /*
2983 3021   * Callback function which expands the physical size of the vdev.
2984 3022   */
2985 3023  vdev_t *
2986 3024  grow_vdev(vdev_t *vd, void *arg)
2987 3025  {
2988 3026          spa_t *spa = vd->vdev_spa;
2989 3027          size_t *newsize = arg;
2990 3028          size_t fsize;
2991 3029          int fd;
↓ open down ↓ 66 lines elided ↑ open up ↑
3058 3096                              (u_longlong_t)tvd->vdev_state,
3059 3097                              (u_longlong_t)generation,
3060 3098                              (u_longlong_t)spa->spa_config_generation);
3061 3099                  }
3062 3100                  return (vd);
3063 3101          }
3064 3102          return (NULL);
3065 3103  }
3066 3104  
3067 3105  /*
     3106 + * Callback function which checks that the given vdev is
     3107 + * - not a part of replacing group
     3108 + * - not being removed
     3109 + * - healthy
     3110 + */
     3111 +/* ARGSUSED */
     3112 +vdev_t *
     3113 +check_valid_vdev(vdev_t *vd, void *arg)
     3114 +{
     3115 +        spa_t *spa = vd->vdev_spa;
     3116 +
     3117 +        ASSERT(spa_config_held(spa, SCL_STATE, RW_READER) == SCL_STATE);
     3118 +        ASSERT(vd->vdev_ops->vdev_op_leaf);
     3119 +
     3120 +        if (vd->vdev_parent->vdev_ops == &vdev_replacing_ops ||
     3121 +            vd->vdev_removing || vd->vdev_state != VDEV_STATE_HEALTHY)
     3122 +                return (NULL);
     3123 +
     3124 +        return (vd);
     3125 +}
     3126 +
     3127 +/*
3068 3128   * Traverse the vdev tree calling the supplied function.
3069 3129   * We continue to walk the tree until we either have walked all
3070 3130   * children or we receive a non-NULL return from the callback.
3071 3131   * If a NULL callback is passed, then we just return back the first
3072 3132   * leaf vdev we encounter.
3073 3133   */
3074 3134  vdev_t *
3075 3135  vdev_walk_tree(vdev_t *vd, vdev_t *(*func)(vdev_t *, void *), void *arg)
3076 3136  {
3077 3137          if (vd->vdev_ops->vdev_op_leaf) {
↓ open down ↓ 22 lines elided ↑ open up ↑
3100 3160          vdev_t *vd, *tvd;
3101 3161          metaslab_class_t *mc;
3102 3162          metaslab_group_t *mg;
3103 3163          size_t psize, newsize;
3104 3164          uint64_t top;
3105 3165          uint64_t old_class_space, new_class_space, old_ms_count, new_ms_count;
3106 3166  
3107 3167          mutex_enter(&ztest_vdev_lock);
3108 3168          spa_config_enter(spa, SCL_STATE, spa, RW_READER);
3109 3169  
3110      -        /*
3111      -         * If there is a vdev removal in progress, it could complete while
3112      -         * we are running, in which case we would not be able to verify
3113      -         * that the metaslab_class space increased (because it decreases
3114      -         * when the device removal completes).
3115      -         */
3116      -        if (spa->spa_vdev_removal != NULL) {
3117      -                spa_config_exit(spa, SCL_STATE, FTAG);
3118      -                mutex_exit(&ztest_vdev_lock);
3119      -                return;
3120      -        }
3121      -
3122 3170          top = ztest_random_vdev_top(spa, B_TRUE);
3123 3171  
3124 3172          tvd = spa->spa_root_vdev->vdev_child[top];
3125 3173          mg = tvd->vdev_mg;
3126 3174          mc = mg->mg_class;
3127 3175          old_ms_count = tvd->vdev_ms_count;
3128 3176          old_class_space = metaslab_class_get_space(mc);
3129 3177  
3130 3178          /*
3131 3179           * Determine the size of the first leaf vdev associated with
↓ open down ↓ 71 lines elided ↑ open up ↑
3203 3251                              "intervening vdev offline or remove.\n");
3204 3252                  }
3205 3253                  spa_config_exit(spa, SCL_STATE, spa);
3206 3254                  mutex_exit(&ztest_vdev_lock);
3207 3255                  return;
3208 3256          }
3209 3257  
3210 3258          /*
3211 3259           * Make sure we were able to grow the vdev.
3212 3260           */
3213      -        if (new_ms_count <= old_ms_count) {
3214      -                fatal(0, "LUN expansion failed: ms_count %llu < %llu\n",
     3261 +        if (new_ms_count <= old_ms_count)
     3262 +                fatal(0, "LUN expansion failed: ms_count %llu <= %llu\n",
3215 3263                      old_ms_count, new_ms_count);
3216      -        }
3217 3264  
3218 3265          /*
3219 3266           * Make sure we were able to grow the pool.
3220 3267           */
3221      -        if (new_class_space <= old_class_space) {
3222      -                fatal(0, "LUN expansion failed: class_space %llu < %llu\n",
     3268 +        if (new_class_space <= old_class_space)
     3269 +                fatal(0, "LUN expansion failed: class_space %llu <= %llu\n",
3223 3270                      old_class_space, new_class_space);
3224      -        }
3225 3271  
3226 3272          if (ztest_opts.zo_verbose >= 5) {
3227 3273                  char oldnumbuf[NN_NUMBUF_SZ], newnumbuf[NN_NUMBUF_SZ];
3228 3274  
3229 3275                  nicenum(old_class_space, oldnumbuf, sizeof (oldnumbuf));
3230 3276                  nicenum(new_class_space, newnumbuf, sizeof (newnumbuf));
3231 3277                  (void) printf("%s grew from %s to %s\n",
3232 3278                      spa->spa_name, oldnumbuf, newnumbuf);
3233 3279          }
3234 3280  
↓ open down ↓ 1452 lines elided ↑ open up ↑
4687 4733  
4688 4734          for (int p = 0; p < sizeof (proplist) / sizeof (proplist[0]); p++)
4689 4735                  (void) ztest_dsl_prop_set_uint64(zd->zd_name, proplist[p],
4690 4736                      ztest_random_dsl_prop(proplist[p]), (int)ztest_random(2));
4691 4737  
4692 4738          rw_exit(&ztest_name_lock);
4693 4739  }
4694 4740  
4695 4741  /* ARGSUSED */
4696 4742  void
4697      -ztest_remap_blocks(ztest_ds_t *zd, uint64_t id)
4698      -{
4699      -        rw_enter(&ztest_name_lock, RW_READER);
4700      -
4701      -        int error = dmu_objset_remap_indirects(zd->zd_name);
4702      -        if (error == ENOSPC)
4703      -                error = 0;
4704      -        ASSERT0(error);
4705      -
4706      -        rw_exit(&ztest_name_lock);
4707      -}
4708      -
4709      -/* ARGSUSED */
4710      -void
4711 4743  ztest_spa_prop_get_set(ztest_ds_t *zd, uint64_t id)
4712 4744  {
4713 4745          nvlist_t *props = NULL;
4714 4746  
4715 4747          rw_enter(&ztest_name_lock, RW_READER);
4716 4748  
4717 4749          (void) ztest_spa_prop_set_uint64(ZPOOL_PROP_DEDUPDITTO,
4718 4750              ZIO_DEDUPDITTO_MIN + ztest_random(ZIO_DEDUPDITTO_MIN));
4719 4751  
4720 4752          VERIFY0(spa_prop_get(ztest_spa, &props));
4721 4753  
4722 4754          if (ztest_opts.zo_verbose >= 6)
4723 4755                  dump_nvlist(props, 4);
4724 4756  
4725 4757          nvlist_free(props);
4726 4758  
4727 4759          rw_exit(&ztest_name_lock);
4728 4760  }
4729 4761  
     4762 +/* vdev and cos property tests */
     4763 +typedef enum {
     4764 +        VDEV_PROP_UINT64,
     4765 +        VDEV_PROP_STRING,
     4766 +        COS_PROP_UINT64
     4767 +} ztest_prop_t;
     4768 +
     4769 +/* common functions */
     4770 +static vdev_t *
     4771 +ztest_get_random_vdev_leaf(spa_t *spa)
     4772 +{
     4773 +        vdev_t *lvd = NULL, *tvd = NULL;
     4774 +        uint64_t top = 0;
     4775 +
     4776 +        spa_config_enter(spa, SCL_ALL, FTAG, RW_READER);
     4777 +
     4778 +        for (;;) {
     4779 +                /* Pick a leaf of a random top-level vdev */
     4780 +                top = ztest_random_vdev_top(spa, B_TRUE);
     4781 +                tvd = spa->spa_root_vdev->vdev_child[top];
     4782 +                lvd = vdev_walk_tree(tvd, check_valid_vdev, NULL);
     4783 +                if (lvd == NULL) {
     4784 +                        /*
     4785 +                         * We cannot  return NULL and no reasons to crash.
     4786 +                         * Just let other threads to finish their work and
     4787 +                         * maybe next time we will have leaf-vdev
     4788 +                         */
     4789 +                        spa_config_exit(spa, SCL_ALL, FTAG);
     4790 +                        (void) poll(NULL, 0, 100);
     4791 +                        spa_config_enter(spa, SCL_ALL, FTAG, RW_READER);
     4792 +                        continue;
     4793 +                }
     4794 +
     4795 +                ASSERT(lvd->vdev_ops->vdev_op_leaf);
     4796 +                break;
     4797 +        }
     4798 +
     4799 +        spa_config_exit(spa, SCL_ALL, FTAG);
     4800 +
     4801 +        return (lvd);
     4802 +}
     4803 +
     4804 +#define ZTEST_COS_NAME          "ztest_cos"
     4805 +
     4806 +/*ARGSUSED*/
     4807 +static nvlist_t *
     4808 +ztest_props_set(const vdev_t *lvd, const char *name, const ztest_prop_t t,
     4809 +    const void *props, const size_t size)
     4810 +{
     4811 +        spa_t *spa = ztest_spa;
     4812 +        nvlist_t *sprops;
     4813 +        int error = 0;
     4814 +
     4815 +        VERIFY(0 == nvlist_alloc(&sprops, NV_UNIQUE_NAME, 0));
     4816 +
     4817 +        for (int p = 0; p < size; p++) {
     4818 +                uint64_t ival;
     4819 +                char sval[16];
     4820 +                const char *pname =
     4821 +                    (t == VDEV_PROP_UINT64 || t == VDEV_PROP_STRING) ?
     4822 +                    vdev_prop_to_name(((vdev_prop_t *)props)[p]) :
     4823 +                    cos_prop_to_name(((cos_prop_t *)props)[p]);
     4824 +
     4825 +                switch (t) {
     4826 +                case VDEV_PROP_UINT64:
     4827 +                case COS_PROP_UINT64:
     4828 +                        /* range 0...10 is valid for all properties */
     4829 +                        ival = ztest_random(10) + 1;
     4830 +                        VERIFY(0 == nvlist_add_uint64(sprops, pname, ival));
     4831 +                        break;
     4832 +                case VDEV_PROP_STRING:
     4833 +                        /* use a well known name for cos property */
     4834 +                        if (((vdev_prop_t *)props)[p] == VDEV_PROP_COS) {
     4835 +                                (void) snprintf(sval, 15, "%s", ZTEST_COS_NAME);
     4836 +                        } else {
     4837 +                                /* any short string will do */
     4838 +                                (void) snprintf(sval, 15, "prop_value%d", p);
     4839 +                        }
     4840 +                        VERIFY(0 == nvlist_add_string(sprops, pname, sval));
     4841 +                        break;
     4842 +                default:
     4843 +                        /* unknown property */
     4844 +                        error = EINVAL;
     4845 +                        break;
     4846 +                }
     4847 +        }
     4848 +        VERIFY3U(0, ==, error);
     4849 +
     4850 +        /* set the props */
     4851 +        switch (t) {
     4852 +        case VDEV_PROP_UINT64:
     4853 +        case VDEV_PROP_STRING:
     4854 +                error = spa_vdev_prop_set(spa, lvd->vdev_guid, sprops);
     4855 +                break;
     4856 +        case COS_PROP_UINT64:
     4857 +                error = spa_cos_prop_set(spa, name, sprops);
     4858 +                break;
     4859 +        default:
     4860 +                error = EINVAL;
     4861 +                break;
     4862 +        }
     4863 +        if (error == ENOSPC) {
     4864 +                ztest_record_enospc(FTAG);
     4865 +                nvlist_free(sprops);
     4866 +                return (NULL);
     4867 +        }
     4868 +        ASSERT0(error);
     4869 +        return (sprops);
     4870 +}
     4871 +
     4872 +static nvlist_t *
     4873 +ztest_props_get(const vdev_t *lvd, const char *name)
     4874 +{
     4875 +        spa_t *spa = ztest_spa;
     4876 +        nvlist_t *gprops = NULL;
     4877 +        int error = 0;
     4878 +
     4879 +        if (lvd)
     4880 +                error = spa_vdev_prop_get(spa, lvd->vdev_guid, &gprops);
     4881 +        else
     4882 +                error = spa_cos_prop_get(spa, name, &gprops);
     4883 +        if (error == ENOSPC) {
     4884 +                ztest_record_enospc(FTAG);
     4885 +                return (NULL);
     4886 +        }
     4887 +        ASSERT0(error);
     4888 +        return (gprops);
     4889 +}
     4890 +
     4891 +static void
     4892 +ztest_props_test(const ztest_prop_t t, const void *props, const size_t size,
     4893 +    nvlist_t *sprops, nvlist_t *gprops)
     4894 +{
     4895 +        for (int p = 0; p < size; p++) {
     4896 +                const char *pname =
     4897 +                    (t == VDEV_PROP_UINT64 || t == VDEV_PROP_STRING) ?
     4898 +                    vdev_prop_to_name(((vdev_prop_t *)props)[p]) :
     4899 +                    cos_prop_to_name(((cos_prop_t *)props)[p]);
     4900 +
     4901 +                switch (t) {
     4902 +                case VDEV_PROP_UINT64:
     4903 +                case COS_PROP_UINT64:
     4904 +                {
     4905 +                        uint64_t sival, gival;
     4906 +                        VERIFY3U(0, ==, nvlist_lookup_uint64(sprops, pname,
     4907 +                            &sival));
     4908 +                        VERIFY3U(0, ==, nvlist_lookup_uint64(gprops, pname,
     4909 +                            &gival));
     4910 +                        VERIFY3U(gival, ==, sival);
     4911 +                }
     4912 +                break;
     4913 +                case VDEV_PROP_STRING:
     4914 +                {
     4915 +                        char *ssval, *gsval;
     4916 +                        VERIFY3U(0, ==, nvlist_lookup_string(sprops, pname,
     4917 +                            &ssval));
     4918 +                        VERIFY3U(0, ==, nvlist_lookup_string(gprops, pname,
     4919 +                            &gsval));
     4920 +                        VERIFY3U(0, ==, strcmp(ssval, gsval));
     4921 +                }
     4922 +                break;
     4923 +                default:
     4924 +                        /* unknown property */
     4925 +                        VERIFY(0);
     4926 +                        break;
     4927 +                }
     4928 +        }
     4929 +
     4930 +        nvlist_free(sprops);
     4931 +        nvlist_free(gprops);
     4932 +}
     4933 +
     4934 +static const cos_prop_t cprops_uint64[] = {
     4935 +        COS_PROP_READ_MINACTIVE,
     4936 +        COS_PROP_AREAD_MINACTIVE,
     4937 +        COS_PROP_WRITE_MINACTIVE,
     4938 +        COS_PROP_AWRITE_MINACTIVE,
     4939 +        COS_PROP_SCRUB_MINACTIVE,
     4940 +        COS_PROP_RESILVER_MINACTIVE,
     4941 +        COS_PROP_READ_MAXACTIVE,
     4942 +        COS_PROP_AREAD_MAXACTIVE,
     4943 +        COS_PROP_WRITE_MAXACTIVE,
     4944 +        COS_PROP_AWRITE_MAXACTIVE,
     4945 +        COS_PROP_SCRUB_MAXACTIVE,
     4946 +        COS_PROP_RESILVER_MAXACTIVE,
     4947 +        COS_PROP_PREFERRED_READ
     4948 +};
     4949 +
     4950 +/* ARGSUSED */
     4951 +void
     4952 +ztest_cos_prop_get_set(ztest_ds_t *zd, uint64_t id)
     4953 +{
     4954 +        spa_t *spa = ztest_spa;
     4955 +        nvlist_t *sprops = NULL, *gprops = NULL, *cos_list = NULL;
     4956 +        char cos_name[MAXCOSNAMELEN];
     4957 +        const char *pname = NULL;
     4958 +        char *sval = NULL;
     4959 +        uint64_t cos_id = ztest_random(~0ULL), val = 0;
     4960 +        vdev_t *lvd = NULL;
     4961 +
     4962 +        (void) snprintf(cos_name, MAXCOSNAMELEN-1, "cos_%llu", cos_id);
     4963 +
     4964 +        mutex_enter(&ztest_props_lock);
     4965 +
     4966 +        VERIFY3U(0, ==, spa_alloc_cos(spa, cos_name, cos_id));
     4967 +
     4968 +        sprops = ztest_props_set(NULL, cos_name,
     4969 +            COS_PROP_UINT64, (void *)&cprops_uint64[0],
     4970 +            sizeof (cprops_uint64) / sizeof (cprops_uint64[0]));
     4971 +        gprops = ztest_props_get(NULL, cos_name);
     4972 +        ztest_props_test(COS_PROP_UINT64, (void *)&cprops_uint64[0],
     4973 +            sizeof (cprops_uint64) / sizeof (cprops_uint64[0]),
     4974 +            sprops, gprops);
     4975 +
     4976 +        VERIFY3U(0, ==, nvlist_alloc(&cos_list, NV_UNIQUE_NAME, 0));
     4977 +        VERIFY3U(0, ==, spa_list_cos(spa, cos_list));
     4978 +        VERIFY3U(0, ==, nvlist_lookup_uint64(cos_list, cos_name, &val));
     4979 +        VERIFY3U(cos_id, ==, val);
     4980 +        nvlist_free(cos_list);
     4981 +
     4982 +        VERIFY3U(0, ==, spa_free_cos(spa, cos_name, B_FALSE));
     4983 +        VERIFY3U(0, ==, nvlist_alloc(&cos_list, NV_UNIQUE_NAME, 0));
     4984 +        VERIFY3U(0, ==, spa_list_cos(spa, cos_list));
     4985 +        VERIFY3U(ENOENT, ==, nvlist_lookup_uint64(cos_list, cos_name, &val));
     4986 +        nvlist_free(cos_list);
     4987 +
     4988 +        /*
     4989 +         * force spa_free_cos() test
     4990 +         * - allocate cos property, set vdev's cos, then free cos forcefuly
     4991 +         * - verify everything succeeds
     4992 +         * - verify no cos property on vdev
     4993 +         * - verify no cos descriptor remains
     4994 +         */
     4995 +        VERIFY3U(0, ==, spa_alloc_cos(spa, cos_name, cos_id));
     4996 +
     4997 +        /* Make sure vdevs will stay in place */
     4998 +        mutex_enter(&ztest_vdev_lock);
     4999 +
     5000 +        lvd = ztest_get_random_vdev_leaf(spa);
     5001 +
     5002 +        VERIFY(0 == nvlist_alloc(&sprops, NV_UNIQUE_NAME, 0));
     5003 +
     5004 +        pname = vdev_prop_to_name(VDEV_PROP_COS);
     5005 +        VERIFY3U(0, ==, nvlist_add_string(sprops, pname, cos_name));
     5006 +        VERIFY3U(0, ==, spa_vdev_prop_set(spa, lvd->vdev_guid, sprops));
     5007 +
     5008 +        VERIFY3U(0, ==, spa_free_cos(spa, cos_name, B_TRUE));
     5009 +
     5010 +        VERIFY3U(0, ==, spa_vdev_prop_get(spa, lvd->vdev_guid, &gprops));
     5011 +
     5012 +        mutex_exit(&ztest_vdev_lock);
     5013 +
     5014 +        /* verify the vdev cos prop gone */
     5015 +        VERIFY3U(ENOENT, ==, nvlist_lookup_string(gprops, cos_name, &sval));
     5016 +
     5017 +        /* verify the cos descriptor gone */
     5018 +        VERIFY3U(0, ==, nvlist_alloc(&cos_list, NV_UNIQUE_NAME, 0));
     5019 +        VERIFY3U(0, ==, spa_list_cos(spa, cos_list));
     5020 +        VERIFY3U(ENOENT, ==, nvlist_lookup_uint64(cos_list, cos_name, &val));
     5021 +
     5022 +        mutex_exit(&ztest_props_lock);
     5023 +
     5024 +        nvlist_free(cos_list);
     5025 +}
     5026 +
     5027 +/* vdev tests */
     5028 +static const vdev_prop_t vprops_uint64[] = {
     5029 +        VDEV_PROP_READ_MINACTIVE,
     5030 +        VDEV_PROP_AREAD_MINACTIVE,
     5031 +        VDEV_PROP_WRITE_MINACTIVE,
     5032 +        VDEV_PROP_AWRITE_MINACTIVE,
     5033 +        VDEV_PROP_SCRUB_MINACTIVE,
     5034 +        VDEV_PROP_RESILVER_MINACTIVE,
     5035 +        VDEV_PROP_READ_MAXACTIVE,
     5036 +        VDEV_PROP_AREAD_MAXACTIVE,
     5037 +        VDEV_PROP_WRITE_MAXACTIVE,
     5038 +        VDEV_PROP_AWRITE_MAXACTIVE,
     5039 +        VDEV_PROP_SCRUB_MAXACTIVE,
     5040 +        VDEV_PROP_RESILVER_MAXACTIVE,
     5041 +        VDEV_PROP_PREFERRED_READ
     5042 +};
     5043 +static const vdev_prop_t vprops_string[] = {
     5044 +        VDEV_PROP_COS,
     5045 +        VDEV_PROP_SPAREGROUP
     5046 +};
     5047 +
     5048 +static void
     5049 +ztest_cos_free(spa_t *spa, vdev_t *lvd, const char *name)
     5050 +{
     5051 +        nvlist_t *sprops = NULL;
     5052 +        int error = 0;
     5053 +        VERIFY(0 == nvlist_alloc(&sprops, NV_UNIQUE_NAME, 0));
     5054 +        VERIFY(0 == nvlist_add_string(sprops,
     5055 +            vdev_prop_to_name(VDEV_PROP_COS), ""));
     5056 +        VERIFY3U(0, ==, spa_vdev_prop_set(spa, lvd->vdev_guid, sprops));
     5057 +        /*
     5058 +         * this can be called in cleanup code paths when we do not know
     5059 +         * if CoS was allocated
     5060 +         */
     5061 +        error = spa_free_cos(spa, name, B_TRUE);
     5062 +        if (error)
     5063 +                VERIFY3U(error, ==, ENOENT);
     5064 +        nvlist_free(sprops);
     5065 +}
     5066 +
     5067 +/* ARGSUSED */
     5068 +void
     5069 +ztest_vdev_prop_get_set(ztest_ds_t *zd, uint64_t id)
     5070 +{
     5071 +        spa_t *spa = ztest_spa;
     5072 +        nvlist_t *sprops = NULL, *gprops = NULL;
     5073 +        vdev_t *lvd = NULL;
     5074 +        int error = 0;
     5075 +        /* Make sure vdevs will stay in place */
     5076 +        mutex_enter(&ztest_props_lock);
     5077 +
     5078 +        mutex_enter(&ztest_vdev_lock);
     5079 +
     5080 +        lvd = ztest_get_random_vdev_leaf(spa);
     5081 +
     5082 +        /* Test uint64 properties */
     5083 +        sprops = ztest_props_set(lvd, NULL, VDEV_PROP_UINT64,
     5084 +            (void *)&vprops_uint64[0],
     5085 +            sizeof (vprops_uint64) / sizeof (vprops_uint64[0]));
     5086 +        gprops = ztest_props_get(lvd, NULL);
     5087 +        ztest_props_test(VDEV_PROP_UINT64, (void *)&vprops_uint64[0],
     5088 +            sizeof (vprops_uint64) / sizeof (vprops_uint64[0]), sprops, gprops);
     5089 +
     5090 +        /* Test string properties */
     5091 +        /* Allocate CoS descriptor to have vdev-set of cos succeed */
     5092 +        error = spa_alloc_cos(spa, ZTEST_COS_NAME, 0);
     5093 +        if (error)
     5094 +                VERIFY3U(error, ==, EEXIST);
     5095 +
     5096 +        sprops = ztest_props_set(lvd, NULL, VDEV_PROP_STRING,
     5097 +            (void *)&vprops_string[0],
     5098 +            sizeof (vprops_string) / sizeof (vprops_string[0]));
     5099 +        gprops = ztest_props_get(lvd, NULL);
     5100 +        ztest_props_test(VDEV_PROP_STRING, (void *)&vprops_string[0],
     5101 +            sizeof (vprops_string) / sizeof (vprops_string[0]), sprops, gprops);
     5102 +
     5103 +        /* Done, free cos to avoid collisions with other tests */
     5104 +        ztest_cos_free(spa, lvd, ZTEST_COS_NAME);
     5105 +
     5106 +        mutex_exit(&ztest_vdev_lock);
     5107 +
     5108 +        mutex_exit(&ztest_props_lock);
     5109 +}
     5110 +
     5111 +/* end vdev and cos property tests */
     5112 +
4730 5113  static int
4731 5114  user_release_one(const char *snapname, const char *holdname)
4732 5115  {
4733 5116          nvlist_t *snaps, *holds;
4734 5117          int error;
4735 5118  
4736 5119          snaps = fnvlist_alloc();
4737 5120          holds = fnvlist_alloc();
4738 5121          fnvlist_add_boolean(holds, holdname);
4739 5122          fnvlist_add_nvlist(snaps, snapname, holds);
↓ open down ↓ 210 lines elided ↑ open up ↑
4950 5333                           * or unwriteable, or reach behind its back
4951 5334                           * and close the underlying fd.  We can do this if
4952 5335                           * maxfaults == 0 because we'll fail and reexecute,
4953 5336                           * and we can do it if maxfaults >= 2 because we'll
4954 5337                           * have enough redundancy.  If maxfaults == 1, the
4955 5338                           * combination of this with injection of random data
4956 5339                           * corruption below exceeds the pool's fault tolerance.
4957 5340                           */
4958 5341                          vdev_file_t *vf = vd0->vdev_tsd;
4959 5342  
4960      -                        zfs_dbgmsg("injecting fault to vdev %llu; maxfaults=%d",
4961      -                            (long long)vd0->vdev_id, (int)maxfaults);
4962      -
4963 5343                          if (vf != NULL && ztest_random(3) == 0) {
4964 5344                                  (void) close(vf->vf_vnode->v_fd);
4965 5345                                  vf->vf_vnode->v_fd = -1;
4966 5346                          } else if (ztest_random(2) == 0) {
4967 5347                                  vd0->vdev_cant_read = B_TRUE;
4968 5348                          } else {
4969 5349                                  vd0->vdev_cant_write = B_TRUE;
4970 5350                          }
4971 5351                          guid0 = vd0->vdev_guid;
4972 5352                  }
↓ open down ↓ 453 lines elided ↑ open up ↑
5426 5806                  (void) spa_scan(spa, POOL_SCAN_SCRUB);
5427 5807  
5428 5808          pool_guid = spa_guid(spa);
5429 5809          spa_close(spa, FTAG);
5430 5810  
5431 5811          ztest_walk_pool_directory("pools before export");
5432 5812  
5433 5813          /*
5434 5814           * Export it.
5435 5815           */
5436      -        VERIFY3U(0, ==, spa_export(oldname, &config, B_FALSE, B_FALSE));
     5816 +        VERIFY3U(0, ==, spa_export(oldname, &config, B_FALSE, B_FALSE,
     5817 +            B_FALSE));
5437 5818  
5438 5819          ztest_walk_pool_directory("pools after export");
5439 5820  
5440 5821          /*
5441 5822           * Try to import it.
5442 5823           */
5443 5824          newconfig = spa_tryimport(config);
5444 5825          ASSERT(newconfig != NULL);
5445 5826          nvlist_free(newconfig);
5446 5827  
↓ open down ↓ 298 lines elided ↑ open up ↑
5745 6126          objset_t *os;
5746 6127          thread_t resume_tid;
5747 6128          int error;
5748 6129  
5749 6130          ztest_exiting = B_FALSE;
5750 6131  
5751 6132          /*
5752 6133           * Initialize parent/child shared state.
5753 6134           */
5754 6135          mutex_init(&ztest_vdev_lock, NULL, USYNC_THREAD, NULL);
     6136 +        mutex_init(&ztest_props_lock, NULL, USYNC_THREAD, NULL);
5755 6137          rw_init(&ztest_name_lock, NULL, USYNC_THREAD, NULL);
5756 6138  
5757 6139          zs->zs_thread_start = gethrtime();
5758 6140          zs->zs_thread_stop =
5759 6141              zs->zs_thread_start + ztest_opts.zo_passtime * NANOSEC;
5760 6142          zs->zs_thread_stop = MIN(zs->zs_thread_stop, zs->zs_proc_stop);
5761 6143          zs->zs_thread_kill = zs->zs_thread_stop;
5762 6144          if (ztest_random(100) < ztest_opts.zo_killrate) {
5763 6145                  zs->zs_thread_kill -=
5764 6146                      ztest_random(ztest_opts.zo_passtime * NANOSEC);
↓ open down ↓ 269 lines elided ↑ open up ↑
6034 6416          else
6035 6417                  (void) sprintf(timebuf, "%llus", s);
6036 6418  }
6037 6419  
6038 6420  static nvlist_t *
6039 6421  make_random_props()
6040 6422  {
6041 6423          nvlist_t *props;
6042 6424  
6043 6425          VERIFY(nvlist_alloc(&props, NV_UNIQUE_NAME, 0) == 0);
6044      -        if (ztest_random(2) == 0)
6045      -                return (props);
6046      -        VERIFY(nvlist_add_uint64(props, "autoreplace", 1) == 0);
     6426 +        switch (ztest_random(5)) {
     6427 +        case 0:
     6428 +                break;
     6429 +        case 1:
     6430 +                VERIFY(nvlist_add_uint64(props, "autoreplace", 1) == 0);
     6431 +                break;
     6432 +        case 2:
     6433 +                VERIFY(nvlist_add_uint64(props, "enablespecial", 1) == 0);
     6434 +                VERIFY(nvlist_add_uint64(props, "small_data_to_metadev", 1) ==
     6435 +                    0);
     6436 +                break;
     6437 +        case 3:
     6438 +                VERIFY(nvlist_add_uint64(props, "enablespecial", 1) == 0);
     6439 +                VERIFY(nvlist_add_uint64(props, "autoreplace", 1) == 0);
     6440 +                break;
     6441 +        case 4:
     6442 +                VERIFY(nvlist_add_uint64(props, "enablespecial", 1) == 0);
     6443 +                VERIFY(nvlist_add_uint64(props, "meta_placement", 1) == 0);
     6444 +                VERIFY(nvlist_add_uint64(props, "zfs_meta_to_metadev", 1) == 0);
     6445 +                break;
     6446 +        }
6047 6447  
6048 6448          return (props);
6049 6449  }
6050 6450  
     6451 +static void
     6452 +set_random_ds_props(char *dsname)
     6453 +{
     6454 +        uint64_t value = META_PLACEMENT_OFF;
     6455 +
     6456 +        switch (ztest_random(3)) {
     6457 +        case 0:
     6458 +                break;
     6459 +        case 1:
     6460 +                value = META_PLACEMENT_ON;
     6461 +                break;
     6462 +        case 2:
     6463 +                value = META_PLACEMENT_DUAL;
     6464 +                break;
     6465 +        }
     6466 +
     6467 +        VERIFY(ztest_dsl_prop_set_uint64(dsname, ZFS_PROP_ZPL_META_TO_METADEV,
     6468 +            value, B_TRUE) == 0);
     6469 +}
     6470 +
6051 6471  /*
6052 6472   * Create a storage pool with the given name and initial vdev size.
6053 6473   * Then test spa_freeze() functionality.
6054 6474   */
6055 6475  static void
6056 6476  ztest_init(ztest_shared_t *zs)
6057 6477  {
6058 6478          spa_t *spa;
6059 6479          nvlist_t *nvroot, *props;
6060 6480  
↓ open down ↓ 3 lines elided ↑ open up ↑
6064 6484          kernel_init(FREAD | FWRITE);
6065 6485  
6066 6486          /*
6067 6487           * Create the storage pool.
6068 6488           */
6069 6489          (void) spa_destroy(ztest_opts.zo_pool);
6070 6490          ztest_shared->zs_vdev_next_leaf = 0;
6071 6491          zs->zs_splits = 0;
6072 6492          zs->zs_mirrors = ztest_opts.zo_mirrors;
6073 6493          nvroot = make_vdev_root(NULL, NULL, NULL, ztest_opts.zo_vdev_size, 0,
6074      -            0, ztest_opts.zo_raidz, zs->zs_mirrors, 1);
     6494 +            0, ztest_opts.zo_raidz, zs->zs_mirrors, 1, B_FALSE);
     6495 +        /*
     6496 +         * Add special vdevs
     6497 +         */
     6498 +        add_special_vdevs(nvroot, ztest_opts.zo_vdev_size, ztest_opts.zo_raidz,
     6499 +            zs->zs_mirrors, 1);
     6500 +
6075 6501          props = make_random_props();
6076 6502          for (int i = 0; i < SPA_FEATURES; i++) {
6077 6503                  char buf[1024];
6078 6504                  (void) snprintf(buf, sizeof (buf), "feature@%s",
6079 6505                      spa_feature_table[i].fi_uname);
6080 6506                  VERIFY3U(0, ==, nvlist_add_uint64(props, buf, 0));
6081 6507          }
6082 6508          VERIFY3U(0, ==, spa_create(ztest_opts.zo_pool, nvroot, props, NULL));
6083 6509          nvlist_free(nvroot);
6084 6510          nvlist_free(props);
6085 6511  
6086 6512          VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG));
6087 6513          zs->zs_metaslab_sz =
6088 6514              1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift;
6089 6515  
     6516 +        /* set props on the root dataset */
     6517 +        set_random_ds_props(ztest_opts.zo_pool);
     6518 +
6090 6519          spa_close(spa, FTAG);
6091 6520  
6092 6521          kernel_fini();
6093 6522  
6094 6523          ztest_run_zdb(ztest_opts.zo_pool);
6095 6524  
6096 6525          ztest_freeze();
6097 6526  
6098 6527          ztest_run_zdb(ztest_opts.zo_pool);
6099 6528  
6100 6529          rw_destroy(&ztest_name_lock);
     6530 +        mutex_destroy(&ztest_props_lock);
6101 6531          mutex_destroy(&ztest_vdev_lock);
6102 6532  }
6103 6533  
6104 6534  static void
6105 6535  setup_data_fd(void)
6106 6536  {
6107 6537          static char ztest_name_data[] = "/tmp/ztest.data.XXXXXX";
6108 6538  
6109 6539          ztest_fd_data = mkstemp(ztest_name_data);
6110 6540          ASSERT3S(ztest_fd_data, >=, 0);
↓ open down ↓ 384 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX