]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/spa.c
spa.c: Replace VERIFY(nvlist_*(...) == 0) with fnvlist_* (#12678)
[mirror_zfs.git] / module / zfs / spa.c
index a02fd198bed03812c67d934885fd484542d9348a..1c0856d7f2114d05082f07d11aec271f3b1f25e0 100644 (file)
@@ -277,15 +277,15 @@ spa_prop_add_list(nvlist_t *nvl, zpool_prop_t prop, char *strval,
        const char *propname = zpool_prop_to_name(prop);
        nvlist_t *propval;
 
-       VERIFY(nvlist_alloc(&propval, NV_UNIQUE_NAME, KM_SLEEP) == 0);
-       VERIFY(nvlist_add_uint64(propval, ZPROP_SOURCE, src) == 0);
+       propval = fnvlist_alloc();
+       fnvlist_add_uint64(propval, ZPROP_SOURCE, src);
 
        if (strval != NULL)
-               VERIFY(nvlist_add_string(propval, ZPROP_VALUE, strval) == 0);
+               fnvlist_add_string(propval, ZPROP_VALUE, strval);
        else
-               VERIFY(nvlist_add_uint64(propval, ZPROP_VALUE, intval) == 0);
+               fnvlist_add_uint64(propval, ZPROP_VALUE, intval);
 
-       VERIFY(nvlist_add_nvlist(nvl, propname, propval) == 0);
+       fnvlist_add_nvlist(nvl, propname, propval);
        nvlist_free(propval);
 }
 
@@ -1773,8 +1773,8 @@ spa_load_spares(spa_t *spa)
        if (spa->spa_spares.sav_config == NULL)
                nspares = 0;
        else
-               VERIFY(nvlist_lookup_nvlist_array(spa->spa_spares.sav_config,
-                   ZPOOL_CONFIG_SPARES, &spares, &nspares) == 0);
+               VERIFY0(nvlist_lookup_nvlist_array(spa->spa_spares.sav_config,
+                   ZPOOL_CONFIG_SPARES, &spares, &nspares));
 
        spa->spa_spares.sav_count = (int)nspares;
        spa->spa_spares.sav_vdevs = NULL;
@@ -1836,16 +1836,15 @@ spa_load_spares(spa_t *spa)
         * Recompute the stashed list of spares, with status information
         * this time.
         */
-       VERIFY(nvlist_remove(spa->spa_spares.sav_config, ZPOOL_CONFIG_SPARES,
-           DATA_TYPE_NVLIST_ARRAY) == 0);
+       fnvlist_remove(spa->spa_spares.sav_config, ZPOOL_CONFIG_SPARES);
 
        spares = kmem_alloc(spa->spa_spares.sav_count * sizeof (void *),
            KM_SLEEP);
        for (i = 0; i < spa->spa_spares.sav_count; i++)
                spares[i] = vdev_config_generate(spa,
                    spa->spa_spares.sav_vdevs[i], B_TRUE, VDEV_CONFIG_SPARE);
-       VERIFY(nvlist_add_nvlist_array(spa->spa_spares.sav_config,
-           ZPOOL_CONFIG_SPARES, spares, spa->spa_spares.sav_count) == 0);
+       fnvlist_add_nvlist_array(spa->spa_spares.sav_config,
+           ZPOOL_CONFIG_SPARES, spares, spa->spa_spares.sav_count);
        for (i = 0; i < spa->spa_spares.sav_count; i++)
                nvlist_free(spares[i]);
        kmem_free(spares, spa->spa_spares.sav_count * sizeof (void *));
@@ -1895,16 +1894,15 @@ spa_load_l2cache(spa_t *spa)
                goto out;
        }
 
