text stringlengths 0 14.1k |
|---|
return (zfs_error(hdl, EZFS_SCRUBBING, msg)); |
else |
return (zfs_error(hdl, EZFS_RESILVERING, msg)); |
} else if (errno == ENOENT) { |
return (zfs_error(hdl, EZFS_NO_SCRUB, msg)); |
} else { |
return (zpool_standard_error(hdl, errno, msg)); |
} |
} |
/* |
* Find a vdev that matches the search criteria specified. We use the |
* the nvpair name to determine how we should look for the device. |
* 'avail_spare' is set to TRUE if the provided guid refers to an AVAIL |
* spare; but FALSE if its an INUSE spare. |
*/ |
static nvlist_t * |
vdev_to_nvlist_iter(nvlist_t *nv, nvlist_t *search, boolean_t *avail_spare, |
boolean_t *l2cache, boolean_t *log) |
{ |
uint_t c, children; |
nvlist_t **child; |
nvlist_t *ret; |
uint64_t is_log; |
char *srchkey; |
nvpair_t *pair = nvlist_next_nvpair(search, NULL); |
/* Nothing to look for */ |
if (search == NULL || pair == NULL) |
return (NULL); |
/* Obtain the key we will use to search */ |
srchkey = nvpair_name(pair); |
switch (nvpair_type(pair)) { |
case DATA_TYPE_UINT64: { |
uint64_t srchval, theguid, present; |
verify(nvpair_value_uint64(pair, &srchval) == 0); |
if (strcmp(srchkey, ZPOOL_CONFIG_GUID) == 0) { |
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NOT_PRESENT, |
&present) == 0) { |
/* |
* If the device has never been present since |
* import, the only reliable way to match the |
* vdev is by GUID. |
*/ |
verify(nvlist_lookup_uint64(nv, |
ZPOOL_CONFIG_GUID, &theguid) == 0); |
if (theguid == srchval) |
return (nv); |
} |
} |
break; |
} |
case DATA_TYPE_STRING: { |
char *srchval, *val; |
verify(nvpair_value_string(pair, &srchval) == 0); |
if (nvlist_lookup_string(nv, srchkey, &val) != 0) |
break; |
/* |
* Search for the requested value. We special case the search |
* for ZPOOL_CONFIG_PATH when it's a wholedisk and when |
* Looking for a top-level vdev name (i.e. ZPOOL_CONFIG_TYPE). |
* Otherwise, all other searches are simple string compares. |
*/ |
if (strcmp(srchkey, ZPOOL_CONFIG_PATH) == 0 && val) { |
uint64_t wholedisk = 0; |
(void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_WHOLE_DISK, |
&wholedisk); |
if (wholedisk) { |
/* |
* For whole disks, the internal path has 's0', |
* but the path passed in by the user doesn't. |
*/ |
if (strlen(srchval) == strlen(val) - 2 && |
strncmp(srchval, val, strlen(srchval)) == 0) |
return (nv); |
break; |
} |
} else if (strcmp(srchkey, ZPOOL_CONFIG_TYPE) == 0 && val) { |
char *type, *idx, *end, *p; |
uint64_t id, vdev_id; |
/* |
* Determine our vdev type, keeping in mind |
* that the srchval is composed of a type and |
* vdev id pair (i.e. mirror-4). |
*/ |
if ((type = strdup(srchval)) == NULL) |
return (NULL); |
if ((p = strrchr(type, '-')) == NULL) { |
free(type); |
break; |
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.