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>
This commit is contained in:
parent
56e2f1d898
commit
269062efc8
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user