Lines Matching refs:tx

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