From nobody Sat May 4 04:00:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; arc=fail (Bad Signature); dmarc=pass(p=none dis=none) header.from=nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620201146270168.10958486558047; Wed, 5 May 2021 00:52:26 -0700 (PDT) Received: from localhost ([::1]:42040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leCKX-0006vn-7U for importer@patchew.org; Wed, 05 May 2021 03:52:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIi-0005Ee-ON; Wed, 05 May 2021 03:50:32 -0400 Received: from mail-eopbgr80109.outbound.protection.outlook.com ([40.107.8.109]:41697 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIg-0002WS-P5; Wed, 05 May 2021 03:50:32 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6839.eurprd08.prod.outlook.com (2603:10a6:20b:352::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.39; Wed, 5 May 2021 07:50:25 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4108.026; Wed, 5 May 2021 07:50:25 +0000 Received: from localhost.localdomain (185.215.60.236) by HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 07:50:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xq8SGBTcV7xsWY9QVoyrGtEHMTZT/GIUFokySJm6ZIAFHRzg0eFCL0Cvdd2IUuVd+qQqzhXGOCgR+qc4w9IMZ1WF4mZ0ifpbsf9I0VS+FBmP+mq+IvcikDxC2Pu9wR8PanxpRQ3Cq76r6r5fljtdrse9T7gbOGtJ2GAhxgAEhx1B9JTgHQlC+D9SmR+CVGytlg8NZBer5WilNGApsMBT9cXhBIfs1WqM5vN7ft89XjyvdDPIJqjV39GqI4vJXUG5UpMa6qHs+61uoJvOaE8oN9K+7vVe+kYZuDajZpt0pkZC0EiqATr+WiCH6aRbVwEzDmPh8pOG9xsf72sfc5ZcLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WiV61dGe1qTIVM/d0JADQuX/3yopVilba7wx0Z/kzUQ=; b=FiVIcz40wkgzi6Tv8jSNFROvHsuPDNxpx4W/g21wNvE3R8GMOqVRxKfEvcU6JQHdy9Ap6Vrdgj6yBd3tU7LJeU/7an4w70EUSn8+eyu7OQovsw/0Uch8aXRaRo2Nh4nHffxzDZSf4VhMsB3WAYKv5awnlY22iTUmXVbNTr5yGofIIRmObWAgortlFlLxK+P1Re+3ZxZtXLtbIQsSb6YxTFReOiFQltZAfe/o3DKtLdkwMCOQSYX2pzu+uIHemoq9oiIGhXqXDQvAvbA7Cj6wex7/4ocyl5I7tybOyn19MZzmRCLwy5N49Dbh6DAD7jDl1NhlFQL/MtKPdql4Ho2zrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WiV61dGe1qTIVM/d0JADQuX/3yopVilba7wx0Z/kzUQ=; b=USrtCKf8GXEKU5/AYeJw4Q9iNsH4Rqxwo8Vd3LlF+yk4A2SgJqdPmwTXjXT3Iuy5+HqhcYOF6xDHZSrE5Do2aHRMhhca/sClboS9j5LsmvLVXbultL+W8Qg3ZD+dcnAAWriu+iz5q78ruHUdjI2YJ1LxZU3zn2wJKXLpt9zx7mI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, stefanha@redhat.com, kwolf@redhat.com, mreitz@redhat.com, vsementsov@virtuozzo.com, Fam Zheng Subject: [PATCH v5 01/11] block/io: bring request check to bdrv_co_(read, write)v_vmstate Date: Wed, 5 May 2021 10:49:51 +0300 Message-Id: <20210505075001.45041-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210505075001.45041-1-vsementsov@virtuozzo.com> References: <20210505075001.45041-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.236] X-ClientProxiedBy: HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2137c435-9b26-4758-e260-08d90f9a7136 X-MS-TrafficTypeDiagnostic: AS8PR08MB6839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1728; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LEwXph3RahvCsLi+Cix0T8AVnHe4bLR0Vod54cvMaIlstyT78iQSA3OECybOIMJKfgQbU6sY7GrkqgopDze9VRFBeLyhrnMFawybW43sMf7GG0dsebqsK+5/vpfJo3omZZlhtE07CK/+TylQ9PswoEkqClSHbh5aqNT3HQ59elHZSboPeQWimuPoFdupaWtqLoDdNwVMoRetbGQgRY1UHhJYP5kUMoSF9VmOCDSHXPNyaZ1E/hHwqYaVWiKYR6gtGT3EKZXoaeGZVkqCozCF9h/PLmCff+uuhXBmAcf1+T37n8PNTj6a+VweGWKQZpA7blSZ8KSLZPE16vil4I9WoTynMweENzLy3nb+dWD1qUDJMBH7mSWqUUjnlPIec66Qxnh3ILRBc+WIrdsxgOC2zep1hbn987e1Vv953XYi2JUsdtCS2zi8iW8xBoKrDa6bVZ8LZXQSSFL7zJaz8zWeuSku47w2QYOMM05Etiqca+9CTtOQARqyoNw/LTi2XmirUH2xhKZETBaIhdChqCdDQl0MyOP5XkakhNM9iPUM4Fj8+uv1eRagCO0OUjEua3lKsA3gYMuMqv2PWvHR5BJvPI5Vk6vWsxVfy6DWdMIyV39wUAbai+dbuoZ/7sviRRlkmnaNBhhp4TQJy2Lw8v37jvEiQE8RY2t8WhwhIfmp/Pmz8TWCcx5Z/T96B27WWsJ3 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(376002)(346002)(396003)(366004)(136003)(38350700002)(38100700002)(66946007)(26005)(66556008)(6506007)(66476007)(86362001)(16526019)(83380400001)(6666004)(6916009)(4326008)(36756003)(478600001)(316002)(8676002)(6512007)(2616005)(2906002)(186003)(52116002)(956004)(6486002)(8936002)(5660300002)(1076003)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?zMr/e3CpqyYShjl4pTrrO5HX1w3kpMQ2oxKJVKtyqioTZGNiD1p9k9A4b3nN?= =?us-ascii?Q?LSZWBLomKPmQrb1RP1fcy/28fc12jc9chWX//CNWfy+9iAl+u7V2b8zSDVVm?= =?us-ascii?Q?ceYcK4zWdey0u4rgI0biN6RXYFPnW50E3Zvt4V5ndMJuWCMm30ejiSODw6GW?= =?us-ascii?Q?TNndSWWd2JLe1S0YI7cP0J2j9QLwV0TXKdNYSRVGGIHtvfot29yrlLYtGa2s?= =?us-ascii?Q?/YwCIzsW/FNMdbA/KR50QZ07n1ktxd/VBfu2cHcXHPZRLR6nU6Z7iGZNIhWo?= =?us-ascii?Q?5O7k8uRWlPkwhR7LXUUOOKX1OaVgcoWLeZtNOV07FZleeheVC7Ic5SDWKDDP?= =?us-ascii?Q?rArtyAsp1XE44qE9lgHS2inrurfHVYbdXUmeKHi8Z2OUQFL5QkDer/l9EkWy?= =?us-ascii?Q?OSbv2PwO+LDVWwW3Z/pnPXNzp6ycKcTkr3GKW7KA6VwdPf+wDHsXayadaePA?= =?us-ascii?Q?HAaw8jHHSKNrtqCJHJwhLEOaSktuXu6Te303mrJByK7HuEzb1J/gEnQ9eD97?= =?us-ascii?Q?BUMwwY9OvuNCvck33aDAnNhyjdipaUrihpTv3rsBkOVe8Z+sVrqsJwHy1eAj?= =?us-ascii?Q?vn9gmXZCFmnRhi5ev/xiHmn2wfv2Xpk5nV2RrxT5+ezGYu1f6ZaLmv1C72Ru?= =?us-ascii?Q?78JgsbBLAoTEYW67mqznvzzVzn2vLfp0J35NmSmBTUzbAJKwTuOe06oSfr5O?= =?us-ascii?Q?2KkvwLCe9FEuf95wbH733hZzcqVq1rUDaaL34P0uZYOp3HeVXd+l9QwQpfKH?= =?us-ascii?Q?PLMol6YjefeZu9/xCDWuamxqRaFbgkvYg/tG+mh5bjhec1D0XrdvZUBmWWjJ?= =?us-ascii?Q?t5eofHZNX58TsoXASAlI91VkcgosBlM7QUF7Qa+9ExPwbM4mNlBvgcR4ssNx?= =?us-ascii?Q?MVcurD0VjwlCB35ottdEyJEk4vEDzNIoAApcibViVtP3x7/3aCY14LjlN0NN?= =?us-ascii?Q?ThBzH42pIblyi+gqtIHUP8eQYn7E3G+4WfMRrUjLgkpV7KyjqU9zKpw5X2Um?= =?us-ascii?Q?Q5nJI6xYUqxpjlFyCNRlykveQYPwdeYSfA0RY3QN+dmwnt8HJlx2msqnGR+I?= =?us-ascii?Q?Gi45pa2Nqotc/nDHPYdDVoVVzsVizGVSuD7y/Av8LxFzWLOPJ4Pq6ooOnG9W?= =?us-ascii?Q?U3ttUlm8oxmU3BecWKW1QO42fTTP5Ygxz8IrBxQ57MPYycehrV3L5x6WeYOT?= =?us-ascii?Q?JkbmjQJj8/XyLkoHL7cd2IJYAeE99uNC1qXjsEoGtGx2jx0UIQlBuWz4l6oM?= =?us-ascii?Q?ITGGJHlJAC2R1EP4AafPq9qYTUFL+GE0De2E+IZeIwXTRL/QYfpPSYXPApA2?= =?us-ascii?Q?2Nc2lS5z/eVkoeusj88/2XrK?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2137c435-9b26-4758-e260-08d90f9a7136 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 07:50:24.9782 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lD4D1LbQigWrbSFSs0j4Geg9urM3bcSdVqXIQeLzJrTqTYLywcGttqLopvDq4xYpggPasoyYaCag45ZoKchfv+A1VlwsE1OHaGtxmN3/ckw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6839 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=40.107.8.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: Vladimir Sementsov-Ogievskiy From: Vladimir Sementsov-Ogievskiy via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" There are only two drivers supporting vmstate: qcow2 and sheepdog. Sheepdog is deprecated. In qcow2 these requests go through .bdrv_co_p{read,write}v_part handlers. So, let's do our basic check for the request on vmstate generic handlers. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/io.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index 35b6c56efc..3eb6a38008 100644 --- a/block/io.c +++ b/block/io.c @@ -2745,7 +2745,12 @@ bdrv_co_readv_vmstate(BlockDriverState *bs, QEMUIOVe= ctor *qiov, int64_t pos) { BlockDriver *drv =3D bs->drv; BlockDriverState *child_bs =3D bdrv_primary_bs(bs); - int ret =3D -ENOTSUP; + int ret; + + ret =3D bdrv_check_qiov_request(pos, qiov->size, qiov, 0, NULL); + if (ret < 0) { + return ret; + } =20 if (!drv) { return -ENOMEDIUM; @@ -2757,6 +2762,8 @@ bdrv_co_readv_vmstate(BlockDriverState *bs, QEMUIOVec= tor *qiov, int64_t pos) ret =3D drv->bdrv_load_vmstate(bs, qiov, pos); } else if (child_bs) { ret =3D bdrv_co_readv_vmstate(child_bs, qiov, pos); + } else { + ret =3D -ENOTSUP; } =20 bdrv_dec_in_flight(bs); @@ -2769,7 +2776,12 @@ bdrv_co_writev_vmstate(BlockDriverState *bs, QEMUIOV= ector *qiov, int64_t pos) { BlockDriver *drv =3D bs->drv; BlockDriverState *child_bs =3D bdrv_primary_bs(bs); - int ret =3D -ENOTSUP; + int ret; + + ret =3D bdrv_check_qiov_request(pos, qiov->size, qiov, 0, NULL); + if (ret < 0) { + return ret; + } =20 if (!drv) { return -ENOMEDIUM; @@ -2781,6 +2793,8 @@ bdrv_co_writev_vmstate(BlockDriverState *bs, QEMUIOVe= ctor *qiov, int64_t pos) ret =3D drv->bdrv_save_vmstate(bs, qiov, pos); } else if (child_bs) { ret =3D bdrv_co_writev_vmstate(child_bs, qiov, pos); + } else { + ret =3D -ENOTSUP; } =20 bdrv_dec_in_flight(bs); --=20 2.29.2 From nobody Sat May 4 04:00:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1620201269; cv=pass; d=zohomail.com; s=zohoarc; b=HelDc28mlgjaaoTUyUTTO1d3j+cd2b6gHYRP6qhSkGGtRIVJmCvtmgZIE6P0iIoTWMXHY3onQn5SzrtV9ymFhv4HIdRWPJbxHsyqQ3azEd8TcNlJ1/WAAuLeh5YwrkbLQLKvWv+FTtMg6pDUz0uwfQFsssGINbA3tHxLL887jtg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201269; h=Content-Type: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; bh=n4QtYr0EV0xTidykAWV/aMtQUFF43vNDdRWOi/3mZmQ=; b=ClnlL5P5tzRjYu7HhdtywXPjgDrN4uqon2AjM60HMJjJD2IL/0lJGL8KPQ+GCeIC1c+FTqHBOfXv2QAZABSND9vDVxLEG8xtHZbYA1TlMiZe9ZteT4O79o/gpj5TrW5y+r4Nm++b52O6p3/8heCEHkve4+XHPeI+1lYp8fkuhW8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine 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 1620201269337324.74907520582894; Wed, 5 May 2021 00:54:29 -0700 (PDT) Received: from localhost ([::1]:50900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leCMV-00028z-5m for importer@patchew.org; Wed, 05 May 2021 03:54:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIl-0005Jl-C9; Wed, 05 May 2021 03:50:35 -0400 Received: from mail-eopbgr80109.outbound.protection.outlook.com ([40.107.8.109]:41697 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIj-0002WS-FD; Wed, 05 May 2021 03:50:35 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6839.eurprd08.prod.outlook.com (2603:10a6:20b:352::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.39; Wed, 5 May 2021 07:50:26 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4108.026; Wed, 5 May 2021 07:50:26 +0000 Received: from localhost.localdomain (185.215.60.236) by HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 07:50:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QYecoxRiFA/U2sG9Y52+pnvlC5zAhY07FGtawaTAdnFTLqQfXKrVYHIeN+HdsOAG/zIkgD6BOOgtLZ6gbtGx+KapWofOpDmv4Ol/G2aHcwQKgJjKIUvvo/mt9Zs6Qr5u4De36mb+2BAEDzAv2EELQmzHDV6SewQyQgL7D8Cz10uxPZvu5STuS8x77ed8tnWqvIgQlc6Qde5UKczUhVDB9/9/7FHROL4j9HVPfc1xPbFXLzLjLXamXGLtlJvY5m5LbOLux7xfP1u0R+q8/IA0j3U+8qQetDrqgSH3BiEUSnidcw1mKcAVDhYKEs+wbWGr2Io7i/DbyHltHwJqZAFeDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n4QtYr0EV0xTidykAWV/aMtQUFF43vNDdRWOi/3mZmQ=; b=i+2BV7OQ+CvyPS5Moy+2/gA5ujGmRl+0rSSomdt4VBucrPI3JPy0UIYo6nkKW4dslQ4d/G8FqQHckg23e6f4Rw9EKrHgNZLzK0XDnYgAA/2XMhBtLhyiikiuwhl6uR8bJp2x1O0khoTvBHwO7onTzsnI9TyAquvFYMIugbtdwUVezbIy39SNbLJ1FLkxR+zz6ysZMxSXqTk7xiYOZC+zNqHCXcSTq1TvK2BkDNAcGZ4M8a5w1G9wCRdCFv5MjHgWrWl0R/hAwU7SqJuJTETDxwprOi2OqEWX4x+JYYqiaUpF3HhNlbNUKDlIRmd5FgJuPm7kUmu6L3Qc94nbx8ZDzg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n4QtYr0EV0xTidykAWV/aMtQUFF43vNDdRWOi/3mZmQ=; b=ITkh4ypG6fLrpWzVDIhbuKXchZ8ZfgQHNV0HoP7QR3Bfg8wTuGXnIza5ftQhXCSBovNOi+L0SMvg41NzY/ocrAhdime185MpEUYZSV8zZicWs/iPIM5EB2jSWM0MRCGjt3ZGozcft3MwdLxRH+jTeJbXI4uA+oqQkHcHMTDVnXI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, stefanha@redhat.com, kwolf@redhat.com, mreitz@redhat.com, vsementsov@virtuozzo.com, Fam Zheng Subject: [PATCH v5 02/11] qcow2: check request on vmstate save/load path Date: Wed, 5 May 2021 10:49:52 +0300 Message-Id: <20210505075001.45041-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210505075001.45041-1-vsementsov@virtuozzo.com> References: <20210505075001.45041-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.236] X-ClientProxiedBy: HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 35567e8a-de93-4432-546a-08d90f9a71f4 X-MS-TrafficTypeDiagnostic: AS8PR08MB6839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:519; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f4dKjJIvb5evrkir4EY32dIGIKC8yLXTkNddiyapOm63sNoY1tLXneoJqZQNCikiZUqXIpSUlbwx2FPVgXYZksPjrURgCmqNe22OcilSEXL4AmGc9YLVvkR/w+NZYnc1xihOB3Mqg+FbeXV/EdimWaTeZoXvccmjyQtvm/q3Y8ROJI2eaPV5lFduQnO0fYMJoo8YKb5zartXHrrp1hvAkgkCPA2tmcFS0mXcpjPsSg80QROaDBJY3142mk4FBv8A0qN6W9vcu+pHlUHab6dRIZWS9s0F06CvANCk9Et7ZJ3RZKq/3HSnSMxGLxWv37OFmyZd7HuY48R7gGoRLWrcK1KrgAsDynKFB0oW6arDH0cH9gVpVSYLvL/vrc4u+ppVzFKAblwUDtaEQ0+f0UDlFNvQxnwK0ymCIPI2PpMX8aGe69E+6ZMjkWTgLa8vhAubPPgjE5X0LzRQ9/h6zCERx1xg8nSDLiC5gFlbGJzSeig0xafhZSarTdhRK7xX1O1G8IvpRSsU0zRV2CMpoQLBIiBmu95iYBMJwlSW0VZ4YWtJ903FtfUlKlr42yXaSOEvOlACKALrI8vW/JWB7C9WWGrRG1set5nEvRp8Mu7NkBnDMGggxbKQRjEmbeBDr+wlxZMMW5GjyTgjTCuFy+oxz2VG6KFAjJRKB2yIX8DXfRPuUpjFskFZ1Yoy1Podd7W3 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(376002)(346002)(396003)(366004)(136003)(38350700002)(38100700002)(66946007)(26005)(66556008)(6506007)(66476007)(86362001)(16526019)(83380400001)(6666004)(6916009)(4326008)(36756003)(478600001)(316002)(8676002)(6512007)(2616005)(2906002)(186003)(52116002)(956004)(6486002)(8936002)(5660300002)(1076003)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?8BahzO9qUB3Ua4IGl4jfol9QFB2mQg8FKGedmWq7CLWXGdSqYjM70O6FA8D3?= =?us-ascii?Q?a0P4r9BOaoNjhGC8dJ5ueKaHV2iXL2WzHjhKZG4Vp1J34TAR6vAitITuu8H4?= =?us-ascii?Q?GbmiaVi+R1Ci+V6ZXwKm7BF/W1kwcF8wCKzp3kDSSua5YVPf78xOW7C2VmrG?= =?us-ascii?Q?wTYDwaot7HItqrY6wnJgP4yQMUvVvsGywWXwohUwghGF3Xzwzrc2J1vhn0kn?= =?us-ascii?Q?o2Pc5BtgsUY8cKoqvnmNoyT1ImtaFFDFgNcDVQQIF4fSJVNE4uN1PP9k2Qz+?= =?us-ascii?Q?unzgtQQT+rdnU7ZTy3w/qveJhqVYfAuKIZ6C/8T0sjfA0OTXMQG6WnMseR3L?= =?us-ascii?Q?RCiPGtDQxnviv4EUfP6UPm61i9D4BM2F5oYebn/gcccBVil5wEaVSTXgbFuN?= =?us-ascii?Q?IYAR60BwzuPOWnjMLvObebwGcKHn9jTBx2YygATfFFL90a6tKDRsmnvKWbJ9?= =?us-ascii?Q?7fLJGYyh4jZLwOBYos/QPKTXMGYKIzQCWhrUQvENPUsAAk83FtoPFNTFkSZF?= =?us-ascii?Q?+O2P5Vv1zJQ3l46/gweMoVcv8LW39O6lU0pvwS0ae1DYGQm4lYo5YnRyOwzi?= =?us-ascii?Q?SWlK16aLT17fZXDdiTpnIqfpH0xMXhx83I8qGU2lptDkrOe29W/Z82CPFY93?= =?us-ascii?Q?ydciIUHso9a3XBbB2hPsrr01k0lk5PQGU1reJgrb8/K9Nyeu846ajLAGCfbP?= =?us-ascii?Q?pJfxy4RRdiCfm4AFGrd3bSOIPCceHwiC/lsU6e7dz7QiRrctHEqRN1SrMXd5?= =?us-ascii?Q?kRyOpRt74JwBzmYEIcbSA/pXskyPM8o6a+t7IXn2YpeAySmlx9xvn8aJtOtx?= =?us-ascii?Q?qubiqnOchHw68GpbTo/3IX9QH+9S+wXb+jEnnTktOGdlrJBNoULQPHNzVltN?= =?us-ascii?Q?Ocu9dveSHBSislUwe9gtnB83jpkQetzVgmV/Z85C6yO8M+xdcu8tGjflxCOF?= =?us-ascii?Q?b+VsSz2lXfGZhpG4AznGUVK4oHIyWtKN5QmkbDJsCEfrD4CKouOK5BoK5vTC?= =?us-ascii?Q?1/2HQbfPOudulKJhdGzfAPLCdEgftxs8RlTx0GPl4Fox4o6DZCKWEGT2J0Xh?= =?us-ascii?Q?FtP3aEYAqgVgDoTGO+HdBRR0Ks4a2CUFAwEkn9Zu7PdawAEVtnkiQBvgYmc+?= =?us-ascii?Q?1PuuIGbVGrJk7oEnbWZfUVA84C3VYUkVUhEzLtMNbVi/u7ePqAxx/FlhXI/P?= =?us-ascii?Q?/m3a+MkWEwst7FuXkvEW/2bHrhBK7mveQ07T1+qc2nlvHkq2+frmbHqbZr6k?= =?us-ascii?Q?qM5s9z26Ovz4nWm8m9TucrSFs0Gh7CgxAoY2QyYS6eO8gaqmpdDHKGLYWs5P?= =?us-ascii?Q?f//u/pHnhQf7RrBmdpypAd+n?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35567e8a-de93-4432-546a-08d90f9a71f4 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 07:50:26.2815 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ab1Z27HkZdp9G9GcZfbWVj1Y7RJQQqj/VdIaDgvC03PQr+ByNVXCzQBbBXhiLWVRX5G6DsZmatkRv0OTIcQ+4w+P09OC11Oh+JDpWIEqpV0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6839 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=40.107.8.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We modify the request by adding an offset to vmstate. Let's check the modified request. It will help us to safely move .bdrv_co_preadv_part and .bdrv_co_pwritev_part to int64_t type of offset and bytes. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 3 +++ block/io.c | 6 +++--- block/qcow2.c | 43 +++++++++++++++++++++++++++++++++------ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index c823f5b1b3..d2143eb40f 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -93,6 +93,9 @@ typedef struct BdrvTrackedRequest { struct BdrvTrackedRequest *waiting_for; } BdrvTrackedRequest; =20 +int bdrv_check_qiov_request(int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, + Error **errp); int bdrv_check_request(int64_t offset, int64_t bytes, Error **errp); =20 struct BlockDriver { diff --git a/block/io.c b/block/io.c index 3eb6a38008..932a26f0bb 100644 --- a/block/io.c +++ b/block/io.c @@ -951,9 +951,9 @@ bool coroutine_fn bdrv_make_request_serialising(BdrvTra= ckedRequest *req, return waited; } =20 -static int bdrv_check_qiov_request(int64_t offset, int64_t bytes, - QEMUIOVector *qiov, size_t qiov_offset, - Error **errp) +int bdrv_check_qiov_request(int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, + Error **errp) { /* * Check generic offset/bytes correctness diff --git a/block/qcow2.c b/block/qcow2.c index 9727ae8fe3..227885620d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5201,24 +5201,55 @@ static int qcow2_has_zero_init(BlockDriverState *bs) } } =20 +/* + * Check the request to vmstate. On success return + * qcow2_vm_state_offset(bs) + @pos + */ +static int64_t qcow2_check_vmstate_request(BlockDriverState *bs, + QEMUIOVector *qiov, int64_t pos) +{ + BDRVQcow2State *s =3D bs->opaque; + int64_t vmstate_offset =3D qcow2_vm_state_offset(s); + int ret; + + /* Incoming requests must be OK */ + bdrv_check_qiov_request(pos, qiov->size, qiov, 0, &error_abort); + + if (INT64_MAX - pos < vmstate_offset) { + return -EIO; + } + + pos +=3D vmstate_offset; + ret =3D bdrv_check_qiov_request(pos, qiov->size, qiov, 0, NULL); + if (ret < 0) { + return ret; + } + + return pos; +} + static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { - BDRVQcow2State *s =3D bs->opaque; + int64_t offset =3D qcow2_check_vmstate_request(bs, qiov, pos); + if (offset < 0) { + return offset; + } =20 BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE); - return bs->drv->bdrv_co_pwritev_part(bs, qcow2_vm_state_offset(s) + po= s, - qiov->size, qiov, 0, 0); + return bs->drv->bdrv_co_pwritev_part(bs, offset, qiov->size, qiov, 0, = 0); } =20 static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { - BDRVQcow2State *s =3D bs->opaque; + int64_t offset =3D qcow2_check_vmstate_request(bs, qiov, pos); + if (offset < 0) { + return offset; + } =20 BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD); - return bs->drv->bdrv_co_preadv_part(bs, qcow2_vm_state_offset(s) + pos, - qiov->size, qiov, 0, 0); + return bs->drv->bdrv_co_preadv_part(bs, offset, qiov->size, qiov, 0, 0= ); } =20 /* --=20 2.29.2 From nobody Sat May 4 04:00:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1620201270; cv=pass; d=zohomail.com; s=zohoarc; b=SUddAG3kzXUX1eeMWV7WZC+ceKu+IzjAEhIbp3oJzzoj8wT2olJKQRPRcw45yW8gtVd8G0xua6Q+vnmiVAAvmTxPUu2JccjCEs46taLN1yXRml0raRKwozXeKGOtg7wG8PTJNmU8coNI5oZSIiYJCCDFmbaTutWFP02f1jIeP28= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201270; h=Content-Type: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; bh=u7NdcYo4w6lLSC50j+iITY1+6MTyPOjkBp7L6iCU4yQ=; b=apIiJbvhJ69NXGSLTSy2jXw3aier66RyQsHES88kt31FKjCvVGCsANBcJxce+jj5UemwyHO+9amqEnaNVNxE2zxUoLD9wXXgbf7ZqNHYdPtteWPPO+RNJyb87VEE66pnENdv77rV4lSrsWprPUrMcGgE3YgdafRq9b1PElHQAoc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine 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 1620201270349962.7137721421683; Wed, 5 May 2021 00:54:30 -0700 (PDT) Received: from localhost ([::1]:50950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leCMX-0002AC-7a for importer@patchew.org; Wed, 05 May 2021 03:54:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIp-0005Vr-OU; Wed, 05 May 2021 03:50:39 -0400 Received: from mail-eopbgr80109.outbound.protection.outlook.com ([40.107.8.109]:41697 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIm-0002WS-1f; Wed, 05 May 2021 03:50:39 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6839.eurprd08.prod.outlook.com (2603:10a6:20b:352::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.39; Wed, 5 May 2021 07:50:28 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4108.026; Wed, 5 May 2021 07:50:28 +0000 Received: from localhost.localdomain (185.215.60.236) by HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 07:50:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BN7Q5NW055nlU6iyelPxJROkd4+bVOT+ex8fF324/2NlYCBkQ+IoOfPqM32HLLVZdeY25yhEqoPkhIpMDhsbjJdXi6Hw3VnpZ8VfxvlY5mQkqt3QrGrmqEuQ8jB6R0irEa+4yEaCCfu5BzzFaY3NsfRo2POWlwG/iDy/rAf2JHHba0TWNYDiMhAsQMzIoOufaEcEq60u96cHRpC6CGCFZWVlW04x/0HW2kxytX6JdHkJ5w3tYTndv9vKratSa8sg3nN6ipefITYI0c0+Wv81eYrNGLReqsP6j9hSOoqtNUb9DsqfkIE3v9Fnhkgwj6GoV6eR3cpesqX9ele77+Uo2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u7NdcYo4w6lLSC50j+iITY1+6MTyPOjkBp7L6iCU4yQ=; b=BeofKYeXxZkHkCmtbmnSEktCY7qNBx21G7SClmuapKvOR6363YBjDr796Ee9QEotUqbQBRzd5CEgvSvCZS0WhtDuBRMBpakxWcAVV6w6NyzbmlA+Ftn8ksBtshSUDIK2GKnX1cW4q30F3dOypj5r7zpqtAu3yw9usbhXrliqQd/HrvcHTg2A5LyID2vh7otOY3Nuq4mHy9ytVNFKrPrNAf7/NiSPT/aCBFvGACmOrv1bRskQh6V9slxaH1l1DIWld9R7F2F4ZK3vDKoI0qy+tLwxTztKbUpsCXDDbyC8QgOAxEzWik8bBU+/CjjyJyG9dsqVveAr6e0cLI14KyTo2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u7NdcYo4w6lLSC50j+iITY1+6MTyPOjkBp7L6iCU4yQ=; b=t6kVxKoQp5EL8k9Zi8zMqQSOMa2QjNKVOSla8dTdSllf3Sg63SaJgQvpP8qEq080p+FKoY7/KgqnPBkJsrS6g7FQMessYKAaPwpfHvcmZjJANwutdgNNTJaieB8Ylu+qsSYgMvORs8FO58ycpP/p6xRO7A3wdB+w54EmfFmmnLs= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, stefanha@redhat.com, kwolf@redhat.com, mreitz@redhat.com, vsementsov@virtuozzo.com, John Snow , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , Stefan Weil , Peter Lieven , Fam Zheng , Alberto Garcia , Jason Dillaman Subject: [PATCH v5 03/11] block: use int64_t instead of uint64_t in driver read handlers Date: Wed, 5 May 2021 10:49:53 +0300 Message-Id: <20210505075001.45041-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210505075001.45041-1-vsementsov@virtuozzo.com> References: <20210505075001.45041-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.236] X-ClientProxiedBy: HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3cefccf7-451c-4f28-1635-08d90f9a733d X-MS-TrafficTypeDiagnostic: AS8PR08MB6839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:390; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EjQdBvDDBhYl1QX/PqsRuLvk//1JnqC4vqCHCP3gGs1th77ij1HAgNXdSR+crPDS7XcQdEdmkYH+d99gFMnn6xxwp1gmw1k6l4mJnBD2le5faxhmPkVmTKCnYCGCgXdoEd5MIrkDUdo16BLAVHIHFiCFoBF+puyGTjzm2xKwRhT5ulw1gKQH1Jh7aQrprrwpyOAwevc4JEWXfNytNm2ByT6I7GVTybdbzAPmlR74M0TFhBB/T8JuCEt7NTaB9PGKt2Xt8yoCPp8S30hfG2IVVfwrjHZVKrNaS9T00N8Uk0/2fcd1/JrKcL+MHy4E10mMshta2ViA9O8r5wCkLfUXMzLeNoKHk4ubujRi/NBk4LcENzEoo+VLSEFLp16fqRHrxRmQOPOVYpvCx2IgQ6jE0NHKhXijDpQ5KHMee7rqpKRIV4g2DNh6H4cq0uOt5jN+ujvYR3tUwLfxt79GSemo6tJGHTJlVPBqBccNaqulTzs3/jrwQFvFxPjttAikPBDENm3NMPiLGji7MMxofo5uxKu4gHv0emtCPiHDCwMyNrAQbi1OLl8GqyIYv+5ZPICo448gAsHOAWHheRyukK+TB7jBaPUGy4Rg7pTBNmFdPEVRf9OaEG1zZB/+CNV1MO0Vhr24MtHt7hHnzKvGP7lv0wkdYQLi9TD1+vaOC6GenC+f8a1G84gNVY9z/9HYDDRu X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(376002)(346002)(396003)(366004)(136003)(38350700002)(38100700002)(66946007)(26005)(66556008)(6506007)(66476007)(86362001)(16526019)(30864003)(83380400001)(6666004)(7416002)(54906003)(6916009)(4326008)(36756003)(478600001)(316002)(8676002)(6512007)(2616005)(2906002)(186003)(52116002)(956004)(6486002)(8936002)(5660300002)(1076003)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?LbL1MLJpKiwfOoO6suCqWOkRVKMeEIPEe8D07Gf0d/Y5LO0tUoUXH8X28dZD?= =?us-ascii?Q?mSR06T0XjQf69DlJayu83+C+YTm7OMXu05sI0sb4jxB6BbbIZtop0J6hoPP4?= =?us-ascii?Q?NL+zQTT53UR6VN7H6evcuRFk9WRE8vw44gpugkBM6avN9bJZSdLSMqMenOsF?= =?us-ascii?Q?jRL7af7HwoGCefGnsUO5WyavbhkYmxJ3tgpY3kTwCBmn5sDOhvGcwEUpat9F?= =?us-ascii?Q?RE9mvxy4Y4Inn3pqLgR3bRc0Hr9nxv4zo9zFpKjdwjoA22xdxvSzjMiuY/WS?= =?us-ascii?Q?hjfT99bub+6D39yH9puU0gWY8KMwEEynZU+ereWkwyR4YKeBJWeuduHtx9hY?= =?us-ascii?Q?FdL3AmyC24oVGOJJfY6bIcfLsM3ss+6A1n7fsqv83BW5m7nEiUqjBfBbiceG?= =?us-ascii?Q?mdD50/G/X6Y7O0WNAMyNtwDTQCSroI3PGQBWWpGpZjbxtvxzvDZr96Vt1wKH?= =?us-ascii?Q?EFBaOphgdab8UrvTH5XpNxOO2cwhTYhxEZwAS61CUKmlymMEhM5/BvBwmC5f?= =?us-ascii?Q?1LPc8xcDzTUwGgthcRK+CO1NgqsZ+5711sWTuGxVFoK0uQ7af4Z1ZT7lvjXW?= =?us-ascii?Q?OV5V9Tf+oaP0yI63D5uNv7dPZ8HP+TA8j+rnBtMqjigReGEHhSIGfl+ZwLWW?= =?us-ascii?Q?+R417vBlrYfLbZY63MOLlm8miKqFkF1+JACdKndGZT9fnGwPmVKPhn6gzJRk?= =?us-ascii?Q?b0mm23SdrqWQJeoxVDxLe3jesFMm5lHsODtY/sXByixjL/AJCpsM6Gx9/NJK?= =?us-ascii?Q?PQ2FogWW2pzAWQDD7PQpU6ehw3JfbLfPiTA4lWNBJDN7/FRlSRGNLfr9hL2M?= =?us-ascii?Q?+NOH5HR7vXGdfAKi0dlNA7Th8gGUJs+adx5kCGfymreK02Fx1lKNNB6t57Dn?= =?us-ascii?Q?YCS1cQKozXCZBNEWJezEyllhEIdH8vQ+je6cAkdggfBFpF00MiwJg3cAF7Ac?= =?us-ascii?Q?3vZ2K1o3xEMb3BgYDEZKEehS4Kas+M9OuB78Wq89EfQLhglqBuPIadw4AZoX?= =?us-ascii?Q?7aoaTTe7oUJHGL6NRBpNXnD6mcMw0rJBdTDSkT1JbIWPyaBNDr1DqP/SFdgg?= =?us-ascii?Q?Kmlx+lsLsxkv/fdqWfxKFqF4i7INNQIyRxRJLZj0+BvXmw0HIO+MuQPUeMVy?= =?us-ascii?Q?WvUuc+2x6CGZqMhPuuCpvRM+wnRUoYe80+FnX7scPohxs4uspjrgaYnDetj2?= =?us-ascii?Q?kJtp4A9qr7QlZ52jElz/Kkz+VKUCBZ+pvdMRI+BFHhJvghx9NJAwivZKaiz/?= =?us-ascii?Q?Iz1AbKlD8BfhyJz8s4ovxtTC9gUFIYCuBNfF5WdPAgtol0m0QYCTZmIidvAq?= =?us-ascii?Q?5ZWSEcnTherMdKoNPcxOtzBv?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3cefccf7-451c-4f28-1635-08d90f9a733d X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 07:50:28.4539 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kJ7iP9qmDL9Pd9Xy3aqGWKJvNak6s737wkYV+iHk0FB1aRQBBkS1BrLCx9i1vKNiGSwTy7t9JokR4BUuENlQoSfn9x304c2RYJ4oE/oWBnc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6839 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=40.107.8.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are going to convert .bdrv_co_preadv_part and .bdrv_co_pwritev_part to int64_t type for offset and bytes parameters (as it's already done for generic block/io.c layer). In qcow2 .bdrv_co_preadv_part is used in some places, so let's add corresponding checks and assertions. Signed-off-by: Vladimir Sementsov-Ogievskiy block: use int64_t instead of uint64_t in driver read handlers We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, convert driver read handlers parameters which are already 64bit to signed type. While being here, convert also flags parameter to be BdrvRequestFlags. Now let's consider all callers. Simple git grep '\->bdrv_\(aio\|co\)_preadv\(_part\)\?' shows that's there three callers of driver function: bdrv_driver_preadv() in block/io.c, passes int64_t, checked by bdrv_check_qiov_request() to be non-negative. qcow2_load_vmstate() does bdrv_check_qiov_request(). do_perform_cow_read() has uint64_t argument. And a lot of things in qcow2 driver are uint64_t, so converting it is big job. But we must not work with requests that doesn't satisfy bdrv_check_qiov_request(), so let's just assert it here. Still, the functions may be called directly, not only by drv->... Let's check: git grep '\.bdrv_\(aio\|co\)_preadv\(_part\)\?\s*=3D' | \ awk '{print $4}' | sed 's/,//' | sed 's/&//' | sort | uniq | \ while read func; do git grep "$func(" | \ grep -v "$func(BlockDriverState"; done The only one such caller: QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, &data, 1); ... ret =3D bdrv_replace_test_co_preadv(bs, 0, 1, &qiov, 0); in tesTS/unit/test-bdrv-drain.c, and it's OK obviously. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 11 ++++++----- block/backup-top.c | 4 ++-- block/blkdebug.c | 4 ++-- block/blklogwrites.c | 4 ++-- block/blkreplay.c | 2 +- block/blkverify.c | 4 ++-- block/bochs.c | 4 ++-- block/cloop.c | 4 ++-- block/commit.c | 2 +- block/copy-on-read.c | 4 ++-- block/crypto.c | 4 ++-- block/curl.c | 3 ++- block/dmg.c | 4 ++-- block/file-posix.c | 6 +++--- block/file-win32.c | 4 ++-- block/filter-compress.c | 4 ++-- block/mirror.c | 2 +- block/nbd.c | 5 +++-- block/nfs.c | 6 +++--- block/null.c | 9 +++++---- block/nvme.c | 5 +++-- block/preallocate.c | 4 ++-- block/qcow.c | 6 +++--- block/qcow2-cluster.c | 14 +++++++++++++- block/qcow2.c | 5 +++-- block/quorum.c | 4 ++-- block/raw-format.c | 20 ++++++++++---------- block/rbd.c | 5 +++-- block/throttle.c | 5 +++-- block/vdi.c | 4 ++-- block/vmdk.c | 4 ++-- block/vpc.c | 4 ++-- block/vvfat.c | 4 ++-- tests/unit/test-bdrv-drain.c | 16 +++++++++------- tests/unit/test-block-iothread.c | 19 ++++++++++++++----- 35 files changed, 120 insertions(+), 89 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index d2143eb40f..dc08f99e95 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -234,8 +234,8 @@ struct BlockDriver { =20 /* aio */ BlockAIOCB *(*bdrv_aio_preadv)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags, - BlockCompletionFunc *cb, void *opaque); + int64_t offset, int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque); BlockAIOCB *(*bdrv_aio_pwritev)(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags, BlockCompletionFunc *cb, void *opaque); @@ -264,10 +264,11 @@ struct BlockDriver { * The buffer in @qiov may point directly to guest memory. */ int coroutine_fn (*bdrv_co_preadv)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags); + int64_t offset, int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags); int coroutine_fn (*bdrv_co_preadv_part)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, size_t qiov_offset, int flags); + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); int coroutine_fn (*bdrv_co_writev)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int flags); /** diff --git a/block/backup-top.c b/block/backup-top.c index 425e3778be..fb32ac7b2b 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -41,8 +41,8 @@ typedef struct BDRVBackupTopState { } BDRVBackupTopState; =20 static coroutine_fn int backup_top_co_preadv( - BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { return bdrv_co_preadv(bs->backing, offset, bytes, qiov, flags); } diff --git a/block/blkdebug.c b/block/blkdebug.c index 2c0b9b0ee8..b26fecf222 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -614,8 +614,8 @@ static int rule_check(BlockDriverState *bs, uint64_t of= fset, uint64_t bytes, } =20 static int coroutine_fn -blkdebug_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +blkdebug_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { int err; =20 diff --git a/block/blklogwrites.c b/block/blklogwrites.c index b7579370a3..de3d4ba2b6 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -301,8 +301,8 @@ static void blk_log_writes_refresh_limits(BlockDriverSt= ate *bs, Error **errp) } =20 static int coroutine_fn -blk_log_writes_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t b= ytes, - QEMUIOVector *qiov, int flags) +blk_log_writes_co_preadv(BlockDriverState *bs, int64_t offset, int64_t byt= es, + QEMUIOVector *qiov, BdrvRequestFlags flags) { return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); } diff --git a/block/blkreplay.c b/block/blkreplay.c index 4a247752fd..13ea2166bb 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -72,7 +72,7 @@ static void block_request_create(uint64_t reqid, BlockDri= verState *bs, } =20 static int coroutine_fn blkreplay_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags fl= ags) { uint64_t reqid =3D blkreplay_next_id(); int ret =3D bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); diff --git a/block/blkverify.c b/block/blkverify.c index 188d7632fa..5e35744b8a 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -221,8 +221,8 @@ blkverify_co_prwv(BlockDriverState *bs, BlkverifyReques= t *r, uint64_t offset, } =20 static int coroutine_fn -blkverify_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +blkverify_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BlkverifyRequest r; QEMUIOVector raw_qiov; diff --git a/block/bochs.c b/block/bochs.c index 2f010ab40a..4d68658087 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -238,8 +238,8 @@ static int64_t seek_to_sector(BlockDriverState *bs, int= 64_t sector_num) } =20 static int coroutine_fn -bochs_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +bochs_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVBochsState *s =3D bs->opaque; uint64_t sector_num =3D offset >> BDRV_SECTOR_BITS; diff --git a/block/cloop.c b/block/cloop.c index c99192a57f..b8c6d0eccd 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -245,8 +245,8 @@ static inline int cloop_read_block(BlockDriverState *bs= , int block_num) } =20 static int coroutine_fn -cloop_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +cloop_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVCloopState *s =3D bs->opaque; uint64_t sector_num =3D offset >> BDRV_SECTOR_BITS; diff --git a/block/commit.c b/block/commit.c index b89bb20b75..d9278d0192 100644 --- a/block/commit.c +++ b/block/commit.c @@ -212,7 +212,7 @@ static const BlockJobDriver commit_job_driver =3D { }; =20 static int coroutine_fn bdrv_commit_top_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags fl= ags) { return bdrv_co_preadv(bs->backing, offset, bytes, qiov, flags); } diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 9cad9e1b8c..afb2a77b08 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -141,10 +141,10 @@ static int64_t cor_getlength(BlockDriverState *bs) =20 =20 static int coroutine_fn cor_co_preadv_part(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, - int flags) + BdrvRequestFlags flags) { int64_t n; int local_flags; diff --git a/block/crypto.c b/block/crypto.c index 1d30fde38e..a732a36d10 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -397,8 +397,8 @@ static int block_crypto_reopen_prepare(BDRVReopenState = *state, #define BLOCK_CRYPTO_MAX_IO_SIZE (1024 * 1024) =20 static coroutine_fn int -block_crypto_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t byt= es, - QEMUIOVector *qiov, int flags) +block_crypto_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BlockCrypto *crypto =3D bs->opaque; uint64_t cur_bytes; /* number of bytes in current iteration */ diff --git a/block/curl.c b/block/curl.c index 50e741a0d7..4a8ae2b269 100644 --- a/block/curl.c +++ b/block/curl.c @@ -896,7 +896,8 @@ out: } =20 static int coroutine_fn curl_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { CURLAIOCB acb =3D { .co =3D qemu_coroutine_self(), diff --git a/block/dmg.c b/block/dmg.c index ef35a505f2..447901fbb8 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -689,8 +689,8 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) } =20 static int coroutine_fn -dmg_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +dmg_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVDMGState *s =3D bs->opaque; uint64_t sector_num =3D offset >> BDRV_SECTOR_BITS; diff --git a/block/file-posix.c b/block/file-posix.c index 10b71d9a13..e0e758e446 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2009,9 +2009,9 @@ static int coroutine_fn raw_co_prw(BlockDriverState *= bs, uint64_t offset, return raw_thread_pool_submit(bs, handle_aiocb_rw, &acb); } =20 -static int coroutine_fn raw_co_preadv(BlockDriverState *bs, uint64_t offse= t, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static int coroutine_fn raw_co_preadv(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { return raw_co_prw(bs, offset, bytes, qiov, QEMU_AIO_READ); } diff --git a/block/file-win32.c b/block/file-win32.c index 2642088bd6..15076350f2 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -436,8 +436,8 @@ fail: } =20 static BlockAIOCB *raw_aio_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags fla= gs, BlockCompletionFunc *cb, void *opaque) { BDRVRawState *s =3D bs->opaque; diff --git a/block/filter-compress.c b/block/filter-compress.c index 5136371bf8..54a16c6c64 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -63,10 +63,10 @@ static int64_t compress_getlength(BlockDriverState *bs) =20 =20 static int coroutine_fn compress_co_preadv_part(BlockDriverState *bs, - uint64_t offset, uint64_t = bytes, + int64_t offset, int64_t by= tes, QEMUIOVector *qiov, size_t qiov_offset, - int flags) + BdrvRequestFlags flags) { return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset, flags); diff --git a/block/mirror.c b/block/mirror.c index 840b8e8c15..684652092a 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1380,7 +1380,7 @@ static void coroutine_fn active_write_settle(MirrorOp= *op) } =20 static int coroutine_fn bdrv_mirror_top_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags fl= ags) { return bdrv_co_preadv(bs->backing, offset, bytes, qiov, flags); } diff --git a/block/nbd.c b/block/nbd.c index 1d4668d42d..f1aac282e4 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1545,8 +1545,9 @@ static int nbd_co_request(BlockDriverState *bs, NBDRe= quest *request, return ret ? ret : request_ret; } =20 -static int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, int fl= ags) +static int nbd_client_co_preadv(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { int ret, request_ret; Error *local_err =3D NULL; diff --git a/block/nfs.c b/block/nfs.c index 8c1968bb41..eee8f706ba 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -265,9 +265,9 @@ nfs_co_generic_cb(int ret, struct nfs_context *nfs, voi= d *data, nfs_co_generic_bh_cb, task); } =20 -static int coroutine_fn nfs_co_preadv(BlockDriverState *bs, uint64_t offse= t, - uint64_t bytes, QEMUIOVector *iov, - int flags) +static int coroutine_fn nfs_co_preadv(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *iov, + BdrvRequestFlags flags) { NFSClient *client =3D bs->opaque; NFSRPC task; diff --git a/block/null.c b/block/null.c index cc9b1d4ea7..343dbb580d 100644 --- a/block/null.c +++ b/block/null.c @@ -116,8 +116,9 @@ static coroutine_fn int null_co_common(BlockDriverState= *bs) } =20 static coroutine_fn int null_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVNullState *s =3D bs->opaque; =20 @@ -187,8 +188,8 @@ static inline BlockAIOCB *null_aio_common(BlockDriverSt= ate *bs, } =20 static BlockAIOCB *null_aio_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags fl= ags, BlockCompletionFunc *cb, void *opaque) { diff --git a/block/nvme.c b/block/nvme.c index 2b5421e7aa..58342c6409 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1221,8 +1221,9 @@ static int nvme_co_prw(BlockDriverState *bs, uint64_t= offset, uint64_t bytes, } =20 static coroutine_fn int nvme_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { return nvme_co_prw(bs, offset, bytes, qiov, false, flags); } diff --git a/block/preallocate.c b/block/preallocate.c index b619206304..5709443612 100644 --- a/block/preallocate.c +++ b/block/preallocate.c @@ -227,8 +227,8 @@ static void preallocate_reopen_abort(BDRVReopenState *s= tate) } =20 static coroutine_fn int preallocate_co_preadv_part( - BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, size_t qiov_offset, int flags) + BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) { return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset, flags); diff --git a/block/qcow.c b/block/qcow.c index f8919a44d1..1151b8d79b 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -617,9 +617,9 @@ static void qcow_refresh_limits(BlockDriverState *bs, E= rror **errp) bs->bl.request_alignment =3D BDRV_SECTOR_SIZE; } =20 -static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, uint64_t offs= et, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, int64_t offse= t, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVQcowState *s =3D bs->opaque; int offset_in_cluster; diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index bd0597842f..70adea9f59 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -505,7 +505,19 @@ static int coroutine_fn do_perform_cow_read(BlockDrive= rState *bs, return -ENOMEDIUM; } =20 - /* Call .bdrv_co_readv() directly instead of using the public block-la= yer + /* + * We never deal with requests that doesn't satisfy + * bdrv_check_qiov_request(), and aligning requests to clusters never = break + * this condition. So, do some assertions before calling + * bs->drv->bdrv_co_preadv_part() which has int64_t arguments. + */ + assert(src_cluster_offset <=3D INT64_MAX); + assert(src_cluster_offset + offset_in_cluster <=3D INT64_MAX); + assert(qiov->size <=3D INT64_MAX); + bdrv_check_qiov_request(src_cluster_offset + offset_in_cluster, qiov->= size, + qiov, 0, &error_abort); + /* + * Call .bdrv_co_readv() directly instead of using the public block-la= yer * interface. This avoids double I/O throttling and request tracking, * which can lead to deadlock when block layer copy-on-read is enabled. */ diff --git a/block/qcow2.c b/block/qcow2.c index 227885620d..35844beb46 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2282,9 +2282,10 @@ static coroutine_fn int qcow2_co_preadv_task_entry(A= ioTask *task) } =20 static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs, - uint64_t offset, uint64_t byt= es, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, - size_t qiov_offset, int flags) + size_t qiov_offset, + BdrvRequestFlags flags) { BDRVQcow2State *s =3D bs->opaque; int ret =3D 0; diff --git a/block/quorum.c b/block/quorum.c index cfc1436abb..1eba2ce7ff 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -663,8 +663,8 @@ static int read_fifo_child(QuorumAIOCB *acb) return ret; } =20 -static int quorum_co_preadv(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, int flags) +static int quorum_co_preadv(BlockDriverState *bs, int64_t offset, int64_t = bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVQuorumState *s =3D bs->opaque; QuorumAIOCB *acb =3D quorum_aio_get(bs, qiov, offset, bytes, flags); diff --git a/block/raw-format.c b/block/raw-format.c index 7717578ed6..e3f459b2cb 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -181,8 +181,8 @@ static void raw_reopen_abort(BDRVReopenState *state) } =20 /* Check and adjust the offset, against 'offset' and 'size' options. */ -static inline int raw_adjust_offset(BlockDriverState *bs, uint64_t *offset, - uint64_t bytes, bool is_write) +static inline int raw_adjust_offset(BlockDriverState *bs, int64_t *offset, + int64_t bytes, bool is_write) { BDRVRawState *s =3D bs->opaque; =20 @@ -201,9 +201,9 @@ static inline int raw_adjust_offset(BlockDriverState *b= s, uint64_t *offset, return 0; } =20 -static int coroutine_fn raw_co_preadv(BlockDriverState *bs, uint64_t offse= t, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static int coroutine_fn raw_co_preadv(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { int ret; =20 @@ -259,7 +259,7 @@ static int coroutine_fn raw_co_pwritev(BlockDriverState= *bs, uint64_t offset, qiov =3D &local_qiov; } =20 - ret =3D raw_adjust_offset(bs, &offset, bytes, true); + ret =3D raw_adjust_offset(bs, (int64_t *)&offset, bytes, true); if (ret) { goto fail; } @@ -294,7 +294,7 @@ static int coroutine_fn raw_co_pwrite_zeroes(BlockDrive= rState *bs, { int ret; =20 - ret =3D raw_adjust_offset(bs, (uint64_t *)&offset, bytes, true); + ret =3D raw_adjust_offset(bs, (int64_t *)&offset, bytes, true); if (ret) { return ret; } @@ -306,7 +306,7 @@ static int coroutine_fn raw_co_pdiscard(BlockDriverStat= e *bs, { int ret; =20 - ret =3D raw_adjust_offset(bs, (uint64_t *)&offset, bytes, true); + ret =3D raw_adjust_offset(bs, &offset, bytes, true); if (ret) { return ret; } @@ -541,7 +541,7 @@ static int coroutine_fn raw_co_copy_range_from(BlockDri= verState *bs, { int ret; =20 - ret =3D raw_adjust_offset(bs, &src_offset, bytes, false); + ret =3D raw_adjust_offset(bs, (int64_t *)&src_offset, bytes, false); if (ret) { return ret; } @@ -560,7 +560,7 @@ static int coroutine_fn raw_co_copy_range_to(BlockDrive= rState *bs, { int ret; =20 - ret =3D raw_adjust_offset(bs, &dst_offset, bytes, true); + ret =3D raw_adjust_offset(bs, (int64_t *)&dst_offset, bytes, true); if (ret) { return ret; } diff --git a/block/rbd.c b/block/rbd.c index f098a89c7b..6a937723f4 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -994,8 +994,9 @@ failed: } =20 static BlockAIOCB *qemu_rbd_aio_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { diff --git a/block/throttle.c b/block/throttle.c index b685166ad4..20362b5fe5 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -112,8 +112,9 @@ static int64_t throttle_getlength(BlockDriverState *bs) } =20 static int coroutine_fn throttle_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { =20 ThrottleGroupMember *tgm =3D bs->opaque; diff --git a/block/vdi.c b/block/vdi.c index 548f8a057b..b394cf6ca6 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -544,8 +544,8 @@ static int coroutine_fn vdi_co_block_status(BlockDriver= State *bs, } =20 static int coroutine_fn -vdi_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vdi_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVVdiState *s =3D bs->opaque; QEMUIOVector local_qiov; diff --git a/block/vmdk.c b/block/vmdk.c index 4499f136bd..78592160d0 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1888,8 +1888,8 @@ static int vmdk_read_extent(VmdkExtent *extent, int64= _t cluster_offset, } =20 static int coroutine_fn -vmdk_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vmdk_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVVmdkState *s =3D bs->opaque; int ret; diff --git a/block/vpc.c b/block/vpc.c index 17a705b482..29c8517ff8 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -608,8 +608,8 @@ static int vpc_get_info(BlockDriverState *bs, BlockDriv= erInfo *bdi) } =20 static int coroutine_fn -vpc_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vpc_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVVPCState *s =3D bs->opaque; int ret; diff --git a/block/vvfat.c b/block/vvfat.c index 54807f82ca..8ac90166c5 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1522,8 +1522,8 @@ static int vvfat_read(BlockDriverState *bs, int64_t s= ector_num, } =20 static int coroutine_fn -vvfat_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vvfat_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { int ret; BDRVVVFATState *s =3D bs->opaque; diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c index 892f7f47d8..e3fc9ced3e 100644 --- a/tests/unit/test-bdrv-drain.c +++ b/tests/unit/test-bdrv-drain.c @@ -65,8 +65,9 @@ static void co_reenter_bh(void *opaque) } =20 static int coroutine_fn bdrv_test_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t byte= s, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVTestState *s =3D bs->opaque; =20 @@ -1105,8 +1106,9 @@ static void bdrv_test_top_close(BlockDriverState *bs) } =20 static int coroutine_fn bdrv_test_top_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t = bytes, - QEMUIOVector *qiov, int fl= ags) + int64_t offset, int64_t by= tes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVTestTopState *tts =3D bs->opaque; return bdrv_co_preadv(tts->wait_child, offset, bytes, qiov, flags); @@ -1854,10 +1856,10 @@ static void bdrv_replace_test_close(BlockDriverStat= e *bs) * Set .has_read to true and return success. */ static int coroutine_fn bdrv_replace_test_co_preadv(BlockDriverState *bs, - uint64_t offset, - uint64_t bytes, + int64_t offset, + int64_t bytes, QEMUIOVector *qiov, - int flags) + BdrvRequestFlags flags) { BDRVReplaceTestState *s =3D bs->opaque; =20 diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 8cf172cb7a..b3f8f3ff8e 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -31,9 +31,18 @@ #include "qemu/main-loop.h" #include "iothread.h" =20 -static int coroutine_fn bdrv_test_co_prwv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +static int coroutine_fn bdrv_test_co_preadv(BlockDriverState *bs, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) +{ + return 0; +} + +static int coroutine_fn bdrv_test_co_pwritev(BlockDriverState *bs, + uint64_t offset, uint64_t byt= es, + QEMUIOVector *qiov, + int flags) { return 0; } @@ -66,8 +75,8 @@ static BlockDriver bdrv_test =3D { .format_name =3D "test", .instance_size =3D 1, =20 - .bdrv_co_preadv =3D bdrv_test_co_prwv, - .bdrv_co_pwritev =3D bdrv_test_co_prwv, + .bdrv_co_preadv =3D bdrv_test_co_preadv, + .bdrv_co_pwritev =3D bdrv_test_co_pwritev, .bdrv_co_pdiscard =3D bdrv_test_co_pdiscard, .bdrv_co_truncate =3D bdrv_test_co_truncate, .bdrv_co_block_status =3D bdrv_test_co_block_status, --=20 2.29.2 From nobody Sat May 4 04:00:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1620201223; cv=pass; d=zohomail.com; s=zohoarc; b=EUv1DVjeaGh1yJOuPH1Zp73t/sixCmOi7Tk7VsWdCRR9JzNrH1W6RIDx7VoZeLIRftnHappebHqeA85S8z0f0xdQmxa+dHCxEJh014VpHXzlLtWBUQp4vNkOP8scoKTjnTcZCQYmq+F9T/DdkK33uvZURXLXRjcm1Qo32xq7hlo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201223; h=Content-Type: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; bh=+QBEzlNRBT4XnUuG4iLRTK0i15JXnj5g/1WR0ovpvsA=; b=m1FA3Td6MzoyWe83wCunIhCHbFf37gBEvjjOehFebui2TM7ISbbAkaqgm5puD854XUJhPyfS6mAaeH5dRF31cI50nAJ+s/pR3DNDXtYWM7LCUY4KDn7at3IoA1JDJ9Oo9w2nmKWkxU6yAav2RtHAwTCFkzoCIVQG8YMy1DnkQEY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine 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 1620201223279895.9933053614988; Wed, 5 May 2021 00:53:43 -0700 (PDT) Received: from localhost ([::1]:47440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leCLm-0000iz-0o for importer@patchew.org; Wed, 05 May 2021 03:53:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIv-0005hC-3l; Wed, 05 May 2021 03:50:45 -0400 Received: from mail-db8eur05on2090.outbound.protection.outlook.com ([40.107.20.90]:42592 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIq-0002eS-SS; Wed, 05 May 2021 03:50:44 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6839.eurprd08.prod.outlook.com (2603:10a6:20b:352::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.39; Wed, 5 May 2021 07:50:30 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4108.026; Wed, 5 May 2021 07:50:30 +0000 Received: from localhost.localdomain (185.215.60.236) by HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 07:50:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IphS6hs3bfF2u6JTYZKqwPcH3QxDaKMqGa1Vy3lbPPPNkg3Clyyjvc/lFpWrmkAec7wMau34oGUayi7+fzVafffGvYBoP/3C4U+skXSfMF1V2KOeCNuRXCB20ZmIbcXV7oLfTI+OIA8Kt2qBpE8FGrB5vWqBljeHQ/oOxjVu6hHRxXl7pPC1jWWpPsBOomVe92jgMXI9nWMEhIxKQUgYYJyN4r8ohm4EKfiEB7FKF1f75MQ6l1jtcGpZM1BoHorhPSGewGVDAxJEWXXMpdz/+uETawWkBmaxDi0R6XA50pHxrTrEcEXY6CNweVJAbUdqG4cInovd18cW6nrsP9PMiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+QBEzlNRBT4XnUuG4iLRTK0i15JXnj5g/1WR0ovpvsA=; b=nSTdjFPPVeIVSR+Buk1NyKNWmZVzTa/5NdX37OPr5V4aCYlzHbFsrgi/A+ScwGZ8VreCE6nfCAduIa0YM45ZcDrtpUyDx8ijNPFgumUK+BytV5GGnoRmGcoytjNyqWvLpeWMJn2UglMqo3gon781VUkm/RD9T6OIuiEsusndex19q6IQ1R3UrCDi0iJv6oo6dirbNt8z2dC2GBnynv8Et5ptIUxsAj7MaAZKIPxTloMOH3xXiaUD4ZV7IxJ2fAJyNlkQm/+H3j9Rdopa6N4TCU2ufX4bQIqX/+ey8HjyKfRggcJDSUm/YTnQy4xZ4Dwt5+BPKbPWx9+toIn/e2M12g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+QBEzlNRBT4XnUuG4iLRTK0i15JXnj5g/1WR0ovpvsA=; b=QMGmuRvsLj7sgmD3X/yQ1RNJRniIOY4T42n4TMHFqFE0xJ12sr0wFUnUbS/rOi98EXlbxlU6uYmvF0g5Tpf+2SRPeLxzEvwuQGV39mCYf5/1X1Vyhka8ZoiR5MxgysqVytzlXZ42KlZsygOhtYFgnfdZ3nGhEsTcJgYj0DLJJ1Q= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, stefanha@redhat.com, kwolf@redhat.com, mreitz@redhat.com, vsementsov@virtuozzo.com, John Snow , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , Stefan Weil , Fam Zheng , Peter Lieven , Alberto Garcia , Jason Dillaman Subject: [PATCH v5 04/11] block: use int64_t instead of uint64_t in driver write handlers Date: Wed, 5 May 2021 10:49:54 +0300 Message-Id: <20210505075001.45041-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210505075001.45041-1-vsementsov@virtuozzo.com> References: <20210505075001.45041-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.236] X-ClientProxiedBy: HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 154cfd84-0213-417b-e467-08d90f9a7475 X-MS-TrafficTypeDiagnostic: AS8PR08MB6839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:254; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R8//RiKKH0fev3MDIztq4USKDB+z4fFfxQp6Tbye4SksklbX36Q40rOYZeiuV2zobD2cObtAr6QxKoV730xzRL0nMymqGLTKLhbZ4J9C/gq092C/jlgqVwglxg1H+QfE9jRuzcREXyCT3P4wQUAGj7r0qdyvl/fyYgH1/TbC3gyoBPrf6P63fDWN7mD+PpZqwZ4yzskDJeWQonUP8TfGGlasAoL25Ztxi1u/9IU6NPs5zI+MMVhte9EcLGBJjpcAdxeJKjPHphqrTNyRPzWdUVANpijlAmRCWgL5giGq1eoqvMmDIPRiCj0M49zdQwUYghrZbVRSC1VwZIx5V/e1YzTH95b8W9oApENYhtLs3OEZ+ZNQRvw4mz1nTdnLsDe5ZrvaxeA4GAElKCaScdAKImma3VL7whcMqWgjLO3vT9iinyxZeaPholaK7Ir3ZbmwIl/HEaU1PXjCuIOIrQp0sWBDr1iYfA28pUY4U7+jedQ9OPcr9oPi1Lw3HRWXX2lyfAuEtk1R+4CGU6Cshvoezlts9H5mNN77/kud4KFmIG4SLUBx4aU8QJci+yLiYHqcQn1oWMI4f+uCqGv774zomCLGaweN/xtd8XCZHyTOJ0IEFhSj+urz46zr7YHeoUg4Ze1ZPzXdX7Ia0qnet+/GVbfbX/LNV5HZdmCvcJkLyY3vWtewFfykMSGdHYpm8pMXEOiD3dwqKh+W/QxhVrLkGw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(376002)(346002)(396003)(366004)(136003)(38350700002)(38100700002)(66946007)(26005)(66556008)(6506007)(66476007)(86362001)(16526019)(30864003)(83380400001)(6666004)(7416002)(54906003)(6916009)(4326008)(36756003)(478600001)(316002)(8676002)(6512007)(2616005)(2906002)(186003)(52116002)(956004)(6486002)(8936002)(5660300002)(1076003)(69590400013)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?+n7T7WONZJ1dd2OtxCPyU4q9jLf/d0wrGLewnE7TYbh3qxVxVSXL9YDvtrO5?= =?us-ascii?Q?wv19lzJw9DWi0HJ93B8+A6fHloylHFEIlTqVA60K/ybDkGyhkLMTk6nVs+FV?= =?us-ascii?Q?Npk/OG9evNKM7ioS3W/KlY8EmK/l/UFiqozOTd5h+5THQizlqIIL1oveFK7f?= =?us-ascii?Q?ZsatJ+JPPaeIzYd89w7jZ8J8U6uF3MpRr50wrdzgkmWVmsD2T6x36+Jy1sQf?= =?us-ascii?Q?C91cp06SlP8VH/i1xmc7oZRW1rEOs8Nao72xmSqJNGe3v5R56nmGNuK8FR9Q?= =?us-ascii?Q?zY46gQS+7FHD2cr8I4kFcs8zC/y6skFFiiM5J9mxvAMl62NuEXGgTJmyzn2f?= =?us-ascii?Q?bt8yAHbF2gFyKncp3lF10lh7tvQT0RA+4G83fj3JlvIIefMCnxFXxBvE2liT?= =?us-ascii?Q?o4i71M4e4FKavDOz8Vk0ILmHIoTPc0+dlpeV4jhUCVnuabjmLQYr0mjUvk5x?= =?us-ascii?Q?hlZn+5/r1hZrXeIEIJop1RS2i5mNT+x+Xd1B0rvjrUuC74YtWSsqI2Z12vo+?= =?us-ascii?Q?jtdIgrTFvikXV8le6o4IpDmsq43TALrnWHRH1pMoHoS/03Jokyz0eA278yI5?= =?us-ascii?Q?HBInhBT+o1tY6LD+oCvyH2sL4KRGpIsj6v8D9ArNuvbHQ21PYVdYxOVSs+lM?= =?us-ascii?Q?WQ3AdwurQ1bF7yUc8lcBfdf8ICWLxGXOUBZO3MxbC5J5EVgH11Cp8ANA64wy?= =?us-ascii?Q?KdC4ANKHr+g2c+ZjTlwR0NS/E9duhAo2WeXhMCKlHA2yl8OmAKamlhawe4aN?= =?us-ascii?Q?NZylQWtgwaJk61T693DlzDEdA9B7J1kJsLGlWlL7ehNKO6o1oOLLi2eq8T1B?= =?us-ascii?Q?F/+YshPpvXd0KXwDlCcMkMroJREFl70XF79wrzAzC9I64HP8ubnZqRbZ4ag3?= =?us-ascii?Q?xbG6ejFzcEMlcJw//ke5cF7N6Rbd14yik6zIWZE3hQmyI9b3uVTi+4fO1Kpl?= =?us-ascii?Q?lG+oS+LDZ+LJM6eh3ZoFNrpqLM9AcHnOBYXR/q4RYVCWy5ESRDoKz/kLr7jC?= =?us-ascii?Q?qWC38X++Q7FFhL2qxEW5VdZkUu36sSPxIdcRZKfT2yDHX7Gunx+nzkdb6Q/w?= =?us-ascii?Q?675JigGFEmn64VQg2vqRFRvocmSqq+A1nt+qiIhg4+IHIBtXkHPw2HF4cMcD?= =?us-ascii?Q?ReMt1qz7qOacLBkG50gEjNmmRnazDN9TFNBoPgoQcRWKSrE4a5pUsPI6umue?= =?us-ascii?Q?FpwUGqWJAJsq4Trcl196No9VVd1YYGbM+P3U3WdAVLC5twqwKgDJ6t26QhSL?= =?us-ascii?Q?LrgC3dg2jwGaUC7wyLmy8am8X38AZIJH44g5XbvIm3Mx3seYDcRUP0MPb3/3?= =?us-ascii?Q?OX6KsxE0kvh+jP/TrirEHxxV?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 154cfd84-0213-417b-e467-08d90f9a7475 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 07:50:30.5258 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fGzGjTvtetdXznoIfQz6tR9E0+3PAcn3MtBOM9dUEeZ0GSk9Q2vKTISP+DUJFd2nYnhUCIYrydbH2T509D37R0JBU+HIV2mme6mR06bO7Bg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6839 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=40.107.20.90; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, convert driver write handlers parameters which are already 64bit to signed type. While being here, convert also flags parameter to be BdrvRequestFlags. Now let's consider all callers. Simple git grep '\->bdrv_\(aio\|co\)_pwritev\(_part\)\?' shows that's there two callers of driver function: bdrv_driver_pwritev() in block/io.c, passes int64_t, checked by bdrv_check_qiov_request() to be non-negative. qcow2_save_vmstate() does bdrv_check_qiov_request(). Still, the functions may be called directly, not only by drv->... Let's check: git grep '\.bdrv_\(aio\|co\)_pwritev\(_part\)\?\s*=3D' | \ awk '{print $4}' | sed 's/,//' | sed 's/&//' | sort | uniq | \ while read func; do git grep "$func(" | \ grep -v "$func(BlockDriverState"; done shows several callers: qcow2: qcow2_co_truncate() write at most up to @offset, which is checked in generic qcow2_co_truncate() by bdrv_check_request(). qcow2_co_pwritev_compressed_task() pass the request (or part of the request) that already went through normal write path, so it should be OK qcow: qcow_co_pwritev_compressed() pass int64_t, it's updated by this patch quorum: quorum_co_pwrite_zeroes() pass int64_t and int - OK throttle: throttle_co_pwritev_compressed() pass int64_t, it's updated by this patch vmdk: vmdk_co_pwritev_compressed() pass int64_t, it's updated by this patch Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 16 ++++++++-------- block/backup-top.c | 6 +++--- block/blkdebug.c | 4 ++-- block/blklogwrites.c | 4 ++-- block/blkreplay.c | 2 +- block/blkverify.c | 4 ++-- block/copy-on-read.c | 11 ++++++----- block/crypto.c | 4 ++-- block/file-posix.c | 6 +++--- block/file-win32.c | 4 ++-- block/filter-compress.c | 7 ++++--- block/io.c | 6 ++++-- block/mirror.c | 2 +- block/nbd.c | 5 +++-- block/nfs.c | 6 +++--- block/null.c | 9 +++++---- block/nvme.c | 5 +++-- block/preallocate.c | 6 +++--- block/qcow.c | 10 +++++----- block/qcow2.c | 6 +++--- block/quorum.c | 5 +++-- block/raw-format.c | 10 +++++----- block/rbd.c | 5 +++-- block/throttle.c | 9 +++++---- block/vdi.c | 4 ++-- block/vmdk.c | 8 ++++---- block/vpc.c | 4 ++-- block/vvfat.c | 8 ++++---- tests/unit/test-block-iothread.c | 4 ++-- block/trace-events | 2 +- 30 files changed, 96 insertions(+), 86 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index dc08f99e95..38ce897972 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -237,8 +237,8 @@ struct BlockDriver { int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque); BlockAIOCB *(*bdrv_aio_pwritev)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags, - BlockCompletionFunc *cb, void *opaque); + int64_t offset, int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque); BlockAIOCB *(*bdrv_aio_flush)(BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque); BlockAIOCB *(*bdrv_aio_pdiscard)(BlockDriverState *bs, @@ -287,10 +287,11 @@ struct BlockDriver { * The buffer in @qiov may point directly to guest memory. */ int coroutine_fn (*bdrv_co_pwritev)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags); + int64_t offset, int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags); int coroutine_fn (*bdrv_co_pwritev_part)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, size_t qiov_offset, int flags); + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_off= set, + BdrvRequestFlags flags); =20 /* * Efficiently zero a region of the disk image. Typically an image fo= rmat @@ -428,10 +429,9 @@ struct BlockDriver { Error **errp); =20 int coroutine_fn (*bdrv_co_pwritev_compressed)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov); + int64_t offset, int64_t bytes, QEMUIOVector *qiov); int coroutine_fn (*bdrv_co_pwritev_compressed_part)(BlockDriverState *= bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, - size_t qiov_offset); + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_off= set); =20 int (*bdrv_snapshot_create)(BlockDriverState *bs, QEMUSnapshotInfo *sn_info); diff --git a/block/backup-top.c b/block/backup-top.c index fb32ac7b2b..6834921092 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -86,9 +86,9 @@ static int coroutine_fn backup_top_co_pwrite_zeroes(Block= DriverState *bs, } =20 static coroutine_fn int backup_top_co_pwritev(BlockDriverState *bs, - uint64_t offset, - uint64_t bytes, - QEMUIOVector *qiov, int flag= s) + int64_t offset, int64_t byte= s, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { int ret =3D backup_top_cbw(bs, offset, bytes, flags); if (ret < 0) { diff --git a/block/blkdebug.c b/block/blkdebug.c index b26fecf222..a7fedd80fd 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -635,8 +635,8 @@ blkdebug_co_preadv(BlockDriverState *bs, int64_t offset= , int64_t bytes, } =20 static int coroutine_fn -blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +blkdebug_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { int err; =20 diff --git a/block/blklogwrites.c b/block/blklogwrites.c index de3d4ba2b6..ca174ab135 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -460,8 +460,8 @@ blk_log_writes_co_do_file_pdiscard(BlkLogWritesFileReq = *fr) } =20 static int coroutine_fn -blk_log_writes_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t = bytes, - QEMUIOVector *qiov, int flags) +blk_log_writes_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t by= tes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { return blk_log_writes_co_log(bs, offset, bytes, qiov, flags, blk_log_writes_co_do_file_pwritev, 0, fal= se); diff --git a/block/blkreplay.c b/block/blkreplay.c index 13ea2166bb..7ba62dcac1 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -83,7 +83,7 @@ static int coroutine_fn blkreplay_co_preadv(BlockDriverSt= ate *bs, } =20 static int coroutine_fn blkreplay_co_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags fl= ags) { uint64_t reqid =3D blkreplay_next_id(); int ret =3D bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags); diff --git a/block/blkverify.c b/block/blkverify.c index 5e35744b8a..d1facf5ba9 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -250,8 +250,8 @@ blkverify_co_preadv(BlockDriverState *bs, int64_t offse= t, int64_t bytes, } =20 static int coroutine_fn -blkverify_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +blkverify_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BlkverifyRequest r; return blkverify_co_prwv(bs, &r, offset, bytes, qiov, qiov, flags, tru= e); diff --git a/block/copy-on-read.c b/block/copy-on-read.c index afb2a77b08..7675565080 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -194,10 +194,11 @@ static int coroutine_fn cor_co_preadv_part(BlockDrive= rState *bs, =20 =20 static int coroutine_fn cor_co_pwritev_part(BlockDriverState *bs, - uint64_t offset, - uint64_t bytes, + int64_t offset, + int64_t bytes, QEMUIOVector *qiov, - size_t qiov_offset, int flags) + size_t qiov_offset, + BdrvRequestFlags flags) { return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset, flags); @@ -220,8 +221,8 @@ static int coroutine_fn cor_co_pdiscard(BlockDriverStat= e *bs, =20 =20 static int coroutine_fn cor_co_pwritev_compressed(BlockDriverState *bs, - uint64_t offset, - uint64_t bytes, + int64_t offset, + int64_t bytes, QEMUIOVector *qiov) { return bdrv_co_pwritev(bs->file, offset, bytes, qiov, diff --git a/block/crypto.c b/block/crypto.c index a732a36d10..c8ba4681e2 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -460,8 +460,8 @@ block_crypto_co_preadv(BlockDriverState *bs, int64_t of= fset, int64_t bytes, =20 =20 static coroutine_fn int -block_crypto_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t by= tes, - QEMUIOVector *qiov, int flags) +block_crypto_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t byte= s, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BlockCrypto *crypto =3D bs->opaque; uint64_t cur_bytes; /* number of bytes in current iteration */ diff --git a/block/file-posix.c b/block/file-posix.c index e0e758e446..9771eafe5e 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2016,9 +2016,9 @@ static int coroutine_fn raw_co_preadv(BlockDriverStat= e *bs, int64_t offset, return raw_co_prw(bs, offset, bytes, qiov, QEMU_AIO_READ); } =20 -static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offs= et, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, int64_t offse= t, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { assert(flags =3D=3D 0); return raw_co_prw(bs, offset, bytes, qiov, QEMU_AIO_WRITE); diff --git a/block/file-win32.c b/block/file-win32.c index 15076350f2..7c2706c329 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -451,8 +451,8 @@ static BlockAIOCB *raw_aio_preadv(BlockDriverState *bs, } =20 static BlockAIOCB *raw_aio_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags fl= ags, BlockCompletionFunc *cb, void *opaque) { BDRVRawState *s =3D bs->opaque; diff --git a/block/filter-compress.c b/block/filter-compress.c index 54a16c6c64..505822a44f 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -74,10 +74,11 @@ static int coroutine_fn compress_co_preadv_part(BlockDr= iverState *bs, =20 =20 static int coroutine_fn compress_co_pwritev_part(BlockDriverState *bs, - uint64_t offset, - uint64_t bytes, + int64_t offset, + int64_t bytes, QEMUIOVector *qiov, - size_t qiov_offset, int f= lags) + size_t qiov_offset, + BdrvRequestFlags flags) { return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset, flags | BDRV_REQ_WRITE_COMPRESSED); diff --git a/block/io.c b/block/io.c index 932a26f0bb..448251beaa 100644 --- a/block/io.c +++ b/block/io.c @@ -1225,7 +1225,8 @@ out: static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, QEMUIOVector *qiov, - size_t qiov_offset, int flags) + size_t qiov_offset, + BdrvRequestFlags flags) { BlockDriver *drv =3D bs->drv; int64_t sector_num; @@ -2064,7 +2065,8 @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t of= fset, int64_t bytes, */ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, BdrvTrackedRequest *req, int64_t offset, int64_t bytes, - int64_t align, QEMUIOVector *qiov, size_t qiov_offset, int flags) + int64_t align, QEMUIOVector *qiov, size_t qiov_offset, + BdrvRequestFlags flags) { BlockDriverState *bs =3D child->bs; BlockDriver *drv =3D bs->drv; diff --git a/block/mirror.c b/block/mirror.c index 684652092a..fdf477a0fd 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1434,7 +1434,7 @@ out: } =20 static int coroutine_fn bdrv_mirror_top_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags fl= ags) { MirrorBDSOpaque *s =3D bs->opaque; QEMUIOVector bounce_qiov; diff --git a/block/nbd.c b/block/nbd.c index f1aac282e4..d3de441c2b 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1604,8 +1604,9 @@ static int nbd_client_co_preadv(BlockDriverState *bs,= int64_t offset, return ret ? ret : request_ret; } =20 -static int nbd_client_co_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, int f= lags) +static int nbd_client_co_pwritev(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; NBDRequest request =3D { diff --git a/block/nfs.c b/block/nfs.c index eee8f706ba..c6563930cf 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -299,9 +299,9 @@ static int coroutine_fn nfs_co_preadv(BlockDriverState = *bs, int64_t offset, return 0; } =20 -static int coroutine_fn nfs_co_pwritev(BlockDriverState *bs, uint64_t offs= et, - uint64_t bytes, QEMUIOVector *iov, - int flags) +static int coroutine_fn nfs_co_pwritev(BlockDriverState *bs, int64_t offse= t, + int64_t bytes, QEMUIOVector *iov, + BdrvRequestFlags flags) { NFSClient *client =3D bs->opaque; NFSRPC task; diff --git a/block/null.c b/block/null.c index 343dbb580d..75f7d0db40 100644 --- a/block/null.c +++ b/block/null.c @@ -130,8 +130,9 @@ static coroutine_fn int null_co_preadv(BlockDriverState= *bs, } =20 static coroutine_fn int null_co_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { return null_co_common(bs); } @@ -203,8 +204,8 @@ static BlockAIOCB *null_aio_preadv(BlockDriverState *bs, } =20 static BlockAIOCB *null_aio_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags f= lags, BlockCompletionFunc *cb, void *opaque) { diff --git a/block/nvme.c b/block/nvme.c index 58342c6409..349c152ab5 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1229,8 +1229,9 @@ static coroutine_fn int nvme_co_preadv(BlockDriverSta= te *bs, } =20 static coroutine_fn int nvme_co_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { return nvme_co_prw(bs, offset, bytes, qiov, true, flags); } diff --git a/block/preallocate.c b/block/preallocate.c index 5709443612..c19885af17 100644 --- a/block/preallocate.c +++ b/block/preallocate.c @@ -349,11 +349,11 @@ static int coroutine_fn preallocate_co_pwrite_zeroes(= BlockDriverState *bs, } =20 static coroutine_fn int preallocate_co_pwritev_part(BlockDriverState *bs, - uint64_t offset, - uint64_t bytes, + int64_t offset, + int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, - int flags) + BdrvRequestFlags flags) { handle_write(bs, offset, bytes, false); =20 diff --git a/block/qcow.c b/block/qcow.c index 1151b8d79b..c39940f33e 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -714,9 +714,9 @@ static coroutine_fn int qcow_co_preadv(BlockDriverState= *bs, int64_t offset, return ret; } =20 -static coroutine_fn int qcow_co_pwritev(BlockDriverState *bs, uint64_t off= set, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static coroutine_fn int qcow_co_pwritev(BlockDriverState *bs, int64_t offs= et, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVQcowState *s =3D bs->opaque; int offset_in_cluster; @@ -1047,8 +1047,8 @@ static int qcow_make_empty(BlockDriverState *bs) /* XXX: put compressed sectors first, then all the cluster aligned tables to avoid losing bytes in alignment */ static coroutine_fn int -qcow_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov) +qcow_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t b= ytes, + QEMUIOVector *qiov) { BDRVQcowState *s =3D bs->opaque; z_stream strm; diff --git a/block/qcow2.c b/block/qcow2.c index 35844beb46..5bab24d1dc 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2569,8 +2569,8 @@ static coroutine_fn int qcow2_co_pwritev_task_entry(A= ioTask *task) } =20 static coroutine_fn int qcow2_co_pwritev_part( - BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, size_t qiov_offset, int flags) + BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) { BDRVQcow2State *s =3D bs->opaque; int offset_in_cluster; @@ -4603,7 +4603,7 @@ static coroutine_fn int qcow2_co_pwritev_compressed_t= ask_entry(AioTask *task) */ static coroutine_fn int qcow2_co_pwritev_compressed_part(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset) { BDRVQcow2State *s =3D bs->opaque; diff --git a/block/quorum.c b/block/quorum.c index 1eba2ce7ff..353401ac08 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -714,8 +714,9 @@ static void write_quorum_entry(void *opaque) } } =20 -static int quorum_co_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, int flags) +static int quorum_co_pwritev(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVQuorumState *s =3D bs->opaque; QuorumAIOCB *acb =3D quorum_aio_get(bs, qiov, offset, bytes, flags); diff --git a/block/raw-format.c b/block/raw-format.c index e3f459b2cb..b0fe75f54a 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -216,9 +216,9 @@ static int coroutine_fn raw_co_preadv(BlockDriverState = *bs, int64_t offset, return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); } =20 -static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offs= et, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, int64_t offse= t, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { void *buf =3D NULL; BlockDriver *drv; @@ -259,7 +259,7 @@ static int coroutine_fn raw_co_pwritev(BlockDriverState= *bs, uint64_t offset, qiov =3D &local_qiov; } =20 - ret =3D raw_adjust_offset(bs, (int64_t *)&offset, bytes, true); + ret =3D raw_adjust_offset(bs, &offset, bytes, true); if (ret) { goto fail; } @@ -294,7 +294,7 @@ static int coroutine_fn raw_co_pwrite_zeroes(BlockDrive= rState *bs, { int ret; =20 - ret =3D raw_adjust_offset(bs, (int64_t *)&offset, bytes, true); + ret =3D raw_adjust_offset(bs, &offset, bytes, true); if (ret) { return ret; } diff --git a/block/rbd.c b/block/rbd.c index 6a937723f4..3936d7888a 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1005,8 +1005,9 @@ static BlockAIOCB *qemu_rbd_aio_preadv(BlockDriverSta= te *bs, } =20 static BlockAIOCB *qemu_rbd_aio_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { diff --git a/block/throttle.c b/block/throttle.c index 20362b5fe5..1330e844c3 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -124,8 +124,9 @@ static int coroutine_fn throttle_co_preadv(BlockDriverS= tate *bs, } =20 static int coroutine_fn throttle_co_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t byte= s, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { ThrottleGroupMember *tgm =3D bs->opaque; throttle_group_co_io_limits_intercept(tgm, bytes, true); @@ -153,8 +154,8 @@ static int coroutine_fn throttle_co_pdiscard(BlockDrive= rState *bs, } =20 static int coroutine_fn throttle_co_pwritev_compressed(BlockDriverState *b= s, - uint64_t offset, - uint64_t bytes, + int64_t offset, + int64_t bytes, QEMUIOVector *qiov) { return throttle_co_pwritev(bs, offset, bytes, qiov, diff --git a/block/vdi.c b/block/vdi.c index b394cf6ca6..bdc58d726e 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -600,8 +600,8 @@ vdi_co_preadv(BlockDriverState *bs, int64_t offset, int= 64_t bytes, } =20 static int coroutine_fn -vdi_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vdi_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVVdiState *s =3D bs->opaque; QEMUIOVector local_qiov; diff --git a/block/vmdk.c b/block/vmdk.c index 78592160d0..8d49e54bdd 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2068,8 +2068,8 @@ static int vmdk_pwritev(BlockDriverState *bs, uint64_= t offset, } =20 static int coroutine_fn -vmdk_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vmdk_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { int ret; BDRVVmdkState *s =3D bs->opaque; @@ -2080,8 +2080,8 @@ vmdk_co_pwritev(BlockDriverState *bs, uint64_t offset= , uint64_t bytes, } =20 static int coroutine_fn -vmdk_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov) +vmdk_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t b= ytes, + QEMUIOVector *qiov) { if (bytes =3D=3D 0) { /* The caller will write bytes 0 to signal EOF. diff --git a/block/vpc.c b/block/vpc.c index 29c8517ff8..1b4c7333af 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -658,8 +658,8 @@ fail: } =20 static int coroutine_fn -vpc_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vpc_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVVPCState *s =3D bs->opaque; int64_t image_offset; diff --git a/block/vvfat.c b/block/vvfat.c index 8ac90166c5..0b6ed1c6d1 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3061,8 +3061,8 @@ DLOG(checkpoint()); } =20 static int coroutine_fn -vvfat_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vvfat_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { int ret; BDRVVVFATState *s =3D bs->opaque; @@ -3099,8 +3099,8 @@ static int coroutine_fn vvfat_co_block_status(BlockDr= iverState *bs, } =20 static int coroutine_fn -write_target_commit(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +write_target_commit(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { int ret; =20 diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index b3f8f3ff8e..50b8718b2a 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -40,9 +40,9 @@ static int coroutine_fn bdrv_test_co_preadv(BlockDriverSt= ate *bs, } =20 static int coroutine_fn bdrv_test_co_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t byt= es, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, - int flags) + BdrvRequestFlags flags) { return 0; } diff --git a/block/trace-events b/block/trace-events index 1a12d634e2..3cbea9e2e2 100644 --- a/block/trace-events +++ b/block/trace-events @@ -75,7 +75,7 @@ luring_resubmit_short_read(void *s, void *luringcb, int n= read) "LuringState %p l =20 # qcow2.c qcow2_add_task(void *co, void *bs, void *pool, const char *action, int clu= ster_type, uint64_t host_offset, uint64_t offset, uint64_t bytes, void *qio= v, size_t qiov_offset) "co %p bs %p pool %p: %s: cluster_type %d file_clust= er_offset %" PRIu64 " offset %" PRIu64 " bytes %" PRIu64 " qiov %p qiov_off= set %zu" -qcow2_writev_start_req(void *co, int64_t offset, int bytes) "co %p offset = 0x%" PRIx64 " bytes %d" +qcow2_writev_start_req(void *co, int64_t offset, int64_t bytes) "co %p off= set 0x%" PRIx64 " bytes %" PRId64 qcow2_writev_done_req(void *co, int ret) "co %p ret %d" qcow2_writev_start_part(void *co) "co %p" qcow2_writev_done_part(void *co, int cur_bytes) "co %p cur_bytes %d" --=20 2.29.2 From nobody Sat May 4 04:00:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1620201515; cv=pass; d=zohomail.com; s=zohoarc; b=MluHJxOvsQzGshsIJ9lC5bi0fnoYh57d4PH3YY4IjNJzG05LLKuE2FCMSOBdyPvIRnYdVJLI0LovHHY+dbvvqtF4H6J9pFIybtM1y24eK2T4hXkRMASP87DUZaeoMo7aMZZjxRM0KVdatrHL3pdz++JJ5FAPMYXZqmS0FJvObzg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201515; h=Content-Type: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; bh=gfybI+lE3oIAT7zbnN6jXII/jgrNSQxPYrH/H6lr0e4=; b=nNnnYgigIsNoYDpRMVHarfzy6Vp72JLAEurE9Og8isHaSC+26PmIIQE3FL7ayiW5BwUK8RZyicoUuvo4n9/pWm4waCC2MtfhLMopdTUrLoSA3YJYzn/HF935HCy42qU2Fs7ZeUi6nZlasuABjxN4kObRWLLd2ZDgH3HdSOAt+D8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine 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 1620201515597874.5061370148497; Wed, 5 May 2021 00:58:35 -0700 (PDT) Received: from localhost ([::1]:59354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leCQU-0005qW-Go for importer@patchew.org; Wed, 05 May 2021 03:58:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIs-0005cX-SV; Wed, 05 May 2021 03:50:42 -0400 Received: from mail-eopbgr80109.outbound.protection.outlook.com ([40.107.8.109]:41697 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIq-0002WS-FL; Wed, 05 May 2021 03:50:42 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6839.eurprd08.prod.outlook.com (2603:10a6:20b:352::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.39; Wed, 5 May 2021 07:50:32 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4108.026; Wed, 5 May 2021 07:50:31 +0000 Received: from localhost.localdomain (185.215.60.236) by HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 07:50:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iNyHqnvlziYUuFb1w7Jhub+HqIckJa2rdWrZfWyrtBnnwh6jgTWAf2ovKfxi3yx1bl4ybCXUn8mTpK8mH1gfzlzaUHjRE5XhQLw4pLTILkSgYvKqpHjATRbJS/aNDUgfnmV9Zjlhz2FvFAwQqy/jS6ztt/QKrD+knzmDHU5bfMygLMsd6RUl/wAJC8fxcOLsbw242sE0fQWomq6weQqNS7VuOawHf6JCMvWqfc2EouJlC14dzszCDf+Rxnes3GXGD54Lna/agATCacDBUKxQo3DhPdFLZUswkZuvR6r/wvqGtgtDSxud59jibN+VRwbYlEb3z8U1LGdhBL2+VOm2vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gfybI+lE3oIAT7zbnN6jXII/jgrNSQxPYrH/H6lr0e4=; b=DyuuD25d8H5oBrQs5gjSKyFVTfa4YWYMiIzIFgJx/y12prFGIkwNonkdfnO/B3ndrrF6qxeulWuGw+kS2luPsbfjqkSAPw5eKkpMsLbA8C598kxyLQFhcfUMqOrqTC1KysewZcrgyFhNAtTttvBHkyOu39x2gafs7Su+qovT82ZdNvz1Ksr4enOALB4G14XJW7MGAI+EDEvug+0+I93E5u13RiLrZlrKhZCMQeuIRjORT+akshBOVDr+VaK8ozMxdxHgYcy7P+7Ehygy3w/DmnaESZNNHVkXvExWmr13vx2iA0Sc+1/iX/bmUY5FyZdlkEPKRwkA4oFsrB55+ScLFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gfybI+lE3oIAT7zbnN6jXII/jgrNSQxPYrH/H6lr0e4=; b=K3TsErNuDwrolgIi1alxBFmgmexnPx2+I1NZGcPNLE3AV3y96EyaDf3Kau5WyDJe8I0cs76cKY515IetddWk8RWAs/C6lk7Vu21rhQgV+vp7Mi26RruWTP089r7HolWJO7yvd4H3cNU4ADX+wyC9xqkvFiS3/hKw5DKkbI6d9UY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, stefanha@redhat.com, kwolf@redhat.com, mreitz@redhat.com, vsementsov@virtuozzo.com, Ronnie Sahlberg , Paolo Bonzini , Peter Lieven Subject: [PATCH v5 05/11] block: use int64_t instead of uint64_t in copy_range driver handlers Date: Wed, 5 May 2021 10:49:55 +0300 Message-Id: <20210505075001.45041-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210505075001.45041-1-vsementsov@virtuozzo.com> References: <20210505075001.45041-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.236] X-ClientProxiedBy: HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 847543d0-234f-44f5-a51c-08d90f9a754b X-MS-TrafficTypeDiagnostic: AS8PR08MB6839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1468; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BL6RvKiOcZ5QM8lvgiBGZ6Q81z5WP5UvUmcEeLOcRoR3KsTBBpNNEvT9rR+ukrOqyZzM9cxmQ5+zoss+LKGYd3J5c9K2Q4QhSqb0FOz4gfpdRVz1zxIGru1LnxhAFQ4EwmhTh3DVHRBWA9SyVI+QXFAHc6wRMeJufMdZdgISaVN1Uo1pkzm9lNirmk1+F2WrpyVz0M7VyUqXhuADdICQj3suOhzU262cPhIAHUP5ZRjMY4cn82/9EzArGmEAJSFfCe7SbvfZx+wNxgowLKAwXs1uSBI99oYVLzBxRvNTmsXk7S7UHt2iZV8EiYO8e3cxs24ELqoXNfl5B2jn9kUNp7dr64swRXdBBrzLEIkibim50Br7aRfjvkkpCyMgQ/hoFOHxBfXIakuC53G7htUYXro5gfLK8if2xhl/ijoCbc2TkUpma9CvTHOB5DKGT6OQbDujUhATQ1Cc8ZhLzxGeLlwKssg8tzOcBU0aNeEmIk9AdQz3XN8JjX5pSBlKSJBRtNsq/svrRLhubtUA2g6tVD9A0iEj0bMGokA3rJOBukjGJn+UMAYM3awrXTOi4rdApVv3UuQ5jBN00me+B8xz6d7Wim9CJU3IQ6zZykktfnk66uP2ATlrDFvbhup9wNHTG9HyoFQGj9ULIhYLlbqEJrSaM+x/UFCO7t3kJSbjrfFXvFTSxQM14k3szJa5NH72 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(376002)(346002)(396003)(366004)(136003)(38350700002)(38100700002)(66946007)(26005)(66556008)(6506007)(66476007)(86362001)(16526019)(83380400001)(6666004)(54906003)(6916009)(4326008)(36756003)(478600001)(316002)(8676002)(6512007)(2616005)(2906002)(186003)(52116002)(956004)(6486002)(8936002)(5660300002)(1076003)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?3Vv1Fnx942aEkx+z193As5W9kz+QR1Wo602RE5Un38ZU0H+Z7wvMTlyWTtjM?= =?us-ascii?Q?fCsY9TxtMfE5Dm8MZdAeT66E1Aut8yrXzL8o10P7bdBFQeeOPtbSTIHFsgh9?= =?us-ascii?Q?ItZQTvh+iu9PPXmst5MoHBG3d3ItNcG3ul0S2lwCVAk3dx7Wzn+cGka2imKS?= =?us-ascii?Q?nnb6MQclBy20rQ1XvHeL01yzLPajgj+/p43WzsqoPrNyIyqvUTv3MMDCuaeJ?= =?us-ascii?Q?8mcPSPRn+6VO81ZMKXS9pnvBCgcOfItvVcljDF/GYqt2nFsqjvmisC6/hZ/C?= =?us-ascii?Q?d8pjr8m78u13sZwUqXOcKtOZtLjTrwrlNTBeXbyj/nyGCRAlfcebpZdYvalI?= =?us-ascii?Q?Ixt1OnX+Vb8X7QkzRignB7DdfZLOzUvsT4oP2ENoh61AKS8WwBpJujx0uhmh?= =?us-ascii?Q?VJoDAzOOOxzXWgZwKcm363Xto85B0AsavTCfptqv2Wby1NX9FJBgTPS+LSaz?= =?us-ascii?Q?wlLKKQNcTL+ymoItaD+PP0FSjmbrN1JS/HjKyZA8VBXQTm9HqNuiKwPEZ3d4?= =?us-ascii?Q?HPNXFnxFWqtKrDnqOoTLy/ysEe6tWlwd6Z5hc6zu74sTYLj2P7qYVDdojB0D?= =?us-ascii?Q?dAvTvSExwZQdmZrJNC7qLTWLTPmh3MWQWf0BMBTxCDk7eaEzEscORR1ZjOtU?= =?us-ascii?Q?6SAHIL1xGhFqN/PFRVFyE4OieUElMYtQR2UYieE0jZUowIC2gsLoumtEiTIs?= =?us-ascii?Q?9YkdRQJc9v/sbjGHOe9LjZK7mZ/0K4/VgQixyhJwDVh4vURb58bOMpNCcJEB?= =?us-ascii?Q?a8yow1DGoH+uDQs0rrPUf+nvCRUXMUsMXnq1E5ZId6uf4H3NfrhYDxEGtOee?= =?us-ascii?Q?LkcCd+fx6JWbBRcFGbVZoSDHPE2fRmdJSVFH/lSjIeppbYfYSRnkAHpyVieT?= =?us-ascii?Q?Ebt9THI23ht+CpuCLQaabkj+15eqhaHNoH/Md9mQxb/7vgIxa3y/TWQ6RMdU?= =?us-ascii?Q?InMXI18r+Pa0rsTcqbHQqqEkxtFCK5YNKoPY8n9BDue0ZRfzjO5nZ2t3GJlX?= =?us-ascii?Q?kokR/GN/9XH/j0BpEJzLZmbUXOMOjvnVjd0kEtX3SVbRJpP4OTZ42DmqLx9C?= =?us-ascii?Q?7gWgZdbALhBIk01dLvZkzZy32ADlsZCKhcZzXPI0HkKVefkylrt1mZ54fAOP?= =?us-ascii?Q?MdFQ1Mk+ojKxCrIFQGHQ0CT+e2dSm3QXgM9JERc/mLu1Uz7/EdAfPiOO7FWN?= =?us-ascii?Q?khcF0Y0p0ZSzH6hWkSQU53H/Sln/8XjmaqRqafOczwpeJvB0J+G06fTtq25+?= =?us-ascii?Q?xmHh2gozEVrwI2AN1MVTGZOL2Z10LujtgHC/3opzS++thxJgSp70cvBZS/Wh?= =?us-ascii?Q?asyN7/beM3VjKOTl+aw/Zha5?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 847543d0-234f-44f5-a51c-08d90f9a754b X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 07:50:31.8441 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7TCv5v40zbgL/7y0bHnOI23PKpFR2D5s4qgsh8ilN/k1n/Ia6B6VRyt1xegBmhYZ9bwvR74enfoAF+35F9zkcvS6gp6X305qo14D105FPnU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6839 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=40.107.8.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, convert driver copy_range handlers parameters which are already 64bit to signed type. Now let's consider all callers. Simple git grep '\->bdrv_co_copy_range' shows the only caller: bdrv_co_copy_range_internal(), which doesn bdrv_check_request32(), so everything is OK. Still, the functions may be called directly, not only by drv->... Let's check: git grep '\.bdrv_co_copy_range_\(from\|to\)\s*=3D' | \ awk '{print $4}' | sed 's/,//' | sed 's/&//' | sort | uniq | \ while read func; do git grep "$func(" | \ grep -v "$func(BlockDriverState"; done shows no more callers. So, we are done. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 12 ++++++------ block/file-posix.c | 10 +++++----- block/iscsi.c | 12 ++++++------ block/qcow2.c | 12 ++++++------ block/raw-format.c | 16 ++++++++-------- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 38ce897972..b614db5cf9 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -313,10 +313,10 @@ struct BlockDriver { */ int coroutine_fn (*bdrv_co_copy_range_from)(BlockDriverState *bs, BdrvChild *src, - uint64_t offset, + int64_t offset, BdrvChild *dst, - uint64_t dst_offset, - uint64_t bytes, + int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flag= s, BdrvRequestFlags write_fla= gs); =20 @@ -330,10 +330,10 @@ struct BlockDriver { */ int coroutine_fn (*bdrv_co_copy_range_to)(BlockDriverState *bs, BdrvChild *src, - uint64_t src_offset, + int64_t src_offset, BdrvChild *dst, - uint64_t dst_offset, - uint64_t bytes, + int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags= ); =20 diff --git a/block/file-posix.c b/block/file-posix.c index 9771eafe5e..df1b3c98c8 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -3134,8 +3134,8 @@ static void raw_abort_perm_update(BlockDriverState *b= s) } =20 static int coroutine_fn raw_co_copy_range_from( - BlockDriverState *bs, BdrvChild *src, uint64_t src_offset, - BdrvChild *dst, uint64_t dst_offset, uint64_t bytes, + BlockDriverState *bs, BdrvChild *src, int64_t src_offset, + BdrvChild *dst, int64_t dst_offset, int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { return bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes, @@ -3144,10 +3144,10 @@ static int coroutine_fn raw_co_copy_range_from( =20 static int coroutine_fn raw_co_copy_range_to(BlockDriverState *bs, BdrvChild *src, - uint64_t src_offset, + int64_t src_offset, BdrvChild *dst, - uint64_t dst_offset, - uint64_t bytes, + int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { diff --git a/block/iscsi.c b/block/iscsi.c index 4d2a416ce7..6bcde6ec6b 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -2172,10 +2172,10 @@ static void coroutine_fn iscsi_co_invalidate_cache(= BlockDriverState *bs, =20 static int coroutine_fn iscsi_co_copy_range_from(BlockDriverState *bs, BdrvChild *src, - uint64_t src_offset, + int64_t src_offset, BdrvChild *dst, - uint64_t dst_offset, - uint64_t bytes, + int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_fla= gs, BdrvRequestFlags write_fl= ags) { @@ -2313,10 +2313,10 @@ static void iscsi_xcopy_data(struct iscsi_data *dat= a, =20 static int coroutine_fn iscsi_co_copy_range_to(BlockDriverState *bs, BdrvChild *src, - uint64_t src_offset, + int64_t src_offset, BdrvChild *dst, - uint64_t dst_offset, - uint64_t bytes, + int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flag= s) { diff --git a/block/qcow2.c b/block/qcow2.c index 5bab24d1dc..acf29277c9 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3998,9 +3998,9 @@ static coroutine_fn int qcow2_co_pdiscard(BlockDriver= State *bs, =20 static int coroutine_fn qcow2_co_copy_range_from(BlockDriverState *bs, - BdrvChild *src, uint64_t src_offset, - BdrvChild *dst, uint64_t dst_offset, - uint64_t bytes, BdrvRequestFlags read_flags, + BdrvChild *src, int64_t src_offset, + BdrvChild *dst, int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { BDRVQcow2State *s =3D bs->opaque; @@ -4081,9 +4081,9 @@ out: =20 static int coroutine_fn qcow2_co_copy_range_to(BlockDriverState *bs, - BdrvChild *src, uint64_t src_offset, - BdrvChild *dst, uint64_t dst_offset, - uint64_t bytes, BdrvRequestFlags read_flags, + BdrvChild *src, int64_t src_offset, + BdrvChild *dst, int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { BDRVQcow2State *s =3D bs->opaque; diff --git a/block/raw-format.c b/block/raw-format.c index b0fe75f54a..051b00a4d4 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -532,16 +532,16 @@ static int raw_probe_geometry(BlockDriverState *bs, H= DGeometry *geo) =20 static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs, BdrvChild *src, - uint64_t src_offset, + int64_t src_offset, BdrvChild *dst, - uint64_t dst_offset, - uint64_t bytes, + int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flag= s) { int ret; =20 - ret =3D raw_adjust_offset(bs, (int64_t *)&src_offset, bytes, false); + ret =3D raw_adjust_offset(bs, &src_offset, bytes, false); if (ret) { return ret; } @@ -551,16 +551,16 @@ static int coroutine_fn raw_co_copy_range_from(BlockD= riverState *bs, =20 static int coroutine_fn raw_co_copy_range_to(BlockDriverState *bs, BdrvChild *src, - uint64_t src_offset, + int64_t src_offset, BdrvChild *dst, - uint64_t dst_offset, - uint64_t bytes, + int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { int ret; =20 - ret =3D raw_adjust_offset(bs, (int64_t *)&dst_offset, bytes, true); + ret =3D raw_adjust_offset(bs, &dst_offset, bytes, true); if (ret) { return ret; } --=20 2.29.2 From nobody Sat May 4 04:00:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1620201278; cv=pass; d=zohomail.com; s=zohoarc; b=CvHwu0lrWprFySBZPHf+Uz9LmMpv5oHvhrnbylnu3to5z8viCVxaFo5o/6+OdF7QOvUYDHzKE+6Xzh/8ACvROTY+29Ks6a1Luz87L8A323urN341K5CzGPXm89ddzXVWbU30qhlMwW89LmnOCL+JaE4lFwo4SN3V4YDd3Zqq5qY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201278; h=Content-Type: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; bh=+AUveZ1e4j04OHAbBzQRo9qu1TofSSHQQAV2vxofMF8=; b=h6X40fBnvtlYecZ4iEQeaqFJlqf6/0UKAMhHo3Cvece3MA/q/CV07PxRc00bE9XDZVY4NrdUfeSfo1KB9DgG+f4rShCYWndMKoB1BPb6N0dnI4rbxYLI2pg4tzz8Q/WMalPRwPMARhB0VxMRkuBRDIlBJdGq4TN2INg/HhPmc7M= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine 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 1620201278472616.9562868070241; Wed, 5 May 2021 00:54:38 -0700 (PDT) Received: from localhost ([::1]:51846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leCMf-0002XG-AN for importer@patchew.org; Wed, 05 May 2021 03:54:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIz-0005rm-RZ; Wed, 05 May 2021 03:50:49 -0400 Received: from mail-eopbgr80109.outbound.protection.outlook.com ([40.107.8.109]:41697 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIt-0002WS-Gl; Wed, 05 May 2021 03:50:49 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6839.eurprd08.prod.outlook.com (2603:10a6:20b:352::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.39; Wed, 5 May 2021 07:50:33 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4108.026; Wed, 5 May 2021 07:50:33 +0000 Received: from localhost.localdomain (185.215.60.236) by HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 07:50:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JNRy5lsdUhHKTosvwW7qaWXFFJtLDgHVSNEWmN1M8pOTgA1p1UJWrG0Q/xtdef7mZqrMytBkR0UmDQilDeckyeBpff82rvq1jxR0JwbQODJ4L74jSpmS5FVZJLUW3KYIZfFToc9bT+8UH4dFe5fMuNquTB51zM/dlCOzYa1Gcd7WjoSYeTZe+gIu+Bp+ztfUvg3A5vtYHcsrQmr5kjIsZBhZtkSVn1tUHVgBqu8Bak/HU5EuP/6w/9D/ZsqxMHjMA+2p5TpiF2fnTDPNKWnXAHNKsn2eYFMLris7vE4IEqzW2KRm3kQTNnL0i9KJQlQoVL60ywo5ztDJPX3SUXAqJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+AUveZ1e4j04OHAbBzQRo9qu1TofSSHQQAV2vxofMF8=; b=JYHOD0M9gj+y4DzThGtYzMTtKfJQaI+Q6QVbkPvgfUTi9rT+T7h9xTTCi6yLJAQ67v6iM0S7o6NIAQAqzRsr7Vm0J+0U3KmKUezcHl5gtqpN8ORp9Lx3pUcCkh5bxgm5826DWIje6tQYT+EZ+opfdyerynSayGIj5jFjqWS+FMIcVeHob3UCOnmeBm6ryZ5lgsMIY/wcu8ONP+OWEZULrdl0XZH12nU3P4S5MaiUWCCHAXJDtuUkvApil+Pvn4LWbxB6mOENJohsFXKgPKMETlpvFxnS4fbtZXSs0Ku+qkDdTdsBLoag07FDJMuGZhXMnWvqLx7FmtBLLBHNaNgncQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+AUveZ1e4j04OHAbBzQRo9qu1TofSSHQQAV2vxofMF8=; b=VaCBosVJVBNeewzc1EA9c2FSrDJvN2cM6z3IK3Uh8ctCsbSI5feWJHBIMGVYKyCR/RRNGHW9+UZPRZwNXwFCtZ5eVX0vOzA2CGafwoC3JDE9q6pIIvhZriYhMHw69tZ7WjOsfJ7pcQJW77y4fMfgepLsp9ZjuVzxK2Fe0wmWovc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, stefanha@redhat.com, kwolf@redhat.com, mreitz@redhat.com, vsementsov@virtuozzo.com, Fam Zheng Subject: [PATCH v5 06/11] block: make BlockLimits::max_pwrite_zeroes 64bit Date: Wed, 5 May 2021 10:49:56 +0300 Message-Id: <20210505075001.45041-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210505075001.45041-1-vsementsov@virtuozzo.com> References: <20210505075001.45041-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.236] X-ClientProxiedBy: HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e97348ae-e597-4ea1-d62c-08d90f9a7604 X-MS-TrafficTypeDiagnostic: AS8PR08MB6839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MNTmjNgFHsLBsXUA9NRLKeiqAZ/OR1vwatMhGStojglNRuWVyrPA4ZN4Cevf71ej0zdrpJLg6nwB8nNG7kOHigFc5fD18f5uaiql1NqeIx1ULopcxf/Yer2xDzJkSUYcJ69Tc9widWOPCjv7wajZ47z2MhOPRYv7h4AU4U7DftV5AdafcaMd+VmxHM5FAuGjxHzIlNkaNuS5yaAxp4HLlSPyBMa/hhLyV7pgZNOrGH6gHnlHuLRPaoJP5wLGMEJZJHC2IsV2m5XyoGUqmQ+juY844F8YqoE15NcW6d22UJLNR9LXhQjrZnOqCvYSYa7PhO7A9WnFnptYNwz7OM3hpXm9CyTUjQ73y0qbwRebPYTQo1mo9Ml1p79pRvoho5zgcBzjT5TTofi1TrLrPW1cuORTmeBWt0xnqWnP3ehkv+t/p/eXzxO23be5AduNgOPWdCYKKjwS41IGx4Quc4TGuutBmCXOg1ZUxqC4Ys65tmZwzUKJWvy3AEahskCrE51ocGW8yuCH/epJXFs6OVwvh5pxOSVR+FgaarFWmZ8ritJhlQ8iVz3CF/eZ/a0N9Q/DRGi/kn8LbUPLoklxa9vp9Ql7sTCB3HslZIHnFweCCSeZILm0tQdWIlyA81a9laZzKTBNvztmrXTLWyQCijbEPHFGOsKsAie8Ffz892pvJ5+CdX41CZzU6xuP4gwMLPAb X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(376002)(346002)(396003)(366004)(136003)(38350700002)(38100700002)(66946007)(26005)(66556008)(6506007)(66476007)(86362001)(16526019)(83380400001)(6666004)(6916009)(4326008)(36756003)(478600001)(316002)(8676002)(6512007)(2616005)(2906002)(186003)(52116002)(956004)(6486002)(8936002)(5660300002)(1076003)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?Z4JPKApscmte0Vdmb5QdlqlNqsV99gWWXNXqlcGh66SjmR9xzG50ktoXiKbC?= =?us-ascii?Q?6g0gY33aUHDUUS9bjiEEI3J6Tv3KV1wBQ52RYVeu9kTAk17oE85WcvoSrzTv?= =?us-ascii?Q?IUGIO89aqsFjrNL18NVUBPbWNpIh3pzhGNu8d7EtXLqBi4I5r8TsIWfMHfjD?= =?us-ascii?Q?+Z9u4WxfLo5ZT3WqWQtTyCYWH8dZnlliJwZuzjXhr4YqHMCrub6lwYjb9Ws6?= =?us-ascii?Q?FfzCU3JHtSYcz11PQ4VuCqC2lBvh23cOtiurZEDj3s9qxB3RCOeawxlTyEA9?= =?us-ascii?Q?nx5bIK4KbtM3Y/EmVZr0Wmm6bkLBDWHa/O+zKEaW21laIOuDmbp1ufgkOn+t?= =?us-ascii?Q?92uOtioAWLAi4bfwyuo8TH6anOIGc/6nh+4AszQEde44g/KAX7DBVVvrt/dZ?= =?us-ascii?Q?YiRwttX/Xv5OPtPrYRUOhPOkv0PPir8A1SZ3EGxIPOPuxoN1Zw8Js0J8ctU+?= =?us-ascii?Q?QizjQ9ww4rHdASEDLfBEe5vLtryNQhRySPDYl8qssHJxG/og6lY3k0Pkb+YG?= =?us-ascii?Q?NmiZfEgZ7RFnVT/XItBicGIPdnmR2NOOsjhufF66LPseXBuq0o21o7ObDFxN?= =?us-ascii?Q?Ak7LVCDFYuTqQd2XPAynly1Sd9WzXip2otDMEbI622XoueW9RsOm3k09gnLD?= =?us-ascii?Q?Az1IlbZxnq1NXTPGktiehoB8p5eyDGwuEGZ1NSXJvWzK7qvxamalhR1GzQLN?= =?us-ascii?Q?tHULJhBTQTaaccMRbPghCtG6tTsrrCJETXPCgySYTye6IkBUJOMnnd1FoEM4?= =?us-ascii?Q?mjjX+GT6WK3FfsGTDYiMh3S5RjIq/Ym39DBOf1sKYf4OqNIG0BBwGGji5Zvg?= =?us-ascii?Q?S0C4ItlnHpZPlKKnsn3BpFMHuZMkycdehm67748hZoXQlB/25TsgBPuJWA57?= =?us-ascii?Q?iCcaEl/zkGc6FWPkzjHxI2sorGsvsTAUN9i3ocoB4TNJvhkm02eIYI438l9B?= =?us-ascii?Q?ZmlfyWpQEsHb1jBUHwRUhgsGoy6FbKwp+zS52SWQ7t5WTLYg9iJhfv48pOcn?= =?us-ascii?Q?LXOKaDH5DSABZf1X/4o1EyZaKLj1bXQoBnaeO7mn6daJ2zSZq1WQsDpEZ4Ng?= =?us-ascii?Q?N0rTeiFSfbDV4RgYY4li23tWu50MzTl//Q2pNMhXKq0F+xJeA2BT2xI83Ak6?= =?us-ascii?Q?zNjzBFWsCmUPPo8SVjcCtiJqBBhTuvP17NkYKjd5lXuMIoZnVIocXxkVDinZ?= =?us-ascii?Q?CKn5GLwtkuSTVr30rTPxJ95jjCBYF7gNeyzZRpHo1y8loA+O2Xaa01qQuYvH?= =?us-ascii?Q?GPXFKRw6cMK+VOjpbZavISJMfeBN2GyDYRGwlwzEjoUjAEXsamf0HlEXjHhX?= =?us-ascii?Q?M6ogsCzDlJnTzT3oWERuGsi2?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e97348ae-e597-4ea1-d62c-08d90f9a7604 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 07:50:33.1155 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aki4G2AcaPh777K26UIwrSJz5wqdObB3Uroaiq9M6XOa+cM6+lj8aGXHuzYAS0gRAu2ET16TkeanN0JpoyeDNULkTzPj3LEcfGvpr+I7SMA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6839 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=40.107.8.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are going to support 64 bit write-zeroes requests. Now update the limit variable. It's absolutely safe. The variable is set in some drivers, and used in bdrv_co_do_pwrite_zeroes(). Update also max_write_zeroes variable in bdrv_co_do_pwrite_zeroes(), so that bdrv_co_do_pwrite_zeroes() is now prepared to 64bit requests. The remaining logic including num, offset and bytes variables is already supporting 64bit requests. So the only thing that prevents 64 bit requests is limiting max_write_zeroes variable to INT_MAX in bdrv_co_do_pwrite_zeroes(). We'll drop this limitation after updating all block drivers. Ah, we also have bdrv_check_request32() in bdrv_co_pwritev_part(). It will be modified to do bdrv_check_request() for write-zeroes path. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 9 +++++---- block/io.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index b614db5cf9..1f93a38a23 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -676,10 +676,11 @@ typedef struct BlockLimits { * that is set. May be 0 if bl.request_alignment is good enough */ uint32_t pdiscard_alignment; =20 - /* Maximum number of bytes that can zeroized at once (since it is - * signed, it must be < 2G, if set). Must be multiple of - * pwrite_zeroes_alignment. May be 0 if no inherent 32-bit limit */ - int32_t max_pwrite_zeroes; + /* + * Maximum number of bytes that can zeroized at once. Must be multiple= of + * pwrite_zeroes_alignment. May be 0 if no inherent 64-bit limit. + */ + int64_t max_pwrite_zeroes; =20 /* Optimal alignment for write zeroes requests in bytes. A power * of 2 is best but not mandatory. Must be a multiple of diff --git a/block/io.c b/block/io.c index 448251beaa..0648561b15 100644 --- a/block/io.c +++ b/block/io.c @@ -1863,7 +1863,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(Bloc= kDriverState *bs, int head =3D 0; int tail =3D 0; =20 - int max_write_zeroes =3D MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MA= X); + int64_t max_write_zeroes =3D MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, IN= T_MAX); int alignment =3D MAX(bs->bl.pwrite_zeroes_alignment, bs->bl.request_alignment); int max_transfer =3D MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFF= ER); --=20 2.29.2 From nobody Sat May 4 04:00:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1620201834; cv=pass; d=zohomail.com; s=zohoarc; b=hjDmSf/XRfowkCqV9E7EqQBZ0d18C5IfJqnZB2KRLfcXb5wCFdPrSfwxZJe5m70KnSjT3JSg6BZWkddKaKoOt+XFvrmHrnAqVOVRjNUpnt042bPtv5qaUS9vlL1nFy6VLItfiVxv342IppvVp5wN5jH/f1I+/BdVkpuGftLTJdg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201834; h=Content-Type: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; bh=lRc3qnU31UcxuxG4xM+cGmaQL71Oxg1IGriu+Z9Bh+8=; b=ZFW2XoIJekZmxgsrELIRtY0g73WAkIBDD+Cr5w0r5sxDVP922pdGY1IFJiSagpC6Nv3JibZu7nklYYoVekuaw4HTYozTLvoWA9MnXpsISSypDBDqwfCTfbzjZG8fNShry8mKBgkw9fWpV2SE+UzlhLDOwSrpgZR+RH6ID9xr4Lc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine 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 1620201834522836.6118836580829; Wed, 5 May 2021 01:03:54 -0700 (PDT) Received: from localhost ([::1]:45998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leCVd-0003uj-A7 for importer@patchew.org; Wed, 05 May 2021 04:03:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCJ2-0005w2-1z; Wed, 05 May 2021 03:50:52 -0400 Received: from mail-db8eur05on2090.outbound.protection.outlook.com ([40.107.20.90]:42592 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIv-0002eS-Pp; Wed, 05 May 2021 03:50:51 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6839.eurprd08.prod.outlook.com (2603:10a6:20b:352::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.39; Wed, 5 May 2021 07:50:35 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4108.026; Wed, 5 May 2021 07:50:35 +0000 Received: from localhost.localdomain (185.215.60.236) by HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 07:50:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MYjyeX9qc6PM+2CDVY4rSqceQXmvVGM/q48fI3lYVanccEr616ZMt+/WywM0Fio3V4aM13OYCtLUlU88m3PWr9l4jataPGMqNsXXHY0l/QoiCUhJevNzF8t+HhY9KP1EqrNDaFCa+FKUpkn8XSlh28lir+wGNk2cjm0WBDMFOyu9veJV24YXAFsB+OdX26Sz6Z3ASthixtRmQqNASFjwG08v6ZdBlybn0TDs+2ru+L1gyd9DbmLOzq+1Be0PJay9gF0jL/rghAq2RvvtB1YgcXK8b0ScKrQ57p0z49sxmFYSYcj0IoVyLG1XFvMfGWppdi3aePx7/c0If7jgGmt/rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lRc3qnU31UcxuxG4xM+cGmaQL71Oxg1IGriu+Z9Bh+8=; b=lDjJWFfZ5PtCIjBx3jRQBcg8xm1uv3y0r6mfez/3u7RUc3K0zvs3MCJXdtZgUJH/6dR2dzXrts/V22DpG0cqgCk+IwxYFOSINRnxz7CezAepWp38YP8qA61P/lIOQSZ6lnzm9rR3PF1+QbGhZzVcIEE33mu7LrZe5E/9SIy6kUbLbO7CwToNuVgZMW2ajB1U0yUIKv2m3eWgsmRYNxo1uV6EDNKgZ7FeBzaBPj+JT63eQSSSByBMOr+Nog6KUZdLcxrDm1a9cDj4h20a3NDhIOtlfFm2/B6uqwvI3Ztoz02FsSkv+yUsxRleY3DOOukzk/pxKtEcrDfTiDu7vbXZ+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lRc3qnU31UcxuxG4xM+cGmaQL71Oxg1IGriu+Z9Bh+8=; b=P7bM73tgxNG/+TufS3T8xY8ODt8Xl5RB49N6yWa3AYnP9xy2oyEjMiitoVGj6b83TkoeQh2M5/YiQtplVk5GOWT5ruS566chWY8gYzneNqvOLrlgYuBuzpbc5XGGdq6XjJIUgN3XqDcsClojsqMq6BXf6RqtwgsV2bqZ5G1bAuI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, stefanha@redhat.com, kwolf@redhat.com, mreitz@redhat.com, vsementsov@virtuozzo.com, John Snow , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , Ronnie Sahlberg , Peter Lieven , Fam Zheng , Alberto Garcia , integration@gluster.org (open list:GLUSTER) Subject: [PATCH v5 07/11] block: use int64_t instead of int in driver write_zeroes handlers Date: Wed, 5 May 2021 10:49:57 +0300 Message-Id: <20210505075001.45041-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210505075001.45041-1-vsementsov@virtuozzo.com> References: <20210505075001.45041-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.236] X-ClientProxiedBy: HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 654d5f05-817a-4420-971e-08d90f9a7735 X-MS-TrafficTypeDiagnostic: AS8PR08MB6839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AwG29hwQKIOelajnt7xC7MJRQjvqyX0VCZTDpt9b/IA+uVtCGwUi40SgBh6QhSqBjYCTOKjqqARQcVJN62RPZOwz5gGsOiwV1UWiHVI1a3DTfzuvHZxOy8k4ITwYFpW1Vo6qJjB83ykhMwIiH51D1q9Hrok3XTjpN0P5qvdd5IMLCz3hurFaPQC17DORsID1aB/fDTVYLdz6q9bf2JACCCzLs/+RW//MnrB7nveTDK6KtSiJEozQ3cDSllj78fi1XpF1wXnHlsgb+PQ5d6U5d9Nh0Q2GUZjTLeqeUCa+hpL5FdJERRiKZI0bij6BU//LMwaAcy9k8i3ZZ6Pl5bYvnaHfiQXk960MaQe6od7qQYwyA2uQCfO1q00D+p1CFrkSNULPR9DlzL+37+V3nkFFcsSrgbHJLJS45ifviIeVQOvCo9NFpLnSeVzvzMFQUYArFMwsUQgkKPUATIFLhyBopZw+mt3YRIor9CbqbOWHq0Dr8KoTcTXSQJ9Gcey/ro4aarYOV3SkI3h1IZSgtSMbPUWbPkzVQWFK6kYcATEwOUut2DRseHtImb69k/e1U/Z+G1YX7CwUjm5Ulv4b7w6hqYC9oug1BVBaYtpq0ZnrrFeY5HSaySVZp2lWqLVjU9KzLnnoMmyvhKxE5jKu0rHYGM/csbjjU5mGm3HQGFzEim4wtnxI94YtnokW+D8nBiaL X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(376002)(346002)(396003)(366004)(136003)(38350700002)(38100700002)(66946007)(26005)(66556008)(6506007)(66476007)(86362001)(16526019)(30864003)(83380400001)(6666004)(7416002)(54906003)(6916009)(4326008)(36756003)(478600001)(316002)(8676002)(6512007)(2616005)(2906002)(186003)(52116002)(956004)(6486002)(8936002)(5660300002)(1076003)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?FDlzSs/u0mkBl/pgT0BKV5hNmJm/ucOfY6VmQyj5MOLLAxOpL3+oq+7AKIEf?= =?us-ascii?Q?Fl/RRy1V60Gh0hBpzFi8XXb10WA/LcBF2qiTwADs5U6PedccTzw1QohoTv6U?= =?us-ascii?Q?yropIllEKMk8FDy7TXtzMY9qd0eQm1iurRQnKJE8YEMl/93txkjR+Ib+4Z5l?= =?us-ascii?Q?LGy007E/bDIf37Kpkwd3wBN8ll+3cDUFKHOL1+u7EQMSf9o0sZ98Cj7KkKip?= =?us-ascii?Q?ZYNX+VqEF2QAm9ncO/2nROQU/En4r9iMZ0nfMB7Ofv/YVPs68eKMLTv2gprJ?= =?us-ascii?Q?6D30s4LmJdnLoZqAbOkN/ipaFa071l0vmT9SjfIxWbKM26OJrE5szugeb/p6?= =?us-ascii?Q?D3MgMnYzQxX9+65MzuZxZtXqOPiMfODg/VXtcXvh8mHwc6NEwCdEfdBpBM8A?= =?us-ascii?Q?L0A8hZGLRabCC4eXcEjqCQ4V3VgxRb0UkXTobrZh0El9g9bVYL+WXMQfzNZ7?= =?us-ascii?Q?7j+n9jrECOm1Eox9m5NruDAVid/Vx1sSMJxnXfWtBwwKjwnVzVV/SP1STTsT?= =?us-ascii?Q?gesDhXXz4zpsN8lNCX4VYyJG6LQVlAmYCNZBLB/zp97/phqx0c8KrmAtX5pC?= =?us-ascii?Q?t5D8dusStAGVvOqWVBvokxpAMKhQo50NWiwRq39UnCY3XPZdChacYpV8bNSH?= =?us-ascii?Q?sc5bP5mxL9h5rVQEiTzAZIHiP2pLk2hEDav+txTxJ3ZCm3vZqQnQIB1J78rn?= =?us-ascii?Q?3JtBRkaYoGjGnBOSN9aGUTkWz3jXJ3ArPWhxZrtS4BeHSab7n9B4YxTPbTGe?= =?us-ascii?Q?SPGYkzP/fEg4WqMy5lbHOiZzrcapY79oqNtVURVF3RkNVGE4I3/8j4tCWNOm?= =?us-ascii?Q?tI4ZR5X8NBQtqmGiysqkeyNHukpYgGrwkqdDgvG8lcbw/PK0IRQ4gmcRTCoO?= =?us-ascii?Q?vBIH/+N4U1zBqeQFpYwoDHvnr8/odlQloGX0YTKBzqbRCrVfyPoMvGbtH6A2?= =?us-ascii?Q?EV7feQsBUM0xIOVWah2mlg0vzlOpV+9BKac5jdjdJvOzJXWhD5IQ7XAdIo0q?= =?us-ascii?Q?/T1LR/WndbWUJ/UKvQ7bdJAn4k0Hd1RRz3z6LNnHB1G+1cGU5RXXfEp4BlE1?= =?us-ascii?Q?WiJWTqhu/HmHs7QOIdyB2Vkf1KmmdCoFJTlirchun9XhRcVTLcRQ7WZ1GIQ+?= =?us-ascii?Q?tpGqp57ck8178zgpE3nQmqTHOjOq77Cof9z8SAWQIq6Ow+oAljnDpFvDCOus?= =?us-ascii?Q?Axyo8+zhm9ULmAflyiddtEYzkLlhQr8WaaFx6bXntlEE5qrXVCR9vINKsCJ/?= =?us-ascii?Q?8Rwr85a+SE1Smf6VS4aW/bS6s3O3oHVYYBDzI0KBaLsS2ARu8P0oLLh+NQrc?= =?us-ascii?Q?Ph+VujwvvRCxF+suapDaRSSO?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 654d5f05-817a-4420-971e-08d90f9a7735 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 07:50:35.1595 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: f5GqnnM5zunHitcVmIjWYl8g/FX5u6Vet8Y3PTgMjHDXyRaIQXUFYSgId4wm5KI0LFoSRxVYkASOKckH8nGbKk5Cczdsr0CGW2sOxpN8xgI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6839 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=40.107.20.90; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, convert driver write_zeroes handlers bytes parameter to int64_t. The only caller of all updated function is bdrv_co_do_pwrite_zeroes(). bdrv_co_do_pwrite_zeroes() itself is of course OK with widening of callee parameter type. Also, bdrv_co_do_pwrite_zeroes()'s max_write_zeroes is limited to INT_MAX. So, updated functions all are safe, the will not get "bytes" larger than before. Still, let's look through all updated functions, and add assertions to the ones which are actually unprepared to values larger than INT_MAX. For these drivers also set explicit max_pwrite_zeroes limit. Let's go: backup-top: Calls backup_top_cbw() and bdrv_co_pwrite_zeroes, both have 64bit argument. blkdebug: calculations can't overflow, thanks to bdrv_check_qiov_request() in generic layer. rule_check() and bdrv_co_pwrite_zeroes() both have 64bit argument. blklogwrites: pass to blk_log_writes_co_log() with 64bit argument. blkreply, copy-on-read, filter-compress: pass to bdrv_co_pwrite_zeroes() wh= ich is OK file-posix: both handler calls raw_do_pwrite_zeroes, which is updated. In raw_do_pwrite_zeroes() calculations are OK due to bdrv_check_qiov_request(), bytes go to RawPosixAIOData::aio_nbytes which is uint64_t. gluster: bytes go to GlusterAIOCB::size which is int64_t and to glfs_zerofill_async works with off_t. iscsi: Aha, here we deal with iscsi_writesame16_task() that has uint32_t num_blocks argument and iscsi_writesame16_task() has uint16_t argument. Make comments, add assertions and clarify max_pwrite_zeroes calculation. iscsi_allocmap_() functions already has int64_t argument is_byte_request_lun_aligned is simple to update, do it. mirror_top: pass to bdrv_mirror_top_do_write which has uint16_t argument nbd: Aha, here we have protocol limitation, and NBDRequest::len is uint32_t. max_pwrite_zeroes is cleanly set to 32bit value, so we are OK for now. nvme: Again, protocol limitation. And no inherent limit for write-zeroes at all. But from code that calculates cdw12 it's obvious that we do have limit and alignment. Let's clarify it. Also, obviously the code is not prepared to bytes=3D0. Let's handle this case too. trace events already 64bit qcow2: offset + bytes and alignment still works good (thanks to bdrv_check_qiov_request()), so tail calculation is OK qcow2_subcluster_zeroize() has 64bit argument, should be OK trace events updated qed: qed_co_request wants int nb_sectors. Also in code we have size_t used for request length which may be 32bit.. So, let's just keep INT_MAX as a limit (aligning it down to pwrite_zeroes_alignment) and don't care. raw-format: Is OK. raw_adjust_offset and bdrv_co_pwrite_zeroes are both 64bit. throttle: Both throttle_group_co_io_limits_intercept() and bdrv_co_pwrite_zeroes() are 64bit. vmdk: pass to vmdk_pwritev which is 64bit quorum: pass to quorum_co_pwritev() which is 64bit preallocated: pass to handle_write() and bdrv_co_pwrite_zeroes(), both 64bit. Hooray! At this point all block drivers are prepared to 64bit write-zero requests or has explicitly set max_pwrite_zeroes. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/block/block_int.h | 2 +- block/backup-top.c | 2 +- block/blkdebug.c | 2 +- block/blklogwrites.c | 4 ++-- block/blkreplay.c | 2 +- block/copy-on-read.c | 2 +- block/file-posix.c | 6 +++--- block/filter-compress.c | 2 +- block/gluster.c | 6 +++--- block/iscsi.c | 31 +++++++++++++++++++++---------- block/mirror.c | 2 +- block/nbd.c | 6 ++++-- block/nvme.c | 24 +++++++++++++++++++++--- block/preallocate.c | 2 +- block/qcow2.c | 2 +- block/qed.c | 9 ++++++++- block/quorum.c | 2 +- block/raw-format.c | 2 +- block/throttle.c | 2 +- block/vmdk.c | 2 +- block/trace-events | 4 ++-- 21 files changed, 77 insertions(+), 39 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 1f93a38a23..5734f44e59 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -300,7 +300,7 @@ struct BlockDriver { * will be called instead. */ int coroutine_fn (*bdrv_co_pwrite_zeroes)(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags); + int64_t offset, int64_t bytes, BdrvRequestFlags flags); int coroutine_fn (*bdrv_co_pdiscard)(BlockDriverState *bs, int64_t offset, int bytes); =20 diff --git a/block/backup-top.c b/block/backup-top.c index 6834921092..f193cc549c 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -75,7 +75,7 @@ static int coroutine_fn backup_top_co_pdiscard(BlockDrive= rState *bs, } =20 static int coroutine_fn backup_top_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { int ret =3D backup_top_cbw(bs, offset, bytes, flags); if (ret < 0) { diff --git a/block/blkdebug.c b/block/blkdebug.c index a7fedd80fd..c81cb9cb1a 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -667,7 +667,7 @@ static int blkdebug_co_flush(BlockDriverState *bs) } =20 static int coroutine_fn blkdebug_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int byte= s, + int64_t offset, int64_t = bytes, BdrvRequestFlags flags) { uint32_t align =3D MAX(bs->bl.request_alignment, diff --git a/block/blklogwrites.c b/block/blklogwrites.c index ca174ab135..d7ae64c22d 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -468,8 +468,8 @@ blk_log_writes_co_pwritev(BlockDriverState *bs, int64_t= offset, int64_t bytes, } =20 static int coroutine_fn -blk_log_writes_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int = bytes, - BdrvRequestFlags flags) +blk_log_writes_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, + int64_t bytes, BdrvRequestFlags flags) { return blk_log_writes_co_log(bs, offset, bytes, NULL, flags, blk_log_writes_co_do_file_pwrite_zeroes, = 0, diff --git a/block/blkreplay.c b/block/blkreplay.c index 7ba62dcac1..89d74a3cca 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -94,7 +94,7 @@ static int coroutine_fn blkreplay_co_pwritev(BlockDriverS= tate *bs, } =20 static int coroutine_fn blkreplay_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { uint64_t reqid =3D blkreplay_next_id(); int ret =3D bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 7675565080..758a5d44d5 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -206,7 +206,7 @@ static int coroutine_fn cor_co_pwritev_part(BlockDriver= State *bs, =20 =20 static int coroutine_fn cor_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); diff --git a/block/file-posix.c b/block/file-posix.c index df1b3c98c8..6114bdd308 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2905,7 +2905,7 @@ raw_co_pdiscard(BlockDriverState *bs, int64_t offset,= int bytes) } =20 static int coroutine_fn -raw_do_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bytes, +raw_do_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes, BdrvRequestFlags flags, bool blkdev) { BDRVRawState *s =3D bs->opaque; @@ -2973,7 +2973,7 @@ raw_do_pwrite_zeroes(BlockDriverState *bs, int64_t of= fset, int bytes, =20 static int coroutine_fn raw_co_pwrite_zeroes( BlockDriverState *bs, int64_t offset, - int bytes, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags flags) { return raw_do_pwrite_zeroes(bs, offset, bytes, flags, false); } @@ -3544,7 +3544,7 @@ hdev_co_pdiscard(BlockDriverState *bs, int64_t offset= , int bytes) } =20 static coroutine_fn int hdev_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { int rc; =20 diff --git a/block/filter-compress.c b/block/filter-compress.c index 505822a44f..fb85686b69 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -86,7 +86,7 @@ static int coroutine_fn compress_co_pwritev_part(BlockDri= verState *bs, =20 =20 static int coroutine_fn compress_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int byte= s, + int64_t offset, int64_t = bytes, BdrvRequestFlags flags) { return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); diff --git a/block/gluster.c b/block/gluster.c index e8ee14c8e9..6a17b37c0c 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -1003,19 +1003,19 @@ static void qemu_gluster_reopen_abort(BDRVReopenSta= te *state) #ifdef CONFIG_GLUSTERFS_ZEROFILL static coroutine_fn int qemu_gluster_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int size, + int64_t bytes, BdrvRequestFlags fla= gs) { int ret; GlusterAIOCB acb; BDRVGlusterState *s =3D bs->opaque; =20 - acb.size =3D size; + acb.size =3D bytes; acb.ret =3D 0; acb.coroutine =3D qemu_coroutine_self(); acb.aio_context =3D bdrv_get_aio_context(bs); =20 - ret =3D glfs_zerofill_async(s->fd, offset, size, gluster_finish_aiocb,= &acb); + ret =3D glfs_zerofill_async(s->fd, offset, bytes, gluster_finish_aiocb= , &acb); if (ret < 0) { return -errno; } diff --git a/block/iscsi.c b/block/iscsi.c index 6bcde6ec6b..b90ed67377 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -427,14 +427,14 @@ static int64_t sector_qemu2lun(int64_t sector, IscsiL= un *iscsilun) return sector * BDRV_SECTOR_SIZE / iscsilun->block_size; } =20 -static bool is_byte_request_lun_aligned(int64_t offset, int count, +static bool is_byte_request_lun_aligned(int64_t offset, int64_t bytes, IscsiLun *iscsilun) { - if (offset % iscsilun->block_size || count % iscsilun->block_size) { + if (offset % iscsilun->block_size || bytes % iscsilun->block_size) { error_report("iSCSI misaligned request: " "iscsilun->block_size %u, offset %" PRIi64 - ", count %d", - iscsilun->block_size, offset, count); + ", bytes %" PRIi64, + iscsilun->block_size, offset, bytes); return false; } return true; @@ -1205,15 +1205,16 @@ out_unlock: =20 static int coroutine_fn iscsi_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags flags) { IscsiLun *iscsilun =3D bs->opaque; struct IscsiTask iTask; uint64_t lba; - uint32_t nb_blocks; + uint64_t nb_blocks; bool use_16_for_ws =3D iscsilun->use_16_for_rw; int r =3D 0; =20 + if (!is_byte_request_lun_aligned(offset, bytes, iscsilun)) { return -ENOTSUP; } @@ -1250,11 +1251,21 @@ coroutine_fn iscsi_co_pwrite_zeroes(BlockDriverStat= e *bs, int64_t offset, iscsi_co_init_iscsitask(iscsilun, &iTask); retry: if (use_16_for_ws) { + /* + * iscsi_writesame16_task num_blocks argument is uint32_t. We rely= here + * on our max_pwrite_zeroes limit. + */ + assert(nb_blocks < UINT32_MAX); iTask.task =3D iscsi_writesame16_task(iscsilun->iscsi, iscsilun->l= un, lba, iscsilun->zeroblock, iscsilun-= >block_size, nb_blocks, 0, !!(flags & BDRV_= REQ_MAY_UNMAP), 0, 0, iscsi_co_generic_cb, &iT= ask); } else { + /* + * iscsi_writesame10_task num_blocks argument is uint16_t. We rely= here + * on our max_pwrite_zeroes limit. + */ + assert(nb_blocks < UINT16_MAX); iTask.task =3D iscsi_writesame10_task(iscsilun->iscsi, iscsilun->l= un, lba, iscsilun->zeroblock, iscsilun-= >block_size, nb_blocks, 0, !!(flags & BDRV_= REQ_MAY_UNMAP), @@ -2074,10 +2085,10 @@ static void iscsi_refresh_limits(BlockDriverState *= bs, Error **errp) bs->bl.pdiscard_alignment =3D iscsilun->block_size; } =20 - if (iscsilun->bl.max_ws_len < 0xffffffff / block_size) { - bs->bl.max_pwrite_zeroes =3D - iscsilun->bl.max_ws_len * iscsilun->block_size; - } + bs->bl.max_pwrite_zeroes =3D + MIN_NON_ZERO(iscsilun->bl.max_ws_len * iscsilun->block_size, + max_xfer_len * iscsilun->block_size); + if (iscsilun->lbp.lbpws) { bs->bl.pwrite_zeroes_alignment =3D iscsilun->bl.opt_unmap_gran * iscsilun->block_size; diff --git a/block/mirror.c b/block/mirror.c index fdf477a0fd..f0a3eac216 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1479,7 +1479,7 @@ static int coroutine_fn bdrv_mirror_top_flush(BlockDr= iverState *bs) } =20 static int coroutine_fn bdrv_mirror_top_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { return bdrv_mirror_top_do_write(bs, MIRROR_METHOD_ZERO, offset, bytes,= NULL, flags); diff --git a/block/nbd.c b/block/nbd.c index d3de441c2b..bf56735e4a 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1630,15 +1630,17 @@ static int nbd_client_co_pwritev(BlockDriverState *= bs, int64_t offset, } =20 static int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offse= t, - int bytes, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags fla= gs) { BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; NBDRequest request =3D { .type =3D NBD_CMD_WRITE_ZEROES, .from =3D offset, - .len =3D bytes, + .len =3D bytes, /* .len is uint32_t actually */ }; =20 + assert(bytes < UINT32_MAX); /* relay on max_pwrite_zeroes */ + assert(!(s->info.flags & NBD_FLAG_READ_ONLY)); if (!(s->info.flags & NBD_FLAG_SEND_WRITE_ZEROES)) { return -ENOTSUP; diff --git a/block/nvme.c b/block/nvme.c index 349c152ab5..51fc65fc91 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1266,19 +1266,29 @@ static coroutine_fn int nvme_co_flush(BlockDriverSt= ate *bs) =20 static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, + int64_t bytes, BdrvRequestFlags flags) { BDRVNVMeState *s =3D bs->opaque; NVMeQueuePair *ioq =3D s->queues[INDEX_IO(0)]; NVMeRequest *req; - - uint32_t cdw12 =3D ((bytes >> s->blkshift) - 1) & 0xFFFF; + uint32_t cdw12; =20 if (!s->supports_write_zeroes) { return -ENOTSUP; } =20 + if (bytes =3D=3D 0) { + return 0; + } + + cdw12 =3D ((bytes >> s->blkshift) - 1) & 0xFFFF; + /* + * We should not loose information. pwrite_zeroes_alignment and + * max_pwrite_zeroes guarantees it. + */ + assert(((cdw12 + 1) << s->blkshift) =3D=3D bytes); + NvmeCmd cmd =3D { .opcode =3D NVME_CMD_WRITE_ZEROES, .nsid =3D cpu_to_le32(s->nsid), @@ -1442,6 +1452,14 @@ static void nvme_refresh_limits(BlockDriverState *bs= , Error **errp) bs->bl.opt_mem_alignment =3D s->page_size; bs->bl.request_alignment =3D s->page_size; bs->bl.max_transfer =3D s->max_transfer; + + /* + * Look at nvme_co_pwrite_zeroes: after shift and decrement we should = get + * at most 0xFFFF + */ + bs->bl.max_pwrite_zeroes =3D 1ULL << (s->blkshift + 16); + bs->bl.pwrite_zeroes_alignment =3D MAX(bs->bl.request_alignment, + 1UL << s->blkshift); } =20 static void nvme_detach_aio_context(BlockDriverState *bs) diff --git a/block/preallocate.c b/block/preallocate.c index c19885af17..99e28d9f08 100644 --- a/block/preallocate.c +++ b/block/preallocate.c @@ -337,7 +337,7 @@ static bool coroutine_fn handle_write(BlockDriverState = *bs, int64_t offset, } =20 static int coroutine_fn preallocate_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { bool want_merge_zero =3D !(flags & ~(BDRV_REQ_ZERO_WRITE | BDRV_REQ_NO_FALLBACK)); diff --git a/block/qcow2.c b/block/qcow2.c index acf29277c9..59c5137410 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3913,7 +3913,7 @@ static bool is_zero(BlockDriverState *bs, int64_t off= set, int64_t bytes) } =20 static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { int ret; BDRVQcow2State *s =3D bs->opaque; diff --git a/block/qed.c b/block/qed.c index f45c640513..09773c584b 100644 --- a/block/qed.c +++ b/block/qed.c @@ -582,6 +582,7 @@ static void bdrv_qed_refresh_limits(BlockDriverState *b= s, Error **errp) BDRVQEDState *s =3D bs->opaque; =20 bs->bl.pwrite_zeroes_alignment =3D s->header.cluster_size; + bs->bl.max_pwrite_zeroes =3D QEMU_ALIGN_DOWN(INT_MAX, s->header.cluste= r_size); } =20 /* We have nothing to do for QED reopen, stubs just return @@ -1397,7 +1398,7 @@ static int coroutine_fn bdrv_qed_co_writev(BlockDrive= rState *bs, =20 static int coroutine_fn bdrv_qed_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, + int64_t bytes, BdrvRequestFlags flags) { BDRVQEDState *s =3D bs->opaque; @@ -1408,6 +1409,12 @@ static int coroutine_fn bdrv_qed_co_pwrite_zeroes(Bl= ockDriverState *bs, */ QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, NULL, bytes); =20 + /* + * QED is not prepared for 62bit write-zero requests, so rely on + * max_pwrite_zeroes. + */ + assert(bytes <=3D INT_MAX); + /* Fall back if the request is not aligned */ if (qed_offset_into_cluster(s, offset) || qed_offset_into_cluster(s, bytes)) { diff --git a/block/quorum.c b/block/quorum.c index 353401ac08..772de80a77 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -746,7 +746,7 @@ static int quorum_co_pwritev(BlockDriverState *bs, int6= 4_t offset, } =20 static int quorum_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags flags) =20 { return quorum_co_pwritev(bs, offset, bytes, NULL, diff --git a/block/raw-format.c b/block/raw-format.c index 051b00a4d4..4e9304c63b 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -289,7 +289,7 @@ static int coroutine_fn raw_co_block_status(BlockDriver= State *bs, } =20 static int coroutine_fn raw_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { int ret; diff --git a/block/throttle.c b/block/throttle.c index 1330e844c3..c13fe9067f 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -135,7 +135,7 @@ static int coroutine_fn throttle_co_pwritev(BlockDriver= State *bs, } =20 static int coroutine_fn throttle_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int byte= s, + int64_t offset, int64_t = bytes, BdrvRequestFlags flags) { ThrottleGroupMember *tgm =3D bs->opaque; diff --git a/block/vmdk.c b/block/vmdk.c index 8d49e54bdd..fb4cc9da90 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2109,7 +2109,7 @@ vmdk_co_pwritev_compressed(BlockDriverState *bs, int6= 4_t offset, int64_t bytes, =20 static int coroutine_fn vmdk_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, + int64_t bytes, BdrvRequestFlags flags) { int ret; diff --git a/block/trace-events b/block/trace-events index 3cbea9e2e2..3edd2899c2 100644 --- a/block/trace-events +++ b/block/trace-events @@ -80,8 +80,8 @@ qcow2_writev_done_req(void *co, int ret) "co %p ret %d" qcow2_writev_start_part(void *co) "co %p" qcow2_writev_done_part(void *co, int cur_bytes) "co %p cur_bytes %d" qcow2_writev_data(void *co, uint64_t offset) "co %p offset 0x%" PRIx64 -qcow2_pwrite_zeroes_start_req(void *co, int64_t offset, int count) "co %p = offset 0x%" PRIx64 " count %d" -qcow2_pwrite_zeroes(void *co, int64_t offset, int count) "co %p offset 0x%= " PRIx64 " count %d" +qcow2_pwrite_zeroes_start_req(void *co, int64_t offset, int64_t bytes) "co= %p offset 0x%" PRIx64 " bytes %" PRId64 +qcow2_pwrite_zeroes(void *co, int64_t offset, int64_t bytes) "co %p offset= 0x%" PRIx64 " bytes %" PRId64 qcow2_skip_cow(void *co, uint64_t offset, int nb_clusters) "co %p offset 0= x%" PRIx64 " nb_clusters %d" =20 # qcow2-cluster.c --=20 2.29.2 From nobody Sat May 4 04:00:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1620201425; cv=pass; d=zohomail.com; s=zohoarc; b=EqYfjh1kp43zD8cSbDxNy8of2M0/cztp2QwUpue+NKFKni6Vhb/u7CHXVwHurBmuBbVUXpgIdzODm/M71t3jCL11fbRdEMCl3nMYiwNcpk+Loqe8AptgE05rAWmmO0LI3ZYniE/tQd/TozwDSzWbYJvXMxujaZO2FtAT/ripdd8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201425; h=Content-Type: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; bh=lyTu4G1ABqa2GqOxkDz/PheUnnxvT6/B+ecXhi0G2h8=; b=W1kof5btUiLJ+v2E7lx/JoIfBW/pKVhz53YiT+QVzGJTupR7xYvqwmXQOPwZFknpwILL5d85CEFbi995m2HUAtpfvXig+ATNrw68WRl8eZxVhrn/KTddg4DEvx89Q1EtOu2ACslTbvEmWCIZeajng8T17c90SUOCSjybMNwF+Ng= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine 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 1620201425012886.3250358413256; Wed, 5 May 2021 00:57:05 -0700 (PDT) Received: from localhost ([::1]:56532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leCP0-0004W5-6f for importer@patchew.org; Wed, 05 May 2021 03:57:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCJ3-0005zR-E7; Wed, 05 May 2021 03:50:53 -0400 Received: from mail-eopbgr80109.outbound.protection.outlook.com ([40.107.8.109]:41697 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCJ0-0002WS-Hn; Wed, 05 May 2021 03:50:53 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6839.eurprd08.prod.outlook.com (2603:10a6:20b:352::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.39; Wed, 5 May 2021 07:50:36 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4108.026; Wed, 5 May 2021 07:50:36 +0000 Received: from localhost.localdomain (185.215.60.236) by HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 07:50:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AlVgLPDMbA/LrvOwyd/B/99fFHy/DiQwftWTzgIPSY7O6d3Vs4wzKF6W/z9jcpEhBooBuhLTZgfgbyXZ3iKeOMuac9zPa61QLO/L+OHD64ayz7uyjnra4SXgDFkFpGdcxHACnzfDK19nip87HcHsFIS+y2n399e30q0Hy/+itmQzQvNUPNyGuhv0Zr2RDzsbQWuorifRTfGoBcybwCzCozj3N8Vo73E2MjZ9R9NLoGrM0i2NT7ky59d6549t/DEh55W3PsLcpoxP6sp+eEgdGHbLvvmvRPE2NAjJvWsDYsZyPnl0u7GkfYtwQ8111oYNyxlkeFWcbY1SZNSCkQOQbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lyTu4G1ABqa2GqOxkDz/PheUnnxvT6/B+ecXhi0G2h8=; b=SsKwxfW/n8Chb/3+PIF5MYyqiq2zCddB6V7Y9LYzjOh2Q/9VxKj//5DwNl/3Fsk1spuMHrus6+sWXlzpnm61W0D1Cu7NpqNwwyPlo9Zvi7YMLA8Tkpi5BsNxWcFlY5VPXwfenz/HvphNvKivTkYOMEyY/uiFSi4YxtCOU//XnnuSQiEiy1eNX7oOqRGAsOAw3QGzcS7Mw7OZareIs/iSOy6U9mSpe0OgIGUIdsiJB0L3tTLIaAaLV1aB/Sbo5OXQ0y5+UTvP5axXxAPWNEdRpAFb8fXDhF3I/nqmS4o0M0G/CQ+clcqvHSksXa/8ppEZbaVCI3WmBwSp4AYHIsCcVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lyTu4G1ABqa2GqOxkDz/PheUnnxvT6/B+ecXhi0G2h8=; b=e56+3Qa1n+cKALTseJny78UGYp/Bx63y21QyAkk8+ytU+p6zFUhgMe+zSEm+TejahgzG8WVJ/lWnUNr+gibNiyO4UnGYBR2QRUySyD0MPM8DuaJUPJV0Sr0viKjeQj7z2OwqS4fEI2UfBs5JvNjJSi9YE+phH0fHDTgnplaXaEc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, stefanha@redhat.com, kwolf@redhat.com, mreitz@redhat.com, vsementsov@virtuozzo.com, Fam Zheng Subject: [PATCH v5 08/11] block/io: allow 64bit write-zeroes requests Date: Wed, 5 May 2021 10:49:58 +0300 Message-Id: <20210505075001.45041-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210505075001.45041-1-vsementsov@virtuozzo.com> References: <20210505075001.45041-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.236] X-ClientProxiedBy: HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9ad032f5-7ef0-4ab6-7e46-08d90f9a77ff X-MS-TrafficTypeDiagnostic: AS8PR08MB6839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:154; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2LL5QXOk+etyfh9Hyxk6WMxxU4OAkTtIm+ZIYwti6/d9sft7uqo55UffwnwJ7EEmQNubhWvok3R7OMMTTiYUewB00jbJpyEaJOLZ59sZuZF9yx7G7ailocco/a0r2GcBRCw1fh2WjAd2vSY3pGQf72SaPlN26Xx0Sk4zxJkXaFwMrVHQmSUXlNDOZaHmqvbXNi4evGzH+J70OYcFVUKukCaKOTydP8nODs2yd93lUPz6jqdm2FxOaWfrqE6hL9G9o92KpIiJAFCNSMb0Fa0DfcUV1IbKEhzdxPXXgIs6gGafuwcr5DJYGpLMYxIdzA9fW68imoh3W72wXv/Bzrw9FHfzwRODuj4Z33O7UuyBRXE39m0vxAcT85Kfb/cC7J54dfRwNQlxNiQN6omG9vF9hjwBJ5MKUMhhK3lLsZ4542PHfH9c2loBJ/TbYD+7YaLBN0t6x3Mud6g+icWYrr4BdUOUOsw6wY7taWlfcsQoj6mdPGhifZatTSaJ2PUvBLs9sEWDSqPwxKxMoW7+q0ZqffMqHJgkf289JnGGlYNLVL+lMzU9En96V+Mw/5fsNGsFntDRR0839av0pOlqcea+TkP1rB4Y59h6Txu6zT/tsGcPIpFKfoXL4cTPBHV+6t99obXLNKvC1EvIUQ4WHu4NcQX1XrKp+oOO/tGMRWGwVoYGkEJEFtZ7p69aK9aYlkzX X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(376002)(346002)(396003)(366004)(136003)(38350700002)(38100700002)(66946007)(26005)(66556008)(6506007)(66476007)(86362001)(16526019)(83380400001)(6666004)(6916009)(4326008)(36756003)(478600001)(316002)(8676002)(6512007)(2616005)(2906002)(186003)(52116002)(956004)(6486002)(8936002)(5660300002)(1076003)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?QNxUMEYNqiTavKgeEkOVUPpFEB06itGmsE2P9RpAHnlcs83scD6rqj4jIjCh?= =?us-ascii?Q?H3KWH/tucxuddf/60PJEnX7qVClBU2I+VNsC8J1bK8a/hz24EBiPYlxBn3kw?= =?us-ascii?Q?y01tjo15WG32h5TBVPWyiw0dZTCPHufOJw51ni7SyMsZJcWMp9LztgdLLv/8?= =?us-ascii?Q?k9Ag28DQ3KdMblOmsVYPS3597ySQEpfU7T/9v/ByC4j8DTDRwfns5NtzQ9zz?= =?us-ascii?Q?0eQr+Yk8oVzP8g2hhjZF3+4irgT6l08w3duV9I2NuOXvp00S4r8HcJ5rUBma?= =?us-ascii?Q?SxZq35Tx/tKy8s6pwGHvZ0rdPnvhGqlp5hEZF0QTAQHeHG7eEKS7JVujCSSN?= =?us-ascii?Q?p8isjt0iYHtDcgl1XHW0JcorFR7IsHnuUUm6JJxgjHp3tvE5V5J+TLHLC0ge?= =?us-ascii?Q?lxfwgYNOQDIkXrPs9DvIC4cIvi0AuJuW2BJEhSe4lLYRM1Q3PtV4M7rWpvhh?= =?us-ascii?Q?3jF6dUWJVucTt3CwJn4YpKOVEned9qNWtt2Dg+KFnnp2qV0FvpinlLFasWtR?= =?us-ascii?Q?WDpWoSWMQmMDPq+DUfUeuHnOT3XNKBux4f7hQ72Y1MZxV//LEc19Vo60giWu?= =?us-ascii?Q?6oabwj8cZjR9SpKFCCKaizFOKgzgDA9YTzOWbBOxa9HlzGZbCujFrtOThumj?= =?us-ascii?Q?1Lb2GYL4DP1nJhKOWgtgjn2YJm+/4XM6XYij5D3nwzQ4VHiv+zy+FoYvtADg?= =?us-ascii?Q?69HJEH6Uf2cJIu2zAIB3HIf9acMnBbKhoTCCHbzUwBUZz3x92ydFgEunm/Bv?= =?us-ascii?Q?YdGC42xastFoPl9o54B1+kEi30ciSNcbLf49Aqiz7kcay+8/GnxE1hHXB20z?= =?us-ascii?Q?Svn2wo0kqyllzUC1eJ822wnpKNeqTPojyIkSxwLuU+dYDUvHth8Q9GVRr+Cr?= =?us-ascii?Q?3Y6omYZjQLUxS/vK3Ud9WLpj90q3csfADpXxE5kYrvJS+e/lxnAd6QCOIK5t?= =?us-ascii?Q?rFvIZcTcLLL9xGX8s63aLgMgWDo82LoSPtBP8oK9fHRAYyFwXT/o/zks67i8?= =?us-ascii?Q?e7wAbAWGCWA3zi03qqRc3ekJuxyXqsTL8t47IfZh6sx5EXGsXNXgGQjWMSc8?= =?us-ascii?Q?TjLMnWc7fG21rZRx+odRBrPVaSjb+xd4RH0+ReCknHRGqCu8kPZBjgM3DwKA?= =?us-ascii?Q?9m1wMdgvKyWezgltCbkRMn6+GMCt+jXs+7QxMAAx5unpmOGiqMucd9Qvy3o3?= =?us-ascii?Q?TJsjbkyEvSRat07kOYWwHixny/IJp4FH04tAVcD0tGYwlotgPv8FRTxsIBVW?= =?us-ascii?Q?rpE0pze3hmmkghSft/HBbGqGLRRRnFcbiTMVdRRbbWe37RmNrV2QdzMs/Tj4?= =?us-ascii?Q?jAtTXZ8OxqPbdCpHHF73D7MM?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ad032f5-7ef0-4ab6-7e46-08d90f9a77ff X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 07:50:36.3991 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OLR98B8zSeH7TNEfg3DsZxpVQfcPWL7i1c+AuOqpXGXYBYk7JtF8+Tlmx7xNuBPj6A5MWAuda6CCHygPnRFypkIbTB0U9WLbBbihZSwOIb4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6839 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=40.107.8.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" Now, when all drivers are updated by previous commit, we can drop two last limiters on write-zeroes path: INT_MAX in bdrv_co_do_pwrite_zeroes() and bdrv_check_request32() in bdrv_co_pwritev_part(). Now everything is prepared for implementing incredibly cool and fast big-write-zeroes in NBD and qcow2. And any other driver which wants it of course. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/io.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index 0648561b15..195b68b19e 100644 --- a/block/io.c +++ b/block/io.c @@ -1863,7 +1863,8 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(Bloc= kDriverState *bs, int head =3D 0; int tail =3D 0; =20 - int64_t max_write_zeroes =3D MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, IN= T_MAX); + int64_t max_write_zeroes =3D MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, + INT64_MAX); int alignment =3D MAX(bs->bl.pwrite_zeroes_alignment, bs->bl.request_alignment); int max_transfer =3D MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFF= ER); @@ -2239,7 +2240,11 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *chi= ld, return -ENOMEDIUM; } =20 - ret =3D bdrv_check_request32(offset, bytes, qiov, qiov_offset); + if (flags & BDRV_REQ_ZERO_WRITE) { + ret =3D bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, = NULL); + } else { + ret =3D bdrv_check_request32(offset, bytes, qiov, qiov_offset); + } if (ret < 0) { return ret; } --=20 2.29.2 From nobody Sat May 4 04:00:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1620201604; cv=pass; d=zohomail.com; s=zohoarc; b=DtIH5aS2Sx5Cztd24xAuha0gE5NgRXhZii77LkymHwWCEgA3aDE2oubHIGbyceWcrm6IOWDBnGDtoWU3ouDvu3aiSPSXeBfRVKQH49xcCeVs348LaQAZ3S3s0tcBcwYNT0VG/LR87RY9jV+5ZwMIJIk52oWEIkDPoNvzAYxaaH4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201604; h=Content-Type: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; bh=H6mLkofIWm2Uvt7XQGokzAyAnODP0LsXy+zPcVOxcvI=; b=CQVxpaLvcDorI2am8f4VNtlSPAfpRw5KxUnd17+joEgfx77irRL65lfdRIXgg6xwb+jEZA8u90Vd/gPCpuU7pydhmJ5KYrXfkjWyELqXq9BUgEGAQvQhYNkt/sq0qXIXA9OV00nYiBA1zi1QWxAicdNAqPFSzJEpheMVl9Ry8xA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine 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 1620201604411597.3871941828801; Wed, 5 May 2021 01:00:04 -0700 (PDT) Received: from localhost ([::1]:36306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leCRr-0007xw-9n for importer@patchew.org; Wed, 05 May 2021 03:59:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCJ5-000639-0t; Wed, 05 May 2021 03:50:55 -0400 Received: from mail-db8eur05on2090.outbound.protection.outlook.com ([40.107.20.90]:42592 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCJ2-0002eS-Sy; Wed, 05 May 2021 03:50:54 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6839.eurprd08.prod.outlook.com (2603:10a6:20b:352::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.39; Wed, 5 May 2021 07:50:37 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4108.026; Wed, 5 May 2021 07:50:37 +0000 Received: from localhost.localdomain (185.215.60.236) by HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 07:50:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UP3wDthk9vfOI4p43Xr09OfiMcu/NZdSMmS3FRsO8gk8e4THIhcC0F+Pt7to12jDiMDSZoQEt1MWytwq8QQmes3IzEB/So03UDVcgHSpyxWC7/FPWjUNUZxMwrdm5SDiIuwGR9dRid6pUtSoRtmuPXvW9Ld+krCVAV0nVSHqvlOsSa0nlhKAXlMkmTwmsr9AG75EEbpjF+Ehxo48tszBPVFLM/ZHgqycfAZ1FK2D3wFmCJDfwBw1VhdDvQxjUw+UrNFLe/0zcsAs3zuoo75k7uTNVf+8wiP0Z+tmJ47NqS56Sbc6+6FfMFz81dk8WF/in6JVduQVmB0DJWsQus5tRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H6mLkofIWm2Uvt7XQGokzAyAnODP0LsXy+zPcVOxcvI=; b=PXT1+dGzIjPUD7ykjTKd9RTFngS9csOkd2qrk4Bcbfl621FqTXy8RmreavJ3NmGnHK9utYpkTpviGZSJZEeAgYDMuOzZREAo8rv0pMiLR7ieOrvYB8UxDEOWuGgW9fGXqUuiEwm5AqmZc0tHA8Y+8IXh2+tRFztiqYv0j9pm07nyKFH/S2HUuDsSqZQYS4HhIuLN9sYER9XXb5jS7uNhOR21an3UrC1zDibH5kF3CKpwv+HruW1qN4n0FcIzmYmq3GjbceCZ+lSZE7W0g9UZrUGDbYM22gbuXRZEqj8y/hJxWta+s6bMWlfVtCLHsqE+dcEFH3klpXSVB1AmMkeioA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H6mLkofIWm2Uvt7XQGokzAyAnODP0LsXy+zPcVOxcvI=; b=eBSgsBQ+P74HYUrKnOpcppXXmn/RAiaq/JQpN/EVJbWQe6I1d5ohiksL80TXIZ8G6h1OGCg76W/j0A+yCZv8+e9ff/6y/bvq3IU+xgE5VCgJBXKgEvhZUNfbul/sWSLCT/gZe1sbd9D1Gs+mTq7ACZCZvWOnhwdFVcxiXfT0QDU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, stefanha@redhat.com, kwolf@redhat.com, mreitz@redhat.com, vsementsov@virtuozzo.com, Fam Zheng Subject: [PATCH v5 09/11] block: make BlockLimits::max_pdiscard 64bit Date: Wed, 5 May 2021 10:49:59 +0300 Message-Id: <20210505075001.45041-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210505075001.45041-1-vsementsov@virtuozzo.com> References: <20210505075001.45041-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.236] X-ClientProxiedBy: HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3463dfb1-2f27-4eb8-a87e-08d90f9a78ae X-MS-TrafficTypeDiagnostic: AS8PR08MB6839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UKjQnU/MRCciPI6Vmn5FHg+7Xhk2DCKLkfRUNsJnbFZVYTxIYYhSuXXmTROqKlFrOcz+EmXbif+zlwDy/+upPDq5pfGakU9eXsEjXStmLo7Uolx8CEhWp8UP8GT3rlqXH6Oly61mg6KUAbl9ExU58fKEc5MtlFmsfSBS95nhckzxayBA+IO6k+WFB7ky5XJua3kC5YuTAJbkzo4Q3YFxfJU6ya6LbF7a3Cd2lYfIYLiQ+7gwY09DtuMg8OWZe5qmHgLgOw+qR5DfrmTiiYzJR2IFC0vviK57MyBQIqakLygv/N4C2fZjOR47C6sj4RHUd4Jc+X5Wuh7N1P9zcQkZH8sXI+L0wCI8+F/BogRF+QJbPhOuTWRNOKIWCmtX5d7NKOV+H/T8EGS61mveyRV+4ibqdiWGbdZ/lQ1HMTap2CX/AjHRSKLt1VUwOzL77eB9BfJuAVEHJrokd4XSOK2cs636rhceVfId4ePsWjr5fQ+8yIAWVHOh1kczW/X5Ep6zxGOTqfWQyg93ZyspcnP3j3773aeKmV+DDPWy9aBbEPHnGV28/W9UKIDFnlP9laGfwxfpMWg9cusDlKcYmNivQ6pOGIXZ39iyCKvv5xXI7iGKwy5710kdIZVao9joC3X0jMdZkezWotxQ8BhihG82k44hspbQCzwqmZwPx6a4210O2p5WTiCQjq9NbYtv0s0f X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(376002)(346002)(396003)(366004)(136003)(38350700002)(38100700002)(66946007)(26005)(66556008)(6506007)(66476007)(86362001)(16526019)(83380400001)(6666004)(6916009)(4326008)(36756003)(478600001)(316002)(8676002)(6512007)(2616005)(2906002)(186003)(52116002)(956004)(6486002)(8936002)(5660300002)(1076003)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?qbdkKghc6LlIMZ31ysHoeSfk7zgpsUPYSluh+oUAXBPTn2iCdv1uiht0X2bB?= =?us-ascii?Q?6bzXUrcKP5vVq5Og138vY98Tpk/ZB820/kmmzK2NJlixue3z/aWu8gOX1kLj?= =?us-ascii?Q?69CVXCx4xGuEVfyrV8ooHlR+jABQQ36EX8lhqNlTdCfQjW8H9boKo/oDHlVZ?= =?us-ascii?Q?kHiCYTtTY6iOBpORO84Ts8+kNFBXJAjot7eR1IJTEfz17N11rSKO8XMdchNE?= =?us-ascii?Q?RZvW7MZMoD6T0WCqv7xUlu884nPkC5ipXzol8bRQA26lghXYtDUnp6Zwwn/R?= =?us-ascii?Q?xS7Y6bGT91oB/YEbBiLDqY8c2+MKByXDbEV9DMqWsSfSBiC7DvWZ0rc9/f50?= =?us-ascii?Q?pCjMf2vttmc1IBnaXNbEZoNYK1qKEXtYLPc9GYz4amno1ey7v2gzCt6zcFZL?= =?us-ascii?Q?mhGfhYe/WrTp7jftzvN4S2i3SjzEsOd8E+YWckwQ7gsT5E2s9yNRuF55ypJO?= =?us-ascii?Q?52BxcK6+Br/4/l2nJouZljSKFHRaZy/MUQZxcKFE81v/mc3KMX8C3IDXoZ1W?= =?us-ascii?Q?O8PUEmEbpBXwPbkB0yOgKiQrLDNeuffuH20cZo+Fyn3AqyIPKQBgHmRXJk/J?= =?us-ascii?Q?WWk5UHmlCJG8P0VosdPAotsATfqx1e461AhB/V9fjLIy8z2M2P6UHX0/T/8o?= =?us-ascii?Q?kTOP0NYGbqobhBbj+XK7D6ygNJ7aDAdBfrLaxxFMbM0CngYbF3XJRa7HTSDd?= =?us-ascii?Q?WPxzkX0jHNu0oppnnLVJD/+/OOnWxb18k1C82RbED6axc/Itvnd2MMN/gJ0B?= =?us-ascii?Q?2ELO1IzagnKYcbQfWYoFE7ox2UUd4jSPQq+7lLmUywMZ+LqgKDany3kZrHoH?= =?us-ascii?Q?kTOtAxmWPVwbZr9GlCGUC6NaGldvBnGVhg1WwRD4GECXU2VbeyeQ98hVjf0W?= =?us-ascii?Q?AffuXWzr0bFKAr6VPWXiauzc+oCrtKcNjJXUBssETVVQKmDZPWQn5W80vqCY?= =?us-ascii?Q?76LfCUY3B2to1S/++h4MI+8u354hYePz5g1cIhVliTkz/0sbZU20r90cLOJ/?= =?us-ascii?Q?Aa/qlL44JPxAybl+QHnjMUp4uhMZcG8Xn0GkuGbe/yc9GeM2hms1HctYtmN3?= =?us-ascii?Q?S+TTFTKWJ/C9c975Bm9wOcZf1pG9Gs0H9HuC5GVVeeBE3kL4A5kygltnEX2t?= =?us-ascii?Q?yRBjqEkK1LWquCwSi1Rp+aprnqfZSJoTs/pASWBcA/UjVT9Dh0ZVPHMWHyqS?= =?us-ascii?Q?JkgAe5cApTD0UAjZM4gRNXH3grXI1s86MmxUt8JmpIXuidz7ds7HXglYZAbF?= =?us-ascii?Q?IbYpZrkHmE8J/FOA/iy9Am7Nb87hpyLwt5VXSY21+4O+Oo0HTTePIGRcgdHI?= =?us-ascii?Q?9+hJys8h1uxth1kns7v/cHel?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3463dfb1-2f27-4eb8-a87e-08d90f9a78ae X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 07:50:37.4843 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: M2ioGtV3NSS0nvEYVixdY2TRhb5WDI3pWX2gISlPGpOrXRTdO24Emtj5bDNSpMg6hg8SeRSSSpRjvhtazubBVWZukx/g6XiFD1ypE03MtQ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6839 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=40.107.20.90; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are going to support 64 bit discard requests. Now update the limit variable. It's absolutely safe. The variable is set in some drivers, and used in bdrv_co_pdiscard(). Update also max_pdiscard variable in bdrv_co_pdiscard(), so that bdrv_co_pdiscard() is now prepared to 64bit requests. The remaining logic including num, offset and bytes variables is already supporting 64bit requests. So the only thing that prevents 64 bit requests is limiting max_pdiscard variable to INT_MAX in bdrv_co_pdiscard(). We'll drop this limitation after updating all block drivers. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/block/block_int.h | 11 ++++++----- block/io.c | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 5734f44e59..cb36ba93a6 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -664,11 +664,12 @@ typedef struct BlockLimits { * otherwise. */ uint32_t request_alignment; =20 - /* Maximum number of bytes that can be discarded at once (since it - * is signed, it must be < 2G, if set). Must be multiple of - * pdiscard_alignment, but need not be power of 2. May be 0 if no - * inherent 32-bit limit */ - int32_t max_pdiscard; + /* + * Maximum number of bytes that can be discarded at once. Must be mult= iple + * of pdiscard_alignment, but need not be power of 2. May be 0 if no + * inherent 64-bit limit. + */ + int64_t max_pdiscard; =20 /* Optimal alignment for discard requests in bytes. A power of 2 * is best but not mandatory. Must be a multiple of diff --git a/block/io.c b/block/io.c index 195b68b19e..a7edb1ef54 100644 --- a/block/io.c +++ b/block/io.c @@ -2991,7 +2991,8 @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, i= nt64_t offset, int64_t bytes) { BdrvTrackedRequest req; - int max_pdiscard, ret; + int ret; + int64_t max_pdiscard; int head, tail, align; BlockDriverState *bs =3D child->bs; =20 --=20 2.29.2 From nobody Sat May 4 04:00:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1620201171; cv=pass; d=zohomail.com; s=zohoarc; b=l4JfsuFVmE+cNH2x+YIDBRkqXp7wHofC4bdTrbXsZ/epZUUcTjyP7MeGeAsFVd5k46kTRxwWzDZyy+oVVFMKRbSAcZuXDQQV+qvVsZHY9ghBcrgdF/54ldE/vuDy5cKjjyJe8IZnVnmqZtO8Nvunw8n5cabAJfJ4xhwmj8nutBo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201171; h=Content-Type: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; bh=HkFYxOJGNrSMCABwC//GmN8DEC5NH7pMqwE/1SVAyhY=; b=hfZymD6G1NpL+6vFIM1E38wOqUsPT1lvAe0Dzhn3j74ptnHEVmy5dnQnr65M5HvZawm8LN8muGR28HG/ICRQVCs+jn7WtYw1Yyxks7f4/QX1Zzb0yKjQjy37usS38PDkiWpHkLuebyIAOtFMJCq02N9/T353E+/s+itxIlnssNM= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine 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 1620201170856783.3611708696122; Wed, 5 May 2021 00:52:50 -0700 (PDT) Received: from localhost ([::1]:43622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leCKv-0007b5-LK for importer@patchew.org; Wed, 05 May 2021 03:52:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIw-0005km-Mq; Wed, 05 May 2021 03:50:46 -0400 Received: from mail-eopbgr10116.outbound.protection.outlook.com ([40.107.1.116]:51367 helo=EUR02-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIt-0002fG-4d; Wed, 05 May 2021 03:50:46 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6551.eurprd08.prod.outlook.com (2603:10a6:20b:319::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.38; Wed, 5 May 2021 07:50:39 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4108.026; Wed, 5 May 2021 07:50:39 +0000 Received: from localhost.localdomain (185.215.60.236) by HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 07:50:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EzW2qKhmB/uIgtRKntGRj1eYEkCc52Kkm3NJIaVV06eNwcM4gIa/+dMkbdWuZHDx30AuGIQNgIP67RGu8RnYw1RRwjpf41NQLh1isLrNaoeMLleuqAwXKexfe9Ml0tdDADSltOYuCHjHXlzf2V6pfUkako0A1pOdTDBuGN2uPr41oovsYylUEApBW5nBOsR9ohADNzhw3MsroRkHNVkVZE86V/WON3uciXRQBykmRY+vg6fgOXaqoa6JQ7gYLoZSLF8W/izuJJbHgDdXr2wMNeboZvoXNAFYSBtXPRM2p+TpWM4hR4kM8DQ0zHKjqBFrrclhvXW4cpz5UNfIBQtF/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HkFYxOJGNrSMCABwC//GmN8DEC5NH7pMqwE/1SVAyhY=; b=kEYm39Ow7/isAk7yhzbKD5BvqgklVNVcK50GOElcVC1JjZDjMyD6D+/XsXWjCjpZxL43SknO0aY0dIgTSmD7IJjLjnN2XUPbppcmBiHXWuOE81TwnHl/1uHtbpTnGATU8mmsMeTlg8Q3SdBTx1+c6sucsChZlAYv0FYdRUkGTPFa+qcAXvelXyk1BE0a1nJpDX5nLp88e3vX6NNoQiRZhd3nEgtpbDkNjO8TFbUAlNpg+kqLz5jBQ13Y/i+0YB0xQlr3C3Yr6jnscd/K/C5OobAL/ofCmq54yveIcpaoxzGrPcm0twJFMyLHOxK2rWY6EY6TmjYmEotPmQ2+OENeGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HkFYxOJGNrSMCABwC//GmN8DEC5NH7pMqwE/1SVAyhY=; b=LxjdYI1OjakLiN/eHPTRQJV/mKBHXFzV8bUQpvwnLMPi3VGyz1wna6siSkbeb481kG4Adr/3zaEMFOvNQmtaYxNOBXF1khixDWU3Yv2CmEOMaB1grVcBFSDdyEqLD/YrHp/+AxgKEV7w8fe/bu/JPvYa1v0+xBfx/lGxuN+Rrt4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, stefanha@redhat.com, kwolf@redhat.com, mreitz@redhat.com, vsementsov@virtuozzo.com, John Snow , Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , Ronnie Sahlberg , Peter Lieven , Fam Zheng , Liu Yuan , integration@gluster.org (open list:GLUSTER) Subject: [PATCH v5 10/11] block: use int64_t instead of int in driver discard handlers Date: Wed, 5 May 2021 10:50:00 +0300 Message-Id: <20210505075001.45041-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210505075001.45041-1-vsementsov@virtuozzo.com> References: <20210505075001.45041-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.236] X-ClientProxiedBy: HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7fae10d3-9655-4570-144d-08d90f9a79c9 X-MS-TrafficTypeDiagnostic: AS8PR08MB6551: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2I7hAHA1P0l8Tg5AlelprL4m9qUqRCOU0K387ppTnBQuXwbAgHf/OxntEahtPmX9+GevEMfMXJmF1iZUCGqE1Fjdq9HTXnyfsn9W0O4AamRx0Hx42T1a8OxBp+SIeEogb9uYakrDQt0iQ2yaxkAdqOP9VJoGLVD3e22A92dwxWFodAw5vv0w854/q7juAeSSo5/CH76JkDdmlOaAcvwqfDs0MDgF7pxqDhTi4miUwN5TG/gO89Rg1MdmOQleXfTe0n7AsET+9DhhDVQey2hYZjLvsfuOPD8R5fIiwbXLdQQE76Rn47lGy3ZpmwUDJTA87zLAsPR7u0YEsBX+qufa7Ji/LeBu6cRe5UyS8FleQ9wvO7SyQA+AsFsNnR1UaBO/aDRUE0AwdYUcyHRkRkrr8quKYqZbSOY9pyoaxslNVrWs0KeMA2UtBq3loHVG1ZHs08t308JVdkyEJV5rg4ysFKFDc1rUpJ0ool3rE0zXlwHGz8DB3kofx9x5g17iigfrPJFL7eDeKqTmQTRLW9jM7P3Cv9RkTy7Eu9S5hSS0b03lN41QQML9xjZxcsbON8VSNe8tZA3zCNmz2s4YESy4oUig3suZxC5mtsxT+EczmkI9GvoqWocebsUl/JLYRvVFq0uZ+6wVjfdoF4b8NI4etDWoFEqVPisAXufhMMvyHNNX0s8uPePP+0J1P/QDrAN8 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(366004)(136003)(39840400004)(346002)(376002)(2616005)(5660300002)(1076003)(26005)(38350700002)(86362001)(66946007)(52116002)(38100700002)(54906003)(6512007)(66556008)(956004)(36756003)(66476007)(2906002)(6916009)(83380400001)(6506007)(6486002)(4326008)(316002)(478600001)(16526019)(8936002)(186003)(8676002)(6666004)(30864003)(7416002)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?4pQQ21vmQPh2jHQdcRCyhXFd5KDUjUJPQRiRNqZ1w99MJomjfOmfFkRBzQvl?= =?us-ascii?Q?ccQtxRqTh2kU8KUVfDfpauoBsmQ5X8cUscliVvLMCo8muqmaK1GoomDoWY/n?= =?us-ascii?Q?JuC015S+cqd5eviCt2PXxBxLXg8jGX3JlTRFRyKJ8GoTSdygiABuZS0xtamg?= =?us-ascii?Q?flZLsXdrdj1ecoBefXhvILPuABQdKzYVOZTu43+/Njrq+5hS2K0Cfzx34UX8?= =?us-ascii?Q?XQ95hJMurwbhEdFfcN5tjuLRghAoidL6dQP91kZsJbBpcK3GpzIe7skQ1Gjh?= =?us-ascii?Q?E0xUTTzb+KuxgCSlcVVWAZ5NyI8rgakt19TcCmTO5uH0xbLmMZPWHW+uGmwX?= =?us-ascii?Q?W0aVO6H2aZ1I/gKGoDVBzl++LJS08ZXhVcel/SLZCLqnmalYW0b0b5UuH2E2?= =?us-ascii?Q?mN23w1MDCu1QTshpZ9HzQgJv9LJlF2YAY1tfuzwZDJqLcr8D3vszZNq9oLKc?= =?us-ascii?Q?s7tVZM8LAC7M0fJH1t0T3XdbStdjtEC7YXuOuJaLKgzBU9RFAdlzhE/Whqln?= =?us-ascii?Q?BsDmikWK4Qm8EMmVut+9qVafEMrbDBmrMJcoUZhCastSWvv/z9R9BvIRQ9Ym?= =?us-ascii?Q?fg4/zZGvlT4cUNhay6Y3kNiYTXYp2MKkU8W4jdSiSFQczIKhXTc6EAMjwVjk?= =?us-ascii?Q?ii/szEDEih9eTZiK/gt32JP17slGSBlBjivNP9n70HKQA/SIWHaIOutkMSP6?= =?us-ascii?Q?2E9IW3+kbo+QXjW/+QzKt2xzlNuL2nMPQYSM6ttr7gmpHEQrEh3ewBpu/G9p?= =?us-ascii?Q?Ue0YoMrG5rw8Rq69kRYVo+LLHFxqXQskR4LN2My7/jZvZcr8xw79S9tfk23a?= =?us-ascii?Q?HGzjU/X7CUmU7qXGpzu8DY/ndfi1kTUywBfQwzWnnUTU8f6TDtOPe1iRx919?= =?us-ascii?Q?X/b18CqBA30ccylEqcxBXfgxu+ZYXNoUgWL2bKXSPG7edQd9cZGK7hWD6Yab?= =?us-ascii?Q?YHqdXNgxgx313NQVONykSA75R4XC3fxfKd1x90nzS5j6eJESBfShORk+3I1D?= =?us-ascii?Q?RMD7exATNLzvOFpulSA64LXfmM3iSfMTkUEGYCvfjv3vCofjpjb66eVpGjwS?= =?us-ascii?Q?INEB/eJjLO9zbJ8sAfYS62UP2WWOzvQzbINmVfib4kN9h0/V7fNenFNgCVSs?= =?us-ascii?Q?A/PZED3pr3WBiElG6t4N8RdwwIEeD6i009IifJfcg8bamP6qSkTS0OS0zaRd?= =?us-ascii?Q?A8BJ4OXZckoVBTC89urNHRbu31lGumJ08AmOTgbusCgc1L2oSJWBBGopPtNa?= =?us-ascii?Q?AhIx8U48huPjQyu2GULQsbWo/LrVrJPfh7mEG0xLwfJPi2W5BhS2zbbMhTCw?= =?us-ascii?Q?ymC14A/2hjSf8ynK6j2IbMCx?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7fae10d3-9655-4570-144d-08d90f9a79c9 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 07:50:39.3332 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TLB3V3huJIgbu34hGy5zTuaLmQe4N9TQ1HrNc3UHBc0UuulKQRNexPOk2I2JE2TTsiy2W0jd2txSXAVgpE+A07LgeUzcuysXBhlvR6/iMog= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6551 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=40.107.1.116; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, convert driver discard handlers bytes parameter to int64_t. The only caller of all updated function is bdrv_co_pdiscard in block/io.c. It is already prepared to work with 64bit requests, but pass at most max(bs->bl.max_pdiscard, INT_MAX) to the driver. Let's look at all updated functions: backup-top: pass to bdrv_co_pdiscard which is 64bit blkdebug: all calculations are still OK, thanks to bdrv_check_qiov_request(). both rule_check and bdrv_co_pdiscard are 64bit blklogwrites: pass to blk_loc_writes_co_log which is 64bit blkreply, copy-on-read, filter-compress: pass to bdrv_co_pdiscard, OK file-posix: one handler calls raw_account_discard() is 64bit and both handlers calls raw_do_pdiscard(). Update raw_do_pdiscard, which pass to RawPosixAIOData::aio_nbytes, which is 64bit (and calls raw_account_discard()) gluster: somehow, third argument of glfs_discard_async is size_t. Let's set max_pdiscard accordingly. iscsi: iscsi_allocmap_set_invalid is 64bit, !is_byte_request_lun_aligned is 64bit. list.num is uint32_t. Let's clarify max_pdiscard and pdiscard_alignment. mirror_top, preallocate: pass to bdrv_mirror_top_do_write() which is 64bit nbd: protocol limitation. max_pdiscard is alredy set strict enough, keep it as is for now. nvmd: buf.nlb is uint32_t and we do shift. So, add corresponding limits to nvme_refresh_limits(). qcow2: calculations are still OK, thanks to bdrv_check_qiov_request(), qcow2_cluster_discard() is 64bit. raw-format: raw_adjust_offset() is 64bit, bdrv_co_pdiscard too. sheepdog: the format is deprecated. Don't care and just make old INT_MAX limit to be explicit throttle: pass to bdrv_co_pdiscard() which is 64bit and to throttle_group_co_io_limits_intercept() which is 64bit as well. test-block-iothread: bytes argument is unused Great! Now all drivers are prepared to 64bit discard requests or has explicit max_pdiscard limit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 2 +- block/backup-top.c | 2 +- block/blkdebug.c | 2 +- block/blklogwrites.c | 4 ++-- block/blkreplay.c | 2 +- block/copy-on-read.c | 2 +- block/file-posix.c | 7 ++++--- block/filter-compress.c | 2 +- block/gluster.c | 7 +++++-- block/iscsi.c | 10 +++++----- block/mirror.c | 2 +- block/nbd.c | 6 ++++-- block/nvme.c | 14 +++++++++++++- block/preallocate.c | 2 +- block/qcow2.c | 2 +- block/raw-format.c | 2 +- block/sheepdog.c | 15 ++++++++++++++- block/throttle.c | 2 +- tests/unit/test-block-iothread.c | 2 +- block/trace-events | 4 ++-- 20 files changed, 61 insertions(+), 30 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index cb36ba93a6..adc5ea12cc 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -302,7 +302,7 @@ struct BlockDriver { int coroutine_fn (*bdrv_co_pwrite_zeroes)(BlockDriverState *bs, int64_t offset, int64_t bytes, BdrvRequestFlags flags); int coroutine_fn (*bdrv_co_pdiscard)(BlockDriverState *bs, - int64_t offset, int bytes); + int64_t offset, int64_t bytes); =20 /* Map [offset, offset + nbytes) range onto a child of @bs to copy fro= m, * and invoke bdrv_co_copy_range_from(child, ...), or invoke diff --git a/block/backup-top.c b/block/backup-top.c index f193cc549c..45240aef9e 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -64,7 +64,7 @@ static coroutine_fn int backup_top_cbw(BlockDriverState *= bs, uint64_t offset, } =20 static int coroutine_fn backup_top_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t byt= es) { int ret =3D backup_top_cbw(bs, offset, bytes, 0); if (ret < 0) { diff --git a/block/blkdebug.c b/block/blkdebug.c index c81cb9cb1a..2d98a33982 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -700,7 +700,7 @@ static int coroutine_fn blkdebug_co_pwrite_zeroes(Block= DriverState *bs, } =20 static int coroutine_fn blkdebug_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { uint32_t align =3D bs->bl.pdiscard_alignment; int err; diff --git a/block/blklogwrites.c b/block/blklogwrites.c index d7ae64c22d..f7a251e91f 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -484,9 +484,9 @@ static int coroutine_fn blk_log_writes_co_flush_to_disk= (BlockDriverState *bs) } =20 static int coroutine_fn -blk_log_writes_co_pdiscard(BlockDriverState *bs, int64_t offset, int count) +blk_log_writes_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t b= ytes) { - return blk_log_writes_co_log(bs, offset, count, NULL, 0, + return blk_log_writes_co_log(bs, offset, bytes, NULL, 0, blk_log_writes_co_do_file_pdiscard, LOG_DISCARD_FLAG, false); } diff --git a/block/blkreplay.c b/block/blkreplay.c index 89d74a3cca..dcbe780ddb 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -105,7 +105,7 @@ static int coroutine_fn blkreplay_co_pwrite_zeroes(Bloc= kDriverState *bs, } =20 static int coroutine_fn blkreplay_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t byte= s) { uint64_t reqid =3D blkreplay_next_id(); int ret =3D bdrv_co_pdiscard(bs->file, offset, bytes); diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 758a5d44d5..c29cfdd10e 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -214,7 +214,7 @@ static int coroutine_fn cor_co_pwrite_zeroes(BlockDrive= rState *bs, =20 =20 static int coroutine_fn cor_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { return bdrv_co_pdiscard(bs->file, offset, bytes); } diff --git a/block/file-posix.c b/block/file-posix.c index 6114bdd308..6959e2feba 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2875,7 +2875,8 @@ static void raw_account_discard(BDRVRawState *s, uint= 64_t nbytes, int ret) } =20 static coroutine_fn int -raw_do_pdiscard(BlockDriverState *bs, int64_t offset, int bytes, bool blkd= ev) +raw_do_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes, + bool blkdev) { BDRVRawState *s =3D bs->opaque; RawPosixAIOData acb; @@ -2899,7 +2900,7 @@ raw_do_pdiscard(BlockDriverState *bs, int64_t offset,= int bytes, bool blkdev) } =20 static coroutine_fn int -raw_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) +raw_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes) { return raw_do_pdiscard(bs, offset, bytes, false); } @@ -3530,7 +3531,7 @@ static int fd_open(BlockDriverState *bs) } =20 static coroutine_fn int -hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) +hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes) { BDRVRawState *s =3D bs->opaque; int ret; diff --git a/block/filter-compress.c b/block/filter-compress.c index fb85686b69..d5be538619 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -94,7 +94,7 @@ static int coroutine_fn compress_co_pwrite_zeroes(BlockDr= iverState *bs, =20 =20 static int coroutine_fn compress_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { return bdrv_co_pdiscard(bs->file, offset, bytes); } diff --git a/block/gluster.c b/block/gluster.c index 6a17b37c0c..066fdf60fa 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -891,6 +891,7 @@ out: static void qemu_gluster_refresh_limits(BlockDriverState *bs, Error **errp) { bs->bl.max_transfer =3D GLUSTER_MAX_TRANSFER; + bs->bl.max_pdiscard =3D SIZE_MAX; } =20 static int qemu_gluster_reopen_prepare(BDRVReopenState *state, @@ -1297,18 +1298,20 @@ error: =20 #ifdef CONFIG_GLUSTERFS_DISCARD static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs, - int64_t offset, int size) + int64_t offset, int64_t b= ytes) { int ret; GlusterAIOCB acb; BDRVGlusterState *s =3D bs->opaque; =20 + assert(bytes <=3D SIZE_MAX); /* rely on max_pdiscard */ + acb.size =3D 0; acb.ret =3D 0; acb.coroutine =3D qemu_coroutine_self(); acb.aio_context =3D bdrv_get_aio_context(bs); =20 - ret =3D glfs_discard_async(s->fd, offset, size, gluster_finish_aiocb, = &acb); + ret =3D glfs_discard_async(s->fd, offset, bytes, gluster_finish_aiocb,= &acb); if (ret < 0) { return -errno; } diff --git a/block/iscsi.c b/block/iscsi.c index b90ed67377..297919ebc2 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1141,7 +1141,8 @@ iscsi_getlength(BlockDriverState *bs) } =20 static int -coroutine_fn iscsi_co_pdiscard(BlockDriverState *bs, int64_t offset, int b= ytes) +coroutine_fn iscsi_co_pdiscard(BlockDriverState *bs, int64_t offset, + int64_t bytes) { IscsiLun *iscsilun =3D bs->opaque; struct IscsiTask iTask; @@ -2075,10 +2076,9 @@ static void iscsi_refresh_limits(BlockDriverState *b= s, Error **errp) } =20 if (iscsilun->lbp.lbpu) { - if (iscsilun->bl.max_unmap < 0xffffffff / block_size) { - bs->bl.max_pdiscard =3D - iscsilun->bl.max_unmap * iscsilun->block_size; - } + bs->bl.max_pdiscard =3D + MIN_NON_ZERO(iscsilun->bl.max_unmap * iscsilun->block_size, + (uint64_t)UINT32_MAX * iscsilun->block_size); bs->bl.pdiscard_alignment =3D iscsilun->bl.opt_unmap_gran * iscsilun->block_size; } else { diff --git a/block/mirror.c b/block/mirror.c index f0a3eac216..3dbe696873 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1486,7 +1486,7 @@ static int coroutine_fn bdrv_mirror_top_pwrite_zeroes= (BlockDriverState *bs, } =20 static int coroutine_fn bdrv_mirror_top_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { return bdrv_mirror_top_do_write(bs, MIRROR_METHOD_DISCARD, offset, byt= es, NULL, 0); diff --git a/block/nbd.c b/block/nbd.c index bf56735e4a..03f74b6f60 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1680,15 +1680,17 @@ static int nbd_client_co_flush(BlockDriverState *bs) } =20 static int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, - int bytes) + int64_t bytes) { BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; NBDRequest request =3D { .type =3D NBD_CMD_TRIM, .from =3D offset, - .len =3D bytes, + .len =3D bytes, /* len is uint32_t */ }; =20 + assert(bytes <=3D UINT32_MAX); /* rely on max_pdiscard */ + assert(!(s->info.flags & NBD_FLAG_READ_ONLY)); if (!(s->info.flags & NBD_FLAG_SEND_TRIM) || !bytes) { return 0; diff --git a/block/nvme.c b/block/nvme.c index 51fc65fc91..1d59514f63 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1330,7 +1330,7 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDr= iverState *bs, =20 static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, int64_t offset, - int bytes) + int64_t bytes) { BDRVNVMeState *s =3D bs->opaque; NVMeQueuePair *ioq =3D s->queues[INDEX_IO(0)]; @@ -1357,6 +1357,14 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriver= State *bs, =20 assert(s->queue_count > 1); =20 + /* + * Filling the @buf requires @offset and @bytes to satisfy restrictions + * defined in nvme_refresh_limits(). + */ + assert(QEMU_IS_ALIGNED(bytes, 1UL << s->blkshift)); + assert(QEMU_IS_ALIGNED(offset, 1UL << s->blkshift)); + assert((bytes >> s->blkshift) <=3D UINT32_MAX); + buf =3D qemu_try_memalign(s->page_size, s->page_size); if (!buf) { return -ENOMEM; @@ -1460,6 +1468,10 @@ static void nvme_refresh_limits(BlockDriverState *bs= , Error **errp) bs->bl.max_pwrite_zeroes =3D 1ULL << (s->blkshift + 16); bs->bl.pwrite_zeroes_alignment =3D MAX(bs->bl.request_alignment, 1UL << s->blkshift); + + bs->bl.max_pdiscard =3D (uint64_t)UINT32_MAX << s->blkshift; + bs->bl.pdiscard_alignment =3D MAX(bs->bl.request_alignment, + 1UL << s->blkshift); } =20 static void nvme_detach_aio_context(BlockDriverState *bs) diff --git a/block/preallocate.c b/block/preallocate.c index 99e28d9f08..1d4233f730 100644 --- a/block/preallocate.c +++ b/block/preallocate.c @@ -235,7 +235,7 @@ static coroutine_fn int preallocate_co_preadv_part( } =20 static int coroutine_fn preallocate_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t byt= es) { return bdrv_co_pdiscard(bs->file, offset, bytes); } diff --git a/block/qcow2.c b/block/qcow2.c index 59c5137410..442917b85d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3968,7 +3968,7 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockD= riverState *bs, } =20 static coroutine_fn int qcow2_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { int ret; BDRVQcow2State *s =3D bs->opaque; diff --git a/block/raw-format.c b/block/raw-format.c index 4e9304c63b..45846e42d5 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -302,7 +302,7 @@ static int coroutine_fn raw_co_pwrite_zeroes(BlockDrive= rState *bs, } =20 static int coroutine_fn raw_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { int ret; =20 diff --git a/block/sheepdog.c b/block/sheepdog.c index a45c73826d..80e04dccfd 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -3101,7 +3101,7 @@ static int sd_load_vmstate(BlockDriverState *bs, QEMU= IOVector *qiov, =20 =20 static coroutine_fn int sd_co_pdiscard(BlockDriverState *bs, int64_t offse= t, - int bytes) + int64_t bytes) { SheepdogAIOCB acb; BDRVSheepdogState *s =3D bs->opaque; @@ -3113,6 +3113,8 @@ static coroutine_fn int sd_co_pdiscard(BlockDriverSta= te *bs, int64_t offset, return 0; } =20 + assert(bytes <=3D INT_MAX); /* thanks to max_pdiscard */ + memset(&discard_iov, 0, sizeof(discard_iov)); memset(&iov, 0, sizeof(iov)); iov.iov_base =3D &zero; @@ -3186,6 +3188,11 @@ static int64_t sd_get_allocated_file_size(BlockDrive= rState *bs) return size; } =20 +static void sd_refresh_limits(BlockDriverState *bs, Error **errp) +{ + bs->bl.max_pdiscard =3D INT_MAX; +} + static QemuOptsList sd_create_opts =3D { .name =3D "sheepdog-create-opts", .head =3D QTAILQ_HEAD_INITIALIZER(sd_create_opts.head), @@ -3269,6 +3276,8 @@ static BlockDriver bdrv_sheepdog =3D { =20 .create_opts =3D &sd_create_opts, .strong_runtime_opts =3D sd_strong_runtime_opts, + + .bdrv_refresh_limits =3D sd_refresh_limits, }; =20 static BlockDriver bdrv_sheepdog_tcp =3D { @@ -3307,6 +3316,8 @@ static BlockDriver bdrv_sheepdog_tcp =3D { =20 .create_opts =3D &sd_create_opts, .strong_runtime_opts =3D sd_strong_runtime_opts, + + .bdrv_refresh_limits =3D sd_refresh_limits, }; =20 static BlockDriver bdrv_sheepdog_unix =3D { @@ -3345,6 +3356,8 @@ static BlockDriver bdrv_sheepdog_unix =3D { =20 .create_opts =3D &sd_create_opts, .strong_runtime_opts =3D sd_strong_runtime_opts, + + .bdrv_refresh_limits =3D sd_refresh_limits, }; =20 static void bdrv_sheepdog_init(void) diff --git a/block/throttle.c b/block/throttle.c index c13fe9067f..6e8d52fa24 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -145,7 +145,7 @@ static int coroutine_fn throttle_co_pwrite_zeroes(Block= DriverState *bs, } =20 static int coroutine_fn throttle_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { ThrottleGroupMember *tgm =3D bs->opaque; throttle_group_co_io_limits_intercept(tgm, bytes, true); diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 50b8718b2a..9656814814 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -48,7 +48,7 @@ static int coroutine_fn bdrv_test_co_pwritev(BlockDriverS= tate *bs, } =20 static int coroutine_fn bdrv_test_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t byte= s) { return 0; } diff --git a/block/trace-events b/block/trace-events index 3edd2899c2..3b86c03b2f 100644 --- a/block/trace-events +++ b/block/trace-events @@ -152,8 +152,8 @@ nvme_write_zeroes(void *s, uint64_t offset, uint64_t by= tes, int flags) "s %p off nvme_qiov_unaligned(const void *qiov, int n, void *base, size_t size, int = align) "qiov %p n %d base %p size 0x%zx align 0x%x" nvme_prw_buffered(void *s, uint64_t offset, uint64_t bytes, int niov, int = is_write) "s %p offset 0x%"PRIx64" bytes %"PRId64" niov %d is_write %d" nvme_rw_done(void *s, int is_write, uint64_t offset, uint64_t bytes, int r= et) "s %p is_write %d offset 0x%"PRIx64" bytes %"PRId64" ret %d" -nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %p offset 0x%"PRIx64= " bytes %"PRId64"" -nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p off= set 0x%"PRIx64" bytes %"PRId64" ret %d" +nvme_dsm(void *s, int64_t offset, int64_t bytes) "s %p offset 0x%"PRIx64" = bytes %"PRId64"" +nvme_dsm_done(void *s, int64_t offset, int64_t bytes, int ret) "s %p offse= t 0x%"PRIx64" bytes %"PRId64" ret %d" nvme_dma_map_flush(void *s) "s %p" nvme_free_req_queue_wait(void *s, unsigned q_index) "s %p q #%u" nvme_create_queue_pair(unsigned q_index, void *q, unsigned size, void *aio= _context, int fd) "index %u q %p size %u aioctx %p fd %d" --=20 2.29.2 From nobody Sat May 4 04:00:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1620201704; cv=pass; d=zohomail.com; s=zohoarc; b=Qbrcy+hqneWe1Pdo/wxdM7exh6gTbaeNI3iOZl03FCeWYBiuwC8SkA4OraAzD72GAR0eIFw7OAXtTbJfH2DhLKe4DGzJ+5NFX8TxlvqzzZHNP/Ph64G57Sfp66cxGoxoUkBlZpvhTxFhU5R4uuy74y3cuLy7BA9VCfNBa1niu/s= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201704; h=Content-Type: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; bh=1l4J8UuffPxvc0RdSXCxpXXeG964dtu+YwvTY7koGF4=; b=oDdmCokdDKoQjTANhOdkV3xOhONabXg0rChDa61KJ5rdi1M8l1r1/gsmjhnARMMttHcDtVMgcPxlCtbkTQOHGnOYlGDyrrcxQa1JzTURrM7r2qTa0dFoaz3NyYuCeuvQ1C1VnpCUDYNHXFDCIl+hnCTByAIt108aZ1Yed/aZdrc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine 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 1620201704976992.1983418200604; Wed, 5 May 2021 01:01:44 -0700 (PDT) Received: from localhost ([::1]:39706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leCTX-00010Y-JM for importer@patchew.org; Wed, 05 May 2021 04:01:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCJ0-0005uH-Qg; Wed, 05 May 2021 03:50:50 -0400 Received: from mail-eopbgr10116.outbound.protection.outlook.com ([40.107.1.116]:51367 helo=EUR02-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCIx-0002fG-FQ; Wed, 05 May 2021 03:50:50 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6551.eurprd08.prod.outlook.com (2603:10a6:20b:319::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.38; Wed, 5 May 2021 07:50:40 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4108.026; Wed, 5 May 2021 07:50:40 +0000 Received: from localhost.localdomain (185.215.60.236) by HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 07:50:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y71nP9kEagi1YJAPDHwgogyRDpu0vtMsZvl9BoDwRWcdKG1NF2/Ed5wA/eaNmGtQ72mJfFTMbVin9HDskXOTfB0Rw5tZImhfT7yTKpwJ6YYq8mBItxTvoRxJ4mmAjtD+ONwLvOmVw4Xh64Bgm/MbwSAopas7MnvovVOJzpaXpXMfibKWhwXYo/J+KoMJu5dDhayG490QfnO0RvPRWbZi9Ykz1bhdHi7X6plmeqNo+RF8VIlA4WMbdjnVUGk0y80VSWO5SR7Ds2KgisZrF999fX6jhzx3EZBxpK1jhMq0Ukp1+s0aI1AoVBRyGf0khpKB6wzYkaa4cQyF7O+dPgIQ3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1l4J8UuffPxvc0RdSXCxpXXeG964dtu+YwvTY7koGF4=; b=CasK5PrroKtupHTiRNk/Gs1Mf9aCn7aVQtzp8RW+w2d1+XR5RE5jyjGX5mbaLpUm378mNDFJlqztIp9ZLNxuRZFEqoonud2ZuFUvR6oGkteuwpV52BDRLzsLwG2+sdhbrmk1W0cwbUziIEqrDVJ+0+FlbqjIaE/f/JA3PfqBNPkbtEI8Yd+aX1hHPoGq2odpXVxZxVd05IrnyHGASkwP5YbT0PuxpPX7W4e9t3hXDLhnjXJNp2JG3oIx50xUrFIF7suyxzOyQpS0g9Lq5V+hftizCKMPP+KI3VRmt3JzRzncxKLu1Cx1Ql+XlxiGfPQcfjwIebio9NFPkl/8/r+9lg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1l4J8UuffPxvc0RdSXCxpXXeG964dtu+YwvTY7koGF4=; b=fJIUj6QWr9o7KuMdtP7aVs0H5IaARgtXlgQxzyEuYNSQq7iRP71zICoagUQ9JFtx9q9RKf4/VaGc1u+FCIRTTLFg18xqr1rIe0rhY702k2UxW3fsBoWeIOKs29NHLZP99Btvn5pJn0LhAxUvQfysqHrfnGQiFuNrndGLrOMONAI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, stefanha@redhat.com, kwolf@redhat.com, mreitz@redhat.com, vsementsov@virtuozzo.com, Fam Zheng Subject: [PATCH v5 11/11] block/io: allow 64bit discard requests Date: Wed, 5 May 2021 10:50:01 +0300 Message-Id: <20210505075001.45041-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210505075001.45041-1-vsementsov@virtuozzo.com> References: <20210505075001.45041-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.236] X-ClientProxiedBy: HE1P195CA0024.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::34) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e9f16d50-7d27-4ff7-d9a9-08d90f9a7a6c X-MS-TrafficTypeDiagnostic: AS8PR08MB6551: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:137; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: spnrKtsSBX2iyNJOFC7dcriyWmTutu4AhBmS+eZikLMzoDMfD1T+lRQOnBbZNeWqisZyFd6YwKpQ8bit5UnkgdwZ62r3+7p3SW46Tw3SAGWt/eOUNEIPTIDteQhketsk25a94/CfmP8jWmDZfc+c7frlF0FHERcSqktaZGYKfHAJGfmsSKbeX2J9/7Iddy84ZNa7Iqto7RnaWgIXitFOYDA9kK1bAR4bZ3antXGidpr+golrTmqVcjMVrWvOPL6ByCzVdc/mdkSXxqrL5E+JKcA/fDgVStRTdzktptFsP9E8cj+LPN4fwVj4yAHavO2Bj9WBDw2a+9vSkY35JiyyG2k7oP/0OIj+cjrIyt3PqYjp0s10bLq28Y6Wl+/zjEncbFbg022877JuIFX6A/mD9OXTL430h1Vb3ixPyP/yViEBpoSvbyQMSDbl1G9rGL6FjnUuXU8QRD2U3ZKpwN+sCXiOFW4SWvmPY/lmQgukCL0BonwyVVDE8o/BdPdeuCzk9sPtOAkQalC3nUvJoxaiCXnJHucJ8xEpi7k403KQiLS0N08X25RsFuUHy9/4fvdfSn3M0rFviBJtBVlJDK2gm4/l8HdZJDrtlyFU3beU/BxT0td4z/onxTOC+H++LIB60EpMgXlNz1IOSENae24SL6oyIqUI5VA3jkuhDaR4pGyJ2HlEAKK6n4YaamCgeM8E X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(366004)(136003)(39840400004)(346002)(376002)(2616005)(5660300002)(1076003)(26005)(38350700002)(86362001)(66946007)(52116002)(38100700002)(6512007)(66556008)(956004)(36756003)(66476007)(2906002)(6916009)(83380400001)(6506007)(6486002)(4326008)(316002)(478600001)(16526019)(8936002)(186003)(4744005)(8676002)(6666004)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?sql78CiK6pkSdNyzrjNg6g0LDshvwt+YygcwcB6YF+Gwnjghvz5y4UX7JEuB?= =?us-ascii?Q?BXT1AnkMKihINA9wVFgy2D5WGPOPf8yuJcEkMZlgpxot9RF2avG6ylyLHGDp?= =?us-ascii?Q?eRK5HOmwKXWKkYF16PUl0oIfC6KADbhok+fS1KedG/om8iHh9mXQsYPw8OZI?= =?us-ascii?Q?hQgolq15vh6kH8b5yjFhc6E0mOljqJVybQBMb9/wBiHrRFnidvKoYFKuTUXD?= =?us-ascii?Q?VLwjql5wUs+Zn3ULqXtIiEcREDMAlBalG2pXVdKEWLiCr3zrQ+tavegGqPMr?= =?us-ascii?Q?1ucJOXv0JKYmjWM5f4k0brh3an4Q3EmGRmnRp3YXamyvchcFenPk2Ivz+ZRc?= =?us-ascii?Q?HJq9mQeVBQFq1P9dDGSYbiNiI6jxe5rcfc+zY27nyQd684E5w5MrFzS3Fwvo?= =?us-ascii?Q?8ZEjGK4TCJLb670Ex47nJLvlzOUEdlqhscqTgPc2/D0OVkw9PBZeGWZCXEBx?= =?us-ascii?Q?zSOqNARcscwovb1oV2mkOSlYJLmfiuJ3zasW7Sbhv9Sd6mlZ9lL0vnChFbA+?= =?us-ascii?Q?fhnacsxwW2JX5LZYtsceMIKI8UOavzhuyv+sgAEQ3GPZbiaXf6XMNbp4lLyM?= =?us-ascii?Q?En5g+5VaZ3xcLgNGEhDFtBVV7FQJsazsIb0PuX8/sfIZXBmgxMtQBVBgGrFb?= =?us-ascii?Q?tsgB+dt8S+YBBCC5Up6pBlvVm5AoooCRt+YDb+KohcOm9RHvXSvW5btvbRlK?= =?us-ascii?Q?ayYgAAp4njKSj9EMiLCU+dHfpmXHwdlH9s4xqaFfGAVZs19v3lNauI3QGnmE?= =?us-ascii?Q?TU7bn0w8v9eqHij9a7t4BTj4zuGwZ1Lb+K+TX7JYSW6Fkcos0YslaqBcam9o?= =?us-ascii?Q?h4j/xIh0XK1cHw2UGWLRUPMHr6KZShFtTHw7NAWum/pWq8ls6aJdMvVJ2N3d?= =?us-ascii?Q?tDGjA84vmr1IpTqF5eNHjSZPFP70zU15DoCXIr4+N0TUmrIEllj1I8R/la60?= =?us-ascii?Q?dTUaA91D8QA3IQVnPI306FAtGYAz3P/KgXlbVoEEtQA0KMGY+rjzRETdYjA/?= =?us-ascii?Q?J1bz+WwBMvK3ilN54zW3ZUBp0LAGZMM9AxeJ761O0l6nNB77rptb+YTM/JIC?= =?us-ascii?Q?ybCamzINFhqPf97qrmpVLk5SZrb6ChXR4cEMFiZxVtJZ7b1e3kVbQ+e5DUZi?= =?us-ascii?Q?jAkGAk1LJQZTf9q7GxmIhGvOuE2XnrjB1npfLzXtT7THTakKFuZ16tIvp8wu?= =?us-ascii?Q?eRHLDt7d/gvfAwpsdU+uNQGEfMJMrqqUMJ/q4TaM8eLoVKrXb6OEy/rgYfM9?= =?us-ascii?Q?K6rgdGlG+x74VAS117PNd+QE0lrppqxKAaiCl3kZ3PB249pN8cUSzKddRr+8?= =?us-ascii?Q?+u5iNOKktsi8O82AbDhgWusd?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9f16d50-7d27-4ff7-d9a9-08d90f9a7a6c X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 07:50:40.4324 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZkKFgC6eTI7DbBwFT7uesWrxep8TVBZ0oy7/W/GHqPJYJalq/ujEsbjRUsBcnjhViMdt1+tG/50/q7nDK7PUTmRBTXkvv9NOFpZHDBrlJu0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6551 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=40.107.1.116; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" Now, when all drivers are updated by previous commit, we can drop the last limiter on pdiscard path: INT_MAX in bdrv_co_pdiscard(). Now everything is prepared for implementing incredibly cool and fast big-discard requests in NBD and qcow2. And any other driver which wants it of course. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index a7edb1ef54..e0b3ebcc37 100644 --- a/block/io.c +++ b/block/io.c @@ -3036,7 +3036,7 @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, i= nt64_t offset, goto out; } =20 - max_pdiscard =3D QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_pdiscard, INT= _MAX), + max_pdiscard =3D QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_pdiscard, INT= 64_MAX), align); assert(max_pdiscard >=3D bs->bl.request_alignment); =20 --=20 2.29.2