On 07.09.2015 09:34, Fam Zheng wrote: > Sometimes block jobs must execute as a transaction group. Finishing > jobs wait until all other jobs are ready to complete successfully. > Failure or cancellation of one job cancels the other jobs in the group. > > Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com> > [Rewrite the implementation which is now contained in block_job_completed. > --Fam] > Signed-off-by: Fam Zheng <f...@redhat.com> > --- > blockjob.c | 134 > ++++++++++++++++++++++++++++++++++++++++++++++- > include/block/block.h | 1 + > include/block/blockjob.h | 38 ++++++++++++++ > 3 files changed, 171 insertions(+), 2 deletions(-) >
[snip] > diff --git a/include/block/block.h b/include/block/block.h > index e619b99..f80d984 100644 > --- a/include/block/block.h > +++ b/include/block/block.h [snip] > @@ -395,4 +398,39 @@ void block_job_defer_to_main_loop(BlockJob *job, > BlockJobDeferToMainLoopFn *fn, > void *opaque); > > +/** > + * block_job_txn_new: > + * > + * Allocate and return a new block job transaction. Jobs can be added to the > + * transaction using block_job_txn_add_job(). > + * > + * The transaction is automatically freed when the last job completes or is > + * cancelled. > + * > + * All jobs in the transaction either complete successfully or fail/cancel > as a > + * group. Jobs wait for each other before completing. Cancelling one job > + * cancels all jobs in the transaction. > + */ > +BlockJobTxn *block_job_txn_new(void); > + > +/** > + * block_job_txn_unref: > + * > + * Release a reference that was previously acquired with > block_job_txn_add_job > + * or block_job_txn_new. If it's the last reference to the object, it will be > + * freed. > + */ > +void block_job_txn_unref(BlockJobTxn *txn); > + > +/** > + * block_job_txn_add_job: > + * @txn: The transaction (may be NULL) > + * @job: Job to add to the transaction > + * > + * Add @job to the transaction. The @job must not already be in a > transaction. > + * The block job driver must call block_job_txn_prepare_to_complete() before > + * final cleanup and completion. This comment still needs a fixup (block_job_txn_prepare_to_complete() does not exist). Looks good other than that. Max > + */ > +void block_job_txn_add_job(BlockJobTxn *txn, BlockJob *job); > + > #endif >
signature.asc
Description: OpenPGP digital signature