diff options
author | Kevin Wolf <kwolf@redhat.com> | 2010-09-13 18:08:52 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2010-09-21 15:39:42 +0200 |
commit | bd28f835652e396841bb73080a07bcc08fe21bf0 (patch) | |
tree | 7f8b026a2beb604f1f6b7f47c90b13b734df4f44 /block/qcow2-cluster.c | |
parent | b8a83a4f79ca4cd0689117b119ffaa1a91b00d52 (diff) | |
download | qemu-bd28f835652e396841bb73080a07bcc08fe21bf0.zip qemu-bd28f835652e396841bb73080a07bcc08fe21bf0.tar.gz qemu-bd28f835652e396841bb73080a07bcc08fe21bf0.tar.bz2 |
qcow2: Avoid bounce buffers for AIO read requests
qcow2 used to use bounce buffers for any AIO requests. This does not only imply
unnecessary copying, but also unbounded allocations which should be avoided.
This patch removes bounce buffers from the normal AIO read path, and constrains
them to a constant size for encrypted images.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/qcow2-cluster.c')
-rw-r--r-- | block/qcow2-cluster.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index cb2e33f..fb4224a 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -350,6 +350,8 @@ static int qcow_read(BlockDriverState *bs, int64_t sector_num, BDRVQcowState *s = bs->opaque; int ret, index_in_cluster, n, n1; uint64_t cluster_offset; + struct iovec iov; + QEMUIOVector qiov; while (nb_sectors > 0) { n = nb_sectors; @@ -364,7 +366,11 @@ static int qcow_read(BlockDriverState *bs, int64_t sector_num, if (!cluster_offset) { if (bs->backing_hd) { /* read from the base image */ - n1 = qcow2_backing_read1(bs->backing_hd, sector_num, buf, n); + iov.iov_base = buf; + iov.iov_len = n * 512; + qemu_iovec_init_external(&qiov, &iov, 1); + + n1 = qcow2_backing_read1(bs->backing_hd, &qiov, sector_num, n); if (n1 > 0) { BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING); ret = bdrv_read(bs->backing_hd, sector_num, buf, n1); |