From: Fiona Ebner <f.ebner@proxmox.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com,
hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru,
jsnow@redhat.com, f.gruenbichler@proxmox.com,
t.lamprecht@proxmox.com, mahaocong@didichuxing.com
Subject: [RFC 2/4] drive-mirror: add support for conditional and always bitmap sync modes
Date: Fri, 16 Feb 2024 11:55:11 +0100 [thread overview]
Message-ID: <20240216105513.309901-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20240216105513.309901-1-f.ebner@proxmox.com>
From: John Snow <jsnow@redhat.com>
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.
Originally-by: John Snow <jsnow@redhat.com>
[FG: add check for bitmap-mode without bitmap
switch to bdrv_dirty_bitmap_merge_internal]
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
[FE: rebase for 9.0]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
The original patch this was based on came from a WIP git branch and
thus has no Signed-off-by trailer from John, see [0]. I added an
Originally-by trailer for now. Let me know if I should drop that and
wait for John's Signed-off-by instead.
[0] https://lore.kernel.org/qemu-devel/1599140071.n44h532eeu.astroid@nora.none/
block/mirror.c | 24 ++++++++++++++++++------
blockdev.c | 3 +++
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
index 315dff11e2..84155b1f78 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -689,8 +689,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);
@@ -796,6 +794,18 @@ static int mirror_exit_common(Job *job)
bdrv_drained_end(target_bs);
bdrv_unref(target_bs);
+ 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_dirty_bitmap_merge_internal(s->sync_bitmap, s->dirty_bitmap,
+ NULL, true);
+ }
+ }
+ bdrv_release_dirty_bitmap(s->dirty_bitmap);
+
bs_opaque->job = NULL;
bdrv_drained_end(src);
@@ -1755,10 +1765,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,
@@ -1775,6 +1781,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);
}
diff --git a/blockdev.c b/blockdev.c
index c65d9ded70..aeb9fde9f3 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2873,6 +2873,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) {
return;
}
+ } else if (has_bitmap_mode) {
+ error_setg(errp, "Cannot specify bitmap sync mode without a bitmap");
+ return;
}
if (!replaces) {
--
2.39.2
next prev parent reply other threads:[~2024-02-16 10:56 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 10:55 [RFC 0/4] mirror: implement incremental and bitmap modes Fiona Ebner
2024-02-16 10:55 ` [RFC 1/4] drive-mirror: add support for sync=bitmap mode=never Fiona Ebner
2024-02-21 6:55 ` Markus Armbruster
2024-02-21 9:21 ` Fiona Ebner
2024-02-16 10:55 ` Fiona Ebner [this message]
2024-02-16 10:55 ` [RFC 3/4] mirror: move some checks to qmp Fiona Ebner
2024-02-16 10:55 ` [RFC 4/4] iotests: add test for bitmap mirror Fiona Ebner
2024-02-28 16:00 ` [RFC 0/4] mirror: implement incremental and bitmap modes Vladimir Sementsov-Ogievskiy
2024-02-28 16:06 ` Vladimir Sementsov-Ogievskiy
2024-02-29 10:11 ` Fiona Ebner
2024-02-29 11:48 ` Vladimir Sementsov-Ogievskiy
2024-02-29 12:47 ` Fiona Ebner
2024-03-06 13:44 ` Fiona Ebner
2024-03-07 9:20 ` Vladimir Sementsov-Ogievskiy
2024-02-28 16:24 ` Vladimir Sementsov-Ogievskiy
2024-02-29 10:41 ` Fiona Ebner
2024-02-29 12:00 ` Vladimir Sementsov-Ogievskiy
2024-02-29 14:50 ` Fiona Ebner
2024-03-01 14:14 ` Vladimir Sementsov-Ogievskiy
2024-03-01 14:52 ` Fiona Ebner
2024-03-01 15:02 ` Vladimir Sementsov-Ogievskiy
2024-03-01 15:14 ` Fiona Ebner
2024-03-01 15:46 ` Vladimir Sementsov-Ogievskiy
2024-03-04 7:50 ` Fiona Ebner
2024-03-04 9:02 ` Fabian Grünbichler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240216105513.309901-3-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=f.gruenbichler@proxmox.com \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mahaocong@didichuxing.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=t.lamprecht@proxmox.com \
--cc=vsementsov@yandex-team.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).