From patchwork Mon Apr 24 09:31:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0FDF2C7618E for ; Mon, 24 Apr 2023 09:32:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsYa-0007hO-Sm; Mon, 24 Apr 2023 05:32:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsYV-0007fl-DL; Mon, 24 Apr 2023 05:32:19 -0400 Received: from mail-am0eur02on20719.outbound.protection.outlook.com ([2a01:111:f400:fe13::719] helo=EUR02-AM0-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsYT-0007Ri-Ti; Mon, 24 Apr 2023 05:32:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FCm2wVNaGvBm4nkDnXpwxg11Xh4BjuJQkuNluHcjwV9HxnQWSFFZXTx5kEuokt8Ei9WtFY4SxT6BKFK9nYWTadmqR23dyrQccYmcfsWXlbBT8BhjHSge6F+1vyNxyvo7bjRdsobg8LlSfAG9eKpynZmftK0hlZi4I6Iek0SC1UerPkp1SD+8XX52Ie3C1TYg7U1bWFX3wsnGqUv8dZRrH2zTJEi4FinzwYXqeTAZvTGZmMp5LYt8e5U2WspUuoFMNgF0OtH71eWznARzwezb7olzMqdLORaT9h//5I6J2XpKo55B1wkFxwiN3LMVxlcWb84H2twvOh3x6pWLQc0xJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KK3P1C61R+xQsw5/2/BWqWPfe3WZoCYaX3UuCzBp0Ws=; b=HLZPlhFntws37K9uDQWCpF8LA0CHPbZQh63iLN6uJHt87FeJjN7y5QWG3PFISwjQmnNmkYlIyfqi3xU2e0MvoFdj82s7Sqo8KpPkFAC99jxY1hWX+Lbdavt+ZvLvEePRl7xVPJMdxmapXQGmqKbaQ5rMS1gqm/xgPesgXlAr8OvcgjDX1Ope0p4WCzgWHyMhtPH3QIa5vuPZbiVcBQ297KdFejzKpTjuUPm/TdRNEW/tSuPi2WX5huuPyZvUdqt3pVsB1UPAARWE/s8KCdjCL1Uu0IwpHXWLoM+Pj2BLjYJ2Os6PSy768w8KMWzlobLrTOKP3EKuA6WxbowyytwCNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KK3P1C61R+xQsw5/2/BWqWPfe3WZoCYaX3UuCzBp0Ws=; b=h9gug+1qVbOYoGLXDLgnARJwzHclS/f41lbZqkVp/LSHknylLRQUeNXlkG0IqBjOnYm87O8y2EYIwU2DcGOaaa+32GtW5svAij9LOotUzE7MjqXwQiBiJYnX+jHjR6O7DnW30iLJqb4pgCm0RMME04S+MjsYxFFbcpu9hXclsQccJ04TjPFOyM8wmJd8FkyvsbAHhmjPKeMVBWfKX0b5rtATFWfCvSKPeGtf0eYm+gvk8cW4zj5mojvNHQtQ+oP3d7vnQbVLVCl+lryr/eTIzCLMNHvGSJLqdyz8QzPmRIQsQwI/7JxlBF41e+Yi9e0AmB3M69/UACcSDUXSdAxeZA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) by PA4PR08MB6077.eurprd08.prod.outlook.com (2603:10a6:102:e7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:32:03 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:32:03 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v11 06/12] parallels: Move check of unclean image to a separate function Date: Mon, 24 Apr 2023 11:31:41 +0200 Message-Id: <20230424093147.197643-7-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> References: <20230424093147.197643-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0169.eurprd07.prod.outlook.com (2603:10a6:802:3e::17) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|PA4PR08MB6077:EE_ X-MS-Office365-Filtering-Correlation-Id: df30d951-1dd8-4bd5-8fb6-08db44a6c309 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6Z0HZFxSv3XU1JTT6rT9j950MV6gMbffqn9Ck7bngD5JK+qBE7iIe+Vwze6/llT4+U3mIp71b8JMokAOi8oqwcYP+x0x45ENpToSQEI00QvzKOPZYuwqvI3Q0/UdU8HGLNEBuRqCm5lyROsw9hrQr9DOXRZpwKPc83dCwxvIr2TAAqna/3ewmTWwoA80iybkwkL+WM8Tl4MxUfsXy00G9A3qvupjOitUMviyP1UXoFfhPYWQq5QzjxHEUQUDQnXXpDLBLm5sySiRdD1ikIj9koIX+ku5r5MIILyA3P7vyJpj6VgXGLLtqnCT7ajgIXVxTMSi/stwdqjJsYA3tKhBwt6QOM4mq6YQWSaFrz0kqbAevYqR4fMP0FL1deFP8NcPgkZI8zZ+pFzaWSb9zo/Wcos7jPK3cxwiCG2yU+ljaHLDAxT5dcvnvcofxvKJPWljNAaz6xqI6l1Yrd1/Z+HsW0KKH3WnZQmpyvcP4Rj8HAN+64Szt2aXIL0turnU2LTbjze+Ud2uvK2xqZ/YJKQkWB3Qtn0Fo/nq7yOK+sjqiiWl1N2+AL2Fq2tImVPbDq8dAZBBUbVnMVnXGB0ok+CCJAz1ii/v5aNlrDttGshvlsI= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(136003)(39850400004)(376002)(366004)(346002)(451199021)(6506007)(1076003)(26005)(6512007)(2616005)(36756003)(83380400001)(186003)(38100700002)(38350700002)(66946007)(478600001)(86362001)(6916009)(66556008)(66476007)(8936002)(8676002)(44832011)(5660300002)(52116002)(6486002)(41300700001)(2906002)(4326008)(6666004)(316002); DIR:OUT; SFP:1102; X-M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X7MXi+D76ilax1aBrOZwgliZp++I9U/xKrueRleTlrf478AB+TSzJjXLcqvmiL7s69kSzN06E6EUl7AIq5aWfzTlSG8dch5/Y6C9fuuF3uXHSaVe2YoTOQm1QgNn8YorCrsGyHWFeydA16fBh2VXY0Jq/LGAfo04183TELZJoqxUjJdrKMc3PnoYK61e1Her7RZQMrjspAMNM4SuoZuejt6QU8XN/1NyQy9Jrjj7C80/FrWbTc57tsbXLj4Pip9oFT5lviNUOUoIaS85Mt8MKQsWjsZkvq+n3wGwb3lhJkhS6z6d6gG3g/8/iFCkloK1BlJa2gG/zfKr8sQPrHrJjA1VtoDIXKSaWI7w1Rl6QWSxkyVSCdDWWahAacUs6TtK++3GXTVNn6XWa0TIXdPEJ0ZxdZWDa9Llb6v1AjSUq6Kea1Na2V94LmDLdJ6sgyKNBoAM7yWI9txkVegVfsReCcwu9OfLpacSB5SaM+Pdnbk2ir7dWK6OWoDRPHFtG0yzcfrYHKNZz/LpbUhyif+jJtZ/3Pn+Ugn9b2YIRGpTQZwYsIfO2mpXZz7s78UbsZN7huEB3IRYaPkpsw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: df30d951-1dd8-4bd5-8fb6-08db44a6c309 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:32:03.1576 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9mj6u+A1qurOXxeY1MhlWcCE32DJ0JQ4h/UUiXq5eQSd3OR2LKOSaNYRv/9/K7TByq+fJVXTKGgNobm1mFhlEpFy5/LcghNf/q+qlBYRXZ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6077 Received-SPF: pass client-ip=2a01:111:f400:fe13::719; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-AM0-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 7f076db001..4f14bac616 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -420,6 +420,25 @@ parallels_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, return ret; } +static void parallels_check_unclean(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + + if (!s->header_unclean) { + return; + } + + fprintf(stderr, "%s image was not closed correctly\n", + fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR"); + res->corruptions++; + if (fix & BDRV_FIX_ERRORS) { + /* parallels_close will do the job right */ + res->corruptions_fixed++; + s->header_unclean = false; + } +} static int coroutine_fn GRAPH_RDLOCK parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, @@ -437,16 +456,8 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, } qemu_co_mutex_lock(&s->lock); - if (s->header_unclean) { - fprintf(stderr, "%s image was not closed correctly\n", - fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR"); - res->corruptions++; - if (fix & BDRV_FIX_ERRORS) { - /* parallels_close will do the job right */ - res->corruptions_fixed++; - s->header_unclean = false; - } - } + + parallels_check_unclean(bs, res, fix); res->bfi.total_clusters = s->bat_size; res->bfi.compressed_clusters = 0; /* compression is not supported */