]>
Commit | Line | Data |
---|---|---|
83faa3fe | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
059a9447 | 2 | From: John Snow <jsnow@redhat.com> |
83faa3fe TL |
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 | |
059a9447 FG |
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 | --- | |
22 | block/mirror.c | 24 ++++++++++++++++++------ | |
23 | 1 file changed, 18 insertions(+), 6 deletions(-) | |
24 | ||
25 | diff --git a/block/mirror.c b/block/mirror.c | |
8dca018b | 26 | index f1416d96f3..3e37967365 100644 |
059a9447 FG |
27 | --- a/block/mirror.c |
28 | +++ b/block/mirror.c | |
8dca018b | 29 | @@ -655,8 +655,6 @@ static int mirror_exit_common(Job *job) |
059a9447 FG |
30 | bdrv_unfreeze_backing_chain(mirror_top_bs, target_bs); |
31 | } | |
32 | ||
33 | - bdrv_release_dirty_bitmap(s->dirty_bitmap); | |
34 | - | |
35 | /* Make sure that the source BDS doesn't go away during bdrv_replace_node, | |
36 | * before we can call bdrv_drained_end */ | |
37 | bdrv_ref(src); | |
8dca018b | 38 | @@ -764,6 +762,18 @@ static int mirror_exit_common(Job *job) |
059a9447 FG |
39 | blk_set_perm(bjob->blk, 0, BLK_PERM_ALL, &error_abort); |
40 | blk_insert_bs(bjob->blk, mirror_top_bs, &error_abort); | |
41 | ||
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); | |
50 | + } | |
51 | + } | |
52 | + bdrv_release_dirty_bitmap(s->dirty_bitmap); | |
53 | + | |
54 | bs_opaque->job = NULL; | |
55 | ||
56 | bdrv_drained_end(src); | |
8dca018b | 57 | @@ -1613,10 +1623,6 @@ static BlockJob *mirror_start_job( |
059a9447 FG |
58 | " sync mode", |
59 | MirrorSyncMode_str(sync_mode)); | |
60 | return NULL; | |
61 | - } else if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) { | |
62 | - error_setg(errp, | |
63 | - "Bitmap Sync Mode '%s' is not supported by Mirror", | |
64 | - BitmapSyncMode_str(bitmap_mode)); | |
65 | } | |
66 | } else if (bitmap) { | |
67 | error_setg(errp, | |
8dca018b | 68 | @@ -1633,6 +1639,12 @@ static BlockJob *mirror_start_job( |
059a9447 FG |
69 | return NULL; |
70 | } | |
71 | granularity = bdrv_dirty_bitmap_granularity(bitmap); | |
72 | + | |
73 | + if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) { | |
74 | + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) { | |
75 | + return NULL; | |
76 | + } | |
77 | + } | |
78 | } else if (granularity == 0) { | |
79 | granularity = bdrv_get_default_bitmap_granularity(target); | |
80 | } |