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>
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 100e828639..7d3c3252f3 100644
29 @@ -653,8 +653,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 @@ -752,6 +750,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 @@ -1589,10 +1599,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 @@ -1609,6 +1615,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);