diff --git a/module/zfs/spa.c b/module/zfs/spa.c index bbb83fc610..6be6fe1156 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -9281,7 +9281,13 @@ spa_sync(spa_t *spa, uint64_t txg) * into config changes that go out with this transaction group. */ spa_config_enter(spa, SCL_STATE, FTAG, RW_READER); - while (list_head(&spa->spa_state_dirty_list) != NULL) { + while ((vd = list_head(&spa->spa_state_dirty_list)) != NULL) { + /* Avoid holding the write lock unless actually necessary */ + if (vd->vdev_aux == NULL) { + vdev_state_clean(vd); + vdev_config_dirty(vd); + continue; + } /* * We need the write lock here because, for aux vdevs, * calling vdev_config_dirty() modifies sav_config.