Skip to content

Commit 008c966

Browse files
authored
Set spa_final_txg in spa_unload()
I've noticed that after some dedup tests system reboot ends up in assertion about ms_defer tree not free. It seems to be caused by DDT flushing still freeing some blocks while ZFS trying to reach a final steady state due to spa_final_txg, while being set by spa_export_common() on pool export, is not set when spa_unload() is called by spa_evict_all() on system reboot/shutdown. Setting spa_final_txg in spa_unload() fixes this issue. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Rob Norris <[email protected]> Reviewed-by: Paul Dagnelie <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes #17395
1 parent f5a6dd8 commit 008c966

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

module/zfs/spa.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,7 @@ spa_activate(spa_t *spa, spa_mode_t mode)
16831683
ASSERT(spa->spa_state == POOL_STATE_UNINITIALIZED);
16841684

16851685
spa->spa_state = POOL_STATE_ACTIVE;
1686+
spa->spa_final_txg = UINT64_MAX;
16861687
spa->spa_mode = mode;
16871688
spa->spa_read_spacemaps = spa_mode_readable_spacemaps;
16881689

@@ -2085,6 +2086,11 @@ spa_unload(spa_t *spa)
20852086
vdev_rebuild_stop_all(spa);
20862087
l2arc_spa_rebuild_stop(spa);
20872088
}
2089+
2090+
spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
2091+
spa->spa_final_txg = spa_last_synced_txg(spa) +
2092+
TXG_DEFER_SIZE + 1;
2093+
spa_config_exit(spa, SCL_ALL, FTAG);
20882094
}
20892095

20902096
/*

0 commit comments

Comments
 (0)