libzfs_config.c (168404) | libzfs_config.c (168926) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 60 unchanged lines hidden (view full) --- 69 else 70 return (0); 71} 72 73void 74namespace_clear(libzfs_handle_t *hdl) 75{ 76 if (hdl->libzfs_ns_avl) { | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 60 unchanged lines hidden (view full) --- 69 else 70 return (0); 71} 72 73void 74namespace_clear(libzfs_handle_t *hdl) 75{ 76 if (hdl->libzfs_ns_avl) { |
77 uu_avl_walk_t *walk; | |
78 config_node_t *cn; | 77 config_node_t *cn; |
78 void *cookie = NULL; |
|
79 | 79 |
80 if ((walk = uu_avl_walk_start(hdl->libzfs_ns_avl, 81 UU_WALK_ROBUST)) == NULL) 82 return; 83 84 while ((cn = uu_avl_walk_next(walk)) != NULL) { 85 uu_avl_remove(hdl->libzfs_ns_avl, cn); | 80 while ((cn = uu_avl_teardown(hdl->libzfs_ns_avl, 81 &cookie)) != NULL) { |
86 nvlist_free(cn->cn_config); 87 free(cn->cn_name); 88 free(cn); 89 } 90 | 82 nvlist_free(cn->cn_config); 83 free(cn->cn_name); 84 free(cn); 85 } 86 |
91 uu_avl_walk_end(walk); 92 | |
93 uu_avl_destroy(hdl->libzfs_ns_avl); 94 hdl->libzfs_ns_avl = NULL; 95 } 96 97 if (hdl->libzfs_ns_avlpool) { 98 uu_avl_pool_destroy(hdl->libzfs_ns_avlpool); 99 hdl->libzfs_ns_avlpool = NULL; 100 } --- 4 unchanged lines hidden (view full) --- 105 */ 106static int 107namespace_reload(libzfs_handle_t *hdl) 108{ 109 nvlist_t *config; 110 config_node_t *cn; 111 nvpair_t *elem; 112 zfs_cmd_t zc = { 0 }; | 87 uu_avl_destroy(hdl->libzfs_ns_avl); 88 hdl->libzfs_ns_avl = NULL; 89 } 90 91 if (hdl->libzfs_ns_avlpool) { 92 uu_avl_pool_destroy(hdl->libzfs_ns_avlpool); 93 hdl->libzfs_ns_avlpool = NULL; 94 } --- 4 unchanged lines hidden (view full) --- 99 */ 100static int 101namespace_reload(libzfs_handle_t *hdl) 102{ 103 nvlist_t *config; 104 config_node_t *cn; 105 nvpair_t *elem; 106 zfs_cmd_t zc = { 0 }; |
113 uu_avl_walk_t *walk; | 107 void *cookie; |
114 115 if (hdl->libzfs_ns_gen == 0) { 116 /* 117 * This is the first time we've accessed the configuration 118 * cache. Initialize the AVL tree and then fall through to the 119 * common code. 120 */ 121 if ((hdl->libzfs_ns_avlpool = uu_avl_pool_create("config_pool", --- 45 unchanged lines hidden (view full) --- 167 return (-1); 168 } 169 170 zcmd_free_nvlists(&zc); 171 172 /* 173 * Clear out any existing configuration information. 174 */ | 108 109 if (hdl->libzfs_ns_gen == 0) { 110 /* 111 * This is the first time we've accessed the configuration 112 * cache. Initialize the AVL tree and then fall through to the 113 * common code. 114 */ 115 if ((hdl->libzfs_ns_avlpool = uu_avl_pool_create("config_pool", --- 45 unchanged lines hidden (view full) --- 161 return (-1); 162 } 163 164 zcmd_free_nvlists(&zc); 165 166 /* 167 * Clear out any existing configuration information. 168 */ |
175 if ((walk = uu_avl_walk_start(hdl->libzfs_ns_avl, 176 UU_WALK_ROBUST)) == NULL) { 177 nvlist_free(config); 178 return (no_memory(hdl)); 179 } 180 181 while ((cn = uu_avl_walk_next(walk)) != NULL) { 182 uu_avl_remove(hdl->libzfs_ns_avl, cn); | 169 cookie = NULL; 170 while ((cn = uu_avl_teardown(hdl->libzfs_ns_avl, &cookie)) != NULL) { |
183 nvlist_free(cn->cn_config); 184 free(cn->cn_name); 185 free(cn); 186 } 187 | 171 nvlist_free(cn->cn_config); 172 free(cn->cn_name); 173 free(cn); 174 } 175 |
188 uu_avl_walk_end(walk); 189 | |
190 elem = NULL; 191 while ((elem = nvlist_next_nvpair(config, elem)) != NULL) { 192 nvlist_t *child; 193 uu_avl_index_t where; 194 195 if ((cn = zfs_alloc(hdl, sizeof (config_node_t))) == NULL) { 196 nvlist_free(config); 197 return (-1); --- 19 unchanged lines hidden (view full) --- 217 uu_avl_insert(hdl->libzfs_ns_avl, cn, where); 218 } 219 220 nvlist_free(config); 221 return (0); 222} 223 224/* | 176 elem = NULL; 177 while ((elem = nvlist_next_nvpair(config, elem)) != NULL) { 178 nvlist_t *child; 179 uu_avl_index_t where; 180 181 if ((cn = zfs_alloc(hdl, sizeof (config_node_t))) == NULL) { 182 nvlist_free(config); 183 return (-1); --- 19 unchanged lines hidden (view full) --- 203 uu_avl_insert(hdl->libzfs_ns_avl, cn, where); 204 } 205 206 nvlist_free(config); 207 return (0); 208} 209 210/* |
225 * Retrive the configuration for the given pool. The configuration is a nvlist | 211 * Retrieve the configuration for the given pool. The configuration is a nvlist |
226 * describing the vdevs, as well as the statistics associated with each one. 227 */ 228nvlist_t * 229zpool_get_config(zpool_handle_t *zhp, nvlist_t **oldconfig) 230{ 231 if (oldconfig) 232 *oldconfig = zhp->zpool_old_config; 233 return (zhp->zpool_config); --- 141 unchanged lines hidden --- | 212 * describing the vdevs, as well as the statistics associated with each one. 213 */ 214nvlist_t * 215zpool_get_config(zpool_handle_t *zhp, nvlist_t **oldconfig) 216{ 217 if (oldconfig) 218 *oldconfig = zhp->zpool_old_config; 219 return (zhp->zpool_config); --- 141 unchanged lines hidden --- |