Skip to content

Commit d753118

Browse files
rincebrainbehlendorf
authored andcommitted
Fix unfortunate NULL in spa_update_dspace
After 1325434, we can in certain circumstances end up calling spa_update_dspace with vd->vdev_mg NULL, which ends poorly during vdev removal. So let's not do that further space adjustment when we can't. Reviewed-by: Matthew Ahrens <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Rich Ercolani <[email protected]> Closes #12380 Closes #12428
1 parent 89d1d38 commit d753118

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

module/zfs/spa_misc.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,14 @@ spa_update_dspace(spa_t *spa)
18641864
spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER);
18651865
vdev_t *vd =
18661866
vdev_lookup_top(spa, spa->spa_vdev_removal->svr_vdev_id);
1867-
if (vd->vdev_mg->mg_class == spa_normal_class(spa)) {
1867+
/*
1868+
* If the stars align, we can wind up here after
1869+
* vdev_remove_complete() has cleared vd->vdev_mg but before
1870+
* spa->spa_vdev_removal gets cleared, so we must check before
1871+
* we dereference.
1872+
*/
1873+
if (vd->vdev_mg &&
1874+
vd->vdev_mg->mg_class == spa_normal_class(spa)) {
18681875
spa->spa_dspace -= spa_deflate(spa) ?
18691876
vd->vdev_stat.vs_dspace : vd->vdev_stat.vs_space;
18701877
}

0 commit comments

Comments
 (0)