All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: Max Reitz <mreitz@redhat.com>, Fam Zheng <famz@redhat.com>,
	qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Benoit Canet <benoit@irqsave.net>,
	Markus Armbruster <armbru@redhat.com>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Jd <jd_jedi@convirture.com>, Paolo Bonzini <pbonzini@redhat.com>,
	Vladimir Sementsov-Ogievskij <etendren@gmail.com>
Subject: Re: [Qemu-devel] [PATCH v6 08/10] qapi: Add transaction support to block-dirty-bitmap-{add, enable, disable}
Date: Fri, 21 Nov 2014 17:24:19 -0500	[thread overview]
Message-ID: <546FBB93.7000809@redhat.com> (raw)
In-Reply-To: <5458B279.8010300@redhat.com>



On 11/04/2014 06:03 AM, Max Reitz wrote:
> On 2014-10-30 at 04:22, Fam Zheng wrote:
>> This adds three qmp commands to transactions.
>>
>> Users can stop a dirty bitmap, start backup of it, and start another
>> dirty bitmap atomically, so that the dirty bitmap is tracked
>> incrementally and we don't miss any write.
>>
>> Signed-off-by: Fam Zheng <famz@redhat.com>
>> ---
>>   blockdev.c       | 92
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   qapi-schema.json |  5 ++-
>>   2 files changed, 96 insertions(+), 1 deletion(-)
>>
>> diff --git a/blockdev.c b/blockdev.c
>> index fca909b..34fa314 100644
>> --- a/blockdev.c
>> +++ b/blockdev.c
>> @@ -1490,6 +1490,83 @@ static void
>> drive_backup_abort(BlkTransactionState *common)
>>       }
>>   }
>> +static void block_dirty_bitmap_add_prepare(BlkTransactionState *common,
>> +                                           Error **errp)
>> +{
>> +    BlockDirtyBitmapAdd *action;
>> +
>> +    action = common->action->block_dirty_bitmap_add;
>> +    qmp_block_dirty_bitmap_add(action->device, action->name,
>> +                               action->has_granularity,
>> action->granularity,
>> +                               errp);
>> +}
>> +
>> +static void block_dirty_bitmap_add_abort(BlkTransactionState *common)
>> +{
>> +    BlockDirtyBitmapAdd *action;
>> +    BdrvDirtyBitmap *bm;
>> +    BlockDriverState *bs;
>> +
>> +    action = common->action->block_dirty_bitmap_add;
>> +    bs = bdrv_find(action->device);
>> +    if (bs) {
>> +        bm = bdrv_find_dirty_bitmap(bs, action->name);
>> +        if (bm) {
>> +            bdrv_release_dirty_bitmap(bs, bm);
>> +        }
>> +    }
>> +}
>> +
>> +static void block_dirty_bitmap_enable_prepare(BlkTransactionState
>> *common,
>> +                                               Error **errp)
>> +{
>> +    BlockDirtyBitmap *action;
>> +
>> +    action = common->action->block_dirty_bitmap_enable;
>> +    qmp_block_dirty_bitmap_enable(action->device, action->name, errp);
>> +}
>> +
>> +static void block_dirty_bitmap_enable_abort(BlkTransactionState *common)
>> +{
>> +    BlockDirtyBitmap *action;
>> +    BdrvDirtyBitmap *bitmap;
>> +    BlockDriverState *bs;
>> +
>> +    action = common->action->block_dirty_bitmap_enable;
>> +    bs = bdrv_find(action->device);
>> +    if (bs) {
>> +        bitmap = bdrv_find_dirty_bitmap(bs, action->name);
>> +        if (bitmap) {
>> +            bdrv_disable_dirty_bitmap(bs, bitmap);
>
> But what if the dirty bitmap was enabled before so that this enabling
> transaction was supposed to be a no-op?

Maybe it's not a problem: The only case in which the enable/disable 
operation will fail is if it cannot find the device or bitmap -- in 
which case, the abort operation isn't going to be able to affect 
anything either.

Unless you know something I don't.

Still, it does look goofy. Thoughts?

>> +        }
>> +    }
>> +}
>> +
>> +static void block_dirty_bitmap_disable_prepare(BlkTransactionState
>> *common,
>> +                                               Error **errp)
>> +{
>> +    BlockDirtyBitmap *action;
>> +
>> +    action = common->action->block_dirty_bitmap_disable;
>> +    qmp_block_dirty_bitmap_disable(action->device, action->name, errp);
>> +}
>> +
>> +static void block_dirty_bitmap_disable_abort(BlkTransactionState
>> *common)
>> +{
>> +    BlockDirtyBitmap *action;
>> +    BdrvDirtyBitmap *bitmap;
>> +    BlockDriverState *bs;
>> +
>> +    action = common->action->block_dirty_bitmap_disable;
>> +    bs = bdrv_find(action->device);
>> +    if (bs) {
>> +        bitmap = bdrv_find_dirty_bitmap(bs, action->name);
>> +        if (bitmap) {
>> +            bdrv_enable_dirty_bitmap(bs, bitmap);
>
> Same here, the other way round.
>
>> +        }
>> +    }
>> +}
>> +
>>   static void abort_prepare(BlkTransactionState *common, Error **errp)
>>   {
>>       error_setg(errp, "Transaction aborted using Abort action");
>> @@ -1522,6 +1599,21 @@ static const BdrvActionOps actions[] = {
>>           .prepare  = internal_snapshot_prepare,
>>           .abort = internal_snapshot_abort,
>>       },
>> +    [TRANSACTION_ACTION_KIND_BLOCK_DIRTY_BITMAP_ADD] = {
>> +        .instance_size = sizeof(BlkTransactionState),
>> +        .prepare = block_dirty_bitmap_add_prepare,
>> +        .abort = block_dirty_bitmap_add_abort,
>> +    },
>> +    [TRANSACTION_ACTION_KIND_BLOCK_DIRTY_BITMAP_ENABLE] = {
>> +        .instance_size = sizeof(BlkTransactionState),
>> +        .prepare = block_dirty_bitmap_enable_prepare,
>> +        .abort = block_dirty_bitmap_enable_abort,
>> +    },
>> +    [TRANSACTION_ACTION_KIND_BLOCK_DIRTY_BITMAP_DISABLE] = {
>> +        .instance_size = sizeof(BlkTransactionState),
>> +        .prepare = block_dirty_bitmap_disable_prepare,
>> +        .abort = block_dirty_bitmap_disable_abort,
>> +    },
>>   };
>>   /*
>> diff --git a/qapi-schema.json b/qapi-schema.json
>> index 24379ab..ae07677 100644
>> --- a/qapi-schema.json
>> +++ b/qapi-schema.json
>> @@ -1260,7 +1260,10 @@
>>          'blockdev-snapshot-sync': 'BlockdevSnapshot',
>>          'drive-backup': 'DriveBackup',
>>          'abort': 'Abort',
>> -       'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternal'
>> +       'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternal',
>> +       'block-dirty-bitmap-add': 'BlockDirtyBitmapAdd',
>
> Ah, you're reusing that type here. Very well then.
>
> Max
>
>> +       'block-dirty-bitmap-enable': 'BlockDirtyBitmap',
>> +       'block-dirty-bitmap-disable': 'BlockDirtyBitmap'
>>      } }
>>   ##
>
>

-- 
—js

  reply	other threads:[~2014-11-21 22:24 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-30  3:22 [Qemu-devel] [PATCH v6 00/10] block: Incremental backup series Fam Zheng
2014-10-30  3:22 ` [Qemu-devel] [PATCH v6 01/10] qapi: Add optional field "name" to block dirty bitmap Fam Zheng
2014-11-04  9:08   ` Max Reitz
2014-11-07 12:48   ` Eric Blake
2014-10-30  3:22 ` [Qemu-devel] [PATCH v6 02/10] qmp: Add block-dirty-bitmap-add and block-dirty-bitmap-remove Fam Zheng
2014-11-04  9:26   ` Max Reitz
2014-11-07 13:00   ` Eric Blake
2014-11-18 16:44     ` [Qemu-devel] qmp-commands.hx and inherited types (Was: Re: [PATCH v6 02/10] qmp: Add block-dirty-bitmap-add and block-dirty-bitmap-remove) John Snow
2014-11-18 17:00       ` Eric Blake
2014-10-30  3:22 ` [Qemu-devel] [PATCH v6 03/10] block: Introduce bdrv_dirty_bitmap_granularity() Fam Zheng
2014-11-04  9:44   ` Max Reitz
2014-10-30  3:22 ` [Qemu-devel] [PATCH v6 04/10] hbitmap: Add hbitmap_copy Fam Zheng
2014-11-04  9:58   ` Max Reitz
2014-10-30  3:22 ` [Qemu-devel] [PATCH v6 05/10] block: Add bdrv_copy_dirty_bitmap and bdrv_reset_dirty_bitmap Fam Zheng
2014-11-04 10:08   ` Max Reitz
2014-10-30  3:22 ` [Qemu-devel] [PATCH v6 06/10] qmp: Add block-dirty-bitmap-enable and block-dirty-bitmap-disable Fam Zheng
2014-11-04 10:17   ` Max Reitz
2014-10-30  3:22 ` [Qemu-devel] [PATCH v6 07/10] qmp: Add support of "dirty-bitmap" sync mode for drive-backup Fam Zheng
2014-11-04 10:53   ` Max Reitz
2014-10-30  3:22 ` [Qemu-devel] [PATCH v6 08/10] qapi: Add transaction support to block-dirty-bitmap-{add, enable, disable} Fam Zheng
2014-11-04 11:03   ` Max Reitz
2014-11-21 22:24     ` John Snow [this message]
2014-11-24  8:35       ` Max Reitz
2014-11-24  9:41         ` Paolo Bonzini
2014-11-24  9:46           ` Max Reitz
2014-11-24  9:54             ` Paolo Bonzini
2014-10-30  3:22 ` [Qemu-devel] [PATCH v6 09/10] qmp: Add dirty bitmap 'enabled' field in query-block Fam Zheng
2014-11-04 11:05   ` Max Reitz
2014-10-30  3:22 ` [Qemu-devel] [PATCH v6 10/10] qemu-iotests: Add tests for drive-backup sync=dirty-bitmap Fam Zheng
2014-11-04 11:10   ` Max Reitz

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=546FBB93.7000809@redhat.com \
    --to=jsnow@redhat.com \
    --cc=armbru@redhat.com \
    --cc=benoit@irqsave.net \
    --cc=etendren@gmail.com \
    --cc=famz@redhat.com \
    --cc=jd_jedi@convirture.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.