]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
b0ade6850b70a339eef6391110fe0ec3f2c943ff
[pve-qemu.git] / debian / patches / bitmap-mirror / 0002-drive-mirror-add-support-for-conditional-and-always-.patch
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
5 sync modes
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 Teach mirror two new tricks for using bitmaps:
11
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
14 date.
15
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.
19
20 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
21 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
22 ---
23 block/mirror.c | 24 ++++++++++++++++++------
24 1 file changed, 18 insertions(+), 6 deletions(-)
25
26 diff --git a/block/mirror.c b/block/mirror.c
27 index 9099c75992..e2ff42067b 100644
28 --- a/block/mirror.c
29 +++ b/block/mirror.c
30 @@ -680,8 +680,6 @@ static int mirror_exit_common(Job *job)
31 bdrv_unfreeze_backing_chain(mirror_top_bs, target_bs);
32 }
33
34 - bdrv_release_dirty_bitmap(s->dirty_bitmap);
35 -
36 /* Make sure that the source BDS doesn't go away during bdrv_replace_node,
37 * before we can call bdrv_drained_end */
38 bdrv_ref(src);
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);
42
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);
51 + }
52 + }
53 + bdrv_release_dirty_bitmap(s->dirty_bitmap);
54 +
55 bs_opaque->job = NULL;
56
57 bdrv_drained_end(src);
58 @@ -1688,10 +1698,6 @@ static BlockJob *mirror_start_job(
59 " sync mode",
60 MirrorSyncMode_str(sync_mode));
61 return NULL;
62 - } else if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
63 - error_setg(errp,
64 - "Bitmap Sync Mode '%s' is not supported by Mirror",
65 - BitmapSyncMode_str(bitmap_mode));
66 }
67 } else if (bitmap) {
68 error_setg(errp,
69 @@ -1708,6 +1714,12 @@ static BlockJob *mirror_start_job(
70 return NULL;
71 }
72 granularity = bdrv_dirty_bitmap_granularity(bitmap);
73 +
74 + if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
75 + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) {
76 + return NULL;
77 + }
78 + }
79 } else if (granularity == 0) {
80 granularity = bdrv_get_default_bitmap_granularity(target);
81 }