Lines Matching refs:tx
124 tx_state_t *tx = &dp->dp_tx;
126 bzero(tx, sizeof (tx_state_t));
128 tx->tx_cpu = kmem_zalloc(max_ncpus * sizeof (tx_cpu_t), KM_SLEEP);
133 mutex_init(&tx->tx_cpu[c].tc_lock, NULL, MUTEX_DEFAULT, NULL);
134 mutex_init(&tx->tx_cpu[c].tc_open_lock, NULL, MUTEX_DEFAULT,
137 cv_init(&tx->tx_cpu[c].tc_cv[i], NULL, CV_DEFAULT,
139 list_create(&tx->tx_cpu[c].tc_callbacks[i],
145 mutex_init(&tx->tx_sync_lock, NULL, MUTEX_DEFAULT, NULL);
147 cv_init(&tx->tx_sync_more_cv, NULL, CV_DEFAULT, NULL);
148 cv_init(&tx->tx_sync_done_cv, NULL, CV_DEFAULT, NULL);
149 cv_init(&tx->tx_quiesce_more_cv, NULL, CV_DEFAULT, NULL);
150 cv_init(&tx->tx_quiesce_done_cv, NULL, CV_DEFAULT, NULL);
151 cv_init(&tx->tx_exit_cv, NULL, CV_DEFAULT, NULL);
153 tx->tx_open_txg = txg;
162 tx_state_t *tx = &dp->dp_tx;
165 ASSERT(tx->tx_threads == 0);
167 mutex_destroy(&tx->tx_sync_lock);
169 cv_destroy(&tx->tx_sync_more_cv);
170 cv_destroy(&tx->tx_sync_done_cv);
171 cv_destroy(&tx->tx_quiesce_more_cv);
172 cv_destroy(&tx->tx_quiesce_done_cv);
173 cv_destroy(&tx->tx_exit_cv);
178 mutex_destroy(&tx->tx_cpu[c].tc_open_lock);
179 mutex_destroy(&tx->tx_cpu[c].tc_lock);
181 cv_destroy(&tx->tx_cpu[c].tc_cv[i]);
182 list_destroy(&tx->tx_cpu[c].tc_callbacks[i]);
186 if (tx->tx_commit_cb_taskq != NULL)
187 taskq_destroy(tx->tx_commit_cb_taskq);
189 kmem_free(tx->tx_cpu, max_ncpus * sizeof (tx_cpu_t));
191 bzero(tx, sizeof (tx_state_t));
200 tx_state_t *tx = &dp->dp_tx;
202 mutex_enter(&tx->tx_sync_lock);
206 ASSERT(tx->tx_threads == 0);
208 tx->tx_threads = 2;
210 tx->tx_quiesce_thread = thread_create(NULL, 0, txg_quiesce_thread,
218 tx->tx_sync_thread = thread_create(NULL, 32<<10, txg_sync_thread,
221 mutex_exit(&tx->tx_sync_lock);
225 txg_thread_enter(tx_state_t *tx, callb_cpr_t *cpr)
227 CALLB_CPR_INIT(cpr, &tx->tx_sync_lock, callb_generic_cpr, FTAG);
228 mutex_enter(&tx->tx_sync_lock);
232 txg_thread_exit(tx_state_t *tx, callb_cpr_t *cpr, kthread_t **tpp)
236 tx->tx_threads--;
237 cv_broadcast(&tx->tx_exit_cv);
238 CALLB_CPR_EXIT(cpr); /* drops &tx->tx_sync_lock */
243 txg_thread_wait(tx_state_t *tx, callb_cpr_t *cpr, kcondvar_t *cv, clock_t time)
248 (void) cv_timedwait(cv, &tx->tx_sync_lock, time);
250 cv_wait(cv, &tx->tx_sync_lock);
252 CALLB_CPR_SAFE_END(cpr, &tx->tx_sync_lock);
261 tx_state_t *tx = &dp->dp_tx;
267 ASSERT(tx->tx_threads == 2);
272 txg_wait_synced(dp, tx->tx_open_txg + TXG_DEFER_SIZE);
277 mutex_enter(&tx->tx_sync_lock);
279 ASSERT(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);
298 tx_state_t *tx = &dp->dp_tx;
299 tx_cpu_t *tc = &tx->tx_cpu[CPU_SEQID];
303 txg = tx->tx_open_txg;
359 tx_state_t *tx = &dp->dp_tx;
367 mutex_enter(&tx->tx_cpu[c].tc_open_lock);
369 ASSERT(txg == tx->tx_open_txg);
370 tx->tx_open_txg++;
371 tx->tx_open_time = gethrtime();
374 DTRACE_PROBE2(txg__opened, dsl_pool_t *, dp, uint64_t, tx->tx_open_txg);
381 mutex_exit(&tx->tx_cpu[c].tc_open_lock);
387 tx_cpu_t *tc = &tx->tx_cpu[c];
417 tx_state_t *tx = &dp->dp_tx;
421 tx_cpu_t *tc = &tx->tx_cpu[c];
432 if (tx->tx_commit_cb_taskq == NULL) {
436 tx->tx_commit_cb_taskq = taskq_create("tx_commit_cb",
447 (void) taskq_dispatch(tx->tx_commit_cb_taskq, (task_func_t *)
457 tx_state_t *tx = &dp->dp_tx;
461 txg_thread_enter(tx, &cpr);
476 !tx->tx_exiting && timer > 0 &&
477 tx->tx_synced_txg >= tx->tx_sync_txg_waiting &&
478 tx->tx_quiesced_txg == 0 &&
481 tx->tx_synced_txg, tx->tx_sync_txg_waiting, dp);
482 txg_thread_wait(tx, &cpr, &tx->tx_sync_more_cv, timer);
491 while (!tx->tx_exiting && tx->tx_quiesced_txg == 0) {
492 if (tx->tx_quiesce_txg_waiting < tx->tx_open_txg+1)
493 tx->tx_quiesce_txg_waiting = tx->tx_open_txg+1;
494 cv_broadcast(&tx->tx_quiesce_more_cv);
495 txg_thread_wait(tx, &cpr, &tx->tx_quiesce_done_cv, 0);
498 if (tx->tx_exiting)
499 txg_thread_exit(tx, &cpr, &tx->tx_sync_thread);
506 txg = tx->tx_quiesced_txg;
507 tx->tx_quiesced_txg = 0;
508 tx->tx_syncing_txg = txg;
510 cv_broadcast(&tx->tx_quiesce_more_cv);
513 txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting);
514 mutex_exit(&tx->tx_sync_lock);
520 mutex_enter(&tx->tx_sync_lock);
521 tx->tx_synced_txg = txg;
522 tx->tx_syncing_txg = 0;
524 cv_broadcast(&tx->tx_sync_done_cv);
537 tx_state_t *tx = &dp->dp_tx;
540 txg_thread_enter(tx, &cpr);
552 while (!tx->tx_exiting &&
553 (tx->tx_open_txg >= tx->tx_quiesce_txg_waiting ||
554 tx->tx_quiesced_txg != 0))
555 txg_thread_wait(tx, &cpr, &tx->tx_quiesce_more_cv, 0);
557 if (tx->tx_exiting)
558 txg_thread_exit(tx, &cpr, &tx->tx_quiesce_thread);
560 txg = tx->tx_open_txg;
562 txg, tx
563 tx->tx_sync_txg_waiting);
564 mutex_exit(&tx->tx_sync_lock);
566 mutex_enter(&tx->tx_sync_lock);
572 tx->tx_quiesced_txg = txg;
574 cv_broadcast(&tx->tx_sync_more_cv);
575 cv_broadcast(&tx->tx_quiesce_done_cv);
587 tx_state_t *tx = &dp->dp_tx;
591 if (tx->tx_open_txg > txg ||
592 tx->tx_syncing_txg == txg-1 || tx->tx_synced_txg == txg-1)
595 mutex_enter(&tx->tx_sync_lock);
596 if (tx->tx_open_txg > txg || tx->tx_synced_txg == txg-1) {
597 mutex_exit(&tx->tx_sync_lock);
602 tx->tx_syncing_txg < txg-1 && !txg_stalled(dp)) {
603 (void) cv_timedwait_hires(&tx->tx_quiesce_more_cv,
604 &tx->tx_sync_lock, delay, resolution, 0);
607 mutex_exit(&tx->tx_sync_lock);
613 tx_state_t *tx = &dp->dp_tx;
617 mutex_enter(&tx->tx_sync_lock);
618 ASSERT(tx->tx_threads == 2);
620 txg = tx->tx_open_txg + TXG_DEFER_SIZE;
621 if (tx->tx_sync_txg_waiting < txg)
622 tx->tx_sync_txg_waiting = txg;
624 txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting);
625 while (tx->tx_synced_txg < txg) {
628 tx->tx_synced_txg, tx->tx_sync_txg_waiting, dp);
629 cv_broadcast(&tx->tx_sync_more_cv);
630 cv_wait(&tx->tx_sync_done_cv, &tx->tx_sync_lock);
632 mutex_exit(&tx->tx_sync_lock);
638 tx_state_t *tx = &dp->dp_tx;
642 mutex_enter(&tx->tx_sync_lock);
643 ASSERT(tx->tx_threads == 2);
645 txg = tx->tx_open_txg + 1;
646 if (tx->tx_quiesce_txg_waiting < txg)
647 tx->tx_quiesce_txg_waiting = txg;
649 txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting);
650 while (tx->tx_open_txg < txg) {
651 cv_broadcast(&tx->tx_quiesce_more_cv);
652 cv_wait(&tx->tx_quiesce_done_cv, &tx->tx_sync_lock);
654 mutex_exit(&tx->tx_sync_lock);
664 tx_state_t *tx = &dp->dp_tx;
668 mutex_enter(&tx->tx_sync_lock);
669 if (tx->tx_syncing_txg == 0 &&
670 tx->tx_quiesce_txg_waiting <= tx->tx_open_txg &&
671 tx->tx_sync_txg_waiting <= tx->tx_synced_txg &&
672 tx->tx_quiesced_txg <= tx->tx_synced_txg) {
673 tx->tx_quiesce_txg_waiting = tx->tx_open_txg + 1;
674 cv_broadcast(&tx->tx_quiesce_more_cv);
676 mutex_exit(&tx->tx_sync_lock);
682 tx_state_t *tx = &dp->dp_tx;
683 return (tx->tx_quiesce_txg_waiting > tx->tx_open_txg);
689 tx_state_t *tx = &dp->dp_tx;
691 return (tx->tx_syncing_txg <= tx->tx_sync_txg_waiting ||
692 tx->tx_quiesced_txg != 0);