[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/41] qcow2: do decompression in threads
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 13/41] qcow2: do decompression in threads |
Date: |
Wed, 12 Dec 2018 14:27:07 +0100 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
Do decompression in threads, like it is already done for compression.
This improves asynchronous compressed reads performance.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2.c | 34 +++++++++++++++++++++++++++-------
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index c1886c46e3..0b5ad13006 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3807,20 +3807,24 @@ static ssize_t qcow2_decompress(void *dest, size_t
dest_size,
#define MAX_COMPRESS_THREADS 4
+typedef ssize_t (*Qcow2CompressFunc)(void *dest, size_t dest_size,
+ const void *src, size_t src_size);
typedef struct Qcow2CompressData {
void *dest;
size_t dest_size;
const void *src;
size_t src_size;
ssize_t ret;
+
+ Qcow2CompressFunc func;
} Qcow2CompressData;
static int qcow2_compress_pool_func(void *opaque)
{
Qcow2CompressData *data = opaque;
- data->ret = qcow2_compress(data->dest, data->dest_size,
- data->src, data->src_size);
+ data->ret = data->func(data->dest, data->dest_size,
+ data->src, data->src_size);
return 0;
}
@@ -3830,10 +3834,9 @@ static void qcow2_compress_complete(void *opaque, int
ret)
qemu_coroutine_enter(opaque);
}
-/* See qcow2_compress definition for parameters description */
-static ssize_t qcow2_co_compress(BlockDriverState *bs,
- void *dest, size_t dest_size,
- const void *src, size_t src_size)
+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;
@@ -3843,6 +3846,7 @@ static ssize_t qcow2_co_compress(BlockDriverState *bs,
.dest_size = dest_size,
.src = src,
.src_size = src_size,
+ .func = func,
};
while (s->nb_compress_threads >= MAX_COMPRESS_THREADS) {
@@ -3865,6 +3869,22 @@ static ssize_t qcow2_co_compress(BlockDriverState *bs,
return arg.ret;
}
+static ssize_t coroutine_fn
+qcow2_co_compress(BlockDriverState *bs, void *dest, size_t dest_size,
+ const void *src, size_t src_size)
+{
+ return qcow2_co_do_compress(bs, dest, dest_size, src, src_size,
+ qcow2_compress);
+}
+
+static ssize_t coroutine_fn
+qcow2_co_decompress(BlockDriverState *bs, void *dest, size_t dest_size,
+ const void *src, size_t src_size)
+{
+ return qcow2_co_do_compress(bs, dest, dest_size, src, src_size,
+ qcow2_decompress);
+}
+
/* XXX: put compressed sectors first, then all the cluster aligned
tables to avoid losing bytes in alignment */
static coroutine_fn int
@@ -3993,7 +4013,7 @@ qcow2_co_preadv_compressed(BlockDriverState *bs,
goto fail;
}
- if (qcow2_decompress(out_buf, s->cluster_size, buf, csize) < 0) {
+ if (qcow2_co_decompress(bs, out_buf, s->cluster_size, buf, csize) < 0) {
ret = -EIO;
goto fail;
}
--
2.19.2
- [Qemu-devel] [PULL 02/41] configure: adding support to lzfse library., (continued)
- [Qemu-devel] [PULL 02/41] configure: adding support to lzfse library., Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 03/41] dmg: including dmg-lzfse module inside dmg block driver., Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 05/41] block/replication: drop extra synchronization, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 04/41] dmg: exchanging hardcoded dmg UDIF block types to enum., Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 09/41] qcow2: move decompression from qcow2-cluster.c to qcow2.c, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 06/41] block/backup: drop unused synchronization interface, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 08/41] qcow2: make more generic interface for qcow2_compress, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 10/41] qcow2: refactor decompress_buffer, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 11/41] qcow2: use byte-based read in qcow2_decompress_cluster, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 07/41] qcow2: use Z_OK instead of 0 for deflateInit2 return code check, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 13/41] qcow2: do decompression in threads,
Kevin Wolf <=
- [Qemu-devel] [PULL 12/41] qcow2: aio support for compressed cluster read, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 16/41] file-posix: Avoid aio_worker() for QEMU_AIO_TRUNCATE, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 14/41] file-posix: Reorganise RawPosixAIOData, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 15/41] file-posix: Factor out raw_thread_pool_submit(), Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 18/41] file-posix: Avoid aio_worker() for QEMU_AIO_WRITE_ZEROES, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 17/41] file-posix: Avoid aio_worker() for QEMU_AIO_COPY_RANGE, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 21/41] file-posix: Move read/write operation logic out of aio_worker(), Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 19/41] file-posix: Avoid aio_worker() for QEMU_AIO_DISCARD, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 20/41] file-posix: Avoid aio_worker() for QEMU_AIO_FLUSH, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 23/41] file-posix: Remove paio_submit_co(), Kevin Wolf, 2018/12/12