Skip to content

Commit 72b8210

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 2c7c89d commit 72b8210

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
@@ -1849,7 +1849,14 @@ spa_update_dspace(spa_t *spa)
18491849
spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER);
18501850
vdev_t *vd =
18511851
vdev_lookup_top(spa, spa->spa_vdev_removal->svr_vdev_id);
1852-
if (vd->vdev_mg->mg_class == spa_normal_class(spa)) {
1852+
/*
1853+
* If the stars align, we can wind up here after
1854+
* vdev_remove_complete() has cleared vd->vdev_mg but before
1855+
* spa->spa_vdev_removal gets cleared, so we must check before
1856+
* we dereference.
1857+
*/
1858+
if (vd->vdev_mg &&
1859+
vd->vdev_mg->mg_class == spa_normal_class(spa)) {
18531860
spa->spa_dspace -= spa_deflate(spa) ?
18541861
vd->vdev_stat.vs_dspace : vd->vdev_stat.vs_space;
18551862
}

0 commit comments

Comments
 (0)