diff --git a/module/zfs/dmu_tx.c b/module/zfs/dmu_tx.c index 5457ca2a8..7954cdbe2 100644 --- a/module/zfs/dmu_tx.c +++ b/module/zfs/dmu_tx.c @@ -1323,6 +1323,7 @@ dmu_tx_destroy(dmu_tx_t *tx) void dmu_tx_commit(dmu_tx_t *tx) { + /* This function should only be used on assigned transactions. */ ASSERT(tx->tx_txg != 0); /* @@ -1361,7 +1362,12 @@ dmu_tx_commit(dmu_tx_t *tx) void dmu_tx_abort(dmu_tx_t *tx) { - ASSERT(tx->tx_txg == 0); + /* This function should not be used on assigned transactions. */ + ASSERT0(tx->tx_txg); + + /* Should not be needed, but better be safe than sorry. */ + if (tx->tx_tempreserve_cookie) + dsl_dir_tempreserve_clear(tx->tx_tempreserve_cookie, tx); /* * Call any registered callbacks with an error code. @@ -1369,6 +1375,9 @@ dmu_tx_abort(dmu_tx_t *tx) if (!list_is_empty(&tx->tx_callbacks)) dmu_tx_do_callbacks(&tx->tx_callbacks, SET_ERROR(ECANCELED)); + /* Should not be needed, but better be safe than sorry. */ + dmu_tx_unassign(tx); + dmu_tx_destroy(tx); } diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index afd9e6131..cacf74dcb 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -1681,7 +1681,7 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp, */ if (inblksz != outzp->z_blksz) { error = SET_ERROR(EINVAL); - dmu_tx_abort(tx); + dmu_tx_commit(tx); break; }