-       VERIFY(nvlist_lookup_nvlist_array(sav->sav_config,
-           ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache) == 0);
+       VERIFY0(nvlist_lookup_nvlist_array(sav->sav_config,
+           ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache));
        newvdevs = kmem_alloc(nl2cache * sizeof (void *), KM_SLEEP);
 
        /*
         * Process new nvlist of vdevs.
         */
        for (i = 0; i < nl2cache; i++) {
-               VERIFY(nvlist_lookup_uint64(l2cache[i], ZPOOL_CONFIG_GUID,
-                   &guid) == 0);
+               guid = fnvlist_lookup_uint64(l2cache[i], ZPOOL_CONFIG_GUID);
 
                newvdevs[i] = NULL;
                for (j = 0; j < oldnvdevs; j++) {
@@ -1965,8 +1963,7 @@ spa_load_l2cache(spa_t *spa)
         * Recompute the stashed list of l2cache devices, with status
         * information this time.
         */
-       VERIFY(nvlist_remove(sav->sav_config, ZPOOL_CONFIG_L2CACHE,
-           DATA_TYPE_NVLIST_ARRAY) == 0);
+       fnvlist_remove(sav->sav_config, ZPOOL_CONFIG_L2CACHE);
 
        if (sav->sav_count > 0)
                l2cache = kmem_alloc(sav->sav_count * sizeof (void *),
@@ -1974,8 +1971,8 @@ spa_load_l2cache(spa_t *spa)
        for (i = 0; i < sav->sav_count; i++)
                l2cache[i] = vdev_config_generate(spa,
                    sav->sav_vdevs[i], B_TRUE, VDEV_CONFIG_L2CACHE);
-       VERIFY(nvlist_add_nvlist_array(sav->sav_config,
-           ZPOOL_CONFIG_L2CACHE, l2cache, sav->sav_count) == 0);
+       fnvlist_add_nvlist_array(sav->sav_config, ZPOOL_CONFIG_L2CACHE, l2cache,
+           sav->sav_count);
 
 out:
        /*
@@ -2085,7 +2082,7 @@ spa_check_for_missing_logs(spa_t *spa)
 
                child = kmem_alloc(rvd->vdev_children * sizeof (nvlist_t *),
                    KM_SLEEP);
-               VERIFY(nvlist_alloc(&nv, NV_UNIQUE_NAME, KM_SLEEP) == 0);
+               nv = fnvlist_alloc();
 
                for (uint64_t c = 0; c < rvd->vdev_children; c++) {
                        vdev_t *tvd = rvd->vdev_child[c];
@@ -2388,12 +2385,12 @@ spa_load_verify(spa_t *spa)
                spa->spa_load_txg_ts = spa->spa_uberblock.ub_timestamp;
 
                loss = spa->spa_last_ubsync_txg_ts - spa->spa_load_txg_ts;
-               VERIFY(nvlist_add_uint64(spa->spa_load_info,
-                   ZPOOL_CONFIG_LOAD_TIME, spa->spa_load_txg_ts) == 0);
-               VERIFY(nvlist_add_int64(spa->spa_load_info,
-                   ZPOOL_CONFIG_REWIND_TIME, loss) == 0);
-               VERIFY(nvlist_add_uint64(spa->spa_load_info,
-                   ZPOOL_CONFIG_LOAD_DATA_ERRORS, sle.sle_data_count) == 0);
+               fnvlist_add_uint64(spa->spa_load_info, ZPOOL_CONFIG_LOAD_TIME,
+                   spa->spa_load_txg_ts);
+               fnvlist_add_int64(spa->spa_load_info, ZPOOL_CONFIG_REWIND_TIME,
+                   loss);
+               fnvlist_add_uint64(spa->spa_load_info,
+                   ZPOOL_CONFIG_LOAD_DATA_ERRORS, sle.sle_data_count);
        } else {
                spa->spa_load_max_txg = spa->spa_uberblock.ub_txg;
        }
@@ -3647,7 +3644,7 @@ spa_ld_select_uberblock(spa_t *spa, spa_import_type_t type)
                 * from the label.
                 */
                nvlist_free(spa->spa_label_features);
-               VERIFY(nvlist_dup(features, &spa->spa_label_features, 0) == 0);
+               spa->spa_label_features = fnvlist_dup(features);
        }
 
        nvlist_free(label);
@@ -3660,21 +3657,20 @@ spa_ld_select_uberblock(spa_t *spa, spa_import_type_t type)
        if (ub->ub_version >= SPA_VERSION_FEATURES) {
                nvlist_t *unsup_feat;
 
-               VERIFY(nvlist_alloc(&unsup_feat, NV_UNIQUE_NAME, KM_SLEEP) ==
-                   0);
+               unsup_feat = fnvlist_alloc();
 
                for (nvpair_t *nvp = nvlist_next_nvpair(spa->spa_label_features,
                    NULL); nvp != NULL;
                    nvp = nvlist_next_nvpair(spa->spa_label_features, nvp)) {
                        if (!zfeature_is_supported(nvpair_name(nvp))) {
-                               VERIFY(nvlist_add_string(unsup_feat,
-                                   nvpair_name(nvp), "") == 0);
+                               fnvlist_add_string(unsup_feat,
+                                   nvpair_name(nvp), "");
                        }
                }
 
                if (!nvlist_empty(unsup_feat)) {
-                       VERIFY(nvlist_add_nvlist(spa->spa_load_info,
-                           ZPOOL_CONFIG_UNSUP_FEAT, unsup_feat) == 0);
+                       fnvlist_add_nvlist(spa->spa_load_info,
+                           ZPOOL_CONFIG_UNSUP_FEAT, unsup_feat);
                        nvlist_free(unsup_feat);
                        spa_load_failed(spa, "some features are unsupported");
                        return (spa_vdev_err(rvd, VDEV_AUX_UNSUP_FEAT,
@@ -5181,11 +5177,10 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy,
                         * attempted vdev_open().  Return this to the user.
                         */
                        if (config != NULL && spa->spa_config) {
-                               VERIFY(nvlist_dup(spa->spa_config, config,
-                                   KM_SLEEP) == 0);
-                               VERIFY(nvlist_add_nvlist(*config,
+                               *config = fnvlist_dup(spa->spa_config);
+                               fnvlist_add_nvlist(*config,
                                    ZPOOL_CONFIG_LOAD_INFO,
-                                   spa->spa_load_info) == 0);
+                                   spa->spa_load_info);
                        }
                        spa_unload(spa);
                        spa_deactivate(spa);
@@ -5207,8 +5202,8 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy,
         * gathered while doing the load.
         */
        if (state == SPA_LOAD_RECOVER) {
-               VERIFY(nvlist_add_nvlist(*config, ZPOOL_CONFIG_LOAD_INFO,
-                   spa->spa_load_info) == 0);
+               fnvlist_add_nvlist(*config, ZPOOL_CONFIG_LOAD_INFO,
+                   spa->spa_load_info);
        }
 
        if (locked) {
@@ -5286,15 +5281,14 @@ spa_add_spares(spa_t *spa, nvlist_t *config)
        if (spa->spa_spares.sav_count == 0)
                return;
 
-       VERIFY(nvlist_lookup_nvlist(config,
-           ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0);
-       VERIFY(nvlist_lookup_nvlist_array(spa->spa_spares.sav_config,
-           ZPOOL_CONFIG_SPARES, &spares, &nspares) == 0);
+       nvroot = fnvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE);
+       VERIFY0(nvlist_lookup_nvlist_array(spa->spa_spares.sav_config,
+           ZPOOL_CONFIG_SPARES, &spares, &nspares));
        if (nspares != 0) {
-               VERIFY(nvlist_add_nvlist_array(nvroot,
-                   ZPOOL_CONFIG_SPARES, spares, nspares) == 0);
-               VERIFY(nvlist_lookup_nvlist_array(nvroot,
-                   ZPOOL_CONFIG_SPARES, &spares, &nspares) == 0);
+               fnvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES, spares,
+                   nspares);
+               VERIFY0(nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES,
+                   &spares, &nspares));
 
                /*
                 * Go through and find any spares which have since been
@@ -5302,13 +5296,13 @@ spa_add_spares(spa_t *spa, nvlist_t *config)
                 * their status appropriately.
                 */
                for (i = 0; i < nspares; i++) {
-                       VERIFY(nvlist_lookup_uint64(spares[i],
-                           ZPOOL_CONFIG_GUID, &guid) == 0);
+                       guid = fnvlist_lookup_uint64(spares[i],
+                           ZPOOL_CONFIG_GUID);
                        if (spa_spare_exists(guid, &pool, NULL) &&
                            pool != 0ULL) {
-                               VERIFY(nvlist_lookup_uint64_array(
-                                   spares[i], ZPOOL_CONFIG_VDEV_STATS,
-                                   (uint64_t **)&vs, &vsc) == 0);
+                               VERIFY0(nvlist_lookup_uint64_array(spares[i],
+                                   ZPOOL_CONFIG_VDEV_STATS, (uint64_t **)&vs,
+                                   &vsc));
                                vs->vs_state = VDEV_STATE_CANT_OPEN;
                                vs->vs_aux = VDEV_AUX_SPARED;
                        }
@@ -5335,23 +5329,22 @@ spa_add_l2cache(spa_t *spa, nvlist_t *config)
        if (spa->spa_l2cache.sav_count == 0)
                return;
 
-       VERIFY(nvlist_lookup_nvlist(config,
-           ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0);
-       VERIFY(nvlist_lookup_nvlist_array(spa->spa_l2cache.sav_config,
-           ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache) == 0);
+       nvroot = fnvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE);
+       VERIFY0(nvlist_lookup_nvlist_array(spa->spa_l2cache.sav_config,
+           ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache));
        if (nl2cache != 0) {
-               VERIFY(nvlist_add_nvlist_array(nvroot,
-                   ZPOOL_CONFIG_L2CACHE, l2cache, nl2cache) == 0);
-               VERIFY(nvlist_lookup_nvlist_array(nvroot,
-                   ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache) == 0);
+               fnvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_L2CACHE, l2cache,
+                   nl2cache);
+               VERIFY0(nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_L2CACHE,
+                   &l2cache, &nl2cache));
 
                /*
                 * Update level 2 cache device stats.
                 */
 
                for (i = 0; i < nl2cache; i++) {
-                       VERIFY(nvlist_lookup_uint64(l2cache[i],
-                           ZPOOL_CONFIG_GUID, &guid) == 0);
+                       guid = fnvlist_lookup_uint64(l2cache[i],
+                           ZPOOL_CONFIG_GUID);
 
                        vd = NULL;
                        for (j = 0; j < spa->spa_l2cache.sav_count; j++) {
@@ -5363,9 +5356,8 @@ spa_add_l2cache(spa_t *spa, nvlist_t *config)
                        }
                        ASSERT(vd != NULL);
 
-                       VERIFY(nvlist_lookup_uint64_array(l2cache[i],
-                           ZPOOL_CONFIG_VDEV_STATS, (uint64_t **)&vs, &vsc)
-                           == 0);
+                       VERIFY0(nvlist_lookup_uint64_array(l2cache[i],
+                           ZPOOL_CONFIG_VDEV_STATS, (uint64_t **)&vs, &vsc));
                        vdev_get_stats(vd, vs);
                        vdev_config_generate_stats(vd, l2cache[i]);
 
@@ -5480,20 +5472,20 @@ spa_get_stats(const char *name, nvlist_t **config,
 
                        loadtimes[0] = spa->spa_loaded_ts.tv_sec;
                        loadtimes[1] = spa->spa_loaded_ts.tv_nsec;
-                       VERIFY(nvlist_add_uint64_array(*config,
-                           ZPOOL_CONFIG_LOADED_TIME, loadtimes, 2) == 0);
+                       fnvlist_add_uint64_array(*config,
+                           ZPOOL_CONFIG_LOADED_TIME, loadtimes, 2);
 
-                       VERIFY(nvlist_add_uint64(*config,
+                       fnvlist_add_uint64(*config,
                            ZPOOL_CONFIG_ERRCOUNT,
-                           spa_get_errlog_size(spa)) == 0);
+                           spa_get_errlog_size(spa));
 
                        if (spa_suspended(spa)) {
-                               VERIFY(nvlist_add_uint64(*config,
+                               fnvlist_add_uint64(*config,
                                    ZPOOL_CONFIG_SUSPENDED,
-                                   spa->spa_failmode) == 0);
-                               VERIFY(nvlist_add_uint64(*config,
+                                   spa->spa_failmode);
+                               fnvlist_add_uint64(*config,
                                    ZPOOL_CONFIG_SUSPENDED_REASON,
-                                   spa->spa_suspended) == 0);
+                                   spa->spa_suspended);
                        }
 
                        spa_add_spares(spa, *config);
@@ -5585,8 +5577,8 @@ spa_validate_aux_devs(spa_t *spa, nvlist_t *nvroot, uint64_t crtxg, int mode,
 
                if ((error = vdev_open(vd)) == 0 &&
                    (error = vdev_label_init(vd, crtxg, label)) == 0) {
-                       VERIFY(nvlist_add_uint64(dev[i], ZPOOL_CONFIG_GUID,
-                           vd->vdev_guid) == 0);
+                       fnvlist_add_uint64(dev[i], ZPOOL_CONFIG_GUID,
+                           vd->vdev_guid);
                }
 
                vdev_free(vd);
@@ -5637,23 +5629,20 @@ spa_set_aux_vdevs(spa_aux_vdev_t *sav, nvlist_t **devs, int ndevs,
                 * Generate new dev list by concatenating with the
                 * current dev list.
                 */
-               VERIFY(nvlist_lookup_nvlist_array(sav->sav_config, config,
-                   &olddevs, &oldndevs) == 0);
+               VERIFY0(nvlist_lookup_nvlist_array(sav->sav_config, config,
+                   &olddevs, &oldndevs));
 
                newdevs = kmem_alloc(sizeof (void *) *
                    (ndevs + oldndevs), KM_SLEEP);
                for (i = 0; i < oldndevs; i++)
-                       VERIFY(nvlist_dup(olddevs[i], &newdevs[i],
-                           KM_SLEEP) == 0);
+                       newdevs[i] = fnvlist_dup(olddevs[i]);
                for (i = 0; i < ndevs; i++)
-                       VERIFY(nvlist_dup(devs[i], &newdevs[i + oldndevs],
-                           KM_SLEEP) == 0);
+                       newdevs[i + oldndevs] = fnvlist_dup(devs[i]);
 
-               VERIFY(nvlist_remove(sav->sav_config, config,
-                   DATA_TYPE_NVLIST_ARRAY) == 0);
+               fnvlist_remove(sav->sav_config, config);
 
-               VERIFY(nvlist_add_nvlist_array(sav->sav_config,
-                   config, newdevs, ndevs + oldndevs) == 0);
+               fnvlist_add_nvlist_array(sav->sav_config, config, newdevs,
+                   ndevs + oldndevs);
                for (i = 0; i < oldndevs + ndevs; i++)
                        nvlist_free(newdevs[i]);
                kmem_free(newdevs, (oldndevs + ndevs) * sizeof (void *));
@@ -5661,10 +5650,8 @@ spa_set_aux_vdevs(spa_aux_vdev_t *sav, nvlist_t **devs, int ndevs,
                /*
                 * Generate a new dev list.
                 */
-               VERIFY(nvlist_alloc(&sav->sav_config, NV_UNIQUE_NAME,
-                   KM_SLEEP) == 0);
-               VERIFY(nvlist_add_nvlist_array(sav->sav_config, config,
-                   devs, ndevs) == 0);
+               sav->sav_config = fnvlist_alloc();
+               fnvlist_add_nvlist_array(sav->sav_config, config, devs, ndevs);
        }
 }
 
@@ -5873,10 +5860,9 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
         */
        if (nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES,
            &spares, &nspares) == 0) {
-               VERIFY(nvlist_alloc(&spa->spa_spares.sav_config, NV_UNIQUE_NAME,
-                   KM_SLEEP) == 0);
-               VERIFY(nvlist_add_nvlist_array(spa->spa_spares.sav_config,
-                   ZPOOL_CONFIG_SPARES, spares, nspares) == 0);
+               spa->spa_spares.sav_config = fnvlist_alloc();
+               fnvlist_add_nvlist_array(spa->spa_spares.sav_config,
+                   ZPOOL_CONFIG_SPARES, spares, nspares);
                spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
                spa_load_spares(spa);
                spa_config_exit(spa, SCL_ALL, FTAG);
@@ -5888,10 +5874,9 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
         */
        if (nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_L2CACHE,
            &l2cache, &nl2cache) == 0) {
-               VERIFY(nvlist_alloc(&spa->spa_l2cache.sav_config,
-                   NV_UNIQUE_NAME, KM_SLEEP) == 0);
-               VERIFY(nvlist_add_nvlist_array(spa->spa_l2cache.sav_config,
-                   ZPOOL_CONFIG_L2CACHE, l2cache, nl2cache) == 0);
+               spa->spa_l2cache.sav_config = fnvlist_alloc();
+               fnvlist_add_nvlist_array(spa->spa_l2cache.sav_config,
+                   ZPOOL_CONFIG_L2CACHE, l2cache, nl2cache);
                spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
                spa_load_l2cache(spa);
                spa_config_exit(spa, SCL_ALL, FTAG);
@@ -6092,8 +6077,7 @@ spa_import(char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
         * Propagate anything learned while loading the pool and pass it
         * back to caller (i.e. rewind info, missing devices, etc).
         */
-       VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_LOAD_INFO,
-           spa->spa_load_info) == 0);
+       fnvlist_add_nvlist(config, ZPOOL_CONFIG_LOAD_INFO, spa->spa_load_info);
 
        spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
        /*
@@ -6111,8 +6095,7 @@ spa_import(char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
                spa_load_l2cache(spa);
        }
 
-       VERIFY(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
-           &nvroot) == 0);
+       nvroot = fnvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE);
        spa_config_exit(spa, SCL_ALL, FTAG);
 
        if (props != NULL)
@@ -6136,13 +6119,12 @@ spa_import(char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
        if (nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES,
            &spares, &nspares) == 0) {
                if (spa->spa_spares.sav_config)
-                       VERIFY(nvlist_remove(spa->spa_spares.sav_config,
-                           ZPOOL_CONFIG_SPARES, DATA_TYPE_NVLIST_ARRAY) == 0);
+                       fnvlist_remove(spa->spa_spares.sav_config,
+                           ZPOOL_CONFIG_SPARES);
                else
-                       VERIFY(nvlist_alloc(&spa->spa_spares.sav_config,
-                           NV_UNIQUE_NAME, KM_SLEEP) == 0);
-               VERIFY(nvlist_add_nvlist_array(spa->spa_spares.sav_config,
-                   ZPOOL_CONFIG_SPARES, spares, nspares) == 0);
+                       spa->spa_spares.sav_config = fnvlist_alloc();
+               fnvlist_add_nvlist_array(spa->spa_spares.sav_config,
+                   ZPOOL_CONFIG_SPARES, spares, nspares);
                spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
                spa_load_spares(spa);
                spa_config_exit(spa, SCL_ALL, FTAG);
@@ -6151,13 +6133,12 @@ spa_import(char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
        if (nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_L2CACHE,
            &l2cache, &nl2cache) == 0) {
                if (spa->spa_l2cache.sav_config)
-                       VERIFY(nvlist_remove(spa->spa_l2cache.sav_config,
-                           ZPOOL_CONFIG_L2CACHE, DATA_TYPE_NVLIST_ARRAY) == 0);
+                       fnvlist_remove(spa->spa_l2cache.sav_config,
+                           ZPOOL_CONFIG_L2CACHE);
                else
-                       VERIFY(nvlist_alloc(&spa->spa_l2cache.sav_config,
-                           NV_UNIQUE_NAME, KM_SLEEP) == 0);
-               VERIFY(nvlist_add_nvlist_array(spa->spa_l2cache.sav_config,
-                   ZPOOL_CONFIG_L2CACHE, l2cache, nl2cache) == 0);
+                       spa->spa_l2cache.sav_config = fnvlist_alloc();
+               fnvlist_add_nvlist_array(spa->spa_l2cache.sav_config,
+                   ZPOOL_CONFIG_L2CACHE, l2cache, nl2cache);
                spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
                spa_load_l2cache(spa);
                spa_config_exit(spa, SCL_ALL, FTAG);
@@ -6247,16 +6228,14 @@ spa_tryimport(nvlist_t *tryconfig)
         */
        if (spa->spa_root_vdev != NULL) {
                config = spa_config_generate(spa, NULL, -1ULL, B_TRUE);
-               VERIFY(nvlist_add_string(config, ZPOOL_CONFIG_POOL_NAME,
-                   poolname) == 0);
-               VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_STATE,
-                   state) == 0);
-               VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_TIMESTAMP,
-                   spa->spa_uberblock.ub_timestamp) == 0);
-               VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_LOAD_INFO,
-                   spa->spa_load_info) == 0);
-               VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_ERRATA,
-                   spa->spa_errata) == 0);
+               fnvlist_add_string(config, ZPOOL_CONFIG_POOL_NAME, poolname);
+               fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_STATE, state);
+               fnvlist_add_uint64(config, ZPOOL_CONFIG_TIMESTAMP,
+                   spa->spa_uberblock.ub_timestamp);
+               fnvlist_add_nvlist(config, ZPOOL_CONFIG_LOAD_INFO,
+                   spa->spa_load_info);
+               fnvlist_add_uint64(config, ZPOOL_CONFIG_ERRATA,
+                   spa->spa_errata);
 
                /*
                 * If the bootfs property exists on this pool then we
@@ -6285,8 +6264,8 @@ spa_tryimport(nvlist_t *tryconfig)
                                        (void) snprintf(dsname, MAXPATHLEN,
                                            "%s/%s", poolname, ++cp);
                                }
-                               VERIFY(nvlist_add_string(config,
-                                   ZPOOL_CONFIG_BOOTFS, dsname) == 0);
+                               fnvlist_add_string(config, ZPOOL_CONFIG_BOOTFS,
+                                   dsname);
                                kmem_free(dsname, MAXPATHLEN);
                        }
                        kmem_free(tmpname, MAXPATHLEN);
@@ -6435,7 +6414,7 @@ export_spa:
        }
 
        if (oldconfig && spa->spa_config)
-               VERIFY(nvlist_dup(spa->spa_config, oldconfig, 0) == 0);
+               *oldconfig = fnvlist_dup(spa->spa_config);
 
        if (new_state != POOL_STATE_UNINITIALIZED) {
                if (!hardforce)
@@ -7578,14 +7557,14 @@ spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
                }
 
                /* we need certain info from the top level */
