diff options
author | Peter Lieven <pl@kamp.de> | 2016-05-30 13:31:13 +0200 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2016-06-07 14:40:51 +0100 |
commit | 117bc3fa22d359db6c4f0c10f34c8c9e00ed64af (patch) | |
tree | daebd01e11358993b50f6bef3406aab2461d2cd0 /block/io.c | |
parent | e3a4f91b4dda92666379e4865ea9847644f3bc19 (diff) | |
download | qemu-117bc3fa22d359db6c4f0c10f34c8c9e00ed64af.zip qemu-117bc3fa22d359db6c4f0c10f34c8c9e00ed64af.tar.gz qemu-117bc3fa22d359db6c4f0c10f34c8c9e00ed64af.tar.bz2 |
block/io: optimize bdrv_co_pwritev for small requests
in a read-modify-write cycle a small request might cause
head and tail to fall into the same aligned block. Currently
QEMU reads the same block twice in this case which is
not necessary.
Signed-off-by: Peter Lieven <pl@kamp.de>
Message-id: 1464607873-28206-1-git-send-email-pl@kamp.de
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/io.c')
-rw-r--r-- | block/io.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -1427,6 +1427,14 @@ int coroutine_fn bdrv_co_pwritev(BlockDriverState *bs, bytes += offset & (align - 1); offset = offset & ~(align - 1); + + /* We have read the tail already if the request is smaller + * than one aligned block. + */ + if (bytes < align) { + qemu_iovec_add(&local_qiov, head_buf + bytes, align - bytes); + bytes = align; + } } if ((offset + bytes) & (align - 1)) { |