546 dprintf("txg=%llu quiesce_txg=%llu sync_txg=%llu\n",
547 txg, tx->tx_quiesce_txg_waiting,
548 tx->tx_sync_txg_waiting);
549 mutex_exit(&tx->tx_sync_lock);
550 txg_quiesce(dp, txg);
551 mutex_enter(&tx->tx_sync_lock);
552
553 /*
554 * Hand this txg off to the sync thread.
555 */
556 dprintf("quiesce done, handing off txg %llu\n", txg);
557 tx->tx_quiesced_txg = txg;
558 DTRACE_PROBE2(txg__quiesced, dsl_pool_t *, dp, uint64_t, txg);
559 cv_broadcast(&tx->tx_sync_more_cv);
560 cv_broadcast(&tx->tx_quiesce_done_cv);
561 }
562 }
563
564 /*
565 * Delay this thread by delay nanoseconds if we are still in the open
566 * transaction group and there is already a waiting txg quiesing or quiesced.
567 * Abort the delay if this txg stalls or enters the quiesing state.
568 */
569 void
570 txg_delay(dsl_pool_t *dp, uint64_t txg, hrtime_t delay, hrtime_t resolution)
571 {
572 tx_state_t *tx = &dp->dp_tx;
573 hrtime_t start = gethrtime();
574
575 /* don't delay if this txg could transition to quiesing immediately */
576 if (tx->tx_open_txg > txg ||
577 tx->tx_syncing_txg == txg-1 || tx->tx_synced_txg == txg-1)
578 return;
579
580 mutex_enter(&tx->tx_sync_lock);
581 if (tx->tx_open_txg > txg || tx->tx_synced_txg == txg-1) {
582 mutex_exit(&tx->tx_sync_lock);
583 return;
584 }
585
586 while (gethrtime() - start < delay &&
587 tx->tx_syncing_txg < txg-1 && !txg_stalled(dp)) {
588 (void) cv_timedwait_hires(&tx->tx_quiesce_more_cv,
589 &tx->tx_sync_lock, delay, resolution, 0);
590 }
591
592 mutex_exit(&tx->tx_sync_lock);
593 }
594
595 void
|
546 dprintf("txg=%llu quiesce_txg=%llu sync_txg=%llu\n",
547 txg, tx->tx_quiesce_txg_waiting,
548 tx->tx_sync_txg_waiting);
549 mutex_exit(&tx->tx_sync_lock);
550 txg_quiesce(dp, txg);
551 mutex_enter(&tx->tx_sync_lock);
552
553 /*
554 * Hand this txg off to the sync thread.
555 */
556 dprintf("quiesce done, handing off txg %llu\n", txg);
557 tx->tx_quiesced_txg = txg;
558 DTRACE_PROBE2(txg__quiesced, dsl_pool_t *, dp, uint64_t, txg);
559 cv_broadcast(&tx->tx_sync_more_cv);
560 cv_broadcast(&tx->tx_quiesce_done_cv);
561 }
562 }
563
564 /*
565 * Delay this thread by delay nanoseconds if we are still in the open
566 * transaction group and there is already a waiting txg quiescing or quiesced.
567 * Abort the delay if this txg stalls or enters the quiescing state.
568 */
569 void
570 txg_delay(dsl_pool_t *dp, uint64_t txg, hrtime_t delay, hrtime_t resolution)
571 {
572 tx_state_t *tx = &dp->dp_tx;
573 hrtime_t start = gethrtime();
574
575 /* don't delay if this txg could transition to quiescing immediately */
576 if (tx->tx_open_txg > txg ||
577 tx->tx_syncing_txg == txg-1 || tx->tx_synced_txg == txg-1)
578 return;
579
580 mutex_enter(&tx->tx_sync_lock);
581 if (tx->tx_open_txg > txg || tx->tx_synced_txg == txg-1) {
582 mutex_exit(&tx->tx_sync_lock);
583 return;
584 }
585
586 while (gethrtime() - start < delay &&
587 tx->tx_syncing_txg < txg-1 && !txg_stalled(dp)) {
588 (void) cv_timedwait_hires(&tx->tx_quiesce_more_cv,
589 &tx->tx_sync_lock, delay, resolution, 0);
590 }
591
592 mutex_exit(&tx->tx_sync_lock);
593 }
594
595 void
|