From patchwork Tue Jan 31 10:27:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13122837 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 1B290C38142 for ; Tue, 31 Jan 2023 10:28:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMnrl-0003LS-Do; Tue, 31 Jan 2023 05:27:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnrj-0003Kx-8c; Tue, 31 Jan 2023 05:27:51 -0500 Received: from mail-vi1eur04on2130.outbound.protection.outlook.com ([40.107.8.130] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnrh-0006VK-BL; Tue, 31 Jan 2023 05:27:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jE0Usg/QgQPT2vSbhb6j5P5iQ4PJaD40mPspOb4bBLLt1kv+4ZRgLMmX7dHD/E03mipYwyV43JCmdJJJbPhwYfXSSzNa1HiuQU/K+1OmogCsXzFBV0q3Se6ko5RsidGTnMjI/uvvx7KgJlNB/qvGKP44RnbIxH27fYqq7EjCJQbI+ZvKoZyuqO1Z1V8I13c+vne6lHi4mFLKO27djSJ3hUX6Zew1qYFZgWk/h1x9GKbyFrGwpddLU2NDxVyFGF5yuvws2uZvwsoGLqihDPlgyt7CUfYbF5IB5/Sb4+ZfhseP7ssvXJ0miN/rvRCgOqqzVNNDNbM9igmaPUpupdlDgg== 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=tzrCE19U5Bc+4gW+rzytIfAwTYgTCv7OsgBMKOeLLug=; b=TPaYEuxHDt3/FFyLZZxIsp8AObF2Lfs3y5ZjuzBmvsF5S5MM051djKtDBNY/IfLbY/7APQ7AcBzsRBN5N4LqkfTIbpusgOJ5Tph7o3MFpyhmr3rA1A02cZ2dd/NLz6WK5IQa9tXLgMGdUZMsN/bDTt5+KwxjjiV4yEu2ubZVzADWXb0qdoRmIpCRoJ7w3897lj9OVLBiQm1UJ+SWe+8sfnVuXWhEugwiNsEgbVZ4hWl4C3kA5WaYEML2ElmaVhOCtNFVzt61jswO6dp23EIBH53iturfQBo4NXSQg3a1MNtcfcZTeEy5Pcsl5yyV8Vb7Vx0bsdmxhQ2xtGXUhISnKQ== 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=tzrCE19U5Bc+4gW+rzytIfAwTYgTCv7OsgBMKOeLLug=; b=B/454cowWOGOX9ahWO2f4YBPaLPGdV16Ymol+UgRvDP8zykmF7NSG/yAFNNH1XVlMAHgnxMdj0nmmTGB4mSSwpA9Yv4Mcb60uvZplOpogA4WIJnNBwArZ24xQx56pDrEkICa3sW/kHTT0kMeIjGJgwPYvCL8shzZescGxZdKMCqRhnaPOGOM/UC3gXGYl3lohmz502qrdKPdna7sNKlhPhp5SDVpiUXOeKPUzVL9PqnK501xy1g++lsFl60HseskyWoT9gou/eyQbTmppZEtQ9o18ciQzdivXlm3QlKwp7OVf+lD+abbRiero1RLbLfeSahXO1lB/iWRs0wVaMRJZg== 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 DU0PR08MB8615.eurprd08.prod.outlook.com (2603:10a6:10:401::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Tue, 31 Jan 2023 10:27:44 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6043.038; Tue, 31 Jan 2023 10:27:44 +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 v9 01/12] parallels: Out of image offset in BAT leads to image inflation Date: Tue, 31 Jan 2023 11:27:25 +0100 Message-Id: <20230131102736.2127945-2-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> References: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR0602CA0016.eurprd06.prod.outlook.com (2603:10a6:800:bc::26) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DU0PR08MB8615:EE_ X-MS-Office365-Filtering-Correlation-Id: c410134a-c6e8-43c6-e866-08db0375ca42 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NOXSnSmSnCQHmz3CFYVfATkjYb33y2L8prhISqsZBmQUP9YzBW4FF66tlKSRjb1EZv3+MdJih7tvZY6A8OVWaOF8SzLIgv5I7DeCaXOtBKVqSVOihhGGS+IEN9RXbMWF303GN6Q8DadSiuQHG4pUTKkjVrJxjxxD+uO7I8mkhtz1U3Ui5qsRSJTMx2QmcwYmB8AZo3h4bihPVzvu8plsQ1hk81nLZhh9t7zO23LGqmBoPAw/Y8LjaPDwuPZocwtKSq7YrN6CujCm9GaCTDZwSNVPX/pclrMbWPWsD7Ujp8vsxLPTJXRhDQ7gdSHLvjpDa3Im9F7eJzD9D6Ulvf7pEuKGeQP78S+v5NLblx2Bu06aagNO9KdietS2aumzz3o+l3efbe56a2DN6lyCvSWAMtTcJRaNTUkBwpaO/nMB6nFmOd1xli6r3fCnFpcLQq9NuqViUzOTRJ0q1CUST6fQyu/sKAaEfPlVcy3k//CYJpZnSvCKmygLAVZDfl249RJKsMTVDa2N05qzXZQLUnZfSgBZK6maAwpwrt8EHxsFs2VSVLN+rJaT1nJCsKuCq/e9e+szC3t1bGjPLr5pkJVPeb1WVTEpvHAPmOre8to3EFpvC1yIsUj5/Wf1QMOnROTHpG8Im03cvLKuQ849gctBe7d2NkBJeSIVlINbSDTbQzgzfv9xyQ0HDFB5ujErzFDdLcekx4FUY1bCr6w7UF+ccg== 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:(13230025)(4636009)(346002)(366004)(136003)(396003)(39850400004)(376002)(451199018)(44832011)(5660300002)(2906002)(8936002)(41300700001)(6916009)(2616005)(66556008)(8676002)(478600001)(52116002)(4326008)(316002)(38350700002)(6512007)(38100700002)(6486002)(66476007)(86362001)(83380400001)(186003)(26005)(36756003)(6506007)(6666004)(1076003)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GqjJSH2R2Aya1fTPhgtkFvSVgXsiT4PiFLoyshe+wBNxeM5fhhWE/TZqVOxptjLIgVFvTpT7DUkfbGv0OZJ2VPxi7DS2WY7UFB8PTlJA/+lnk5VtK1mV8ZWhmcl+/KLGAmj4LPeiN/7vVC/L+gpAvmK7NBEV0mQ4Pwz1dci9OQOOBvfX3HO03pYY3og1R9hygBc8GtWbyPHHRKtnDnV2LhSTVTRZUUR+gTsjcrKDTm1zEQRvxqqMLAvL/tJyNnRGZg7VHNaoRSXyegtQ9NYOJhBC3ydqLlV1T3STVh+t0Z55ppR7FvLKeroRvnOBjoWySrrhXj3mMHM/rk28co2sJdMHspKTzaUuDE4v0hncnDTflgH8A7KhPYCT4NGEjOQ7FJI+xkNwnjyEqpJ4ffpEj/A0G6MX0wKyDd/cjXpqAKlZf5CP+BG+kv8BUbmka+Dgl3UR3qN/M7lPR935dUTjJ/vIIS933wA8elFGycl6UqPAfFHi785ZNm4x7+eYPlVIi68wPW34MfjKyBOro/GqMgnZXkOVRylatCrpy8HbtIgH91olhjSmJ0R5i6g7SEmE96IV5clDnRwU2hdiP2bX8pYJddcbpXwmyrbBx/cbGOCIhNTqMFNkR2xwgJiV18W9I0TyGMCK31jbFABORkMfjIQTlVRfLgsoZd79OjtJ2oiCmJF+ld2mF9EJtODeEWj6BgzYr9MjRRPzuzMhg9hfPLXnPVswWKUmRngfdNNNMaq8YxM/rk+EGlg6rI6cj1MxqdGWovfZ5cyllf15OoMwDiKZg5Zo5/kQb/vTmUz02c07oYQ1QtJXeE8MPySuQbhJ+6N4kZUJdzxjGfDRLaSKpHom1GojRLvBJc68i0IJLL6vb3Rc6kqYpe1NQGES/gEl3s4NQy5Bp3zzQqzjKbmm2vhgiwAKWxL9S4TjGmWOumct2FZcE3piw4/0pyeEeKURcK/1zcbn4rKOpHDXUJCnpS0PthWFVeVZjMfLOUSA0L6bFWSpv66ApHgJKbzfEBk6OZzRgMFeRZGm0qBZE0lOAWolPwctCflmWHqKmpvLDOKUvghDwLPtGMLn/N5IrfjbjEu3FSbYTGKDzu6z3JuoJN7CZrmSD+Ttu1POYddyZbxOOHim8RF6+enNRUuFUpqPtGaE9T2Hitr20SDerulllkq+WvKiFpiq+nPVlhzHZkJ5T8ygbneWNgJRsZD7q5E8QaCURSDzTN2XJtksNQ9Qd7qVN1gZtzxBqltSu8G+E/l+Yh1F1SU18WmvKX2J/EGPjXJkYIpjHJ+TL4vOayKXYbp1WrvUZYz4pwnxg8GHzh6rnHnK0QEUBZoH1K3maNOWElyBUZrxQqmDXxlo6ApFAYd8CEBRWmUFHakyxLxhBnX0wKj4BvP+JMAlRevNpjYqwcssVrBueHhjJ7Vk9AXrRWxfRNtu6UWXiwAdfiGUmdBLjNuVQdkQlDprnZ6IkBubEAGDsvIf55EW2k5rjHpJPsyMC0/m1PMtrqcRfAZw0I6tYskxX3+sl4RaTtzUkCBHMXeRfSFJzY1BmQaEZylF6mrR/s56uaXEN8+V8yET7LRo/GY9sYziYGwpOzd6ifzJUjGT6QwOKEffhqm7+ATfdyLFsiNhVuoBtl/dxoPeVrs= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c410134a-c6e8-43c6-e866-08db0375ca42 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 10:27:44.3746 (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: gTS4HMk/CAZl5YjRrxeLYB70dPs6bfj9wWBh2DRWs6U1DdFirw3U9L00k6K1FifzP0pHeS98PJmY/gJh33CZRWhOb0iGSYVpUkgnwjGyOkI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8615 Received-SPF: pass client-ip=40.107.8.130; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 Reviewed-by: Denis V. Lunev --- block/parallels.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index bbea2f2221..4af68adc61 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -732,6 +732,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, BDRVParallelsState *s = bs->opaque; ParallelsHeader ph; int ret, size, i; + int64_t file_size; QemuOpts *opts = NULL; Error *local_err = NULL; char *buf; @@ -741,6 +742,12 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, return ret; } + file_size = bdrv_getlength(bs->file->bs); + if (file_size < 0) { + return -EINVAL; + } + file_size >>= BDRV_SECTOR_BITS; + ret = bdrv_pread(bs->file, 0, sizeof(ph), &ph, 0); if (ret < 0) { goto fail; @@ -805,6 +812,16 @@ 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_size) { + if (flags & BDRV_O_CHECK) { + continue; + } + error_setg(errp, "parallels: Offset %" PRIi64 " in BAT[%d] entry " + "is larger than file size (%" PRIi64 ")", + off, i, file_size); + ret = -EINVAL; + goto fail; + } if (off >= s->data_end) { s->data_end = off + s->tracks; } From patchwork Tue Jan 31 10:27:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13122838 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 F33F1C38142 for ; Tue, 31 Jan 2023 10:28:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMnrp-0003OL-ME; Tue, 31 Jan 2023 05:27:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnrn-0003N7-Uk; Tue, 31 Jan 2023 05:27:55 -0500 Received: from mail-vi1eur04on2130.outbound.protection.outlook.com ([40.107.8.130] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnrm-0006VK-Fw; Tue, 31 Jan 2023 05:27:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=To5VyoHEMSTf2EwO5EydHLvA4ywM+SgHAcc5/ur+/3DNVkyI63MLX8pegbx1TER3H8Jw94OFC0pSSmX9KSQFpqhup0MdQHxetWWrGptqFzBVV8b6VrpASVxhG4trCnMZzz+oLy1/eFDxt5mhzr900WscBdZDwfuwZlN1OX05TtyS9Yctj4cASRU/JY7wgW5owmwdyEceqhWU8jQY+JwHlNF09i1r17WP1S9ByIeJIuCrWmqWtD4BYd02PIC0tU68Hk2tSZd6ILptussXsgyTCNJluW/sGjK000g4X6clck8si2K26MJlo9buwJ1PKccdkKmd0+XMlrUH9KMmOGDeGA== 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=qF3NOVPO0k3//yRzQXkyNI1yCckXNC+VUzpe20je6FQ=; b=RsCLNmF0lBE15dbt/Pqwmqy6JuT3dU9bP2lschYIINX/tRJoBb71aYs34hCwloPpGRpAQop6pMj08hrdmfbefU38zusYr/lJHZ8oXpu83n3feIBJ9sXT7xf3r7BSHBiSqq+a0fMQGfUx7CEMk6H/lwqdB/2j332fXmkSkY3zGZbXMG64+wmUfETOqEnrAVvfiwPvX+dZf/5yY/0bAixUhnwgrvL+PJZoS5ar38+Nc8tJ3Ns2SZHyUGcz/iCSPzX5RdDdwjURNtc7rNqY1cM4bFqxFe35YxX17fdXiVXEKqezkmsFAntrI6cKCOHodz/5+FyEcXWVtNDmau7OKBJRbg== 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=qF3NOVPO0k3//yRzQXkyNI1yCckXNC+VUzpe20je6FQ=; b=zluv65Hj9rvvy7sUckONub9SLo8IuJJU0GzAF7sbSKnrbdu0chM9PKAL02EnO7xOCQVwnXkqg3P5mrilroeK4CrjJwx6wAmxJv4ZhORqvxrmL5WxQmM73ZncjBOk9e5kWedy7hlbKsvBsTEjcefeNoHVN4tI0DDs4uxvaO51fy22xm5arpZthGmyI3Y9/v5L+oWNINEmGvvZJsZa28RJxtb08MIEn7mtOK2BhmcLIRAPwPdR1a29OtFtVqqdrBHYaMr+kRNyHqt0U/4btqsEZGqCNOF0fdmjZqCeu5Ng/Mrmf9vI0SdDbhkbYnfOzs5klR1g+R+DFYJfBHUcWUjF0g== 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 DU0PR08MB8615.eurprd08.prod.outlook.com (2603:10a6:10:401::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Tue, 31 Jan 2023 10:27:47 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6043.038; Tue, 31 Jan 2023 10:27:47 +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 v9 02/12] parallels: Fix high_off calculation in parallels_co_check() Date: Tue, 31 Jan 2023 11:27:26 +0100 Message-Id: <20230131102736.2127945-3-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> References: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR0602CA0016.eurprd06.prod.outlook.com (2603:10a6:800:bc::26) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DU0PR08MB8615:EE_ X-MS-Office365-Filtering-Correlation-Id: 941e573e-d252-4bad-b991-08db0375cbf2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ChjtybRImBLs0VTT9GNOv3Nze2gRMLyqzc0orvkhuY/b/GRdWcy31NcsDAN/N3iwFEW8b4mE16KjG3iDt1FZKBxpIuzAP6Ja5811L6E5gjqPHN+PcnA6z0/7APqkyRnOt7/pZ5a+MxGvYCxLD4W0kineeZgLQbTZuxOwbYr/EhoOYdUWzh+4rhmvcTIfwCYB7X9C/oObsCxQdB3ESLKfEg13wFjEjZnJZdeX+wQuKAaD3RII6VeOq3/DAsDG/XIcPAwmJAmKJNyB1CV9BhpcJLqHCVLeE18OiP8rcXhugAkQCF9iZz0QujpIYL9AccTXALu8ZNj4VavvJLlVDm/30u8Tq/RICFKw1MWhGyEV/RCPTiEBhqyVvBhkzTsHVTmelVT4AB8G3lPMGOLWDl6266l6QJfAGXiEarKAhPSCjxteB4oeB6SbNJsbKu8guDIdje7jpM1l6jx/X3qxR+F8B42wb3ovWdJhntw/HtRvderUIm/5RY3jhPQ6vfZL7nBTf/Cr+AbW+K/JvuDv3JvNDp9xv7+YtotAZCIwerPnCum36W/wMAOdxIeP8sfWUvyPdOp13sQRPXnJQjSTWzoHezP/Zk8CZbfy/PGEOUz6mbE/VcEet9tYjR1o3nrfDqP/YsuXYJfBJRlzvuP303L55arh4G9mamoASJhpnqh4AzeFZjUsfcNMuD3ijFABvx4vHyVjqcskMH+W5VVriDE7Dw== 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:(13230025)(4636009)(346002)(366004)(136003)(396003)(39850400004)(376002)(451199018)(4744005)(44832011)(5660300002)(2906002)(8936002)(41300700001)(6916009)(2616005)(66556008)(8676002)(478600001)(52116002)(4326008)(316002)(38350700002)(6512007)(38100700002)(6486002)(66476007)(86362001)(83380400001)(186003)(26005)(36756003)(6506007)(6666004)(1076003)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gyhHqPpWZYukn+7XrWodx66WdDC3oYVwVhO2+JU40Wb929w9GRIRPtoplxkEXOLy8eKq42uzkqRRLvetLwzoDc0B7VfJR4F7QEf8jtNFBPMJu4gnWbpCWpoMU30kzu0YfLnrWdqFca4KgVvD7NNBYjRwZXi67qyJCitLe+ArSHzbct66Fa3KSO6PdA5PZLQE720kEgJ4bE6xDUh7IcUJDZ2d7Nxx9B3XsZlSvahuB2gQK2csD/tbakccvokAyAOp3h8yOvorquCI+N6Qsdca122vzy6K30cmt7h6ozJYOsRXGDY4+H+Vo3O8KodV0aSNUS0NHQC1PWVn/CI7njIQVu70S94a/EVpB49EDSCXsLbMkvxPd4mom40CqICtk57e4SpSNWwhg7Zt20DZwautucIdWRpNHorJurcnF9iBgeDinb7dU4WYaqW98dsbedSZKb/IAYLo4c2XcyVLIF2io6uqIq0N3/CSfdO4/ad9k94RaAhbbs1hekDulM6GRsS8ZJBqmugNxVPlryRegfMIY1D5cCIt702CZPkowz+W3IgZ0M6aiKOmPpcZs6+axUgf+llbiXOmIp8trh73HpWpzbl2Usa2uEN6HHvp7EXVFxRJ1PIfg7IhtklmatXPepAmP0NhODZ1d1Kpubw2AI/4nNSaPH17r6nHdeD74dcGYrnIN+uFS0m+Ckitcu8lG6ukwHFxSj6H7/ftZkbz8kY8mjQfmtSSth8RgIuH4QQBYNNn9ZnPVE6jTe9jQ19x4ymnCctzTq0aEupalV5CRvnz/qXMc/BFdF/m3dcV8vMk7v6BWCCHQL5PbRqqVJuR7Tq3xHJBftodVJs33sywNSkBu0LHS3YJjdLaeydHXgyyTbJY4GjmIXbOdMfGbcO3RBukYaa5sIhZAu2O3ER3rwu0chgjlkhhEx4MTo+gz1n67cTx8jeGV0j9IqEvSMPK3PJKPOwonac9DPfe/USyn2lIuC/R1UMUp5eqiPNTmVzvu5ssSP5jrblbqtL5A5/mglD4dVb6pLrCFAHGaf4UXIvjVecxOAAI33Ecs2tM2aEsG1yLpUMgAD1C+rV2WM49vggt2JWXEDc3GEeemNtAUxVqiYRd/cSU1Es2qfOT7ECh90Z76wBYmDozTnLibfnzjvCogi3lmVTYUoryy8Ulu/iyDmhcHJ1KFZgrBZCLM61pQLTSs5nZLu62AGs1A76aIYqke0Zy8mAexS6mH9rXSr+ElSSlE1EVn7Q8MXakokPp2zXK8dr55A0AFOU8H1BaeHz0n7oExHVa6ICilE+5nyFa7wDE5l246cM/xFjTrmTAmKe0GR5CNs6tZmdUdJdwzqPOiljrlhofb2CLu/ruuktrMmltrhKLdxQpNUFmGaVMW2KdAxRdicaI15wtBTGp38yV0CFQk3c9W9uQ1YcCIDEtI2ksag8PczqXQ6FYV4/KBhLnRC1cndkEwxl1PRc9pTToodrrR7z+OboNfeLpuhoVfRWR+nlW8klZ7D0NcDYppxIdrRfRQqFXInd8pMvRQHOAB4Cw2+SgxLZcp9ZRpOIgzq2iOgd0pdss/6ldXTP6kJWM5aG4O1iOXUQe7iACeA6XPbQTzRJbSg4x1MO5P4DkVvQqKTJf3xBi6WJwLsQuZqA= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 941e573e-d252-4bad-b991-08db0375cbf2 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 10:27:47.2827 (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: uMLLDXtJ1emtPbOR3gYEbg8anUJT8ax6ffrPsmbS+kFtFHYPH7NsWGIYKj8Bm+e25fbnzfodhIIDkwNxberY0XBA4CLptmEF2i8v5PrxzOk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8615 Received-SPF: pass client-ip=40.107.8.130; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 --- block/parallels.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 4af68adc61..436b36bbd9 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -460,12 +460,12 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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 Tue Jan 31 10:27:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13122845 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 87B0BC636CC for ; Tue, 31 Jan 2023 10:31:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMnrs-0003Pa-30; Tue, 31 Jan 2023 05:28:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnrq-0003OV-3s; Tue, 31 Jan 2023 05:27:58 -0500 Received: from mail-vi1eur04on2130.outbound.protection.outlook.com ([40.107.8.130] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnro-0006VK-MT; Tue, 31 Jan 2023 05:27:57 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G/lVgieWk0CUBrIlULQBBPZPgzxvfw0LcC2HQ+iZwlpT9cc0BxKUeAhBOYx1srr3GTH7PACAlF9RpkHAIJ0awc6knGnkOpVjmGB+dkFbTgxyShKy7ynLfbOEJjX528m7OLULD4GRX5tYpWhl+bf4SpjG4ry5kB+55gVhy7lniLBXVtIXJ0gps/UF0gncB6jnLf82RDUza9S97lEMhfhBJEpBmhX+uKwwQwQxnP7dy9WDceaLPHO13kNsFXd8NeHNwnCrGjiUJ2WqWIhmZN4+J6fFex/KpvM4k1rQxBmiFN5G9xrJECpWmM7oZfGjTzi8bU1fFPlEwaL/CCvjEgeUBg== 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=rvz6ScsGUgHavI95St+g9I9z/gAbgo+9V0WdlrmWipI=; b=QfCJJiwtAZkD8dirwukne7hZ6wbvmiiDebR+vcj5U5TBJintNnqSU6sKgugfzg2kfKVKYlOPOezja5MsQh921V0cjwNHfopJmN8gpwL9Ll0qOwHbvKgu05X6wpUI0R/coI6DRcV8PPoF4slm/6882q7zdYKz7YUrFZN/7XfHcHC3lDINQHK86Nh6Bnl7KZ/HEwsTm0dJOR7AKMQwxbDh8xj3lakjAv85LafijgkFaTQ6BEedWYFf3HLgMEMKyZJt7Q8AU1zB4lc/ruNtZea4Hi/Z0ifCPpodQUvxsJIR+jgIrPQbgo8aDE5tEl0Gzm9iThddLNAN+bPnCJO3BfseBw== 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=rvz6ScsGUgHavI95St+g9I9z/gAbgo+9V0WdlrmWipI=; b=skoRjEhdZKv9z60XVVugEePg7Zf3WPkc4Qw7wiiejobJ7By3tg+YE1230MQSR5bQ78tn0La7hskoiBF7zUJHphn0OrWs2p9NSfTZlIinjp9XCilj4EtXrmNOoYKy9JiTekd9Nt3s7+b7dxt1SOPx4SmwL/ljqHgJAMVf2PzAGeBbl5ragrLrrTwFpBc+dvth9h/Vlc3726PbXkYvceeZz9q4L1JvZonh4MqqRJ8f9ZKB+n6xuvmVrmDdxwN3w88fQTtK0/VfIbSmMm+g8YBuFzGTEoYAvmX2+g/mHl/62grcbp6m+JO3uZ5ZWpTGKK9IOpLO4Csrtgqu4Up05d/xHw== 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 DU0PR08MB8615.eurprd08.prod.outlook.com (2603:10a6:10:401::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Tue, 31 Jan 2023 10:27:48 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6043.038; Tue, 31 Jan 2023 10:27:48 +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 v9 03/12] parallels: Fix image_end_offset and data_end after out-of-image check Date: Tue, 31 Jan 2023 11:27:27 +0100 Message-Id: <20230131102736.2127945-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> References: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR0602CA0016.eurprd06.prod.outlook.com (2603:10a6:800:bc::26) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DU0PR08MB8615:EE_ X-MS-Office365-Filtering-Correlation-Id: a4e5b01a-aa25-4991-c2a6-08db0375cc62 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uVhn8Ve/mPfL6sBmmOTnidsysyM3fRh4kTUkoVK8GzXSjzggjh6/6v2hAftVPZ9BbGw2usq/2sHk4GnK8I9/8C3aTjb2VAOOmA9PuSqFC6d/RgOzFAagPevpOOSxg3IoABVmTsdNhfcg5Xcz7CBSXKryLIT4cMxLgwEL1EkjBDSskX/WjQ/6DqZh9ZAZEnV1PyiIGjGwqPSxrsjm6yTAXDvL1/+AnI/D0fwulTJ4eKJW4txK0HZdc0CoHn8OgRP0W+JT3fAqiz1rmRljNbNk0gQu/u0K6uc0OJKtzRwp94MX4tzMocElXwug1yBMVTVTFpVzm1lY5M9MAK5QvV3HU54Gxdw4Vr/OP7Byep/EJ95KlqGnyNHc7r72W1eMsdTZ2/cIPZtQtwaYJ0610XKTXW/7cSf3qFnNPDNmS6w9IXle/SkgmqalJOnEisJUXK8njQsofE5A1oZvVhxms7Xt0NbljTTxnyeoSOXgXUpf17vxfJCQSOV2P0ZMrUWmfFXZdQUYq5Towtk6dCGXBOmFe1pUGhiHAvVbPs9Tgn2AsIWl7igm4AQE+tWou4NAqtVYQFfmL13LZl6cstSRoi+gTBKLynuL9EgPaOEaKdnD4gNkI9xpmBpzeOk343Luv6N/TgdN5KsL2InFxnWMZDLioSOG4wDjBsTXHiXjuvxrdotDOqYSnxyHHZ95zUODAPMB9ZKUddFTiPS/X9klOCErLw== 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:(13230025)(4636009)(346002)(366004)(136003)(396003)(39850400004)(376002)(451199018)(4744005)(44832011)(5660300002)(2906002)(8936002)(41300700001)(6916009)(2616005)(66556008)(8676002)(478600001)(52116002)(4326008)(316002)(38350700002)(6512007)(38100700002)(6486002)(66476007)(86362001)(83380400001)(186003)(26005)(36756003)(6506007)(6666004)(1076003)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +r+yjLbl+7++fD/WcOmn72CnM27gWGEVvduE7CJJb2+MMNCyrEhi80pt/2o3pweOXENQujr7OQVuC0pIChmMdW8s0ZWeCZ09F0OkrTADZTe++IEGxAMBQv3G9h+5Z8aWKofdWJl46Z9TdzE8I1GpW8UiPR4B/wjOhYv5SJSsXMlg+fcsJjZcP02A2N+ABImYqfxXUohrgpyJHlO17tzSnZEADOHeqsewePPUcKZvAQaMLeeREJgoY8Uglb+ZYh1qI3O4FAdjiKnCHLuPiKv9EmW12cTOcGuF7v8Sk16utJmW0sVduDbqCWp5PbF2P4LByiWd+hnB96LVYPddDY/A11iipfiif03XR1ypweePGMlbNfYSRiTC61Zh6BzAU5MM8vftHEzEFP374KKSPEgK/54A4EcvsvjQmEG0mU/67LWiIsn8Qo4xmE48eQ/TR/xqqkmDL465hMw5lsQJ9cw+qJzhsEzVtm92ZHkkJ4gxPhoQRc78d9DyMQr4SZaE8BB3axJS75hcOCKY8LyDPUY0SOnYBED8WzG5pQbKmISqeitR2cAKp6VfB3/umDtl5aDxHHBerFULfKI9d41L8G1tKXyYI7FG7TkoYoA/nSy3vJLzqG4Vw3yfGKotiFxTunKhwfmkYT0BQaOsxQmmxrixSET4O1p5nJb+/iBM8zCPYfNNcQ9wfcVctl9m0eplWaVrmNOk8jXB1Z5KD3G4EtmW6EqlKpMeyzJedZHK7I+7pIoJ6rMnZBReXf+dRZnzpOc1aKJjHLPwsrleqYl57sDC//exaSRPaVv/Ulv8Rtmbyk/ZAP3y1KUqgYwl5JipNhOO4fVNu4PqC7YMhTejGSIbw8tRgSVw1P6ptDtMGrBRspu7C2wGjuYeNA/4lRl3e/Eg+uLi5HDYIqeiylhHwi2d58BlgfOLzjP+e31F2bScc5HZ8uS8MutS21nCR6L4rf9sSZ1sUfIJ94e9NJ0dDMdzarHg6xJFFJlVg/qEPAqLScLN5nFvwJ3ZlidtS2bOZIQXQkuhSMKej+DwcLXUs8slHZdGdBGLR+h5/rgaWjZNJWT+s1NIVqa6HTgSK+yYS1Kw/2Fbh7DzK6LrWT6vvhACNPCJxZ6y8EixOvnsTumszReKXeUhqs1IBSkvr5ULY9WYoXNJf0xBuLyST8pFJ93/mI3T4XWlxlgsZM5hsWOyULRwrLUCWtrDaafxNExXA3ctR821zHzilj87aUd5Xe6i4aLYDqU2eiuk1tqAta/CSM4Vx/w5moy7vz5VVXPaWhckyRcRzs5S8+BM5I85MoHxHgSuna6XtpnTJPNPOXL5cyO5UsntCV1sfh3aiyk2QawuQiBJkZUSAde+uqs45cRuzb4wD0YIewFXGRVdhLuiy7TeJzQ8ZPh8sS0f9Ph72mlB4eCGoOyrV+ThYabRwjK/AKd/jLxv38FkTEgTudzz85VtPNeFnjc7aGLklV/g7Xade2IfkLGPpJ0cXOLNFFVr2GaMYv+/BUgxZIIiKr6SYIgsdbkLpMLJq5UpiMAyOwwCgKi6+jAf6ZLO42FRrQEN9kGKKkn4R0zmWnSGeZzsvMf51geTx2QqyY54nvOtZ182uz0NqUZANIHQFwOyArWGHHU7mmWpPUXhzGJ5m6Xcc5M= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4e5b01a-aa25-4991-c2a6-08db0375cc62 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 10:27:47.9700 (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: x3qRqAKakQo7l5wqhGa7gFIhIg4EREee1exshcZMzMq42o2oUnDBbLGpSKe46t+wo08YfEGJ3sb4bLTjw5b62Nsmd+WtMMeUHecLpB8nVYw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8615 Received-SPF: pass client-ip=40.107.8.130; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 436b36bbd9..2ed7cca249 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -488,7 +488,13 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } } - 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 Tue Jan 31 10:27:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13122839 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 62727C38142 for ; Tue, 31 Jan 2023 10:28:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMnrp-0003OM-Qa; Tue, 31 Jan 2023 05:27:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnrn-0003MU-Du; Tue, 31 Jan 2023 05:27:55 -0500 Received: from mail-he1eur04on0704.outbound.protection.outlook.com ([2a01:111:f400:fe0d::704] 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 1pMnrl-0006WH-Hq; Tue, 31 Jan 2023 05:27:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C5QlrIs6OpjL76sHx8aik6e+x5Dmfzlpt7QKoTwAyU3IxdStcyf7JZSP846tD7rCN/IAZGaI9nFX1rWKEpo3/aHFwH81rdbgissTQsm7j0KCSSwNlQB8yNd1paszm+ycJPr2MbWeggLNsBVBRTloYGB88ijdHqMiYn+6pLHUXmNPSxzQWcRmrecVhLRSUB7kSWzrkYKhvXHBkntcgAcvkVKC2EUraMfHR2NCcYdv2pOtZx3NxiCJijtsH1/BSZQnE+E+iFe34J0/pDHf4Z4ar6h9hqpx6Yz+d/HFfOvph8veGW3wegJw5F7nquq1boFwTa9cnYKZbTMXZRk87ooulA== 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=h2ts94JiKDu2CEKEoewinTUcevlr0YazshLv5T+UNgU=; b=TXCoJHybR0NiZm/ZN6dfVvxXQfBSGS13evy1edUmMfUf+WGLWrKgMkk/3snK4wra+DC+fOc3/hL/0l8ewONnwQmek4n6OneAqhDyZI8Z8QohPFL1iYwdRdNCQHubpfm63R4L1tz344MoyH2+bkKs5ulZhu13wcjr6OPGkjxy7vbrf9NVG3u68oG4n+b39UqzOJZWX6GdxiDZPvIk2tS1wOkVmIdp/EESqNMWfZZuRug9IlukS/qPZENZLVVMj/9MpaFrXi09Rp4ZJZzeAekkI23GNSzzi7+w47r1w7U6UTz8QPHM4AIwrTUy6z+tZQ3A/ynsGe+8vHhdJvHfor2T6w== 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=h2ts94JiKDu2CEKEoewinTUcevlr0YazshLv5T+UNgU=; b=GqVOWwBeRO1/P9PkXCzC4FtpcgL5qWbTm4r3I6ImCwEqICyO8tW2BjwdPhuKODXt+rdTbzZJMMKqbBZJDC+lOywodzP98zXJIC7iJTEoPqPj+UuebCNa0Kr41rIkoIHGBgZ5zsh6DLzuIJnGFjXk1ZaTt8Bd3hOA5sNcw5jYJB3duterOkgszMXdzd8g9OALpk/nnJExPQAYOd85Ybjik6y+bTaNZb8UuROBRxywMMT/pnXKt0lkZz0ifsNi5mPM8skbNHJof+sYqTN6JVcOYqgAx7Suro8+9lgVDOvOCqhZiJMHWRKkZw6uMwfgiHZF57qdJhanwmANYBp7CbgXmg== 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 VI1PR08MB10217.eurprd08.prod.outlook.com (2603:10a6:800:1bc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Tue, 31 Jan 2023 10:27:48 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6043.038; Tue, 31 Jan 2023 10:27:48 +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 v9 04/12] parallels: create parallels_set_bat_entry_helper() to assign BAT value Date: Tue, 31 Jan 2023 11:27:28 +0100 Message-Id: <20230131102736.2127945-5-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> References: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR0602CA0016.eurprd06.prod.outlook.com (2603:10a6:800:bc::26) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|VI1PR08MB10217:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d5ffffc-e11d-4902-42c6-08db0375ccc9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7Z8gQOjHL4UNst/Q06oT1r5ld8ZJqZGuG1v1E8MrJ8UYpOs9KYgyIZiJfYZnx54CxNIiH87/Swddg8TmDdITfWf0TDwYlQgXl+2GxllbDTAYyTsUKLvKZ8Y8Xo3t6o3lyX83VZQ4rnn6I6+RpYStorhkBJQ7AZcI09rrlx9Mu5dFaXXHalrIh6NModW20FSJurUxffLRs6aLuvLzy2YHu2i61Y78SiALdVfgU0JWcmV01x/6xg1+nWgEDPD/VhVcFTgewWJzUAASu4lPIZB5pYt9k4ddpertwvPPuZ0tQ8q2wefENgK9NGxsoFZIMmgL20r5DxuoO9rcoBYmP/SJznJ+JdCi5GwtZ9+LBb9NDoCwf5V9bTpjUOe9B+iFGzzY9pim+RGWU/h9pMR4McAtuWLbuGxMtN63V14B1xiyO0Isqsu/NhAT0ZuXIBIAMq0+DlDxr5KERqnPFE+SaX4QAzBHcODcccf4mr+qOm+OC95NIJF+2z79UI8oxXp3Tbc5KMtVEqoPv9fPQWizcXq6uZ5R0v8ObueVO5Ta1miW1bZ/aG5egs2Um0QB6BT8BFt03BqCSRMaZYZVLOsbLbcD1FQFa03BohhC1fuBIta+JQwtFj7EzrmTPxvw7ik2vWM6J+bADX9QucFjfrY71d34iMDqiu9231LFkSN2KHJSYc118bp08Q1U2soCGUNR8yQAIMrGYTKmXGbvLHX6QAKrvQ== 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:(13230025)(4636009)(376002)(396003)(346002)(136003)(366004)(39850400004)(451199018)(478600001)(6486002)(26005)(186003)(86362001)(52116002)(83380400001)(38100700002)(38350700002)(2616005)(6512007)(36756003)(6666004)(1076003)(6506007)(4326008)(8676002)(66946007)(66556008)(66476007)(8936002)(5660300002)(6916009)(316002)(41300700001)(44832011)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: m4teQ8zNRJLoVmfBg93MuNUN9uH+HjR9UD5niep127B5iexL2pkDlGUrvn7m/IHvv8Vi2DBSyohKgqi96QF7+on7QBirM4PwIM9DSlQOugkG+CocFFQf7om6r+v3pTtDKv8XBoG9oJaQBg5llQiGUi9OBnBrkZVmaddAT9abEMOzwpRQFxsKV0/HgU39Mub0uWiCshxO0/gmflgv5cl7guBxHblCxFEjps12RTNIFOzHu3JUzl+6K0hr9C3YlSwcKXxQIT/TqPW3k+BHT4pJjPS37cuFoH+Ny7lzezMfMf0MoRzUf+TQFtOaJiA2IQtfMIau1/kdN61+K+85xPPlWxWlTmiKQuJxaN0xIXOlYw5u4CeajKUJ1lasv1ueG+pM3WPadOYGXzbhGyQsJGqX4TOlmilvHEfrz5DOe6uGf4R14ShXLitRr0oxxSyE9IuNquaNv7v2AXAKeTj704O6mCMUvh0OcauUJC3yNzL93Huw53IlmTsCuuHOVLTz5MnAbLagWXpRmThcof1sDicRKxJgFIQehChkKAJvBJL1mowkO72DyujE0smArLL7mL3Pg88HTFjr1FplKH3y4teL6cB4GnvQva8QeLyDbJOm2q32HmfZ9XUjtriaMht7YWDEcpjAFtAAsTlC5h7eGm42JQlyE2jIxPk16oVTkLa7N5PXM5hB0Yu4p/kTIXC+UGFK6VwOHhll7bYOJa2/I9gcr19HKzhYU4zEZI4rJ6qHAVdK7sGBoCJpFmUC4SqZzJPqlmyrPSnS1LDN+JXjtBI0GSWaJBqx2qZxRXvkdMzASZ1giijSEk7++1b/f0HkV3ipCUEfYIZZgo1xZcsjkO7MQAQuvCn40LlU/xuwUpWH41Dkl6B2ePgGmhdHV5lch8FTO3sSum3bDDPwLA4O2X1eIW8rctSujtAnjC/HjyFkycYZrseBXuuayBYP3aPM4r7m5G/nyUsiXapZDj9MBTimD8NiT+YTpK06RGqNtQR/X2XSBs1kuyRifaRp5zHqPpOoPFq1RiMwIle8kaklYNhg/KKv+9Jlf1C106U6R77aIDiFGsZNaJxOZzt/jYZ6O+SenqRncZ9Hc/eebKyop+b9F0ExBDeR/UNh/urcePo5ut0qHmT3J8MAM8a12ZNiLY2wqf9hcWFbBCZ3FWf2uUR1+mgimPtFGGUsrmRIvi7DSwWtr61XTZ1RRxW5U6W074a/Z9yFVv/fMd1P+U1WfQt+M8AEh5bnRSQ74QWiiGWTyz8aakaRnhiq1F/23mM9PbB9y53BktZrHda/4vuaUzxn6N77kSaAwEGA0Azuc1WNf3Xx0J+DTmVUZixhF2I0zh9oPr62rizieKpCgbfzIht6x31+SLPO3CQwZRsAhWrQilewLeM2/DtbAX3SbB8RMt9IqohKQ69ST02suPrty3EUUSGA1qJfLitmdaGWcFwxWzqzzaA6HbURxUEBUl9BrFDkKsAcZEvBkyvvzsxddL4Cr5qYRGJ2fL0zneB8Sk5JxHhrWljDNSL0+CBIbPABgbPo01GBSp1ot55N4NvJfwol9rgELRsq9mGsP0AyAzyBYW2jc9l0Lpx6/41XnCzois4dLP94KnJjMUTvJaR76T4IkHTIx6pSWnFpzHE26Z0IEEY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d5ffffc-e11d-4902-42c6-08db0375ccc9 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 10:27:48.5949 (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: 62eJzhhZuyMY9JcWc6ZUWkGg5k4jQdpC2IkfUTQyQywIcDPM5VahZ8H+NWQekWM6bLY2K1U8tn3hD+UiQb7QSZ90cob+xg6bi6KJsopYy3A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB10217 Received-SPF: pass client-ip=2a01:111:f400:fe0d::704; 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 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 2ed7cca249..b2e3f5f98f 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 coroutine_fn int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) @@ -251,10 +258,8 @@ static coroutine_fn int64_t allocate_clusters(BlockDriverState *bs, } 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 Tue Jan 31 10:27:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13122847 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 84F81C636CC for ; Tue, 31 Jan 2023 10:31:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMnrs-0003R2-U2; Tue, 31 Jan 2023 05:28:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnrr-0003P8-4a; Tue, 31 Jan 2023 05:27:59 -0500 Received: from mail-he1eur04on2122.outbound.protection.outlook.com ([40.107.7.122] 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 1pMnrp-0006XE-D8; Tue, 31 Jan 2023 05:27:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TJ+mulaqi+mtqFEahSsTOgu7QtBlN7baW4lMDA6OYXtkuPB/ZL8bVX9rf7M+JhiWsKewsTHhgP9F4l7+aMWMw2B08IPwrdUpJdMny3NM76R/RXmW9fWu/YSc54njznUpD0YN0njrrLCXlLjlGbrkVGvUl/wUzpHiyWC9PmIQdIrKl9TvCb34OgEoSlk9GvCdUDMZ3+Qy1gnN6cSjTfn93sVreIG8hK9qYKDIj94sbGoQ1wa/ybT5zOPHoFPJjvNoWfLvtrlHKKpkg6s+1HzBjp1oQ9hBgI2mB0GA3nTFQdDqG/ejRpOxJgJVhQfiz7OQrd2zL7z0qih5XO39Ms2m+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZWHA8EJjOhuvT0aJtGXbHtecNQioXt+iEQlas045jas=; b=k8E175ZIUGwo6HVwLtT90zQB2WkToz6p3+YSsYQZGEHJvTAhpR9pzVw7xr/n81qJdgAP5Tn9OLQsuqTKobVx8BjOJDCjMlZz/KNH7/xuEe7ON1kcAi0L/HYDM48anEQb7wbPFEOVkfK7K517KDbiqHKwkzA07SC3nMyUquLwM8nqfaj1UwvrH99OxpbRBcJSpI4e5ZoL4SfxyAbuKwofwdngLIOdDVPtcCZSGaHjfwQMMqRYxYNKdO7ZsaZCBqOMIh0icEjLCUWKWqbKCYCCrVfxybSDD64kp0LvbsNTiSk21JVOeCneFFwWLcI1ecmOCVl9mTjAfCZ+Yz4WQ2PiGw== 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=ZWHA8EJjOhuvT0aJtGXbHtecNQioXt+iEQlas045jas=; b=BHtwG2CYfAYMT2bcu9+DYS6iJd+cYoE7jqFKVilZYmHg88eHr9oyjNaIpUKnhwOz5vxWSs/2kXnEBUTmh2sy+ICWNGjTNJ6M9+9Po/S2XEYYtZicbjFqukIo8uoVcWkB6BFE0saTvBjUgXdhi2wqMuej2jMBaJlX1SwJhzWziGfpfgArBE+XgD1L4XSEN8ZKjzOvZbM2wbUpTZF6frXeZRg07PPXTSUsEMWXMSbWHMc61qTGVW5bwbhgJB4JCdrmU+au90TVj5/HGyrCWReLabh8hjdS0l0oj3ABp0ppdGN7HGQeFtZtBlCV93NoXIHb538a7NePoBADmFsAXaQD5Q== 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 VI1PR08MB10217.eurprd08.prod.outlook.com (2603:10a6:800:1bc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Tue, 31 Jan 2023 10:27:49 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6043.038; Tue, 31 Jan 2023 10:27:49 +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 v9 05/12] parallels: Use generic infrastructure for BAT writing in parallels_co_check() Date: Tue, 31 Jan 2023 11:27:29 +0100 Message-Id: <20230131102736.2127945-6-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> References: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR0602CA0016.eurprd06.prod.outlook.com (2603:10a6:800:bc::26) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|VI1PR08MB10217:EE_ X-MS-Office365-Filtering-Correlation-Id: de64bcb0-0f93-4603-ca35-08db0375cd28 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N7x7YCJ3IbCXyE+7KctiPbcjuvxaxOuEXvIRCfycuwdfW4zbjJZQqEteOlltHIYE19CMr14K7LcE97vlDjLDbnVmTWX6mHyptwh9s/SSmCL1BEn/d0NNllV194unVQOJu/RfYAy7CUo/0i0DUu/bmkqouxaP9SOFz53GiOd0M7RmE72eURCzUM82PcBXwACRkRxp8ALWvESljRdi0JH46FCA9CaihTxDLBIbAITurVUhzP6SjXzq5F5BzxcheKUn+A51WvdyOLqg876nsO5FTl2SztIITs66zb2hI32TWp/e31ak/jbWen6Yly5ZQCVeSVy5N6lnU+JEic36vQbzFL7hpHBX6DifmHrLO3F/9v/B1MW2OSH38i5crqVPg6K2DLi06Qxjfcg9AT4WkAhqTiLEptoT3djcbtj1I5f30nT0TWUwAKT/hAHz0API1xhnCthoh0nqY3u/6lekJ21+UQaLElClg05F5xY31vmJztXH87R/7ubRc7LvZJkE/5MtajBzQyE5urO20i21+2vUnVRQZPK3gI02iuuymjbhO5YFFGh6BHRGeFa6OXJ++TvFbavgfJsYt+VbCUdHAf2DPrtIh4CR9qhY8ZXTmBbULnN8wCCcBDwKFNvCBjLvY/BEaJuELOgUyPKA8Xn+TA/Qi3HAnytPy0zUpGhF2jjcthkwr5USeLg77RzqljaM3y+PgP200kN8VXLy51hC0kpeMd0+PJQ0E73yniUb5OoQg+o= 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:(13230025)(4636009)(376002)(396003)(346002)(136003)(366004)(39850400004)(451199018)(478600001)(6486002)(26005)(186003)(86362001)(52116002)(83380400001)(38100700002)(38350700002)(2616005)(6512007)(36756003)(6666004)(1076003)(6506007)(4326008)(8676002)(66946007)(66556008)(66476007)(8936002)(5660300002)(6916009)(316002)(41300700001)(44832011)(2906002)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G2V2PzWAo6Y5VkgXw/5MP1PrXhYE9all6Z8qN/YB+JwtvfT3+S2F2ocztzZsqbBvLkNB3PrvqM/UueJEz4U7CbvnynP1dK5Sbbp8D/kMHDJmFFs7rSxIAeBtaokUJu6NgOGBbj6A9iyfkm+eT4JuO8gKbietoARFjnQeVM0NMhAITknP97kwm43Gx5q5YCUkSpbgLeOFlcw3VLLvOwPgjjMFECLsLyrEUMlhIXdHKkkwH4EcEFnWBZGjHZEgNHBKYQ2xJQx1V0/Go+IvXv0Y++e1/K8qg+Qn3JgKVBOaa+mWVFXwJ6r3xYqp5XFre7OK/iKsGrKAuuCpMALPbTZ7CVICf4AGjyNTWOopnACu/5c2i6YyutX6D94LcNaQKPdpcWJfCHqowQGgszi+lKOghrLbHQoqG4Lvkv/wDwfDXPrzQuU2kIIIVpXcuYDXLChvgmvshQDKZQlCxor43UPAsp6VOMVgsjXkl4TUKQcU8ZuG4pN8CZh39nO7tVSChCm2FtSH4HzfTSdF/mDZ0N1ZeZgIkkFu0Ih4wKqS8ixuLst0TSTiY+xwwC0XaMq7VIWhf+GRhDf+dtMnS2GMifytdLgFCwK2wMoBsX99RYA+5Z6LthktfVb3QZFTVKCjgZ/ftuaaDMJdIpOksCLCKIP7IwgKbWay1PoDAKkPX374D88VdyahlLDLYcoo71F+OzYZyYM0jW7Er9mvplYepPBomfKqxYKJc48NvzL/hP2ycU49tvc8yGN3pOBMtvwvTCQPVWhMhRCAXHW+5OEmR8/70e4TvCUbDCYoEFLH4F6FSZaUXDrYpk0wmsQ03uoJociz7aX3fL/b5G/SefCfjx0FjfoZTU01xVdC2ZXK9fInL4ziZxlF92gCsyC7Q/0m5IbP8D/fUU9KAuLO68qQybZ9LtwNF5RcH8mWvTcrLhbPZMuDz+EZsu3PSJNhgP18Sz4ihVrjsBT2zXP6QyYtJLuzni1xgfuQOvFkO7Jl4E+ICu7E283qkkA5B8H5HSx5qstL8y6TbF9kcc3Bv04C5Px7G8/yEa6RlMZhws0tjekDSy8U+l9Ha1KikyaTDsE+SSY+WGPkwjfWBTVxEMJwKVKshSwSlVFmm5akzHGAjH9H8SAsqH4b0Z4MhcPcwG8hNnq/QbgPRA/hFzvefNOzLaoUlyTqyYzhsnFc68y49ixzbfx1D7NAYZz8PR1kWKTdnI2XdhxibjFmzFHbaLlY8BNzILebuj7wUMZm1j7Lae68P0xQhufXMc7vVkQZLz4QYXxBjwzQgD3RpMwqcrE3HjntZLB5SFfMle9BzKmI81iW2msQDOXSlCOz4sx6YYG26z78KDGDZdz15hZMg+ske/z1dvFjScJugAitJ0hrmyIeX0rI5ZkmUKXQPi4Bj/pMleV/zvNS8eEu03KkkvcZbaS7Er8nBIpIJf9UY9ojXOVbKethNwEMiuDr9AeHqv0xb+uibWLKtY42QyYB5+CJA6GovQmdA5JOL09F7UiuswTcHaqk74NXF9UKsyKKaeEdZBw6s3v+yOknOO9nnJfC8hDCooElRVUEtJ7bd+m5heQuSrHEGQTaGplF8CseClBI5lQ70FviPwc7TN6EWqmy79Nh4GY1pLCUNPUMrHMWlHC5lzo= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: de64bcb0-0f93-4603-ca35-08db0375cd28 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 10:27:49.3772 (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: XUt5w6tXMLlWhZIowVMWRx3DRMaPxtKLv1XI6W8gQwL76hL03iQ7HbSBd0lU3ny+nCRPS5nKlnHTaAeURCE5h4BBneffc5SPF8u1qDTq94g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB10217 Received-SPF: pass client-ip=40.107.7.122; 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 b2e3f5f98f..63bfd7074c 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -425,9 +425,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, { 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) { @@ -465,9 +464,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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; @@ -484,15 +482,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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 { @@ -527,6 +516,14 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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 Tue Jan 31 10:27:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13122844 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 5188AC38142 for ; Tue, 31 Jan 2023 10:30:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMnrr-0003PU-SK; Tue, 31 Jan 2023 05:27:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnrp-0003ON-NL; Tue, 31 Jan 2023 05:27:57 -0500 Received: from mail-he1eur04on0704.outbound.protection.outlook.com ([2a01:111:f400:fe0d::704] 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 1pMnro-0006WH-5e; Tue, 31 Jan 2023 05:27:57 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lLqicKppezCQrhLPHE3xMrCrwN/q7AeqZ0DutT0aoF0pusmDEhmhd0P2lRkdMo1AuYW2XsUk4HiV+0+dZ3UFQKF8sM7ApmxGbgR9PulflDHmy4DUH/6iSPAbYbJDw1icN+S6i7lFv641OkzDLnJqnfCxCywHpig3SuK2yroPdCjlAoxDDmIWaSlR5+rOhHOWydqfv+em/Tu4sl6IdQpHac5+3IRUYO9US4lsgHp7DlLmYAtspljchxKGfKwtpwzAYpS1zlBAi+Ti/aWbN1Y7iS7aKTcnALrYIS1uaxILNtL4TqMku8UPPDkAEPlDJty815yDRUrN6v9ucjRSdhLwiQ== 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=yHHhH6GkEPcmWeaMwexhl+42aBznDOcUp1XNu338ZX4=; b=XoSSHvKC5QZxqZcFRHKLtlsBCt9vKzkwR4YyRv3I/Q64+Je4vS5huQdTQ38l8vFhJPctS1rW7ElA6YNKRfO9/rw6nzNI0/VPfBvqPzKOhTpAbJYrJsduppvA0U1VkrGU4uldW3w50hybxQJd0aujl5Gl2VOuNOIaCLNY5HRO9raKlZCZOncsNqprht9M0QF9LcAd0SuMDT+53qlGPh9PErYXIoSI3DUauTYiY5CdK/jhdnKkU5zEBKHRtyZjBS2WylkIah6m+bG9X4fr4Zpeh5+a9lNznFIRODr6chsEyTWP9MWScS0mktsUHFYEr+eEPz5kByih24QZabr8WrRpsA== 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=yHHhH6GkEPcmWeaMwexhl+42aBznDOcUp1XNu338ZX4=; b=JxqqjBZ//Gl4udlDz2JcNw0TZuVMkvPD+PtVqUbS/RpBB5AbFpl7Bc8OnVeudPmu38gWdfR8PViYWEi0xyGDTP3CJk1L3J4VZlO5pznEtdzNn942kL3UoBavffQztpB9aJiqnT/qqBfxWpZKT/Bj2t/nwmIhniAaTWFGO3vQYWq0xWXVZLcmQ2BM7oIEvAT5M23rPdsbgXtnLtHiN9S3nLK3XCmc2jB4p/hGwRHwRkRA1cBI1AIpe1h1V4qS69ErMyjyvBkzDNTqJCNsQXLD8XL4SDykrZMp8oTuo/3/ligwsjgjWSMZeICJCSySDEcEZYcC/dEX2exi9uZiuklEdw== 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 VI1PR08MB10217.eurprd08.prod.outlook.com (2603:10a6:800:1bc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Tue, 31 Jan 2023 10:27:50 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6043.038; Tue, 31 Jan 2023 10:27:50 +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 v9 06/12] parallels: Move check of unclean image to a separate function Date: Tue, 31 Jan 2023 11:27:30 +0100 Message-Id: <20230131102736.2127945-7-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> References: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR0602CA0016.eurprd06.prod.outlook.com (2603:10a6:800:bc::26) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|VI1PR08MB10217:EE_ X-MS-Office365-Filtering-Correlation-Id: 50a17aeb-d778-4074-f9fd-08db0375cd9f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IrILjtLILb8J7pOYIS4UEqTtdmZBxStRCG5nLE31/2Wbfm/M4RRVtKNKgGwmQ/nDs4CWkJ5jnvTQgwnc/cGHFUee2Cum0QaTDHajS+dbBNTiBtOVmtc8cINqyV8r6AZmgEwdgXkqtB66HVXGcgyMK1C8dLmQagmtpL0b7WfymeXBCToQy1z4c9AbOTDTdzJwUw/qodS7MKcdqIjDx1wK2Rfvugj/jKln/v8GufV1tNVy7l88mnb1M57zhA5x72a0O8jXETcBydkZKy8D9XhcsXDQh/+etoj90jhl79JsvkhVX1DE978Scj/kpWDxnA6g9DaLo6zSUiKNySGM9kPv3m4/VPf83THv7VwH7uuipnlvRYSOB/J6bHbSb8ZjWYkdnTU0/UJAk66SI1dneMZspo5+Yfi0HCYtugRO+/TzoWPryfZYVnF9vYF7dEUOPByZsTGZ16vAPTvF2REiwgSefw/nY0x/KBSU/FH0/b/QQoOwyh82fMYya167nVgbUW+gWcfblqv90PB1zt5K4NyIQPwSKYxZd2EWIVMWdRNnFP3PodUEdV+hNczJkAE5p+EiDUW4fZlSspD9FnBMj4d9C0/uBzMpxMwEbW29UrAGCZNhpZ3ZMU8KoRrFSVz7P6yKjkOsLsEduQ06tbfXekQ37Gi6NHAGMeek0l+TBy8kjCZWSpsUipm5ogOgHvKGK+qe 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:(13230025)(4636009)(376002)(396003)(346002)(136003)(366004)(39850400004)(451199018)(478600001)(6486002)(26005)(186003)(86362001)(52116002)(83380400001)(38100700002)(38350700002)(2616005)(6512007)(36756003)(6666004)(1076003)(6506007)(4326008)(8676002)(66946007)(66556008)(66476007)(8936002)(5660300002)(6916009)(316002)(41300700001)(44832011)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 73CmStJ+7eptBAVZKZvpOiiJTOBziqUmr536Jn/OO0d5KXsUgwGf+VxcfsnyoJlDmN3LDhQZjGAmPjFMjXesVHCHipmC++hVOY5z/86wAhHN3Htp6yCj/bGLHSM7w6yHk+deSgaTGy9jUMm2T1UEaKhZTBWrgMfmoKG2UbmHfmhU3sXOY7WmpR0IfwBOZ/1n48pG9NBMox84QmYoysw+5PZWcEU4YL+UalMMkmMwU11omD/iEsgGVLA8O+kjqw65vKK0CyqD/fGl+qMidRoCcB6UPwNFurKkgKAOdw7UVBe+/0rf8WYBYPg38/K9doLdCRVOEdbOSQK10nXWvlh9IWmmQLlwhyuYa1/u0WS//+ZLzYfPYRRgZiIwncuhETjDRRQ3OXgMT4ybU34NIE5Kl8zc9r9sC7pf6Q4xBk3GgXgXMaAPIgMkmhq7o5lsX8idqvJvHzYpxqVC6SF3i7NKNVRW2aosjlb0zb7Qyuvwm38P8EzUgb/Oig9ByZ1Bl9KQV/oEEPDQDSPt0G602U1fhidkCO4odKtn+SGnGnWAMlViijtPt2F9BodogZ4kBbXc33yCqiuVbXj3lRFUqRKK/Gb6sByuK1LZj81huy5VOBn1Gjn6WW7AwOZkkimYCQmzmHJMhWc7nWttIoAjYT9F8gd/4bW5q4jDWTN8ihJl6+svf8hTYVRGjYYWWZeJPBFp0fqtats+AvyBj6XQeZ/CpUrBeWOitEReDFQVLaTaW7dLsh2PbGY4QSfvR7XiMi0YHWpxS2rgQqI0IF6hoG468BkEDFntCIbuXseVzBF4eFvBxTIV15qbMR221cCzCEhqJrpwyYA0boHQCBvmkLB4XyrnEyfqaFUmU9Vo0gKwa96w9kf+XB8Lg7f8J93cH1SwOGpKWEeAxBtaU8FO6aUHGdPKtGygu7O1vQQSrm6+vwi60cix+R6dkcf6qRcRMwqRK9EprfGVL9heelG4q6Z2QqmjvgiKWwUxW8IQu32ilZyjCYDg+I5XZQJgfO8afCLik29lVDh2RkVNRkT0CS4q2GgaYr9+eImLOd4HZFyshmS1YwNpQOn2GZHLw8f9TNlZvRnwW0/U3lxe0j2mecoKpoC0ovhdbPYrJVBw2hYo6TdfpbSMOS2ZREC/BcB3y/RifVLx9T9SaraAkDVG0srzyBbZN58c8s0Qusa7mqn6KGFrDE0qzDh3r4n3u27ynN/xftLw01EVjbSjRE201X+Dy5J4YT8xKOh8ozMWX7OhbLgyHAEFRxrWaXRFfpzjKsiDdWG1U+9Wy8FBUMPPirton/rZ/sF8wlmCm8YvcCU2a9vfRNIEcMRmGWallduXX26fo0PsY/9apgQ0e0s2lQ0Q6NpmPj4e9Nuad0oLYgf4Vc0ZLsxGh80rbJ9drFLC8w855ohVauw89KP+B2cLi0wYHccllGMDkZQSwtGMuxHK6EKhnKaj3tXmJ8lNYutt1qpELMRbjICni8/exFv7eSXkMP2u5ydj4V0EK9TZ4PQ9ZLnH8TgvVExI3IZvLAFoK787nbXZ3ZUGCTkhX1pN4bHP3WqiV42tdflxN8mK365glQYrZwHZ2py+R7NAyVsk6wHbRkFucP0RNnyF/ldQ3ZuAqTc4wS6pVbGB1L3toye6BBc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50a17aeb-d778-4074-f9fd-08db0375cd9f X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 10:27:49.9864 (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: 9T4vTU4xlRwyeRrG4ioQjMEHSn8VPsd+Xau5tdq0P5M4W9nmyEi5mcUaCSRUeW2B0rbnrjTD/Tcdgk0V91b8rdsbome+1cOKGcwZf6B5GkM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB10217 Received-SPF: pass client-ip=2a01:111:f400:fe0d::704; 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 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 63bfd7074c..02fbaee1f2 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -418,6 +418,25 @@ static coroutine_fn int parallels_co_readv(BlockDriverState *bs, 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 parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, @@ -435,16 +454,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } 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 Tue Jan 31 10:27:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13122848 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 7B5C4C38142 for ; Tue, 31 Jan 2023 10:31:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMnru-0003RV-0D; Tue, 31 Jan 2023 05:28:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnrs-0003QO-9J; Tue, 31 Jan 2023 05:28:00 -0500 Received: from mail-he1eur04on0704.outbound.protection.outlook.com ([2a01:111:f400:fe0d::704] 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 1pMnrq-0006WH-Kh; Tue, 31 Jan 2023 05:28:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ka58nzVGbTOQ+rDGf0B/4aS+LXpbYk3WWUB4P4FNOXqnpmqpWsZTIEG2uohIWB4qVF8YjiON8oNATbCCo5+rJJzjUpDll+D5vt1MNHgaAOwUeePoJ0N76a0+T5RpT6tEoiyXab8ywKXI9hTJCcyrOLT1mzk6BO/RY4NrTrX6EJja6Z1dudWrcMtqZAvTIIJAfJz9dkUGwUHBf+li1ajDhGJJ0AdLwBt08k5jEHI3F+CTCPBRsW16Q676xnYPgZdmxzp5zu6KefE58/opCKD/CGpaFt3kWe/f2tiUV3/h4WZp4TF3p/8NtDkSuZ9VwOU9LkOnE5reMwLWZx36uhDOtw== 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=OiuuyvlLvU7PBeR+AaFndHK1L8XF+44rEDOFdwsVsKQ=; b=cAeQ73VEnJPjrp+H9NXe4aXYIZWrUFP1+t2QnBu+yWRN947vgKaqA7VVnNSZKlCWzuyoUt0welMVqZoggHA66YxsOEmqgM1yDIrjyBygF1wStj25nZkBWwXCLQ5qs/kfqQakzViRPcS1Q6bdLWNc3/jjxWTdrgJEBb4zlSkfdo95XnMeD2bFSTK9uUxiCmyMyJvpPux06Qk981AnnsE6Bc2L2ngnHOup08MPGfz5OZI68CkScAIQ8E2ClHztfgEdpqf0YqAh9gV4j9GcEWKdbkHeT9q2sJPt9MjKesB0Ae5rIjncbd8PiBxG1g3+NImIn/CejM+JkeD01EG7x320fQ== 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=OiuuyvlLvU7PBeR+AaFndHK1L8XF+44rEDOFdwsVsKQ=; b=aqOJ1Lp1QcaM3+336XT8BBOWitBCWzc/tCQi503qNdf2qO6jq3IAN/wXGTXJId7p1MibmE+cqhVIK9nkQh6hHaha7S8NhHkOwPUezqcKkjr4CEWHjXscfjU5icBOX5bTMRUdZgMSx05yzEE49gQ3kiCyJBw7vgSCn5dKAhOXx9zKbUpl1un4M7Id7H/X/qAdLVNB0zE1Y5iOieWvKthQ9bsnm0Joe+imWTdx1ARsUqJ8Qy7xrm2bnA0mp+9xqi7K7ratGpgeLz4vCACkt8Q6Mt9s9PTei64A0apgPYvScWS742v+2wlfoaZx/zhQZLsJEz6mpF7ZX0aUV/Cs18QrAg== 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 VI1PR08MB10217.eurprd08.prod.outlook.com (2603:10a6:800:1bc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Tue, 31 Jan 2023 10:27:50 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6043.038; Tue, 31 Jan 2023 10:27:50 +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 v9 07/12] parallels: Move check of cluster outside image to a separate function Date: Tue, 31 Jan 2023 11:27:31 +0100 Message-Id: <20230131102736.2127945-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> References: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR0602CA0016.eurprd06.prod.outlook.com (2603:10a6:800:bc::26) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|VI1PR08MB10217:EE_ X-MS-Office365-Filtering-Correlation-Id: fcd7407e-bec4-41a7-536b-08db0375cdff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LoSivzJqiPYJ74auqlS7UP7sKG9ssna5UHI+up4Z5Fqo0b3XR/+9nUPvJziPa5Sc0Ox17OFeDljtqyBbI6ic8iZenjRo9hzhjOcvXBrgNrzyQp2O9YJeDsG/kuasDV2gKiOz1G5I65CumHzTvCiI3yw+T4ubQAY6Gd+x9oiF8vdcyoNr0WYKlXyERQLZCPDUyYc40FGoTm63c3u1Q/99zkm/e2zefAyxrFpDsnzeODiEKyRY+V4YDtVTagpvks5WsnmBdkh0P8rB8kJOFchDPW0cJj4N8Oa7dgFqkMg1lqnse9cxrHa7gJyUNDrE1KPor96zWpaDHREEP/2IkcP8ijZ8w/8roY11PLaDk/AEGR9dKMokVHt48W4l4nOubNheSxDowHdWN8VPIwaj6pltzW8Mu4n0p60tVlZBTsoTvfByc4SRtbjlUIqv+veQIPtZeAwrGHM5T145PHfOKVUiG1WU9c5hD8XO6rTWND7mlm/EHUkuAIOVO8djTy0GAsDyQUZEP8dYN1cOWgrR9grUY1Uy7r/iPbW0TZTAZutOkp89UQQd/nHeoADCA9vq60MR8ii0Sg0NXim/CkNvK8bf7jVyeOuT996fFANS6eeVuFKhMnj0Ecgcco44lVfth98fKi3kQIxSqVhpH8WbFHAHT4b0oRTMVXdRi582ct8i6AxRkBa54NOhZYhBFxtfkLJT9lIvI2wLMJyNSo2N0e9rGQ== 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:(13230025)(4636009)(376002)(396003)(346002)(136003)(366004)(39850400004)(451199018)(478600001)(6486002)(26005)(186003)(86362001)(52116002)(83380400001)(38100700002)(38350700002)(2616005)(6512007)(36756003)(6666004)(1076003)(6506007)(4326008)(8676002)(66946007)(66556008)(66476007)(8936002)(5660300002)(6916009)(316002)(41300700001)(44832011)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kwNBSEquDnLvEjjNqhpfAAJW1jw7wVo3QoHzQ73XwwrRM9H6oYoKaGojCemYCVbdD7mtQB47TiyBYuuJKsUqaBoAFNJDP8zJNnlOSkiEBddipMdXWuAF6UgqE+yBT3WeBtdBsMlu96DxiR72QMv1vprUBcdiesjPhJCYnJ5os3A8cAn5bQ74Shvi/MHKThhO0o816jTC7H/OVhrTEPuWgOmj0kbw7VeuNyoZ7xrYtb0XIhfo1gwqsNS+Fk/GDtQyTjjbSM2jIjGpC5b6u0H94Gz9biC2LXg1ts3FxbwHa4XINu0YFsRBxzXE8sK0szMn305AJsB+icnu2KkYzSdDQdV2Fxqbf4xz+6ToTMtIh2xxpYJiSy2wkbjzFEhjVDhv15aZqW81nW4F8ObXOHvAuLnw5G0t7IfP66LT82M5E+cUX6IIowAXOxJ/TLKRDvj/1v+bc5G0OpjFuJWqATiwFMld2cG2gU9JlVPSJseRQlc8lV+bKmcxMEmGN2UxebrrhCxS+t6Io7r/55CLGzxFqLKZnZvrZWl4R5bubRZfmuMNZ1j2bBszBuNogoUpIQqaNWs4Ei7pMyaMp4jwS48KbQbYfurfYH36Js7Y7FmSA6LTSjQxeXa0OtEYYO7I1VfignJ47VIeSf0zVDZPx/cA4hvFr1fDNkZWKKtAAz98k5b1+shLu7SHxsX0sYpjseXcL41vVtMNu75OkBLNdyKnvMPrgPgtSTo/HtsLrT+RhMSHDAMcs0fHF2Ki4wc6swaoXvxu+OJeXQ04cJrAnTwkZZPR1JpBNT7hX6HaaLp5EUAntJ041ScwFuKCZ6SLuMamQ3iGv/k5h7iwX2j7bQMQaAlKYx2KXA/z43bIusaA5vhoH9H4qNMoNzpgeWEBVcs9sL51Chm36chILy/3ENOQmdEYA1Xzgzih1F5LM8ntWGytBd/6brygvpWGCKRlzpFQzNHcjRsYzmIGrZ9kGhZuhkPx+3PLRfMcCyDqoJ3qxyDT5XLtND+7tiYrFn/riK6YiQB+gp+sEBOWuPcy0F9vaqgadYsRR3N00+Jt0aIGt2VLbomdEOJy7NOn0TdaUEx91ZbA/CvpxpXklGVUjEtxZeEXhW9rI7VVjFUn7h+NEaRDyFRjOP7dX12vDp0ni8KXyxKhMtkLUFdqcVPsOfqX3xTd2jtr9vTSyXhtbN+xbn67VMoFWDRqQC4T0rCjb/Qx3q9AG9FhGk0teYqN6W/FWuDxMSySYT/Jkh4z/54cr1zQSoa0caXiRaJvFV1cGSHhbJ3oLBu2wnJ7p9bC8Tz00jjxponxcK7Tanmf3KXJZVngVdxeqhTOlnNJT4UHQtiIi8FSi9em2PlbOSLG1SsF2vD2Rd3xJva6dagVLYGwTY5Yro2J9TwTekPs0H5miGjYS6qRkPlAwPZ888KEqxXhtZaNb4CqL0oQX8RvELx4zXYoSVwexRa2GxjmEuGOSAlzwe6PFzpTgamD3yp9YPq4/kFEFljGdKYtN2O8Z+fkLvRG3+IoWypar+/9VHO/8HWwiehfm5NUfcpWH+0qD2YVvKL1qiQOPGx+doYsBmSwZ0pzgjB6/7yeMdAMTF22Z+9oFodMltMF1Cqko/CnMm5/dqs9brL2uj7Z7vrUUKw+fIY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fcd7407e-bec4-41a7-536b-08db0375cdff X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 10:27:50.6426 (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: f7bLMx60sG2Mpo+Ro7zJJPJdlQ4TmJBZLQ6nYgY1DXtv6UdHO92Zh1YAW61QdF2Ax5bgv4AWGNcXCz1/3B6HywtGmLN7egh38S9OJgvt3DI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB10217 Received-SPF: pass client-ip=2a01:111:f400:fe0d::704; 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 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 | 81 ++++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 29 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 02fbaee1f2..f9acee1fa8 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -438,14 +438,13 @@ static void parallels_check_unclean(BlockDriverState *bs, } } -static int coroutine_fn parallels_co_check(BlockDriverState *bs, - BdrvCheckResult *res, - BdrvCheckMode fix) +static int 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) { @@ -453,23 +452,9 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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); @@ -478,19 +463,11 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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) { @@ -500,6 +477,52 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; } + return 0; +} + +static int coroutine_fn 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 Tue Jan 31 10:27:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13122841 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 7233CC636CC for ; Tue, 31 Jan 2023 10:29:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMnrv-0003Sv-Ik; Tue, 31 Jan 2023 05:28:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnrt-0003R9-DC; Tue, 31 Jan 2023 05:28:01 -0500 Received: from mail-he1eur04on2122.outbound.protection.outlook.com ([40.107.7.122] 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 1pMnrr-0006XE-TR; Tue, 31 Jan 2023 05:28:01 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q1OoT6DBL0Ursq6/zBcZsP51TVCjuvatpne2OFP9euo7sFyYEFvUhbuMFAJp3SeXNfFyXmnTF3vXFZd3f4qsq5mh9vkmf+y8r1tmTSsRLUBRx28CeuD1bQZ8woG2OT4joETjRNaxzHphtfURU77/4h44F8T0Enj1eXjyjWn/+GXEeIXsLTr77ctk7ZEZOlo8gv/ycHH3CYtlCYQxTmQecWVjixo29VzkcdcdSoR4G3l+ZAkcORfvUoNUyw3cpnUQ94fgw7F7zAeRHaIgidCeSMGCF/f1sQeATtNooAmfUDtuuNgyQX8iZTEt9yO8uJuH08w2eayyNER3/xjIVQOAJQ== 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=nTK30jiLts27gqjKEU4bHg9ETTLBBjr6Ie5jhjUAeb8=; b=aZVKYp3U2QtNsGHd4ciNFPbvkymSVN7T1f0Sa3dZ3Y+Yzph0BPfB02H2igDFLdzeO7Igqs7OTx8ZCjmAytKax9zJx/tnCH9VhenwuVq3nVsE7mE/R+exG5t6iRn0fsfCZnDrBC0KCMPGmslQCeZPZH4lIIuHO0Vf5alm58dfrHD3w2cwc8z93sIKyqhQ2rqbdJ9/jvqemm/zdlKUWh8w29sT4liVstIedUzHIjQmYwISoiHwymVofkUqbrdG74iQASDE0TLAVi+2u552CsB49xspGLywzKycVD+vyQpNH5qhsKUZMaENs8JrfiGP5r0kNK7TD34nvVCjiU9mnDnAUQ== 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=nTK30jiLts27gqjKEU4bHg9ETTLBBjr6Ie5jhjUAeb8=; b=PQaqjHdiq2Hl/9n+HhOrDbeTV24eYJmf6YGjFZLsnh7Wq29YEk8UwERoyr+avPDyC/8wNPWLCcY25ntpTZ8tZDhxKOG8c/ZcQGEMoHFQzbbGfSm9KM2PqiCb6zi2vjFXCr7rQRJH8uEqsGLdB5tJ9Nb/AaN0ULk3XQPhkV4AOAbEnNf+kPio0ucBe4lv8CokTr8WNi7C3VwxJnZXd5dM/dnLN2UeKgnR6zziD3bm99qIVAqP2LNdiIVG3MpAZalMky1eRt2Q9S+VbkTwjseqSdHzulTaWU9yM6yZNjrzZHyUW9ywHlI46RAxrxyMMejXcuhSYiLSgZqNJv7wdOvLuw== 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 VI1PR08MB10217.eurprd08.prod.outlook.com (2603:10a6:800:1bc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Tue, 31 Jan 2023 10:27:51 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6043.038; Tue, 31 Jan 2023 10:27:51 +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 v9 08/12] parallels: Fix statistics calculation Date: Tue, 31 Jan 2023 11:27:32 +0100 Message-Id: <20230131102736.2127945-9-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> References: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR0602CA0016.eurprd06.prod.outlook.com (2603:10a6:800:bc::26) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|VI1PR08MB10217:EE_ X-MS-Office365-Filtering-Correlation-Id: 33a398e4-5550-4d41-3f68-08db0375ce61 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wX+9tKae02G0LpBcHUiydIvvwVjYRySDT4TIzFegzIuTygB+C+9jyJZ+2w+Awy6zz0xjwrvxDTc1yINerJKlXJgq/vecvlPCSJ7GdO7sLyy59dAiIL073fc8BAaCwkqbvubKHUM5/zBksca1dECgdGUXzGW9GQxvdEjWHbGWCvb3txkaywNuQgcMPO5Kj3VRXoUP2SU+5KpbyzDwASN8YYriPNg8lII8voNywYO4R+gPGMXHzcEuMOP7tnYMiyZyK++1PEnqO4oM85EDOWi6qKoy8pNqThofPWPI5fOwFaFjmzaxoFBQPaha3Cqban2CIbVjskrdynH949l8lQHkL10+wOWt8M+l+2uYgUjV8JCD0h2vuashd9rU/jyqdR5Zwm0fV0HH9sn9H6S3lcQg/Uh9r6kUZEXl2pXOX27cXe0h7gXW6MxdvJtvmjxrpFPve9Ju3Ne+dc7x95Sf0pzIukZ4zfai7uPIy8VVOLUNYWRXLrPbTIGyWXSN9ZYW60gp8BBpUZqXXxlBcim2j52ii9bfpo2wUfpYCnJzvJe57VS7qGTdLEOsWvIQ39dTHNlA5AXZ9ownUIANetWjTRxixF6rUbr69auV0WC03JL+8xoLkBPz/rOjmo9IzqY+KqcILGL8PbsRRTr2oHJJwkpE2ohHrO2KWcEdO/5HVMDIpxuxt+R5QpiU125HLuEhnG6VTXaQtwyxIMOz9JAQr7+m4Q== 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:(13230025)(4636009)(376002)(396003)(346002)(136003)(366004)(39850400004)(451199018)(478600001)(6486002)(26005)(186003)(86362001)(52116002)(83380400001)(38100700002)(38350700002)(2616005)(6512007)(36756003)(6666004)(1076003)(6506007)(4326008)(8676002)(66946007)(66556008)(66476007)(4744005)(8936002)(5660300002)(6916009)(316002)(41300700001)(44832011)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KToGNH51FcF/xdc0tLq429NiXVatRP9XwYIsgtt77aRFxoYYxdOKC+96h5qYxRhK94vVuuBBZ42ye8fYY3tAwWBBWEx7G8/JGDpPL/xSbHPFRC/tqaN6QBf/KAadS+FifToWVBVar/H07VM7Z8+tPAMQjBWsqm8cE1Cxiq9Ct5dIIjy6sCfKxGKoHfosAOX7KSNgypWZXkMqlpFCOGJP6xHnw1qIZcop0DSSOoyPpMHv8W3JmgRyLXKwQML7DnOm/YcG0hmuEgrNgrfzEbjtWbwDF7TAQhQRzU5z+deBP7f8kO8r+StNskGk4H9c1k07fknLOe1Aor7IEe2L69UjmxP7fut4rPibUDgh3jZfTRJ5USe/MttFN1AShLa8N9mztzarWZdIM+8h3es5IyrSRQngpWB2K98q2AKBQer67uMpUkzP8zysNNVyJ3hFdCXmczpUktcGsrHyjW3yvl5oC0MSL4v0tmLr+9SBZpbo6vFzmm25sJaFdxsr5YEPXkwAfuFqCUUp70bakMnddoAk/VTtI5SJ3pHE35jZDgD24dAp3vfXsctZc4/Jspwt5ycrKiz/WcUdeyhMlLD7SZJJRvBc+pOcgum+BpwOCkFtmF2zDDNW9+LKFSHKNf2j2fQgdgeZf5Hzj1nd15Dnvz4bp/1W70jC24rNUcKLGn9jMlTKWL7il7BdRxJhWd4EK7nYNQo5xZJPjWyVWII3fUONR/Umo1K/rZ4lp2QaZmWjsKmwLNvSjmpJl0NEIdVVrxakPEEB2cO44igeIeEwdZyddF5EIDlfTdkIKpO3qHlJR8BdDsixVqDTgpH0zpJxX8qF/zK+G8zk9S0TMwqDTeUHnSoesmTscf09fKT8ASoP0FMETCnzfy4U/zUYeXc6SGYmVcVJ0YpWdBlf7qk49zsMG2Vq35YPLuebQf8l+EoWLDqxnUKB0WEbJtmhB9KoZ2+D25+DnhCj99p8AoTDvqmLppTqp6LNnScCeMFXKo7OYCEZTwIF0vus/t4g94wwfOXJkEAyrc/qqzaL3Mi2PCjLmSHuuAXdD9+mNxEs+pMT0H743ZX8oyAERhMhcn5E/0aNRt8GTZbRJ2QOQ0dMhiPMy8jUuDAcJu8XgRzBs+V+jPkI/lbOkVifq83/bsaKMUVrwbG1SH+kIlFxG33EUHBfxWkzHZZYeduIkPUUGJsUhXdcbErnBhASg+DzuTVBEY3eSxToDJ4y9D4q5irovYfzifcPgWS6nRU72nwaxwfyKxogDh0XR7IVruWDTVE/yJ4xoG13AWZJPaylN3GTIhkOkFmfxeJKQrQ5Fo5uGBy1WdLySuxj5Cz6KyF/vs5t31/LWwIHdk4q3Wtk02COj8svILj8wlb2rRe4Pju92GBnAxyh9o14ndLUzTh29+gL36n0BYDyQL/S+KZsvTKW/lWrjoEaF6uwupZ2tO1fk3tBn2sAX4NZM7FxabG5yU4jRjICykug3dh48AxmurGhC+WFpCnpEtperdduJWNdPnYX424CKwVGPeGOFnNVsfENxMduUIZeMZSG89SafgdsPqitwLkF8IHyCHhmxkwCYEEnGJUy5/u0H6/mWuIv22JXAFtPKP+HwFHX4Dgct6Qlgrj4W2eBK/cgI/5LuL0ZRjWtb1g= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33a398e4-5550-4d41-3f68-08db0375ce61 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 10:27:51.3312 (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: TWuavm5Xm/JjjJiwhcFya1KCqmSjUxqqgTRSXlikr9Z7LpMeI/O8UeXzPGqK6dnChDr6nLy/B5kYDNOsOwTm/zc9YdnhsEx+SgddDLg6Vuo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB10217 Received-SPF: pass client-ip=40.107.7.122; 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index f9acee1fa8..7382c01191 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -510,7 +510,7 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, prev_off = 0; for (i = 0; i < s->bat_size; i++) { int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; - if (off == 0) { + if (off == 0 || off + s->cluster_size > res->image_end_offset) { prev_off = 0; continue; } From patchwork Tue Jan 31 10:27:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13122846 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 5970AC636CC for ; Tue, 31 Jan 2023 10:31:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMnrx-0003UL-7l; Tue, 31 Jan 2023 05:28:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnru-0003SY-Ll; Tue, 31 Jan 2023 05:28:02 -0500 Received: from mail-he1eur04on0704.outbound.protection.outlook.com ([2a01:111:f400:fe0d::704] 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 1pMnrt-0006WH-2I; Tue, 31 Jan 2023 05:28:02 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JuKOg2gfIpvHtgJb7TV6DphAZeY4JLfTcutvo/WKbc8yR1PICQ2rmzVuKRsltfX9XVEepiw5GpanORYQu2Bvw3jxcmTCRe4CfG341f2KMYaPkePiwfTsnbILjshx/A9bYlqBeEmZ2jeQdyk90Cfl5seqbjvwKtpP/VoOwSK5PX6WIBz1WaqgvdG1qf0KMM+zk6DU36fvAjJVpuOHk8KPtMVaqvZVzh/KXIWFc5rohT0Dho8G2QEsCfFce0HQGXOiJQm814HcAqvSutxwGfsOxKsMMhwCATuM0TzrNOdB3a6NLmqdTiFFbv/B+WUsWNq9FeoskBA1mmm21doi2Nl+ig== 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=vXpdpQsoKM0XFVogGuVHYYbARp03koYeekDXRMFoUT8=; b=GdX3wHXO1VSdFV9K8S9dSV9id40/uZ5NgY/9BwTrb8aIFHcNc7Oa9UDW0PaKbtaYULW8dRPaOiH0i1+gqv9KUcSPbD+VwB7DRrBwal+RcgccBSeKBBtOsFj5AiMbRuAmb2SnpXCaTKLjDOz0bsTb5GK+rMXIORJWMeTjcCf58fAR4xv7/riQBBx2SV4GhJ68lRa1ssM7NKK286Ttm0DjM6cmz7oDTIHWAYIVD46dMWPXrr5WV/JR6Jly3g6ixE9RboQ7XBofRGLavKzcjRSkhSUdQqhCBaxIgjhgNmwgoO3YbPrRkoJoQoHIJQxVo9vOVoV6SnWWB7DvRrmdoycihw== 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=vXpdpQsoKM0XFVogGuVHYYbARp03koYeekDXRMFoUT8=; b=QELZmrh0v7beR8SfUQ7ZXQPfLLsgbKote5YvlAiHKWd3HUINyAMfwIIgTD3YGN3v0GkS3zgrwoxGAABabtRUNI7/aHzkGXBhNMadx1855/EMitQvjXSltvJ99GMYq9NNlZhTtWX535qrhFUDwOhrurQTRWd0Dbm8MczOIBaoX+njajNp9SKST/Vq830jcawt7MmRTRMKcOWFMoXg9vRgTGGSuSqlnYC/wiE4EnpCYduAfeYmpLtDpm94+PRtqNHhI9HuQrjxVT4xoNLQ+ON0fTTraCYw+HuSWPiQnXQMR1wWykEboOcpDmhTQJs8CyN9LI9JAPJb/4teZ6Y6C4iydA== 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 VI1PR08MB10217.eurprd08.prod.outlook.com (2603:10a6:800:1bc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Tue, 31 Jan 2023 10:27:52 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6043.038; Tue, 31 Jan 2023 10:27:52 +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 v9 09/12] parallels: Move check of leaks to a separate function Date: Tue, 31 Jan 2023 11:27:33 +0100 Message-Id: <20230131102736.2127945-10-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> References: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR0602CA0016.eurprd06.prod.outlook.com (2603:10a6:800:bc::26) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|VI1PR08MB10217:EE_ X-MS-Office365-Filtering-Correlation-Id: 3cae001c-a845-43c2-3520-08db0375cecc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BH5XFE+b/st8IM23LuORnFet1Z2DQ8Jw6Ahr8E5k0HcM6NRgwz33OzumfxKZh84z/UhXUpAriuxP/YUq/zXEgItFWpu7sr8eTfP8Hf8Gp3YSztwd0eT0G0QqIA+0pTMK81ZfVtPnt9dpI4o8De6LAUEhhcVAYImzLjf298+kFVhnhVaE4clrZ3TRLgZ5xrOe2OBKVA7ZEbStP+CRdfj408f8KjRd66H1idnK1jcmIhxBLgfrbv9NvhXpVRQAixm7bt9L0eXQisZbMq6ZM7eqy6jezBRCgjISQX6AZKyriiayCbFRaji2+lsuC7Ejuin1DKHg+il2KkhdIukklOQpYs7M4RBqQza2LpUcrjJRQCx1I4B6e2iiQMCGsGFT36B8jZov0/Hs3qJVos/LkLMuYOMOAlocO7vQHSJstovykyx6Le1a76NDaNbBWqWsiLMjH6FNwYVeOcs+oon0JiGoalK1gCFA55pA50ybtzR70o3o4RalJybcY5ypZIemnCkVfXOBBpYz5YjT/VCSTzj/WWofBH0wfkELlavA/p1bB9GlFPBw+YX8iZ0eM9tmxFwwhLXu9sXzTHznf9bdLv/XQmxQO8OP6LxYwUjoPi+nAtX4l/Tr4c2/YmayBNFgVLcqHiwXxE8Ws+1Qa+uZk++DkF9ZOtwbkl+nQGlo6lb6+Zn6wsaDMif+D+2pKMMtokRlQjtH8+czB09ajDfdox4SeA== 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:(13230025)(4636009)(376002)(396003)(346002)(136003)(366004)(39850400004)(451199018)(478600001)(6486002)(26005)(186003)(86362001)(52116002)(83380400001)(38100700002)(38350700002)(2616005)(6512007)(36756003)(6666004)(1076003)(6506007)(4326008)(8676002)(66946007)(66556008)(66476007)(8936002)(5660300002)(6916009)(316002)(41300700001)(44832011)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pXXI+KT5EpY0JhiBgDKHNXR9To0e1rERd6+5ZS9Pdg9OymZHQq+G2KFGRUG7TFhZkrT6titZCOfbXJmMB2u8Hnoy1i9R1s6ZxZN0Q+h00ci3EVIuejwi/d4hAxXhJXE2iQJWX8HKdUefbBvyYch/LKmxw2hPnnKPh3iJjajrmyWRPE4PE9o66D1OSSAuM7Xj5HpPAcjXdcjo+NoIO/qKFPG4P+7o3lesqDpHaTZ74DspROBv/38O1HV/8yClHPCWf4WdXBfGcexjqBQZp9f8I4rWymRKHtx1MizvMbq+wnkN+L/iEcNuSEqtHk0qCt0DEX+k/3nt4aAkjF9esLx6Py4Wso0uhaRg28l151r6g5NcXXHxU0I6dWvlY+7s3I4zM2Y4GZxJOTVnOVf/puOB290uz0uRfmZZv6nxsqdgusjpvmyK+QJH8tgz12dHTL9i0QGtgBX2PYhAxe/rPk7IPfB4hy2mLaphVmgGRTXZqgewDDmvK+kvs5w3QSEpSI0yEHKIZ/r602G2h3x8wG3K3Zq4IHmlYwOcqpjDh8swivPu/eclfaUlRUMXdCM3vZ4i45rN/aTbovdMjOf55grjFPeM4Grk3BA9YF3PWcbzVHX5HEAG5LYZLdSM1n5q4ukAJW74FhKyflyhPqW8FpVEBAF1sNRv/wq+Fe3OI7m8pViT2sS8CVHkX+4f5/oyO8/fSbwk4bfm/uncdZ1M31kFohI/F+RkAaTlNP6gXMyK36ZJXFSdzRyRHtShvZ9031oba2QWvAN/OCbaC+w81GNpMszkFd8/nxSuG5lcV4xwrqFoXWv1VD8UFcTwHAm5LG348NaUgXsE3kqsIDCqaE8CWYQw8f+ZUmWjgrm04ecD9TQ0+Minh78/EiqFIsPtGz0H6qf9J31oloC7XgegJ0Q1T4bEk9nrQnlJ3DCd7TMbKdaIibVZ8YZTvlODKK/74JZeHtu9S2pihg5DP3ZaP1ZsHZlf/qQnabRiRx5/RLeYzszmsNqH4iuWwhzHdLqowmnmXXW4ngREmg7SeD2kkTJQteh2DEJWCpBHHagfC0dJynT5XasA94qQqIidCoVekSe1qhiDD/CAbQLCQvEK/8gLgy6bJnGHs60uFAoRsiyMW0wcls1MX7IR8VSsrBkivl/LbzIJjskOd8Ea1oCTPfTmSmxJ0xssfrMn+fmUsN9suc5yDFTfw2av8To7/gzLFSO6c1woRenWzg/VyNb1vi96nbcNgdt0EBcOILdwktV+sktCo02n1j/XmYnmyJE4dt5hzhkD9mxNjC4grMbxb5FwwXX4DRg6ulQxdpIec2N/pRL8I9OPvcyAFXZRUJXXxJUkqLRIy3choc4SB3FGUkilaLbKt//Jbf6YoxPKjEfgRrlJD63NdgdIwwt30rSQ3MMqjmJewI7dm+bHWtRvH0ixLO1ZFE3rcEJp58DVqXLSUDEP7JpTbk0qHdlvLWnSfGFQZgX4OL3QXHXLUUs1FsWBKDgiS9UccpXm/+G61s/6hPT+2UTChdqJoC3yI66/bHItP6vY1wmOJ4f7cFV5fFKchRhX3uxCCFOojPx1nb5M8Np6MkO4XlUYXNCaRQagWM/z9A4YgEfgvyPudKL7r1oy4wZalOEht0y+d6LC1IzkaOs= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3cae001c-a845-43c2-3520-08db0375cecc X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 10:27:51.9697 (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: Wwd0hgoTtumxgYxQLsWuUYOeHAa6e61/gavb/fH560RM1rhJE5SnWqJRd7e1iuwQHs/wHRqeQjYaZiELJtnaz4mfT+Zmzkzap0A26rR0Mxo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB10217 Received-SPF: pass client-ip=2a01:111:f400:fe0d::704; 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 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 | 85 ++++++++++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 35 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 7382c01191..eb39db53ec 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -480,14 +480,13 @@ static int parallels_check_outside_image(BlockDriverState *bs, return 0; } -static int coroutine_fn parallels_co_check(BlockDriverState *bs, - BdrvCheckResult *res, - BdrvCheckMode fix) +static int 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) { @@ -495,34 +494,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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 || 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); @@ -542,12 +513,57 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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 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 (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); @@ -561,7 +577,6 @@ out: return ret; } - static int coroutine_fn parallels_co_create(BlockdevCreateOptions* opts, Error **errp) { From patchwork Tue Jan 31 10:27:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13122842 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 A0291C38142 for ; Tue, 31 Jan 2023 10:29:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMnry-0003V8-40; Tue, 31 Jan 2023 05:28:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnrv-0003TJ-Pq; Tue, 31 Jan 2023 05:28:03 -0500 Received: from mail-he1eur04on2122.outbound.protection.outlook.com ([40.107.7.122] 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 1pMnru-0006XE-6i; Tue, 31 Jan 2023 05:28:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ULtTUaYwV3akWQ2YczpCbHPCB90cmDlQAcX+r1PKd9Nh8xxL3dx5hXkPqWtEpRROL6wB7MpQOFsND/OJabJTBh2cl593eIIrLFbLKMpc62KT7kzZd31yj3D8Nn/p6M8ZWj34U+98JZIX7a4s6Zab25uouaS485qxF9TRmH+XA+FRtICFdotzBd9+mA7LU1aSr2NPXhBXSYPjEvQOa4F8shghQHnkEIFYMDjiI18ISkqWhnzwOdbAWso5WYgveK5VUZTBWrzgMVeQ2MTUCnD8TdoP4LnsH5Sfvmv72P/Yf/wvna8kgaMScyU5HrS6L4TEejo9gHZsy9vFWFph3v1Jqg== 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=IWNw2FjimG9keLRlRJjXGZrCUECC6PKOPARIoIOoQRs=; b=d4r/+cP8/sUSvQpJv9wWhHH1R3Bt0EgjHGv8omTFbOq84NU6FDXAwKwjve82JM4suor97UhZtUSEEp8WXcborn/h1GbVHsDjdGH2TfDcJl2cZPBSBIBhXfd5Eyo7+7+ThIGiWAZVI6E/uC2uttXmmvS5877jVYt5bF94jynNM9paAT8v9Amzs0XeJRqlAHx++1im22LQaZ4LxoiPKXgqd8WLl1fSZ83NxvETO26Pmn5lFDCBKk7NoJ8jixhfGxZz1rAIPDOJVl73m3XnZwDvEYvyLu/5ExucWeufAzSY4KuKSVNAqRnw4oEkEjexKH884ovytSS9IaiNiD7BjYYXvg== 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=IWNw2FjimG9keLRlRJjXGZrCUECC6PKOPARIoIOoQRs=; b=C38YuR/VPAWtBKeJD+H61nP0diYzmfxmYIK+qrRWwA06IssBoCccOdPjaUfvTOLb1RCEmc4EaIcLYLJjY381IPLH7JKbUbd2pngwJiNZn8k0u8BslRw8Tt950aKZ3n0yagwRhRm+7IaylOmsYF6l3uXUz/ImtGEU0RWV9oRI0DHlcH95Ylp3n5qt1Wds0UGiVf4/kWK5hMUwUF7ldcXl1oOIUBTCtnwekd65jSBRXDbOlKI1d5V6gjkb50e1YkWTFQD9JxgtNZMRT3Lun5FXpgwjVtZMEPqAQq35FBYfHBW2DR5WrZOITnH44V1mLlT1ez8xCl1K8dqWYD1SX9W4oA== 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 VI1PR08MB10217.eurprd08.prod.outlook.com (2603:10a6:800:1bc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Tue, 31 Jan 2023 10:27:52 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6043.038; Tue, 31 Jan 2023 10:27:52 +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 v9 10/12] parallels: Move statistic collection to a separate function Date: Tue, 31 Jan 2023 11:27:34 +0100 Message-Id: <20230131102736.2127945-11-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> References: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR0602CA0016.eurprd06.prod.outlook.com (2603:10a6:800:bc::26) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|VI1PR08MB10217:EE_ X-MS-Office365-Filtering-Correlation-Id: b097a0d4-5854-4c64-2c56-08db0375cf29 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hWcpKp8d/apIrfiXVOtM4Q6Jadse1ruyEozF5d+49pOil/KJSG51eS4OHUE3SeqRyWfY1jMq9U+bTVKID5di41Em66pPZb8Ei0CflE9JGWeYf8Bjg9wD67eqiIkc3kSt2qys7uqn8zoc/Wl68/d2UhK9gPQ/EhEFzgD3hwgRkC3OlQMO3tJPc/FxSFScSACvjbE1T0Fkgfdp9adoEbdNFecHZEC79iWwMl9hGN4+BP9Hzck55ccwTgyifphfuZDYl2Mqbv4DzVgzGNeq908qrQVtLApfbnTDv/OhcOGsoKLSAhwZK1jOpQy8sLOIpb+Gw7ZAkgQzUxdwhX645Iynj7XLfejUiVUHmHneITOrVH0AGP5ESmwsGqRP1RIz6zZrIg5BfmF6fhG49lucZlkl35yVxIn51zNynuWbmhKm/SIJRBsoSeAgIHOI9HKOUmgG+ft7hyBZfZm0TGcbosZ7K5M9gM/BlWFLudikxBVPK3CZbErCW67D74mQuK7JXY5QEZ5T0vBAPAEAEY9TWb027z4hVCmhYbIa6HF2kgIMtIUuXUS5DXTEiXjgTl8gKiLpDm6VwrJhW9DgkHVgbAHGqADIvquBmyGjnp1jfGy6YrxnLVl22wbMuK0U3o6mjqL6hZJIT1ZT/o1jS0yrHhDfaHQhaZ3hYuFVNz3STSD+8EhnGw3UOuG91m//Qs6PUcEKtXKhcjZZfBrbWHFk2Qqv4g== 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:(13230025)(4636009)(376002)(396003)(346002)(136003)(366004)(39850400004)(451199018)(478600001)(6486002)(26005)(186003)(86362001)(52116002)(83380400001)(38100700002)(38350700002)(2616005)(6512007)(36756003)(6666004)(1076003)(6506007)(4326008)(8676002)(66946007)(66556008)(66476007)(8936002)(5660300002)(6916009)(316002)(41300700001)(44832011)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fw5uy61poGZB//hMOa0wNXlu2wMUvcBDJzY4iIKTmRn4eJ6jcqWwQOvfMXiutJdF1frNMGHr62Zov0/S1bvfV4ZMSgabmvZFvTJzEBCmwJgParkAVoQw3YVCFLvLMrwGic5EWUE35T/BPSozgjLU8gYErsIUnRk+iY7p3Z9utwr2uEPbCfy3AAvaUniR9JwETTCnugJdTYqfk5tp+LmbVK2J8Y3Y5nru0y8Du+imY0E1HWIFmveGxcPuZRRtFnKSMox5UMmrVWXo5xuIi00mtO4kIC3Vr1JjjLeFBCYMmJDDrNFrdBYn/lsRmzXwnzY1Oj7GJbcLerMf5EPGkfsJvOHJOvipFlsaF3TmoVpYpU4LBEhnUY13MuxpM7MEUm5Sn1rqINopSQPg2edPNVqmXJx/iL1IE4GWcj3TgiJP/ezpvHIsAx14eBo4bfsyZLk3BV1AnaKectoJFRmHzRSBKt+psbm52GW56YHQarZDjpJ4+aDvNzPSlgZbYGoVR1o/rrVzo/oPkQ/F/Tacqm4wa3kb5NJ/DqO5XzeAug9hqpBfCv+PJmrsyLS6mlJ9fZxL2Ka9gqh4e7IV9HgS6mKWhw8W8qawz+C7cAeTJalRkqYJaQ/xP2X4h3CIyo3/ZdysCUfwjZVCugnJxCny2BTql0SlG77bpInid6heoDm47Ml/CEktt9/Y8vKH5eIK7jLL/mytPypBU+TTnrytLfLciU5D6NlkDUFQzJcoSOsIll9amADDXUgZ7Xn4Xe5CeAYrQF3xpPLGh4FLUWW0VnurADOsyfYDDrPiAAsITiph2HYw+xwVYge73kN3TumW4G8ofj/tXFXDJ6n8Bx7Fua+pI+K26wOqxU56WUMNHcw3dPFiJJ1rH+vksvx9O13U1t+jinNQvq3N8LIIXvyKkIPJc1TejMSKU7R1qx4PpZ6dgCFbkcFqBipnbnqgmwRPn7qqKT0XlF3nXkyKEkK99rIoL2pWINV45+B6bWsUJVve1Zlp3TZHSSyv1Byd1NvW6saZyonAZ/kmWbVj9ZdIeKbOUQbF9ToehocLut9eB9n+MsyWwPJifEfT/OaKJjXTLArXZU+PvrOaBmqtRnuMmi4SgKdfX/CbNn3v8yOfxIehGbY+tK5QwZpxlxDpcHDXu6JOBxF7ds3MVIt5Pwgg2i6z3va7MAb7KbrRMVlP2/rlMoHQUKd91NzLy9NfRZRETsBvGbr0VTLQj4CAgQPrfftQdXzzYCTHIYPPvB6w9D/7H9I0ZIZ2bUMzuKdviyu8mdLKisFsdV/Riskq6jJHQVac57NH9xZGpfHV4PWMRVeAqsF80YGfUwa+JGMRjv9Q/7aX5JyzJECjw5tQS79H++fDQDLmIAf8H6Dls79GsRfhmDeAjSQq41QBccC/uuwPg5EL2Y7gqH/G1AenR3R7NpgO0OyOvObEQWaTbJDxb9aqUEN1nHBg1/acr5WpZ/SHoFN/y5I2wB5O0/EyQH3eBMi8wz53gRgwcWL6HCg9bVzJ1taBlV+9TGRZjlTAB4x+DfwcA7mNik6Ik7m/eovC1NJVKotiNq0yipXpokL8NvdhZr7zkGQEIJzOmNalvcsNcQCk9iv3nLz6sO/fwOx6Bq2bA6cmF9ZCfuvoEMUnT0v3EFY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b097a0d4-5854-4c64-2c56-08db0375cf29 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 10:27:52.5790 (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: W304lJOvs7H3/M76DegdQ2iuQeOC/+wLWnhH5z2plRao2PRCM6pcV0raaRGMUJhoAE4cePTR4Yjj2wmnRN2KX5iQ1TOtN09bv2DIRax3wP0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB10217 Received-SPF: pass client-ip=40.107.7.122; 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 eb39db53ec..23c9ba7b7b 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -522,47 +522,55 @@ static int parallels_check_leak(BlockDriverState *bs, return 0; } -static int coroutine_fn 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 (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; + res->bfi.allocated_clusters++; } +} + +static int coroutine_fn 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 Tue Jan 31 10:27:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13122836 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 1B2EDC636CD for ; Tue, 31 Jan 2023 10:28:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMnrz-0003Xv-Pk; Tue, 31 Jan 2023 05:28:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnrw-0003U5-Tf; Tue, 31 Jan 2023 05:28:05 -0500 Received: from mail-he1eur04on0704.outbound.protection.outlook.com ([2a01:111:f400:fe0d::704] 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 1pMnrv-0006WH-Dt; Tue, 31 Jan 2023 05:28:04 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G8wl0x+4qshTiBqsVmRzT/hCqYpI3/npWyQaxz7tyPAm1KFZ0FVW2wFrZn8TmWrfryPcOFgw6hvpNBbfis+8guQu3/O6vFrbx2i3vTQ9NO9O9RUV1BLmFd1SGkI296vfM4a3943zXSFQvsflIWrKb4ESlDCwDZbSd6IjqFv+alSGaIL1+ad8dC/UtiMjdui8XjI7bOCPQ7ppy12oErP4sMM+6RjKNTAKmvmJbx+3hZUnkD8d+XVgkQpZRw7wookLVfXkqC6TGVlbqgzKQHg82yfZBbHPIYRuoKKPboqhNc5nuBhgF7ntxe986RaVy8gB1voBYKQcT0kyVY3V3bhF7Q== 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=aN7VI25ymTQXJ6uuVXX+SYV9vhnbFxSnH/PryfIepIA=; b=fPuexb5mI8TrKvki8gpcgmMAP1bGcKk/StQ7u+m12uM//FU3CE45vkwJyiaF++qDKTX+CA85bIZpMogIPqL6IhsnefhcOAkkXC4TnrSW633lH+oBoOLmQENo9VundChhqJYTL/577E7dXWSdocixBK3pthhjpGAxnCXLqJrNvpI6A8XoYtZ+AoXZed0qtegWzI2LzTEx+mlxXP6MNEYsX6pN14fupS5K0GfGCdepNuwHcRyIg0JSZm+tDq/YDSpk3DA0C7sMEtWAlyGDacSe7aKm7/Eaxy0sqxusTM9LmmYv4NoztrJrpi+Nzu6YXNZBQFqzUUjlKOO6F0H9/aQnDw== 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=aN7VI25ymTQXJ6uuVXX+SYV9vhnbFxSnH/PryfIepIA=; b=rd/krDAckj/pYZtAN19M/lM2QEdPMsM7HoUYlRX/9319loX7kU/xQIYYQb1ya67j97wk4pCkImXjGrP03r91m1VEpC9IZlhixn0Hx2ULJDMVXwDMI4uSialozs+N9LETTID18xQZ/biiir4pZelueCVhtzvteRB5W/p1U9tPUJR/jxXEEgUgM5ZyMjfnXoE/59xURxnlBVtQFgehCGWSAgmYh1MBmntaG2ZiXcCaThKjN81b3pdVj4Y6iQRDHz5DRzjL1TGBNMf2D1t7BhZzRR/TcxWtzJuc6xYduOOtTi61EMS9+ni8zXclz0xXrj1MHOsTajkFSYTOIfzjt/GzKA== 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 VI1PR08MB10217.eurprd08.prod.outlook.com (2603:10a6:800:1bc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Tue, 31 Jan 2023 10:27:53 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6043.038; Tue, 31 Jan 2023 10:27:53 +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 v9 11/12] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD Date: Tue, 31 Jan 2023 11:27:35 +0100 Message-Id: <20230131102736.2127945-12-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> References: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR0602CA0016.eurprd06.prod.outlook.com (2603:10a6:800:bc::26) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|VI1PR08MB10217:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c4ad14d-fa30-4447-bdae-08db0375cf88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M6igUVW1SAE0iFfPdZpiAwvmzoScGbA1UUcDpBd9GWfHwD17ZuNSzyPaPvVwpd4Y1Va36LA/sI1aPDP/jXmqb4q+IjwvAbzDCjp9iujlHQ18OTVWMivtFBt5f8z4MkauZRIpRiJYXOED4s8dwqFjMbnKqZ3/Kn5co2p0J6t8NwY4PV3TvgCD72+kbjDYQeN0sK2JPPheY1Xc8Nn5Mdt2l/72CbjKCEXUUEboH237i5pxhRlLaFVt22SAA7dwdx9jmUU7OjzJ6kt/sqW0B0Q0JXMU1DiaWyzJCGcU2iGrfiobHjzLBK4bceSnG0pYRtv5ujix6rzoiaBmEis0zUAX7XXlHJCRm/JuUIjWqfY6zxTOBqRyUZQRENZ3rJb6R2AOid+Cqvqba7Ix3B1AVxAWAThKtwGD0oOXk3odcdW4ECSrwTlm9g8XjtVD9uNFmT602F5fLErlyFlXZ7Cjl6+bXnIZD2hkTGTm/ns4vVKrAHoG9c1i3XK9FuQ822wPvgJqk+jkK40ppZgHA+g55pgcgiPaYFnAlgGtbNJa9I2D/LTwGWgbLuLjpTaBaNqtVPm+wgxilGnRDeg+HHhzT9M33GFT8q6x0mQSu0stSfM+C46RAuMbgLXWF8NOPGuiEiSLi16NZ28wH9ZEHfdUQV07jH+eD/JqqGXJGLb9yc4+kvCNhDerkUL9C9jRIA2dO5/0A1OlT08EYXeJtHMjsJgL+w== 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:(13230025)(4636009)(376002)(396003)(346002)(136003)(366004)(39850400004)(451199018)(478600001)(6486002)(26005)(186003)(86362001)(52116002)(83380400001)(38100700002)(38350700002)(2616005)(6512007)(36756003)(6666004)(1076003)(6506007)(4326008)(8676002)(66946007)(66556008)(66476007)(8936002)(5660300002)(6916009)(316002)(41300700001)(44832011)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WMsYgJ1j2a6cwn97MCuZqrg9c6SdU683/hmtDDAWw0E93xjO8HVtoA6QHEoxwHi+30txJ5He34ohUJteH3f4JCrTaspVXSNiA2TU/WNtzycmmox1CMSJf+ig5Gmge1kVbZ/8htt4I/GMSy1w0Pr13wIcJ+H1JY+dBn6wCD5fOjucXh4Jd9V+xhn7jFn76/vQSTiHaE7W7d7ebDenLL89ZjHk3uNsbi2p+ld6NCnLce/Kjw/iHsd5cmOTvyaOIMsJ3UT28NeU+ytz/f0WkDACYhgcGtE+e5/bSQXu7xc2IOU/QmGqPVu12J68UP3VYqaJC1KTQbQZv+i8wyGTegNCsAcGGYKVs32JHsqRWC3hFvwKmzCWCR3HF1b7Cz/kwelCrGM72ycnvQnB9JGoxAKupqFgCfH9ckRtd7fsSUrwAJfNTPz8K4790w5gYoeMh/CRsRDgP9u1iDOrAotJd7DfP0cCbkX+2LF5NKYZvmtvinl1KHL8HtFefl/1Ak8sI1mKQoYp8zufaakEBHmxaQwVbhIrOaQEUYaoi61FW0jShDfkdYeVO7/tyanmoPS2lLssfeWUYZUzI/cP5Fnm47lFtq2Mq+D9O/SiUtz3UQK8Vk/V+O5Zfk9t8zRyl3zEzYNjFCE7SMSj705uwF9kze83m3hduEuk3w62kUZDU8Z8S6jUHcR454OJFlYoW+mz7qry1LutouKhH4u8pYiURVw9zC0T6XljHD0AiBJKtw4uryc3HAGrQ3/Zw8rUs0pOatis5bXUZ5ob2R5lrxY7mpbdCnnMJF2Dt+SSNK7aBwk17WeZ3gp1NcKjKXCAEXzVz8/IfkNOQVVRryU4FC+OT9SnrsjB1QYSH/PLbXFP8WgMMH1e4UQpjS8ah2/TK0SCW+TiGomz3sUjYPMLCg/riDILpXnAYb4Ggi4DtIH/GsZWL8TsNeoy69m3ftE4gQ6H+IwSfmwVcHVaW/VBoT8lGrSiXWEewhtckDE7m+/tI7BeGZ5nVfUb+UvBJrV4BbpsVkl8IxxuqrJn7G+r1q3zCJzU7j8Pt3aAgnSAuAe6h/uLlxRQc2B1qNJmHDEZgS1bI+WO3SXsmp3SNAZ232Ry+stRV+57DSLTF4tIWIuq+CHNDLuNxGvE/TqkogQfdEFQCuxzLKmmBRdTD3bQwDiz7FxkP/PYVogOAe1NE9lpaK5MviFp7PF1Crq4FylFvEO3uRJQzjDI+nCPwPTCAI6XLKrMruZCbj405OlLF43prhIZao6Xoj9f6RoobCaEvzHyygnNI79uhMOR4Q1qb2hycMKAjvyT/FboEnH+08U+aKXPVDlUebrLubMDHDtyVFVc8bSck3RSnMiGHhm3hqanG/tBrj9blm91QoSvYy+tz2c+dbgZOhzH3bbO6ctZvVbdokzPI0skRhZYIpAvO3oDv6HKCXm+1ypfCVwhPQwLHPtY0gQ87YJ2mZjaVzFnBobwGAkZNHHvnkcD8VPZTMK5mCplJ0SfzGWRLiYSGkXRq0Ii75B/p3LpRnjPmv3wWpdeXNk9NDx0ZrG8I2niQWC9zqI/xW/AbRx+1H77c2ow3z0PTPw1dwd7bfSFE90SNPydjgVMEuhojIWkbWlGA5/s827C3XQpAouLyc3h8zbUb9e3z3s= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c4ad14d-fa30-4447-bdae-08db0375cf88 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 10:27:53.2052 (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: ZvdZG0hVgYfS3dZQS1REzVWifc67vMJPADjNVbcCT/ep6I+skrn0/LkzfjXkdr5mwAb1khToOgg5oGkRbQvWlIfDXLeoL/DpYpIsO2d59os= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB10217 Received-SPF: pass client-ip=2a01:111:f400:fe0d::704; 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 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 23c9ba7b7b..e4faa14add 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -556,30 +556,25 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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 Tue Jan 31 10:27: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: 13122843 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 B01B1C636CC for ; Tue, 31 Jan 2023 10:29:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMnrz-0003Xt-OK; Tue, 31 Jan 2023 05:28:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMnry-0003V4-0P; Tue, 31 Jan 2023 05:28:06 -0500 Received: from mail-he1eur04on2122.outbound.protection.outlook.com ([40.107.7.122] 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 1pMnrw-0006XE-IP; Tue, 31 Jan 2023 05:28:05 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GGd3p49BMXKgdUJ/9YEFS2o+2Qf+nBzxSZN4h22ztqfVb4NYJc9RSG7ApmOpexCaAmUA5miT8qRsVscZkkPiouj7saRMb2FQ69+HJWh028+N6uY1yP/uZ3NT4kt+0vpJRprlg1dTCArxrbls1Emjm0GJhwauDo39ETp4qtYIsGitH1NUzJFOaZcxjf/BXBylt1z+zONQL3UcPJRjJxQYYyMLV8lj1Biz5oA4hPjn2yhGnh/olr4+O4jjkJsCr9zQ3xpqVbauFo4txtJZ0REvFOaP9ckdj7t4eHGFXhGqOZp3Kh0VJefYgMgESn3s+tLMJgC51L4OJ7sZKbuRCpf4nA== 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=zSMqJx2PL+v6MWcetRwwP8P9X79cWki3OCg7wXojsEM=; b=BeXGkiUZAzJsMDUzTKGKJTO7GXo1oC+EL0FvYSYiIRceKaFT7lmWB3AZzpKu3qeCRJbspM+Abfst/iN+xty3VWWcLDou0T/dYHzs8dFOnr06S/Y/3jezRYruXjMG5H4QCLDI1yOoCYVdcwZY9uwNnSwJP0Q/YZx8zz4P3R/qIlAL0qgwsE/PIkTIv1WV7s8RB14vr6qQrz2TRfPKhYcF8FqgC96yXrcI5uk1INZpijZWEkjNz98NoiR9VosduDYKvYiWshTm9xE3YRIpHk/8LrzUnkMLMrEMXKkBEnSq24BA0HYBqASSPdJJFFP58YXJq53SrrxNQT0x+k1xOEqcpQ== 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=zSMqJx2PL+v6MWcetRwwP8P9X79cWki3OCg7wXojsEM=; b=QQin90HnoutbShxowPw67XWnipSbg/nESmM1h4WA3OMoFlmKaISNVp7ytSu1CFtFl07TYyKK653s6hgH+X9l51yTEIlTYr/FeorgZzH61ruvuP4v98c+L5kyXs+/RwXAMU6C+w1gMJa6ZueNaz5EZwVUIY5LX2DG2BYt4yIhLKaTeJ+QEymwLhn3XnIqlbgu4vCTKI/mph+zySr9Xr+WzyIEdzEHSX7jPwtVaudMFfboSKmN8/J7ejUGUrXm4ne7fkewqsxuwZ86yCetLmSDwy22G79YY6uPnDtjpGn15R54RyzaY6QxfqA98EyFYuVbDYCQnCAAZrJ980yB73q5rQ== 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 VI1PR08MB10217.eurprd08.prod.outlook.com (2603:10a6:800:1bc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Tue, 31 Jan 2023 10:27:54 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6043.038; Tue, 31 Jan 2023 10:27:53 +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 v9 12/12] parallels: Incorrect condition in out-of-image check Date: Tue, 31 Jan 2023 11:27:36 +0100 Message-Id: <20230131102736.2127945-13-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> References: <20230131102736.2127945-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR0602CA0016.eurprd06.prod.outlook.com (2603:10a6:800:bc::26) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|VI1PR08MB10217:EE_ X-MS-Office365-Filtering-Correlation-Id: d0f1ddf7-e95b-48cd-1713-08db0375cfe8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j5HnB0rhusS/IHg5llivEioDU7goZFEIBAPt7lGKgzkizO1vFVYj4KXKeG0CLNk2nrVBeJoXufM6Ey7km1vu0rHYje3738DPaIGa34vjyyjMCsDOjfJ0KMlrGLXCMmF04X3khswCol0vGHLFmdAbSycr16T9Gzm1HXgIGP1vELQDy9RqARtt51Cq2zM7ocD96quIsUglzMQF33CYx17b46DhMpBWYRFSB9pa6fJrrYDxj+f4C2DFrQY61dsw8pvvBPau5VmzAx6k1QsxwRl821axlycoRbC4rYFmrSqq02joRyK8ifqpndiuddQZ8FIraaPTxwfIFTyTaO9R/jlFBKndrvOnMFrn6IA7lP0QVax9z156aj0SxeS1TIfpT+m0F1oJj0OS4HB5uunmgwGAEd1mRHYNBABjEE5dAk3waHDKOXYjVJnEnYLqAfXXiozynN1/naxR2nLruwdgM03hPhqULC79SRDTpVt45vABZFGko8sjjGSkSmR93+KETX9TjZwJxQsQbrOFriCdyQ4f9UBBW4HafIMLexUL0WJBGeUkEI6NXl00zS0qA07vcb6/aTz5mR3CrxoWtcjw5ivsNs3Rfo1lsg964ZMrJcjpz31BSsuKQdcaSBldDtAkxqABnUYVslGD71W6vBmA2b6VAEEpzW6tYtSv8b8Acb7f+VYKSP+3YGCIrm3O5Jeaq37K7YTzaRY3+t7B4fbAme+94Q== 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:(13230025)(4636009)(376002)(396003)(346002)(136003)(366004)(39850400004)(451199018)(478600001)(6486002)(26005)(186003)(86362001)(52116002)(83380400001)(38100700002)(38350700002)(2616005)(6512007)(36756003)(6666004)(1076003)(6506007)(4326008)(8676002)(66946007)(66556008)(66476007)(4744005)(8936002)(5660300002)(6916009)(316002)(41300700001)(44832011)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: prcD9JqENMGv+F+JJqej3Zq35yfAyfDcmeMLIMwqUc/gX9iQbANPBoXbd9etgWVM7yOMymYENbUZmJUr/bVzramY0tp4W2HUCtbPNUMgxrIzg2yc2hjC2CqJfi87UJDs/y+FfVmaAnsI8oMcEgOAnPK9p4VPjY0AZg7XDeYAGPiMOZzpJeOAv16oeqT7HtwfKZsNYMg3IeMNP3o+ke9uofQnwFD0pgSVljKzKWwsJb/+qvcKV9e6m7f8sVizmCCFb9lkaWvuO8AGrO+EGeW5tXTbAbP69ENxn8wpHZaVbyJimuXuPOeQG871jclv/iPIQjLNf5ApFo2U/kHeCdhfX3hbkCUQdDxnMKhVKlPQ1OxHIbke9AG/yHgNvjsmuaolOg/8rWiqKLvB7gt+IfJba5WYvqTCAxz/9SqpWBEdUU6a+AJDmLsxvdg+WYm8RAd1wd5kWp09V5Y3t4tMrPDzWy0li5vw7UcHOU2hKhwgxGJQ7h4taVup00jNPUOY2WdKHpj2ixceV1is1Z+zcG014kVwMWPA+jDw505p4joW0499/4532olnnoFJpl321LF06Qu4Wcb6XZpv/h0L9wBRl8wlk0omUCQD8e4MPaqSPjL80uwcOXHgG0IRr7A6MlfCScr8vooOT7t6ce2hAnrGBU1Ble1SGL1osCpnp1ZDmyW8gS1UyPVGbTnOeJjePfM6gD6CflUU406p2W+tGwALtoOGbdC84VhXI1g9gaOkXxqLwuZVETcHOve2bHMPHjDTjRDCPemYpvLuH1XAdhPfIAs1iJoEL0fhaspp5Hk/kA6fm31jFKRlKeCHNYoyY85pogL0+1b40vzww7kcACtvEGn/r2L7dUAw8TCFs+x+l1RhWdJHFlEcyGT7bubBNVytl5zDWCpNrU9okmlqrUNOOjeJqfzXjdc9ku/emmGzelyqNpIvfajD2Mz9mpTexcS/O3NnE6tqFY8npe9IRH6H4Cr9NfTlOExx3ZqELVt3nv0FH8kejHkMbS2y8/sr2vfRWG63FRH+oDmyev9c7KYZOtkZaJtVJw5tyiryN8Y84ihrkw62htKdFlyuhkPpQ7AojI72DWWHQmgSq0Gqm9gn8AsZgXvIGBd9phgnlJh3zhu+dA/pbYVlbVS4FY68E7R9mjctoqj7n37IO4SP0cqsET1bVFziAoZLTzgCYQDGo4jvf29wiqSLibrzbSCN9WOXSz3UhDe2oUc8q6gWJhkxPHpjhwfWXkifhBMC27R/QQ6Qb6LPVEM/bs97qT6QY0XRafYkav1qtuu3hbYkY31G1kfkeJ0A9EgLsZTXvl6ZJ55bME3LCCI/sCawTKGulMqFRsTvdid9mfDLRJ9SoN0w+9VIkhhCd9LyKMvVE0rsVwVkEBcZVuvFYjakK+HyjU4SMe1N0ifxAXxvorAZEpo0t3Ip4z0efzAIDi4/4oFT4mylIOurRBrIRJaZ58M7Kr5dK3wESTzcw+SNIcQuOSZer4cVlLWy3UNIqnOlZeacmZXaaAVqPSzBbTEJ04Alrxz+XpHTq7txi1gGQ+lmXCORdim+GRhBX1TNtzGaNy0cgz9ozczMy1tlJA82s/Kj4UW1+WbswB3/hFWxOMJc8+z/P2vgfQg+8w5cJqkHaI1v3I4= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0f1ddf7-e95b-48cd-1713-08db0375cfe8 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 10:27:53.8926 (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: CvcH2zdR3R8q9NJFMjTkj/Zg8XY1czw4utu4NNH3VEpG0ML5YO1JFc6DYkuIXwO3v7PVhHc8HMdegp6yu5TbJoDTfRadOaFmeHWhub+hHcI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB10217 Received-SPF: pass client-ip=40.107.7.122; 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 e4faa14add..e469fe3f78 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -455,7 +455,7 @@ static int parallels_check_outside_image(BlockDriverState *bs, 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++;