From: John Snow <jsnow@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, John Snow <jsnow@redhat.com>,
jcody@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 7/9] block: add differential backup mode
Date: Thu, 4 Jun 2015 20:20:40 -0400 [thread overview]
Message-ID: <1433463642-21840-8-git-send-email-jsnow@redhat.com> (raw)
In-Reply-To: <1433463642-21840-1-git-send-email-jsnow@redhat.com>
This is simple: instead of clearing the bitmap, just leave the bitmap
data intact even in case of success.
Signed-off-by: John Snow <jsnow@redhat.com>
---
block.c | 9 ++++++++-
block/backup.c | 17 ++++++++++-------
block/mirror.c | 9 +++++++--
include/block/block.h | 1 +
qapi/block-core.json | 6 ++++--
5 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/block.c b/block.c
index 5551f79..3e780f9 100644
--- a/block.c
+++ b/block.c
@@ -3166,7 +3166,9 @@ DirtyBitmapStatus bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap)
* Requires that the bitmap is not frozen and has no successor.
*/
int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs,
- BdrvDirtyBitmap *bitmap, Error **errp)
+ BdrvDirtyBitmap *bitmap,
+ MirrorSyncMode sync_mode,
+ Error **errp)
{
uint64_t granularity;
BdrvDirtyBitmap *child;
@@ -3191,6 +3193,11 @@ int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs,
/* Install the successor and freeze the parent */
bitmap->successor = child;
bitmap->successor_refcount = 1;
+
+ if (sync_mode == MIRROR_SYNC_MODE_DIFFERENTIAL) {
+ bitmap->act = SUCCESSOR_ACTION_RECLAIM;
+ }
+
return 0;
}
diff --git a/block/backup.c b/block/backup.c
index a8f7c43..dd808c2 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -390,7 +390,8 @@ static void coroutine_fn backup_run(void *opaque)
qemu_coroutine_yield();
job->common.busy = true;
}
- } else if (job->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
+ } else if ((job->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) ||
+ (job->sync_mode == MIRROR_SYNC_MODE_DIFFERENTIAL)) {
ret = backup_run_incremental(job);
} else {
/* Both FULL and TOP SYNC_MODE's require copying.. */
@@ -510,15 +511,18 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target,
return;
}
- if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
+ if ((sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) ||
+ (sync_mode == MIRROR_SYNC_MODE_DIFFERENTIAL)) {
if (!sync_bitmap) {
- error_setg(errp, "must provide a valid bitmap name for "
- "\"incremental\" sync mode");
+ error_setg(errp,
+ "must provide a valid bitmap name for \"%s\" sync mode",
+ MirrorSyncMode_lookup[sync_mode]);
return;
}
/* Create a new bitmap, and freeze/disable this one. */
- if (bdrv_dirty_bitmap_create_successor(bs, sync_bitmap, errp) < 0) {
+ if (bdrv_dirty_bitmap_create_successor(bs, sync_bitmap,
+ sync_mode, errp) < 0) {
return;
}
} else if (sync_bitmap) {
@@ -548,8 +552,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target,
job->on_target_error = on_target_error;
job->target = target;
job->sync_mode = sync_mode;
- job->sync_bitmap = sync_mode == MIRROR_SYNC_MODE_INCREMENTAL ?
- sync_bitmap : NULL;
+ job->sync_bitmap = sync_bitmap;
job->common.len = len;
job->common.co = qemu_coroutine_create(backup_run);
qemu_coroutine_enter(job->common.co, job);
diff --git a/block/mirror.c b/block/mirror.c
index adf391c..1cde86b 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -709,9 +709,14 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target,
bool is_none_mode;
BlockDriverState *base;
- if (mode == MIRROR_SYNC_MODE_INCREMENTAL) {
- error_setg(errp, "Sync mode 'incremental' not supported");
+ switch (mode) {
+ case MIRROR_SYNC_MODE_INCREMENTAL:
+ case MIRROR_SYNC_MODE_DIFFERENTIAL:
+ error_setg(errp, "Sync mode \"%s\" not supported",
+ MirrorSyncMode_lookup[mode]);
return;
+ default:
+ break;
}
is_none_mode = mode == MIRROR_SYNC_MODE_NONE;
base = mode == MIRROR_SYNC_MODE_TOP ? bs->backing_hd : NULL;
diff --git a/include/block/block.h b/include/block/block.h
index e88a332..8169a60 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -462,6 +462,7 @@ BdrvDirtyBitmap *bdrv_copy_dirty_bitmap(BlockDriverState *bs,
Error **errp);
int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs,
BdrvDirtyBitmap *bitmap,
+ MirrorSyncMode sync_mode,
Error **errp);
BdrvDirtyBitmap *bdrv_frozen_bitmap_decref(BlockDriverState *bs,
BdrvDirtyBitmap *parent,
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 92c9e53..421fd25 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -534,12 +534,14 @@
#
# @none: only copy data written from now on
#
-# @incremental: only copy data described by the dirty bitmap. Since: 2.4
+# @incremental: Copy data described by the bitmap, and clear it. Since: 2.4
+#
+# @differential: Copy data described by the bitmap, don't clear it. Since: 2.4
#
# Since: 1.3
##
{ 'enum': 'MirrorSyncMode',
- 'data': ['top', 'full', 'none', 'incremental'] }
+ 'data': ['top', 'full', 'none', 'incremental', 'differential'] }
##
# @BlockJobType:
--
2.1.0
next prev parent reply other threads:[~2015-06-05 0:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 0:20 [Qemu-devel] [PATCH 0/9] block: add differential backup support John Snow
2015-06-05 0:20 ` [Qemu-devel] [PATCH 1/9] qapi: Rename 'dirty-bitmap' mode to 'incremental' John Snow
2015-06-05 2:34 ` Eric Blake
2015-06-25 16:16 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-06-05 0:20 ` [Qemu-devel] [PATCH 2/9] hbitmap: add hbitmap_copy John Snow
2015-06-05 2:37 ` Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 3/9] block: add bdrv_copy_dirty_bitmap John Snow
2015-06-05 2:42 ` Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 4/9] qapi: add Copy data type for bitmaps John Snow
2015-06-05 2:57 ` Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 5/9] qmp: add qmp cmd block-dirty-bitmap-copy John Snow
2015-06-05 3:04 ` Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 6/9] qmp: add block-dirty-bitmap-copy transaction John Snow
2015-06-05 0:20 ` John Snow [this message]
2015-06-05 0:20 ` [Qemu-devel] [PATCH 8/9] iotests: 124: support differential backups John Snow
2015-06-05 0:20 ` [Qemu-devel] [PATCH 9/9] iotests: add differential backup test John Snow
2015-06-23 17:00 ` [Qemu-devel] [PATCH 0/9] block: add differential backup support John Snow
2015-06-24 14:33 ` 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=1433463642-21840-8-git-send-email-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@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).