Lines Matching refs:tx
119 tx_state_t *tx = &dp->dp_tx; in txg_init() local
121 bzero(tx, sizeof (tx_state_t)); in txg_init()
123 tx->tx_cpu = kmem_zalloc(max_ncpus * sizeof (tx_cpu_t), KM_SLEEP); in txg_init()
128 mutex_init(&tx->tx_cpu[c].tc_lock, NULL, MUTEX_DEFAULT, NULL); in txg_init()
129 mutex_init(&tx->tx_cpu[c].tc_open_lock, NULL, MUTEX_DEFAULT, in txg_init()
132 cv_init(&tx->tx_cpu[c].tc_cv[i], NULL, CV_DEFAULT, in txg_init()
134 list_create(&tx->tx_cpu[c].tc_callbacks[i], in txg_init()
140 mutex_init(&tx->tx_sync_lock, NULL, MUTEX_DEFAULT, NULL); in txg_init()
142 cv_init(&tx->tx_sync_more_cv, NULL, CV_DEFAULT, NULL); in txg_init()
143 cv_init(&tx->tx_sync_done_cv, NULL, CV_DEFAULT, NULL); in txg_init()
144 cv_init(&tx->tx_quiesce_more_cv, NULL, CV_DEFAULT, NULL); in txg_init()
145 cv_init(&tx->tx_quiesce_done_cv, NULL, CV_DEFAULT, NULL); in txg_init()
146 cv_init(&tx->tx_exit_cv, NULL, CV_DEFAULT, NULL); in txg_init()
148 tx->tx_open_txg = txg; in txg_init()
157 tx_state_t *tx = &dp->dp_tx; in txg_fini() local
160 ASSERT(tx->tx_threads == 0); in txg_fini()
162 mutex_destroy(&tx->tx_sync_lock); in txg_fini()
164 cv_destroy(&tx->tx_sync_more_cv); in txg_fini()
165 cv_destroy(&tx->tx_sync_done_cv); in txg_fini()
166 cv_destroy(&tx->tx_quiesce_more_cv); in txg_fini()
167 cv_destroy(&tx->tx_quiesce_done_cv); in txg_fini()
168 cv_destroy(&tx->tx_exit_cv); in txg_fini()
173 mutex_destroy(&tx->tx_cpu[c].tc_open_lock); in txg_fini()
174 mutex_destroy(&tx->tx_cpu[c].tc_lock); in txg_fini()
176 cv_destroy(&tx->tx_cpu[c].tc_cv[i]); in txg_fini()
177 list_destroy(&tx->tx_cpu[c].tc_callbacks[i]); in txg_fini()
181 if (tx->tx_commit_cb_taskq != NULL) in txg_fini()
182 taskq_destroy(tx->tx_commit_cb_taskq); in txg_fini()
184 kmem_free(tx->tx_cpu, max_ncpus * sizeof (tx_cpu_t)); in txg_fini()
186 bzero(tx, sizeof (tx_state_t)); in txg_fini()
195 tx_state_t *tx = &dp->dp_tx; in txg_sync_start() local
197 mutex_enter(&tx->tx_sync_lock); in txg_sync_start()
201 ASSERT(tx->tx_threads == 0); in txg_sync_start()
203 tx->tx_threads = 2; in txg_sync_start()
205 tx->tx_quiesce_thread = thread_create(NULL, 0, txg_quiesce_thread, in txg_sync_start()
213 tx->tx_sync_thread = thread_create(NULL, 32<<10, txg_sync_thread, in txg_sync_start()
216 mutex_exit(&tx->tx_sync_lock); in txg_sync_start()
220 txg_thread_enter(tx_state_t *tx, callb_cpr_t *cpr) in txg_thread_enter() argument
222 CALLB_CPR_INIT(cpr, &tx->tx_sync_lock, callb_generic_cpr, FTAG); in txg_thread_enter()
223 mutex_enter(&tx->tx_sync_lock); in txg_thread_enter()
227 txg_thread_exit(tx_state_t *tx, callb_cpr_t *cpr, kthread_t **tpp) in txg_thread_exit() argument
231 tx->tx_threads--; in txg_thread_exit()
232 cv_broadcast(&tx->tx_exit_cv); in txg_thread_exit()
238 txg_thread_wait(tx_state_t *tx, callb_cpr_t *cpr, kcondvar_t *cv, clock_t time) in txg_thread_wait() argument
243 (void) cv_timedwait(cv, &tx->tx_sync_lock, in txg_thread_wait()
246 cv_wait(cv, &tx->tx_sync_lock); in txg_thread_wait()
248 CALLB_CPR_SAFE_END(cpr, &tx->tx_sync_lock); in txg_thread_wait()
257 tx_state_t *tx = &dp->dp_tx; in txg_sync_stop() local
263 ASSERT(tx->tx_threads == 2); in txg_sync_stop()
268 txg_wait_synced(dp, tx->tx_open_txg + TXG_DEFER_SIZE); in txg_sync_stop()
273 mutex_enter(&tx->tx_sync_lock); in txg_sync_stop()
275 ASSERT(tx->tx_threads == 2); in txg_sync_stop()
277 tx->tx_exiting = 1; in txg_sync_stop()
279 cv_broadcast(&tx->tx_quiesce_more_cv); in txg_sync_stop()
280 cv_broadcast(&tx->tx_quiesce_done_cv); in txg_sync_stop()
281 cv_broadcast(&tx->tx_sync_more_cv); in txg_sync_stop()
283 while (tx->tx_threads != 0) in txg_sync_stop()
284 cv_wait(&tx->tx_exit_cv, &tx->tx_sync_lock); in txg_sync_stop()
286 tx->tx_exiting = 0; in txg_sync_stop()
288 mutex_exit(&tx->tx_sync_lock); in txg_sync_stop()
294 tx_state_t *tx = &dp->dp_tx; in txg_hold_open() local
295 tx_cpu_t *tc = &tx->tx_cpu[CPU_SEQID]; in txg_hold_open()
299 txg = tx->tx_open_txg; in txg_hold_open()
355 tx_state_t *tx = &dp->dp_tx; in txg_quiesce() local
363 mutex_enter(&tx->tx_cpu[c].tc_open_lock); in txg_quiesce()
365 ASSERT(txg == tx->tx_open_txg); in txg_quiesce()
366 tx->tx_open_txg++; in txg_quiesce()
367 tx->tx_open_time = gethrtime(); in txg_quiesce()
370 DTRACE_PROBE2(txg__opened, dsl_pool_t *, dp, uint64_t, tx->tx_open_txg); in txg_quiesce()
377 mutex_exit(&tx->tx_cpu[c].tc_open_lock); in txg_quiesce()
383 tx_cpu_t *tc = &tx->tx_cpu[c]; in txg_quiesce()
411 tx_state_t *tx = &dp->dp_tx; in txg_dispatch_callbacks() local
415 tx_cpu_t *tc = &tx->tx_cpu[c]; in txg_dispatch_callbacks()
426 if (tx->tx_commit_cb_taskq == NULL) { in txg_dispatch_callbacks()
430 tx->tx_commit_cb_taskq = taskq_create("tx_commit_cb", in txg_dispatch_callbacks()
441 (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_sync_thread() local
454 txg_thread_enter(tx, &cpr); in txg_sync_thread()
469 !tx->tx_exiting && timer > 0 && in txg_sync_thread()
470 tx->tx_synced_txg >= tx->tx_sync_txg_waiting && in txg_sync_thread()
471 tx->tx_quiesced_txg == 0 && in txg_sync_thread()
474 tx->tx_synced_txg, tx->tx_sync_txg_waiting, dp); in txg_sync_thread()
475 txg_thread_wait(tx, &cpr, &tx->tx_sync_more_cv, timer); in txg_sync_thread()
484 while (!tx->tx_exiting && tx->tx_quiesced_txg == 0) { in txg_sync_thread()
485 if (tx->tx_quiesce_txg_waiting < tx->tx_open_txg+1) in txg_sync_thread()
486 tx->tx_quiesce_txg_waiting = tx->tx_open_txg+1; in txg_sync_thread()
487 cv_broadcast(&tx->tx_quiesce_more_cv); in txg_sync_thread()
488 txg_thread_wait(tx, &cpr, &tx->tx_quiesce_done_cv, 0); in txg_sync_thread()
491 if (tx->tx_exiting) in txg_sync_thread()
492 txg_thread_exit(tx, &cpr, &tx->tx_sync_thread); in txg_sync_thread()
499 txg = tx->tx_quiesced_txg; in txg_sync_thread()
500 tx->tx_quiesced_txg = 0; in txg_sync_thread()
501 tx->tx_syncing_txg = txg; in txg_sync_thread()
503 cv_broadcast(&tx->tx_quiesce_more_cv); in txg_sync_thread()
506 txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting); in txg_sync_thread()
507 mutex_exit(&tx->tx_sync_lock); in txg_sync_thread()
513 mutex_enter(&tx->tx_sync_lock); in txg_sync_thread()
514 tx->tx_synced_txg = txg; in txg_sync_thread()
515 tx->tx_syncing_txg = 0; in txg_sync_thread()
517 cv_broadcast(&tx->tx_sync_done_cv); in txg_sync_thread()
529 tx_state_t *tx = &dp->dp_tx; in txg_quiesce_thread() local
532 txg_thread_enter(tx, &cpr); in txg_quiesce_thread()
544 while (!tx->tx_exiting && in txg_quiesce_thread()
545 (tx->tx_open_txg >= tx->tx_quiesce_txg_waiting || in txg_quiesce_thread()
546 tx->tx_quiesced_txg != 0)) in txg_quiesce_thread()
547 txg_thread_wait(tx, &cpr, &tx->tx_quiesce_more_cv, 0); in txg_quiesce_thread()
549 if (tx->tx_exiting) in txg_quiesce_thread()
550 txg_thread_exit(tx, &cpr, &tx->tx_quiesce_thread); in txg_quiesce_thread()
552 txg = tx->tx_open_txg; in txg_quiesce_thread()
554 txg, tx->tx_quiesce_txg_waiting, in txg_quiesce_thread()
555 tx->tx_sync_txg_waiting); in txg_quiesce_thread()
556 mutex_exit(&tx->tx_sync_lock); in txg_quiesce_thread()
558 mutex_enter(&tx->tx_sync_lock); in txg_quiesce_thread()
564 tx->tx_quiesced_txg = txg; in txg_quiesce_thread()
566 cv_broadcast(&tx->tx_sync_more_cv); in txg_quiesce_thread()
567 cv_broadcast(&tx->tx_quiesce_done_cv); in txg_quiesce_thread()
579 tx_state_t *tx = &dp->dp_tx; in txg_delay() local
583 if (tx->tx_open_txg > txg || in txg_delay()
584 tx->tx_syncing_txg == txg-1 || tx->tx_synced_txg == txg-1) in txg_delay()
587 mutex_enter(&tx->tx_sync_lock); in txg_delay()
588 if (tx->tx_open_txg > txg || tx->tx_synced_txg == txg-1) { in txg_delay()
589 mutex_exit(&tx->tx_sync_lock); in txg_delay()
594 tx->tx_syncing_txg < txg-1 && !txg_stalled(dp)) { in txg_delay()
595 (void) cv_timedwait_hires(&tx->tx_quiesce_more_cv, in txg_delay()
596 &tx->tx_sync_lock, delay, resolution, 0); in txg_delay()
599 mutex_exit(&tx->tx_sync_lock); in txg_delay()
605 tx_state_t *tx = &dp->dp_tx; in txg_wait_synced() local
609 mutex_enter(&tx->tx_sync_lock); in txg_wait_synced()
610 ASSERT(tx->tx_threads == 2); in txg_wait_synced()
612 txg = tx->tx_open_txg + TXG_DEFER_SIZE; in txg_wait_synced()
613 if (tx->tx_sync_txg_waiting < txg) in txg_wait_synced()
614 tx->tx_sync_txg_waiting = txg; in txg_wait_synced()
616 txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting); in txg_wait_synced()
617 while (tx->tx_synced_txg < txg) { in txg_wait_synced()
620 tx->tx_synced_txg, tx->tx_sync_txg_waiting, dp); in txg_wait_synced()
621 cv_broadcast(&tx->tx_sync_more_cv); in txg_wait_synced()
622 cv_wait(&tx->tx_sync_done_cv, &tx->tx_sync_lock); in txg_wait_synced()
624 mutex_exit(&tx->tx_sync_lock); in txg_wait_synced()
630 tx_state_t *tx = &dp->dp_tx; in txg_wait_open() local
634 mutex_enter(&tx->tx_sync_lock); in txg_wait_open()
635 ASSERT(tx->tx_threads == 2); in txg_wait_open()
637 txg = tx->tx_open_txg + 1; in txg_wait_open()
638 if (tx->tx_quiesce_txg_waiting < txg) in txg_wait_open()
639 tx->tx_quiesce_txg_waiting = txg; in txg_wait_open()
641 txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting); in txg_wait_open()
642 while (tx->tx_open_txg < txg) { in txg_wait_open()
643 cv_broadcast(&tx->tx_quiesce_more_cv); in txg_wait_open()
644 cv_wait(&tx->tx_quiesce_done_cv, &tx->tx_sync_lock); in txg_wait_open()
646 mutex_exit(&tx->tx_sync_lock); in txg_wait_open()
656 tx_state_t *tx = &dp->dp_tx; in txg_kick() local
660 mutex_enter(&tx->tx_sync_lock); in txg_kick()
661 if (tx->tx_syncing_txg == 0 && in txg_kick()
662 tx->tx_quiesce_txg_waiting <= tx->tx_open_txg && in txg_kick()
663 tx->tx_sync_txg_waiting <= tx->tx_synced_txg && in txg_kick()
664 tx->tx_quiesced_txg <= tx->tx_synced_txg) { in txg_kick()
665 tx->tx_quiesce_txg_waiting = tx->tx_open_txg + 1; in txg_kick()
666 cv_broadcast(&tx->tx_quiesce_more_cv); in txg_kick()
668 mutex_exit(&tx->tx_sync_lock); in txg_kick()
674 tx_state_t *tx = &dp->dp_tx; in txg_stalled() local
675 return (tx->tx_quiesce_txg_waiting > tx->tx_open_txg); in txg_stalled()
681 tx_state_t *tx = &dp->dp_tx; in txg_sync_waiting() local
683 return (tx->tx_syncing_txg <= tx->tx_sync_txg_waiting || in txg_sync_waiting()
684 tx->tx_quiesced_txg != 0); in txg_sync_waiting()