Skip to content

Commit a05263b

Browse files
authored
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 #14653
1 parent 0ad5f43 commit a05263b

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
@@ -5393,13 +5393,15 @@ spa_add_spares(spa_t *spa, nvlist_t *config)
53935393
for (i = 0; i < nspares; i++) {
53945394
guid = fnvlist_lookup_uint64(spares[i],
53955395
ZPOOL_CONFIG_GUID);
5396+
VERIFY0(nvlist_lookup_uint64_array(spares[i],
5397+
ZPOOL_CONFIG_VDEV_STATS, (uint64_t **)&vs, &vsc));
53965398
if (spa_spare_exists(guid, &pool, NULL) &&
53975399
pool != 0ULL) {
5398-
VERIFY0(nvlist_lookup_uint64_array(spares[i],
5399-
ZPOOL_CONFIG_VDEV_STATS, (uint64_t **)&vs,
5400-
&vsc));
54015400
vs->vs_state = VDEV_STATE_CANT_OPEN;
54025401
vs->vs_aux = VDEV_AUX_SPARED;
5402+
} else {
5403+
vs->vs_state =
5404+
spa->spa_spares.sav_vdevs[i]->vdev_state;
54035405
}
54045406
}
54055407
}

0 commit comments

Comments
 (0)