1 From 4c46f8b0f6fd8efba5e4d0b738b4f01ffcb92d33 Mon Sep 17 00:00:00 2001
2 From: John Snow <jsnow@redhat.com>
3 Date: Tue, 9 Jul 2019 21:12:30 -0400
4 Subject: [PATCH qemu 35/39] drive-mirror: add support for conditional and
5 always bitmap sync modes
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 Teach mirror two new tricks for using bitmaps:
12 Always: no matter what, we synchronize the copy_bitmap back to the
13 sync_bitmap. In effect, this allows us resume a failed mirror at a later
16 Conditional: On success only, we sync the bitmap. This is akin to
17 incremental backup modes; we can use this bitmap to later refresh a
18 successfully created mirror.
20 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
22 block/mirror.c | 24 ++++++++++++++++++------
23 1 file changed, 18 insertions(+), 6 deletions(-)
25 diff --git a/block/mirror.c b/block/mirror.c
26 index fd7f574365..40d174a625 100644
29 @@ -645,8 +645,6 @@ static int mirror_exit_common(Job *job)
30 bdrv_unfreeze_backing_chain(mirror_top_bs, target_bs);
33 - bdrv_release_dirty_bitmap(s->dirty_bitmap);
35 /* Make sure that the source BDS doesn't go away during bdrv_replace_node,
36 * before we can call bdrv_drained_end */
38 @@ -731,6 +729,18 @@ static int mirror_exit_common(Job *job)
39 blk_set_perm(bjob->blk, 0, BLK_PERM_ALL, &error_abort);
40 blk_insert_bs(bjob->blk, mirror_top_bs, &error_abort);
42 + if (s->sync_bitmap) {
43 + if (s->bitmap_mode == BITMAP_SYNC_MODE_ALWAYS ||
44 + (s->bitmap_mode == BITMAP_SYNC_MODE_ON_SUCCESS &&
45 + job->ret == 0 && ret == 0)) {
46 + /* Success; synchronize copy back to sync. */
47 + bdrv_clear_dirty_bitmap(s->sync_bitmap, NULL);
48 + bdrv_merge_dirty_bitmap(s->sync_bitmap, s->dirty_bitmap,
49 + NULL, &error_abort);
52 + bdrv_release_dirty_bitmap(s->dirty_bitmap);
54 bs_opaque->job = NULL;
56 bdrv_drained_end(src);
57 @@ -1562,10 +1572,6 @@ static BlockJob *mirror_start_job(
59 MirrorSyncMode_str(sync_mode));
61 - } else if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
63 - "Bitmap Sync Mode '%s' is not supported by Mirror",
64 - BitmapSyncMode_str(bitmap_mode));
68 @@ -1582,6 +1588,12 @@ static BlockJob *mirror_start_job(
71 granularity = bdrv_dirty_bitmap_granularity(bitmap);
73 + if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
74 + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) {
78 } else if (granularity == 0) {
79 granularity = bdrv_get_default_bitmap_granularity(target);