From patchwork Thu Dec 28 09:41:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13505747 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 33ED4C3DA6E for ; Thu, 28 Dec 2023 09:44:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rImuM-0008KP-T1; Thu, 28 Dec 2023 04:42:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rImuE-0008EV-PF; Thu, 28 Dec 2023 04:42:23 -0500 Received: from mail-am6eur05on20701.outbound.protection.outlook.com ([2a01:111:f403:2612::701] helo=EUR05-AM6-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 1rImu5-0008GX-67; Thu, 28 Dec 2023 04:42:22 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CBME/44BzIV1ocZTy0pUadIbaHEkjPVtFpMfSG/CL4mes70LqcefKJjrXE8vMoRMjtIF1ni2DV0tu4yNAfHYO3WQFBOE/4r6ruxeJ3YhzuujBHXdU/8q+GbsorLe2Mt0xE/e045nyx6wokeoh5dv3PHQWq1jvvB5hdVMtbCPBPnrvaHKdrdZPAxVBfciheshjAvOfCNntRNq0Vp/xEVqAD7M8kBzN9PGI+6uMixa6yG/tQRun5yCm8P2kuiOfSqvUuK4wqcb0p9qWQL0U3qDrzUuNAWylS97T7kVObyrAdBqOPMylhDFdMiOB6DvB/3Lo6booVeCRwwcs48BHFsb9w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QZAYmTt6a8iWzR3ObMRJXGIqRa8RVqoX0brRg6ZAt0Q=; b=Mw8g6CXgUNmIqNIK6G6D8D1mF+sMiXlquejUJboouRa/SYsiUtZevQzPml1VgbxiQJ0AMz8eGxSZqozKI6NlGjdDvLcqGzmuUuM3sG7jYu6M54eaJ8eNFmnEAJyUcjgfWDT27zq36e9mqDC8rO6gVur7pw6xJjIthwH4r1dw9WmAhTyqvyN2Hn/LXxqb9b9OGzP3wHlUXF/JWJFhdbKWcXmvSlIoWQzeKxHLqDzokf2EcjdZefSL87x/ItocTTeY1nGIsaRRYvpRlO3C2z8ikOqez9AhDLoTpRwZHvqGnPboRmlx1+yw3IaM7d5dgoAx2Gq12CaLnvfMFi99TZZvyw== 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=QZAYmTt6a8iWzR3ObMRJXGIqRa8RVqoX0brRg6ZAt0Q=; b=SGMRwS+NFMwnRZ1n5x0ol7/DFagFIkoEW5nZX5SSPOD4BJropjivt2f6oJWDjbs6GyNcCxFhodNeWg20o6nu6OQA4iqL1l53z73euIg2ta1V5VlTAZdBS1d4+xW5smauCiIPuByHDOestNKmfucwDEOGOFCcodSiyBqc8Mf59p8/mtYaK5hmImb6yG3eh9jeUImzMFpjUYSV4BPyeSkaudphpZH0BLsAGdBqxWOxb9+wE5BtUyDNKW37nSQxEsWlrtnvpe9fAyL+DVRwY/qhoyGNr1IvhVO5cOl141oiweoA07aU3WtkdOTxc8qi3kvnPmLwa4nJKTyFvPDt1HcLKA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from VI0PR08MB10743.eurprd08.prod.outlook.com (2603:10a6:800:205::19) by AS8PR08MB8969.eurprd08.prod.outlook.com (2603:10a6:20b:5b4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.20; Thu, 28 Dec 2023 09:42:01 +0000 Received: from VI0PR08MB10743.eurprd08.prod.outlook.com ([fe80::60f7:3267:9f9d:cdc0]) by VI0PR08MB10743.eurprd08.prod.outlook.com ([fe80::60f7:3267:9f9d:cdc0%5]) with mapi id 15.20.7135.019; Thu, 28 Dec 2023 09:42:01 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 03/21] parallels: Make mark_used() a global function Date: Thu, 28 Dec 2023 10:41:35 +0100 Message-Id: <20231228094153.370291-3-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231228094153.370291-1-alexander.ivanov@virtuozzo.com> References: <20231228094153.370291-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VE1PR08CA0003.eurprd08.prod.outlook.com (2603:10a6:803:104::16) To VI0PR08MB10743.eurprd08.prod.outlook.com (2603:10a6:800:205::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI0PR08MB10743:EE_|AS8PR08MB8969:EE_ X-MS-Office365-Filtering-Correlation-Id: 239d117b-1df8-43b8-aeb1-08dc07893db0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s90wtEVWZWycSHRKUzYsqyB04VIw5DVbQEYvqDIQb5N9acPqG4bxBWhuP1vle/vh4Q05mdVzL7dfMpftmPN0tLEdhljCOhP0KHtRgSdzHHlAAnzswER3mFEhKlb1fE4m9mw/IkyAJm65b9+wia68eezfRTZA0dLqx4N072Z0jeIGOq0hg5nrOEj5qlWxoqiwpER5qgGksVlozk4tv2YVDsGz73x4PxPp0lgQLHncqyQP37y9taZX3OJigfzDcVfuWkJYpdtTdYNq/LvNXImKEOJVvG+Sqldqa+8Tx/4NVRQKuQ+D26ypzCRlY1ty7Da+N0ddxpIbiLMO8YzYmT9YAwpv+i56kTXSEvItMkbsbQKQUIK4Ue3gz6jMHf/3+BsPf0fUMCLLn95vl49/WK6WNFQwx+v5xuI3HQP/RSovEhg84LQUj0BjBx/NXXawOlaRlnMESDH2YVweGHy5eNlgzxPPZ9wccDL4IWijdBQ14sEz6EX/bb+xmG408g38giDsjqHsig3VYbMZCfk6rMSMW+URAPiEXIcxoItWwEgNJF68XuN3DOynJMpdH6RLNYVNUghdL145gA3xioZOF/xV+4krcjwBAkZTMtklBggiQSXC3pWclZSV5y2zdJc4S9hZ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI0PR08MB10743.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(39840400004)(396003)(366004)(376002)(346002)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(2616005)(1076003)(26005)(38350700005)(38100700002)(83380400001)(36756003)(44832011)(66476007)(66556008)(6916009)(4326008)(66946007)(86362001)(6486002)(8936002)(8676002)(316002)(6666004)(41300700001)(6506007)(6512007)(2906002)(478600001)(5660300002)(52116002); DIR:OUT; SFP:1102; X-MS-Exch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RepfJaOs4fI2TtJzxnonJwe2uZOmsLdF9TyzXzN7+8MkcWwW1hLKMFWtQ43HiA6PJzsS+tZtC+FOOTuTTjzBDoKpg1wIFi/b+cAiUainUGhDX708Oq7p4xO1nO1OZYtsh6CFzmn36oNEMst2PHOrNnRko4RGpAb2+k3eBQ8zIfKtvxMjeL/FrXB3Alicv8tYPOYnM+54jtI8W8nRTuqdgFrJqes/PD8Uu3y3MXcdqT9jitQtLM3+778TS+Xd72ROlkzwVcsvRuXQZDkDOQjuUuXtBl6aIhov6oWtUC09mZODnPiCgj7p8Z7wKC4e9BzrPeX9RKpIutCuQNuQr2BLVTJWSn9cF/Xua7YFBJCVcjOfZBgXyA2XhDiHw8GsWUY1NbiPG7T2DhdM/OU6/0Bav1XU9IXUNdPkf4RDbsGXN3OsI/bMZ45gQLCufSlSqGsyqfQrMq9MZsREC9so2fzwZodleG6jrVCD4G2iD/vdFWa0pstK9IkZXUXcn+97YHhNOBqphjyXHlhQRZQ4bVI7YWMeEFCmXXpfnfq4/SpnXptAbjqWO5YP6+OCS2y5KXIO2stvmWyITSxgWSyY2DKYFdQNckc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 239d117b-1df8-43b8-aeb1-08dc07893db0 X-MS-Exchange-CrossTenant-AuthSource: VI0PR08MB10743.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2023 09:42:00.7756 (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: BuNopFLae84hVHisbMjtej+QckgIKbMyT/I5g2xjN/ervaIMzrzUf76ekKM1b0OZfXb2SbchE+KtY8ZkGJsWCNfrJPYAlN/ArXJ45w7uPWE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8969 Received-SPF: pass client-ip=2a01:111:f403:2612::701; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-AM6-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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org We will need this function and a function for marking unused clusters (will be added in the next patch) in parallels-ext.c too. Let it be a global function parallels_mark_used(). Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 14 ++++++++------ block/parallels.h | 3 +++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 992362ce29..ae524f1820 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -178,8 +178,8 @@ static void parallels_set_bat_entry(BDRVParallelsState *s, bitmap_set(s->bat_dirty_bmap, bat_entry_off(index) / s->bat_dirty_block, 1); } -static int mark_used(BlockDriverState *bs, unsigned long *bitmap, - uint32_t bitmap_size, int64_t off, uint32_t count) +int parallels_mark_used(BlockDriverState *bs, unsigned long *bitmap, + uint32_t bitmap_size, int64_t off, uint32_t count) { BDRVParallelsState *s = bs->opaque; uint32_t cluster_index = host_cluster_index(s, off); @@ -232,7 +232,8 @@ static int GRAPH_RDLOCK parallels_fill_used_bitmap(BlockDriverState *bs) continue; } - err2 = mark_used(bs, s->used_bmap, s->used_bmap_size, host_off, 1); + err2 = parallels_mark_used(bs, s->used_bmap, s->used_bmap_size, + host_off, 1); if (err2 < 0 && err == 0) { err = err2; } @@ -366,7 +367,8 @@ allocate_clusters(BlockDriverState *bs, int64_t sector_num, } } - ret = mark_used(bs, s->used_bmap, s->used_bmap_size, host_off, to_allocate); + ret = parallels_mark_used(bs, s->used_bmap, s->used_bmap_size, + host_off, to_allocate); if (ret < 0) { /* Image consistency is broken. Alarm! */ return ret; @@ -827,7 +829,7 @@ parallels_check_duplicate(BlockDriverState *bs, BdrvCheckResult *res, continue; } - ret = mark_used(bs, bitmap, bitmap_size, host_off, 1); + ret = parallels_mark_used(bs, bitmap, bitmap_size, host_off, 1); assert(ret != -E2BIG); if (ret == 0) { continue; @@ -887,7 +889,7 @@ parallels_check_duplicate(BlockDriverState *bs, BdrvCheckResult *res, * considered, and the bitmap size doesn't change. This specifically * means that -E2BIG is OK. */ - ret = mark_used(bs, bitmap, bitmap_size, host_off, 1); + ret = parallels_mark_used(bs, bitmap, bitmap_size, host_off, 1); if (ret == -EBUSY) { res->check_errors++; goto out_repair_bat; diff --git a/block/parallels.h b/block/parallels.h index 423b2ad727..68077416b1 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -90,6 +90,9 @@ typedef struct BDRVParallelsState { Error *migration_blocker; } BDRVParallelsState; +int parallels_mark_used(BlockDriverState *bs, unsigned long *bitmap, + uint32_t bitmap_size, int64_t off, uint32_t count); + int GRAPH_RDLOCK parallels_read_format_extension(BlockDriverState *bs, int64_t ext_off, Error **errp);