Skip to content

Commit 0efe2f5

Browse files
author
Paul Dagnelie
committed
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 at most the current open TXG. Signed-off-by: Paul Dagnelie <[email protected]> Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc.
1 parent f8b082b commit 0efe2f5

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

include/sys/txg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ extern boolean_t txg_stalled(struct dsl_pool *dp);
137137

138138
/* returns TRUE if someone is waiting for the next txg to sync */
139139
extern boolean_t txg_sync_waiting(struct dsl_pool *dp);
140+
extern uint64_t txg_cur_open(struct dsl_pool *dp);
140141

141142
extern void txg_verify(spa_t *spa, uint64_t txg);
142143

module/zfs/txg.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,12 @@ txg_verify(spa_t *spa, uint64_t txg)
867867
}
868868
#endif
869869

870+
uint64_t
871+
txg_cur_open(dsl_pool_t *dp)
872+
{
873+
return (dp->dp_tx.tx_open_txg);
874+
}
875+
870876
/*
871877
* Per-txg object lists.
872878
*/

module/zfs/zio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3319,7 +3319,8 @@ zio_write_gang_block(zio_t *pio, metaslab_class_t *mc)
33193319
spa_feature_is_enabled(spa, SPA_FEATURE_DYNAMIC_GANG_HEADER) &&
33203320
!spa_feature_is_active(spa, SPA_FEATURE_DYNAMIC_GANG_HEADER)) {
33213321
dmu_tx_t *tx =
3322-
dmu_tx_create_assigned(spa->spa_dsl_pool, txg + 1);
3322+
dmu_tx_create_assigned(spa->spa_dsl_pool, MIN(txg + 1,
3323+
txg_cur_open(spa->spa_dsl_pool)));
33233324
dsl_sync_task_nowait(spa->spa_dsl_pool,
33243325
zio_update_feature,
33253326
(void *)SPA_FEATURE_DYNAMIC_GANG_HEADER, tx);

0 commit comments

Comments
 (0)