From abf6a03921cb02d3e2d583b4564f6af15789ec83 Mon Sep 17 00:00:00 2001 From: Will Andrews Date: Thu, 18 Sep 2014 14:02:25 +0000 Subject: [PATCH] Fix an assert to tolerate spare parents with more than 2 children. This can occur if a spare is being spared, which would yield three children: the original pool drive, the previous spare, and the spare that is replacing it. MFC after: 1 week Sponsored by: Spectra Logic Affects: All ZFS versions starting 7 Jun 2006 (illumos 94de1d4c) MFSpectraBSD: r668345 on 2013/06/04 17:10:43 --- cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c index a7747f67e7bb..e974b7519b02 100644 --- a/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c +++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c @@ -653,6 +653,7 @@ get_replication(nvlist_t *nvroot, boolean_t fatal) dontreport = 0; vdev_size = -1ULL; for (c = 0; c < children; c++) { + boolean_t is_replacing, is_spare; nvlist_t *cnv = child[c]; char *path; struct stat64 statbuf; @@ -669,16 +670,19 @@ get_replication(nvlist_t *nvroot, boolean_t fatal) * If this is a replacing or spare vdev, then * get the real first child of the vdev. */ - if (strcmp(childtype, - VDEV_TYPE_REPLACING) == 0 || - strcmp(childtype, VDEV_TYPE_SPARE) == 0) { + is_replacing = strcmp(childtype, + VDEV_TYPE_REPLACING) == 0; + is_spare = strcmp(childtype, + VDEV_TYPE_SPARE) == 0; + if (is_replacing || is_spare) { nvlist_t **rchild; uint_t rchildren; verify(nvlist_lookup_nvlist_array(cnv, ZPOOL_CONFIG_CHILDREN, &rchild, &rchildren) == 0); - assert(rchildren == 2); + assert((is_replacing && rchildren == 2) + || (is_spare && rchildren >= 2)); cnv = rchild[0]; verify(nvlist_lookup_string(cnv,