Skip to content

Commit 97de9cb

Browse files
ixhamzatonyhutter
authored andcommitted
Update vdev state for spare vdev
zfsd fetches new pool configuration through ZFS_IOC_POOL_STATS but it does not get updated nvlist configuration for spare vdev since the configuration is read by spa_spares->sav_config. In this commit, updating the vdev state for spare vdev that is consumed by zfsd on spare disk hotplug. Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ameer Hamza <[email protected]> Closes openzfs#14653
1 parent 5219a26 commit 97de9cb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

module/zfs/spa.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5327,13 +5327,15 @@ spa_add_spares(spa_t *spa, nvlist_t *config)
53275327
for (i = 0; i < nspares; i++) {
53285328
guid = fnvlist_lookup_uint64(spares[i],
53295329
ZPOOL_CONFIG_GUID);
5330+
VERIFY0(nvlist_lookup_uint64_array(spares[i],
5331+
ZPOOL_CONFIG_VDEV_STATS, (uint64_t **)&vs, &vsc));
53305332
if (spa_spare_exists(guid, &pool, NULL) &&
53315333
pool != 0ULL) {
5332-
VERIFY0(nvlist_lookup_uint64_array(spares[i],
5333-
ZPOOL_CONFIG_VDEV_STATS, (uint64_t **)&vs,
5334-
&vsc));
53355334
vs->vs_state = VDEV_STATE_CANT_OPEN;
53365335
vs->vs_aux = VDEV_AUX_SPARED;
5336+
} else {
5337+
vs->vs_state =
5338+
spa->spa_spares.sav_vdevs[i]->vdev_state;
53375339
}
53385340
}
53395341
}

0 commit comments

Comments
 (0)