Unverified Commit e4efb709 authored by Ryan Moeller's avatar Ryan Moeller Committed by GitHub
Browse files

FreeBSD: Clean up ASSERT/VERIFY use in module



Convert use of ASSERT() to ASSERT0(), ASSERT3U(), ASSERT3S(), 
ASSERT3P(), and likewise for VERIFY().  In some cases it ended up 
making more sense to change the code, such as VERIFY on nvlist 
operations that I have converted to use fnvlist instead.  In one 
place I changed an internal struct member from int to boolean_t to 
match its use.  Some asserts that combined multiple checks with && 
in a single assert have been split to separate asserts, to make it 
apparent which check fails.
Reviewed-by: default avatarBrian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: default avatarRyan Moeller <ryan@iXsystems.com>
Closes #11971
parent ec4f3308
......@@ -43,7 +43,6 @@
#include <grp.h>
#include <pwd.h>
#include <acl_common.h>
#define ASSERT assert
#endif
#define ACE_POSIX_SUPPORTED_BITS (ACE_READ_DATA | \
......@@ -170,8 +169,9 @@ ksort(caddr_t v, int n, int s, int (*f)(void *, void *))
return;
/* Sanity check on arguments */
ASSERT(((uintptr_t)v & 0x3) == 0 && (s & 0x3) == 0);
ASSERT(s > 0);
ASSERT3U(((uintptr_t)v & 0x3), ==, 0);
ASSERT3S((s & 0x3), ==, 0);
ASSERT3S(s, >, 0);
for (g = n / 2; g > 0; g /= 2) {
for (i = g; i < n; i++) {
for (j = i - g; j >= 0 &&
......
......@@ -75,7 +75,7 @@ typedef struct callb {
typedef struct callb_table {
kmutex_t ct_lock; /* protect all callb states */
callb_t *ct_freelist; /* free callb structures */
int ct_busy; /* != 0 prevents additions */
boolean_t ct_busy; /* B_TRUE prevents additions */
kcondvar_t ct_busy_cv; /* to wait for not busy */
int ct_ncallb; /* num of callbs allocated */
callb_t *ct_first_cb[NCBCLASS]; /* ptr to 1st callb in a class */
......@@ -98,7 +98,7 @@ callb_cpr_t callb_cprinfo_safe = {
static void
callb_init(void *dummy __unused)
{
callb_table.ct_busy = 0; /* mark table open for additions */
callb_table.ct_busy = B_FALSE; /* mark table open for additions */
mutex_init(&callb_safe_mutex, NULL, MUTEX_DEFAULT, NULL);
mutex_init(&callb_table.ct_lock, NULL, MUTEX_DEFAULT, NULL);
}
......@@ -139,7 +139,7 @@ callb_add_common(boolean_t (*func)(void *arg, int code),
{
callb_t *cp;
ASSERT(class < NCBCLASS);
ASSERT3S(class, <, NCBCLASS);
mutex_enter(&ct->ct_lock);
while (ct->ct_busy)
......@@ -259,7 +259,7 @@ callb_execute_class(int class, int code)
callb_t *cp;
void *ret = NULL;
ASSERT(class < NCBCLASS);
ASSERT3S(class, <, NCBCLASS);
mutex_enter(&ct->ct_lock);
......@@ -351,8 +351,8 @@ void
callb_lock_table(void)
{
mutex_enter(&ct->ct_lock);
ASSERT(ct->ct_busy == 0);
ct->ct_busy = 1;
ASSERT(!ct->ct_busy);
ct->ct_busy = B_TRUE;
mutex_exit(&ct->ct_lock);
}
......@@ -363,8 +363,8 @@ void
callb_unlock_table(void)
{
mutex_enter(&ct->ct_lock);
ASSERT(ct->ct_busy != 0);
ct->ct_busy = 0;
ASSERT(ct->ct_busy);
ct->ct_busy = B_FALSE;
cv_broadcast(&ct->ct_busy_cv);
mutex_exit(&ct->ct_lock);
}
......
......@@ -61,9 +61,8 @@
void
list_create(list_t *list, size_t size, size_t offset)
{
ASSERT(list);
ASSERT(size > 0);
ASSERT(size >= offset + sizeof (list_node_t));
ASSERT3P(list, !=, NULL);
ASSERT3U(size, >=, offset + sizeof (list_node_t));
list->list_size = size;
list->list_offset = offset;
......@@ -76,9 +75,9 @@ list_destroy(list_t *list)
{
list_node_t *node = &list->list_head;
ASSERT(list);
ASSERT(list->list_head.list_next == node);
ASSERT(list->list_head.list_prev == node);
ASSERT3P(list, !=, NULL);
ASSERT3P(list->list_head.list_next, ==, node);
ASSERT3P(list->list_head.list_prev, ==, node);
node->list_next = node->list_prev = NULL;
}
......@@ -124,7 +123,7 @@ list_remove(list_t *list, void *object)
{
list_node_t *lold = list_d2l(list, object);
ASSERT(!list_empty(list));
ASSERT(lold->list_next != NULL);
ASSERT3P(lold->list_next, !=, NULL);
list_remove_node(lold);
}
......@@ -195,8 +194,8 @@ list_move_tail(list_t *dst, list_t *src)
list_node_t *dstnode = &dst->list_head;
list_node_t *srcnode = &src->list_head;
ASSERT(dst->list_size == src->list_size);
ASSERT(dst->list_offset == src->list_offset);
ASSERT3U(dst->list_size, ==, src->list_size);
ASSERT3U(dst->list_offset, ==, src->list_offset);
if (list_empty(src))
return;
......
......@@ -112,7 +112,7 @@ zfs_kmem_free(void *buf, size_t size __unused)
if (i == buf)
break;
}
ASSERT(i != NULL);
ASSERT3P(i, !=, NULL);
LIST_REMOVE(i, next);
mtx_unlock(&kmem_items_mtx);
memset(buf, 0xDC, MAX(size, 16));
......@@ -162,7 +162,7 @@ kmem_cache_create(char *name, size_t bufsize, size_t align,
{
kmem_cache_t *cache;
ASSERT(vmp == NULL);
ASSERT3P(vmp, ==, NULL);
cache = kmem_alloc(sizeof (*cache), KM_SLEEP);
strlcpy(cache->kc_name, name, sizeof (cache->kc_name));
......@@ -324,7 +324,7 @@ void
spl_kmem_cache_set_move(kmem_cache_t *skc,
kmem_cbrc_t (move)(void *, void *, size_t, void *))
{
ASSERT(move != NULL);
ASSERT3P(move, !=, NULL);
}
#ifdef KMEM_DEBUG
......
......@@ -69,7 +69,7 @@ __kstat_set_seq_raw_ops(kstat_t *ksp,
static int
kstat_default_update(kstat_t *ksp, int rw)
{
ASSERT(ksp != NULL);
ASSERT3P(ksp, !=, NULL);
if (rw == KSTAT_WRITE)
return (EACCES);
......@@ -223,7 +223,7 @@ restart:
sbuf_printf(sb, "%s", ksp->ks_raw_buf);
} else {
ASSERT(ksp->ks_ndata == 1);
ASSERT3U(ksp->ks_ndata, ==, 1);
sbuf_hexdump(sb, ksp->ks_data,
ksp->ks_data_size, NULL, 0);
}
......@@ -250,7 +250,7 @@ __kstat_create(const char *module, int instance, const char *name,
KASSERT(instance == 0, ("instance=%d", instance));
if ((ks_type == KSTAT_TYPE_INTR) || (ks_type == KSTAT_TYPE_IO))
ASSERT(ks_ndata == 1);
ASSERT3U(ks_ndata, ==, 1);
if (class == NULL)
class = "misc";
......@@ -461,7 +461,7 @@ kstat_install(kstat_t *ksp)
struct sysctl_oid *root;
if (ksp->ks_ndata == UINT32_MAX)
VERIFY(ksp->ks_type == KSTAT_TYPE_RAW);
VERIFY3U(ksp->ks_type, ==, KSTAT_TYPE_RAW);
switch (ksp->ks_type) {
case KSTAT_TYPE_NAMED:
......@@ -493,7 +493,7 @@ kstat_install(kstat_t *ksp)
default:
panic("unsupported kstat type %d\n", ksp->ks_type);
}
VERIFY(root != NULL);
VERIFY3P(root, !=, NULL);
ksp->ks_sysctl_root = root;
}
......@@ -535,7 +535,7 @@ kstat_waitq_exit(kstat_io_t *kiop)
delta = new - kiop->wlastupdate;
kiop->wlastupdate = new;
wcnt = kiop->wcnt--;
ASSERT((int)wcnt > 0);
ASSERT3S(wcnt, >, 0);
kiop->wlentime += delta * wcnt;
kiop->wtime += delta;
}
......@@ -566,7 +566,7 @@ kstat_runq_exit(kstat_io_t *kiop)
delta = new - kiop->rlastupdate;
kiop->rlastupdate = new;
rcnt = kiop->rcnt--;
ASSERT((int)rcnt > 0);
ASSERT3S(rcnt, >, 0);
kiop->rlentime += delta * rcnt;
kiop->rtime += delta;
}
......@@ -102,6 +102,6 @@ kmem_asprintf(const char *fmt, ...)
void
kmem_strfree(char *str)
{
ASSERT(str != NULL);
ASSERT3P(str, !=, NULL);
kmem_free(str, strlen(str) + 1);
}
......@@ -245,7 +245,7 @@ sysevent_worker(void *arg __unused)
if (error == ESHUTDOWN)
break;
} else {
VERIFY(event != NULL);
VERIFY3P(event, !=, NULL);
log_sysevent(event);
nvlist_free(event);
}
......
......@@ -48,7 +48,7 @@
int
zfs_uiomove(void *cp, size_t n, zfs_uio_rw_t dir, zfs_uio_t *uio)
{
ASSERT(zfs_uio_rw(uio) == dir);
ASSERT3U(zfs_uio_rw(uio), ==, dir);
return (uiomove(cp, (int)n, GET_UIO_STRUCT(uio)));
}
......@@ -102,6 +102,6 @@ zfs_uioskip(zfs_uio_t *uio, size_t n)
int
zfs_uio_fault_move(void *p, size_t n, zfs_uio_rw_t dir, zfs_uio_t *uio)
{
ASSERT(zfs_uio_rw(uio) == dir);
ASSERT3U(zfs_uio_rw(uio), ==, dir);
return (vn_io_fault_uiomove(p, n, GET_UIO_STRUCT(uio)));
}
......@@ -275,13 +275,13 @@ mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, char *fspath,
void
vn_rele_async(vnode_t *vp, taskq_t *taskq)
{
VERIFY(vp->v_usecount > 0);
VERIFY3U(vp->v_usecount, >, 0);
if (refcount_release_if_not_last(&vp->v_usecount)) {
#if __FreeBSD_version < 1300045
vdrop(vp);
#endif
return;
}
VERIFY(taskq_dispatch((taskq_t *)taskq,
(task_func_t *)vrele, vp, TQ_SLEEP) != 0);
VERIFY3U(taskq_dispatch((taskq_t *)taskq,
(task_func_t *)vrele, vp, TQ_SLEEP), !=, 0);
}
......@@ -168,8 +168,7 @@ abd_verify_scatter(abd_t *abd)
* if an error if the ABD has been marked as a linear page.
*/
ASSERT(!abd_is_linear_page(abd));
ASSERT3U(ABD_SCATTER(abd).abd_offset, <,
zfs_abd_chunk_size);
ASSERT3U(ABD_SCATTER(abd).abd_offset, <, zfs_abd_chunk_size);
n = abd_scatter_chunkcnt(abd);
for (i = 0; i < n; i++) {
ASSERT3P(ABD_SCATTER(abd).abd_chunks[i], !=, NULL);
......
......@@ -120,7 +120,7 @@ dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
dmu_buf_t *db = dbp[i];
caddr_t va;
ASSERT(size > 0);
ASSERT3U(size, >, 0);
ASSERT3U(db->db_size, >=, PAGESIZE);
bufoff = offset - db->db_offset;
......@@ -170,7 +170,7 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count,
int err;
ASSERT3U(ma[0]->pindex + count - 1, ==, ma[count - 1]->pindex);
ASSERT(last_size <= PAGE_SIZE);
ASSERT3S(last_size, <=, PAGE_SIZE);
err = dmu_buf_hold_array(os, object, IDX_TO_OFF(ma[0]->pindex),
IDX_TO_OFF(count - 1) + last_size, TRUE, FTAG, &numbufs, &dbp);
......@@ -182,7 +182,7 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count,
if (dbp[0]->db_offset != 0 || numbufs > 1) {
for (i = 0; i < numbufs; i++) {
ASSERT(ISP2(dbp[i]->db_size));
ASSERT((dbp[i]->db_offset % dbp[i]->db_size) == 0);
ASSERT3U((dbp[i]->db_offset % dbp[i]->db_size), ==, 0);
ASSERT3U(dbp[i]->db_size, ==, dbp[0]->db_size);
}
}
......@@ -202,10 +202,10 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count,
vm_page_do_sunbusy(m);
break;
}
ASSERT(m->dirty == 0);
ASSERT3U(m->dirty, ==, 0);
ASSERT(!pmap_page_is_write_mapped(m));
ASSERT(db->db_size > PAGE_SIZE);
ASSERT3U(db->db_size, >, PAGE_SIZE);
bufoff = IDX_TO_OFF(m->pindex) % db->db_size;
va = zfs_map_page(m, &sf);
bcopy((char *)db->db_data + bufoff, va, PAGESIZE);
......@@ -229,7 +229,7 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count,
if (m != bogus_page) {
vm_page_assert_xbusied(m);
ASSERT(vm_page_none_valid(m));
ASSERT(m->dirty == 0);
ASSERT3U(m->dirty, ==, 0);
ASSERT(!pmap_page_is_write_mapped(m));
va = zfs_map_page(m, &sf);
}
......@@ -248,25 +248,28 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count,
* end of file anyway.
*/
tocpy = MIN(db->db_size - bufoff, PAGESIZE - pgoff);
ASSERT3S(tocpy, >=, 0);
if (m != bogus_page)
bcopy((char *)db->db_data + bufoff, va + pgoff, tocpy);
pgoff += tocpy;
ASSERT(pgoff <= PAGESIZE);
ASSERT3S(pgoff, >=, 0);
ASSERT3S(pgoff, <=, PAGESIZE);
if (pgoff == PAGESIZE) {
if (m != bogus_page) {
zfs_unmap_page(sf);
vm_page_valid(m);
}
ASSERT(mi < count);
ASSERT3S(mi, <, count);
mi++;
pgoff = 0;
}
bufoff += tocpy;
ASSERT(bufoff <= db->db_size);
ASSERT3S(bufoff, >=, 0);
ASSERT3S(bufoff, <=, db->db_size);
if (bufoff == db->db_size) {
ASSERT(di < numbufs);
ASSERT3S(di, <, numbufs);
di++;
bufoff = 0;
}
......@@ -286,23 +289,23 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count,
* with a size that is not a multiple of the page size.
*/
if (mi == count) {
ASSERT(di >= numbufs - 1);
ASSERT3S(di, >=, numbufs - 1);
IMPLY(*rahead != 0, di == numbufs - 1);
IMPLY(*rahead != 0, bufoff != 0);
ASSERT(pgoff == 0);
ASSERT0(pgoff);
}
if (di == numbufs) {
ASSERT(mi >= count - 1);
ASSERT(*rahead == 0);
ASSERT3S(mi, >=, count - 1);
ASSERT0(*rahead);
IMPLY(pgoff == 0, mi == count);
if (pgoff != 0) {
ASSERT(mi == count - 1);
ASSERT((dbp[0]->db_size & PAGE_MASK) != 0);
ASSERT3S(mi, ==, count - 1);
ASSERT3U((dbp[0]->db_size & PAGE_MASK), !=, 0);
}
}
#endif
if (pgoff != 0) {
ASSERT(m != bogus_page);
ASSERT3P(m, !=, bogus_page);
bzero(va + pgoff, PAGESIZE - pgoff);
zfs_unmap_page(sf);
vm_page_valid(m);
......@@ -318,17 +321,17 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count,
vm_page_do_sunbusy(m);
break;
}
ASSERT(m->dirty == 0);
ASSERT3U(m->dirty, ==, 0);
ASSERT(!pmap_page_is_write_mapped(m));
ASSERT(db->db_size > PAGE_SIZE);
ASSERT3U(db->db_size, >, PAGE_SIZE);
bufoff = IDX_TO_OFF(m->pindex) % db->db_size;
tocpy = MIN(db->db_size - bufoff, PAGESIZE);
va = zfs_map_page(m, &sf);
bcopy((char *)db->db_data + bufoff, va, tocpy);
if (tocpy < PAGESIZE) {
ASSERT(i == *rahead - 1);
ASSERT((db->db_size & PAGE_MASK) != 0);
ASSERT3S(i, ==, *rahead - 1);
ASSERT3U((db->db_size & PAGE_MASK), !=, 0);
bzero(va + tocpy, PAGESIZE - tocpy);
}
zfs_unmap_page(sf);
......
......@@ -95,8 +95,7 @@ spa_generate_rootconf(const char *name)
for (i = 0; i < count; i++) {
uint64_t txg;
VERIFY(nvlist_lookup_uint64(configs[i], ZPOOL_CONFIG_POOL_TXG,
&txg) == 0);
txg = fnvlist_lookup_uint64(configs[i], ZPOOL_CONFIG_POOL_TXG);
if (txg > best_txg) {
best_txg = txg;
best_cfg = configs[i];
......@@ -115,72 +114,66 @@ spa_generate_rootconf(const char *name)
break;
if (configs[i] == NULL)
continue;
VERIFY(nvlist_lookup_nvlist(configs[i], ZPOOL_CONFIG_VDEV_TREE,
&nvtop) == 0);
nvlist_dup(nvtop, &tops[i], KM_SLEEP);
nvtop = fnvlist_lookup_nvlist(configs[i],
ZPOOL_CONFIG_VDEV_TREE);
tops[i] = fnvlist_dup(nvtop);
}
for (i = 0; holes != NULL && i < nholes; i++) {
if (i >= nchildren)
continue;
if (tops[holes[i]] != NULL)
continue;
nvlist_alloc(&tops[holes[i]], NV_UNIQUE_NAME, KM_SLEEP);
VERIFY(nvlist_add_string(tops[holes[i]], ZPOOL_CONFIG_TYPE,
VDEV_TYPE_HOLE) == 0);
VERIFY(nvlist_add_uint64(tops[holes[i]], ZPOOL_CONFIG_ID,
holes[i]) == 0);
VERIFY(nvlist_add_uint64(tops[holes[i]], ZPOOL_CONFIG_GUID,
0) == 0);
tops[holes[i]] = fnvlist_alloc();
fnvlist_add_string(tops[holes[i]], ZPOOL_CONFIG_TYPE,
VDEV_TYPE_HOLE);
fnvlist_add_uint64(tops[holes[i]], ZPOOL_CONFIG_ID, holes[i]);
fnvlist_add_uint64(tops[holes[i]], ZPOOL_CONFIG_GUID, 0);
}
for (i = 0; i < nchildren; i++) {
if (tops[i] != NULL)
continue;
nvlist_alloc(&tops[i], NV_UNIQUE_NAME, KM_SLEEP);
VERIFY(nvlist_add_string(tops[i], ZPOOL_CONFIG_TYPE,
VDEV_TYPE_MISSING) == 0);
VERIFY(nvlist_add_uint64(tops[i], ZPOOL_CONFIG_ID,
i) == 0);
VERIFY(nvlist_add_uint64(tops[i], ZPOOL_CONFIG_GUID,
0) == 0);
tops[i] = fnvlist_alloc();
fnvlist_add_string(tops[i], ZPOOL_CONFIG_TYPE,
VDEV_TYPE_MISSING);
fnvlist_add_uint64(tops[i], ZPOOL_CONFIG_ID, i);
fnvlist_add_uint64(tops[i], ZPOOL_CONFIG_GUID, 0);
}
/*
* Create pool config based on the best vdev config.
*/
nvlist_dup(best_cfg, &config, KM_SLEEP);
config = fnvlist_dup(best_cfg);
/*
* Put this pool's top-level vdevs into a root vdev.
*/
VERIFY(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID,
&pgid) == 0);
VERIFY(nvlist_alloc(&nvroot, NV_UNIQUE_NAME, KM_SLEEP) == 0);
VERIFY(nvlist_add_string(nvroot, ZPOOL_CONFIG_TYPE,
VDEV_TYPE_ROOT) == 0);
VERIFY(nvlist_add_uint64(nvroot, ZPOOL_CONFIG_ID, 0ULL) == 0);
VERIFY(nvlist_add_uint64(nvroot, ZPOOL_CONFIG_GUID, pgid) == 0);
VERIFY(nvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN,
tops, nchildren) == 0);
pgid = fnvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID);
nvroot = fnvlist_alloc();
fnvlist_add_string(nvroot, ZPOOL_CONFIG_TYPE, VDEV_TYPE_ROOT);
fnvlist_add_uint64(nvroot, ZPOOL_CONFIG_ID, 0ULL);
fnvlist_add_uint64(nvroot, ZPOOL_CONFIG_GUID, pgid);
fnvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN, tops,
nchildren);
/*
* Replace the existing vdev_tree with the new root vdev in
* this pool's configuration (remove the old, add the new).
*/
VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, nvroot) == 0);
fnvlist_add_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, nvroot);
/*
* Drop vdev config elements that should not be present at pool level.
*/
nvlist_remove(config, ZPOOL_CONFIG_GUID, DATA_TYPE_UINT64);
nvlist_remove(config, ZPOOL_CONFIG_TOP_GUID, DATA_TYPE_UINT64);
fnvlist_remove(config, ZPOOL_CONFIG_GUID);
fnvlist_remove(config, ZPOOL_CONFIG_TOP_GUID);
for (i = 0; i < count; i++)
nvlist_free(configs[i]);
fnvlist_free(configs[i]);
kmem_free(configs, count * sizeof (void *));
for (i = 0; i < nchildren; i++)
nvlist_free(tops[i]);
fnvlist_free(tops[i]);
kmem_free(tops, nchildren * sizeof (void *));
nvlist_free(nvroot);
fnvlist_free(nvroot);
return (config);
}
......@@ -201,10 +194,9 @@ spa_import_rootpool(const char *name, bool checkpointrewind)
mutex_enter(&spa_namespace_lock);
if (config != NULL) {
VERIFY(nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME,
&pname) == 0 && strcmp(name, pname) == 0);
VERIFY(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_TXG, &txg)
== 0);
pname = fnvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME);
VERIFY0(strcmp(name, pname));
txg = fnvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_TXG);
if ((spa = spa_lookup(pname)) != NULL) {
/*
......@@ -213,7 +205,7 @@ spa_import_rootpool(const char *name, bool checkpointrewind)
*/
if (spa->spa_state == POOL_STATE_ACTIVE) {
mutex_exit(&spa_namespace_lock);
nvlist_free(config);
fnvlist_free(config);
return (0);
}
......@@ -235,12 +227,12 @@ spa_import_rootpool(const char *name, bool checkpointrewind)
spa->spa_ubsync.ub_version = SPA_VERSION_INITIAL;
} else if ((spa = spa_lookup(name)) == NULL) {
mutex_exit(&spa_namespace_lock);
nvlist_free(config);
fnvlist_free(config);
cmn_err(CE_NOTE, "Cannot find the pool label for '%s'",
name);
return (EIO);
} else {
VERIFY(nvlist_dup(spa->spa_config, &config, KM_SLEEP) == 0);
config = fnvlist_dup(spa->spa_config);
}
spa->spa_is_root = B_TRUE;
spa->spa_import_flags = ZFS_IMPORT_VERBATIM;
......@@ -251,15 +243,14 @@ spa_import_rootpool(const char *name, bool checkpointrewind)
/*
* Build up a vdev tree based on the boot device's label config.
*/
VERIFY(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
&nvtop) == 0);
nvtop = fnvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE);
spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
error = spa_config_parse(spa, &rvd, nvtop, NULL, 0,
VDEV_ALLOC_ROOTPOOL);
spa_config_exit(spa, SCL_ALL, FTAG);
if (error) {
mutex_exit(&spa_namespace_lock);
nvlist_free(config);
fnvlist_free(config);
cmn_err(CE_NOTE, "Can not parse the config for pool '%s'",
pname);
return (error);
......@@ -270,7 +261,7 @@ spa_import_rootpool(const char *name, bool checkpointrewind)
spa_config_exit(spa, SCL_ALL, FTAG);
mutex_exit(&spa_namespace_lock);
nvlist_free(config);
fnvlist_free(config);
return (0);
}
......
......@@ -59,13 +59,13 @@ vdev_file_fini(void)
static void
vdev_file_hold(vdev_t *vd)
{
ASSERT(vd->vdev_path != NULL);
ASSERT3P(vd->vdev_path, !=, NULL);
}
static void
vdev_file_rele(vdev_t *vd)
{
ASSERT(vd->vdev_path != NULL);
ASSERT3P(vd->vdev_path, !=, NULL);
}
static mode_t
......@@ -137,7 +137,8 @@ vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
* administrator has already decided that the pool should be available
* to local zone users, so the underlying devices should be as well.
*/