diff options
author | Basil Crow <[email protected]> | 2015-07-05 21:17:49 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2015-07-10 12:07:13 -0700 |
commit | de0a9d763075cc688d6cb75c94d62dde912ed669 (patch) | |
tree | 431858405642e7ef8f9217deb1f9a7b6cfa24ebd /cmd/zpool/zpool_vdev.c | |
parent | 3e43edd2c5b40d49bae9881566570a5fb7c2c181 (diff) |
Illumos 5118 - When verifying or creating a storage pool, error messages only show one device
5118 When verifying or creating a storage pool, error messages
only show one device
Reviewed by: Adam Leventhal <[email protected]>
Reviewed by: Dan Kimmel <[email protected]>
Reviewed by: Matt Ahrens <[email protected]>
Reviewed by: Boris Protopopov <[email protected]>
Approved by: Dan McDonald <[email protected]>
References:
https://github.com/illumos/illumos-gate/commit/75fbdf9
https://www.illumos.org/issues/5118
Ported-by: kernelOfTruth [email protected]
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #3567
Diffstat (limited to 'cmd/zpool/zpool_vdev.c')
-rw-r--r-- | cmd/zpool/zpool_vdev.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c index cae911426..cae20147b 100644 --- a/cmd/zpool/zpool_vdev.c +++ b/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. */ /* @@ -1289,8 +1290,8 @@ make_disks(zpool_handle_t *zhp, nvlist_t *nv) * 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; @@ -1299,6 +1300,7 @@ check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force, int ret = 0; char buf[MAXPATHLEN]; uint64_t wholedisk = B_FALSE; + boolean_t anyinuse = B_FALSE; verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) == 0); @@ -1324,38 +1326,38 @@ check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force, } if (is_spare(config, buf)) - return (0); + return (B_FALSE); } if (strcmp(type, VDEV_TYPE_DISK) == 0) ret = check_device(path, force, isspare, wholedisk); - 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 * @@ -1710,7 +1712,7 @@ make_root_vdev(zpool_handle_t *zhp, nvlist_t *props, 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); } |