From nobody Tue Nov 11 03:20:46 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=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1560876040; cv=none; d=zoho.com; s=zohoarc; b=TtkOSu+/U5NCAKyTQNaG9NVjRjCB7htFY3h0uR5heyuaxkgrdGg+QytJAg5NrJ4TSTVSy3PoOKzMX3ynYBial0LCrk59MF83xw8M2x+JHeMRiGbtHBGlZGcwN/DADZ89i86zATGte6JIpYgWdi7eVSZLrzzZnU8D1QhARWlghGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560876040; 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=lj9349eOQeNx+/H/iLKWW/YH/MC7dXsKy3cD19aYRSg=; b=gBT6IYM42LtlHhH/RI5yJ7rHmhFx5CxyE4jd3xQhl+qF4tYBKLoLBImSvc4gE2heQNvfNp3dY1OIoKnIeFheUmY34PAf1Ta9WQrenkHbFgxMLvV5Q9wP68egLdn9IQ2mFrdADZ/w1r9m852siBM1ZH7/RVOyqbynUzv4F5GR75Y= 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 1560876040968132.09777253318964; Tue, 18 Jun 2019 09:40:40 -0700 (PDT) Received: from localhost ([::1]:59734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdH9z-0002Wp-RD for importer@patchew.org; Tue, 18 Jun 2019 12:40:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34201) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdGFe-0007QF-5m for qemu-devel@nongnu.org; Tue, 18 Jun 2019 11:42:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdGFX-0005rU-5M for qemu-devel@nongnu.org; Tue, 18 Jun 2019 11:42:22 -0400 Received: from relay.sw.ru ([185.231.240.75]:38512) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hdGFT-0005VY-BY; Tue, 18 Jun 2019 11:42:17 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1hdGFH-0002Sc-Jm; Tue, 18 Jun 2019 18:42:03 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 18 Jun 2019 18:42:00 +0300 Message-Id: <20190618154202.89107-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190618154202.89107-1-vsementsov@virtuozzo.com> References: <20190618154202.89107-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 1/3] block: implement BDRV_REQ_PREFETCH 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: kwolf@redhat.com, fam@euphon.net, 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" Do effective copy-on-read request when we don't need data actually. It will be used for block-stream and NBD_CMD_CACHE. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block.h | 8 +++++++- block/io.c | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index f9415ed740..a063ee135b 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -88,8 +88,14 @@ typedef enum { * fallback. */ BDRV_REQ_NO_FALLBACK =3D 0x100, =20 + /* + * BDRV_REQ_PREFETCH may be used only together with BDRV_REQ_COPY_ON_R= EAD + * on read request and means that caller don't really need data to be + * written to qiov parameter which may be NULL. + */ + BDRV_REQ_PREFETCH =3D 0x200, /* Mask of valid flags */ - BDRV_REQ_MASK =3D 0x1ff, + BDRV_REQ_MASK =3D 0x3ff, } BdrvRequestFlags; =20 typedef struct BlockSizes { diff --git a/block/io.c b/block/io.c index 9ba1bada36..a232243de3 100644 --- a/block/io.c +++ b/block/io.c @@ -1104,7 +1104,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, + int flags) { BlockDriverState *bs =3D child->bs; =20 @@ -1215,9 +1216,11 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(Bdr= vChild *child, goto err; } =20 - qemu_iovec_from_buf(qiov, progress, bounce_buffer + skip_bytes, - pnum - skip_bytes); - } else { + if (!(flags & BDRV_REQ_PREFETCH)) { + qemu_iovec_from_buf(qiov, progress, bounce_buffer + skip_b= ytes, + 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); @@ -1268,7 +1271,8 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild= *child, * potential fallback support, if we ever implement any read flags * to pass through to drivers. For now, there aren't any * passthrough flags. */ - assert(!(flags & ~(BDRV_REQ_NO_SERIALISING | BDRV_REQ_COPY_ON_READ))); + assert(!(flags & ~(BDRV_REQ_NO_SERIALISING | BDRV_REQ_COPY_ON_READ | + BDRV_REQ_PREFETCH))); =20 /* Handle Copy on Read and associated serialisation */ if (flags & BDRV_REQ_COPY_ON_READ) { @@ -1296,7 +1300,9 @@ 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, f= lags); + goto out; + } else if (flags & BDRV_REQ_PREFETCH) { goto out; } } --=20 2.18.0