From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
Max Reitz <mreitz@redhat.com>, Eric Blake <eblake@redhat.com>,
stefanha@redhat.com
Subject: [Qemu-devel] [PATCH for-2.10 v2 2/4] nbd: Fix order of bdrv_set_perm and bdrv_invalidate_cache
Date: Tue, 15 Aug 2017 21:07:38 +0800 [thread overview]
Message-ID: <20170815130740.31229-3-famz@redhat.com> (raw)
In-Reply-To: <20170815130740.31229-1-famz@redhat.com>
From: Kevin Wolf <kwolf@redhat.com>
The "inactive" state of BDS affects whether the permissions can be
granted, we must call bdrv_invalidate_cache before bdrv_set_perm to
support "-incoming defer" case.
Reported-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
---
nbd/server.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/nbd/server.c b/nbd/server.c
index 82a78bf439..b68b6fb535 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1045,11 +1045,22 @@ NBDExport *nbd_export_new(BlockDriverState *bs, off_t dev_offset, off_t size,
bool writethrough, BlockBackend *on_eject_blk,
Error **errp)
{
+ AioContext *ctx;
BlockBackend *blk;
NBDExport *exp = g_malloc0(sizeof(NBDExport));
uint64_t perm;
int ret;
+ /*
+ * NBD exports are used for non-shared storage migration. Make sure
+ * that BDRV_O_INACTIVE is cleared and the image is ready for write
+ * access since the export could be available before migration handover.
+ */
+ ctx = bdrv_get_aio_context(bs);
+ aio_context_acquire(ctx);
+ bdrv_invalidate_cache(bs, NULL);
+ aio_context_release(ctx);
+
/* Don't allow resize while the NBD server is running, otherwise we don't
* care what happens with the node. */
perm = BLK_PERM_CONSISTENT_READ;
@@ -1087,15 +1098,6 @@ NBDExport *nbd_export_new(BlockDriverState *bs, off_t dev_offset, off_t size,
exp->eject_notifier.notify = nbd_eject_notifier;
blk_add_remove_bs_notifier(on_eject_blk, &exp->eject_notifier);
}
-
- /*
- * NBD exports are used for non-shared storage migration. Make sure
- * that BDRV_O_INACTIVE is cleared and the image is ready for write
- * access since the export could be available before migration handover.
- */
- aio_context_acquire(exp->ctx);
- blk_invalidate_cache(blk, NULL);
- aio_context_release(exp->ctx);
return exp;
fail:
--
2.13.4
next prev parent reply other threads:[~2017-08-15 13:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-15 13:07 [Qemu-devel] [PATCH for-2.10 v2 0/4] block: Fix non-shared storage migration Fam Zheng
2017-08-15 13:07 ` [Qemu-devel] [PATCH for-2.10 v2 1/4] stubs: Add vm state change handler stubs Fam Zheng
2017-08-15 13:59 ` Eric Blake
2017-08-15 13:07 ` Fam Zheng [this message]
2017-08-15 14:16 ` [Qemu-devel] [PATCH for-2.10 v2 2/4] nbd: Fix order of bdrv_set_perm and bdrv_invalidate_cache Eric Blake
2017-08-15 13:07 ` [Qemu-devel] [PATCH for-2.10 v2 3/4] block-backend: Defer shared_perm tightening migration completion Fam Zheng
2017-08-15 14:21 ` Eric Blake
2017-08-15 13:07 ` [Qemu-devel] [PATCH for-2.10 v2 4/4] iotests: Add non-shared storage migration case 192 Fam Zheng
2017-08-15 14:26 ` Eric Blake
2017-08-18 14:14 ` [Qemu-devel] [PATCH for-2.10 v2 0/4] block: Fix non-shared storage migration Christian Ehrhardt
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=20170815130740.31229-3-famz@redhat.com \
--to=famz@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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;
as well as URLs for NNTP newsgroup(s).