-               VERIFY(nvlist_add_uint64(child[c], ZPOOL_CONFIG_METASLAB_ARRAY,
-                   vml[c]->vdev_top->vdev_ms_array) == 0);
-               VERIFY(nvlist_add_uint64(child[c], ZPOOL_CONFIG_METASLAB_SHIFT,
-                   vml[c]->vdev_top->vdev_ms_shift) == 0);
-               VERIFY(nvlist_add_uint64(child[c], ZPOOL_CONFIG_ASIZE,
-                   vml[c]->vdev_top->vdev_asize) == 0);
-               VERIFY(nvlist_add_uint64(child[c], ZPOOL_CONFIG_ASHIFT,
-                   vml[c]->vdev_top->vdev_ashift) == 0);
+               fnvlist_add_uint64(child[c], ZPOOL_CONFIG_METASLAB_ARRAY,
+                   vml[c]->vdev_top->vdev_ms_array);
+               fnvlist_add_uint64(child[c], ZPOOL_CONFIG_METASLAB_SHIFT,
+                   vml[c]->vdev_top->vdev_ms_shift);
+               fnvlist_add_uint64(child[c], ZPOOL_CONFIG_ASIZE,
+                   vml[c]->vdev_top->vdev_asize);
+               fnvlist_add_uint64(child[c], ZPOOL_CONFIG_ASHIFT,
+                   vml[c]->vdev_top->vdev_ashift);
 
                /* transfer per-vdev ZAPs */
                ASSERT3U(vml[c]->vdev_leaf_zap, !=, 0);
