qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Daniel Kucera <daniel.kucera@gmail.com>
Cc: qemu-devel@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	"open list:Block Jobs" <qemu-block@nongnu.org>,
	Jeff Cody <jcody@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Max Reitz <mreitz@redhat.com>,
	jsnow@redhat.com, "Denis V. Lunev" <den@openvz.org>
Subject: Re: [Qemu-devel] [PATCH] mirror: add sync mode incremental to drive-mirror and blockdev-mirror
Date: Mon, 8 May 2017 16:35:56 -0400	[thread overview]
Message-ID: <20170508203556.GA22634@stefanha-x1.localdomain> (raw)
In-Reply-To: <20170504105444.8940-1-daniel.kucera@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3162 bytes --]

On Thu, May 04, 2017 at 12:54:40PM +0200, Daniel Kucera wrote:

Seems like a logical extension along the same lines as the backup block
job's dirty bitmap sync mode.

> parameter bitmap chooses existing dirtymap instead of newly created
> in mirror_start_job
> 
> Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
> ---
>  block/mirror.c            | 47 ++++++++++++++++++++++++++++++-----------------
>  blockdev.c                | 16 +++++++++++++++-
>  include/block/block_int.h |  4 +++-
>  qapi/block-core.json      | 12 ++++++++++--
>  4 files changed, 58 insertions(+), 21 deletions(-)

This patch modifies the user's bitmap in-place and does not
differentiate successful completion from failure.  I suggest following
the same bitmap lifecycle as the backup block job so that
cancellation/failure offers useful behavior.  (If the job fails due to
intermittent errors on the target it should be possible to start the job
again - the bitmap must not be lost!).

> diff --git a/block/mirror.c b/block/mirror.c
> index 9f5eb69..1bfbe2e 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -49,7 +49,7 @@ typedef struct MirrorBlockJob {
>      BlockDriverState *to_replace;
>      /* Used to block operations on the drive-mirror-replace target */
>      Error *replace_blocker;
> -    bool is_none_mode;
> +    MirrorSyncMode sync_mode;
>      BlockMirrorBackingMode backing_mode;
>      BlockdevOnError on_source_error, on_target_error;
>      bool synced;
> @@ -523,7 +523,9 @@ static void mirror_exit(BlockJob *job, void *opaque)
>      bdrv_child_try_set_perm(mirror_top_bs->backing, 0, BLK_PERM_ALL,
>                              &error_abort);
>      if (s->backing_mode == MIRROR_SOURCE_BACKING_CHAIN) {
> -        BlockDriverState *backing = s->is_none_mode ? src : s->base;
> +        BlockDriverState *backing =
> +        (s->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) ||
> +        (s->sync_mode == MIRROR_SYNC_MODE_NONE) ? src : s->base;

Please update the comment in include/block/block_int.h:typedef enum
BlockMirrorBackingMode.

> @@ -1213,9 +1217,21 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs,
>          s->should_complete = true;
>      }
>  
> -    s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp);
> -    if (!s->dirty_bitmap) {
> -        goto fail;
> +    if (s->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
> +        if (bitmap == NULL) {
> +            error_setg(errp, "Mode incremental requires parameter 'bitmap'");
> +            goto fail;
> +        }
> +        s->dirty_bitmap = bdrv_find_dirty_bitmap(bs, bitmap);
> +        if (!s->dirty_bitmap) {
> +            error_setg(errp, "Bitmap '%s' not found", bitmap);
> +            goto fail;
> +        }
> +    } else {
> +        s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp);
> +        if (!s->dirty_bitmap) {
> +            goto fail;
> +        }
>      }

Do we need to check that granularity is compatible with the pre-existing
dirty bitmap's granularity when sync_mode is
MIRROR_SYNC_MODE_INCREMENTAL?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2017-05-08 20:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-04 10:54 [Qemu-devel] [PATCH] mirror: add sync mode incremental to drive-mirror and blockdev-mirror Daniel Kucera
2017-05-08 20:35 ` Stefan Hajnoczi [this message]
2017-05-08 21:02   ` Denis V. Lunev
2017-05-08 21:07     ` John Snow
2017-05-09 16:52       ` Stefan Hajnoczi
2017-05-10 13:25         ` Denis V. Lunev
2017-05-10 15:00           ` Stefan Hajnoczi
2017-05-10 15:05             ` Denis V. Lunev
2017-05-11 14:16               ` Daniel Kučera
2017-05-11 14:28                 ` Denis V. Lunev
2017-05-11 14:52                   ` Daniel Kučera
2017-05-11 18:35                   ` Stefan Hajnoczi
2017-05-11 18:43                     ` John Snow
2017-05-11 18:46                       ` Denis V. Lunev

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=20170508203556.GA22634@stefanha-x1.localdomain \
    --to=stefanha@gmail.com \
    --cc=armbru@redhat.com \
    --cc=daniel.kucera@gmail.com \
    --cc=den@openvz.org \
    --cc=jcody@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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).