summaryrefslogtreecommitdiffstats
path: root/cddl/contrib
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2014-09-25 21:45:07 +0000
committerdelphij <delphij@FreeBSD.org>2014-09-25 21:45:07 +0000
commitfae039850785bc539ef28235b8e2c3143d9b34d3 (patch)
treef5c76526406ada28b5aa84c2fee27b7e5d5732c8 /cddl/contrib
parent085d517a22c1dbea65c98e89da7876d7fefb0ded (diff)
downloadFreeBSD-src-fae039850785bc539ef28235b8e2c3143d9b34d3.zip
FreeBSD-src-fae039850785bc539ef28235b8e2c3143d9b34d3.tar.gz
MFC r271227: MFV r271225:
Iterate through all the children instead of returning error when we hit the first error. This makes the error message give more information rather than just the first device that causes problem. Illumos issue: 5118 When verifying or creating a storage pool, error messages only show one device Approved by: re (gjb)
Diffstat (limited to 'cddl/contrib')
-rw-r--r--cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c
index 374798b..a7747f6 100644
--- a/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c
+++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/*
@@ -1068,8 +1069,8 @@ is_spare(nvlist_t *config, const char *path)
* Go through and find any devices that are in use. We rely on libdiskmgt for
* the majority of this task.
*/
-static int
-check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force,
+static boolean_t
+is_device_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force,
boolean_t replacing, boolean_t isspare)
{
nvlist_t **child;
@@ -1078,6 +1079,7 @@ check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force,
int ret;
char buf[MAXPATHLEN];
uint64_t wholedisk;
+ boolean_t anyinuse = B_FALSE;
verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) == 0);
@@ -1102,38 +1104,37 @@ check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force,
(void) strlcpy(buf, path, sizeof (buf));
if (is_spare(config, buf))
- return (0);
+ return (B_FALSE);
}
if (strcmp(type, VDEV_TYPE_DISK) == 0)
ret = check_device(path, force, isspare);
-
- if (strcmp(type, VDEV_TYPE_FILE) == 0)
+ else if (strcmp(type, VDEV_TYPE_FILE) == 0)
ret = check_file(path, force, isspare);
- return (ret);
+ return (ret != 0);
}
for (c = 0; c < children; c++)
- if ((ret = check_in_use(config, child[c], force,
- replacing, B_FALSE)) != 0)
- return (ret);
+ if (is_device_in_use(config, child[c], force, replacing,
+ B_FALSE))
+ anyinuse = B_TRUE;
if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_SPARES,
&child, &children) == 0)
for (c = 0; c < children; c++)
- if ((ret = check_in_use(config, child[c], force,
- replacing, B_TRUE)) != 0)
- return (ret);
+ if (is_device_in_use(config, child[c], force, replacing,
+ B_TRUE))
+ anyinuse = B_TRUE;
if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_L2CACHE,
&child, &children) == 0)
for (c = 0; c < children; c++)
- if ((ret = check_in_use(config, child[c], force,
- replacing, B_FALSE)) != 0)
- return (ret);
+ if (is_device_in_use(config, child[c], force, replacing,
+ B_FALSE))
+ anyinuse = B_TRUE;
- return (0);
+ return (anyinuse);
}
static const char *
@@ -1487,7 +1488,7 @@ make_root_vdev(zpool_handle_t *zhp, int force, int check_rep,
* uses (such as a dedicated dump device) that even '-f' cannot
* override.
*/
- if (check_in_use(poolconfig, newroot, force, replacing, B_FALSE) != 0) {
+ if (is_device_in_use(poolconfig, newroot, force, replacing, B_FALSE)) {
nvlist_free(newroot);
return (NULL);
}
OpenPOWER on IntegriCloud