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=1606934108; cv=none; d=zohomail.com; s=zohoarc; b=CGOULnik+j6Z4Bw1jM2mCYWhjlWpbs3Hlgf7pvVgzkedAjhjN/w+2CokTMJPzzqSL3UnE8wDDgQ9eoO2lWxFU8/e6RWQ+pi5EJk4ORDUsiItJnBuJtHTszUR+8Z3MV16Bh9UbBSs+naB3lHC++OHHbtI1dAwv70JSIvHbP3AhIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606934108; 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=XeODPuFqNsrW8OzWcqOHDUi2UHlpUwpR3KODsH256Og=; b=RE0KP9dYNZZ0fUjqoTdnRuHesL0I2Kb3t4pMmBZRoX0psbAi85qWROUe1Z2UzAu9Z+dC/AWRq0lOAc0WaixZ7a/s44gjE6gdziyyK1AD3UavvRYOucBR0GmvrKt+oLjzkXscXFNeaUBBJMQWJlWPhgUHEqEBkcvp1LUNYWW2Ny8= 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 1606934108829159.307107328156; Wed, 2 Dec 2020 10:35:08 -0800 (PST) Received: from localhost ([::1]:51414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kkWy3-0006cr-ND for importer@patchew.org; Wed, 02 Dec 2020 13:35:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kkWuH-0001cp-Ff; Wed, 02 Dec 2020 13:31:13 -0500 Received: from relay.sw.ru ([185.231.240.75]:49928 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-000100-4g; Wed, 02 Dec 2020 13:31:13 -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-FQ; 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 07/10] block: include supported_read_flags into BDS structure Date: Wed, 2 Dec 2020 21:30:58 +0300 Message-Id: <1606933861-297777-8-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" Add the new member supported_read_flags to the BlockDriverState structure. It will control the flags set for copy-on-read operations. Make the block generic layer evaluate supported read flags before they go to a block driver. Suggested-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Andrey Shinkevich Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/io.c | 12 ++++++++++-- include/block/block_int.h | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index ec5e152..e28b11c 100644 --- a/block/io.c +++ b/block/io.c @@ -1405,6 +1405,9 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild= *child, if (flags & BDRV_REQ_COPY_ON_READ) { int64_t pnum; =20 + /* The flag BDRV_REQ_COPY_ON_READ has reached its addressee */ + flags &=3D ~BDRV_REQ_COPY_ON_READ; + ret =3D bdrv_is_allocated(bs, offset, bytes, &pnum); if (ret < 0) { goto out; @@ -1426,9 +1429,13 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChil= d *child, goto out; } =20 + if (flags & ~bs->supported_read_flags) { + abort(); + } + max_bytes =3D ROUND_UP(MAX(0, total_bytes - offset), align); if (bytes <=3D max_bytes && bytes <=3D max_transfer) { - ret =3D bdrv_driver_preadv(bs, offset, bytes, qiov, qiov_offset, 0= ); + ret =3D bdrv_driver_preadv(bs, offset, bytes, qiov, qiov_offset, f= lags); goto out; } =20 @@ -1441,7 +1448,8 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild= *child, =20 ret =3D bdrv_driver_preadv(bs, offset + bytes - bytes_remainin= g, num, qiov, - qiov_offset + bytes - bytes_remaining= , 0); + qiov_offset + bytes - bytes_remaining, + flags); max_bytes -=3D num; } else { num =3D bytes_remaining; diff --git a/include/block/block_int.h b/include/block/block_int.h index c05fa1e..247e166 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -873,6 +873,10 @@ struct BlockDriverState { /* I/O Limits */ BlockLimits bl; =20 + /* + * Flags honored during pread + */ + unsigned int supported_read_flags; /* Flags honored during pwrite (so far: BDRV_REQ_FUA, * BDRV_REQ_WRITE_UNCHANGED). * If a driver does not support BDRV_REQ_WRITE_UNCHANGED, those --=20 1.8.3.1