text stringlengths 0 14.1k |
|---|
/* |
* If we're just doing a dry run, exit now with success. |
*/ |
if (flags.dryrun) { |
memory_err = B_FALSE; |
freelist = B_FALSE; |
goto out; |
} |
/* now build up the config list & call the ioctl */ |
if (nvlist_alloc(&newconfig, NV_UNIQUE_NAME, 0) != 0) |
goto out; |
if (nvlist_add_nvlist(newconfig, |
ZPOOL_CONFIG_VDEV_TREE, *newroot) != 0 || |
nvlist_add_string(newconfig, |
ZPOOL_CONFIG_POOL_NAME, newname) != 0 || |
nvlist_add_uint64(newconfig, ZPOOL_CONFIG_VERSION, vers) != 0) |
goto out; |
/* |
* The new pool is automatically part of the namespace unless we |
* explicitly export it. |
*/ |
if (!flags.import) |
zc.zc_cookie = ZPOOL_EXPORT_AFTER_SPLIT; |
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); |
(void) strlcpy(zc.zc_string, newname, sizeof (zc.zc_string)); |
if (zcmd_write_conf_nvlist(hdl, &zc, newconfig) != 0) |
goto out; |
if (zc_props != NULL && zcmd_write_src_nvlist(hdl, &zc, zc_props) != 0) |
goto out; |
if (zfs_ioctl(hdl, ZFS_IOC_VDEV_SPLIT, &zc) != 0) { |
retval = zpool_standard_error(hdl, errno, msg); |
goto out; |
} |
freelist = B_FALSE; |
memory_err = B_FALSE; |
out: |
if (varray != NULL) { |
int v; |
for (v = 0; v < vcount; v++) |
nvlist_free(varray[v]); |
free(varray); |
} |
zcmd_free_nvlists(&zc); |
if (zc_props) |
nvlist_free(zc_props); |
if (newconfig) |
nvlist_free(newconfig); |
if (freelist) { |
nvlist_free(*newroot); |
*newroot = NULL; |
} |
if (retval != 0) |
return (retval); |
if (memory_err) |
return (no_memory(hdl)); |
return (0); |
} |
/* |
* Remove the given device. Currently, this is supported only for hot spares |
* and level 2 cache devices. |
*/ |
int |
zpool_vdev_remove(zpool_handle_t *zhp, const char *path) |
{ |
zfs_cmd_t zc = { 0 }; |
char msg[1024]; |
nvlist_t *tgt; |
boolean_t avail_spare, l2cache, islog; |
libzfs_handle_t *hdl = zhp->zpool_hdl; |
uint64_t version; |
(void) snprintf(msg, sizeof (msg), |
dgettext(TEXT_DOMAIN, ""cannot remove %s""), path); |
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); |
if ((tgt = zpool_find_vdev(zhp, path, &avail_spare, &l2cache, |
&islog)) == 0) |
return (zfs_error(hdl, EZFS_NODEVICE, msg)); |
/* |
* XXX - this should just go away. |
*/ |
if (!avail_spare && !l2cache && !islog) { |
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, |
""only inactive hot spares, cache, top-level, "" |
""or log devices can be removed"")); |
return (zfs_error(hdl, EZFS_NODEVICE, msg)); |
} |
version = zpool_get_prop_int(zhp, ZPOOL_PROP_VERSION, NULL); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.