@@ -7615,28 +7594,24 @@ spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
         * Temporarily record the splitting vdevs in the spa config.  This
         * will disappear once the config is regenerated.
         */
-       VERIFY(nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_SLEEP) == 0);
-       VERIFY(nvlist_add_uint64_array(nvl, ZPOOL_CONFIG_SPLIT_LIST,
-           glist, children) == 0);
+       nvl = fnvlist_alloc();
+       fnvlist_add_uint64_array(nvl, ZPOOL_CONFIG_SPLIT_LIST, glist, children);
        kmem_free(glist, children * sizeof (uint64_t));
 
        mutex_enter(&spa->spa_props_lock);
-       VERIFY(nvlist_add_nvlist(spa->spa_config, ZPOOL_CONFIG_SPLIT,
-           nvl) == 0);
+       fnvlist_add_nvlist(spa->spa_config, ZPOOL_CONFIG_SPLIT, nvl);
        mutex_exit(&spa->spa_props_lock);
        spa->spa_config_splitting = nvl;
        vdev_config_dirty(spa->spa_root_vdev);
 
        /* configure and create the new pool */
-       VERIFY(nvlist_add_string(config, ZPOOL_CONFIG_POOL_NAME, newname) == 0);
-       VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_STATE,
-           exp ? POOL_STATE_EXPORTED : POOL_STATE_ACTIVE) == 0);
-       VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_VERSION,
-           spa_version(spa)) == 0);
-       VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_TXG,
-           spa->spa_config_txg) == 0);
-       VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_GUID,
-           spa_generate_guid(NULL)) == 0);
+       fnvlist_add_string(config, ZPOOL_CONFIG_POOL_NAME, newname);
+       fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_STATE,
+           exp ? POOL_STATE_EXPORTED : POOL_STATE_ACTIVE);
+       fnvlist_add_uint64(config, ZPOOL_CONFIG_VERSION, spa_version(spa));
+       fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_TXG, spa->spa_config_txg);
+       fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_GUID,
+           spa_generate_guid(NULL));
        VERIFY0(nvlist_add_boolean(config, ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS));
        (void) nvlist_lookup_string(props,
            zpool_prop_to_name(ZPOOL_PROP_ALTROOT), &altroot);
