diff options
author | asomers <asomers@FreeBSD.org> | 2018-03-10 03:04:48 +0000 |
---|---|---|
committer | asomers <asomers@FreeBSD.org> | 2018-03-10 03:04:48 +0000 |
commit | 3d560352dae13b4d6e831a10c11528fefcf02ae0 (patch) | |
tree | 418000837ff961d99c002cc7f316452c7a1c6d92 /cddl/contrib | |
parent | c9ede81c61b5d300b5acb89d4167b11f917be4c4 (diff) | |
download | FreeBSD-src-3d560352dae13b4d6e831a10c11528fefcf02ae0.zip FreeBSD-src-3d560352dae13b4d6e831a10c11528fefcf02ae0.tar.gz |
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
Diffstat (limited to 'cddl/contrib')
-rw-r--r-- | cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c index 9f98dbf..d860afc 100644 --- a/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c +++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c @@ -688,6 +688,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, |