From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
Subject: [Qemu-devel] [PULL 03/10] block/migration: Disable cache invalidate for incoming migration
Date: Wed, 15 Oct 2014 10:24:57 +0200 [thread overview]
Message-ID: <1413361504-26396-4-git-send-email-quintela@redhat.com> (raw)
In-Reply-To: <1413361504-26396-1-git-send-email-quintela@redhat.com>
From: Alexey Kardashevskiy <aik@ozlabs.ru>
When migrated using libvirt with "--copy-storage-all", at the end of
migration there is race between NBD mirroring task trying to do flush
and migration completion, both end up invalidating cache. Since qcow2
driver does not handle this situation very well, random crashes happen.
This disables the BDRV_O_INCOMING flag for the block device being migrated
once the cache has been invalidated.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
--
fixed parens by hand
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
block.c | 18 +++++-------------
migration.c | 1 -
nbd.c | 6 ++++++
3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/block.c b/block.c
index d3aebeb..27533f3 100644
--- a/block.c
+++ b/block.c
@@ -5043,6 +5043,11 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp)
return;
}
+ if (!(bs->open_flags & BDRV_O_INCOMING)) {
+ return;
+ }
+ bs->open_flags &= ~BDRV_O_INCOMING;
+
if (bs->drv->bdrv_invalidate_cache) {
bs->drv->bdrv_invalidate_cache(bs, &local_err);
} else if (bs->file) {
@@ -5078,19 +5083,6 @@ void bdrv_invalidate_cache_all(Error **errp)
}
}
-void bdrv_clear_incoming_migration_all(void)
-{
- BlockDriverState *bs;
-
- QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
- AioContext *aio_context = bdrv_get_aio_context(bs);
-
- aio_context_acquire(aio_context);
- bs->open_flags = bs->open_flags & ~(BDRV_O_INCOMING);
- aio_context_release(aio_context);
- }
-}
-
int bdrv_flush(BlockDriverState *bs)
{
Coroutine *co;
diff --git a/migration.c b/migration.c
index 8d675b3..c49a05a 100644
--- a/migration.c
+++ b/migration.c
@@ -103,7 +103,6 @@ static void process_incoming_migration_co(void *opaque)
}
qemu_announce_self();
- bdrv_clear_incoming_migration_all();
/* Make sure all file formats flush their mutable metadata */
bdrv_invalidate_cache_all(&local_err);
if (local_err) {
diff --git a/nbd.c b/nbd.c
index e9b539b..a7bce45 100644
--- a/nbd.c
+++ b/nbd.c
@@ -972,6 +972,12 @@ NBDExport *nbd_export_new(BlockDriverState *bs, off_t dev_offset,
exp->ctx = bdrv_get_aio_context(bs);
bdrv_ref(bs);
bdrv_add_aio_context_notifier(bs, bs_aio_attached, bs_aio_detach, exp);
+ /*
+ * NBD exports are used for non-shared storage migration. Make sure
+ * that BDRV_O_INCOMING is cleared and the image is ready for write
+ * access since the export could be available before migration handover.
+ */
+ bdrv_invalidate_cache(bs, NULL);
return exp;
}
--
2.1.0
next prev parent reply other threads:[~2014-10-15 8:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-15 8:24 [Qemu-devel] [PULL 00/10] Migration pull request Juan Quintela
2014-10-15 8:24 ` [Qemu-devel] [PULL 01/10] QEMUSizedBuffer based QEMUFile Juan Quintela
2014-10-15 8:24 ` [Qemu-devel] [PULL 02/10] Tests: QEMUSizedBuffer/QEMUBuffer Juan Quintela
2014-10-15 8:24 ` Juan Quintela [this message]
2014-10-15 8:24 ` [Qemu-devel] [PULL 04/10] vmstate: Allow dynamic allocation for VBUFFER during migration Juan Quintela
2014-10-15 8:24 ` [Qemu-devel] [PULL 05/10] qemu-file: Add copyright header to qemu-file.c Juan Quintela
2014-10-15 8:25 ` [Qemu-devel] [PULL 06/10] qemu-file: Make qemu_file_is_writable() non-static Juan Quintela
2014-10-15 8:25 ` [Qemu-devel] [PULL 07/10] qemu-file: Use qemu_file_is_writable() on stdio_fclose() Juan Quintela
2014-10-15 8:25 ` [Qemu-devel] [PULL 08/10] qemu-file: Move unix and socket implementations to qemu-file-unix.c Juan Quintela
2014-10-15 8:25 ` [Qemu-devel] [PULL 09/10] qemu-file: Move stdio implementation to qemu-file-stdio.c Juan Quintela
2014-10-15 8:25 ` [Qemu-devel] [PULL 10/10] migration: catch unknown flag combinations in ram_load Juan Quintela
2014-10-15 12:37 ` [Qemu-devel] [PULL 00/10] Migration pull request Peter Maydell
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=1413361504-26396-4-git-send-email-quintela@redhat.com \
--to=quintela@redhat.com \
--cc=aik@ozlabs.ru \
--cc=qemu-devel@nongnu.org \
/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).