Atul Vidwansa wrote:
> ZFS Experts,
> 
> Is it possible to use DMU as general purpose transaction engine? More
> specifically, in following order:
> 
> 1. Create transaction:
> tx = dmu_tx_create(os);
> error = dmu_tx_assign(tx, TXG_WAIT)
> 
> 2. Decide what to modify(say create new object):
> dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT);
> dmu_tx_hold_bonus(tx, dzp->z_id);
> dmu_tx_hold_zap(tx, dzp->z_id, TRUE, name);
> |
> |
> 
> 3. Commit transaction:
> dmu_tx_commit(tx);
> 
> The reason I am asking for this particular order because I may not
> know the intent of transaction till late in the process.
> If it is not possible, can I at least declare that the transaction is
> going to change N objects (without specification of each object) and
> each change is M blocks at most (without specification of object and
> offset). If yes, how?

You must specify what will be modified (by using dmu_tx_hold_*) before doing 
dmu_tx_assign().  dmu_tx_assign() needs to know what may be modified in order 
to determine if there is enough space available.

You can try to solve this problem by doing dmu_tx_hold_*() on anything that 
*might* be modified.  Hopefully you have enough information up front to 
determine that to some degree of accuracy.  Otherwise, you must go far enough 
in your process to determine what will be modified before doing the 
dmu_tx_hold_*() and dmu_tx_assign().

--matt

Reply via email to