Lines Matching full:tx

43 typedef void (*dmu_tx_hold_func_t)(dmu_tx_t *tx, struct dnode *dn,
67 dmu_tx_t *tx = kmem_zalloc(sizeof (dmu_tx_t), KM_SLEEP); in dmu_tx_create_dd() local
68 tx->tx_dir = dd; in dmu_tx_create_dd()
70 tx->tx_pool = dd->dd_pool; in dmu_tx_create_dd()
71 list_create(&tx->tx_holds, sizeof (dmu_tx_hold_t), in dmu_tx_create_dd()
73 list_create(&tx->tx_callbacks, sizeof (dmu_tx_callback_t), in dmu_tx_create_dd()
75 tx->tx_start = gethrtime(); in dmu_tx_create_dd()
76 return (tx); in dmu_tx_create_dd()
82 dmu_tx_t *tx = dmu_tx_create_dd(os->os_dsl_dataset->ds_dir); in dmu_tx_create() local
83 tx->tx_objset = os; in dmu_tx_create()
84 return (tx); in dmu_tx_create()
90 dmu_tx_t *tx = dmu_tx_create_dd(NULL); in dmu_tx_create_assigned() local
93 tx->tx_pool = dp; in dmu_tx_create_assigned()
94 tx->tx_txg = txg; in dmu_tx_create_assigned()
95 tx->tx_anyobj = TRUE; in dmu_tx_create_assigned()
97 return (tx); in dmu_tx_create_assigned()
101 dmu_tx_is_syncing(dmu_tx_t *tx) in dmu_tx_is_syncing() argument
103 return (tx->tx_anyobj); in dmu_tx_is_syncing()
107 dmu_tx_private_ok(dmu_tx_t *tx) in dmu_tx_private_ok() argument
109 return (tx->tx_anyobj); in dmu_tx_private_ok()
113 dmu_tx_hold_dnode_impl(dmu_tx_t *tx, dnode_t *dn, enum dmu_tx_hold_type type, in dmu_tx_hold_dnode_impl() argument
119 (void) zfs_refcount_add(&dn->dn_holds, tx); in dmu_tx_hold_dnode_impl()
120 if (tx->tx_txg != 0) { in dmu_tx_hold_dnode_impl()
123 * dn->dn_assigned_txg == tx->tx_txg doesn't pose a in dmu_tx_hold_dnode_impl()
128 dn->dn_assigned_txg = tx->tx_txg; in dmu_tx_hold_dnode_impl()
129 (void) zfs_refcount_add(&dn->dn_tx_holds, tx); in dmu_tx_hold_dnode_impl()
135 txh->txh_tx = tx; in dmu_tx_hold_dnode_impl()
142 list_insert_tail(&tx->tx_holds, txh); in dmu_tx_hold_dnode_impl()
148 dmu_tx_hold_object_impl(dmu_tx_t *tx, objset_t *os, uint64_t object, in dmu_tx_hold_object_impl() argument
158 tx->tx_err = err; in dmu_tx_hold_object_impl()
162 txh = dmu_tx_hold_dnode_impl(tx, dn, type, arg1, arg2); in dmu_tx_hold_object_impl()
169 dmu_tx_add_new_object(dmu_tx_t *tx, dnode_t *dn) in dmu_tx_add_new_object() argument
175 if (!dmu_tx_is_syncing(tx)) in dmu_tx_add_new_object()
176 (void) dmu_tx_hold_dnode_impl(tx, dn, THT_NEWOBJECT, 0, 0); in dmu_tx_add_new_object()
355 dmu_tx_hold_write(dmu_tx_t *tx, uint64_t object, uint64_t off, int len) in dmu_tx_hold_write() argument
359 ASSERT0(tx->tx_txg); in dmu_tx_hold_write()
363 txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, in dmu_tx_hold_write()
372 dmu_tx_hold_write_by_dnode(dmu_tx_t *tx, dnode_t *dn, uint64_t off, int len) in dmu_tx_hold_write_by_dnode() argument
376 ASSERT0(tx->tx_txg); in dmu_tx_hold_write_by_dnode()
380 txh = dmu_tx_hold_dnode_impl(tx, dn, THT_WRITE, off, len); in dmu_tx_hold_write_by_dnode()
393 dmu_tx_hold_append(dmu_tx_t *tx, uint64_t object, uint64_t off, int len) in dmu_tx_hold_append() argument
397 ASSERT0(tx->tx_txg); in dmu_tx_hold_append()
400 txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, in dmu_tx_hold_append()
409 dmu_tx_hold_append_by_dnode(dmu_tx_t *tx, dnode_t *dn, uint64_t off, int len) in dmu_tx_hold_append_by_dnode() argument
413 ASSERT0(tx->tx_txg); in dmu_tx_hold_append_by_dnode()
416 txh = dmu_tx_hold_dnode_impl(tx, dn, THT_APPEND, off, DMU_OBJECT_END); in dmu_tx_hold_append_by_dnode()
432 dmu_tx_mark_netfree(dmu_tx_t *tx) in dmu_tx_mark_netfree() argument
434 tx->tx_netfree = B_TRUE; in dmu_tx_mark_netfree()
440 dmu_tx_t *tx = txh->txh_tx; in dmu_tx_count_free() local
444 ASSERT(tx->tx_txg == 0); in dmu_tx_count_free()
491 zio_t *zio = zio_root(tx->tx_pool->dp_spa, in dmu_tx_count_free()
500 tx->tx_err = err; in dmu_tx_count_free()
510 tx->tx_err = err; in dmu_tx_count_free()
517 tx->tx_err = err; in dmu_tx_count_free()
524 dmu_tx_hold_free(dmu_tx_t *tx, uint64_t object, uint64_t off, uint64_t len) in dmu_tx_hold_free() argument
528 txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, in dmu_tx_hold_free()
537 dmu_tx_hold_free_by_dnode(dmu_tx_t *tx, dnode_t *dn, uint64_t off, uint64_t len) in dmu_tx_hold_free_by_dnode() argument
541 txh = dmu_tx_hold_dnode_impl(tx, dn, THT_FREE, off, len); in dmu_tx_hold_free_by_dnode()
559 dmu_tx_hold_clone_by_dnode(dmu_tx_t *tx, dnode_t *dn, uint64_t off, int len) in dmu_tx_hold_clone_by_dnode() argument
563 ASSERT0(tx->tx_txg); in dmu_tx_hold_clone_by_dnode()
566 txh = dmu_tx_hold_dnode_impl(tx, dn, THT_CLONE, off, len); in dmu_tx_hold_clone_by_dnode()
576 dmu_tx_t *tx = txh->txh_tx; in dmu_tx_hold_zap_impl() local
580 ASSERT(tx->tx_txg == 0); in dmu_tx_hold_zap_impl()
594 zap_get_micro_max_size(tx->tx_pool->dp_spa), FTAG); in dmu_tx_hold_zap_impl()
608 tx->tx_err = err; in dmu_tx_hold_zap_impl()
618 tx->tx_err = err; in dmu_tx_hold_zap_impl()
624 dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t object, int add, const char *name) in dmu_tx_hold_zap() argument
628 ASSERT0(tx->tx_txg); in dmu_tx_hold_zap()
630 txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, in dmu_tx_hold_zap()
637 dmu_tx_hold_zap_by_dnode(dmu_tx_t *tx, dnode_t *dn, int add, const char *name) in dmu_tx_hold_zap_by_dnode() argument
641 ASSERT0(tx->tx_txg); in dmu_tx_hold_zap_by_dnode()
644 txh = dmu_tx_hold_dnode_impl(tx, dn, THT_ZAP, add, (uintptr_t)name); in dmu_tx_hold_zap_by_dnode()
650 dmu_tx_hold_bonus(dmu_tx_t *tx, uint64_t object) in dmu_tx_hold_bonus() argument
654 ASSERT(tx->tx_txg == 0); in dmu_tx_hold_bonus()
656 txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, in dmu_tx_hold_bonus()
663 dmu_tx_hold_bonus_by_dnode(dmu_tx_t *tx, dnode_t *dn) in dmu_tx_hold_bonus_by_dnode() argument
667 ASSERT0(tx->tx_txg); in dmu_tx_hold_bonus_by_dnode()
669 txh = dmu_tx_hold_dnode_impl(tx, dn, THT_BONUS, 0, 0); in dmu_tx_hold_bonus_by_dnode()
675 dmu_tx_hold_space(dmu_tx_t *tx, uint64_t space) in dmu_tx_hold_space() argument
679 ASSERT(tx->tx_txg == 0); in dmu_tx_hold_space()
681 txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, in dmu_tx_hold_space()
691 dmu_tx_dirty_buf(dmu_tx_t *tx, dmu_buf_impl_t *db) in dmu_tx_dirty_buf() argument
698 ASSERT(tx->tx_txg != 0); in dmu_tx_dirty_buf()
699 ASSERT(tx->tx_objset == NULL || dn->dn_objset == tx->tx_objset); in dmu_tx_dirty_buf()
702 if (tx->tx_anyobj) { in dmu_tx_dirty_buf()
713 for (dmu_tx_hold_t *txh = list_head(&tx->tx_holds); txh != NULL; in dmu_tx_dirty_buf()
714 txh = list_next(&tx->tx_holds, txh)) { in dmu_tx_dirty_buf()
715 ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg); in dmu_tx_dirty_buf()
927 dmu_tx_delay(dmu_tx_t *tx, uint64_t dirty) in dmu_tx_delay() argument
929 dsl_pool_t *dp = tx->tx_pool; in dmu_tx_delay()
965 if (now > tx->tx_start + tx_time) in dmu_tx_delay()
968 DTRACE_PROBE3(delay__mintime, dmu_tx_t *, tx, uint64_t, dirty, in dmu_tx_delay()
972 wakeup = MAX(tx->tx_start + tx_time, dp->dp_last_wakeup + tx_time); in dmu_tx_delay()
1019 dmu_tx_try_assign(dmu_tx_t *tx, uint64_t txg_how) in dmu_tx_try_assign() argument
1021 spa_t *spa = tx->tx_pool->dp_spa; in dmu_tx_try_assign()
1023 ASSERT0(tx->tx_txg); in dmu_tx_try_assign()
1025 if (tx->tx_err) { in dmu_tx_try_assign()
1027 return (tx->tx_err); in dmu_tx_try_assign()
1049 if (!tx->tx_dirty_delayed && in dmu_tx_try_assign()
1050 dsl_pool_need_wrlog_delay(tx->tx_pool)) { in dmu_tx_try_assign()
1051 tx->tx_wait_dirty = B_TRUE; in dmu_tx_try_assign()
1056 if (!tx->tx_dirty_delayed && in dmu_tx_try_assign()
1057 dsl_pool_need_dirty_delay(tx->tx_pool)) { in dmu_tx_try_assign()
1058 tx->tx_wait_dirty = B_TRUE; in dmu_tx_try_assign()
1063 tx->tx_txg = txg_hold_open(tx->tx_pool, &tx->tx_txgh); in dmu_tx_try_assign()
1064 tx->tx_needassign_txh = NULL; in dmu_tx_try_assign()
1074 for (dmu_tx_hold_t *txh = list_head(&tx->tx_holds); txh != NULL; in dmu_tx_try_assign()
1075 txh = list_next(&tx->tx_holds, txh)) { in dmu_tx_try_assign()
1080 * while assigning the tx, because this can lead to in dmu_tx_try_assign()
1086 * syncing until its tx can complete (calling in dmu_tx_try_assign()
1098 if (dn->dn_assigned_txg == tx->tx_txg - 1) { in dmu_tx_try_assign()
1100 tx->tx_needassign_txh = txh; in dmu_tx_try_assign()
1105 dn->dn_assigned_txg = tx->tx_txg; in dmu_tx_try_assign()
1106 ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg); in dmu_tx_try_assign()
1107 (void) zfs_refcount_add(&dn->dn_tx_holds, tx); in dmu_tx_try_assign()
1115 uint64_t asize = spa_get_worst_case_asize(tx->tx_pool->dp_spa, towrite); in dmu_tx_try_assign()
1119 if (tx->tx_dir != NULL && asize != 0) { in dmu_tx_try_assign()
1120 int err = dsl_dir_tempreserve_space(tx->tx_dir, memory, in dmu_tx_try_assign()
1121 asize, tx->tx_netfree, &tx->tx_tempreserve_cookie, tx); in dmu_tx_try_assign()
1132 dmu_tx_unassign(dmu_tx_t *tx) in dmu_tx_unassign() argument
1134 if (tx->tx_txg == 0) in dmu_tx_unassign()
1137 txg_rele_to_quiesce(&tx->tx_txgh); in dmu_tx_unassign()
1143 for (dmu_tx_hold_t *txh = list_head(&tx->tx_holds); in dmu_tx_unassign()
1144 txh && txh != tx->tx_needassign_txh; in dmu_tx_unassign()
1145 txh = list_next(&tx->tx_holds, txh)) { in dmu_tx_unassign()
1151 ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg); in dmu_tx_unassign()
1153 if (zfs_refcount_remove(&dn->dn_tx_holds, tx) == 0) { in dmu_tx_unassign()
1160 txg_rele_to_sync(&tx->tx_txgh); in dmu_tx_unassign()
1162 tx->tx_lasttried_txg = tx->tx_txg; in dmu_tx_unassign()
1163 tx->tx_txg = 0; in dmu_tx_unassign()
1167 * Assign tx to a transaction group; txg_how is a bitmask:
1180 * If TXG_NOTHROTTLE is set, this indicates that this tx should not be
1184 * different tx).
1187 * will assign the tx to monotonically increasing txgs. Of course this is
1203 dmu_tx_assign(dmu_tx_t *tx, uint64_t txg_how) in dmu_tx_assign() argument
1207 ASSERT(tx->tx_txg == 0); in dmu_tx_assign()
1209 ASSERT(!dsl_pool_sync_context(tx->tx_pool)); in dmu_tx_assign()
1212 IMPLY((txg_how & TXG_WAIT), !dsl_pool_config_held(tx->tx_pool)); in dmu_tx_assign()
1215 tx->tx_dirty_delayed = B_TRUE; in dmu_tx_assign()
1217 while ((err = dmu_tx_try_assign(tx, txg_how)) != 0) { in dmu_tx_assign()
1218 dmu_tx_unassign(tx); in dmu_tx_assign()
1223 dmu_tx_wait(tx); in dmu_tx_assign()
1226 txg_rele_to_quiesce(&tx->tx_txgh); in dmu_tx_assign()
1232 dmu_tx_wait(dmu_tx_t *tx) in dmu_tx_wait() argument
1234 spa_t *spa = tx->tx_pool->dp_spa; in dmu_tx_wait()
1235 dsl_pool_t *dp = tx->tx_pool; in dmu_tx_wait()
1238 ASSERT(tx->tx_txg == 0); in dmu_tx_wait()
1239 ASSERT(!dsl_pool_config_held(tx->tx_pool)); in dmu_tx_wait()
1243 if (tx->tx_wait_dirty) { in dmu_tx_wait()
1259 dmu_tx_delay(tx, dirty); in dmu_tx_wait()
1261 tx->tx_wait_dirty = B_FALSE; in dmu_tx_wait()
1266 * destroy this tx and try again. The common case, in dmu_tx_wait()
1269 tx->tx_dirty_delayed = B_TRUE; in dmu_tx_wait()
1270 } else if (spa_suspended(spa) || tx->tx_lasttried_txg == 0) { in dmu_tx_wait()
1275 * obtain a tx. If that's the case then tx_lasttried_txg in dmu_tx_wait()
1279 } else if (tx->tx_needassign_txh) { in dmu_tx_wait()
1280 dnode_t *dn = tx->tx_needassign_txh->txh_dnode; in dmu_tx_wait()
1283 while (dn->dn_assigned_txg == tx->tx_lasttried_txg - 1) in dmu_tx_wait()
1286 tx->tx_needassign_txh = NULL; in dmu_tx_wait()
1300 dmu_tx_destroy(dmu_tx_t *tx) in dmu_tx_destroy() argument
1304 while ((txh = list_head(&tx->tx_holds)) != NULL) { in dmu_tx_destroy()
1307 list_remove(&tx->tx_holds, txh); in dmu_tx_destroy()
1314 dnode_rele(dn, tx); in dmu_tx_destroy()
1317 list_destroy(&tx->tx_callbacks); in dmu_tx_destroy()
1318 list_destroy(&tx->tx_holds); in dmu_tx_destroy()
1319 kmem_free(tx, sizeof (dmu_tx_t)); in dmu_tx_destroy()
1323 dmu_tx_commit(dmu_tx_t *tx) in dmu_tx_commit() argument
1325 ASSERT(tx->tx_txg != 0); in dmu_tx_commit()
1331 for (dmu_tx_hold_t *txh = list_head(&tx->tx_holds); txh != NULL; in dmu_tx_commit()
1332 txh = list_next(&tx->tx_holds, txh)) { in dmu_tx_commit()
1339 ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg); in dmu_tx_commit()
1341 if (zfs_refcount_remove(&dn->dn_tx_holds, tx) == 0) { in dmu_tx_commit()
1348 if (tx->tx_tempreserve_cookie) in dmu_tx_commit()
1349 dsl_dir_tempreserve_clear(tx->tx_tempreserve_cookie, tx); in dmu_tx_commit()
1351 if (!list_is_empty(&tx->tx_callbacks)) in dmu_tx_commit()
1352 txg_register_callbacks(&tx->tx_txgh, &tx->tx_callbacks); in dmu_tx_commit()
1354 if (tx->tx_anyobj == FALSE) in dmu_tx_commit()
1355 txg_rele_to_sync(&tx->tx_txgh); in dmu_tx_commit()
1357 dmu_tx_destroy(tx); in dmu_tx_commit()
1361 dmu_tx_abort(dmu_tx_t *tx) in dmu_tx_abort() argument
1363 ASSERT(tx->tx_txg == 0); in dmu_tx_abort()
1368 if (!list_is_empty(&tx->tx_callbacks)) in dmu_tx_abort()
1369 dmu_tx_do_callbacks(&tx->tx_callbacks, SET_ERROR(ECANCELED)); in dmu_tx_abort()
1371 dmu_tx_destroy(tx); in dmu_tx_abort()
1375 dmu_tx_get_txg(dmu_tx_t *tx) in dmu_tx_get_txg() argument
1377 ASSERT(tx->tx_txg != 0); in dmu_tx_get_txg()
1378 return (tx->tx_txg); in dmu_tx_get_txg()
1382 dmu_tx_pool(dmu_tx_t *tx) in dmu_tx_pool() argument
1384 ASSERT(tx->tx_pool != NULL); in dmu_tx_pool()
1385 return (tx->tx_pool); in dmu_tx_pool()
1396 dmu_tx_callback_register(dmu_tx_t *tx, dmu_tx_callback_func_t *func, void *data) in dmu_tx_callback_register() argument
1405 list_insert_tail(&tx->tx_callbacks, dcb); in dmu_tx_callback_register()
1437 dmu_tx_sa_registration_hold(sa_os_t *sa, dmu_tx_t *tx) in dmu_tx_sa_registration_hold() argument
1445 dmu_tx_hold_zap(tx, sa->sa_reg_attr_obj, in dmu_tx_sa_registration_hold()
1448 dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, in dmu_tx_sa_registration_hold()
1455 dmu_tx_hold_spill(dmu_tx_t *tx, uint64_t object) in dmu_tx_hold_spill() argument
1459 txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, object, in dmu_tx_hold_spill()
1467 dmu_tx_hold_sa_create(dmu_tx_t *tx, int attrsize) in dmu_tx_hold_sa_create() argument
1469 sa_os_t *sa = tx->tx_objset->os_sa; in dmu_tx_hold_sa_create()
1471 dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); in dmu_tx_hold_sa_create()
1473 if (tx->tx_objset->os_sa->sa_master_obj == 0) in dmu_tx_hold_sa_create()
1476 if (tx->tx_objset->os_sa->sa_layout_attr_obj) { in dmu_tx_hold_sa_create()
1477 dmu_tx_hold_zap(tx, sa->sa_layout_attr_obj, B_TRUE, NULL); in dmu_tx_hold_sa_create()
1479 dmu_tx_hold_zap(tx, sa->sa_master_obj, B_TRUE, SA_LAYOUTS); in dmu_tx_hold_sa_create()
1480 dmu_tx_hold_zap(tx, sa->sa_master_obj, B_TRUE, SA_REGISTRY); in dmu_tx_hold_sa_create()
1481 dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, B_TRUE, NULL); in dmu_tx_hold_sa_create()
1482 dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, B_TRUE, NULL); in dmu_tx_hold_sa_create()
1485 dmu_tx_sa_registration_hold(sa, tx); in dmu_tx_hold_sa_create()
1490 (void) dmu_tx_hold_object_impl(tx, tx->tx_objset, DMU_NEW_OBJECT, in dmu_tx_hold_sa_create()
1497 * dmu_tx_hold_sa(dmu_tx_t *tx, sa_handle_t *, attribute, add, size)
1504 dmu_tx_hold_sa(dmu_tx_t *tx, sa_handle_t *hdl, boolean_t may_grow) in dmu_tx_hold_sa() argument
1507 sa_os_t *sa = tx->tx_objset->os_sa; in dmu_tx_hold_sa()
1515 dmu_tx_hold_bonus_by_dnode(tx, DB_DNODE(db)); in dmu_tx_hold_sa()
1518 if (tx->tx_objset->os_sa->sa_master_obj == 0) in dmu_tx_hold_sa()
1521 if (tx->tx_objset->os_sa->sa_reg_attr_obj == 0 || in dmu_tx_hold_sa()
1522 tx->tx_objset->os_sa->sa_layout_attr_obj == 0) { in dmu_tx_hold_sa()
1523 dmu_tx_hold_zap(tx, sa->sa_master_obj, B_TRUE, SA_LAYOUTS); in dmu_tx_hold_sa()
1524 dmu_tx_hold_zap(tx, sa->sa_master_obj, B_TRUE, SA_REGISTRY); in dmu_tx_hold_sa()
1525 dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, B_TRUE, NULL); in dmu_tx_hold_sa()
1526 dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, B_TRUE, NULL); in dmu_tx_hold_sa()
1529 dmu_tx_sa_registration_hold(sa, tx); in dmu_tx_hold_sa()
1531 if (may_grow && tx->tx_objset->os_sa->sa_layout_attr_obj) in dmu_tx_hold_sa()
1532 dmu_tx_hold_zap(tx, sa->sa_layout_attr_obj, B_TRUE, NULL); in dmu_tx_hold_sa()
1535 ASSERT(tx->tx_txg == 0); in dmu_tx_hold_sa()
1536 dmu_tx_hold_spill(tx, object); in dmu_tx_hold_sa()
1540 ASSERT(tx->tx_txg == 0); in dmu_tx_hold_sa()
1541 dmu_tx_hold_spill(tx, object); in dmu_tx_hold_sa()