diff options
Diffstat (limited to 'block/qcow2-threads.c')
-rw-r--r-- | block/qcow2-threads.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/block/qcow2-threads.c b/block/qcow2-threads.c index 5a39fdac69..50a9fdeec5 100644 --- a/block/qcow2-threads.c +++ b/block/qcow2-threads.c @@ -158,15 +158,19 @@ qcow2_co_do_compress(BlockDriverState *bs, void *dest, size_t dest_size, .func = func, }; + qemu_co_mutex_lock(&s->lock); while (s->nb_compress_threads >= MAX_COMPRESS_THREADS) { - qemu_co_queue_wait(&s->compress_wait_queue, NULL); + qemu_co_queue_wait(&s->compress_wait_queue, &s->lock); } - s->nb_compress_threads++; + qemu_co_mutex_unlock(&s->lock); + thread_pool_submit_co(pool, qcow2_compress_pool_func, &arg); - s->nb_compress_threads--; + qemu_co_mutex_lock(&s->lock); + s->nb_compress_threads--; qemu_co_queue_next(&s->compress_wait_queue); + qemu_co_mutex_unlock(&s->lock); return arg.ret; } |