| 670 | } |
| 671 | |
| 672 | static boolean_t |
| 673 | txg_wait_synced_impl(dsl_pool_t *dp, uint64_t txg, boolean_t wait_sig) |
| 674 | { |
| 675 | tx_state_t *tx = &dp->dp_tx; |
| 676 | |
| 677 | ASSERT(!dsl_pool_config_held(dp)); |
| 678 | |
| 679 | mutex_enter(&tx->tx_sync_lock); |
| 680 | ASSERT3U(tx->tx_threads, ==, 2); |
| 681 | if (txg == 0) |
| 682 | txg = tx->tx_open_txg + TXG_DEFER_SIZE; |
| 683 | if (tx->tx_sync_txg_waiting < txg) |
| 684 | tx->tx_sync_txg_waiting = txg; |
| 685 | dprintf("txg=%llu quiesce_txg=%llu sync_txg=%llu\n", |
| 686 | txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting); |
| 687 | while (tx->tx_synced_txg < txg) { |
| 688 | dprintf("broadcasting sync more " |
| 689 | "tx_synced=%llu waiting=%llu dp=%px\n", |
| 690 | tx->tx_synced_txg, tx->tx_sync_txg_waiting, dp); |
| 691 | cv_broadcast(&tx->tx_sync_more_cv); |
| 692 | if (wait_sig) { |
| 693 | /* |
| 694 | * Condition wait here but stop if the thread receives a |
| 695 | * signal. The caller may call txg_wait_synced*() again |
| 696 | * to resume waiting for this txg. |
| 697 | */ |
| 698 | if (cv_wait_io_sig(&tx->tx_sync_done_cv, |
| 699 | &tx->tx_sync_lock) == 0) { |
| 700 | mutex_exit(&tx->tx_sync_lock); |
| 701 | return (B_TRUE); |
| 702 | } |
| 703 | } else { |
| 704 | cv_wait_io(&tx->tx_sync_done_cv, &tx->tx_sync_lock); |
| 705 | } |
| 706 | } |
| 707 | mutex_exit(&tx->tx_sync_lock); |
| 708 | return (B_FALSE); |
| 709 | } |
| 710 | |
| 711 | void |
| 712 | txg_wait_synced(dsl_pool_t *dp, uint64_t txg) |
no test coverage detected