Skip to content

Commit

Permalink
Fix overly broad locking in spa_vdev_config_exit()
Browse files Browse the repository at this point in the history
Calling vdev_free() only requires the we acquire the spa config
SCL_STATE_ALL locks, not the SCL_ALL locks.  In particular, we need
need to avoid taking the SCL_CONFIG lock (included in SCL_ALL) as a
writer since this can lead to a deadlock.  The txg_sync_thread() may
block in spa_txg_history_init_io() when taking the SCL_CONFIG lock
as a reading when it detects there's a pending writer.

Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #11585
  • Loading branch information
behlendorf committed May 20, 2021
1 parent ae7a428 commit ad2638b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions module/zfs/spa_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1274,9 +1274,9 @@ spa_vdev_config_exit(spa_t *spa, vdev_t *vd, uint64_t txg, int error, char *tag)
*/
vdev_autotrim_stop_wait(vd);

spa_config_enter(spa, SCL_ALL, spa, RW_WRITER);
spa_config_enter(spa, SCL_STATE_ALL, spa, RW_WRITER);
vdev_free(vd);
spa_config_exit(spa, SCL_ALL, spa);
spa_config_exit(spa, SCL_STATE_ALL, spa);
}

/*
Expand Down

0 comments on commit ad2638b

Please sign in to comment.