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