@@ -7698,10 +7673,9 @@ spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
 
        /* if that worked, generate a real config for the new pool */
        if (newspa->spa_root_vdev != NULL) {
-               VERIFY(nvlist_alloc(&newspa->spa_config_splitting,
-                   NV_UNIQUE_NAME, KM_SLEEP) == 0);
-               VERIFY(nvlist_add_uint64(newspa->spa_config_splitting,
-                   ZPOOL_CONFIG_SPLIT_GUID, spa_guid(spa)) == 0);
+               newspa->spa_config_splitting = fnvlist_alloc();
+               fnvlist_add_uint64(newspa->spa_config_splitting,
+                   ZPOOL_CONFIG_SPLIT_GUID, spa_guid(spa));
                spa_config_set(newspa, spa_config_generate(newspa, NULL, -1ULL,
                    B_TRUE));
        }
@@ -8489,16 +8463,15 @@ spa_sync_aux_dev(spa_t *spa, spa_aux_vdev_t *sav, dmu_tx_t *tx,
                    &sav->sav_object, tx) == 0);
        }
 
-       VERIFY(nvlist_alloc(&nvroot, NV_UNIQUE_NAME, KM_SLEEP) == 0);
+       nvroot = fnvlist_alloc();
        if (sav->sav_count == 0) {
-               VERIFY(nvlist_add_nvlist_array(nvroot, config, NULL, 0) == 0);
+               fnvlist_add_nvlist_array(nvroot, config, NULL, 0);
        } else {
                list = kmem_alloc(sav->sav_count*sizeof (void *), KM_SLEEP);
                for (i = 0; i < sav->sav_count; i++)
                        list[i] = vdev_config_generate(spa, sav->sav_vdevs[i],
                            B_FALSE, VDEV_CONFIG_L2CACHE);
-               VERIFY(nvlist_add_nvlist_array(nvroot, config, list,
-                   sav->sav_count) == 0);
+               fnvlist_add_nvlist_array(nvroot, config, list, sav->sav_count);
                for (i = 0; i < sav->sav_count; i++)
                        nvlist_free(list[i]);
                kmem_free(list, sav->sav_count * sizeof (void *));