text stringlengths 0 14.1k |
|---|
(void) zfs_error(zhp->zpool_hdl, EZFS_BADTARGET, msg); |
break; |
case EBUSY: |
/* |
* There are no other replicas of this device. |
*/ |
(void) zfs_error(hdl, EZFS_NOREPLICAS, msg); |
break; |
default: |
(void) zpool_standard_error(hdl, errno, msg); |
} |
return (-1); |
} |
/* |
* Find a mirror vdev in the source nvlist. |
* |
* The mchild array contains a list of disks in one of the top-level mirrors |
* of the source pool. The schild array contains a list of disks that the |
* user specified on the command line. We loop over the mchild array to |
* see if any entry in the schild array matches. |
* |
* If a disk in the mchild array is found in the schild array, we return |
* the index of that entry. Otherwise we return -1. |
*/ |
static int |
find_vdev_entry(zpool_handle_t *zhp, nvlist_t **mchild, uint_t mchildren, |
nvlist_t **schild, uint_t schildren) |
{ |
uint_t mc; |
for (mc = 0; mc < mchildren; mc++) { |
uint_t sc; |
char *mpath = zpool_vdev_name(zhp->zpool_hdl, zhp, |
mchild[mc], B_FALSE); |
for (sc = 0; sc < schildren; sc++) { |
char *spath = zpool_vdev_name(zhp->zpool_hdl, zhp, |
schild[sc], B_FALSE); |
boolean_t result = (strcmp(mpath, spath) == 0); |
free(spath); |
if (result) { |
free(mpath); |
return (mc); |
} |
} |
free(mpath); |
} |
return (-1); |
} |
/* |
* Split a mirror pool. If newroot points to null, then a new nvlist |
* is generated and it is the responsibility of the caller to free it. |
*/ |
int |
zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot, |
nvlist_t *props, splitflags_t flags) |
{ |
zfs_cmd_t zc = { 0 }; |
char msg[1024]; |
nvlist_t *tree, *config, **child, **newchild, *newconfig = NULL; |
nvlist_t **varray = NULL, *zc_props = NULL; |
uint_t c, children, newchildren, lastlog = 0, vcount, found = 0; |
libzfs_handle_t *hdl = zhp->zpool_hdl; |
uint64_t vers; |
boolean_t freelist = B_FALSE, memory_err = B_TRUE; |
int retval = 0; |
(void) snprintf(msg, sizeof (msg), |
dgettext(TEXT_DOMAIN, ""Unable to split %s""), zhp->zpool_name); |
if (!zpool_name_valid(hdl, B_FALSE, newname)) |
return (zfs_error(hdl, EZFS_INVALIDNAME, msg)); |
if ((config = zpool_get_config(zhp, NULL)) == NULL) { |
(void) fprintf(stderr, gettext(""Internal error: unable to "" |
""retrieve pool configuration\n"")); |
return (-1); |
} |
verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &tree) |
== 0); |
verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, &vers) == 0); |
if (props) { |
if ((zc_props = zpool_valid_proplist(hdl, zhp->zpool_name, |
props, vers, B_TRUE, msg)) == NULL) |
return (-1); |
} |
if (nvlist_lookup_nvlist_array(tree, ZPOOL_CONFIG_CHILDREN, &child, |
&children) != 0) { |
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.