|
|
ae23c9 |
From d62dd4f2f0b7acca3177935fbad1f1253ac722ef Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Date: Wed, 10 Oct 2018 20:21:43 +0100
|
|
|
ae23c9 |
Subject: [PATCH 17/49] block: Defer .bdrv_drain_begin callback to polling
|
|
|
ae23c9 |
phase
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Message-id: <20181010202213.7372-5-kwolf@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 82594
|
|
|
ae23c9 |
O-Subject: [RHEL-8 qemu-kvm PATCH 14/44] block: Defer .bdrv_drain_begin callback to polling phase
|
|
|
ae23c9 |
Bugzilla: 1637976
|
|
|
ae23c9 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
We cannot allow aio_poll() in bdrv_drain_invoke(begin=true) until we're
|
|
|
ae23c9 |
done with propagating the drain through the graph and are doing the
|
|
|
ae23c9 |
single final BDRV_POLL_WHILE().
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Just schedule the coroutine with the callback and increase bs->in_flight
|
|
|
ae23c9 |
to make sure that the polling phase will wait for it.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit 0109e7e6f83ae5166b81bbd9a4319d60be49985a)
|
|
|
ae23c9 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
block/io.c | 28 +++++++++++++++++++++++-----
|
|
|
ae23c9 |
1 file changed, 23 insertions(+), 5 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/block/io.c b/block/io.c
|
|
|
ae23c9 |
index 9c41ff9..23fe069 100644
|
|
|
ae23c9 |
--- a/block/io.c
|
|
|
ae23c9 |
+++ b/block/io.c
|
|
|
ae23c9 |
@@ -181,22 +181,40 @@ static void coroutine_fn bdrv_drain_invoke_entry(void *opaque)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/* Set data->done before reading bs->wakeup. */
|
|
|
ae23c9 |
atomic_mb_set(&data->done, true);
|
|
|
ae23c9 |
- bdrv_wakeup(bs);
|
|
|
ae23c9 |
+ bdrv_dec_in_flight(bs);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ if (data->begin) {
|
|
|
ae23c9 |
+ g_free(data);
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/* Recursively call BlockDriver.bdrv_co_drain_begin/end callbacks */
|
|
|
ae23c9 |
static void bdrv_drain_invoke(BlockDriverState *bs, bool begin)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
- BdrvCoDrainData data = { .bs = bs, .done = false, .begin = begin};
|
|
|
ae23c9 |
+ BdrvCoDrainData *data;
|
|
|
ae23c9 |
|
|
|
ae23c9 |
if (!bs->drv || (begin && !bs->drv->bdrv_co_drain_begin) ||
|
|
|
ae23c9 |
(!begin && !bs->drv->bdrv_co_drain_end)) {
|
|
|
ae23c9 |
return;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- data.co = qemu_coroutine_create(bdrv_drain_invoke_entry, &data);
|
|
|
ae23c9 |
- bdrv_coroutine_enter(bs, data.co);
|
|
|
ae23c9 |
- BDRV_POLL_WHILE(bs, !data.done);
|
|
|
ae23c9 |
+ data = g_new(BdrvCoDrainData, 1);
|
|
|
ae23c9 |
+ *data = (BdrvCoDrainData) {
|
|
|
ae23c9 |
+ .bs = bs,
|
|
|
ae23c9 |
+ .done = false,
|
|
|
ae23c9 |
+ .begin = begin
|
|
|
ae23c9 |
+ };
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ /* Make sure the driver callback completes during the polling phase for
|
|
|
ae23c9 |
+ * drain_begin. */
|
|
|
ae23c9 |
+ bdrv_inc_in_flight(bs);
|
|
|
ae23c9 |
+ data->co = qemu_coroutine_create(bdrv_drain_invoke_entry, data);
|
|
|
ae23c9 |
+ aio_co_schedule(bdrv_get_aio_context(bs), data->co);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ if (!begin) {
|
|
|
ae23c9 |
+ BDRV_POLL_WHILE(bs, !data->done);
|
|
|
ae23c9 |
+ g_free(data);
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/* Returns true if BDRV_POLL_WHILE() should go into a blocking aio_poll() */
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|