aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2019-05-06 17:27:36 +0300
committerMax Reitz <mreitz@redhat.com>2019-05-28 20:30:55 +0200
commit269062efc8c665707ef88d425d383f4223ce1b11 (patch)
tree438c8bda15d8326ff0e5f1ae22f1c576ab06d617
parent56e2f1d898849784c25928d49b5143e5e9b71d08 (diff)
downloadqemu-269062efc8c665707ef88d425d383f4223ce1b11.zip
qemu-269062efc8c665707ef88d425d383f4223ce1b11.tar.gz
qemu-269062efc8c665707ef88d425d383f4223ce1b11.tar.bz2
qcow2-threads: use thread_pool_submit_co
Use thread_pool_submit_co, instead of reinventing it here. Note, that thread_pool_submit_aio() never returns NULL, so checking it was an extra thing. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 20190506142741.41731-4-vsementsov@virtuozzo.com Signed-off-by: Max Reitz <mreitz@redhat.com>
-rw-r--r--block/qcow2-threads.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/block/qcow2-threads.c b/block/qcow2-threads.c
index 85b8034..5a39fda 100644
--- a/block/qcow2-threads.c
+++ b/block/qcow2-threads.c
@@ -144,17 +144,11 @@ static int qcow2_compress_pool_func(void *opaque)
return 0;
}
-static void qcow2_compress_complete(void *opaque, int ret)
-{
- qemu_coroutine_enter(opaque);
-}
-
static ssize_t coroutine_fn
qcow2_co_do_compress(BlockDriverState *bs, void *dest, size_t dest_size,
const void *src, size_t src_size, Qcow2CompressFunc func)
{
BDRVQcow2State *s = bs->opaque;
- BlockAIOCB *acb;
ThreadPool *pool = aio_get_thread_pool(bdrv_get_aio_context(bs));
Qcow2CompressData arg = {
.dest = dest,
@@ -169,16 +163,9 @@ qcow2_co_do_compress(BlockDriverState *bs, void *dest, size_t dest_size,
}
s->nb_compress_threads++;
- acb = thread_pool_submit_aio(pool, qcow2_compress_pool_func, &arg,
- qcow2_compress_complete,
- qemu_coroutine_self());
-
- if (!acb) {
- s->nb_compress_threads--;
- return -EINVAL;
- }
- qemu_coroutine_yield();
+ thread_pool_submit_co(pool, qcow2_compress_pool_func, &arg);
s->nb_compress_threads--;
+
qemu_co_queue_next(&s->compress_wait_queue);
return arg.ret;