[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/69] block: extract bdrv_drain_poll/bdrv_co_yield_t
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 04/69] block: extract bdrv_drain_poll/bdrv_co_yield_to_drain from bdrv_drain/bdrv_co_drain |
Date: |
Thu, 12 May 2016 16:34:44 +0200 |
From: Paolo Bonzini <address@hidden>
Do not call bdrv_drain_recurse twice in bdrv_co_drain. A small
tweak to the logic in Fam's patch, which is harmless since no
one implements bdrv_drain anyway. But better get it right.
Signed-off-by: Paolo Bonzini <address@hidden>
Acked-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/io.c | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/block/io.c b/block/io.c
index 9201b89..c484856 100644
--- a/block/io.c
+++ b/block/io.c
@@ -243,18 +243,30 @@ typedef struct {
bool done;
} BdrvCoDrainData;
+static void bdrv_drain_poll(BlockDriverState *bs)
+{
+ bool busy = true;
+
+ while (busy) {
+ /* Keep iterating */
+ bdrv_flush_io_queue(bs);
+ busy = bdrv_requests_pending(bs);
+ busy |= aio_poll(bdrv_get_aio_context(bs), busy);
+ }
+}
+
static void bdrv_co_drain_bh_cb(void *opaque)
{
BdrvCoDrainData *data = opaque;
Coroutine *co = data->co;
qemu_bh_delete(data->bh);
- bdrv_drain(data->bs);
+ bdrv_drain_poll(data->bs);
data->done = true;
qemu_coroutine_enter(co, NULL);
}
-void coroutine_fn bdrv_co_drain(BlockDriverState *bs)
+static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs)
{
BdrvCoDrainData data;
@@ -288,20 +300,19 @@ void coroutine_fn bdrv_co_drain(BlockDriverState *bs)
* not depend on events in other AioContexts. In that case, use
* bdrv_drain_all() instead.
*/
-void bdrv_drain(BlockDriverState *bs)
+void coroutine_fn bdrv_co_drain(BlockDriverState *bs)
{
- bool busy = true;
+ bdrv_drain_recurse(bs);
+ bdrv_co_yield_to_drain(bs);
+}
+void bdrv_drain(BlockDriverState *bs)
+{
bdrv_drain_recurse(bs);
if (qemu_in_coroutine()) {
- bdrv_co_drain(bs);
- return;
- }
- while (busy) {
- /* Keep iterating */
- bdrv_flush_io_queue(bs);
- busy = bdrv_requests_pending(bs);
- busy |= aio_poll(bdrv_get_aio_context(bs), busy);
+ bdrv_co_yield_to_drain(bs);
+ } else {
+ bdrv_drain_poll(bs);
}
}
--
1.8.3.1
- [Qemu-devel] [PULL 00/69] Block layer patches, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 04/69] block: extract bdrv_drain_poll/bdrv_co_yield_to_drain from bdrv_drain/bdrv_co_drain,
Kevin Wolf <=
- [Qemu-devel] [PULL 03/69] block: move restarting of throttled reqs to block/throttle-groups.c, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 09/69] block: Introduce bdrv_driver_pwritev(), Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 07/69] linux-aio: make it more type safe, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 05/69] block: introduce bdrv_no_throttling_begin/end, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 01/69] block: Don't disable I/O throttling on sync requests, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 02/69] block: make bdrv_start_throttled_reqs return void, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 16/69] vdi: Implement .bdrv_co_preadv() interface, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 12/69] block: Introduce .bdrv_co_preadv/pwritev BlockDriver function, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 06/69] block: plug whole tree at once, introduce bdrv_io_unplugged_begin/end, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 10/69] block: Support AIO drivers in bdrv_driver_preadv/pwritev(), Kevin Wolf, 2016/05/12