From nobody Wed Dec 17 05:44:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566937250; cv=none; d=zoho.com; s=zohoarc; b=IJsaBoC+V0r+Cof7hkScKhTRb1/3KRzJcbpJil1zZ+WaCusGh00Gc1p5LB7nqniEy8EJecNjLm9Ts4QSXIKBDsws0BeCqZsa93bI/EZGcmj/0eK+7i6Uv52syBQzMonSU9uGbQ+fCFkcoU4wICQmgk9JeBg/Scg/Z2y+W9opWIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566937250; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=oD5floX5ae+1AJZSJemX97mMUqCZ5hKGoePswXexCkI=; b=l3ossVMsYTzSNX7drPUQPbNLt/R/rZY33U2GRF5ERAWeYShBOVvzizmk8K1zCewRkFS3Yx100sJK2gbPwxsts5KtTN/n4EYZyTmzh6Eb8me53xBrAsA2kGb9uYI2FAAKc9bevX/LTzaVizQfeHsMJmFZ9Gp6AB2M/HMhTLztwwE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566937250300332.9599979560802; Tue, 27 Aug 2019 13:20:50 -0700 (PDT) Received: from localhost ([::1]:58038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2hxQ-0000pa-EA for importer@patchew.org; Tue, 27 Aug 2019 16:20:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51372) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2huL-00069h-FD for qemu-devel@nongnu.org; Tue, 27 Aug 2019 16:17:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2huK-0000ov-Ct for qemu-devel@nongnu.org; Tue, 27 Aug 2019 16:17:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42432) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i2huH-0000nP-OP; Tue, 27 Aug 2019 16:17:33 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1141210F23E7; Tue, 27 Aug 2019 20:17:33 +0000 (UTC) Received: from localhost (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A80E6E700; Tue, 27 Aug 2019 20:17:26 +0000 (UTC) From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Tue, 27 Aug 2019 21:16:32 +0100 Message-Id: <20190827201639.30368-6-stefanha@redhat.com> In-Reply-To: <20190827201639.30368-1-stefanha@redhat.com> References: <20190827201639.30368-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Tue, 27 Aug 2019 20:17:33 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/12] block/io: bdrv_co_do_copy_on_readv: use and support qiov_offset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org, Peter Maydell , Max Reitz , Stefan Hajnoczi , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Use and support new API in bdrv_co_do_copy_on_readv. Note that in case of allocated-in-top we need to shrink read size to MIN(..) by hand, as pre-patch this was actually done implicitly by qemu_iovec_concat (and we used local_qiov.size). Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Stefan Hajnoczi Message-id: 20190604161514.262241-6-vsementsov@virtuozzo.com Message-Id: <20190604161514.262241-6-vsementsov@virtuozzo.com> Signed-off-by: Stefan Hajnoczi --- block/io.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/block/io.c b/block/io.c index fd2fc7d5ff..5817bb9405 100644 --- a/block/io.c +++ b/block/io.c @@ -1227,7 +1227,7 @@ bdrv_driver_pwritev_compressed(BlockDriverState *bs, = uint64_t offset, =20 static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, - int flags) + size_t qiov_offset, int flags) { BlockDriverState *bs =3D child->bs; =20 @@ -1239,7 +1239,6 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(Bdrv= Child *child, void *bounce_buffer; =20 BlockDriver *drv =3D bs->drv; - QEMUIOVector local_qiov; int64_t cluster_offset; int64_t cluster_bytes; size_t skip_bytes; @@ -1302,6 +1301,8 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(Bdrv= Child *child, assert(skip_bytes < pnum); =20 if (ret <=3D 0) { + QEMUIOVector local_qiov; + /* Must copy-on-read; use the bounce buffer */ pnum =3D MIN(pnum, MAX_BOUNCE_BUFFER); qemu_iovec_init_buf(&local_qiov, bounce_buffer, pnum); @@ -1339,16 +1340,15 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(Bd= rvChild *child, } =20 if (!(flags & BDRV_REQ_PREFETCH)) { - qemu_iovec_from_buf(qiov, progress, bounce_buffer + skip_b= ytes, + qemu_iovec_from_buf(qiov, qiov_offset + progress, + bounce_buffer + skip_bytes, pnum - skip_bytes); } } else if (!(flags & BDRV_REQ_PREFETCH)) { /* Read directly into the destination */ - qemu_iovec_init(&local_qiov, qiov->niov); - qemu_iovec_concat(&local_qiov, qiov, progress, pnum - skip_byt= es); - ret =3D bdrv_driver_preadv(bs, offset + progress, local_qiov.s= ize, - &local_qiov, 0, 0); - qemu_iovec_destroy(&local_qiov); + ret =3D bdrv_driver_preadv(bs, offset + progress, + MIN(pnum - skip_bytes, bytes - progre= ss), + qiov, qiov_offset + progress, 0); if (ret < 0) { goto err; } @@ -1422,7 +1422,7 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild= *child, } =20 if (!ret || pnum !=3D bytes) { - ret =3D bdrv_co_do_copy_on_readv(child, offset, bytes, qiov, f= lags); + ret =3D bdrv_co_do_copy_on_readv(child, offset, bytes, qiov, 0= , flags); goto out; } else if (flags & BDRV_REQ_PREFETCH) { goto out; --=20 2.21.0