From patchwork Mon Apr 24 09:31:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221918 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 25A10C77B61 for ; Mon, 24 Apr 2023 09:33:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsYT-0007dQ-60; Mon, 24 Apr 2023 05:32:17 -0400 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 1pqsYO-0007ZA-D1; Mon, 24 Apr 2023 05:32:12 -0400 Received: from mail-am0eur02on2070d.outbound.protection.outlook.com ([2a01:111:f400:fe13::70d] helo=EUR02-AM0-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 1pqsYM-0007RT-Lx; Mon, 24 Apr 2023 05:32:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KFlHB1G61qlGlovHmYiDhL0T8NutM+A5avxqCOCMjlYheN54OGPt7dbXTtfA+bY+1eRsuhtMeLFnIKkEYqGdpzxq+iSkJd493ERRu907wV2otAEcd9sCwORBfksOv+X2jmRkNhccCpi6FEPkWbEyau8zehTUrY+Y3A2glZi8I4ZGSOLiS3ddMb4P8f9S+6IASQsRPFyjWKFMeQ5m+LtNnGBesjpbMKc1lA6a1PBVp1mHAeoALQzOhGbZA8/P2LXl2YFxo0RA6doqvAxttFFj08vNA9wYMgjZcWKDI1Iyqjq52hGpNOs+1SaM3f6K2o3YyCsm0KhKyJCegg8/NtKMMg== 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=bXOwa/L67joB3+1DEfpVcK72jpfn9Lr1WBBHTA2x4Wc=; b=S2TLmEwfJ+bSEYwPb4hArQys5rKQ+ZlK1hY3ZwILFb6iZNAM6ZAT/0q1xtOTNUzn1y3eAzSxMYKOiEK75ukNU3JTgy+KDZ8duk2uw4S+WwDst/Xk8LKS3kBZjhrIlRBUSbp9SfUz+iade2XuCVsZyUaGGdmo71Fa842SFv0pNSJ0xSOITpk6D9JOnUBESLVphS64WqmhAK2RqZNiWScTDOjt10V4+LhpPI6xRuTT9/HuL9hPHnwTzUo9VOL0zo3Gy4YWSHHClPG8FUD1Yi3BuwL5BNQDUbMCYTiexHqguFFA3Dh1i7HK/iiJFDAjK8b7L/CwiM6fNQXzmWPOdtNGIA== 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=bXOwa/L67joB3+1DEfpVcK72jpfn9Lr1WBBHTA2x4Wc=; b=POQVLNn6npe4lozRJ5Lf4lEj0+2qKgzy1UZvdN1w9PttqiWRzXx5DiIKzBf57ubXwUUF02va457dtDMphQz6c/yLbOJ3ah+1dyV9SJgKxnK2qDtXpntLZp1nLgrCTBh3bUiI47OjtG64H30J0Ilyugwz9j3GsuWU6Wk8ami9KWIhp2/3vX1MqcB3RrijDE9tI/5U0lABKHXJ5AWOH3rPoHnP3iRI7ype/zIJHdjLU00nHmUwz1Y0MR9yaDFng/iDdGETWC7eC3HMsnBNMQRLDa5lYNI5UO007gVlFk63XCvINASURx3QxK8K6kQPQGu0AUDOYH4IYPQhw18uPFg12A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) by PA4PR08MB6077.eurprd08.prod.outlook.com (2603:10a6:102:e7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:31:58 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:31:58 +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 v11 01/12] parallels: Out of image offset in BAT leads to image inflation Date: Mon, 24 Apr 2023 11:31:36 +0200 Message-Id: <20230424093147.197643-2-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> References: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0169.eurprd07.prod.outlook.com (2603:10a6:802:3e::17) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|PA4PR08MB6077:EE_ X-MS-Office365-Filtering-Correlation-Id: d6f5d360-b0d1-4238-4a9e-08db44a6bf4b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wvv302h20tkrhRb6nJsgOxV4cSz4y75qCxjTV/xpDEO8BBu9c4KKpAmpr0Zl8PR6JCAAhGbzKZj/CcjOIxm9mc7/LmPiXqyeWlCUVc+Lp0tihD4wcjuMYrbqwgZqO0f9UpTxayfNY8ItTySvl1PC0Tx1iqVi4ewMS4U+tl0qFIeMWhygxbxf9PJsz20egRQ9h0HJrxJarmof9cFIpoBRh1yExV9j2DJyY8Ylkw0fqlCX0hN/JDHLCUdJS35pPwgaV86tdgsTEC2sZc6j49N2UKQKTpArQ97qBXStROyj+jQjmnZaRImYHZEDiLnXdJ90FLogoIF/Q2nToZqdQFmYU+EvGBgN84lNoYxpb/8BGwaWKEolkuPRuY4aqGAm1ubDl21hvZfBHnfYRCGfLD9GX98NyrvcYk4WZLK6gu7Zg02v3Ovalwfg5xa+NVFfIY9bEz3rUeslcJM8G48h7oymrFcHX4R4BgJa2NyMqDGsKwLa4+rNgDT81Wp1oTpjxoNkIM2gMVsYu+iAOMARPsVtCXK8MMedYJcWjS16ViHvA2S864RsmL9EYRL90Xn2Qxjkls0Ib6/NGmFmsYHu2IIxYg0EacDoL993Ro58bcK4xgo3yp5m+ruwdyrkMv5vuK0s X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(136003)(39850400004)(376002)(366004)(346002)(451199021)(6506007)(1076003)(26005)(6512007)(2616005)(36756003)(83380400001)(186003)(38100700002)(38350700002)(66946007)(478600001)(86362001)(6916009)(66556008)(66476007)(8936002)(8676002)(44832011)(5660300002)(52116002)(6486002)(41300700001)(2906002)(4326008)(6666004)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jSQqf3YL7cZg7Oo79ojHnB1gzXF92GRYdaDYiDFHjI1mYYAFAxvIairqF+pxvEp4Ao/qCtQeJ6k8AKrBLSrK502DRy3tBdWKdHbSx96gxmuUV2izB2JX2M8x52+ymMR3O3B0uTn3npMNLWCedCE9ULBETUkFQFX7CYruUdjvn+7E8DzpfwXTNnr/uDZ0bga31VHv5pFgfn7Lg6cTsgIc3Oyu4Vu+hjMfxCEDV9RSE2x4vRW000ZMOtE6l6dQyCR5TZCnXEF74n+ip+ggLmgKS6d2FxRfLeNaO62Xz8944/s7YxMxa+lSvbHhCGEX27SPfXPsv59/Ye4lm6GP1N6KcWqCqnzvnpvHiS1AqvBmctWfexDBicsdO00CbvoWf0bSq+VidKQNXxKhIUjAz8kHWM+BDDxDgWMbP54B8uziMBSiHl6Xxw0DSYqkB83JYW7p8CQojGf5ma5HgYrjFgO/RvGpD6N5WVCyvi8XYBqTBOzqKk1oaGE8r6S9rYzIKHCIXGloOgCowIVitU982HRlrjKdVoAl76prropHKQJUm+k5mschMOgLG+6OuzNIBIB0DLZY05aGyLQuz6mAVyktB+i4C3nN89hYH8ugKp2o9a001AIf1weQGBxz+O9SdIY7W6UwQzLxUxm3o/Pr09NzOKj7haOnNWG6oq/Jna4kWSuZZ5RBMjQNMzLeJwi4vCi+Z85aGmMMKdA4sWCHH0GYKWOUDoFU/AGQ7SZmDtxZbJWhA3IBBZVqetKZjTZk50+XXv4uerswuIoqmPUigKV5bV0IRTe9LNBvWC4mFIUZ3jU021zkNaHHTu3wndUAGiovUiLqL3f0mPyi+ETEtXEXKqlMU0sHSB9wnTcyfbPkOI6BkHYWSEEcmlAu7jP2uNbyTzpF3EKin+zu1fn1uex/Zeo177M4zKU9RTBgJW9zdUY5rJ0dpqq1yHl2KofoCjIu3UvWgO8XaOZVAEp2jwwgS6mqajmJA+Wd193jyMbCEzlpz5Tin6LcXNT2l4ZmsLYQiSSnke6p3f/7QYYkAjOFt+2y9xWtmF9ds9PYxLAgGI3xBN6LQsL07RJPYpdALofv3l1UMFaKHVSgWmguWJ2epk4lEMayXEkJqK5GXq6W/1IA7zKCasuPGfSBOcbUWUyKdCF7MTYPxy+6foneFAsBXrqWcTBLiVXRiMqE1RYCpN6uf87K25HhQ4RGbALrRnZcRBr4U8B7/XQ5YPmeAQYtbD8TbbxQwkSbYzKdcAyn89K9fCy5jvKC6AhIBxNNXbO1gtLb0Tt3EIyX5OReHdApbblPLwrAVGWoQzY2lULkHsq2t2misq10om8ks9pQGPU+QfTdk21rVfl4cu9HFGOwA1DaXycJJpNnOeMFYea9z9zCDiNfhyWQM8oc/sYD+c4MBa16wAxtlQAW9TqiR0T7QF5L4XFSSSzRyuO69YTaxnt91osYoDkcKSFi8XH/KuOhP9q51etnG37z1QWrL550k6pCh2ZCCMeBOqHT++C5YTBwkzRJwwHPBDbik5DdOtqEhc+aOp8+6ikZ8qACcq8hZXISoerKmhdAudcdIhyQ5fuELz1QFlqVqrA245roL+QlHlRPDJQdgu2Zp/9PNWH6lQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6f5d360-b0d1-4238-4a9e-08db44a6bf4b X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:31:56.9244 (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: g2dasGfPk/h6GvYKr9K9f0F/s0R3+QfCCj6lst/JZ47WZcIq3bamusB8w6dKETzHR2hth+0Kj8xP7f3MuHMOwDgqgWf/FTagj1qQBz7s54s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6077 Received-SPF: pass client-ip=2a01:111:f400:fe13::70d; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-AM0-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 data_end field in BDRVParallelsState is set to the biggest offset present in BAT. If this offset is outside of the image, any further write will create the cluster at this offset and/or the image will be truncated to this offset on close. This is definitely not correct. Raise an error in parallels_open() if data_end points outside the image and it is not a check (let the check to repaire the image). Set data_end to the end of the cluster with the last correct offset. Signed-off-by: Alexander Ivanov --- block/parallels.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index 013684801a..7e563062eb 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -733,6 +733,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, BDRVParallelsState *s = bs->opaque; ParallelsHeader ph; int ret, size, i; + int64_t file_nb_sectors; QemuOpts *opts = NULL; Error *local_err = NULL; char *buf; @@ -742,6 +743,11 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, return ret; } + file_nb_sectors = bdrv_nb_sectors(bs->file->bs); + if (file_nb_sectors < 0) { + return -EINVAL; + } + ret = bdrv_pread(bs->file, 0, sizeof(ph), &ph, 0); if (ret < 0) { goto fail; @@ -806,6 +812,17 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, for (i = 0; i < s->bat_size; i++) { int64_t off = bat2sect(s, i); + if (off >= file_nb_sectors) { + if (flags & BDRV_O_CHECK) { + continue; + } + error_setg(errp, "parallels: Offset %" PRIi64 " in BAT[%d] entry " + "is larger than file size (%" PRIi64 ")", + off << BDRV_SECTOR_BITS, i, + file_nb_sectors << BDRV_SECTOR_BITS); + ret = -EINVAL; + goto fail; + } if (off >= s->data_end) { s->data_end = off + s->tracks; } From patchwork Mon Apr 24 09:31:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221916 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 40D71C77B61 for ; Mon, 24 Apr 2023 09:33:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsYP-0007Z8-6f; Mon, 24 Apr 2023 05:32:13 -0400 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 1pqsYM-0007Ya-0u; Mon, 24 Apr 2023 05:32:10 -0400 Received: from mail-am0eur02on2070d.outbound.protection.outlook.com ([2a01:111:f400:fe13::70d] helo=EUR02-AM0-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 1pqsYK-0007RT-5k; Mon, 24 Apr 2023 05:32:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dM6SOFogrpR7axsASi5tIyQcLtCSSa8301huXv+dYeXlQ29aE4MWQ2oemGDsrNPB2/liuF7TadwJMbkEJXnFXlLA2U76NZE77FB5fg77ReKr2FWj6JLmYodQr+2/HOs4NqPFUktt/5lohnMyI92zATx8ROQbw7XqBY7G1/ot+llyyQ89jIwvLp4t7pYMHKjwWYFbabH1fGQU4UbSDqQSB6/fZKeZS2lQgl2CKvns1R0ySSaHT4Zk2892JYLp8RYrkHEJhI5CzzEqASljb6mW3l4gLmjK4WXc7rg1SWikrOaOvPvtIbsU3VOe211iCWFFhMpL42C2q0HwI5dhuFvFbA== 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=CawKWs8LqUW9xPfghs3zWz7WiYV7vklzsUxCh5g8+mc=; b=KZEFr/KiLEx37K1mKeb08anhf3DNVG8+vc1vvdfRChp2M+nlUGIgKx0Rmv2cjpNzR/wYkLjO2rYs5/yitJSeLQ75QFrEH8ybibNtwwaPm5sKnswu9M7wpIyRUOXflCmuoloSnQqnWHZcB5iOiZLDkpLCviyWIKGmj3tm5uBCZoCbINgii2FFWCThdZCb7R38ljlfla5uco4NITFB/42EVXSAUEnWRDP4VCeLGC4wgwz/FrEvb2FQhRbYArDMA8pNLia3BP0/qRjshmrxBgaio7w5S+wsVbOtEU6TbCKIoWNf0+vwbJ9mjVGmtNt52jKgK2z7Au3EiZbaCanfg4ikyQ== 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=CawKWs8LqUW9xPfghs3zWz7WiYV7vklzsUxCh5g8+mc=; b=iIgrL8FpVlR2lKn1spb8o5u96kAFcZGxYnG7CU0CibjnIrV3lBYrfe7hIpT0M6gljQumzPPPbRR1+1UFStLBzM+ztjKi/CBtEq37tx52P76vV4Wge/aED6jnQyXNk/81Fur/f2S3nL7gd8vjINWIRyHzFbhuzgzvxu8k3+SiCX5J4peSMHjfTecfY643EnWh1mfXXrN+bOYz/Aok+hCXQqYMTnjC6mgX/+o6NkIlyg9z2xBtPIQEG2Rtp9QsBTdn44e2++n0WriBiPdI9KOk3rSSqS4sA2iZIW0UjIdJootZ1J6Fpy8kE5T+aCGYkWl172LDaEkbiGLtZrDcIEZPtA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) by PA4PR08MB6077.eurprd08.prod.outlook.com (2603:10a6:102:e7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:31:58 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:31:58 +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 v11 02/12] parallels: Fix high_off calculation in parallels_co_check() Date: Mon, 24 Apr 2023 11:31:37 +0200 Message-Id: <20230424093147.197643-3-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> References: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0169.eurprd07.prod.outlook.com (2603:10a6:802:3e::17) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|PA4PR08MB6077:EE_ X-MS-Office365-Filtering-Correlation-Id: 1fab0470-d323-4cd8-8e4e-08db44a6bfd5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x7LLjs2wuulYMd9wC90upQY0a/BK0ZtDYwYUeOZAb/m0pxxUSre+RTZiT9RtZNxeUFr3xkm4iqbHzoY0DKfTjW6IBs2Fqu6dbelX8AGYmgamrN3ulWuD6VU8QR5KYdaxsSKf+p1k9aRfSPw+h6m0/aP3WSsIeGahoPyLnr4KWuDPOepfmOVThWXWCNLrioTFsf8nKNojS3NNWktsTw+/SoFlfOQdDji9vX8vC96yEBYzE1+q340jq+ODpucQkaRrQXY65SUtadzZdYMvkDl4AuHP3kKxj//WzkFxxyc+0O5hq7zlmmMFAma/Q+pkuUChdtep3RsqkPXw5EBU/lRSaUrHEhSukd5Q2Vv1IZuhGSTje2sAs8PsTNw/wyhNDfK2rTB7rfLs9qd40/G8DDzOGxHzuD34rUx88FW8H1OTGzwE0fXlqAavGTUBv8U6e+1IGctL308Iq9+Fh0WSCDObMtzhRQK3FjOeTqXxqxPuOcbpJMOgLVSfnXD48lf0ykdmq5G48PsxjHQABJ9UyMnC4Aa042AY1RJtPq6+jehQY+EXYez4uX5wj7e+aPHBzQszQzE+hrU/SqU0HPUaGp8HiAFPh95c5PV6yxwomMp5LA2AqBKifRMOODqWedgl7g8i X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(136003)(39850400004)(376002)(366004)(346002)(451199021)(6506007)(1076003)(26005)(6512007)(2616005)(36756003)(83380400001)(186003)(38100700002)(38350700002)(66946007)(478600001)(86362001)(6916009)(66556008)(66476007)(8936002)(8676002)(44832011)(5660300002)(52116002)(6486002)(41300700001)(4744005)(2906002)(4326008)(6666004)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TKEGcbFbLrRXqY6ngf0Q73LWAItk1TKU7ve25DtB0mRyBaI6urmPcfbemy/GotQEIwDCYCKlOubUzKm4jx1b7tvovT34HTYleLM1mi0oKSip6YHMlhobAQO5J8tjK6VeaRwRtI8niUwuULHDkHxjqaGjdud7FCcX8qsLI60J+/0yO/xgkRS9oP9CKVRtawMmOcNhaBbMeioofx9ZIpZQKi/ToXGY6xG4WnZcjvCyQJA2WkJe98bP6eBXTktGepEPLYKuBX34kH6Rhjxcmyhw0A2VNPwZ+kJ1NiSHpC5j5O95YsP64nw7+gs29dZ8DRkqg8I7yL/amINn6iDsrHoU53M3zdnnvenrBIsTu2EaixS8ajnLdhf6xKxsZGV75a8sJeLUtZMNnoC9claz24QCUlpUG5dcTXkYdwkPL/TIajtOPIU8sJJCZckjGyXXwqsbPsDp5yoFNUMgW1qIOMM1wlWh/WBzcYcvgmYO+EIyrPZDE6H8XudTk7Ztxtqdfsa442BmYdAsEtYnHDRUadRscfQOENYRzXGQ9NOoHiznf2yaxYxAL9lIEtkQmVWG1Jv6ELH20TixL4FFLSykbbD+C0f0oSsHRFXgB515kBBhq8eRm7vQ3h3sWziVSeavIdj2mTTqwG92QiQcVp1iRhwyUBvRbyBxWtnnM5rw84Z7GmrgUgujkcRlv2y963CclKJLiIZXe5ppK7MyzTctWJJlhNPe78gdSfGrqKojmw8bkryKnNc54oP/yZMuYmwdOKQSa6rDBvfpPz+IokZvAyA1Q2Oabn3e1gNMYtSiJjd1AdkLRo/0DEWh7beF+ksqXg+I1Mg5lGxLhfjBK6M01O0kifU1PjZN/7VAt0fPX3CXiY13UyIqLChhGvdYzYfYmtIFsaA9K/NC+Vl4wbxHVcrTPpx6qpbHQfsdZHCF+LgADfBSOZTBkQSFU83xnUx/WIUhz9lNS9ugeYuC9e6Rejp2QRvhklD7IR8VCRFQDRj904t5IssZ7DmT6bAlQudLfMEcfOXrMIoQmS31evMyqXFdeNjXTvBN9J817lGclYJjsy4qvPkQQT4sgQYouZGO8r103k0oeBNniSPDlD9SoD0A0RqfS/k9eQizmFV1jh4aezJiXnZZ3248gmoE2C8hEqGyHxEo5JimtgTlW676OhAlJA4H4ZmXwk2DBeWs3eJ5lmmPOleZMcidY5AF15jrX2wILWFh6pZLgY4WRseEXeW6suVIDocA58uh1/PJ76yeN/FgauAxFS4+Rh5Q+r1CLtkncxS9Bn0PZtIYP9WK8CL497fc+uvCmqBKByXY/ZKpk3Dp1DrKMOvSp2XseeSUiu+xATDGnOJMOmCzaYdI+TRP2WLN8xlZZvpzh1xZay3PocRC1pwotgyknnF6wm2ccQqJz/T7W0szlIRfQsR4oLbpDrvvfsSkcxEczDVhnOlmBH1do3zmGUahQAVKDYLNKODR1p7q3T6Pl1uBGkMNxcbafV89yw1U3o3jDrmRst/IoQFS36YaakSDfaVILcSDAqrCm7/qdXgkQaNU4FRXgnbseh0u8yHIGiJfjqXYEBm/Q1hdqsviLGlU0zbXohMOVCofJsb1KSRLCSwEQXo67p1sJA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1fab0470-d323-4cd8-8e4e-08db44a6bfd5 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:31:57.9532 (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: OQmTt5nqtGMIh/JvSta9CpBr28vtqGnCf7d4RT3W6HNPj7BvEcePLg0/W+8cR0sxbvNBjoy3NB7VLcsp81QwmntVyYMFrobGBU4UYr+KMnI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6077 Received-SPF: pass client-ip=2a01:111:f400:fe13::70d; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-AM0-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 Don't let high_off be more than the file size even if we don't fix the image. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 7e563062eb..4d6284a314 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -462,12 +462,12 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++; if (fix & BDRV_FIX_ERRORS) { - prev_off = 0; s->bat_bitmap[i] = 0; res->corruptions_fixed++; flush_bat = true; - continue; } + prev_off = 0; + continue; } res->bfi.allocated_clusters++; From patchwork Mon Apr 24 09:31:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221920 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 68C55C7618E for ; Mon, 24 Apr 2023 09:34:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsYW-0007gJ-6I; Mon, 24 Apr 2023 05:32:20 -0400 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 1pqsYT-0007dk-Db; Mon, 24 Apr 2023 05:32:17 -0400 Received: from mail-am0eur02on20719.outbound.protection.outlook.com ([2a01:111:f400:fe13::719] helo=EUR02-AM0-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 1pqsYR-0007Ri-IA; Mon, 24 Apr 2023 05:32:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A4ThMx9wnK6mVFv7RchkkElAWuRWocsfrDl5E4qQS4NaEnqjvcCuxV5u7Zecc62AwPvuzxU1n7jypKKfovJKZls53aujEhBhPjXC2tWV/LZHUkU2stI8k6sXXuYvdiy7Qd50qZjbIHlXzxAMTHuCEuc8ZGiHkma1x6vZwXtyTxA6K9EXkPUyCf5U7crBitsJ54nvpCIJQOBnWG6KT6x1+5vA69+pAo0eeKrDNH5VQFrzhZ7Ku0CqV0vUTrngbozaxNQYtQawLnhfCy1YyX4gjmX3Lslgo4KhwMoAy7clv4JSe8fErLKAw7iiqEWmOBtEILXAJZJz6LMJYDHO5dk06A== 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=zT8W6VkfskeNZk+bb6qA74Z5tZiFUW3i0tPgZQDqOfY=; b=Vpp8avFnwFb7TRa94E6JuMEPjAlSD5MknnAWC0gU0kbZPKQXmrwdc54c9LwBwNd8PEVhViUKw+2ZlWTd/rzyEXhVCUC9RLOJqkY9k7Gs1zyAzMfvFhIhjpn6JLtbHnSuhYpGs/ovhmAMWsc5tjyATi+jH6brtCwP+yl59FGfRkEJYk/28dpHqfpQRBM1i8VP5poYePV1I7Hj182UDsH++9/d6X70t1hO1p/j7OpdcliVk7B9x8vc2BavndEC0tNkaHkfeppjPXMUxrHiNp63fn3d5nj3mA9JAOiKEoIry83eswXSVhrDxrY5x5sVkNkSgM1hrrk+yeZb6Ti77TJhYw== 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=zT8W6VkfskeNZk+bb6qA74Z5tZiFUW3i0tPgZQDqOfY=; b=rmlzaaA74aWce+h6FNrW/l3c6TP400D2954Gc1myPyw7/AGaY+qImsmZvIiaGwPU+bqqpzBeCbzF++ihJilVh0NOY3/DnLNbfg0nIG5bwh/sKsDU1sSAqMNDeD2JWyuLZKSEeqFtjKEa0MP/4003e21sk88vZRQfQNbCKrrWVazua8x4PjUCEMsR6NHuNj05y6ogaCwL2D8ixqcdQzo57Ti1bmjvMcTikWeQRlMXf/H52cVvnAS7bWr5j6NiWr/MAvOQfdCtY+MtWxQ4U0ZioqQjkndmqQZzzeGrtuis7zE+plqHr7+ppCmrfmwWmis26lxNALypyZCNtXIGg1AyAw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) by PA4PR08MB6077.eurprd08.prod.outlook.com (2603:10a6:102:e7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:31:59 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:31:59 +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 v11 03/12] parallels: Fix image_end_offset and data_end after out-of-image check Date: Mon, 24 Apr 2023 11:31:38 +0200 Message-Id: <20230424093147.197643-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> References: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0169.eurprd07.prod.outlook.com (2603:10a6:802:3e::17) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|PA4PR08MB6077:EE_ X-MS-Office365-Filtering-Correlation-Id: c7fb9c11-ff3d-42e2-9f42-08db44a6c0b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UEsuxPUWngzWD6+hxSIzH8IQeB2NP6tCjH7stilFHEuLvHDGl0iGWf9dy0itCzSuChaxb5OwO7CGda3A50nXIqTADNMvk0DxJgf2ZA8tnIbBU3S0t0xS/mmnH+yFSMv+AsHc/XFDmZ/zIZXlF1cA3qaiIHndLI8H9xVsuJVI0+2l6vQD/AtjDuEw6ei6j5slvSGZv7mVmyiqLdGSVfOUkc/lfsumwEOed5pTqsvJYgvVyMdn3d5hpBsolhicbDTS9iVH1cSc+A6Yyzp7pG97r3YlJUKGByDJamQHFfo98wFZJhgtuSDKoyEHf+oNUsAfpovCpQqNLCvym235f0bbmwGES7IgJ7TPhXZlt30l/at0DmvjrNVKEhoR5Y4qXHaluS2pcuXF8t4xZW39V5DPlPMHR4YpzVv42/VyL1EizY4tuEP3lwk45tAIWDBl6SFn/0N/2QIhLoA9tXm0hXoQN2oTLOJxZDrg4M6apvzBpOnohO8heJ3zaCXUXNW5BVGl60LLOt7bpPobnpiiOqhj/NNRHTeinwVFiO492aViJa8RXZ41xhtlyUARcQeZWQYc+AqvB3o4yvMfUQdSDqoxCpVwVM9as6MooNxC8aQl0Tk13i5JPqgz7gmxEYWoSIhY X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(136003)(39850400004)(376002)(366004)(346002)(451199021)(6506007)(1076003)(26005)(6512007)(2616005)(36756003)(83380400001)(186003)(38100700002)(38350700002)(66946007)(478600001)(86362001)(6916009)(66556008)(66476007)(8936002)(8676002)(44832011)(5660300002)(52116002)(6486002)(41300700001)(2906002)(4326008)(6666004)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EtHYYFXP98m94sOu0HxHdoNNKBqRlxwUHLnDFP7R+UPtKhYVl4l+52Cfj6s2PXJH5ccQUQYPqm2sguR2FCQgoUogep/ml5sB81LQVmURgoAjUXevNqdAxlkT5+Y0MT+0cym0hW3unxgd9jsnFyfzApwiVkhhRv1ugKY9pP5NV88LHa0hpWvNBHuO9hLYg9iQmDrGClWYizRnYwTwWAvmoIC6KFk/VzJJHmQI+KK0vPZYagatzDC5lBGSo58gIWY3HDZAVCJ/z/sv2ODemf8sseAz0om9bRhYyKM0g9FVyyPFpsR8l37eo4k7f7Pu4RIyAxM70HmzHzFwm0DwrW+Qd7gJ8QKo6oRCeLOiv5HcaHquE7Kr2nZfj75APZptJMWHWauu0Z010AOWW5RXK0+vfhIRYmutQbxEJuqKWpjk/iSjMg+aih9YD5a2LQeEwj+lDNhD0lGMrlTQ28vM/e3l2AiJFujgGwahQk1NA9UJCyl7G+W3tvMjOjL9AwugbwIvL+rFvii4mn1o5DQlrkzgR7EfyJozyqy6SG/SYqwSpTaedxUOBbUzI9EB6+GERh+7VpH9DeIr2L+MB58bTBpT0mXd3E5zaHtjhMLL6y6dYdFHsPKXslZnPtWc0Y0QbyTS/zRnn5B36zZuY++BvgNNEjGAKJeWbRRMnIfHQj8i8Vwa6cTGJ8+yHWHZynWbnYU3NxW0NJ0TMTrinJy+RVciPByRn/B/yR1K5POt59DZdwy1tQIr6H/8vtkR0/dB7sxskAVoNVgpuCrb5FyjA1yLT/RaQ0p+OA8TLxaYg5AEj/z9XfrVBkfDO+VbSevdrftK338/WKD/qnJBKX9zf1UlvHFc0NGNnYSIn92rAP6R5tUnwOFWW3UYVwBnwjLapG9DH3yo/f76ZWOy0MXhAgbWGM0R0RUepAIjkUBSfJrZK2WdiuatHPonoYac7oBNS4MfDcmRpnxK9YHv3duxx8lkNOWNdXAtOmzmgSDjLjT7uUn07ry6chtBQ1Xt18F1FyEZuKssrNkONoYnUIhnSV/GGW1DwfPsqtjBxp6F2ImrLEWx9C2CyQxAeFZqa+lOiS4zxk8Kp7WAC9UmbwYA7T3l/Ve51uf8pOAKFI32RwZk5IjwuAwmblz3fVEug/yBSF4ibG46va5yeeVNyTVjNOf/jvwCROmwUEhYR0yV4aYQZFXGf7we/M8ZE/3b4x8Vz9VF1YPy3zriL28qwJwJ0haio7SCEBTNrj3iMKXvIJJZbTGQHy5DGCTO7JJYVKtyKQ/dYxMGJQccp+6j/6ZuiQ7N/HuYvT0IH+hi+3TyDLn+IadsviyCJMsgKSaidM24gYV7+a8kGRMF3L6AgVZ+floFVlQ6dklN8dSoa98ts1GzItCA6dizn6lvcdFG8886dCl8MHl3m5sNkztdUMq44sjB8dOC4PVrqYQE2ZtBAVE/jcaVCym/+/fL2txG5M5rrxx8qocwQ4WKtlYQNu7Bf12XaQTLhZm0xEUQdtN2EYzLIJqxVKwcn89zCMt+l3VKl3UxMHzmJA2RYc11YqLLWXrhCVDFzsts/xSrrqgqowalNZoQLD83v39dS60Wxq5mhCa1GZC34ldtwUm4YRWdLHbzOw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c7fb9c11-ff3d-42e2-9f42-08db44a6c0b5 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:31:59.3313 (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: cJNXZGXehF8rvMv++KswJos8Z65xlzcskn8Vtz1mPnrhZDQfz48kzZn7gjaRKCl+e8coVXWlZx4w7aCzt2n/2cIHPzYu41k8IKBS4YLR7CE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6077 Received-SPF: pass client-ip=2a01:111:f400:fe13::719; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-AM0-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 Set data_end to the end of the last cluster inside the image. In such a way we can be sure that corrupted offsets in the BAT can't affect on the image size. If there are no allocated clusters set image_end_offset by data_end. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index 4d6284a314..dec4fe1f06 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -490,7 +490,13 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, } } - res->image_end_offset = high_off + s->cluster_size; + if (high_off == 0) { + res->image_end_offset = s->data_end << BDRV_SECTOR_BITS; + } else { + res->image_end_offset = high_off + s->cluster_size; + s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; + } + if (size > res->image_end_offset) { int64_t count; count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size); From patchwork Mon Apr 24 09:31:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221935 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 0B820C77B61 for ; Mon, 24 Apr 2023 09:34:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsYg-0007oh-Pn; Mon, 24 Apr 2023 05:32:30 -0400 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 1pqsYW-0007gg-SX; Mon, 24 Apr 2023 05:32:22 -0400 Received: from mail-am0eur02on2070d.outbound.protection.outlook.com ([2a01:111:f400:fe13::70d] helo=EUR02-AM0-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 1pqsYP-0007RT-3z; Mon, 24 Apr 2023 05:32:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SSC5mz1nH0x1R0tQ6DlpqnaVSn5xQ72Z5y26TwSWgUw3AypWHdsu+WILFfR7NT7ogaFcqcpwdTKzZal2DfkpVCEu5hRFFfkpHLOr1Uyymfl0+wtJfM3fc8RkEwEd2WOp3DGBqhcPw+H2lwyFeIf1bCUPKRYqMEtbDhD0qWezyHILPMp9+CmbggTw1BH1vzXTdeN/ksHuRbUrxwxMZ/XwnfXj2nIt5hy58MmfsFHbqETQblI96kU6RaltbZqCyyUdI/WPxK1rVx5bzd20S5n7bqQy9A3Wymhayf5/L8L9KAiyo1C1+sTncOATa6BARHZ+6aLwZqfpcJnPGBoHK0Jjmg== 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=4K+8ywx4jiP8ZR36s3ypqHuxr230ENxlQ6+8WzsL5nA=; b=JtaKGSpGAm+ygSNtsj5d+rqMIYhmpQtAHBKS2QdFWj6OCl19YfEywS//gUk1OJQW9/MN258TaQz7t/w3xSfEynY6vGLu5vZ62fRRVerI4WO1m//HlbCnDcE/SfC/5ZSWDb3o3gbzlfizBqQ9B+BY446VrHni0W2A0ZWnyFrK2Jd/MztgxE5DujNypSVCGBPJI3foE9lZr/XTwO0CZqzhnolzYbISSyeWy1nbTFbFpcTMQUgU8ubsp+Xr8JOxZ5FLhb9tywAsTrhqFeX7NILMK+F/CDhLbtIN9j0yqTpTKoUiaRj5KtrAwmM9L450KglGXBd4igVZZ+1PFC/rYu6lnA== 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=4K+8ywx4jiP8ZR36s3ypqHuxr230ENxlQ6+8WzsL5nA=; b=B8LvoiCraRqmZkUPZQBv3T2v0rckoQ9Ni1ZJ9FBWjwGQD5QvAiaSykD02RDgGlHrrNMETzcrb/VdMoYppEG78tG/k0k0iTVj/yEDQHKRSTTT/kKThqcfb5Ty1PEj2abZJNLCb5ke+rB5YOZNaGZygYRLpxfxnJwolIXqV/Pw+ewf3Lu3fZBw9Jb8b9Ouj8Qk+MTTfEkSOYabHgcr1yzO0yuuAf0CgxjiWKjScSmrQVPMygF8jwbpa8XSs+5M60NJBWfJpzAsOgHegWukjF/5idow7b5G00e0shh1ILC5S0iOShLBicoxxeu5qslSw/vEVgtqwap8UVRkaF2CkOw4cA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) by PA4PR08MB6077.eurprd08.prod.outlook.com (2603:10a6:102:e7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:32:00 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:32:00 +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 v11 04/12] parallels: create parallels_set_bat_entry_helper() to assign BAT value Date: Mon, 24 Apr 2023 11:31:39 +0200 Message-Id: <20230424093147.197643-5-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> References: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0169.eurprd07.prod.outlook.com (2603:10a6:802:3e::17) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|PA4PR08MB6077:EE_ X-MS-Office365-Filtering-Correlation-Id: 25bb54ad-c229-45ac-07fd-08db44a6c166 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C31VRbAN+ymebqdMSwf1FS8MEPpxf+Kx1px0Vt5AXZT4sxDRMbohGbibE51UUm/wxcHXlpi6/AR2+TVHB3eS+3iWi0QR8FtRUhqJgl3u/KJCmOHATjRp7TQOsla+qyHeUMlGt8Eg8jL/E0FN3B68aPpF44cbns2PxgFX9HkEVVe+qhOqsDsL8f+btyCSfJIecOQ0W3Eq+ZUIeQIUjknWW4M4ujEbdBeNKAXVZSEDtrk8FKlfjjMosDpMh7eqNR3D4MfeTvX8R5b6arcl8boMMLH5gVYQ1Ie0j0cmpb4JdIMH3veCqiOC9XQOsKjsnRTLoxbNNeOHvin+4C7+YCN36d9os4QWp9IRaobzCSvdHK3wG+JaFmFdhgx5HIFydS6fI08AV9GpKzAWBLZNj+oY3I6eTQnImmmF9WMwmcTBiKoF44q6+DLWfjM4skmCaRPa4+jAvi/67+EStajeU4+leYBjVVaudksOw2fjxBGJeyNhJNlnGkH+x+C6psbn9cHMbKzb6JbucIgKXZ9zBd/tDA0+oIuD/AGZVirbjtZkni5/hown+OZPslzS9wd62J72r0OVzSjhIRQy+StdxNMc/vzexd1wy/VsC/VjEqo+YpGPOkOOas7Da4grVLZukaAp X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(136003)(39850400004)(376002)(366004)(346002)(451199021)(6506007)(1076003)(26005)(6512007)(2616005)(36756003)(83380400001)(186003)(38100700002)(38350700002)(66946007)(478600001)(86362001)(6916009)(66556008)(66476007)(8936002)(8676002)(44832011)(5660300002)(52116002)(6486002)(41300700001)(2906002)(4326008)(6666004)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tQZsfHz4bAwqIe1Pl4GM19sqx1TkM514tWExYrNd5Zvqr2iGBIk8LKMNOIRlqK8q2CS3Jxf0lPLyEYSj1cWC0kDeSMhQNrqlb6GO0r7ca2aumPKDljzLAPiIunfHewhreRKN5Y1vt5ggk23fwhg/TQnV0MAUtqNAkdJCNtiQ7Mo2ExI4Mnq7xrRSDkmeCNOxBm+skYbbDuhfxTo6V6tVMaOSa7jyLfNQ9QGPw5YUXJk/GxpVOwY89BLd6UOX60oOtQQd7umBUx5J0C0In0p/aESm2XbJR8foGmlk8rfemhhrsq1H+ZQQ0iQugCX8keAgxv5AnczmLfIa829d6SWj2HxZbDTbBbXxCsFUjjJzTI66TSZtrNx2fTmSR+J46aCVKRyVyRVq9p8JHQhyca9mDJCJTD93rlTO0/ZV/gJHGUdxY6vwtTb9xZw9r+T7q0FtHrUVUXJbLDYFNhoReZhv5AMr5mWu/0fWjVSY6tt9u+Rfiqsyo4oM8atcLsAGpbpeOMBd6ovrvHwsVeGa5bDliH5OIhBH3t3KI3BwSQ2Wm73sUx483tSl6hAVgxztQYP/50FPR+YhW9wc9woQzKlW9AkwVN7tjuSP/AhKeq1a8sHAe68SB1znFEeDnwiMseahgjtQCY9v7dPS1unp9bhyflqhCs7/hpK7Epnor+G5r2bnc21QxClwueq9MGtg3gv4k24EOx07mn+S3VdKaUhGjXwnk00hJ+uFlxnqQd9GUfYYyOEuO0OyhwbDAV/1k7nWqK6/SvRZ9XEq2X7Wcb+Y0/4GRGJQCL2UC5+OZjygHr2/2tPE5E9QKTx1846CjPaeJerNSkdWTvYBWyYxFhhEYa0E6I2dJufspTUhs45Wh3rKfOGELJDqYTucck0R/x0wNCe+cPWXatowAHk48vP9drirpdd1jg/f11X+bylVAG5UEeaKn72Pqbc0WseZAVzrLrZxP7wZE1wkD8+I3GW+AolJhYwSJaQ5pSloBs0sxI9WCtOz72ykyEDmK9rqLnNTC8McVJ2OBGUGD0P+OCnJRkm0jy7s8YfdO3RjgIkCNm0Y2C+4K8Usfc9C9P2EgFRae59LHpIaMPW9wrJjl2OmW4SE8oWqg+/dQyT2iAaxUxAXDCqB4K9BnAmxrcFBL8pB5ApuUsWI0I7PXBY30kyJYIsS8KOho7GFXYTX2VvXZ92zqSGKdWPr7IBdB4cMjGdlycDvitZGmv/O25DuoUHWC0FwfxW5/REr2ha/Xt6VWebPYH/y9QfYOtu31xp7qQLfWS50bqGtUhHUK4ntTZakjwJDXtSIvxtZWcux/aduNOvK5c+jS2kuYMpMHMb6nG3IrCspF1j2vPr1qMW36uNSpFS2cLRCVncYlUWpwMadpqYTAF8W5bhBN5VmLS6/eoztt5y8eV16rLlh1p2w66rujsyDCNxcVZwhM+LjpUNHND9kXq5n2vHcqJg5az9jwyIAodS5JoNGqpQl4xUjKpK9UjNgGYWplAwylrXxYgfrakeKxb1SWYtcCTUCKoluRpLOOlCqkTePT0QRwE6fzv+DU8gs33mTGJ5oBxZuvDz+lY4i1S8R5f5yXfr+n0zKpLf/9xiCNY699Weg8ALLBOInQg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25bb54ad-c229-45ac-07fd-08db44a6c166 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:32:00.4755 (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: KslIcm+EguEUDfxMuY9sOcJWbwAACP3cWK5w//4DY0oaAwHVYu5T38FOMIlXeW6GkvZuasf9zJqOiw8RHejRqTrVpwaJq3MMqAq23LVcpIU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6077 Received-SPF: pass client-ip=2a01:111:f400:fe13::70d; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-AM0-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 This helper will be reused in next patches during parallels_co_check rework to simplify its code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index dec4fe1f06..14fae04c99 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -165,6 +165,13 @@ static int64_t block_status(BDRVParallelsState *s, int64_t sector_num, return start_off; } +static void parallels_set_bat_entry(BDRVParallelsState *s, + uint32_t index, uint32_t offset) +{ + s->bat_bitmap[index] = cpu_to_le32(offset); + bitmap_set(s->bat_dirty_bmap, bat_entry_off(index) / s->bat_dirty_block, 1); +} + static int64_t coroutine_fn GRAPH_RDLOCK allocate_clusters(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) @@ -251,10 +258,8 @@ allocate_clusters(BlockDriverState *bs, int64_t sector_num, } for (i = 0; i < to_allocate; i++) { - s->bat_bitmap[idx + i] = cpu_to_le32(s->data_end / s->off_multiplier); + parallels_set_bat_entry(s, idx + i, s->data_end / s->off_multiplier); s->data_end += s->tracks; - bitmap_set(s->bat_dirty_bmap, - bat_entry_off(idx + i) / s->bat_dirty_block, 1); } return bat2sect(s, idx) + sector_num % s->tracks; From patchwork Mon Apr 24 09:31:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221921 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 1A6FAC77B61 for ; Mon, 24 Apr 2023 09:34:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsYT-0007eP-PO; Mon, 24 Apr 2023 05:32:17 -0400 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 1pqsYR-0007aA-SE; Mon, 24 Apr 2023 05:32:15 -0400 Received: from mail-am0eur02on20719.outbound.protection.outlook.com ([2a01:111:f400:fe13::719] helo=EUR02-AM0-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 1pqsYO-0007Ri-5Y; Mon, 24 Apr 2023 05:32:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dD+/n9OZqQ+knAk6ZgXRppEqevsTuZ7udNV0MlxTlvaHU0Y8gcLX9mc7taa2X3lWbkO/y8YzWWTBR+Se+jeabFN7gPKNDmedukcw6BrtVXtJ9lGAzkJw5u+/szTotBnxgLQ13d5HSabrWBazLfdW2pKDAwAqa+vuHjXouPBw8fUmfBEAcxuDY4KXG6G6lzKBgwhDl2IxZWZvuh8M2UEjd6MDYY1nDCoVYTAH21tmAqduaWbpt0+7u9jzbpjKbLU3IgOejOGufPNpl5/v5BFgwPv1iwJDC8ixVwi21002trt9BnVgEI4Fib9xdjh9k+9viVR55Z9Z9Z80TVknOP9r+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WEN6uvzL47tJIlWemMWFzC2Yw8mGEH1Iu55bJZSXHf4=; b=jQrxj8IVFVxmZUd6flHid3IABqRgA23OSuj0PNJHmjZ31Iqr4mUnQMcVgyCSU0jML+YIMdtxDX1mvXXAp/EAnZtbk3sgEhkvaBiZBgfImFCWnEz74qVy/9fWejqLTbdAGhF5ILkhsKd5VQL1Jiw4+KdoiZOEk0y3XxPhZx8IiPhEULfXvWfo4mg8RHgC8ezBgwT09dD1xMOFvbU1ON3wIWZUMPWeQ8G12qwHTrre+JF+JQ/fx/5aV+0QCmBh8VhoQUQvZqlLLpMyM4ezrfQBwIqh9vjZgmFQIdcM1JM77WEHTfw33cu9So1UABeRfWR3Z8Ji2imTGvhZt6KMsOdItA== 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=WEN6uvzL47tJIlWemMWFzC2Yw8mGEH1Iu55bJZSXHf4=; b=AoLvUI+tFjY7ymjf9A2pIdYNwpL5JQnfMZLBMyOsg2538MImBzV7v8P8Tf0mU6v2NeuNThiaoYecnqlZibxckm9JQr0zQceEt3yHWHYKlOX5ckfli2XbAgb7chHguSb6QUwlDlkOeE7+KMyAoDImq6tjhgXO8XPj0YTUoON+cmKYdvJzsDfx+uJmrmMQgRjUuPzF+YWps4tLH5b81MMLzHBR0G13se1UgfWBK/WbCKpQ6yM4YhDEaV204DxFyqVJXsprz2BAIyjt8u08MBv4/iUtIjcLaW9mCVtupn4sZs7qzABRtX1HVwr8RfTivkYAUU8MbAHbDFWf0JldMQBF5w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) by PA4PR08MB6077.eurprd08.prod.outlook.com (2603:10a6:102:e7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:32:02 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:32: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 v11 05/12] parallels: Use generic infrastructure for BAT writing in parallels_co_check() Date: Mon, 24 Apr 2023 11:31:40 +0200 Message-Id: <20230424093147.197643-6-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> References: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0169.eurprd07.prod.outlook.com (2603:10a6:802:3e::17) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|PA4PR08MB6077:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e5b7a60-bccd-4455-b5ae-08db44a6c243 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PhZ3oGyssc2zDoqCko3GQlopv9Iw6Oi7McVoVtInTVNuc0+iENg7Nb7YPgW2cfM5PVRCmJWflv1I2C/kMxqIKClflcsAltGoD7zUSHrfyyEPoQbH6Ftu7Bi4WJ7Uf2zItkhEewCyt5ZykhnPv7BruwwQlw4D2dSRNg0dlGXqsypSdW0YjcDdRJctHS8Qy3eLftCgBcKWvLTV+1SkGBxGIwDczEKhKb1hp73Asp+N2zLdPJDlTs4fSh/mQzNNln22UlR3720UoXn+t1AfXRcTg7ZkBQpqzLU3AzEh+CVH5z+12kQQ2fYOVg3/qdLGYw27i8XFOQ81HNCiUwQ3FuuXcMQer/bbhRBCO6WOFv/iIujiOgKDtPNbgFd47iTLQg6ux7KHKUEvq7yM0lrN7bMQzRq5xBcoWjd0nJhi8k2pd5hz8GpZ875nZXQRE5Llq64ZYW7jbXdqyyTXyfJYxh6XFGt0XqlrSwFUsLXKggOKCHte3YPNnA0GQNl1v7aGyMY7d/+7IgCwAvP99rW0vowj8+du7GfYy6V+NppqYaW+PhicmzM16VQe1587n0q92Cg8xZjtOwGZ7yAnM7maqdntdOJsLhvcN1FPNI2ng1Mf3883P06rre2hBPuvADoW07HV1M8iLMIEFvaDhdS4BzR7Jw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(136003)(39850400004)(376002)(366004)(346002)(451199021)(6506007)(1076003)(26005)(6512007)(2616005)(36756003)(83380400001)(186003)(38100700002)(38350700002)(66946007)(478600001)(86362001)(6916009)(66556008)(66476007)(8936002)(8676002)(44832011)(5660300002)(52116002)(6486002)(41300700001)(2906002)(4326008)(6666004)(316002)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4d0du0Z5sER7qaWyZ95gSKpNAlFF4tAc4dMRjVs1arVq7dO7t6fRaDW47Bga/dBMLsyvdDauLkAZy2cdmxnHWuQKMj4ioSibokUc9JZ1NptSmHS7jNnEziSy2QU5Mg5HzvSc0ykZYNtGtJFcWtcKI9p78Rn1Z5N6nZX1by+zxZODBMQUZEQWb2zGswaRFXVazuJsK6VkST4JLdydLtmPBJBnQ/jY5Q6Geb5Nh2aXCXMyw8rbAs8VFzYFxjy4mA3GHzDX83K7v3L0PxnnpIaxOhmjFzb2miCEd/H/fTmoiNwrIZIrEeMK7fbjSJOTmapUZPmmmLaHhMneCVQjGk2ueU/7CIYg5oBKxk9sgKuARD7QnEBvl49wTqhKhKtzDzJo2GhbZT1afRGmMUGdV0VIg7K3FY4FDVIkmoLqOwnuVHEXcErBGj0Epi9k0gvLJdM3y2j2uYFgLzJouhrzaYceYZalHvZ9sHvmUuH0h1H+8qwhBLWzH5/H50jy/Qa1/+ZZT5/nJpctPgNmB6tJoYRcNESMxRmIJ7OaOwxPbinSblBpjxDAhDhLD1eo/f2qpl5vx6OSQQKCAIoXea8nTnWE+Uh7TsaCDIskoikvCvrF0q+RCDRNKQKsTUq8yfNJmeMAuW6OIq1/z8icoiiZGr9NjMWovmIwZON9d6GaCKqUtDSX9b/eQZyj31ULI5ci32K61tPOd/X9NSagIZTH6Mpi7V0TsUHeL5NRMmfwhaKaYQH/xQ9p6CvrFjsfGky/u16yZs667JvzZujdqy9yy0gTFsgjf+OmYpc+nzh9pHSS/gVzbcKHkoLPSZv8jBNpj+8FyDIqweYiHT0P/YD3xXVRsM/nzMRwXXk1yCmur8mA2TTXVbvExo/o0EWfdMk8E09vc7j9KZ6cN+boZ/jgSzUspy1XpcvFud+AuOBNYBmlXuEKRipy4F+mdpRVwgoS4++cqx3kVcqGsSithna2LaSVKWi9QnABfxwIyP8q+5nQ8YQfk5L8ubnrlS/w0CkWhqnhH0cyzxBHkgOd5w6t7l3eVkpe9L8YczQf845RN1C5EvJbD9smmlIZVSxEkJ1SCvLI19jp+XgEiU+YS0BApr+MW9DBcr+B0L0KcSc3k7XYf0iW4JXjEGsy1CHNFLCt6HjyXlhL6EWCvXd6a+YzcM6nKXKIOcoMGrbF2oUt4hO1UTu3k7p2s3wgorZnmiveHAbcdOAqx4zRV4qwgIqDpHwerALHn0D4i80aMTYsIU/bVWmWImaHqSCt98ASXY29OQlhgcAoBj2YhRmYqJ04HK194YFzwBtd33N+t4qVpZOQ63jUlgTNpy2tybqwEN5yQJOcKBgBF5K97PKZUOtx8TSoXlQHc16Ch2Egg23aGKqq+pqPwl9xzTNT7kTlJXTFgrTJmunCRrRBdDaECFWGgWwi1tKfxZJ7d7GNFvDghLtd8Cv3KyrUDP4zGrkX/B8kJIOwhylnE+987kRa2UWYmzwe7czTDfX5Ryc5/NQ5c2VCtVLriFzBEPSp1Uds9oUpKoANONHGNuEG4rFYGcflUEWPoSdvt3y5CiEfjj1lgxTVZTNHM+TqrjXGVxHJITsCC9bzbeAip2xODt6TolSwhNt21A== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e5b7a60-bccd-4455-b5ae-08db44a6c243 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:32:01.9174 (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: 0IO/XUpTRlvGZ5l+tvxUW+PcyaDmCoR8ucL0+PWHcGhHG+zwpvnorNE3gJHGqDyTJLyWqG6UKjY57rZka+MdRhYNYK720D8YGwWD9uZ/AP4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6077 Received-SPF: pass client-ip=2a01:111:f400:fe13::719; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-AM0-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 BAT is written in the context of conventional operations over the image inside bdrv_co_flush() when it calls parallels_co_flush_to_os() callback. Thus we should not modify BAT array directly, but call parallels_set_bat_entry() helper and bdrv_co_flush() further on. After that there is no need to manually write BAT and track its modification. This makes code more generic and allows to split parallels_set_bat_entry() for independent pieces. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 14fae04c99..7f076db001 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -427,9 +427,8 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, { BDRVParallelsState *s = bs->opaque; int64_t size, prev_off, high_off; - int ret; + int ret = 0; uint32_t i; - bool flush_bat = false; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -467,9 +466,8 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++; if (fix & BDRV_FIX_ERRORS) { - s->bat_bitmap[i] = 0; + parallels_set_bat_entry(s, i, 0); res->corruptions_fixed++; - flush_bat = true; } prev_off = 0; continue; @@ -486,15 +484,6 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, prev_off = off; } - ret = 0; - if (flush_bat) { - ret = bdrv_co_pwrite_sync(bs->file, 0, s->header_size, s->header, 0); - if (ret < 0) { - res->check_errors++; - goto out; - } - } - if (high_off == 0) { res->image_end_offset = s->data_end << BDRV_SECTOR_BITS; } else { @@ -529,6 +518,14 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, out: qemu_co_mutex_unlock(&s->lock); + + if (ret == 0) { + ret = bdrv_co_flush(bs); + if (ret < 0) { + res->check_errors++; + } + } + return ret; } From patchwork Mon Apr 24 09:31:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221911 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 0FDF2C7618E for ; Mon, 24 Apr 2023 09:32:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsYa-0007hO-Sm; Mon, 24 Apr 2023 05:32:24 -0400 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 1pqsYV-0007fl-DL; Mon, 24 Apr 2023 05:32:19 -0400 Received: from mail-am0eur02on20719.outbound.protection.outlook.com ([2a01:111:f400:fe13::719] helo=EUR02-AM0-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 1pqsYT-0007Ri-Ti; Mon, 24 Apr 2023 05:32:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FCm2wVNaGvBm4nkDnXpwxg11Xh4BjuJQkuNluHcjwV9HxnQWSFFZXTx5kEuokt8Ei9WtFY4SxT6BKFK9nYWTadmqR23dyrQccYmcfsWXlbBT8BhjHSge6F+1vyNxyvo7bjRdsobg8LlSfAG9eKpynZmftK0hlZi4I6Iek0SC1UerPkp1SD+8XX52Ie3C1TYg7U1bWFX3wsnGqUv8dZRrH2zTJEi4FinzwYXqeTAZvTGZmMp5LYt8e5U2WspUuoFMNgF0OtH71eWznARzwezb7olzMqdLORaT9h//5I6J2XpKo55B1wkFxwiN3LMVxlcWb84H2twvOh3x6pWLQc0xJg== 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=KK3P1C61R+xQsw5/2/BWqWPfe3WZoCYaX3UuCzBp0Ws=; b=HLZPlhFntws37K9uDQWCpF8LA0CHPbZQh63iLN6uJHt87FeJjN7y5QWG3PFISwjQmnNmkYlIyfqi3xU2e0MvoFdj82s7Sqo8KpPkFAC99jxY1hWX+Lbdavt+ZvLvEePRl7xVPJMdxmapXQGmqKbaQ5rMS1gqm/xgPesgXlAr8OvcgjDX1Ope0p4WCzgWHyMhtPH3QIa5vuPZbiVcBQ297KdFejzKpTjuUPm/TdRNEW/tSuPi2WX5huuPyZvUdqt3pVsB1UPAARWE/s8KCdjCL1Uu0IwpHXWLoM+Pj2BLjYJ2Os6PSy768w8KMWzlobLrTOKP3EKuA6WxbowyytwCNg== 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=KK3P1C61R+xQsw5/2/BWqWPfe3WZoCYaX3UuCzBp0Ws=; b=h9gug+1qVbOYoGLXDLgnARJwzHclS/f41lbZqkVp/LSHknylLRQUeNXlkG0IqBjOnYm87O8y2EYIwU2DcGOaaa+32GtW5svAij9LOotUzE7MjqXwQiBiJYnX+jHjR6O7DnW30iLJqb4pgCm0RMME04S+MjsYxFFbcpu9hXclsQccJ04TjPFOyM8wmJd8FkyvsbAHhmjPKeMVBWfKX0b5rtATFWfCvSKPeGtf0eYm+gvk8cW4zj5mojvNHQtQ+oP3d7vnQbVLVCl+lryr/eTIzCLMNHvGSJLqdyz8QzPmRIQsQwI/7JxlBF41e+Yi9e0AmB3M69/UACcSDUXSdAxeZA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) by PA4PR08MB6077.eurprd08.prod.outlook.com (2603:10a6:102:e7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:32:03 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:32:03 +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 v11 06/12] parallels: Move check of unclean image to a separate function Date: Mon, 24 Apr 2023 11:31:41 +0200 Message-Id: <20230424093147.197643-7-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> References: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0169.eurprd07.prod.outlook.com (2603:10a6:802:3e::17) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|PA4PR08MB6077:EE_ X-MS-Office365-Filtering-Correlation-Id: df30d951-1dd8-4bd5-8fb6-08db44a6c309 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6Z0HZFxSv3XU1JTT6rT9j950MV6gMbffqn9Ck7bngD5JK+qBE7iIe+Vwze6/llT4+U3mIp71b8JMokAOi8oqwcYP+x0x45ENpToSQEI00QvzKOPZYuwqvI3Q0/UdU8HGLNEBuRqCm5lyROsw9hrQr9DOXRZpwKPc83dCwxvIr2TAAqna/3ewmTWwoA80iybkwkL+WM8Tl4MxUfsXy00G9A3qvupjOitUMviyP1UXoFfhPYWQq5QzjxHEUQUDQnXXpDLBLm5sySiRdD1ikIj9koIX+ku5r5MIILyA3P7vyJpj6VgXGLLtqnCT7ajgIXVxTMSi/stwdqjJsYA3tKhBwt6QOM4mq6YQWSaFrz0kqbAevYqR4fMP0FL1deFP8NcPgkZI8zZ+pFzaWSb9zo/Wcos7jPK3cxwiCG2yU+ljaHLDAxT5dcvnvcofxvKJPWljNAaz6xqI6l1Yrd1/Z+HsW0KKH3WnZQmpyvcP4Rj8HAN+64Szt2aXIL0turnU2LTbjze+Ud2uvK2xqZ/YJKQkWB3Qtn0Fo/nq7yOK+sjqiiWl1N2+AL2Fq2tImVPbDq8dAZBBUbVnMVnXGB0ok+CCJAz1ii/v5aNlrDttGshvlsI= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(136003)(39850400004)(376002)(366004)(346002)(451199021)(6506007)(1076003)(26005)(6512007)(2616005)(36756003)(83380400001)(186003)(38100700002)(38350700002)(66946007)(478600001)(86362001)(6916009)(66556008)(66476007)(8936002)(8676002)(44832011)(5660300002)(52116002)(6486002)(41300700001)(2906002)(4326008)(6666004)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NflwiYO5omqTOmGBHpFgNqTqVu8gsbIhqbuFKsx8dTG2vOgOAoiKMOfViBUilV7bWK8YdrbYxA6lNmff7SzBtfY3H2QiCnWqpvYzOp5ecVB6PtA6+vEJPJILieMm1mlN6GBU7eYvResqktmzJqIc7OsqILia6paR4BlTWoeEVkvSQoo/uoZCbMZ6WtZk1eq6q8F3gZZexlY9VlAiibjjgoLBXcJ44qDRUTdlnApoYLHy5QmIpGk42bJzWdXdJF0/IZUaB9EtXFzsnswdaYlyyXIeYYimK7aYF5zrlw0/ux7hqHt29EeCe2DZY91G4+jFbLrR3Kl6k4yXqdzIxfZDJyQY2Kweo3UK/Xl1AR/lBoFiASC3+RZMgMpvCtd8ekgLssFs6dfA7GxRDmgbwzzl8wbr3M8XPHPgIRKUEudwoDww3W0T5iEw2obGr4J46hcapeSGrq3OtGb0osZT2Pd8kAov5E576MYWACNbjrVDCVR8xKCw1X55VoYLJogxpfOtSgpbbMRROiX/m0oeJCkgllKkhhdzrM/plfP5nphTO4jdyu246J/YExdVO+ESv8wbwZfks/ESbvdJZjZP2linYylNlltNyBGV3G3ue/+AX1FgZJSNS7eNol3QnVs/mpsZLr6OvNLVNtdknqL3PwzaiS0HCIoTwO5z7FjvDCaIcXSbU4EJPlMkA33w604Q6n5TfROyVffhO7FP/SaYnfoFHcr+Qpl6FhovZxnv4blT8r0o2nwM/FaBX+x8dwBpxKy1kYjzemP9rY54IPRP2H/0vI4/WMbGXtMcWKM8xF7o8caVjefcXGwCoUx3V9ah+A6tuplMMUmyDu/bsMO5oZtvHwh/fpRYuE+9xZaZiLJq7vKIe+9KKKyWi/rE2xMNnv3HNplekYmGsO8a/LxMUf1BPMtaZEhbl10/mEOXdxI4wa1ds9fTKT4adoKW84ujcFIZvldLU5i4Gu9bEDf3pWNRxEzUdH4eJRkTcI5H5uVx9rUNZ1Dn+4BwZbKJONrP+slq3I34MrVaX7MXi+D76ilax1aBrOZwgliZp++I9U/xKrueRleTlrf478AB+TSzJjXLcqvmiL7s69kSzN06E6EUl7AIq5aWfzTlSG8dch5/Y6C9fuuF3uXHSaVe2YoTOQm1QgNn8YorCrsGyHWFeydA16fBh2VXY0Jq/LGAfo04183TELZJoqxUjJdrKMc3PnoYK61e1Her7RZQMrjspAMNM4SuoZuejt6QU8XN/1NyQy9Jrjj7C80/FrWbTc57tsbXLj4Pip9oFT5lviNUOUoIaS85Mt8MKQsWjsZkvq+n3wGwb3lhJkhS6z6d6gG3g/8/iFCkloK1BlJa2gG/zfKr8sQPrHrJjA1VtoDIXKSaWI7w1Rl6QWSxkyVSCdDWWahAacUs6TtK++3GXTVNn6XWa0TIXdPEJ0ZxdZWDa9Llb6v1AjSUq6Kea1Na2V94LmDLdJ6sgyKNBoAM7yWI9txkVegVfsReCcwu9OfLpacSB5SaM+Pdnbk2ir7dWK6OWoDRPHFtG0yzcfrYHKNZz/LpbUhyif+jJtZ/3Pn+Ugn9b2YIRGpTQZwYsIfO2mpXZz7s78UbsZN7huEB3IRYaPkpsw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: df30d951-1dd8-4bd5-8fb6-08db44a6c309 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:32:03.1576 (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: 9mj6u+A1qurOXxeY1MhlWcCE32DJ0JQ4h/UUiXq5eQSd3OR2LKOSaNYRv/9/K7TByq+fJVXTKGgNobm1mFhlEpFy5/LcghNf/q+qlBYRXZ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6077 Received-SPF: pass client-ip=2a01:111:f400:fe13::719; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-AM0-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 add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 7f076db001..4f14bac616 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -420,6 +420,25 @@ parallels_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, return ret; } +static void parallels_check_unclean(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + + if (!s->header_unclean) { + return; + } + + fprintf(stderr, "%s image was not closed correctly\n", + fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR"); + res->corruptions++; + if (fix & BDRV_FIX_ERRORS) { + /* parallels_close will do the job right */ + res->corruptions_fixed++; + s->header_unclean = false; + } +} static int coroutine_fn GRAPH_RDLOCK parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, @@ -437,16 +456,8 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, } qemu_co_mutex_lock(&s->lock); - if (s->header_unclean) { - fprintf(stderr, "%s image was not closed correctly\n", - fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR"); - res->corruptions++; - if (fix & BDRV_FIX_ERRORS) { - /* parallels_close will do the job right */ - res->corruptions_fixed++; - s->header_unclean = false; - } - } + + parallels_check_unclean(bs, res, fix); res->bfi.total_clusters = s->bat_size; res->bfi.compressed_clusters = 0; /* compression is not supported */ From patchwork Mon Apr 24 09:31:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221913 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 73F7EC7618E for ; Mon, 24 Apr 2023 09:33:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsYS-0007dI-61; Mon, 24 Apr 2023 05:32:16 -0400 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 1pqsYN-0007Z3-Hb; Mon, 24 Apr 2023 05:32:12 -0400 Received: from mail-he1eur04on0731.outbound.protection.outlook.com ([2a01:111:f400:fe0d::731] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsYK-0007Rb-AG; Mon, 24 Apr 2023 05:32:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FOVOAzRR9sqDb8dBbM+JRhdpngWSKyNv9mGAb0sQFMj2/w4IKAbnqIYEDwRK1l1zD/9Pklczni2yEJpbDRKIuBLJ3KSl+IUFEBOrs/9wTpVb0cQufP6vIrKMknM/gWXdKcv2StfzY+Xj6gYpD+Aos0f5xWELBBQXnLYc3eZ7+KQOz9EaxBqMtiooRQnAzGE3jmFG01p1toBIN6DPaMK1HdFSKrM92RWQ6aDNBleenqH+IrM8vFvIIZ0udX5AyBJCLGp4IcBT0Zxl11tWZlKmWqWtouc+Nx5C7vynkNm0ZpO6JVnNNMGrgNGJiQs7zxKnfdkGuPITtI3GFfxYDyOZEw== 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=vMDOrMQOAEcLzCo+0O8hmjMAoxZudV/fIB8RrFdBEuk=; b=OsRGcS4GRjA05uqL/yVuri3ntElzCNXetCqw7W+bI6COA9/BIiKzvrE1dEQHrcCNq0zlE/kLxg2uVQ6bAe+hnokX5PJjlVzDSO/yMGxypONo4ckX9yTkkkp+dxWqAqGsbH50PlnAW553QHcp+VjPkiLf+ZXaufplfHXRUpQV7o8x/96CW+Rtl3FgvneVxEkTTs8aWjEqW+3EjqiuXjs0GtXIzordWThKqgLwIigjNV0ziCoQrUGHHI2zZkktzAPFzOAzSBCea0xirXuAo75UdDThNG7eHfLTaHjusQxz4BMr71UuB3PTEbm7nGe7pPQ44D3cBvpd5hXMlX//LnJmYw== 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=vMDOrMQOAEcLzCo+0O8hmjMAoxZudV/fIB8RrFdBEuk=; b=DVl4LWCOvkWXq6iVb9dG3hkJYU8KOwstOCNcyYJVwDTAihtv/zyo7kG/+rEh6RbBvKtEx9azXJLssmDmLXWY06gv0FSvrvMhFXMAUSStlDerHBz7Gc/zTK2dlA4FeH4bJYlQ+yfPQrtINO+6mARzZ/jE/E/Y/rqyMKjkzVQnQIUp3VoUGYweMJpk0FypX0wkDMsV9zxzUWWxGIsV2uoqfAEMo6//3T8YpikeL3qhGKU8JquOcP9QCJLsseVcPnSNa14D/P9ujq7Go0tzcrU4nBZcZSWmmKhtqkSlCgwFYLWQFRCWjv4wDI2DdK/7E1MlAEgsCPK0t2MkrpME4hXNxw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) by DU0PR08MB9487.eurprd08.prod.outlook.com (2603:10a6:10:42c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:32:04 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:32:04 +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 v11 07/12] parallels: Move check of cluster outside image to a separate function Date: Mon, 24 Apr 2023 11:31:42 +0200 Message-Id: <20230424093147.197643-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> References: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0169.eurprd07.prod.outlook.com (2603:10a6:802:3e::17) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DU0PR08MB9487:EE_ X-MS-Office365-Filtering-Correlation-Id: affbb203-3e82-44bf-0a45-08db44a6c3ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vRxKZ5K6bRbR8pKEoA3oemEOKGQ34bwz+M0XztPHC/i4joc4NPPOrbteqBmGVdEv+hHoHCV7JfuiiAdxQPtpLRbyy6Mg2y9ZmbKQdoOVdSRbNf037P5WBLmaX0Yfg//EkZOCZl/EKTREmVQWza93l64WDLi/i3nkG4GtD5WH+h/w6tR7/ch/Vi03jQCJHKqer1oUhxNgcjYrWsTkr4s3ypKijpRtKFQtCtxXLFck0fz42MD1H+N65Z3bjtLXfIziktYR9wGsN5b3abj9jU4SUYTT3GJL1+0/+2v1RikOGzbyAsQpEmkBi5Dy9wifV8HdprPRJMwsPWndCmUjhltFgcFBZw0FijzNsN/cq+Ea5/u2Gfk7QeAS83D3kdA4ZQmDoMtx1Q3Bi2WiNDbBsQ+qZT3j/UlqJit9t9gc0HV1qbzsU3TTEjwbvm8t7YF9bwYzm7Qv0oG5kWEiIfsbfPBpWLysC70UmBfRGu9V60ep+Ne1dPaeoGhgasKl/lryKvqgPLECAMTzRTWNKp8yKB+ye29Gd9ZrRdiRpqeZXb1SBCl8yUkUtyCcvLEO3JXkQXpkr3PL9r+H4Ue1KbCy9UuyoZaeQlNKoyeIA+IpIm0JK0Hq1tyKR8c1aZAltIgBfzGx X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(376002)(346002)(39850400004)(136003)(396003)(451199021)(478600001)(86362001)(36756003)(186003)(6486002)(26005)(52116002)(1076003)(6506007)(6512007)(6666004)(4326008)(6916009)(66476007)(66556008)(316002)(44832011)(83380400001)(66946007)(2906002)(38350700002)(38100700002)(41300700001)(8676002)(8936002)(5660300002)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QiQJwLcRY8mWLTwOLsbmiVqZg1omzXHY445s16K7JTghsHH+xOu+WE0+aYsGfOJrQ6u1UauUAKmTYDkK8y5GZfeLfxqQz/HhweAmvZV1E6byqPyxEN5n1dKoavXDhl1DrGiq8sBcxQ1SplYBFRGNwLxqn/aN5EKe5dpOuUJ2nl3PNW6kx6poZNv6N0OqWhaBZw+sDyYWfK2eGpjULzd95Q66bZ3Foc6ppKJLGXiqlfCP9qxjUV3b5ywJEQUGT2buUmfcsGNp+xAY0g6oNlremJ3CdIE3qVgcvQIYHA62PfLaukkvII2vR6GZ9VqdAGE3kXf7Y+NYhamp72QPyU0JM6cqdKt5+hYkeKUwAUnGVyNreLvChS4WpIOk9GWGo+G6CHMhbI25OIEaODl/m5MyG7M8L1UDgtJCOhGuO1TAfayhcw0GO0ullyC0063IlbpA7spJolj+F9bwU6mBVOOV3iieYodu7hnuC1iUndPcHfCcS0RWnjZF6GFnG0XZtPYTZFHqtKRd7u67VzoafAxyLD8gKRXhMJFVnwI+CDeV0N8NHmy259zD+OdLo/vNKXbz7h4d7fL5eDcHqd9GrIKhQZNCLQp3TLPp/eB/+gHIQ6Oyu71vJI4wrZAfTPMDxPlr/PTITSDCT2zZQ7ijDkv3VWKsQr+s6t9cK64hQPqEHljbjbfshac7JoJ6ijEdzdnDkDA6jJB8etjIke0RCyLE9lYRqoep1MRQjroxW9Rneqbi+vJt3ZOYfs07A/vWpqkysGA5D0DLsd/FHnwO3JyuDZzZSRAucxuMO351JFm/9n7rwZ3FB2w8t4qRNt0QVZTQRT73/Xmawhh0mOvJAdAfYK8SRxBgSjhn+KrOX5S8rNQefmO7aYa37B7nFmi6sbfhBoxYDEgJEMQtzq327hJ3+s1r93OqMpUnSdGkh29CowRvsJEa+62KQ7BHOqHL/JRm9IBWzrKFRexyXVWwWVcSncXgNaPPTGuERvLRRRC0qIMuW5ePIWi4gMq/nCoTpnX+U58ExJ2cbtLqoz5Sg9xSAAAxielE4X8WXXw0aX232Fnvj5gkrDyNOykn9hFbuFW3TlSwxnSRCAW9NbZTqnelSv56oJXaqiyCeOb8Ft6efjl9bXVJPEJhjyCXmBxyZUwmc8RlCJs69qs9Pxu0eYsYkT9NbDZGmqBdkcDm5w4wf/02e39/0cMotWVAL+Ke5QqTR3nds5OT+2kUdafRmwLvf8kOqDsx/qKbVT3PLNRlQWYQt0SlEkL9Y6SBy7rJdu7iRCsCbkg2b8ctKLXk08RDQX+dfU2ZIFXigInfOG+J93rrqzTQQPPnIx+c24yS3Ws7D10mpvA6+1dqXDzlkZmOiNt7Aj1a9/4DpYhUkI9Ul6dzusyujolhOjCbX1xdNCBfkDxoI8uOVv0Qo7suHPMZJSHG8xvNaLYtnFCPmvBVtc6dafG21hPhjx2Np/c/DpmHOxoZuHDKlPylBouNDhoYQoGDU+1ngGHFoVLvas2nvRE8+gkmLanyhkU8+Ai+SsH20xFQl1TY1IFcziNHstKBMqtvzefB06h6S0x8MmPlZduLzUqLV2eBnhD4IM6f65EXwmAuiUvK1+ELrxjAsva24Q== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: affbb203-3e82-44bf-0a45-08db44a6c3ae X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:32:04.2945 (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: HlH5q9Z3GQgJdE0G6ADNke8QwtOikTMMfOT2NeMKijIIYIp+phMF744kIPQyVf1H1xudZbiWGCuUGMLgBnly6oyGTRy9fkOCokOOqPdJ4K4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9487 Received-SPF: pass client-ip=2a01:111:f400:fe0d::731; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-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 add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 79 ++++++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 28 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 4f14bac616..8588c3d775 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -441,13 +441,12 @@ static void parallels_check_unclean(BlockDriverState *bs, } static int coroutine_fn GRAPH_RDLOCK -parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, - BdrvCheckMode fix) +parallels_check_outside_image(BlockDriverState *bs, BdrvCheckResult *res, + BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - int64_t size, prev_off, high_off; - int ret = 0; uint32_t i; + int64_t off, high_off, size; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -455,23 +454,9 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, return size; } - qemu_co_mutex_lock(&s->lock); - - parallels_check_unclean(bs, res, fix); - - res->bfi.total_clusters = s->bat_size; - res->bfi.compressed_clusters = 0; /* compression is not supported */ - high_off = 0; - prev_off = 0; for (i = 0; i < s->bat_size; i++) { - int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; - if (off == 0) { - prev_off = 0; - continue; - } - - /* cluster outside the image */ + off = bat2sect(s, i) << BDRV_SECTOR_BITS; if (off > size) { fprintf(stderr, "%s cluster %u is outside image\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); @@ -480,19 +465,11 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, parallels_set_bat_entry(s, i, 0); res->corruptions_fixed++; } - prev_off = 0; continue; } - - res->bfi.allocated_clusters++; - if (off > high_off) { + if (high_off < off) { high_off = off; } - - if (prev_off != 0 && (prev_off + s->cluster_size) != off) { - res->bfi.fragmented_clusters++; - } - prev_off = off; } if (high_off == 0) { @@ -502,6 +479,52 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; } + return 0; +} + +static int coroutine_fn GRAPH_RDLOCK +parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + int64_t size, prev_off; + int ret; + uint32_t i; + + size = bdrv_getlength(bs->file->bs); + if (size < 0) { + res->check_errors++; + return size; + } + + qemu_co_mutex_lock(&s->lock); + + parallels_check_unclean(bs, res, fix); + + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + + res->bfi.total_clusters = s->bat_size; + res->bfi.compressed_clusters = 0; /* compression is not supported */ + + prev_off = 0; + for (i = 0; i < s->bat_size; i++) { + int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; + if (off == 0) { + prev_off = 0; + continue; + } + + res->bfi.allocated_clusters++; + + if (prev_off != 0 && (prev_off + s->cluster_size) != off) { + res->bfi.fragmented_clusters++; + } + prev_off = off; + } + if (size > res->image_end_offset) { int64_t count; count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size); From patchwork Mon Apr 24 09:31:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221912 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 415F7C77B76 for ; Mon, 24 Apr 2023 09:32:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsYV-0007fg-FZ; Mon, 24 Apr 2023 05:32:19 -0400 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 1pqsYP-0007a2-R4; Mon, 24 Apr 2023 05:32:13 -0400 Received: from mail-he1eur04on0731.outbound.protection.outlook.com ([2a01:111:f400:fe0d::731] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsYO-0007Rb-AI; Mon, 24 Apr 2023 05:32:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hf6YDbL9rsRXhLqcbpu1YpFkS0PXGWEokUi/PdNDHE2yqZfXPuRLXt+DEvpUwzPetbzB37bCe4G3KuNPZAcO9s5w5+6CJ7Yqz/3pdZOKHXSfrnKjA4X3ePNEk8a8GqMoRyFe+Nm8b0j5d5RCNKDJLRUk1birUz6sNAlXhbuV1mruk3GHJTe23C8eudUT9X/PS8na3jZE1VHecOc8PkiBtMz4GugLP8QJaMsGiVSTijangHMjQM2fB6VCRoRbCffF90ey6U141Mkd1zNHPymlglmm1tMJ0LXbXpb6G3kITaW9lMkCLTAjVaQEHWdiXmaGgKRzFwevnGD6n4UkEw9evA== 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=YzdUYM1t83GtJ+XUwNuVoTU1WC9dIlfan1AXZqmH9W0=; b=EgLdi2K/Xidup5W/ej4UDJPCr78zNWaS2QIEkoDal7dJXLL7MFs4Uy+niBQpTBwt7mg842NAycfHfkQNgnPx38K0EfmgRVDK/JW0WxcYD/H+eh7R/q5BysT2SIe6CoFv7mkdH4bljKxw6LS2hFvcrh0nkCe85E1plL1KC6HATxQaIi79O9ZHid92BxBkUtZj74+UczgZnaNxrDYQK/N4Ul+sLsKNfzCmdaGLzEBRIjfyWIqGdYqU2Z8rmzJunoQBLqU3ZpTL06ACn3e/YPAFvZj8EOG6ha+gmQl2G7F9tbSamq1WPhuLI08m4NvuYV90zmbduD1g3ZWoU9/UFpVLHQ== 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=YzdUYM1t83GtJ+XUwNuVoTU1WC9dIlfan1AXZqmH9W0=; b=SeeYvFiVVcNtIPQ+Fn79a2ZTt8HdJ+Q+ArUhM7eU47gLFX0SuL2EaJ9XhLYfh2XVdcb023p/vWol9p8BAn9k3M9gGqGjnP7cLUZ0Mvqc2kQG/rkrNQoVSAHBPRu4KKiBVXF7rVd765L4+NoWzFy1DgQmq3mEVmSZveXFG7krWaqjncVL7sZ2MT768X1A85c7P6G+JAF0d+odZsFlQJOcdry+KxzSNlTx6iOS2in005oVAzTGFCp7yluQjXBQyklHGe/O2Oil1/ayVqiQT2QSXxpBY5D3apYFLi/M1h1eGcKwwoszbV2/6WmsAj1Dx/jorG2rnO+bJbTHmYdCX4nipg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) by DU0PR08MB9487.eurprd08.prod.outlook.com (2603:10a6:10:42c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:32:05 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:32:05 +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 v11 08/12] parallels: Fix statistics calculation Date: Mon, 24 Apr 2023 11:31:43 +0200 Message-Id: <20230424093147.197643-9-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> References: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0169.eurprd07.prod.outlook.com (2603:10a6:802:3e::17) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DU0PR08MB9487:EE_ X-MS-Office365-Filtering-Correlation-Id: 415740c3-9c8d-4943-7021-08db44a6c45e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rF9GIzr5CHO/Ar03YtgzQFwDeLoiScn8OymMkbEdj+aqwUS8SJqouqR07Aq1sR46Y0TMsjeWLpmvyoFlkbR9DegxVvhSa5InNANnrXqFkJzGGBFQQVEhmtEGn8uweea1h2MOJQBJMsl/MuAgl2++PqyGgzQjY9LImwdp+epuIeuoha16xr7YVH0HCPgKnN0yJJ0bJ/tEX0YjXJDGYuvm+/VsjUD+4jEn9LONdUpv+iBsTTfmIWNGIDi7J09oim2rIJ0OU523Ve7CZYd+0JWwWo7VHGKLj+2V7uJzwhMwnkHwsrtLs9RHIBU5eZSMcnnwE0GBPsGftLQBeSABS7jj2qzWmwqZ6EyNY0QUc8Xo2V8hwZ0brsA1Bn6SaO4+QvWhzHRmZ5qk+VhiM/2ciMewC0SZtygvegvv/PhbFfy9dajdeHOjKoXJhpBHfLXO92vgYXncP5FtCoOrPbGrZ50R6ec3y1MLTiCsVPhKlM0090Mkc58Op70bMkRTmBPRFmpDephcmic/eIlrgOqCaJlIeXRVjBPkQ+h84JuQSafG7nkCux2UXPszvb5rs6kow2eDxf1OM3yWLzXS0cfKH/ny9a67pIXHIHzzOfw6wjydhZsam9zgB+iOIVEJsjmyY+Bc X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(376002)(346002)(39850400004)(136003)(396003)(451199021)(478600001)(86362001)(36756003)(186003)(6486002)(26005)(52116002)(1076003)(6506007)(6512007)(6666004)(4326008)(6916009)(66476007)(66556008)(316002)(44832011)(83380400001)(66946007)(2906002)(4744005)(38350700002)(38100700002)(41300700001)(8676002)(8936002)(5660300002)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +akkF+k7c0PnL0mH8HGzYFNlKR7ZXPjQ9nGyN30s/agqIU4DfTbYn/0HQ1+p0t/tyXhB76x3IrYisZ12+s7YQqiX9xqASwzGjNXT6nPkwRuPEmIq62lY4lr8ZzFlRLDwFGME62G5z9FAyRBKCLDYb9S9TxIdxFxovw23fY+8060WYPwOj5UFCBf821TMol+0IuEKIbxeStiPhxDnrrPfcmXZ+UzVJdJV6p5dQpOcx9wGwuY2D8Xedato1ITGBPw2NnnMvQyBPuDPvaOVkVbOsmvyMHxqjI+oogem2g8jUFlm1lj2NudAeGN4BQVgTTQF6Ia8YUc23JNZ5k+g92IuBK23PZ8ReBsWHa5CGGEF4MVlnLY9sIbDWek0afZ2XbCLNiIn6pVKpFnFK7SSE6Lm7s/GoRyZVq+mr3bBFifDOOWFdX7LqaENXskvRZdctSppBabhbDxW0C/36ftJ/AVcRf0/xNG2Zdsam9U1KxZPGn7hjI4ARvYQMlz/ud43mO+P598NTpY2hQJerBpW5WQcBbL0YV2lHgVGonyeAHQRqH4LWjNjYHe6W0lHyzfbFI5DsUEHrDdgA5Ekxh6U3RJ0PYk5GbZziivkuYhMLD8azsgdt+6lebnweyDqAKd2h3pQgxV35QBtpI2OtqTVaiZyKkOqMpYn98EX7VjtYOdKZl4SAARSS19uDwkoXNvn3ItUkJQB8pYhWLLAukJ4D8dNvQE6kxncj0emFklO9R+bvF92aLb9iJg9Lde5B9hH6F90YHt59xZ39CCf4wMLxU60oIKCcE0b+hJbck1g9KlYgXvTJ+iLnlv4F6Yj110yDas2wa8b5JRRrTjdwRR8E41EXOXnuCrNOaUzQbsAjj/LKPIgqTdFBoAsW2BPvCZupKHlqNYOtonzXnxhHjpZAjSNDIjFYkRXhIu2nad0Z0xGlRI4nHaVfFlgw6CNTWb2JSEVrN8eYuCj4FjwGE4fanhS+FFxe1Zvzy76Bmjl9Yf5kTZ1XZU2m1CXBfmzzY/9sxX0yHwoTuulWw2+tfHnj30VXeoVn/sHOOeChxyG0KjKN9D9l5ZzeAcwRVibvf6B3U1q0rVZpv4E2QB7R2nNc2FZc4JCFmQVWMxnDJuDV4BVcQelE0cmvFtKYp03KJ9r/CZptOhTcsFnwWSk9XeAp5pQzFyBfJ/K1SS3fYrvzLINYZeSEb3gJ41KD/T1rWzo3x4+EwivKtjD4k6oWPhhct+PgJQZbYZKGKsM+tbUcGErw2GNDZEOxAUMTOjaHFa9keq37WDdVQHoh0Lc/wBAWQPCkox7kAZeEpFzYn9kSJ70xMbVhKNvtqIdUEycsK2ZaXigJZEm7VmN5RqeFY+gYAoF9Igp+QS42i/3jsJ9yx9WvzMnb20Lb5Gq0tKeKlGcU3XPhI14U0sGTvIcEJf9DiFpAdvt2AFDiObsyXxmu+DP3eFBYlqJVaPOPSX1MiREHL88boIB6jvVOwtQaEl7RqAbiZ+GX6el87rtLEuwZEg/xLsfoQeWA/BjQX5EZTSe6YT2JYzB367hqt04Dz/DlFrfkrn20+8bKpDbHCE7EiRpN1RC2dx/y1zPPtRwriiPgaXastuD7HAumqdvaqYilLVYGQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 415740c3-9c8d-4943-7021-08db44a6c45e X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:32:05.5266 (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: p3Sshmre75uNo3fKSMZrfCydTuLVcFEfRm16IjB4wh4VxY1I0QUQltJtu0Td5VF4rSY+/qm28NU+IdjET6IDapq0VfAsS69Y0BtLhSC0zrU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9487 Received-SPF: pass client-ip=2a01:111:f400:fe0d::731; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-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 Exclude out-of-image clusters from allocated and fragmented clusters calculation. Signed-off-by: Alexander Ivanov --- block/parallels.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index 8588c3d775..f389a74466 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -512,7 +512,11 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, prev_off = 0; for (i = 0; i < s->bat_size; i++) { int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; - if (off == 0) { + /* + * If BDRV_FIX_ERRORS is not set, out-of-image BAT entries were not + * fixed. Skip not allocated and out-of-image BAT entries. + */ + if (off == 0 || off + s->cluster_size > res->image_end_offset) { prev_off = 0; continue; } From patchwork Mon Apr 24 09:31:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221922 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 493E9C7618E for ; Mon, 24 Apr 2023 09:34:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsYo-0007y8-71; Mon, 24 Apr 2023 05:32:38 -0400 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 1pqsYU-0007ek-2G; Mon, 24 Apr 2023 05:32:18 -0400 Received: from mail-he1eur04on0731.outbound.protection.outlook.com ([2a01:111:f400:fe0d::731] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsYS-0007Rb-9K; Mon, 24 Apr 2023 05:32:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eAaOL+OcTYkIs4pN3fLoYVXZZ6I/hhBNn14fSCMPidViyT9k4j2msQN3ttinmSDkKiCVTKZ6L8ViR5rnLwnbe1+eRqhHi5auO+zfFa1U6SiYH3/HWC2k2L1U0DlK/NBBEnflOmC9Kx2VMoQQnAx6I+OscziJyg9VYdwhDIFdJAuA9zalhBwXTxJMyTxsJHtblDpZR3i37Uj3eD6yRYl1vZKqrpJoX4vA9+AbqwsV3y1QeQAmFzvL132Eewzvg1f9qgA9CYMjGscRnvrGZV3qB33BMx6MXQBpfv9AJZ16G7FV/bbSwwJazmOSwrWWDhRRU04kWI78dc2yTYqbkINNwg== 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=FlilXhw4n7l5bywa2l+Kq87+Ffa2JsvoDKGDo7EQJHU=; b=JQ9pQi+Yd+Kjw/DE2UDDOWuEWj6o7BMtkp1x4YEHLluct0bFr3fN/Pme6Bko3XDzoTS4gyqZq1FN8LKx9Y9VRJKdcURDS3CEcqSxSN21jPoaUopyKVAVMGvdR2tk6Z40TcAdpmhN54U3tDkBFSsR5ei8POmTTzFpbCXRbmEfRZLpB48NMgxjK2GucYiyzXJPo65VNzhiLpNXMKZSycGp8poC63VcfTXYrkdSZA+XS80ZE4JoLHhS488YNImIHjAQUIY83EajfEHp07/YSFWvK9VBP1/Oxit/OxZgwcdIef/Mk+IeBWOreYyTBq13C2lVcUudiFeLffq9Tu0YxVHbrg== 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=FlilXhw4n7l5bywa2l+Kq87+Ffa2JsvoDKGDo7EQJHU=; b=uyxKWskWGvLuxW0punvQcX2MRF9IvprgK3A/7SXHZfOb8q6eapHBo7vlDTZnmmUlJDEHV3tShPLKRU5W+IBjeVOT3yxqlTIHbqFZfhuqciTTJZE8MHanRk3a8PlDQdZ99o8syQcixc5padHAmA1033Ouq7T/wvy5OOubdVYtyMpUsnOKgoU17/iG+U222TrAud3dUZrwF46DF6pMP8TAxY/UZJ1e8WBH5eHJw8vONvd96kpcl8uMQ7Qv8DIrBp7pYNwze1KiA/nqRheRYrbAKlUSnBvbeUdRJszLXzdgEjxHMMdUvIBDpnigbZ4t6Ep05vrLh1SQwK0nk6ZfpuyMFw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) by DU0PR08MB9487.eurprd08.prod.outlook.com (2603:10a6:10:42c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:32:06 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:32:06 +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 v11 09/12] parallels: Move check of leaks to a separate function Date: Mon, 24 Apr 2023 11:31:44 +0200 Message-Id: <20230424093147.197643-10-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> References: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0169.eurprd07.prod.outlook.com (2603:10a6:802:3e::17) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DU0PR08MB9487:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d693d66-5886-434a-c417-08db44a6c4fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tcGeUyIbiJqXXUi32/B1VAtmkDOzo4N0hkbI/C/u2L1M8qVglYsuhn5R0ykaPMl9Pk3aBw/i+0tYKrn7GvJxiv9KjMOAn4XKH+PbDY0y/zca1hak0w9q29AA6NE69qOozS4RrNqvqWqd+CQEq01BudfS4dK0UWchyk2487r3BiZSZtTnXXXRMLdi7ocjgwOj54rudbPz2Cj+CxKkir8lA4elMWTZEeS/Pylqr+jZyGTzBE/MOnonf6L1eEgGnp93PTwzJHYV+cE/RkND6qq3SqW1jobPc4otUPxcJfzyJhzt2CvhVLfKa05+RVhSSSL87LDQuYIm8TIXchdcd0gHQsLHr+xfG5EYr2erfvov7cn3P/OfNAyI3ngkmySB0ElxTZp1SIg6cZ2omTDX91pXlaw/iImloMfWImP1fFo9h5XeIsghaVAXVNErniub7HENzSGRwAFs8EtR9xoKoRQahHFiy8UcA248t/0NDRqOufBTRvRSSuLJ/FswqXA/OSL1C+b8NetR2SSpwjOqGoZq5EhCv/qza9yyEIDGEN/zENgbpeMokQHms/laAPESHGcyFDGzWg/Bu2j7uRL0nyGvuXFmF3ZnRiYbguHkLSqC1vidMHEA+/Vz73PI7ry2w1sg X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(376002)(346002)(39850400004)(136003)(396003)(451199021)(478600001)(86362001)(36756003)(186003)(6486002)(26005)(52116002)(1076003)(6506007)(6512007)(6666004)(4326008)(6916009)(66476007)(66556008)(316002)(44832011)(83380400001)(66946007)(2906002)(38350700002)(38100700002)(41300700001)(8676002)(8936002)(5660300002)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ssPEkqKrQXGY+FbjiuhRb/zrVWgvinJNUIRNK3HUgG5BQnJZ1M5jWWd0KOH7kld49EyOXsFEoHnhFfiN00RrYyV1CP7kIPA7iq4XgIsQNq9uNVxHJnaGP9L1pd2oCPlYMZ3V6BAwW+zmmjEC00W9GqCrW/GZ6Mq0GK+rEOOiR7l7J2Dce0flE6bwraU3hc/P/5ouL7k45O89Tq1Hq/3aIeTVeMsaXV1PaY0Noi//Um0MrnxAnqixmGsiMWMFL1Lp5V3IsogcqQ+fchpaUHJgzEqLobhueGF+OgbvB0kTUCdEpx0Hty8s6/gYEProZMecNaT/sYwqz6O8Hjaq6evF4hoPzg/oz+GMrKToJWHhH/it6gl+Wie1bPX8v47pJy9Kq5zk9Pb69/fJ0i5iedqDZWc1utolZiQaq15WYu/JWjSUu9h5mLR46QXvC8b192+K17k2HQH8xjbOlF0iChIGgzOjdYGmoehOJ7D64qGc7DMOjLJ1M1r2IKszYrI/R3I9lA9/modyfkl0iJQBd5xrlvruNMQ9BCk1DDNeQmHX3lcWQJd7aW7nkCl+rLjHDLOjjlUtg0AbkDFn4sGfHN0NY/RDZIY63u5TYeohzma259rIcf/8FEb6/q+p6YdKTfz1cKJyNv8Tom8rp1ZWWVP5v5T6gk8BQR+LUJl+H7WiCjdPoVgPTP5AATbWfCx3JZ5OzP9RcHVqIWsm9ViU/abajHdUV6gjm7mmLLxX6sizKcgsK3U3CZXFNIt1b+lWD/BJSxiN9roUoNSOKKPaMIonmMCyDYxJDB2Kler2paVYhHnDEucHLX3ECg0NGSWD5OduZ8vtekc28M0wzIsXzOFnhqAioez01dM3EETCcRjCjMWYal3TJv4g0HSPVjqE7LodQeSZpCbyeBK4aPgDdN0hWxgmtb00HlYmbcaBHHVk+gD47hsuPfUnwuD8oHIaaVEhpnUzXz+e7NXP/7BQLKmjfpaGZI8kfWRKusOXqv45bX6MyB/aR3yraXDIpY0kUf+pfS38j4dMVrStD2GJ/nPLd/GxGU1NaC9wGifZqGI8TbxpKu2rcjG5NTQTG4MvQAvbQuWrd8CYW4TAT4BwHEJses6m93o4fUBX4IlrFyki5ruGbuhdMhTUFEVEWgbzR3FdNKi8SuqvkI80k10g/wFEJ0ZZvJDt4gSLAAyP7XyOpGvZq9K68wEjVZGm4Z8vzoKJJGc0gE5ARIki67SUlbR0/lGZM+F1PGD/clUMnVDUXXiwOTx2X0QTYLmjLbvcABSM89LpfpaQBFvVA4LrqnNXAK4MYq7XnRd9WZU2GKDOahAQIUmh9Cht5sxZFdIQhsVR1WPhcul1GdCrnyjQXYxJVajTp94fIZYUuRca8n61t0uNGU386ls7SOpHk2HrKDbpe765Lp9p7eL0lmFA0t1qjetFtZL1y8F/HwLJ9vHFQ4/za9p0zRNPBsE9xNoWjWTTV86CWDWh1tvF0fg0CkrVFrBRrJwCfPfOLo+atICdiz4Zbogw9Z2IVImzpnreOX6du+ygZErSoxXwuUgzqgQ8zUgWctmFPs3bAAh3iAcw5cmAS27b7RyiCDOufDV4dN3B6Vn9ZoIS6M3d0jTblS5WZw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d693d66-5886-434a-c417-08db44a6c4fb X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:32:06.4904 (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: hN50frffdVswfAMAtrL434CcEEtXMjzWdeFS3zz6rDeTelEwGJDwRPNSQU5YjFCY/l9P4QSPlNUIeVZ/m0qkpGdYtT0BsX3lG/sggL5FAxs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9487 Received-SPF: pass client-ip=2a01:111:f400:fe0d::731; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-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 add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov --- block/parallels.c | 90 ++++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index f389a74466..c3e220b60f 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -483,13 +483,12 @@ parallels_check_outside_image(BlockDriverState *bs, BdrvCheckResult *res, } static int coroutine_fn GRAPH_RDLOCK -parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, - BdrvCheckMode fix) +parallels_check_leak(BlockDriverState *bs, BdrvCheckResult *res, + BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - int64_t size, prev_off; + int64_t size; int ret; - uint32_t i; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -497,38 +496,6 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, return size; } - qemu_co_mutex_lock(&s->lock); - - parallels_check_unclean(bs, res, fix); - - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } - - res->bfi.total_clusters = s->bat_size; - res->bfi.compressed_clusters = 0; /* compression is not supported */ - - prev_off = 0; - for (i = 0; i < s->bat_size; i++) { - int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; - /* - * If BDRV_FIX_ERRORS is not set, out-of-image BAT entries were not - * fixed. Skip not allocated and out-of-image BAT entries. - */ - if (off == 0 || off + s->cluster_size > res->image_end_offset) { - prev_off = 0; - continue; - } - - res->bfi.allocated_clusters++; - - if (prev_off != 0 && (prev_off + s->cluster_size) != off) { - res->bfi.fragmented_clusters++; - } - prev_off = off; - } - if (size > res->image_end_offset) { int64_t count; count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size); @@ -548,12 +515,61 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, if (ret < 0) { error_report_err(local_err); res->check_errors++; - goto out; + return ret; } res->leaks_fixed += count; } } + return 0; +} + +static int coroutine_fn GRAPH_RDLOCK +parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + int64_t prev_off; + int ret; + uint32_t i; + + qemu_co_mutex_lock(&s->lock); + + parallels_check_unclean(bs, res, fix); + + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + goto out; + } + + res->bfi.total_clusters = s->bat_size; + res->bfi.compressed_clusters = 0; /* compression is not supported */ + + prev_off = 0; + for (i = 0; i < s->bat_size; i++) { + int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; + /* + * If BDRV_FIX_ERRORS is not set, out-of-image BAT entries were not + * fixed. Skip not allocated and out-of-image BAT entries. + */ + if (off == 0 || off + s->cluster_size > res->image_end_offset) { + prev_off = 0; + continue; + } + + res->bfi.allocated_clusters++; + + if (prev_off != 0 && (prev_off + s->cluster_size) != off) { + res->bfi.fragmented_clusters++; + } + prev_off = off; + } + out: qemu_co_mutex_unlock(&s->lock); From patchwork Mon Apr 24 09:31:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221919 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 85E72C77B61 for ; Mon, 24 Apr 2023 09:34:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsYe-0007i3-S9; Mon, 24 Apr 2023 05:32:29 -0400 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 1pqsYW-0007gP-DF; Mon, 24 Apr 2023 05:32:20 -0400 Received: from mail-he1eur04on0731.outbound.protection.outlook.com ([2a01:111:f400:fe0d::731] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsYU-0007Rb-TA; Mon, 24 Apr 2023 05:32:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XflpA3NG4jO+8c4ncSpFjJddk+6zpIQ4W6StPCJ87tA7MghKQRkbuLdoAQetBWoLmmjC/fX+ckctGHQ0mad4Jw6OpanZ3YPG8d0cBToc0FOB6/0Jx1umByqp1Xl5vWmILx3eJUGorPABHhxV1ZzVIGas4ErYNTPeB374t4yhHkX3aD7ssxqCCJEXfuqcsjUyiyzEGuepXOkTrr9TbWmNwIkFX9hbrqcSLpr7ougLuns5zuEiqybFZm5XvaZCuZNumqNcFi4Vd8cTeIYENXxrBSNy6+lfzMehIk0UtIu8t8H6p7+MdIhw1ucKV0LqtsGgMs43Yh/wTWdrYNP8BBRq8A== 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=M59z86ocTmWdEiULiva7UwJlxeM57dsdQ9CRBOMRxpA=; b=Wb3TLOmMgJ1YIPfsbMFladfAX39xqvW+QmMNwwHjA9uXgHTum678hWfd6hHQOwFsdfk1ozms4lNthYeX7OTGPbHKJHs+aiDejomAnM245ubWMzrHGgRJVvS7x6uatpznmzFb+rSQEv0dLpSmNhC3LL6ipnUEH0SVizESc8+aySTzU1pLfQhStwgQSqD+LlPyDmCyrTOTM7mbbTuUHljzrfXDotqmNpD8ygzMkAvhsr7BvMryINDhkmKwM++T/kh8OSwaQ+AYEZegZoqPoa9rvSP7VyxoNv4gSsvFgZI4+Lpxf8CzxC5zO4wq4MGGa1zbVnRl1Goy75en/LFUa3rmQg== 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=M59z86ocTmWdEiULiva7UwJlxeM57dsdQ9CRBOMRxpA=; b=qYZT9POyTrcUsBfJtUKn0m/weWY7DQ0biEj7OMraTdW6b4wsokCfOXgmINSr+qydXU9RkOT1y6wH+/TCmclwzXUDl/37kuEs/MgPZo3c9eEn1NJz478VwvFUmTpt1SRviQLN7kDsvmcPvY938t3Uk+bK6lSVyxsZCNFRL56Y2HaObOimzJ8ilDs9qLQ4ALf/cuz+EZZcBBH4/SjG+X0QBDDdIyBQVhzsNqkXdIllSnd3tQmIOLuyDvJe2qzliigDE5IX0lt8JOp6u7qSmf2SDnYbEqDmTsO2BXRI4qOMhU4EoeYaDd1y5LVun2anaw0BxAQsW4pij5yuU8vrRIPe1w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) by DU0PR08MB9487.eurprd08.prod.outlook.com (2603:10a6:10:42c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:32:07 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:32:07 +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 v11 10/12] parallels: Move statistic collection to a separate function Date: Mon, 24 Apr 2023 11:31:45 +0200 Message-Id: <20230424093147.197643-11-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> References: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0169.eurprd07.prod.outlook.com (2603:10a6:802:3e::17) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DU0PR08MB9487:EE_ X-MS-Office365-Filtering-Correlation-Id: 3bbe4c71-2587-490b-b2ff-08db44a6c5b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OmnMXUx3Z2IlyOA/jsaxgL49gw4ybJlSqGg6YtrLevPMXXbql+MZcaBxKgHNDmbKxHZELlV0bYpE30hwzheFnd9yyVtFUOXI05oF9rw9takOrlbAx7FOeapoLrphc5z1fcgOIbaCmDAar87WMtrKhx+72MZy7Tts6SN1BNEgBHAf/JwaCHDTjIWU0C35PWrxZDuUuMcDn5RfdcMINpq8+qj46Mq69UXQefiP84bpjspaOs0/T1ET3ODIkoeX2tk8+ZdwVewJDYmgeG07PLu1UdVlNn674Y5EP3bgU9a8BgzTWz0FtDBzCU+kGMKVbUU4mHln6bzhUIYzShrVSq+7LxLrv2sDVSnnN3KpM5r2u3UfVJxhVC20MOtGpDHj773bhvXHIWj7f5fQReh4AVhjGi0B1/M3C0IzMdQ6wZKl674Sxt/0OgdygcnaYpA0cWVZSa272c/ep4OohO3ufqmhvqDWubc6GvbcuAdk5w7HBL8aetoywtDNZ+Y2cIrG7yxMS6UhSivepkQEcE3nC7gTd+CKgfD6qXmcGJiPvgd7fNwxVV+Jp0xbb2FpvJBMAbt1CTsadbkMr9IXmMsZJGv74c6DQV0kkUxZKViLNTBfRdzRUC1kQ+zCUZW25v1AeoaZ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(376002)(346002)(39850400004)(136003)(396003)(451199021)(478600001)(86362001)(36756003)(186003)(6486002)(26005)(52116002)(1076003)(6506007)(6512007)(6666004)(4326008)(6916009)(66476007)(66556008)(316002)(44832011)(83380400001)(66946007)(2906002)(38350700002)(38100700002)(41300700001)(8676002)(8936002)(5660300002)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MDgQYGj0jbGp+PCMwPcw2j5Av+48UTwPf37/H8CQRH0HSCSLuiAFcVHb5SJawHoHpQ5BdjO8Pb+BL8iYcphx9GVDKkd1qRhLbKne1xrgE9OlSeYEUtSzMdV42RIQ9uBOtrWJxKtDtTnjw/1K+86QmOuGvQKBlX7LECdtvTkn1UVIR9oTd/6Pxh3U8l/2ohXMq1/ZtIr5F2HdxiaVXhQm0GeqlYDjaqvpeec4LQl3y7IBWsZXdq4FP7A5pzs9tEo0g5OO/fpRQfdKz9kPqJi3RBEjSEF4dv5AD/0zz5AD2s5uyCEItwZtHtClEcaReM1da0AKtUcmLlx42MH7lkSU3MhafJ1l4r07dojzgHrzzhn5igNCcmQyskVNbv0SYOozP9Z7X2scbGliKo8hPJl8DDcHUlRj6YMf3pQeRg/PB0AEEppVL+0q67Zm5ditiLDMEYxZRiDgWrGgAIxmNGif1/VQBtJoGTbaJkf3j4YCNxf8NsDnylx3P7zyc1BczDfa1Ob6p/A+ksph3ps0JhmYenwjENUtI6+IcudNLy6qI0Dn0smY6PhLBXsLGBxKxCpHLOvIfrYd4bOMcBcsvRJide8BFIm6wxhP5L0AJeR5fWetHw7AWskbYVes6vvEyn8h/r9P1T6uAvJfE2cuT6avJXSO/erwumVSxDJ/OTNV7LQpa29mlK/2LzJx0HBbtgzGxyuXzHc4yrTa9Uprl6lZ7GPYsn1nRzcHYTUh4JMtovpFslW4AHWGxaoqP3cF2LfLf4owsmE4B1Q9GqAVuDZ0MjGsir757qwfba2WGzE89I35QsAqd0rcJDb8YE6iGq0G8Pr3Bzcp7h/wlPAZYy/zkQqeutDA4YgJSxBIFeBeZMm/6mujrBdAnF4HQ5vUEbJ8460bRDN8aHHBiBu03d8T7Y+eXKvSr22hCu0TjdoyT6IVPFWxqKIc1XovhRv3jdostcS1ZELCR/3w6b0OEWBl2slUsUcvG2+EN26m0UKRqdxQ6WZQJ3fSUYm1jW4K89my5XK2cb632yGQDGzJKkpU3LcHogBY62B1F/k0ZSApCB02h4UQjdn+mwLRQqP87dhLH1MEGGHUSx+Kej5Pi1nXj+6lFbggrwptzD+jkSWy62Xt7Xl1VpEJZdMwfgci2hinplk1GvGeKb2FfbZbqceHTWkk+jtLRLoj8xBJZ0xXBQRrtgpOez0vhIgLhC+BMybNhWZixYuceiK1PSReIjEd8VsUim8zmzqa68meXotA+eEpZ85IFvRi4DrlVEEtUBBQtKwjllrHMyzmuxNCVAgUggB3pYBpWjUuA2dCsMZqXzhm4pJ4/bgPQlHbwyXpS494APpFRXnHPWM6QXUUjh8n3X8l7vpwf8LUNFpONd04IQ2LcQ/xet14oY8lKipNM6hsSRLgMsSlN8P4s12yrKOA09K8TGf5kNKGQ/9NUKV4fkjrO4roc0M6Qm6N2rhH7jHXV52emBy+oe7CDhF6Bi4CnpkFuLxra1CtFeVVokeKSL+/EtWBXSciDg1dNUxCF9beul0ixmVbZQlpFI/HVCkkNXGANmb+XOZLgOKG1sMiL33vLyTQE4fz8xnHbYGY6LUQEFzE3B6sQhQ7+CRHSn3TIQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3bbe4c71-2587-490b-b2ff-08db44a6c5b5 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:32:07.7331 (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: cDCfxmql6C9Edc8Xjk62CSIqjoPesRnGhXijGQ3BQttaWYGMYoFc5yd0V0SjxCD1LxLv50ZbgQHvp9CkdmIjAeBsIy7v8Ubu1n2ARF8Q8CM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9487 Received-SPF: pass client-ip=2a01:111:f400:fe0d::731; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-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 add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 52 +++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index c3e220b60f..48ee5224c7 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -524,35 +524,20 @@ parallels_check_leak(BlockDriverState *bs, BdrvCheckResult *res, return 0; } -static int coroutine_fn GRAPH_RDLOCK -parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, - BdrvCheckMode fix) +static void parallels_collect_statistics(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - int64_t prev_off; - int ret; + int64_t off, prev_off; uint32_t i; - qemu_co_mutex_lock(&s->lock); - - parallels_check_unclean(bs, res, fix); - - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } - - ret = parallels_check_leak(bs, res, fix); - if (ret < 0) { - goto out; - } - res->bfi.total_clusters = s->bat_size; res->bfi.compressed_clusters = 0; /* compression is not supported */ prev_off = 0; for (i = 0; i < s->bat_size; i++) { - int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; + off = bat2sect(s, i) << BDRV_SECTOR_BITS; /* * If BDRV_FIX_ERRORS is not set, out-of-image BAT entries were not * fixed. Skip not allocated and out-of-image BAT entries. @@ -562,13 +547,36 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, continue; } - res->bfi.allocated_clusters++; - if (prev_off != 0 && (prev_off + s->cluster_size) != off) { res->bfi.fragmented_clusters++; } prev_off = off; + res->bfi.allocated_clusters++; } +} + +static int coroutine_fn GRAPH_RDLOCK +parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + int ret; + + qemu_co_mutex_lock(&s->lock); + + parallels_check_unclean(bs, res, fix); + + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + goto out; + } + + parallels_collect_statistics(bs, res, fix); out: qemu_co_mutex_unlock(&s->lock); From patchwork Mon Apr 24 09:31:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221917 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 C25E3C7618E for ; Mon, 24 Apr 2023 09:33:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsYo-0007ze-WE; Mon, 24 Apr 2023 05:32:39 -0400 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 1pqsYa-0007h1-5x; Mon, 24 Apr 2023 05:32:24 -0400 Received: from mail-he1eur04on0731.outbound.protection.outlook.com ([2a01:111:f400:fe0d::731] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsYX-0007Rb-Se; Mon, 24 Apr 2023 05:32:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ce84MDfUxnN7rDTy1GcwU3E5jx6JKXLr4HRJ7ZWHqckRzXEfwmtL5w/1+X+LlyN2kjQ4l/1DTVh0b7tYgFBaOsieGAsFugGpNWqye19oJfmdggEZbr92QeTQ12mm8DhJI6+R33dw5ni58advhmEGhq/H7koHMCNY2dvVh4tFxhlcxKer6OrKqeC0eOLldSEvEpquQS6XbAsIvRKleFQiQXuBam40dY6hxZQJzx69A6iZ50kJEEUd2T4k4MwslqGyeQTqxhWMtqKw4Tca0JKHqzRiSWqFLN7WGokiWlnUc2Z0w9rVZE6Xk6PbJ4R4XBIbKO/UHctdjMPzmusWySocIw== 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=kedXKnE+fbWyxSCs+643SW7HHz6rEerQzrdQaqVHiyQ=; b=Py5hv73plPfIgCv1XOnLBfzKaiy56/OtOxi/1TCopjhNV9sN5doTRGlpEzGJWi5fX44RzakoPVrftaMkAWsFFAx3t8XZ1NppwL/NFmSzhweoT00DRCfDZj33f3AFtjw4SHpwbeE/OcgLnGOfZcIpAVGuc77fd0dzRRPtWzlNM2L6PigANJHCKAr3nZ43gP0bkZfLu7bKWkk7tg7rzxaWS0YMN/IEM3xGi1vl5cNOltAkI7tTgnz0yqfIB9kDt4BKjdlioOFSMSxs+arR5LiBfU5pPtX7IHvTSLVZaFR3pYYwBZKKs+hla/3JXcKVz4vcs47xuTFMhI/74LwTvGyb/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kedXKnE+fbWyxSCs+643SW7HHz6rEerQzrdQaqVHiyQ=; b=CKOfkqP4hWhXmeMP4c3wGKZK0YNhUTTi2gKtyGVh/Nv+ELzpCjzyi64aLnrlEzYIl8V313fZ3/C0raYFrwclK/jDBQjDQrTLlqZqL2RB00eIZ72BwBofOYm7ZIGaYt1a3xzYXx95IPf2Ueh6thsbWeEkA2apvnx9lbwJeIfa4y3pZ5UetJOQW/0TGUgwu5MiNS4PxP7IApsbgvyWrbZkrZmNxGq5ofmDgfu+u6FGa9gFwl6rodfKHBscQKLptrwD5OALi6ptGZ9sJsIMBMbTDoNkqltWjeUt3kBVyxvAz+OYCJd0uzhwFMR7W2udaARksFI28A5RXWztuRaKjr9CEw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) by DU0PR08MB9487.eurprd08.prod.outlook.com (2603:10a6:10:42c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:32:08 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:32:08 +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 v11 11/12] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD Date: Mon, 24 Apr 2023 11:31:46 +0200 Message-Id: <20230424093147.197643-12-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> References: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0169.eurprd07.prod.outlook.com (2603:10a6:802:3e::17) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DU0PR08MB9487:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ce204e1-322b-4966-cb50-08db44a6c657 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wyr8l7erF6suyABKFnBTn1f+xS0+wn8dK67kSx4JTD/975tfxH14Jr61q+kgXKLXNZSO8PA9R34O0Dw5tY9lFQFbIT7IRZc2tQO5BFqFpQCVHK+VK9y7iPWclPl0jqbc3eXHU+2xIcC1FUiF2fBMi+17ZRpwJ3nT2reb+CWooz9yp41EKCCytG1hvbAYk2Wqyb06farIxJt+/qZmi5q8dcKyJya1StL2V2Nf7etpkCI9SEknpj/IIptZgNb4+MNo0INYoF2FvVw3+MtQVLZc93Qk7tHJIMXeGJp0XcxuczT8yoIu936A+IHvnW6r216yW8pm7lo+DDBhqsfBmvBaGryseT/6s1Cr7YQXLUouVTsGozDQUKy0zDEYhTBgTgRPdId0oVd5zNX2MmLslstrNU1AGz6s6/VRnNoAOp9xote/jlS7tZNxUdmI+xWNd48IkWI1V2Wr//rarMeZ06NmL6eiK9dHhPI4qxKQC+aAb+/40lv+rueQIHRnwbR9+q8x8eE5vWljBwNwLiBGA3ax+BPGFsuvV5E+LS24Ym6aXjkiP5G2JUDsR6qN0NsXucNv2G4qNjOa7pj5XJySWYzv2Af+PfdHrT4V1z9eRlZp7OtB2j8ABVnrMl/nKeNLtBIh X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(376002)(346002)(39850400004)(136003)(396003)(451199021)(478600001)(86362001)(36756003)(186003)(6486002)(26005)(52116002)(1076003)(6506007)(6512007)(6666004)(4326008)(6916009)(66476007)(66556008)(316002)(44832011)(83380400001)(66946007)(2906002)(38350700002)(38100700002)(41300700001)(8676002)(8936002)(5660300002)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ISrOLjlHGq5C+z3I+x67007ft5HH6/nZqLqFVW64u94e/u1YqSa8phvnVGlMm3Q0CPcsesZAA892ym1kGWtfPjFzP0/7C3jEWhWakD0r3iFxCpxZ11c7SxT6Tc7Sut/4eM2QXX93mZlTepdZ12wW9h132iOHnCdUSa4d2ROCNYOsleLbL9bjLbLPOnz1edk2dfwRwo8MbEfWidDcB0BZKXUBYqDOpjr2OaK33BxCrmFFQmvLTyXChXW+iQY25fWQJsWp1PXsQS/EnMZWIipQM6PvfvKnTGE4L8b9a/tunSMYgCg9EE5lbceMhRfb4EeMNr+M+2DXZPCaGPzBcnp+UJ/f0NDt9rNbkd/1nwx3RFiqvDhMcBNhEziEGM77b3k8yebQ1W5mTylbhvuTVq28bW9ihXGaSv2LztvRuj+e93EJCDZ1vR5ubaQJySLzR4ET0KLDH/3erxImnXwMDXUIvGmf2EyM1npZ3q+MRevH6K6LiiYqrXlF41s6en3SxennG+O3oRG7lqt5K+JMPKBiw66nZ4+yov/ezJCR3sTadtdiD9cQ0IKKllFaM+6BS8BJHIC7Z17iZw4lCFsXjxv5WSNhAlkmFll9Pw3Db9pnPyrmVqOvoSw32dclW/8ajBvmIDxROSYtvHzMUnCstaCvI+UO/2nOjhPVZQsQ/V2y1A4ai+SKeOPil7hAioNGh+mFza56R8pLflNQxHQS/TjVNvsGJu1CJjQ76NbfBxH5pq6bQ2OtmW5/rk3hqbu8hVMb0H1d3v6j/xHBc5XT5fXvGx/1XWTvZldfT2UQDWvbIOwKcUP0tNLQTA5uIX7YTH2VoydJP6DWPxf4GDO+/BuhGM2oCj30unLN7UMUUXWTnmT1dZ6ZA1zfYhKRwsdVfLCe0bZyyRCquj0SCBDtz2oUNEzH9VQGVIYtPNtWOYJX6xaMwFwmjwLhIDKKIRKZbSL+Lw4yLm6kydRavdxDqgQLziUmjLVkYnSsvTN1E9QF3j/+pMO4NyhlsAjaWe3EYVvUAeFwD9rfjxxsqknnJoy01IoXPJ2Imoy7rv7sL7qrsZJrq87My1YqG9oyeQ9vhMkNdABuZloFbLBoVJYXC/lyqG8yAbypuo7jCTNOeSBbNQs1dxg87GMW0EGE/tZaA6OrysgXtr7gwNAkZ9E5155/ZQ4nWRVOe9jv/C7IEKC/UqSWh4saXGKptxsVaiWlfzOQOFFmPlIP4GwtZjLSiY7shps7OrGzHuH+Z14zxFcS2boYvUeKVY8OQ804Yke+4BNSsYDRmCJK2IWa4hDVqj2fXYxyquVgoFISIZ4ZdEJuzzuGvzAJat5QEfkO6kUgwm+ykSutwVJTSeTlWB+wtss+ndU5BQE1BVSNvArv7Rax6EEADlfxrC/mIPgTmpkI2znLznFfPG5JJxDe5VbrcowYVdsJQz3MgubE3mvKPuGjsYGqM/NScjjgZ9fIYa5DC4dKE8Y9oSL73t531k1nkANnzbrGIoE34WkXwzp8Ap0CuL8TMahpQsz6utAWy9BCSqGvjreetnw9rD2hXuyb8C4NuZPlltbOzF1NB7RN5N8VvQfN+9hDnBR63DbzzRsIPZdF/fmwTHb3thArpBSqfdo5lw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ce204e1-322b-4966-cb50-08db44a6c657 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:32:08.7150 (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: go9rIZY0znpPrGMVjgnEe36bNeCLhkuGyuNFCX9vKzvsugP/FqLBc+cJvCGBpa2dU435pxkohaqiNFUb0L/TY0kxc/dQZMmisTvvWGXtyl4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9487 Received-SPF: pass client-ip=2a01:111:f400:fe0d::731; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-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 Replace the way we use mutex in parallels_co_check() for simplier and less error prone code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 48ee5224c7..a6a1c7ce0e 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -562,30 +562,25 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, BDRVParallelsState *s = bs->opaque; int ret; - qemu_co_mutex_lock(&s->lock); + WITH_QEMU_LOCK_GUARD(&s->lock) { + parallels_check_unclean(bs, res, fix); - parallels_check_unclean(bs, res, fix); + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + return ret; + } - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + return ret; + } - ret = parallels_check_leak(bs, res, fix); - if (ret < 0) { - goto out; + parallels_collect_statistics(bs, res, fix); } - parallels_collect_statistics(bs, res, fix); - -out: - qemu_co_mutex_unlock(&s->lock); - - if (ret == 0) { - ret = bdrv_co_flush(bs); - if (ret < 0) { - res->check_errors++; - } + ret = bdrv_co_flush(bs); + if (ret < 0) { + res->check_errors++; } return ret; From patchwork Mon Apr 24 09:31:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221914 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 E8622C77B61 for ; Mon, 24 Apr 2023 09:33:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsYm-0007wU-TF; Mon, 24 Apr 2023 05:32:36 -0400 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 1pqsYd-0007lG-EX; Mon, 24 Apr 2023 05:32:28 -0400 Received: from mail-he1eur04on0731.outbound.protection.outlook.com ([2a01:111:f400:fe0d::731] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsYa-0007Rb-Vx; Mon, 24 Apr 2023 05:32:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H++YH9iIEL4rD2PqBJIohJ0xSkBlfWD/GqWldxZvdVuh1byDb7FY85FqxYTpv1vfEytVMXSouo7+SETrU9t/3GVLfhYsebTJz5+rS/F8DVMj94XVsj1ws/jEjEziTUn4hjO49ERky5O4dcZlBzDoKSXdbXuxijSsixVfSz5Z3ifZmBu9LJTMn6kzSnQYUbDBBiWlJ8mVBVDT9Y6hWVYPC+/xI3WWat/M9VoM/OGnFDAZn0OLQnRW43MzDIDI/Dx17zlDv1v5Ta3uwZX+YR33A2YucLvhbeEES9H11NBTKt+AbR5aWgsy1+AmQyEICTYxmVrjW7ZDR67uwUPIfeOb/g== 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=nx4ydLakxGaxs4rP6xdhzZCIhq1dnfz5GYSH+RoWka0=; b=cp/1O3onmJRy3Nyx985CFtE2MyIAWVDQCUMr4nbjXEx4XP0cjPH2xCe58yyiMKblwRZv1cwIciPqz/6bLp5uZ3voXJKKbWwtS0JsdugbnB9ibRCWOu7T4wWM4YSCB5H3O6MVQvlVWds9MTy6dClzq0XckNh5cYHQAAzLqArQnJ/XzMYly/LSJSmd2q8GLdGJ5iC+W8YpsV+aKK0D5g2D/VumMrjn49+U9jL9nQNT3dm05bEeAfzAT3S/0WFcSW/FauTeo60b0EmerDTfu3PPuCQ4b4fM+pX8DfNBBvIFS54JR1/akGNguPBMM8daFOtp40CsH5bS4W+qpDy/XDZkRw== 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=nx4ydLakxGaxs4rP6xdhzZCIhq1dnfz5GYSH+RoWka0=; b=ILlQom9jRe7xB3U6qP/7HBUgOmlt+z0nSWDinZELbMN7MhpiZ43FsdkNt3X9LGzwwCKZrS2VKUVc5hqKHHShKlYK41+PsmLTk+e5/iwzaTNt7ivs4lEpbKFKUaoCSURMc43DvhwB4NWuUlHZ/fEsEp64WHF6/ikQ9BRHFd6N9NxccNWnhRySYa35hb77tmik/tvLI3fw+l+pcXe8ko6aHpjlYYQBSM3ApNBpCgFJMNScCRTGeVya3+F6uwCPV1fF59TpnWrA/pOrOFoHZ9A0AAN6owlqkswPF89MEwGPresSbadozBDprO8B9OGqajoVqiffwqbUS/r9KUWg5eJN7g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) by DU0PR08MB9487.eurprd08.prod.outlook.com (2603:10a6:10:42c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:32:09 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:32:09 +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 v11 12/12] parallels: Incorrect condition in out-of-image check Date: Mon, 24 Apr 2023 11:31:47 +0200 Message-Id: <20230424093147.197643-13-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> References: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0169.eurprd07.prod.outlook.com (2603:10a6:802:3e::17) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DU0PR08MB9487:EE_ X-MS-Office365-Filtering-Correlation-Id: 2adbc7f7-7f81-48cb-4ba2-08db44a6c6be X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g4QGuyKohKWPXW0MCVfyEznlS3XnQRMyLTZr0X9cuP4yq6+6168wvk4c537wTa0tA59GrkmQrd5UTh3MgC9MgSEJIhxtThABYs8tKqkrKntfFFUwgLJ7FoHiO9aj00DH8OF4uJzh1MfsIZTz6PRj4lWN6iJa6+OQGl5oF7K7No80Co00Rsz23Gvmeg855G8L48uhvUkIKe4JrP2eGEPM0eSSc4AVnEpdr5u3CTbgMb7LaK6OAyg9LsVzLes5bvBoTNc/mTD9NMaacVycFWsi/KEhuO2cknQ/OhyguL+cKOzVn4QlJpT64vl0Q0PMT3/RE+qqvkCFlqXd/JBrnghJ4DhCYYMdVNHGICX0KFL3f1hsZd89mOKD8PsxQAwVUMuvpku4eSegGd5eAtCkJ0fPjgZ9c9lcyT2yKcQpoK1lKToXoEu6SLFxq7xdARGFt47FVdszOmhHtWAyGvIQbYTLbve7qFaRJwq/jv3tmz1Thv08r7sahw3vWvZca3zTLkjeobtFHbbgcHl8wLMTvzSdWQHF53JqYQIY2v/UWsLWu1qdszcHajNcFc2oK8nkCozwaM/ipbDZoOwdNdNWN8PjzxIpR7sr1+jLo1vTl9FzV4XPScCyoRbAjBgvNn09Hpua X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(376002)(346002)(39850400004)(136003)(396003)(451199021)(478600001)(86362001)(36756003)(186003)(6486002)(26005)(52116002)(1076003)(6506007)(6512007)(6666004)(4326008)(6916009)(66476007)(66556008)(316002)(44832011)(83380400001)(66946007)(2906002)(4744005)(38350700002)(38100700002)(41300700001)(8676002)(8936002)(5660300002)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: O+4rZUbif8xJhO2lBx6zzt7B3FWji1J0xbQdoKYrea1A/7gwiCUtZClK/4ehhGHnX8QA0jy/D7RvpNgSymCaLNZxHZr+/B98h8F7qudWH9I53MlC63vv6ZOxRvKJfMW8DS8IbH95u8DV6u186+ePu2RcVOKTYDls8RnxTugMRHy4bb1U8Yvew97ZBPAfAfl6MLu0pw3tFzcCbxsb8QstQHbHGmMdKiu+A+roFwpZkalPin+SXC7FoU5KY6L2zbsyZpuin207/cW8xrKy6SW/7nZnXBfseXhfVxfzphULsm8IPs3UD/f4cuLElUvLdYh2TBJcvwLrmAEiIanXTXcOtp9pNC8S635J3qUSkFZs+jtkTgBNJibzMo1KoNwBCfRahA11179n5SOOY6GIA7WRbte5T6VkMGBM56ilxPmc4eX4qPGwJ5EAlCDhXGpO0aSP9Dd49SUKQYWW27OiHIP0H8ImhzbZUgEy46/Tmhv8eCGb0FKWKdTIVhDOMkUON2Q/lepgWmvnMSNhMXH/yj7ViFoEMUGoixfNYJlWFdz1RxSgOXsmdpb/7aYR8ZRU0ps5joyCHePNn/E6Q0Mj9dlwzbbwQcO44OEvWcQNLJCNweHzrNwtDxqgH3/4UfeTlP88ZVcXDNx1uzOghQjdI4fYqGg2lHi100/ZsMeTyv8QXyEW7A5J3Sgi6FnbyHCRB/aNLwOgoFgTMLbUdpSTlQQZU7d11uPOBs/pp6N6ruFVgipB78fRt54oYIgZW/XktoLgAGT3dx1sh0JwiS/K0LOX8+kaVotStMVfVGV6WSEd6bHdNEZHJmqaRdl1NvZi9itnjOUdUpfD6ficctlw8Wj5FOXIMksir0hmzhj9VyPU7Aq2u3ejRMGQSS0eW+kj3F0fmCjn9uMqgCjfJhJGAqTJMvtDQ7jlK9Sh4PlQzVL5GhU4xWosTlFQvyd4V4sTkq2F0BhcYXfLuxPWWozc0BLJsujhhIC+TUmobwhoNKKBFCPnkyEVRSQaGmFwzJgpLwVpn/hCTfo5eVOP6S4xkKZaRyGQUGtricZPbbkulQgNSbE9nMBG07cIq5tXgiZyI0lVLjQDqK6D88jieHVF1SJrrcNGzAwIPjA/yLc87JsU8IrNLqoZUOvFvbXiKmAmSNRMQ2BKXDCDW//hhljmQj+Otgou519sttRfjqBBnEDW/jp1L0KcdNOEk7We5G1uVJ+plCBn8qIUCGfy1mIfaAnOoBeS6tslUAKJxXXcenwfwbGQtP9sZ994ataEDhBaKLX+1wQFJanvK/dwIqPnrJwaGD4eD+Xu8+qt8UtTadOOCEGY1xgaco1wK0g+CYJhJrqwb69gCZd3BU04TVIROkjkBU9loAMHEyApmAT0yKedHIPr5AGWvLBMTVakjQ4jg72rC4WY3CUkV1Yv2b0TVgfMJLeAjT6Kf0mcoDclarQX0K3AGifgqhyxlLwyPc67XpwUdHDpJAgHjaMh85338nvbDMgcN5G/HJYT7tlmFm43miv6tKCPypXQOqQZoQVSdto1sxBwiKM3XO1Kle7mvpTN0gd/KRaCdtB7NFKuIqdjW/3mbvoU/rbq9Q20dN5RBdgOoeC31iO8PoWwDIX6xXpWsg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2adbc7f7-7f81-48cb-4ba2-08db44a6c6be X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:32:09.4107 (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: Dk/Gz2PJ8XpEi3FdNiLb1xOKTzhV5Isnw0iWvq9NQld8ql7ymsyyHXDBA2KAsZUXvT4uiLriyVgjr47dAgaT6nv/1ghmfJZuFQESPhiTrsg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9487 Received-SPF: pass client-ip=2a01:111:f400:fe0d::731; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-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 All the offsets in the BAT must be lower than the file size. Fix the check condition for correct check. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index a6a1c7ce0e..ce9ac47c55 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -457,7 +457,7 @@ parallels_check_outside_image(BlockDriverState *bs, BdrvCheckResult *res, high_off = 0; for (i = 0; i < s->bat_size; i++) { off = bat2sect(s, i) << BDRV_SECTOR_BITS; - if (off > size) { + if (off + s->cluster_size > size) { fprintf(stderr, "%s cluster %u is outside image\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++;