1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: John Snow <jsnow@redhat.com>
3 Date: Mon, 6 Apr 2020 12:17:04 +0200
4 Subject: [PATCH] drive-mirror: add support for conditional and always bitmap
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>
21 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
23 block/mirror.c | 24 ++++++++++++++++++------
24 1 file changed, 18 insertions(+), 6 deletions(-)
26 diff --git a/block/mirror.c b/block/mirror.c
27 index 9099c75992..e2ff42067b 100644
30 @@ -680,8 +680,6 @@ static int mirror_exit_common(Job *job)
31 bdrv_unfreeze_backing_chain(mirror_top_bs, target_bs);
34 - bdrv_release_dirty_bitmap(s->dirty_bitmap);
36 /* Make sure that the source BDS doesn't go away during bdrv_replace_node,
37 * before we can call bdrv_drained_end */
39 @@ -782,6 +780,18 @@ static int mirror_exit_common(Job *job)
40 block_job_remove_all_bdrv(bjob);
41 bdrv_replace_node(mirror_top_bs, mirror_top_bs->backing->bs, &error_abort);
43 + if (s->sync_bitmap) {
44 + if (s->bitmap_mode == BITMAP_SYNC_MODE_ALWAYS ||
45 + (s->bitmap_mode == BITMAP_SYNC_MODE_ON_SUCCESS &&
46 + job->ret == 0 && ret == 0)) {
47 + /* Success; synchronize copy back to sync. */
48 + bdrv_clear_dirty_bitmap(s->sync_bitmap, NULL);
49 + bdrv_merge_dirty_bitmap(s->sync_bitmap, s->dirty_bitmap,
50 + NULL, &error_abort);
53 + bdrv_release_dirty_bitmap(s->dirty_bitmap);
55 bs_opaque->job = NULL;
57 bdrv_drained_end(src);
58 @@ -1688,10 +1698,6 @@ static BlockJob *mirror_start_job(
60 MirrorSyncMode_str(sync_mode));
62 - } else if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
64 - "Bitmap Sync Mode '%s' is not supported by Mirror",
65 - BitmapSyncMode_str(bitmap_mode));
69 @@ -1708,6 +1714,12 @@ static BlockJob *mirror_start_job(
72 granularity = bdrv_dirty_bitmap_granularity(bitmap);
74 + if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
75 + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) {
79 } else if (granularity == 0) {
80 granularity = bdrv_get_default_bitmap_granularity(target);