From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAHy5-0003Eg-2X for qemu-devel@nongnu.org; Tue, 07 Jun 2016 10:26:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAHy0-0006cC-7W for qemu-devel@nongnu.org; Tue, 07 Jun 2016 10:26:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56302) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAHxz-0006c4-Vi for qemu-devel@nongnu.org; Tue, 07 Jun 2016 10:26:52 -0400 From: Stefan Hajnoczi Date: Tue, 7 Jun 2016 15:26:22 +0100 Message-Id: <1465309585-31551-10-git-send-email-stefanha@redhat.com> In-Reply-To: <1465309585-31551-1-git-send-email-stefanha@redhat.com> References: <1465309585-31551-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 09/12] block/io: optimize bdrv_co_pwritev for small requests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Peter Lieven , Stefan Hajnoczi From: Peter Lieven 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 Message-id: 1464607873-28206-1-git-send-email-pl@kamp.de Signed-off-by: Stefan Hajnoczi --- block/io.c | 8 ++++++++ tests/qemu-iotests/077 | 12 +----------- tests/qemu-iotests/077.out | 26 -------------------------- 3 files changed, 9 insertions(+), 37 deletions(-) diff --git a/block/io.c b/block/io.c index 7ac9897..e12f303 100644 --- a/block/io.c +++ b/block/io.c @@ -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)) { diff --git a/tests/qemu-iotests/077 b/tests/qemu-iotests/077 index 4dc680b..d2d2a2d 100755 --- a/tests/qemu-iotests/077 +++ b/tests/qemu-iotests/077 @@ -60,7 +60,7 @@ EOF # Sequential RMW requests on the same physical sector off=0x1000 -for ev in "head" "after_head" "tail" "after_tail"; do +for ev in "head" "after_head"; do cat <