4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
25 #include <sys/zfs_context.h>
26 #include <sys/txg_impl.h>
27 #include <sys/dmu_impl.h>
28 #include <sys/dmu_tx.h>
29 #include <sys/dsl_pool.h>
30 #include <sys/dsl_scan.h>
31 #include <sys/callb.h>
32 #include <sys/spa_impl.h>
35 * Pool-wide transaction groups.
38 static void txg_sync_thread(dsl_pool_t *dp);
39 static void txg_quiesce_thread(dsl_pool_t *dp);
41 int zfs_txg_timeout = 5; /* max seconds worth of delta per txg */
44 * Prepare the txg subsystem.
47 txg_init(dsl_pool_t *dp, uint64_t txg)
49 tx_state_t *tx = &dp->dp_tx;
51 bzero(tx, sizeof (tx_state_t));
53 tx->tx_cpu = vmem_zalloc(max_ncpus * sizeof (tx_cpu_t), KM_SLEEP);
55 for (c = 0; c < max_ncpus; c++) {
58 mutex_init(&tx->tx_cpu[c].tc_lock, NULL, MUTEX_DEFAULT, NULL);
59 for (i = 0; i < TXG_SIZE; i++) {
60 cv_init(&tx->tx_cpu[c].tc_cv[i], NULL, CV_DEFAULT,
62 list_create(&tx->tx_cpu[c].tc_callbacks[i],
63 sizeof (dmu_tx_callback_t),
64 offsetof(dmu_tx_callback_t, dcb_node));
68 mutex_init(&tx->tx_sync_lock, NULL, MUTEX_DEFAULT, NULL);
70 cv_init(&tx->tx_sync_more_cv, NULL, CV_DEFAULT, NULL);
71 cv_init(&tx->tx_sync_done_cv, NULL, CV_DEFAULT, NULL);
72 cv_init(&tx->tx_quiesce_more_cv, NULL, CV_DEFAULT, NULL);
73 cv_init(&tx->tx_quiesce_done_cv, NULL, CV_DEFAULT, NULL);
74 cv_init(&tx->tx_exit_cv, NULL, CV_DEFAULT, NULL);
76 tx->tx_open_txg = txg;
80 * Close down the txg subsystem.
83 txg_fini(dsl_pool_t *dp)
85 tx_state_t *tx = &dp->dp_tx;
88 ASSERT(tx->tx_threads == 0);
90 mutex_destroy(&tx->tx_sync_lock);
92 cv_destroy(&tx->tx_sync_more_cv);
93 cv_destroy(&tx->tx_sync_done_cv);
94 cv_destroy(&tx->tx_quiesce_more_cv);
95 cv_destroy(&tx->tx_quiesce_done_cv);
96 cv_destroy(&tx->tx_exit_cv);
98 for (c = 0; c < max_ncpus; c++) {
101 mutex_destroy(&tx->tx_cpu[c].tc_lock);
102 for (i = 0; i < TXG_SIZE; i++) {
103 cv_destroy(&tx->tx_cpu[c].tc_cv[i]);
104 list_destroy(&tx->tx_cpu[c].tc_callbacks[i]);
108 if (tx->tx_commit_cb_taskq != NULL)
109 taskq_destroy(tx->tx_commit_cb_taskq);
111 vmem_free(tx->tx_cpu, max_ncpus * sizeof (tx_cpu_t));
113 bzero(tx, sizeof (tx_state_t));
117 * Start syncing transaction groups.
120 txg_sync_start(dsl_pool_t *dp)
122 tx_state_t *tx = &dp->dp_tx;
124 mutex_enter(&tx->tx_sync_lock);
126 dprintf("pool %p\n", dp);
128 ASSERT(tx->tx_threads == 0);
132 tx->tx_quiesce_thread = thread_create(NULL, 0, txg_quiesce_thread,
133 dp, 0, &p0, TS_RUN, minclsyspri);
136 * The sync thread can need a larger-than-default stack size on
137 * 32-bit x86. This is due in part to nested pools and
138 * scrub_visitbp() recursion.
140 tx->tx_sync_thread = thread_create(NULL, 32<<10, txg_sync_thread,
141 dp, 0, &p0, TS_RUN, minclsyspri);
143 mutex_exit(&tx->tx_sync_lock);
147 txg_thread_enter(tx_state_t *tx, callb_cpr_t *cpr)
149 CALLB_CPR_INIT(cpr, &tx->tx_sync_lock, callb_generic_cpr, FTAG);
150 mutex_enter(&tx->tx_sync_lock);
154 txg_thread_exit(tx_state_t *tx, callb_cpr_t *cpr, kthread_t **tpp)
156 ASSERT(*tpp != NULL);
159 cv_broadcast(&tx->tx_exit_cv);
160 CALLB_CPR_EXIT(cpr); /* drops &tx->tx_sync_lock */
165 txg_thread_wait(tx_state_t *tx, callb_cpr_t *cpr, kcondvar_t *cv, uint64_t time)
167 CALLB_CPR_SAFE_BEGIN(cpr);
170 (void) cv_timedwait_interruptible(cv, &tx->tx_sync_lock,
171 ddi_get_lbolt() + time);
173 cv_wait_interruptible(cv, &tx->tx_sync_lock);
175 CALLB_CPR_SAFE_END(cpr, &tx->tx_sync_lock);
179 * Stop syncing transaction groups.
182 txg_sync_stop(dsl_pool_t *dp)
184 tx_state_t *tx = &dp->dp_tx;
186 dprintf("pool %p\n", dp);
188 * Finish off any work in progress.
190 ASSERT(tx->tx_threads == 2);
193 * We need to ensure that we've vacated the deferred space_maps.
195 txg_wait_synced(dp, tx->tx_open_txg + TXG_DEFER_SIZE);
198 * Wake all sync threads and wait for them to die.
200 mutex_enter(&tx->tx_sync_lock);
202 ASSERT(tx->tx_threads == 2);
206 cv_broadcast(&tx->tx_quiesce_more_cv);
207 cv_broadcast(&tx->tx_quiesce_done_cv);
208 cv_broadcast(&tx->tx_sync_more_cv);
210 while (tx->tx_threads != 0)
211 cv_wait(&tx->tx_exit_cv, &tx->tx_sync_lock);
215 mutex_exit(&tx->tx_sync_lock);
219 txg_hold_open(dsl_pool_t *dp, txg_handle_t *th)
221 tx_state_t *tx = &dp->dp_tx;
226 * It appears the processor id is simply used as a "random"
227 * number to index into the array, and there isn't any other
228 * significance to the chosen tx_cpu. Because.. Why not use
229 * the current cpu to index into the array?
232 tc = &tx->tx_cpu[CPU_SEQID];
235 mutex_enter(&tc->tc_lock);
237 txg = tx->tx_open_txg;
238 tc->tc_count[txg & TXG_MASK]++;
247 txg_rele_to_quiesce(txg_handle_t *th)
249 tx_cpu_t *tc = th->th_cpu;
251 mutex_exit(&tc->tc_lock);
255 txg_register_callbacks(txg_handle_t *th, list_t *tx_callbacks)
257 tx_cpu_t *tc = th->th_cpu;
258 int g = th->th_txg & TXG_MASK;
260 mutex_enter(&tc->tc_lock);
261 list_move_tail(&tc->tc_callbacks[g], tx_callbacks);
262 mutex_exit(&tc->tc_lock);
266 txg_rele_to_sync(txg_handle_t *th)
268 tx_cpu_t *tc = th->th_cpu;
269 int g = th->th_txg & TXG_MASK;
271 mutex_enter(&tc->tc_lock);
272 ASSERT(tc->tc_count[g] != 0);
273 if (--tc->tc_count[g] == 0)
274 cv_broadcast(&tc->tc_cv[g]);
275 mutex_exit(&tc->tc_lock);
277 th->th_cpu = NULL; /* defensive */
281 txg_quiesce(dsl_pool_t *dp, uint64_t txg)
285 tx_state_t *tx = &dp->dp_tx;
286 int g = txg & TXG_MASK;
290 * Grab all tx_cpu locks so nobody else can get into this txg.
292 for (c = 0; c < max_ncpus; c++)
293 mutex_enter(&tx->tx_cpu[c].tc_lock);
295 ASSERT(txg == tx->tx_open_txg);
299 * Measure how long the txg was open and replace the kstat.
301 th = dsl_pool_txg_history_get(dp, txg);
302 th->th_kstat.open_time = gethrtime() - th->th_kstat.birth;
303 th->th_kstat.state = TXG_STATE_QUIESCING;
304 dsl_pool_txg_history_put(th);
305 dsl_pool_txg_history_add(dp, tx->tx_open_txg);
308 * Now that we've incremented tx_open_txg, we can let threads
309 * enter the next transaction group.
311 for (c = 0; c < max_ncpus; c++)
312 mutex_exit(&tx->tx_cpu[c].tc_lock);
315 * Quiesce the transaction group by waiting for everyone to txg_exit().
319 for (c = 0; c < max_ncpus; c++) {
320 tx_cpu_t *tc = &tx->tx_cpu[c];
321 mutex_enter(&tc->tc_lock);
322 while (tc->tc_count[g] != 0)
323 cv_wait(&tc->tc_cv[g], &tc->tc_lock);
324 mutex_exit(&tc->tc_lock);
328 * Measure how long the txg took to quiesce.
330 th = dsl_pool_txg_history_get(dp, txg);
331 th->th_kstat.quiesce_time = gethrtime() - start;
332 dsl_pool_txg_history_put(th);
336 txg_do_callbacks(list_t *cb_list)
338 dmu_tx_do_callbacks(cb_list, 0);
340 list_destroy(cb_list);
342 kmem_free(cb_list, sizeof (list_t));
346 * Dispatch the commit callbacks registered on this txg to worker threads.
349 txg_dispatch_callbacks(dsl_pool_t *dp, uint64_t txg)
352 tx_state_t *tx = &dp->dp_tx;
355 for (c = 0; c < max_ncpus; c++) {
356 tx_cpu_t *tc = &tx->tx_cpu[c];
357 /* No need to lock tx_cpu_t at this point */
359 int g = txg & TXG_MASK;
361 if (list_is_empty(&tc->tc_callbacks[g]))
364 if (tx->tx_commit_cb_taskq == NULL) {
366 * Commit callback taskq hasn't been created yet.
368 tx->tx_commit_cb_taskq = taskq_create("tx_commit_cb",
369 100, minclsyspri, max_ncpus, INT_MAX,
370 TASKQ_THREADS_CPU_PCT | TASKQ_PREPOPULATE);
373 cb_list = kmem_alloc(sizeof (list_t), KM_PUSHPAGE);
374 list_create(cb_list, sizeof (dmu_tx_callback_t),
375 offsetof(dmu_tx_callback_t, dcb_node));
377 list_move_tail(cb_list, &tc->tc_callbacks[g]);
379 (void) taskq_dispatch(tx->tx_commit_cb_taskq, (task_func_t *)
380 txg_do_callbacks, cb_list, TQ_SLEEP);
385 * Wait for pending commit callbacks of already-synced transactions to finish
387 * Calling this function from within a commit callback will deadlock.
390 txg_wait_callbacks(dsl_pool_t *dp)
392 tx_state_t *tx = &dp->dp_tx;
394 if (tx->tx_commit_cb_taskq != NULL)
395 taskq_wait(tx->tx_commit_cb_taskq);
399 txg_sync_thread(dsl_pool_t *dp)
401 spa_t *spa = dp->dp_spa;
402 tx_state_t *tx = &dp->dp_tx;
404 uint64_t start, delta;
408 * Annotate this process with a flag that indicates that it is
409 * unsafe to use KM_SLEEP during memory allocations due to the
410 * potential for a deadlock. KM_PUSHPAGE should be used instead.
412 current->flags |= PF_NOFS;
415 txg_thread_enter(tx, &cpr);
421 uint64_t timer, timeout;
424 timeout = zfs_txg_timeout * hz;
427 * We sync when we're scanning, there's someone waiting
428 * on us, or the quiesce thread has handed off a txg to
429 * us, or we have reached our timeout.
431 timer = (delta >= timeout ? 0 : timeout - delta);
432 while (!dsl_scan_active(dp->dp_scan) &&
433 !tx->tx_exiting && timer > 0 &&
434 tx->tx_synced_txg >= tx->tx_sync_txg_waiting &&
435 tx->tx_quiesced_txg == 0) {
436 dprintf("waiting; tx_synced=%llu waiting=%llu dp=%p\n",
437 tx->tx_synced_txg, tx->tx_sync_txg_waiting, dp);
438 txg_thread_wait(tx, &cpr, &tx->tx_sync_more_cv, timer);
439 delta = ddi_get_lbolt() - start;
440 timer = (delta > timeout ? 0 : timeout - delta);
444 * Wait until the quiesce thread hands off a txg to us,
445 * prompting it to do so if necessary.
447 while (!tx->tx_exiting && tx->tx_quiesced_txg == 0) {
448 if (tx->tx_quiesce_txg_waiting < tx->tx_open_txg+1)
449 tx->tx_quiesce_txg_waiting = tx->tx_open_txg+1;
450 cv_broadcast(&tx->tx_quiesce_more_cv);
451 txg_thread_wait(tx, &cpr, &tx->tx_quiesce_done_cv, 0);
455 txg_thread_exit(tx, &cpr, &tx->tx_sync_thread);
458 * Consume the quiesced txg which has been handed off to
459 * us. This may cause the quiescing thread to now be
460 * able to quiesce another txg, so we must signal it.
462 txg = tx->tx_quiesced_txg;
463 tx->tx_quiesced_txg = 0;
464 tx->tx_syncing_txg = txg;
465 cv_broadcast(&tx->tx_quiesce_more_cv);
467 th = dsl_pool_txg_history_get(dp, txg);
468 th->th_kstat.state = TXG_STATE_SYNCING;
469 vdev_get_stats(spa->spa_root_vdev, &th->th_vs1);
470 dsl_pool_txg_history_put(th);
472 dprintf("txg=%llu quiesce_txg=%llu sync_txg=%llu\n",
473 txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting);
474 mutex_exit(&tx->tx_sync_lock);
476 start = ddi_get_lbolt();
477 hrstart = gethrtime();
479 delta = ddi_get_lbolt() - start;
481 mutex_enter(&tx->tx_sync_lock);
482 tx->tx_synced_txg = txg;
483 tx->tx_syncing_txg = 0;
484 cv_broadcast(&tx->tx_sync_done_cv);
487 * Dispatch commit callbacks to worker threads.
489 txg_dispatch_callbacks(dp, txg);
492 * Measure the txg sync time determine the amount of I/O done.
494 th = dsl_pool_txg_history_get(dp, txg);
495 vdev_get_stats(spa->spa_root_vdev, &th->th_vs2);
496 th->th_kstat.sync_time = gethrtime() - hrstart;
497 th->th_kstat.nread = th->th_vs2.vs_bytes[ZIO_TYPE_READ] -
498 th->th_vs1.vs_bytes[ZIO_TYPE_READ];
499 th->th_kstat.nwritten = th->th_vs2.vs_bytes[ZIO_TYPE_WRITE] -
500 th->th_vs1.vs_bytes[ZIO_TYPE_WRITE];
501 th->th_kstat.reads = th->th_vs2.vs_ops[ZIO_TYPE_READ] -
502 th->th_vs1.vs_ops[ZIO_TYPE_READ];
503 th->th_kstat.writes = th->th_vs2.vs_ops[ZIO_TYPE_WRITE] -
504 th->th_vs1.vs_ops[ZIO_TYPE_WRITE];
505 th->th_kstat.state = TXG_STATE_COMMITTED;
506 dsl_pool_txg_history_put(th);
511 txg_quiesce_thread(dsl_pool_t *dp)
513 tx_state_t *tx = &dp->dp_tx;
516 txg_thread_enter(tx, &cpr);
522 * We quiesce when there's someone waiting on us.
523 * However, we can only have one txg in "quiescing" or
524 * "quiesced, waiting to sync" state. So we wait until
525 * the "quiesced, waiting to sync" txg has been consumed
526 * by the sync thread.
528 while (!tx->tx_exiting &&
529 (tx->tx_open_txg >= tx->tx_quiesce_txg_waiting ||
530 tx->tx_quiesced_txg != 0))
531 txg_thread_wait(tx, &cpr, &tx->tx_quiesce_more_cv, 0);
534 txg_thread_exit(tx, &cpr, &tx->tx_quiesce_thread);
536 txg = tx->tx_open_txg;
537 dprintf("txg=%llu quiesce_txg=%llu sync_txg=%llu\n",
538 txg, tx->tx_quiesce_txg_waiting,
539 tx->tx_sync_txg_waiting);
540 mutex_exit(&tx->tx_sync_lock);
541 txg_quiesce(dp, txg);
542 mutex_enter(&tx->tx_sync_lock);
545 * Hand this txg off to the sync thread.
547 dprintf("quiesce done, handing off txg %llu\n", txg);
548 tx->tx_quiesced_txg = txg;
549 cv_broadcast(&tx->tx_sync_more_cv);
550 cv_broadcast(&tx->tx_quiesce_done_cv);
555 * Delay this thread by 'ticks' if we are still in the open transaction
556 * group and there is already a waiting txg quiesing or quiesced. Abort
557 * the delay if this txg stalls or enters the quiesing state.
560 txg_delay(dsl_pool_t *dp, uint64_t txg, int ticks)
562 tx_state_t *tx = &dp->dp_tx;
563 clock_t timeout = ddi_get_lbolt() + ticks;
565 /* don't delay if this txg could transition to quiesing immediately */
566 if (tx->tx_open_txg > txg ||
567 tx->tx_syncing_txg == txg-1 || tx->tx_synced_txg == txg-1)
570 mutex_enter(&tx->tx_sync_lock);
571 if (tx->tx_open_txg > txg || tx->tx_synced_txg == txg-1) {
572 mutex_exit(&tx->tx_sync_lock);
576 while (ddi_get_lbolt() < timeout &&
577 tx->tx_syncing_txg < txg-1 && !txg_stalled(dp))
578 (void) cv_timedwait(&tx->tx_quiesce_more_cv, &tx->tx_sync_lock,
581 DMU_TX_STAT_BUMP(dmu_tx_delay);
583 mutex_exit(&tx->tx_sync_lock);
587 txg_wait_synced(dsl_pool_t *dp, uint64_t txg)
589 tx_state_t *tx = &dp->dp_tx;
591 mutex_enter(&tx->tx_sync_lock);
592 ASSERT(tx->tx_threads == 2);
594 txg = tx->tx_open_txg + TXG_DEFER_SIZE;
595 if (tx->tx_sync_txg_waiting < txg)
596 tx->tx_sync_txg_waiting = txg;
597 dprintf("txg=%llu quiesce_txg=%llu sync_txg=%llu\n",
598 txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting);
599 while (tx->tx_synced_txg < txg) {
600 dprintf("broadcasting sync more "
601 "tx_synced=%llu waiting=%llu dp=%p\n",
602 tx->tx_synced_txg, tx->tx_sync_txg_waiting, dp);
603 cv_broadcast(&tx->tx_sync_more_cv);
604 cv_wait(&tx->tx_sync_done_cv, &tx->tx_sync_lock);
606 mutex_exit(&tx->tx_sync_lock);
610 txg_wait_open(dsl_pool_t *dp, uint64_t txg)
612 tx_state_t *tx = &dp->dp_tx;
614 mutex_enter(&tx->tx_sync_lock);
615 ASSERT(tx->tx_threads == 2);
617 txg = tx->tx_open_txg + 1;
618 if (tx->tx_quiesce_txg_waiting < txg)
619 tx->tx_quiesce_txg_waiting = txg;
620 dprintf("txg=%llu quiesce_txg=%llu sync_txg=%llu\n",
621 txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting);
622 while (tx->tx_open_txg < txg) {
623 cv_broadcast(&tx->tx_quiesce_more_cv);
624 cv_wait(&tx->tx_quiesce_done_cv, &tx->tx_sync_lock);
626 mutex_exit(&tx->tx_sync_lock);
630 txg_stalled(dsl_pool_t *dp)
632 tx_state_t *tx = &dp->dp_tx;
633 return (tx->tx_quiesce_txg_waiting > tx->tx_open_txg);
637 txg_sync_waiting(dsl_pool_t *dp)
639 tx_state_t *tx = &dp->dp_tx;
641 return (tx->tx_syncing_txg <= tx->tx_sync_txg_waiting ||
642 tx->tx_quiesced_txg != 0);
646 * Per-txg object lists.
649 txg_list_create(txg_list_t *tl, size_t offset)
653 mutex_init(&tl->tl_lock, NULL, MUTEX_DEFAULT, NULL);
655 tl->tl_offset = offset;
657 for (t = 0; t < TXG_SIZE; t++)
658 tl->tl_head[t] = NULL;
662 txg_list_destroy(txg_list_t *tl)
666 for (t = 0; t < TXG_SIZE; t++)
667 ASSERT(txg_list_empty(tl, t));
669 mutex_destroy(&tl->tl_lock);
673 txg_list_empty(txg_list_t *tl, uint64_t txg)
675 return (tl->tl_head[txg & TXG_MASK] == NULL);
679 * Add an entry to the list.
680 * Returns 0 if it's a new entry, 1 if it's already there.
683 txg_list_add(txg_list_t *tl, void *p, uint64_t txg)
685 int t = txg & TXG_MASK;
686 txg_node_t *tn = (txg_node_t *)((char *)p + tl->tl_offset);
689 mutex_enter(&tl->tl_lock);
690 already_on_list = tn->tn_member[t];
691 if (!already_on_list) {
692 tn->tn_member[t] = 1;
693 tn->tn_next[t] = tl->tl_head[t];
696 mutex_exit(&tl->tl_lock);
698 return (already_on_list);
702 * Add an entry to the end of the list (walks list to find end).
703 * Returns 0 if it's a new entry, 1 if it's already there.
706 txg_list_add_tail(txg_list_t *tl, void *p, uint64_t txg)
708 int t = txg & TXG_MASK;
709 txg_node_t *tn = (txg_node_t *)((char *)p + tl->tl_offset);
712 mutex_enter(&tl->tl_lock);
713 already_on_list = tn->tn_member[t];
714 if (!already_on_list) {
717 for (tp = &tl->tl_head[t]; *tp != NULL; tp = &(*tp)->tn_next[t])
720 tn->tn_member[t] = 1;
721 tn->tn_next[t] = NULL;
724 mutex_exit(&tl->tl_lock);
726 return (already_on_list);
730 * Remove the head of the list and return it.
733 txg_list_remove(txg_list_t *tl, uint64_t txg)
735 int t = txg & TXG_MASK;
739 mutex_enter(&tl->tl_lock);
740 if ((tn = tl->tl_head[t]) != NULL) {
741 p = (char *)tn - tl->tl_offset;
742 tl->tl_head[t] = tn->tn_next[t];
743 tn->tn_next[t] = NULL;
744 tn->tn_member[t] = 0;
746 mutex_exit(&tl->tl_lock);
752 * Remove a specific item from the list and return it.
755 txg_list_remove_this(txg_list_t *tl, void *p, uint64_t txg)
757 int t = txg & TXG_MASK;
758 txg_node_t *tn, **tp;
760 mutex_enter(&tl->tl_lock);
762 for (tp = &tl->tl_head[t]; (tn = *tp) != NULL; tp = &tn->tn_next[t]) {
763 if ((char *)tn - tl->tl_offset == p) {
764 *tp = tn->tn_next[t];
765 tn->tn_next[t] = NULL;
766 tn->tn_member[t] = 0;
767 mutex_exit(&tl->tl_lock);
772 mutex_exit(&tl->tl_lock);
778 txg_list_member(txg_list_t *tl, void *p, uint64_t txg)
780 int t = txg & TXG_MASK;
781 txg_node_t *tn = (txg_node_t *)((char *)p + tl->tl_offset);
783 return (tn->tn_member[t]);
787 * Walk a txg list -- only safe if you know it's not changing.
790 txg_list_head(txg_list_t *tl, uint64_t txg)
792 int t = txg & TXG_MASK;
793 txg_node_t *tn = tl->tl_head[t];
795 return (tn == NULL ? NULL : (char *)tn - tl->tl_offset);
799 txg_list_next(txg_list_t *tl, void *p, uint64_t txg)
801 int t = txg & TXG_MASK;
802 txg_node_t *tn = (txg_node_t *)((char *)p + tl->tl_offset);
806 return (tn == NULL ? NULL : (char *)tn - tl->tl_offset);
809 #if defined(_KERNEL) && defined(HAVE_SPL)
810 EXPORT_SYMBOL(txg_init);
811 EXPORT_SYMBOL(txg_fini);
812 EXPORT_SYMBOL(txg_sync_start);
813 EXPORT_SYMBOL(txg_sync_stop);
814 EXPORT_SYMBOL(txg_hold_open);
815 EXPORT_SYMBOL(txg_rele_to_quiesce);
816 EXPORT_SYMBOL(txg_rele_to_sync);
817 EXPORT_SYMBOL(txg_register_callbacks);
818 EXPORT_SYMBOL(txg_delay);
819 EXPORT_SYMBOL(txg_wait_synced);
820 EXPORT_SYMBOL(txg_wait_open);
821 EXPORT_SYMBOL(txg_wait_callbacks);
822 EXPORT_SYMBOL(txg_stalled);
823 EXPORT_SYMBOL(txg_sync_waiting);
825 module_param(zfs_txg_timeout, int, 0644);
826 MODULE_PARM_DESC(zfs_txg_timeout, "Max seconds worth of delta per txg");