[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 04/21] qcow2-threads: qcow2_co_do_compress: protect q
From: |
Max Reitz |
Subject: |
[Qemu-block] [PULL 04/21] qcow2-threads: qcow2_co_do_compress: protect queuing by mutex |
Date: |
Tue, 28 May 2019 21:28:30 +0200 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
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>
Reviewed-by: Max Reitz <address@hidden>
Message-id: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
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 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;
}
--
2.21.0
- [Qemu-block] [PULL 00/21] Block patches, Max Reitz, 2019/05/28
- [Qemu-block] [PULL 01/21] qcow2.h: add missing include, Max Reitz, 2019/05/28
- [Qemu-block] [PULL 04/21] qcow2-threads: qcow2_co_do_compress: protect queuing by mutex,
Max Reitz <=
- [Qemu-block] [PULL 03/21] qcow2-threads: use thread_pool_submit_co, Max Reitz, 2019/05/28
- [Qemu-block] [PULL 05/21] qcow2-threads: split out generic path, Max Reitz, 2019/05/28
- [Qemu-block] [PULL 02/21] qcow2: add separate file for threaded data processing functions, Max Reitz, 2019/05/28
- [Qemu-block] [PULL 13/21] block/backup: refactor: split out backup_calculate_cluster_size, Max Reitz, 2019/05/28
- [Qemu-block] [PULL 16/21] qemu-img: rebase: Reuse parent BlockDriverState, Max Reitz, 2019/05/28
- [Qemu-block] [PULL 07/21] qcow2: bdrv_co_pwritev: move encryption code out of the lock, Max Reitz, 2019/05/28
- [Qemu-block] [PULL 06/21] qcow2: qcow2_co_preadv: improve locking, Max Reitz, 2019/05/28
- [Qemu-block] [PULL 14/21] block: Use bdrv_unref_child() for all children in bdrv_close(), Max Reitz, 2019/05/28
- [Qemu-block] [PULL 10/21] block/backup: move to copy_bitmap with granularity, Max Reitz, 2019/05/28
- [Qemu-block] [PULL 15/21] block: Make bdrv_root_attach_child() unref child_bs on failure, Max Reitz, 2019/05/28