本文整理汇总了C++中zpool_close函数的典型用法代码示例。如果您正苦于以下问题:C++ zpool_close函数的具体用法?C++ zpool_close怎么用?C++ zpool_close使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zpool_close函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_pool
/*
* Callback function for pool_list_get(). Adds the given pool to the AVL tree
* of known pools.
*/
static int
add_pool(zpool_handle_t *zhp, void *data)
{
zpool_list_t *zlp = data;
zpool_node_t *node = safe_malloc(sizeof (zpool_node_t));
uu_avl_index_t idx;
node->zn_handle = zhp;
uu_avl_node_init(node, &node->zn_avlnode, zlp->zl_pool);
if (uu_avl_find(zlp->zl_avl, node, NULL, &idx) == NULL) {
if (zlp->zl_proplist &&
zpool_expand_proplist(zhp, zlp->zl_proplist) != 0) {
zpool_close(zhp);
free(node);
return (-1);
}
uu_avl_insert(zlp->zl_avl, node, idx);
} else {
zpool_close(zhp);
free(node);
return (-1);
}
return (0);
}
示例2: zfs_mark_pool
/*ARGSUSED*/
static int
zfs_mark_pool(zpool_handle_t *zhp, void *unused)
{
zfs_case_t *zcp;
uint64_t pool_guid;
nvlist_t *config, *vd;
int ret;
pool_guid = zpool_get_prop_int(zhp, ZPOOL_PROP_GUID, NULL);
/*
* Mark any cases associated with just this pool.
*/
for (zcp = uu_list_first(zfs_cases); zcp != NULL;
zcp = uu_list_next(zfs_cases, zcp)) {
if (zcp->zc_data.zc_pool_guid == pool_guid &&
zcp->zc_data.zc_vdev_guid == 0)
zcp->zc_present = B_TRUE;
}
if ((config = zpool_get_config(zhp, NULL)) == NULL) {
zpool_close(zhp);
return (-1);
}
ret = nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &vd);
assert(ret == 0);
zfs_mark_vdev(pool_guid, vd);
zpool_close(zhp);
return (0);
}
示例3: fmd_fmri_present
int
fmd_fmri_present(nvlist_t *nvl)
{
uint64_t pool_guid, vdev_guid;
cbdata_t cb;
int ret;
(void) nvlist_lookup_uint64(nvl, FM_FMRI_ZFS_POOL, &pool_guid);
cb.cb_guid = pool_guid;
cb.cb_pool = NULL;
if (zpool_iter(g_zfs, find_pool, &cb) != 1)
return (0);
if (nvlist_lookup_uint64(nvl, FM_FMRI_ZFS_VDEV, &vdev_guid) != 0) {
zpool_close(cb.cb_pool);
return (1);
}
ret = (find_vdev(cb.cb_pool, vdev_guid) != NULL);
zpool_close(cb.cb_pool);
return (ret);
}
示例4: zpool_open_silent
/*
* Like the above, but silent on error. Used when iterating over pools (because
* the configuration cache may be out of date).
*/
int
zpool_open_silent(libzfs_handle_t *hdl, const char *pool, zpool_handle_t **ret)
{
zpool_handle_t *zhp;
boolean_t missing;
if ((zhp = zfs_alloc(hdl, sizeof (zpool_handle_t))) == NULL)
return (-1);
zhp->zpool_hdl = hdl;
(void) strlcpy(zhp->zpool_name, pool, sizeof (zhp->zpool_name));
if (zpool_refresh_stats(zhp, &missing) != 0) {
zpool_close(zhp);
return (-1);
}
if (missing) {
zpool_close(zhp);
*ret = NULL;
return (0);
}
*ret = zhp;
return (0);
}
示例5: fmd_fmri_replaced
int
fmd_fmri_replaced(nvlist_t *nvl)
{
uint64_t pool_guid, vdev_guid;
cbdata_t cb;
int ret;
(void) nvlist_lookup_uint64(nvl, FM_FMRI_ZFS_POOL, &pool_guid);
cb.cb_guid = pool_guid;
cb.cb_pool = NULL;
if (zpool_iter(g_zfs, find_pool, &cb) != 1)
return (FMD_OBJ_STATE_NOT_PRESENT);
if (nvlist_lookup_uint64(nvl, FM_FMRI_ZFS_VDEV, &vdev_guid) != 0) {
zpool_close(cb.cb_pool);
return (FMD_OBJ_STATE_STILL_PRESENT);
}
ret = (find_vdev(cb.cb_pool, vdev_guid) != NULL) ?
FMD_OBJ_STATE_STILL_PRESENT : FMD_OBJ_STATE_NOT_PRESENT;
zpool_close(cb.cb_pool);
return (ret);
}
示例6: set_bootfs
/*
* Function: set_bootfs
* Description: Sets the bootfs property on the boot pool to be the
* root dataset of the activated BE.
* Parameters:
* boot_pool - The pool we're setting bootfs in.
* be_root_ds - The main dataset for the BE.
* Return:
* BE_SUCCESS - Success
* be_errno_t - Failure
* Scope:
* Private
*/
static int
set_bootfs(char *boot_rpool, char *be_root_ds)
{
zpool_handle_t *zhp;
int err = BE_SUCCESS;
if ((zhp = zpool_open(g_zfs, boot_rpool)) == NULL) {
be_print_err(gettext("set_bootfs: failed to open pool "
"(%s): %s\n"), boot_rpool, libzfs_error_description(g_zfs));
err = zfs_err_to_be_err(g_zfs);
return (err);
}
err = zpool_set_prop(zhp, "bootfs", be_root_ds);
if (err) {
be_print_err(gettext("set_bootfs: failed to set "
"bootfs property for pool %s: %s\n"), boot_rpool,
libzfs_error_description(g_zfs));
err = zfs_err_to_be_err(g_zfs);
zpool_close(zhp);
return (err);
}
zpool_close(zhp);
return (BE_SUCCESS);
}
示例7: ztop
/*
* given the path to a zvol, return the cXtYdZ name
* returns < 0 on error, 0 if it isn't a zvol, > 1 on success
*/
static int
ztop(char *arg, char *diskname)
{
zpool_handle_t *zpool_handle;
nvlist_t *config, *nvroot;
nvlist_t **child;
uint_t children;
libzfs_handle_t *lzfs;
char *vname;
char *p;
char pool_name[MAXPATHLEN];
if (strncmp(arg, "/dev/zvol/dsk/", 14)) {
return (0);
}
arg += 14;
(void) strncpy(pool_name, arg, MAXPATHLEN);
if ((p = strchr(pool_name, '/')) != NULL)
*p = '\0';
STRCPYLIM(new_cc.cf_fs, p + 1, "statefile path");
if ((lzfs = libzfs_init()) == NULL) {
mesg(MERR, "failed to initialize ZFS library\n");
return (-1);
}
if ((zpool_handle = zpool_open(lzfs, pool_name)) == NULL) {
mesg(MERR, "couldn't open pool '%s'\n", pool_name);
libzfs_fini(lzfs);
return (-1);
}
config = zpool_get_config(zpool_handle, NULL);
if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
&nvroot) != 0) {
zpool_close(zpool_handle);
libzfs_fini(lzfs);
return (-1);
}
verify(nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN,
&child, &children) == 0);
if (children != 1) {
mesg(MERR, "expected one vdev, got %d\n", children);
zpool_close(zpool_handle);
libzfs_fini(lzfs);
return (-1);
}
vname = zpool_vdev_name(lzfs, zpool_handle, child[0], B_FALSE);
if (vname == NULL) {
mesg(MERR, "couldn't determine vdev name\n");
zpool_close(zpool_handle);
libzfs_fini(lzfs);
return (-1);
}
(void) strcpy(diskname, "/dev/dsk/");
(void) strcat(diskname, vname);
free(vname);
zpool_close(zpool_handle);
libzfs_fini(lzfs);
return (1);
}
示例8: zfsdle_vdev_online
static int
zfsdle_vdev_online(zpool_handle_t *zhp, void *data)
{
char *devname = data;
boolean_t avail_spare, l2cache;
vdev_state_t newstate;
nvlist_t *tgt;
zed_log_msg(LOG_INFO, "zfsdle_vdev_online: searching for '%s' in '%s'",
devname, zpool_get_name(zhp));
if ((tgt = zpool_find_vdev_by_physpath(zhp, devname,
&avail_spare, &l2cache, NULL)) != NULL) {
char *path, fullpath[MAXPATHLEN];
uint64_t wholedisk = 0ULL;
verify(nvlist_lookup_string(tgt, ZPOOL_CONFIG_PATH,
&path) == 0);
verify(nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_WHOLE_DISK,
&wholedisk) == 0);
(void) strlcpy(fullpath, path, sizeof (fullpath));
if (wholedisk) {
char *spath = zfs_strip_partition(fullpath);
if (!spath) {
zed_log_msg(LOG_INFO, "%s: Can't alloc",
__func__);
return (0);
}
(void) strlcpy(fullpath, spath, sizeof (fullpath));
free(spath);
/*
* We need to reopen the pool associated with this
* device so that the kernel can update the size
* of the expanded device.
*/
(void) zpool_reopen(zhp);
}
if (zpool_get_prop_int(zhp, ZPOOL_PROP_AUTOEXPAND, NULL)) {
zed_log_msg(LOG_INFO, "zfsdle_vdev_online: setting "
"device '%s' to ONLINE state in pool '%s'",
fullpath, zpool_get_name(zhp));
if (zpool_get_state(zhp) != POOL_STATE_UNAVAIL)
(void) zpool_vdev_online(zhp, fullpath, 0,
&newstate);
}
zpool_close(zhp);
return (1);
}
zpool_close(zhp);
return (0);
}
示例9: zfs_mark_pool
/*ARGSUSED*/
static int
zfs_mark_pool(zpool_handle_t *zhp, void *unused)
{
zfs_case_t *zcp;
uint64_t pool_guid;
uint64_t *tod;
er_timeval_t loaded = { 0 };
nvlist_t *config, *vd;
uint_t nelem = 0;
int ret;
pool_guid = zpool_get_prop_int(zhp, ZPOOL_PROP_GUID, NULL);
/*
* Mark any cases associated with just this pool.
*/
for (zcp = uu_list_first(zfs_cases); zcp != NULL;
zcp = uu_list_next(zfs_cases, zcp)) {
if (zcp->zc_data.zc_pool_guid == pool_guid &&
zcp->zc_data.zc_vdev_guid == 0)
zcp->zc_present = B_TRUE;
}
if ((config = zpool_get_config(zhp, NULL)) == NULL) {
zpool_close(zhp);
return (-1);
}
(void) nvlist_lookup_uint64_array(config, ZPOOL_CONFIG_LOADED_TIME,
&tod, &nelem);
if (nelem == 2) {
loaded.ertv_sec = tod[0];
loaded.ertv_nsec = tod[1];
for (zcp = uu_list_first(zfs_cases); zcp != NULL;
zcp = uu_list_next(zfs_cases, zcp)) {
if (zcp->zc_data.zc_pool_guid == pool_guid &&
zcp->zc_data.zc_vdev_guid == 0) {
zcp->zc_when = loaded;
}
}
}
ret = nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &vd);
if (ret) {
zpool_close(zhp);
return (-1);
}
zfs_mark_vdev(pool_guid, vd, &loaded);
zpool_close(zhp);
return (0);
}
示例10: name_or_guid_exists
static int
name_or_guid_exists(zpool_handle_t *zhp, void *data)
{
importargs_t *import = data;
int found = 0;
if (import->poolname != NULL) {
char *pool_name;
verify(nvlist_lookup_string(zhp->zpool_config,
ZPOOL_CONFIG_POOL_NAME, &pool_name) == 0);
if (strcmp(pool_name, import->poolname) == 0)
found = 1;
} else {
uint64_t pool_guid;
verify(nvlist_lookup_uint64(zhp->zpool_config,
ZPOOL_CONFIG_POOL_GUID, &pool_guid) == 0);
if (pool_guid == import->guid)
found = 1;
}
zpool_close(zhp);
return (found);
}
示例11: find_aux
static int
find_aux(zpool_handle_t *zhp, void *data)
{
aux_cbdata_t *cbp = data;
nvlist_t **list;
uint_t i, count;
uint64_t guid;
nvlist_t *nvroot;
verify(nvlist_lookup_nvlist(zhp->zpool_config, ZPOOL_CONFIG_VDEV_TREE,
&nvroot) == 0);
if (nvlist_lookup_nvlist_array(nvroot, cbp->cb_type,
&list, &count) == 0) {
for (i = 0; i < count; i++) {
verify(nvlist_lookup_uint64(list[i],
ZPOOL_CONFIG_GUID, &guid) == 0);
if (guid == cbp->cb_guid) {
cbp->cb_zhp = zhp;
return (1);
}
}
}
zpool_close(zhp);
return (0);
}
示例12: zpool_find_load_time
static int
zpool_find_load_time(zpool_handle_t *zhp, void *arg)
{
struct load_time_arg *lta = arg;
uint64_t pool_guid;
uint64_t *tod;
nvlist_t *config;
uint_t nelem;
if (lta->lt_found)
return (0);
pool_guid = zpool_get_prop_int(zhp, ZPOOL_PROP_GUID, NULL);
if (pool_guid != lta->lt_guid)
return (0);
if ((config = zpool_get_config(zhp, NULL)) == NULL) {
zpool_close(zhp);
return (-1);
}
if (nvlist_lookup_uint64_array(config, ZPOOL_CONFIG_LOADED_TIME,
&tod, &nelem) == 0 && nelem == 2) {
lta->lt_found = B_TRUE;
lta->lt_time->ertv_sec = tod[0];
lta->lt_time->ertv_nsec = tod[1];
}
return (0);
}
示例13: zfs_enable_ds
void
zfs_enable_ds(void *arg)
{
unavailpool_t *pool = (unavailpool_t *)arg;
(void) zpool_enable_datasets(pool->uap_zhp, NULL, 0);
zpool_close(pool->uap_zhp);
free(pool);
}
示例14: pool_list_remove
/*
* Remove the given pool from the list. When running iostat, we want to remove
* those pools that no longer exist.
*/
void
pool_list_remove(zpool_list_t *zlp, zpool_handle_t *zhp)
{
zpool_node_t search, *node;
search.zn_handle = zhp;
if ((node = uu_avl_find(zlp->zl_avl, &search, NULL, NULL)) != NULL) {
uu_avl_remove(zlp->zl_avl, node);
zpool_close(node->zn_handle);
free(node);
}
}
示例15: find_pool
static int
find_pool(zpool_handle_t *zhp, void *data)
{
find_cbdata_t *cbp = data;
if (cbp->cb_guid == zpool_get_guid(zhp)) {
cbp->cb_zhp = zhp;
return (1);
}
zpool_close(zhp);
return (0);
}