mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 02:44:41 +03:00
Check l2cache vdevs pending list inside the vdev_inuse()
The l2cache device could be added twice because vdev_inuse() does not check spa_l2cache for added devices. Make l2cache vdevs inuse checking logic more closer to spare vdevs. Reviewed-by: George Amanakis <gamanakis@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Fedor Uporov <fuporov.vstack@gmail.com> Closes #9153 Closes #12689
This commit is contained in:
+19
-4
@@ -933,7 +933,7 @@ vdev_inuse(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason,
|
||||
/*
|
||||
* Check to see if this is a spare device. We do an explicit check for
|
||||
* spa_has_spare() here because it may be on our pending list of spares
|
||||
* to add. We also check if it is an l2cache device.
|
||||
* to add.
|
||||
*/
|
||||
if (spa_spare_exists(device_guid, &spare_pool, NULL) ||
|
||||
spa_has_spare(spa, device_guid)) {
|
||||
@@ -942,7 +942,6 @@ vdev_inuse(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason,
|
||||
|
||||
switch (reason) {
|
||||
case VDEV_LABEL_CREATE:
|
||||
case VDEV_LABEL_L2CACHE:
|
||||
return (B_TRUE);
|
||||
|
||||
case VDEV_LABEL_REPLACE:
|
||||
@@ -959,8 +958,24 @@ vdev_inuse(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason,
|
||||
/*
|
||||
* Check to see if this is an l2cache device.
|
||||
*/
|
||||
if (spa_l2cache_exists(device_guid, NULL))
|
||||
return (B_TRUE);
|
||||
if (spa_l2cache_exists(device_guid, NULL) ||
|
||||
spa_has_l2cache(spa, device_guid)) {
|
||||
if (l2cache_guid)
|
||||
*l2cache_guid = device_guid;
|
||||
|
||||
switch (reason) {
|
||||
case VDEV_LABEL_CREATE:
|
||||
return (B_TRUE);
|
||||
|
||||
case VDEV_LABEL_REPLACE:
|
||||
return (!spa_has_l2cache(spa, device_guid));
|
||||
|
||||
case VDEV_LABEL_L2CACHE:
|
||||
return (spa_has_l2cache(spa, device_guid));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We can't rely on a pool's state if it's been imported
|
||||
|
||||
Reference in New Issue
Block a user