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