From nobody Mon Feb 9 06:34:10 2026 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=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1559665822; cv=none; d=zoho.com; s=zohoarc; b=DABqYrQqQgYVdNeEAoNFfp3lEbonLR8rPDkVLqAqzphCvZ4wkybEk+rrXCQIKptYqbme6OxxDjgQPwWMGBJ/PwjLodccyfYLfwegBMDSDBLG/f1F7T/regqlSA9CLi4e9VsxI36iE0eLRg4EtIXSzVGO516DRacj3n6PDzzfRV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559665822; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=P7sEm/YyQGccySxq+NUV1d4YxZTd+Rawb5a/RPCiEac=; b=oMe9JDI/IkRhld2XHMBJCDOO4EBnRNn9uCU9iGUE/vYaOh6hgJv/r8iOfI6WKXc1Jox+0jWin7V7wUnOagS1imIjxZEr0TUbDXapDcHU64lb15+hX3R6uiz8xzNTC1C6fsWa7tdNmwGJM3R+wHzeN/+a5R9Btsy67KErlLZDUaU= 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 1559665822523198.14143503728678; Tue, 4 Jun 2019 09:30:22 -0700 (PDT) Received: from localhost ([127.0.0.1]:55087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYCKG-0004Gb-Hc for importer@patchew.org; Tue, 04 Jun 2019 12:30:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYC6F-00016R-Su for qemu-devel@nongnu.org; Tue, 04 Jun 2019 12:15:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYC6B-0005ge-6u for qemu-devel@nongnu.org; Tue, 04 Jun 2019 12:15:45 -0400 Received: from relay.sw.ru ([185.231.240.75]:41652) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYC6A-0005Bw-Mh; 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 1hYC5j-0005Pq-Qk; Tue, 04 Jun 2019 19:15:15 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 4 Jun 2019 19:15:07 +0300 Message-Id: <20190604161514.262241-6-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 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.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- block/io.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/block/io.c b/block/io.c index 7e53a11492..efd2b80293 100644 --- a/block/io.c +++ b/block/io.c @@ -1161,7 +1161,8 @@ 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) + int64_t offset, unsigned int bytes, + QEMUIOVector *qiov, size_t qiov_offset) { BlockDriverState *bs =3D child->bs; =20 @@ -1173,7 +1174,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; @@ -1236,6 +1236,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); @@ -1272,15 +1274,14 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(Bd= rvChild *child, goto err; } =20 - qemu_iovec_from_buf(qiov, progress, bounce_buffer + skip_bytes, + qemu_iovec_from_buf(qiov, qiov_offset + progress, + bounce_buffer + skip_bytes, pnum - skip_bytes); } else { /* 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; } @@ -1353,7 +1354,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); + ret =3D bdrv_co_do_copy_on_readv(child, offset, bytes, qiov, 0= ); goto out; } } --=20 2.18.0