[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC qemu 2/6] drive-mirror: add support for conditional and always bitm
From: |
Fabian Grünbichler |
Subject: |
[RFC qemu 2/6] drive-mirror: add support for conditional and always bitmap sync modes |
Date: |
Tue, 18 Feb 2020 11:07:36 +0100 |
From: John Snow <address@hidden>
Teach mirror two new tricks for using bitmaps:
Always: no matter what, we synchronize the copy_bitmap back to the
sync_bitmap. In effect, this allows us resume a failed mirror at a later
date.
Conditional: On success only, we sync the bitmap. This is akin to
incremental backup modes; we can use this bitmap to later refresh a
successfully created mirror.
---
Note: original commit by John Snow <address@hidden>, but missing SOB -
please ACK/reply and I'll add it.
This is also broken without patch #4, since it's fairly straight-forward
we might even squash all three into a single commit?
block/mirror.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
index fd7f574365..40d174a625 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -645,8 +645,6 @@ static int mirror_exit_common(Job *job)
bdrv_unfreeze_backing_chain(mirror_top_bs, target_bs);
}
- bdrv_release_dirty_bitmap(s->dirty_bitmap);
-
/* Make sure that the source BDS doesn't go away during bdrv_replace_node,
* before we can call bdrv_drained_end */
bdrv_ref(src);
@@ -731,6 +729,18 @@ static int mirror_exit_common(Job *job)
blk_set_perm(bjob->blk, 0, BLK_PERM_ALL, &error_abort);
blk_insert_bs(bjob->blk, mirror_top_bs, &error_abort);
+ if (s->sync_bitmap) {
+ if (s->bitmap_mode == BITMAP_SYNC_MODE_ALWAYS ||
+ (s->bitmap_mode == BITMAP_SYNC_MODE_ON_SUCCESS &&
+ job->ret == 0 && ret == 0)) {
+ /* Success; synchronize copy back to sync. */
+ bdrv_clear_dirty_bitmap(s->sync_bitmap, NULL);
+ bdrv_merge_dirty_bitmap(s->sync_bitmap, s->dirty_bitmap,
+ NULL, &error_abort);
+ }
+ }
+ bdrv_release_dirty_bitmap(s->dirty_bitmap);
+
bs_opaque->job = NULL;
bdrv_drained_end(src);
@@ -1562,10 +1572,6 @@ static BlockJob *mirror_start_job(
" sync mode",
MirrorSyncMode_str(sync_mode));
return NULL;
- } else if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
- error_setg(errp,
- "Bitmap Sync Mode '%s' is not supported by Mirror",
- BitmapSyncMode_str(bitmap_mode));
}
} else if (bitmap) {
error_setg(errp,
@@ -1582,6 +1588,12 @@ static BlockJob *mirror_start_job(
return NULL;
}
granularity = bdrv_dirty_bitmap_granularity(bitmap);
+
+ if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
+ if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) {
+ return NULL;
+ }
+ }
} else if (granularity == 0) {
granularity = bdrv_get_default_bitmap_granularity(target);
}
--
2.20.1
- [RFC qemu 0/6] mirror: implement incremental and bitmap modes, Fabian Grünbichler, 2020/02/18
- [RFC qemu 4/6] mirror: switch to bdrv_dirty_bitmap_merge_internal, Fabian Grünbichler, 2020/02/18
- [RFC qemu 2/6] drive-mirror: add support for conditional and always bitmap sync modes,
Fabian Grünbichler <=
- [RFC qemu 3/6] mirror: add check for bitmap-mode without bitmap, Fabian Grünbichler, 2020/02/18
- [RFC qemu 6/6] mirror: move some checks to QMP, Fabian Grünbichler, 2020/02/18
- [RFC qemu 1/6] drive-mirror: add support for sync=bitmap mode=never, Fabian Grünbichler, 2020/02/18
- [RFC qemu 5/6] iotests: add test for bitmap mirror, Fabian Grünbichler, 2020/02/18
- Re: [RFC qemu 0/6] mirror: implement incremental and bitmap modes, no-reply, 2020/02/18
- Re: [RFC qemu 0/6] mirror: implement incremental and bitmap modes, John Snow, 2020/02/25