From 0430f8daa551890e0788d3fd28aef3be44cf8730 Mon Sep 17 00:00:00 2001 From: eschrock Date: Fri, 4 Jul 2008 13:08:26 -0700 Subject: 6721901 uninitialized variable in zfs_fm_recv() can confuse diagnosis 6721906 probe failure should be ignored during pool open 6721920 cache device failure should not trigger pool I/O failure 6722096 ZFS DE case clearing logic for vdevs is busted 6722098 ZFS DE should avoid ereports against non-leaf vdevs 6722100 replacing a hot spare with an idle spare doesn't work --- usr/src/lib/libzfs/common/libzfs_pool.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'usr/src/lib/libzfs/common/libzfs_pool.c') diff --git a/usr/src/lib/libzfs/common/libzfs_pool.c b/usr/src/lib/libzfs/common/libzfs_pool.c index 639bae9a24..00df5ca616 100644 --- a/usr/src/lib/libzfs/common/libzfs_pool.c +++ b/usr/src/lib/libzfs/common/libzfs_pool.c @@ -1502,7 +1502,7 @@ zpool_vdev_attach(zpool_handle_t *zhp, nvlist_t *tgt; boolean_t avail_spare, l2cache; uint64_t val, is_log; - char *path; + char *path, *newname; nvlist_t **child; uint_t children; nvlist_t *config_root; @@ -1538,17 +1538,20 @@ zpool_vdev_attach(zpool_handle_t *zhp, verify(nvlist_lookup_nvlist(zpool_get_config(zhp, NULL), ZPOOL_CONFIG_VDEV_TREE, &config_root) == 0); + if ((newname = zpool_vdev_name(NULL, NULL, child[0])) == NULL) + return (-1); + /* * If the target is a hot spare that has been swapped in, we can only * replace it with another hot spare. */ if (replacing && nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_IS_SPARE, &val) == 0 && - nvlist_lookup_string(child[0], ZPOOL_CONFIG_PATH, &path) == 0 && - (zpool_find_vdev(zhp, path, &avail_spare, &l2cache) == NULL || + (zpool_find_vdev(zhp, newname, &avail_spare, &l2cache) == NULL || !avail_spare) && is_replacing_spare(config_root, tgt, 1)) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "can only be replaced by another hot spare")); + free(newname); return (zfs_error(hdl, EZFS_BADTARGET, msg)); } @@ -1558,13 +1561,16 @@ zpool_vdev_attach(zpool_handle_t *zhp, */ if (replacing && nvlist_lookup_string(child[0], ZPOOL_CONFIG_PATH, &path) == 0 && - zpool_find_vdev(zhp, path, &avail_spare, &l2cache) != NULL && + zpool_find_vdev(zhp, newname, &avail_spare, &l2cache) != NULL && avail_spare && is_replacing_spare(config_root, tgt, 0)) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "device has already been replaced with a spare")); + free(newname); return (zfs_error(hdl, EZFS_BADTARGET, msg)); } + free(newname); + if (zcmd_write_conf_nvlist(hdl, &zc, nvroot) != 0) return (-1); -- cgit v1.2.3