From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server] migration: use copy-mode "write-blocking" for drive mirror
Date: Tue, 27 Sep 2022 13:50:04 +0200 [thread overview]
Message-ID: <20220927115004.121044-1-f.ebner@proxmox.com> (raw)
Otherwise, there is nothing enforcing that the drive mirror is ready
when the migration inactivates the block devices, which can lead to a
failing assertion:
> ../block/io.c:2026: bdrv_co_write_req_prepare: Assertion
> `!(bs->open_flags & BDRV_O_INACTIVE)' failed.
QAPI documentation of 'write-blocking' (currently the only alternative
to the default 'background' mode):
> when data is written to the source, write it (synchronously) to the
> target as well. In addition, data is copied in background just like
> in background mode.
Reported in the community forum [0] (and likely [1]).
Reproduced consistently with a 1 core, 1 GiB RAM, 4 GiB disk Debian 11
VM. I added a sleep of 5 second before issuing the migrate QMP command
and executed the following in the VM after the drive-mirror became
first ready:
> fio --name=make-mirror-work --size=100M --direct=1 --rw=randwrite \
> --bs=4k --ioengine=psync --numjobs=5 --runtime=60 --time_based
This ensures that there is a large number of dirty clusters and that
the mirror still has work to do when the block device is inactivated.
[0] https://forum.proxmox.com/threads/111831/
[1] https://forum.proxmox.com/threads/100020/
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
PVE/QemuMigrate.pm | 14 +++++++++++++-
PVE/QemuServer.pm | 6 +++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index d52dc8db..dd6b073e 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -831,7 +831,19 @@ sub phase2 {
my $bitmap = $target->{bitmap};
$self->log('info', "$drive: start migration to $nbd_uri");
- PVE::QemuServer::qemu_drive_mirror($vmid, $drive, $nbd_uri, $vmid, undef, $self->{storage_migration_jobs}, 'skip', undef, $bwlimit, $bitmap);
+ PVE::QemuServer::qemu_drive_mirror(
+ $vmid,
+ $drive,
+ $nbd_uri,
+ $vmid,
+ undef,
+ $self->{storage_migration_jobs},
+ 'skip',
+ undef,
+ $bwlimit,
+ $bitmap,
+ 1,
+ );
}
}
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 4e85dd02..2901cd83 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -7450,7 +7450,7 @@ sub qemu_img_format {
}
sub qemu_drive_mirror {
- my ($vmid, $drive, $dst_volid, $vmiddst, $is_zero_initialized, $jobs, $completion, $qga, $bwlimit, $src_bitmap) = @_;
+ my ($vmid, $drive, $dst_volid, $vmiddst, $is_zero_initialized, $jobs, $completion, $qga, $bwlimit, $src_bitmap, $write_blocking) = @_;
$jobs = {} if !$jobs;
@@ -7477,6 +7477,10 @@ sub qemu_drive_mirror {
my $opts = { timeout => 10, device => "drive-$drive", mode => "existing", sync => "full", target => $qemu_target };
$opts->{format} = $format if $format;
+ # Relevant for migration, to ensure that the mirror will be ready (after being ready once) when
+ # the migration inactivates the block drives.
+ $opts->{'copy-mode'} = 'write-blocking' if $write_blocking;
+
if (defined($src_bitmap)) {
$opts->{sync} = 'incremental';
$opts->{bitmap} = $src_bitmap;
--
2.30.2
reply other threads:[~2022-09-27 11:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220927115004.121044-1-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/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