[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 11/41] qcow2: use byte-based read in qcow2_decompress
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 11/41] qcow2: use byte-based read in qcow2_decompress_cluster |
Date: |
Wed, 12 Dec 2018 14:27:05 +0100 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
We are gradually moving away from sector-based interfaces, towards
byte-based. Get rid of it here too.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index ac9bb3a225..d4b25d88b5 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3957,17 +3957,19 @@ fail:
return ret;
}
-int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset)
+int coroutine_fn
+qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset)
{
BDRVQcow2State *s = bs->opaque;
- int ret, csize, nb_csectors, sector_offset;
+ int ret, csize, nb_csectors;
uint64_t coffset;
+ struct iovec iov;
+ QEMUIOVector local_qiov;
coffset = cluster_offset & s->cluster_offset_mask;
if (s->cluster_cache_offset != coffset) {
nb_csectors = ((cluster_offset >> s->csize_shift) & s->csize_mask) + 1;
- sector_offset = coffset & 511;
- csize = nb_csectors * 512 - sector_offset;
+ csize = nb_csectors * 512 - (coffset & 511);
/* Allocate buffers on first decompress operation, most images are
* uncompressed and the memory overhead can be avoided. The buffers
@@ -3985,14 +3987,17 @@ int qcow2_decompress_cluster(BlockDriverState *bs,
uint64_t cluster_offset)
s->cluster_cache = g_malloc(s->cluster_size);
}
+ iov.iov_base = s->cluster_data;
+ iov.iov_len = csize;
+ qemu_iovec_init_external(&local_qiov, &iov, 1);
+
BLKDBG_EVENT(bs->file, BLKDBG_READ_COMPRESSED);
- ret = bdrv_read(bs->file, coffset >> 9, s->cluster_data,
- nb_csectors);
+ ret = bdrv_co_preadv(bs->file, coffset, csize, &local_qiov, 0);
if (ret < 0) {
return ret;
}
if (qcow2_decompress(s->cluster_cache, s->cluster_size,
- s->cluster_data + sector_offset, csize) < 0) {
+ s->cluster_data, csize) < 0) {
return -EIO;
}
s->cluster_cache_offset = coffset;
--
2.19.2
- [Qemu-block] [PULL 00/41] Block layer patches, Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 01/41] block: adding lzfse decompressing support as a module., Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 02/41] configure: adding support to lzfse library., Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 04/41] dmg: exchanging hardcoded dmg UDIF block types to enum., Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 03/41] dmg: including dmg-lzfse module inside dmg block driver., Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 05/41] block/replication: drop extra synchronization, Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 08/41] qcow2: make more generic interface for qcow2_compress, Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 11/41] qcow2: use byte-based read in qcow2_decompress_cluster,
Kevin Wolf <=
- [Qemu-block] [PULL 07/41] qcow2: use Z_OK instead of 0 for deflateInit2 return code check, Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 06/41] block/backup: drop unused synchronization interface, Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 09/41] qcow2: move decompression from qcow2-cluster.c to qcow2.c, Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 10/41] qcow2: refactor decompress_buffer, Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 13/41] qcow2: do decompression in threads, Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 12/41] qcow2: aio support for compressed cluster read, Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 14/41] file-posix: Reorganise RawPosixAIOData, Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 15/41] file-posix: Factor out raw_thread_pool_submit(), Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 16/41] file-posix: Avoid aio_worker() for QEMU_AIO_TRUNCATE, Kevin Wolf, 2018/12/12
- [Qemu-block] [PULL 18/41] file-posix: Avoid aio_worker() for QEMU_AIO_WRITE_ZEROES, Kevin Wolf, 2018/12/12