From patchwork Thu Apr 30 11:10:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 283711 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, 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 3A6FFC8300B for ; Thu, 30 Apr 2020 11:15:54 +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 035CE2076D for ; Thu, 30 Apr 2020 11:15:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="ivrDDutF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 035CE2076D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU7AX-0000rq-3o for qemu-devel@archiver.kernel.org; Thu, 30 Apr 2020 07:15:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57720) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU78Q-0006uk-Hi for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:14:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jU76v-0005F1-4v for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:13:42 -0400 Received: from mail-eopbgr70099.outbound.protection.outlook.com ([40.107.7.99]:12710 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jU75l-0003SE-4k; Thu, 30 Apr 2020 07:10:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EhM3xYOs1IzWL5EpG8dhPX715NkfScXXYqo2VM+oap3xzFx4ywzQZp5T7rwO2PrD/IW1PIrsoDC5kXI0F8f97GP4P9mMOHYy6ZeC+iI/SbHkOXWFGSe4ktdIBW2gobMEqQxNQWY8KtxaEgxo1cRQ4wW7ruMzUsYSbs8CmUMxRF7exPlutWSjvdg9bbquW0t6+n8Dz5AWUGdJhaQzZIFUoLtCJTkaBuxIefqE5anpqpPVu+/JfyU7BOZClKL0GkvZrClGGKfSenWgzrsjwLzzq8n+n18waf+0OddwdeYVmvxwojGmnheFmvguWrADR4H0pHDEpx3EyeBEJvbj07YAMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m/X8z63edrEOxxhzoG1B/7J3UygWJU5Ku2Fj98P+Nq0=; b=Z9FRr0ngtu6q3nhqOvn/kT7qO0i1u4rl9hIl3HaLBumNkNvLXx90sxQW7LkGXikTZYb7XC7jeKyFv668H7JLb82UeANuottaLQgs9DYAgUId8djHFBDRZPT4fdD8wKzsXUcMkagX0jX0JCFOkuT5yn2oytUZidEWrb5lLawrLCofQSnyDaOSQ2Q3UCBsolzeRbeXR/FzxG/+HMDdA+HORPk2iIUeGBjV6JkQ/2bzNSfVdRdmaCpn53qRILoRRH9jKfEBwB0MdDphL5beDfpQ3UyABon060+ArSPpQyJxCwfGJSdf3cy/FaXPRuJ4Hp7JAi/HODlgTVPSEDze2KT8ow== 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=m/X8z63edrEOxxhzoG1B/7J3UygWJU5Ku2Fj98P+Nq0=; b=ivrDDutFaQGlYDF3J4kk85S+MIPIfrr6Pbx5BP0rt9v6vcexWVlAdyMMMJPyJ4qZBRu+xS3xE7K2zeyrra0+pOFuArWkF2lJ7EmSKGlRAInMZLit2nKs3K+46sGo9Fvc14KGsSCrAmE0gjj57jp5y2/jUJvo3IP7l/t5mzAttKI= 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 AM7PR08MB5399.eurprd08.prod.outlook.com (2603:10a6:20b:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20; Thu, 30 Apr 2020 11:10:53 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9%3]) with mapi id 15.20.2958.020; Thu, 30 Apr 2020 11:10:53 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v3 04/17] block/io: use int64_t bytes in driver wrappers Date: Thu, 30 Apr 2020 14:10:20 +0300 Message-Id: <20200430111033.29980-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200430111033.29980-1-vsementsov@virtuozzo.com> References: <20200430111033.29980-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.138) by AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Thu, 30 Apr 2020 11:10:52 +0000 X-Mailer: git-send-email 2.21.0 X-Originating-IP: [185.215.60.138] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5659ffc7-e5df-4479-7485-08d7ecf72626 X-MS-TrafficTypeDiagnostic: AM7PR08MB5399: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-Forefront-PRVS: 0389EDA07F X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x+q+cuLlhqgVr/Jy2quVvDq1v5uP+vAO53VGBwskyecX14+EymWa6f3tADI6ZD3twElHwOGnBuESeKDQAmWBn32MBXepcyv0B1ybh5o1z8wiRmMoFLcUucex5NyI12FHYbdI9fU5CqPtuRWCfxDpXj6adzoz2dv+wceK3a9xR5xG7PLaEsp/2vfxeTJwzCygCSvHgl3N+TMHQII9kLdjOxv2crxJekbiiaoKrV/fr9Efav3/VjipZY/QmG0k2mcqwQ2k6SWvByCH3qmxlQbu2mNoJQgldud4YdneLnRWh8AqZKf8PLhgRw/+/GKUVGoE4EfFERP4Gc/CSmmsSf9nRuWgjYcK4ZAxSmgRpqBDxcyKzjVx2beX0ikobuGCY0PDpAk1oyQ+WOZAtNzwdQaFic5YnWeiTW/KM7LI5yOWWhatOybHCtmO5f0vHTWOQ5PF 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; SFTY:; SFS:(4636009)(396003)(366004)(39840400004)(346002)(136003)(376002)(1076003)(36756003)(478600001)(8936002)(26005)(6512007)(7416002)(5660300002)(107886003)(6486002)(66476007)(66556008)(86362001)(6916009)(6506007)(6666004)(8676002)(316002)(2906002)(186003)(66946007)(16526019)(2616005)(956004)(4326008)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: E+uAGRMVDCiPqeMgPfFcb4pbhSTqeqGbTwpILswnksqC7YaoPPeMEWj8zs692Xk4gipmIr9xntcgYDc+aCB9Bt5BB5YJ20fjBI4t9V5nAkFkaYPcsdNXl9Sdn2NN0IR+nXNLxhLyZwEto33TzOyGnPZyewDt3q+/3K5DMxYdwwe1zdzZ5tt4LqfxQJWKqgtgv5ZlePFCAOC/WOcu14+nwtJehhmRyp30ZFy9JPJjfWyQ0mvcyIaIpfrg7Fc4bVGAT0HRD7E+HsqCEnNnW2zLx3eMM0RCfGSu1+x5oQOVF5yYr0kVnSplcmvylIHEHVX/yogOCUTEXXFQC+MKZWErh6/Hiv/Br4n1GtwlFE9IyCkayufy76ZRmEA04vWvINS1PYopAFyhVA5RoiQG+zv07jyes06DAQYcuXcsdoKDAKbe8hLuPUeiC/xQrqn2iqMYgBlmD9sH7yMMv9zUWvElTN+JGfifTiMthq1cKnhYHZByCoeiE7VN6PoWJQvrIfvlaCxc2Tweo52QXrlWfbEJKnUoNWvj+HCU9qHfmYTYuWFP0eqP9HiAsbu3PYxBJzrxRv0Va2M9omtO2MSMWPtkOfydF4t1GBmWc2I7/oLF53Z8/cu6Qv1uybGg/NvKJcu/I1blnsC/vQstgB2YJtWWbCBKuIF60Tx5sdYCrxFmFa/kcnpZXJD5FMafo0WSk9EmxVjMgSsxx0D5ZOwLqqR8lrberzGaKhcliQjF85IvUu+9rVCD23oL7YWfMBySz4BysgCD5lBfmhd5T+fERgxsc2KoJEI2ydnTY6tBN3eBbNY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5659ffc7-e5df-4479-7485-08d7ecf72626 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2020 11:10:53.9158 (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: xdwIrKAfKepTtkOJQvwUhbU7ybxKO5YkUu32GvV8tr0H7XY9v3zJEl96akfj3ePRPSae1sd9lA40KM53iZasaXmyeghMtQTwKAOKaKWNOcU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5399 Received-SPF: pass client-ip=40.107.7.99; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/30 07:10:48 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.7.99 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, fam@euphon.net, integration@gluster.org, berto@igalia.com, pavel.dovgaluk@ispras.ru, dillaman@redhat.com, qemu-devel@nongnu.org, sw@weilnetz.de, pl@kamp.de, ronniesahlberg@gmail.com, mreitz@redhat.com, den@openvz.org, sheepdog@lists.wpkg.org, vsementsov@virtuozzo.com, stefanha@redhat.com, namei.unix@gmail.com, pbonzini@redhat.com, jsnow@redhat.com, ari@tuxera.com 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 wrappers parameters which are already 64bit to signed type. Patch-correctness audit by Eric Blake: bdrv_driver_preadv Remains 64 bits, the question is whether any caller could pass in something larger than 63 bits. Callers are: bdrv_co_do_copy_on_readv() - passes 'int64_t pnum', but sets pnum in a fragmenting loop, MAX_BOUNCE_BUFFER when copy-on-read is needed, or max_transfer bounded by BDRV_REQUEST_MAX_BYTES otherwise bdrv_aligned_preadv() - passes 'unsigned int bytes' further limited by fragmenting loop on max_transfer <= INT_MAX Input is bounded to < 2G, internal use of 'bytes' is: drv->bdrv_co_preadv_part(uint64_t) - safe qemu_iovec_init_slice(size_t) - potential truncation on 32-bit platform [*] drv->bdrv_co_preadv(uint64_t) - safe drv->bdrv_aio_preadv(uint64_t) - safe drv->bdrv_co_readv(int) after assertion of <2G - safe bdrv_driver_pwritev Remains 64 bits, the question is whether any caller could pass in something larger than 63. Callers are: bdrv_co_do_copy_on_readv() - passes 'int64_t pnum', but set in a fragmenting loop bounded by MAX_BOUNCE_BUFFER bdrv_co_do_pwrite_zeroes() - passes 'int num' bdrv_aligned_pwritev() - passes 'unsigned int bytes' further limited by fragmenting loop on max_transfer <= INT_MAX Input is bounded to < 2G, internal use of 'bytes' is: drv->bdrv_co_pwritev_part(uint64_t) - safe qemu_iovec_init_slice(size_t) - potential truncation on 32-bit platform [*] drv->bdrv_co_pwritev(uint64_t) - safe drv->bdrv_aio_pwritev(uint64_t) - safe drv->bdrv_co_writev(int) after assertion of <2G - safe bdrv_driver_pwritev_compressed bdrv_aligned_pwritev() - passes 'unsigned int bytes' Input is bounded to < 4G, internal use of 'bytes' is: drv->bdrv_co_pwritev_compressed_part(uint64_t) - safe drv->bdrv_co_pwritev_compressed(uint64_t) - safe qemu_iovec_init_slice(size_t) - potential truncation on 32-bit platform [*] [*]: QEMUIOVector is in-RAM data, so size_t seems a valid type for it's operation. To avoid truncations we should require max_transfer to be not greater than SIZE_MAX, limiting RAM-occupying operations and QEMUIOVector usage. Still, 64bit discard and write_zeroes (which doesn't use QEMUIOVector) should work even on 32bit machines, not being limited by max_transfer. For now, we safe anyway, as all input goes through bdrv_aligned_pwritev() and bdrv_aligned_preadv(), which are limiting max_transfer to INT_MAX. Series: 64bit-block-status Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/io.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/io.c b/block/io.c index 7a7d4e578d..eeba3b828c 100644 --- a/block/io.c +++ b/block/io.c @@ -906,7 +906,7 @@ static void bdrv_co_io_em_complete(void *opaque, int ret) } static int coroutine_fn bdrv_driver_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, int flags) { @@ -975,7 +975,7 @@ out: } static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, int flags) { @@ -1055,8 +1055,8 @@ emulate_flags: } static int coroutine_fn -bdrv_driver_pwritev_compressed(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, +bdrv_driver_pwritev_compressed(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset) { BlockDriver *drv = bs->drv; From patchwork Thu Apr 30 11:10:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 283709 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, 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 97321C8300B for ; Thu, 30 Apr 2020 11:18:54 +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 64B262070B for ; Thu, 30 Apr 2020 11:18:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="n5T1qA2O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 64B262070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU7DR-00052V-H3 for qemu-devel@archiver.kernel.org; Thu, 30 Apr 2020 07:18:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57734) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU78S-0006xr-G4 for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:14:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jU76x-0005Fl-27 for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:13:44 -0400 Received: from mail-eopbgr70099.outbound.protection.outlook.com ([40.107.7.99]:12710 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jU75m-0003SE-5o; Thu, 30 Apr 2020 07:10:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bv2M4cIiGg8N1Ty6a+UrITXGgzL6JhH9UdcjkBfnB4I8a5MDuUTXawMxhKawcwE4IriQ5OmBI+P/+ozjhNC5u//763NGVwXyjhdkPyZ6FSeOwa47BLIk2Qh+xH53GZWEk7MSrk6ofLpvovy5Lhhnq9W23i9Votj0mihYpwEXcugridtqEfspfZ1kfHpsveZq1+ICLT/dA5r2gVuX7eyiCvEYy5DgREdML2jetfEpFcxEl7J5ylTf59+7ygp+B9hVHyWveBTEEjiv8bH2mlQIdk8jByQHhTzdKqHKqRuWqQ9PvbfYsk3q5b7YSb60alFf9Sm0dLaNEM15zTcYoo4XTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dtPlf/oE8vAuiNTry/E6NoEu5Rrio9+5gDt1YkLZynw=; b=CKQTwst876NI4/hyvzbdNZAisiZiGLNjaiDd/lqe8HN7JavYaKYzsMmiLoVdIPsPCNuSxFL6upJFZ8pVde1PTEUpm+16/NjrwPbep8ho/Zi/A4Z/CZOsvwrG6VBl9cN2Pv5/oxhy0kwI9dfU9G3HAVT0otWPYFCQ7MsS0hag2fOOxCpDzmrexM6QIsNvN184uAELCYMTfaYnELdebhqIBxvGPh4aaGtzlXrUFxBxvaw1+hSXqI+86fVxaSc+N9+/mU8d6Xmju0FWPIMesOAEI01wE149Grap0B/XSly3XJQ4kQ1Woatr9ixd65vJdeG5dKT3ETCLBKlgtjjf53lc8w== 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=dtPlf/oE8vAuiNTry/E6NoEu5Rrio9+5gDt1YkLZynw=; b=n5T1qA2OKKlGndD8ORJlnzETl/k70pPOAHx+KXYTgKVxSaBTjXMnl1cJLIIsN5HPK6qTUXlKfpNSpJq8xg3nYvKiY3Fgi7Xjvtktyn+MgYwY4c0SDgW0knAXE8WJ5OITPVOPBpvalqbbI62QCBpspWpoMkFU6j/50/Z6NbH1gwE= 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 AM7PR08MB5399.eurprd08.prod.outlook.com (2603:10a6:20b:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20; Thu, 30 Apr 2020 11:10:55 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9%3]) with mapi id 15.20.2958.020; Thu, 30 Apr 2020 11:10:55 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v3 05/17] block/io: support int64_t bytes in bdrv_co_do_pwrite_zeroes() Date: Thu, 30 Apr 2020 14:10:21 +0300 Message-Id: <20200430111033.29980-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200430111033.29980-1-vsementsov@virtuozzo.com> References: <20200430111033.29980-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.138) by AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Thu, 30 Apr 2020 11:10:54 +0000 X-Mailer: git-send-email 2.21.0 X-Originating-IP: [185.215.60.138] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2e37d5a7-1092-4a3e-0fb0-08d7ecf72708 X-MS-TrafficTypeDiagnostic: AM7PR08MB5399: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-Forefront-PRVS: 0389EDA07F X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ch8V5DhwuZ0ExWWzahVIYZfsVsxqsNaGGdHRP8r7VDA8QBc7Gs6XnegGdbPwTqWVI2Z2G40tIxYEKwOr8A4lExj2Kubfi6gs+XRhDoQ1QZxct7Ep6xBMFsQG2hCXhZkLq59hDpb2XVE2q4kIRKeTSHIR8S4UQy1i6oX2ClOLzynkEzbyaTCaK63+AfJ036kth+EMx9Te265ZVNTXCTtOojGsw+hMDlNsxphS370CkBMtzh71dPSQ1s6TfryYdE4FAWCUaUQi7xVWhqdXw3vldT+4J9x9+jA/BMqCYdNV+Tw6xrTYKYuCZiNDIQIFEbBj6OOq+qVPLd1nD/Usrg7UaaZB8q2ASZWoIZma93OiRvbt2La+0wWankBllHU172p0ZYjG+qnODREaaEyfKhNDx0hvbcdwDW6Yjq12YGxV0mzw2zMTU2Zr9ADVupEOrGw5 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; SFTY:; SFS:(4636009)(396003)(366004)(39840400004)(346002)(136003)(376002)(1076003)(36756003)(478600001)(8936002)(26005)(6512007)(7416002)(5660300002)(107886003)(6486002)(66476007)(66556008)(86362001)(6916009)(6506007)(6666004)(8676002)(316002)(2906002)(186003)(66946007)(16526019)(2616005)(956004)(4326008)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: RHbI61pESYS/PMhbC/A8voABlCrAkTBqpx0UwzXCgU5QvnBizaJSSvmYFd4fdj5ssZBxjHi1E/jXNqRoPgecl+/NEhG8QIQS/fBC801S5UmYPrjO1xKvTLKni4IVfzHEMERszgY08RNxpkFrr2DJ1WXmvjWEkgIue9yui2yySjlEcRgc53+sNtd4GuQdnAvMRTECgmCi2Fmm+QXmT2rdwRyNMxv3sZ1pTKS2GrU7btvRfy7hzmTpZZ/HIZEm+K917gZSRVryCddBzUOK6CTDZ4uWwNAV/5JtPoAVXew/W7TgjMPCG3NPW07a8Tyo9wKjoRiToL7iExN3b52xRroxoXkVyAjv0ilY2adKS4PE/1xjM9Uby3Y3UMa4urVj1gdmIjGXmDCnGfzDrLKhHD6J/W2MvC767GHof12biW2T91iRAXcsomiotcfCMprcB3DmZY4ZJ4B6b7pAY6PbhSMrmuQylqj3SVRdyYPGTAGcXEreKC953N8rI+idIn20XYuIeT0x7mfsse3MjHsUuoOT+YaXYbkXfVB9lyyvOO1ul2URoI/m+aHKGAREzsKWGxS8CGWwweOULpwH2sm2AtNkbQrNDSCWDZwhHJP0J4oqx1PHt5sAN2npZnnzTj2LwGHaS1+017GAVfLhTJPNkydmTM11tNsaDlqFVNwAPhUco5yV06A0ZuoOZLi/bb/t46mTdWxHdgGRZr5F5xAr2RZbeLC3eiwfkawIRdfCW5h9RFZMzuPPuOCFvf08Onbap+xAgBWxvnMtxepXS2bF1QLo4VeTxyKgS9x6Aq01u2Vy9xE= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e37d5a7-1092-4a3e-0fb0-08d7ecf72708 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2020 11:10:55.3814 (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: +LtnyMTN6VFx+frHwCa7hGvFnl7vqghGLCHtPj8CdHdwvfVwkssusoi4A1zzE3Ji2lB30rYrNCtxjRJ6Nn8Q82StY9z5Rt6GLDUZRYHsVyc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5399 Received-SPF: pass client-ip=40.107.7.99; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/30 07:10:48 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.7.99 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, fam@euphon.net, integration@gluster.org, berto@igalia.com, pavel.dovgaluk@ispras.ru, dillaman@redhat.com, qemu-devel@nongnu.org, sw@weilnetz.de, pl@kamp.de, ronniesahlberg@gmail.com, mreitz@redhat.com, den@openvz.org, sheepdog@lists.wpkg.org, vsementsov@virtuozzo.com, stefanha@redhat.com, namei.unix@gmail.com, pbonzini@redhat.com, jsnow@redhat.com, ari@tuxera.com 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, prepare bdrv_co_do_pwrite_zeroes() now. Patch-correctness audit by Eric Blake: Widens from 32- to 64-bit. Callers: bdrv_co_do_copy_on_readv() - passes 'int64_t pnum' bounded by fragmenting loop limited to MAX_BOUNCE_BUFFER bdrv_aligned_pwritev() - passes 'unsigned int bytes' - latent bug fix for sizes between 2G and 4G, if any to see if that bug could be tickled, look at callers of bdrv_aligned_pwritev: bdrv_co_do_zero_pwritev() - splits 'unsigned int bytes' into head|body|tail; head and tail are safe but body could be > 2G bdrv_co_pwritev_part() - gates with bdrv_check_byte_request() continuing the audit, callers of bdrv_co_do_zero_pwritev: bdrv_co_pwritev_part() - gates with bdrv_check_byte_request() okay, all callers pass < 2G per our current code in bdrv_check_byte_request(), so there is no actual bug. Use of 'bytes' within the function: compute 'int tail' via % 'int alignment' - safe fragmentation loop 'int num' - still fragments with a cap on max_transfer use of 'num' within the loop compute 'int head' via % 'int alignment' - safe clamp size by 'int max_write_zeroes' - safe drv->bdrv_co_pwrite_zeroes(int) - safe because of clamping clamp size by 'int max_transfer' - safe qemu_iovec_init_buf(size_t) - safe because of clamping bdrv_driver_pwritev(uint64_t) [well, int64_t after 4/17] - safe So even with the wider type, we aren't exceeding the contract of anything we pass it on to. Later patches may improve drv->bdrv_co_pwrite_zeroes and qemu_iovec_init_buf to be 64-bit clean, at which point we would want to revisit this function to use 64-bit clamping rather than 32-bit clamping, but it does not have to happen here. Series: 64bit-block-status Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/io.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/io.c b/block/io.c index eeba3b828c..b83749cc50 100644 --- a/block/io.c +++ b/block/io.c @@ -42,7 +42,7 @@ static void bdrv_parent_cb_resize(BlockDriverState *bs); static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags); + int64_t offset, int64_t bytes, BdrvRequestFlags flags); static void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore, bool ignore_bds_parents) @@ -1575,7 +1575,7 @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, } static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { BlockDriver *drv = bs->drv; QEMUIOVector qiov; @@ -1605,7 +1605,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, assert(max_write_zeroes >= bs->bl.request_alignment); while (bytes > 0 && !ret) { - int num = bytes; + int64_t num = bytes; /* Align request. Block drivers can expect the "bulk" of the request * to be aligned, and that unaligned requests do not cross cluster From patchwork Thu Apr 30 11:10:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 283707 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, 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 BB32BC8300B for ; Thu, 30 Apr 2020 11:21:30 +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 898F42076D for ; Thu, 30 Apr 2020 11:21:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="I1/cp/3P" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 898F42076D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU7Fx-0000yZ-My for qemu-devel@archiver.kernel.org; Thu, 30 Apr 2020 07:21:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57740) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU78T-0006zq-QI for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:14:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jU76x-0005G8-Mb for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:13:45 -0400 Received: from mail-eopbgr70099.outbound.protection.outlook.com ([40.107.7.99]:12710 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jU75n-0003SE-7L; Thu, 30 Apr 2020 07:10:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ytt3M3h8kH7dXTP3iJAhp0vOsXNL7r7O3wnGtWYK7MnVUiTIEXbY9MicMOzYmDOglhqJKdmTtgbJIk9/3oEhw7mF1xQZyXpm5sqEoYNvKMFdaWjpOSte+vBvg05HRzIvJnh5CMI3/9go9HSC2Pvr5kPuljUTtLXXR3AXn3D2tHu3gOoK5HIr6jw/DDk4pMh9oJb2/x4jopjkEM4pkQ+qkZisPVBP+Iq4aHyMTQiRYnN8hZqXZPfb8xOIfJDtWof1ltCdvO+TewJBbfWji6zFArdvBNgDY1y2HUrt1ob9TJJ+HIApvQLNspnoQjvhggb28L81JCi6M3FWD5IbeqnZKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aQLHfkrzAIN4DFGRA0i6kTfYA/424J/RhqUISyzuxUw=; b=djObvAaagqqurE/Yo4zfW0qRTTMmTiiLxTUnlckcYH3nvFNk1nV0oixOb2UJhVF7zw6r+B4ETPSTuiJBzTNQGl9eSBHOMwhkBK1Kyf14mgtHv6kg0WX6b1XadcOpU3D25Vd9hAI+EFQ15lVYEdS3hVirMA4lWAP9tq/iZVs1JGSA9d3JBKk0bj+iDxEJN4ZGxBltLOfdwYky4I0BSpT/lXvWioBuPsoXvOy2ryvyS1BrWvcu3mrzsPVkWI8EVfxIhxKTsBVjB2pqNHRl99Y1ScSf3W1IHi6m3qEjzJkOYDGHwNbtR3MjZ5w/GesCnuS+cLnrdU1OfyMk/2dVVx5EMw== 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=aQLHfkrzAIN4DFGRA0i6kTfYA/424J/RhqUISyzuxUw=; b=I1/cp/3PwgjpewMfqthnw3JDuK4X/BN3B5mZJY3XN3qxRyPQNb2k6TzGJro+Bo0NgXQlKEFTSa/3qd5ewDthM8WpIeeR2N/eABxi2OSoJF1EXhXqMR0z/rA/eijMJtdBiPoRI4RhFvis08d6Mk26B0Ol5oha9hj2ADQAt5IEg4o= 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 AM7PR08MB5399.eurprd08.prod.outlook.com (2603:10a6:20b:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20; Thu, 30 Apr 2020 11:10:57 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9%3]) with mapi id 15.20.2958.020; Thu, 30 Apr 2020 11:10:56 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v3 06/17] block/io: support int64_t bytes in bdrv_aligned_pwritev() Date: Thu, 30 Apr 2020 14:10:22 +0300 Message-Id: <20200430111033.29980-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200430111033.29980-1-vsementsov@virtuozzo.com> References: <20200430111033.29980-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.138) by AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Thu, 30 Apr 2020 11:10:55 +0000 X-Mailer: git-send-email 2.21.0 X-Originating-IP: [185.215.60.138] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cba11a18-38ab-4867-73b3-08d7ecf727e8 X-MS-TrafficTypeDiagnostic: AM7PR08MB5399: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:773; X-Forefront-PRVS: 0389EDA07F X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qd2OqrVcuv1RcgdlNUhAhFoHmnZ2yzXWcpao75gHgwRG55DCk5CjQvnMjRJMSYvfxHSl23oIfc49Wqn57uGli5CjgemdpKxOsDisSc4VlvhXwsV5nmkAdik4HhRwkYk5nnaDHMsizm8Doz8kpkjjl7LPFX3c/6Qc/JM5A7pGp+rXiSvjN24e7d4IOs0uEICzuQLXXEZzYAjun4io9UP2V1nBxlJUxfVoqbUJnJkTEwFUi8w1gBUCIMNVx+C7zN36pm27+AxMOk145dtH3s1T9yXqk+0eAWa6d61YEqN+CU6tp3nNDn3tVdJxlCP7kM0UsulxprEvRYhWXKMhY6tfkCCkXGHxZCSC2ibL6jlISIMwVJXvrZTfpQYUZFhpEHzonBsCGY2qlBqR76L2RXSgQXwPfXpeULDf+l+LVOUMaBjJzZncjVT4r4iFURovXQv1 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; SFTY:; SFS:(4636009)(396003)(366004)(39840400004)(346002)(136003)(376002)(1076003)(36756003)(478600001)(8936002)(26005)(6512007)(7416002)(5660300002)(107886003)(6486002)(66476007)(66556008)(86362001)(6916009)(6506007)(6666004)(8676002)(316002)(2906002)(186003)(66946007)(16526019)(2616005)(956004)(4326008)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: q/NBX88CEPOMwp6B5z3SDRQ1tA6cxNUq6xBsvIxgsQRXAx3bRCtzqs+jYvq+d7A15P3+UdwyQGyY2oQva+wL6p1qdhko2s6RD4enYhvhDLdtM0O6KxSOX8DwxY1ucTN2Y17rsJQdNFLgAcQ80XrMWTcGtkcIRSRu2I4R867OF1NCGAt4XJkG0c7mhL8loS8WyhOxx3FLtCTBxOVsbrvXP5aoxDVI+5yaZSLgBa2qXDcwUiQ3WC/d4cs6rJZ0EQW5jFmdsFrd2tNbfS12C0VEmLM8ZwPjEUZm98tKEh8kYl6JMDH6nY+UooOFsGx0KUXR3HXFv1dgvQXBl21oeTAA2N3DqA3krAPCrJNB+KB5duzA+68nF/f6wc6dhZExWfUI+PqTfNIVi49NBpLH9VRHhQJtEGrrg9lpLPGjiKmFnWaHslJZ75o8M3slE7tSlKUpc7ZkOTnd5yxjv5jututrWhZdMBr1ciLjB4mKaICB+l3RmORH2D3N/4wo1kHcEgD01aMf3ygvBO0O0u4reGgIw+XJAD2BGk8GWXCy4RPcU0u0mxqkd8HVeJXrMfxX1XPPqpXZWQ8/yZ9HMOC7gAxQ/sxO/yBHabHeAl6Csac0VA9DjARJ7cvLz5pvbeErcpOunM+7wCgYJsB8K+3hTyA2ObyDI3ktfGwb4mLSfWn7hw+KWG58CpfZ8n0ATOObFE5e+Ux9chEqtz0iT2EK/NYb2j2EhUvenJBLGrZ6CajtoDU7cxLNvlDyNQrB9t3a8WaFPw1K6brJPrA/XZPS5vMNaOga1a8yQxtG9l2i4LklvHE= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cba11a18-38ab-4867-73b3-08d7ecf727e8 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2020 11:10:56.8808 (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: MXIji1iZ2qcpwxJvDVTnyKYv+7BXTJQszQOUYyW/e08Bgh7UK2K8jremcq3T/00+9wovACVXvAPELwHD3kdZislJM5/ICqSTb5PhPdnSY10= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5399 Received-SPF: pass client-ip=40.107.7.99; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/30 07:10:48 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.7.99 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, fam@euphon.net, integration@gluster.org, berto@igalia.com, pavel.dovgaluk@ispras.ru, dillaman@redhat.com, qemu-devel@nongnu.org, sw@weilnetz.de, pl@kamp.de, ronniesahlberg@gmail.com, mreitz@redhat.com, den@openvz.org, sheepdog@lists.wpkg.org, vsementsov@virtuozzo.com, stefanha@redhat.com, namei.unix@gmail.com, pbonzini@redhat.com, jsnow@redhat.com, ari@tuxera.com 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, prepare bdrv_aligned_pwritev() now and convert the dependencies: bdrv_co_write_req_prepare() and bdrv_co_write_req_finish() to signed type bytes. Series: 64bit-block-status Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/io.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/block/io.c b/block/io.c index b83749cc50..8bb4ea6285 100644 --- a/block/io.c +++ b/block/io.c @@ -1686,12 +1686,11 @@ fail: } static inline int coroutine_fn -bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, +bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, int64_t bytes, BdrvTrackedRequest *req, int flags) { BlockDriverState *bs = child->bs; bool waited; - int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE); if (bs->read_only) { return -EPERM; @@ -1716,8 +1715,10 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, } assert(req->overlap_offset <= offset); + assert(offset <= INT64_MAX - bytes); assert(offset + bytes <= req->overlap_offset + req->overlap_bytes); - assert(end_sector <= bs->total_sectors || child->perm & BLK_PERM_RESIZE); + assert(offset + bytes <= bs->total_sectors * BDRV_SECTOR_SIZE || + child->perm & BLK_PERM_RESIZE); switch (req->type) { case BDRV_TRACKED_WRITE: @@ -1738,7 +1739,7 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, } static inline void coroutine_fn -bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, uint64_t bytes, +bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, int64_t bytes, BdrvTrackedRequest *req, int ret) { int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE); @@ -1780,14 +1781,14 @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, uint64_t bytes, * after possibly fragmenting it. */ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, - BdrvTrackedRequest *req, int64_t offset, unsigned int bytes, + BdrvTrackedRequest *req, int64_t offset, int64_t bytes, int64_t align, QEMUIOVector *qiov, size_t qiov_offset, int flags) { BlockDriverState *bs = child->bs; BlockDriver *drv = bs->drv; int ret; - uint64_t bytes_remaining = bytes; + int64_t bytes_remaining = bytes; int max_transfer; if (!drv) { @@ -1799,6 +1800,8 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, } assert(is_power_of_2(align)); + assert(offset >= 0); + assert(bytes >= 0); assert((offset & (align - 1)) == 0); assert((bytes & (align - 1)) == 0); assert(!qiov || qiov_offset + bytes <= qiov->size); @@ -1899,7 +1902,7 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, assert(!bytes || (offset & (align - 1)) == 0); if (bytes >= align) { /* Write the aligned part in the middle. */ - uint64_t aligned_bytes = bytes & ~(align - 1); + int64_t aligned_bytes = bytes & ~(align - 1); ret = bdrv_aligned_pwritev(child, req, offset, aligned_bytes, align, NULL, 0, flags); if (ret < 0) { From patchwork Thu Apr 30 11:10:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 283705 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=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, 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 C0D49C8300A for ; Thu, 30 Apr 2020 11:23:32 +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 792A32064A for ; Thu, 30 Apr 2020 11:23:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="ZEYU8elH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 792A32064A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU7Hv-0004Ve-LU for qemu-devel@archiver.kernel.org; Thu, 30 Apr 2020 07:23:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57762) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU78V-00073D-SA for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:14:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jU770-0005Gi-6E for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:13:47 -0400 Received: from mail-eopbgr60129.outbound.protection.outlook.com ([40.107.6.129]:22328 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 1jU75s-0003Xs-7s; Thu, 30 Apr 2020 07:11:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bSaFWrDSZMfzakb8COsVmE+ByOkrQH5n1WtI7hQYS/n0ixv6caCcimub0vPKLHZUlXswHDj4eXKaISA6ZMwmEFFt5INUqUgUpWllMfluFw4iI+eXdWXLRcFx5o2M/RRTGMYkjzhuc0zKAaqxNIxPzl949ttj2VWaOds8Uu5M2P081BU/09hFwwqIOZn5QeGB1Hk/G0IRIYo6cJ8hNE3LfaGu9OP5HBj/y2JBCqmZu5HRFWMvclN06hKDLJp45dqX4Iv2a5SuE7NUh4N6DM1dxu2dQ+FvN4BiEc+03Zkn9qffFzjhg+V4LpqFI3+/AEZGFsxXZYveXQooUxmtsA5dLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hUkTTDThD4tWgPkpzYZLn22MWCM4YFEnWTss8BuYshQ=; b=DsXLG3wrxxk8570KNN10r6UaQMDpQuFoywaw51qg2CzihFgPBj0tgZBA4LfxBCD9MNsmtu3lO/uYYXe3qF5yXIMhKPz/XjLntkUhn7+YhbR+X4Ec29mVyowxyxGiL4Pul5DmTWf6gUYee9L9NEDJZMy4/UORJxjlh1lVvmPwSace+YF0drrh9a7QhUWEq+z+nOxlV/zA/L+B4mCwzZ7a+5Rjw//IOYd+MPSoS5dN4JJ8p6ZAoC8ctCo3lU8rWHHFkprQ18QXbt+aIpdZwxybpS5X9ffdwSvnuu4w/AzElcIflkSyX4fmoL6RewDNx356Y1Dg9EFlDaedKK+33SG6Qw== 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=hUkTTDThD4tWgPkpzYZLn22MWCM4YFEnWTss8BuYshQ=; b=ZEYU8elH0yDzD4HrDkeFei4ZSmVc/pyodAx+z530ZbHlzPiBgXdIGaxrSXerdK/bxrGxbhAcGvMOE36K8Gk4mWZXj8ZnfX0o8JNta7TQhf3FhWwN3mBUc5yYxHL08BfgyGHH9ctU1H7WlDGfjvXW2/h/K1MhdPKXyOeNxBkGAnA= 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 AM7PR08MB5447.eurprd08.prod.outlook.com (2603:10a6:20b:10b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.22; Thu, 30 Apr 2020 11:11:01 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9%3]) with mapi id 15.20.2958.020; Thu, 30 Apr 2020 11:11:01 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v3 09/17] block/io: support int64_t bytes in bdrv_co_p{read, write}v_part() Date: Thu, 30 Apr 2020 14:10:25 +0300 Message-Id: <20200430111033.29980-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200430111033.29980-1-vsementsov@virtuozzo.com> References: <20200430111033.29980-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.138) by AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Thu, 30 Apr 2020 11:11:00 +0000 X-Mailer: git-send-email 2.21.0 X-Originating-IP: [185.215.60.138] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ddf97130-7f46-4d37-d3e4-08d7ecf72a91 X-MS-TrafficTypeDiagnostic: AM7PR08MB5447: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-Forefront-PRVS: 0389EDA07F 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; SFTY:; SFS:(4636009)(39840400004)(136003)(346002)(376002)(396003)(366004)(66556008)(6512007)(107886003)(316002)(6506007)(26005)(52116002)(186003)(478600001)(956004)(2616005)(16526019)(66476007)(2906002)(86362001)(5660300002)(66946007)(6486002)(6916009)(7416002)(36756003)(8936002)(1076003)(6666004)(8676002)(4326008)(142933001); DIR:OUT; SFP:1102; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3p1ll+HZDYnbQIFy9/7nql2W2nqo4/TG1KxJ3ZBt5xyhax+WEFqT7+yaoid9tnK/wuhrmOHDKDd4SSVfVkULgmLz8J+GrdiYjVSQsLCxhRmM+tikjGn9QhVT3NI8tpyR1VDEO9cyb/jXFi7ctMH41kU6lzEWXxFPPp0h6roD3Yn5uAqJ7amtIxwLku1CxDo+DoT54egqt8/wSF36T2cG/IXNLm2JgOlQnTz+jPxEmDu8znnNC6k1t0/DwtIofq1APn4DtOaTBilqo5DpSbFD/Gk6KII+D7DXSBMRGvtU5CXBSqNrTdUimrZ36SUwb1JOFrgvahbww0xGlN30EMJYgx5C1sASEMIYFB2Nw1h2lNN4oMOVeiBwDDttwNxYNLDx1Zx9aa64WnDkj5jyxoJSn5gCeKB5vURTrePVT+MrAuWPKAKOioFbKiNpOLQjt3odtZ6r0qeSEdBy4x6Vo5xhBET6aeOIWtnYbopjQWQMI2c4K0SsvrN4UiRVVhRHZCDY X-MS-Exchange-AntiSpam-MessageData: 7PpwTfxPSw239q6I/fPJJbsgSHKQDGeN5ku0RE0o4asfPKrebyYEI1WixJIPSSGeF9IamtC3PJYnxuQYgmD2kdI9vbUe94R/+mkX4Rf9VcNEwFtRCTQ7wCJn+gQi+hSnFqE1Jgv83nicWhLQodjPiY6OcKaycQL1mxVzuJfJcqq2fngP2gzbT7uHBMa1O8NCL3ePf+iT/kC2zJCHQmWT0yDMJkLVB1etSIqXHE8pN1m10hoXpI2I3gl/HObLTfQ/OCRVjTy2ioW7r1J+BK8fMYR5oA5OOx7B/fc3p7nuCqTu3jRpyupCJ6acuymh1B4Tl4mpd0goAKB/35vsDdohrmvjggRe6zvzFkbLb51Z2lRDWh2GY7931VVp04FGmHeILRE0MqzifjB0sg2yQNHn/Qmg1hWA8odgs4lPS9sA2eipwtC2nYViy8Ov4+478Vyl612WZXLxr+v31JIzzCKm0prINt4qqPgEgdMB6k3muEmQh6qD9BP/oLS38/hy9aFvG4xHYhnJAM1hw6ZlOvcbPE3SQ8t1e9ISQGOr4b+R+ReiZ2uXCgPjXxBsuc9nACHnIERyRgDpK1YtncrfPNudS9X4e1nptewl3VyzfVDc24Xfw+Tphpzii1BzFTzmDWhn9E65nX4kvBFvftItSuSLoZ9IgKLwoJABb12vPCm0xvvdiyOIXSGXho15tjDfzptruTjvXu/4md/Zhvt9dEXTbqP+H2CtDnb4XOwjuQ6abHEqVNkiZj/iztCQUX0f+mNX9rB6MfwRRaCrLzTTDU/D3W8XIY+3Pr57LuAXvx6CuVU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ddf97130-7f46-4d37-d3e4-08d7ecf72a91 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2020 11:11:01.3582 (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: ltZRwFaBGu8o83Vju7i2V+Uf7rlrEVWMEtZp/opbKvLVEZNtKCfRX9ET8pIqtJxtCxCeIgfNssX0VZAN4vVa6lM8hStpWnmYMJmr/s74AA4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5447 Received-SPF: pass client-ip=40.107.6.129; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/30 07:11:02 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.6.129 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, fam@euphon.net, integration@gluster.org, berto@igalia.com, pavel.dovgaluk@ispras.ru, dillaman@redhat.com, qemu-devel@nongnu.org, sw@weilnetz.de, pl@kamp.de, ronniesahlberg@gmail.com, mreitz@redhat.com, den@openvz.org, sheepdog@lists.wpkg.org, vsementsov@virtuozzo.com, stefanha@redhat.com, namei.unix@gmail.com, pbonzini@redhat.com, jsnow@redhat.com, ari@tuxera.com 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, prepare bdrv_co_preadv_part() and bdrv_co_pwritev_part() and their remaining dependencies now. Series: 64bit-block-status Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 4 ++-- block/io.c | 16 ++++++++-------- block/trace-events | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index c8daba608b..3c2a1d741a 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -975,13 +975,13 @@ int coroutine_fn bdrv_co_preadv(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, - int64_t offset, unsigned int bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); int coroutine_fn bdrv_co_pwritev(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, - int64_t offset, unsigned int bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); static inline int coroutine_fn bdrv_co_pread(BdrvChild *child, diff --git a/block/io.c b/block/io.c index d336e4e691..d7fd429345 100644 --- a/block/io.c +++ b/block/io.c @@ -1488,7 +1488,7 @@ static void bdrv_padding_destroy(BdrvRequestPadding *pad) */ static bool bdrv_pad_request(BlockDriverState *bs, QEMUIOVector **qiov, size_t *qiov_offset, - int64_t *offset, unsigned int *bytes, + int64_t *offset, int64_t *bytes, BdrvRequestPadding *pad) { if (!bdrv_init_padding(bs, *offset, *bytes, pad)) { @@ -1515,7 +1515,7 @@ int coroutine_fn bdrv_co_preadv(BdrvChild *child, /* To be called between exactly one pair of bdrv_inc/dec_in_flight() */ static int coroutine_fn bdrv_do_preadv_part(BdrvChild *child, - int64_t offset, unsigned int bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) { @@ -1524,7 +1524,7 @@ static int coroutine_fn bdrv_do_preadv_part(BdrvChild *child, BdrvRequestPadding pad; int ret; - trace_bdrv_co_preadv(bs, offset, bytes, flags); + trace_bdrv_co_preadv_part(bs, offset, bytes, flags); ret = bdrv_check_byte_request(bs, offset, bytes); if (ret < 0) { @@ -1562,7 +1562,7 @@ static int coroutine_fn bdrv_do_preadv_part(BdrvChild *child, } int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, - int64_t offset, unsigned int bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) { @@ -1866,7 +1866,7 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, int64_t offset, - unsigned int bytes, + int64_t bytes, BdrvRequestFlags flags, BdrvTrackedRequest *req) { @@ -1941,7 +1941,7 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, /* To be called between exactly one pair of bdrv_inc/dec_in_flight() */ static int coroutine_fn bdrv_do_pwritev_part(BdrvChild *child, - int64_t offset, unsigned int bytes, QEMUIOVector *qiov, size_t qiov_offset, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) { BlockDriverState *bs = child->bs; @@ -1950,7 +1950,7 @@ static int coroutine_fn bdrv_do_pwritev_part(BdrvChild *child, BdrvRequestPadding pad; int ret; - trace_bdrv_co_pwritev(child->bs, offset, bytes, flags); + trace_bdrv_co_pwritev_part(child->bs, offset, bytes, flags); if (!bs->drv) { return -ENOMEDIUM; @@ -2009,7 +2009,7 @@ out: } int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, - int64_t offset, unsigned int bytes, QEMUIOVector *qiov, size_t qiov_offset, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) { int ret; diff --git a/block/trace-events b/block/trace-events index 179b47bf63..dd367a9b19 100644 --- a/block/trace-events +++ b/block/trace-events @@ -11,8 +11,8 @@ blk_root_attach(void *child, void *blk, void *bs) "child %p blk %p bs %p" blk_root_detach(void *child, void *blk, void *bs) "child %p blk %p bs %p" # io.c -bdrv_co_preadv(void *bs, int64_t offset, int64_t nbytes, unsigned int flags) "bs %p offset %"PRId64" nbytes %"PRId64" flags 0x%x" -bdrv_co_pwritev(void *bs, int64_t offset, int64_t nbytes, unsigned int flags) "bs %p offset %"PRId64" nbytes %"PRId64" flags 0x%x" +bdrv_co_preadv_part(void *bs, int64_t offset, int64_t bytes, int flags) "bs %p offset %" PRId64 " bytes %" PRId64 " flags 0x%x" +bdrv_co_pwritev_part(void *bs, int64_t offset, int64_t bytes, int flags) "bs %p offset %" PRId64 " bytes %" PRId64 " flags 0x%x" bdrv_co_pwrite_zeroes(void *bs, int64_t offset, int count, int flags) "bs %p offset %"PRId64" count %d flags 0x%x" bdrv_co_do_copy_on_readv(void *bs, int64_t offset, int64_t bytes, int64_t cluster_offset, int64_t cluster_bytes) "bs %p offset %" PRId64 " bytes %" PRId64 " cluster_offset %" PRId64 " cluster_bytes %" PRId64 bdrv_co_copy_range_from(void *src, uint64_t src_offset, void *dst, uint64_t dst_offset, uint64_t bytes, int read_flags, int write_flags) "src %p offset %"PRIu64" dst %p offset %"PRIu64" bytes %"PRIu64" rw flags 0x%x 0x%x" From patchwork Thu Apr 30 11:10:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 283706 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, 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 1E5A6C8300A for ; Thu, 30 Apr 2020 11:21:40 +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 D055320775 for ; Thu, 30 Apr 2020 11:21:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="KGaT3AdA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D055320775 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU7G6-0001Id-WF for qemu-devel@archiver.kernel.org; Thu, 30 Apr 2020 07:21:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57772) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU78X-000767-7s for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:14:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jU771-0005H0-Mx for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:13:49 -0400 Received: from mail-eopbgr60129.outbound.protection.outlook.com ([40.107.6.129]:22328 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 1jU75u-0003Xs-6R; Thu, 30 Apr 2020 07:11:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GQEK/B6v/AghkRJ11TLmn0gVi1p4reKEOO/DTqufBPMBethx4oxX43AmKYk+UQBAFOPSDqAWJ6xnlHUEHrbgpWWJEoiZ+BY7W2fIMvafjaTH613j3t0L3XeR5dWP/DY0JpDjWPPXkgeEGaicnGAD7CGm5k8aIvQ6lpp4rp9LxRKnearShiaOSETwc9lEerX7vgkdN2Cic9B/5r2DcxqFdyW+7bH16k4Y44iaheM/apQKYy6UPGAL3KtlxEIkTD1qDG99aMh/TjxmUiiTJS3TwUHJoVOGHh9r5wOBAIZg8R45bwB3mhnEGcTs/0odd/G0g6QJ4MKz1mOaZAinofmykA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IoKXATxQwNFhW5mgkUoT6ST4SlqHyD6XpHb/VQY54iA=; b=eKkRMgc/EPJV4KjUN9b7TFdOSfPKGbl7I49MkHCaZjL/wD4DrQeB/GPqFg9vSr44yeuVQIbcCV8nwJFmFKF9E7WT0v3lyuJ6WWfmoz/U9cywWOkRHZC1WSNOvTBInhFQtIqRW7OWfpFpphT8jU4pUpVAbEBza0mAZyZSh+uKDwdGTwp65nEsy0kgBaIJEONqL1FOgKQZ+t14tPxd6XgpESoxu5Sa2DE50pufWMgydwMfeb8CWgvLlZhTTs33oblueWoC8CuvoO6n9AxFxqAyThMveBX4IodG7iuhpZz2qDZ2fSYgR8EZO3UP9rAEtDlBd570rX/1Rjxrqt3dCqH0tw== 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=IoKXATxQwNFhW5mgkUoT6ST4SlqHyD6XpHb/VQY54iA=; b=KGaT3AdAO4z6lAyVkxJsB5/FiFO2Xq8o2oYvjcKNto95Dvz745kVlrJdnsuFXEkmzxAlS7HlqzDy/Rxfd7N341LDkTxpyteO1deiOo2ZuYRvtmoYNeoXgY9lMQyw2cw2igtt6q0AAAZGacp5dzJp1x02Z4zmEHrKEmllGhDAeOA= 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 AM7PR08MB5447.eurprd08.prod.outlook.com (2603:10a6:20b:10b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.22; Thu, 30 Apr 2020 11:11:04 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9%3]) with mapi id 15.20.2958.020; Thu, 30 Apr 2020 11:11:04 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v3 11/17] block/io: use int64_t bytes in copy_range Date: Thu, 30 Apr 2020 14:10:27 +0300 Message-Id: <20200430111033.29980-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200430111033.29980-1-vsementsov@virtuozzo.com> References: <20200430111033.29980-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.138) by AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Thu, 30 Apr 2020 11:11:03 +0000 X-Mailer: git-send-email 2.21.0 X-Originating-IP: [185.215.60.138] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 21acda43-be00-4e64-b6ec-08d7ecf72c6e X-MS-TrafficTypeDiagnostic: AM7PR08MB5447: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:635; X-Forefront-PRVS: 0389EDA07F 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; SFTY:; SFS:(4636009)(39840400004)(136003)(346002)(376002)(396003)(366004)(66556008)(6512007)(107886003)(316002)(6506007)(26005)(52116002)(186003)(478600001)(956004)(2616005)(16526019)(66476007)(2906002)(86362001)(5660300002)(66946007)(6486002)(6916009)(7416002)(36756003)(8936002)(1076003)(6666004)(8676002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Idy1yo5jNLCX5aNP7TWQBWqm1YWKEx8mKp+oiYmfLgB0/pHlBSc43BV8+WLeXzzSt5EMcf24heElxG60i+przIUnLoD2Jc/nFN1Lf3gKYzoUBvBeECGPyxX2Ab0rdjx0K6o89SZyyxhixrV/zT5FE7ZmSdBAEmWkQAjepsCm+CFgk7gSapg7sPTOmfc/ByQdJakVwvjct33XL+/iWmj+bBHEv/2jf0T7teBQBQb88xjmfuaXEPiYOonuqUTqElPkWaPc40aMi5gJxeoOXu/ghoEDi90vrVrSdzMF1Up6uxxQ1sY17nq7MgWqrJjELezcxRatrE2XSsFONLOJC+FTNGlx/JuNHbV5tNrLA5ySCrLqG+bLq6ASAeARp0L6HkItAOshzNHBlf3e7Rjxi88c93cT39q/7I8m3wJFbEUKXxt0evbN4AhDUjlqC7PDolsP X-MS-Exchange-AntiSpam-MessageData: hB7S6t+nh/LpmvYky1X1MebJMPv9DoasJRzZj1nS7tTkAYvH2PX60KEzIws3zAyl4g03CQTkc2Obcx6dlxoq6ZLFOBSG+SHHL7cb7adgcpxX/77cMvDVrLLyE1ykg3TfLxePKQCJM9FAO3u592lLgqYz6XpXf1GEMAfncZlt+5c8hkEXpMW+b90zfpf+imAtMfYDGjZDwd2xoy9wq/dL0gFRplDe5ePfWJryfF1wymysWRKJfzxcu8sd2W9oo3jeNjqxRYwAIVkTe2w1wbYihr926QUBSIDE7SzpDBWg6JUwm2eas7lQ7AETrdyYlBShAnfAxOfNnV/LrMGhqctkStotfmPXReo5Tfgca8v1eeQmSgtU8p6NVjgQFb0igj+lex7m2uRmULuV+zGOUShOBXjogkLEYTKGS5kYKlS4JelqCbzdgamD983QOcaAmsQITJIFYBmrvarlXE/vcvdfJRiAGbrCSrNYWS/8ahAzAzZ2+kmR35eX4uFHk2VHQfp5u60biVRkJIWGME1vtgjl4IjCvM9VOTISyt/hDpC13TAUx7NDLrCOB7ZHOTDPsPrPYzql3YkozZuVOT1IPccdpYpvMjRhD8hu83V6sGe7/zCfZWKkAMochvRV+Zhpx5tP6FDVJQsibo+CISMq92lMiEGHsjEM5KpGfWlRgBI+5/YPvJJmn1x4xJIDmftTOsP5QQy0jWobUqLeoTRzzc52ntUyOxIwIqGwokdG2EmAVo63m0HzaUvsnSib/ZswlZCnd3nEVDMvOFGwpXO3oobrjYgnKnf+iQ9Vp6gyrPelido= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21acda43-be00-4e64-b6ec-08d7ecf72c6e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2020 11:11:04.4616 (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: LbgnJ+7lb31PhU4ZbwTL4VvsSB+FoReSgmVPPKXizmcTNafQf2TadmPKjFzThx9TzwjBJzBOrl0C5c04bkKMF2YUzRuZjEUrxTua66opX0Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5447 Received-SPF: pass client-ip=40.107.6.129; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/30 07:11:02 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.6.129 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, fam@euphon.net, integration@gluster.org, berto@igalia.com, pavel.dovgaluk@ispras.ru, dillaman@redhat.com, qemu-devel@nongnu.org, sw@weilnetz.de, pl@kamp.de, ronniesahlberg@gmail.com, mreitz@redhat.com, den@openvz.org, sheepdog@lists.wpkg.org, vsementsov@virtuozzo.com, stefanha@redhat.com, namei.unix@gmail.com, pbonzini@redhat.com, jsnow@redhat.com, ari@tuxera.com 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 now copy_range parameters which are already 64bit to signed type. Series: 64bit-block-status Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block.h | 6 +++--- include/block/block_int.h | 12 ++++++------ block/io.c | 22 +++++++++++----------- block/trace-events | 4 ++-- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 1688e7fa55..4bc90c493e 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -732,8 +732,8 @@ void bdrv_unregister_buf(BlockDriverState *bs, void *host); * * Returns: 0 if succeeded; negative error code if failed. **/ -int coroutine_fn bdrv_co_copy_range(BdrvChild *src, uint64_t src_offset, - BdrvChild *dst, uint64_t dst_offset, - uint64_t bytes, BdrvRequestFlags read_flags, +int coroutine_fn bdrv_co_copy_range(BdrvChild *src, int64_t src_offset, + BdrvChild *dst, int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags); #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index b4b42d0cd6..28aea2bcfd 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1315,14 +1315,14 @@ void bdrv_dec_in_flight(BlockDriverState *bs); void blockdev_close_all_bdrv_states(void); -int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, uint64_t src_offset, - BdrvChild *dst, uint64_t dst_offset, - uint64_t bytes, +int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, int64_t src_offset, + BdrvChild *dst, int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags); -int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, uint64_t src_offset, - BdrvChild *dst, uint64_t dst_offset, - uint64_t bytes, +int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, int64_t src_offset, + BdrvChild *dst, int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags); diff --git a/block/io.c b/block/io.c index 7564153dbe..db8b3b153d 100644 --- a/block/io.c +++ b/block/io.c @@ -3451,8 +3451,8 @@ void bdrv_unregister_buf(BlockDriverState *bs, void *host) } static int coroutine_fn bdrv_co_copy_range_internal( - BdrvChild *src, uint64_t src_offset, BdrvChild *dst, - uint64_t dst_offset, uint64_t bytes, + BdrvChild *src, int64_t src_offset, BdrvChild *dst, + int64_t dst_offset, int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags, bool recurse_src) { @@ -3530,9 +3530,9 @@ static int coroutine_fn bdrv_co_copy_range_internal( * * See the comment of bdrv_co_copy_range for the parameter and return value * semantics. */ -int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, uint64_t src_offset, - BdrvChild *dst, uint64_t dst_offset, - uint64_t bytes, +int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, int64_t src_offset, + BdrvChild *dst, int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { @@ -3546,9 +3546,9 @@ int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, uint64_t src_offset, * * See the comment of bdrv_co_copy_range for the parameter and return value * semantics. */ -int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, uint64_t src_offset, - BdrvChild *dst, uint64_t dst_offset, - uint64_t bytes, +int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, int64_t src_offset, + BdrvChild *dst, int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { @@ -3558,9 +3558,9 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, uint64_t src_offset, bytes, read_flags, write_flags, false); } -int coroutine_fn bdrv_co_copy_range(BdrvChild *src, uint64_t src_offset, - BdrvChild *dst, uint64_t dst_offset, - uint64_t bytes, BdrvRequestFlags read_flags, +int coroutine_fn bdrv_co_copy_range(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_from(src, src_offset, diff --git a/block/trace-events b/block/trace-events index 13ad9af0d8..e4d68438af 100644 --- a/block/trace-events +++ b/block/trace-events @@ -15,8 +15,8 @@ bdrv_co_preadv_part(void *bs, int64_t offset, int64_t bytes, int flags) "bs %p o bdrv_co_pwritev_part(void *bs, int64_t offset, int64_t bytes, int flags) "bs %p offset %" PRId64 " bytes %" PRId64 " flags 0x%x" bdrv_co_pwrite_zeroes(void *bs, int64_t offset, int64_t bytes, int flags) "bs %p offset %" PRId64 " bytes %" PRId64 " flags 0x%x" bdrv_co_do_copy_on_readv(void *bs, int64_t offset, int64_t bytes, int64_t cluster_offset, int64_t cluster_bytes) "bs %p offset %" PRId64 " bytes %" PRId64 " cluster_offset %" PRId64 " cluster_bytes %" PRId64 -bdrv_co_copy_range_from(void *src, uint64_t src_offset, void *dst, uint64_t dst_offset, uint64_t bytes, int read_flags, int write_flags) "src %p offset %"PRIu64" dst %p offset %"PRIu64" bytes %"PRIu64" rw flags 0x%x 0x%x" -bdrv_co_copy_range_to(void *src, uint64_t src_offset, void *dst, uint64_t dst_offset, uint64_t bytes, int read_flags, int write_flags) "src %p offset %"PRIu64" dst %p offset %"PRIu64" bytes %"PRIu64" rw flags 0x%x 0x%x" +bdrv_co_copy_range_from(void *src, int64_t src_offset, void *dst, int64_t dst_offset, int64_t bytes, int read_flags, int write_flags) "src %p offset %" PRId64 " dst %p offset %" PRId64 " bytes %" PRId64 " rw flags 0x%x 0x%x" +bdrv_co_copy_range_to(void *src, int64_t src_offset, void *dst, int64_t dst_offset, int64_t bytes, int read_flags, int write_flags) "src %p offset %" PRId64 " dst %p offset %" PRId64 " bytes %" PRId64 " rw flags 0x%x 0x%x" # stream.c stream_one_iteration(void *s, int64_t offset, uint64_t bytes, int is_allocated) "s %p offset %" PRId64 " bytes %" PRIu64 " is_allocated %d" From patchwork Thu Apr 30 11:10:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 283708 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, 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 C3E58C8300A for ; Thu, 30 Apr 2020 11:19:17 +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 7DF992076D for ; Thu, 30 Apr 2020 11:19:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="ugbMWO6s" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7DF992076D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU7Do-0005JN-JS for qemu-devel@archiver.kernel.org; Thu, 30 Apr 2020 07:19:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57780) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU78Y-00077X-9J for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:14:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jU772-0005HB-MF for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:13:50 -0400 Received: from mail-eopbgr80117.outbound.protection.outlook.com ([40.107.8.117]:39403 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jU75x-0003Yq-AS; Thu, 30 Apr 2020 07:11:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T01TacMPMMQWLlZRLfeA21Y0fHa3qJGOemLzOtXOYm65LI3rkiEJKxiS/5nSZN0kZbataJiXw7UBB3oY0xPbo8cuXaPNBjg6BdA5m6OaJ/G5koRBxiwvPb/oO3szMFTGTnPuP+FbP6CcOGoOGTBLdLH4cJgVZeMiKmPmyjyLDWBtJl6qY96fVeYcDOtzxT/8xJLbXuJxYQ2vKhqFEe4r9roW42joVMPLKNgn9gvEwiAAQiAgAGGFaE958ukR2a6sak+QkB33244S/U0IZ0OTlMzIOZUuM0ZvkUFteGM10C5gmAs73vScKxLZ+YpNMNiVrSr1ahUuGUPn3GvSxMuNKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p96Q8f6SVdBp4AN38/xYSuB/77eP/QtXR1B0Z8I3bD0=; b=PnbaKBnMtsTO8RL23j3506V1eEGhq6Uywl9cFnc1yYhoAJ3h3lPD0yQYtGwCD/5QFi/g1A4lMDE4isfDGmRVsl8gxQZq6uX5h8rhCnnYv0/Z0LPJIFrIQqlH1XkGBwevVSUGaPOnANHFujtkhs2V/eIDnARZwaCJLW+OT7DHTn88JOQXnMm9ttIRV60+WK90o1g7W037SlczDKbBP5SoA/tqRVfa6ohH1hxamS/xtvsMyk50t9Lk8cwR7GXGw7OoQP3rup3hzcOj1F0QZxT1cMWoHXUcnWnmZKA/JMy5xTENCHkU27fCwJTgZPxAJat57t8FE49ByGP48VRGfahjrQ== 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=p96Q8f6SVdBp4AN38/xYSuB/77eP/QtXR1B0Z8I3bD0=; b=ugbMWO6sNOLBEdeGo89ZkwEEO/ldvMYwjPV/sLVheya17cHJlciVhZGnUwOQXyS1XtFWscvT7oOiK8mK0bukkC9L5am+pYnYB20W2Q6yLlUE9yr3Qs/V/2Y5cWYllxzhFf8MGsUWqfFJ0Kmg50Uhmm6N9O+PFiZsRvRTJ10pRQU= 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 AM7PR08MB5447.eurprd08.prod.outlook.com (2603:10a6:20b:10b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.22; Thu, 30 Apr 2020 11:11:06 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9%3]) with mapi id 15.20.2958.020; Thu, 30 Apr 2020 11:11:06 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v3 12/17] block/block-backend: convert blk io path to use int64_t parameters Date: Thu, 30 Apr 2020 14:10:28 +0300 Message-Id: <20200430111033.29980-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200430111033.29980-1-vsementsov@virtuozzo.com> References: <20200430111033.29980-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.138) by AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Thu, 30 Apr 2020 11:11:04 +0000 X-Mailer: git-send-email 2.21.0 X-Originating-IP: [185.215.60.138] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0c2773d0-d9d3-46ce-37f6-08d7ecf72d4c X-MS-TrafficTypeDiagnostic: AM7PR08MB5447: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:390; X-Forefront-PRVS: 0389EDA07F 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; SFTY:; SFS:(4636009)(39840400004)(136003)(346002)(376002)(396003)(366004)(66556008)(6512007)(107886003)(316002)(6506007)(26005)(52116002)(186003)(478600001)(956004)(2616005)(16526019)(66476007)(2906002)(30864003)(86362001)(5660300002)(66946007)(6486002)(6916009)(7416002)(36756003)(8936002)(1076003)(6666004)(8676002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kN+LSLZnZM07AKs4sOCVx+o8JFJQ6+WApPRcAAPHfvnUQeuAxCKi9KoHL71mrJJ3G3VKKH0LMfNoeUOejQ0PkoV4lj+gnigTab3oodaBWqAe4n0CKlenn5SHacpUhclvvJ+TGYdMGIwR6hT1iQ56ZvCJeyF6ztsXVdnt3jZZiGpjsp98bmFI4OjW6LB+P0e5/MEdrpL5qtsEq0b+H6MC3hCjWrfsef/AD6UpunHF8Zvgoev4tX2g5Hi/+VWh0B/t9wpuIrWv4rr/TeJsSI/Tf4YtP3VlA8TspAIIZKCEJaRAYuuKgkA/2Vi4einhK7qWjKbU9cGaYdPtRvLYSByHatLBuPQUL5rQ/Sr34icVJNDIZXJdhA8mhti+r6DcscNjhqheE+UxMNgWDCAU++5dJGkBXpQnM2JhokB/jsoYPhGj6wmQl1IrHd5di6nIjbfa X-MS-Exchange-AntiSpam-MessageData: 9/zR1fMrB9hUDFXJwbmjwSU3KoA83beId+lvhrbfQ31It2eMvGhfiS7l1oERsRe8YVy97Hcyx7CCxVN8hwdJrpxWsktgRCnDrlOWUXiZpoPXf6VdgG2yy65P5S+VIjdb20YBd09QIpuDZHiiQ84uOvm+exQkny8kCbaTJA3Tvd3WOVSuNTkLzLGYp6O+5waTpE6tiAGfJgJS25MrLdOS2YaKbxhnIOBKCzvMMLsbJKUur7eawBAXXuf3d/S/I8FJf79P0paKAy9uSJK4z1rZQ3A8+xUbQnVvjglTba1jFSh1PvnmSygGKFPEt4ySo2XlliajYug/1Ior0aypvIQ6D+/1MQgyFoLNucW7N1TEECaIHrk5ySpozpgudpdNH+39fY7KnJ3LnwWMTWTFf5dTwIJkoa8GxR/IDfr0gnQXyE1ylLJjqFXrGQbk+PzCOH8oe5umxiE1eF3iXIShoI4vo+4U6lcreIZ4Dy57CXYFXvVahOo28ZphBUdF0cAfhJ0ya9We9o7+9OCloJBOk6PzR+y6Ru3/cPN8au1D476aA8gNCS8QjXzfu5q+1odXm3jme6A6ADUzWx85HtXAOqfDo9Zsd7U+E5a2Zvwgbn84KM0jm+qSz+klmhV8NY6NLCKIgqX6yG4f6Q4NrU11gOe3e5OaxORVk4RGqd0fSeXgnEqvmuJseIZvDsqd9FYarE4DgR2cVj2UqaOrL29NvjOv7IZm7AG73JWbRyvleMMLzNfCK0/+3zcOJAVqsNB1yw9OH0R4xQk89ed7Tm7AV+5m/PHjoKfaDcfsoFDhDlbfyGM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c2773d0-d9d3-46ce-37f6-08d7ecf72d4c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2020 11:11:06.2010 (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: wn93SmIyBeMoZxN7ya30FiHzGx/jSM9NJJqnIxQiQgEzycO7JyS9vvNi1g7NJyM+xkYKPs74dlSof4rMLZK1782v8AkqyLs/tbXBmn0zZpI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5447 Received-SPF: pass client-ip=40.107.8.117; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/30 07:11:07 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.8.117 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, fam@euphon.net, integration@gluster.org, berto@igalia.com, pavel.dovgaluk@ispras.ru, dillaman@redhat.com, qemu-devel@nongnu.org, sw@weilnetz.de, pl@kamp.de, ronniesahlberg@gmail.com, mreitz@redhat.com, den@openvz.org, sheepdog@lists.wpkg.org, vsementsov@virtuozzo.com, stefanha@redhat.com, namei.unix@gmail.com, pbonzini@redhat.com, jsnow@redhat.com, ari@tuxera.com 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). Now bdrv layer is converted, convert blk layer too. Series: 64bit-block-status Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/sysemu/block-backend.h | 26 +++++++-------- block/block-backend.c | 60 ++++++++++++++++++---------------- 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 9bbdbd63d7..0c1eee1778 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -119,14 +119,14 @@ BlockBackend *blk_by_dev(void *dev); BlockBackend *blk_by_qdev_id(const char *id, Error **errp); void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void *opaque); int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, - unsigned int bytes, QEMUIOVector *qiov, + int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); int coroutine_fn blk_co_pwritev_part(BlockBackend *blk, int64_t offset, - unsigned int bytes, + int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, - unsigned int bytes, QEMUIOVector *qiov, + int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); static inline int coroutine_fn blk_co_pread(BlockBackend *blk, int64_t offset, @@ -148,13 +148,13 @@ static inline int coroutine_fn blk_co_pwrite(BlockBackend *blk, int64_t offset, } int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset, - int bytes, BdrvRequestFlags flags); + int64_t bytes, BdrvRequestFlags flags); BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset, - int bytes, BdrvRequestFlags flags, + int64_t bytes, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque); int blk_make_zero(BlockBackend *blk, BdrvRequestFlags flags); -int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int bytes); -int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int bytes, +int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int64_t bytes); +int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int64_t bytes, BdrvRequestFlags flags); int64_t blk_getlength(BlockBackend *blk); void blk_get_geometry(BlockBackend *blk, uint64_t *nb_sectors_ptr); @@ -167,14 +167,14 @@ BlockAIOCB *blk_aio_pwritev(BlockBackend *blk, int64_t offset, BlockCompletionFunc *cb, void *opaque); BlockAIOCB *blk_aio_flush(BlockBackend *blk, BlockCompletionFunc *cb, void *opaque); -BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk, int64_t offset, int bytes, +BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes, BlockCompletionFunc *cb, void *opaque); void blk_aio_cancel(BlockAIOCB *acb); void blk_aio_cancel_async(BlockAIOCB *acb); int blk_ioctl(BlockBackend *blk, unsigned long int req, void *buf); BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf, BlockCompletionFunc *cb, void *opaque); -int blk_co_pdiscard(BlockBackend *blk, int64_t offset, int bytes); +int blk_co_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes); int blk_co_flush(BlockBackend *blk); int blk_flush(BlockBackend *blk); int blk_commit_all(void); @@ -233,12 +233,12 @@ int blk_get_open_flags_from_root_state(BlockBackend *blk); void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk, BlockCompletionFunc *cb, void *opaque); int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, - int bytes, BdrvRequestFlags flags); + int64_t bytes, BdrvRequestFlags flags); int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *buf, - int bytes); + int64_t bytes); int blk_truncate(BlockBackend *blk, int64_t offset, bool exact, PreallocMode prealloc, Error **errp); -int blk_pdiscard(BlockBackend *blk, int64_t offset, int bytes); +int blk_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes); int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, int64_t pos, int size); int blk_load_vmstate(BlockBackend *blk, uint8_t *buf, int64_t pos, int size); @@ -259,7 +259,7 @@ void blk_unregister_buf(BlockBackend *blk, void *host); int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, BlockBackend *blk_out, int64_t off_out, - int bytes, BdrvRequestFlags read_flags, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags); const BdrvChild *blk_root(BlockBackend *blk); diff --git a/block/block-backend.c b/block/block-backend.c index 38ae413826..b3f6edfc70 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1110,11 +1110,11 @@ void blk_set_disable_request_queuing(BlockBackend *blk, bool disable) } static int blk_check_byte_request(BlockBackend *blk, int64_t offset, - size_t size) + int64_t bytes) { int64_t len; - if (size > INT_MAX) { + if (bytes > INT_MAX) { return -EIO; } @@ -1122,7 +1122,7 @@ static int blk_check_byte_request(BlockBackend *blk, int64_t offset, return -ENOMEDIUM; } - if (offset < 0) { + if (offset < 0 || bytes < 0) { return -EIO; } @@ -1132,7 +1132,7 @@ static int blk_check_byte_request(BlockBackend *blk, int64_t offset, return len; } - if (offset > len || len - offset < size) { + if (offset > len || len - offset < bytes) { return -EIO; } } @@ -1154,7 +1154,7 @@ static void coroutine_fn blk_wait_while_drained(BlockBackend *blk) /* To be called between exactly one pair of blk_inc/dec_in_flight() */ static int coroutine_fn -blk_do_preadv(BlockBackend *blk, int64_t offset, unsigned int bytes, +blk_do_preadv(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) { int ret; @@ -1185,7 +1185,7 @@ blk_do_preadv(BlockBackend *blk, int64_t offset, unsigned int bytes, } int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, - unsigned int bytes, QEMUIOVector *qiov, + int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) { int ret; @@ -1199,7 +1199,7 @@ int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, /* To be called between exactly one pair of blk_inc/dec_in_flight() */ static int coroutine_fn -blk_do_pwritev_part(BlockBackend *blk, int64_t offset, unsigned int bytes, +blk_do_pwritev_part(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) { @@ -1235,7 +1235,7 @@ blk_do_pwritev_part(BlockBackend *blk, int64_t offset, unsigned int bytes, } int coroutine_fn blk_co_pwritev_part(BlockBackend *blk, int64_t offset, - unsigned int bytes, + int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) { @@ -1249,7 +1249,7 @@ int coroutine_fn blk_co_pwritev_part(BlockBackend *blk, int64_t offset, } int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, - unsigned int bytes, QEMUIOVector *qiov, + int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) { return blk_co_pwritev_part(blk, offset, bytes, qiov, 0, flags); @@ -1311,7 +1311,7 @@ static int blk_prw(BlockBackend *blk, int64_t offset, uint8_t *buf, } int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset, - int bytes, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags flags) { return blk_prw(blk, offset, NULL, bytes, blk_write_entry, flags | BDRV_REQ_ZERO_WRITE); @@ -1361,7 +1361,7 @@ BlockAIOCB *blk_abort_aio_request(BlockBackend *blk, typedef struct BlkAioEmAIOCB { BlockAIOCB common; BlkRwCo rwco; - int bytes; + int64_t bytes; bool has_returned; } BlkAioEmAIOCB; @@ -1385,7 +1385,8 @@ static void blk_aio_complete_bh(void *opaque) blk_aio_complete(acb); } -static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes, +static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, + int64_t offset, int64_t bytes, void *iobuf, CoroutineEntry co_entry, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) @@ -1442,31 +1443,31 @@ static void blk_aio_write_entry(void *opaque) } BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset, - int count, BdrvRequestFlags flags, + int64_t bytes, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { - return blk_aio_prwv(blk, offset, count, NULL, blk_aio_write_entry, + return blk_aio_prwv(blk, offset, bytes, NULL, blk_aio_write_entry, flags | BDRV_REQ_ZERO_WRITE, cb, opaque); } -int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int count) +int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int64_t bytes) { - int ret = blk_prw(blk, offset, buf, count, blk_read_entry, 0); + int ret = blk_prw(blk, offset, buf, bytes, blk_read_entry, 0); if (ret < 0) { return ret; } - return count; + return bytes; } -int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int count, - BdrvRequestFlags flags) +int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, + int64_t bytes, BdrvRequestFlags flags) { - int ret = blk_prw(blk, offset, (void *) buf, count, blk_write_entry, + int ret = blk_prw(blk, offset, (void *) buf, bytes, blk_write_entry, flags); if (ret < 0) { return ret; } - return count; + return bytes; } int64_t blk_getlength(BlockBackend *blk) @@ -1567,7 +1568,7 @@ BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf, /* To be called between exactly one pair of blk_inc/dec_in_flight() */ static int coroutine_fn -blk_do_pdiscard(BlockBackend *blk, int64_t offset, int bytes) +blk_do_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes) { int ret; @@ -1591,14 +1592,15 @@ static void blk_aio_pdiscard_entry(void *opaque) } BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk, - int64_t offset, int bytes, + int64_t offset, int64_t bytes, BlockCompletionFunc *cb, void *opaque) { return blk_aio_prwv(blk, offset, bytes, NULL, blk_aio_pdiscard_entry, 0, cb, opaque); } -int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset, int bytes) +int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset, + int64_t bytes) { int ret; @@ -1618,7 +1620,7 @@ static void blk_pdiscard_entry(void *opaque) aio_wait_kick(); } -int blk_pdiscard(BlockBackend *blk, int64_t offset, int bytes) +int blk_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes) { return blk_prw(blk, offset, NULL, bytes, blk_pdiscard_entry, 0); } @@ -2123,16 +2125,16 @@ void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk, } int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, - int bytes, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags flags) { return blk_co_pwritev(blk, offset, bytes, NULL, flags | BDRV_REQ_ZERO_WRITE); } int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *buf, - int count) + int64_t bytes) { - return blk_prw(blk, offset, (void *) buf, count, blk_write_entry, + return blk_prw(blk, offset, (void *) buf, bytes, blk_write_entry, BDRV_REQ_WRITE_COMPRESSED); } @@ -2358,7 +2360,7 @@ void blk_unregister_buf(BlockBackend *blk, void *host) int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, BlockBackend *blk_out, int64_t off_out, - int bytes, BdrvRequestFlags read_flags, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { int r; From patchwork Thu Apr 30 11:10:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 283710 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, 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 873EAC8300A for ; Thu, 30 Apr 2020 11:16:07 +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 417502076D for ; Thu, 30 Apr 2020 11:16:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="HF7+P5I8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 417502076D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU7Ak-000160-DT for qemu-devel@archiver.kernel.org; Thu, 30 Apr 2020 07:16:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57794) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU78e-0007A1-5h for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:14:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jU775-0005Hi-G6 for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:13:55 -0400 Received: from mail-eopbgr80117.outbound.protection.outlook.com ([40.107.8.117]:39403 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jU75y-0003Yq-B6; Thu, 30 Apr 2020 07:11:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xquaj7um6ut7fNliv91odYE7P2XF6AvuM7n3VIX5s7jaFYqN6FCIf2YqNuM0SjPfLaXmEwRmp29iwypFR4AL2eu3IiRUMEck2hKtbDiWxmdH+47QqswL9gK297t8iia03VttgpqdqREHPolegtJSbS1EWuq5WLD/rg7Si9eDloT2OZMc/Fser5Uy4TcyBk6kuKT0VneC4D0emEcnkVaCusfPibEhl0rmK4RnYB+cutYT2HqRlDe98+xQEJInKa13283S61/sESU0qtlaI0W5LRBHj82LEmqDdc8U4fF0Ur+KOgmI24x42jWoJBnY3MyrOudlmq8tTrqSPdyFYRycLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IQVZEUmlJUyIxRKWgtZ4QqTL9rUQ5Ko92pUVd+FmBiI=; b=Z02WL5IvtaEFnYpp0HHFfiHmKS1g2D0RuWnQZmK3DEEXqi+DYZQl9+xRjkDvcjFXHqGVVYOpcPiKpG3Fa4lm34ijw4rwZYPW0hD31bmQHR0UGw7Et2dDuQbH7iu3T9FJ9eg5z9tiQWl4DIp1iXRvmZgNMghJQr6quTBsmGMwD3lg5JWh/oUZrkMD5Dn1UIpF5CWfC6Wf3LfXDt34MGqX3bT3H1yqPxI8x7Rmtk9BpaB6c5eDGZazk8/dcF8rIYfOWrkBZBM692vuy2ffhMtzVnNPwOQTWLioEwv3zwjlzC7cyWxL2LYwyhiPShWw5RXdJXCbDDnq7DJudnIbkdv8Xw== 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=IQVZEUmlJUyIxRKWgtZ4QqTL9rUQ5Ko92pUVd+FmBiI=; b=HF7+P5I808eWowbODT9AVICGxYzmhLivoHcSxsSbqv653prPXXfPdEkI2lg7HneiS9khJ3LAj2r9iWotWWq3HjmbRuK80eRZmaegv0zui4GpbF9t/SPJ7l6Ydxi6hVhGi5W+mboPjmslVmK/cM/nM0suQYoR7LPRMt00SojlEF8= 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 AM7PR08MB5447.eurprd08.prod.outlook.com (2603:10a6:20b:10b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.22; Thu, 30 Apr 2020 11:11:07 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9%3]) with mapi id 15.20.2958.020; Thu, 30 Apr 2020 11:11:07 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v3 13/17] block: use int64_t instead of uint64_t in driver read handlers Date: Thu, 30 Apr 2020 14:10:29 +0300 Message-Id: <20200430111033.29980-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200430111033.29980-1-vsementsov@virtuozzo.com> References: <20200430111033.29980-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.138) by AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Thu, 30 Apr 2020 11:11:06 +0000 X-Mailer: git-send-email 2.21.0 X-Originating-IP: [185.215.60.138] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9798f3e6-f560-4ffa-d192-08d7ecf72e58 X-MS-TrafficTypeDiagnostic: AM7PR08MB5447: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:151; X-Forefront-PRVS: 0389EDA07F 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; SFTY:; SFS:(4636009)(39840400004)(136003)(346002)(376002)(396003)(366004)(66556008)(6512007)(107886003)(316002)(6506007)(26005)(52116002)(186003)(478600001)(956004)(2616005)(16526019)(66476007)(2906002)(30864003)(86362001)(5660300002)(66946007)(6486002)(6916009)(7416002)(36756003)(8936002)(1076003)(6666004)(8676002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LZCh/6ZQkpTFzFEI2HWG7P7syLisFuUrfwJMSXZrQ+kSVnoOqdHZgkGqbjezVGQARWCj79QNqNcI26fumTP+mgTfoYa4VW4Ws8DqKFyoypNWIqRqMoKeycJA3HEDaqHzQq35FsFmWJu6l7UCEedG1htF8X26lVnE6kfVFVxChiX0Zh5EUws5LR58+ouljacCP5OpuzClgawDlulibTK34hr9Fk642EtjpQ2xHZoBHF3ov6GAAaIeOab7zHeU+eZ8AzMxwzRpmJ84Ig2W6PhzMzSHaOVztsxu1L+kqiODyI6uIXtvRE6oY3RIxKXZfyWknQXN4W79TlmQTnZ4u2A1f8PZMzIg5WkbCrT4eTDRUbXREprLAMedh0zHPVlRRwnL8K8C8nc4IgX2FgYhg0gp8RYdU9hAZZfbk6juK6D89YWmhxHrzwVJnWYQIEyMooUA X-MS-Exchange-AntiSpam-MessageData: 3uXGGUJdtY7NE4xt+2RDrWciJoa2WBWLZgn3idPmT+ToF7BLAkYHNE62gcPiV/4gWXNX/+UN5P33ZA9nCCRzAQcLG8uYSU8z5Q5jNCUe0taSXXDE6SMlhZdeutvV4V2dw4uN6gLQmYIUzF2SVYz53SabalGUkcioteMq46IhFP8aq2Kd8uhcqTXrss9+Jk71zp9bzv1Cyd/4Dhri/ochRrKfJh+L66V2WWz2HbuPWU8oA8zUvH4s85XslRyPzjEkYvLm6ncrpQ0MLXIUD6WIN/ymEFtTjKVWlFbP6alcgCSM1Mnbu/YAod/KQIVtX2xiTcJ2FhcJOsgsGN4pKZZPaqjw7sh8SGs0bA0zcF6FiWSBOvY3Aq7Oaoa1EvkEKmMyGdHB8RQJikth+r4AZSMIN+rEzZ8sk0lS2hIVkaGu1ScqlKDsUjGkbI7eslsYOrKmfZQG3J+3CSpVk+zu/kwp4jPiry2uRp4DiupKTUADM9q8TFAusn57Db3X8shq+w2Z3zuwb6GipWZ/Ff/donnYkp2f/uvy2jrpI8tLJnFcQaKo0JNEGJXfXwLFDaRfC4YjuGqo/8kL8dBJ1blsAze4hikQUkUEVwB8dYCZdcpo0h1Fq27/zFAhwpQsnvvKVX4LgcR2ZLJUyCygft3Q7ua0PNq3r4ZSWHj8aqHFgzlgZCh8UTK/AExYqePGueJ25Y/E+nfvp/vtgcutzfxZd7xhgDd6IM/oPaCQawm6lWT1dLJvgSZLfJcMtz2J6Mgce/ts9Yq4z3CB4d3DGOzcdGwsrfe2vg6UvmUeTCGFqA4ZGAs= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9798f3e6-f560-4ffa-d192-08d7ecf72e58 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2020 11:11:07.7791 (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: sX2PC6j/XjeLSGFxX958mLDV39rbP5jlSWSrUdgG2VFrAiVBW2lvhJpiRLXD8rOyrQ+DaMTWsErlfj0aHzNyCy8JPzmH4oiGY1idvgy1zCM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5447 Received-SPF: pass client-ip=40.107.8.117; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/30 07:11:07 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.8.117 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, fam@euphon.net, integration@gluster.org, berto@igalia.com, pavel.dovgaluk@ispras.ru, dillaman@redhat.com, qemu-devel@nongnu.org, sw@weilnetz.de, pl@kamp.de, ronniesahlberg@gmail.com, mreitz@redhat.com, den@openvz.org, sheepdog@lists.wpkg.org, vsementsov@virtuozzo.com, stefanha@redhat.com, namei.unix@gmail.com, pbonzini@redhat.com, jsnow@redhat.com, ari@tuxera.com 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. Series: 64bit-block-status Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 11 ++++++----- block/backup-top.c | 4 ++-- block/blkdebug.c | 4 ++-- block/blklogwrites.c | 4 ++-- block/blkreplay.c | 2 +- block/blkverify.c | 4 ++-- block/bochs.c | 4 ++-- block/cloop.c | 4 ++-- block/commit.c | 2 +- block/copy-on-read.c | 5 +++-- 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/qcow.c | 6 +++--- block/qcow2.c | 5 +++-- block/quorum.c | 4 ++-- block/raw-format.c | 20 ++++++++++---------- block/rbd.c | 5 +++-- block/throttle.c | 5 +++-- block/vdi.c | 4 ++-- block/vmdk.c | 4 ++-- block/vpc.c | 4 ++-- block/vvfat.c | 4 ++-- block/vxhs.c | 4 ++-- tests/test-bdrv-drain.c | 16 +++++++++------- tests/test-block-iothread.c | 19 ++++++++++++++----- 34 files changed, 108 insertions(+), 88 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 28aea2bcfd..7b5f936269 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -180,8 +180,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); @@ -210,10 +210,11 @@ struct BlockDriver { * The buffer in @qiov may point directly to guest memory. */ int coroutine_fn (*bdrv_co_preadv)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags); + int64_t offset, int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags); int coroutine_fn (*bdrv_co_preadv_part)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, size_t qiov_offset, int flags); + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); int coroutine_fn (*bdrv_co_writev)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int flags); /** diff --git a/block/backup-top.c b/block/backup-top.c index 3b50c06e2c..289fee5a92 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -42,8 +42,8 @@ typedef struct BDRVBackupTopState { } BDRVBackupTopState; static coroutine_fn int backup_top_co_preadv( - BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { return bdrv_co_preadv(bs->backing, offset, bytes, qiov, flags); } diff --git a/block/blkdebug.c b/block/blkdebug.c index af44aa973f..7e02156c63 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -619,8 +619,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 04d8b33607..db60b396bc 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -307,8 +307,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 c96ac8f4bc..c8dd17bfff 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -73,7 +73,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 667e60d832..6bc2982a95 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -224,8 +224,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 32bb83b268..7c8c181705 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 4de94876d4..5322f720db 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 8e672799af..517f9aa7a0 100644 --- a/block/commit.c +++ b/block/commit.c @@ -211,7 +211,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-on-read.c b/block/copy-on-read.c index 242d3ff055..c2a0916b66 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -74,8 +74,9 @@ static int64_t cor_getlength(BlockDriverState *bs) static int coroutine_fn cor_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 bdrv_co_preadv(bs->file, offset, bytes, qiov, flags | BDRV_REQ_COPY_ON_READ); diff --git a/block/crypto.c b/block/crypto.c index d577f89659..4df71b25f1 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -335,8 +335,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 6e325901dc..39086e83c3 100644 --- a/block/curl.c +++ b/block/curl.c @@ -922,7 +922,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 4a045f2b3e..0e3ac05371 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 7e19bbff5f..1026e6040b 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1941,9 +1941,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 15859839a1..8a163837ab 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -415,8 +415,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 82c315b298..e61de56b96 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -62,10 +62,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 c26fd9260d..7cd720ac32 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1365,7 +1365,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 2160859f64..fedad8843f 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1160,8 +1160,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 cc2413d5ab..647250e4d8 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -263,9 +263,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 15e1d56746..e2a59caf46 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 7b7c0cc5d6..c79e398bff 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1062,8 +1062,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/qcow.c b/block/qcow.c index 8973e4e565..40fc5b96a4 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -628,9 +628,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.c b/block/qcow2.c index b524b0c53f..817b0bfd2b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2202,9 +2202,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 6d7a56bd93..3c65c05d17 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -660,8 +660,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 93b25e1b6b..709b8aecdb 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -171,8 +171,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; @@ -191,9 +191,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; @@ -249,7 +249,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; } @@ -284,7 +284,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, (int64_t *)&offset, bytes, true); if (ret) { return ret; } @@ -296,7 +296,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; } @@ -516,7 +516,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; } @@ -535,7 +535,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 e637639a07..b7edd685f6 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1034,8 +1034,9 @@ failed: } static BlockAIOCB *qemu_rbd_aio_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { diff --git a/block/throttle.c b/block/throttle.c index 71f4bb0ad1..63d1956074 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -114,8 +114,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 e1a11f2aa0..1b5365f34c 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -547,8 +547,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 218d9c9800..a1a0a77fe9 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1868,8 +1868,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 d8141b52da..45c254c3f7 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -611,8 +611,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 ab800c4887..80d488f556 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1538,8 +1538,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/block/vxhs.c b/block/vxhs.c index d79fc97df6..a1e437b2cb 100644 --- a/block/vxhs.c +++ b/block/vxhs.c @@ -480,8 +480,8 @@ errout: } static BlockAIOCB *vxhs_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) { return vxhs_aio_rw(bs, offset, qiov, bytes, cb, opaque, VDISK_AIO_READ); diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index fa0e6a648b..f384e0eb32 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/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; @@ -1120,8 +1121,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); @@ -1862,10 +1864,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/test-block-iothread.c b/tests/test-block-iothread.c index 0c861809f0..9567617c50 100644 --- a/tests/test-block-iothread.c +++ b/tests/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, + BdrvRequestFlags flags) { return 0; } @@ -65,8 +74,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, From patchwork Thu Apr 30 11:10:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 283704 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, 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 DB470C8300A for ; Thu, 30 Apr 2020 11:24:20 +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 93C012076D for ; Thu, 30 Apr 2020 11:24:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="PX1Hz063" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93C012076D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU7Ih-0006Fd-OP for qemu-devel@archiver.kernel.org; Thu, 30 Apr 2020 07:24:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57834) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU78h-0007Dx-S3 for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:14:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jU78K-0005Qb-GL for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:13:59 -0400 Received: from mail-eopbgr70120.outbound.protection.outlook.com ([40.107.7.120]:6058 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jU761-0003ZE-Pz; Thu, 30 Apr 2020 07:11:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=czPzxvBdKVNSF3pRcvihWlkRjml01Ib/bMDpfcSeM8VAGzG2GrKQw/8RdwEhRcFi0uGlWuVX2A1VC+x0liKogieKVITeGfnQcnc+2rhQGFfyM6MfyumKrlkEJ3oj+yf3+uK8RUI1Wje8tZKsghIG2pYGaPaUigo4lAk+oGdVeMMXxDwjIfa+qwKoeJH0L/bAQ1c4ZyCMgzzg7rS5c+0bkdwDXXOkX8fr47I3W3lyUlXRRbjRBapjwAOYwIclZS7pivo7O80THahwgDXdNqdc/XKspHkuxk3gu1bdqNPlvUYvRQm7IfDIHv7gde1zqgEusXO24K7jOzeJWxq1NQ1b+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QQgyQIl/97Xztt4TT3uchoaV2bXyusN1mPYn+I5K4ZY=; b=FYKoODsi8SHCnXIfzVnfvQJVV3wapC77W8Gv9GIJCLxs0bVy8zZT+r5qDHSGPs5Xm1/V/1hbFkt0qU39pc/Gb6M8n+32/afc6Qt7/sYUbMqMajpbXbb1Czz810o4CA1EJS54hpH4msKsZBirai1Q8pOkPvj73wVMRrZO0Q+KJbiDFPjCFmkkXaZ7ruquxKyq6gBHxP1crpR7zv5eGQuZGEvjEXYRes5KPqGaf9tzzu85bvcJQir5dkrl29Qtm13styeM8LR+LS8n29YgDkGkkogY/KosJ7AWAhnWCcg75Y+NpvTn+VNDyFwRRPpqnFinXBHLbEcUHh8QVoKo7pfTjA== 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=QQgyQIl/97Xztt4TT3uchoaV2bXyusN1mPYn+I5K4ZY=; b=PX1Hz063DVrmCv1WBfhiQ2WQ5t/leWVlkbu/9u33kNSC1ofy3pJ0G58NgBZfOyjPBbQbUltodWfbVuMgHJfR2sNguFzP3k86YZs7Bo1H4VYmET8tmfG/igc82lrRFU2hke/kkvTtZMHeZDlxPS9DLDiUHp/yJHrOn+AhN8w9wV4= 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 AM7PR08MB5399.eurprd08.prod.outlook.com (2603:10a6:20b:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20; Thu, 30 Apr 2020 11:11:10 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9%3]) with mapi id 15.20.2958.020; Thu, 30 Apr 2020 11:11:10 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v3 15/17] block: use int64_t instead of uint64_t in copy_range driver handlers Date: Thu, 30 Apr 2020 14:10:31 +0300 Message-Id: <20200430111033.29980-16-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200430111033.29980-1-vsementsov@virtuozzo.com> References: <20200430111033.29980-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.138) by AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Thu, 30 Apr 2020 11:11:09 +0000 X-Mailer: git-send-email 2.21.0 X-Originating-IP: [185.215.60.138] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6118a362-77ad-4b04-9d64-08d7ecf7302a X-MS-TrafficTypeDiagnostic: AM7PR08MB5399: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:389; X-Forefront-PRVS: 0389EDA07F X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3BdQeDlTlzNHfb9Jfg01hcMU7qLveEO83NJTOlwUqU4NcW8sEQqq85XO0twAT+iE8tzfRbMClC69YSlubPoMtOnuDADYpYTYKZW54LldIdi+fLX9flmlLSKOUgcLCBRjGfBTWpg8i/9CjM/6yrCHvP5dPVzruY95qFbxYid7RaVdLtlVAmiP0XLbu2X52dlkaFECz1ylUVGrKcUVTstFJFKMgZ+7kCIU6x9o8XQBMzBMvUsAKgFwpsmS7nkC/B0sMB/28Qjg0m1WISxWQ2Zd6tV3ePHIqkkt2gnxNrw1TANQcTsW44OAqP0u1Y+0hQx9z4hvaEGuSHwSetYJTDBSitvv0CodueA8jT4pU3LAnsvCgQhI5czgbuFtWgc8CR5637iUa8SsSO3gFZ6OC7pOVQ3uIS+BU+xL7dFe5YsmqoTGuQumN4ySEA4VavOGc1/h 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; SFTY:; SFS:(4636009)(39850400004)(396003)(366004)(346002)(136003)(376002)(1076003)(36756003)(478600001)(8936002)(26005)(6512007)(7416002)(5660300002)(107886003)(6486002)(66476007)(66556008)(86362001)(6916009)(6506007)(6666004)(8676002)(316002)(2906002)(186003)(66946007)(16526019)(2616005)(956004)(4326008)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: dp+oxKhEuSOk+6C6/029g3l25ppK5x0YUxfbBygkbOB0EumECIuBbDgQq+bvI0KwTKf0R6nZiyUV4K022BrGGpcgQruid4CCFuJBpuxG4rlv/LFixFRsJu/8OmHVUEmIPdajpvR6QAKyBG3hRA5TrRWLHHDDjXimRS6PQdjpm+nOdn53BeNtwYsE26H6SXthT6pLAhaeBTRmdpxxb3MBtlvjQEOwGjtnZOAQDqe06TvCP2SCgsEC+Tu04gPi2XOUy0kQxjGhcs2AeWT804mW5Eu/DOCdnTxjBV6Rm5v/rHEgsXm1ieDJIDyLO0VR2H2TOTuT7rM/BcA7KNgBl/Le+eLVoSxBvX+iAVQrM9GFUsKIL4Xeua6FWcSFXhcfeeBF6CpcNzR/4JkOHp5tO3ckKhFVgaPDEjHwVcdX0dwVk7ZbSTo79FoCl8DSk5xXjV74+0sx4CrUFrQpNvY92OBwzJ8JNe9yhaZuj1XQLAY3HCJZjy+Ah7vlz+yHFEnwAZvFwfz9iao88TPou8K2gCL69/EpEfLu+YUYtO6xsR+kwVKu7QwxQ367rXHJtIk/+sP5AGADlqZ059nczNzOk4tS4krG5kTvLiVAlR+zZ/T19eYo9SRubPgGk5JqmSkVrzQ4KqibCAvGoj5MtRIWmbw23eYUdxUoFB1Uv0wmdYS4P+mmpeLxweDyzAdW2jTVprPdl4vjES+C5pzaa9XuvP3u3AUTUuawNP9RpTR8VL57Lq3ONIlerkMceWUCAWnCK8bAUIUjTMgnoMt0QyXx465Ykz4k0sVBtN/8TLismHC7z7g= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6118a362-77ad-4b04-9d64-08d7ecf7302a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2020 11:11:10.7700 (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: wM/Ag49DemOmZuXlHOvktJODfSAykmmJwSi51l6b77VJwc9R40Lk4VSak5vc01mmByyX3YkV0ejsSUDsaA2lf3SaiqGpPA4Qsrshc13xJps= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5399 Received-SPF: pass client-ip=40.107.7.120; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/30 07:11:10 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.7.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, fam@euphon.net, integration@gluster.org, berto@igalia.com, pavel.dovgaluk@ispras.ru, dillaman@redhat.com, qemu-devel@nongnu.org, sw@weilnetz.de, pl@kamp.de, ronniesahlberg@gmail.com, mreitz@redhat.com, den@openvz.org, sheepdog@lists.wpkg.org, vsementsov@virtuozzo.com, stefanha@redhat.com, namei.unix@gmail.com, pbonzini@redhat.com, jsnow@redhat.com, ari@tuxera.com 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. Series: 64bit-block-status Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 12 ++++++------ block/file-posix.c | 10 +++++----- block/iscsi.c | 12 ++++++------ block/qcow2.c | 12 ++++++------ block/raw-format.c | 16 ++++++++-------- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 9e8819bc28..3f08baeff0 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -259,10 +259,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); @@ -276,10 +276,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 2c21f785b4..38c1398494 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -3034,8 +3034,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, @@ -3044,10 +3044,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 0b4b7210df..861a70c823 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -2180,10 +2180,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) { @@ -2321,10 +2321,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 ce1c123cb7..15a6d3c6ef 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3810,9 +3810,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; @@ -3891,9 +3891,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 3a393a31c7..fdf024705b 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -507,16 +507,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; } @@ -526,16 +526,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 Thu Apr 30 11:10:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 283703 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, 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 AA316C8300A for ; Thu, 30 Apr 2020 11:25: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 55EDB20774 for ; Thu, 30 Apr 2020 11:25:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="hMrs/UrE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55EDB20774 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU7KA-0000EI-Gb for qemu-devel@archiver.kernel.org; Thu, 30 Apr 2020 07:25:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57844) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU78j-0007FP-Bl for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:14:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jU78M-0005Vy-0d for qemu-devel@nongnu.org; Thu, 30 Apr 2020 07:14:01 -0400 Received: from mail-eopbgr70120.outbound.protection.outlook.com ([40.107.7.120]:6058 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jU762-0003ZE-UI; Thu, 30 Apr 2020 07:11:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P53jVKWzBw0UfO1DlkoqPcjCmliQ8tUBKsHuAOCeEt30Q3LIiN1k9tzUXInk+y+upfCHK2r2XvorxAED50AVhNXfiX2CiwabsU5VqICVZjnoiZFJngpPggxW1Cvnrg5G4WL+ud569A2kY1f9bI3/8+x8QxYBLZND01dsbP8C9q8hkW6WPDlWZL84UXJRJCNlWu4HTHPPVqUa4f5DHmnEgupNEYlxhz06L0hRiKvOiH2tDWNY3oG8/i1daIG3rlGhJBg/eEtk5HnDWAWD2OiUsyP8A/pxnMW6ogI24OJ8PiqKT86OM411OXlKP/OnKPCIUXHalJk7tfX8VWetx0yhVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/58aRH73IHGHhfUO6Z1+nmWkxa+Uq7D/NJoMhB5eTVw=; b=cusP4Tvqop9tkVSo5EAWWEKu6w4V5lEvgzHlzTMfmCzMthTiStNwYtHCs9f7eq5NaRQUcvISRbDsqhrvP9Nr2gDj//M5Kkzmj9ggtteFDi++3AfeIXccAPvaDiHQgWwApm2rEiLkzLR4vFJ8NOi83EmX0jGu5OmtNgAZ5RIsw/RfO/0d8pyKGSRrsTh/0nrE1wSY6FgffnsmLDn/ah5t6RpI4tM09dwl8a0TMO5kMNQ7n3ZIWSH2kb0E0nYNwQkj4AMoyY7tSEKHVbQiwWYwSOnsTg7wyeVWfBVNAtIwDikmpWK6IQCgXxRrGMUnJvV3HUWyC46IgvZnICxg7+TT7w== 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=/58aRH73IHGHhfUO6Z1+nmWkxa+Uq7D/NJoMhB5eTVw=; b=hMrs/UrE079vMtc7nxaWCmAMfib4Daj19lSBEyKNGh4wZTkv9K6ssXWcwoyG7DDVzc2CUTi6RfvX0fWD6yVRIY/zHHdOERj3rNNLX8EuhYyiL4wsVSB6TgPJ8c+aULZqXI+06cCTwwDBwecLinGFzpcpaOeRbzHE4g7ixCFKZUg= 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 AM7PR08MB5399.eurprd08.prod.outlook.com (2603:10a6:20b:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20; Thu, 30 Apr 2020 11:11:12 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9%3]) with mapi id 15.20.2958.020; Thu, 30 Apr 2020 11:11:12 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v3 16/17] block: use int64_t instead of int in driver write_zeroes handlers Date: Thu, 30 Apr 2020 14:10:32 +0300 Message-Id: <20200430111033.29980-17-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200430111033.29980-1-vsementsov@virtuozzo.com> References: <20200430111033.29980-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.138) by AM0P190CA0021.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Thu, 30 Apr 2020 11:11:10 +0000 X-Mailer: git-send-email 2.21.0 X-Originating-IP: [185.215.60.138] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6c31fb43-9fe2-4f49-c0da-08d7ecf73112 X-MS-TrafficTypeDiagnostic: AM7PR08MB5399: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:626; X-Forefront-PRVS: 0389EDA07F X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VZazNdtzCLZp1p9I1ZJNULw2tbbEQutiAeN8hBTZ1s7KTHtzwP6a/DB5UTgY+iu0LFkYkPuoqMWr7T3gJswwFH/AYTeywm6AuiM3DA0UyztXfn0gY37mvQjTsIMQartBcDkYNrMtd8QIpPkYezgo10arO7rKVqSFm3jo1ojg1HrJE5QL//WCuaSlTpX3O4aUr7Q5nzP57nzH0eABBXmTsIW/y9g+QQscW4k2ag6t7SD5kWN0hqKeiiiVHLpc5d72YshbKoxIk5M8eb+z13mQ2zL+lxlkaruBK1/bU+XaxKfXHx9EQczgtl2JwbJXCjlusoaZQHCXl2wBhUIS/AcoZcyEb93EXXxvzF1PsiMUNERgVtgrO9Hd/OM5Qa4OS2u4Jrf/c5PhFxsBGhnWHHHxUpPPAq2cDYlWDAx4iLix3TCKR4bVncZDxwn6u8aA+Luz 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; SFTY:; SFS:(4636009)(39850400004)(396003)(366004)(346002)(136003)(376002)(1076003)(36756003)(478600001)(8936002)(26005)(6512007)(30864003)(7416002)(5660300002)(107886003)(6486002)(66476007)(66556008)(86362001)(6916009)(6506007)(6666004)(8676002)(316002)(2906002)(186003)(66946007)(16526019)(2616005)(956004)(4326008)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: ks52jpCHXZYKhDK2poPwn9BC3hLKA5bhyQ+FLa7o2+yCx3B83ixATEPst8pVXfVdFKdaofewhTQtaUy+slRIlDj9oMAEfsNpisH+20LXop9FuMD6klJLgygD9VQrK256wxYymAa6GF0GRyBVhF3Fd1YM9ZS8e1HMMVOLMel447JV2cB0Cwm6BZqPJ/4Pfm9XatxW+gN0XdHb1t3lQL0ky3J6BuGmllULNA80DRjLc5ckI7y9CNB44I+HZyS7hCnqeZqloLAqH40dEDtqtBY46l5Frz64pYKzxeUIec7V5/wB/PWFFxI/OIBqrryDb4wlRfzmzbpe8/gzfkVqj+a0LFbgsvaFQhn62F+raACWDNSoyMWvJsnxgp1QVZ64lFfl8iSrKvd6KYTCQ3uhkwivu6MDgvfVB9PEmSvebmBiI2ozbs63MYMS8SggMCiGtpCW1TDQMz2SmYEppGHqlxh6oNcjwZmnIrXOantUgo2h+LBzX9z04b9SymIAR8uwr54ROSDOHKysHC9hxAAu7JnuJ2LNSBYFxTphAtuXwOvlGlQYeGfFsPYW5b2jwbNh2IpO4DWog0wN2WEm1ZdVWN2zJe6Tj2rMeb6GP0T6nVM2smlt4XGBYRe4Cl3amhuq4UmJiEEdA4q3NBNqhJseAxBZ5yY44JWRzsVahLK0IiAigs3UxItJ9r/i0tOkuR/gGwHcbn44wVzq/r5xSvCJUkpUn+uB0DiOtLIinIpnyacdnLzsCVEwg06kZ8reNzGxRtOlrldiwh93deP7KGFcthtYXbls50fiX32K5aaZktd2DhY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c31fb43-9fe2-4f49-c0da-08d7ecf73112 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2020 11:11:12.2914 (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: p/hYSPLvsS0cagsx1HUnPCAvndrSpNKXn8IyoGgatbm4KcIo6RvytlelsTVnzYY1mQlt+2KzrVQdkDziuJzAkFIJurJP8kgMa8lBQL+/bxI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5399 Received-SPF: pass client-ip=40.107.7.120; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/30 07:11:10 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.7.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, fam@euphon.net, integration@gluster.org, berto@igalia.com, pavel.dovgaluk@ispras.ru, dillaman@redhat.com, qemu-devel@nongnu.org, sw@weilnetz.de, pl@kamp.de, ronniesahlberg@gmail.com, mreitz@redhat.com, den@openvz.org, sheepdog@lists.wpkg.org, vsementsov@virtuozzo.com, stefanha@redhat.com, namei.unix@gmail.com, pbonzini@redhat.com, jsnow@redhat.com, ari@tuxera.com 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. This patch just converts handlers where it is obvious that bytes parameter is passed further to 64bit interfaces, and add simple wrappers where it is not obvious. Series: 64bit-block-status Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 2 +- block/backup-top.c | 2 +- block/blkdebug.c | 2 +- block/blklogwrites.c | 4 ++-- block/blkreplay.c | 2 +- block/copy-on-read.c | 2 +- block/file-posix.c | 6 +++--- block/filter-compress.c | 2 +- block/gluster.c | 8 +++++--- block/iscsi.c | 12 ++++++++++-- block/mirror.c | 2 +- block/nbd.c | 4 +++- block/nvme.c | 16 ++++++++++++---- block/qcow2.c | 9 ++++++++- block/qed.c | 17 +++++++++++++---- block/raw-format.c | 2 +- block/throttle.c | 2 +- block/vmdk.c | 2 +- 18 files changed, 66 insertions(+), 30 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 3f08baeff0..c98d591a56 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -246,7 +246,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/backup-top.c b/block/backup-top.c index 519c7ea5ad..2484293fb0 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -76,7 +76,7 @@ static int coroutine_fn backup_top_co_pdiscard(BlockDriverState *bs, } static int coroutine_fn backup_top_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { int ret = backup_top_cbw(bs, offset, bytes, flags); if (ret < 0) { diff --git a/block/blkdebug.c b/block/blkdebug.c index e47a686628..d593d6c85d 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -672,7 +672,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 f9697aaa75..8ca41d09cd 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -474,8 +474,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 98b8dff860..186d28cc6a 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -95,7 +95,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-on-read.c b/block/copy-on-read.c index 174e711393..d99e07e99f 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -94,7 +94,7 @@ static int coroutine_fn cor_co_pwritev(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 38c1398494..fa9ac5b13e 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2797,7 +2797,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; @@ -2866,7 +2866,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); } @@ -3489,7 +3489,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 09c0201c51..7cf47608b5 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -85,7 +85,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 0aa1f2cda4..88130c3d2d 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -1017,19 +1017,21 @@ 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; + assert(bytes < INT_MAX); + + 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 861a70c823..c4183ef12f 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1204,8 +1204,8 @@ out_unlock: } static int -coroutine_fn iscsi_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, BdrvRequestFlags flags) +coroutine_fn iscsi_co_pwrite_zeroes_old(BlockDriverState *bs, int64_t offset, + int bytes, BdrvRequestFlags flags) { IscsiLun *iscsilun = bs->opaque; struct IscsiTask iTask; @@ -1308,6 +1308,14 @@ out_unlock: return r; } +static int +coroutine_fn iscsi_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, + int64_t bytes, BdrvRequestFlags flags) +{ + assert(bytes < INT_MAX); + return iscsi_co_pwrite_zeroes_old(bs, offset, bytes, flags); +} + static void apply_chap(struct iscsi_context *iscsi, QemuOpts *opts, Error **errp) { diff --git a/block/mirror.c b/block/mirror.c index ac3d4bc8c5..7f4fdfb470 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1464,7 +1464,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 8cd417f018..0e52b76d72 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1245,7 +1245,7 @@ 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 = { @@ -1254,6 +1254,8 @@ static int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, .len = bytes, }; + assert(bytes < INT_MAX); + 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 d91bbe60bf..724f894b00 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1104,10 +1104,10 @@ static coroutine_fn int nvme_co_flush(BlockDriverState *bs) } -static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, - int bytes, - BdrvRequestFlags flags) +static coroutine_fn int nvme_co_pwrite_zeroes_old(BlockDriverState *bs, + int64_t offset, + int bytes, + BdrvRequestFlags flags) { BDRVNVMeState *s = bs->opaque; NVMeQueuePair *ioq = s->queues[1]; @@ -1157,6 +1157,14 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs, return data.ret; } +static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs, + int64_t offset, + int64_t bytes, + BdrvRequestFlags flags) +{ + assert(bytes <= INT_MAX); + return nvme_co_pwrite_zeroes_old(bs, offset, bytes, flags); +} static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, int64_t offset, diff --git a/block/qcow2.c b/block/qcow2.c index 15a6d3c6ef..0800d0378a 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3727,7 +3727,7 @@ static bool is_zero(BlockDriverState *bs, int64_t offset, int64_t bytes) return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == bytes; } -static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, +static coroutine_fn int qcow2_co_pwrite_zeroes_old(BlockDriverState *bs, int64_t offset, int bytes, BdrvRequestFlags flags) { int ret; @@ -3779,6 +3779,13 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, return ret; } +static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, + int64_t offset, int64_t bytes, BdrvRequestFlags flags) +{ + assert(bytes < INT_MAX); + return qcow2_co_pwrite_zeroes_old(bs, offset, bytes, flags); +} + static coroutine_fn int qcow2_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) { diff --git a/block/qed.c b/block/qed.c index 1af9b3cb1d..fe00dbbff5 100644 --- a/block/qed.c +++ b/block/qed.c @@ -1439,10 +1439,10 @@ static int coroutine_fn bdrv_qed_co_writev(BlockDriverState *bs, return qed_co_request(bs, sector_num, qiov, nb_sectors, QED_AIOCB_WRITE); } -static int coroutine_fn bdrv_qed_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, - int bytes, - BdrvRequestFlags flags) +static int coroutine_fn bdrv_qed_co_pwrite_zeroes_old(BlockDriverState *bs, + int64_t offset, + int bytes, + BdrvRequestFlags flags) { BDRVQEDState *s = bs->opaque; @@ -1463,6 +1463,15 @@ static int coroutine_fn bdrv_qed_co_pwrite_zeroes(BlockDriverState *bs, QED_AIOCB_WRITE | QED_AIOCB_ZERO); } +static int coroutine_fn bdrv_qed_co_pwrite_zeroes(BlockDriverState *bs, + int64_t offset, + int64_t bytes, + BdrvRequestFlags flags) +{ + assert(bytes <= INT_MAX); + return bdrv_qed_co_pwrite_zeroes_old(bs, offset, bytes, flags); +} + static int coroutine_fn bdrv_qed_co_truncate(BlockDriverState *bs, int64_t offset, bool exact, diff --git a/block/raw-format.c b/block/raw-format.c index fdf024705b..0996741056 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -279,7 +279,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/throttle.c b/block/throttle.c index af8cc3b2dd..c97da1d6a7 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -137,7 +137,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 61b409ebc7..9611bb191e 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2089,7 +2089,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;