From nobody Tue Nov 18 02:53:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1606933992; cv=none; d=zohomail.com; s=zohoarc; b=aBc1w3Spe6CgZxp6+FAAZ+Qv0tpPL9JttFy9kvlC126/8OxTToDyKna4BT+p6LGf/5jNe6ZqYtNT+kgv1hIkQbNfj7SWwhIBFSXC63ctOH5Nmewtb7SC/UsFoYaOAlXx8iGfcyevEOtY3iWX+v757wFt5F6k96YzFnm4TIu8dts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606933992; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=idIFqkEUltSRcJ7JCl8ip7Rb/K7IEJInxv9E3yolumM=; b=Jhs9CkvG7Pnv7KxsaYqvOIm0R7SKRJvGiYNE1dz0VhlQI4KG6oTnsBLRrXu8tPvKWqb+efLp8YmraE2nw/xH1Wt+5RFOCYk2RCLEz7m4qDq42RHVkIGV/zjy/NnnlTQMC3EW/2662Aq08mbt5mijuFD4jnq5u57DfqKKmLFlkH4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass 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 1606933991918553.4869401247691; Wed, 2 Dec 2020 10:33:11 -0800 (PST) Received: from localhost ([::1]:43274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kkWw9-0003Mr-RR for importer@patchew.org; Wed, 02 Dec 2020 13:33:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kkWuG-0001cd-V5; Wed, 02 Dec 2020 13:31:12 -0500 Received: from relay.sw.ru ([185.231.240.75]:49924 helo=relay3.sw.ru) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kkWuB-000101-47; Wed, 02 Dec 2020 13:31:12 -0500 Received: from [172.16.25.136] (helo=localhost.sw.ru) by relay3.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1kkWtu-00BTPZ-H0; Wed, 02 Dec 2020 21:30:50 +0300 To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, mreitz@redhat.com, stefanha@redhat.com, fam@euphon.net, armbru@redhat.com, jsnow@redhat.com, eblake@redhat.com, den@openvz.org, vsementsov@virtuozzo.com, andrey.shinkevich@virtuozzo.com Subject: [PATCH v13 08/10] copy-on-read: skip non-guest reads if no copy needed Date: Wed, 2 Dec 2020 21:30:59 +0300 Message-Id: <1606933861-297777-9-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1606933861-297777-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1606933861-297777-1-git-send-email-andrey.shinkevich@virtuozzo.com> Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay3.sw.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Andrey Shinkevich From: Andrey Shinkevich via Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If the flag BDRV_REQ_PREFETCH was set, skip idling read/write operations in COR-driver. It can be taken into account for the COR-algorithms optimization. That check is being made during the block stream job by the moment. Add the BDRV_REQ_PREFETCH flag to the supported_read_flags of the COR-filter. block: Modify the comment for the flag BDRV_REQ_PREFETCH as we are going to use it alone and pass it to the COR-filter driver for further processing. Signed-off-by: Andrey Shinkevich Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/copy-on-read.c | 14 ++++++++++---- include/block/block.h | 8 +++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 2cddc96..123d197 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -49,6 +49,8 @@ static int cor_open(BlockDriverState *bs, QDict *options,= int flags, return -EINVAL; } =20 + bs->supported_read_flags =3D BDRV_REQ_PREFETCH; + bs->supported_write_flags =3D BDRV_REQ_WRITE_UNCHANGED | (BDRV_REQ_FUA & bs->file->bs->supported_write_flags); =20 @@ -150,10 +152,14 @@ static int coroutine_fn cor_co_preadv_part(BlockDrive= rState *bs, } } =20 - ret =3D bdrv_co_preadv_part(bs->file, offset, n, qiov, qiov_offset, - local_flags); - if (ret < 0) { - return ret; + /* Skip if neither read nor write are needed */ + if ((local_flags & (BDRV_REQ_PREFETCH | BDRV_REQ_COPY_ON_READ)) != =3D + BDRV_REQ_PREFETCH) { + ret =3D bdrv_co_preadv_part(bs->file, offset, n, qiov, qiov_of= fset, + local_flags); + if (ret < 0) { + return ret; + } } =20 offset +=3D n; diff --git a/include/block/block.h b/include/block/block.h index 81a3894..3499554 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -81,9 +81,11 @@ typedef enum { 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 doesn't really need data to be - * written to qiov parameter which may be NULL. + * BDRV_REQ_PREFETCH makes sense only in the context of copy-on-read + * (i.e., together with the BDRV_REQ_COPY_ON_READ flag or when a COR + * filter is involved), in which case it signals that the COR operation + * need not read the data into memory (qiov) but only ensure they are + * copied to the top layer (i.e., that COR operation is done). */ BDRV_REQ_PREFETCH =3D 0x200, /* Mask of valid flags */ --=20 1.8.3.1