|
Pablo Greco |
e6a3ae |
From cf6bc30f7b525f0d646db62e49cbf02f3f28a1f2 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
e6a3ae |
From: Kevin Wolf <kwolf@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Date: Wed, 14 Aug 2019 08:42:29 +0100
|
|
Pablo Greco |
e6a3ae |
Subject: [PATCH 06/10] block: Use normal drain for bdrv_set_aio_context()
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Message-id: <20190814084229.6458-6-kwolf@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Patchwork-id: 89968
|
|
Pablo Greco |
e6a3ae |
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 5/5] block: Use normal drain for bdrv_set_aio_context()
|
|
Pablo Greco |
e6a3ae |
Bugzilla: 1716349
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
Now that bdrv_set_aio_context() works inside drained sections, it can
|
|
Pablo Greco |
e6a3ae |
also use the real drain function instead of open coding something
|
|
Pablo Greco |
e6a3ae |
similar.
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
Pablo Greco |
e6a3ae |
(cherry picked from commit d70d595429ecd9ac4917e53453dd8979db8e5ffd)
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
RHEL: This conflicts because we didn't backport the removal of the
|
|
Pablo Greco |
e6a3ae |
polling loop. The conflict is resolved so that the polling loop moves to
|
|
Pablo Greco |
e6a3ae |
above the drain and any requests a BH would spawn would still be
|
|
Pablo Greco |
e6a3ae |
correctly drained afterwards. The changed order alone would have
|
|
Pablo Greco |
e6a3ae |
compensated for the virtio-blk bug and it potentially compensates for
|
|
Pablo Greco |
e6a3ae |
other bugs, too (we know of bugs in the NBD client at least), so leaving
|
|
Pablo Greco |
e6a3ae |
the polling loop in, with the new ordering, feels like the safe way for
|
|
Pablo Greco |
e6a3ae |
a downstream backport.
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
Pablo Greco |
e6a3ae |
---
|
|
Pablo Greco |
e6a3ae |
block.c | 11 +++++------
|
|
Pablo Greco |
e6a3ae |
1 file changed, 5 insertions(+), 6 deletions(-)
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
diff --git a/block.c b/block.c
|
|
Pablo Greco |
e6a3ae |
index 9d9b8a9..8f3ceea 100644
|
|
Pablo Greco |
e6a3ae |
--- a/block.c
|
|
Pablo Greco |
e6a3ae |
+++ b/block.c
|
|
Pablo Greco |
e6a3ae |
@@ -4989,18 +4989,18 @@ void bdrv_attach_aio_context(BlockDriverState *bs,
|
|
Pablo Greco |
e6a3ae |
bs->walking_aio_notifiers = false;
|
|
Pablo Greco |
e6a3ae |
}
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
+/* The caller must own the AioContext lock for the old AioContext of bs, but it
|
|
Pablo Greco |
e6a3ae |
+ * must not own the AioContext lock for new_context (unless new_context is
|
|
Pablo Greco |
e6a3ae |
+ * the same as the current context of bs). */
|
|
Pablo Greco |
e6a3ae |
void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context)
|
|
Pablo Greco |
e6a3ae |
{
|
|
Pablo Greco |
e6a3ae |
AioContext *ctx = bdrv_get_aio_context(bs);
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
- aio_disable_external(ctx);
|
|
Pablo Greco |
e6a3ae |
- bdrv_parent_drained_begin(bs, NULL, false);
|
|
Pablo Greco |
e6a3ae |
- bdrv_drain(bs); /* ensure there are no in-flight requests */
|
|
Pablo Greco |
e6a3ae |
-
|
|
Pablo Greco |
e6a3ae |
while (aio_poll(ctx, false)) {
|
|
Pablo Greco |
e6a3ae |
/* wait for all bottom halves to execute */
|
|
Pablo Greco |
e6a3ae |
}
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
+ bdrv_drained_begin(bs);
|
|
Pablo Greco |
e6a3ae |
bdrv_detach_aio_context(bs);
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
/* This function executes in the old AioContext so acquire the new one in
|
|
Pablo Greco |
e6a3ae |
@@ -5008,8 +5008,7 @@ void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context)
|
|
Pablo Greco |
e6a3ae |
*/
|
|
Pablo Greco |
e6a3ae |
aio_context_acquire(new_context);
|
|
Pablo Greco |
e6a3ae |
bdrv_attach_aio_context(bs, new_context);
|
|
Pablo Greco |
e6a3ae |
- bdrv_parent_drained_end(bs, NULL, false);
|
|
Pablo Greco |
e6a3ae |
- aio_enable_external(ctx);
|
|
Pablo Greco |
e6a3ae |
+ bdrv_drained_end(bs);
|
|
Pablo Greco |
e6a3ae |
aio_context_release(new_context);
|
|
Pablo Greco |
e6a3ae |
}
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
--
|
|
Pablo Greco |
e6a3ae |
1.8.3.1
|
|
Pablo Greco |
e6a3ae |
|