From nobody Wed Dec 17 05:43:40 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=1566937344; cv=none; d=zoho.com; s=zohoarc; b=PhxYftGhW1okrBz07KOqHwkZ/0xlXxYDTuOhUnCUdQZDuevD6h5K/MiGV2pRc0Tl6jwUlWaTebbzjA4PZBtTtXqYeBVS3pBacLXI9gKJYJH4UVn4D89od5TW/IUySDeHsx2hxZ58Z1asPVv94Dqd5mVjYodJK+uA2XUfRDFd+jA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566937344; 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=a/XIzfidPfDM7tNIac5anIV+EkWcPliDntAyb4QZArY=; b=Cr2ACZdCE/lPz8cx6aLez1S/VFdsmIn/Th+k1NDIj8hMRe0BNdY4HQzxZEUFHR493RoxYwfG+tWq3c5iO/NRupFdBwFv0phYHRor74rpOBhmPJ8UuQQiFgNVpHy4tbomYUGaBxv1ZTAqbsdslXQn/lN1J+NEtHEwterH2rp7/Zg= 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 156693734464779.07708122577742; Tue, 27 Aug 2019 13:22:24 -0700 (PDT) Received: from localhost ([::1]:58086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2hyx-0003Ma-Br for importer@patchew.org; Tue, 27 Aug 2019 16:22:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51475) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2hub-0006Qq-1H for qemu-devel@nongnu.org; Tue, 27 Aug 2019 16:17:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2huZ-0000uS-N7 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 16:17:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39918) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i2huW-0000t4-UM; Tue, 27 Aug 2019 16:17:49 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39ACF307D8E3; Tue, 27 Aug 2019 20:17:48 +0000 (UTC) Received: from localhost (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6275196AE; Tue, 27 Aug 2019 20:17:47 +0000 (UTC) From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Tue, 27 Aug 2019 21:16:35 +0100 Message-Id: <20190827201639.30368-9-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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 27 Aug 2019 20:17:48 +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 08/12] block/io: bdrv_aligned_pwritev: 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_aligned_pwritev. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Stefan Hajnoczi Message-id: 20190604161514.262241-9-vsementsov@virtuozzo.com Message-Id: <20190604161514.262241-9-vsementsov@virtuozzo.com> Signed-off-by: Stefan Hajnoczi --- block/io.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/block/io.c b/block/io.c index f191a3fa1e..237d7f40f5 100644 --- a/block/io.c +++ b/block/io.c @@ -1872,7 +1872,7 @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t of= fset, uint64_t bytes, */ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, BdrvTrackedRequest *req, int64_t offset, unsigned int bytes, - int64_t align, QEMUIOVector *qiov, int flags) + int64_t align, QEMUIOVector *qiov, size_t qiov_offset, int flags) { BlockDriverState *bs =3D child->bs; BlockDriver *drv =3D bs->drv; @@ -1892,7 +1892,7 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChil= d *child, assert(is_power_of_2(align)); assert((offset & (align - 1)) =3D=3D 0); assert((bytes & (align - 1)) =3D=3D 0); - assert(!qiov || bytes =3D=3D qiov->size); + assert(!qiov || qiov_offset + bytes <=3D qiov->size); max_transfer =3D QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_transfer, INT= _MAX), align); =20 @@ -1900,7 +1900,7 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChil= d *child, =20 if (!ret && bs->detect_zeroes !=3D BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF = && !(flags & BDRV_REQ_ZERO_WRITE) && drv->bdrv_co_pwrite_zeroes && - qemu_iovec_is_zero(qiov, 0, qiov->size)) { + qemu_iovec_is_zero(qiov, qiov_offset, bytes)) { flags |=3D BDRV_REQ_ZERO_WRITE; if (bs->detect_zeroes =3D=3D BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP)= { flags |=3D BDRV_REQ_MAY_UNMAP; @@ -1913,15 +1913,15 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvCh= ild *child, bdrv_debug_event(bs, BLKDBG_PWRITEV_ZERO); ret =3D bdrv_co_do_pwrite_zeroes(bs, offset, bytes, flags); } else if (flags & BDRV_REQ_WRITE_COMPRESSED) { - ret =3D bdrv_driver_pwritev_compressed(bs, offset, bytes, qiov, 0); + ret =3D bdrv_driver_pwritev_compressed(bs, offset, bytes, + qiov, qiov_offset); } else if (bytes <=3D max_transfer) { bdrv_debug_event(bs, BLKDBG_PWRITEV); - ret =3D bdrv_driver_pwritev(bs, offset, bytes, qiov, 0, flags); + ret =3D bdrv_driver_pwritev(bs, offset, bytes, qiov, qiov_offset, = flags); } else { bdrv_debug_event(bs, BLKDBG_PWRITEV); while (bytes_remaining) { int num =3D MIN(bytes_remaining, max_transfer); - QEMUIOVector local_qiov; int local_flags =3D flags; =20 assert(num); @@ -1931,12 +1931,10 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvCh= ild *child, * need to flush on the last iteration */ local_flags &=3D ~BDRV_REQ_FUA; } - qemu_iovec_init(&local_qiov, qiov->niov); - qemu_iovec_concat(&local_qiov, qiov, bytes - bytes_remaining, = num); =20 ret =3D bdrv_driver_pwritev(bs, offset + bytes - bytes_remaini= ng, - num, &local_qiov, 0, local_flags); - qemu_iovec_destroy(&local_qiov); + num, qiov, bytes - bytes_remaining, + local_flags); if (ret < 0) { break; } @@ -1979,7 +1977,7 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvC= hild *child, =20 qemu_iovec_init_buf(&local_qiov, pad.buf, write_bytes); ret =3D bdrv_aligned_pwritev(child, req, aligned_offset, write= _bytes, - align, &local_qiov, + align, &local_qiov, 0, flags & ~BDRV_REQ_ZERO_WRITE); if (ret < 0 || pad.merge_reads) { /* Error or all work is done */ @@ -1995,7 +1993,7 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvC= hild *child, /* Write the aligned part in the middle. */ uint64_t aligned_bytes =3D bytes & ~(align - 1); ret =3D bdrv_aligned_pwritev(child, req, offset, aligned_bytes, al= ign, - NULL, flags); + NULL, 0, flags); if (ret < 0) { goto out; } @@ -2009,7 +2007,8 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvC= hild *child, =20 qemu_iovec_init_buf(&local_qiov, pad.tail_buf, align); ret =3D bdrv_aligned_pwritev(child, req, offset, align, align, - &local_qiov, flags & ~BDRV_REQ_ZERO_WRI= TE); + &local_qiov, 0, + flags & ~BDRV_REQ_ZERO_WRITE); } =20 out: @@ -2062,7 +2061,7 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, } =20 ret =3D bdrv_aligned_pwritev(child, &req, offset, bytes, align, - qiov, flags); + qiov, 0, flags); =20 bdrv_padding_destroy(&pad); =20 --=20 2.21.0