zed: Prevent special vdev to be replaced by hot spare

Special vdevs should not be replaced by a hot spare.
Log vdevs already support this, extending the
functionality for special vdevs.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Closes #14129
This commit is contained in:
Ameer Hamza 2022-11-04 23:33:47 +05:00 committed by Brian Behlendorf
parent cd1f023846
commit ca3a675c74
2 changed files with 9 additions and 2 deletions

View File

@ -6772,10 +6772,12 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing,
return (spa_vdev_exit(spa, newrootvd, txg, error)); return (spa_vdev_exit(spa, newrootvd, txg, error));
/* /*
* Spares can't replace logs * log, dedup and special vdevs should not be replaced by spares.
*/ */
if (oldvd->vdev_top->vdev_islog && newvd->vdev_isspare) if ((oldvd->vdev_top->vdev_alloc_bias != VDEV_BIAS_NONE ||
oldvd->vdev_top->vdev_islog) && newvd->vdev_isspare) {
return (spa_vdev_exit(spa, newrootvd, txg, ENOTSUP)); return (spa_vdev_exit(spa, newrootvd, txg, ENOTSUP));
}
/* /*
* A dRAID spare can only replace a child of its parent dRAID vdev. * A dRAID spare can only replace a child of its parent dRAID vdev.

View File

@ -123,6 +123,11 @@ done
# the removed data device # the removed data device
for conf in "${poolconfs[@]}" for conf in "${poolconfs[@]}"
do do
# special vdev can not be replaced by a hot spare
if [[ $conf = *"special mirror"* ]]; then
continue
fi
# 1. Create a pool with a spare # 1. Create a pool with a spare
log_must zpool create -f $TESTPOOL $conf log_must zpool create -f $TESTPOOL $conf
block_device_wait ${DEV_DSKDIR}/${removedev} block_device_wait ${DEV_DSKDIR}/${removedev}