From: Stefan Hajnoczi <stefanha@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Jeff Cody <jcody@redhat.com>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
vsementsov@parallels.com, John Snow <jsnow@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 05/10] block: add block job transactions
Date: Wed, 8 Jul 2015 14:36:26 +0100 [thread overview]
Message-ID: <20150708133626.GC20502@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <20150708015924.GF10382@ad.nay.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3037 bytes --]
On Wed, Jul 08, 2015 at 09:59:24AM +0800, Fam Zheng wrote:
> On Tue, 07/07 13:59, Stefan Hajnoczi wrote:
> > On Tue, Jul 07, 2015 at 03:32:45PM +0800, Fam Zheng wrote:
> > > On Mon, 07/06 15:24, Stefan Hajnoczi wrote:
> > > > +/**
> > > > + * 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
> > >
> > > s/block_job_txn_prepare_to_complete/block_job_txn_job_done/
> > >
> > > Reading this for a second time I start to feel it too complicated for the good.
> > >
> > > I have another idea: in block_job_completed, check if other jobs have failed,
> > > and call this job driver's (imaginary) "abort()" callback accordingly; if all
> > > jobs has succeeded, call a "commit" callback during last block_job_completed.
> > >
> > > Does that make sense?
> >
> > I think you've skipped the hard part: immediate cancellation. If a job
> > is cancelled by the user or a job fails, then all other jobs are
> > cancelled immediately.
> >
> > Immediate cancellation has the problem that jobs could be running in any
> > AioContext, so you need to handle concurrency. That's where the
> > locking, juggling AioContexts, and interaction between blockjobs comes
> > in.
>
> OK, let me try again:
>
> The idea is intercepting job->cb so we can handle jobs completely in
> block_job_completed (which is in main loop), rather than the coroutines that
> can be any AioContext.
>
> 1) If a job is cancelled or failed, it goes to block_job_completed immediately,
> with block_job_is_cancelled() == true. In this case, we call
> block_job_cancel_sync on all other jobs, and then call "abort()" callbacks to
> reclaim any bitmaps, then emit QMP events. Some other jobs may have already
> completed before this point, but it's not a problem because we always defer the
> actual completions (abort/commit and QMP) altogether.
>
> 2) If there is no job failed or canceled, in the last block_job_completed, we
> call "commit()" to abdicate bitmaps, and emit the QMP events.
>
> This would still require BlockJobTxn to track the block jobs in a group, but
> hopefully it could reduce the complexity of interactions between block jobs.
>
> I can prototype it if this isn't missing anything obvious.
Yes, please try it. It's half-way between what John originally did and
what I did. It might be the simplest solution.
Be careful with the final piece of code used to complete jobs from
block_job_defer_to_main_loop(). It runs from a BH in the main loop
after the coroutine has terminated. In the fail/cancel case you might
need to protect against race conditions - especially if two jobs finish
in the same event loop iteration.
I didn't handle that since block_job_txn_job_done() is called while the
coroutine is still alive.
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2015-07-08 13:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-06 14:24 [Qemu-devel] [PATCH v2 00/10] block: incremental backup transactions using BlockJobTxn Stefan Hajnoczi
2015-07-06 14:24 ` [Qemu-devel] [PATCH v2 01/10] qapi: Add transaction support to block-dirty-bitmap operations Stefan Hajnoczi
2015-07-06 14:24 ` [Qemu-devel] [PATCH v2 02/10] iotests: add transactional incremental backup test Stefan Hajnoczi
2015-07-07 6:48 ` Fam Zheng
2015-07-06 14:24 ` [Qemu-devel] [PATCH v2 03/10] block: rename BlkTransactionState and BdrvActionOps Stefan Hajnoczi
2015-07-07 6:50 ` Fam Zheng
2015-07-06 14:24 ` [Qemu-devel] [PATCH v2 04/10] block: keep bitmap if incremental backup job is cancelled Stefan Hajnoczi
2015-07-07 6:51 ` Fam Zheng
2015-07-06 14:24 ` [Qemu-devel] [PATCH v2 05/10] block: add block job transactions Stefan Hajnoczi
2015-07-07 7:32 ` Fam Zheng
2015-07-07 12:59 ` Stefan Hajnoczi
2015-07-08 1:59 ` Fam Zheng
2015-07-08 13:36 ` Stefan Hajnoczi [this message]
2015-07-06 14:24 ` [Qemu-devel] [PATCH v2 06/10] blockdev: make BlockJobTxn available to qmp 'transaction' Stefan Hajnoczi
2015-07-06 14:24 ` [Qemu-devel] [PATCH v2 07/10] block/backup: support block job transactions Stefan Hajnoczi
2015-07-06 14:24 ` [Qemu-devel] [PATCH v2 08/10] iotests: 124 - transactional failure test Stefan Hajnoczi
2015-07-06 14:24 ` [Qemu-devel] [PATCH v2 09/10] qmp-commands.hx: Update the supported 'transaction' operations Stefan Hajnoczi
2015-07-06 14:24 ` [Qemu-devel] [PATCH v2 10/10] tests: add BlockJobTxn unit test Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150708133626.GC20502@stefanha-thinkpad.redhat.com \
--to=stefanha@redhat.com \
--cc=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@parallels.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).