Lines Matching refs:tx

120 	tx_state_t *tx = &dp->dp_tx;  in txg_init()  local
122 bzero(tx, sizeof (tx_state_t)); in txg_init()
124 tx->tx_cpu = kmem_zalloc(max_ncpus * sizeof (tx_cpu_t), KM_SLEEP); in txg_init()
129 mutex_init(&tx->tx_cpu[c].tc_lock, NULL, MUTEX_DEFAULT, NULL); in txg_init()
130 mutex_init(&tx->tx_cpu[c].tc_open_lock, NULL, MUTEX_DEFAULT, in txg_init()
133 cv_init(&tx->tx_cpu[c].tc_cv[i], NULL, CV_DEFAULT, in txg_init()
135 list_create(&tx->tx_cpu[c].tc_callbacks[i], in txg_init()
141 mutex_init(&tx->tx_sync_lock, NULL, MUTEX_DEFAULT, NULL); in txg_init()
143 cv_init(&tx->tx_sync_more_cv, NULL, CV_DEFAULT, NULL); in txg_init()
144 cv_init(&tx->tx_sync_done_cv, NULL, CV_DEFAULT, NULL); in txg_init()
145 cv_init(&tx->tx_quiesce_more_cv, NULL, CV_DEFAULT, NULL); in txg_init()
146 cv_init(&tx->tx_quiesce_done_cv, NULL, CV_DEFAULT, NULL); in txg_init()
147 cv_init(&tx->tx_exit_cv, NULL, CV_DEFAULT, NULL); in txg_init()
149 tx->tx_open_txg = txg; in txg_init()
158 tx_state_t *tx = &dp->dp_tx; in txg_fini() local
161 ASSERT0(tx->tx_threads); in txg_fini()
163 mutex_destroy(&tx->tx_sync_lock); in txg_fini()
165 cv_destroy(&tx->tx_sync_more_cv); in txg_fini()
166 cv_destroy(&tx->tx_sync_done_cv); in txg_fini()
167 cv_destroy(&tx->tx_quiesce_more_cv); in txg_fini()
168 cv_destroy(&tx->tx_quiesce_done_cv); in txg_fini()
169 cv_destroy(&tx->tx_exit_cv); in txg_fini()
174 mutex_destroy(&tx->tx_cpu[c].tc_open_lock); in txg_fini()
175 mutex_destroy(&tx->tx_cpu[c].tc_lock); in txg_fini()
177 cv_destroy(&tx->tx_cpu[c].tc_cv[i]); in txg_fini()
178 list_destroy(&tx->tx_cpu[c].tc_callbacks[i]); in txg_fini()
182 if (tx->tx_commit_cb_taskq != NULL) in txg_fini()
183 taskq_destroy(tx->tx_commit_cb_taskq); in txg_fini()
185 kmem_free(tx->tx_cpu, max_ncpus * sizeof (tx_cpu_t)); in txg_fini()
187 bzero(tx, sizeof (tx_state_t)); in txg_fini()
196 tx_state_t *tx = &dp->dp_tx; in txg_sync_start() local
198 mutex_enter(&tx->tx_sync_lock); in txg_sync_start()
202 ASSERT0(tx->tx_threads); in txg_sync_start()
204 tx->tx_threads = 2; in txg_sync_start()
206 tx->tx_quiesce_thread = thread_create(NULL, 0, txg_quiesce_thread, in txg_sync_start()
214 tx->tx_sync_thread = thread_create(NULL, 32<<10, txg_sync_thread, in txg_sync_start()
217 mutex_exit(&tx->tx_sync_lock); in txg_sync_start()
221 txg_thread_enter(tx_state_t *tx, callb_cpr_t *cpr) in txg_thread_enter() argument
223 CALLB_CPR_INIT(cpr, &tx->tx_sync_lock, callb_generic_cpr, FTAG); in txg_thread_enter()
224 mutex_enter(&tx->tx_sync_lock); in txg_thread_enter()
228 txg_thread_exit(tx_state_t *tx, callb_cpr_t *cpr, kthread_t **tpp) in txg_thread_exit() argument
232 tx->tx_threads--; in txg_thread_exit()
233 cv_broadcast(&tx->tx_exit_cv); in txg_thread_exit()
239 txg_thread_wait(tx_state_t *tx, callb_cpr_t *cpr, kcondvar_t *cv, clock_t time) in txg_thread_wait() argument
244 (void) cv_timedwait(cv, &tx->tx_sync_lock, in txg_thread_wait()
247 cv_wait(cv, &tx->tx_sync_lock); in txg_thread_wait()
249 CALLB_CPR_SAFE_END(cpr, &tx->tx_sync_lock); in txg_thread_wait()
258 tx_state_t *tx = &dp->dp_tx; in txg_sync_stop() local
264 ASSERT3U(tx->tx_threads, ==, 2); in txg_sync_stop()
269 txg_wait_synced(dp, tx->tx_open_txg + TXG_DEFER_SIZE); in txg_sync_stop()
274 mutex_enter(&tx->tx_sync_lock); in txg_sync_stop()
276 ASSERT3U(tx->tx_threads, ==, 2); in txg_sync_stop()
278 tx->tx_exiting = 1; in txg_sync_stop()
280 cv_broadcast(&tx->tx_quiesce_more_cv); in txg_sync_stop()
281 cv_broadcast(&tx->tx_quiesce_done_cv); in txg_sync_stop()
282 cv_broadcast(&tx->tx_sync_more_cv); in txg_sync_stop()
284 while (tx->tx_threads != 0) in txg_sync_stop()
285 cv_wait(&tx->tx_exit_cv, &tx->tx_sync_lock); in txg_sync_stop()
287 tx->tx_exiting = 0; in txg_sync_stop()
289 mutex_exit(&tx->tx_sync_lock); in txg_sync_stop()
295 tx_state_t *tx = &dp->dp_tx; in txg_hold_open() local
296 tx_cpu_t *tc = &tx->tx_cpu[CPU_SEQID]; in txg_hold_open()
300 txg = tx->tx_open_txg; in txg_hold_open()
356 tx_state_t *tx = &dp->dp_tx; in txg_quiesce() local
364 mutex_enter(&tx->tx_cpu[c].tc_open_lock); in txg_quiesce()
366 ASSERT(txg == tx->tx_open_txg); in txg_quiesce()
367 tx->tx_open_txg++; in txg_quiesce()
368 tx->tx_open_time = gethrtime(); in txg_quiesce()
371 DTRACE_PROBE2(txg__opened, dsl_pool_t *, dp, uint64_t, tx->tx_open_txg); in txg_quiesce()
378 mutex_exit(&tx->tx_cpu[c].tc_open_lock); in txg_quiesce()
384 tx_cpu_t *tc = &tx->tx_cpu[c]; in txg_quiesce()
412 tx_state_t *tx = &dp->dp_tx; in txg_dispatch_callbacks() local
416 tx_cpu_t *tc = &tx->tx_cpu[c]; in txg_dispatch_callbacks()
427 if (tx->tx_commit_cb_taskq == NULL) { in txg_dispatch_callbacks()
431 tx->tx_commit_cb_taskq = taskq_create("tx_commit_cb", in txg_dispatch_callbacks()
442 (void) taskq_dispatch(tx->tx_commit_cb_taskq, (task_func_t *) in txg_dispatch_callbacks()
450 tx_state_t *tx = &dp->dp_tx; in txg_is_syncing() local
451 ASSERT(MUTEX_HELD(&tx->tx_sync_lock)); in txg_is_syncing()
452 return (tx->tx_syncing_txg != 0); in txg_is_syncing()
458 tx_state_t *tx = &dp->dp_tx; in txg_is_quiescing() local
459 ASSERT(MUTEX_HELD(&tx->tx_sync_lock)); in txg_is_quiescing()
460 return (tx->tx_quiescing_txg != 0); in txg_is_quiescing()
466 tx_state_t *tx = &dp->dp_tx; in txg_has_quiesced_to_sync() local
467 ASSERT(MUTEX_HELD(&tx->tx_sync_lock)); in txg_has_quiesced_to_sync()
468 return (tx->tx_quiesced_txg != 0); in txg_has_quiesced_to_sync()
476 tx_state_t *tx = &dp->dp_tx; in txg_sync_thread() local
480 txg_thread_enter(tx, &cpr); in txg_sync_thread()
497 !tx->tx_exiting && timer > 0 && in txg_sync_thread()
498 tx->tx_synced_txg >= tx->tx_sync_txg_waiting && in txg_sync_thread()
503 tx->tx_synced_txg, tx->tx_sync_txg_waiting, dp); in txg_sync_thread()
504 txg_thread_wait(tx, &cpr, &tx->tx_sync_more_cv, timer); in txg_sync_thread()
513 while (!tx->tx_exiting && !txg_has_quiesced_to_sync(dp)) { in txg_sync_thread()
514 if (tx->tx_quiesce_txg_waiting < tx->tx_open_txg+1) in txg_sync_thread()
515 tx->tx_quiesce_txg_waiting = tx->tx_open_txg+1; in txg_sync_thread()
516 cv_broadcast(&tx->tx_quiesce_more_cv); in txg_sync_thread()
517 txg_thread_wait(tx, &cpr, &tx->tx_quiesce_done_cv, 0); in txg_sync_thread()
520 if (tx->tx_exiting) in txg_sync_thread()
521 txg_thread_exit(tx, &cpr, &tx->tx_sync_thread); in txg_sync_thread()
528 ASSERT(tx->tx_quiesced_txg != 0); in txg_sync_thread()
529 txg = tx->tx_quiesced_txg; in txg_sync_thread()
530 tx->tx_quiesced_txg = 0; in txg_sync_thread()
531 tx->tx_syncing_txg = txg; in txg_sync_thread()
533 cv_broadcast(&tx->tx_quiesce_more_cv); in txg_sync_thread()
536 txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting); in txg_sync_thread()
537 mutex_exit(&tx->tx_sync_lock); in txg_sync_thread()
543 mutex_enter(&tx->tx_sync_lock); in txg_sync_thread()
544 tx->tx_synced_txg = txg; in txg_sync_thread()
545 tx->tx_syncing_txg = 0; in txg_sync_thread()
547 cv_broadcast(&tx->tx_sync_done_cv); in txg_sync_thread()
560 tx_state_t *tx = &dp->dp_tx; in txg_quiesce_thread() local
563 txg_thread_enter(tx, &cpr); in txg_quiesce_thread()
575 while (!tx->tx_exiting && in txg_quiesce_thread()
576 (tx->tx_open_txg >= tx->tx_quiesce_txg_waiting || in txg_quiesce_thread()
578 txg_thread_wait(tx, &cpr, &tx->tx_quiesce_more_cv, 0); in txg_quiesce_thread()
580 if (tx->tx_exiting) in txg_quiesce_thread()
581 txg_thread_exit(tx, &cpr, &tx->tx_quiesce_thread); in txg_quiesce_thread()
583 txg = tx->tx_open_txg; in txg_quiesce_thread()
585 txg, tx->tx_quiesce_txg_waiting, in txg_quiesce_thread()
586 tx->tx_sync_txg_waiting); in txg_quiesce_thread()
587 tx->tx_quiescing_txg = txg; in txg_quiesce_thread()
589 mutex_exit(&tx->tx_sync_lock); in txg_quiesce_thread()
591 mutex_enter(&tx->tx_sync_lock); in txg_quiesce_thread()
597 tx->tx_quiescing_txg = 0; in txg_quiesce_thread()
598 tx->tx_quiesced_txg = txg; in txg_quiesce_thread()
600 cv_broadcast(&tx->tx_sync_more_cv); in txg_quiesce_thread()
601 cv_broadcast(&tx->tx_quiesce_done_cv); in txg_quiesce_thread()
613 tx_state_t *tx = &dp->dp_tx; in txg_delay() local
617 if (tx->tx_open_txg > txg || in txg_delay()
618 tx->tx_syncing_txg == txg-1 || tx->tx_synced_txg == txg-1) in txg_delay()
621 mutex_enter(&tx->tx_sync_lock); in txg_delay()
622 if (tx->tx_open_txg > txg || tx->tx_synced_txg == txg-1) { in txg_delay()
623 mutex_exit(&tx->tx_sync_lock); in txg_delay()
628 tx->tx_syncing_txg < txg-1 && !txg_stalled(dp)) { in txg_delay()
629 (void) cv_timedwait_hires(&tx->tx_quiesce_more_cv, in txg_delay()
630 &tx->tx_sync_lock, delay, resolution, 0); in txg_delay()
633 mutex_exit(&tx->tx_sync_lock); in txg_delay()
639 tx_state_t *tx = &dp->dp_tx; in txg_wait_synced_impl() local
643 mutex_enter(&tx->tx_sync_lock); in txg_wait_synced_impl()
644 ASSERT3U(tx->tx_threads, ==, 2); in txg_wait_synced_impl()
646 txg = tx->tx_open_txg + TXG_DEFER_SIZE; in txg_wait_synced_impl()
647 if (tx->tx_sync_txg_waiting < txg) in txg_wait_synced_impl()
648 tx->tx_sync_txg_waiting = txg; in txg_wait_synced_impl()
650 txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting); in txg_wait_synced_impl()
651 while (tx->tx_synced_txg < txg) { in txg_wait_synced_impl()
654 tx->tx_synced_txg, tx->tx_sync_txg_waiting, dp); in txg_wait_synced_impl()
655 cv_broadcast(&tx->tx_sync_more_cv); in txg_wait_synced_impl()
662 if (cv_wait_sig(&tx->tx_sync_done_cv, in txg_wait_synced_impl()
663 &tx->tx_sync_lock) == 0) { in txg_wait_synced_impl()
664 mutex_exit(&tx->tx_sync_lock); in txg_wait_synced_impl()
668 cv_wait(&tx->tx_sync_done_cv, &tx->tx_sync_lock); in txg_wait_synced_impl()
671 mutex_exit(&tx->tx_sync_lock); in txg_wait_synced_impl()
698 tx_state_t *tx = &dp->dp_tx; in txg_wait_open() local
702 mutex_enter(&tx->tx_sync_lock); in txg_wait_open()
703 ASSERT3U(tx->tx_threads, ==, 2); in txg_wait_open()
705 txg = tx->tx_open_txg + 1; in txg_wait_open()
706 if (tx->tx_quiesce_txg_waiting < txg && should_quiesce) in txg_wait_open()
707 tx->tx_quiesce_txg_waiting = txg; in txg_wait_open()
709 txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting); in txg_wait_open()
710 while (tx->tx_open_txg < txg) { in txg_wait_open()
711 cv_broadcast(&tx->tx_quiesce_more_cv); in txg_wait_open()
712 cv_wait(&tx->tx_quiesce_done_cv, &tx->tx_sync_lock); in txg_wait_open()
714 mutex_exit(&tx->tx_sync_lock); in txg_wait_open()
724 tx_state_t *tx = &dp->dp_tx; in txg_kick() local
728 mutex_enter(&tx->tx_sync_lock); in txg_kick()
731 tx->tx_quiesce_txg_waiting <= tx->tx_open_txg && in txg_kick()
732 tx->tx_sync_txg_waiting <= tx->tx_synced_txg && in txg_kick()
733 tx->tx_quiesced_txg <= tx->tx_synced_txg) { in txg_kick()
734 tx->tx_quiesce_txg_waiting = tx->tx_open_txg + 1; in txg_kick()
735 cv_broadcast(&tx->tx_quiesce_more_cv); in txg_kick()
737 mutex_exit(&tx->tx_sync_lock); in txg_kick()
743 tx_state_t *tx = &dp->dp_tx; in txg_stalled() local
744 return (tx->tx_quiesce_txg_waiting > tx->tx_open_txg); in txg_stalled()
750 tx_state_t *tx = &dp->dp_tx; in txg_sync_waiting() local
752 return (tx->tx_syncing_txg <= tx->tx_sync_txg_waiting || in txg_sync_waiting()
753 tx->tx_quiesced_txg != 0); in txg_sync_waiting()