aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2019-05-06 17:27:37 +0300
committerMax Reitz <mreitz@redhat.com>2019-05-28 20:30:55 +0200
commit0f5636c51c76fed01e2ed02fbb7a46da869f0489 (patch)
tree1dec721ed3191bcb1968c02d3d683a12b8f270c9 /block
parent269062efc8c665707ef88d425d383f4223ce1b11 (diff)
qcow2-threads: qcow2_co_do_compress: protect queuing by mutex
Drop dependence on AioContext lock. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 20190506142741.41731-5-vsementsov@virtuozzo.com Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/qcow2-threads.c10
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;
}