[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v4 4/9] qcow2-threads: qcow2_co_do_compress: protect

From: Vladimir Sementsov-Ogievskiy
Subject: [Qemu-devel] [PATCH v4 4/9] qcow2-threads: qcow2_co_do_compress: protect queuing by mutex
Date: Mon, 11 Feb 2019 17:44:16 +0300

Drop dependence on AioContext lock.

Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>

    v4: add r-b by Alberto and Paolo.
    Paolo asked to add some information to the commit message.
    I don't have good understanding of moving from
    "AioContext lock usage" to other locks, so I just added
    "Drop dependence on AioContext lock.", not being sure that
    it is correct or make sense. And, in the same time take both
    r-b's. So, hope maintainers will adjust commit message if

 block/qcow2-threads.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/block/qcow2-threads.c b/block/qcow2-threads.c
index 20b2616529..156e0667be 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);
+    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_mutex_unlock(&s->lock);
     return arg.ret;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]