From patchwork Wed Mar 24 20:51:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12162351 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12DC5C433E0 for ; Wed, 24 Mar 2021 20:57:48 +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 A975861A17 for ; Wed, 24 Mar 2021 20:57:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A975861A17 Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=nongnu.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPAZW-0003vu-Oo for qemu-devel@archiver.kernel.org; Wed, 24 Mar 2021 16:57:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPATy-0006MO-N4; Wed, 24 Mar 2021 16:52:02 -0400 Received: from mail-vi1eur05on2092.outbound.protection.outlook.com ([40.107.21.92]:36928 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPATw-0005MQ-3Y; Wed, 24 Mar 2021 16:52:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jdvISCbT7lEiaorw1CqZYiKSN5Sf35DVvl3hHfZ5IjgN68iAgd+yn3iiilmGlyYF9ZvvEPU+/RQq7b3zYXji2u3fDPrL8u3VJy2UWJnyajnofOTbLb1PU2MJgMfoGVuZJ5F98SLScGqEkAdTEd6BcDV8H2W6yS+O+NjQaxVvdW4zkMdDrGE7UN8a8vUCAQ4h/VzQ0lBByUDPObWCK4VAGXWDWiJDR/ndvl+/OpXG/oX5uI6SZq7DQKeTa0Mum+ye9bes775w0dRVI0Mz6Ex6DxDTQZeq8u7MvfaDZlCQoQlj3LgICZFkc/IzV03QVcuxYQP6iDeTZJm/QQXxVM4w+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6LXXx9ulPXjxpstjADDnLl2sVDKfeh7GcxkQc6eREcM=; b=nJSXOaM8Xx/N6RNhbFdfYQuW6pju7sD3owTf5OaNoqNKt7TRyiruBLKLQtrHsBDHaZ/7xYMfb18guz8llFkrLBpulhymE+ngvsuzavAQ3OhtGFQpdJv1/eODRZhFunbs2Na1QN0997NWybtdzNpCSyS0p0uVyrCc5kX3T357/ZDWrE06D4jrrkwDqxo9Hh4+dPy66ZjD+uvDHXw91fnGYmMYeURjVczdsXMoo9ehfjfuFuU6csmuNxU5pFMohvMDSf3Fild2DdG4OxZh0tc80SH9VSOSnwC756H07jkrcKjC0OalD2t90R/CdvbbV35/zCSA2c2nLO/TY8xO9MJZBQ== 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=6LXXx9ulPXjxpstjADDnLl2sVDKfeh7GcxkQc6eREcM=; b=Q/CUCMl9SEv0NVOyUafWjZooNoUw3H1eJQVEIy6ZYXxikYyuWg8q567T9m1TrDSP3akcoEOOlanZyXVPeJ4Vh1h/NR5p74MJNLcvr+TgmEzk6N1CI4uANs/xMlm5o+Z+J6qLVDrH5AoaCvG64MeTwWbIV0UepasD8Z5hSwlTMUw= 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.3977.24; Wed, 24 Mar 2021 20:51:48 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a%7]) with mapi id 15.20.3955.027; Wed, 24 Mar 2021 20:51:48 +0000 To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, namei.unix@gmail.com, dillaman@redhat.com, berto@igalia.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v4 01/11] block/io: bring request check to bdrv_co_{read, write}v_vmstate Date: Wed, 24 Mar 2021 23:51:22 +0300 Message-Id: <20210324205132.464899-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210324205132.464899-1-vsementsov@virtuozzo.com> References: <20210324205132.464899-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.202] X-ClientProxiedBy: AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.202) by AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.9 via Frontend Transport; Wed, 24 Mar 2021 20:51:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 92c71332-bc47-41e1-b5b9-08d8ef06a48a X-MS-TrafficTypeDiagnostic: AM7PR08MB5447: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1728; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fG93SnpEz5W2De1zfxjPdjOncsZT8RbTyr2lax78Y79jXghBNsfa4okFmqxHzoH9AqcpToliOr7CId+0yovDAU/4nujlPZueBKZMD145Qvi0aNvrm1VfuwR0fhRsvbCfbMppLpfbvS8lcC2Oud7qVoYn4F818GBaYotNlsVUazeKKXfeC9yU/UOTEF03EquU5MFUWMTnUv5YXeoynB7ObYZSRAjUkcAezuWUAWcYt2jD0szUL+ccEOtS5PcyKd8gkqc/7US6nSR0CeXg2nC/xIfqUKlCE38b9/EEjvUMwgrwFoWK0uMn7SgpSaAU+YTcoll8WJUTsIIL2+9kd0Qf2oZlremeaC7wH1GeMNZ3tct9xFamQODCjzi81T+9hdBXYr+rz4xAlzGwXbyQbX6Ia3BtM5cRwkI6dVtPUNcDXC5UqRxpEwYGCKHUu55zWwHlG7otAY2veMpydsFq9s3cj3fmixtkbH8X4UQ1+nsdzMOCw94AbqdC4z9YsyaO7LgKsMg2DD+0fGR9Zzlxsg+kW4UVavQFKusgaQEtqr5cDolZQcgUaT3wNSv5H6lBzPmOJM7qHytwuNypH7MJhkx6pw1FknJ/NcpJGHU00iEEtpPRDpDvebF/YJqD/AJOhceTip8GJfb00FvdHLgfK9bNZVDqvjnPVv+j1p8laf9JM4J4xsMidM1g0p+2MCbaLhe4 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(346002)(136003)(376002)(396003)(366004)(2616005)(6916009)(478600001)(8936002)(66946007)(38100700001)(956004)(66556008)(6512007)(66476007)(6506007)(6486002)(52116002)(186003)(5660300002)(26005)(69590400012)(83380400001)(7416002)(6666004)(86362001)(2906002)(16526019)(316002)(1076003)(36756003)(4326008)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 7/fYzdRXxsFLwJrq7/L7eaojBRBp14ZpA+LNvm0J4WflFTzw8RypXQC+ooNaoXQ1kn5ZtfefpZoSfnY/XYKtatedwpvcpwK8xlulBHICtOjNWK/gaLHAAO9XL4LcCbHfN2thZ5v2A5ZKkgqdN0ERpCaYhN8eCrGmVLhfDy5AgpiHFlFR73Sxm3r3lC2avLS3bYyx0bLkyGZ1tOtztCNjACCFINhA7expj7pnE0O4+WbNsUcKdm/KRTVW6HxOMz93Ca5PPifKBCy7rve9R6Lg+WE1Ff7LYEJ5wLE4dXyXQKv9zHYmk0dbfjJxlYym9MIpOr4M52zk5eZl8Mw+riPakO7Y3bvsShw9ugrDGb1TBgUU1jC/Nm8PBesyMFzAiintEHx73hAGpUuRDpPXvNAr+bYki3swA/7RQfBAsSt8IEk3tDKv4dk3sWf4UqIRYOm7uQeKRZ3Ndxya/1OYH7r60YnkHS/zV5U7tFLYutvYfDgG+3YzsCwI47g5RMl9J8T5y133DW0NEACeKqk0ZwUVmdhh9WduDtirMSUDC3ocyWVHw8rH1hMwm4HH59Q7EE7eIz37FBXMmOxfanD59vlMA8v5LL0e/Z4aKHklm5jpJhnwFJfCh7MtUZJRvm0fdae+AF79hmovbHRRSIohN7hXBX9IKMdvZpGn4PGJOkVEiAs9UxOLZN7S9UqmRPxtiPtni9INDwOHpJmo6YLXLsLIXwNGDFYD7H8RWTo0OQoDp6x09+JHW1AGs2Fgg/qzihZdPRUo8lFjbnUzBb4QXgfKKLbeVai4kaMWDAC8LNa2tDDppbz2bQDwZhUXU2ArJYicuiV5wr3C7fk+io2KS2WPAaOsyzDqAvpmU7qHs0rgqU1jxVkjGg/bxv9We4o5zfIdsRKPeEodOZHxjQggHNJBkqdwnkpDAKGXdPl0EA9jwFy0+S49nq0oQZMH5LzcrfA+IKgvshb/XkP4WXaOzjrgnds84G1qPdlgqcecfRCylyLeL50Zm7dn2WjqsNV7PwOkgOC2dMqRl38cUA31uO9Qr8dCSyItgYtaELb/rpzoADvZsYmfFHG4/IIAHMKju+d6JgeUY5KIrKhpo5Jb/9JqMzc6xiUAc9zqXi5rL0rajIRjMu39cAE+7V4OTlAKw/b9M0kQg+O1zFBlcSXmgLi26ZJKMQi5RCjT8ozJOqruzLxO9+QXC8g/ROJ5CJajnOt8K5UWTzZBxg+sTvccyb/gDXIWYVzLi4HYpYx3WJZAMZA4XwAEuzADOFOV2AasYyvkLPEnQvbjSTVdsKpGknMbcXS8lE/mBSl+zy+e6wKyeq1DqWWpcP+wUeiiGNeCsedS X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 92c71332-bc47-41e1-b5b9-08d8ef06a48a X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2021 20:51:48.3595 (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: uJfjNO8630o2GNDG/E7I9cKhc+2/V+ry7dx4qTWzyQGUDM1z4P5/r/Ubwv1+A7MvUD2PGaGKq+J2eNxLFOQNU+qW+dkYM33imv+8sDlkLa4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5447 Received-SPF: pass client-ip=40.107.21.92; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reply-to: Vladimir Sementsov-Ogievskiy X-Patchwork-Original-From: Vladimir Sementsov-Ogievskiy via From: Vladimir Sementsov-Ogievskiy There are only two drivers supporting vmstate: qcow2 and sheepdog. Sheepdog is deprecated. In qcow2 these requests go through .bdrv_co_p{read,write}v_part handlers. So, let's do our basic check for the request on vmstate generic handlers. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/io.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index ca2dca3007..3bbb852da6 100644 --- a/block/io.c +++ b/block/io.c @@ -2718,7 +2718,12 @@ bdrv_co_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { BlockDriver *drv = bs->drv; BlockDriverState *child_bs = bdrv_primary_bs(bs); - int ret = -ENOTSUP; + int ret; + + ret = bdrv_check_qiov_request(pos, qiov->size, qiov, 0, NULL); + if (ret < 0) { + return ret; + } if (!drv) { return -ENOMEDIUM; @@ -2730,6 +2735,8 @@ bdrv_co_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) ret = drv->bdrv_load_vmstate(bs, qiov, pos); } else if (child_bs) { ret = bdrv_co_readv_vmstate(child_bs, qiov, pos); + } else { + ret = -ENOTSUP; } bdrv_dec_in_flight(bs); @@ -2742,7 +2749,12 @@ bdrv_co_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { BlockDriver *drv = bs->drv; BlockDriverState *child_bs = bdrv_primary_bs(bs); - int ret = -ENOTSUP; + int ret; + + ret = bdrv_check_qiov_request(pos, qiov->size, qiov, 0, NULL); + if (ret < 0) { + return ret; + } if (!drv) { return -ENOMEDIUM; @@ -2754,6 +2766,8 @@ bdrv_co_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) ret = drv->bdrv_save_vmstate(bs, qiov, pos); } else if (child_bs) { ret = bdrv_co_writev_vmstate(child_bs, qiov, pos); + } else { + ret = -ENOTSUP; } bdrv_dec_in_flight(bs); From patchwork Wed Mar 24 20:51:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12162333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFFC2C433C1 for ; Wed, 24 Mar 2021 20:54:25 +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 71867619B4 for ; Wed, 24 Mar 2021 20:54:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 71867619B4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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]:41664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPAWE-0000K0-N2 for qemu-devel@archiver.kernel.org; Wed, 24 Mar 2021 16:54:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPATx-0006L3-Rv; Wed, 24 Mar 2021 16:52:01 -0400 Received: from mail-vi1eur05on2116.outbound.protection.outlook.com ([40.107.21.116]:40416 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPATu-0005Ie-Do; Wed, 24 Mar 2021 16:52:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B8+ASj5LisjuXVOUutCLjl0ElTdeXRTphWsjmk2rfN2j7tpGn8JkiOWSwdRBQ3zZZRlo8vdbLCAt71QK9vkI15gEmTqfFPMdYDtWZTg0a0EfTvbiuKzaX+IU/e2qh1wIGnBmm30L6f5DP+TvFIe20QTEJIFwXt3PvhXGI1lfViVEaMKG9wxRXC0XehyWTfUzOzC3W0uQFBnSfDMlqNXeq7RdTwvLNOEdXbwFLHsliZo6FLaLylHIplshoBI68Iz0vzy63b4ODE7WkJSVbnLyblZI3nFeNAEVz/l7CXxt9/qqe3qfsObLC/Q+IAoudYq23oF83aOXmoqGiEbGQUh++Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kf5uaxmxNNSZu5jfBNaBtf9iEXVGXhAqkOq91nIXARA=; b=V2V10c5xebNmHo27XxRGabuZ3yxAz11+89eqt3Y0tlBnZVScfv3XkesN/4groWdrfs8npGZvmYLv+rpLNhoHGihDrS0x/dVwkxI5t9CD61efog98ljZkbmGDvPMvji9G2Kh//UHJNkMd4MfqacfdzlNkvw7pLR205bN4xJRj3ZWTYdjBZ4N83i3HYdEvbJFBF9tAnlGLDDXdidJrStxBej1U49DyNa8ooDCb6uCMDlCDjX1vbQ0DlOQHPic8OIGMRfmZNZm2YTAC5SDGQCPqVEge0lW1IX4bV9H3UBdBC/EbCMDso7588p3GnSdi9kAT4AiuaCtXc4WQo3YQAltZgw== 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=Kf5uaxmxNNSZu5jfBNaBtf9iEXVGXhAqkOq91nIXARA=; b=gNzxTZAZA8gwCARhnB8z7pjfH6AIGWYc0gcn8WGPNuhQLP4thYbuxSzGVBxsNVmmhec7DVi8XJkID0mKD9dDPsfH6ncEzEdyI5o4tkijp9RAvB/fbPPEYAZn+/QFxDVSleoasFTj03EE4/jlBPs0yGkpXxxLu650iOdbeLqgE1o= 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.3977.24; Wed, 24 Mar 2021 20:51:49 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a%7]) with mapi id 15.20.3955.027; Wed, 24 Mar 2021 20:51:49 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, namei.unix@gmail.com, dillaman@redhat.com, berto@igalia.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v4 02/11] qcow2: check request on vmstate save/load path Date: Wed, 24 Mar 2021 23:51:23 +0300 Message-Id: <20210324205132.464899-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210324205132.464899-1-vsementsov@virtuozzo.com> References: <20210324205132.464899-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.202] X-ClientProxiedBy: AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.202) by AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.9 via Frontend Transport; Wed, 24 Mar 2021 20:51:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8c474daa-2ce3-4ec5-38d8-08d8ef06a561 X-MS-TrafficTypeDiagnostic: AM7PR08MB5447: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:519; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bNxcASoHwlwJnQC2nLK4L+t9+kMTLggdbst1WVmlj+pQwjyy6996XutK2PODTce/2jmMMdv9UPoe10Ep3gp94GjOvjJ5CymaqnZsRHRpjXKz2736O8xa/lNvCmZ6Yvb1yPjR1UK959tgzlFIgE+yzde35m+kdE0GSFGn84JIEY/SOJSyna4J4oX8suoHc5WdfSD4EE4ZgEwNUmnUhovw1EmaKiZu1HmijFc+QQqzsc2KEps21369B/UWVaNz4QU2dXAASaGwH0c/GhnvzB1YdMMf1PdfeF54jx//u/1gIm627GcD1Rsl45pKZGcNoaoqGKdcwXlKJ2EsNDoGo6jEsmEunZTbrXUrtDTkd9aeltTP+2XIdBsJQNbwbJVGbqPX7QTy3WH+FrobC4mZMkOzYjlHD6uJH++7wsOyH1BEAMioFJtzwoqIf2YbdAXTwII8psemofiEk4o+clhtJkynGeI22UOU2QepuCqmqVJezrX+PncROKDh7gfMQiMqZGDCWufSXBz7l2AIXVpgR5d4HeJiSebbbwaDfw8uEul5p4LWBnbPogx9z49fbhUInrhKq6P2pf7T21D6unEL+pjj9InNZH79s/9A0uZZsaGMGDbAsVH9vrPsZUSgJZNDrLGCo7eVPqxFkX08jAItx4Z6weAAU0UiXvT2Qo1Z+UoVJBeLXEDxkFH1q4u3GV/UKpEw X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(346002)(136003)(376002)(396003)(366004)(2616005)(6916009)(478600001)(8936002)(66946007)(38100700001)(956004)(66556008)(6512007)(66476007)(6506007)(6486002)(52116002)(186003)(5660300002)(26005)(69590400012)(83380400001)(7416002)(6666004)(86362001)(2906002)(16526019)(316002)(1076003)(36756003)(4326008)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: nQcyEKSJcrIwAyvN+HMjGrBa1jhVGqLWV30ek7l0e4OSVhcYQotJ2AGffoFx+0/wxCLT5FHkyZWwHYawo7WZLoZ0vzYj7KLdsSSnSe3F+Lv6wop5jaEbNsPW+BK3Gt4m2vec4MV1/DkRFVmlxtRvIdlqmJ7eUQWX+mS7MGeBhgFZ5B7y7dcjte3S1iNVq6n9L7iomz8NtyFVTShFftZhSQX8jIH7uUHsk2HzblU2wVanxbzsiyCQ9UlxNE9PSMQzx89jM680z+JG9K6RLmoueKCiw2ebgYxX3y+H7V2yVBSgYZ00lhVshonWokXBtPnWuc7lma4GV4brtTXMD1XMIwgzSCjgMDm5tR5qtWYnzlws3jn4XURLvoYojQja/W6s6cohG0CNQR6NuoDYqMs6/pqliNMrpyqpRwBg8WIbPvZlqpwdsRUt3salXpVDe770ZLg+Di3k+Mhv2NnJ3cF7+pJ7l200E34hTWOA4gH2qhV2laLGD+WHd9mqKyg+M4x7PAqYnJQ55t5tzcLMN3IPtHMIgWtmjWhYnCfcAv+a72iUZMJoJBZ/qN2hk2WBKXtuTyp0Qd0pu1KG05+65c0zH2DiQrEtytUgVsuVpf0hnCfRgv1i7wp7PhllexOVT/QEss7RlivE8db5cCJ0wiqMr1oJbtC9YIPL2jzVt0jxgJXc1/jepbnZtsjLaaSWZy5aqD5PxcL2CK57IXc6wFVijpSFG1A1hf5+9T/Liw1aITmhPgpdRGSQfbdG6OMD3lzJKF5wvZby+jXAcu/5sbDoLktND8lVA6ctsfgrfTSnY8c4G0vT1gqB5KFOFBOI1q18liXfqM6nQzSv49MW9eq0rwqfAZy5lzn4qbItwSW/oWCbvJYVAVO2vdUOXfA2SbuSbya8W+BZ/FGE6Z60nLk/6to/M0XsiQTDAFTm32MCPPZIMPlj/7lH12Zh9ukd2I7eqWsFkcG4NoQQxgdjZavkeEJszK/etJTf9gpe0azPDPMLkde9UFzBnrqjHM7BwkEekyV+t/OHPtCvukbM10lCtGAeyQT8vkazqk+HvY9SXF2qyAN+48E3P7+YSiGy8m7YTyKSiwB0KVTtNmz8XnyySr76g8ZnVYD26asMuYEshtGu26oKxHIzwz4unf1VL+Ua+UiA535oseUSEuMMpmVfK8RMVCNp+WhiU4ARX1oH+3GTm6wo++zsQuBBAykMEi6hsZPVyHf3upp3VjO/uev57Z0g5l20T8n4BEl/J/8XLvRHuDyTTHTJwh6T00nMy4meAnh9Ql3fb8TwUi5gWTM992DHZ6rgul1p/x4g2cMsm2E9ZAb19JbqXntk7hyzaJj4 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8c474daa-2ce3-4ec5-38d8-08d8ef06a561 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2021 20:51:49.7474 (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: Dee+VW+TySaGr2bjb3aCfjX5gG0M/wUHF3UoIhQPFvG8rwJQGKlKdplyh6XNoL9c10OASx8ZjbEHRpq4sWtTRfm1cEzG81IPDo52peZ9Axo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5447 Received-SPF: pass client-ip=40.107.21.116; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We modify the request by adding an offset to vmstate. Let's check the modified request. It will help us to safely move .bdrv_co_preadv_part and .bdrv_co_pwritev_part to int64_t type of offset and bytes. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/block/block_int.h | 3 +++ block/io.c | 6 +++--- block/qcow2.c | 43 +++++++++++++++++++++++++++++++++------ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 88e4111939..db7a909ea9 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -93,6 +93,9 @@ typedef struct BdrvTrackedRequest { struct BdrvTrackedRequest *waiting_for; } BdrvTrackedRequest; +int bdrv_check_qiov_request(int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, + Error **errp); int bdrv_check_request(int64_t offset, int64_t bytes, Error **errp); struct BlockDriver { diff --git a/block/io.c b/block/io.c index 3bbb852da6..59924867c5 100644 --- a/block/io.c +++ b/block/io.c @@ -924,9 +924,9 @@ bool coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req, return waited; } -static int bdrv_check_qiov_request(int64_t offset, int64_t bytes, - QEMUIOVector *qiov, size_t qiov_offset, - Error **errp) +int bdrv_check_qiov_request(int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, + Error **errp) { /* * Check generic offset/bytes correctness diff --git a/block/qcow2.c b/block/qcow2.c index 0db1227ac9..b57acda010 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5166,24 +5166,55 @@ static int qcow2_has_zero_init(BlockDriverState *bs) } } +/* + * Check the request to vmstate. On success return + * qcow2_vm_state_offset(bs) + @pos + */ +static int64_t qcow2_check_vmstate_request(BlockDriverState *bs, + QEMUIOVector *qiov, int64_t pos) +{ + BDRVQcow2State *s = bs->opaque; + int64_t vmstate_offset = qcow2_vm_state_offset(s); + int ret; + + /* Incoming requests must be OK */ + bdrv_check_qiov_request(pos, qiov->size, qiov, 0, &error_abort); + + if (INT64_MAX - pos < vmstate_offset) { + return -EIO; + } + + pos += vmstate_offset; + ret = bdrv_check_qiov_request(pos, qiov->size, qiov, 0, NULL); + if (ret < 0) { + return ret; + } + + return pos; +} + static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { - BDRVQcow2State *s = bs->opaque; + int64_t offset = qcow2_check_vmstate_request(bs, qiov, pos); + if (offset < 0) { + return offset; + } BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE); - return bs->drv->bdrv_co_pwritev_part(bs, qcow2_vm_state_offset(s) + pos, - qiov->size, qiov, 0, 0); + return bs->drv->bdrv_co_pwritev_part(bs, offset, qiov->size, qiov, 0, 0); } static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { - BDRVQcow2State *s = bs->opaque; + int64_t offset = qcow2_check_vmstate_request(bs, qiov, pos); + if (offset < 0) { + return offset; + } BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD); - return bs->drv->bdrv_co_preadv_part(bs, qcow2_vm_state_offset(s) + pos, - qiov->size, qiov, 0, 0); + return bs->drv->bdrv_co_preadv_part(bs, offset, qiov->size, qiov, 0, 0); } /* From patchwork Wed Mar 24 20:51:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12162357 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60F1FC433C1 for ; Wed, 24 Mar 2021 21:00:47 +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 9936761A1E for ; Wed, 24 Mar 2021 21:00:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9936761A1E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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]:57904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPAcP-000780-Jv for qemu-devel@archiver.kernel.org; Wed, 24 Mar 2021 17:00:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPAU3-0006XS-Nk; Wed, 24 Mar 2021 16:52:07 -0400 Received: from mail-vi1eur05on2116.outbound.protection.outlook.com ([40.107.21.116]:40416 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPATy-0005Ie-OG; Wed, 24 Mar 2021 16:52:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PqlLArJ2NSbv+UIC9g7ZfaCNwjoUAPTpXMnMVrvLEAVHmYuD+UwxWluwUSySM10+lMb/zBGQZbynp62KAAOF8zHHD3n27VEj8Z1rlbraqWj60un/0xYaLSzc114GVzxpFueIG33ir+5Sq4kBa//rLyCqz5orMaBoolSQvHiUuu0RUezgMU7nmoCoPH4ZaQiMquHFFvOBbE1xwMonRslxgg4W1u8IVk/HYjpeAM+5/7lNyd+NXhIN5EnEPsvcc+qaIqrkI2WY/U4AfZYkvX0Bf7LR2Zx2jTnuea1s2AMtUde0MlBiapKfRfAx1NcqjuoWq0THZxqmA3U6wyJAzyLZvg== 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=XeKk68IYLZDtwcva7amIbtzPaGGJcfFqUnvEVbFPHtc=; b=SWN7or6MGsdnwBy6P0rk5Y9rovmHTB8WddECiUI5n89ENZ52PapXTDcfN1Njg5yHvay4P81hAApw7dd6S9z39zz7D3LUlZGm6tnsOtHdrpD5IwEccTvQ8hsmo3LbNtmiPDKs/uLQrXPOMUwI4CeITNez+14sUUj/SLYr03u3eaxXDCAxt0VeiiJk4s0EYTKTLq5Ur0WoUucXLjookxJFjaKRE/bUYsciwfhKTUxGzWGPrrWXjTBNAoyl1UYSyMA1ATIaqT84ulTQ7qZchEf9mT6bl5H6YLw4ONzW/m6puQ0OQ5mPlHk1Jc8ujGZpphplW1HZbdr0w7dZpYsG6eComw== 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=XeKk68IYLZDtwcva7amIbtzPaGGJcfFqUnvEVbFPHtc=; b=SNOclEh5cMXzyHoFvFLdsio7ZkdcVxoSfHxQ3DptvzR17xWHqeyiIb2tMPQtDNeDB0mIUmW5/P0U6E/levbK69WJpR8vBOQJSGKyAtb6pTQXlJbDxEEgr7OrTDMXrfFwx34nBzz76VaCOynsNOYLzF7vKH4vvl4e5NHnMO9qxLo= 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.3977.24; Wed, 24 Mar 2021 20:51:51 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a%7]) with mapi id 15.20.3955.027; Wed, 24 Mar 2021 20:51:51 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, namei.unix@gmail.com, dillaman@redhat.com, berto@igalia.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v4 03/11] block: use int64_t instead of uint64_t in driver read handlers Date: Wed, 24 Mar 2021 23:51:24 +0300 Message-Id: <20210324205132.464899-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210324205132.464899-1-vsementsov@virtuozzo.com> References: <20210324205132.464899-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.202] X-ClientProxiedBy: AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.202) by AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.9 via Frontend Transport; Wed, 24 Mar 2021 20:51:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 40662d71-a8f9-450c-43dc-08d8ef06a632 X-MS-TrafficTypeDiagnostic: AM7PR08MB5447: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:390; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tQ+lpK7gtNr+vsZsjxsjriXfIIp5y4Lkf/JyDdzds5vL10EMJUCzR80a6jsWTmwvk+t3xGpaEFgeEzojFVUDdpVTzlO1yW/KYVUGi25l42SC7TkTvcEryGa0NHaIQWNO9R2gUJxLNGQ9mE9b/ftB1kalVjRhGAJdwdmv1hkfUPhZvJm+ZqvXq9wxYvOH5EG6quzod2j8NxAmPRgqNJX57tF/zw4fGftXhje++tN8aBbjCsiRa3kASAxmg0iMpTLow/kCK1DBiAdGyNmJMTumxQ+iskl46yD+huFP3uek9HCWbC9NIIOBAD922wRMnjZBpSyZo1p/cuLgOJxVHXq06PdjNa61JYYt148uT+qf+7HY3YmDHZQrI9Ok5Z2klHbCbQTu9LEye2ymv1oJ25vl17AdzDWvZje0EPs+6tEqynUNvC/hBGmtXsq0deXC7sKRqLf801C3s8ZnKCv6KHvqUcmZ3uHQA0vmy9iMyYL/QwZxktXO7C7FmBB+gCtH4qvb+5z5KgqAoalWZKiWbGQiXS2YacFo4cl6gPrp0x7eP00B8xFq0AQYLw0f+ebKhFfhkscU8qjk2QtXw/icjeQpvPlsoqI+Ymd5CpOcjCRFOHGP6fv4dI8fn89FjZsmhSACXimFWLr66Fw4akkkb1Bwnnn5noccuarpwULZsFXIPdKviwZBe061uZ0kCuL67VN4 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(346002)(136003)(376002)(396003)(366004)(2616005)(6916009)(478600001)(8936002)(66946007)(38100700001)(956004)(66556008)(6512007)(66476007)(6506007)(6486002)(52116002)(186003)(5660300002)(26005)(69590400012)(83380400001)(7416002)(6666004)(86362001)(2906002)(30864003)(16526019)(316002)(1076003)(36756003)(4326008)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: F2GpAk/iCGqqSj1j2lBwk198ItAjqXisTp4fujImCiloVlxLvQhaJphQPHuxolaygfIfo60+ZsB+HhvZI5znXfORFhKSCLXPsX1yA9Zgrk846ApE3+S2kXxHMcrjzsOWAONu2Be4xl1vwFZR8HS6eQv65VjM98Pcih0T11arKpGoRQyk3K/3V6iWJaSchfBFLSBDzFLXbvpoi5L8GK5UNNLzauusEyfGuvrAHe83GydQFqnzGV8Ex2bhzuGMacyFDf9OhwWOHwMhK6MqL7YbPEVgBM1CNEHFkt6zIu8aUaXih4ehiJL1AWgqZjxTXgGJPCGQkUgFerbX5+whtHdv1RmGzWMnRYpofA1TusEqCdsSkpEbcSdmk+UIa5HSU/vsDd2NQ4w0TvLquU53MQJyHSS1gk1hw278qIW4UCNFdE4FodB4FLyFfe+i/Bc1D6hLtUiIfdNcquNxm69Mmgttd69vB1FccCNBwrh0xDcsJqKjyLxb/9i7cF2XiTR/E6KujemUtvIBAFc5mmTcMrpWvwMlseB6BTyQdy+vbGajrh1BiG/AbCdKArQnA4dDoLwQwBrAWXhm0JcTbmuMIFtPX/QY56/4ElBbwq33PKo0hN62ytgE3/M5K9vcHs5ZaKLC86qNEaKdgZoyIgsIh37zTlxmj96RbHhV3teRhPzPf6RsBOn1DoC5afa9kALze32tKjqz1D1f5YLUCzBNuBhBpz67GFWwxKf0+tBnCxcC8yNZ/FEPbwZ4/50jr+vwaFOelMHnuNHJomPwJ5R21/dIRCmNbSS4eJsQUBJHUbgQkiDdYBO1jxFNOaIgLWe2CebJBTHbvknJRqFc9QEmtzvhnjlIlFgl+KDUbfQH4xll/+EqWUDuPJrzEoxfbQ3RPuw1Ya0q4D8odsrpmpco9GJnlBuZZp7cDETrOjpBuY9BUEny4KkEdXHH20rOr4JRChzyRwdIyKS5zXL/EcCXgDvEdIjFf4IaMNo+7UyKO7sHbjEc0ZWPCwU8oi2n6QjctmFygBHgM/AihRd65l0sW3ZAe4B7UdcABdUUTppe9XFlnI68d3WUtg3sVw45wzAODWru8MgTMa64MLv16GWxb5i4QIk5JSHrlc+sZhvA7kGATJdCv8hGVjEAE79x6Zaa5cjkGo0jVMHHe6Z5tvL0c4QlhASqykwyeRIZy/3tL1zIQnxRdwSdN8CCnTIjpsvv6OgSInn5FhMR1mOmfRQopAU2q9Zt3arKOrubja0M2Re6sO8+3ZLnEkYT26e1UcU+XOjab7JK7XICfkQTQ1a9DqkhaeoSrX4CEmLAZ20F68IWsGK/BNMvAls9QZB34ohmOLat X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40662d71-a8f9-450c-43dc-08d8ef06a632 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2021 20:51:51.1831 (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: BYdotB3cNkuDI27A7qMWbv27bthUxeEmT7dxsgFVjvpiGDYLP8EbbBvTyMZoNicZpV+aFz8nlcvf7UR3BuUaHJRqytMzAIjz1d8mKzcFskc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5447 Received-SPF: pass client-ip=40.107.21.116; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are going to convert .bdrv_co_preadv_part and .bdrv_co_pwritev_part to int64_t type for offset and bytes parameters (as it's already done for generic block/io.c layer). In qcow2 .bdrv_co_preadv_part is used in some places, so let's add corresponding checks and assertions. Signed-off-by: Vladimir Sementsov-Ogievskiy block: use int64_t instead of uint64_t in driver read handlers We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, convert driver read handlers parameters which are already 64bit to signed type. While being here, convert also flags parameter to be BdrvRequestFlags. Now let's consider all callers. Simple git grep '\->bdrv_\(aio\|co\)_preadv\(_part\)\?' shows that's there three callers of driver function: bdrv_driver_preadv() in block/io.c, passes int64_t, checked by bdrv_check_qiov_request() to be non-negative. qcow2_load_vmstate() does bdrv_check_qiov_request(). do_perform_cow_read() has uint64_t argument. And a lot of things in qcow2 driver are uint64_t, so converting it is big job. But we must not work with requests that doesn't satisfy bdrv_check_qiov_request(), so let's just assert it here. Still, the functions may be called directly, not only by drv->... Let's check: git grep '\.bdrv_\(aio\|co\)_preadv\(_part\)\?\s*=' | \ awk '{print $4}' | sed 's/,//' | sed 's/&//' | sort | uniq | \ while read func; do git grep "$func(" | \ grep -v "$func(BlockDriverState"; done The only one such caller: QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, &data, 1); ... ret = bdrv_replace_test_co_preadv(bs, 0, 1, &qiov, 0); in tesTS/unit/test-bdrv-drain.c, and it's OK obviously. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/block/block_int.h | 11 ++++++----- block/backup-top.c | 4 ++-- block/blkdebug.c | 4 ++-- block/blklogwrites.c | 4 ++-- block/blkreplay.c | 2 +- block/blkverify.c | 4 ++-- block/bochs.c | 4 ++-- block/cloop.c | 4 ++-- block/commit.c | 2 +- block/copy-on-read.c | 4 ++-- block/crypto.c | 4 ++-- block/curl.c | 3 ++- block/dmg.c | 4 ++-- block/file-posix.c | 6 +++--- block/file-win32.c | 4 ++-- block/filter-compress.c | 4 ++-- block/mirror.c | 2 +- block/nbd.c | 5 +++-- block/nfs.c | 6 +++--- block/null.c | 9 +++++---- block/nvme.c | 5 +++-- block/preallocate.c | 4 ++-- block/qcow.c | 6 +++--- block/qcow2-cluster.c | 14 +++++++++++++- block/qcow2.c | 5 +++-- block/quorum.c | 4 ++-- block/raw-format.c | 20 ++++++++++---------- block/rbd.c | 5 +++-- block/throttle.c | 5 +++-- block/vdi.c | 4 ++-- block/vmdk.c | 4 ++-- block/vpc.c | 4 ++-- block/vvfat.c | 4 ++-- tests/unit/test-bdrv-drain.c | 16 +++++++++------- tests/unit/test-block-iothread.c | 19 ++++++++++++++----- 35 files changed, 120 insertions(+), 89 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index db7a909ea9..e6bcf74e46 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -234,8 +234,8 @@ struct BlockDriver { /* aio */ BlockAIOCB *(*bdrv_aio_preadv)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags, - BlockCompletionFunc *cb, void *opaque); + int64_t offset, int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque); BlockAIOCB *(*bdrv_aio_pwritev)(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags, BlockCompletionFunc *cb, void *opaque); @@ -264,10 +264,11 @@ struct BlockDriver { * The buffer in @qiov may point directly to guest memory. */ int coroutine_fn (*bdrv_co_preadv)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags); + int64_t offset, int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags); int coroutine_fn (*bdrv_co_preadv_part)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, size_t qiov_offset, int flags); + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); int coroutine_fn (*bdrv_co_writev)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int flags); /** diff --git a/block/backup-top.c b/block/backup-top.c index 589e8b651d..9779493a4b 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) { BDRVBackupTopState *s = bs->opaque; diff --git a/block/blkdebug.c b/block/blkdebug.c index 2c0b9b0ee8..b26fecf222 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -614,8 +614,8 @@ static int rule_check(BlockDriverState *bs, uint64_t offset, uint64_t bytes, } static int coroutine_fn -blkdebug_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +blkdebug_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { int err; diff --git a/block/blklogwrites.c b/block/blklogwrites.c index b7579370a3..de3d4ba2b6 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -301,8 +301,8 @@ static void blk_log_writes_refresh_limits(BlockDriverState *bs, Error **errp) } static int coroutine_fn -blk_log_writes_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +blk_log_writes_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); } diff --git a/block/blkreplay.c b/block/blkreplay.c index 4a247752fd..13ea2166bb 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -72,7 +72,7 @@ static void block_request_create(uint64_t reqid, BlockDriverState *bs, } static int coroutine_fn blkreplay_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) { uint64_t reqid = blkreplay_next_id(); int ret = bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); diff --git a/block/blkverify.c b/block/blkverify.c index 188d7632fa..5e35744b8a 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -221,8 +221,8 @@ blkverify_co_prwv(BlockDriverState *bs, BlkverifyRequest *r, uint64_t offset, } static int coroutine_fn -blkverify_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +blkverify_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BlkverifyRequest r; QEMUIOVector raw_qiov; diff --git a/block/bochs.c b/block/bochs.c index 2f010ab40a..4d68658087 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -238,8 +238,8 @@ static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num) } static int coroutine_fn -bochs_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +bochs_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVBochsState *s = bs->opaque; uint64_t sector_num = offset >> BDRV_SECTOR_BITS; diff --git a/block/cloop.c b/block/cloop.c index c99192a57f..b8c6d0eccd 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -245,8 +245,8 @@ static inline int cloop_read_block(BlockDriverState *bs, int block_num) } static int coroutine_fn -cloop_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +cloop_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVCloopState *s = bs->opaque; uint64_t sector_num = offset >> BDRV_SECTOR_BITS; diff --git a/block/commit.c b/block/commit.c index dd9ba87349..04a1bb43c1 100644 --- a/block/commit.c +++ b/block/commit.c @@ -212,7 +212,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 9cad9e1b8c..afb2a77b08 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -141,10 +141,10 @@ static int64_t cor_getlength(BlockDriverState *bs) static int coroutine_fn cor_co_preadv_part(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, - int flags) + BdrvRequestFlags flags) { int64_t n; int local_flags; diff --git a/block/crypto.c b/block/crypto.c index 1d30fde38e..a732a36d10 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -397,8 +397,8 @@ static int block_crypto_reopen_prepare(BDRVReopenState *state, #define BLOCK_CRYPTO_MAX_IO_SIZE (1024 * 1024) static coroutine_fn int -block_crypto_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +block_crypto_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BlockCrypto *crypto = bs->opaque; uint64_t cur_bytes; /* number of bytes in current iteration */ diff --git a/block/curl.c b/block/curl.c index 50e741a0d7..4a8ae2b269 100644 --- a/block/curl.c +++ b/block/curl.c @@ -896,7 +896,8 @@ out: } static int coroutine_fn curl_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { CURLAIOCB acb = { .co = qemu_coroutine_self(), diff --git a/block/dmg.c b/block/dmg.c index ef35a505f2..447901fbb8 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -689,8 +689,8 @@ static inline int dmg_read_chunk(BlockDriverState *bs, uint64_t sector_num) } static int coroutine_fn -dmg_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +dmg_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVDMGState *s = bs->opaque; uint64_t sector_num = offset >> BDRV_SECTOR_BITS; diff --git a/block/file-posix.c b/block/file-posix.c index 20e14f8e96..25da79cdd5 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2033,9 +2033,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 2642088bd6..15076350f2 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -436,8 +436,8 @@ fail: } static BlockAIOCB *raw_aio_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { BDRVRawState *s = bs->opaque; diff --git a/block/filter-compress.c b/block/filter-compress.c index 5136371bf8..54a16c6c64 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -63,10 +63,10 @@ static int64_t compress_getlength(BlockDriverState *bs) static int coroutine_fn compress_co_preadv_part(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, - int flags) + BdrvRequestFlags flags) { return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset, flags); diff --git a/block/mirror.c b/block/mirror.c index 6af02a57c4..1587cda13c 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1381,7 +1381,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 c26dc5a54f..a2b6aa1bca 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1534,8 +1534,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 8c1968bb41..eee8f706ba 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -265,9 +265,9 @@ nfs_co_generic_cb(int ret, struct nfs_context *nfs, void *data, nfs_co_generic_bh_cb, task); } -static int coroutine_fn nfs_co_preadv(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *iov, - int flags) +static int coroutine_fn nfs_co_preadv(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *iov, + BdrvRequestFlags flags) { NFSClient *client = bs->opaque; NFSRPC task; diff --git a/block/null.c b/block/null.c index cc9b1d4ea7..343dbb580d 100644 --- a/block/null.c +++ b/block/null.c @@ -116,8 +116,9 @@ static coroutine_fn int null_co_common(BlockDriverState *bs) } static coroutine_fn int null_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVNullState *s = bs->opaque; @@ -187,8 +188,8 @@ static inline BlockAIOCB *null_aio_common(BlockDriverState *bs, } static BlockAIOCB *null_aio_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { diff --git a/block/nvme.c b/block/nvme.c index 2b5421e7aa..58342c6409 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1221,8 +1221,9 @@ static int nvme_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes, } static coroutine_fn int nvme_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { return nvme_co_prw(bs, offset, bytes, qiov, false, flags); } diff --git a/block/preallocate.c b/block/preallocate.c index b619206304..5709443612 100644 --- a/block/preallocate.c +++ b/block/preallocate.c @@ -227,8 +227,8 @@ static void preallocate_reopen_abort(BDRVReopenState *state) } static coroutine_fn int preallocate_co_preadv_part( - BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, size_t qiov_offset, int flags) + BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) { return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset, flags); diff --git a/block/qcow.c b/block/qcow.c index f8919a44d1..1151b8d79b 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -617,9 +617,9 @@ static void qcow_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.request_alignment = BDRV_SECTOR_SIZE; } -static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVQcowState *s = bs->opaque; int offset_in_cluster; diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index bd0597842f..70adea9f59 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -505,7 +505,19 @@ static int coroutine_fn do_perform_cow_read(BlockDriverState *bs, return -ENOMEDIUM; } - /* Call .bdrv_co_readv() directly instead of using the public block-layer + /* + * We never deal with requests that doesn't satisfy + * bdrv_check_qiov_request(), and aligning requests to clusters never break + * this condition. So, do some assertions before calling + * bs->drv->bdrv_co_preadv_part() which has int64_t arguments. + */ + assert(src_cluster_offset <= INT64_MAX); + assert(src_cluster_offset + offset_in_cluster <= INT64_MAX); + assert(qiov->size <= INT64_MAX); + bdrv_check_qiov_request(src_cluster_offset + offset_in_cluster, qiov->size, + qiov, 0, &error_abort); + /* + * Call .bdrv_co_readv() directly instead of using the public block-layer * interface. This avoids double I/O throttling and request tracking, * which can lead to deadlock when block layer copy-on-read is enabled. */ diff --git a/block/qcow2.c b/block/qcow2.c index b57acda010..34c5e1c073 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2281,9 +2281,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 cfc1436abb..1eba2ce7ff 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -663,8 +663,8 @@ static int read_fifo_child(QuorumAIOCB *acb) return ret; } -static int quorum_co_preadv(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, int flags) +static int quorum_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVQuorumState *s = bs->opaque; QuorumAIOCB *acb = quorum_aio_get(bs, qiov, offset, bytes, flags); diff --git a/block/raw-format.c b/block/raw-format.c index 7717578ed6..e3f459b2cb 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -181,8 +181,8 @@ static void raw_reopen_abort(BDRVReopenState *state) } /* Check and adjust the offset, against 'offset' and 'size' options. */ -static inline int raw_adjust_offset(BlockDriverState *bs, uint64_t *offset, - uint64_t bytes, bool is_write) +static inline int raw_adjust_offset(BlockDriverState *bs, int64_t *offset, + int64_t bytes, bool is_write) { BDRVRawState *s = bs->opaque; @@ -201,9 +201,9 @@ static inline int raw_adjust_offset(BlockDriverState *bs, uint64_t *offset, return 0; } -static int coroutine_fn raw_co_preadv(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static int coroutine_fn raw_co_preadv(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { int ret; @@ -259,7 +259,7 @@ static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset, qiov = &local_qiov; } - ret = raw_adjust_offset(bs, &offset, bytes, true); + ret = raw_adjust_offset(bs, (int64_t *)&offset, bytes, true); if (ret) { goto fail; } @@ -294,7 +294,7 @@ static int coroutine_fn raw_co_pwrite_zeroes(BlockDriverState *bs, { int ret; - ret = raw_adjust_offset(bs, (uint64_t *)&offset, bytes, true); + ret = raw_adjust_offset(bs, (int64_t *)&offset, bytes, true); if (ret) { return ret; } @@ -306,7 +306,7 @@ static int coroutine_fn raw_co_pdiscard(BlockDriverState *bs, { int ret; - ret = raw_adjust_offset(bs, (uint64_t *)&offset, bytes, true); + ret = raw_adjust_offset(bs, &offset, bytes, true); if (ret) { return ret; } @@ -541,7 +541,7 @@ static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs, { int ret; - ret = raw_adjust_offset(bs, &src_offset, bytes, false); + ret = raw_adjust_offset(bs, (int64_t *)&src_offset, bytes, false); if (ret) { return ret; } @@ -560,7 +560,7 @@ static int coroutine_fn raw_co_copy_range_to(BlockDriverState *bs, { int ret; - ret = raw_adjust_offset(bs, &dst_offset, bytes, true); + ret = raw_adjust_offset(bs, (int64_t *)&dst_offset, bytes, true); if (ret) { return ret; } diff --git a/block/rbd.c b/block/rbd.c index 9071a00e3f..69299e5f6f 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -992,8 +992,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 b685166ad4..20362b5fe5 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -112,8 +112,9 @@ static int64_t throttle_getlength(BlockDriverState *bs) } static int coroutine_fn throttle_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { ThrottleGroupMember *tgm = bs->opaque; diff --git a/block/vdi.c b/block/vdi.c index 5627e7d764..c0e71bfa53 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -544,8 +544,8 @@ static int coroutine_fn vdi_co_block_status(BlockDriverState *bs, } static int coroutine_fn -vdi_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vdi_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVVdiState *s = bs->opaque; QEMUIOVector local_qiov; diff --git a/block/vmdk.c b/block/vmdk.c index 4499f136bd..78592160d0 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1888,8 +1888,8 @@ static int vmdk_read_extent(VmdkExtent *extent, int64_t cluster_offset, } static int coroutine_fn -vmdk_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vmdk_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVVmdkState *s = bs->opaque; int ret; diff --git a/block/vpc.c b/block/vpc.c index 17a705b482..29c8517ff8 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -608,8 +608,8 @@ static int vpc_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) } static int coroutine_fn -vpc_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vpc_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVVPCState *s = bs->opaque; int ret; diff --git a/block/vvfat.c b/block/vvfat.c index 54807f82ca..8ac90166c5 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1522,8 +1522,8 @@ static int vvfat_read(BlockDriverState *bs, int64_t sector_num, } static int coroutine_fn -vvfat_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vvfat_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { int ret; BDRVVVFATState *s = bs->opaque; diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c index 8a29e33e00..2627d9781e 100644 --- a/tests/unit/test-bdrv-drain.c +++ b/tests/unit/test-bdrv-drain.c @@ -65,8 +65,9 @@ static void co_reenter_bh(void *opaque) } static int coroutine_fn bdrv_test_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVTestState *s = bs->opaque; @@ -1105,8 +1106,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); @@ -1854,10 +1856,10 @@ static void bdrv_replace_test_close(BlockDriverState *bs) * Set .has_read to true and return success. */ static int coroutine_fn bdrv_replace_test_co_preadv(BlockDriverState *bs, - uint64_t offset, - uint64_t bytes, + int64_t offset, + int64_t bytes, QEMUIOVector *qiov, - int flags) + BdrvRequestFlags flags) { BDRVReplaceTestState *s = bs->opaque; diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index 8cf172cb7a..b3f8f3ff8e 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -31,9 +31,18 @@ #include "qemu/main-loop.h" #include "iothread.h" -static int coroutine_fn bdrv_test_co_prwv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +static int coroutine_fn bdrv_test_co_preadv(BlockDriverState *bs, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) +{ + return 0; +} + +static int coroutine_fn bdrv_test_co_pwritev(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, + int flags) { return 0; } @@ -66,8 +75,8 @@ static BlockDriver bdrv_test = { .format_name = "test", .instance_size = 1, - .bdrv_co_preadv = bdrv_test_co_prwv, - .bdrv_co_pwritev = bdrv_test_co_prwv, + .bdrv_co_preadv = bdrv_test_co_preadv, + .bdrv_co_pwritev = bdrv_test_co_pwritev, .bdrv_co_pdiscard = bdrv_test_co_pdiscard, .bdrv_co_truncate = bdrv_test_co_truncate, .bdrv_co_block_status = bdrv_test_co_block_status, From patchwork Wed Mar 24 20:51:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12162349 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F34DBC433C1 for ; Wed, 24 Mar 2021 20:57:15 +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 8931261A17 for ; Wed, 24 Mar 2021 20:57:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8931261A17 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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]:48812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPAZ0-0003LC-Hr for qemu-devel@archiver.kernel.org; Wed, 24 Mar 2021 16:57:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPAU3-0006WL-9i; Wed, 24 Mar 2021 16:52:07 -0400 Received: from mail-vi1eur05on2092.outbound.protection.outlook.com ([40.107.21.92]:36928 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPATz-0005MQ-Ft; Wed, 24 Mar 2021 16:52:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k0hz7MKIW08JN4A44OQK9wHUquEFGFPg54LfD5axj71UddOYWdnRj7H0RPb8SwhhoQYi6jiqJBXVzEPAk4G8P45mlP3ti/xGHLlaAPbz1sPChgiZMIQajoOIbeUQvFFWWXfDASspoV4WWv+I2CdcnsiQsBTDhQt+f8Uy8cOhhxLTQNPadJaDMlaLoIx8fVnYDnDWV2VWtLPwPOIt/Mwur0hs4qDe8PRWe9LkRX/b8WDO/ziUPsh6V4ohP7JsrUiQ+2eaSsMGqpiy6vvQ4p4fkSV0sd732m5Vuytes0GtwglmO7OY8TDuKn8gVq/RfNqNyN8wamFeAyJfxCBF34A7ag== 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=3qy3seYCy4/ADrGcme8/S3+782QExpvgjBWX4+tnky4=; b=iIz1UV5ozqhb+td9rVKHV1Qe8jwYIXI9g0Oeob0B+rfBp1s/MbHBMp1ldVIf93Ftcr3ABBLEszDEpz49emE5ORDk2WGHDhh2Fb27B8dUds+W6jo2uWXG8OoE6Zf6tE/5aulZOjjcQAKMnJ/p2GeTqIwW9l/ybeaQDcPI0iUSuaBJ1V1JFyi3lmZrI1N0PzLLFiqW0TC312Rn+j/0eM3VnL22AMXc9KKs2YvjlU5o1x90W1ctpsCjSiXyW5KtIrKFFz8sOyxJ7F0CX3hYk3R0cjAaXo6hjBlcFQh4ZqbL1FJzWoKVQosMHiz700+jpuJwJ9TPnWj5xVEJCiPWmh08gw== 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=3qy3seYCy4/ADrGcme8/S3+782QExpvgjBWX4+tnky4=; b=Z2NLIvLsO4dyy0YHzV13eZDskXjxKaFolfwaH1DRABoQEDoqIDVjOp7ApktF5zbqQzZyArgdzdRE/xbtiTJ/2MjMabFlvKj/ZxXIKhT6dNGG/KFZ714hPf1VB0HEcwL/j1ouyTO4pkNIlQ0MHlhDT1V1c5ZGawi3TbSRdCtjfRk= 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.3977.24; Wed, 24 Mar 2021 20:51:52 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a%7]) with mapi id 15.20.3955.027; Wed, 24 Mar 2021 20:51:52 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, namei.unix@gmail.com, dillaman@redhat.com, berto@igalia.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v4 04/11] block: use int64_t instead of uint64_t in driver write handlers Date: Wed, 24 Mar 2021 23:51:25 +0300 Message-Id: <20210324205132.464899-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210324205132.464899-1-vsementsov@virtuozzo.com> References: <20210324205132.464899-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.202] X-ClientProxiedBy: AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.202) by AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.9 via Frontend Transport; Wed, 24 Mar 2021 20:51:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 74bf4c27-9576-40bc-3f14-08d8ef06a70e X-MS-TrafficTypeDiagnostic: AM7PR08MB5447: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:254; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GsoNvMCEfEZNPhbOu3W/QjdJSXEkEx3FGIWxFlbjClKWzVMKFFK+/BHo4r2bZVIc57xsV9HDcOQaQq/csZUNju9JtiC18Vcu4fy2wHspWr62alx2E7ob6eiqMmwI0KggZwOCKe5ke3uHCDZNdJ3mar0Cn04fQ2eSNJfanhtKEsWDUlwZ/5xdOwAijwiCiEC/OLaffK93SAj0g1yFAuNl+D3I6nJCwcgwygoYInhu8siWUx8syCZwznVuMNprAE1X8Mon/n5iyTuc+GctPPa7vSGG03LAyzAkRn8EGXlfGbJQBfJ3/KAgemRpmYRFzl2pRyh8JupuIusc9oKvKj2Prt/WRJyZGN8q4VyDs0988wjJy0ZV6VeKoyYXpMY/rGr3/5YbVzRDsob+7DAw+b35wKUJgKgJZlWPeXKyopRAhzc4eJugrMopp8+jrEWB94ggB3yp08rMI6DDUktEnC1qrQOmLtx+avOxJSHLXpbF7hvG892dn7wMpodcyxA4OO6WQ/83rB5i3GTBMl3VUJ7xiv2sIk1YndLwE6h56nWYsXq+c0n4bUPN34Ok1pdXl7II7EOV7ryVjbydZNQXb2feSeHp1Cgazb8/zajqdlDfVX2nsbIkhW0SYrGtSESJAgrrStxCoaPUJUjTGAshpEia8nqQj42UBGpXYjPmG0C/na9vDxoCFKJNz2Nkq2LmI5c3kANkgModb07XeUpuMPDYQQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(346002)(136003)(376002)(396003)(366004)(2616005)(6916009)(478600001)(8936002)(66946007)(38100700001)(956004)(66556008)(6512007)(66476007)(6506007)(6486002)(52116002)(186003)(5660300002)(26005)(69590400012)(83380400001)(7416002)(6666004)(86362001)(2906002)(30864003)(16526019)(316002)(1076003)(36756003)(4326008)(8676002)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: IBVcaQLhQ//pIm7h/SB+bpLgRG+CXS8cJOka4k+SRCk2L/EFfvr+kvV00C0wkctl61F8oMT9JM7UfOWPO+LR7ZTJV2OVxKALDqLVb2vh+wACLsdbIyZC2a/VRE2tSFfVtqGlRa7UrKPuf/+75zdMKJoTVvSsmVYNsy2iUQUtS1gxOAj0K9NLBSAWTGkD7qOE0TIPtjYJGGCwKmf8fWSb3GiVgZXuoOoF3h7xCqP5WFNGV9ilYWG1dlB2i+jL4JxWOZeUtmxrXehgH/kxghS4TaL8OGyDPxNJTdxYrOHLxYo6TaxTjokeyO6ZFfW1gweI+i1DoE2VxiOUdVxVjMyBy11CruSP8+fwDb2yRZ28FCAZl6k+oqtBozc/aGDhvFwJSi09GhKXUgMvdtpl0Wlj5gkWOOfOYRT3+fdCf36S7mZ5hB8SyO6ImEpLpBmdcd8wXtxM9X+7fKXwhCkChQwHNIyj3EEeMnBgQydpJfldz90DOqFANpYcc33jOWPYr37Hym4N6IzBjOAFAJNhPoL0W1XOAxfhRlvRot0R60mECtNDIWKNH3vmRL/k+gmHeRiLdX2xgLRzpreOwi2YbOuXci5VfJEeAq9rkzef7hwUHZBmmQqtepMhXJQ2UMVSNP62QG8TSx6nwGJtohAVn+ypzZIDcpcvjGpSq9Kc8CCHpCf6vqDSiksDs4ieEYFcjXysk8ZJG/ymX1y3S1lvgtSGjtRMl2Oe857J33MLN9AWfG772HmjVtkJxoPrGCrRkyXu6q7gvG2lM4xWjrrRGEE6FqP36kvleKbKyBcidcb4DNQWlQjtypwO7oCSeE6Do5LHRLDKgd2eK0ak4ScS57RaKJDtFjIywGyW3oqZ2QlHvYs5+AM/2Ob1CiImorXaElyTrh72L4NsbKXiJE18/vPWcMmG0CDxYf4sBoF2KATEkxSFPCzT0HAlU9IFB+kVUdk85CNWTyUDRgqw2hkYVTe/QG1Afse15Fl1hFvU+neL6aVY2cLS2YwyGKY6q09DHRlbLO7HSB4RIjD6NeqKTqYeRqMzxUdzVjV8JET9NOfGDRQCvzvXekYu9fmfLji4ek3ac7KNdnuK/z9gcgs9kpTkTJAzfzxr3rd6gRySsPTvIwgrw7F9kiRyEPQ2gobOiirVMZ6qN0gjrAPXz61sWbZ0hNb88yJ09lyFLTDmpdZIhebwBiMx+ypJd34IuVHA/NkGTlFjNfgBS+rhHe+SAB9nm7LjvtrWOoD0ln7hjzVZ1qR7wMPP7jb6xI0dbDVUpdZRoG1nh53FSU+nykJ0fzqTUmMfdiot6t3WzkFUS0vdXVtfde90OpSuo6Mmxvn8d36W X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 74bf4c27-9576-40bc-3f14-08d8ef06a70e X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2021 20:51:52.6387 (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: CYxGnpaqnEqj4W7bT52wW6qHlvbjqbjuxDtgKP+VaOvIkQ9wJuOwmqCM9FfmlmhzEPep+mKDk650e4jV1YlPL3PkB0Ti5dHNTU0YIFY2rrE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5447 Received-SPF: pass client-ip=40.107.21.92; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, convert driver write handlers parameters which are already 64bit to signed type. While being here, convert also flags parameter to be BdrvRequestFlags. Now let's consider all callers. Simple git grep '\->bdrv_\(aio\|co\)_pwritev\(_part\)\?' shows that's there two callers of driver function: bdrv_driver_pwritev() in block/io.c, passes int64_t, checked by bdrv_check_qiov_request() to be non-negative. qcow2_save_vmstate() does bdrv_check_qiov_request(). Still, the functions may be called directly, not only by drv->... Let's check: git grep '\.bdrv_\(aio\|co\)_pwritev\(_part\)\?\s*=' | \ awk '{print $4}' | sed 's/,//' | sed 's/&//' | sort | uniq | \ while read func; do git grep "$func(" | \ grep -v "$func(BlockDriverState"; done shows several callers: qcow2: qcow2_co_truncate() write at most up to @offset, which is checked in generic qcow2_co_truncate() by bdrv_check_request(). qcow2_co_pwritev_compressed_task() pass the request (or part of the request) that already went through normal write path, so it should be OK qcow: qcow_co_pwritev_compressed() pass int64_t, it's updated by this patch quorum: quorum_co_pwrite_zeroes() pass int64_t and int - OK throttle: throttle_co_pwritev_compressed() pass int64_t, it's updated by this patch vmdk: vmdk_co_pwritev_compressed() pass int64_t, it's updated by this patch Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/block/block_int.h | 16 ++++++++-------- block/backup-top.c | 6 +++--- block/blkdebug.c | 4 ++-- block/blklogwrites.c | 4 ++-- block/blkreplay.c | 2 +- block/blkverify.c | 4 ++-- block/copy-on-read.c | 11 ++++++----- block/crypto.c | 4 ++-- block/file-posix.c | 6 +++--- block/file-win32.c | 4 ++-- block/filter-compress.c | 7 ++++--- block/io.c | 6 ++++-- block/mirror.c | 2 +- block/nbd.c | 5 +++-- block/nfs.c | 6 +++--- block/null.c | 9 +++++---- block/nvme.c | 4 ++-- block/preallocate.c | 6 +++--- block/qcow.c | 10 +++++----- block/qcow2.c | 6 +++--- block/quorum.c | 5 +++-- block/raw-format.c | 10 +++++----- block/rbd.c | 5 +++-- block/throttle.c | 9 +++++---- block/vdi.c | 4 ++-- block/vmdk.c | 8 ++++---- block/vpc.c | 4 ++-- block/vvfat.c | 8 ++++---- tests/unit/test-block-iothread.c | 4 ++-- block/trace-events | 2 +- 30 files changed, 95 insertions(+), 86 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index e6bcf74e46..928369e0bc 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -237,8 +237,8 @@ struct BlockDriver { int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque); BlockAIOCB *(*bdrv_aio_pwritev)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags, - BlockCompletionFunc *cb, void *opaque); + int64_t offset, int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque); BlockAIOCB *(*bdrv_aio_flush)(BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque); BlockAIOCB *(*bdrv_aio_pdiscard)(BlockDriverState *bs, @@ -287,10 +287,11 @@ struct BlockDriver { * The buffer in @qiov may point directly to guest memory. */ int coroutine_fn (*bdrv_co_pwritev)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags); + int64_t offset, int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags); int coroutine_fn (*bdrv_co_pwritev_part)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, size_t qiov_offset, int flags); + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, + BdrvRequestFlags flags); /* * Efficiently zero a region of the disk image. Typically an image format @@ -428,10 +429,9 @@ struct BlockDriver { Error **errp); int coroutine_fn (*bdrv_co_pwritev_compressed)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov); + int64_t offset, int64_t bytes, QEMUIOVector *qiov); int coroutine_fn (*bdrv_co_pwritev_compressed_part)(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, - size_t qiov_offset); + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset); int (*bdrv_snapshot_create)(BlockDriverState *bs, QEMUSnapshotInfo *sn_info); diff --git a/block/backup-top.c b/block/backup-top.c index 9779493a4b..aa27afbb1b 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -97,9 +97,9 @@ static int coroutine_fn backup_top_co_pwrite_zeroes(BlockDriverState *bs, } static coroutine_fn int backup_top_co_pwritev(BlockDriverState *bs, - uint64_t offset, - uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { int ret = backup_top_cbw(bs, offset, bytes, flags); if (ret < 0) { diff --git a/block/blkdebug.c b/block/blkdebug.c index b26fecf222..a7fedd80fd 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -635,8 +635,8 @@ blkdebug_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, } static int coroutine_fn -blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +blkdebug_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { int err; diff --git a/block/blklogwrites.c b/block/blklogwrites.c index de3d4ba2b6..ca174ab135 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -460,8 +460,8 @@ blk_log_writes_co_do_file_pdiscard(BlkLogWritesFileReq *fr) } static int coroutine_fn -blk_log_writes_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +blk_log_writes_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { return blk_log_writes_co_log(bs, offset, bytes, qiov, flags, blk_log_writes_co_do_file_pwritev, 0, false); diff --git a/block/blkreplay.c b/block/blkreplay.c index 13ea2166bb..7ba62dcac1 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -83,7 +83,7 @@ static int coroutine_fn blkreplay_co_preadv(BlockDriverState *bs, } static int coroutine_fn blkreplay_co_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) { uint64_t reqid = blkreplay_next_id(); int ret = bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags); diff --git a/block/blkverify.c b/block/blkverify.c index 5e35744b8a..d1facf5ba9 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -250,8 +250,8 @@ blkverify_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, } static int coroutine_fn -blkverify_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +blkverify_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BlkverifyRequest r; return blkverify_co_prwv(bs, &r, offset, bytes, qiov, qiov, flags, true); diff --git a/block/copy-on-read.c b/block/copy-on-read.c index afb2a77b08..7675565080 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -194,10 +194,11 @@ static int coroutine_fn cor_co_preadv_part(BlockDriverState *bs, static int coroutine_fn cor_co_pwritev_part(BlockDriverState *bs, - uint64_t offset, - uint64_t bytes, + int64_t offset, + int64_t bytes, QEMUIOVector *qiov, - size_t qiov_offset, int flags) + size_t qiov_offset, + BdrvRequestFlags flags) { return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset, flags); @@ -220,8 +221,8 @@ static int coroutine_fn cor_co_pdiscard(BlockDriverState *bs, static int coroutine_fn cor_co_pwritev_compressed(BlockDriverState *bs, - uint64_t offset, - uint64_t bytes, + int64_t offset, + int64_t bytes, QEMUIOVector *qiov) { return bdrv_co_pwritev(bs->file, offset, bytes, qiov, diff --git a/block/crypto.c b/block/crypto.c index a732a36d10..c8ba4681e2 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -460,8 +460,8 @@ block_crypto_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, static coroutine_fn int -block_crypto_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +block_crypto_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BlockCrypto *crypto = bs->opaque; uint64_t cur_bytes; /* number of bytes in current iteration */ diff --git a/block/file-posix.c b/block/file-posix.c index 25da79cdd5..add56cab00 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2040,9 +2040,9 @@ static int coroutine_fn raw_co_preadv(BlockDriverState *bs, int64_t offset, return raw_co_prw(bs, offset, bytes, qiov, QEMU_AIO_READ); } -static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { assert(flags == 0); return raw_co_prw(bs, offset, bytes, qiov, QEMU_AIO_WRITE); diff --git a/block/file-win32.c b/block/file-win32.c index 15076350f2..7c2706c329 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -451,8 +451,8 @@ static BlockAIOCB *raw_aio_preadv(BlockDriverState *bs, } static BlockAIOCB *raw_aio_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { BDRVRawState *s = bs->opaque; diff --git a/block/filter-compress.c b/block/filter-compress.c index 54a16c6c64..505822a44f 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -74,10 +74,11 @@ static int coroutine_fn compress_co_preadv_part(BlockDriverState *bs, static int coroutine_fn compress_co_pwritev_part(BlockDriverState *bs, - uint64_t offset, - uint64_t bytes, + int64_t offset, + int64_t bytes, QEMUIOVector *qiov, - size_t qiov_offset, int flags) + size_t qiov_offset, + BdrvRequestFlags flags) { return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset, flags | BDRV_REQ_WRITE_COMPRESSED); diff --git a/block/io.c b/block/io.c index 59924867c5..55095dd08e 100644 --- a/block/io.c +++ b/block/io.c @@ -1198,7 +1198,8 @@ out: static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, QEMUIOVector *qiov, - size_t qiov_offset, int flags) + size_t qiov_offset, + BdrvRequestFlags flags) { BlockDriver *drv = bs->drv; int64_t sector_num; @@ -2037,7 +2038,8 @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, int64_t bytes, */ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, BdrvTrackedRequest *req, int64_t offset, int64_t bytes, - int64_t align, QEMUIOVector *qiov, size_t qiov_offset, int flags) + int64_t align, QEMUIOVector *qiov, size_t qiov_offset, + BdrvRequestFlags flags) { BlockDriverState *bs = child->bs; BlockDriver *drv = bs->drv; diff --git a/block/mirror.c b/block/mirror.c index 1587cda13c..f7b7f4d566 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1435,7 +1435,7 @@ out: } static int coroutine_fn bdrv_mirror_top_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) { MirrorBDSOpaque *s = bs->opaque; QEMUIOVector bounce_qiov; diff --git a/block/nbd.c b/block/nbd.c index a2b6aa1bca..34cb28927b 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1593,8 +1593,9 @@ static int nbd_client_co_preadv(BlockDriverState *bs, int64_t offset, return ret ? ret : request_ret; } -static int nbd_client_co_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, int flags) +static int nbd_client_co_pwritev(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVNBDState *s = (BDRVNBDState *)bs->opaque; NBDRequest request = { diff --git a/block/nfs.c b/block/nfs.c index eee8f706ba..c6563930cf 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -299,9 +299,9 @@ static int coroutine_fn nfs_co_preadv(BlockDriverState *bs, int64_t offset, return 0; } -static int coroutine_fn nfs_co_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *iov, - int flags) +static int coroutine_fn nfs_co_pwritev(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *iov, + BdrvRequestFlags flags) { NFSClient *client = bs->opaque; NFSRPC task; diff --git a/block/null.c b/block/null.c index 343dbb580d..75f7d0db40 100644 --- a/block/null.c +++ b/block/null.c @@ -130,8 +130,9 @@ static coroutine_fn int null_co_preadv(BlockDriverState *bs, } static coroutine_fn int null_co_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { return null_co_common(bs); } @@ -203,8 +204,8 @@ static BlockAIOCB *null_aio_preadv(BlockDriverState *bs, } static BlockAIOCB *null_aio_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { diff --git a/block/nvme.c b/block/nvme.c index 58342c6409..1a128ef95e 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1229,8 +1229,8 @@ static coroutine_fn int nvme_co_preadv(BlockDriverState *bs, } static coroutine_fn int nvme_co_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { return nvme_co_prw(bs, offset, bytes, qiov, true, flags); } diff --git a/block/preallocate.c b/block/preallocate.c index 5709443612..c19885af17 100644 --- a/block/preallocate.c +++ b/block/preallocate.c @@ -349,11 +349,11 @@ static int coroutine_fn preallocate_co_pwrite_zeroes(BlockDriverState *bs, } static coroutine_fn int preallocate_co_pwritev_part(BlockDriverState *bs, - uint64_t offset, - uint64_t bytes, + int64_t offset, + int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, - int flags) + BdrvRequestFlags flags) { handle_write(bs, offset, bytes, false); diff --git a/block/qcow.c b/block/qcow.c index 1151b8d79b..c39940f33e 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -714,9 +714,9 @@ static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, int64_t offset, return ret; } -static coroutine_fn int qcow_co_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static coroutine_fn int qcow_co_pwritev(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVQcowState *s = bs->opaque; int offset_in_cluster; @@ -1047,8 +1047,8 @@ static int qcow_make_empty(BlockDriverState *bs) /* XXX: put compressed sectors first, then all the cluster aligned tables to avoid losing bytes in alignment */ static coroutine_fn int -qcow_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov) +qcow_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov) { BDRVQcowState *s = bs->opaque; z_stream strm; diff --git a/block/qcow2.c b/block/qcow2.c index 34c5e1c073..1e55ab52b3 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2568,8 +2568,8 @@ static coroutine_fn int qcow2_co_pwritev_task_entry(AioTask *task) } static coroutine_fn int qcow2_co_pwritev_part( - BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, size_t qiov_offset, int flags) + BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) { BDRVQcow2State *s = bs->opaque; int offset_in_cluster; @@ -4568,7 +4568,7 @@ static coroutine_fn int qcow2_co_pwritev_compressed_task_entry(AioTask *task) */ static coroutine_fn int qcow2_co_pwritev_compressed_part(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset) { BDRVQcow2State *s = bs->opaque; diff --git a/block/quorum.c b/block/quorum.c index 1eba2ce7ff..353401ac08 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -714,8 +714,9 @@ static void write_quorum_entry(void *opaque) } } -static int quorum_co_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, int flags) +static int quorum_co_pwritev(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVQuorumState *s = bs->opaque; QuorumAIOCB *acb = quorum_aio_get(bs, qiov, offset, bytes, flags); diff --git a/block/raw-format.c b/block/raw-format.c index e3f459b2cb..b0fe75f54a 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -216,9 +216,9 @@ static int coroutine_fn raw_co_preadv(BlockDriverState *bs, int64_t offset, return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); } -static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, - int flags) +static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) { void *buf = NULL; BlockDriver *drv; @@ -259,7 +259,7 @@ static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset, qiov = &local_qiov; } - ret = raw_adjust_offset(bs, (int64_t *)&offset, bytes, true); + ret = raw_adjust_offset(bs, &offset, bytes, true); if (ret) { goto fail; } @@ -294,7 +294,7 @@ static int coroutine_fn raw_co_pwrite_zeroes(BlockDriverState *bs, { int ret; - ret = raw_adjust_offset(bs, (int64_t *)&offset, bytes, true); + ret = raw_adjust_offset(bs, &offset, bytes, true); if (ret) { return ret; } diff --git a/block/rbd.c b/block/rbd.c index 69299e5f6f..598b801f96 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1003,8 +1003,9 @@ static BlockAIOCB *qemu_rbd_aio_preadv(BlockDriverState *bs, } static BlockAIOCB *qemu_rbd_aio_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { diff --git a/block/throttle.c b/block/throttle.c index 20362b5fe5..1330e844c3 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -124,8 +124,9 @@ static int coroutine_fn throttle_co_preadv(BlockDriverState *bs, } static int coroutine_fn throttle_co_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { ThrottleGroupMember *tgm = bs->opaque; throttle_group_co_io_limits_intercept(tgm, bytes, true); @@ -153,8 +154,8 @@ static int coroutine_fn throttle_co_pdiscard(BlockDriverState *bs, } static int coroutine_fn throttle_co_pwritev_compressed(BlockDriverState *bs, - uint64_t offset, - uint64_t bytes, + int64_t offset, + int64_t bytes, QEMUIOVector *qiov) { return throttle_co_pwritev(bs, offset, bytes, qiov, diff --git a/block/vdi.c b/block/vdi.c index c0e71bfa53..020f7a3cbc 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -600,8 +600,8 @@ vdi_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, } static int coroutine_fn -vdi_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vdi_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVVdiState *s = bs->opaque; QEMUIOVector local_qiov; diff --git a/block/vmdk.c b/block/vmdk.c index 78592160d0..8d49e54bdd 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2068,8 +2068,8 @@ static int vmdk_pwritev(BlockDriverState *bs, uint64_t offset, } static int coroutine_fn -vmdk_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vmdk_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { int ret; BDRVVmdkState *s = bs->opaque; @@ -2080,8 +2080,8 @@ vmdk_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, } static int coroutine_fn -vmdk_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov) +vmdk_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov) { if (bytes == 0) { /* The caller will write bytes 0 to signal EOF. diff --git a/block/vpc.c b/block/vpc.c index 29c8517ff8..1b4c7333af 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -658,8 +658,8 @@ fail: } static int coroutine_fn -vpc_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vpc_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVVPCState *s = bs->opaque; int64_t image_offset; diff --git a/block/vvfat.c b/block/vvfat.c index 8ac90166c5..0b6ed1c6d1 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3061,8 +3061,8 @@ DLOG(checkpoint()); } static int coroutine_fn -vvfat_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +vvfat_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { int ret; BDRVVVFATState *s = bs->opaque; @@ -3099,8 +3099,8 @@ static int coroutine_fn vvfat_co_block_status(BlockDriverState *bs, } static int coroutine_fn -write_target_commit(BlockDriverState *bs, uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +write_target_commit(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { int ret; diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index b3f8f3ff8e..50b8718b2a 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -40,9 +40,9 @@ static int coroutine_fn bdrv_test_co_preadv(BlockDriverState *bs, } static int coroutine_fn bdrv_test_co_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, - int flags) + BdrvRequestFlags flags) { return 0; } diff --git a/block/trace-events b/block/trace-events index 1a12d634e2..3cbea9e2e2 100644 --- a/block/trace-events +++ b/block/trace-events @@ -75,7 +75,7 @@ luring_resubmit_short_read(void *s, void *luringcb, int nread) "LuringState %p l # qcow2.c qcow2_add_task(void *co, void *bs, void *pool, const char *action, int cluster_type, uint64_t host_offset, uint64_t offset, uint64_t bytes, void *qiov, size_t qiov_offset) "co %p bs %p pool %p: %s: cluster_type %d file_cluster_offset %" PRIu64 " offset %" PRIu64 " bytes %" PRIu64 " qiov %p qiov_offset %zu" -qcow2_writev_start_req(void *co, int64_t offset, int bytes) "co %p offset 0x%" PRIx64 " bytes %d" +qcow2_writev_start_req(void *co, int64_t offset, int64_t bytes) "co %p offset 0x%" PRIx64 " bytes %" PRId64 qcow2_writev_done_req(void *co, int ret) "co %p ret %d" qcow2_writev_start_part(void *co) "co %p" qcow2_writev_done_part(void *co, int cur_bytes) "co %p cur_bytes %d" From patchwork Wed Mar 24 20:51:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12162335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7343BC433DB for ; Wed, 24 Mar 2021 20:54:42 +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 114C161A17 for ; Wed, 24 Mar 2021 20:54:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 114C161A17 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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]:42640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPAWW-0000iv-Ts for qemu-devel@archiver.kernel.org; Wed, 24 Mar 2021 16:54:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPAU8-0006hI-4e; Wed, 24 Mar 2021 16:52:12 -0400 Received: from mail-vi1eur05on2092.outbound.protection.outlook.com ([40.107.21.92]:36928 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPAU4-0005MQ-2j; Wed, 24 Mar 2021 16:52:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=crEmVcLk/xnn423uylqTGRvFwUMva2rHz1nUQiQ3MV+1FQKa7t09v8DznvyKdwT2uRpk8XH8/6fudmXh20BuUEXSj6RSuZFDrgOmAqRy0okTiqo8B79I/+TkTZXBaT5jtIxi24mgaVAIN4i1KKi9a+Pq/HwSjsiKItVUi2ZPBk6keTY7VVn10TDHZTUK450a/BpwAtS7wAvhai3ySvHDf0jslrxf6k3+kxuK0521AqNtsrsFytQ3WP5wXVbYdeX2H659EXJOYhSwfXLTnMti1eZAOuQrR0JC1NQtxPODpKMZ33QYJDkhK28lY7OEvWZvUJW/DDuA+4mfCHUBbY621A== 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=tdBzwN23DErr3rhqFhBhFjdkM5PB4KJyxk4JvcqNfRs=; b=XE8GuF+uZEMQRyeGFXbscT9tCfqQJ3h1lE/kfML+iW6KpaXEKsQSnlSzXGZULnwu72/3a9DMradQV7zygBo6axoK3uDXYNGuj4UY9NIXPAmsyynCIs+kQRGaiO17NjqNrrrjhTYvm9iBQW3oul9Q6yLZVigAYiDs4FLljDrNptHGHvUmKNFNXh//fKTc5EShuRnoNWs+Go9d/JQJVuNB6IGtbZka9I2/RfH/04zKWbH/v7XGCafXbJkHsbycET61ronUK26ePiaCfGhcTi86pDcYc8HMwcd4xA8jSMmvJ5BO3HHQ5TE+F/Ceg+/RzMycdDQpXbGplU//VjC9r9uVtw== 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=tdBzwN23DErr3rhqFhBhFjdkM5PB4KJyxk4JvcqNfRs=; b=m47pKamIti9go/dt4+W1x15V4cSl6gZ2CZMrWlTK8ISUtR3s5wi/VuEsZb6BQbNvDWxAzymINTnUej3P9IRRQRD0D+LOdAwRq7f2tQfnaxYVdpzom61toQYjUm87eL+pGBZDgs/aUsH2jz5WIPRnKGN5q4GMLvEQtNWvFGRdYSc= 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.3977.24; Wed, 24 Mar 2021 20:51:54 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a%7]) with mapi id 15.20.3955.027; Wed, 24 Mar 2021 20:51:54 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, namei.unix@gmail.com, dillaman@redhat.com, berto@igalia.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v4 05/11] block: use int64_t instead of uint64_t in copy_range driver handlers Date: Wed, 24 Mar 2021 23:51:26 +0300 Message-Id: <20210324205132.464899-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210324205132.464899-1-vsementsov@virtuozzo.com> References: <20210324205132.464899-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.202] X-ClientProxiedBy: AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.202) by AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.9 via Frontend Transport; Wed, 24 Mar 2021 20:51:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae3fce06-2eba-44ad-ec86-08d8ef06a7e9 X-MS-TrafficTypeDiagnostic: AM7PR08MB5447: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1468; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n9eAvb/ctrjuAA2Yj+t9JX0Vvit+NMzlOEyWxrXv+Uh6iKGvgvu1FKq5uRDLZ0CLzLFP2GNQexeL1SYCZzysKEDnhgdQiHFM+xdLsJDSteJit4FnrI6JUJYGS4KEB3MKYRFHjD3EI97oRTrkDn9gI8Z6mOkUWhVj4QEJ/dmcpUQrDEFUzHVWNPdZfDCAhZLaZNpUIbLgGir268BzxMhM8H7gGkkqKYt3VPgMUS5YercpQ591+NmvtV1xSMOLAGvQNcL+Bcm5SA3RtvgfzTIFoJXp+c1ws+WhKb2ucsZmnF5WI/8vbv0Q7/I3gvXvgpmNRO1GwXbb+mVwwb2tgd+owLMcEcveiM0iWv0kvsPTtB4gZAcN9+IeFrHN8fT1WRKr3loXPsieMs2S7lILWXtnmGmuAS+ALGEgsg7VjK48Ed+cMd5cKHdKQWICzQFr1mU91PD6RlAjOuhLq+Lh8QWfjED4NsoWtQUHEPgvlSfi2memrgEvF/Sw7xXNFwiVGxAXr+Ww2QpaAyzFZnvWaQno9fygIZJomYtEGLR1X8IOUscdpbdXbhfzTWJbbynP1GxdTF7QoZ1Pv0Q5kPSaBdar6yMVNXYDzP7HG6YS7DdfRiq6GQzkH69XSeT2YVJUKi16l5Ef8YUNvN1jO2rQFUbRrilBKMAOKSAqMMwvNfFJddkaxWbiXlJ3JohlydCEM/nd X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(346002)(136003)(376002)(396003)(366004)(2616005)(6916009)(478600001)(8936002)(66946007)(38100700001)(956004)(66556008)(6512007)(66476007)(6506007)(6486002)(52116002)(186003)(5660300002)(26005)(69590400012)(83380400001)(7416002)(6666004)(86362001)(2906002)(16526019)(316002)(1076003)(36756003)(4326008)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: tub1AaATRqBxn0HE4cfqsqCEbR8LWIFa4jnWlfmBBUC+1giwp812K7clCz4nkN3PKYk+AXhOG0tCDyun7ryFs5Gv+XE4S1lLV+cOcusl/+NqqJSluMC6MR8JSeb3xk4N5a8LKncSKN8ZlLMWvlisuuczhShsU1rwQQN0k0C2sJI/nXdH+YwQqJkOtyqFyqvHqSTqRm1gP0t4SvUwyLvmueK+7SIufPlkZCEaSEDr7OKkosnrep7uuuHGgbguXU1bOoI7puOI2S5qmROqgimviCh5GDEoLne6EOdBdM2gnCtyI776htY/60gFPSNTmJgjZSdWNTj2zdAkpvntKrHueEigG4WqDliln0634NA9Uq9Ul10mZ3u6IiE2K/pDJ6Al5m1zqIwzgh1JSL+mh4oZrLlKzkZjLHMtyefG3OZHcZXN2z8H2mVCCki4O4xda9ubykPlIKaWdUi+EjA32hjoUMUFr1tkWzQIuLC/WHftEXKZByGHAKW86+EY9Eguw2Uqkthw+2E1t4uknqGcLA1XjvyW7JEvM2K7EyhIRXxcrenMzAAEoQHQ8ocuAI71jLqJgi0NVQkHDS0iZSHH+oBuefAx+Mwr3imJni+UIbZVL+Q9zqrVuQVKrWxADA2RVXflMMHYQXQj+UWT+GmF6FQsdJczggYN/jb/8YJbX8oYPoYm1hXB/LwjBzqofiXXlGM7hiDQR0XUOuedEVljIV7JvgvzsciA5TSLsR0kD2pLYHU0hPW3ooR34OUn7e10W8MIjiEwvbT40AvWm/Ywtp3AIVEDl2UKqPGcxJTse5We/sRrwl3R/6LU5+LYk0zDzkYgl+iGNOaNa8qxvZMJ+nc7nL0T8AbtRU1+LIDiPpFcx8lyNbtB95mpqSNIZRuUnvAIhh+yBV9BehFU26dho0vHfMalX7TTuzIlsXUbffeIPPnDRjNIkTorfVuLQ7g1QFDwsBeWaaxWueMr8VuW27pyDh+axON/ULLn/Ekes2c8w+V0I22w6MOE+U7KmZWJ08n4ToaqETrDkDBU0A68o3s0H8y2VJASYe6WA05FKwKPpIPWnO+YjA8q42pkqLQ0+UteYLFTH6wOMuXfqZCa2Amf9U7bq8UsNLEy4dTNFdJVFVU1dA+GggAfz8zI1OesS0Pz2VIBwTkHMu/Qk3bUyfWYCh3Y9h8SrrQVaGGirLGOkKI4Br8wTBdOQJ5oonotjv0olSyIJnkOE3OpzsNXxI1psz6MkQG3cwCfcCFJy/Ll6jc08XpWzLWoCMGy8IRivLzsU/xxvuXV3jmL4o/kx9rA19Za99bInWhi4vohTjEse/ht7l4GR68Y11lQvrHzdB2b X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae3fce06-2eba-44ad-ec86-08d8ef06a7e9 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2021 20:51:54.0217 (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: N29Q+5N6J4tT95Nt6TiU0HBHrHAN3kX6IZMxUKPo2DFQSumL/dUVSjvKKya6HnMdJXizNrJiL8UNDoVgDd4bWcE68E3z/QAY0M1VOi2menc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5447 Received-SPF: pass client-ip=40.107.21.92; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, convert driver copy_range handlers parameters which are already 64bit to signed type. Now let's consider all callers. Simple git grep '\->bdrv_co_copy_range' shows the only caller: bdrv_co_copy_range_internal(), which doesn bdrv_check_request32(), so everything is OK. Still, the functions may be called directly, not only by drv->... Let's check: git grep '\.bdrv_co_copy_range_\(from\|to\)\s*=' | \ awk '{print $4}' | sed 's/,//' | sed 's/&//' | sort | uniq | \ while read func; do git grep "$func(" | \ grep -v "$func(BlockDriverState"; done shows no more callers. So, we are done. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/block/block_int.h | 12 ++++++------ block/file-posix.c | 10 +++++----- block/iscsi.c | 12 ++++++------ block/qcow2.c | 12 ++++++------ block/raw-format.c | 16 ++++++++-------- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 928369e0bc..88b19db756 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -313,10 +313,10 @@ struct BlockDriver { */ int coroutine_fn (*bdrv_co_copy_range_from)(BlockDriverState *bs, BdrvChild *src, - uint64_t offset, + int64_t offset, BdrvChild *dst, - uint64_t dst_offset, - uint64_t bytes, + int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags); @@ -330,10 +330,10 @@ struct BlockDriver { */ int coroutine_fn (*bdrv_co_copy_range_to)(BlockDriverState *bs, BdrvChild *src, - uint64_t src_offset, + int64_t src_offset, BdrvChild *dst, - uint64_t dst_offset, - uint64_t bytes, + int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags); diff --git a/block/file-posix.c b/block/file-posix.c index add56cab00..6faf7eb96e 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -3167,8 +3167,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, @@ -3177,10 +3177,10 @@ static int coroutine_fn raw_co_copy_range_from( static int coroutine_fn raw_co_copy_range_to(BlockDriverState *bs, BdrvChild *src, - uint64_t src_offset, + int64_t src_offset, BdrvChild *dst, - uint64_t dst_offset, - uint64_t bytes, + int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { diff --git a/block/iscsi.c b/block/iscsi.c index 4d2a416ce7..6bcde6ec6b 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -2172,10 +2172,10 @@ static void coroutine_fn iscsi_co_invalidate_cache(BlockDriverState *bs, static int coroutine_fn iscsi_co_copy_range_from(BlockDriverState *bs, BdrvChild *src, - uint64_t src_offset, + int64_t src_offset, BdrvChild *dst, - uint64_t dst_offset, - uint64_t bytes, + int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { @@ -2313,10 +2313,10 @@ static void iscsi_xcopy_data(struct iscsi_data *data, static int coroutine_fn iscsi_co_copy_range_to(BlockDriverState *bs, BdrvChild *src, - uint64_t src_offset, + int64_t src_offset, BdrvChild *dst, - uint64_t dst_offset, - uint64_t bytes, + int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { diff --git a/block/qcow2.c b/block/qcow2.c index 1e55ab52b3..c786601d52 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3975,9 +3975,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; @@ -4058,9 +4058,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 b0fe75f54a..051b00a4d4 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -532,16 +532,16 @@ static int raw_probe_geometry(BlockDriverState *bs, HDGeometry *geo) static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs, BdrvChild *src, - uint64_t src_offset, + int64_t src_offset, BdrvChild *dst, - uint64_t dst_offset, - uint64_t bytes, + int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { int ret; - ret = raw_adjust_offset(bs, (int64_t *)&src_offset, bytes, false); + ret = raw_adjust_offset(bs, &src_offset, bytes, false); if (ret) { return ret; } @@ -551,16 +551,16 @@ static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs, static int coroutine_fn raw_co_copy_range_to(BlockDriverState *bs, BdrvChild *src, - uint64_t src_offset, + int64_t src_offset, BdrvChild *dst, - uint64_t dst_offset, - uint64_t bytes, + int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { int ret; - ret = raw_adjust_offset(bs, (int64_t *)&dst_offset, bytes, true); + ret = raw_adjust_offset(bs, &dst_offset, bytes, true); if (ret) { return ret; } From patchwork Wed Mar 24 20:51:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12162373 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC1DDC433DB for ; Wed, 24 Mar 2021 21:03:04 +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 38D4761A1B for ; Wed, 24 Mar 2021 21:03:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38D4761A1B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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]:34594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPAed-0000v7-5F for qemu-devel@archiver.kernel.org; Wed, 24 Mar 2021 17:03:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPAU7-0006fa-A7; Wed, 24 Mar 2021 16:52:11 -0400 Received: from mail-vi1eur05on2116.outbound.protection.outlook.com ([40.107.21.116]:40416 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPAU4-0005Ie-Hc; Wed, 24 Mar 2021 16:52:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aB2Rwi0potVWuk/Un9yPlefaiTKI55T2puym0oQ9zPFjRpHkSe0sDP/98PGWvnvntCeP5ZvxI7Zeb1KT+UUeIMZa9H+m6XizCsX3tmjoLpbjsm7MT3wnJqy4ItErcwsrrsf0G/AtojHvvwuSwlXT/HANEW2sZUYDXQc3bT3Yid+hbtQhbg3VYwCHTbM2WhzZFgALWEZ8oV48zEWErCMxaCiLRVTRLdBslGsYKjzmEW7iM0bZXVLYMoJ3Rugb24zbOnl6mjTHRP37oFD/3pFdXg5zREqKbba30b6B7ub+fpc05HjdYVKee9L0lQcPO9su0WBwMCQ/ICz2ajI9jvVvcg== 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=ajHSNZBLXJdejHFx3sNu2R9jm4Sw5Pru+WDibOJOH8A=; b=blYJNrt8z7qB7MdxTLIVrN5kqViD76eKngvs2M8iKUtCg5L1QUPzYH3AFg8j4y23x3Xlo3QATIwktdlViSEXZKvWTaDRpoKKOtbk0UyYNL1x6TVrmC6JjAWrTtq5EdjR97f7MJRANTpOZCUWr1fCN6eGRQCOb7KH8rjCjiXeXK/x57YAXj0BGyHfbB47QN/8haUNftiym0LL3sCp4Qmrj7Vqkm1AtiNebuEzgQHyLYMHOtiZ+AVl9LvhMdqT5CQvielXtcYu28pNPM7tcWmvUiBpXwV180FH3REITkM12U4YkVjcuFInRxQFmnUyBaF6VfIvnALaHn8nhpwkBNb5Xw== 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=ajHSNZBLXJdejHFx3sNu2R9jm4Sw5Pru+WDibOJOH8A=; b=vN3FAf5pA/kLqg+qvzH2DhTgieKCkS7DIVldsvvsQubCjBsa7XsdawurndUFw2EMm+PrwT1ZISp3VdWX3AL2BxUtVo/yUrMNKv0qm9P1RiNhlWnLNRBZgIShkrPEv0f4ETw+yyTTEEhJVN+D3jaUcz3T0iO2X9Srb2tjoYdSHMY= 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.3977.24; Wed, 24 Mar 2021 20:51:55 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a%7]) with mapi id 15.20.3955.027; Wed, 24 Mar 2021 20:51:55 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, namei.unix@gmail.com, dillaman@redhat.com, berto@igalia.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v4 06/11] block: make BlockLimits::max_pwrite_zeroes 64bit Date: Wed, 24 Mar 2021 23:51:27 +0300 Message-Id: <20210324205132.464899-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210324205132.464899-1-vsementsov@virtuozzo.com> References: <20210324205132.464899-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.202] X-ClientProxiedBy: AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.202) by AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.9 via Frontend Transport; Wed, 24 Mar 2021 20:51:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3f0ead44-08f1-4d30-5597-08d8ef06a8bc X-MS-TrafficTypeDiagnostic: AM7PR08MB5447: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xEl9zlsi6V6ar4bWU8+fFWezvQZOWXq7bIZ8iWWTTccmH4j2Xw/g63iNqiBg0VbXg4+jF63R7UcID898HE1ScUjrCeRckGFh7/Q467V/i1AlrVzjMtiO11ImKLQOAD0y2TbWnh02iZSKZJmVFeIM5uvB5ZAC8DLSWOwbqc4QjmGnSOFpj4SsEdIz848BmBk16taMe/uzahQFQdjo51p7+EH8xC5WtIGLuoFPDdNVwEqSzVj3t1HjTzsrs6ulaWPMHBeHPnksY1beh0Nt1TmTprdVZnF6PnCW+1pt6DZ/6RoKttr7mzzJqEEK/HWcvi4v/hgqfCt4A+lkmgiw1k+oJs/4blFSlSd+AL5Kv/r1Vq9JAFhCRTHXgSfhxDhOj5nRb5jJdawvH3QGlHKqyo5BkH5e7knW5l5L1LsXjPqgC1gwEAEiyeDlIE+4e90ZYfXKJ4KOBIdRq+TLqOf8wuiwTQTUyOoOm3K1S1qVCf5QOqKB2heZ7xA2xyDFxqrnBy/zFomG7g1nyqnlVL80OdFKmSUndIN83h4SchG6p8K6xTZy9Us4yXVkNltJuwP4B9eyCa24woq21JlnrqW3Y9LZclRGo1+sfAvAGiRyp6e5E9Kjn9qQi2oKL8X3smYQv7VFqf16lw2QCybn/WUMeSCS8kBa/BLpfs7oC3L+g6vCig+RJFU8SRj43Wnpae4Td7N2 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(346002)(136003)(376002)(396003)(366004)(2616005)(6916009)(478600001)(8936002)(66946007)(38100700001)(956004)(66556008)(6512007)(66476007)(6506007)(6486002)(52116002)(186003)(5660300002)(26005)(69590400012)(83380400001)(7416002)(6666004)(86362001)(2906002)(16526019)(316002)(1076003)(36756003)(4326008)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: kVXU10pSsOsMYTmHi3ZcP7R5zv2SYl9kDva27xYPAu8L1j5GsP8jb+72bTYTL4uheXa9PW2s2wWfj9ch6O1gJwA5q8bBnOORKsmrgqsAvFplQOP0loDUszanth2aY19QXAzW2sFYv9ZaP0u/1EayJ5LHkfEA4+wScrrwSOjuulinsABadRSQvWbaGxX4fc2F1PUuXrkg5+QUGA1IlTu6izFhEswixWZNX+WnR5lCLrAtP5KfDEHRIBB4Zbqb28pDX6GrjuNsbuRSJserKpiNlr82XXtho9ptZb+HGLd+/14S8sutVx5bmnmLUBIgbr5R3oWStA3vMlbYvbA+on+Nm+mBrdyHgzDzaLVuqJCd2em0CCoKptlITurB+2cHWtWaqboWM9n0dnh0j+9vMrT7PpJF7F6OkV0ETRO2O6KjGFSiHszt65z1IPjT7nIdzPMyJi+W7LDv3L7W4Lw6zTZMYi8+I6ovtfzWY7l/bDSIdnGNnif0/dckIxviKuJjzyQrDGocHfq0pq1omogegWeRM/EGe4GDK6ugwMRTr0X4aLVJX9S3Z0n4slIeCnwqvGRNIeiP68GABM83lq3g4t1Wo9aplZgF4Oblq9su3noTHCSa/oi+tgwMOgeuAvVf3EfnCeOsXxUhVTOezl6pOwSAgOFh8AO3PU366zxevSE8F9WUlP7hRLC8n+u+nTdwCjCJz/atOoixpJQlGL9e7MOGjnr2f7U6wTnaULy+p29fiJTQeQv2S1i62R6ihAxwbS2tlyNkGpyrejzGDebf90Lkyk8kd1NM/XnbK6GYNgtQrc3Bs4FmGDr48dCzYfMD9WOa7IBGH3f6tIrRO5e2zhDRgU3oTYukBWdApji9f3QpC5wDdrZNbhKz/ZhVCRrL4lgBYn4HHq1ci8mDYaX5FJVXCaocJTpkyvYqXv1A8zwvnGAj0qxlj/i5eSSPQN8+5PYY5hHHB/D09w9CC9v1dksN2b9LNNMjn1A3TxsXnk8Hh69Q7zvDVjQIFjmGc/HNbxkdps0iq64wgiParTjjH/k9QHOLK8coRe5Fr/Cii1xT3VELLEB387xW7F9JyV41Odqlyi2hdlYxjDg90kdZJdIgij2MF21PDaiRK83aeOEYROV0dILd0DHSOiB9EhDxI+kwuNsOGdKU76da7zNtwURyHBptXEvezXfp/wYJC9/45FrEgnSgNBgwczpHiQjXaVQRe+tGTD1Afec7AJsrR4YAdJaSx5WeUD6TCl8RijOX3I5nzBwVuPMKGkumyYw27dkWlOZCtCMa6jD2vXeVg2AJebo6TIBp74obZ4MSLYxBmoFoN0ByT+FV7oWa0n1SHKyn X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f0ead44-08f1-4d30-5597-08d8ef06a8bc X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2021 20:51:55.4016 (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: Q18XFVmhcbpYNCdumYQUNNVu6aymNgCL2owPaX5oFMLYGLZijdDeAifN2adplcDOsnoGi2KI7b0MYejfS4AlmGgU6h/OmeZVZZyO8nrBGoU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5447 Received-SPF: pass client-ip=40.107.21.116; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are going to support 64 bit write-zeroes requests. Now update the limit variable. It's absolutely safe. The variable is set in some drivers, and used in bdrv_co_do_pwrite_zeroes(). Update also max_write_zeroes variable in bdrv_co_do_pwrite_zeroes(), so that bdrv_co_do_pwrite_zeroes() is now prepared to 64bit requests. The remaining logic including num, offset and bytes variables is already supporting 64bit requests. So the only thing that prevents 64 bit requests is limiting max_write_zeroes variable to INT_MAX in bdrv_co_do_pwrite_zeroes(). We'll drop this limitation after updating all block drivers. Ah, we also have bdrv_check_request32() in bdrv_co_pwritev_part(). It will be modified to do bdrv_check_request() for write-zeroes path. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 7 +++---- block/io.c | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 88b19db756..71e5025534 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -676,10 +676,9 @@ typedef struct BlockLimits { * that is set. May be 0 if bl.request_alignment is good enough */ uint32_t pdiscard_alignment; - /* Maximum number of bytes that can zeroized at once (since it is - * signed, it must be < 2G, if set). Must be multiple of - * pwrite_zeroes_alignment. May be 0 if no inherent 32-bit limit */ - int32_t max_pwrite_zeroes; + /* Maximum number of bytes that can zeroized at once. Must be multiple of + * pwrite_zeroes_alignment. May be 0 if no inherent 64-bit limit */ + int64_t max_pwrite_zeroes; /* Optimal alignment for write zeroes requests in bytes. A power * of 2 is best but not mandatory. Must be a multiple of diff --git a/block/io.c b/block/io.c index 55095dd08e..79e600af27 100644 --- a/block/io.c +++ b/block/io.c @@ -1836,7 +1836,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, int head = 0; int tail = 0; - int max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX); + int64_t max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX); int alignment = MAX(bs->bl.pwrite_zeroes_alignment, bs->bl.request_alignment); int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFFER); From patchwork Wed Mar 24 20:51:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12162337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4BC3C433DB for ; Wed, 24 Mar 2021 20:55:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F1CB61A17 for ; Wed, 24 Mar 2021 20:55:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F1CB61A17 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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]:44548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPAXY-0001Vm-FQ for qemu-devel@archiver.kernel.org; Wed, 24 Mar 2021 16:55:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPAU1-0006RV-3V; Wed, 24 Mar 2021 16:52:05 -0400 Received: from mail-eopbgr140109.outbound.protection.outlook.com ([40.107.14.109]:48878 helo=EUR01-VE1-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 1lPATx-0005Mt-H9; Wed, 24 Mar 2021 16:52:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YKB9aIG7QSPtaCxydIkf4qgn4lsBBFZL2NfBhBV+zULFHeiL70xUpNdOytlVXXPjDt+6JVwb50E3mFZZGS4nlHzFpb7MEaep4aK46W65GOdint42bV3HNBTVeOoob6K+tH17Lr9JsXAIb+RWPOQI9sRj6LjnverLmcc0eertNGSQdmfdtdlZoQMnHKj9LibZDFjTLX6C/j08xbnOd8/ZN+G8K0ZTVvgL0/hIamgh3cVrRIp8B2yHYG7HsAxLpZM2T1qb6Uys4pERCQlaEcnxpVvlgEpwr7vTGIgbC26WmfvIocrGYdqN42bmmBdQqe9zVpNxNO1BMhbASlCry0as0Q== 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=xIGTFJeqdu2j+631u69SnZRDnts0JNmrwz53r3tF0aM=; b=U6Yshsv0cGdZFxJ0SYP8tcP8fkTJcpKWFxiNXq+SWlx0sGHs8h5NgcYD1T8tmg8YgnFAJwWHR8WaqKzxu3ZdAduwr2GmwohMGKSD02jxPE3+OWrxYjkj7dZUCtHkBWMLg6In8MROKbf2u7CnQM1i9RlfzgesEm9YCU8HQeKE9eNcS0GSByM0Mj7NVFGnIxzZKFD8rxjuGho0sm2hrGFbfBp6mXfFmgIyu6fmxoUbqUJrFK9VVMoIebC+TueDoWKurZXJpEcVLOj4z3XoM8cOhszDPVXgjSSZkAqJdPjM2GNYi90N/qnAa6lFGTgvW0PWwc7KvWZY/rXTLwdckIbU4A== 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=xIGTFJeqdu2j+631u69SnZRDnts0JNmrwz53r3tF0aM=; b=TgPB6N3dEPjCeb3yPL9lzsYrI8omoRS/6ecC8xs04jOqlntGb67KyjENoDXIMWMEcTmQhkhhKBjrQf6H7X41ezS5H1wXGNR4dZNhdtSw74m3y3t7VDTmEcOhbljfcygnMUQEHMsBgG50VCYuGBvBlmjEARtQYL+8iv9RQ4M6u58= 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 AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24; Wed, 24 Mar 2021 20:51:57 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a%7]) with mapi id 15.20.3955.027; Wed, 24 Mar 2021 20:51:56 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, namei.unix@gmail.com, dillaman@redhat.com, berto@igalia.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v4 07/11] block: use int64_t instead of int in driver write_zeroes handlers Date: Wed, 24 Mar 2021 23:51:28 +0300 Message-Id: <20210324205132.464899-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210324205132.464899-1-vsementsov@virtuozzo.com> References: <20210324205132.464899-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.202] X-ClientProxiedBy: AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.202) by AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.9 via Frontend Transport; Wed, 24 Mar 2021 20:51:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4315ebb9-af66-4369-163a-08d8ef06a992 X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7RtppqAvIJveVJDKNagB8pnsVkm1e2PaKAhlK+0qjh5wcaFgeWTngC5Fo4Iew9McyiPZ06qFlGhsNA4XhBCkeXqqWHicS3cRQ0ljDvfUVv36zgfkBhcCRYhjN5f1PM9CO5o8kdJ/RcO/DU0u1VOCjjTGY3a/oZDU9FvqYimF7G0Q/sDxExoSHILKNninP+96jO1mfpKpEOgxk9IgO1gQlv9RAUZ+4b30bJf7gWwraas8bTJeyGAJnMu23oimHLEFhs+fbJhAPbiFPVMPpdrQqMjf7tCJgoTPzmXf86F2eKuN41QZwyI1iLygI/GAdOqUhxT2XEs07FVSNldnCvF5jnTBZVzaSKcPyAeiKFrqYJ2tDG0NQsFQR3y78Hzv+bvb2nOGYOOk3+e/r2OBRZGiMAr1aC+mur02iKvEUXRZu2QlqXnyS8W8mOeDH/+V9OZZFqAwBVMBuHjPHBppwXfOg4kVs80rR3HgkjAIEDEYmiTVTlY6RwbIlhUK/bqQkBbnmDP5nR5SMOEbUgF7lV4MAg/HDsGNqdhRS1/8ScaNJ3rcKcs8vr1opIQs3ZFmXwIqS0NMk9wSzbtEa0lq+lPW7NVJ59SlyfA2WmwnT22eRPyrWeNoxwsgtPwN2eMKGgVTagOEWSSDnWYu+JDnUvc9oxZ4nEKFAiVNLD2afWIleV5m17Szt07QpjdbeA0uNXnL X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(346002)(396003)(136003)(39840400004)(38100700001)(16526019)(478600001)(6916009)(8936002)(8676002)(186003)(26005)(52116002)(316002)(36756003)(2616005)(6506007)(30864003)(4326008)(5660300002)(956004)(69590400012)(6486002)(1076003)(6666004)(2906002)(66946007)(6512007)(86362001)(83380400001)(7416002)(66556008)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: MbEyh7B7xl/OAT9rFQ6vvdL4NS8p4GmgVnLEJ+czaiVC1P83k1Y1Zqb5fE/qlL+SVlJu2U8zR8uMgXp/BvuFC4rDtFWLSmKAqDPD7ws/CAMlyHFM4nXWjmQJvxG7rg7mnWfnDODLZ8cXqoa/YAjKDUUJ0hWjYwMp0dleK7OH6jQmNu47a+AAbNv5l16jL7fr28Jq3oin+QNvqwAmfq8vbns6TbDO03WVjnQnmwB9lIWahXi/EBdDced6ezZsTz490X+f9dL6XzwVPWC/3YtXEIAMM/3CPoIEkJRZStG3OsoFqClMLYz3BC/oPCNa8f62pvq71mKcdplFQtZ31gpv+qqpjMo5jf8vGtKWZAkLYoq7CwfbM5DhIHlJarc3xFPfo3RdavrGdtMRBIh/8rrFHJsvRWusekqqkiWsi3FXfLP96z0d9FPrVqkmwonQS3hMYIS/lGfL2MBUYqGOwngdwPb/5CCMQg5k9xASEQx/z+LddbJZ06QBObWBakon0Ib44zqaUcZPG1YxvNwexAMn2yhmtTBQn3VJPJf//tDQ6MbLPO5aNKzTUK/PR5NF8viwTe+T0wniqg8KY/E3E4W11Jkt7nTL6Rp56f5pU5NiVp5/DMrCAsEJQ1ApwXL4DrornkrR/lA9fGDrYUWGQB+BoH5doC75yMoDSDic94bdvNgoxYZnFcPlpkk2guNPglTF9VOw50H4KiMRhO2fdhaP5oMPI0+rALjJJ7hQDRdP7zB4NmzSNYFOETohY4nho7sGq0eTWX5BJwNfkE4d3RzRkcCSWuRfbkUA3i6IoLFGBOQhuYqLrr0i692umlXwU6O8Sdm+um1IQDaf0Qi4YL5yHm2jqTebxrTG8tb8slY+39w10OjbwEF5Lw3mWbMZ58+0stvVLhm4tmW7im0aIpgM3CHdeOeDmRy+TcgGotF1Ht4CWhEldF5crs9yy51/tyeI4ux8DG6aBiDOdQOsVBoa3auw5TSSrw/svu6qvb5KSko4xn2heTNwIuQVpX4Lp19kW+M7cSRPvZfCpXfWQVRXf2RRCszJyV5gX1BFcMCsPsEHN0ju/khHxbCp+EH59NmVx76++CiYW3Of7vRi8NPlqfFyMMvz49spLYHNArwpCcG0hNtGhvA8Kcnco84/PQuXJo6K5f18nUp1f/OoIfsMNlZkxZ3o8etCXlXs0XFwngy/t+VPV6ydsFklCy8UulQDZ+FYJUYr73DYtfYhDWybNzsBKPuZGYf71hahhRVKTthMCGkj80SMjl2MfysUlGnVgq80Q4lMtdxH1UsouOb1cg0mpkQX33Cb62jydxRWTCQf2IE/YKZMMKw0SN/ANlTa X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4315ebb9-af66-4369-163a-08d8ef06a992 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2021 20:51:56.8044 (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: eR+A/BMlTqCL/VYaj5JG2PLirSG2MuP1Qc6lFirz9q4wq8jGqprC+jBze8aMfZ3w9QDtsbnHnsrsPA+GF96vACl+LjOiYAbBphX52Fsaouw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.14.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, convert driver write_zeroes handlers bytes parameter to int64_t. The only caller of all updated function is bdrv_co_do_pwrite_zeroes(). bdrv_co_do_pwrite_zeroes() itself is of course OK with widening of callee parameter type. Also, bdrv_co_do_pwrite_zeroes()'s max_write_zeroes is limited to INT_MAX. So, updated functions all are safe, the will not get "bytes" larger than before. Still, let's look through all updated functions, and add assertions to the ones which are actually unprepared to values larger than INT_MAX. For these drivers also set explicit max_pwrite_zeroes limit. Let's go: backup-top: Calls backup_top_cbw() and bdrv_co_pwrite_zeroes, both have 64bit argument. blkdebug: calculations can't overflow, thanks to bdrv_check_qiov_request() in generic layer. rule_check() and bdrv_co_pwrite_zeroes() both have 64bit argument. blklogwrites: pass to blk_log_writes_co_log() with 64bit argument. blkreply, copy-on-read, filter-compress: pass to bdrv_co_pwrite_zeroes() which is OK file-posix: both handler calls raw_do_pwrite_zeroes, which is updated. In raw_do_pwrite_zeroes() calculations are OK due to bdrv_check_qiov_request(), bytes go to RawPosixAIOData::aio_nbytes which is uint64_t. gluster: bytes go to GlusterAIOCB::size which is int64_t and to glfs_zerofill_async works with off_t. iscsi: Aha, here we deal with iscsi_writesame16_task() that has uint32_t num_blocks argument and iscsi_writesame16_task() has uint16_t argument. Make comments, add assertions and clarify max_pwrite_zeroes calculation. iscsi_allocmap_() functions already has int64_t argument is_byte_request_lun_aligned is simple to update, do it. mirror_top: pass to bdrv_mirror_top_do_write which has uint16_t argument nbd: Aha, here we have protocol limitation, and NBDRequest::len is uint32_t. max_pwrite_zeroes is cleanly set to 32bit value, so we are OK for now. nvme: Again, protocol limitation. And no inherent limit for write-zeroes at all. But from code that calculates cdw12 it's obvious that we do have limit and alignment. Let's clarify it. Also, obviously the code is not prepared to bytes=0. Let's handle this case too. trace events already 64bit qcow2: offset + bytes and alignment still works good (thanks to bdrv_check_qiov_request()), so tail calculation is OK qcow2_subcluster_zeroize() has 64bit argument, should be OK trace events updated qed: qed_co_request wants int nb_sectors. Also in code we have size_t used for request length which may be 32bit.. So, let's just keep INT_MAX as a limit (aligning it down to pwrite_zeroes_alignment) and don't care. raw-format: Is OK. raw_adjust_offset and bdrv_co_pwrite_zeroes are both 64bit. throttle: Both throttle_group_co_io_limits_intercept() and bdrv_co_pwrite_zeroes() are 64bit. vmdk: pass to vmdk_pwritev which is 64bit quorum: pass to quorum_co_pwritev() which is 64bit preallocated: pass to handle_write() and bdrv_co_pwrite_zeroes(), both 64bit. Hooray! At this point all block drivers are prepared to 64bit write-zero requests or has explicitly set max_pwrite_zeroes. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 2 +- block/backup-top.c | 2 +- block/blkdebug.c | 2 +- block/blklogwrites.c | 4 ++-- block/blkreplay.c | 2 +- block/copy-on-read.c | 2 +- block/file-posix.c | 6 +++--- block/filter-compress.c | 2 +- block/gluster.c | 6 +++--- block/iscsi.c | 31 +++++++++++++++++++++---------- block/mirror.c | 2 +- block/nbd.c | 6 ++++-- block/nvme.c | 24 +++++++++++++++++++++--- block/preallocate.c | 2 +- block/qcow2.c | 2 +- block/qed.c | 9 ++++++++- block/quorum.c | 2 +- block/raw-format.c | 2 +- block/throttle.c | 2 +- block/vmdk.c | 2 +- block/trace-events | 4 ++-- 21 files changed, 77 insertions(+), 39 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 71e5025534..d9e1f04b21 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -300,7 +300,7 @@ struct BlockDriver { * will be called instead. */ int coroutine_fn (*bdrv_co_pwrite_zeroes)(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags); + int64_t offset, int64_t bytes, BdrvRequestFlags flags); int coroutine_fn (*bdrv_co_pdiscard)(BlockDriverState *bs, int64_t offset, int bytes); diff --git a/block/backup-top.c b/block/backup-top.c index aa27afbb1b..838027981b 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -86,7 +86,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 a7fedd80fd..c81cb9cb1a 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -667,7 +667,7 @@ static int blkdebug_co_flush(BlockDriverState *bs) } static int coroutine_fn blkdebug_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { uint32_t align = MAX(bs->bl.request_alignment, diff --git a/block/blklogwrites.c b/block/blklogwrites.c index ca174ab135..d7ae64c22d 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -468,8 +468,8 @@ blk_log_writes_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, } static int coroutine_fn -blk_log_writes_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bytes, - BdrvRequestFlags flags) +blk_log_writes_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, + int64_t bytes, BdrvRequestFlags flags) { return blk_log_writes_co_log(bs, offset, bytes, NULL, flags, blk_log_writes_co_do_file_pwrite_zeroes, 0, diff --git a/block/blkreplay.c b/block/blkreplay.c index 7ba62dcac1..89d74a3cca 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -94,7 +94,7 @@ static int coroutine_fn blkreplay_co_pwritev(BlockDriverState *bs, } static int coroutine_fn blkreplay_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { uint64_t reqid = blkreplay_next_id(); int ret = bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 7675565080..758a5d44d5 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -206,7 +206,7 @@ static int coroutine_fn cor_co_pwritev_part(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 6faf7eb96e..03618cc18b 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2929,7 +2929,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; @@ -2997,7 +2997,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); } @@ -3577,7 +3577,7 @@ hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) } static coroutine_fn int hdev_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { int rc; diff --git a/block/filter-compress.c b/block/filter-compress.c index 505822a44f..fb85686b69 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -86,7 +86,7 @@ static int coroutine_fn compress_co_pwritev_part(BlockDriverState *bs, static int coroutine_fn compress_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); diff --git a/block/gluster.c b/block/gluster.c index e8ee14c8e9..6a17b37c0c 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -1003,19 +1003,19 @@ static void qemu_gluster_reopen_abort(BDRVReopenState *state) #ifdef CONFIG_GLUSTERFS_ZEROFILL static coroutine_fn int qemu_gluster_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int size, + int64_t bytes, BdrvRequestFlags flags) { int ret; GlusterAIOCB acb; BDRVGlusterState *s = bs->opaque; - acb.size = size; + acb.size = bytes; acb.ret = 0; acb.coroutine = qemu_coroutine_self(); acb.aio_context = bdrv_get_aio_context(bs); - ret = glfs_zerofill_async(s->fd, offset, size, gluster_finish_aiocb, &acb); + ret = glfs_zerofill_async(s->fd, offset, bytes, gluster_finish_aiocb, &acb); if (ret < 0) { return -errno; } diff --git a/block/iscsi.c b/block/iscsi.c index 6bcde6ec6b..b90ed67377 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -427,14 +427,14 @@ static int64_t sector_qemu2lun(int64_t sector, IscsiLun *iscsilun) return sector * BDRV_SECTOR_SIZE / iscsilun->block_size; } -static bool is_byte_request_lun_aligned(int64_t offset, int count, +static bool is_byte_request_lun_aligned(int64_t offset, int64_t bytes, IscsiLun *iscsilun) { - if (offset % iscsilun->block_size || count % iscsilun->block_size) { + if (offset % iscsilun->block_size || bytes % iscsilun->block_size) { error_report("iSCSI misaligned request: " "iscsilun->block_size %u, offset %" PRIi64 - ", count %d", - iscsilun->block_size, offset, count); + ", bytes %" PRIi64, + iscsilun->block_size, offset, bytes); return false; } return true; @@ -1205,15 +1205,16 @@ out_unlock: static int coroutine_fn iscsi_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags flags) { IscsiLun *iscsilun = bs->opaque; struct IscsiTask iTask; uint64_t lba; - uint32_t nb_blocks; + uint64_t nb_blocks; bool use_16_for_ws = iscsilun->use_16_for_rw; int r = 0; + if (!is_byte_request_lun_aligned(offset, bytes, iscsilun)) { return -ENOTSUP; } @@ -1250,11 +1251,21 @@ coroutine_fn iscsi_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, iscsi_co_init_iscsitask(iscsilun, &iTask); retry: if (use_16_for_ws) { + /* + * iscsi_writesame16_task num_blocks argument is uint32_t. We rely here + * on our max_pwrite_zeroes limit. + */ + assert(nb_blocks < UINT32_MAX); iTask.task = iscsi_writesame16_task(iscsilun->iscsi, iscsilun->lun, lba, iscsilun->zeroblock, iscsilun->block_size, nb_blocks, 0, !!(flags & BDRV_REQ_MAY_UNMAP), 0, 0, iscsi_co_generic_cb, &iTask); } else { + /* + * iscsi_writesame10_task num_blocks argument is uint16_t. We rely here + * on our max_pwrite_zeroes limit. + */ + assert(nb_blocks < UINT16_MAX); iTask.task = iscsi_writesame10_task(iscsilun->iscsi, iscsilun->lun, lba, iscsilun->zeroblock, iscsilun->block_size, nb_blocks, 0, !!(flags & BDRV_REQ_MAY_UNMAP), @@ -2074,10 +2085,10 @@ static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.pdiscard_alignment = iscsilun->block_size; } - if (iscsilun->bl.max_ws_len < 0xffffffff / block_size) { - bs->bl.max_pwrite_zeroes = - iscsilun->bl.max_ws_len * iscsilun->block_size; - } + bs->bl.max_pwrite_zeroes = + MIN_NON_ZERO(iscsilun->bl.max_ws_len * iscsilun->block_size, + max_xfer_len * iscsilun->block_size); + if (iscsilun->lbp.lbpws) { bs->bl.pwrite_zeroes_alignment = iscsilun->bl.opt_unmap_gran * iscsilun->block_size; diff --git a/block/mirror.c b/block/mirror.c index f7b7f4d566..e40608b2d3 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1480,7 +1480,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 34cb28927b..9ec822c083 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1619,15 +1619,17 @@ static int nbd_client_co_pwritev(BlockDriverState *bs, int64_t offset, } static int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags flags) { BDRVNBDState *s = (BDRVNBDState *)bs->opaque; NBDRequest request = { .type = NBD_CMD_WRITE_ZEROES, .from = offset, - .len = bytes, + .len = bytes, /* .len is uint32_t actually */ }; + assert(bytes < UINT32_MAX); /* relay on max_pwrite_zeroes */ + assert(!(s->info.flags & NBD_FLAG_READ_ONLY)); if (!(s->info.flags & NBD_FLAG_SEND_WRITE_ZEROES)) { return -ENOTSUP; diff --git a/block/nvme.c b/block/nvme.c index 1a128ef95e..1263022e1c 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1265,19 +1265,29 @@ static coroutine_fn int nvme_co_flush(BlockDriverState *bs) static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, + int64_t bytes, BdrvRequestFlags flags) { BDRVNVMeState *s = bs->opaque; NVMeQueuePair *ioq = s->queues[INDEX_IO(0)]; NVMeRequest *req; - - uint32_t cdw12 = ((bytes >> s->blkshift) - 1) & 0xFFFF; + uint32_t cdw12; if (!s->supports_write_zeroes) { return -ENOTSUP; } + if (bytes == 0) { + return 0; + } + + cdw12 = ((bytes >> s->blkshift) - 1) & 0xFFFF; + /* + * We should not loose information. pwrite_zeroes_alignment and + * max_pwrite_zeroes guarantees it. + */ + assert(((cdw12 + 1) << s->blkshift) == bytes); + NvmeCmd cmd = { .opcode = NVME_CMD_WRITE_ZEROES, .nsid = cpu_to_le32(s->nsid), @@ -1441,6 +1451,14 @@ static void nvme_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.opt_mem_alignment = s->page_size; bs->bl.request_alignment = s->page_size; bs->bl.max_transfer = s->max_transfer; + + /* + * Look at nvme_co_pwrite_zeroes: after shift and decrement we should get + * at most 0xFFFF + */ + bs->bl.max_pwrite_zeroes = 1ULL << (s->blkshift + 16); + bs->bl.pwrite_zeroes_alignment = MAX(bs->bl.request_alignment, + 1UL << s->blkshift); } static void nvme_detach_aio_context(BlockDriverState *bs) diff --git a/block/preallocate.c b/block/preallocate.c index c19885af17..99e28d9f08 100644 --- a/block/preallocate.c +++ b/block/preallocate.c @@ -337,7 +337,7 @@ static bool coroutine_fn handle_write(BlockDriverState *bs, int64_t offset, } static int coroutine_fn preallocate_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { bool want_merge_zero = !(flags & ~(BDRV_REQ_ZERO_WRITE | BDRV_REQ_NO_FALLBACK)); diff --git a/block/qcow2.c b/block/qcow2.c index c786601d52..c9bce9711d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3890,7 +3890,7 @@ static bool is_zero(BlockDriverState *bs, int64_t offset, int64_t bytes) } static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { int ret; BDRVQcow2State *s = bs->opaque; diff --git a/block/qed.c b/block/qed.c index f45c640513..09773c584b 100644 --- a/block/qed.c +++ b/block/qed.c @@ -582,6 +582,7 @@ static void bdrv_qed_refresh_limits(BlockDriverState *bs, Error **errp) BDRVQEDState *s = bs->opaque; bs->bl.pwrite_zeroes_alignment = s->header.cluster_size; + bs->bl.max_pwrite_zeroes = QEMU_ALIGN_DOWN(INT_MAX, s->header.cluster_size); } /* We have nothing to do for QED reopen, stubs just return @@ -1397,7 +1398,7 @@ static int coroutine_fn bdrv_qed_co_writev(BlockDriverState *bs, static int coroutine_fn bdrv_qed_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, + int64_t bytes, BdrvRequestFlags flags) { BDRVQEDState *s = bs->opaque; @@ -1408,6 +1409,12 @@ static int coroutine_fn bdrv_qed_co_pwrite_zeroes(BlockDriverState *bs, */ QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, NULL, bytes); + /* + * QED is not prepared for 62bit write-zero requests, so rely on + * max_pwrite_zeroes. + */ + assert(bytes <= INT_MAX); + /* Fall back if the request is not aligned */ if (qed_offset_into_cluster(s, offset) || qed_offset_into_cluster(s, bytes)) { diff --git a/block/quorum.c b/block/quorum.c index 353401ac08..772de80a77 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -746,7 +746,7 @@ static int quorum_co_pwritev(BlockDriverState *bs, int64_t offset, } static int quorum_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags flags) { return quorum_co_pwritev(bs, offset, bytes, NULL, diff --git a/block/raw-format.c b/block/raw-format.c index 051b00a4d4..4e9304c63b 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -289,7 +289,7 @@ static int coroutine_fn raw_co_block_status(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 1330e844c3..c13fe9067f 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -135,7 +135,7 @@ static int coroutine_fn throttle_co_pwritev(BlockDriverState *bs, } static int coroutine_fn throttle_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { ThrottleGroupMember *tgm = bs->opaque; diff --git a/block/vmdk.c b/block/vmdk.c index 8d49e54bdd..fb4cc9da90 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2109,7 +2109,7 @@ vmdk_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes, static int coroutine_fn vmdk_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int bytes, + int64_t bytes, BdrvRequestFlags flags) { int ret; diff --git a/block/trace-events b/block/trace-events index 3cbea9e2e2..3edd2899c2 100644 --- a/block/trace-events +++ b/block/trace-events @@ -80,8 +80,8 @@ qcow2_writev_done_req(void *co, int ret) "co %p ret %d" qcow2_writev_start_part(void *co) "co %p" qcow2_writev_done_part(void *co, int cur_bytes) "co %p cur_bytes %d" qcow2_writev_data(void *co, uint64_t offset) "co %p offset 0x%" PRIx64 -qcow2_pwrite_zeroes_start_req(void *co, int64_t offset, int count) "co %p offset 0x%" PRIx64 " count %d" -qcow2_pwrite_zeroes(void *co, int64_t offset, int count) "co %p offset 0x%" PRIx64 " count %d" +qcow2_pwrite_zeroes_start_req(void *co, int64_t offset, int64_t bytes) "co %p offset 0x%" PRIx64 " bytes %" PRId64 +qcow2_pwrite_zeroes(void *co, int64_t offset, int64_t bytes) "co %p offset 0x%" PRIx64 " bytes %" PRId64 qcow2_skip_cow(void *co, uint64_t offset, int nb_clusters) "co %p offset 0x%" PRIx64 " nb_clusters %d" # qcow2-cluster.c From patchwork Wed Mar 24 20:51:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12162355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03CABC433DB for ; Wed, 24 Mar 2021 20:59:58 +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 8DCEB61A09 for ; Wed, 24 Mar 2021 20:59:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DCEB61A09 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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]:57074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPAbc-0006kQ-FM for qemu-devel@archiver.kernel.org; Wed, 24 Mar 2021 16:59:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPAU4-0006Zl-MV; Wed, 24 Mar 2021 16:52:08 -0400 Received: from mail-eopbgr140109.outbound.protection.outlook.com ([40.107.14.109]:48878 helo=EUR01-VE1-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 1lPAU1-0005Mt-Uf; Wed, 24 Mar 2021 16:52:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bit78dJVnVetoXrfg3nPQvPqxiyo7jk52tGYLZ4IT++Tv3k0+Gehs8kW3T7WkXSwGp75rXC9Blff09RCxGLwOe52/+5y3ikrVP8JuBqqFbMEx99kEAMYVQTcV+Gi+uZu71/R9dK03jYgsgcSgi//nKuX/VOKX9lL3nH+qYip3OeYWkuZauysPm15Yvg+m8qncvBu1KQAPK7wcgmBJQRaW9u27gNiIcO0TYfq+C0fAs8wH9VRxRMm+x5yRerUj4ve5tcI1Rt5iK7EkNwvv1R/RyuKr1Ew+/EAINJjK8HAMglegcirMt4zOydtuXENzk2ac8BIJKVkkAVv6mzPxUmgwA== 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=rbEdRNIJXRhrWJlivHwWZnJS0yOnfYFGDcVcJmqq3XQ=; b=Wtpx8Ad/qwEBwBgO13OQQZ+6Y92LQ3a4zlqfGkX69bieSyDUCjIuEq8InCy8V2PMEimh8t71HBqzIEpRnw5sJvN+aXSveJ3QlFts1tccbR+Ag31/TGosZiOYEL4yx19mYcXnZCU+aVOWKpf+Vlqiu7Ze0VTihG1dZeGdhN52W8XHzf/HQ/CnYChfe/M3fiKIqAcob5vP691HV0nBvF4xsY6xSs4JHhXAlAw7Kd2XvTJ8znAPicVRWfevjNvJxzYvPwcRGagFXdO4bvzF/HI9bmX7Rci3mVr2Sg+bDv1/Yu//u29DWZ5j5+AHRI7vn577hpbciNhcAKjQesQ20OOXaQ== 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=rbEdRNIJXRhrWJlivHwWZnJS0yOnfYFGDcVcJmqq3XQ=; b=a1GPKFTn/IuqksVtB74oTCVHwj222h1iyhZYE4TKTYIaBwAcZ87jewhU/tLaWvg/T4lToz0vC8q4KBAfzGjAwA7PVRYYATDFPKH45xY+za0ZGk34akhFG3Qrkdyvt0SWPr4dETbkboaxXkj0qKiIg99yb0aStyo4U8tlegj7Ths= 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 AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24; Wed, 24 Mar 2021 20:51:58 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a%7]) with mapi id 15.20.3955.027; Wed, 24 Mar 2021 20:51:58 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, namei.unix@gmail.com, dillaman@redhat.com, berto@igalia.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v4 08/11] block/io: allow 64bit write-zeroes requests Date: Wed, 24 Mar 2021 23:51:29 +0300 Message-Id: <20210324205132.464899-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210324205132.464899-1-vsementsov@virtuozzo.com> References: <20210324205132.464899-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.202] X-ClientProxiedBy: AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.202) by AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.9 via Frontend Transport; Wed, 24 Mar 2021 20:51:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 963270f4-253d-4ec1-4533-08d8ef06aa6a X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:154; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9fbXRO1EARGOcPA5sVXg/29CMRXRFymI19jNQe7/qLfC9HBusDmb4mdMiBbzH2ljIYNrzGoB4UhLefItsyevm5RFc8978N1KMy4kAc5uI6krDVuMUN8WxO4lIOgfKJQn5gmKpCaUCVzIXhsRKZH9rSX8XLObyNJOqgqxXHpz3ZLJ/cqNuRZLhlWRBT7rYg2ozz0+f1yds4XhxP+4jGTrDLYmC2GGZD/BiaOf4S274GVSdsipW8gy3ZrybW5UJuDtd32TikhCdPMWs/IzxDPse8VkZG8fSOHx9NtWdVkf/9bECBS9vqOZtSsv8yJ1Q4KSi86ozJ6o3tL5Uk+UQ6laXEfN14hDyF0MlLFY9lC+Wav7ki4YkbVavncx+tOzvuH5h6i5Y1QOF13FIMdM7OA87JEAhKPQXVCpdHenhy4733rlClQ41RHRfJCBofplBqmGfGFKvJJSzEpeK5jbddaQg7wUnxqTpEjwYJ/aT2vfJqKfx0b9IFiYmC9wz+lx/0tdXDWn5jOzq6jscw3jJjrOuLVg7IaHcIENpmlQro7kbFbUKGcvw8IHZ/0mHSbuVVIB3UmN02/1XnSjJpLHR9gEi0dNbdwyhTyicW6JEJl2ipa87Dpk6vulYlvd7gJ7twgkR9s1fUvlgU2sNsLZHBOE/vdzemqLK5nP+htqGY61NBuiKu37jcn3a3SayJ7faxB2 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(346002)(396003)(136003)(39840400004)(38100700001)(16526019)(478600001)(6916009)(8936002)(8676002)(186003)(26005)(52116002)(316002)(36756003)(2616005)(6506007)(4326008)(5660300002)(956004)(69590400012)(6486002)(1076003)(6666004)(2906002)(66946007)(6512007)(86362001)(83380400001)(7416002)(66556008)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: fiKmfF2VXUrSBZYhDuHT8tmDvMjhqgeC72DyxmzcEcHClSj+DXn+v8vjvDlSSWPFc2zkSiIb2ynsZPZu6RwbRmMenpzc8Wg+rInaaLdM4WhEyanTy3wJkFsi80Vfafn2NYhB1e4BNli4iiUPfEILFJTxqx66hhGr/voZg7OFVNlcwijhwZ8L2/SJYjIHBPgWdD6OKpXf3eAW/PANgbzu+lUYA+m9ttHUMaoMfFNhytKJSPCVOfg2VpmQi1q/J7s6Rpv/s/cxgrqwdDlUZa32x3B6loN8Kq0jluF/9B9dLB4VSA5im1sur4cBNb5X/viUmWajk2y1DsUxJxn/e8R0k7trCQHfaUEUHrSFS1/81rcXxq/wy9D2WOq5KggPt5DLdbMchzRLLZKj+qkAGnOwP8znBBbkAmXk6vYo3C5BSvKTWjGRxR1I0RBWkkvUIa+wo0hvLFLljQC5G0qIq/dYpU+FNvuFJSvpq8U7h3cDqF5LABPTNEuQsbfiThz1AinPrRT65Lgdg5HV+AF7jfrIEs48l4Rm+FlLc4Ps3fo6hUSlM61gzevmhoNoqkZ3wi8M6j/FbntThPrsm7HL4oCIp9/3wZgtvxJkkeeBpdLyZamwBt1DSZoAV8oPL1u5uHW4W+xIT7OolWjt0jSWe1ASJoe2TlfpPGegbJKUvg5EGk6N6Ki/+JiZbrsDODH26XQRA5MTcmR4Atd5D+ccYjScHeRhX6gFK/jjbGVk7E2eu9GfwDC4AN+jieFVvsbjhsWZ270YsGJpjtQYO6a9lGyT3y5Ck44O+Oa4mkEB5WNyHt4sPgH6dtzSWlCCmZsXokQF/texA2oXgdZZuO6JDoS6EHTvOPUv0wLEulj/KZDcyfic3tkfqeJ1VI24HmtRXogOVH3wDX0VaNB6kajSFJNArJWLV8e9wHU9gwy/zqFai3IFGQXrnx9saPtVvUPNjawt0lPb8DheAepMh0l5vDTgY1foPgvPj7Cf7F16XBhZNsr0OqD1qotFmeDMTzsSTmXQtu6RjlGPHuyVijsR5/sc2eljtOOuu/xZJeHbGdm6doOIeucm2X6ZfihTsm6Z4ymP7Kf7zbf6N87s218mPdHAynCR6X7Mr0+/hOpgQHblVHRBy5zLExm0A+9YRmNT77U04AqnfC/N9HBVAJdbwSMLpzvIi6GRMMAZmdE0iwvRSIuiVb0MDTRp6cHyDua2atxLdePQtE1s/MezZbT7s3bdYqBBR/KCpsMoKgQLSsE35WQfS0ssKLJI+1vCkNTgrr7peLlcrVr2BMudorE+b/Wl+2meNUzOEdN099B5tGIXLhl4dy0WwLlFBG6OrGCiMHgX X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 963270f4-253d-4ec1-4533-08d8ef06aa6a X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2021 20:51:58.2123 (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: kXpFNFMY/ofNf4QWvmpHN6KVX4snVkxoHaEJsJ1FUUYOFRAmwgHvsSTgl+HkFxOkwQ8JE25tL5WjEtUiM0Jd9uOSHj6Q4fpoZyxnouw2SOY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.14.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Now, when all drivers are updated by previous commit, we can drop two last limiters on write-zeroes path: INT_MAX in bdrv_co_do_pwrite_zeroes() and bdrv_check_request32() in bdrv_co_pwritev_part(). Now everything is prepared for implementing incredibly cool and fast big-write-zeroes in NBD and qcow2. And any other driver which wants it of course. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/io.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index 79e600af27..a3c2b7740c 100644 --- a/block/io.c +++ b/block/io.c @@ -1836,7 +1836,8 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, int head = 0; int tail = 0; - int64_t max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX); + int64_t max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, + INT64_MAX); int alignment = MAX(bs->bl.pwrite_zeroes_alignment, bs->bl.request_alignment); int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFFER); @@ -2212,7 +2213,11 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, return -ENOMEDIUM; } - ret = bdrv_check_request32(offset, bytes, qiov, qiov_offset); + if (flags & BDRV_REQ_ZERO_WRITE) { + ret = bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, NULL); + } else { + ret = bdrv_check_request32(offset, bytes, qiov, qiov_offset); + } if (ret < 0) { return ret; } From patchwork Wed Mar 24 20:51:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12162353 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D71E9C433DB for ; Wed, 24 Mar 2021 20:58: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 759F961A17 for ; Wed, 24 Mar 2021 20:58:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 759F961A17 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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]:51946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPAZq-0004fs-Is for qemu-devel@archiver.kernel.org; Wed, 24 Mar 2021 16:58:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPAU8-0006iA-FF; Wed, 24 Mar 2021 16:52:12 -0400 Received: from mail-eopbgr140109.outbound.protection.outlook.com ([40.107.14.109]:48878 helo=EUR01-VE1-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 1lPAU5-0005Mt-CC; Wed, 24 Mar 2021 16:52:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lst9FIr0ya8TNzd3rFxFnzvuW1kYdATWvxvRrJ6nT9eY8yfYJzromUq7Bk3HsHEtFHRmNXWCfwpUDC5qi0fIN9lD+AqB5rhkByb/TUGAwwID/gxmNpk3s9gO8UQVhDX2P5X61VmBmzBWoCLRil2YJ+Cgj5WxBtPA1mfU07NmkkiqPxoCaWHzJfEcNoIu8q5VlCS1NxpW+uFtO/x1gRJgNRdwKR+GzvCF0uuNKJFqSdGGbF8UlI+nmxiFTE/nAikdNOQ9LAN4fklejqT8aN0DSxKghr76Ens7dJU8O4Xs4WFVPZRrnfkoVab6In/P6wDTRw1i1xT8ARvtqHf9fpyTHg== 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=2igTTbRtCSDChe6pEOhuLZR1KtVLw3XXracJeMmdLSw=; b=PzweuTl0u6IqeZ16XURvs/9HmlV1XTl+kdw41T9nGSsanrUZKHLQuGSJRrT7H1hJttygqSUOxU1qZSEv4FU2DKRphbSSi3r7fRy7taDu9uQ6X83OcwbY9KzqG1C2nS/Zfr86p/kTHutIj4fJQ5f4phEobHcAnizSxg44DERblF1PNNxuTmgvZ78MZxaHYf+tzQTxjoYTa4yXEp8whOM96tyIJ7Z+rGTNjklCo6OurRdERab6afiQ0fznFyv/Ys3BFAQQXNlWMnoVkc/apeA24zQndBxvj9GgCYq793f95TthUCpqL/imG5Yx7y+tDHKnEBMtixZgZLYx3KEPAJ9c4A== 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=2igTTbRtCSDChe6pEOhuLZR1KtVLw3XXracJeMmdLSw=; b=c8D10MT4jR2XHCorDy+jhyS1YqYGuP+hxr0MyqORtJ+dZyKxrt8IFAj2131mt8IIRQUoRzjB3XKREmPyUnfIQ+vh9Qs+4vEd6uo4EjTuww4EoE/WRBeLtBSQABeNiWBN9ZTW9nkH7YHYq4L9tHwq91r/lQs27NwMv3zlA2ASblo= 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 AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24; Wed, 24 Mar 2021 20:51:59 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a%7]) with mapi id 15.20.3955.027; Wed, 24 Mar 2021 20:51:59 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, namei.unix@gmail.com, dillaman@redhat.com, berto@igalia.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v4 09/11] block: make BlockLimits::max_pdiscard 64bit Date: Wed, 24 Mar 2021 23:51:30 +0300 Message-Id: <20210324205132.464899-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210324205132.464899-1-vsementsov@virtuozzo.com> References: <20210324205132.464899-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.202] X-ClientProxiedBy: AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.202) by AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.9 via Frontend Transport; Wed, 24 Mar 2021 20:51:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cbc01d8f-1af7-4cb6-160e-08d8ef06ab41 X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GS4bZGhvg6rarFRd9b91JnqJ5qXDHNLApGfUfl6lAzzJYcqH37A+AcgDE2Mt7lLGFUIFVrouwgU1wJfa64JlzKGj6gWgUMfwzo/bCKrAkiFikMu/82hnJ30by6A856JVAzGW/tDzLVci/PAKditAUbt1Ly7mVgjYC/c+xDIl1WwMBy/SneTEdK7dFSkzcNA5Sk6EJxHsT+0kh1RKMZE5xzqfUXwLrc63t0x59fPPyEJ+72QfK/X1zJWfK07t9d94+uKkfI+/gQKgCKMH4K/tpM+5W5T2oazuMxdTwiIiTy3jIW05X81Ueh3kDjGtUr3ddAaIDdj3D58k5I5IPiiVpsZKeR5Dt91c6FNzclxHhfPHDTy5UmHQhlHXGsl1MTk1/rgKjJYA0uiuXjIBwMLInVFw4B75fpBnUnf8kbKrqFYKBWDnsxZ8O8pCWOT/j2m8V0ZDj2I6G5Yp2b1yoOcRH6c4SZysVzQnb4v0D2XELiiUc1Al1Qn4DPrnmfLOXBsQzxOficik2pFq1uGHxoc6N00Ui2XIR25Rn3ks11P8fWJT6zC0dDBuFpv9bQIf1G3gBjFKQAK3S2aRX353rToO/mQ+TA20b4k/5oMT0Lkrs9bIlZkp0NrHWEKKzpeJ+AKcBKIwMsMcKn1VouW0i3Ld6kWN7689R76NbZoBHWm/824YHHfdkUsuHxAr1LnDzDKW X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(346002)(396003)(136003)(39840400004)(38100700001)(16526019)(478600001)(6916009)(8936002)(8676002)(186003)(26005)(52116002)(316002)(36756003)(2616005)(6506007)(4326008)(5660300002)(956004)(69590400012)(6486002)(1076003)(6666004)(2906002)(66946007)(6512007)(86362001)(83380400001)(7416002)(66556008)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: a+Qoo6juenaR09Gh41IfuFRf/GmmQcrnJayqV4cpDU09FY6hHmotzvMnI5HnOd9tBTd971MvZl8zN8CpHaffP/P7TnuBMdk8r5WFmBnOFYstrssp/lj70X9+7etg+fjfgFZsCtt1/d3I+n8WiOqhS2dwytoP8DWR31QG37oVHRXK2z3xD5STn87tJMnwT0msUee8JLcRsGUAXbBifumrIFQEf5Jyb9gNGnCdSXQeJ8BFwCIxB8t9/Dfv4U9Zpd6sA9mTYMjDDn31t6fDIKwqAyuLWEo45uK31EYnStc3HXwS90LaJWCyuhqf+/CYM49F60ou890hjIGDm8iNawAulrITDR03Y3JbZdiAwoGM1KrNz9JkMIFCnIGpfPQ0eBin4ROi48VsZ2N91tLK8XINRMY4104xn7Ef3Kn6hcThMKy7VQE7EPADLb9E/ilpaolOpcty0vmmtl0AZWQN0G3Rv9Zyxr2RctzrXkQ7/akVaSFzPi6U9tTcUBRFAl7bzK3jmMvywrJ6lOf3gZSw5R1P2Og9pyQkVHEKXJwfI3ooSFvSufgiCWhr6EjZ3TZTaEo8ViJGIhrmQxceyhAUsDb4nU1Dq38+SG0QkIyedZ7730P9P4n3XIZs6E83+Bir9yONE6vfXM6OPqyCXcW4QNJWBIaJipJS7zswAVk+UJLbclgvpWzTx54auC/u5YPSTOCqFbr7MWjRaxVFFTSCF33EuRvrqVos5GghTjufe2JHuiV1N3fnr+lLtzHmIoRXrvPCXlk/3m2m6BQdvH+x2kbcq9PPKXi6xkbM/Bf+r1Xw1Lxfye/PUC79UTNpgRrWAa3wyyoYuBjXxL4/v57MzoT8UlMIKVd1GRhw6kLeD7VZh/8eU/jLtwiwh2r1/ixzDjLJQyzhhLGoJMkIeDTJVi2zesrcduwZ3oSNIJHLPpF/NYSidxSMgO0e95/aytts6js9mZ6dGQmpz64RZOZLPl+TFPSkpHJHQrulh2oLFk3mfLaPNVbDTzZ9rrYbSBJcvjzFrrDODg/zeDtqc0gyertcMPumpXWRcZPTyJpbUpEty0CR5f3XkSdztfU294mqY3iqdT4m01gMK076ey+LcZrjRff4fn17j1ZzFqwYY4YU7HVfSjfxivm/Rfe/UHjxas2JtPLtYyQPTLDQ/uQ1ftJDA/Zr0L8jA9yw1+5wyHwJG4D+X8RloZDyY9LUXuC9RANKTTIx6qH7ges46FkI8jLzOnVP4PS47oHmaK47CXsB5BXdKfGGg19h0seh/P5EizOZy1UVlASW4XchYGZrRkhvY3yXPU7jIfsr03Dau7NshydzJM1bcF5FuhFXzw5RTR/6 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbc01d8f-1af7-4cb6-160e-08d8ef06ab41 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2021 20:51:59.6091 (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: HRRsNGKDHBSFZBzCKV8X3U17cLxOZTCPKcb0qOfU3ACDu1Qe5knexCUoJThRHgntExa6plFoVTlyjD06jvg1xuK+kOVOYh5NSpYtcwjCT/w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.14.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are going to support 64 bit discard requests. Now update the limit variable. It's absolutely safe. The variable is set in some drivers, and used in bdrv_co_pdiscard(). Update also max_pdiscard variable in bdrv_co_pdiscard(), so that bdrv_co_pdiscard() is now prepared to 64bit requests. The remaining logic including num, offset and bytes variables is already supporting 64bit requests. So the only thing that prevents 64 bit requests is limiting max_pdiscard variable to INT_MAX in bdrv_co_pdiscard(). We'll drop this limitation after updating all block drivers. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 9 ++++----- block/io.c | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index d9e1f04b21..0245620bf6 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -664,11 +664,10 @@ typedef struct BlockLimits { * otherwise. */ uint32_t request_alignment; - /* Maximum number of bytes that can be discarded at once (since it - * is signed, it must be < 2G, if set). Must be multiple of - * pdiscard_alignment, but need not be power of 2. May be 0 if no - * inherent 32-bit limit */ - int32_t max_pdiscard; + /* Maximum number of bytes that can be discarded at once. Must be multiple + * of pdiscard_alignment, but need not be power of 2. May be 0 if no + * inherent 64-bit limit */ + int64_t max_pdiscard; /* Optimal alignment for discard requests in bytes. A power of 2 * is best but not mandatory. Must be a multiple of diff --git a/block/io.c b/block/io.c index a3c2b7740c..129cfba68e 100644 --- a/block/io.c +++ b/block/io.c @@ -2964,7 +2964,8 @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes) { BdrvTrackedRequest req; - int max_pdiscard, ret; + int ret; + int64_t max_pdiscard; int head, tail, align; BlockDriverState *bs = child->bs; From patchwork Wed Mar 24 20:51:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12162375 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A31D5C433C1 for ; Wed, 24 Mar 2021 21:03: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 233AC61A1B for ; Wed, 24 Mar 2021 21:03:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 233AC61A1B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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]:36194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPAfD-0001de-6v for qemu-devel@archiver.kernel.org; Wed, 24 Mar 2021 17:03:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPAUC-0006rS-IQ; Wed, 24 Mar 2021 16:52:16 -0400 Received: from mail-eopbgr140109.outbound.protection.outlook.com ([40.107.14.109]:48878 helo=EUR01-VE1-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 1lPAU9-0005Mt-Ay; Wed, 24 Mar 2021 16:52:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JBHypbiPuk3lsu2JvAV+e2hFGophnOezURIUnST1SEPObp1WWEtM/8fTIj+KANZLJMCIxC9IDYYueCW4vT2PcfAqdjkioLWyj96EFiWfMoc9RFXNcUsbWmWVI4ulLVwqlrBIa6g/erqTu+DRFDHOCJKc/TqWUxeALG4/PgFnCVgZSp5v0oXhMNXDWRm0SvUCjzIjv7aC9AvoDZbIR1pVdu8erETJ0afvZ54eKjk+qVFro3VNMhY+Vze9hxD+4C4OWpHWwqdq9JzwhgLfHRR0xf35cH+u2upK290H2/+4so1ewY4MyzRiio15pBOzgRAvih0Eaq4NM4IVin8OBHqfrQ== 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=NPPtsSb/Z9pNqmvKnFIp5rqoJZO8E3HrT2ovSK5R5lA=; b=av+QtDLCZR1g0o2Q/Qcg1oSnL+iqGkkJUAlPWYfCMVLW1Le3zrsmFPcVTLwz1s3QB163QXJ6qOb7AmDLaMZbkbPLqKcZhXA9V7pqqnJ/kebbnwVRwc/tViNyCzKwXNtd4osOMHOjVC8YktHriqD3HDalfpM+XYk98k2GkAppmV8i6s/sWXCpUZ3mk68kMIC0/AfA7c7ki4gYDdMWAejbabQQFk1/S8otcdAds4A7GPER8UrNBFPv4NNi+z3fC/t7VTv3dzepGEAnsJu2l8elL6X4Q76dTzRgO1ABqZ5IRgqcMgjqCRdhAXdhm8cGdr93u6KYUsaCdxx2DL9IyIiarQ== 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=NPPtsSb/Z9pNqmvKnFIp5rqoJZO8E3HrT2ovSK5R5lA=; b=ezScg58NKrh8oA0AoLHU1iZ0OA8gVDP0QMhDdS0qN4wbSwx1Nx1WHPJPXBTJcoyZo8qrj33Bba2yqlDAWPwiTkcgGWKO5lWbSPS4UNnFsBYwDZcr8/75U+KOOKiskzNz1K0+YBaETPuBzpPGvO6gkcbs18QiCXL+sxAVpVSN1P0= 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 AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24; Wed, 24 Mar 2021 20:52:01 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a%7]) with mapi id 15.20.3955.027; Wed, 24 Mar 2021 20:52:01 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, namei.unix@gmail.com, dillaman@redhat.com, berto@igalia.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v4 10/11] block: use int64_t instead of int in driver discard handlers Date: Wed, 24 Mar 2021 23:51:31 +0300 Message-Id: <20210324205132.464899-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210324205132.464899-1-vsementsov@virtuozzo.com> References: <20210324205132.464899-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.202] X-ClientProxiedBy: AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.202) by AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.9 via Frontend Transport; Wed, 24 Mar 2021 20:51:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 393c9488-c917-4e4f-1abf-08d8ef06ac14 X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ePrkiLEguv2LV6ULze1zo8Yc6RXAXAFXnk+CFngqc3a4phcffqRvSO5ASS19Yam3EHeWLaKwlEOxnbVSdjtK9Fp1Z9Eq/M68b21UfS8I6n9iH12BYFwXaEJmom+JKk5vZQjTvnjVcLW5YJxU3/a+PcPfmQQ50ASvfFHMbTABIgFoc8xvqwJWkNN69EK2lVpMO36ZqZrxcDUnefIa7iej5iyF+3KPtnT1UeqmpbfUZskzspdwDWNCgyLp+ZAM1u/EQ42Vc472s8C1yEEgoe5Ewg0hBG7YWcmof0Spgr6FQdCRpnEPB9179D0lFNlqbqnB2IhZMchdqpf3BIazKnFiAWhUsQtAOsCFD+gcwmvDZfPpcRVdLiZMWgaBdPxSSaOIUUoMzh/A4o7dldI4jhaVqplPL7yTHjOWOheTX0Q+ZcHIzW4FZxM9rfjQreXB/cFPXK+kVdXp9+PY8DSIeHOZpYNxa1Nw0HMP9EiaLDEBBtUtm8I46ar99Sx4pgjW4fYn5GKBsNMncIf6QoUshja2qUTId0T+Qp7izWPDSEwL0WQ3UFf+ACRpxYJzCscGKv+7etYVmXpkH4KlbWTEq9QGYaKRuQBOChaqTCANI9UZl3H/8uTwyhM7Iga417kVePHVCuUQUiRjB/xwcEsdJhui4+eE8STdm5CNcA0XIq4bTVl34m+YoYzxD4hcJeuuiCiu X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(346002)(396003)(136003)(39840400004)(38100700001)(16526019)(478600001)(6916009)(8936002)(8676002)(186003)(26005)(52116002)(316002)(36756003)(2616005)(6506007)(30864003)(4326008)(5660300002)(956004)(69590400012)(6486002)(1076003)(6666004)(2906002)(66946007)(6512007)(86362001)(83380400001)(7416002)(66556008)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: fZUUBT8FMVgZIEcLOO7YDq6OFphBhICSlI39wYzrCQpqo1UEnPdZXAUSe5UJV0a8fyHA0p24AUh8PEWnY7ClRF/mG4B7cUzeoffewgusJaLlf9Y0wYYkIn3lthPCA/DYEWUgUkZBEQq0DeMYrRQS8Hhe5kWiQGqKXpPNe9cLU6wkiZanhQEhdGfLf+mQHX4DWMpw59Ol+1zCtQNmI8+OqvQuJve/SZ99xekg0bR5MCRhCgv9jk4Wn9VUFt5bH5SKLEeR4hWV4ozAcWZD3kasPaquccbOe4jLTZG0TwRTLg2ppWZjg2WZuBqIDt5VwC6TcMDeBTM22wN7G+g7qta8YneXAARhQyQg8Z+zoQrZwrSTzkiOlIG9TgHImgH31lVxiJ6XFhr1aGnTI4C9N3tqdEh7rBNDokJ9FPtwGKBIwnNigryy4tG2RBJQ7HT+lt+nbal9A4kA5aoxxnMffYPJuqULHS+kMSe370pIGWOo4nGeApVPWjFQZRYtbjp0/efTEzB0UtwaE7e3SwP5FQmsqyN63Yi39HUf7KrouIIV0CmAal11CkkXToFykwY1gPY23Jnfl1NQ/rN4c9aWrQSbV4FC5IEM6u3iem3Qyeh3Q1Cv+x8AHazMRQpxLGxzpAvNW23FJnMiN4UkwNh390iHv6/Wq4NGN9Lt5AwDk3JYNVNfDuromnX8OEZ8dJiM3Wi/I3UV2cfKO2XR7OBK7V/Yzwj++WQCT/zFayKrHjdG+iHxiIkIIA37ligVdoJU6d1Z3TtIqIh0/bB9QiZZezMQ1Rq+G2pKgqsMvQxyY9p0txoYcEph3fJnPyIWVMNooGnEcps3vUd8TrtKLmnW72pADBkniPl6tn9rOPixKUXS4tcJ2Nu27SwOCs1ytJnf9uVfADNDjQbZfWJep3skg43/AqThTDLSVNliYAWV00WpfcshMGXBZd5QfU5sCDfhYNBXbVRg8jjzKCEwt8RHRJ86jNI6IfSo5tn7sXW3IX95qNpnZ5SINNRUwg9DBgNfkynH0VELFcNaS8a9OXgq59Lqyu5PFA+y6cd014SCiGrDPodJRocRgOeuCDt1i3pafOrR9cVPoEzDX+I6jVXiSANJENGMyh1Yifxboxx9iG4qSbmftaLjyY4Kiqb3q91ZqZAAEg2UU0ULFPjfNFGsknAD4IsCDCiVEbJ4W+nfUgavdrZTZtKkBcUaK7LjhFZOy5PF8Q37DHv5xRrAAnaARmIFFzP+Mgwl57zxlrqcuyWVL9+SNONpdL9AsNg5qPD29u/PKa0H7AbZcecRsJKKws1YwTT2veMuXSW52OY1ZXEaBqRtfQ7wwZaD7Pe6b2vfmbzK X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 393c9488-c917-4e4f-1abf-08d8ef06ac14 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2021 20:52:01.0179 (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: zoymiq3haQNIlB9PcEBEMEbQt0d8yK0hHK3X6AoeUM7RIsUhi1THt6Ysl35hnNEncwmeMzt7I+sHlVvT9ziJ8NsTMUJTNfPl6BGkN4t+UnQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.14.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, convert driver discard handlers bytes parameter to int64_t. The only caller of all updated function is bdrv_co_pdiscard in block/io.c. It is already prepared to work with 64bit requests, but pass at most max(bs->bl.max_pdiscard, INT_MAX) to the driver. Let's look at all updated functions: backup-top: pass to bdrv_co_pdiscard which is 64bit blkdebug: all calculations are still OK, thanks to bdrv_check_qiov_request(). both rule_check and bdrv_co_pdiscard are 64bit blklogwrites: pass to blk_loc_writes_co_log which is 64bit blkreply, copy-on-read, filter-compress: pass to bdrv_co_pdiscard, OK file-posix: one handler calls raw_account_discard() is 64bit and both handlers calls raw_do_pdiscard(). Update raw_do_pdiscard, which pass to RawPosixAIOData::aio_nbytes, which is 64bit (and calls raw_account_discard()) gluster: somehow, third argument of glfs_discard_async is size_t. Let's set max_pdiscard accordingly. iscsi: iscsi_allocmap_set_invalid is 64bit, !is_byte_request_lun_aligned is 64bit. list.num is uint32_t. Let's clarify max_pdiscard and pdiscard_alignment. mirror_top, preallocate: pass to bdrv_mirror_top_do_write() which is 64bit nbd: protocol limitation. max_pdiscard is alredy set strict enough, keep it as is for now. nvmd: buf.nlb is uint32_t and we do shift. So, add corresponding limits to nvme_refresh_limits(). qcow2: calculations are still OK, thanks to bdrv_check_qiov_request(), qcow2_cluster_discard() is 64bit. raw-format: raw_adjust_offset() is 64bit, bdrv_co_pdiscard too. sheepdog: the format is deprecated. Don't care and just make old INT_MAX limit to be explicit throttle: pass to bdrv_co_pdiscard() which is 64bit and to throttle_group_co_io_limits_intercept() which is 64bit as well. test-block-iothread: bytes argument is unused Great! Now all drivers are prepared to 64bit discard requests or has explicit max_pdiscard limit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 2 +- block/backup-top.c | 2 +- block/blkdebug.c | 2 +- block/blklogwrites.c | 4 ++-- block/blkreplay.c | 2 +- block/copy-on-read.c | 2 +- block/file-posix.c | 7 ++++--- block/filter-compress.c | 2 +- block/gluster.c | 7 +++++-- block/iscsi.c | 10 +++++----- block/mirror.c | 2 +- block/nbd.c | 6 ++++-- block/nvme.c | 14 +++++++++++++- block/preallocate.c | 2 +- block/qcow2.c | 2 +- block/raw-format.c | 2 +- block/sheepdog.c | 15 ++++++++++++++- block/throttle.c | 2 +- tests/unit/test-block-iothread.c | 2 +- block/trace-events | 4 ++-- 20 files changed, 61 insertions(+), 30 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 0245620bf6..735935841e 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -302,7 +302,7 @@ struct BlockDriver { int coroutine_fn (*bdrv_co_pwrite_zeroes)(BlockDriverState *bs, int64_t offset, int64_t bytes, BdrvRequestFlags flags); int coroutine_fn (*bdrv_co_pdiscard)(BlockDriverState *bs, - int64_t offset, int bytes); + int64_t offset, int64_t bytes); /* Map [offset, offset + nbytes) range onto a child of @bs to copy from, * and invoke bdrv_co_copy_range_from(child, ...), or invoke diff --git a/block/backup-top.c b/block/backup-top.c index 838027981b..c5ce84def4 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -75,7 +75,7 @@ static coroutine_fn int backup_top_cbw(BlockDriverState *bs, uint64_t offset, } static int coroutine_fn backup_top_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { int ret = backup_top_cbw(bs, offset, bytes, 0); if (ret < 0) { diff --git a/block/blkdebug.c b/block/blkdebug.c index c81cb9cb1a..2d98a33982 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -700,7 +700,7 @@ static int coroutine_fn blkdebug_co_pwrite_zeroes(BlockDriverState *bs, } static int coroutine_fn blkdebug_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { uint32_t align = bs->bl.pdiscard_alignment; int err; diff --git a/block/blklogwrites.c b/block/blklogwrites.c index d7ae64c22d..f7a251e91f 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -484,9 +484,9 @@ static int coroutine_fn blk_log_writes_co_flush_to_disk(BlockDriverState *bs) } static int coroutine_fn -blk_log_writes_co_pdiscard(BlockDriverState *bs, int64_t offset, int count) +blk_log_writes_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes) { - return blk_log_writes_co_log(bs, offset, count, NULL, 0, + return blk_log_writes_co_log(bs, offset, bytes, NULL, 0, blk_log_writes_co_do_file_pdiscard, LOG_DISCARD_FLAG, false); } diff --git a/block/blkreplay.c b/block/blkreplay.c index 89d74a3cca..dcbe780ddb 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -105,7 +105,7 @@ static int coroutine_fn blkreplay_co_pwrite_zeroes(BlockDriverState *bs, } static int coroutine_fn blkreplay_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { uint64_t reqid = blkreplay_next_id(); int ret = bdrv_co_pdiscard(bs->file, offset, bytes); diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 758a5d44d5..c29cfdd10e 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -214,7 +214,7 @@ static int coroutine_fn cor_co_pwrite_zeroes(BlockDriverState *bs, static int coroutine_fn cor_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { return bdrv_co_pdiscard(bs->file, offset, bytes); } diff --git a/block/file-posix.c b/block/file-posix.c index 03618cc18b..1ea2d0c889 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2899,7 +2899,8 @@ static void raw_account_discard(BDRVRawState *s, uint64_t nbytes, int ret) } static coroutine_fn int -raw_do_pdiscard(BlockDriverState *bs, int64_t offset, int bytes, bool blkdev) +raw_do_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes, + bool blkdev) { BDRVRawState *s = bs->opaque; RawPosixAIOData acb; @@ -2923,7 +2924,7 @@ raw_do_pdiscard(BlockDriverState *bs, int64_t offset, int bytes, bool blkdev) } static coroutine_fn int -raw_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) +raw_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes) { return raw_do_pdiscard(bs, offset, bytes, false); } @@ -3563,7 +3564,7 @@ static int fd_open(BlockDriverState *bs) } static coroutine_fn int -hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) +hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes) { BDRVRawState *s = bs->opaque; int ret; diff --git a/block/filter-compress.c b/block/filter-compress.c index fb85686b69..d5be538619 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -94,7 +94,7 @@ static int coroutine_fn compress_co_pwrite_zeroes(BlockDriverState *bs, static int coroutine_fn compress_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { return bdrv_co_pdiscard(bs->file, offset, bytes); } diff --git a/block/gluster.c b/block/gluster.c index 6a17b37c0c..066fdf60fa 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -891,6 +891,7 @@ out: static void qemu_gluster_refresh_limits(BlockDriverState *bs, Error **errp) { bs->bl.max_transfer = GLUSTER_MAX_TRANSFER; + bs->bl.max_pdiscard = SIZE_MAX; } static int qemu_gluster_reopen_prepare(BDRVReopenState *state, @@ -1297,18 +1298,20 @@ error: #ifdef CONFIG_GLUSTERFS_DISCARD static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs, - int64_t offset, int size) + int64_t offset, int64_t bytes) { int ret; GlusterAIOCB acb; BDRVGlusterState *s = bs->opaque; + assert(bytes <= SIZE_MAX); /* rely on max_pdiscard */ + acb.size = 0; acb.ret = 0; acb.coroutine = qemu_coroutine_self(); acb.aio_context = bdrv_get_aio_context(bs); - ret = glfs_discard_async(s->fd, offset, size, gluster_finish_aiocb, &acb); + ret = glfs_discard_async(s->fd, offset, bytes, gluster_finish_aiocb, &acb); if (ret < 0) { return -errno; } diff --git a/block/iscsi.c b/block/iscsi.c index b90ed67377..297919ebc2 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1141,7 +1141,8 @@ iscsi_getlength(BlockDriverState *bs) } static int -coroutine_fn iscsi_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) +coroutine_fn iscsi_co_pdiscard(BlockDriverState *bs, int64_t offset, + int64_t bytes) { IscsiLun *iscsilun = bs->opaque; struct IscsiTask iTask; @@ -2075,10 +2076,9 @@ static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp) } if (iscsilun->lbp.lbpu) { - if (iscsilun->bl.max_unmap < 0xffffffff / block_size) { - bs->bl.max_pdiscard = - iscsilun->bl.max_unmap * iscsilun->block_size; - } + bs->bl.max_pdiscard = + MIN_NON_ZERO(iscsilun->bl.max_unmap * iscsilun->block_size, + (uint64_t)UINT32_MAX * iscsilun->block_size); bs->bl.pdiscard_alignment = iscsilun->bl.opt_unmap_gran * iscsilun->block_size; } else { diff --git a/block/mirror.c b/block/mirror.c index e40608b2d3..e2038a06d3 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1487,7 +1487,7 @@ static int coroutine_fn bdrv_mirror_top_pwrite_zeroes(BlockDriverState *bs, } static int coroutine_fn bdrv_mirror_top_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { return bdrv_mirror_top_do_write(bs, MIRROR_METHOD_DISCARD, offset, bytes, NULL, 0); diff --git a/block/nbd.c b/block/nbd.c index 9ec822c083..cc522a765c 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1669,15 +1669,17 @@ static int nbd_client_co_flush(BlockDriverState *bs) } static int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, - int bytes) + int64_t bytes) { BDRVNBDState *s = (BDRVNBDState *)bs->opaque; NBDRequest request = { .type = NBD_CMD_TRIM, .from = offset, - .len = bytes, + .len = bytes, /* len is uint32_t */ }; + assert(bytes <= UINT32_MAX); /* rely on max_pdiscard */ + assert(!(s->info.flags & NBD_FLAG_READ_ONLY)); if (!(s->info.flags & NBD_FLAG_SEND_TRIM) || !bytes) { return 0; diff --git a/block/nvme.c b/block/nvme.c index 1263022e1c..0c6c4031f3 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1329,7 +1329,7 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs, static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, int64_t offset, - int bytes) + int64_t bytes) { BDRVNVMeState *s = bs->opaque; NVMeQueuePair *ioq = s->queues[INDEX_IO(0)]; @@ -1356,6 +1356,14 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, assert(s->queue_count > 1); + /* + * Filling the @buf requires @offset and @bytes to satisfy restrictions + * defined in nvme_refresh_limits(). + */ + assert(QEMU_IS_ALIGNED(bytes, 1UL << s->blkshift)); + assert(QEMU_IS_ALIGNED(offset, 1UL << s->blkshift)); + assert((bytes >> s->blkshift) <= UINT32_MAX); + buf = qemu_try_memalign(s->page_size, s->page_size); if (!buf) { return -ENOMEM; @@ -1459,6 +1467,10 @@ static void nvme_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.max_pwrite_zeroes = 1ULL << (s->blkshift + 16); bs->bl.pwrite_zeroes_alignment = MAX(bs->bl.request_alignment, 1UL << s->blkshift); + + bs->bl.max_pdiscard = (uint64_t)UINT32_MAX << s->blkshift; + bs->bl.pdiscard_alignment = MAX(bs->bl.request_alignment, + 1UL << s->blkshift); } static void nvme_detach_aio_context(BlockDriverState *bs) diff --git a/block/preallocate.c b/block/preallocate.c index 99e28d9f08..1d4233f730 100644 --- a/block/preallocate.c +++ b/block/preallocate.c @@ -235,7 +235,7 @@ static coroutine_fn int preallocate_co_preadv_part( } static int coroutine_fn preallocate_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { return bdrv_co_pdiscard(bs->file, offset, bytes); } diff --git a/block/qcow2.c b/block/qcow2.c index c9bce9711d..955e488046 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3945,7 +3945,7 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, } static coroutine_fn int qcow2_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { int ret; BDRVQcow2State *s = bs->opaque; diff --git a/block/raw-format.c b/block/raw-format.c index 4e9304c63b..45846e42d5 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -302,7 +302,7 @@ static int coroutine_fn raw_co_pwrite_zeroes(BlockDriverState *bs, } static int coroutine_fn raw_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { int ret; diff --git a/block/sheepdog.c b/block/sheepdog.c index a45c73826d..80e04dccfd 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -3101,7 +3101,7 @@ static int sd_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, static coroutine_fn int sd_co_pdiscard(BlockDriverState *bs, int64_t offset, - int bytes) + int64_t bytes) { SheepdogAIOCB acb; BDRVSheepdogState *s = bs->opaque; @@ -3113,6 +3113,8 @@ static coroutine_fn int sd_co_pdiscard(BlockDriverState *bs, int64_t offset, return 0; } + assert(bytes <= INT_MAX); /* thanks to max_pdiscard */ + memset(&discard_iov, 0, sizeof(discard_iov)); memset(&iov, 0, sizeof(iov)); iov.iov_base = &zero; @@ -3186,6 +3188,11 @@ static int64_t sd_get_allocated_file_size(BlockDriverState *bs) return size; } +static void sd_refresh_limits(BlockDriverState *bs, Error **errp) +{ + bs->bl.max_pdiscard = INT_MAX; +} + static QemuOptsList sd_create_opts = { .name = "sheepdog-create-opts", .head = QTAILQ_HEAD_INITIALIZER(sd_create_opts.head), @@ -3269,6 +3276,8 @@ static BlockDriver bdrv_sheepdog = { .create_opts = &sd_create_opts, .strong_runtime_opts = sd_strong_runtime_opts, + + .bdrv_refresh_limits = sd_refresh_limits, }; static BlockDriver bdrv_sheepdog_tcp = { @@ -3307,6 +3316,8 @@ static BlockDriver bdrv_sheepdog_tcp = { .create_opts = &sd_create_opts, .strong_runtime_opts = sd_strong_runtime_opts, + + .bdrv_refresh_limits = sd_refresh_limits, }; static BlockDriver bdrv_sheepdog_unix = { @@ -3345,6 +3356,8 @@ static BlockDriver bdrv_sheepdog_unix = { .create_opts = &sd_create_opts, .strong_runtime_opts = sd_strong_runtime_opts, + + .bdrv_refresh_limits = sd_refresh_limits, }; static void bdrv_sheepdog_init(void) diff --git a/block/throttle.c b/block/throttle.c index c13fe9067f..6e8d52fa24 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -145,7 +145,7 @@ static int coroutine_fn throttle_co_pwrite_zeroes(BlockDriverState *bs, } static int coroutine_fn throttle_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { ThrottleGroupMember *tgm = bs->opaque; throttle_group_co_io_limits_intercept(tgm, bytes, true); diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index 50b8718b2a..9656814814 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -48,7 +48,7 @@ static int coroutine_fn bdrv_test_co_pwritev(BlockDriverState *bs, } static int coroutine_fn bdrv_test_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) + int64_t offset, int64_t bytes) { return 0; } diff --git a/block/trace-events b/block/trace-events index 3edd2899c2..3b86c03b2f 100644 --- a/block/trace-events +++ b/block/trace-events @@ -152,8 +152,8 @@ nvme_write_zeroes(void *s, uint64_t offset, uint64_t bytes, int flags) "s %p off nvme_qiov_unaligned(const void *qiov, int n, void *base, size_t size, int align) "qiov %p n %d base %p size 0x%zx align 0x%x" nvme_prw_buffered(void *s, uint64_t offset, uint64_t bytes, int niov, int is_write) "s %p offset 0x%"PRIx64" bytes %"PRId64" niov %d is_write %d" nvme_rw_done(void *s, int is_write, uint64_t offset, uint64_t bytes, int ret) "s %p is_write %d offset 0x%"PRIx64" bytes %"PRId64" ret %d" -nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %p offset 0x%"PRIx64" bytes %"PRId64"" -nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p offset 0x%"PRIx64" bytes %"PRId64" ret %d" +nvme_dsm(void *s, int64_t offset, int64_t bytes) "s %p offset 0x%"PRIx64" bytes %"PRId64"" +nvme_dsm_done(void *s, int64_t offset, int64_t bytes, int ret) "s %p offset 0x%"PRIx64" bytes %"PRId64" ret %d" nvme_dma_map_flush(void *s) "s %p" nvme_free_req_queue_wait(void *s, unsigned q_index) "s %p q #%u" nvme_create_queue_pair(unsigned q_index, void *q, unsigned size, void *aio_context, int fd) "index %u q %p size %u aioctx %p fd %d" From patchwork Wed Mar 24 20:51:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12162377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA4BEC433DB for ; Wed, 24 Mar 2021 21:06:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 613EE61A1E for ; Wed, 24 Mar 2021 21:06:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 613EE61A1E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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]:41488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPAiK-0003yQ-3s for qemu-devel@archiver.kernel.org; Wed, 24 Mar 2021 17:06:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPAUF-0006xK-6m; Wed, 24 Mar 2021 16:52:19 -0400 Received: from mail-eopbgr140109.outbound.protection.outlook.com ([40.107.14.109]:48878 helo=EUR01-VE1-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 1lPAUD-0005Mt-CU; Wed, 24 Mar 2021 16:52:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QQR+5eLmhHmorL0MIiG6vEs3bf0lkvmUF+jGF8V+PBbTgfIXf0x6RKEkx08yYwCw4l3RydQl+YsLSjcjCBk4LQY5M7FPhHJsDAsxlzhrBJgwLZQ9b+jjDlqScPSg1rb9sFgZ0Nw9BsPs8jkimzDvrnpcHJmowNbQfMBUV14PlRs5nV5tD2Jwoho+Z33W8HUvIy6FX298QanMg4D1wLLmIhk8r4rppxysTsWksj2b6YJPlY4nuJNyFD9njPXDhyX6gCy7uzLAOhXU2cMHSv43TpW1GJUTh+FZqaHt6IC+9OyfTzKzx7y6Oq8rX+4r62z9Z/gnUKIkwUEGte2jkkAdFA== 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=eF1dGGQD33N9dv9hNuzPTrsDg7dlBGwBDx53CxwPzoU=; b=c6NAUQeuksY6B6Kdlp4xm7w07GbQWUkxS4NAHdO4AZdA7r3Wt4Ty82i1cOIPwHjjOFs80ADugZ+7K/8P5jcXNS8d1vEsduCELN7Oj8/a+qfZeEAudAufzroXV6HCV8xMwGOFLHSAghr+5Ki2X0+aLmY+AhcwBqye1W4qmupa/fnJ23Fh0dagdhqSqm3u8Wz8rvzlJ5qCussCS8g9Zm3q1R7FwvoddiAMP36CT/1pkBkVdE0WjQUXFD2+pbl0qMFhTH9Bre3D7Cb9BFINp3NRyWr+PRbZkR9ekM3CW2bNLX/RuD4tM73BLMb6BBigR/DweJg46QLdMfgZzw32Lv2Sxw== 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=eF1dGGQD33N9dv9hNuzPTrsDg7dlBGwBDx53CxwPzoU=; b=g8DlJn0YD1eEmyIi04/LMznTF8IlaHSGVx/3XOCY7208YhCQKTk5l3aHcZFS8FIoXADZbJMVOlWa29FklDb9XIYK+Fd6l7+RA/ZIOPkY17TbtXTIn5gpz/8f/YMQCjUiTDYG1473+T5rY2FdaWcuf6pLpmLDyNOcj3l3qIeuc6M= 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 AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24; Wed, 24 Mar 2021 20:52:02 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::f1f0:6610:11f5:5e4a%7]) with mapi id 15.20.3955.027; Wed, 24 Mar 2021 20:52:02 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, integration@gluster.org, namei.unix@gmail.com, dillaman@redhat.com, berto@igalia.com, eblake@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com, fam@euphon.net, sw@weilnetz.de, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v4 11/11] block/io: allow 64bit discard requests Date: Wed, 24 Mar 2021 23:51:32 +0300 Message-Id: <20210324205132.464899-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210324205132.464899-1-vsementsov@virtuozzo.com> References: <20210324205132.464899-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.202] X-ClientProxiedBy: AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.202) by AM0PR07CA0022.eurprd07.prod.outlook.com (2603:10a6:208:ac::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.9 via Frontend Transport; Wed, 24 Mar 2021 20:52:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a0be4a33-0045-495c-2f8b-08d8ef06ace8 X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:137; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q9WYrzynx9YMWDmRzpy+EY7tLauByoTMIkKOE25FrysP3pQ0hPWEh+kDC0Jvfl31r/OJohhg4zXrKCWzsXTQweqUKb+z2v/70vw46WVmU8i70sgSVztTpUxnOoMS4Eg8rP42GfoNYsiZkVCRsWhf4Fud51MD7xllMe9aYHXc8UCt5TrdBoTRwXAfk9RwaoKRg1bWpfJo8DDzey1QoT8+9qArmUMCPW5zi45cMySO2OJu+xIbhmjJCIpZg1lYEnY2A8Y3cFbeBViEoegJu3MJmJCy/uJcbcNnyK/WLIR6lFpyJSAdg1Bzo0Cfc7UAC47aXZJLFwVmk4oXGb0+viyFPqUURSeJDwz+KhhYFsaPTxOl3kOX7Seqvp5SuhEbRgbJjoxQfzKgk8w/3QMbaRXI9L+u/F0S2La9RS9a9lfN3mc8QahtiEbx988zgEaw8Y6/YOQH0Hvz2okrG1MBVktyhQuZlyRAJASH8/rtCFlmyPr2EKgx0cu7WevfGxohh17mvQdT6u64xtsFIBjNQR4NjU6bmkyEcTT/PQRIoFPxy1BcAqWImMN3Tt9oTmgxE4/qMpDCYnFFaQ+w0cmhFs/2uz/V1QdW3f4NEEi/9tdMmNsfpI+d5GR3ZvO3XPIZWOIUQ1ktDcLMEBxVjnHm7nKnDYVVeWm7LvjMgxBNIUzq08ZfU0kMKdnL2t39K0LiKCur X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(346002)(396003)(136003)(39840400004)(38100700001)(16526019)(478600001)(6916009)(8936002)(8676002)(186003)(26005)(52116002)(316002)(4744005)(36756003)(2616005)(6506007)(4326008)(5660300002)(956004)(69590400012)(6486002)(1076003)(6666004)(2906002)(66946007)(6512007)(86362001)(83380400001)(7416002)(66556008)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Y4jvVZ3EhPkLhR9cqlmVZHEjy+xeRtZj4LYB7zTr+girch5eINQy89Sp7Y/qO7NBIjAam/D2T5EbVXoUREJcf0+h0g5WPEDd9rBPDi5+tN651+Qd0glU1wd7XrlH+FA6SchLPAweafhhktmUgYvxXvaHN2ltBrgSOcbgnXi/b/LgjSZQr7Uc31BLnPBF8uktTYetJPpx4PCS8GUTykUt39WogxPdo1LNCHrH5CnPF2H5tn6m3Hf4CvRwigfkUSOh64WoXtdc3QHjwY8XuGCT+IQgs6H8cbhFogqaAkuvHS/R9wB6mu12Ct1spOd/BuvFuv3mi5WnAC9fyTYdFzHt3d7MEM/dWgHip28gseWyWjAFP3ucvO3XOxCozgCTgvCokBf0AobBdK27W3YK/zCRKT4tjTSyFPMkT5gA2eB3T65n8cWMDS0WK0iQzryvwAeAR0r6D1sv1NMk93DiswQFSh83CCP2gkUPK9eMrNcy+NgBwip4HstlssFo6oOR5FoBEQS0TKBQbc/vP5TXEbeNg7Sr3CAJUHF5zbwJhALP5Wsxamr/uM34eIjNiYLCrYpb/VkMP9vG2dRsvyAqjnZDNJ+86c6r9iqQdhzoTAkI3Wljbd4kBXtbEY31K1OHwSxE+l0Rm7qbJIeQt2kKOFBBGLA7t0tfJkq8Vp6JDEIDQ2sawaRhQDrurm9eN90o7JlbRB2MkiA3aYVgQOn65cuopcrpeMD2872FdHBPRnP+R2AHxn+Rx20/p1TxzhZuGGWdVIrIU95hgWu9jcfEE2eqDhx9OiXWB1DApN7Kw1y70Ek/kwK96HEXWvblmgtywm8ojkX6oIq5Mx1uzJetphYDa1mYP5CHWZzKsBSUHcABdV2dPW4mm/R8SNbBNVTC1u13pypX0UHA2wSHV8gYkqSEzWH5n2BrsUCM3cmlZ7H7h/trATGtZUHQ/W/IH7ADJxh0uQ5F8k3cg/s7QpWSvwOCMQ/QaDVbZEo+Raly5cj5SSl3Q9Aqf0MfIpJgqLtKUtaQy1ezgWtPYx8mC2/08BD+6j+aYaL8BzOEReFduiUOg/9QfU5+Hc8F39UcugC3glM5B9cK8AmQ0t5Mbhh9bs2nO60w61a2VIbngIXxFKN1FSbBnrk2deEgUBu+xFOMyfvUa/jKhk9zYacmj5FrtMFKvMG3M+2TqBv6aYEiqDPtM9/JxpizFey937okM6jjy8YWfT6dV3DWH0PQOjQNuW7ssgO2c7P1xdvtUQDcuzkoVEQBWbF9cAhcUNk2Jt3dVEaoVYuw4e+akPQvzVfJLXUsF/B/Oetb9Y3ROclUVlmRwxEf3IDqIGDj/D2pthtV75Ti X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0be4a33-0045-495c-2f8b-08d8ef06ace8 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2021 20:52:02.3929 (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: TWqgnxMNtm2eQzcXjOhs2mdxaUCoIC64n/MCAFXJ5ASZh6XKIiBwxh9JdgdWoD7HwNw1SdGprO81LjEoFVHx/CDDJsw6l4SakOsce6citEY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.14.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Now, when all drivers are updated by previous commit, we can drop the last limiter on pdiscard path: INT_MAX in bdrv_co_pdiscard(). Now everything is prepared for implementing incredibly cool and fast big-discard requests in NBD and qcow2. And any other driver which wants it of course. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index 129cfba68e..e3d0c1ae30 100644 --- a/block/io.c +++ b/block/io.c @@ -3009,7 +3009,7 @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset, goto out; } - max_pdiscard = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_pdiscard, INT_MAX), + max_pdiscard = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_pdiscard, INT64_MAX), align); assert(max_pdiscard >= bs->bl.request_alignment);