From patchwork Fri Sep 3 10:27:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12474087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 382F4C433F5 for ; Fri, 3 Sep 2021 10:30:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A847160F56 for ; Fri, 3 Sep 2021 10:30:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A847160F56 Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=nongnu.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:36716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM6TF-0005hY-OI for qemu-devel@archiver.kernel.org; Fri, 03 Sep 2021 06:30:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM6Qy-0002sN-Ft; Fri, 03 Sep 2021 06:28:33 -0400 Received: from mail-vi1eur05on2111.outbound.protection.outlook.com ([40.107.21.111]:45006 helo=EUR05-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 1mM6Qt-00025z-Vg; Fri, 03 Sep 2021 06:28:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fAqU5uRSITXgeNqbtUUVtaBTMeGK8IrzuY2pwrpm2FJ1rRcVspdWA43ENNKM4fq6aU8osR1pKddKOBli/6Lt/BQrVrEoraJTQN1FX9yBunzztQiYGrLQPnNMCD2E6e2urKutuoDqqy61E1KY8mu8VPV5wRRlQAGckAE/OPbdXxxbdgDe/IhgD5srgOmOqDuWoWyERZKjapoE10K7JSFwvbxorxF+9w7KHMpUglew5a0wxE1HVbAWC5IncoLnqyMcIN2XbBI8HQRBmOt0K7YU+29qx/bVJbGnSzVWpuREL6Cu7twTjHgCZIKxs2spAUavYOT3jXBkKd6tZYa9XG1p8w== 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; bh=9UVOQU91pgfFowIoo0BNRqZZ4KeR3qCuvYPHk6zEBVc=; b=ViXP59CZrdC2NTDA9Dx4eVIiMauDu+36o8OuZDRpwYutpcns9jc1K6z6SCYXtyuQWNyds1tod27uuxmQWKCZ+FDPcfuJ/Dg5xhPRI3GEBi27srf4wOtNzSalbHvSWPxi0j4X404mAD8xcGrv5McaG7/JGOtNVE5bRIn0IiWqsA3uCVwx+gIp4zMCR6STVNKj4o1CPBXOelJdJTyx2E912KoZ79iu4cXB6Mz8V0Gexvzydhg7CflwYKX0XfEtxixci/y0B50uzDoSWFqFO+pGIxvrVB8+N2RK/LMqTQLRNo8vvZGmfyvR8g6iw41vtlzxPS+QIHZkZHNpDnJIANEmXw== 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=9UVOQU91pgfFowIoo0BNRqZZ4KeR3qCuvYPHk6zEBVc=; b=Zd0g/SFqHNcOziq2VlPhQvzJ/NKS7XJsHfAFrfrj7qtjCNnAyFdwSSjjlAiSVeQqaO/0CP3yXZRS/O2CWQJg1vH2bC+dKKNcyxoJTm1yBzMSbCmtETgGftp4arRTlVCiY5u8N0leMYwnC37E42uRfLlExOO8olL0VXD76pPlsIk= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB7009.eurprd08.prod.outlook.com (2603:10a6:20b:34c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.21; Fri, 3 Sep 2021 10:28:24 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.022; Fri, 3 Sep 2021 10:28:24 +0000 To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, kraxel@redhat.com, idryomov@gmail.com, berto@igalia.com, philmd@redhat.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, vsementsov@virtuozzo.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v6 01/11] block/io: bring request check to bdrv_co_(read, write)v_vmstate Date: Fri, 3 Sep 2021 13:27:57 +0300 Message-Id: <20210903102807.27127-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210903102807.27127-1-vsementsov@virtuozzo.com> References: <20210903102807.27127-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Fri, 3 Sep 2021 10:28:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: df23b71a-93f0-4cfd-ce21-08d96ec58f68 X-MS-TrafficTypeDiagnostic: AS8PR08MB7009: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2887; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K5UlQ1SbrClRwc2XPdIhGOuDjyLx/7kIdQy4gsVVMPdK6X97qkto8bqxRRR0ddTUhiF7s7YhywyI1vfmk6GLDH2Nh+ZLjvJmbsEDV2dMGM5/mJ1CZY8ISICZbsr0FAbb+idriX/8thxUgGaO0OTRuCy7Pk2Ht4dymKApBjxYD6RTk/3ZcOUTDaJFXtsSRXpBF56CxElKLilzQSIDnUZY1BmoZvAuPhbDRcxLxBGHNzas2EtcmeMS/wIFBGhpmNZEJQecYiyPuri3omt2WG9DLyTdAndAgUzeCFm9mDw7GnxylOxiLMvN4JL15vXhGVV/F5/UjdwJslojHR6eG7t5QDKD1tDsh5MDyU+YnrWVpvsssd626NDR++B0/CjJTp3cxBnSLlxQ3GSpLIVWgfcUvkLXLS0u0ILAu+da/Ge67jqMB144Qo6VQR2RPBrgfLjpZZMSYJwf7p0HuLHLTqfGPt2KygYMRPNhbbBdVz+J2RBFOUyNCdc2XCc6zoOMiqM6PMhtn2X9Zw7Eh7KB43n45pG1IBf7/xY2s1AgJXTEd5AB1Bx+WPE5YwU2BJ/O2MTtFNfdl+q7PV83tR0O8aao05qPqigW+X70KDHC8dORJEQxKxTzXaftkpegudpH86FSi12/ky5LjxnIku9LNZ12S46a7I0UN2QpIUFL4nUGwt+5jmENSLMguQFcpmG4ortD5rVM3+SZi9QDQ0S6PmXbLQ== 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)(366004)(66556008)(186003)(6666004)(508600001)(36756003)(66946007)(6512007)(66476007)(8676002)(52116002)(8936002)(83380400001)(7416002)(86362001)(38100700002)(38350700002)(6506007)(956004)(26005)(6486002)(2616005)(316002)(1076003)(4326008)(5660300002)(2906002)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LSdSCCeK4Zl9Cy5sN2nqwmOoUsIsZm2s8FvhhyEhzmwckSMJ5H+rxM0T2u0JBy8SrcfEAzixAGXSW1xHWjH6qtAGwrF/c9UfU1m2aWv3DdwamIic8RT4t2WPmfGB5IO4tsgK75RZs9DVe5d62Qgx5+gyVflVPhuK9G2Nm8L8obEK34Rrw3ZNZX9XDf/bXTh+Ty/thnJSGpYvd7ACnOtxb8E1h7hM0kKwxBTWV2D14QNTGCALVWPp8jyVRrn4VVwkWmwFTsD02a5Ro2b5UtEDbZMtePR+EpHVnlpjTdWunvmIGW1y+0nXAmWnIf4/+wMxGsWqFc+8A0IkU/BMcp3OCb+I6VVzt76TVTK6wMT9XmhJVUUSkzi897xdlzzrptarmhghFO/J/ImZ8qguRFqUV9ydBpOXPCfN22/GwGHn83by1jiClD0qF3yZMNF4bhFLOihLTxuJpKDFDbM5a8tjBkrH4S/0TdEsVksWIV5hZ2EacihlTWnC5TKEBqGJvqwfrjmpCm0tWj3atsF7rQY0U61RL56a/GPqy2AmwJnReKOZNOQGMhCwUZogs5zzIIIp51P/Oh40TB0Ps96F2nmBSOyCwiQ1NDLvyJ6VSIolP8ws6D+MaJy8LOx2I7p2Cm8XQXGQNfkEcMxG7gH+L0/43TmmaRUFXzrxJ/y1eZl5xZ/Qwag3qKbEqfGyjjAdbW1GAfVa4GYOZVYgjpaT3MENCprQp4F6NzYCyonqlAFkB9D+jaAc5vRn3ER883zWISrypUCFIDJLTUAbAiUvir0ZuAHMtT00Yt4Y6hXWs+u6ze0/6FQzAQGxiNhYjMmXXPD0Wk1obLstX7C/aVVp/w2D3H2RAdodpEonXUYA3menclXYH5Lyc9dxaAunXCUjdx/pbuEnyQEi56o98li5gfQQ/uqaFha4wKIB4kfGKFbAtLT/JFDnC4q7cb4CtRb/0CD8emVEHD7rkVnYSUoKkAO0pwo80jHYBMs3InSZX0vQTcnjYKInYws9E7oWxBdlxJzcAV8hRRWJCe5+PHgDqeqqAp13cUMZPe3VycJQ3HHDddfZb8/0+6dCQy0RvzJWKVpfpUbdsh4G/xG8fxp3jctX/iwYKtl5DA68li4bZ5/9NSugM/Gy6cwG97JkPMHhrAHwCQNiq4ASL86qOcDdoiwweEmetAqsYqfVwezJz6SkmQ7tZjxYB+T0Q8LQAfNOFigeZsHBMZ7uxfM64i06yh62/2sESzCgRx+Irx4+Xu7xpGtNpn9VX7M47kMfdDeA4WXIxfFGU/jIDgEdEFGzRkbbWfovsojk7j/43AqbcW9qpWe+jVhg9ck29mrgN221tJdS X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: df23b71a-93f0-4cfd-ce21-08d96ec58f68 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2021 10:28:24.4851 (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: /gUCtNpGp9dzD3oDEoUGYYkvyJeMjYOvWEX52EOpxdVY4uh4KzrjMY8i/TTQXxxbAgrLa1cevPXsKWv3MbH+oA1LeRv81DQ8DwxySPueZrs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7009 Received-SPF: pass client-ip=40.107.21.111; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reply-to: Vladimir Sementsov-Ogievskiy X-Patchwork-Original-From: Vladimir Sementsov-Ogievskiy via From: Vladimir Sementsov-Ogievskiy Only qcow2 driver supports vmstate. 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 Reviewed-by: Eric Blake --- block/io.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index a19942718b..542e0305dc 100644 --- a/block/io.c +++ b/block/io.c @@ -2751,7 +2751,12 @@ bdrv_co_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { BlockDriver *drv = bs->drv; BlockDriverState *child_bs = bdrv_primary_bs(bs); - int ret = -ENOTSUP; + int ret; + + ret = bdrv_check_qiov_request(pos, qiov->size, qiov, 0, NULL); + if (ret < 0) { + return ret; + } if (!drv) { return -ENOMEDIUM; @@ -2763,6 +2768,8 @@ bdrv_co_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) ret = drv->bdrv_load_vmstate(bs, qiov, pos); } else if (child_bs) { ret = bdrv_co_readv_vmstate(child_bs, qiov, pos); + } else { + ret = -ENOTSUP; } bdrv_dec_in_flight(bs); @@ -2775,7 +2782,12 @@ bdrv_co_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { BlockDriver *drv = bs->drv; BlockDriverState *child_bs = bdrv_primary_bs(bs); - int ret = -ENOTSUP; + int ret; + + ret = bdrv_check_qiov_request(pos, qiov->size, qiov, 0, NULL); + if (ret < 0) { + return ret; + } if (!drv) { return -ENOMEDIUM; @@ -2787,6 +2799,8 @@ bdrv_co_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) ret = drv->bdrv_save_vmstate(bs, qiov, pos); } else if (child_bs) { ret = bdrv_co_writev_vmstate(child_bs, qiov, pos); + } else { + ret = -ENOTSUP; } bdrv_dec_in_flight(bs); From patchwork Fri Sep 3 10:27:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12474099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09494C433EF for ; Fri, 3 Sep 2021 10:34:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 916C4610A2 for ; Fri, 3 Sep 2021 10:34:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 916C4610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:46376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM6X9-0003pB-Mf for qemu-devel@archiver.kernel.org; Fri, 03 Sep 2021 06:34:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM6R0-0002t6-Nu; Fri, 03 Sep 2021 06:28:34 -0400 Received: from mail-vi1eur05on2111.outbound.protection.outlook.com ([40.107.21.111]:45006 helo=EUR05-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 1mM6Qz-00025z-5Y; Fri, 03 Sep 2021 06:28:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AVuetuZmqv/le7doSen25G5KHQ+axDkGxk+4NGKenqeD/iomuokVBq8idpi/6tzrld20QvSeqfIqFoDCQAr0DkacgN+mZ2+Fl/vfFCdFmum0i9LfLC1eoZXGoyl9rPeDccEuuDllcbNwQlbmkgK4yc9sc7qgOLl16s7yqmixYO7T8mJzBb7WosAjTsaRxewWI9xqFErWvs3g6KcN6vIXt+P7npBzdk0wNCxHkBjJSMh2uIHkzQM9waR0/NaTnovAQGauWNaN+enyCxE7aTDyeydm34VU+JPMy2U2JP5xP+KZI2ZWoUiGoxZ7mdj+FT7/a//+n0HhWGcbrgFe7pXoeg== 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; bh=LtY5DMEzIGq0nSG6N4d2PbDlqXMuzHVf5c9Ffma9Fys=; b=fdQKBvUnkkxaOaFufWHdMzlBwW8DgGNIHfLL3W1KeUKuCD0BSZl6s6X2Rjn504vIuvLzQeDhqVMPVP5w42jdhwss+yEphL6vhcYbYwEQ+608N20qK0c0sbrS8fRgWp4X+iiNz5W3awUrnUsKqvhp8PZ+a7P+l4JpVZnSSk2+GaoVZ5Q0j7I5wo4SA7tj0Olm5no2uNamS29oVN6/Z5CB9IT2LOkAHLV61xMIJ0BMURu5VB0dTbp4Wz7N2B+JWa5Hfbaakx79LAqKUWdUJezXn0ATfFvcIf72DY8gaqKQCS8BT1ZMzhwsyLZ2drafgapMyE5DlCyb7NT/7vUixjCiHg== 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=LtY5DMEzIGq0nSG6N4d2PbDlqXMuzHVf5c9Ffma9Fys=; b=XHEEFa4QsAujuIRO36jLa30IG6irNZZLhB6wDPjLIp3+UE2oyKNiHRIriN941NGIHYjx7CMv8gJMxXpF+zdBg8D2oz3xnZqNdtzfbbsjaaef1WTV+0oEieGX4kpYQVZ+45mzTDZOqJlpr4b3mbuxN/mv3qBNq20uU9RvWLw8s0Q= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB7009.eurprd08.prod.outlook.com (2603:10a6:20b:34c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.21; Fri, 3 Sep 2021 10:28:26 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.022; Fri, 3 Sep 2021 10:28:26 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, kraxel@redhat.com, idryomov@gmail.com, berto@igalia.com, philmd@redhat.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, vsementsov@virtuozzo.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v6 02/11] qcow2: check request on vmstate save/load path Date: Fri, 3 Sep 2021 13:27:58 +0300 Message-Id: <20210903102807.27127-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210903102807.27127-1-vsementsov@virtuozzo.com> References: <20210903102807.27127-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Fri, 3 Sep 2021 10:28:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 59989b92-fe80-4e8c-957a-08d96ec59097 X-MS-TrafficTypeDiagnostic: AS8PR08MB7009: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:519; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BLWolEeuSqpRY8mbnOxJTi2bMSpPhgxdtZCAofLFn+hYDbltLTNJFTOfkoRG4MQiLUVzN98l1SgEr9/jhSp9ARYbLKbmk2w3fc7/3fnnMgtzkZ0Rg3Y90z785Cw1Njq06fuM0svLU2Vu3fweMKzeizJc0i4Ojxj8sZYKYnSBjBDKX0oosdwdPeTcqsDZ0sKwcYrsPqLwDCTIXvpsbRG8WRXGsUkzoXq9ArazlydlqC2BC85kMdcTFJ8qZPc52+UJqiano68g4nLPjvFYamnWabbjRbR8CDAyo5XB9WFPbG83fNdww7oO7/h3GkjZMiwe/u/VAJHSeSJvla83cWz+YgnRACexsNUbQUpxCnJKwL5Z6fAnN9HQE75F3nKh5wskKMfz/sUvmB9AJWVUt+Dg7JQmOQDyxGALGZJffW9aeiTPPCSX/eMiH5A1BPEiceFVP4G051+xznqoVlUfEvwkdgC40VloBm9R1wn6fUbJp8AvnuUGcJmsjhrvvlZVfgqXttj8376OiGMqKjMPmxvkeJyYy4D+W3SX83Jk/MCU5Mo0pxpFRvpwNiuP8Cg9z0AS+B8UZPxWVduTjN/mdPOewK0U2anTEBTOU4utip7PuIDrwo0ox9nsmorUwDG0O0s9FERDezWze7BxZfjmePW3Xn6sDfTq5vowhvL99sjUNbpPnUXRQVl2TW9xQBrxIfX/ja0r5CntLPXVR3mateHCCw== 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)(366004)(66556008)(186003)(6666004)(508600001)(36756003)(66946007)(6512007)(66476007)(8676002)(52116002)(8936002)(83380400001)(7416002)(86362001)(38100700002)(38350700002)(6506007)(956004)(26005)(6486002)(2616005)(316002)(1076003)(4326008)(5660300002)(2906002)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rqvyiuIweNB6Mg+tYad37H6OSc0aJBtkOjsJFfL1b6vdGZemaRLXViirC49nLfIyn5Fbopsijh4AYxIB73Sb6hHGs7JMnPNMlj6JSRjuq3Weh6N/AcbX3fEzDO5Z/G4y5OT+gMZ/pscTeajcgz72OgKcWZFsCX8TjExjkJRL/QuiqEzRrG+sWHUdgcDJEbkMT6tumSeQ+Vc6kwL7eWJrWsmjygcStlJSS0s79bEAvEgvdas0cHlgiYvPXkFyPkV0JbO9cUfXOgJTTw8r8AIjJUxvdxVjjs3NtZ+kjNnZa1H7pYstSQH0qgg/6oYrIYYrcMpvSAju/NVtIo662WG09RdTBuARXCXZVNjUrKoBI7/VkztqeA8wcdQu06Oy15oqGhjdwLtKXaHFIDM/TZvFCzHTygBOizZBUqm6c83ONCpQSnkfdP8AiB3DREeDM9JyHVVm7OGB54Y9IrOHwH/DUo3NA76XMNjZRR/SBPRUpH2WS9c74v2nHvnMy4vRGNZLhNkTNxK8HJ66iLlG3mZbKr31fjx5519wbMWvk65tUZdCjN6Ja/4Yr++pQPO43ANvo4TZjG5J9lRc35sF5INnhMnySD/h58eoWsTtnl1ijfSMIKfeiAU0j+3LEDEz0lsgjOLQuBhXkyZTHmhmuBxJyYSOYUCBHqcYXBmuJI1XeYNd4/LZunFbQbKemUmZxgOhMWjv9cT1MfUct9doa1nwXV0gw6um7z+eLE9fHRUPfqQzgfB0poIWV7AhRkDZPWSEoKSqCplxCmicGG2PUP83nyRZ2vxQWJOWHrIPmM7q+MJ22SIQIdd3sdTgjZ07W57DzcNZrX4WOnzPSo/YKZCM0QK39UQJjOh+DVBkADILjBSi1x8MQnCxAHlB+c6cOxBJPVqco9NmYDeoi4i0PHgmBR23YrmX9T8jg2a2mO0+kcvafckYk0DFvbk898zwEcCGG32nXHjkY/Hl8jOvrHV59tI70lqxu8sd+vv5UskAJojtvKxD1IfcQUJ3hlVyMtJ2rxQ7wSix+e+4XNhHTlTJRhHGiHFg2+0/6BDcOC8M2/3WkAuMBVo5YOOUgfaNFGPhTwKTQq2bBpjPeYEBh5QfJoWFFYRLcKjCD9bisqaVwtdOTeA1ONLulMcY8bWFQRwHxmV/Nrp2ozObSGatpSjN+99WyChN8KtntyQpqNTYKHpik/L+QRk96ZUWZxwRA8F4k0RjG+GE2keTp+MDeC4QKv9QNpZAl9lxxtdYMfiSkRkzuN/QK7ZMCHtiwvZpkqdOoLhW2djwVpE9DmAGMXt9zjM7T/7e9/TBM5B5rD0tHTavHE6JzVv2iyMKZBw1wVKM X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59989b92-fe80-4e8c-957a-08d96ec59097 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2021 10:28:26.4794 (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: xLRDKENvu776/aNkLrtg1beF2NiqazDeX5PCirL8GiewysiA8qmyoF8VeN7DA5nNhFCcfh5+D8cpryFWTYES8wk4SxQFb7RFmNohI3wHAvc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7009 Received-SPF: pass client-ip=40.107.21.111; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Eric Blake --- 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 f1a54db0f8..6f15cc9073 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; +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); struct BlockDriver { diff --git a/block/io.c b/block/io.c index 542e0305dc..0058cf4a6f 100644 --- a/block/io.c +++ b/block/io.c @@ -956,9 +956,9 @@ bool coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req, return waited; } -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 9f1b6461c8..04ad512897 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5230,24 +5230,55 @@ static int qcow2_has_zero_init(BlockDriverState *bs) } } +/* + * 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 = bs->opaque; + int64_t vmstate_offset = 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 += vmstate_offset; + ret = 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 = bs->opaque; + int64_t offset = qcow2_check_vmstate_request(bs, qiov, pos); + if (offset < 0) { + return offset; + } BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE); - return bs->drv->bdrv_co_pwritev_part(bs, qcow2_vm_state_offset(s) + pos, - qiov->size, qiov, 0, 0); + return bs->drv->bdrv_co_pwritev_part(bs, offset, qiov->size, qiov, 0, 0); } static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { - BDRVQcow2State *s = bs->opaque; + int64_t offset = qcow2_check_vmstate_request(bs, qiov, pos); + if (offset < 0) { + return offset; + } 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); } /* From patchwork Fri Sep 3 10:27:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12474089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 739ADC433EF for ; Fri, 3 Sep 2021 10:31:08 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C193160F42 for ; Fri, 3 Sep 2021 10:31:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C193160F42 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:37132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM6TS-0005yl-V0 for qemu-devel@archiver.kernel.org; Fri, 03 Sep 2021 06:31:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM6R1-0002tU-Cm; Fri, 03 Sep 2021 06:28:35 -0400 Received: from mail-eopbgr60121.outbound.protection.outlook.com ([40.107.6.121]:7190 helo=EUR04-DB3-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 1mM6Qx-0002A7-P5; Fri, 03 Sep 2021 06:28:35 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UUk3Sa73EOEzAFmuJedFBpMOZfG8kRCR5c1/7zAN75vTqsDcEAq/Mp6rJS898WbMc6sg/lyL69hsrszA7dMSHg6d66gOQy0Pn+xHPdikGy8krlVdmyQCvm5QEkDCvD6BEg4J6ss9jxyPqQkTtDJSsuwenRaTelv0kvftpyQ3bqdYB96ckJqPgTM8fyipCrH5alR+fpBGshYqh6VCUlelbk7GFjc3bybx1ZP6nwAediFPmpUH/i1l9CRIuASp/4mp+IP0+PafT+MQ+WoAv+KZC5qDhsXhTUftbZWD3Cbe/lJ4B/SLFhmdSha/qKQaR8U6M8LfvxxkvpM//PKl0H25Qg== 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; bh=jhQIM2V3yCcVe+4d3x5oj8fdIOee2PI9kvlJknTDbz0=; b=Pqy5qXTBGwe3+cApi2VMcDSmH1YSHFBXpPTrytUsUGLnlMzoFYH2Pz4qQnjAvP5TXEzqRvWCv9DAc774sReeA9iubltvgWeWa8NbauqzM4UkBapmFu1CDYMhIn40KlBOKvQHYP82ocvvGZNgS/kBtnLW8lprjXnQXDHj61XwaKiQLM+OukOus0iJU7xcYfjYZ0grfpnAAmVRgFzvVGfyj1R9bPiTQq8sZLttFgje3U34R2OMKwWAoWXT5NTeYbWDUG/anhPzqXMilnAqCSqPO9evcMrUFba0Jw8fPp4RyBUFAoaYs7M3E6SmP9jazT590PlO0MUWonvudVCxLRSPQg== 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=jhQIM2V3yCcVe+4d3x5oj8fdIOee2PI9kvlJknTDbz0=; b=fdKrxSI1MkddO3CuplduI78nvFLViOJsOHY46v2QB4CNWvsXfFGldONdfztSeR5ocVYcoVYrXhFOqz3SQaRbkfybQOHqq/sxaHe07+LMTBTTVAmlh8kad1QeHqp6WIbFnnWB3VcaDV4MVRm/K4BjYcohemjNRZwWDKBWAa8bcc4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6945.eurprd08.prod.outlook.com (2603:10a6:20b:344::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Fri, 3 Sep 2021 10:28:29 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.022; Fri, 3 Sep 2021 10:28:29 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, kraxel@redhat.com, idryomov@gmail.com, berto@igalia.com, philmd@redhat.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, vsementsov@virtuozzo.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v6 03/11] block: use int64_t instead of uint64_t in driver read handlers Date: Fri, 3 Sep 2021 13:27:59 +0300 Message-Id: <20210903102807.27127-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210903102807.27127-1-vsementsov@virtuozzo.com> References: <20210903102807.27127-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Fri, 3 Sep 2021 10:28:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 73a52c7c-5de9-4edd-eb87-08d96ec591ca X-MS-TrafficTypeDiagnostic: AS8PR08MB6945: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:332; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Nk5tKrAG5X+1PHMO5NNFztaOrztKi6qzX3Fx5pF377dY0UPZXZctm+Cq9fzeZ0TQHlMoJeSAdWqDDUyU4jXAnZ1wEKwO9fQoxbLfgzmT+GzqdGsFZl1gmmOCL9433SB/Yee0ArhWCfyj9efbkdMBxyIcU0e1QEOZPqfKcabscbA5hxj+mY4DYKCeM71rYU4SCAX39BB5FpyKlDQd5o43H+lpDQ9yBsbRJ7SFNzVNRrEakOE6AtdRlkBcYUnY2o6DCwr/tLaLPehKW127R0fAK4QQAr2E0IjPGtGSildsuriUQsSLBWRXUtPvCSc9RqsQKvZWNjgl4dY6YIPb9QTFPmAQGi86W5O9w9quA4y5AojKGuM2Kp78bVItXZDFlUgs/R8QlWUalkdalnljqMMIS2KqJQZLG1abvPnEZbtwmW5lBwaxygidn5AnUuvZqNBcxHcLMXSZKRNFtmJE2evLvcef+onOswDQsys1rP9pTw61C5TVmXZ+Ibob6ehjxHsUewHRRCV+XLzoqR2Bj3W+TI2mefIv/jhlaqhuwaXZ8BFaVSy+OJmtCxqQB02I4s9XlyxJI3WuEahYZysDsqeD5boAbINhSHj0o5m/RZoLdz/7W6t+vyuMtLd3rS63yQOzKaxyFGyqP61sCW6FX4LQQkjLYkSEWsI6aXy0oyhnwye0wuFJYB2eCgjdON8LFnHg 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)(346002)(136003)(366004)(39840400004)(396003)(376002)(7416002)(83380400001)(38350700002)(36756003)(6512007)(38100700002)(6486002)(5660300002)(52116002)(6666004)(6916009)(186003)(956004)(66556008)(2906002)(66476007)(66946007)(30864003)(8936002)(6506007)(26005)(86362001)(2616005)(316002)(478600001)(1076003)(8676002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uBAsUBlsMMCCBH8CzAiNcktsvOex3O1r6DkCzzB4QN/7DsXZ2zVsnqm1F9Yaoc6+CtsamCXUJ/1JDhNJZY9bb2xFp4+0tgf6SlwHtihGgFFfjDosszHvhSndbcD7kqqZ19FaEA7FRfCKFdyzRHRBEpV+KnXAbeDY5uEcKL4mLdIdTHj+jWJM1l9mKCpfLRRcGknSGXopGsSUZEdam+s7Sog6iMbPQufXo88NjcfzYCGfPXiDOKKagUjPWrloqJt6lyQFnMR4vQVmNPx8uatSKzrMjQKsx6xK48f12VxWSTYXk22WpZim2CS2BG/+awUsFQUwgzXW+zOja4jgokf4n1ukguU/MC2Nbvx1fsJDtLF6nmu3BmD79L+HqluJCYlddbr9bcYITjbmUjO5DrssqBq5dakWb6e8VrX47t0C4kwaP6CjGvTln0OPvZpD15wbGfKsm1tCS2eMzqQOxaBK0YsNIelTG5QW3wIQbWj4p87UVloIlD3wWy3vKzX7K2IMvcVwAuHq1hdv9KVIdJk2f35D7VsCJePkDFGzBTW58MlCKVrOl44mRXEGrhr/OYysEjNYeM81tR244rcUsdk6AcvQbZba5bq5vmwTMAS4PA6f+GgsSNHkw90LMz10LPFbItGd2agjgozXZ9apYeHoXQHJewYzJeEPVe8SIpX54Oizvwceu2sIUN/daga8DpL+CWIcCNTpKIX272VA38NoH3pLGIYZX5V/odWyTYoNRPfSkBurJO4itngU9TOj9zXVrEOF2hWumS07NM8FYGa5ZTpw4MvZb0O4CTnYUEjcXNJwrkODFal7MHYPI9Or3cjIbYYm572b0KVz1iSS/JFDhzpzZxqJNL+1C4ecbeAJx6teTLBufZHrt1KpHfp9LM1og3C2O3MGWVUXKNV1TYxGTfKvOcGGAuuHif6h2pBhC5UvSQ1e7tgOTlmHSYpKDQjEmzbQmXWYR+sasTXsLR7Tx2x5ra48y2OIVD7+WlL3QxIKkpl/m3EqZ5tyAaorG5aIBZMJxAnDF25SmQNvGLdOYn8BRmJf0gAdjPDnCNUEcFSpWcz5VbJH5h0keYF6e+BLJLYlG5piNzdGvgRCKYv1yTI7U8BTN6vnxN3dAiCMr9IUk019aTXXtecyd3daRnSGS1f0ZWODmgLcEBPn3Px7lF3N/AdxiBXcEHZ5wQAj1h3qKx/++cnneUaqZMVuxJ6+qnlTjaFkdXyq9OlIK/dgdInE2SugatVWTrmv63fYKrzz+cVH7s6U2Imk/fXWj4FZPzlm7AiA7pQitTbmHFIhV7zdLq02dk+sfMxFZSOT4KKBdFFxfFrchqe+8v6jgFJT X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73a52c7c-5de9-4edd-eb87-08d96ec591ca X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2021 10:28:29.0640 (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: 4w5groZBwxs3xp94jAvPq4v7Nbn5lbWhC8740ihlY5Im7rOE7ViQAJ+XTjY5+A2gpTjhkFM8OfBrekA3Ah4sGb1/iOafEYhSLt+morRrIt4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6945 Received-SPF: pass client-ip=40.107.6.121; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 don'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*=' | \ 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 = QEMU_IOVEC_INIT_BUF(qiov, &data, 1); ... ret = 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 Reviewed-by: Eric Blake --- include/block/block_int.h | 11 ++++++----- 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-before-write.c | 4 ++-- 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 | 6 +++--- 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 ++++++++++++++----- slirp | 2 +- ui/keycodemapdb | 2 +- 37 files changed, 122 insertions(+), 92 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 6f15cc9073..4906f27097 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -234,8 +234,8 @@ struct BlockDriver { /* 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/blkdebug.c b/block/blkdebug.c index 8b67554bec..12b8419065 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -631,8 +631,8 @@ static int rule_check(BlockDriverState *bs, uint64_t offset, uint64_t bytes, } 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; 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(BlockDriverState *bs, Error **errp) } static int coroutine_fn -blk_log_writes_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +blk_log_writes_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + 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, BlockDriverState *bs, } 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 flags) { uint64_t reqid = blkreplay_next_id(); int ret = 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, BlkverifyRequest *r, uint64_t offset, } 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, int64_t sector_num) } 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 = bs->opaque; uint64_t sector_num = 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) } 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 = bs->opaque; uint64_t sector_num = offset >> BDRV_SECTOR_BITS; diff --git a/block/commit.c b/block/commit.c index 42792b4556..10cc5ff451 100644 --- a/block/commit.c +++ b/block/commit.c @@ -207,7 +207,7 @@ static const BlockJobDriver commit_job_driver = { }; 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 flags) { return bdrv_co_preadv(bs->backing, offset, bytes, qiov, flags); } diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 2a5e57deca..591cc3ac75 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -40,8 +40,8 @@ typedef struct BDRVCopyBeforeWriteState { } BDRVCopyBeforeWriteState; static coroutine_fn int cbw_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->file, offset, bytes, qiov, flags); } diff --git a/block/copy-on-read.c b/block/copy-on-read.c index c428682272..d34add4476 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -128,10 +128,10 @@ static int64_t cor_getlength(BlockDriverState *bs) 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) static coroutine_fn int -block_crypto_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +block_crypto_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BlockCrypto *crypto = 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: } 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 = { .co = 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) } 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 = bs->opaque; uint64_t sector_num = offset >> BDRV_SECTOR_BITS; diff --git a/block/file-posix.c b/block/file-posix.c index cb9bffe047..9c81e45179 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2077,9 +2077,9 @@ static int coroutine_fn raw_co_prw(BlockDriverState *bs, uint64_t offset, return raw_thread_pool_submit(bs, handle_aiocb_rw, &acb); } -static int coroutine_fn raw_co_preadv(BlockDriverState *bs, uint64_t offset, - 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 b97c58d642..4e8947009b 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -440,8 +440,8 @@ fail: } 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 flags, BlockCompletionFunc *cb, void *opaque) { BDRVRawState *s = 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) static int coroutine_fn compress_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) { return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset, flags); diff --git a/block/mirror.c b/block/mirror.c index 98fc66eabf..8595007be7 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1395,7 +1395,7 @@ static void coroutine_fn active_write_settle(MirrorOp *op) } 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 flags) { return bdrv_co_preadv(bs->backing, offset, bytes, qiov, flags); } diff --git a/block/nbd.c b/block/nbd.c index f6ff1c4fb4..c816933d7d 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1322,8 +1322,9 @@ static int nbd_co_request(BlockDriverState *bs, NBDRequest *request, return ret ? ret : request_ret; } -static int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, int flags) +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 = NULL; diff --git a/block/nfs.c b/block/nfs.c index 9aeaefb364..27f9ab8307 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -262,9 +262,9 @@ nfs_co_generic_cb(int ret, struct nfs_context *nfs, void *data, nfs_co_generic_bh_cb, task); } -static int coroutine_fn nfs_co_preadv(BlockDriverState *bs, uint64_t offset, - 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 = 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) } 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 = bs->opaque; @@ -187,8 +188,8 @@ static inline BlockAIOCB *null_aio_common(BlockDriverState *bs, } 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 flags, BlockCompletionFunc *cb, void *opaque) { diff --git a/block/nvme.c b/block/nvme.c index e8dbbc2317..c7fba6623d 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1243,8 +1243,9 @@ static int nvme_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes, } 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 *state) } 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, Error **errp) bs->bl.request_alignment = BDRV_SECTOR_SIZE; } -static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVQcowState *s = 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(BlockDriverState *bs, return -ENOMEDIUM; } - /* Call .bdrv_co_readv() directly instead of using the public block-layer + /* + * 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 <= INT64_MAX); + assert(src_cluster_offset + offset_in_cluster <= INT64_MAX); + assert(qiov->size <= 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-layer * 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 04ad512897..610fdfc72b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2310,9 +2310,10 @@ static coroutine_fn int qcow2_co_preadv_task_entry(AioTask *task) } static coroutine_fn int qcow2_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) + size_t qiov_offset, + BdrvRequestFlags flags) { BDRVQcow2State *s = bs->opaque; int ret = 0; diff --git a/block/quorum.c b/block/quorum.c index f2c0805000..57c73b2156 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -663,8 +663,8 @@ static int read_fifo_child(QuorumAIOCB *acb) return ret; } -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 = bs->opaque; QuorumAIOCB *acb = quorum_aio_get(bs, qiov, offset, bytes, flags); diff --git a/block/raw-format.c b/block/raw-format.c index c26f493688..a5728e7b0c 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -181,8 +181,8 @@ static void raw_reopen_abort(BDRVReopenState *state) } /* 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 = bs->opaque; @@ -201,9 +201,9 @@ static inline int raw_adjust_offset(BlockDriverState *bs, uint64_t *offset, return 0; } -static int coroutine_fn raw_co_preadv(BlockDriverState *bs, uint64_t offset, - 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; @@ -259,7 +259,7 @@ static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset, qiov = &local_qiov; } - ret = raw_adjust_offset(bs, &offset, bytes, true); + ret = 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(BlockDriverState *bs, { int ret; - ret = raw_adjust_offset(bs, (uint64_t *)&offset, bytes, true); + ret = raw_adjust_offset(bs, &offset, bytes, true); if (ret) { return ret; } @@ -306,7 +306,7 @@ static int coroutine_fn raw_co_pdiscard(BlockDriverState *bs, { int ret; - ret = raw_adjust_offset(bs, (uint64_t *)&offset, bytes, true); + ret = raw_adjust_offset(bs, &offset, bytes, true); if (ret) { return ret; } @@ -541,7 +541,7 @@ static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs, { int ret; - ret = raw_adjust_offset(bs, &src_offset, bytes, false); + ret = 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(BlockDriverState *bs, { int ret; - ret = raw_adjust_offset(bs, &dst_offset, bytes, true); + ret = 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 dcf82b15b8..21438dfb7c 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1164,9 +1164,9 @@ static int coroutine_fn qemu_rbd_start_co(BlockDriverState *bs, } static int -coroutine_fn qemu_rbd_co_preadv(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +coroutine_fn qemu_rbd_co_preadv(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { return qemu_rbd_start_co(bs, offset, bytes, qiov, flags, RBD_AIO_READ); } 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) } 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) { ThrottleGroupMember *tgm = 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(BlockDriverState *bs, } 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 = 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, } 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 = 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, BlockDriverInfo *bdi) } 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 = bs->opaque; int ret; diff --git a/block/vvfat.c b/block/vvfat.c index 34bf1e3a86..9c53c2d0a4 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1522,8 +1522,8 @@ static int vvfat_read(BlockDriverState *bs, int64_t sector_num, } 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 = bs->opaque; diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c index ce071b5fc5..2d3c17e566 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) } static int coroutine_fn bdrv_test_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVTestState *s = bs->opaque; @@ -1106,8 +1107,9 @@ static void bdrv_test_top_close(BlockDriverState *bs) } static int coroutine_fn bdrv_test_top_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVTestTopState *tts = bs->opaque; return bdrv_co_preadv(tts->wait_child, offset, bytes, qiov, flags); @@ -1855,10 +1857,10 @@ static void bdrv_replace_test_close(BlockDriverState *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 = bs->opaque; diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index c39e70b2f5..f18fa6e0fb 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" -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 bytes, + QEMUIOVector *qiov, + int flags) { return 0; } @@ -66,8 +75,8 @@ static BlockDriver bdrv_test = { .format_name = "test", .instance_size = 1, - .bdrv_co_preadv = bdrv_test_co_prwv, - .bdrv_co_pwritev = bdrv_test_co_prwv, + .bdrv_co_preadv = bdrv_test_co_preadv, + .bdrv_co_pwritev = bdrv_test_co_pwritev, .bdrv_co_pdiscard = bdrv_test_co_pdiscard, .bdrv_co_truncate = bdrv_test_co_truncate, .bdrv_co_block_status = bdrv_test_co_block_status, diff --git a/slirp b/slirp index a88d9ace23..8f43a99191 160000 --- a/slirp +++ b/slirp @@ -1 +1 @@ -Subproject commit a88d9ace234a24ce1c17189642ef9104799425e0 +Subproject commit 8f43a99191afb47ca3f3c6972f6306209f367ece diff --git a/ui/keycodemapdb b/ui/keycodemapdb index d21009b1c9..6119e6e19a 160000 --- a/ui/keycodemapdb +++ b/ui/keycodemapdb @@ -1 +1 @@ -Subproject commit d21009b1c9f94b740ea66be8e48a1d8ad8124023 +Subproject commit 6119e6e19a050df847418de7babe5166779955e4 From patchwork Fri Sep 3 10:28:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12474101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DC3FC433F5 for ; Fri, 3 Sep 2021 10:34:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7E704610E6 for ; Fri, 3 Sep 2021 10:34:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7E704610E6 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:46110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM6X8-0003eE-KG for qemu-devel@archiver.kernel.org; Fri, 03 Sep 2021 06:34:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM6R4-0002uJ-Uc; Fri, 03 Sep 2021 06:28:40 -0400 Received: from mail-eopbgr60121.outbound.protection.outlook.com ([40.107.6.121]:7190 helo=EUR04-DB3-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 1mM6R2-0002A7-04; Fri, 03 Sep 2021 06:28:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fK4J7ZtLUkQWR9ZzwORTdQK0GbANoZhAzVN6ZWs59GkbbQDWJIPZMEh5FkqdfjWeWDmv4V4GyvWIBPBidGfiYNLfKBWqozyH6+lA46cyRtfwk+XBFUYvAWE436l8XBqnyQ0huXloLTltbPISCBkvY9Pb+PiiZSxOeA2eNoY6MbqQOLcRW1zOmfwswc+6HP1IBrVFfj6AX0k+DweKJpMlndAzjI/oSFxciaSEQ1jefxhjdLazmMu41AJe2KF8zwJH3yA0/bQl7sTk8y5NqJVuSnRaeS9ciT3qoZ2f0UjBGBUnJjSfhQXejTt7osTa8hPb80KAYbPnkVnTIto1OMkCOg== 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; bh=ts3wsNNt4NddM6CWbhmH/TLehM961aDsA145gHDEkTU=; b=NRjmKyDAWSdWPrd0V2R37ISVjJJ+53eQ97Oj991ImmJ+cYYYl+hDVFfvTTok7tC9oA0VjJ0FT5/3ih7j8r9yDYZbIN6UHaIlf1DGv5VQFGcwstL0ArhMnawuzjQeoIRUBfyIfg7MO3I3FnYCz4yiS7IXCFCt8zvx4ZitLgkBF5VbziIgOaSzkMBnghaDvFqqemgpGIH1FTOA0FPKhf0bmwya6DNnTA0uXP2ATS6T/sOOSFoN37lzlmARmvN6HljKfM+B8Ck0oVFiABm2qlGHQIDOoQpnuprElHbY9SKXtvZ5e2LZe+uYojkOLrqfhF1iHkDeADenMnisOWowYBwGCg== 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=ts3wsNNt4NddM6CWbhmH/TLehM961aDsA145gHDEkTU=; b=Cy3lp+pJa8Tx4C03K3Mt/S/btvcdyPURTT1bjlIO3BS4/H2PCB+j0gTmtEVOjLK6zHtP8bHes06FMhukpzVczEmBhfKh4JBAqXU0he4z5mkkEIfUy0Is6wNZZr14/aDaFd2i8/iLMm5nmVSHLIyasuPqIrXI7nKe9867JBOq8us= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6945.eurprd08.prod.outlook.com (2603:10a6:20b:344::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Fri, 3 Sep 2021 10:28:31 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.022; Fri, 3 Sep 2021 10:28:31 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, kraxel@redhat.com, idryomov@gmail.com, berto@igalia.com, philmd@redhat.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, vsementsov@virtuozzo.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v6 04/11] block: use int64_t instead of uint64_t in driver write handlers Date: Fri, 3 Sep 2021 13:28:00 +0300 Message-Id: <20210903102807.27127-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210903102807.27127-1-vsementsov@virtuozzo.com> References: <20210903102807.27127-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Fri, 3 Sep 2021 10:28:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a72d1312-307f-4332-a3aa-08d96ec5936b X-MS-TrafficTypeDiagnostic: AS8PR08MB6945: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2887; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D46eD5/ZjPF8spl74La3kRTJv9q7Y6UcXGvy20ar/hPNZcc3gcw4YOj7iKykVqY+2P3QYNoK8sstSTcu1DH1/QwcFxR/sWz4Fi4lJwMhCsJxLWRao1DmF3Re2Brqort/vRsRiEEjggq9g0Odf7H/o5jBiVEM2TMUvvBLsfXSUHKRNjHcC6F11148i7d7FoQA3fyBPBg9pFvVw/i2RoxXY6qXx92xL/vghUx59fBXgb70CJiwacQChB2VO4gfjWkv+zZvj9Py9r2bj4RIXufYREaQaYmug5BjAfHXNQ+MVyPdDs5zo2BiS1zR5s+4zPlh7oEcJLBNxYfMOFrVl18cyJ6Ze1MMb2kCNydjHhnvmXy7k98eKIwyNNEhgI+8aUj+wa4WhVeVZoI+YNPjRv3DXM4v8xwwYyQAA8A7skVD8DxcqGoMing2VA/CRAuv/FhEcjQVfhAWzH1uPdqVF213dtHeocPkXX4vUaoP5KpTS9cXSj2lRxbXm2/6kRFVBWSbqCmEX0tNdSQxAR7OKWi6tFD477wvYUlCMBVvJUEC33/+3uNAEhWApLxR4MaT4sTXwaQBVXiUu+cQoUareRSv7Ix6TbtYZAYAHthSZtzwkASlSpXgXC+FURfdotYb6iIhfrxFaF0aW0MzcweAxrIyQlNIMypg6+J81piMikQcx9q+Y/ciuG+4pMlroF6dhEHIIubiCGkUf0xogx784p6Og+kX2j4ZQXaM1F6JDGuSRw4= 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)(346002)(136003)(366004)(39840400004)(396003)(376002)(7416002)(83380400001)(38350700002)(36756003)(6512007)(38100700002)(6486002)(5660300002)(52116002)(6666004)(6916009)(186003)(956004)(66556008)(2906002)(66476007)(66946007)(30864003)(8936002)(6506007)(26005)(86362001)(2616005)(316002)(478600001)(1076003)(8676002)(4326008)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZoZnYPo/7oVVTMkukQ+PWQqz81MDbWyXY0P0HktYk+AyYGkMP8uWdwWMgkQL4ReEQJ8j+AKEfDaHkyu0VeHfk/pDbsc6BHuzpZUNsyUFLW7Xlmyl/0pNBh1+kAPp76AKIVF/wic7Rsocup1GM5HAnyIIirdoRUiIX8EoeDZBTmfYGZjzg2s6uk7CDah1bLkvsTztwlWZV0S92rKiyJh50MGvVKTRH476yPhJcdFLk2U44CjP/oW/QRxU8/RMmNAltW2LQ8mcZpSMHIiedw0Aquh1I3a1FmJcOfQbDHz4G2G721rKyMf4/GEP3f5CFgo15JHJERNC0QUYLZuALxTbM2J4KIFvMaUnGjKfafccPfytG0L2ZIMSQodRh4W5eEnPScW761D97J6LUWGacvzUxx0Yn7dwxgvheWKm1hcAJp/hEMJPcZcgtSbKJCgOESgsOaVuMXKqT1iswyDyvU8jBh/v4H5EtVSaYEXZZTI7zG9nCID/Xc4jN8Ikg5iCanwBhjfQz7Hrd0aSdcVhtC7AXwWx9hT3vTfEcFh1ivI/zF+NPjL0RgZ9kODRdtTy9rZ4aAd70hsVPuAxBDRJ2G7p4wTvEcSWWeGOpuMp8Fp2jD1Y2jkYx2sViJV+4q+vIBwD3Vh3RS7GcIqwrv4lYtizCqYpnQaiPjbgyzbvAZaBZQKHKTPiOz1hM5sNmP1sdO8v0VQqTyKtbt/dVIFAVM3cSelHMJkUrWuyed6Ny1x3LqGrwQXQyG4hod8izYIFMMubyOm9fGtQUFjUq9IAtSCXP9aUspk/2PMMX9pohM0Za2DUz4MZSRGHjNIlgvfcYoTB8AH3h4+qShageTfJbgHgCjujgEOfZACwDeALnqL8HPy6XySuv//5CuTZvPCZmV6M/nLcC4QvQgbJBsnKr1fwR5LOzHKDG6iwNVfD1KsG0Swh+BAPGpOhtbKji5SFqtzkx/K10DPwM+YSSOI4tKITPtfTXKmmDk+Y3N9+0EPPvq4cJk+Ysb7WE29dosZBzYqRBtF7DEIDErXUd4lg1LbUSzpOgQLvSyectZzXPKiu2MrbPORGfIWf2rykd9tlrv/83YY1k2FjvKoWzFHiGFK2SZjesx/h4U3I6Nqtu/asPCY9PLUMnthMaNt2eSYvCNmXPsLF2+W34o2VS6IijKxr3ls01QeYR5wYE8I9/fcZw9o4eVKfjD/8pdrW2MAWKdfHBb3fbOgYIUr1Cau3tkpu21hACodeXzjRb5K8Nfpf72EtTzF1OzvVE01mzqENbyTQwQolhw3d6shKfgPEBEXBHxfQ9tqlJM49tIBAcsgJjnC5hQZ6WnysBP2zVqpAnLas X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a72d1312-307f-4332-a3aa-08d96ec5936b X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2021 10:28:31.2773 (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: 3S2CAm0LZLg1ifRGLqVSUS9SCeHhFvBMDKBOzcMXna/6l3voSVLiLhy2TNv0H/AuFnXfUhQ09O7qvkwTF+eM3320ELmJmwjCZpxCMTQT3bs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6945 Received-SPF: pass client-ip=40.107.6.121; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 three callers of driver function: bdrv_driver_pwritev() and bdrv_driver_pwritev_compressed() in block/io.c, both pass 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*=' | \ 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 Reviewed-by: Eric Blake --- include/block/block_int.h | 16 ++++++++-------- block/blkdebug.c | 4 ++-- block/blklogwrites.c | 4 ++-- block/blkreplay.c | 2 +- block/blkverify.c | 4 ++-- block/copy-before-write.c | 7 ++++--- 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 | 8 ++++---- block/rbd.c | 6 +++--- block/throttle.c | 9 +++++---- block/vdi.c | 4 ++-- block/vmdk.c | 8 ++++---- block/vpc.c | 4 ++-- block/vvfat.c | 4 ++-- tests/unit/test-block-iothread.c | 4 ++-- block/trace-events | 2 +- 30 files changed, 94 insertions(+), 84 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 4906f27097..252fb3df21 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_offset, + BdrvRequestFlags flags); /* * Efficiently zero a region of the disk image. Typically an image format @@ -428,10 +429,9 @@ struct BlockDriver { Error **errp); 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_offset); int (*bdrv_snapshot_create)(BlockDriverState *bs, QEMUSnapshotInfo *sn_info); diff --git a/block/blkdebug.c b/block/blkdebug.c index 12b8419065..e686cd9799 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -652,8 +652,8 @@ blkdebug_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, } 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; 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) } 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 bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { return blk_log_writes_co_log(bs, offset, bytes, qiov, flags, blk_log_writes_co_do_file_pwritev, 0, false); 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(BlockDriverState *bs, } 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 flags) { uint64_t reqid = blkreplay_next_id(); int ret = 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 offset, int64_t bytes, } 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, true); diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 591cc3ac75..74360b4853 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -86,9 +86,10 @@ static int coroutine_fn cbw_co_pwrite_zeroes(BlockDriverState *bs, } static coroutine_fn int cbw_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 ret = cbw_do_copy_before_write(bs, offset, bytes, flags); if (ret < 0) { diff --git a/block/copy-on-read.c b/block/copy-on-read.c index d34add4476..b2ec36b6fc 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -181,10 +181,11 @@ static int coroutine_fn cor_co_preadv_part(BlockDriverState *bs, 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); @@ -207,8 +208,8 @@ static int coroutine_fn cor_co_pdiscard(BlockDriverState *bs, 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 offset, int64_t bytes, static coroutine_fn int -block_crypto_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +block_crypto_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BlockCrypto *crypto = 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 9c81e45179..0afa60bfd1 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2084,9 +2084,9 @@ static int coroutine_fn raw_co_preadv(BlockDriverState *bs, int64_t offset, return raw_co_prw(bs, offset, bytes, qiov, QEMU_AIO_READ); } -static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { assert(flags == 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 4e8947009b..ec9d64d0e4 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -455,8 +455,8 @@ static BlockAIOCB *raw_aio_preadv(BlockDriverState *bs, } 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 flags, BlockCompletionFunc *cb, void *opaque) { BDRVRawState *s = 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(BlockDriverState *bs, 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 flags) + 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 0058cf4a6f..5aca909a80 100644 --- a/block/io.c +++ b/block/io.c @@ -1230,7 +1230,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 = bs->drv; int64_t sector_num; @@ -2070,7 +2071,8 @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, 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 = child->bs; BlockDriver *drv = bs->drv; diff --git a/block/mirror.c b/block/mirror.c index 8595007be7..ed3bc5b1c3 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1449,7 +1449,7 @@ out: } 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 flags) { MirrorBDSOpaque *s = bs->opaque; QEMUIOVector bounce_qiov; diff --git a/block/nbd.c b/block/nbd.c index c816933d7d..caee396525 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1381,8 +1381,9 @@ static int nbd_client_co_preadv(BlockDriverState *bs, int64_t offset, return ret ? ret : request_ret; } -static int nbd_client_co_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, int flags) +static int nbd_client_co_pwritev(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVNBDState *s = (BDRVNBDState *)bs->opaque; NBDRequest request = { diff --git a/block/nfs.c b/block/nfs.c index 27f9ab8307..577aea1d22 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -296,9 +296,9 @@ static int coroutine_fn nfs_co_preadv(BlockDriverState *bs, int64_t offset, return 0; } -static int coroutine_fn nfs_co_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *iov, - int flags) +static int coroutine_fn nfs_co_pwritev(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *iov, + BdrvRequestFlags flags) { NFSClient *client = 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, } 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, } 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 flags, BlockCompletionFunc *cb, void *opaque) { diff --git a/block/nvme.c b/block/nvme.c index c7fba6623d..63a638e52d 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1251,8 +1251,9 @@ static coroutine_fn int nvme_co_preadv(BlockDriverState *bs, } 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, } 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); 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; } -static coroutine_fn int qcow_co_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static coroutine_fn int qcow_co_pwritev(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVQcowState *s = 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 bytes, + QEMUIOVector *qiov) { BDRVQcowState *s = bs->opaque; z_stream strm; diff --git a/block/qcow2.c b/block/qcow2.c index 610fdfc72b..0ee664894c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2597,8 +2597,8 @@ static coroutine_fn int qcow2_co_pwritev_task_entry(AioTask *task) } 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 = bs->opaque; int offset_in_cluster; @@ -4631,7 +4631,7 @@ static coroutine_fn int qcow2_co_pwritev_compressed_task_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 = bs->opaque; diff --git a/block/quorum.c b/block/quorum.c index 57c73b2156..f4b76ea010 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -714,8 +714,9 @@ static void write_quorum_entry(void *opaque) } } -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 = bs->opaque; QuorumAIOCB *acb = quorum_aio_get(bs, qiov, offset, bytes, flags); diff --git a/block/raw-format.c b/block/raw-format.c index a5728e7b0c..d223298dfc 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); } -static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { void *buf = NULL; BlockDriver *drv; @@ -259,7 +259,7 @@ static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset, qiov = &local_qiov; } - ret = raw_adjust_offset(bs, (int64_t *)&offset, bytes, true); + ret = raw_adjust_offset(bs, &offset, bytes, true); if (ret) { goto fail; } diff --git a/block/rbd.c b/block/rbd.c index 21438dfb7c..efc0835ee7 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1172,9 +1172,9 @@ coroutine_fn qemu_rbd_co_preadv(BlockDriverState *bs, int64_t offset, } static int -coroutine_fn qemu_rbd_co_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +coroutine_fn qemu_rbd_co_pwritev(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVRBDState *s = bs->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(BlockDriverState *bs, } static int coroutine_fn throttle_co_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { ThrottleGroupMember *tgm = bs->opaque; throttle_group_co_io_limits_intercept(tgm, bytes, true); @@ -153,8 +154,8 @@ static int coroutine_fn throttle_co_pdiscard(BlockDriverState *bs, } static int coroutine_fn throttle_co_pwritev_compressed(BlockDriverState *bs, - 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, int64_t bytes, } 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 = 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, } 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 = bs->opaque; @@ -2080,8 +2080,8 @@ vmdk_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, } 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 bytes, + QEMUIOVector *qiov) { if (bytes == 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: } 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 = bs->opaque; int64_t image_offset; diff --git a/block/vvfat.c b/block/vvfat.c index 9c53c2d0a4..05e78e3c27 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3061,8 +3061,8 @@ DLOG(checkpoint()); } 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 = bs->opaque; diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index f18fa6e0fb..c86954c7ba 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(BlockDriverState *bs, } static int coroutine_fn bdrv_test_co_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, + 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 b3d2b1e62c..2f5c9c1d71 100644 --- a/block/trace-events +++ b/block/trace-events @@ -75,7 +75,7 @@ luring_resubmit_short_read(void *s, void *luringcb, int nread) "LuringState %p l # qcow2.c qcow2_add_task(void *co, void *bs, void *pool, const char *action, int cluster_type, uint64_t host_offset, uint64_t offset, uint64_t bytes, void *qiov, size_t qiov_offset) "co %p bs %p pool %p: %s: cluster_type %d file_cluster_offset %" PRIu64 " offset %" PRIu64 " bytes %" PRIu64 " qiov %p qiov_offset %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 offset 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" From patchwork Fri Sep 3 10:28:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12474107 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6016C433EF for ; Fri, 3 Sep 2021 10:38:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6CFAA610CE for ; Fri, 3 Sep 2021 10:38:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6CFAA610CE Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:53630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM6aB-0000ch-JA for qemu-devel@archiver.kernel.org; Fri, 03 Sep 2021 06:38:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM6R7-0002uu-HM; Fri, 03 Sep 2021 06:28:42 -0400 Received: from mail-eopbgr60121.outbound.protection.outlook.com ([40.107.6.121]:7190 helo=EUR04-DB3-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 1mM6R5-0002A7-Ki; Fri, 03 Sep 2021 06:28:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d+kOpGR59161n8AJtWGlZIp0wt66MM6bWt85tvKlYXoUqXTmmgUA4unLjItWv0rM7snGU963AAWZ+sDn537ma8PCSNQ3BYk5VZOJ88hMvvOMnuZu3xGKikd495Bj6NxuuQdndMqGB1qLU2ISdfX0HqI6iSV6yChDwdFmObkGKH5uQTLtixzZV4f8OhK/bzWJCkQ3OuHVXKChOP0Mpgvh3KaFwZPbKWgivXu9eoNJHVuVqwb82U3hvGUUBt/A+O4NeLpSC0DBFSpkdmD+em/EPz48EGML2SVdyVEp+5yv8c13r9a/7dDUdQ3N7gha8nbCVB6FqoBkH02INJZMUqMNKw== 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; bh=q3XJZCZ9465fNZaoUo4Bbha9pidk1+hfCBgv1fN+83o=; b=iYLKVeK3/6IgC49IA+W5rVKx8UJOJWwYk+heyo/Ch3SW0xv6OYS2wTslkmVAP6FESEFFzQTeJNPqH5JbwLJiurtl1kGJKfHfIRBPGlSQI7yOfkCS+yFfv2jcadbrP3ozBVyFZv6ml2YpDBSFJqkORN0swQxtLsAA6QcjKj8Q9Pt/CdC5q6K4KxZh4CW07pz5QI1e5879bykJniBreSWiztyNtrXZvIM4LZpFV+ZCIt8S++3AghZ1mKuHA4nWoWxiz7++CSKZmT3reZTma0KPIZ+JUDH49G4GZXFOiLsewN9iYUTGtI4Q4DZ6h7fdFmQDDnRhe1s1c+SCtOBgoJjJIw== 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=q3XJZCZ9465fNZaoUo4Bbha9pidk1+hfCBgv1fN+83o=; b=aDF1/oyTuIn9PtWrk9CJ1LljGqzl5pt+ok43c7MMTanpcgc2mMMmN5zLN9iSb4zxN7nYgoS1UvSBACwLO1X/6quwrHvDeuq47846+G6Mv2x+ZDktQ26QWQl5FqbbqyBgfoOoWIctRdSX+w3AtW1Sod6VPhABP07vfba4sQ3gTao= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6945.eurprd08.prod.outlook.com (2603:10a6:20b:344::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Fri, 3 Sep 2021 10:28:33 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.022; Fri, 3 Sep 2021 10:28:33 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, kraxel@redhat.com, idryomov@gmail.com, berto@igalia.com, philmd@redhat.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, vsementsov@virtuozzo.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v6 05/11] block: use int64_t instead of uint64_t in copy_range driver handlers Date: Fri, 3 Sep 2021 13:28:01 +0300 Message-Id: <20210903102807.27127-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210903102807.27127-1-vsementsov@virtuozzo.com> References: <20210903102807.27127-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Fri, 3 Sep 2021 10:28:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8787d864-a5b0-4634-7e9f-08d96ec594a0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6945: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1468; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kO6rLnHGtyAjSaNHHgplZMkqQ/3Cv7q42r8hiy42RHTIx/zdGrVRcXEvVu4R2dxMFmgfjvXpKL3AMXm8Lt9J+rUZH7Quthl5XYOiHWRIO6E88FJASsaFwuum0tHCMPmwdOK+t754jyMxCktiQl3aqxW6dZUjdiK1/Mcury1GVppmTRVlUxY7CH6GmsXurnkgbq3MuVzRg1OguOcR1i29dwDdooZg7T2uAJ7EE68Tt/2t8Um7q2UZKSWQAR9PM0KbJ8VPsI+nZ8iilgP8x7D0/zj4bAyw87osRWeV4dgR0Qz9MeP6JcC3wt+hanpsR8zBP9NcnnE6In4L6J2C2w0rDkEjZOuwiD1Cl1feU1+wEOyKIFBSmefFKLEafDhJ3u4JHp74kX2Q0D/koBYk/ipzvnms71TiKF0YcgQyau7TTXeAMHeirOlY08DGf21Lz6dSuo7yFzxrVIz+Gxg2HPRQ9ac9Wb7AEBAEdDc2RFGhQKaSVul6AwyovjkbB5cKxs9bUss/iJ1PWvtO31NmOoeX0ltoFgskqAeW/G0t1K/zzpdUbcdHulTd3a6zZ6g5Xf1D2+TijIBbRfWJghGTVEochNZVpIo+bO1lxAHa1L+yHLnMdKGZUSi4C4TPmVa7i3sxm5HMhwyfDiKTk7DXI+EzcLeSzEsCOwEf3cRyIR32534u5exqquS1nGVQIsNbcegdqzAY38jyvFtznrzsFK9NVg== 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)(346002)(136003)(366004)(39840400004)(396003)(376002)(7416002)(83380400001)(38350700002)(36756003)(6512007)(38100700002)(6486002)(5660300002)(52116002)(6666004)(6916009)(186003)(956004)(66556008)(2906002)(66476007)(66946007)(8936002)(6506007)(26005)(86362001)(2616005)(316002)(478600001)(1076003)(8676002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hWE6NYjvjpF8JrUbEzKopKrzHy5OunphdkBPYmE70IpLJl4WvJaspEO1TTp0nmLLbJ/uhjv05GoiAfLLfddpTrgG4X/6SFjkcNBXDtEcRPMYJ/WyC3A+jYu2OTG/Pze3MpFf7CvlD/21jwjPq4P0zxSaPvZTzwFyZLs9jJLO/0ceQdFCe6jc7wi0uqmyoEsSNLLW1n3G9D/An6fRHIqqUYHExswuWFgPFWEWgOiSIxLuVPl/6DLIsOtTKRk3j0C4zWefVJTnTKl6mp0s04NrWbHgG//4EF4R9HlK+4LxTiaYM4NmF1B90dbc9TRWq2l+7LrC7jN46V5D2gyPmoh5hnhU7sPA4g5TojUXTlV16HuXkYNXJIU8MFrYTLkcVSKnQdz3m6jzW+Ik3jWTbwWB1MiyvmA/Q6KfK2igl/Y32xL8ylEoqpqiLQIxieQnhi6rBLQeei/AvZfKiPZqgVJoDufpWgFJ93/eWxPt3AWdyAqkM2ibtjF5A8Nw+Atsm/ZORL8LTPvkwfa4TD5FlRzmGM+Do7g9pZ+yN15BXhC+C6k98FETPPsYOdRXgS6ju/6ZR0Gqli7Ai34fpvi6ipk82zC8g0MtsLp4QFKO/qdLmXYq7OFr5GNzGOLCb2XE9V/LiuAyerg5lY5BVDrazwOG+8kTl4dz5Zbspdvp+KxEi/a6Q0rYdKfGO3yRAYt66byeCjWH7/HgYW3wqCy1Rg7ydjTvISHYmocOCwLbuSxBrcNYxnr8SP84jr042nkVNnAbyyf8sT33/LdkcC24LXEUaBMMJHVEr/6uphmJahQ2pyrprhvB0Mq6Iahp4j6EWzXv3SFpWqshRXB1qYVmgWcZIOs6vAfSeNcz23VQnxd3yC4RGsaZSe9pBkPQmfj8vZHW5NYm+O+MUwB8oyBVEQOAXUvZV0HEksCU7QeSO3UlQm483rPJVG/iKPKVArv3oGYI1MO9vk95YH3Yk5YDqlkM4zlKpGAQz9OJKQLuvelmupFFnCKPGkouQyDR2Kcj3/7Rht1v5UAk39O4CXuvK1bxfAxSS48QbT0kYHslzP2p2Fli1BrqJTJsLS5JmNQxoSURTpo0vElBmLWzYcy/+wOPpMi/2kDJlYDBp24DalQ6bKhhlfY1tKybt9Wi7zjdCXApWr1KronLdNjucla5Xy6KzsVM9SEitgcTVef5+7eKUAm8ZlKlJpG4gYsILqhwKBeep3YN4vBD+9EFcyfMrN5GKjV+slKGWOubjij1ab8YHPv4mE+dVEVgi17qAJ5f7iTNi61S/p3lycBYw6LecTOX9CPnVfYfxcJdcWByHKy2pe+I3Sz5wkjLhvbQQXDFhQGo X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8787d864-a5b0-4634-7e9f-08d96ec594a0 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2021 10:28:33.2317 (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: OZyxv6ocGRI2X5GbqMb4HE7P/cmJkZ3YdpH/CSgar0l/YVK1kjPg8jay2oeqL0VwXnTnS3JsJ6TB8bq6sYrvcyFfTRG3Fn4/qDYwiG+T6bI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6945 Received-SPF: pass client-ip=40.107.6.121; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 does 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*=' | \ 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 Reviewed-by: Eric Blake --- 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 252fb3df21..f40a2e1f5d 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_flags, BdrvRequestFlags write_flags); @@ -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); diff --git a/block/file-posix.c b/block/file-posix.c index 0afa60bfd1..6c64061a47 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -3202,8 +3202,8 @@ static void raw_abort_perm_update(BlockDriverState *bs) } 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, @@ -3212,10 +3212,10 @@ static int coroutine_fn raw_co_copy_range_from( 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, 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_flags, BdrvRequestFlags write_flags) { @@ -2313,10 +2313,10 @@ static void iscsi_xcopy_data(struct iscsi_data *data, 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_flags) { diff --git a/block/qcow2.c b/block/qcow2.c index 0ee664894c..100eda03cb 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -4026,9 +4026,9 @@ static coroutine_fn int qcow2_co_pdiscard(BlockDriverState *bs, 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 = bs->opaque; @@ -4109,9 +4109,9 @@ out: 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 = bs->opaque; diff --git a/block/raw-format.c b/block/raw-format.c index d223298dfc..345137813e 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -532,16 +532,16 @@ static int raw_probe_geometry(BlockDriverState *bs, HDGeometry *geo) 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_flags) { int ret; - ret = raw_adjust_offset(bs, (int64_t *)&src_offset, bytes, false); + ret = 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(BlockDriverState *bs, 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; - ret = raw_adjust_offset(bs, (int64_t *)&dst_offset, bytes, true); + ret = raw_adjust_offset(bs, &dst_offset, bytes, true); if (ret) { return ret; } From patchwork Fri Sep 3 10:28:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12474105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86F86C433EF for ; Fri, 3 Sep 2021 10:37:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 03997610CE for ; Fri, 3 Sep 2021 10:37:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 03997610CE Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:53036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM6Zx-0000Dh-2z for qemu-devel@archiver.kernel.org; Fri, 03 Sep 2021 06:37:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM6RA-0002vz-JO; Fri, 03 Sep 2021 06:28:44 -0400 Received: from mail-eopbgr60121.outbound.protection.outlook.com ([40.107.6.121]:7190 helo=EUR04-DB3-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 1mM6R8-0002A7-4I; Fri, 03 Sep 2021 06:28:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f+sxhzwBEtdiQEjMh4Em8B2fcrqfwtJhOaH47AwQXEUv8DnN2EFH5wcQNKM500SAzD0JsVq9NOPZERhPvgb1WCkN/nrOU0TEh9viXoVzvEutjAzs6TlUQZ84k7180OXDL8slyNanKmF0yt5a7xlPP4aACj3cjRRv0viqc8oO1Ld7nT3sxJygpWTqqf7zRtVdm/SvcM4h03b3bHZo9HxagLoXIwonhVC94j4d3gREdfqoiwtMjno9Hx6JWuh3kA3R9RcD4LTtuevvOCQuE4daDYzja6fs8nxZ5OWRZOvnjuFLQ8asENRm5nur2WGTUu+HqkF5TF/w3UEFVaCKtBd/Ow== 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; bh=o3b4R5GGVndcXn3hG4AnNKUZO6WQRTj02QXpue39f2c=; b=amH+8cypkELzpZHfwo0X3it2Hnz7KMEHafIdZg/oGbHAyjvmrKFYib/GHuShploN2lJbCxbvXZcjVyxzJLgGO6+zCRags/N4cGvWqzp+Ki6WCTxX+G1B3Q2NNtUkKJSJMQboRKyCbnOrMwZeqLE0GoC20MH3rCwYtCl6yqsRZr8vnSu2VQsD6b+OLxkjQswaj/+eiObxnLuQgqvW9tFiD05TPazc7ZFED4aWdRWPifa37Ek9xDXjHbKntGsGnn+NFwcgmE6ndpI1x9RwRNUnohBp7ij36XmGybMdo5uGawMphwdQhXY1TfbN7fEY67FPtbvp7vYh8JlUe0IY1/ox+w== 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=o3b4R5GGVndcXn3hG4AnNKUZO6WQRTj02QXpue39f2c=; b=TMgHRxwFyv/MbfeLZRRDP+5diBDHThtGLSAn9dFm7yQekabgEE7HITGF0xzri61kaTHvAaMhOsPGAZDq+o3Yv38D+DVx3VltE5uAxPAd0NhJJC7RicXfagGzJMceAduAfXdRK/ZAGM+a+HLjB6rVyxOTOaPaccT0l1Dl9uTW9aQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6945.eurprd08.prod.outlook.com (2603:10a6:20b:344::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Fri, 3 Sep 2021 10:28:35 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.022; Fri, 3 Sep 2021 10:28:35 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, kraxel@redhat.com, idryomov@gmail.com, berto@igalia.com, philmd@redhat.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, vsementsov@virtuozzo.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v6 06/11] block: make BlockLimits::max_pwrite_zeroes 64bit Date: Fri, 3 Sep 2021 13:28:02 +0300 Message-Id: <20210903102807.27127-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210903102807.27127-1-vsementsov@virtuozzo.com> References: <20210903102807.27127-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Fri, 3 Sep 2021 10:28:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b971aed6-0e35-4495-bd95-08d96ec595c8 X-MS-TrafficTypeDiagnostic: AS8PR08MB6945: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SJpM81zDgEFIuCkajxUGUef7o+9YLoN8DO2k3UEWMBEamfRhYVopxBr1L7bzbK6rL2mDWO6UXu9maK61HKaBoevIJfqBZNnKGIK5t9bIqUrU72aGmkPgJNkf29kJSe1xPtlLRr+Oa9ERekuChv9//AchNrV2Aoyx2sJGcWYJcPz3ZUjOZPSPxsGQVG8BLGdmk9mhwj5ZkHVRnlpPyi+zLNlzbylxOlOO1NGiyln6k1pImvQbtUQghonQUAQQ610ZzG4rV3wOqkFrZRF+GA/LEh3rLTBsL/TXNcHKoz7TuECgfSesZVUsDSY6YzkvlZDpOhleJwL9oUrEzZPohZ+aB5eYTta55ngCuEMjPh4Zk3TvmFVVqDYFgvE+JlycW3Y72UYoSm7Mr6vQ86IQRbIilUDuRpP0KjbbBqzsm0L6UIEMNXKNjWWiNLq3IynIt3HrCnKH3TkH9kDDQzlXoFselC+Z1GfhJBh8C7cXWWBWXI8mvXZ7XosogzdcP7a/LbDPKk+PqrzPw0Ev2lPxAFJE+kwzXa5Qhbx1Rk/Iym0qXTUV1XkaTEbkIRvr90s6ulo+zI9HpqSU4A8xDxjiHzfhz72I7eSM+3XIfve3eZZWDIu348hpqHmHNV18jEGoSqbCXMmgFRraYBEB3xsYVlb5HFhQ2GeZa8UjwNII5sT+op5fFUtGunLZzkfKJq0fNPUU84xjZ8M4eaEoN9owQEgH6w== 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)(346002)(136003)(366004)(39840400004)(396003)(376002)(7416002)(83380400001)(38350700002)(36756003)(6512007)(38100700002)(6486002)(5660300002)(52116002)(6666004)(6916009)(186003)(956004)(66556008)(2906002)(66476007)(66946007)(8936002)(6506007)(26005)(86362001)(2616005)(316002)(478600001)(1076003)(8676002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +0usES+7uFCGMm+LPXchI5DBnJSzrzVTIhkPMugDoy/+4+3Eufd/vJz3Tff2iy95UK9RfdIDVKDdzH5r6S3i240vAJQiZYIKxUDLfd3Ng5ZpASlXLfzkGrfkOInuNJYOd0GF8fX3p8HQMG+cjHte+xOX6tCE6BSgHZFs93hn1F9MHi/J+IrH0W/ruZt5ZZ8hw/x/HpfOGfQNJNkyNep8zhIhdIhnpJDx30hhr5CjShVrnYZwrCgM0V2mJqoIQ6Ykws45QTSFZH5tlG19hRp1Pv2tRuN0FRHQKWe7YHP6BzTfy4QE+Iz6gofC/xDqxmOxIE3sxzdAe0vnTi0YQBxJ/2QSzd+pz7mEu1OCZcJsvmbBxnnJS0DZjbHSuck+Edi6MKCl5l8cT2o5BTHWOaDaP/U+6m4UQWyeoLnXeVi5W3bclsbvZqMiOwHWR4EjHknlyr3OsjTdB4NbtYRBniDPtNZQNqXyfV/4aLOQx+jJ/xU2Ahy1m3ACkKvsZioJzUzKcJcvUHv20xuuLYI4TDMBTrwPwpKoE3J124L5BQVrOaICLeHexG2Nx9ox3I7tQ94xdQEf/zej6Zbrkqlu0H90tvAoa4BSIukFrFEMKlce5GhZQwq8Q+bTnPZPgNziSDAINudERTViKTMRAj69UAu0BjhwpLbHf2EGoYfIgd557oV6U8RdgAy3hTSGWTUc3I0sqBFduJm4c+4i/PKOtFNkaU/ctAHxbB3cGLOQH4i6jDeEpPzh4gyHugZMAAU8hAzYPPwgFLc7ydZyeoSb/ylDPmCBW95dqZI5bGYSar/0ObrzuTaO5iKbKlBgZ5/ErMSboIVugfz8pQnDPK0COuRd+piwzU8G05xTLaM58qv0NnZGyPihAiekDReiC3oRC3p3P6ASau7QLhbg+Hcxo6rH4lDcm9U5dMU1ronizeVTmsPGxnwtoCpq/tB6c1mzu8fonAURKXfLjgbdJv2kIVug6IesAHXoYmdlR1oSI5kSNUTOP4oZPn6D3ItsAmcwwIKlH5ax5yqjzDUo108V4uwMXg9avWuPKIn7Xl2xUgdmNJxbF0yvRgD+TYxLM/dv7L5tJacp7eEYybew9rShhU7wfo4KmVS8S+PbjROLreu5XBN77UPsfUB+XQAhl2rh4mpfoz0tZ2ZLayibdgQ1bYRJYxsOgpNMnD4ycRQvZtzo2byJDiP9+GLDabXLrdWTsy/z820fSLQAnZBytFI7W0ozo97BpaWmd7sDPNK6uhXBaDXwZ+VEVryYBRdhdQVA3M+eCi62mLAfyjm0kNfM8GQn5XfzTajdiUR7/xKUvSWnb3Nh5ZR4bgLXxfEyt3rSCnfJ X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b971aed6-0e35-4495-bd95-08d96ec595c8 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2021 10:28:35.1712 (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: AI7sj+nHtb7USjCTiIuawQNM7XesH2zYuQeWIt0Q5AooQmmCXRxXpnNUkvJWfR9RZ51ruGdQQ3LNXb6joY7Kr1gFzdmdaw8MK2ZN9Z9tBEg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6945 Received-SPF: pass client-ip=40.107.6.121; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Eric Blake --- 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 f40a2e1f5d..6c47985d5f 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; - /* 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. 0 means no limit. + */ + int64_t max_pwrite_zeroes; /* 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 5aca909a80..b4dce946bd 100644 --- a/block/io.c +++ b/block/io.c @@ -1869,7 +1869,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, int head = 0; int tail = 0; - int max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX); + int64_t max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX); int alignment = MAX(bs->bl.pwrite_zeroes_alignment, bs->bl.request_alignment); int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFFER); From patchwork Fri Sep 3 10:28:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12474097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A860C433F5 for ; Fri, 3 Sep 2021 10:34:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D0741610A2 for ; Fri, 3 Sep 2021 10:34:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D0741610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:46044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM6X5-0003bE-SJ for qemu-devel@archiver.kernel.org; Fri, 03 Sep 2021 06:34:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM6RE-00036F-56; Fri, 03 Sep 2021 06:28:48 -0400 Received: from mail-eopbgr60121.outbound.protection.outlook.com ([40.107.6.121]:7190 helo=EUR04-DB3-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 1mM6RB-0002A7-7w; Fri, 03 Sep 2021 06:28:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=acwCHFz+wcJK7EgO90hSlzflljxYkLDfAJ7QApXgWNi9Drtbwobm6FfZGwOQ6RISoiwkQ5dW+sjwB+QFIGbuxMdodINC48iXnUGPZebX6Vja4OjiCxgPucyQDe1Ju3oKD9j6Pp0QrxWqvmWPV7UtW0f+mdfLVQzk5hhCcCpkXYvi6VBn3Qf2ndCG0VCDQPoCk1/3ifipGUSx0Ksx7U+413G1dRndMqpbofuuav9rLj9mhjC4dONY1nURH2ZuZmrswPDbj3H50OC89YTgOFjgDQnaolaolxT32+gRktwki/32i7N5rODuSlfnjJ6e4qtZItKfzTYkt7kNO17c0Xqslw== 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; bh=kbBnTp8aclESdDddxVHo1pS6Z4OhbktDEoAeyEHzUzQ=; b=IClfkuawDmZsLOvhd2+NyTpDydzRZAmPmR52c3PdKgW1oAVzEEE1SDNhGjFMLgmCFNS2Srz0hMJ5Vg9SzRWyej/vwuKEmhCg66+i7BFYGWNnQBnRm2TzUOUJ3Wn/u3mnq+maLN2Nrkfym4uVZ3/FvfA5AZH0RGI5rZAYZaIkXw5zt762Kucxgu7+K3KsnrfmLr4Felzj6mP16rAw1Ekk6TRwemluHF6GDn/HEM8SKG5S+YMToMpnkpFh5B6o/RzydteCyWtT0FnF5r5XAHU5ME4W8CDHTVUYmts9zHtXhQYWBI7Eg1AfIJzQH9LNpUGUyMbsASSUQgGF0jaiM0mVyQ== 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=kbBnTp8aclESdDddxVHo1pS6Z4OhbktDEoAeyEHzUzQ=; b=URf1wk9h0drcI8VrnfPIquh3pq4QlcrMtTnjsBl2ZrAjUdsZmhQZsMlPrvJACXNFvXQP1MblMnWTA17wy8NtRfIGte6X5HNuroqluo1MdkoWpONXDEZ+zerGerKfSuwrOeqnkzHM7915AQv1sZ2HMU7rtgx32fn4u9+nCwZKSRc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6945.eurprd08.prod.outlook.com (2603:10a6:20b:344::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Fri, 3 Sep 2021 10:28:37 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.022; Fri, 3 Sep 2021 10:28:37 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, kraxel@redhat.com, idryomov@gmail.com, berto@igalia.com, philmd@redhat.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, vsementsov@virtuozzo.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v6 07/11] block: use int64_t instead of int in driver write_zeroes handlers Date: Fri, 3 Sep 2021 13:28:03 +0300 Message-Id: <20210903102807.27127-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210903102807.27127-1-vsementsov@virtuozzo.com> References: <20210903102807.27127-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Fri, 3 Sep 2021 10:28:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3085679-daf9-456c-1d0d-08d96ec596f3 X-MS-TrafficTypeDiagnostic: AS8PR08MB6945: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G7hceJQqXKavNXlzbicgLq1odP6uyxOgHCm2omHS6+MRHntjSh9Ncsh1RUCMH/jlhqmcAZWVBVpLDlD/5O0xlmBOqnmGouuMTws//3Lbfb9wC44fS9ptbK9/A2rSEKi9fv1fSZOr7WI/JCdsW3dyBVRJEWbDiPf3+JRndJ/s5l2AS/fbGSn8squ7PRcp3k/szH5QRbiQz2S4f4rY9xAcMbZZO6tMDYtRgfQPUGNKPDhrHTvl4TJcQHDsX6xgnM+kTLUYgQV4vN0Ax87sZ69m8E15nDsaNFTHAG9CVPQUd8eBfi3r754f0tOPyRygu+AM610AJyr7hqC/ySYwA2oERYRBvLcAGvsVcKKS9O3XZ+bef4+psh1aJAE5PMm6PQmw37m98Ywh5WC4Bv0VZme50D/saYybGDsW3ywpiqs9fJ0htPp5CC2gtP7YhwU9IrHfl2A7ABMJj257gEWZvjmzdmKqDctQFiBk+8Yy3AhAFHU4UiPKZP8AjEUFcsGnfcL8fLHEVB+SjiC1k5yDK8E5BQK4uKCl/gmSqgWHz7EOZa+h2l8/HBbYdMHzYhDHYkF70xWnQushgYgk/XoCDcbEP5ad9ZhriFG35TNXvQOKIJ8+0AGDWt0EF3t3ff2j0KLehC/jRvM/LWmTh04PxAqFDrFysgRkXUbviCXUR+8mx0VZxQrxWXUDyvJRUxWFCNYTaNkfeHkiPBkaynoIXrncVg== 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)(346002)(136003)(366004)(39840400004)(396003)(376002)(7416002)(83380400001)(38350700002)(36756003)(6512007)(38100700002)(6486002)(5660300002)(52116002)(6666004)(6916009)(186003)(956004)(66556008)(2906002)(66476007)(66946007)(30864003)(8936002)(6506007)(26005)(86362001)(2616005)(316002)(478600001)(1076003)(8676002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XnXTxL1EAPrZOI0ryCP6L8IES69rd5yp0FSwKliH4Ai0TU1hiLkvC0Cyfo1md1J3nEtogXCwjCfgcg4MGpmVLeZDZ+pRkKlfCNMD5tYuhTu1Yj7swNLRy14ejpM9bxPdogykAV8UA23VpPHzbz3eJnzPB8ttZvDM8//pYw/nkF2N6ZnUYxklFfJzaeMUEdT9PP6LMjQWOD9nEQJph3Ah/sqzoM5VZ6u09gQbNv+QMuYlXcdv9KeDz6XLRWcnsG/VMrJEob4aNIk6LgyZ9W6CjlUpbS1JWpqNQJHThTFiVbhvR2F1cGV8QmzvVH6haEO2JS4radr3lzh5S/B0HXC5vOo4phRH1qYRumwP4voChcS96x6bAPXY5ZyB9p78zsvTjAEpt4e6jd+8CthfS+7FxlouRhdiw4/XWNuZ//5WkRYN7u0jX2Ryrv7pb77U/5rt/YOWrP/dYbyhicLczAsjqGR2pJHcqRw2gYbNzdG4thgfRJPTAIvVsMCaXuN2l2L7wbpmUqJQXX6gtHfej0X8+LxaHFfgOsgo6D4edwEEe2foXTfxaDJpy7hsd5fGwMk8oK0bjDIwoV974kd5kLI5gmYWoX5O794oVR9L3TtdHrulsMPWc2ZkN5akW69ITEQJxBM5cpIkGCzMDgUM9V/mFDFDtD/ECTWTJUlb5z02XNo0lse2BGKmq24+oGgZN2M2LwuwKah9JKgbuGNe9DUYtTJh2fF7+IbHe331o4jeq4ZLD+oYf/88IrRlbhzaHS+EfldoQ90GK5PbYUHeMsxk5KrwZYbXIQMw8iCYaciwDhORS+CGEu/Rytzj8RrIZxg+SuUZwRqamxQKJtE3gUuh9Sch9Pn9Crbf6p/fXeUfQC+8OyV1wlWWzz7Us/SfL9/hBqpLm01RvMagB+KaqYGCkahHvxto1PMBNgL7lRh1rykc5FdCfIBVhEwJ2s251KQZ9szyj5UCp9spiNKKftFB5O+NBLBP3yqFmfqZM9IAObAESqlJ+Md7uzUDH5yFwGaOLd2DzcAOQLpzttM03My3Lv66miZRfAOxDqGurB9d3o8dK+9b+/JXYZ5nQn7772tyS+eAYlKeBlQy+vnrQMvwgfCoiKpjRtUo28xTvVwE0aVH/Eqdbar2ADQlesXEsGMN9eFPhybhOPjHEmR8qLAoxhLSLYF2+NoEcSuXS8ZGWpSWIGvtvcF+MfoR+RFm/WSt1pUZhlzJmq84Zkg074IlCwbmBNFbB66yvWj4PQ164la3+LjKz2ZbNs4XCR+PbLkatl18qfjDY3ZfkNbkkw8enG/HK99DJ3lOmqLUOc9W0yA3UNYZ62xQpYMvV89D2fQG X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3085679-daf9-456c-1d0d-08d96ec596f3 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2021 10:28:37.2451 (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: R3q/3AlXgvY5JQAqZNIV6lQr1NKLoDQQCfb/2Z1T7+x260Xo1tVydQlwR0lxfdPkJC1swJzMAtUgVKJ2JwWL/MrcIITDLJAwvoRoIsbFHgA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6945 Received-SPF: pass client-ip=40.107.6.121; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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, they 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: 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. blkreplay, copy-on-read, filter-compress: pass to bdrv_co_pwrite_zeroes() which is OK copy-before-write: Calls cbw_do_copy_before_write() and bdrv_co_pwrite_zeroes, both have 64bit argument. 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. Check also where that uint64_t gets handed: handle_aiocb_write_zeroes_block() passes a uint64_t[2] to ioctl(BLKZEROOUT), handle_aiocb_write_zeroes() calls do_fallocate() which takes off_t (and we compile to always have 64-bit off_t), as does handle_aiocb_write_zeroes_unmap. All look safe. 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 uint64_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 handle bytes=0. Let's handle this case too. trace events already 64bit preallocate: pass to handle_write() and bdrv_co_pwrite_zeroes(), both 64bit. rbd: pass to qemu_rbd_start_co() which is 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 Hooray! At this point all block drivers are prepared to support 64bit write-zero requests, or have explicitly set max_pwrite_zeroes. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/block/block_int.h | 2 +- block/blkdebug.c | 2 +- block/blklogwrites.c | 4 ++-- block/blkreplay.c | 2 +- block/copy-before-write.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 | 30 ++++++++++++++++++++---------- 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/rbd.c | 4 ++-- block/throttle.c | 2 +- block/vmdk.c | 2 +- block/trace-events | 4 ++-- 22 files changed, 78 insertions(+), 41 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 6c47985d5f..112a42ae8f 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); diff --git a/block/blkdebug.c b/block/blkdebug.c index e686cd9799..742b4a3834 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -684,7 +684,7 @@ static int blkdebug_co_flush(BlockDriverState *bs) } static int coroutine_fn blkdebug_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { uint32_t align = 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, } 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(BlockDriverState *bs, } 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 = blkreplay_next_id(); int ret = bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 74360b4853..d210e87a45 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -75,7 +75,7 @@ static int coroutine_fn cbw_co_pdiscard(BlockDriverState *bs, } static int coroutine_fn cbw_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { int ret = cbw_do_copy_before_write(bs, offset, bytes, flags); if (ret < 0) { diff --git a/block/copy-on-read.c b/block/copy-on-read.c index b2ec36b6fc..f83dd83f14 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -193,7 +193,7 @@ static int coroutine_fn cor_co_pwritev_part(BlockDriverState *bs, 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 6c64061a47..d90a0bd723 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2971,7 +2971,7 @@ raw_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) } 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 = bs->opaque; @@ -3039,7 +3039,7 @@ raw_do_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bytes, 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); } @@ -3604,7 +3604,7 @@ hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) } 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; 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(BlockDriverState *bs, static int coroutine_fn compress_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/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(BDRVReopenState *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 flags) { int ret; GlusterAIOCB acb; BDRVGlusterState *s = bs->opaque; - acb.size = size; + acb.size = bytes; acb.ret = 0; acb.coroutine = qemu_coroutine_self(); acb.aio_context = bdrv_get_aio_context(bs); - ret = glfs_zerofill_async(s->fd, offset, size, gluster_finish_aiocb, &acb); + ret = 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..eaeb93ebc7 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -427,14 +427,14 @@ static int64_t sector_qemu2lun(int64_t sector, IscsiLun *iscsilun) return sector * BDRV_SECTOR_SIZE / iscsilun->block_size; } -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,12 +1205,12 @@ out_unlock: static int coroutine_fn iscsi_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags flags) { IscsiLun *iscsilun = bs->opaque; struct IscsiTask iTask; uint64_t lba; - uint32_t nb_blocks; + uint64_t nb_blocks; bool use_16_for_ws = iscsilun->use_16_for_rw; int r = 0; @@ -1250,11 +1250,21 @@ coroutine_fn iscsi_co_pwrite_zeroes(BlockDriverState *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 = iscsi_writesame16_task(iscsilun->iscsi, iscsilun->lun, lba, iscsilun->zeroblock, iscsilun->block_size, nb_blocks, 0, !!(flags & BDRV_REQ_MAY_UNMAP), 0, 0, iscsi_co_generic_cb, &iTask); } 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 = iscsi_writesame10_task(iscsilun->iscsi, iscsilun->lun, lba, iscsilun->zeroblock, iscsilun->block_size, nb_blocks, 0, !!(flags & BDRV_REQ_MAY_UNMAP), @@ -2074,10 +2084,10 @@ static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.pdiscard_alignment = iscsilun->block_size; } - if (iscsilun->bl.max_ws_len < 0xffffffff / block_size) { - bs->bl.max_pwrite_zeroes = - iscsilun->bl.max_ws_len * iscsilun->block_size; - } + bs->bl.max_pwrite_zeroes = + 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 = iscsilun->bl.opt_unmap_gran * iscsilun->block_size; diff --git a/block/mirror.c b/block/mirror.c index ed3bc5b1c3..64ef53cdd4 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1494,7 +1494,7 @@ static int coroutine_fn bdrv_mirror_top_flush(BlockDriverState *bs) } 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 caee396525..5e1c4f30b1 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1407,15 +1407,17 @@ static int nbd_client_co_pwritev(BlockDriverState *bs, int64_t offset, } static int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags flags) { BDRVNBDState *s = (BDRVNBDState *)bs->opaque; NBDRequest request = { .type = NBD_CMD_WRITE_ZEROES, .from = offset, - .len = bytes, + .len = bytes, /* .len is uint32_t actually */ }; + 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 63a638e52d..760d7bea73 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1288,19 +1288,29 @@ static coroutine_fn int nvme_co_flush(BlockDriverState *bs) static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, + int64_t bytes, BdrvRequestFlags flags) { BDRVNVMeState *s = bs->opaque; NVMeQueuePair *ioq = s->queues[INDEX_IO(0)]; NVMeRequest *req; - - uint32_t cdw12 = ((bytes >> s->blkshift) - 1) & 0xFFFF; + uint32_t cdw12; if (!s->supports_write_zeroes) { return -ENOTSUP; } + if (bytes == 0) { + return 0; + } + + cdw12 = ((bytes >> s->blkshift) - 1) & 0xFFFF; + /* + * We should not lose information. pwrite_zeroes_alignment and + * max_pwrite_zeroes guarantees it. + */ + assert(((cdw12 + 1) << s->blkshift) == bytes); + NvmeCmd cmd = { .opcode = NVME_CMD_WRITE_ZEROES, .nsid = cpu_to_le32(s->nsid), @@ -1464,6 +1474,14 @@ static void nvme_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.opt_mem_alignment = s->page_size; bs->bl.request_alignment = s->page_size; bs->bl.max_transfer = s->max_transfer; + + /* + * Look at nvme_co_pwrite_zeroes: after shift and decrement we should get + * at most 0xFFFF + */ + bs->bl.max_pwrite_zeroes = 1ULL << (s->blkshift + 16); + bs->bl.pwrite_zeroes_alignment = MAX(bs->bl.request_alignment, + 1UL << s->blkshift); } 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, } 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 = !(flags & ~(BDRV_REQ_ZERO_WRITE | BDRV_REQ_NO_FALLBACK)); diff --git a/block/qcow2.c b/block/qcow2.c index 100eda03cb..b881cba0d5 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3941,7 +3941,7 @@ static bool is_zero(BlockDriverState *bs, int64_t offset, int64_t bytes) } 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 = bs->opaque; diff --git a/block/qed.c b/block/qed.c index f45c640513..558d3646c4 100644 --- a/block/qed.c +++ b/block/qed.c @@ -582,6 +582,7 @@ static void bdrv_qed_refresh_limits(BlockDriverState *bs, Error **errp) BDRVQEDState *s = bs->opaque; bs->bl.pwrite_zeroes_alignment = s->header.cluster_size; + bs->bl.max_pwrite_zeroes = QEMU_ALIGN_DOWN(INT_MAX, s->header.cluster_size); } /* We have nothing to do for QED reopen, stubs just return @@ -1397,7 +1398,7 @@ static int coroutine_fn bdrv_qed_co_writev(BlockDriverState *bs, static int coroutine_fn bdrv_qed_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, + int64_t bytes, BdrvRequestFlags flags) { BDRVQEDState *s = bs->opaque; @@ -1408,6 +1409,12 @@ static int coroutine_fn bdrv_qed_co_pwrite_zeroes(BlockDriverState *bs, */ QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, NULL, bytes); + /* + * QED is not prepared for 63bit write-zero requests, so rely on + * max_pwrite_zeroes. + */ + assert(bytes <= 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 f4b76ea010..c28dda7baa 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -746,7 +746,7 @@ static int quorum_co_pwritev(BlockDriverState *bs, int64_t offset, } static int quorum_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags flags) { return quorum_co_pwritev(bs, offset, bytes, NULL, diff --git a/block/raw-format.c b/block/raw-format.c index 345137813e..a2485926b8 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -289,7 +289,7 @@ static int coroutine_fn raw_co_block_status(BlockDriverState *bs, } 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/rbd.c b/block/rbd.c index efc0835ee7..053eb8e48f 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1205,9 +1205,9 @@ static int coroutine_fn qemu_rbd_co_pdiscard(BlockDriverState *bs, #ifdef LIBRBD_SUPPORTS_WRITE_ZEROES static int coroutine_fn qemu_rbd_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int count, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags flags) { - return qemu_rbd_start_co(bs, offset, count, NULL, flags, + return qemu_rbd_start_co(bs, offset, bytes, NULL, flags, RBD_AIO_WRITE_ZEROES); } #endif 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(BlockDriverState *bs, } static int coroutine_fn throttle_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { ThrottleGroupMember *tgm = 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, int64_t offset, int64_t bytes, 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 2f5c9c1d71..573acd67d5 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 0x%" PRIx64 " nb_clusters %d" # qcow2-cluster.c From patchwork Fri Sep 3 10:28:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12474109 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8ADC7C433F5 for ; Fri, 3 Sep 2021 10:39:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1C589610CE for ; Fri, 3 Sep 2021 10:39:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1C589610CE Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:58742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM6bz-000493-8W for qemu-devel@archiver.kernel.org; Fri, 03 Sep 2021 06:39:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM6RG-0003EX-CV; Fri, 03 Sep 2021 06:28:50 -0400 Received: from mail-eopbgr60121.outbound.protection.outlook.com ([40.107.6.121]:7190 helo=EUR04-DB3-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 1mM6RE-0002A7-OE; Fri, 03 Sep 2021 06:28:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bNkuwyG8eTX7a9YnCDrv7IHqlqy9Hz4PUo7DyULaBCqi83RlkSWWNf7NLAgDfm+AjwOttIfiTMaECOSBosE/f3AFcV4A+e5/Cjx9FMbzWBDhheC8m7gnfam2TPpKO7OH/XsPQZdhGGNayL+0HTih5qozz5oUOfpgpYFed1bg4+3daB/pomxE4Gtwu/BndnDj8MTlAnAIMnrlWCBBWF+hWn9TCeUPAxIfpPEL04KZGuvSqTAJyljRwxWh+uqQzclWZNW3RPCAeztN1rgjVwN15djFxj3VPKcODZCN6IYAbJbKkiUuajTELfJxSbP9q8mwhQt4GttYCCk5/lCNsn11GA== 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; bh=BhsBWb2vxMCBK7qKyU3DpwqXc4vOSgxnp20A2n9Oqz4=; b=CqKtldzxO7ZHtkAmDOyQOto5ymtvm8WUPIN+zFUF9BkBXXyxdIqU/bLNGKlJUXlpAB0mEnjsALm/x1dLV1Iq1ltuOPzkMLW+QDBz2WFqPMNJw71WYEhkfQG51p9miVe+cI3lBdRlV/LSMq0Y/qrowDntg9g5YpjohZG3rjT0IlIzZPJbvTtU+EVOyhavmT08QJ52GDOoQA7hr3e1ZfgVpC4J0IQMhhrl2TO6AMbQt8B+9L4PDzUKZd9ug8caaGOjfFJowuB0mCGXbLsuIyhjQkFaE0Sg+h9ZJqUELj6LoGzgMAujQr5Osw5xx/v1cYgGwWBrntnF8jeXoYdZw/Okuw== 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=BhsBWb2vxMCBK7qKyU3DpwqXc4vOSgxnp20A2n9Oqz4=; b=bqdxgKoC4xyiTqANkdEAkgsZBMYB14uT2EqbKGWxeBnIAeViY02EK5yoMNZUThxto5+mTuo0mdJIe48dxxrv+1SIq6asAVFXofYvVPqKFuiy84OWUdMLWya+x5aY/YPEhCBcsVS2f4fqehq+2BbWVjgW2WgCc+J5fggaOXcKSlE= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6945.eurprd08.prod.outlook.com (2603:10a6:20b:344::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Fri, 3 Sep 2021 10:28:39 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.022; Fri, 3 Sep 2021 10:28:39 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, kraxel@redhat.com, idryomov@gmail.com, berto@igalia.com, philmd@redhat.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, vsementsov@virtuozzo.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v6 08/11] block/io: allow 64bit write-zeroes requests Date: Fri, 3 Sep 2021 13:28:04 +0300 Message-Id: <20210903102807.27127-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210903102807.27127-1-vsementsov@virtuozzo.com> References: <20210903102807.27127-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Fri, 3 Sep 2021 10:28:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0c606212-96a3-4b05-b77b-08d96ec5982f X-MS-TrafficTypeDiagnostic: AS8PR08MB6945: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:183; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2UwTmhJG6C5ZqZf07tsN8Gv6zxTtXnMthGxyXMIW9jnYgEsIozBeeKcZzWmV40o2iMhXxaVerqiNbgp6nm/CbpZcRa7UEviVCSjL50FP37geXnUGHchFnB7ArxQu1ikGcQz6xEzqdwWTSjRI4wdJjRsN58O3MFDPQ0ZjgB+TP3pOpUAXU9Gpd1NDwnoD+cemwRBthTRQ6Ht2o7EfBG4x4vbe7+iWxDN5bG+A7x6awGbuoR1KOI+UPWWGNOn3uI30j6ACFBndwiQuRlXpfcfM4+WNxLkk9WezEx6aySJYDTgDNaTfJ0Odd4szL3J9cIZtj8NgSTKBNxn7+0d2TY9sG/uqDOHmHtQCDS4bFbopU1m2KiFyiEdD/4w1wWH1ZcV20VCR7u6MsoSnS5Hgf1OW4JduNXkzr82eBX7fJgYHM2NCVWROAKHivegO7abU27lvxw1A47C0b5b1lMCtyw4cULkaCY8ETGydrIDeInDgW4t6brvPdZIA+aoM+OuHivEM8QGMkfrknffLxH8z0Hxx4bb/cGxSRC4EVmeWjOMjIjClqFqSFd5sSQTrpChGWFqJ4mTTrzYYtgoh0H6OWT5ulabF+/eG1JdB9zC4ixjdY1rmwKoVbOQRrWBODo1Ew56/3ZLtW2E8GBmqbCAH+8Rur313Lj4ZN7/FaFIt0rgC8VTdi+p0xYco223/pW6d4HufjwycowD1XnVuh+qZ4NZUeg== 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)(346002)(136003)(366004)(39850400004)(396003)(376002)(7416002)(83380400001)(38350700002)(36756003)(6512007)(38100700002)(6486002)(5660300002)(52116002)(6666004)(6916009)(186003)(956004)(66556008)(2906002)(66476007)(66946007)(8936002)(6506007)(26005)(86362001)(2616005)(316002)(478600001)(1076003)(8676002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VZHTjadt3t1CP9ZuL+hrZdFxEPcg8yTmh7WoeIRyGWc7Iv91N/dojkMBo8EpUuCaL/KCCRHHBmiQ1itP5xrzLVplbe/VI7va3L1/qBGC40mRhMZklrnqnjqQi9FNbUSPaiJiPnkI1cE7KG5Rro/TNKJiGT8koSnV5L5N2MusWIHHC17DHgn6PMwGik+2RMF4pz73751s0FQC6FJPSd/bx+NCBCAmKgav4cMj57qn1gyer52ZLneIP2Y8V8jD80jbNKuotUKdKboe2HeVJa0o1eInLiq4abjVzJWtLYKX7N+HQnbrOMyiummlWVUT7jDkkik0hBsTSRmJp4w8B/g3NdIUOmdcN1rM6DVg9u7seiTuf7SYsaMICNmol9aJsQR0fftkksCptZm0rbLABlIxPPdBDM677B2SaUxynMYrCR+HVS9epMZ8edf+qu4ig5AGqZTank3D1yvCdt5Prh0Usj/1F5TrTjzOATXr+MMkDtaGN1Y3+QlmJF9tZ+QPGz72ahAcdszbrrJ06FcO1gbH0CwYibaB86V9wMaeGifCZxNZ5moVHABkcEr2LrOCCAtUVGF8SnRgUjnYekzJjqMqDwqVtuBlR/VQwJdBnLdukCWrvO0Venzemif7+qyfup7yKnjVuCr1+WsNGDibICLy5c6T7UOdvtbZa17v3xM5Q5k/Xk1VGCLzbYk+5oVyn3PUYvHcIzgDm4Uinm1JfIo4iZvkG+vMtHjc05IiNyKXszl9K+GHkrpF+cS0MqxdRGd0dx0474JxhPBYy5/7JkQHKR1IAjCmQ3U/bDmVn1l6XI0D8aK8lhZEWgeap8DjMo0+XJ1MJz6zapYoA7bNAolGsrxX/JejtxHpDdhXJWozpQvpW6r/s4kb63yo3HvUQtDE48nhdvvPa5X10ChwMdIFi+amUae34VAJgPfM1QkHHPnnH5FzmwEAgP/l1JAgTN3lrJFv3Kf1tnzDm8zFG0WFUD+DJYiU7jBqxzixwP8e3Foor7bH39rXZfFKeqovkdQfv6K1QZt7hNrUoWVG+SDnWPEIxFnl2nZp2QW2ZS7MGGt4wwYNXDNtD7x/HhJYVkbh6SfZBXTvFZ+OyI0VHrOjmx3f8nm6fo2pLGey007z2BbFITEl3qkTuIN/cK8OzUcEqsVDeAiu8X554LdHTJFIMf9x2j/zpEWLWfE0qLI7TQJ1IlI04w6siKZrURb1KBwqNQVOzk4oy0BTeGe2zjG9XHpmgTGzB3xix0C3ds+EvCoOhL90DVoT3rES2w8Ue5tjAIED7Fru6mP1eLGxfjdLIBzp9Pm4uhDmi/NNu/bk1dK7wlBHY2IbGb+9IKE5uCJP X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c606212-96a3-4b05-b77b-08d96ec5982f X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2021 10:28:39.1846 (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: m1CCzbIZmVCncAeqw50NtjR6/DR8mDLMCjQ+8NFHcKC0GEyNmUVgAenOQwOaJ0YyQmk8ZumwHak+7baEGEsxgVZWy2eZSzWm4hwMR4Nx72Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6945 Received-SPF: pass client-ip=40.107.6.121; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Now that 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 b4dce946bd..c386cd700e 100644 --- a/block/io.c +++ b/block/io.c @@ -1869,7 +1869,8 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, int head = 0; int tail = 0; - int64_t max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX); + int64_t max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, + INT64_MAX); int alignment = MAX(bs->bl.pwrite_zeroes_alignment, bs->bl.request_alignment); int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFFER); @@ -2245,7 +2246,11 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, return -ENOMEDIUM; } - ret = bdrv_check_request32(offset, bytes, qiov, qiov_offset); + if (flags & BDRV_REQ_ZERO_WRITE) { + ret = bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, NULL); + } else { + ret = bdrv_check_request32(offset, bytes, qiov, qiov_offset); + } if (ret < 0) { return ret; } From patchwork Fri Sep 3 10:28:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12474093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F41E2C433F5 for ; Fri, 3 Sep 2021 10:32:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 85B9E610E6 for ; Fri, 3 Sep 2021 10:32:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 85B9E610E6 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:41618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM6V2-0000ce-K3 for qemu-devel@archiver.kernel.org; Fri, 03 Sep 2021 06:32:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM6RI-0003NA-SI; Fri, 03 Sep 2021 06:28:52 -0400 Received: from mail-eopbgr60121.outbound.protection.outlook.com ([40.107.6.121]:7190 helo=EUR04-DB3-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 1mM6RH-0002A7-43; Fri, 03 Sep 2021 06:28:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZWmetGhXgbkcOQOhzHGLF6OmcXEGFxO9Hm+RsmKsDClJLScgXNuD7xDct6W31ppCLLLPh3vNpN8/Fy6l/bWBvCmYAxNgtN++NnaBXgePxupriQ4LMooCVQya6RmvWpkOXLJ5OeWTJeZLsUFPH/PhZE4nlFF4HQd5KKi311uWRVeFI3UJIPWUptAJW/1OAXVKhfN+qq/vVB2qaEBS6M4W3F01QN3EEW5qQI76qxidsqf5SryXoWXqywz689mHcd2ZX4lA8xB+tWvPiEu0jJB9AjFvIh/OSb93Bo4kWUfGVcRe3TKI7KVyal5n1FZ3KqIxvOjcEaihhtywmh3RCpo5bg== 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; bh=gD/VePNZHIux4q7yb0SoZp/HHdjYFRawxqg/8Jk423g=; b=KaiKRtPx0JJ14ong8oARANcFp2A8DJPmba9UjmTFLoClxBBUq/kPfkvcug9vNDukLa81y7UKPRUWh8cC0SDZpYMQoCssMUOlmS9H7IpVJAtQew0G9s5W35k2+AQ+rdkUSTduijM3z90QFowwpB7tRgveuAXov2lKRGvswXTmUwFgoWtRYZ+egdaFi2a0Pr/cbzwahV9cC3QLZB4eVh9xiuFG3RkxsGq8SjRiybdkDz0YY/+0DG12URWXxrXTh2qNm5eko+ROyp7+sTBWblNUYJwrZX4C5KrcB41l8mP+RtbdRnSeiXWxPQ/7Nt+q1uKl81xDw4Ppg3gauYYmY4p5YQ== 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=gD/VePNZHIux4q7yb0SoZp/HHdjYFRawxqg/8Jk423g=; b=mXXILbtVSAy1nL0eFm81mNOvsBGqG/LvCDpmPmPkTTnHLkgTJnOoal+QL6aJaRUib+hYiDhVwRf1jvXy2O2o7F4wOy3B3+cZX58/hOMDWG5ZRfKMZ34p4H5Uey34cNPzR+X3SGIJmQf6OqrueFyg+y1DoZCMdSyLrYtrljmwhOg= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6945.eurprd08.prod.outlook.com (2603:10a6:20b:344::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Fri, 3 Sep 2021 10:28:41 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.022; Fri, 3 Sep 2021 10:28:41 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, kraxel@redhat.com, idryomov@gmail.com, berto@igalia.com, philmd@redhat.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, vsementsov@virtuozzo.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v6 09/11] block: make BlockLimits::max_pdiscard 64bit Date: Fri, 3 Sep 2021 13:28:05 +0300 Message-Id: <20210903102807.27127-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210903102807.27127-1-vsementsov@virtuozzo.com> References: <20210903102807.27127-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Fri, 3 Sep 2021 10:28:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b2249228-b1b4-467e-4441-08d96ec59958 X-MS-TrafficTypeDiagnostic: AS8PR08MB6945: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ImOp7DOidbGoFG0K5Am7u42sW4EdKW/GluTJ0PnJCaWfeIpRxMOSYa8Mqp+KvmWrlZJ6KrOSooL8PoWcrBBFH2XksiArtIzMaw5ul2/lMMj3iHhOfSOutw6oPajMGGGO2w85LCGDYskXzIuA4P6uTHZ3Vt9PCieLYc8GfBnbNh8YRwZFfvL+T/Rc2IrGJWPV2VWLjhAZR310BZ/MOnOjCayjMOl62zp0t4Fk2hfR8BZxju8GqZsSsHxJDQr77xnGmiCloaI4F8VWgYxmNJVYUpX2Z5sRPkfP8OFG/HEfylJTgNp13ZUBZS1AWtPuaIdbOIGK5aS9iqC3ygxr+qKGONfh2e4svbvpL8xQKZknY0bNqKeWql9gEMlYdyfbwrHcHjTb/J1i7QSaS6XkOfAcu0//hXnTLTp2l60FhsMgdPjyZBMv+wqes1PaGEv2cnoHXRZlKy0IUuou8VQDwp3d+RP/qE1DzAIKJpe8Ufu9FJjOeYlqcAacR16iP+MNsTsKmY15fFXjCumR2A8fPYIJUEaGKMYZIvMPnoPrHLVV8HWa3F4KhGTqOr4RFyoeDT6bOrNIrp6zlo5vhPKjn8mkYbocZ/on4Em4TTw7YoshPwTzppI2LzP/T487+L7pGcLd0+purkDooL/aENyqnUZa0G4VEkCZVUuFe3gWrPHbzf9uTC1zVkMY1pVspTEDO9mb/hKHbpCQGdWsNaMn36EsgQ== 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)(346002)(136003)(366004)(39850400004)(396003)(376002)(7416002)(83380400001)(38350700002)(36756003)(6512007)(38100700002)(6486002)(5660300002)(52116002)(6666004)(6916009)(186003)(956004)(66556008)(2906002)(66476007)(66946007)(8936002)(6506007)(26005)(86362001)(2616005)(316002)(478600001)(1076003)(8676002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: afOBiKtixujoHOV8KI4HK8eKXBzASKsLfuuHWor7/AyXhD9xo6OJDBd9RkX2OlD+L0yACvOHKlS73rHo1EFbGN4ztVscI+kB/JkX3BEPqIcZuDwOj9pzwZd1pavHz+gupGnV+2wpGqJfDA/IQ/YvUzd3W3CdqKOZsgScqqvmElAtMOwYOCGOcQFuDtM9dPi+iPA7DyAQKPQqzoSkovagPkY7KfujX2BXOR+MH9LE4Xf/fWuaXWSh0iZG0CDyAhdfXfcYDldaOi2OaPZ9W23fY/6wfabvOnWNlQx1AmdX1dIXuhhQ//V9+j1jDxwbXgmkVSdyWEzrFFz9lLh40j8CRE1rPYkg7142gAVG+U1UqPR3J5fte9G3Tt/QaUXRsIzTJq66o3B6VsqNJPO2u3bhKMVEv5jILSxAGH6f4QSOKGszd2Whk/BGxUaCLPq9lSfFZPgtCqYkXiHFY0zgrKwpKJPDqq3mcnbvFTyoE4/EPjfJD84RntgzYXb3tImUuwdtt/iq9402YH4LsAvP3aAaAg4ha7orfcSGSQGHYBI1uqx/Mf+4fGWW0ZLnkJsBkP4cOdGgGvd4FuQsmfHMgRRz0rjMBITNjn1pDmBb+dDj+aNNNk79c+PEKKX+7J+PC7mhxOWzDWkaki4EMtNvj7Nw9JuI0IyITr+YsngOPQzXHFp6bvKj9HGEWp9JCAfaZvwyroYEaD2iQ8ZElC8nysynHtb5FFgD3AnCnW1E5mcnL+iaTg1JX5GZpqz24YFk91vh1SDhysk4sge0gHL588iUi793LvK/owDR3Nls5bxFtOB0Xcm0fdhlIMQaK3xMqXE6tqNa3rIrG9g8D31rSbVwP4LEjicgxsu2seLMansjOKVwy9bf0/dxIFMdu/OnFJazUwFUqTcnZb+p/OqP1ftSKy/A9QZhC29/rL6C0J+0Ppadc0Wo4XHNiiS9jiMmMtxLiASQJ7Bkmww+/OdrvkAI6fC1Ehsol7b5LFgbpJ70SLFj7hCEJ3MOKW8VaeKYqK6uDN8xeUx1svhihIcsuIrSgprzf1xGOU97U+NaNs0Nk6icL7G+UDWxUc4FybzvWfSgrdMsb4DJgj4FMkjPvMmuMVUsErtsVql8vPtJ7D/CzBd08uUsx83EXqv07yFGMVsjxe/JlRNbgl64tEgJ/itC7DITTAEF1YuN4N+rCN4I4dl5Q8BUqxfMG/ZYEx7Ng0ONGWdxZ8oNachkC9oePajpWYcftKwuZ8z23Vk26sM1UtlJ40VIncRkIRiWDIfck6ahWBg2pr9NBJEzu33LM0pVEDj0b+MBs/7zZA/UUMnpf3hPSdICajUO4Do2jj0PrZ1W X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b2249228-b1b4-467e-4441-08d96ec59958 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2021 10:28:41.1540 (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: vh2QVpfSoRjDgbnrfK8veX79M13icfVBulbCnQoORwbUoDp7OqRAbh4Z/OhFf3H3SeI8D1quuC8gvAZ6Qy6C2Rfs3w6TT8n9bHL5ibaaOq4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6945 Received-SPF: pass client-ip=40.107.6.121; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 for 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 112a42ae8f..5977859f80 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; - /* 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 multiple + * of pdiscard_alignment, but need not be power of 2. May be 0 if no + * inherent 64-bit limit. + */ + int64_t max_pdiscard; /* 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 c386cd700e..a5ba1f4cf2 100644 --- a/block/io.c +++ b/block/io.c @@ -2997,7 +2997,8 @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes) { BdrvTrackedRequest req; - int max_pdiscard, ret; + int ret; + int64_t max_pdiscard; int head, tail, align; BlockDriverState *bs = child->bs; From patchwork Fri Sep 3 10:28:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12474103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 759CDC433F5 for ; Fri, 3 Sep 2021 10:37:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F2777610CE for ; Fri, 3 Sep 2021 10:37:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F2777610CE Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:52864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM6Zr-000064-Tn for qemu-devel@archiver.kernel.org; Fri, 03 Sep 2021 06:37:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM6RM-0003Up-Iq; Fri, 03 Sep 2021 06:28:57 -0400 Received: from mail-eopbgr60121.outbound.protection.outlook.com ([40.107.6.121]:7190 helo=EUR04-DB3-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 1mM6RJ-0002A7-GZ; Fri, 03 Sep 2021 06:28:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UJr90FQ0ETRgyBKsiirq1r3Z2jIBlkJ7FJhJhXCAGsW8C5qwQ/+uM4ZMh8Fj0OIINoiFU22gW9a1iKn+UzSCqmmd8nvQSqbhmYLh0ZTUqQfEpi6+ame6VeclFj4tWy/VTwYIU+gzDQG4vvi1d3YNwjFZSm8Dj2wMyuN8hDB0OvDqjAcOi0vOc4E5pCdztZ0BOIRC88mAaKaOZSxoug81tHXssaF0GYZzcHSVlLb3lbaZBycu6vz/mDp4WZcIfVNEQoFUs3QG7NogWoseUK5Q97PBH4/uzTcm9yTIeBvPWi/Hy1y+RDJzEFobFgY3bedIc7ADaqKBvfNm+IqIpSxB5A== 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; bh=1g38eaKhUw1NOa/mBH1a35a3Thr5oJh6mtXBn4H2BOU=; b=BSVKb7jKHd05PQFZgmKdSFg0t+dleEfrV3XprFZhLz35kvAtgnLbBjHSkA7P5Co55hOoCHdIktkZdcTx/RsiaTLOFtVho0lx5UQPeE6LpKo1LmnId9d3/4Tn7oe5E7Rpu4JsQMdflbDcSOSy4NXGvYJwQAsx1hCKyrCfToryz/GJWD+zL0KTyKi9G2hhKvRcPNqfUUN55TrbUZa6G4Lnb2q0ws3/o216lR8U8dd2Xx8DSX7VpSNI/sTtiPYJYqj462vCgZTQOYmcr3ioSfYk5wmAEcBgoLx9YNFBMZIsbR2nyVysJRBONhQ4s5F/QRgvb6PI2+6wOMduJ7fFwvBvhQ== 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=1g38eaKhUw1NOa/mBH1a35a3Thr5oJh6mtXBn4H2BOU=; b=AJkCFnzzw42cSeMYggYxxvs3wK1y0VfqG9dqgH9Ulq4YSE7AxwUi6yzfg7CTPEVbe0tN22FSMzviwsJIsqmUxeyndUhTX9xo0pX7Gvy2a353VwdYjBgdbmgfV/zzUNfvih84/ANB5hO1RBpE6YibWgTO5hsQtabKvLOHLoMe7YA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6945.eurprd08.prod.outlook.com (2603:10a6:20b:344::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Fri, 3 Sep 2021 10:28:43 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.022; Fri, 3 Sep 2021 10:28:43 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, kraxel@redhat.com, idryomov@gmail.com, berto@igalia.com, philmd@redhat.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, vsementsov@virtuozzo.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v6 10/11] block: use int64_t instead of int in driver discard handlers Date: Fri, 3 Sep 2021 13:28:06 +0300 Message-Id: <20210903102807.27127-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210903102807.27127-1-vsementsov@virtuozzo.com> References: <20210903102807.27127-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Fri, 3 Sep 2021 10:28:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5793b9a1-7e8b-4999-38db-08d96ec59a85 X-MS-TrafficTypeDiagnostic: AS8PR08MB6945: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KitEoM8ojXsuxmyT2O9z8n7vBNxHSa509XE9gH5a0LVabOJLLxVPtrqHRAWqauSytZTshwxfJWQc+F+wzig429bFGaVUp10kBBPQ0paHT7mrHgsrJQsFCJAQ+XFIVBsXWoIfcG4psDx2bP8pTWH3qB41dc5hhrSegceGyW1xL19JlIZ4Uures9aM0RGHwUGRwxEX+aLpbbNo5NgRJLFi87Tawk3GrPwUwyOEPW/F02WGbIVN6vLxQeORytJhsNEeXiRbe2yXaZ9E635wn1H4Refc/sW5iqfUB5qTVjki5FzwY9NBwuht4rDqAfI9ju0fr7jLw232T0coplBbCK/6vrBc9Sy0R7rrxlckC5CxyFaLe+O0GYB5u9qt93SrpjZiYnrZTCzWL1J+DXdzjKzsXsx0KcnuneiTLAqg4gZ/fM3DPCaXj0tqkMIp+ZEdUBwnbQNuwHpVAwkddGnCqPvQ403dYh/XD+c5JX2z+bRC//puTBlVgjSfzm4OX5w9xdTB69TMWCinxZRjWnnkfVOXaXN1DK3tHLG/KmKbHBR2uHeDeSqU3HqAknX5hYPfx1OAvyPPox6NIH0EZ6BopOdqidxY1n9JmfRefvHbIWr+wcN3NYaDfUsudQNmKla0+KNDO6Gl4L8e5+ND92M9MhnGOAJljHGg/RNoydomTZZ9S2nFN/t2uK5o4aJ+S/Pzby9D9FCLjlSxgSXMXnRbuL9XEg== 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)(346002)(136003)(366004)(39850400004)(396003)(376002)(7416002)(83380400001)(38350700002)(36756003)(6512007)(38100700002)(6486002)(5660300002)(52116002)(6666004)(6916009)(186003)(956004)(66556008)(2906002)(66476007)(66946007)(30864003)(8936002)(6506007)(26005)(86362001)(2616005)(316002)(478600001)(1076003)(8676002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N8/qbbpvIHumQg46dDN25A+KsZKftSDc3aoL9IzTPyp25IEZ3mIZhDM7W5fsHtwoUI15erWiN0rGK1dpMpKDIb91tXljgy5TXaN5rQjDZv7pgyK4OmbogN15LD0jqTWuF0tO/iBAiAN/hrQYUZiFXQbyPhkog9ONhK73jtQo4fy3ENZb+czaqwlQxIM54/ZzN/8NbyBIcdLJGlrNk82ZMTOjS7CPKvPiaqYKVbeSa59YrDzaZndInbXT9Ax7TCsxOoFp28rHPvSSgX5dcX/DgPcr/w7hPUI5hHACgn4g9czphhJCnuURNAsDz9YDnt+Zmm2kaBysMIsWkZqB9kaz6tF4kFHxBxdg/JDiiFG2IXyfSmBYcv+sO2HyNaSXQW4/aq0UFAtkVwTWLdRpcNtQyCN9+yLF0Y1KKzZdXJrNmVk7XlDb5nv5g33SnpYxYy3TORYmxAAfSRfUg8LGgQMM07BEJKbm+V58LiW9qVHOAnjNYgij1XHrNG48MJcT/4XT/qHqWIr1RHr8mgnWJFNzBrlcYVvWqmjf/hoJ6coxWqTvLg/xV/JXAdzVt0T3pCUHiUdQXKCMJkZYY9CodKgn9oYy+7NSfFu5SVDXyVexa59tCP9eYy80HybjisqNmW94i/caIlWqzHClYLW2Euu/Wlyj3aSjXtIFomn4b7MgwQueQc5uipTP6dKvmWL/p7g/ay7V62s9CskyJ5GZgHsOMUCSNWv3cd6rX0jnpa6Z0hLgNrpwTEBo/nghLHf/hY69wDzkR4DZhtAakFXmKakMMrVktrn/ilZ1R7ohKzjyiKr+6YB3iM9CdBiq8zHb+hP1uhZRc3AzmTK6Ef8oa/AkbmLPD3ycyt0IGeAvMXfiHGi7cOSMNA61rxJy4syf580/4qJt4PPH6xwByy4+Fnri9p+DhWrJysolPANaorFbDOO6iZlhA0ka06B8SUulwfre0XeNIpVbqcb02yclaSKJ/i0sD3bbLS1aJ0l54cu5xbkw2KAtLIr7EB4lyujZPWWsqWyc4iHhNPvfZ8cXV8+kgC/qgoApIpPwESUwGbvBPGQ4aFh4RXc9LiW2aKkpP3boibnSmp8QK1Z+OQfwWtn0YpSiRprRJSjyDcTFk29E2vSpXWMnLAdD/aoXq9BniR+no7E3RMsqjJZ2ScLgLZdx/nbuKhMmQ6KPdb2HYLh8q7pAsYST7hdUVOkaHhf98SxUuj8HpILXJFlD/8+gnplyfg1rbHszsU87SNeDwhBP72Fx/Fi2oZpAMCNcuqslH5WT4Hz+6tiSAMFHmV7waoJNmt9s2JJWtwgP3dGmtz6jyeXJ41Qm4Uml65hRLDjPj5f/ X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5793b9a1-7e8b-4999-38db-08d96ec59a85 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2021 10:28:43.1622 (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: Wtt5U/FtsbezQqlV7gnQcv5rioqHbnsbo+gjlqcIbhXMi469N/A8jjVOTfm1RLzjBC6ZDFAOMkqeH8uGrvXFE52Pdfqp/d5Vmb14cGW8EAk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6945 Received-SPF: pass client-ip=40.107.6.121; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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: 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 blkreplay, copy-on-read, filter-compress: pass to bdrv_co_pdiscard, OK copy-before-write: pass to bdrv_co_pdiscard which is 64bit and to cbw_do_copy_before_write which is 64bit 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: 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. nvme: buf.nlb is uint32_t and we do shift. So, add corresponding limits to nvme_refresh_limits(). preallocate: pass to bdrv_co_pdiscard() which is 64bit. rbd: pass to qemu_rbd_start_co() which is 64bit. 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. 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 handle 64bit discard requests, or else have explicit max_pdiscard limits. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/block/block_int.h | 2 +- block/blkdebug.c | 2 +- block/blklogwrites.c | 4 ++-- block/blkreplay.c | 2 +- block/copy-before-write.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 | 16 +++++++++++----- 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/rbd.c | 4 ++-- block/throttle.c | 2 +- tests/unit/test-block-iothread.c | 2 +- block/trace-events | 4 ++-- 20 files changed, 55 insertions(+), 31 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 5977859f80..4e45352268 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); /* Map [offset, offset + nbytes) range onto a child of @bs to copy from, * and invoke bdrv_co_copy_range_from(child, ...), or invoke diff --git a/block/blkdebug.c b/block/blkdebug.c index 742b4a3834..bbf2948703 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -717,7 +717,7 @@ static int coroutine_fn blkdebug_co_pwrite_zeroes(BlockDriverState *bs, } static int coroutine_fn blkdebug_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { uint32_t align = 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) } 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 bytes) { - 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(BlockDriverState *bs, } static int coroutine_fn blkreplay_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { uint64_t reqid = blkreplay_next_id(); int ret = bdrv_co_pdiscard(bs->file, offset, bytes); diff --git a/block/copy-before-write.c b/block/copy-before-write.c index d210e87a45..c30a5ff8de 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -64,7 +64,7 @@ static coroutine_fn int cbw_do_copy_before_write(BlockDriverState *bs, } static int coroutine_fn cbw_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { int ret = cbw_do_copy_before_write(bs, offset, bytes, 0); if (ret < 0) { diff --git a/block/copy-on-read.c b/block/copy-on-read.c index f83dd83f14..1fc7fb3333 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -201,7 +201,7 @@ static int coroutine_fn cor_co_pwrite_zeroes(BlockDriverState *bs, 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 d90a0bd723..f8eae6d881 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2941,7 +2941,8 @@ static void raw_account_discard(BDRVRawState *s, uint64_t nbytes, int ret) } static coroutine_fn int -raw_do_pdiscard(BlockDriverState *bs, int64_t offset, int bytes, bool blkdev) +raw_do_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes, + bool blkdev) { BDRVRawState *s = bs->opaque; RawPosixAIOData acb; @@ -2965,7 +2966,7 @@ raw_do_pdiscard(BlockDriverState *bs, int64_t offset, int bytes, bool blkdev) } 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); } @@ -3590,7 +3591,7 @@ hdev_co_ioctl(BlockDriverState *bs, unsigned long int req, void *buf) #endif /* linux */ 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 = 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(BlockDriverState *bs, 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 = GLUSTER_MAX_TRANSFER; + bs->bl.max_pdiscard = SIZE_MAX; } static int qemu_gluster_reopen_prepare(BDRVReopenState *state, @@ -1297,18 +1298,20 @@ error: #ifdef CONFIG_GLUSTERFS_DISCARD static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs, - int64_t offset, int size) + int64_t offset, int64_t bytes) { int ret; GlusterAIOCB acb; BDRVGlusterState *s = bs->opaque; + assert(bytes <= SIZE_MAX); /* rely on max_pdiscard */ + acb.size = 0; acb.ret = 0; acb.coroutine = qemu_coroutine_self(); acb.aio_context = bdrv_get_aio_context(bs); - ret = glfs_discard_async(s->fd, offset, size, gluster_finish_aiocb, &acb); + ret = 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 eaeb93ebc7..f6abe3a4da 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1141,7 +1141,8 @@ iscsi_getlength(BlockDriverState *bs) } static int -coroutine_fn iscsi_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) +coroutine_fn iscsi_co_pdiscard(BlockDriverState *bs, int64_t offset, + int64_t bytes) { IscsiLun *iscsilun = bs->opaque; struct IscsiTask iTask; @@ -1157,6 +1158,12 @@ coroutine_fn iscsi_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) return 0; } + /* + * We don't want to overflow list.num which is uint32_t. + * We rely on our max_pdiscard. + */ + assert(bytes / iscsilun->block_size <= UINT32_MAX); + list.lba = offset / iscsilun->block_size; list.num = bytes / iscsilun->block_size; @@ -2074,10 +2081,9 @@ static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp) } if (iscsilun->lbp.lbpu) { - if (iscsilun->bl.max_unmap < 0xffffffff / block_size) { - bs->bl.max_pdiscard = - iscsilun->bl.max_unmap * iscsilun->block_size; - } + bs->bl.max_pdiscard = + MIN_NON_ZERO(iscsilun->bl.max_unmap * iscsilun->block_size, + (uint64_t)UINT32_MAX * iscsilun->block_size); bs->bl.pdiscard_alignment = iscsilun->bl.opt_unmap_gran * iscsilun->block_size; } else { diff --git a/block/mirror.c b/block/mirror.c index 64ef53cdd4..c88b307f85 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1501,7 +1501,7 @@ static int coroutine_fn bdrv_mirror_top_pwrite_zeroes(BlockDriverState *bs, } 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, bytes, NULL, 0); diff --git a/block/nbd.c b/block/nbd.c index 5e1c4f30b1..fd2ab2b5f0 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1457,15 +1457,17 @@ static int nbd_client_co_flush(BlockDriverState *bs) } static int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, - int bytes) + int64_t bytes) { BDRVNBDState *s = (BDRVNBDState *)bs->opaque; NBDRequest request = { .type = NBD_CMD_TRIM, .from = offset, - .len = bytes, + .len = bytes, /* len is uint32_t */ }; + assert(bytes <= 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 760d7bea73..c1582923b7 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1352,7 +1352,7 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs, static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, int64_t offset, - int bytes) + int64_t bytes) { BDRVNVMeState *s = bs->opaque; NVMeQueuePair *ioq = s->queues[INDEX_IO(0)]; @@ -1379,6 +1379,14 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, assert(s->queue_count > 1); + /* + * 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) <= UINT32_MAX); + buf = qemu_try_memalign(s->page_size, s->page_size); if (!buf) { return -ENOMEM; @@ -1482,6 +1490,10 @@ static void nvme_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.max_pwrite_zeroes = 1ULL << (s->blkshift + 16); bs->bl.pwrite_zeroes_alignment = MAX(bs->bl.request_alignment, 1UL << s->blkshift); + + bs->bl.max_pdiscard = (uint64_t)UINT32_MAX << s->blkshift; + bs->bl.pdiscard_alignment = MAX(bs->bl.request_alignment, + 1UL << s->blkshift); } 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( } static int coroutine_fn preallocate_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/qcow2.c b/block/qcow2.c index b881cba0d5..d2b034e3a3 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3996,7 +3996,7 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, } static coroutine_fn int qcow2_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { int ret; BDRVQcow2State *s = bs->opaque; diff --git a/block/raw-format.c b/block/raw-format.c index a2485926b8..bda757fd19 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -302,7 +302,7 @@ static int coroutine_fn raw_co_pwrite_zeroes(BlockDriverState *bs, } static int coroutine_fn raw_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { int ret; diff --git a/block/rbd.c b/block/rbd.c index 053eb8e48f..701fbf2b0c 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1197,9 +1197,9 @@ static int coroutine_fn qemu_rbd_co_flush(BlockDriverState *bs) } static int coroutine_fn qemu_rbd_co_pdiscard(BlockDriverState *bs, - int64_t offset, int count) + int64_t offset, int64_t bytes) { - return qemu_rbd_start_co(bs, offset, count, NULL, 0, RBD_AIO_DISCARD); + return qemu_rbd_start_co(bs, offset, bytes, NULL, 0, RBD_AIO_DISCARD); } #ifdef LIBRBD_SUPPORTS_WRITE_ZEROES 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(BlockDriverState *bs, } static int coroutine_fn throttle_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { ThrottleGroupMember *tgm = 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-iothread.c index c86954c7ba..aea660aeed 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(BlockDriverState *bs, } static int coroutine_fn bdrv_test_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { return 0; } diff --git a/block/trace-events b/block/trace-events index 573acd67d5..0819863356 100644 --- a/block/trace-events +++ b/block/trace-events @@ -152,8 +152,8 @@ nvme_write_zeroes(void *s, uint64_t offset, uint64_t bytes, 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 ret) "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 offset 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 offset 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" From patchwork Fri Sep 3 10:28:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12474111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D02ECC433F5 for ; Fri, 3 Sep 2021 10:39:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 63B69610CE for ; Fri, 3 Sep 2021 10:39:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 63B69610CE Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:58908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM6c2-0004Fn-HG for qemu-devel@archiver.kernel.org; Fri, 03 Sep 2021 06:39:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM6RO-0003Xn-SR; Fri, 03 Sep 2021 06:28:58 -0400 Received: from mail-eopbgr60121.outbound.protection.outlook.com ([40.107.6.121]:7190 helo=EUR04-DB3-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 1mM6RN-0002A7-7d; Fri, 03 Sep 2021 06:28:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HavFeezux/FhCrkqi4JfUWQ/7SppSTrHPEUPM7fSoxJzYqqqGMIlDYVfc+wVHSfLSXutKfC3TtSOoRdXXLvcfb+GtBPPdRqg0rucUot73jOKlL6RGAn6lujQEFHC21o2GuYO7uMofecKueQLwWrY28toQ9zMLHWKLIb10Es7t/9o+m1AtitipBFYJ5iHDWJzlFb5UyKOQXXrWt9/Yz5EuQJq1HPTkZYIzVT2uiwQoXJpFdrdw35TmcJl4p7a+oKzOel0fEoZhASAlvOmZ+jxizFQGGJCb9zQTbPCJ40pRlitdHXSqxuAKFR6X7IUKKM6HiyDZPN8hcHxWPguILiQzw== 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; bh=q37jmXxnLW9WYqNnvmLXpmmnhXrp0IGNYomrb41dhl4=; b=Cgt+tXB3NU0KzARMgJc9eBYDkqSH3xVKKLLpkuB2NHBci763YKtdBowIV6Hkbpj4j9AwhnGoQzgnakgfrwWGPqCv8V3dkDp1c57ojLsHcL7/+ed+53zs52WTpl16JPrHpIfwjif3iiuBFTAaIuqEpUYx8g85SONSBNds7Rq/9We5UmYOaHgdREyFI0dQHRct8Posiu2kFvxc9RP6IfgSRE7so26UXZ5rEjSJS8TjuNJcgXbwXzdHE1AsuP7A0nTKDXlymcMwBNLThn2Y+4T0Otx6rxXbk+fgpUlcwq3mSLnD7YDrUssIPHxF8l8cJw9AMdwMPKIc7muc+wRLG2Nhbw== 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=q37jmXxnLW9WYqNnvmLXpmmnhXrp0IGNYomrb41dhl4=; b=ofoXTCvFBptbeGmj9f27Ue3lj+XNoK3hkUg9jAjLl5/M+PsOyi+CaL1AV33ENlEA72Uqlp8DZR1EpMW0oF+8lFLlsEdEFEwhqEYI24fSVehBTdggrjL4UUK76STbccFcC/6jiEaOf8PuowtCgMiOi310rF46PuARZw/bh+8e+Tk= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6945.eurprd08.prod.outlook.com (2603:10a6:20b:344::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Fri, 3 Sep 2021 10:28:45 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.022; Fri, 3 Sep 2021 10:28:45 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, kraxel@redhat.com, idryomov@gmail.com, berto@igalia.com, philmd@redhat.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, vsementsov@virtuozzo.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v6 11/11] block/io: allow 64bit discard requests Date: Fri, 3 Sep 2021 13:28:07 +0300 Message-Id: <20210903102807.27127-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210903102807.27127-1-vsementsov@virtuozzo.com> References: <20210903102807.27127-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0163.eurprd05.prod.outlook.com (2603:10a6:3:f8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Fri, 3 Sep 2021 10:28:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8b4c3f46-cb3e-4cd6-4af8-08d96ec59bbb X-MS-TrafficTypeDiagnostic: AS8PR08MB6945: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:247; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fD0CiVU1u9qsea7lS+vdmPj1CZDzmVC4Nb99rKuBIgz1xTbd1s2NRrgP2TL4vE8YvPirBvzyyWjaOIEq1kOMLK/KdMtnPjYeH2NrIIjYZKTn52H4BHvneqFjm1R9BJXCIhb3U7SLemh2C35jXxC1ABIPSdMsRj8O0v3Q/4cOPOXNIQSQ/Lo52eWzQ/SAmf2T/WOIUoFn0kUfrxNOAgCV3L6d/SXkh+/dx+nHW3p5Hw8QKkKenjcMpKWB+ATBsRwcUwb1uXPKFn+VMs6W8gdOtpb69jlYL6HsriKYEjiuRVH09khMN/VLqlgm4lSLNxYEuGpOp96YQ/20eMiTO5dyVkmokJngQWz8upy5NPgkP0DmZ/4o2IbqjUOHecrpx+7M2iNkVDZSrqNYDJ3MkRYRpajV9EulABQQliMWmOvWhZ1ct4Cdn9x6UYwgpbVovl4gX3J70fTwBpo96Gs3z3BCbMx9e3qHFdKN0kAGtqm04rhiS8g9Mtbk1Zbn3744GCmrqSfQQ1TfqFtR903Jy9Wg/zUDLmy9ZiU4NG/P5ge+JDW8uI0aIPPv41HREc1rjAT0HXYGRvuNXH1b9AATdUB/ciuc2ZMtlXm4cId/xV0goPa7KxgQKUcXvJ6T/cDy/2Rnt5xWTQgrY+Pi1m2EAjWhTxZF/zlrY+mUIthh/UvgGzSCleUNXrJGZQOeuqaNFytQ 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)(346002)(136003)(366004)(39850400004)(396003)(376002)(7416002)(83380400001)(38350700002)(36756003)(6512007)(38100700002)(6486002)(5660300002)(52116002)(6666004)(6916009)(186003)(956004)(66556008)(2906002)(66476007)(66946007)(8936002)(6506007)(26005)(86362001)(2616005)(316002)(478600001)(1076003)(8676002)(4744005)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /Ebo1iX234pikUayYNkCGdBlheTUXo1P1m0+vVQ47Anqm24vqPG7Zd93iWk9oq6vDppHB/1zRx07JcYBvov1gckd8UOgsPP9UWy+Jla3EOmPvMaQuL2zBueGqVfPspd/vt6zgWSo0eBCJhs58X38TZN7j+yPZFkXZbTIkNOuBO4PT56aA1PFMT/EANhJl4FYr0JwN6ZjB9RA6jGQQDhg+/dVqUsiqGQ/EFLEcuQFWJY+I0G8KAATP0wX9Z2FOxu/7J8NSd2cs5HxGZHTD6ySYHtXN1QCzBdB4JGgzsYb1ZnRpV+wQsQaeBQ3tddUy9JRsPeMlAbunpVuoDovhRudaOlk++b3saSBQWX+00VQdDjaYqEP9JvEWvq4cHtZW8OU2Fzakc55fODWHN99Z9OLhbdRIATzynHvHRAJunSE2wIELsmsq+ITZMBgDO1f0JO1OKedbcGa0PO4/Fa4P3a58jRaV6xK7eRoGA10S6iUzFWw4ch/O4gSn15sYiUBV9wRqtuoRDTt/5ekWwGFjk/lWWvPwMop3kHVuHJXLUdVxjNCDbLmZfS0jt3J+C5OT0cBsmSxXzbfjrZwVAir74E9igxGx3VtB/MbEAjIy3fetsnOSZkVQsGmCgRHbDOEsUlStkrVhdf7BIlf9PbFNbyBxHMYezscGa0kjco4e2u6/ttG9oIyOo1sS/AWiiyJt+4qwGZM0t/POVwrBSNFyfQu/BZoR4C/svtrHxm4+oeGNsV+vkVCTWab9BCvDFJd/cZxJGbDrEZsF72yzXaZUOye1Fstlu/SrdZL0NNjsEAmRj3uU+xUDQ2hS/Uv3zAJC8vmF8+KxCf1nE/msSGjXYnksXQHDYGnrnlsytRszU1j1C4xvdxgkxthhnwgHS97auzTLWfQ8N9z6OQTrVQciP+npGqG+UvLpKE27KYjGxXklNifOqwNQAHIrxiefx/c4889tTDzxWXu+fCVRlaub7Iv0ItWLsQ3YDPcRc2J3mT1s2KeB3nBYFu2DDjKuteq55wTiT9UV9oHvBj07A6bA65rsJDkCIkx37zSYcPhpmEPcxlGJ5C7NNOObkAdD+Ei0wT8uTTZBen6zi0Agd89PcAdUGBVpPyOAR7UBTBpfG6TA4eQbQO8haDryIszWu0PqrzWv56jKi6nhYx7cI/k1MzPZpP4eCiBEX3TmOCufxmi5L5rTr1kq99vWOZEa4TJnNSbKBBGEcgo0ySfIIxYfx5fVjzuTa8NEp8VRzNr0kZIPlQTxUsnMjC/LQED/3MXU16lrDi4uqKaYV4Z2r3IJXNvdHPGTvIorhT8gRbSfj2/0eW/ptEujUdui4gsyfaZYkkx X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b4c3f46-cb3e-4cd6-4af8-08d96ec59bbb X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2021 10:28:45.1624 (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: PKnpmcQ0LxxhBfOJnLb5SrX2KLDyvnkEfyTMbCyHz2+l7Ukn1/XKCmF0Htqp99cH60toFJF7PDvR3B5h61JACdikrYHkvKm2AMhd6CKrAq4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6945 Received-SPF: pass client-ip=40.107.6.121; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Now that all drivers are updated by the 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 a5ba1f4cf2..1e9a3a1752 100644 --- a/block/io.c +++ b/block/io.c @@ -3042,7 +3042,7 @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset, goto out; } - max_pdiscard = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_pdiscard, INT_MAX), + max_pdiscard = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_pdiscard, INT64_MAX), align); assert(max_pdiscard >= bs->bl.request_alignment);