From patchwork Mon Aug 29 09:24:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957589 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 8B3A3ECAAD2 for ; Mon, 29 Aug 2022 09:28:36 +0000 (UTC) Received: from localhost ([::1]:49202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSb4L-0000RG-Qs for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 05:28:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSb0Y-0005vU-SK; Mon, 29 Aug 2022 05:24:38 -0400 Received: from mail-db8eur05on2097.outbound.protection.outlook.com ([40.107.20.97]:38848 helo=EUR05-DB8-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 1oSb0V-0006gk-On; Mon, 29 Aug 2022 05:24:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kjpBfJOiPkGw8l5lLfdnzI7t6uF40Z6zeR6l6ovyblbm/6qYkPCT5vw1p8XOPKrFyLSX1ZIpJCmMbQXvhM0PKFzxmG70MFyR0jpc9+MxGOXFMXn7iFu9sqrqPdnLMxCzGIXPQo9ypJx/YdyjLGtZozLx822OrY9iWPM5mxAomKCWC5fPkDFlcgspBPw6cl1cvbeydSHAu9iI3afn6+yPXAwPax+DiKB9xBFIc7j1A3/7ElYzi8TizQlAiZbX3cg7nVR+Tuawa6jjBZYS1SORru+emEtkIGJwfChOIbV/9bkURqvk0h7UiFNxp8x7CfcYZO+5r5KmoXohC99kHAUF1A== 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=ZGP3DBjWL1JXmKfgIkKAcZVSum3f8b5ClOKzvr9OcT0=; b=hkscSiWBAF8JM6Zk2PNCRoc3H457oAV7BJ10BBWDGE10wBXDKEKheoRyZyg5PenukBiAJYFaiQiaEm67ROuBKkBCJcneD3EWtSDNgK5d5jpdkmkvI9qOsWPGa+xXG4LrdzmgWRlxbWgKvyK5ZZMoTiHZq6Ene3Fhrpw//krUp3rA3iut1VYSVulixVUnWuAwOMZK9H00EyPRqcwGwtftkIQxqN+mF/08cvVVT6nI8Tlcoz4DYtOzEvNN9hEgQ+kKoOF6YHrhmxAviuPSTI1mBHBqf6DiJPzh/afTVs2QouSSAEWFlD9/FG3nj8oBLLafqK4RwR8Wy7y+xx199Abm/A== 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=ZGP3DBjWL1JXmKfgIkKAcZVSum3f8b5ClOKzvr9OcT0=; b=oNs4czi+SnRYguzwnUnhMQgJ08Li3NopZ7kRAIMrUP2XpRIIu+tu+T2UWV5/uYrjsCEkoe5Skz/eaYm8AhBeJX76HXwLtfuLkz3Wx5/QCAit8l99dTYSQjGgV3wNcrAoqzqGHoWHr/bu0iMbFQSs4Bk9/zekQRh5KGh5SIAA/QN1MrxMBCxFXT6nU0QOurXwTAb8d+hDaolmMR7ePBcBL0JdQWx8OWzgDnhoj/zHow+88Ff1AlwWIQv2z4dL+dz2pQhmomQXP97MZRf7QHfUSgTPPiifGzTpMC2TQN2o5NXeUghlzWJRdvw1Vpe88X9JMJHyQ1RA/bnn1HLoL4VFaw== 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 VI1PR08MB4447.eurprd08.prod.outlook.com (2603:10a6:803:f3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 09:24:29 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 09:24:29 +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 v7 02/10] parallels: Fix high_off calculation in parallels_co_check() Date: Mon, 29 Aug 2022 11:24:11 +0200 Message-Id: <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0166.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::9) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d83a961d-29a7-4d6f-b9a5-08da89a0460a X-MS-TrafficTypeDiagnostic: VI1PR08MB4447:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nrMa5Fm3xrKNLEDKcG/Bod9gMn/iQuQdLZVHp6zfqF0UkXO8jYNhaF6MaFNh0uDm56tJvwKylu2pWspiYCaITTJtQkPG6XGCVuAdc+FNsx24MQJ5RlC5PQh3jMPH2cWlS3iGY0aHfZkc0F5VIOPiDKDNa6VeeIsYQ/ySc0lLFKJqnyrIOxJCrWgOaYDXv3a2zHoCrtbvRLR0NYKsaqN49Ukn3HTgfVVslQZY7ibJH/HvKhIH9eUXgra6jNSLK7fBK6uvYBjG2Ib+sw15ewO/ZloUVF8XYyUHnvegWd8NqoAAE5AbEqRQ8dbnrTDCr+w2v8rV+84oEj4UjnT/xT8cDLZz27Sf2gkAh3dGydc/TqXtyOMAf3cwCOaOreLvN+PIzRLM5bHloADSVB3sZ2cBViBptdG3kRUgFzUVaeLY8YLkt7sOtUutjk81MPQgSVvmF1BSFeRDyabWOASDMh1Jx2ZtJfWpq6HLverbLzx/HlP81TT4gtRg7ns4iV76hnrwfL/QJlQ0pvXcgbCFKOMjWrXPFSjILlZ/uRhjaIDjK62aAtpA1iy0U3QrT/mbzPOuG5AtL4UeLiXwzvT2fW+OeKaXlTBhxbwHwRjEE/5Nl+z7NreoQCPjFcOS42QnCuO3hugxM07iL3ldrUw50WNveAx166opfqttDtC12ytl4NT82GLn79pBCCOneBN3gxN3RBvnKA6/f4eKZZ1gklSD5lDhEGo3/HUJ8yKcsiNPOOFg6IUefDvIp9FegS0jPPnk4FNMurlLqWoBOCGD2SWy4A== 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:(13230016)(4636009)(396003)(376002)(366004)(346002)(39840400004)(136003)(1076003)(316002)(6916009)(8676002)(86362001)(6486002)(4326008)(66946007)(66476007)(66556008)(5660300002)(478600001)(36756003)(8936002)(41300700001)(4744005)(38350700002)(44832011)(2616005)(6666004)(6506007)(2906002)(52116002)(38100700002)(83380400001)(26005)(6512007)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QUrbKM5CucLgHmxC9Hr87wQ2rdfiZgd8erCFQOGvX6sGvVeN83+TazYgGJB7sRc7c3RKB/tXUIrSJJ/5R9WwCq9UCB4Oh145jsYBJTBuQtGSiPLSnzZl/HSMng8gVw31qVrB13VNA7TqHQl/chGg9DIz1MBUrrL2YdA9lf2bX660k7aNYB0zVtJmhi5z33k42XeBTPi1skS4z4V0xqXDQpHNNoFOgdVUn3fDYHvnedgpjHWXOfSwtH7odeNfCWvqgZa0VT18MfsCZmUw/J+09ryiIOD5yZ6lCHyzD/YK2lSIlcKcYZjvDLp2L/GeIayRwQ8S4BdMIZH5kBeJlgo+0MtT8Mt/yKCzBXMlA4/K6QaoNv1Ru/tB07FhYwPsES18MuP9Mzyv9/Fe7t7Md73V0xnpMj/NMjCvB4agMOdKPvoscjBIeXgAdB9Xthta9nVCzkcGJXZN85iYFKJas3OM+oh5gAeqpnLNbcVIbIeMWe4l+iaXgv7unMpkCgr7THJkv+GzlWG0M/lEVNhFJRzhnXefP9I8XEhdqnaUe9t48q2AS1nVXIDCbIX9/t5Lkx/r7brr6MGyLc8lLq3BXopAuGgTS45WuBPJb4cBsVOzR2x9mP3tzMfq3RCdt44t9pp4ckTcCUylVq9xVPfKC+4xQDEc+9zBbG2n/6UGleJVd0RbCDPbzpawSurKNFWqGP7FW9VeEVpRlP7BGd/AGktFmavyX3Y6kGibuXnuYHE63Us0RyreLQaX0t9sRrA4OGEUttdCiwQ3PB9DQlPtK7pOA8qgB0WwTwWuPMZQ2ZOvSTg3x4Eclk6+hDsHl2BEnTpdVM083dEXhJqJD6jZnUCVOBz3P0x37/nvY/oabICTvlZsLO0rhEX5nhRwIN/pjUPNo3wBTa4WKaeIMHSFehZYIfBClXbemHKeky31/j35GKUUFomu+RpFnQxqYtIVuHtf9eCYMnCJySojdYY4s9KOunCOJoz2zINBF90vmjWZqE7MLO+GxQCvhJ8/3Z6Q7iWJyzgthMogp7Q67ghuAOlqfKb+9uDpE3i8pwTtOu3stS88soP7UdGhlyB82Cio64khF3ssvJiAlXWG5HuHbOvk95rN+qw1un/CevxaNlbsInykgTWDIol4kxwGhm9wfJpkpf/PzIB/mP3BhHN2K33COqmE0lTkEuR66P6AfP5i189MeJ2Hz/1XC2+NaW8AbTEPqCs3DSlS9OqwY403HfY1e/uz1uBALZcBDXrQbGkNJVmh+mUdnByvKZ2tNOgDYMy3o0uCA3RAJAR09PeKgoiG8XvwvrIjfActJCq2SD4ObPd70rrR9TC0QkzljNkO/1bdZDUIhd7x/dP+SN2bs6oPkS7UiPCLgamEDs5G3jLORWLPYDL9CZvBzm7mxtSQCxBkD1uUR9xb55aDKzV3K9Flx+i8iJMs6IhESTvuNitJXrEI6E9OOHRGPpV32U3+Kp5LGoFHCI1u4oAdC4sfBOcbBrdIeb9vv/GDu/+7o17RS+vtn2NhgbQy9hCEPxdhfgYNihbUCUhxGYFGlVoEoxCgee8MeCeN0zsky6anMJIbiqxewizDJw9xC8cDit3eSWsRYf25tVs0ZtnkFKatnaPlV8WDOkJhnsO17F5IaHmMFsY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d83a961d-29a7-4d6f-b9a5-08da89a0460a X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 09:24:29.1570 (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: k96I452buBAyo9F8SFR1XwRgfcbcGF1tzS7vePPv+EW17lmAOQYq8WHevU2vXDfMdC/zqF8uuWmwrQH5k5+P4Ed29BF+Fc4+8iWl3HiZo14= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4447 Received-SPF: pass client-ip=40.107.20.97; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-DB8-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 93bc2750ef..7e8cdbbc3a 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 Mon Aug 29 09:24:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957591 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 792CDECAAD2 for ; Mon, 29 Aug 2022 09:28:49 +0000 (UTC) Received: from localhost ([::1]:60910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSb4a-0000xc-GS for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 05:28:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSb0a-0005wY-TR; Mon, 29 Aug 2022 05:24:41 -0400 Received: from mail-db8eur05on2109.outbound.protection.outlook.com ([40.107.20.109]:39455 helo=EUR05-DB8-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 1oSb0Z-0006h6-DY; Mon, 29 Aug 2022 05:24:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lkejueVh8wyDlaKqXzavs6rx5OsSM+TV8SuuR34nb5I1FBhVYE7kX20/FuuESsCB5xe2juNRsVt5ZO3OkOEabYXT2eJJYpBtO6OFKFh2wMU8flC1ZkPPruIcmLziGwg+D1Xf2/Pd7q+kLGcg8vwkEi/OIUK8Egp0y2Vvk9kB9WtZwpwaaf8OZl2TAPAnP8CkjQcq5zS7Qf2AxmW33tkvcB7Tq34bzbFI7L8/86S4y2nLsZi+68rXiqFDaVtt3gL+p+L0zvRnOVpFoVvXyq4HZrWe6NETbNnN2SozF1oEJN4xMNsV8hmmGy56CfBtlu7UCsqEoyqCGtLWmRP7SX0GMA== 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=dYRFUpACEhkX+bXhxRNDhGyqPDgF7Ofp2pS31i/7POo=; b=ieH4JDpAD7fj2lJeGmOmhxxIKYdF6hrM/rWKT9XaVld8vY9cUPuXlC+Qbd0agvWzFR8l5eB3AyTQQQkzBITPW71p4WrVTWDnVcxfnXXUiAKf5kaPP6KGyscHuz6zHeS+533bUm/Qgia9CeUbxOAxtRBbGWxHvemAlFOUIGNkcbQDcSwnTzAxapSgp93Yag6bd0vmc5wNf1Fbt7eoNxK0kHlMut0SZ12UnRXtZSb1kTl5JYrW7ooDo4cfEZD/rvsIGyLOfVMzf0qz1ymTMEbAikbIjOoh/+YZLyyUb49B2+XAwl8s0pPyDWOhPpEtDpy0Qp3K5EyILLB40NuIcKa8Uw== 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=dYRFUpACEhkX+bXhxRNDhGyqPDgF7Ofp2pS31i/7POo=; b=Ei/aiJQ6BJ61kSizYnkPKMZefgSEYOX0b06IUYh8PwDtcaZFYQNqck+fxUipmL8LMsEi8CgZj36RQD7AMlR2muA2O0a4ejT7xXIQ+NbcEQ/+MlEqDMB6M9LiSKe55v5dpbVbYyjAUpHOgtIxc2nwTl3sEXURHOWoZeqjv7F33Zwoc6Q7RRVTyAWhcuSFjX9qT6R5Ho/XdfGl377Kl3m7x1jUMp0XaE9UE5ugrOJoYyO7V36W1+SSnndioZW7XFBhDpeKL2j/Bewvl01kLNdigRN0QEUAXA2tB45FWd5QxxIjlGrPGJkXUplGnbhrDKNxywfW/3L+UDx+PeyjnFXojQ== 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 VI1PR08MB4447.eurprd08.prod.outlook.com (2603:10a6:803:f3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 09:24:30 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 09:24:30 +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 v7 03/10] parallels: Fix data_end after out-of-image check Date: Mon, 29 Aug 2022 11:24:12 +0200 Message-Id: <20220829092420.341050-2-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0166.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::9) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 42b71639-752a-41f8-459c-08da89a04689 X-MS-TrafficTypeDiagnostic: VI1PR08MB4447:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3oqHhiJoGM1HuwHw3Y5snW81z8A1xgj0Iz+AXpw70nB7e83cU+46gDtJqbhSWAndSSnAjhrfmOiEtLyAsrCeEjLoue7m5SdNvyhtCimJYXr3pDV8ZAEdhzYB5EwYUnv6lYUg3he+lS3zCRUZ7qjo82FvUpjxfzCuhcDDFPXUUSmsS6Qs90tSo7sQ1JGrYYljkWQ1UGtqpPld4QARyED40xh7WWshVG61OHq7dsVpx+ByLF9RAk8/Nry4AduusxxwPgDCiDOEE0KZWsR5jQQ1sNcFQG+Y3e89HQ8f1PHCwsPV1Xdzcz88VurmCLlkyDyXhUJRUsCi7euW/DMHCLFSRL0p8n1m/WXSbJfxC4dNGwR4NJGkBdm1zsCwfzXwtYHfdeb+o3XEnAEyinny1h0c7KSiroYcpA0UMthIKlbgv1VpJ1OXBf/FEWC7Wf+8YDX2I/nt68EPdazRUD0q/rqYlpL9fbgVyogW17/GuI6sB/oEKUV9JkmtnaG/UsKPZXf5qI/09GgVTwj/WGITn9Rykye1UhlSjmfzRHX8wTb1Teu2bL5fV93RY0aicke5Cwj3wVGhEBQoXGoXn9ZLr9FoMiLJB96i7cr4e1LOknb1/2E+TRs6NnAzYDM+VtGRE5DbEESWl4+Zh1CWTex4UvDS5Bdjtc5HxAe4W6ZGBDDZpw9jg7LCBmGj24Jrjvmk5oEwwqjbQDUiftuL8o+diI5CUTRoOtNcJ147ckqY//jDsjCMAaClN4O+oE5OftViCs0lxHgkoc3gwSnJjh1hxYLBGQ== 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:(13230016)(4636009)(396003)(376002)(366004)(346002)(39840400004)(136003)(1076003)(316002)(6916009)(8676002)(86362001)(6486002)(4326008)(66946007)(66476007)(66556008)(5660300002)(478600001)(36756003)(8936002)(41300700001)(4744005)(38350700002)(44832011)(2616005)(6666004)(6506007)(2906002)(52116002)(38100700002)(83380400001)(26005)(6512007)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PG6x8oMma45ngroTvmtZiwZ5T1RRbtseS0IHp7FIkZOW1wuFLrBg20GtkgEWx6+pr8XncOyq4wWTL98fKPQH92YsUe51dAkC4mjOV7oZIL/DMTUSpqLYwNNMGoC03qtWh05AcSJnmlVQ7O+sUqraQIudeaer6WJVdGMb+ckP85BFnLYJJY6JQGFXHMxLyfQoA78ssJko41PmjGzKVPIRBZcxxAIZjCWfjwSZjGO8BFAJUj7cgqKyTPDenqKG5Af9sY0+9LtMrUrS5ASMYtPbaYJW3smx+1A6wduIl24oh9gRpKaxorXYugsd/9oA8TCNQgc8QHiZ2+ezyn+FOdf0VsX3NYbevP4dfNFXxo8DLGKpIDRzBFSv72z3D4cQs/FZujIeoHwhEdLeFs4hjGG2X6woHyVgBZG/bfHBPqpoec34It1wPxYfsVEDCYRDffOn07bY2SHLN4+5wOdtE4z8M1IeDaSMe7nb/dskPto0ArJBV1RSn9onsxbPa9ajVoraXC32/OFJI7hvoNT48XAZ026+EWDsLIbzYHF31h3VTiV1+96Q0srq9+EDjavLZPyBLokQW7SoPVMmWxQ9oeWGTnvVbvVw9VLeeeB7qIVKdvNUHzDv8J/GgdmVuxJi/+60cihwqW9aIFxxQew/kpJpsFSjgOMvH3jBki4vU2jmp9mIiLz0Y/oibt4y8CPnegM4Tu5nYkmR5+gqUFWdTuOjWmO6j2NfPWvpnTcmN8PK2BzYUokiQbM+ucwdkvdtwdP5tYp54YTWzfy2fCLYV0pp1Ir6OtevKVuXayt0dwhsahM2Aie3wSg+4g6VLPOrgSF0iWdz5rFovC8FAfA2qrPxh7ed1P/qAWp/fkldNuyl8qV1gEevuFZi241PtHnD+vg7TXSESV9nBGGeS9K+tYQDWFJ9AnchZViMf4V8DtUl4/8K33JgVDtU0cSczhbgRef4yTnQc2AWDUwJPnBrodysRoLGQwwSb8w/TeCFZaLu66ghsvaWmGDBnoIKkDJ/RWNA6xE85ROphvtCNRefKu0h1HFy8lWNRlzczygBlTobhOQM1vTbqvtjbReblp/es10yiH6fOELUa3fjV0V9UxX/rufMS7O+GUbIjOPy9rLi8bOJxW7fgOF4zrWQS+x1IV4hIvniXiQuC+9kMIZsX18mhb2Wtuw0nz77aJ+JxhXtug2X94PdkVS6j5RG6jqJudRhrKJM6u7LsHv6G+auLLU8dE2bxnsz/oZzSGUx+VjzemqXGIgBRPIpAsIbZokupbIYgk706DOdtp9Evc3HmunuIiNAn2sa3aBxovADCp+uhXPj6HQ2BcORn74iouV/r6IZClxR4rv7PuXbjtanzKFe6MNXJAVPojQh1kzoQ0yVm5dCVpkjYu5cwHvKCdmVetSxLmB5od1jP2quvniVpzNBfm8Wf2MRV3q2xfTcocWA+EV/KBUnKcJr+UKiC+tw7RdvpTK3S+5G4cfMLH5e8xLIQGCos92HavtClt/SGPoAS9G06CtYnO+DpUVNPO+znpN8aK8ko0YgRuCZ4gF/nQqeBMpUdy96MLd5wZKSMTFk6FO5Op2dFh4TgSzaU+9U+J5UkBn14AoFE3IHKTA6A1F9c2ASq+soKbi+MmNZrnoEa1Q= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42b71639-752a-41f8-459c-08da89a04689 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 09:24:29.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: MV5BNCjCAUCnWMZ8zhflcpEG6BHgl+m+Lqn6iJ1Fby/U6asqdZuLxwPvMUgbWwEDmyuIxI2QRtPMvDqqfLRE8KdBNd1riAAEzOv5TwyiXiw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4447 Received-SPF: pass client-ip=40.107.20.109; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-DB8-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index 7e8cdbbc3a..c1ff8bb5f0 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -514,6 +514,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } } + s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; + out: qemu_co_mutex_unlock(&s->lock); return ret; From patchwork Mon Aug 29 09:24:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957594 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 3389FECAAD5 for ; Mon, 29 Aug 2022 09:34:21 +0000 (UTC) Received: from localhost ([::1]:36748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSb9w-0006UV-5p for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 05:34:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSb0a-0005w0-I1; Mon, 29 Aug 2022 05:24:40 -0400 Received: from mail-db8eur05on2097.outbound.protection.outlook.com ([40.107.20.97]:38848 helo=EUR05-DB8-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 1oSb0Y-0006gk-Sf; Mon, 29 Aug 2022 05:24:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hHtwVn7xH0AZLDjJ1px+DTxm5wvcUimLOa/sYc0/uFWCiEwdSTMR0yBuIetA7x8wm7VV+/yoYxvpcvRAt/gdO1MLCy8x9LLpgkro+X2UB8SivCJDBGZQhIH/V7gxJO1OhiyktAFDNB99Tu4ET7hihYqZXO+YDdKa3FpmfyqeLlXmqTlnS9kRFN3JrgKraOfrz57DwEj9diqM/ZEqIqHAvuWjS/WUotw/Fq85O/tRQ7Dvi5laRfeqLgVlpVtsAbSdwEeiDFQxbxeO7MLtaK/qSAOmYi7oiddQmlT4Ja2kqhhUjORQoXB3y7Oo9Vi5PfuyAv13QmbWTa589NAdrLKQ6Q== 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=C/w8TkRCrIOArPPvjz5ambAyfqUEJor64AjcnOtRf7E=; b=UfF2J7Y+DwXIRUXrxHB7AcsndIFQ4Ddx7T9+LkAAfU7fG6DKalPpmPG+UM7/mncpr3IYUugXhQMFA72eJIWrE0MGBvvVjEaVCVonG+leKwLWg2N14jofi9c9V5B56yp9GES8DE5f0xifR9uP9d8ebMTSMAGQIfXxj/LMIz4eTnTLXvFKZjW0UlAVeFs8PgTc9Oytya+NZM5Dwi0I2H7Y1dQqqlIAmkEwIZNqHFREGyL9GoS3ioFi2nBeoXtgiuTwGmUNfUaudBBjhRQMcSa97MgH1ii0peM34lkzcBYGrEFpo5Y69anxMME03LMgzTk+8Ebm2v2+/rNr28XTA2q/rA== 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=C/w8TkRCrIOArPPvjz5ambAyfqUEJor64AjcnOtRf7E=; b=BhYlXAJE1usK9voH6R6pHxwFQjxab7/inE/PoJk9ZmgWb+uqLOnFGr+0qKiMo9cQma+b+rvh58RDw5yO/qK1Z6SMptOpMBU+LWjNwZG+fzTsp6a7w3pQkJ9tDKHzyDMEcYUhIdX8uBA+b+V7F1FLVt6puEyjG1QIqahHmwPR0irBuBs6KweLaDMgs9ou3+AMi9VUCrxaHlxBKLYYEVb6U58wKagZJeCmyLPO2shTt8iT8v2/8CqHhsPj3BA+5s198EUCUmB0EKXzD+lKtIJRh9CCKQXfA4EyN1HkxfbBGEyEpTIVqVZgNey3QyJhaYaCp7z2bQH5/qNeW2ch7SXX3Q== 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 VI1PR08MB4447.eurprd08.prod.outlook.com (2603:10a6:803:f3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 09:24:30 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 09:24:30 +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 v7 04/10] parallels: create parallels_set_bat_entry_helper() to assign BAT value Date: Mon, 29 Aug 2022 11:24:13 +0200 Message-Id: <20220829092420.341050-3-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0166.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::9) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8141e48d-5c08-4cc1-f5d3-08da89a04710 X-MS-TrafficTypeDiagnostic: VI1PR08MB4447:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kG/c5wymG+E4zRLJjTVCnA6I8zX2IL8kHIzoOxDsbndaaQW4YthIhdbxrpejpGGJR5lTLyKtGSyZ06WIlQzLyPKeCiZMfeowH9iFoIz7tq2v17EHoCGFK9M/ePAfAXb2C5VuH1TFt6zgh7QyIAwy+FrZfLaG+5z3mb4nngo1+jDFkvDdSt4OZkXANUcSXLGvQb3octxCeBuDO4fVE5Ue4Ime3rDRAE3akz0K1vA0qiILse98/ahph5KMR7/TlB57wKpH/sbTRxVm32mc5P23ZfuwkiCYdeAMWMOseVWnf7YQ3hMxHd2amT0oOdzHY+XUiBFK+ZGNZyM36gBXrugQ52gIiRJEMHFi8Tm5GdufzqqcEIU4oabb7QuW6PVpjBtBcCod3vMCXJXcDReY4FgmisN/IzVwRiRMnCVQrErq7YCwz66Eoa0Eup2OakCwwmnYoxkpKzKQ8FzVK86Hweg0L75fBy/U2k7Hiv8QJLd71UVIkK71XWtq7u/slRiPfuWWaF8n6tUSOrEGBBbZapx7rrAHOO2XwsJbFMkd6wlgE/evTTY9R/Wl35Ym8YQsIzGddCnylxP5jthNE1BJvYXS6vO0RcUcYiOcrDNruW02Fgxy1RubEX+H+BrlQGclNcwliVih1u7SJM5cAZbleFyuU2hafa5YoqCIjoSBvqtnbW6+BjH7nbL5tM+GvZMq2Q8ag6gw2KvWf0vC/WDg9aYDKRNOoMs6ZotVewgidmGfFfCZloCzjq/ZrWSeo3FisR+UywkM11h+0hEEiNrk/Hg13Q== 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:(13230016)(4636009)(396003)(376002)(366004)(346002)(39840400004)(136003)(1076003)(316002)(6916009)(8676002)(86362001)(6486002)(4326008)(66946007)(66476007)(66556008)(5660300002)(478600001)(36756003)(8936002)(41300700001)(38350700002)(44832011)(2616005)(6666004)(6506007)(2906002)(52116002)(38100700002)(83380400001)(26005)(6512007)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a95WnifaeorD94ahv3+SWtv1w6XVm8qpdbFZTklsFON4wqB4rIqZAYQ1Zl6yKlFUxdh2Z3l0WGgN5gOytSFqWl0TlLi1O6GsD+xvjim4uzrgPH0EeUoYlBVLSQrsfVKs0PD1DxHjf8ux5pp5Uowri74eiecbpLpIIwrfMxsTyUl1uKsUmo9qJ5Vs1CVntsWmn04/8ewT2BI2nvBRMzkvmiqvFqIIjC18jJXD/31XYomfiSwHx34eEWWmvbTu8yn1HV1eQiokNodPI7sEg0PMUxhT5P6cpEKb3ZBfGpqjlOHsLenLSZFGJrwJ8n04bg9B9GIloZYfCjEwyPcPfe0iKOUY3erfnsBppRxQVKbAdvV/gSliPuU4qDQ8Mw59h+EI16SJn9fxhyukK0iq3qG2H2ip3DfykJ/0WZ1Ezr0KUV2bHhjUi7MnFjXCrP6uGlThgFZvH9xQWpniNSIByjgy5Lmb4i7skxJPk/LmkNvYZI0MslsSJqHDFe1YahZVO1lmc4E2r6c7gYX6Mn0Q84/BKus7nkAiDGD/FfZmp2lbqgYZ30WY1xCZUxqhwnPk12xnMYCe0FrKPQQTuAXAvt63a1K1stZPE7pNId1v8YDIoH+qOoUZcctJSuPHd++P5sJZHXlncHqumlF9vsOx9/DeJvbjZhw7dBlgk1q8EXjlerj313eMPrg1gtFnFIMnB5brwGfselPgqJKssmuWiJSRfEy3oEJ5L5DV1dzdpcID7pkgL9FLGIVptSB5djRGDRA7Odw1vJGhSZI+fFYv/WisBkJn64grbYRsRpmTJZFkqt/A1yBNYupDn58IY8c+iUmPD5Hgjefhw81ogyQ6pnQtnxo0WeIN1r/yCmwclXFSZAtCz38V90z6AwurRQQAaJcY/85GOCnTbQEEL0U6D5FmgN9zAT43OomeUEseZYnnBzAcOtFn+XPaevitHgyE9fQZ7m5sa7HnwT0bR+txxcWHqzQQQ5tdEXPaiKKwDYxZC7F0dUUFgX9xbAMn2+htLlCYrAmtER6eQ+eLJC2A8o78RAjZtxRnosdcduDaIwhFrZIn2Q4Se+8gkQHxuPqadL0Mnd8hcVxAn2dbO2T8vrGj+uPhkBv0xYJbh3uJkZ2t0W5pDwT+BrYYVsqPyMirWPtgDcHYj+b5QXTExRGgH0+WXBPajzIGSNQQcSBCFXuLUisyS4xsMvp2snWkNuaELcowvAvaI2Wd1o9g9SdVxTjScHQX0SoIDzzwyodxPfpetgvDIluJE5qPWbrnYwdGM6VVTBUV/9CUiSvwwb3WpaSKXlcWOe8dY52a2Bn21ClDns/TghtgIzbE01Zms7bL7QQcAAT0roPuqoZMw6HcDWBg1mTbF+n3eW96T014iR7rWn8Do4n9DO2g7r2Xapl9df1ilEUvD8EK9NcsBa6shYwpeGPGbBs6OYXtpvGBiUmzGlXi6j2l/C0fXCt0NP9YC93xOR5rMhk3CRT4LZAt2/1dr43JUMnN/23Xam6lzKXCiAWl0e4Z5DuP3eF53cGz22qvjj861gALJFHYUTQH1Imu9mCezlA14KUaKtbpYECC0/Mx2QdOuiPe1ayFL5p55cICciP2DxDfZkTbpF6WNhGa+8uBLx3BhmXd5asbO+XxGuc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8141e48d-5c08-4cc1-f5d3-08da89a04710 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 09:24:30.7975 (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: UNVA0EAtXGDX9opwDipxgK0Yu5Dsdx1+j+PrPpgBJqY+gty0oal3jGb+bzaYXYcyYT27Rcwxq9BVs4UwpaYWy7SlbkD7/4yMsQMnlf93hJ4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4447 Received-SPF: pass client-ip=40.107.20.97; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-DB8-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 c1ff8bb5f0..52a5cce46c 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -165,6 +165,13 @@ static int64_t block_status(BDRVParallelsState *s, int64_t sector_num, return start_off; } +static void parallels_set_bat_entry(BDRVParallelsState *s, + uint32_t index, uint32_t offset) +{ + s->bat_bitmap[index] = cpu_to_le32(offset); + bitmap_set(s->bat_dirty_bmap, bat_entry_off(index) / s->bat_dirty_block, 1); +} + static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { @@ -250,10 +257,8 @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, } for (i = 0; i < to_allocate; i++) { - s->bat_bitmap[idx + i] = cpu_to_le32(s->data_end / s->off_multiplier); + parallels_set_bat_entry(s, idx + i, s->data_end / s->off_multiplier); s->data_end += s->tracks; - bitmap_set(s->bat_dirty_bmap, - bat_entry_off(idx + i) / s->bat_dirty_block, 1); } return bat2sect(s, idx) + sector_num % s->tracks; From patchwork Mon Aug 29 09:24:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957595 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 40E7CC0502C for ; Mon, 29 Aug 2022 09:34:21 +0000 (UTC) Received: from localhost ([::1]:36744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSb9v-0006UA-Sf for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 05:34:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSb0f-0005xY-Un; Mon, 29 Aug 2022 05:24:46 -0400 Received: from mail-db8eur05on2097.outbound.protection.outlook.com ([40.107.20.97]:38848 helo=EUR05-DB8-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 1oSb0b-0006gk-5L; Mon, 29 Aug 2022 05:24:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gCiBYR3DyWVnYQXZmgcnlbO7lcn85vHYIGv/1wK7lelfKeKuPT20dEtKWPHfKRN1sx9GJpUKefyutWVa7B+6PXHrYvk5YNnpI5drHtwJMS6xDJe6iFT8/GGFwG/nfB5i6B0SLZ1RVfpPekyfWL/jzeBqtAoaARebyXeEshtwD2CTF2aTY2JKBblKACKiITVFjPkvO0wkBaEpcAJBgz959ZNrz71srMWxJaKdtU4Ge8l5otoqUvAEeQSwr+R23EPTBB03+W+aaWe9KTCZtnYVuJWWlq4GcvFL1D+77n5377fvXyfxgCUKlO6skgn6Uge9aXP88n4LBz0bJQ6W+d9DvA== 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=j2iHD9ZuqkW49ytEgmewpRVI1oNPJycke20yFKQs7Oc=; b=KapZft456jDfoqo+eTgYA4Cksu5bH+JgEzwnmAXobe1fbRn26nllRbmSWnO4yiW3NX8iPyygTMLB2r9z4mFB2TtHvkem4i+QMScaRYNZL5hlc0Wh7nHA8qHh+C8F85q4zZjf8NQfVklK28PqqNsLTL5LAQD3MWk0q2b5ZMH68u+rqfpGiFxLW5pCISCwc14oqyLjsIPd124rI8De0fO59hKWHAT0Nfql6o2DTc88oKkJtqH7eqgjho7wW0fuPdEOpwWbj2/brFH1s6C/9YosNcfJkfIfau9t5u331CnofMPR2liZCdyrcjJG/cNo5brjZM2pW087qPkSVXS5yFWRfw== 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=j2iHD9ZuqkW49ytEgmewpRVI1oNPJycke20yFKQs7Oc=; b=a7LIqQTJL0mTeUWpvqD95wTecy3oXjr8HPwOVWj1ZOMTyzTgcFzurSlcKJ0NLhgyl1s4urBYBgncaW8PRjyDDJBMXQomGEuDK8bXFyWXB2SqTSl3ZOTsiKsaOiAtgmYPpZK8IzqkrS0kqa9jOx8gRedJ0auai6cLDQl5e1J+VG/Pl+EPrtt3AXX8lbkavwbfw/BlGBrlu+f2a0bx0czyVKFoegSBrvjhu1/gEMJXbpl9Zw5ur8xR+4xrojCeOEQBwsQRKDJ5LFXG4++ngBfp5ghk0Vj7nSySiRtF55sskz4aDzit8Cg0+RG1R65rJ/0xTEkKiuObuGKH7Uw6yWJ6/A== 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 VI1PR08MB4447.eurprd08.prod.outlook.com (2603:10a6:803:f3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 09:24:31 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 09:24:31 +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 v7 05/10] parallels: Use generic infrastructure for BAT writing in parallels_co_check() Date: Mon, 29 Aug 2022 11:24:14 +0200 Message-Id: <20220829092420.341050-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0166.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::9) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e1ba94e9-e0a7-4aaa-bcaf-08da89a0478a X-MS-TrafficTypeDiagnostic: VI1PR08MB4447:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SGrZLrbwHbdUMcFnGHQhYmzYr3B9tmRuKKTDhlfoubU6AoF8Acx276ftDGvcmqqsTJDFlUtRhdYIzWFyZ6/jhO7jIfPINfMci/8nGENxnbs5XNV9OTKRYPni41YRgpx08ilF2KBuxueU79GMUyg+EJRH7jPMuyDAoNA/jj5HbKypc2XJwUyk7fgzi872DfrklRHjQG8zoLbmJVHZyvDKFWL2ezFGTnnWywtvXJKTiPoCqxkDPf1gbypTU5ta16YjwhzXYYSPUr8Hb0BhXdtK9A6DtNVIKnq0/KZWvFv0s8HwRL4nhR9WgbGltYauQxxv/W397hk2uRctbyd/xzdLYDCOdghK0t/2g5iDT4++Lmf9kl7r8ZKPJcF7/gCZ0rCik8wzPq0z2HVzBK3DhhP8N1vVmUtVuvj347vxuAwgWlUI3/ENuNPQKDimrfUNcue0jEniwbplW1+C0XgGhjaSaXJHYJSWWvlTfAm87nUQzk5IeBIO+CnvtrEXCfC5XCiucX3W5wupm3OeylYgUsNn6iS9bp3NST3YTGhL15u7Z3b3pHRsaDDV8yFT0OQEYBIA8eN7SU9SmSTEy0wKwsVoBNS3173UYD7LEzWEYTB0mA2Cbzp1e/CHoNGu/vpEO5c/qRfdUVKSV+WOA9i7+ena4CEfP/qHZFJIz2xvQkf2PHTLy98l8NGVALKEZgQz17ML4i+4/8B5diZLF1LhdgtQ3PMo30Kp94gOawiHZ3hiKsRMre40/VRaOAgKScYhOaDg6s+vhl66QnTdt0xWef4QQRlmj6shr5gxWdIEMKY1F44= 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:(13230016)(4636009)(396003)(376002)(366004)(346002)(39840400004)(136003)(1076003)(316002)(6916009)(8676002)(86362001)(6486002)(4326008)(66946007)(66476007)(66556008)(5660300002)(478600001)(36756003)(8936002)(41300700001)(38350700002)(44832011)(2616005)(6666004)(6506007)(2906002)(52116002)(38100700002)(83380400001)(26005)(6512007)(186003)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U3KgeedoKdYXTTaF2NF5K/0kBft+TSDOXRjbBillBdaSYVHBBFJduXNkN3MsqCorlBORgu8eWdV01NRWTEZfSWeMGeoRSsYi3Kk2inHov7iS8l2gwlASKpAAp6uXXFsRZQsdDrno8j03oSpuyyL2nM+YU3HP6fzLcNp7TZtWzDkBP6rHW4uP+e5h0QcSxVgl2cPQ74cO/WnaGpt/mq0bPRG2mtg1UYLTxOGoyBM2VJ7R+zcTkj1LlJDo2vvTfF7hwbtVx1+YjvIH/tBZ5bZsMRadTztj6ohQctMIKxJtgimqzIxXPnI9otRmbRS+mzQ/qKhyqjb8KS3ZFQ6HAB84q2kJ2FqHDEdVLoBugG2LdW648e62nLrQREi6TTdlgqTGD6KE7qTh6x+mXYAEu/bk90pD1RBDd2Mg0k5mGKuifO2mYS3QXs1O3yt2FQIkzgWxwSo1DHQgByz6A1sh9XFyWfca3HVR7GZ4bkIl0UD16coHKGm+AyJu4PltbqG9P2l9xZNPmF3UDBMHJ0a9NimbUUgtcldvPO2HEvdo/w320EqtjvID75VCYy5SwZJj/qZ66+oLn2M8vC1UYfsKl9gCMOR4FzoxXJqDfwhVMatVilOrLuHLcSrcIrMF6Sfhg8Mi9ef+eFC8IO8/R0mXq1Xlt0RRmWEJie6YBM2z0NWzZFLZMbjVs47K3wI1gW680rj38CwXLT0rieviFyJFq+DXbSAOkw2argC0nVCYzpHcemFh5GCHQpe1O/6UsLVyQKszro8CMOnVzzp4+ocFMt2SDB8dQ9NgYmSuk7H3Bu7bWadkLSVU1sxbVhWxm2w9+0HKBE5NGOrb0KNaaq0lwn8tR4soHs6jhzZZPL3aWzeCV9jFVg0eSUJ0UrOnhZm0XCi+t1+Gkd9Sk3vSenSUKDYKW4Pq6eetzb0cgI78mzdQS99GEiNvQxRbTDF37AG6C4A730Qs+R5LQE/OjwXrQixw9cbACpSuIfNl1l+g4bVhmwvCCu17vjlqpz1wvoBpSDM6zyvgqMguZK5LGkBZ2xmC9mfuL42+1TKbengHOhJjyI6V9D9ZL6GMC6kX8d9FzucWK/oZYDp7StAZGAMGmpV9IVtqsK/nrv0Syh359aYFU+EfUajO6LOXIqGdabLmSYnkVWBjTBlIi+2mWXDOwAFRrd5sO5tIvCWZoyxpS4D3uSSysmhpYhQjZdx5zc1ZrGOlcJ1GYnzm9Lj6p+NbHilNg+DHmlMr9wQtYHJnS1Kp2PJyIBdR+jn6v3BV54QBraaA5MWWF0qVkyAgkvO3tNcvFR2cOP0TJ3h0AOZ/Bk8AagRR73Ig34gMWVjPMqM9k138fmwW5XjCtFTY57tg9xUL8F2c4jFHNaAmbv9NsJUJH4EYpv1gnQ424ArlYpMex2ci736T3xaYoH+pnyzUS1dt0IcuPhh6/efsZ3E/nMYKHGoXxq45yErgMdx1jiYuM9dupLvTQ0cvGaFdd+7oFYoS4nNgOG76NyBCxAvt/BryA6cIv7Kjmct8KrCKLz2VM9BK3VOWiSYxZAQqtHfSYC1gJVq/LZJH3N+8FXy/nbBYvKLS5AJv9QvB+CYiQ2oRFziTLCkAGaNKZmdvCDK50MHZRl3y8cgIY9mYOClcmwn7hss= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1ba94e9-e0a7-4aaa-bcaf-08da89a0478a X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 09:24:31.5799 (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: tcMIfzJHgr6a32TbJHNpwlOp59GbbHpJDoqxdOBcktsfaAV4NGIDP3xt8LKTS+/x4y76gT+y4xzCAlsQGoCgdooYy9UstiiTsK6gLRwwn64= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4447 Received-SPF: pass client-ip=40.107.20.97; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-DB8-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 52a5cce46c..b4a85b8aa7 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; - } - } - res->image_end_offset = high_off + s->cluster_size; if (size > res->image_end_offset) { int64_t count; @@ -523,6 +512,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 Mon Aug 29 09:24:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957588 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 C6D2CECAAD5 for ; Mon, 29 Aug 2022 09:28:38 +0000 (UTC) Received: from localhost ([::1]:49208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSb4P-0000Ue-LK for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 05:28:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSb0g-0005yP-VZ; Mon, 29 Aug 2022 05:24:47 -0400 Received: from mail-db8eur05on2109.outbound.protection.outlook.com ([40.107.20.109]:39455 helo=EUR05-DB8-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 1oSb0b-0006h6-JN; Mon, 29 Aug 2022 05:24:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M9A23D6/z5ofWFqAVCH2YCAXfL2FNhF7FCzsvz+anlUrjySzZOFIKSzBozHfcoECo9K8Gb0GBXn9jwfK8IsoguVmpn3RRfBYz+w9pgC5BlGgTTAjT/vyJ3Xqfag7zwMGh2RlCzfnVxiBnqTWheihD+jSmveJp5kae2oKH80amjvXgTRvik2xbSYh4axKMxmuYAmnMvHLDANeNzYlCWAUzMmPksthO7Pg6li6QKKoZbkln4uKarPyn1AF+qSBGWmGEUyTcKkci6JjNU0tkFvxQzESD7UGvD0iBY7FO5x6PK5QoMQNpnxhvpRIOPYN4Gg2MxQkXAJNP3IvSG+RqYs0Fw== 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=tHAtEScGJd+8SaeeRRtxf4JjrblIDlJicxwATC0GIGY=; b=Viac0oOKpiLQ7yS5lk/TbU+5TczKmuMK1CeOW83oX9/Z8mYxsrlNE89AxSLeGhzB8hxcjDn9NQTU+z3je7lStmg7UmrOiPRFafWe0WUbfZSTHM7JCOEWdyo34Ewv8KxhI1Szjz1mySkmrBcX12ST/AFp7YWoUNC3nN8+kk6PhLrpDeKv03O/KavYEWtv8oi5fy3KEHwRKgF7XIgDWddM9l2n76AQAkWdBV3sOUn6ftdIYtDEFtU7K4NfKoZUJKd9E6av6U3qReae1Lt7MjMMRpHSTakZHGjGZ73NgEFvKqZI94AKKqkB5nzRES77zXFsGGXv+BiMfUaEQ7H0LrtGbg== 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=tHAtEScGJd+8SaeeRRtxf4JjrblIDlJicxwATC0GIGY=; b=vmotRUTOgkogFbuN1dTbYwSkGiiF4KJXA1LpvpgyMeyI0kLy5va5Wx/vQEOnwFg1bbECQhE0URnKPyfnh+n5vp2sDbfzKZuUUfG31TfYQw/7lm3RBqJcgWxyk1Yhg897DmXCYf3pFj6UV/9rDEZxnqPM1svMfNcZATnRj2KF5uFSCdkaZNRGHRvSvhL9ZFDIenvTmA+vOPJYiHHe57xLbGB+2ZpcZQmjp4fw+6Td9/xSrBvthXIWI6GhZxB23O2LgPHlt7+ahdp+PfGkju5iMAZzI3c8QAsaDlPkOJdX7VJiJwSxmp5hMDrfuUaGaVd/Wcfj76nzuL8BaqGZX5WwUw== 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 VI1PR08MB4447.eurprd08.prod.outlook.com (2603:10a6:803:f3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 09:24:32 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 09:24:32 +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 v7 06/10] parallels: Move check of unclean image to a separate function Date: Mon, 29 Aug 2022 11:24:15 +0200 Message-Id: <20220829092420.341050-5-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0166.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::9) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: affab57b-2865-454a-ed4f-08da89a04820 X-MS-TrafficTypeDiagnostic: VI1PR08MB4447:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XNFgCSoXhbSGTSjd1h8M/ND+JzUxH3jDa0/uwHEsmGwNcrzWIdyphfT5JqQyZdn8UkLZg+fWMUwu6/tHBA5neT5y3l3oetJp36SpuU154/ADFp4f03NEj9x2PGyDz8A7ldMp0R/Ruh4BEtavoEXfpppC3Pyv7SoM3C7g2rm2any5rq7Zdu7tq9FZcob6pxKMmdhhFeI9oQSTF6UjmnhTVFvzKh4s1uap6P6kEvnDU9oZox0wI7RC/g7OtfiHI7X3msa2lInM8rAeuOGzvFi4qT5luCusAvr8V6iXH3QKDaulZb2EbXCuqh7N493wHa2NOlRO9ioeSmYPfx7179sDnQ2XWlSc3tF0JF2s7U041wUSaKnID4wupdxBgvenrIITt2LScHg/KIBmz7oVrBgCN5w3lOvKvhgWUBCXbmtzdqLA3yz22yRCtDg7JnCQkrmG16dbm7aG3rkVZNLcRUGk/1X1HsLr8H1d5qmuChjfnEpdBNebNhWLH5vo9gtqNUAOnmXN+J9DsqNopdqqtTQV5DUlsTGP3DP2pxRs2HJ+MAuuJr+nsXFwq09ctq5RvPX6f3dmWHlgC7rZp9hcgdOCmJw2zO2J87jiClajSZShUuMSNSm5ZOral1ghUt8Z1+bajOm6E/Y7AgkLw5GmayBsI/5HBMuCG/vKTliI5TFuP5tFVmI651PUPVJ9aIMT538wPUDu2zU2yB1TcChvhcvNaar6XKJEHpv4qtHArg4NJLnf047eDld9DcVCrM+lrCo3y159xHwzNyHxW364gWVRkQ== 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:(13230016)(4636009)(396003)(376002)(366004)(346002)(39840400004)(136003)(1076003)(316002)(6916009)(8676002)(86362001)(6486002)(4326008)(66946007)(66476007)(66556008)(5660300002)(478600001)(36756003)(8936002)(41300700001)(38350700002)(44832011)(2616005)(6666004)(6506007)(2906002)(52116002)(38100700002)(83380400001)(26005)(6512007)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: v/vRHMpaBoM/JXbFTwOsPeeP+SiOrcDhzqo5bH3dIEHaVRqnQo7sMF+SIyQZphJ3i8RwHsIYfg3ptAtpgHjiA70T5rXm/SbFGHUXx4trAH8mQfiIB+ykrMshZ575zArREPR191LzMwTBxO4LNha9kx0efQ/hjZwkv+JJCkPIBXAo4OxDWGBCvglywWIl/wuMCc/K9LFJIdH69MP+LtHTA349Uf8FRg9J2kvRgj5aTryPwID6vskM0LUp9EdBcCaXNJxthaGrb7mgbQ4wkM/epy2rJ/WqCE4a0rM+VcHBZTaYz1QkYkYYwzIdtihvDojsuBkFFrxW7p+r/CCv8SXK+g1GXm9YhxobXtAqOiOuCo+QNCGpCawfaxy7+gCANkOgpgYy532Ms1xtT0UNFmjCMnbZfE7/G1UWxWQoueYRyYWRnpqHrXQ+peDuh1QZpHXsYou8Z4nDefW1Ym7w7Nc0YGIa8+3BUPHXFyMwWxw6o1K3HEa1hQhsGprVKv8isTh3u+D+u7k3j3/EbW1eZ/kGl+fMYGnBgSnaiAD7R3nW5MwJD9BJ+9+djqibIYHG23Ga4qZKHt1cLj6vCCngh9RUFzU+BGeVRLkTFT1Z9MLSotUnKYL6ZIPfcfu06Hef8Jnl+q5Y+NJCc+BMXG5MzCT5J5guTClN1XT8uGFRQZhvDqifm/5RhlmQuYKhr5JVCgBjCvRYSBJXw7rveKXzHaI3in5I3RcVTBCs7WqqkB+dr2PszRoutra+zcS3eNE4dT/+1+DUt70fPXnHT6fk9P2j5IAaaJWl1jkXQHEoIFX+K0ZDSXMAFAY+12kkY+ZQDGxJggroJg5OKH3iBh+wGqxNWp8Yysj9038avdBxoV9VdRV6Q/SvAw9WOOckJePImfxOWUSgp6Vh9KOF12CQZihulz3v6APoHDtF/HqYEz/4zX1oGRoGEeis62My2Qt7iUzZGH/CNDsHjHo/GogRIrId7l0tWNxn0DY6LNXK/BuzvNaz9cbUo0H/m82pDeZG07RCqqHHgLf4TGcz503kBPq047+RMB88iHnaTNEDxsxTSoTQE6wo+GS/4CaLM88GSK4Opee7iHTHbSqC5t5iBbdLZ9v3cc6tsbJm/cERpwyi1XdicxZ0wHjmD6nSo7fdJ3oK+6/YbyLKJbx9shJgIS2EAyGhaVQ4O9pPSOUK0Axu/0kCC0K+ICWqghMTmU/8z68xJhEwYyaa7FInC7uaf+zGJej7s8TLOnY6082UeQ4lJ0IDa28oRDCagi3r/bfmuzy8idDIXHtSSG3wjAk3fBEmRHIaeKniFyCezLXsANgDMHEfM5ptOaTPvV2WqjclORq6pp36AO99J2gnpJuXGXzoblmDoB82g2vHweavQNlUMpev9LhVHIT2svlgoxe2bh+A/k88NhOsBRLP9oNi2dMY+9yDZnFH7nmfqY7oQPdkoPzn0pPcPDJzsKWWHvw4RT+r2b86E7bZj+5VsGjXqvMxo6+4E47nHQi6zsjd+p3yhu0nllCbPtYirfU7r1Ur/xOTs0jMxGawu6rhC+av8HqzjduvGhRblHGaf9flPhoOGqGEnv1x5d+YqLX6EfMauFeIA7GaVOf1ZKA47eXIXOUpfbI7mQ7+ryKXBuFkiAOr5Sg= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: affab57b-2865-454a-ed4f-08da89a04820 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 09:24:32.5173 (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: hOqI/kIvNUigcRrJCmx2bGeYbgt50alyV812uMNcWvtgxLKcViZUOL4GYVz1W+pZLOLkS3E14KlMMFFy/q7m9hQjNyQq5STlmymJhwSmiTc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4447 Received-SPF: pass client-ip=40.107.20.109; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-DB8-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 b4a85b8aa7..eea318f809 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 Mon Aug 29 09:24:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957602 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 798C9ECAAD2 for ; Mon, 29 Aug 2022 09:45:52 +0000 (UTC) Received: from localhost ([::1]:43100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSbL5-0007ox-Fu for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 05:45:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSb0i-00060m-Ae; Mon, 29 Aug 2022 05:24:48 -0400 Received: from mail-db8eur05on2097.outbound.protection.outlook.com ([40.107.20.97]:38848 helo=EUR05-DB8-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 1oSb0g-0006gk-HM; Mon, 29 Aug 2022 05:24:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NJnmJvqHGvJxXaU3hGA3gMxirRoT4nmVGhFlkqsAUyKOCWQw0eRk2VjnUoAE0WeNbI5JjZdXECoGjVII4x94Wl1b3lW+Zl7tmbqBkSJxfdvX/X4FLMHno8kN/QyzMJSnjd0DA+OYmHuZy1F9x3WUR5uG/YLrmCTvkbJJfHztGoCme5Od2noQrPZhWxIxNIcYYWgHXMYQjq+pTqxd6ySHEm82UHqQzmub+YfmstoX4t2wBjrIGVHd5g/lOd91gJSdlrWsbWmJrp55CeAjkCk21L0eteHr9jcWlsTaweKdMisEb5ZxFmt0AKKjyelKTiLsMvL66XDmQ9ZdDXblheN37Q== 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=LHDIe4Iu3ENxd+Rq6crXwWLf1mk2dxrBPElvAXWaSC0=; b=NhggNx7ubWRthHlJkNaTV/BpAoB/5l3yzbji63A6NPvnjWRF9eMsNapwBXgkDjjkB9wrZew6Mrw18T/Kz9Ah0SnpIbhxppsrk+T9akPMNDXKI0enSvetCWlhf0wNJREiP6CXppRo6kFERnBf6f/eEfpcwjfpkrHIiv4RwqCWSVW571OYcGOEmhc90/pm6ZgQw4REJxYDLFmmlPAdZnNSeHQMXZTFkJMgYaZg3pgFMIHOttqRT9uV9KazHwRuH9OuJo7bxlpQWZz1pMhOB7Kkveji6rmQipOM/nfmo2OUl82Sfr4Mehh205GGqD6AejHrcg52KiPhss/z7LBMK+Y6tg== 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=LHDIe4Iu3ENxd+Rq6crXwWLf1mk2dxrBPElvAXWaSC0=; b=exttNt6oQ56YBTUJSzNFW48NIRNjra1y0k4c+7k8svfOnvxd4+G3geqGIA+F7zv8x9qO2VpVAcD1jOdW1j/+PngTTQtcHjLr3e6cwnEAJ0P72tPrkbZtB9E4yOgdzWD94LOP/EqQqKQQtHyqLPtsDYR++k8F6u9BSGhYLkLQFfQAYTU4XruXSYgyn63K9HHh/5pibJotAIHamvqbIJiNmfquHNJeeaRE8sPwoPsoyuNkkchwhUEqXUfP4ZPkHnRuuAfxRBuF/mQePzPZgMyeenWOBUwb7MvgDf4CPByebhskdJxxx/+pgEiSZrE7qY6v4vqB7tH287pYlkg68spwIg== 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 VI1PR08MB4447.eurprd08.prod.outlook.com (2603:10a6:803:f3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 09:24:33 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 09:24:33 +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 v7 07/10] parallels: Move check of cluster outside image to a separate function Date: Mon, 29 Aug 2022 11:24:16 +0200 Message-Id: <20220829092420.341050-6-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0166.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::9) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 351721d9-3902-4138-33f8-08da89a0488c X-MS-TrafficTypeDiagnostic: VI1PR08MB4447:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XAhDTJ9/qvyCdcf556laRgI+BaMtHrLFFk6d3cRLCc81TsIPks+OSV97sB+4MLM2/fIzH+zuIbUwpphPJRmIbowzGulRKps/W1wIBDTqxkkTXn8Oa3ZdDuD09DGBelszhuVVQ10wYRNc/sthlOLuhGagfN2LW4yKvob7IRTjVLMJfNr5d4oWGLAg8byvC+8JiZzjEHsqG/L8yX7JuprFeGWUCpNdjT2MqQ7IhWBd3AK4dspxCUyJ19blb/VUg4kL8jOT5ZM0U3D61xCLc8J72SjpVCrS5jH4gMQzjVadKl63+bX1QuMuXj0c0sfHwdbpSSBlB9DXe9VcBY/NIrEn8wkYhAxCspP/RtPfuf/jL2uDjmN02CcHE2iqNhj2IEAx+sPgrN1/zrJZ9powyJYg3av/xVgt/hGSHPycByMHnTKgYPX77JMRLyp7qD2SQUzeZspdUxn8imj9phSd/I9h65gZqJpbTGGI5ajPFvnWYDMCj6wMnidL5a86X01d8fZxfNm9m4spmqcRQIAS8QH0wIxy3yrh3dGtbKYwWm6jIx5TLWjaaWqlNvjRKCFkmaAZfxVe1swCKSPyHNxqyjVXQxuXeEWLv/UW4kaCHk8BGzLZk3IIvM8eENhimGkItuO3F4J3uHAPIK81MaTKxo2EdQLO5k7EgQrneQOAlQAYzmaANAR8iYjKIscWwBcUS6hhKvdLuFrtkG5FzR31WpbFOmseu9/iRIBg74ELLDwDtw5YcnXckYKzf3pvCjC2G/ZSZJfAiwSOj3qw60s/uACqeg== 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:(13230016)(4636009)(396003)(376002)(366004)(346002)(39840400004)(136003)(1076003)(316002)(6916009)(8676002)(86362001)(6486002)(4326008)(66946007)(66476007)(66556008)(5660300002)(478600001)(36756003)(8936002)(41300700001)(38350700002)(44832011)(2616005)(6666004)(6506007)(2906002)(52116002)(38100700002)(83380400001)(26005)(6512007)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8NP7p7Qt3EoeQQhTqmOT/GkzaA/I/Nuenqh13s7UlGm3tyWGTFOWg+yIwTti5QJR9h5m1JKk+aTcZXJD8PGS7x1FH/K53z8IKIeWW5pvsZOvREvquSGb38abOGNlU0/aVwZpHLT8Btlxcw2GLNFcJ29iqDjLSav6rUR5WZ2y/HWHEryfNI+wAzKIuQ34hU8babttCIx/gmbwrqdQ8Aon/lzXY1f/XFotAVNrmTs40rh8r0X5aaUGBV5pEmsIebESBZZKHB5nVboaN8V83eeFd74SoUsN+xVspFc4MXr9Fm2HT/EzvdD9GybPCEeTeoyB753e2XqvHmz2E0Ymn0Z30//0dwNcohiMpOxDfTILwQBJJjkAFf5Fxcl/L01xk3U1DXG84XjHZpkTi0wL0HEKhp6zn2R7qVIxIOPYTnKBqcbvI8DVjW9KZkbpC87EUeXF0/Gb1rEad8j6rVunF7Naw/9DsSc3NVbBDjR1o/FAXrxS2iCTiIELw+DynonlDfSBLvJitlRfAOfyGDalXXWoJgar7R6/YG4ch7qck375MDG2qnPFK+BT/zwPpucYCGvtSN0byJxUhlfY6VnYelo0+4dclG1iwXrn2bWeNGUADVowyrSwfBfittyzsq/UrQ+l/6txGCNUoscp3PTUXPnPRbYnIsc9AMMp85xO4pxk4lCFCa0UulyEHuF49Ch46hSbBuVsyZi1gcxI4F78VJgTxtv3yGxcJUwpHK81OIg7l0BSztMuZ+lR3GbIRi44es2Eil6D+EDueKdBGaTQ5QZYhFDTDhxQvcdfiGoXzbFs/0+H3lxSOzkoDWbaAaUFS/KCez+lkYDJIlqx14hDZJoeNqIebXadIQoOoj9fTWvMh/ghPV/mT93Am10wJeqPJI+8e+d5DPjc8WPMylCo6TjJ7sun2Ct61UN03dF/j3DpEJDAV5gSgyPap4nrRUGPbh/URbIFTZ4h1aX2HnSM+pEzf17k3zTjBkrnMa/ogbhG2QSbPvzrRLCJsO1VqOpmGwxGsTTI1xJtDr9yyZWDdSKCkRo8WxCdV6ZI7iUkX6ebzZZeazErKKaHr5o3DexRP9ifQrYntxdjQkbMTFjiuCD8gfBomfmC7oA3ePP4yuoQIrCeVvWlkAiqDAmYH7/DywbiN9zeUgnqRra1z9HdTAN0QKlc48bT1pBLwx+HuAqZ7g+alsLrTI57ON4eFkeSG2GWTD1rzSvqMjjWgzBwLgsWMT0C+NKsJfDGgHUS7EwObIrCUxYB3+flLeE5HsKWTxnjKdWONo9gQTJBRSrhlpUue0jTlExGZToeIHrsVMqCrVdwdHB6LPYMumsrirp6U5VOsGMITg0RbbDuMtsdM+IhimDSLixpACRnsWoQTt60eMBZXVCQgypRrfBYicYfZpUmpRyeMWTeImRniqDioZlLlWvMIysKOAsYIWm9hL5z0NQlnjSgg6U9jHPHE7M8nFOeCJPJVrVPLqodE3VZ+0H4zzEf9ig5TO6qnC1c+YvzQ3hZe+qTgeNaxpIuD/EmoV9ehNQz6R18TsI8rk4xqNQiL6RKZl18zQDyU7kNlwItzK8F31eDbBICiMwIko6s8/ECDpEJJpEGHhQEDk5JmWHuCPwAkPUAu9Hem1hJQrXWg78= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 351721d9-3902-4138-33f8-08da89a0488c X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 09:24:33.3296 (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: 8hZNRNs17Ch8oKZYLqbmDpsxVf5iplo8JRkJ/vNQX3UmVIjvIPAylX5QUPlj4nSIvOLenLvhrbX5F/2r5aF253h3pw11fgoaYa/PNSX3108= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4447 Received-SPF: pass client-ip=40.107.20.97; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-DB8-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 | 59 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index eea318f809..f50cd232aa 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -438,13 +438,50 @@ static void parallels_check_unclean(BlockDriverState *bs, } } +static int parallels_check_outside_image(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + uint32_t i; + int64_t off, high_off, size; + + size = bdrv_getlength(bs->file->bs); + if (size < 0) { + res->check_errors++; + return size; + } + + high_off = 0; + for (i = 0; i < s->bat_size; i++) { + 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); + res->corruptions++; + if (fix & BDRV_FIX_ERRORS) { + parallels_set_bat_entry(s, i, 0); + res->corruptions_fixed++; + } + continue; + } + if (high_off < off) { + high_off = off; + } + } + + s->data_end = (high_off + s->cluster_size) >> 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, high_off; - int ret = 0; + int ret; uint32_t i; size = bdrv_getlength(bs->file->bs); @@ -457,6 +494,11 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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 */ @@ -469,19 +511,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, continue; } - /* cluster outside the image */ - if (off > size) { - fprintf(stderr, "%s cluster %u is outside image\n", - fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); - res->corruptions++; - if (fix & BDRV_FIX_ERRORS) { - parallels_set_bat_entry(s, i, 0); - res->corruptions_fixed++; - } - prev_off = 0; - continue; - } - res->bfi.allocated_clusters++; if (off > high_off) { high_off = off; @@ -519,8 +548,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } } - s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; - out: qemu_co_mutex_unlock(&s->lock); From patchwork Mon Aug 29 09:24:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957593 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 4BB2EECAAD2 for ; Mon, 29 Aug 2022 09:34:20 +0000 (UTC) Received: from localhost ([::1]:36740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSb9t-0006TF-KW for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 05:34:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSb0j-00062J-A8; Mon, 29 Aug 2022 05:24:49 -0400 Received: from mail-db8eur05on2109.outbound.protection.outlook.com ([40.107.20.109]:39455 helo=EUR05-DB8-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 1oSb0h-0006h6-HU; Mon, 29 Aug 2022 05:24:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e+QIrntkg2X6GYQ9y3IUTGW5dm/HXTurGdl66Am/IT+5+Mslk16o2uZKfD2d16vhnKBk33aQRkITRc273J3idhyxF7UZzUmAOorxs0OB6QiR6eeCec4mefW/GvwaRzBqVKKnmFSFINfl0qunNpPGL1vhkmy+bAeH3Pwev60T7Gl9jfi9TMpXxwUIiCw1/kshyEcH73cR6228sh+gk8C9dNhzmTo2rjN08zWOeUogyPGrZcTZk/j6x1nUBoTF7zbyZSGbttvQxDF18rjNh8GJOSOfMtREbWHYgSUhp03SwikTjjKP511SXZkXDFyRrRNrlL6za4NDCFQlD8ULnQAX6w== 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=f4Te2roYcHG1HhYssh3Reheea3kGA2fWHp/VW6Fo1bc=; b=fKL/t0mF+z+0lfTBwKOc6mUJLFsq23BF9anlaGigYbyZ3vrM+HQbSobkosoNGaScpvqNKTdfTtYuhNI5+p91YBb71/4xbzJTEtqpjXB5LAlo7po1myDn3glbKsvju8oBw/h3MHmU1sGx4Y+LP+DQxm6EK9Xfx7sOkYzz9oUFADY1W4f0Mll2SwMoLozDCtk17r7piJvqOWvqOoVGMMdLNHnlbpzfCkUh53V180CM1uDNkN0oPqQrkbSuGoMON1MbxbOsh6M4uXExtqrl9dNUestcS38owmYHpYHu05bvn7NRd7P9Sza/cKct2tUtBoaXlCEo8zHeFpWBfi6LAxzN9Q== 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=f4Te2roYcHG1HhYssh3Reheea3kGA2fWHp/VW6Fo1bc=; b=zMODTQEd70JdxWRwwsU6PXoaD53DpQrHsJaUtn8TRwtGU3jAcQ8vpsP79jaCG8jItEOhBfN2tNu3GODIERF9U3iscN155XT1gB58RlRK/cC9kDn5HUnObCS7T4yBIkZjpBYkyajqUKHhXrMDgEtR7AjAVLgyJCxb0L8XF6GLRxmv3RTft1y//HfuMZFrYP083ZlfQs7/7tG+JhAsQ79roFsusbU18IjINXOUOyRWCXD85JFQGjaEBp4eZe7vUfLNumSmrpZ0K35W4Y5WH2B59xxC+ShV6hxR9Tig/ioMOjTXoJ8KW77n+SKS/gsGVjxCF3MGQQ7s/MmTDZ2WznRm1g== 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 VI1PR08MB4447.eurprd08.prod.outlook.com (2603:10a6:803:f3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 09:24:34 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 09:24:34 +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 v7 08/10] parallels: Move check of leaks to a separate function Date: Mon, 29 Aug 2022 11:24:17 +0200 Message-Id: <20220829092420.341050-7-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0166.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::9) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b8abcabd-088e-44a2-7463-08da89a04914 X-MS-TrafficTypeDiagnostic: VI1PR08MB4447:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dZQwMbvflz3Yy5pRqwdYJrFuZ0qPPlzb1ZAvQt0iaHaWPewdqhusTcV1M34Um8e5pgC3P0IIngRXCTNM+dpK5gma7ZwVATmjIv7BC8fY58GsR3LrxhDW8fdjul6GPg85d1VAyhevs4hvz1xfrbzlX4IiVbSQ+N5FTcNN9oDY2vQFppEUXb67cn3NwsS4vn91GR2GowgsSEu5C/2eMv9X48hpXj7jlte8yVn8OsSbon7cQ+LuzbTXo4QfIgrbBigfOCoMq2WWXfYirLNuRP99QnAdsWiLIJTBzV5xlFPxa8TQcFVCErDb0LIQsuJPIOUCw8BxqvRu5jMzztWti9CsjMV0sl1NsuOXGrxQLeGIOQrvjb9ZiIKfDjSnSHRJ5d34yvRLwCl3BNC3zHO23sBoJj+1KmrKY1gUBDiRCAM7rV7IBRx/JWbWbQVh65KF8RvRYG1nFhZBusMfv8w1mTuaCP/3Z9tS707pGKtlwGDCO+tlodU7/RD3QxcghNcSp0xmm/JoGwc6+Voe0TGQioYn7tqdWQamSBWGs6D/21OmAs9NHXWLDWlTg2aqzmZLIwSKM/y6TYMPyj48yc1TKwle+UFEDDYSXhx4tPUuTSfc/TXf1c29FjDHKr4aV3f6JhnblQOf+mPYAzNDwwmmj3Ut/WXYcu/BEbOFJb4BTAcFvZbEeoCFnwzEIUNNwsD1+UFoLBqqPvfwkML7HGVwwos+MzIeuA5VprLgLFurjq1jslDG2I/Bxuwgzp2Yi5tx4gduPR9T/Ttd7m7HqUEkWuV9SA== 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:(13230016)(4636009)(396003)(376002)(366004)(346002)(39840400004)(136003)(1076003)(316002)(6916009)(8676002)(86362001)(6486002)(4326008)(66946007)(66476007)(66556008)(5660300002)(478600001)(36756003)(8936002)(41300700001)(38350700002)(44832011)(2616005)(6666004)(6506007)(2906002)(52116002)(38100700002)(83380400001)(26005)(6512007)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WX6CALXCLgz2yMibelrDa9o5fuQBEgJBYbH7S36KXeNLSzaOWc0KiIz8P2a7bZFhfC6mZtnUW5OZv6uIThymubl4pnjNlqvirve6DBJGseR37wrJDq3p6ZRqYecj7R75cUs+9rHDpYEegD6GTnLtbJzbPbzW9rz4CB1WTFD4nj5hzaovQhAy6qzaDLcQpb5Xq7U8YqydpDivfJcFFH6jYW/tA7UgOXdbeWQz4mNI69aMdK7GtdlNdU//CzgXh35ywL3loaTedk6r7ZpRlbtzQxOs7zfE7PeQaKtpui9PDZKyg6GjB/01Q0SFHhaUm0IMoEB95T51hkD3qgu4StByxKX/YJmwMRbulqEJvEzScmjjbxS5G3XKPoYlZI7ukz00+T9QOndKp+m9xVuGH+0pEeMWRV2ZFbMCY5pwGc9M+ZHnN84ZupnC88Hr1FPpGAxSUn/7D7ot0WV9k+eaU8fFZRWqpZp6nsjZNIgrbeu5okM6cgptuihnRYb9tV24v86YE3fm5B8xbv367/Ckxhw9xfhZd7pWdT1x6YXpH7Lldx/DGBWjf8+Ja9gjUpBH2oSH2crcKfr8JMPbbvYflL/ZQACu8z8L5ONLZ6VMnN31J48tYrdLmy9RlFp9XCntsei/BLfcSJho/NDxnsLUrmJEZX/+ZPvkudin534i2ldBKj+i4TUzx2M3nfrenqvf+xQmjjP89Dk5/GxFlSytfe/FhMsbb/NT97/Yg9NXFv06KGyiWMVtZrKmBbv0pfxI2GM5eTu76dACvMjOKzJJ6i3I3OEDGHe2H4CFT6qsZzvA3Ad4VM1g89h65oZKio9Xyu2QeEIUN4AuoNrz8vmd2yi3sBcxHXnIK49zHrB2Omiu0ryPa+JSVYBCp20kswQ1DURlZzBnM49XecrCximV9wXuQvdXpkBVPuY8tTG0jd+YKo7iaaqVc6xY7cNAiidEovAMSxzrqoUgzTSTcQVoxrABkcD7lmXDFYOD2EwdGIc8z6iQ00hdsKu3ejLo7WdYCPNmppGRL4ahUvdIPAhIiHNgrB09EeK/hO1LnhjL+8ywSyVCvP1WG8bS9Zs/pCSPcTT+bNVgqQDSD8U6QMANUrw0uWjdj6cQhKyCNdQpNaOUzA5UPwd7D/7ztrewfKlfJAko4IIbkPnw6U6guz+4pJBwDxTZ5IcHC0e+WVrhhHwelqOaO9N6YBd3/r57Djd/yHijvEPpnbz5+Sw7vtLLoO5igGkK7KzlbGmsdsCnm+/AkFAExENs9dWgKeF6KmskA5d6ZX4pFjUmdwyoR3yo7D5IX1IT2GfutEsSHtEer3evjF9eFj0CX3aT5hBlUHy8XB6nQlE83AjjZkpihrE2oKjIJGGakAfrDdfws7txl9lYXAX/8D6RZT6/nqOLOZAJSNRrC74zOX+kPGSzcOP0YmLhOSkq/sxvQTHm96ut/8CBC2wepG3xGwvSxnUh7DJ5g9xOM49CE4wxb8pX2ep9nm+t8unehpQe1P9tBkDQwDVyqe7kJqPhhkRrzuU4Tws0S/tEB6cOk+c+9KO3qkEy+Rpt++BXPVRsEmQJC4u7k1eJqdMy4q44ReKTOGQsABwt9hfbW+dqShRHy4uzBw0WuPaPUz/MutNtZKhkPn7aZGEyrvY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b8abcabd-088e-44a2-7463-08da89a04914 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 09:24:34.0977 (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: rUcwc2hSG9ZlrcZZAPlUGda+roWRX/pObVB501/cyyTSIhLUejaOjnGBGTV2Ceioj+qwt2qzqmYTEr3dJG87ccO3flK9ByQcVnWNqI6x8e8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4447 Received-SPF: pass client-ip=40.107.20.109; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-DB8-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 | 84 +++++++++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index f50cd232aa..1874045c51 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -475,14 +475,14 @@ 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, high_off; - int ret; + int64_t size, off, high_off, count; uint32_t i; + int ret; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -490,41 +490,16 @@ 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 */ - 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; - } - - res->bfi.allocated_clusters++; + off = bat2sect(s, i) << BDRV_SECTOR_BITS; if (off > high_off) { high_off = off; } - - if (prev_off != 0 && (prev_off + s->cluster_size) != off) { - res->bfi.fragmented_clusters++; - } - prev_off = off; } res->image_end_offset = high_off + s->cluster_size; if (size > res->image_end_offset) { - int64_t count; count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size); fprintf(stderr, "%s space leaked at the end of the image %" PRId64 "\n", fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR", @@ -542,12 +517,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) { + prev_off = 0; + continue; + } + + res->bfi.allocated_clusters++; + + if (prev_off != 0 && (prev_off + s->cluster_size) != off) { + res->bfi.fragmented_clusters++; + } + prev_off = off; + } + out: qemu_co_mutex_unlock(&s->lock); From patchwork Mon Aug 29 09:24:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957601 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 15390ECAAD2 for ; Mon, 29 Aug 2022 09:41:38 +0000 (UTC) Received: from localhost ([::1]:51300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSbGz-0004Ht-52 for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 05:41:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSb0z-0006JF-6b; Mon, 29 Aug 2022 05:25:05 -0400 Received: from mail-db8eur05on2097.outbound.protection.outlook.com ([40.107.20.97]:38848 helo=EUR05-DB8-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 1oSb0i-0006gk-W0; Mon, 29 Aug 2022 05:25:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=avpBuTgP+u5ypXGO+ziOUSLyNMWsRGg8EWQaMXz2GD0Y5aNfDYaO3vbZCkG3jZlKWd00eI8trpBao+mtdGWlceNCJGPlHYyN7//lbDoqGtzsSd762AWEfVErxFlMH9bpRC8tVRSFo57jiFKouXGtX1ARpoYwq+WI8CXYXmp6MNz4cfHVkCqCQcNjtDND7bjKkY1pxuoHnSJv+7w0/BRqnNju05MRG7vEbVSuySEkJXyCI91q9XyEo/DESlgA0igrtbXoxV+Isy66zDzM7bmhfumV91Q8k+qj6EPCn17cI/8r2ezmMPr+HgLmBRYB3mUIk1wOf8dFiO4WMGVUU5dI6g== 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=arrAPOJikaGyeNEaTWhS7yx8/exfEpCQTqDC8N98mzI=; b=ZJ5KUpef6dM5pdfp036u7gZ4jH8ozges9gqv8Har4UlW5iHWwUh7toPCE27ld2XjHfsYVzEkCmCorev+JvnnLpWj9psIKFEB830Y6eTY1xOJddRCROhMZvCuNRsBjgepNrapDkcUf0F+zHnzzj7p98ErGmafpq2Kjws5lYnfOTxQkrAFnVu/ltei9a5SPdltytzTMMs3hGC162c4CV/hiTnKj1+xkbgcYX6bEzNYZ6xuC6J0z6QGvMUZGRQlzc/27d9yLwlJIxiAfNR5wX0sOpNGg5VUm/YR8FFFZ3vhM1Tr95aWWBIo4nMhD/P3hvgjs0VIObscZuktcLocwB3uAA== 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=arrAPOJikaGyeNEaTWhS7yx8/exfEpCQTqDC8N98mzI=; b=Rgo2q4h7fSF1YWS/WdNi8G6XBfGU3nad3PLBAxBdYHGiuOu2qMgs6Js11KVQtM62jsz+tT62eC1oZCHGaKL3XcKykMhGDWKZjeZwVFzre7Q0PjS+nvK4le/mwm9O7BmQ2a8pNX9CazIVpk7ThnAorGkEz+vhGo85b2h4euI3oEFsQst+gxHl+gDE3HlWIUAQlP+m/qbFUByegj2ZEMtlqaYVc/erFqHADDWwe5ixun/9JiiuMaNx8NdjEom8q3nNc7hNukJe6GOYJn8iGg/ODb51PMzwgGmqaY51c9KMdfdzRRY8dO64hZ7iw2cgb0jS4gfEnww0uhhresool6gBeg== 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 VI1PR08MB4447.eurprd08.prod.outlook.com (2603:10a6:803:f3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 09:24:34 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 09:24:34 +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 v7 09/10] parallels: Move statistic collection to a separate function Date: Mon, 29 Aug 2022 11:24:18 +0200 Message-Id: <20220829092420.341050-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0166.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::9) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 26481bb8-5a67-432e-b951-08da89a0497f X-MS-TrafficTypeDiagnostic: VI1PR08MB4447:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4ei748fIKpH/M6R7ztNV6Ce35eRRrElL21RyDHieRKovtZ5F9r1cZWGjAn6apsncWpj2U0VQIKYvznagZUm+UmWhSxEkqqJ6Uzcy9rX16uNDk2usRLv+zZm8xU2wk/HUNLRzXIk4zwzbi2vwD7tpGKg9mpemXyXfuZV5I1ASZOe6rC1SgYW68uVn1uuiyEc7m6bIF3khrJcDc5cq1bi8d6SiZBOC0n01iyh9FmqN62sSrzEZoJm2RX+69U1UBMdcXzz2i61Lu6OXgv9FvhKQchAfaKB4FUR5Shq1bvKPb0EZlCPNOaXXczFKTDykX9Qlk33dIO0IKvGUBETPQPZlSGEtDei9PHFSi8W3m4EaJVe9FLkN/HcmS2IhiiHIovEbl4Hqz5LCGIhwtLVngv/U4+PCf+OTY56Wuu2nT3GtflYS90iD3ZGnZ+DH7ortpxGFbyRK/XVjLxzpJQgL9tB/nUJjXpLh1oHoITVBMW037tQr3EtJ9W0Pksvajb34jywLVBRdPZZZHDB5Pa8wtRcAHuWatxs1xxHQVntuoWbT08DhURzu8zJeL52h7pvEOORx74GK5OSZqKG8xAwv8NWMy+0MlZSyWetuImqvILTvudA60iFdLAF23ml0C9IkINvYCosULOQFhxkxyU/d1w7oXxfZj4J/v0rV668wnPoGm4kutLswLF675bGSGN1ZT28hIik7mevZ2nXCtmpRIi76MxZXtNXSMKOdZx7NKlMw9nXR8UkXVKF2KtLTqcEwpk3D6i6yXqXVVYXcQolOCIc7aw== 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:(13230016)(4636009)(396003)(376002)(366004)(346002)(39840400004)(136003)(1076003)(316002)(6916009)(8676002)(86362001)(6486002)(4326008)(66946007)(66476007)(66556008)(5660300002)(478600001)(36756003)(8936002)(41300700001)(38350700002)(44832011)(2616005)(6666004)(6506007)(2906002)(52116002)(38100700002)(83380400001)(26005)(6512007)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AVPv+OkdYlZuvtbz7XwwNJai2XZG/VFq0wyP/0l+3GIZ5Dj/FWc7fO6fMSWH4BzGeY165+XxbS55wWk+oANbY2ZxR+JiJfS0l7QZHsdumEOWNHSf7JQni7sIrP2qhmekqUthlaeR7cr/sZdy4zrNOYO0sxv2LnQBl/dl440y2oXEV8VF6cyTxU6G5FiO6HftcwtUr3fm+QOe9JdiiV1gKAdy2FwdLpZHwTLOfDJZS5+J9wK79WQMKNpjNXCGUJOukkQhXdgbIadPqYtwJT8Zs0dQL9wPG+gkR4+zlOdhWWX9m003bb6yopOGGM5/Afk0GBLq2gMAqEL/xoLYrF+/Ly4iHJCNsZcJ3smfdsvfAVxwMRZaZnrpZWs4VftxzhYHBb7ll1VyfsUZcorHSVXH7b71aBNXPg+2hSkG7aKBCLWes6IxkBHGUAPHBrcVXodCQiRhYrA9FRmaCmK9iUgtxyFcrWFdwNU1napEPW2z7aKpQmi9tdwUpNexyZrPVzlN49afuNb8Vt2lWi1bW4K5qCl4+5Mv2kF/TioV1dTcJkQDlUHGOnKHCAPesAzGwRgfe05W8Xa74JU3NrjavZPpQfFOS/pyhyvR4XG5Ma0K10sBKzRmJqr21rfRDCnlW2ufStJCV/PjMO/Eg6S7lf797I3kUxK0NezH120JQGhUjvpd3TUCo30rfI1YQxv3tVrOpv41go4viPjttvumogWr3Tt2b43oJicyGqsKuMhmwpZCTCnqHc1uOIJer24+wlfF1jWFLCmpv13THpEtBL17XyuBY8WqtyV7mnsla6/jMVtmLpJqa5LkL6cjxrP+GSM5U9iqxJMU1OZw9M4uQuUCopxsBYkhlN0yKcy2ZO45XGWfj5WPnYCr8Olj17eNeRN0Etvah9Vx2jVDBbhha9uUPNkXHgi/qVFNqWmYn+nXj+M4ODaqLaJ9R9PtEUI7Pyyy96bi66jVBiZ0DhIcW/46YwcfMA4jfJc1H+UyyR4F+wyZ9scGyrQMwUe1Ob6seNz5jBXyepahxlTfu6JE4qXqjadzlvGE/nKIOKGIow/Nhcbmr7PzMKEak4AVHZKvHDCUBTJnkvCHhwvj9Wzj0f0EaLtflRVE3Y9EYObsEBWJisa+Cp3NuZyEJDM5GRtq5rByQ/uKioqmE2ETNxRbvdYA41SBLE3W+PlxSyg1x4Dh3eUQyOvSsjcocI/QSXh++qiwVluGEDsDqHfBV3yoyqx+rdsOWb+RsQqVBLnddW7LIusk1mFNZeqiyH19rhRBSxrv6PFN4+UW6l++1s6dg8YjGrp1RLSNSDDtcRoqhpJu0qy6+dAvoMsyYAFHF7BJ28W9TPCUszu169ZlO7dIHI4KJB3Z960hH5aRS5EO1lVlf023mN8KGtpyP3QHl40gpVujJikoT6cKZ0ZgP5zQb0w1YC+PnVTFynKGTd3RBhvHL+Vw1HOQ4Oo73jEgP6unaCIbADR/B3g9Og4IyTfv6j63ytyObI3uH986EaBBXaiv469l5C7RL/Z7GOxFTUDDK3J5bHgUERaPmP0fu3zFAmaDNKhpKQY5JWdAwkQGxH3knqB3fB3kDu1INAIA5XoMSTNxInIsWMwGbRhmrXp7n+3mC5UBsxZX6q1CgeDFX/ToCA8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26481bb8-5a67-432e-b951-08da89a0497f X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 09:24:34.8320 (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: Wf7d6958SKE+Ck9pKmmIvExbXFHAWD7LknBPzdpjdPJmQXt9JJuylk8FA2ze7V1R+EhKYjewNfO5h0ypMi1blBMxqeQ4b1X3R4P7i1sL/IU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4447 Received-SPF: pass client-ip=40.107.20.97; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 | 53 +++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 1874045c51..eacfdea4b6 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -526,47 +526,56 @@ 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) { 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 Mon Aug 29 09:24:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957590 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 2ED70ECAAD4 for ; Mon, 29 Aug 2022 09:28:48 +0000 (UTC) Received: from localhost ([::1]:60908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSb4Z-0000xH-6a for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 05:28:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSb0m-00065W-Gi; Mon, 29 Aug 2022 05:24:52 -0400 Received: from mail-db8eur05on2109.outbound.protection.outlook.com ([40.107.20.109]:39455 helo=EUR05-DB8-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 1oSb0k-0006h6-Tu; Mon, 29 Aug 2022 05:24:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=da0tjhFo4wxf5lCQIfPYwdhFMz8k7kqKllXuuylk3M7okRJM11wVi5HZ+uwFtOwnlQEDAUJ89+HJTCS3yx9qu5OUFKG3/SUSL/cQM5tZhtOc5UHz/uxqqdQgp6DcvbXiXJ6ZRhxS1DJX51s+nLVmmXChSBjscW8RKB2sy1143lb05q5H4tnU11uoUq8vHbFQwOh30DCaoiUNgFIxsYTPS3EYV/b5C9tXj51BJaMjZh6p8ROJU+FhT2j8JesfArG43YGokrE1tLWaDYuJPD8NnwshKCbvbvIjvhS6rLohZkei3XdLV8fyFV1A+tWc0z7fmSZhzLAXkQTcRvDpG0AjMg== 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=muZhga5Mtg2pyW235XbttJqM6vST9qzQe7PQGZbXvSg=; b=AHmPUPUVm+rhv7B4K28fYdzu9/ytP2a9hdfhAjI4qVWZ7/Ur+VfI6pAI6HSoxTyXXajvkibvUlgOp0vUXnXMaZMvLI25Qy2XaM3wJsOyTlUIfWsLC52EUH8AsMWuE4pNUEXJIrQyTNOOAu9jiY5UAELGt0DMyGXIyLtEQN6PjqaX8nBL6f3UUPtFaqGkj8/F32phDwytltP7VH8CXe7dRfp50zXi17rEKdOVhEDDf8Gj5CiOSEV1FlVolK8pqnqOglZNLEUIYmi1MoQf4rpFNbzc8n7uDt5LXoQ+QwPLPobliTsoAKOWvjlDC70ZeGfa1OHwP0t16WSo2w8LImSgPw== 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=muZhga5Mtg2pyW235XbttJqM6vST9qzQe7PQGZbXvSg=; b=Kb2K+Rtv8UcAGpf36HQnYD2ET/RTsZkSFxEsLdQU3RuXZ17sv7rvaNsr1V1C3T2yPnjCscTnPgmuhFF+9PrkLMXWMG0ratcFr9IVT281ve2TaenaOyyq7OZbIU/1FToSmeseM4flyB4+zQgYa2D00LC+VRcInFV+GOs/6GqllkQaPbhCfqFS5WFlpTUdqT7s4VDAosBLXexof47wwhzliGOrnaGplC5x0dntGV47jW/NDxiUUoeGhtp2scCmewXreWTByo5rSuC7FsQcgIX+aPI50sIYEHnVSi0PNiL3xlqy4noRTds+3F32Z/rc7ZT5wIZjQ8Gnve1pEj3xiFaVcw== 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 VI1PR08MB4447.eurprd08.prod.outlook.com (2603:10a6:803:f3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 09:24:35 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 09:24:35 +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 v7 10/10] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD Date: Mon, 29 Aug 2022 11:24:19 +0200 Message-Id: <20220829092420.341050-9-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0166.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::9) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fe46e345-acd8-45ef-419a-08da89a049ed X-MS-TrafficTypeDiagnostic: VI1PR08MB4447:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7VWfv3nvCSWPpRjt7CJRojFmFltSGz/KXTXFudkLKX/VhSLPUAzLPpabVJRLNXTQNuVm0Q+ZTkM9mSlrTOqukNsGXPO3FhTfMtQXPUZcVg45rhoCCEgN4mOH5uCKoaJCACXDMyo3oPBVbzdJe5HKI6lzpWim/D8w0fuAPArioyucINg7aAvn2UHEeosoANmwKlp1yo+1KDWX8YKLAXn4JDAr0DJwu1axZ3i+CaabwpJ1A2d5tRfxZk/Ci0fsu94OAT52h9UTctzynMY0ME5DkEDGTSQ4Um0Flg2mfbfYlY20O3bImX69DXuB/XpjLczJTqLTNKYYP/F58JkQrDdEJ6dvnpx8foaUoR3zghJwYCgtmDRuaaeVZ/f2wAZbdIgPkAoVlT9WXbwLkFGI88YM9eyAJYpJViQVGewIWOA4gvV8qS8JceJ1v6OVArwoqbgiKbuXtL9LRR4mY/Y/ei4k0JxiprLE/vfuelSFdPxRgNfOSFG2lsDx9nTVVV4QTkqyb86luk8yQSIkHnqtMkWX/fPWlyslKqCpoeTxYOluWV8yaUQELQ5YOgO70IRluxXRnEHhOmuTCwVlqPDjTB1RudPQy/gQMSyPShaLKkIp1i9YFStAjnUkPbAfIDqyiMTyhxs9PUJSd2nsyQ16lYFP8TCBZRVviNKdFD9keBxU8COrT17ykhQAi2VhHNWBbkYyX90VoIw0YqVBuXhJiX17s8eEzB+s3bLLr3d7nZg+ajHcZVY1/GT0mxc3jTdXmZYRxpQJDrcjl3G5+tSD5XcrUQ== 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:(13230016)(4636009)(396003)(376002)(366004)(346002)(39840400004)(136003)(1076003)(316002)(6916009)(8676002)(86362001)(6486002)(4326008)(66946007)(66476007)(66556008)(5660300002)(478600001)(36756003)(8936002)(41300700001)(38350700002)(44832011)(2616005)(6666004)(6506007)(2906002)(52116002)(38100700002)(83380400001)(26005)(6512007)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z8Wui2aDSr5QvRH1EuC5BNMc+PNBv74hkJYBNQXldRG6JFagOkufLn7z5KLVYZNk4W0Mvj4ie3k+/Woq09t32eYLUhS/V5IR8XQ1hBWdWoFk4bbuaZcHQ5Wq0a+DK633oPKv+k1nm7QCT/hAjGshK06DdHLnlnf4XQggYbAmzKWVlMAhZ2GPvcGFlc2JyX08NQuxEP1PuVrV675GcXIEhZwxwOFY2y7Jv4rLARCTSeJSWnICSw8ha83/tOrj7yS64wA7AkmXh4LgZjnFSgLBRVfx/qY7GyQPYxWlZT9Thf7jX4w+7X/fphW2k17I8/7ie1VUSToDGEbQ8cMrNzt2l8dRLbFAEIuv65qtM6hbIR8LZmG1cDpSJ3uM7Y15ktDPMrSSWxwVJwo9u1YBapUuTeOkdiF+PSt/L/QnlRlDO6yDPTOxjBbZIuJZzmMvgg0Sg4pw4vrqDY/SSr1Ukc9/R/FQj1mvyymNj32ezvQ0vtzkhLUVePMdhDCBZGu5tWcIJpzlm/Fr6cMqHuBJWQEqVp/cayPUeN0IYmjNPhgJCTz8OfQQHVJ77/Glyvq0o06JINarjwGthDQCIsf41wjDuhE1/0oCBrTNvhgbhL0xec/T1g5soZpIvbNJTgGDkO0PDkFzvX++1p8SqKtSaFOFKQi92jEKIRUl3lThYgDZNT6l6dOkHHWs7mqfZKNlgig5E+nxnnwwvKa1+MjtrZTsl3liqT2PTpi7HjAfyfgkVJvPtN9c2Tld3ceX9zAMQ6Wznq9/0RSMmXmBMxNF03QRTcg6ddOSs0ZZVJ6ApS92xPKqFRgi5P0mkxa7XyiIUxF03V36yv3GvVGTkLDGfcAW37QlgM2Rxhvm0ZUjj4PQzU+aQU0ZvU0pusEKCBQfKKU7jJBwH/WiPVdNUFq5DlfjLpAE0JiaDqTOrqqXYl9sawWams+eY5emWd39RtS6IujpUVFcVJROBF9uBF7djARG+ZQP87gV/OCPk6VEgzaGCTiIhTf3XmQ5dmqLFF4qGyNj3HCHyB+6xc3snh+OpjVsGHlLMZK+8HCglUlvkk5MqBoMFFUcafloMB2V6FFi5kGOdKWAd7lIaIX1c87iIgLdZNfQxV5NxzNwwG/KqNDQnPc/lhS2DpL3x1dO5jLRJFrXpOo5S7o68Usuf5nuVIoKI9+nfmA9dWwDwfOnCKasqSuZtpVRXE4vNT7nqIuSqrzVnKbtoM/u+wPE2i2LNB+waIPg4hykBbqNrt14LCKbEFgyftCyz5TMlScFvJkq8Dh4qHz3qSBbMKAa6hS9sgBX8WGwKVKhtaRztuB4NRRHv8mi/xlwwDcIvwzYFXTe1gwmtBJLBwBZyTMNfcCPahsBAPPJdANUKk1RJFoO8XOjjKQ/XkuglvhqxKXUrFYqte64ZuwF0bry2xuMDkdWUZPrYZznHgpUdjXKXxQ1bOoqcZ2w4tgkuNOz+EnYfc1SXFNLybs9JZB53jG9miL2wAyAZ035w+7yPx/SeJysp6iDkU7CvaOPRasbaczc7YGsC2t/G2KmMvXhkD+Xk8uR5KQvsCZvcgKVJlAVI9RJyzTVsbZZP8x4RxHru5/+9lh1xVRhFsTePgaRORvAb1AiTYDCIddyn1Ngl0gF/RUhXXVa3UY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe46e345-acd8-45ef-419a-08da89a049ed X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 09:24:35.5342 (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: CxcEPEf9Ywxr6RDxJsznM6gssLqltPr42JTuTffm5gG4rHusEMxAreTH4KHJzqWTeC0DIeGhwWkqRYY5yi6zwZoRgHz0U/eTjIh7mGkA6Uc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4447 Received-SPF: pass client-ip=40.107.20.109; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-DB8-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 eacfdea4b6..8943eccbf5 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -561,30 +561,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 Mon Aug 29 09:24:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957600 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 63222C0502C for ; Mon, 29 Aug 2022 09:41:30 +0000 (UTC) Received: from localhost ([::1]:54606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSbGr-0003yF-7x for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 05:41:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSb0h-0005zh-NV; Mon, 29 Aug 2022 05:24:47 -0400 Received: from mail-eopbgr20111.outbound.protection.outlook.com ([40.107.2.111]:46341 helo=EUR02-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSb0f-0006hc-Td; Mon, 29 Aug 2022 05:24:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hreDUnI9dT2P0AZislsURGNuysaq5m4zzPf5DqWTFxEdZV1qeC9pge/vGVk2IUq2DQW+tEV+fdT8oaWOenq0RhQmYcVCmjta3CxfMo6MTnxGVs06At81Iq8GCxSBLc+zIUhsSl8LwJPAjmtEhZVBZ8MrEmsYSqdMggN9nnSVuTxb5FFfbm/uRSy1d571+qZR7dLgEtqyxH+SKysraC36nxMBs6JKxYe5fd3VA+4MfDk+btAbF/zMf2yStsplMuetiX1k5jm91Mw7JDk8MzqBzrAroN0+4TNp6tmzyVKTGNeRG/AwetmjpMVn+uR5qN9i3RP2ayN6kt3FQupdU+w4pw== 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=5iYReJi0zV4ezBFk28gCUFO+tGQpkythYzHceVAAbYo=; b=JVyDt7vK/sAyn1juRfQ1mR6cId51pICniEe3P599JqvmsHsq4T3RWwgSN1T9AI5rNiwfayK+/Mo6IGCIGqQ4UyMq+7bnGDLO1iu3kc9IxzHi4ggBNU5k06xDdQcJPXEXDjMF7Q7SsqJV80FsRgdjPsCTn8FNcYiVwU3wZTdPPPHfQWy94V8WM+/T8oOIw/UaJkiMGVycgn+E0tv5frm+IV1i+/Ar/lXJd8exHASX/mYiqgARPRFOhoCRzKXc68E30oNpWnGtHBmgZ0R6VVQQytfkJIJn5NHj1HhiKpgKVtFtCvjWQEbSb8jxj6pM7YtJyrH3OnlbHbWT9tyDr9aMWA== 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=5iYReJi0zV4ezBFk28gCUFO+tGQpkythYzHceVAAbYo=; b=KDjV9c9AfnrU6m1MlaMAFaUYy9GDNErlIRCPjq/7FCyk7t15XrYxiqWub5ZWmWNwKZrohxD2pQJJICF4GnVjM+Edsi2k7/CRtadxxWCT6ctkWa7oWCOpDVfdAQxvoRN4uPu00rz80YKDfRKoFCnbnFRO4OMFBWotZX8c0r2C3jRgQCy2R2oh62mdSPyosuIQ1qU+EGw8JGp6xaBUZLV+VGXPqotnRTLeWb6PUc0FET2V8stdh+tWaxDTgrMZn3MgJnEVAVexpdBhLDFyftBG/9tP70tKExYhiZe+USBN/w+ge8qOMudRogL3qOyrOBexYsWXYQMfBVMtiCrN4kChLg== 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 PAXPR08MB7041.eurprd08.prod.outlook.com (2603:10a6:102:209::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 09:24:36 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 09:24:36 +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 v7 11/10] parallels: Incorrect condition in out-of-image check Date: Mon, 29 Aug 2022 11:24:20 +0200 Message-Id: <20220829092420.341050-10-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> <20220829092420.341050-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0166.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::9) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5f150e77-5865-4f75-c1f5-08da89a04a53 X-MS-TrafficTypeDiagnostic: PAXPR08MB7041:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9cU+CZBXRd/1UDgLqp1yqJzq3ddRJKx3cgPbjgw32+fmzkYgLAHMDbrh9ku5qxsnf44Ka2bRRlXB3jeTg+En8kTfYS4jZtCtrccS03+fgtTSK0+YUphxOM0aZqumcsCtYLAWT7o4DF/wX92qyner1Dd5C9yWWQGMI8mM++rTfEwVs5Ze7lKzk1IaBafO1Lkv3HQ2rhh9tIEdmca1e8u+jbLWFdxxlnjwtWoGPSgXhxfuLmpKIG+6/z8mzQjovSNWvVWWcdQAwlIKwECjXUpm2oerDEbYHSzFw+sSOYdZUZB1YuBUEghL/XMtc8b9cv5CtFlIYKPMMkrSnIfo0KhJKBFcOsmRI097QuqM0haSzrH/B5KPS8+axyW8w4GKfM74rGKDGTq3D+pVsBS1yhD7QtD+LrLAs41mx3t1UuTn7u3A4ogt7zz00fzjKQKBLu9SiURYhBaVx6eR+NwYhDR7BBxS4ySu665i+geSGwHG5ZvyOiBNuq30qahuF3qk/2NeXhde/bJRsxr98BU67f5xmx461nuAo0kK8ncWeEu2P6lfxpB/o/sX+4fFocTchGNC8OEKmGW7VKDbIngTAO5x1twUEH743pIh5XW7YLLiH7zJdrMZhyH93hu3bDFd6GUvy7iJW3gUzMB9ZjXFXGFA2lAzzg9diM/sqULpyv5pR3oE2HjEByOFTFjuQxvOpbBVmAS9bOxyCuuGPQuYFAGB/RPksF5NzGHAn9C57EhYlq1HFybiWWb+AH0NomsujkOr5aLDPGUxxX7UgX4dP3fwdg== 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:(13230016)(4636009)(376002)(346002)(136003)(39850400004)(366004)(396003)(316002)(38100700002)(6512007)(26005)(38350700002)(41300700001)(44832011)(6666004)(8936002)(4744005)(5660300002)(478600001)(86362001)(8676002)(4326008)(2906002)(66476007)(52116002)(66556008)(66946007)(6486002)(6506007)(2616005)(1076003)(186003)(83380400001)(6916009)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: guZLHW54/3oeslxoSkSSbiMAkZc+2ddr1ywSV+phTtQP5KUHjJnWpqru9ZlmAaBQMV8CdqhaimGCzArciWsFF3cwt8xIK2CffiLmi4Sj7+KRWgyWOWzVxljtNzEZnYins+yq9SMlsvY5OUiUaBJjAs5m6ps/TlshTiev2KNj0nYW7g0nrwZjaZmCNd8+oEcHX1c+DrU8ZbIeMGsERIcSt0GM1QTt+N7uVq6JfutkRfjaFd/rfWdIHidYRo4lfWxryTN/FDxf0Vi2XKC2QOoUcDvOllLKfYlqNCp2+sR1wR9dW3bABAJopHMg0KS01NoU0SKgw7EZ2N7+XYOGbRt3cTmkTsvdfOE0ILbShnUjqvxqRRIAJklQnRosWeaMv5Xh5lu38LrftYS7KnNNbDDQ6Uwrvkxaais+t2+prULAr0o3f2WnZR/q8EivTxOEsOR10u1k9Z5/aurhUD9QSsiQNb5ncE+ym2x3vHzZUUsjLnz3RPe08GO+8rDib2yFOLg1IHGl+d+nzSe/rDsWHZHPFYkbZdHfTRZU6AKFHAV6MqiT4pQIr20mWumPNWMrFlmqtLT58/F4f/gub1GCzdQEmPwQdpl7QckuXNP+rrFqJ0Bm8rl1VwjXoh2OSsdnVwhys4V8VRvRL4RXckSroqUDdptObWX8zrkembmsoi1+Cx/myJm/VupF1oyO1JWQ6PbFYgjrhuhy8nahgZ3I+HFYkR41Q9/4cQTRDn0dI8k7oaqU9obY3J+ty6+KJzBZA1sdL/Qv5I61OdH/XYlX4uPTL3MSIrzZogQUj5bX5VuvKvIEhs4Qg4malvwojKtkOhZyzL/a20wY3WMsbtGWpDEOXFfmthmgp9xRdIDJwfQYqEskw9C4+WMhUWq7lxTe07EYn0LBJnoCZmsFgUTzypWuMj6dgp0KgRz7nyJ7cWMLc6SbUjCo0aKKjnIGH+qoOxEO3T6sm0D0fckEbX94QW14pH8tLYTuCRkxbRc6ga3vkaycGkxUhO7BKz3h9LWKfc3kE4ITIwrjmwPszF6AOUFdt/3DapDqOrJp8/T1Jk8A76/L3zf4WT4CQgjGzGS9kRAmTJYo/hbu/7V5Y2WnAUEGY8I5cg5ldjXQS+h6pK+wYjZ59/NAGioeKN9MwGk7cwkhsHkOIB9wHlVrKOPCUZ1igaPwezSzNVdaxs7IkUKnvl50PPs4/MyjNBzITxpcfMNy0AQOqdnPsdPKyRNdL5a5hJHqGFp5sUs34gJUj0JXfPosHUb0tBw2P+bXBn9dJEa3GiONZ6MiZJQeBU6C3SdpUpkizOCdmzxvt/qeSqsgrkRSQVdGQffeUUYI78/NvUTIuNMKLrFOz5nYAa0MTeANQb1dw6tAeWdcRBkNJjzlU2oWofJ0L7vgNAPxcWUCO5ogJqSR6mBxTecHLy+AgOyXEJruSNRDZtGdTlrWUWd4LMQBEEoQCjSjl7wwY8OwUymgs/6w+308mZLBVBarzyxCNXPqXgSTQupjHuCQhcIjPB6/x+/eYUcO9Kxh0k1KGYUtirzMFsnANLlo2zwbIrXtIFSzQ/cYAxQPyBXqzVkH57N//LkJwgxnhE41WDWsAAvmrtX+VF3yNh/dpO5FsNUJFfb2u7uwd979SnD5DpTcQ8Y= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f150e77-5865-4f75-c1f5-08da89a04a53 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 09:24:36.2372 (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: k5fMNgpWvqMWPVXnWAF4iF7+G9oecPt4AdtEgqfwn22mmZD8Q9b2EmyAsaGZlAcBG/He/ekz9uzEHaXiE6+kyrEFHmj9hOw1M51e/qwPqIM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7041 Received-SPF: pass client-ip=40.107.2.111; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-VE1-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 8943eccbf5..e6e8b9e369 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 >= size) { fprintf(stderr, "%s cluster %u is outside image\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++;