[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/18] block-backend: allow blk_prw from coroutine c
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 03/18] block-backend: allow blk_prw from coroutine context |
Date: |
Wed, 1 Feb 2017 04:05:18 -0800 |
qcow2_create2 calls this. Do not run a nested event loop, as that
breaks when aio_co_wake tries to queue the coroutine on the co_queue_wakeup
list of the currently running one.
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
block/block-backend.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index efbf398..1177598 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -880,7 +880,6 @@ static int blk_prw(BlockBackend *blk, int64_t offset,
uint8_t *buf,
{
QEMUIOVector qiov;
struct iovec iov;
- Coroutine *co;
BlkRwCo rwco;
iov = (struct iovec) {
@@ -897,9 +896,14 @@ static int blk_prw(BlockBackend *blk, int64_t offset,
uint8_t *buf,
.ret = NOT_DONE,
};
- co = qemu_coroutine_create(co_entry, &rwco);
- qemu_coroutine_enter(co);
- BDRV_POLL_WHILE(blk_bs(blk), rwco.ret == NOT_DONE);
+ if (qemu_in_coroutine()) {
+ /* Fast-path if already in coroutine context */
+ co_entry(&rwco);
+ } else {
+ Coroutine *co = qemu_coroutine_create(co_entry, &rwco);
+ qemu_coroutine_enter(co);
+ BDRV_POLL_WHILE(blk_bs(blk), rwco.ret == NOT_DONE);
+ }
return rwco.ret;
}
--
2.9.3
- [Qemu-devel] [PATCH v3 00/18] aio_context_acquire/release pushdown, part 2, Paolo Bonzini, 2017/02/01
- [Qemu-devel] [PATCH 01/18] block: move AioContext and QEMUTimer to libqemuutil, Paolo Bonzini, 2017/02/01
- [Qemu-devel] [PATCH 03/18] block-backend: allow blk_prw from coroutine context,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 02/18] aio: introduce aio_co_schedule and aio_co_wake, Paolo Bonzini, 2017/02/01
- [Qemu-devel] [PATCH 04/18] test-thread-pool: use generic AioContext infrastructure, Paolo Bonzini, 2017/02/01
- [Qemu-devel] [PATCH 05/18] io: add methods to set I/O handlers on AioContext, Paolo Bonzini, 2017/02/01
- [Qemu-devel] [PATCH 06/18] io: make qio_channel_yield aware of AioContexts, Paolo Bonzini, 2017/02/01
- [Qemu-devel] [PATCH 08/18] coroutine-lock: reschedule coroutine on the AioContext it was running on, Paolo Bonzini, 2017/02/01
- [Qemu-devel] [PATCH 09/18] blkdebug: reschedule coroutine on the AioContext it is running on, Paolo Bonzini, 2017/02/01
- [Qemu-devel] [PATCH 07/18] nbd: convert to use qio_channel_yield, Paolo Bonzini, 2017/02/01
- [Qemu-devel] [PATCH 10/18] qed: introduce qed_aio_start_io and qed_aio_next_io_cb, Paolo Bonzini, 2017/02/01
- [Qemu-devel] [PATCH 12/18] block: explicitly acquire aiocontext in timers that need it, Paolo Bonzini, 2017/02/01
- [Qemu-devel] [PATCH 13/18] block: explicitly acquire aiocontext in callbacks that need it, Paolo Bonzini, 2017/02/01