From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12E40C282CE for ; Tue, 4 Jun 2019 16:21:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E429C23CCA for ; Tue, 4 Jun 2019 16:21:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E429C23CCA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([127.0.0.1]:54909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYCC1-00050N-4P for qemu-devel@archiver.kernel.org; Tue, 04 Jun 2019 12:21:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYC6B-00012f-PS for qemu-devel@nongnu.org; Tue, 04 Jun 2019 12:15:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYC6A-0005fV-JX for qemu-devel@nongnu.org; Tue, 04 Jun 2019 12:15:43 -0400 Received: from relay.sw.ru ([185.231.240.75]:41696) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYC6A-0005C2-AV; Tue, 04 Jun 2019 12:15:42 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hYC5k-0005Pq-L1; Tue, 04 Jun 2019 19:15:16 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 4 Jun 2019 19:15:12 +0300 Message-Id: <20190604161514.262241-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190604161514.262241-1-vsementsov@virtuozzo.com> References: <20190604161514.262241-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v2 10/12] block/qcow2: refactor qcow2_co_preadv to use buffer-based io 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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use buffer based io in encrypted case. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index f2cb131048..8a033ae08c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2047,19 +2047,15 @@ static coroutine_fn int qcow2_co_preadv(BlockDriverState *bs, uint64_t offset, } assert(cur_bytes <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); - qemu_iovec_reset(&hd_qiov); - qemu_iovec_add(&hd_qiov, cluster_data, cur_bytes); - } - BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); - ret = bdrv_co_preadv(s->data_file, - cluster_offset + offset_in_cluster, - cur_bytes, &hd_qiov, 0); - if (ret < 0) { - goto fail; - } - if (bs->encrypted) { - assert(s->crypto); + BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); + ret = bdrv_co_pread(s->data_file, + cluster_offset + offset_in_cluster, + cur_bytes, cluster_data, 0); + if (ret < 0) { + goto fail; + } + assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); assert((cur_bytes & (BDRV_SECTOR_SIZE - 1)) == 0); if (qcow2_co_decrypt(bs, cluster_offset, offset, @@ -2068,6 +2064,14 @@ static coroutine_fn int qcow2_co_preadv(BlockDriverState *bs, uint64_t offset, goto fail; } qemu_iovec_from_buf(qiov, bytes_done, cluster_data, cur_bytes); + } else { + BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); + ret = bdrv_co_preadv(s->data_file, + cluster_offset + offset_in_cluster, + cur_bytes, &hd_qiov, 0); + if (ret < 0) { + goto fail; + } } break; -- 2.18.0