Print this page
6223 libzfs improperly uses an avl tree in namespace_reload

@@ -24,10 +24,11 @@
  * Use is subject to license terms.
  */
 
 /*
  * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*
  * The pool configuration repository is stored in /etc/zfs/zpool.cache as a
  * single packed nvlist.  While it would be nice to just read in this

@@ -165,19 +166,22 @@
         }
 
         zcmd_free_nvlists(&zc);
 
         /*
-         * Clear out any existing configuration information.
+         * Clear out any existing configuration information, and recreate
+         * the AVL tree.
          */
         cookie = NULL;
         while ((cn = uu_avl_teardown(hdl->libzfs_ns_avl, &cookie)) != NULL) {
                 nvlist_free(cn->cn_config);
                 free(cn->cn_name);
                 free(cn);
         }
 
+        uu_avl_recreate(hdl->libzfs_ns_avl);
+
         elem = NULL;
         while ((elem = nvlist_next_nvpair(config, elem)) != NULL) {
                 nvlist_t *child;
                 uu_avl_index_t where;