ddt prune: Add SCL_ZIO deadlock workaround

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Signed-off-by: Igor Ostapenko <igor.ostapenko@klarasystems.com>
Closes #17793
This commit is contained in:
Igor Ostapenko 2025-09-29 10:58:52 +00:00 committed by Tony Hutter
parent 01180a63bd
commit b9d1e28a71

View File

@ -4574,8 +4574,29 @@ zio_vdev_io_start(zio_t *zio)
ASSERT0(zio->io_child_error[ZIO_CHILD_VDEV]);
if (vd == NULL) {
if (!(zio->io_flags & ZIO_FLAG_CONFIG_WRITER))
spa_config_enter(spa, SCL_ZIO, zio, RW_READER);
if (!(zio->io_flags & ZIO_FLAG_CONFIG_WRITER)) {
/*
* A deadlock workaround. The ddt_prune_unique_entries()
* -> prune_candidates_sync() code path takes the
* SCL_ZIO reader lock and may request it again here.
* If there is another thread who wants the SCL_ZIO
* writer lock, then scl_write_wanted will be set.
* Thus, the spa_config_enter_priority() is used to
* ignore pending writer requests.
*
* The locking should be revised to remove the need
* for this workaround. If that's not workable then
* it should only be applied to the zios involved in
* the pruning process. This impacts the read/write
* I/O balance while pruning.
*/
if (spa->spa_active_ddt_prune)
spa_config_enter_priority(spa, SCL_ZIO, zio,
RW_READER);
else
spa_config_enter(spa, SCL_ZIO, zio,
RW_READER);
}
/*
* The mirror_ops handle multiple DVAs in a single BP.