Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Mar 2018 04:02:51 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r330735 - stable/10/cddl/contrib/opensolaris/cmd/zpool
Message-ID:  <201803100402.w2A42pVA029892@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Sat Mar 10 04:02:51 2018
New Revision: 330735
URL: https://svnweb.freebsd.org/changeset/base/330735

Log:
  MFC r329067:
  
  Fix "zpool add" crash when a replacing vdev has a spare child
  
  Fix an assertion in zpool that causes a crash when running any "zpool add"
  command on a spare that contains a replacing vdev with a spare child.
  
  This likely affects Illumos, too.
  
  PR:		225546
  Sponsored by:	Spectra Logic Corp
  Differential Revision:	https://reviews.freebsd.org/D14138

Modified:
  stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c
==============================================================================
--- stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c	Sat Mar 10 03:39:49 2018	(r330734)
+++ stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c	Sat Mar 10 04:02:51 2018	(r330735)
@@ -684,6 +684,21 @@ get_replication(nvlist_t *nvroot, boolean_t fatal)
 					verify(nvlist_lookup_string(cnv,
 					    ZPOOL_CONFIG_TYPE,
 					    &childtype) == 0);
+					if (strcmp(childtype,
+					    VDEV_TYPE_SPARE) == 0) {
+						/* We have a replacing vdev with
+						 * a spare child.  Get the first
+						 * real child of the spare
+						 */
+						verify(
+						    nvlist_lookup_nvlist_array(
+							cnv,
+							ZPOOL_CONFIG_CHILDREN,
+							&rchild,
+						    &rchildren) == 0);
+						assert(rchildren >= 2);
+						cnv = rchild[0];
+					}
 				}
 
 				verify(nvlist_lookup_string(cnv,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803100402.w2A42pVA029892>