* Prepare the txg subsystem. */
| 117 | * Prepare the txg subsystem. |
| 118 | */ |
| 119 | void |
| 120 | txg_init(dsl_pool_t *dp, uint64_t txg) |
| 121 | { |
| 122 | tx_state_t *tx = &dp->dp_tx; |
| 123 | int c; |
| 124 | bzero(tx, sizeof (tx_state_t)); |
| 125 | |
| 126 | tx->tx_cpu = vmem_zalloc(max_ncpus * sizeof (tx_cpu_t), KM_SLEEP); |
| 127 | |
| 128 | for (c = 0; c < max_ncpus; c++) { |
| 129 | int i; |
| 130 | |
| 131 | mutex_init(&tx->tx_cpu[c].tc_lock, NULL, MUTEX_DEFAULT, NULL); |
| 132 | mutex_init(&tx->tx_cpu[c].tc_open_lock, NULL, MUTEX_NOLOCKDEP, |
| 133 | NULL); |
| 134 | for (i = 0; i < TXG_SIZE; i++) { |
| 135 | cv_init(&tx->tx_cpu[c].tc_cv[i], NULL, CV_DEFAULT, |
| 136 | NULL); |
| 137 | list_create(&tx->tx_cpu[c].tc_callbacks[i], |
| 138 | sizeof (dmu_tx_callback_t), |
| 139 | offsetof(dmu_tx_callback_t, dcb_node)); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | mutex_init(&tx->tx_sync_lock, NULL, MUTEX_DEFAULT, NULL); |
| 144 | |
| 145 | cv_init(&tx->tx_sync_more_cv, NULL, CV_DEFAULT, NULL); |
| 146 | cv_init(&tx->tx_sync_done_cv, NULL, CV_DEFAULT, NULL); |
| 147 | cv_init(&tx->tx_quiesce_more_cv, NULL, CV_DEFAULT, NULL); |
| 148 | cv_init(&tx->tx_quiesce_done_cv, NULL, CV_DEFAULT, NULL); |
| 149 | cv_init(&tx->tx_exit_cv, NULL, CV_DEFAULT, NULL); |
| 150 | |
| 151 | tx->tx_open_txg = txg; |
| 152 | } |
| 153 | |
| 154 | /* |
| 155 | * Close down the txg subsystem. |
no test coverage detected