Lines Matching refs:tx

122 	tx_state_t *tx = &dp->dp_tx;
124 memset(tx, 0, sizeof (tx_state_t));
126 tx->tx_cpu = vmem_zalloc(max_ncpus * sizeof (tx_cpu_t), KM_SLEEP);
131 mutex_init(&tx->tx_cpu[c].tc_lock, NULL, MUTEX_DEFAULT, NULL);
132 mutex_init(&tx->tx_cpu[c].tc_open_lock, NULL, MUTEX_NOLOCKDEP,
135 cv_init(&tx->tx_cpu[c].tc_cv[i], NULL, CV_DEFAULT,
137 list_create(&tx->tx_cpu[c].tc_callbacks[i],
143 mutex_init(&tx->tx_sync_lock, NULL, MUTEX_DEFAULT, NULL);
145 cv_init(&tx->tx_sync_more_cv, NULL, CV_DEFAULT, NULL);
146 cv_init(&tx->tx_sync_done_cv, NULL, CV_DEFAULT, NULL);
147 cv_init(&tx->tx_quiesce_more_cv, NULL, CV_DEFAULT, NULL);
148 cv_init(&tx->tx_quiesce_done_cv, NULL, CV_DEFAULT, NULL);
149 cv_init(&tx->tx_exit_cv, NULL, CV_DEFAULT, NULL);
151 tx->tx_open_txg = txg;
160 tx_state_t *tx = &dp->dp_tx;
163 ASSERT0(tx->tx_threads);
165 mutex_destroy(&tx->tx_sync_lock);
167 cv_destroy(&tx->tx_sync_more_cv);
168 cv_destroy(&tx->tx_sync_done_cv);
169 cv_destroy(&tx->tx_quiesce_more_cv);
170 cv_destroy(&tx->tx_quiesce_done_cv);
171 cv_destroy(&tx->tx_exit_cv);
176 mutex_destroy(&tx->tx_cpu[c].tc_open_lock);
177 mutex_destroy(&tx->tx_cpu[c].tc_lock);
179 cv_destroy(&tx->tx_cpu[c].tc_cv[i]);
180 list_destroy(&tx->tx_cpu[c].tc_callbacks[i]);
184 if (tx->tx_commit_cb_taskq != NULL)
185 taskq_destroy(tx->tx_commit_cb_taskq);
187 vmem_free(tx->tx_cpu, max_ncpus * sizeof (tx_cpu_t));
189 memset(tx, 0, sizeof (tx_state_t));
198 tx_state_t *tx = &dp->dp_tx;
200 mutex_enter(&tx->tx_sync_lock);
204 ASSERT0(tx->tx_threads);
206 tx->tx_threads = 2;
208 tx->tx_quiesce_thread = thread_create(NULL, 0, txg_quiesce_thread,
216 tx->tx_sync_thread = thread_create(NULL, 0, txg_sync_thread,
219 mutex_exit(&tx->tx_sync_lock);
223 txg_thread_enter(tx_state_t *tx, callb_cpr_t *cpr)
225 CALLB_CPR_INIT(cpr, &tx->tx_sync_lock, callb_generic_cpr, FTAG);
226 mutex_enter(&tx->tx_sync_lock);
230 txg_thread_exit(tx_state_t *tx, callb_cpr_t *cpr, kthread_t **tpp)
234 tx->tx_threads--;
235 cv_broadcast(&tx->tx_exit_cv);
236 CALLB_CPR_EXIT(cpr); /* drops &tx->tx_sync_lock */
241 txg_thread_wait(tx_state_t *tx, callb_cpr_t *cpr, kcondvar_t *cv, clock_t time)
246 (void) cv_timedwait_idle(cv, &tx->tx_sync_lock,
249 cv_wait_idle(cv, &tx->tx_sync_lock);
252 CALLB_CPR_SAFE_END(cpr, &tx->tx_sync_lock);
261 tx_state_t *tx = &dp->dp_tx;
267 ASSERT3U(tx->tx_threads, ==, 2);
272 txg_wait_synced(dp, tx->tx_open_txg + TXG_DEFER_SIZE);
277 mutex_enter(&tx->tx_sync_lock);
279 ASSERT3U(tx->tx_threads, ==, 2);
281 tx->tx_exiting = 1;
283 cv_broadcast(&tx->tx_quiesce_more_cv);
284 cv_broadcast(&tx->tx_quiesce_done_cv);
285 cv_broadcast(&tx->tx_sync_more_cv);
287 while (tx->tx_threads != 0)
288 cv_wait(&tx->tx_exit_cv, &tx->tx_sync_lock);
290 tx->tx_exiting = 0;
292 mutex_exit(&tx->tx_sync_lock);
319 tx_state_t *tx = &dp->dp_tx;
329 tc = &tx->tx_cpu[CPU_SEQID_UNSTABLE];
332 txg = tx->tx_open_txg;
388 tx_state_t *tx = &dp->dp_tx;
397 mutex_enter(&tx->tx_cpu[c].tc_open_lock);
399 ASSERT(txg == tx->tx_open_txg);
400 tx->tx_open_txg++;
401 tx->tx_open_time = tx_open_time = gethrtime();
404 DTRACE_PROBE2(txg__opened, dsl_pool_t *, dp, uint64_t, tx->tx_open_txg);
411 mutex_exit(&tx->tx_cpu[c].tc_open_lock);
421 tx_cpu_t *tc = &tx->tx_cpu[c];
451 tx_state_t *tx = &dp->dp_tx;
455 tx_cpu_t *tc = &tx->tx_cpu[c];
466 if (tx->tx_commit_cb_taskq == NULL) {
470 tx->tx_commit_cb_taskq = taskq_create("tx_commit_cb",
482 (void) taskq_dispatch(tx->tx_commit_cb_taskq,
495 tx_state_t *tx = &dp->dp_tx;
497 if (tx->tx_commit_cb_taskq != NULL)
498 taskq_wait_outstanding(tx->tx_commit_cb_taskq, 0);
504 tx_state_t *tx = &dp->dp_tx;
505 ASSERT(MUTEX_HELD(&tx->tx_sync_lock));
506 return (tx->tx_quiescing_txg != 0);
512 tx_state_t *tx = &dp->dp_tx;
513 ASSERT(MUTEX_HELD(&tx->tx_sync_lock));
514 return (tx->tx_quiesced_txg != 0);
522 tx_state_t *tx = &dp->dp_tx;
527 txg_thread_enter(tx, &cpr);
542 !tx->tx_exiting && timer > 0 &&
543 tx->tx_synced_txg >= tx->tx_sync_txg_waiting &&
546 (u_longlong_t)tx->tx_synced_txg,
547 (u_longlong_t)tx->tx_sync_txg_waiting, dp);
548 txg_thread_wait(tx, &cpr, &tx->tx_sync_more_cv, timer);
566 while (!tx->tx_exiting && !txg_has_quiesced_to_sync(dp)) {
568 txg_thread_wait(tx, &cpr,
569 &tx->tx_quiesce_done_cv, 0);
572 if (tx->tx_quiesce_txg_waiting < tx->tx_open_txg+1)
573 tx->tx_quiesce_txg_waiting = tx->tx_open_txg+1;
574 cv_broadcast(&tx->tx_quiesce_more_cv);
575 txg_thread_wait(tx, &cpr, &tx->tx_quiesce_done_cv, 0);
578 if (tx->tx_exiting)
579 txg_thread_exit(tx, &cpr, &tx->tx_sync_thread);
586 ASSERT(tx->tx_quiesced_txg != 0);
587 txg = tx->tx_quiesced_txg;
588 tx->tx_quiesced_txg = 0;
589 tx->tx_syncing_txg = txg;
591 cv_broadcast(&tx->tx_quiesce_more_cv);
594 (u_longlong_t)txg, (u_longlong_t)tx->tx_quiesce_txg_waiting,
595 (u_longlong_t)tx->tx_sync_txg_waiting);
596 mutex_exit(&tx->tx_sync_lock);
604 mutex_enter(&tx->tx_sync_lock);
605 tx->tx_synced_txg = txg;
606 tx->tx_syncing_txg = 0;
608 cv_broadcast(&tx->tx_sync_done_cv);
621 tx_state_t *tx = &dp->dp_tx;
624 txg_thread_enter(tx, &cpr);
636 while (!tx->tx_exiting &&
637 (tx->tx_open_txg >= tx->tx_quiesce_txg_waiting ||
639 txg_thread_wait(tx, &cpr, &tx->tx_quiesce_more_cv, 0);
641 if (tx->tx_exiting)
642 txg_thread_exit(tx, &cpr, &tx->tx_quiesce_thread);
644 txg = tx->tx_open_txg;
647 (u_longlong_t)tx->tx_quiesce_txg_waiting,
648 (u_longlong_t)tx->tx_sync_txg_waiting);
649 tx->tx_quiescing_txg = txg;
651 mutex_exit(&tx->tx_sync_lock);
653 mutex_enter(&tx->tx_sync_lock);
660 tx->tx_quiescing_txg = 0;
661 tx->tx_quiesced_txg = txg;
663 cv_broadcast(&tx->tx_sync_more_cv);
664 cv_broadcast(&tx->tx_quiesce_done_cv);
676 tx_state_t *tx = &dp->dp_tx;
680 if (tx->tx_open_txg > txg ||
681 tx->tx_syncing_txg == txg-1 || tx->tx_synced_txg == txg-1)
684 mutex_enter(&tx->tx_sync_lock);
685 if (tx->tx_open_txg > txg || tx->tx_synced_txg == txg-1) {
686 mutex_exit(&tx->tx_sync_lock);
691 tx->tx_syncing_txg < txg-1 && !txg_stalled(dp)) {
692 (void) cv_timedwait_hires(&tx->tx_quiesce_more_cv,
693 &tx->tx_sync_lock, delay, resolution, 0);
698 mutex_exit(&tx->tx_sync_lock);
704 tx_state_t *tx = &dp->dp_tx;
708 mutex_enter(&tx->tx_sync_lock);
709 ASSERT3U(tx->tx_threads, ==, 2);
711 txg = tx->tx_open_txg + TXG_DEFER_SIZE;
712 if (tx->tx_sync_txg_waiting < txg)
713 tx->tx_sync_txg_waiting = txg;
715 (u_longlong_t)txg, (u_longlong_t)tx->tx_quiesce_txg_waiting,
716 (u_longlong_t)tx->tx_sync_txg_waiting);
717 while (tx->tx_synced_txg < txg) {
720 (u_longlong_t)tx->tx_synced_txg,
721 (u_longlong_t)tx->tx_sync_txg_waiting, dp);
722 cv_broadcast(&tx->tx_sync_more_cv);
729 if (cv_wait_io_sig(&tx->tx_sync_done_cv,
730 &tx->tx_sync_lock) == 0) {
731 mutex_exit(&tx->tx_sync_lock);
735 cv_wait_io(&tx->tx_sync_done_cv, &tx->tx_sync_lock);
738 mutex_exit(&tx->tx_sync_lock);
765 tx_state_t *tx = &dp->dp_tx;
769 mutex_enter(&tx->tx_sync_lock);
770 ASSERT3U(tx->tx_threads, ==, 2);
772 txg = tx->tx_open_txg + 1;
773 if (tx->tx_quiesce_txg_waiting < txg && should_quiesce)
774 tx->tx_quiesce_txg_waiting = txg;
776 (u_longlong_t)txg, (u_longlong_t)tx->tx_quiesce_txg_waiting,
777 (u_longlong_t)tx->tx_sync_txg_waiting);
778 while (tx->tx_open_txg < txg) {
779 cv_broadcast(&tx->tx_quiesce_more_cv);
787 cv_wait_io(&tx->tx_quiesce_done_cv, &tx->tx_sync_lock);
789 cv_wait_idle(&tx->tx_quiesce_done_cv,
790 &tx->tx_sync_lock);
793 mutex_exit(&tx->tx_sync_lock);
802 tx_state_t *tx = &dp->dp_tx;
806 if (tx->tx_sync_txg_waiting >= txg)
809 mutex_enter(&tx->tx_sync_lock);
810 if (tx->tx_sync_txg_waiting < txg) {
811 tx->tx_sync_txg_waiting = txg;
812 cv_broadcast(&tx->tx_sync_more_cv);
814 mutex_exit(&tx->tx_sync_lock);
820 tx_state_t *tx = &dp->dp_tx;
821 return (tx->tx_quiesce_txg_waiting > tx->tx_open_txg);
827 tx_state_t *tx = &dp->dp_tx;
829 return (tx->tx_syncing_txg <= tx->tx_sync_txg_waiting ||
830 tx->tx_quiesced_txg != 0);