From dda711dbb594dbe51eccf91feb961f5be04001a9 Mon Sep 17 00:00:00 2001 From: Paul Dagnelie Date: Wed, 5 Nov 2025 11:40:22 -0800 Subject: [PATCH] Fix gang write late_arrival bug When a write comes in via dmu_sync_late_arrival, its txg is equal to the open TXG. If that write gangs, and we have not yet activated the new gang header feature, and the gang header we pick can store a larger gang header, we will try to schedule the upgrade for the open TXG + 1. In debug mode, this causes an assertion to trip. This PR sets the TXG for activating the feature to be the larger of either the current open TXG or the syncing TXG + 1. Reviewed-by: Alexander Motin Reviewed-by: Brian Behlendorf Signed-off-by: Paul Dagnelie Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Closes #17824 --- module/zfs/zio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/zfs/zio.c b/module/zfs/zio.c index aeea58bed..4f3ecdc35 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -3318,8 +3318,8 @@ zio_write_gang_block(zio_t *pio, metaslab_class_t *mc) } else if (any_failed && candidate > SPA_OLD_GANGBLOCKSIZE && spa_feature_is_enabled(spa, SPA_FEATURE_DYNAMIC_GANG_HEADER) && !spa_feature_is_active(spa, SPA_FEATURE_DYNAMIC_GANG_HEADER)) { - dmu_tx_t *tx = - dmu_tx_create_assigned(spa->spa_dsl_pool, txg + 1); + dmu_tx_t *tx = dmu_tx_create_assigned(spa->spa_dsl_pool, + MAX(txg, spa_syncing_txg(spa) + 1)); dsl_sync_task_nowait(spa->spa_dsl_pool, zio_update_feature, (void *)SPA_FEATURE_DYNAMIC_GANG_HEADER, tx);