From patchwork Mon May 30 11:31:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 9140929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AC4BE60777 for ; Mon, 30 May 2016 11:32:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DF7828185 for ; Mon, 30 May 2016 11:32:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9287F281C2; Mon, 30 May 2016 11:32:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BEE3828185 for ; Mon, 30 May 2016 11:31:55 +0000 (UTC) Received: from localhost ([::1]:59444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7LQG-0004MC-AX for patchwork-qemu-devel@patchwork.kernel.org; Mon, 30 May 2016 07:31:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7LPx-0004KK-R6 for qemu-devel@nongnu.org; Mon, 30 May 2016 07:31:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b7LPi-0001QG-Oq for qemu-devel@nongnu.org; Mon, 30 May 2016 07:31:33 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:46287 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7LPi-0001PV-Fn for qemu-devel@nongnu.org; Mon, 30 May 2016 07:31:18 -0400 Received: (qmail 9343 invoked by uid 89); 30 May 2016 11:31:16 -0000 Received: from [195.62.97.28] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.99.2/21638. hbedv: 8.3.40.22/7.12.95.236. avast: 1.2.2/16053000. spamassassin: 3.4.1. Clear:RC:1(195.62.97.28):. Processed in 0.105351 secs); 30 May 2016 11:31:16 -0000 Received: from smtp.kamp.de (HELO submission.kamp.de) ([195.62.97.28]) by mx01.kamp.de with ESMTPS (DHE-RSA-AES256-GCM-SHA384 encrypted); 30 May 2016 11:31:14 -0000 X-GL_Whitelist: yes Received: (qmail 30396 invoked from network); 30 May 2016 11:31:14 -0000 Received: from lieven-pc.kamp-intra.net (HELO lieven-pc) (relay@kamp.de@::ffff:172.21.12.60) by submission.kamp.de with ESMTPS (DHE-RSA-AES256-GCM-SHA384 encrypted) ESMTPA; 30 May 2016 11:31:14 -0000 Received: by lieven-pc (Postfix, from userid 1000) id 58E2720971; Mon, 30 May 2016 13:31:14 +0200 (CEST) From: Peter Lieven To: qemu-block@nongnu.org Date: Mon, 30 May 2016 13:31:13 +0200 Message-Id: <1464607873-28206-1-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a02:248:0:51::16 Subject: [Qemu-devel] [PATCH V3] block/io: optimize bdrv_co_pwritev for small requests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, famz@redhat.com, Peter Lieven , qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- v1->v2: following Paolos suggestions to simplify the if condition and adjusting the comment v2->v3: fix iotest 077 for requests that are within the same aligned block [Fam, Kevin] 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 2d832aa..0e4bb1e 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 <