|
|
357786 |
From 13f0c32e5c77278207f63ade463035d8aaa4898d Mon Sep 17 00:00:00 2001
|
|
|
357786 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
Date: Fri, 14 Sep 2018 10:55:15 +0200
|
|
|
357786 |
Subject: [PATCH 24/49] block: Move bdrv_drain_all_begin() out of coroutine
|
|
|
357786 |
context
|
|
|
357786 |
|
|
|
357786 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
Message-id: <20180914105540.18077-18-kwolf@redhat.com>
|
|
|
357786 |
Patchwork-id: 82169
|
|
|
357786 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 17/42] block: Move bdrv_drain_all_begin() out of coroutine context
|
|
|
357786 |
Bugzilla: 1601212
|
|
|
357786 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
357786 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
357786 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
357786 |
|
|
|
357786 |
Before we can introduce a single polling loop for all nodes in
|
|
|
357786 |
bdrv_drain_all_begin(), we must make sure to run it outside of coroutine
|
|
|
357786 |
context like we already do for bdrv_do_drained_begin().
|
|
|
357786 |
|
|
|
357786 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
(cherry picked from commit c8ca33d06def97d909a8511377b82994ae4e5981)
|
|
|
357786 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
357786 |
---
|
|
|
357786 |
block/io.c | 22 +++++++++++++++++-----
|
|
|
357786 |
1 file changed, 17 insertions(+), 5 deletions(-)
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/io.c b/block/io.c
|
|
|
357786 |
index 23fe069..b58c91b 100644
|
|
|
357786 |
--- a/block/io.c
|
|
|
357786 |
+++ b/block/io.c
|
|
|
357786 |
@@ -263,11 +263,16 @@ static void bdrv_co_drain_bh_cb(void *opaque)
|
|
|
357786 |
Coroutine *co = data->co;
|
|
|
357786 |
BlockDriverState *bs = data->bs;
|
|
|
357786 |
|
|
|
357786 |
- bdrv_dec_in_flight(bs);
|
|
|
357786 |
- if (data->begin) {
|
|
|
357786 |
- bdrv_do_drained_begin(bs, data->recursive, data->parent, data->poll);
|
|
|
357786 |
+ if (bs) {
|
|
|
357786 |
+ bdrv_dec_in_flight(bs);
|
|
|
357786 |
+ if (data->begin) {
|
|
|
357786 |
+ bdrv_do_drained_begin(bs, data->recursive, data->parent, data->poll);
|
|
|
357786 |
+ } else {
|
|
|
357786 |
+ bdrv_do_drained_end(bs, data->recursive, data->parent);
|
|
|
357786 |
+ }
|
|
|
357786 |
} else {
|
|
|
357786 |
- bdrv_do_drained_end(bs, data->recursive, data->parent);
|
|
|
357786 |
+ assert(data->begin);
|
|
|
357786 |
+ bdrv_drain_all_begin();
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
data->done = true;
|
|
|
357786 |
@@ -293,7 +298,9 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
|
|
|
357786 |
.parent = parent,
|
|
|
357786 |
.poll = poll,
|
|
|
357786 |
};
|
|
|
357786 |
- bdrv_inc_in_flight(bs);
|
|
|
357786 |
+ if (bs) {
|
|
|
357786 |
+ bdrv_inc_in_flight(bs);
|
|
|
357786 |
+ }
|
|
|
357786 |
aio_bh_schedule_oneshot(bdrv_get_aio_context(bs),
|
|
|
357786 |
bdrv_co_drain_bh_cb, &data);
|
|
|
357786 |
|
|
|
357786 |
@@ -463,6 +470,11 @@ void bdrv_drain_all_begin(void)
|
|
|
357786 |
BlockDriverState *bs;
|
|
|
357786 |
BdrvNextIterator it;
|
|
|
357786 |
|
|
|
357786 |
+ if (qemu_in_coroutine()) {
|
|
|
357786 |
+ bdrv_co_yield_to_drain(NULL, true, false, NULL, true);
|
|
|
357786 |
+ return;
|
|
|
357786 |
+ }
|
|
|
357786 |
+
|
|
|
357786 |
/* BDRV_POLL_WHILE() for a node can only be called from its own I/O thread
|
|
|
357786 |
* or the main loop AioContext. We potentially use BDRV_POLL_WHILE() on
|
|
|
357786 |
* nodes in several different AioContexts, so make sure we're in the main
|
|
|
357786 |
--
|
|
|
357786 |
1.8.3.1
|
|
|
357786 |
|