From: Fam Zheng <famz@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Jeff Cody <jcody@redhat.com>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
vsementsov@parallels.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v3 12/15] block/backup: support block job transactions
Date: Tue, 14 Jul 2015 11:12:46 +0800 [thread overview]
Message-ID: <20150714031246.GB24907@ad.nay.redhat.com> (raw)
In-Reply-To: <55A44644.1090604@redhat.com>
On Mon, 07/13 19:14, John Snow wrote:
> > +static void backup_txn_commit(BlockJob *job)
> > +{
> > + BackupBlockJob *s = container_of(job, BackupBlockJob, common);
> > + if (s->sync_bitmap) {
> > + backup_handle_dirty_bitmap(s, 0);
> > + }
> > +}
> > +
> > +static void backup_txn_abort(BlockJob *job)
> > +{
> > + BackupBlockJob *s = container_of(job, BackupBlockJob, common);
> > + if (s->sync_bitmap) {
> > + backup_handle_dirty_bitmap(s, -1);
> > + }
> > +}
> > +
>
> If you're going to check for sync_bitmap out here in these two functions
> instead of inside backup_handle_dirty_bitmap, add an assertion into the
> called function that job->sync_bitmap *will* be present.
The assertion is not really necessary because we'll get a seg fault if it's
NULL.
>
> > static const BlockJobDriver backup_job_driver = {
> > .instance_size = sizeof(BackupBlockJob),
> > .job_type = BLOCK_JOB_TYPE_BACKUP,
> > .set_speed = backup_set_speed,
> > .iostatus_reset = backup_iostatus_reset,
> > + .txn_commit = backup_txn_commit,
> > + .txn_abort = backup_txn_abort,
> > };
> >
> > static BlockErrorAction backup_error_action(BackupBlockJob *job,
> > @@ -444,7 +462,7 @@ static void coroutine_fn backup_run(void *opaque)
> > qemu_co_rwlock_wrlock(&job->flush_rwlock);
> > qemu_co_rwlock_unlock(&job->flush_rwlock);
> >
> > - if (job->sync_bitmap) {
> > + if (!job->common.txn && job->sync_bitmap) {
> > backup_handle_dirty_bitmap(job, ret);
> > }
>
> Can we add a little call to blockjobs, like:
>
> bool block_cleanup_needed(BlockJob *job)
> {
> return job->common.txn == NULL;
> }
>
> To make this status check look less magical?
> Then, if the sync bitmap check is pushed into backup_handle, you can
> just simply say:
>
> if (blockjob_cleanup_needed(job)) {
> backup_handle_dirty_bitmap(job, ret);
> }
>
> which IMO is nicer.
Good idea.
>
> > hbitmap_free(job->bitmap);
> > @@ -463,7 +481,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target,
> > BlockdevOnError on_source_error,
> > BlockdevOnError on_target_error,
> > BlockCompletionFunc *cb, void *opaque,
> > - Error **errp)
> > + BlockJobTxn *txn, Error **errp)
> > {
> > int64_t len;
> >
> > @@ -545,6 +563,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target,
> > sync_bitmap : NULL;
> > job->common.len = len;
> > job->common.co = qemu_coroutine_create(backup_run);
> > + block_job_txn_add_job(txn, &job->common);
>
> OK, so all backup jobs will participate in the transaction -- but they
> can control this based on whether or not they pass forward the txn
> parameter.
It's a NOP if txn is NULL.
>
> > qemu_coroutine_enter(job->common.co, job);
> > return;
> >
next prev parent reply other threads:[~2015-07-14 3:12 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-10 3:46 [Qemu-devel] [PATCH v3 00/15] block: incremental backup transactions using BlockJobTxn Fam Zheng
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 01/15] qapi: Add transaction support to block-dirty-bitmap operations Fam Zheng
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 02/15] iotests: add transactional incremental backup test Fam Zheng
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 03/15] block: rename BlkTransactionState and BdrvActionOps Fam Zheng
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 04/15] block: keep bitmap if incremental backup job is cancelled Fam Zheng
2015-07-13 19:48 ` John Snow
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 05/15] backup: Extract dirty bitmap handling as a separate function Fam Zheng
2015-07-13 23:06 ` John Snow
2015-07-14 2:46 ` Fam Zheng
2015-07-14 8:26 ` Stefan Hajnoczi
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 06/15] blockjob: Add .txn_commit and .txn_abort transaction actions Fam Zheng
2015-07-13 23:06 ` John Snow
2015-07-14 8:35 ` Stefan Hajnoczi
2015-07-14 9:26 ` Fam Zheng
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 07/15] blockjob: Add "completed" and "ret" in BlockJob Fam Zheng
2015-07-13 23:08 ` John Snow
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 08/15] blockjob: Simplify block_job_finish_sync Fam Zheng
2015-07-13 23:08 ` John Snow
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 09/15] blockjob: Move BlockJobDeferToMainLoopData into BlockJob Fam Zheng
2015-07-14 10:03 ` Stefan Hajnoczi
2015-07-14 10:36 ` Fam Zheng
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 10/15] block: add block job transactions Fam Zheng
2015-07-13 23:12 ` John Snow
2015-07-14 3:04 ` Fam Zheng
2015-07-14 15:05 ` John Snow
2015-07-14 10:27 ` Stefan Hajnoczi
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 11/15] blockdev: make BlockJobTxn available to qmp 'transaction' Fam Zheng
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 12/15] block/backup: support block job transactions Fam Zheng
2015-07-13 23:14 ` John Snow
2015-07-14 3:12 ` Fam Zheng [this message]
2015-07-14 10:32 ` Stefan Hajnoczi
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 13/15] iotests: 124 - transactional failure test Fam Zheng
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 14/15] qmp-commands.hx: Update the supported 'transaction' operations Fam Zheng
2015-07-10 3:46 ` [Qemu-devel] [PATCH v3 15/15] tests: add BlockJobTxn unit test Fam Zheng
2015-07-13 23:14 ` John Snow
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=20150714031246.GB24907@ad.nay.redhat.com \
--to=famz@redhat.com \
--cc=armbru@redhat.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--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).