From patchwork Thu Aug 11 15:00:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12941498 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 CE08DC25B0C for ; Thu, 11 Aug 2022 15:09:54 +0000 (UTC) Received: from localhost ([::1]:50472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM9on-0004Y8-Ty for qemu-devel@archiver.kernel.org; Thu, 11 Aug 2022 11:09:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9gQ-0002g4-UE; Thu, 11 Aug 2022 11:01:15 -0400 Received: from mail-eopbgr70098.outbound.protection.outlook.com ([40.107.7.98]:21646 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9gK-0003aJ-JC; Thu, 11 Aug 2022 11:01:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FBYOGyfdUn9neH1lowYZ+pi6LJkuqKaTzkeNypdCNOoH6RgC4WsCnftlgkzLlDfWSHe6KLIF54nQhystl5ptUspFGtina1CXyWmgH34kUw1aqKcLdjvnmyUzQs75zFZIno5yMmGD6HS3RYtpRQksEcHxZCexFDe8BumVhR4fNBozpv+ch1TRz0abHXsM3ZVwkoyEUUm6MG/MOASu+GmXsrWbV55HJUTiWk7MEuEOpiijgErylzPX8HerkoZ8AbvFLFm3WsPTIzUzIRBFktQmAtVNqo113GqinbDyXGo66R4WcpbPcM1B25f+AN+KHiumDIOGxOcaArISAL/aWLy5QQ== 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=aKOHnbmwAewWrQiviPrzhz5t7QrWlONtmVAW0TO05SI=; b=jmPjd5GJ1fTLFncazgvRWh00RXbx7VnCeUKoeqGoIrglgFUZuc9t25M8VyQapx3mRDgVlrKeW3zFh7QaL3lm/Z//M9TTzvaYDai+pZ68Pzh3DcOoQoSof72CMpZNpuqMKh0V+WGcZFQlDjiDsXpdOOGR5fXeUy1lxhluZYyRpXRBnOYejv6rG4mD5zdfnL7YYNedgj8JUmVXL1Sy194oj3qlJERuYGyvuxDqHeOwSSo4vLx/h5Aa3kPdfnDgkAPYIES0c2EFK10Zg0M6ohSkrxqLozFTQjA5TRii5miD8L5GBmzdCYjdVMTm2u49FHclqp4Srh3b5jdwchVOqbsJKg== 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=aKOHnbmwAewWrQiviPrzhz5t7QrWlONtmVAW0TO05SI=; b=Sgi7YBRVQ8Gkp8FZXCuuiFszONrlgVRRcur4WtDmLZwfXWk+jHTprNBRjoV48wZ/XQeYum5yxgi2JZpvyFKDPxl8kDFii54RvCUyXBJDh42jibT4STdJADVfANLjOqdLF49nh4l5MTQBM9yHYtjZn8PjCAm8eggbSXfSQbbUfDVmVkTJQxYIjJakzn+mMsKgdZ+IBowHbXFiYxq97buZxuHNBEM2vMafrkUYeGPX5jwQQiD8axTDJmncocnlOpIgFzrUQHe1IwSytaERImhCBTkehdpujpitr4ffA4VCnptDW65r/NNrTaM7gdJECjc8DEkecQAkz8mvrCc8FZZTAw== 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 AS8PR08MB8659.eurprd08.prod.outlook.com (2603:10a6:20b:563::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Thu, 11 Aug 2022 15:00:55 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%6]) with mapi id 15.20.5504.021; Thu, 11 Aug 2022 15:00:55 +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 v2 1/8] parallels: Out of image offset in BAT leads to image inflation Date: Thu, 11 Aug 2022 17:00:37 +0200 Message-Id: <20220811150044.1704013-2-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> References: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0145.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::8) 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: 1294836b-d40c-4f7a-86e3-08da7baa4a6f X-MS-TrafficTypeDiagnostic: AS8PR08MB8659:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NDrCro1ltM2yD67dpzPicCl5jYQueT7GfXHGuICBLpuWT57hsRRKWMEkFKkU2HeZk92L7BSsQDYhbNKjVJD5yNrdbUWPHeuka7wBLt+Qozf04YuWXZsHnHwLRwN4CPG4+gxPLCzIsLK+3OrzMGYKtVA3JtX2nnz/eeYcZwVO9QrasNiTXLGkeMnIC6c0cMuLJcj5SruJ5eUqkuwTCqSRmS0RG4qkSsyRSxfewOlYUiWWSFx154TRc73tscbNH28cpr16a8OH+DeIL8p316FN/OGOId9RL4mw2aFL9c5eOFngj1RpzpUrOTh1tMHDaGwgVuabf+rkw2eGtKGm5RwZbMaDwowKU7Ky2XdJxyooM/fbmzZ6dLtzG+tKw5nXa7gn8cmGGRBu/9eivkHRA5pqbX0ndXk8pfVfZREMwozi00Yyxlh6CgL5O3O6MuoM6daml1Y5cQ40Nq5BiEdmBB4stvM/Cd5MZyBlJO4xNHzzf1+SaHO4MbyIgxaKnuGntTeS8x4Xtn9C6OFEDGEvlvWUgzjfbnQEgpcSk0D/I7+nS8oI/9ms4v+FzBarMZq5Ult+ICLbb9jFLNaL4xQLiXLIonZpAIRFJgBnILO8m5XV6sSg1zxUxbRYRce/8NwOYxlrK9oAY8oiSMk+QZ5701gmeXZNimzmQd82rsFaTMmdh3Qqi5R05GixhgT0oDtSurpvoOsPrIv2WFsBjUKgOqzjMhTfUovyYD6n1h8p2t4Zm84S6Q6/IzwaCcxy0RaJclz3pi8Bp08uu7YfMD+ulSBZWnVzUIMnbJNYQMu08BSectA= 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)(366004)(39850400004)(396003)(346002)(136003)(52116002)(4326008)(26005)(6666004)(41300700001)(6512007)(66946007)(6506007)(83380400001)(38100700002)(66476007)(8676002)(6486002)(186003)(316002)(6916009)(86362001)(44832011)(1076003)(2906002)(66556008)(2616005)(478600001)(36756003)(38350700002)(8936002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0pWa2OFD9y22bGbx5Ac4buUcBSOXsUOUAd+VaS4fwJrlwiu24n7oRr/BoyCoyGsfbI2X8IWWNzXTh3hUu39QzpxZ74hJC+/0HsedAOT8DXuFXaNTEXo4ZHH0OehG8BMcIqmKRE1lXIACmy7OwvucTVrkkXJKFptE3TKAEdokYeYMgLNLw9CEdO0FrbRO2BtzBM6hakUBjlMKonWQfdHXP2JNauyx7HdYQkjEX3sBMCSqq8ForDbTvET+Mug5mP3FEhzE7rsrY+FxACHo6BgmJtIGwfkLipZfreL40o4KQeU3s5Rvk3fW7Pm9TELugGDg8K2YLnd/XyiMRSfkNXMj12uccMCPY61kUU9VsuOkwfc/sXFv5moAcj/TED+aQoYNKXEbHxEWiJLZsM5utcimih6OQB9iBPPhX7RkgGMrb/sRvanuM74a1cHIZGs852PunOuwMefGneJko5Y7nOrRlC+zuh0FQFxsTLtqO+guU+SIcQQc5PBuDHsHE568scOWHbjvNz0GQxFJsspKoRDqi93swIvInwd7+u5W0OBhQOt3hTz5iw+zebPPAnvdliyNUDHpOqi4rIk9jmzHsyOcm4chKI4/s10W4I37tqdZelJv1IbHvLJQJYUDy43WBxVNfOj/Ta87Y7jGWBA0qragCEb++LhmH0w0XPbsPhrjnpZDsfXbRyhqZZuZsVQcWeGmxOx8TUJQjYOYhcpIOl82x0WUuwKujhmxV/TxQYWVrust4lJVtddfPrQ2UmKUe/YEZPD3s13h9A2Kw3rP3ngB1xC7GHwSfhsA6rFNB4Ys96+q6pC4Oi/GjmjyxhCZadoqzj6l7raoLztGSGO7dQLL8lgq/zXorDW2rFZN92YS38sHFbc8Nc+gCXtUaoN5U//ww0Z39cwTZ0vMCuQWv5jv1lGzWtV43wIYAtlB6i9nmdUJDc07wFufe6HCEUD3lPP4QXaEpIJMZtj+wDCgTWzmCaWfUFmLZzM3sA+eqrd3BsaLLqa8JyMGvofDaGLNlwRObHFKFOaozQKxpFCbExZpJQCCpjVZvAPIuEIhVreJeD+UuAtm/QBTydE+ITxKLh/52UXb5ncu2nThBBP2Lmn/fnqfVBINfBAlTIM9O5yYzVzqRuFKa6AJd74Ogf/ZTauq06acNezOygvl/dSOGo1WbPJHp1kHroPYSzLlXaqW/SjeO6Cql6aXWh8kWvK0ObBtQjgGwpyYlPPD7ueqW29gQBouvEBRKMPp979S7QbGe0JOtl976BllyyBkAfwrFxvFkWFsJCmTFPZW6fUGiiIo/R1bM6MDQ2u8+EdK1S/tq9aqekWYE1PTEjXqUss667nTMaDOv+/1JAZMoVuXbgo4XW+qPwIS7dvlSGGDAffVYWOuHqnnmvBDpnwGH3VYgKFQY8xqGWJ1fly447C9H74vHMDNzO12yDX0Z/D7oAxe+hIe9BTT2IkuXAN5I/UhvdvMgR4b/dX4C4piJMalzRlOS4oAUcoqG+ZagLMZqSbZVvWOdvVT2qS87wXU7rmAqdMebxeQLjR2edBGKEKoobLWDj4Sl8Vcs3XtmFQU3Ho+BE+NShkQFU2+WxhHz5CKUqCKBg4mBhBEwwcTJ9pDkRVKFlqIXRwKoRMgW6uR8g0ZFfk= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1294836b-d40c-4f7a-86e3-08da7baa4a6f X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2022 15:00:55.1232 (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: FGpWncpfTxZ9ZBqMNUqKnrPiGUlhm05RoYXOPYMpwU9GDPL0AunASgElg6FIQX4w8Kn5w02kHvHKIxbvr/DbX+OEKlLChfhhXUbIr34xGw8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8659 Received-SPF: pass client-ip=40.107.7.98; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, 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" When an image is opened, data_end field in BDRVParallelsState is setted as the biggest offset in the BAT plus cluster size. If there is a corrupted offset pointing outside the image, the image size increase accordingly. It potentially leads to attempts to create a file size of petabytes. Set the data_end field with the original file size if the image was opened for checking and repairing purposes or raise an error. v2: No changes. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index a229c06f25..a76cf9d993 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -732,6 +732,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, BDRVParallelsState *s = bs->opaque; ParallelsHeader ph; int ret, size, i; + int64_t file_size; QemuOpts *opts = NULL; Error *local_err = NULL; char *buf; @@ -811,6 +812,22 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, } } + file_size = bdrv_getlength(bs->file->bs); + if (file_size < 0) { + goto fail; + } + + file_size >>= BDRV_SECTOR_BITS; + if (s->data_end > file_size) { + if (flags & BDRV_O_CHECK) { + s->data_end = file_size; + } else { + error_setg(errp, "parallels: Offset in BAT is out of image"); + ret = -EINVAL; + goto fail; + } + } + if (le32_to_cpu(ph.inuse) == HEADER_INUSE_MAGIC) { /* Image was not closed correctly. The check is mandatory */ s->header_unclean = true; From patchwork Thu Aug 11 15:00:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12941499 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 C7C4EC19F2A for ; Thu, 11 Aug 2022 15:11:44 +0000 (UTC) Received: from localhost ([::1]:55546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM9qZ-00006U-NY for qemu-devel@archiver.kernel.org; Thu, 11 Aug 2022 11:11:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9gU-0002nK-HU; Thu, 11 Aug 2022 11:01:18 -0400 Received: from mail-eopbgr70098.outbound.protection.outlook.com ([40.107.7.98]:21646 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9gR-0003aJ-N1; Thu, 11 Aug 2022 11:01:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GE57IkFGamaGVDON9RL1ZzCtRTl8db6W+oqm4lCZO1U1UJJWFdZLL4cQqGOkJvzurNGLcn81kkdGyZPqs2PCkq5pslGu8KMJavuXK/vHec56VfJSvtF0lOP1d/JHqxT2YlhyhQqD4ZsvsYMYEOtn2s1V3zVE0ih54wHBrOljRsVe7Q5zJ8+mUQ7GlcWJEe9OYeGmLH7RWpScStx04hsojAXJMkBYSCRtA5GQuhurMYTN1vhd+zsyjgA4ARrC/B2xEEiZ19xMz/tATXR+FB6gw8HG7H/rzUqT0NpxTTxnSbrGqsvcdgdgfddXnbCTP887TTpnCA64gE/+/uHHxT3KMQ== 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=TeyeuLuikJsYnaH1fTv9dCTDt89NNz2QBnwFdJx/BM4=; b=aFTdtSQ4cGRPiVlElRyqT9wFhyqyRTeI6WKESGCrWACk35rpeGFt7fo6jc9ZDOiVf3f2AbPUGUw+TCNKasorzFt9+9CO7NiEn1b07kwlHQ6uuibSuQ82ozGfcna+LqGiQ4ZTMu3k745/lm7uZOWSFDEWURHOl9jRuhKptEwqIzEVxQWiwcYNBOPqmYV7qfOtBJ5xZc3319C9pKaL0gL27qJ8XnWIo+AMs1lCzYUxfmwjfs+PT3hrPgMyTgdocLTbpAaHM+1LJA+ktzGoZelNRhn83QkZLkVJczvNPls9vm8p25ALxewylhQdYNgmzvVgtCfe0EO10GEzyuO8xbeFLA== 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=TeyeuLuikJsYnaH1fTv9dCTDt89NNz2QBnwFdJx/BM4=; b=OMz7VX+9R1YRecwM2d23iP60ee/f+bnJjoemOxNNmD25OqYEmhlLvc7VxrSwuoXLBXYd+JDDIMBv08X2W+ri6KmwVhpRdpbPzHqFmKcIGlsUTNBu7Y2nXFv56S8K7/FBbHf28t5OqiJ40vjCmqSJWsUqWx61mu66Mysm/mU496iWs6B80PAxxNKmCxGD6v+PUaDgS9vXQMu74wB1A4absGlaChrNUd3Wi3umT0w15oZgbUZ7lt14OI7HlX+bJOtuerCNEesDI0EnIinp3FOc7yh9OZsbNEN1bSfiTjh/5GTAIal2Hde3SSVKDPCywfAjd5P06OWEpbGWj1b+OFY9ZQ== 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 AS8PR08MB8659.eurprd08.prod.outlook.com (2603:10a6:20b:563::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Thu, 11 Aug 2022 15:00:56 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%6]) with mapi id 15.20.5504.021; Thu, 11 Aug 2022 15:00:55 +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 v2 2/8] parallels: Move BAT entry setting to a separate function Date: Thu, 11 Aug 2022 17:00:38 +0200 Message-Id: <20220811150044.1704013-3-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> References: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0145.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::8) 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: 6def0b68-e963-455e-8548-08da7baa4ae4 X-MS-TrafficTypeDiagnostic: AS8PR08MB8659:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gjaIWcNheRIf+36FbuBK0tTIEcD4niH6GjcWqJuFEinL7Vp0r0oXiO088lTk5cG3jamHUyuJLvSiEREVGJyTDhFIdTxmDuhgsqWucP0C7ztQsixD4/37X+IPyd72k9Af+DyBaR4/ML0SfcqJwwcPAVAd3rX8wR5ZfTcC3IIMHrYcZy9BM2gw88bCb3ZPZfIxGSEZ2FBu9UA+XpvBOJQoUpkAOuoNW+rkDNmYPVCIZJpQCCGGWuPV9IafTJW9v4iuEm4Qwa9G4klZqEN4GQD8bFdBWTjpD6pg6vNVsy8otM1dVO6xPbsGe5p73yVfDH1yroajWoP3jSQgTiZ18gvpdonqGNJZbcR7h4CpepGcpuCpIth8Xd2WfDI2nn2MYDY971fc7WjHZYOtANsuZZUatQ12ijgSK6ehaJ4FZXAEeXzjP9BnNSjxzAoEDv+P4F5XAmryQfPbyAuPyQz3DTc7x2sTYON8y179UY/SSpLJ+w93AkI4QyXZ2+4WzD9q2WjcHQH4STF+omtKPzM9/YkYYsCloXJfRFcQJpiMWPgQqQPKYfuVZW0sXeXyQEh+h4aNVZtxontaPRwg6QGIOwWdbC9DJqFpFhkK6y8rm2LjTmkBf0tEdC1sknYW4OJ0FuI/RiFZ8X//Zyko2LXgMJWA75ExidSsDkd2LTKX8EzbpGtJQNGv53Cs/OwewHnbCbpSVr7TtMUUXN3ZxC9rxDCVx4gHbwNelCvpnDhccruc9ZMaKopkUXGB1QxekwvbKIU77hCvsjWB0C2bWR7HpeF/fvKL4YqjfhDQZ+WCMszVoGc= 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)(366004)(39850400004)(396003)(346002)(136003)(52116002)(4326008)(26005)(6666004)(41300700001)(6512007)(66946007)(6506007)(83380400001)(38100700002)(66476007)(8676002)(6486002)(186003)(316002)(6916009)(86362001)(44832011)(1076003)(2906002)(66556008)(2616005)(478600001)(36756003)(38350700002)(8936002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ReTVNp0hK0sMnZ8Hjl9LMnBH3h7+ayMHtH7wQ26LeKbCrluZYuvsYqKET/v7tJMKwHZAdCWbmpKBkBQVyrIEQ3Lvcvixw7HrGlavJEyS3vm9GeTHS+b2jbSN2/k63ervx4+i7IF/DZDKZMIGTmaEny9enTZpuu3/nPlh2X3P0qYvFFzCjUhBQzuvAlmJ/ayPrj5fixrgSeLblE9h+6m9d+DIYD+F3PJWfT2NG8WPnJW8pYc/rgT20EYaySuTnirI7ryhePOh7sr+eiWRH4rcR9xI542xP3hn6WKCoiw5aSN5sxQRtJkCfVUxZ/xWeLWoRvSmEPwlkcdYS61+fL+oQ4EbAOjBlGWAzvdh2rovi5d2RM8tJQ4LO1zx4I0gWCgwlYmTr1uI45yI7G831sgEn3iDBnUUDysYwJWaqyOQSMmA6q9o3Os3zXk26XqRLNztKEgROsTK/hye0qmCZQY3Np8R1+pmOuPDkLziPIdNEpVmDGqD6fEJymBtIcBTOn6282MRxUIGwuCVq0Bk8zHnMfYM4ibIyZAEQnlnbUtyDM13uUYpqKpY2yzhUlqjtomx0bQWx55APDR3neeYk7zGH7R3EYUf5phdFPO4wQayh/mIeey1IuLybbcCG19YnPC/l/hRn560WbHns2z6iC2Do68tAEIOqeFwXGU2Q3mzIQadQ2oHuafxCsBMhkYpV/y3IdH+2gX4+TU7cKOhmlBPdm6KIbQ47hiQ3/kksnRjMFjEOnAeYAxhXuXUVQfacYI70J1I35I8ugjsJXwztbH6VKHgwfhr57fs7UP8sDQ2dEr7jGLSQr1Nh7ZgCUh6IAss+cEQ8rK8v6t8TH10rkXv5vAWCMMx1/JaZ+M2THxwh+gApa03777zIxAqskOd5TTK0Tk1X0uk6sXYpO/IT1q88XdXO7zPSKCACGaot1IA6ZNHgdqnsgp1A3EW9d0TrdnTyM2RtGKianwaXq7MA+GpR75hRpfE9EsRGs0vJOMR2Tbkr0YcAL/N3IUWVcIZRbCFzYZQ5GALJP/Wsa8wbDsXJDZh8c9OcWSbp1lU8SAupbPxPZbsVamk0a7xOGH7sdTihjDO1cpOdOf15vk4klhRtdgKygYXN61d9BtmgPT0nuI2Kv5PgocPzQnQ+o9YKZd9nEIyD+8nEm3VT3PCrI2IikpHrwwIMaFQedgwRcRNdNDlCs3DF5x6sm2ATgYHOUIhNeSPnaKYqaE62KJfi/5GUtaCHj1cnmGb1iNkSFE1w37WwAclYi3xUHoi4vohFn82Dg5SY4U9l8pBsCx9D8MwdIPChdYO8IM1z04jzSY9mNZJZDLfPQOW+cgRElPiRwIX3fGg/MsiiiUfpj3NL/WpztfYgUH1HBnSJJ01qISoM0qrvRRFwSE6owmJ1BKbOjgF/Us3X7Jwcskm7k4/ODK6J5JwkQ76/65y/68I+iRiAt+iVeLQgWTb3/9AXAc58GpCZqQbGXoaDHCWgZenMC4ZHlOuFc9B/4o9NUL9xVau4vdHUooX1e6Cp4snipYAvt3qP+4Njsmptp0bI77JMP32d+lBjcIG9oR0aFFJKFzfMDkSD+KOUSkWjrrhTBcabH1br98vrnMZ6yBl2Ky+A92qlZUJAnebIpYyqjXbSfTFPrA= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6def0b68-e963-455e-8548-08da7baa4ae4 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2022 15:00:55.9057 (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: svW9a2O2AW0o7MmU7SiquYhfSr/WA14M5XOzTIV2pbPLHmqw4JGTBU0ttTVwi51PiAeUb5KKxNk97lwQRrbYcH6///xM3n6UI8eZtp70EWU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8659 Received-SPF: pass client-ip=40.107.7.98; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, 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" Will need to set BAT entry in multiple places. Move the code of settings entries and marking relevant blocks dirty to a separate helper parallels_set_bat_entry. v2: A new patch - a part of a splitted patch. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index a76cf9d993..7f68f3cbc9 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] = 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,9 @@ 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, + cpu_to_le32(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 Thu Aug 11 15:00:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12941493 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 0CE91C19F2A for ; Thu, 11 Aug 2022 15:04:11 +0000 (UTC) Received: from localhost ([::1]:39746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM9jG-0005XG-MH for qemu-devel@archiver.kernel.org; Thu, 11 Aug 2022 11:04:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9gI-0002Wu-Tf; Thu, 11 Aug 2022 11:01:06 -0400 Received: from mail-eopbgr60138.outbound.protection.outlook.com ([40.107.6.138]:46683 helo=EUR04-DB3-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 1oM9gE-0003b2-L4; Thu, 11 Aug 2022 11:01:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f5hNK5wQ5dCj27Qd9JEux1ccJzcJJQyq5g/ZXthJ0wWq2s4aR3EL+1MpWwWXwG4WezsoO9bDhff6hTvCBdt3S52xtLvbbVOxrFtH/5/ilwBhS2NXVEO47MSJXueYDI6aldJxeSHjO9FCu9JFcTsQkgD/xYqJxhP/uLCk39iRwLmA7fhwIMNTuBBctMmoYwBmiW6crF5QFfpqJtaHugKLfPzKOXyMd6Hb3jWOpf/eRVdTBuYmCEB6c990+uLA+p7AC3pIAagc2L0bUjY1VFk+rwfOgad8PzvFFjldZ8pXs+gPb5rwrH56LZ/ofKR3zpMuh0uuna+8VGLIedhAPa+auw== 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=orwHyo4qwO/qEh8wSDCfc/yRsKvHcgu1SDtc4FLapiI=; b=Rqu1Kqb7jnDCbxMjSEh1Lwmo7StPduEVMEvsn8YXFIhQcR7Ye9ftbSlpVHLQPkSM15uW9yzgHWL1u8oOwlhG6OCh7rUe+nMORiy2JTUdYVtZwTtYGwqTn4/UumCKRxlmzLUgUsoms2Gr95vFbc+7KSWtljdhZm/8SOXtzy/7IBTxUGXXEML7bdZmOuFyl3Dg9nIm+ZtBvOtx4AThm9S9cnqHtU7y9gLYm4hXVleRCa+J0IfcpqzxIyxeK+Kg3nEr8lGj/8BEYwsdlLIjMGqBfwHeeiJhZA1ZaO+fjMygKJnF3uEVC0HjL/+fyIHzabkW9S19QttemjhVzoGWZfjxrg== 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=orwHyo4qwO/qEh8wSDCfc/yRsKvHcgu1SDtc4FLapiI=; b=0MLLIy8q7S54E7US2drUDRyfcbIorNNPOZYtDQ2Y8Ll0pGHxfsqvLrf4+QM5riQ2tYxflVaMV0w8FFtyIYjuLlmWZIgb8jS7eUn+QLYVugDchj20uLjmc/CmrCFJ9HO6MH3QDGJxt6y+OID2iPHEPYM8Kug9jip2xO8iwzVEIkZjXyLXUGs3ofTqjRsaCrXJC3vb7UqT5kHjhloUFju7rK/OaHs53JO1ga1QaXDtZrlNJoUG23ZzDPOskfXqAbao16EXuqnmM4znEUrMTKRNN3JUNBrecZAg6QFi2Zd3cfZn2d03NCRyoH18wUbX5GF4JUUrS9pGXt6OhLMBxqbdEg== 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 DB9PR08MB6521.eurprd08.prod.outlook.com (2603:10a6:10:254::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.18; Thu, 11 Aug 2022 15:00:57 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%6]) with mapi id 15.20.5504.021; Thu, 11 Aug 2022 15:00:56 +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 v2 3/8] parallels: Replace bdrv_co_pwrite_sync by bdrv_co_flush for BAT flushing Date: Thu, 11 Aug 2022 17:00:39 +0200 Message-Id: <20220811150044.1704013-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> References: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0145.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::8) 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: 24010a97-ea16-4bdc-711e-08da7baa4b65 X-MS-TrafficTypeDiagnostic: DB9PR08MB6521:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TuoQaf6Ob+v1gN73Ap9PLcuGg/gINu92sLvtzS5865xNEx7v0DT/mdTMo1ZmWBw6a9w7Pht5XKOQRNiqTvbYV8peEY2CUb/On3sAgSyGHVnKu7BpLz2CX/PfuhHjKgHnl30iCb4YaCG4XiIrxH1a5KQDdzf/Ei12vhCS1b6y+a2cPZSWJeFjBW/PJ/irUcpi7qRoFgsE4VcZjhIkytoX93X4XQU5b/LpB8/6WxN0YmEJ+SrGYbRPNj/xuNJfRzOqRbC+2aKL3Izdxfd3yOKYTYsISe7NueOPUwZoyW1+aYSp7uhXalG8DPbwJrbQ0+bmCkb2o+OUXZlG+8uMqHtXF60hDjfdBLNYfMnJycYIY4FlSL7V2WbOBrPtv0H4gjOMeVVDvaATnrXZjq0GVwctR7kPDacc+RswsDIvq7p0JKTiOraZdltTSwPzkC9UhclY/Al/pvj2PC163FrFxMrbz0teg23J3xOpYrEHg1PFmxtVzidtTh4IsQmb+tCHHDXriYeuGj0bSQfhMkOWB43IPOXGDKLxEzGnWem/GDsHOA/aPvFZwmksd/Rzvbl7BqrjYUYJh8JGRHm9nXzxW33WhCPByr3XFqo+wjLF+JptpXucmZ+n7EyPGzF8zKjOobij9a8nH7xqG8ijQChg5+fxlIVEQTKSo+Ma3v+qivmyKMtyMfv4NPvKvvTCPB2PsvY7o+WzcJ2fvTESroHtmI7P0tmez9cfvbY0EJgF58wc33xQvoQ0fRUSLuU17fgB+abgbxpHVWuty9rbTztJWdf3Mph9ka8p0+EtvcuXHmam8zA= 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)(39850400004)(136003)(376002)(396003)(366004)(346002)(6666004)(36756003)(6512007)(6506007)(41300700001)(478600001)(26005)(86362001)(2616005)(1076003)(186003)(6486002)(83380400001)(52116002)(5660300002)(4326008)(8676002)(66476007)(66946007)(66556008)(6916009)(316002)(38350700002)(38100700002)(44832011)(8936002)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3u1KrATYG7m7pVuLUxQPpPYhhI6nHkug3Eq6OmAJC4ukcBCm6UAfMhw0iWvb3K/ulDOEu/OwXST/LuAXt4XbG1gyJfcLSQ7Qwr8kzKHchEaKhCf4UlShEc+VlRJLqsNg6BS5UiuyZKAgE+URjP449t1DN7qI/wWXd4vnY2Y19eGGD95EN7DFumMqzZ5PTVRV/FJpQaS8wHqHFyROir6nB3JFyKWEM12Ylip/6rjMOZg5bLhq11mFkrzu0bk7UULn5Dw5pVDXNUIjhFrid2fPfJKvpGxmGdG6joNAGazAtwHwvvzodlGZYFaow/SIeyw7q9LsGSNhGn5+sC6kM3wqXUtXQiA762BG+lCJaCgulgM8mUI9UAtEsLkMdG/eNB4nFIMtZMJAq11p4CqNUNWRddZ6V/JpuQnuFSAWduSnlrWItTEiRi7lDPh2NU+/T7yilWWSVTWRCHwgoePsQ3y423KrWNbNxY9gpqunrGCARYla6X7/58LLhK1uGHG8NoJ0BeIhlgoj36heKhbt1PBaMHiQJNgeg32Tr6zjELAe7zQ9HxwJQrx4YzTTTNOAcAlwSVq1ZaFnBdUhVJDFzzaGJXA/R5EyXvsJr2Sy9MFWv8s4UhzB7fQie5K4XRzHU/Fp8usccUSpAE15jksBJllapE/WEwZ0vC8roZrBdf7OU20WIf0zXYSO4VY18KlXrnYET5qTRu4rsgxzNEoqgx/RzF0UhaAxoYNDM9n9vWcy+3Q/w4epc+Jr/9zdYqDQmjxt21Go0jdGWWOGWTBHmVVNAKeXWcpq8QTagNl/uACkh3iV8mNL7kUfeqyPM6sQ4XSTxNakgoAwbsU3MfWzW50p1gHYCkwB5OySbXkE6EbJQIUua335Vc5A8t7Vs3MHgT3DO6uu6Acy1efEK2+qSXRwyXjwEzpA4fDNFUpNO07sgURilN0ooGx4nReHkagqE4c/7mIAGFrF/jPUzR+0yr2280XGu4S+7EccZi/P84kVGXEw3+eBI+GvqL+QfkOOnzaXC8UzZ8rswZJp0mAvpQQMNVrEKczB5DeTdgoPCq7kKkhljaTIu4uazPab4SFVmUMTrYVhP2NAifDoKtK3CKcX+YlEEc1Gq7kgQyN4EwOxODMe8ZRVruWYYqObJZCErlHUbSJ7MQ1D1u++hCM1R+3lC8vmwn0+ofqSO/tIg1NW8Is/gkysePSOg8I0SIhcwMa1D2dn0u28F8B3w6IjquWzIfnanq0EjIXv9Eftb183yAttohh22OK1BPQjfMZ5wdeARxt/6fgif/TZRa9yMpDr88kK5ITVcvJesT8yPHAn488umCKuLKu2QBZSPJuA6skpWVrz/EtamQ/ne3yU6ZPcf7z1ANvmuxIzLQ8YFJoCiU1kjTb2e2FIpn/ulC01DK7hT8HYDfDbNwesLx5L5Nx9phcgGirc6c5uPOwQVkIm3dg0YUI0xSsH6q7G4Cno+sz+267WW4V0uuP7DMbUwbAbRvLEHrpoNJRCQp9kiaiDdirl9Jn4BBN73WCD4ID64h1JmcCprzBe3Q/WzLwmO221cDwxHQN2p9JuhxD12H9jbV/cbohTySwxu/HC/ZRfc5Wow/c0GQjD+jzzIx0RhzV3/w91qSE2Nh6dJuCD9fX5aZ4= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24010a97-ea16-4bdc-711e-08da7baa4b65 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2022 15:00:56.8910 (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: +oGmf5vkNfKVctWjK3ZRQrRLC5WK1EFtgR7dvocrA/Gl9hscDTKFoMR4maGs0z/MdFaVwhrmv+ol6zwWXn7Zc1kYU7+t1hNwAOdPfIvziIk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6521 Received-SPF: pass client-ip=40.107.6.138; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-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" It's too costly to write all the BAT to the disk. Let the flush function write only dirty blocks. Use parallels_set_bat_entry for setting a BAT entry and marking a relevant block as dirty. Move bdrv_co_flush call outside the locked area. v2: Patch order was changed so the replacement is done in parallels_co_check. Now we use a helper to set BAT entry and mark the block dirty. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 7f68f3cbc9..6879ea4597 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -428,7 +428,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, int64_t size, prev_off, high_off; int ret; uint32_t i; - bool flush_bat = false; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -467,9 +466,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, res->corruptions++; if (fix & BDRV_FIX_ERRORS) { prev_off = 0; - s->bat_bitmap[i] = 0; + parallels_set_bat_entry(s, i, 0); res->corruptions_fixed++; - flush_bat = true; continue; } } @@ -485,15 +483,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; @@ -522,6 +511,12 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, out: qemu_co_mutex_unlock(&s->lock); + + ret = bdrv_co_flush(bs); + if (ret < 0) { + res->check_errors++; + } + return ret; } From patchwork Thu Aug 11 15:00:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12941497 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 71446C19F2A for ; Thu, 11 Aug 2022 15:09:07 +0000 (UTC) Received: from localhost ([::1]:48820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM9o2-0003Ne-HE for qemu-devel@archiver.kernel.org; Thu, 11 Aug 2022 11:09:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9gO-0002c8-Cb; Thu, 11 Aug 2022 11:01:12 -0400 Received: from mail-eopbgr60138.outbound.protection.outlook.com ([40.107.6.138]:46683 helo=EUR04-DB3-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 1oM9gJ-0003b2-3A; Thu, 11 Aug 2022 11:01:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b0FmVZJxxbvUAmlXCW8sL4NQdbGuwCKkPHqX0GNlb8S6umvhpqVxUiteoI7DxRmGpUWNAR8FeBmEwzonUvGuqZ5tNx/+OdgvFWOKTDToHPSrjbIu7HpjMVwLSF7ZATU/Ah2eMYzWDByzgBTAifmJAsGv8d++b0k+J19i4TPU5RXNYpRON5Q+Drxocuc8B5hkFM4PGfxinsfHQo8kZ8HFrCsXi1jeLkArVC+BdsRsars83NWu1AVMDp0M4aCza8vBpf4eIT542VdxQtXIdSLYbdBwVkQkyFNjaQPne4Lq9AN5QKoDV4nGSzV9KXQaPYMU+oqqphD+FFTA634hRA3gPA== 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=RkDouN95P/PFj3O2cKgHIPUjY5i1SUwSZABfTv3B9qo=; b=I2r8eLCpX5PuU0W+CVi79lqYL6TsMBQFhF+iif1c73zrQUG4K2AuWWWTKAn+po4D10TCZu4dcw3P6NdK/MqaYhkQprjBjapTK9BCJOZDkgDePftoQMuG1IxaV0Ftzi08Xeyi5Eyi7oB2vNovbnzhvmWIGuI8lN1dAKZNE51y7OnL+zL+EQtUlme0RUcNqqxn3iWF6uJtunYoT4DydmN1jSMR2/fTSDmeRUdpeB+g9MOPh1wJEafj6SrcE+ru+C7fRNpDeGi1by094kDbOs9FQ6PEnm5crUIaWOmTqyLKI4YGZPcb8jKsIk9uQzrimNCj1tuSMnGL1EPBtbuoNhot5w== 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=RkDouN95P/PFj3O2cKgHIPUjY5i1SUwSZABfTv3B9qo=; b=asAxbXn1KSBlzR1VQmyyB7V0Tml8MzmVrT+i0TslEGmC+/hNfkbGFKpqax+zBxw2f+/v4yzyfaiXtA12hxBGqI3tbdpdJ97x5XjqFlh7ZQLktGH3HkncyZDN7g+A5WOAzKl/fALsp3a/Jnucd9povqnNmgsFPRa38ThMQeoAYqEKgPfTnO/14uoQKgU80CjanIv2Q9G33P3Td0wlhS1vmMtFkPKVMRAWVPl+8byryz0/sHg4nMd5CHlndzRloJofWy3jSyskD4xDRi31OKMCvrpfHtAmvaX9HpWVJHyRBCGgVofGlspdOGn62pA8ibiC8UQqA/u9NkkE0AVi80nROA== 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 DB9PR08MB6521.eurprd08.prod.outlook.com (2603:10a6:10:254::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.18; Thu, 11 Aug 2022 15:00:57 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%6]) with mapi id 15.20.5504.021; Thu, 11 Aug 2022 15:00:57 +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 v2 4/8] parallels: Move check of unclean image to a separate function Date: Thu, 11 Aug 2022 17:00:40 +0200 Message-Id: <20220811150044.1704013-5-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> References: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0145.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::8) 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: 2512b0e3-4203-4ccd-d551-08da7baa4c15 X-MS-TrafficTypeDiagnostic: DB9PR08MB6521:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9e0/VMfNLvY8biOX+cTwegFyl4jRXbwdIEnNwHlZb8G+yYF54BjTPnySdIWpqDiqhv9puFxT7akbexk0i4Nccc5sYnrd5YlGU0xiwpDh/AdWrI9pcFVNzlg7RBJNURMGUUSTwUBk+nE6JVJojIXzPmkbADiS/voPS9RUOrNmRNq7NCLOX4R8ec94t7uEEl6vaKbOGDaoNXwF8Uvf3o2a4YqQC6jHRSBiW9bbDpkRZZsfshOK0gSsOXrZzLnmJTz7WJj0HAu3hFVEOxgrUz5mAA6S8/GyYVbATDMtZA0uRuxTL12anbjWxCYY8HYWdirsNvzfQ0RQjHVL8IywP1wJsw0I+a4AGBGK4Idzdxss82QeBMq6RIYb/wWw78ktPU739TXBgfPNnCfIqTkVD0PVBrQsf7gNsioW2nscHMU22iTpy6Dfb1I+Cei2dtFervlvh2q6gO44Z24uZmF3dvdNSxl4m0XaRXFbQ856XuVOOsIqbfnnBj9Y+2YhCk6gkUpd9eh769pNDDk1fWZ8vfs1QmbSCgy1o9rHNIFtomwGvPPxwdoJN91b5XO7IX08quCMJ886avVcu3fyaTNbRqyZ452b/4Euzow4VsOLQjFBLK03JHA99TWn6VxzflgjHhkiLzmTvCFlti9o1KJOnRIRHL//RK5zzi3QmDI7/G+v3To/dE30xJX8Ejs0L7IfvZYxUReoLWql5xo9sn04cpYEoOKAK8f8JmGyoBifnn97OGtA60edBHYHvvPzp2BDAe7hXB3KLRv/g00moPc5OVBRQzH5fWqzoNlkQtUYipc3q7M= 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)(39850400004)(136003)(376002)(396003)(366004)(346002)(6666004)(36756003)(6512007)(6506007)(41300700001)(478600001)(26005)(86362001)(2616005)(1076003)(186003)(6486002)(83380400001)(52116002)(5660300002)(4326008)(8676002)(66476007)(66946007)(66556008)(6916009)(316002)(38350700002)(38100700002)(44832011)(8936002)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iTq+C7F3qlVjuzqiGLKUy355imaNYs861o5W3bUB/lG4a7JlhFTRyk8RcD1rnEvuiXwGkW2q5dIFBTi/LH9V7AbNyV0/AZvsOCdjQ8sfU0dJsMyLq2XR8aHFOagZGs6G+YwTAuP7c4jI/DikXMpujQiJOzXy68ftcuTq7zA4AuzRmgqWlTX/hqZy6ZdTD2NKJeKTu1JeZzB/IESjWN6AGNvpJo+guQhFm9v25pKyMSvGrQkNQuQDdy34Ln0HRFNPtKS7tiSK0rz6S4EJsQQFPbaS2vHkXNch6z7gIUIVz0sFLt8q6rwU+ndy3Sr6QHipP2Wfw/zLvIGxdswkiVNc6Qhn7yOyv2nf10dwBKLa38pzPQRUYsiW7PiMmmmY8spCKa2T1bIST+Ec69OZeD9etlJuMhcMHZN3btbx2h/MhNNfCki2ck/AeLgT1358+ZPlU080CXIXp0jyt+XbW/A60mRvjBy25+xprtG7gYjOasmxhKgZrfGheiU1S3/epW9SsIEg8s2jk5Z9ZJ0Q0D4jKyhBWTtzduDycAvCdybNdeDJY0sJlgyrwo0NOve3UF+QQRIqdmgu2QA/dGyEAqE6jhl83QL058EXrNzaR6aaH8fQi1Cik2N/2iO1retQTCIJ3k44FQR0FCy+gnehVfQte9qICD9SL1JCDiLhuLCQBJewbSopwCSl6AYviYoJe/48JHFqdImcYc4wIzYV8eFkexRGHZAJRW9DWOhZRH9DViAaXCwBa2+/Cj4KUlDXmxWfuuCRI0HSOjinkyE4ak9cgqwDLfks08TvaGqyW/ZcRhVcRQujA3bh6C9sHWlTCmDDcoTBJ9GX+DZXYVe6jcmPv0YMepRC859zmcV8tvZ08+7aSDTzrVLwgdqOAb1TBT/NbqdLxuHGo1/5nF/jHYp6t0q/wB44OnCeeee9RJeZnYJ+6e12ZM5W1zymOkyfk3z8KjVW3wG9YcNTc/QsH+QNKRIWHyYQesh7wBhD4ECm9QKeha9118JHjId1lfBJXxZOEkY/tTfW2mxpJuMctV6a1YC7uBANLK0HkvXDP2sAT5wq8WlB4EYssJc5t0Hfz3OMIHPOH7VUhsNQRHN7PTEL0KqtJrYxIhMJlUdTbbzKaSR7xyHMvh/T5Ta+t+H/GIrpozqMSQuLM3LyMWgQbCYbWpBMDlfVYg8V2kRx8+kdOHp7m7XMi51c5ypur1SrkygtBYC2Im3qjsEPg4en/cJNizl+IbW26/tbXHXTmw7MMqwspqsZM7PJ2KR6X6Wle/6lCyNBE6i1879GpmkVCI98cGvWyGPCvuDp94g16OW0xJq17SfVQIfWTBhRvyJAe2NmthBbG2QOjbGkhCErLNfkqqK/hat37neZZSedjCuySVWsPBSU2PS/AbmoHFzp9aj69d4SDviDdQZAPHLVBT+EVralfWnYYXvX3cWUIbLGnhvw44Csgi3HZwKwlK2zZsG7lCtKYGZOTqULBl61eo+H8694WBBc4Xrri6JOgv5/ey6ixxaWr76+W36RyWV8kjjz87g+ABMSrsu853lp+8JvcFgervhc0YJPw/ZO6YuQsA7qBZsie4xQ/W06MFqSsEL0D+vNSaSePn69Dbbo6AuLrzOp3Xtfz8oHxotu8zgiZq4= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2512b0e3-4203-4ccd-d551-08da7baa4c15 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2022 15:00:57.8752 (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: qGYUJ18vY3efy0oCgaVZBmTMzz0wxPb4ubQt4FvaC9gvLCKAqRDhmjvvEz+QzYJKsvHGvbVixl1nlH79nhaigK+EXYFRR7aCgRf1hy9JnfA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6521 Received-SPF: pass client-ip=40.107.6.138; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-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" v2: Revert the condition with s->header_unclean. Signed-off-by: Alexander Ivanov --- block/parallels.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 6879ea4597..c53b2810cf 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -419,6 +419,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, @@ -436,16 +455,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 Thu Aug 11 15:00:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12941495 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 CF891C19F2A for ; Thu, 11 Aug 2022 15:06:20 +0000 (UTC) Received: from localhost ([::1]:43072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM9lL-0007oX-Q1 for qemu-devel@archiver.kernel.org; Thu, 11 Aug 2022 11:06:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9gQ-0002fg-Pr; Thu, 11 Aug 2022 11:01:14 -0400 Received: from mail-eopbgr60138.outbound.protection.outlook.com ([40.107.6.138]:46683 helo=EUR04-DB3-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 1oM9gO-0003b2-Tu; Thu, 11 Aug 2022 11:01:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JZxh6T1DBbLcK1ArRrsAoPkj72RGKpZv3Z1Y5cA3OG4CCQWerJXYUfwgnYqiJWwCkb/Z4ZP5Uu/c2/+gI6od7YOeQbkO3DZ/21aKhTf8FhSrTAZRhFlYHn6mhRSqSPEYcW3twQn3+/g2CUJFoPkqouhzsHVoLk4jjVgJaAu8KcBR4HqsmJtFRIq/0cAywPNqZ6zxZomI0Du6GRfguQE4LlSk/4vyLW5xJWU5u9rJkTEZ2SynJDNT/VLbwMQdYVVvobtkbKPs4NXC6l3WySSrM92BPgF7L45tho82VfKsh8q/WcIy5NFDw6cbxbpU+GXAnJK7sqPbuU9T7oF8wx84rw== 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=thUbh96sABitnUnEHNhzu02PjOvbLR8/JQHvhHNVqyo=; b=d2LDpPauNsI36R9XqKvmGAIiJtch6ZZmXBJmt2WNq27fAkssNXjlhOFXbMznZFIGQ+2ciSnEPKpEKpJN30eC0jEAxF0cH8JZtE4h9rkQR6a5ZqQkhcBqv8XWo+7y7RcyyWMvfgWex4JdjwxHZU/8A2Et2Plbmtu8N4h4E2D+ShXOp2FZTF/5iDMAjG8XndKOqfhqrw4VsWdeaHNNbexDeCvBCpysxE4i32ye6yWmgrFOxeL2Bq0fR893Ce1lHfvR5Ab3tlajfO2OggoaVJg0mT+oablRnCEf2hbJ7AC4GlSF/Q4Jh9awyEY/v8Oo5M1Nd5uUxfHhNoSu1FCLLmuICw== 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=thUbh96sABitnUnEHNhzu02PjOvbLR8/JQHvhHNVqyo=; b=i6ztwBO72WsEQCiDTQit0LAqpZ4Zp/VWVuHN8H0/C7c9e/3JsG52VQJf7GMVfoUTmd39jHJK+qM9vVWsE1IeHi2DZaTZc3FVAjRaZKpijHG28v4GNgQ5dE4eOuKrwW2jlvSnc5IU2kHcNig7SX33zRIGbHLvez7gW7IBKUbHWFkFHuQFHHQpBNQRkG5vm72iNTk1HIMk+yock5+bXUzUPqI4w7NrR+9mf54VLDVenfCyHVpcJJfoDPLBaxnCi2IXHvA0bfHnAQE/48hZjgkjB6jx1W/GjXkVEybmn4FOwgxgejGFnzxd75DzYv3l+XIH9qGv+/cxnWrdzyBidVPFKw== 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 DB9PR08MB6521.eurprd08.prod.outlook.com (2603:10a6:10:254::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.18; Thu, 11 Aug 2022 15:00:58 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%6]) with mapi id 15.20.5504.021; Thu, 11 Aug 2022 15:00:58 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v2 5/8] parallels: Move check of cluster outside image to a separate function Date: Thu, 11 Aug 2022 17:00:41 +0200 Message-Id: <20220811150044.1704013-6-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> References: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0145.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::8) 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: a822794d-ecdd-4bbc-09c9-08da7baa4c8d X-MS-TrafficTypeDiagnostic: DB9PR08MB6521:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fga+2yb9Qzxyo3zSiG0FyzackoxH1n3+rZcZZk6nvgxwCiA8Lw8wdkYWWxZFmYe+W3KYmcSIpIX9emkT+68yOlrEE1/2YrmtB3oTlNoodC1awurbzUvhBOIeOVXIrxT/brBQA9tl0Kf/2NeomK8dQViajkd0yOeBW5+2CBeneqmqak7KEETOIqai54mLxy7G9oYF/L7H8vPzEPJUtvCoKiyr6lOmZfAy41ihekvJCI80e1vsmoxeX6FfNkuoShcNiryaQ4RSnM+wZTBJtLARFQZlwyvlyKwPcVUZEzSRDZS0Bh1/3hZuCQKNp4i/ImzoIMw8gAutxLR04SQtrRmJUXv8WFWnmHezcxtDDljGT/Qcm+mTINuuv/BIfD+R/KwJCTIjXIIBSj3Ws4nkp9ATPHqGgtT2QHoCpKIE75FA5snGtHKpV5PlH9gM+p4nkrl9lpSR2fjVcRByt2bFAw4lrmouRCqBWdmhlfTM0BVMXL84YEnsrXQJA4iWK0pQKTEXeheijqyFLSvroVdKuSTBLyiu7kiIful41JywIEPZae1KrP1cxLDTXS6cHjUz3PvB9bSKzA2ky2gL+qqbo5Xa7VB9rs+2G9jeXdSng/Tw6q5nJgQ2CBq/obD2AcviTDocVtLX76ZdHj7tT1TOHibrmfwwxwhhhrb0r7t+qhLEJnOdCIvAhRqMOnfbQWW9IO5bMobEjkVLHshFg9aT0a3BqdlsWXGJD5mtf2r9jRETkHBXawGVQsbyyWOCXxIcl27+KRY2djdeH7tJCdzUhU/fw2BPE5+AKRk3gAe2F6jgTMw= 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)(39850400004)(136003)(376002)(396003)(366004)(346002)(6666004)(36756003)(6512007)(6506007)(41300700001)(478600001)(26005)(86362001)(2616005)(1076003)(186003)(6486002)(83380400001)(52116002)(5660300002)(4326008)(8676002)(66476007)(66946007)(66556008)(6916009)(316002)(38350700002)(38100700002)(44832011)(8936002)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OuA/aErm6rwOuJuRtgOWpQpAg0BF6mLWIOTyaC4B2JhiwDs0Rv9YSoB2lup58iTd+3l1dS/Qrs7jT1XjoRCWtWchZA6nwftZ8HNAQJWmKtkl0usRUEuYpuUbYvl3aDSB1X8i05ariiU0aVqiRMyYFsiunuDENJmDUDvN8WA1k3pT6bqBh3FIEYIgjuMck7h8FBUUsiWnh5FT42nWOb4b2dwwPNyIHC4wuTAXdsf+hItjowvhck6fyf65fNhAFUOPosfyUgmVmYkT+ggXXncxF8sLYtWuT0GhrjmOexXOCFIg56/ePUkv/b+v7+aSXjA3c54b+8CVJk5Nd6mecZlq5UkajURLIzJuTfQ3406UXQBl+Yfp9js4jj2MVD3cMfOIVSQ3m8ZNNv0xk+XHaQeRHAzCEF6yiOvjpONxz1eZKyEgAtjwHVIa9tohhToZx4x/HGE8lPnrWTbFi+isjEJ0lRAbIzskLri/D4yqf3IqNUIIGsua7Y1Xoc9Z85Vn4gg6cgH+PnPPHj3XXCLKZNd4ROHmhgn0Q7xxQyb8ZGYR/HjiRzdz89142wcD5f3TwSmU5ardmNlHBbl3DK1CW+ckg/UK0V8D7Qa+TR6/9h0AsQXAicSgTPnafEo2zhJXn2zgnvgC0FwsdrH4rNH4lubftX4djMe2CHzZItKuhypQ6xyH0mLCpMLJslaE9no1IjgglKn2RLeluKo4tszhFbe9tEziEDT1Mj/TrimGoesUsMlB4umFjC4PwU/6yok+djYqpDJ9K2mIjDbusOGOomLdJhphKt951nRdlMLKRxCvBjRWInmN+9fwqHp5qXshYMqSchFEqYz2kx0mqhHDPcSzRnnb3lECtTY/iqmdN0dgncxZmHvYHCUQHkniJdFp1FQ/FuzcFaiSTqfb0sdoDFAOW5ucVa9tiu613xtJpRwrfYLKT1QKy4DV2ptDWLghTMNC6Z8LrvIXgPBif/LBlz1GV5DoP3QNp5Wf21dEvjp4T7Y3RQMez9qicifp8vdbSlJvlHd7hv0navRj06sHZSgiDvt/apxAMk3C+BtEo6H+TpS+mG/4POdPxPRlLELRorpbm957NHuUEOZp81pVOFGCfgS3xKkaVRohfQgjGcoEjRzOheWn03dyRwaQ9FeD4IgqpwOKuvz8mw23puU0xtd474ZkvvJq7PhKgFYqOwQe3TxL1tpZoOdRTdwiCvcazrVtMCbac0HR1GZgc/cnj5woZLjtSRXgUQNGTjEiAJauFfkym2Kk4m6nY0/Qbw3TDP2aINSpN4itpcwpRCm4a8xj4hNCryHB19yknjy97ub/UQNn5mdWYVoUKnXIKGxBXg/kWV7aU2RRGsFOdGxqCwPj1HAredrOJnMCzeMs4sI78vS0FjI5n3Si60ZmRXnovKelLi+ens0g/PzHcxu0ys+dNwN++fUmRJRPmIdGUGkIGYjV3Jib7WlbL76tp5oM/2yLxQ4rbh2HknqsXTZ1vq64zfviumpqBXOSPhibXJQmeEiim9Db2/w3Kd3wMCI7VEFZaJpUCqYC+aPSKY7LIx1Ceb5feYnIOL9Uix7gMUXauz29OflyH0E9vHPt5w9UE/f521qAdPGWncTwJgf412HCIdrWwbaRQZcWR578jieStiE= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a822794d-ecdd-4bbc-09c9-08da7baa4c8d X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2022 15:00:58.6408 (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: djNnhx9QNVLYGAN27J5PdXcShdCh2A8pBe4uKJb0n7foe6Yu+FQBIHCmfnBTZEnHdBu7EQsl3shwB3+k+/Gk56syGw2dXE1bmMpgjHP0nLc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6521 Received-SPF: pass client-ip=40.107.6.138; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-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" v2: Move unrelated helper parallels_set_bat_entry creation to a separate patch. Signed-off-by: Alexander Ivanov --- block/parallels.c | 48 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index c53b2810cf..12104ba5ad 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -439,6 +439,36 @@ 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, size; + + size = bdrv_getlength(bs->file->bs); + if (size < 0) { + res->check_errors++; + return size; + } + + 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++; + } + } + } + + return 0; +} + static int coroutine_fn parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) @@ -458,6 +488,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 */ @@ -470,19 +505,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) { - prev_off = 0; - parallels_set_bat_entry(s, i, 0); - res->corruptions_fixed++; - continue; - } - } - res->bfi.allocated_clusters++; if (off > high_off) { high_off = off; From patchwork Thu Aug 11 15:00:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12941501 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 4065CC19F2A for ; Thu, 11 Aug 2022 15:15:40 +0000 (UTC) Received: from localhost ([::1]:34552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM9uM-0005b4-SG for qemu-devel@archiver.kernel.org; Thu, 11 Aug 2022 11:15:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9gT-0002lS-JI; Thu, 11 Aug 2022 11:01:17 -0400 Received: from mail-eopbgr60138.outbound.protection.outlook.com ([40.107.6.138]:46683 helo=EUR04-DB3-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 1oM9gR-0003b2-KB; Thu, 11 Aug 2022 11:01:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H8HbdlHcvG7jkXF0716u827OcN3JtLYxqLf422KiBiY+OmlDzjYEXarn5Er/zdvZiWxZ06ew5uNGDfMwF1GuKlcjFWZH5Qda2094DQ9U/DE1FNqdseWPA5lFZJMtBpc0ZThfTjxlbtVTQk+JGo1cAXu/+43V26OXiFiFLb1EQRuf8QcLrnMI3ZlF1HDwLvn6mvCgnIEAx6hQzeVH420N83UcsflQ8CRzbjoIhyHwT++7YW7C9OJyhVcR/Lq2DUnj50HCfNmoAtiHgMnq3bZB/WLZL/FEGPcHq/ZS5vLZt6++lhNr18nG/COSgT3ocaHfocc6g7+qKwSdUsu5wdaC8Q== 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=XPvEeeo9IY47D+VLvinSlEWigqt+7wjRlAV64Gk1SH0=; b=kV8jYns4UT6HSJnHbhFSg1Y9mrkhXVL7xzPacqrcWN4P5PnCn0xL56/wpG2L8CYFHDBKJSwbLdm5U2P53jGcqcqdwJiANUUPJrR/J5yNqvPSTOWqFiKC/Uo3APO+db4YeukkAuj5ZP9mXB0/s7sQiiZp3zFO0jjkYEpn06q3A/bdWeWFjtErq5N9fAoVRlOCPGCkH3iQqYPN6BlxtA0tqdlzfajbU8SYcl+5DqKxMEV0NZxyte29KHBmGTgVOatW7QVxa+0tchk+J2pQBjlvJAz7mnM5QOcmChW2tauR8oaCI4cdug80wOvYsHurYlqbwm+a4doL/Tr84NZiutFFVA== 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=XPvEeeo9IY47D+VLvinSlEWigqt+7wjRlAV64Gk1SH0=; b=NOjmZnJ4JI9LlTnsXkXUSuNNTagkNkxm/UjfopbO7mbfzk3xm7QAhuYj7Tg8l6rfM2LgktXxblHkp/EOmyZQOY2/MSE1XJxeQ4UObA7qElutT5YqKYBWi3Y/OkXKJnpes+t0VQBoJA0c2aUGplzafHadRVttdBGXa/PuIkqsgSlf90FyTtfhJTQyRiCgqewUThK7+OzqOmMqHayYF+Zye8dWFAiFZRO/dmIQ+T7vV9uywwmQwAGKmB03A6Wv+vcRPEGpxevgtxLY029aKRkHokxlZ/R/bbPqflC7Q0oVeeWzSWpzXRYQuvIATzyX47FwrKxktM36lA7CHrp7lzQb6A== 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 DB9PR08MB6521.eurprd08.prod.outlook.com (2603:10a6:10:254::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.18; Thu, 11 Aug 2022 15:00:59 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%6]) with mapi id 15.20.5504.021; Thu, 11 Aug 2022 15:00:59 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v2 6/8] parallels: Move check of leaks to a separate function Date: Thu, 11 Aug 2022 17:00:42 +0200 Message-Id: <20220811150044.1704013-7-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> References: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0145.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::8) 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: 40effad3-bfa9-463a-7568-08da7baa4cff X-MS-TrafficTypeDiagnostic: DB9PR08MB6521:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sjGf0CkkxIFryinCS1yMmGVDzREQz8kyT/s4Rxk/HH1N2q0TDMCCLC7wIWbnrk3lTOI7XHPtxJ9vwWoWEADWiexM9ddRsmSJgUB3cQG28FT4khtR2Ns+nKmeGlrEw2QaOYlNWj4Ejqw+3Dc3qkAovu0BaGFCAkYtQxuckc7okzGuP1xaoqgHvzjFX/qJFo3mZ/1+xhYiwJkuXh7SB8W0Rg9ZILU073i8MsqkQLDITyjLSTqF4f5giRVY3sZPp/KFtmhWiTTCs0vH1izLLy6kVD1rDZeex6HudTgg8vKuvU6bEiQaypSySmTl67zHZvMSofnqdESESAEOd+In/RqegtVX39nJnAr2fN8yy3lHtqPSFrp7vHNllF41BUeceHk4uARkoNi0KtFWUWYx/mhnUfKJlnehUtFHbqZb7pH0sqz5B22+nYQ/MrJoFhK2qbFoWGKm7TxqE1ulPTbFybFkjUGwKH2ev8jqn9GtudndgtsGVGNQdyYwkVGeSs+Pmw8wCZ3c8Zzu9WKvj3xbuymxH1BdfE/UgqFwKjTvbgraVSor9DmqNVi9FYUl/IqIM32dI82xdd1PXla7jLmyvsFAxW91LNAfDSGm68wSnfWBwwfyi2G2l01xNfguwPooxcTmDyLMpXIsBlAd57CsjNzKLHY5bSHz5Dk/hJ1bnHsm7GQdUdsOFFbh5Q51InN09FBebJqrZ2174aa728EDmbhDNPinqEqs/Ro3qr9TGIVxT0lm58PHlZ+A/hozYXs1HY5TnhkDMKri2j2Pb76Ykpe9Kb3gVrU1TxEztP2U00E4ivs= 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)(39850400004)(136003)(376002)(396003)(366004)(346002)(6666004)(36756003)(6512007)(6506007)(41300700001)(478600001)(26005)(86362001)(2616005)(1076003)(186003)(6486002)(83380400001)(52116002)(5660300002)(4326008)(8676002)(66476007)(66946007)(66556008)(6916009)(316002)(38350700002)(38100700002)(44832011)(8936002)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jhXxvCCqtbLO5vHULeXFE5hFt0XT+YG53mxOhqjrrf37dgJnCFqxiCe4WjPgHflZhTzpHtW9IihNTV94TIKQPm/4EWF3OxPL+oBeXeg8LmDHb2Icx7N5ObvKhV/RiIvWeSOUCkCpJTNr+GvfKxjFL+2fCbaHQMG6AMEm5FUgbccwi669r5Nbe6hX8zslJoeQmWZrpGbX6FhZoZxSxptdvupFGN0iQoU3feKXzWzhqH2hXC6AKP7sHqk3GgKT0l3XgPKXSJq16UgDevSFSaXW9fwzZrnj4t0sQfJCqUX4Jt/zYDLQUu3dtQya7d/b1l1JROpmm/m5rzgGgkTmtWs9icR/xevswyk97Suu2IuizU4BGzOx+NBEy5HlDYONw83t9SeiU4GAsv8kcb4RpBcCpA5lQn6geKHkI3jx2cRjQ0r8N1lqf1D2fXLbXAlGVCW1hjoPBbZ3vYMEIEzNUHSDHp/rxF0lzvpRpnl/ygchViZwCp5cKxtt0OwbI0Qs2kRmwUZb9KZ4VwE9q0YvZ9W+Oy3HWnf/lr01mUw6B0B6oyZzQb849PmSzUw7ma3zdJbdsKByUuszGxIgka458pIcB9JcJ9GJTvsZs1Xyf+P1hMDFRhFxLEUC22bxugiSUHYPuOwkuy5kZSoL9VGoTIPlh7fv3zYyGZs0rIRK53ZWq9me4RMBqQyiGLchgpET2ozTSZqBz5whpvp6LuY2HKa05SE65k9ZMpH7F/Y3OggXlxhMndavUUSGBRm/cE2R0eWjEeGggujL6mvUlSiivjLT0RzJMSk53DlBh0AoUUCEuMarJepnVBMLgvUa5QTyyHyKi1gvWMe6Jd1UrX/x9uISTHKpGnFEM1T/vNlJVrzfXR3oZj277plTAlJ2HkzraX0e1hnTq9QtJC0wdMSCv9CxSbeYARIasc/mwAaS0GG3ZdwsrdY7ycj9FDxOS0j3GysZeEJMF/4NKrM9l460spXnk/xzBgeh6hD4PDth03+cbJyCsZYKN6TXUlJk2Zkr/S0j0zF9hIFqM2AmEppGBF9jWIlu+QLkEHu+TN1OgTyR4EHBWDu7CBOMH5CuQ9TdzQosWqkfH/771AAyVnAHMilHVc5qXkdB9JxgmMzoN8PCgTjNKGAsgbOVpTaqJ8/ew0A9AYCWyAlz+4sAfX1m++btshOrgt0YoIoSTZmL1SwgRm6UKZZcjSNk2XFLlNJeQ0ep4IHCek5n1NmjqjUuJihiR3zqxHenKD7a+lrJFuZdG4+4LSLu7Uqva2VG4whj7t+afyGe4+yMTro8F4XoA3n4Y4dqwycs0H2ZEYiWkepKzLFp3B4YPhEkoVkU3D+GuCMC5cJP4Av1X/zDTN3mlOK6qXnEbPspxo80cSh0zmL4u4A5HSRNgPHmRsTTFcSQ2Ml32zT37f/sd19vG0lY0m+EqvRxmaiU4n0cm3D17TvOb3akKZMRqf9YcHkifQFo6NLYXyEk+miP6BRZEkEn9taPtUu631Ps22vlUcczDfXX9iK6WmpcEDSLo8Q/tMA41I7hx/6VLbKIfL+VS+G+9f8+yfE09btrxO95X2kTuVjXAq+G2umH7TSRUWJH9g7R1XnbFp0l11zsMR4s89poKkz/d2OL3q9jbPE4FoOen6dFtMU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40effad3-bfa9-463a-7568-08da7baa4cff X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2022 15:00:59.4844 (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: i/Hl4twW+lmigAGPvGX3dBBuq2KxUHSRjOPoFKAvIinPKSmlQiVTXPsY9LDVbikD+VB8NkT2VC0OaiHqLul0XI5d7gjGhOHakW7pF+w2Cuc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6521 Received-SPF: pass client-ip=40.107.6.138; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-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" v2: No changes. Signed-off-by: Alexander Ivanov --- block/parallels.c | 85 +++++++++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 33 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 12104ba5ad..8737eadfb4 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -469,14 +469,13 @@ static int parallels_check_outside_image(BlockDriverState *bs, return 0; } -static int coroutine_fn parallels_co_check(BlockDriverState *bs, - BdrvCheckResult *res, - BdrvCheckMode fix) +static int parallels_check_leak(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - int64_t size, prev_off, high_off; - int ret; - uint32_t i; + int64_t size, off, high_off, count; + int i, ret; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -484,41 +483,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", @@ -536,11 +510,56 @@ 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 Thu Aug 11 15:00:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12941494 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 EC8A1C19F2A for ; Thu, 11 Aug 2022 15:04:18 +0000 (UTC) Received: from localhost ([::1]:40132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM9jN-0005oZ-Nl for qemu-devel@archiver.kernel.org; Thu, 11 Aug 2022 11:04:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9gK-0002YF-2a; Thu, 11 Aug 2022 11:01:08 -0400 Received: from mail-eopbgr130137.outbound.protection.outlook.com ([40.107.13.137]:2827 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9gG-0003bA-JJ; Thu, 11 Aug 2022 11:01:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IRuroLhYdKI8ub+L1gQXGp8jmAieL0SygVVLDF4zhfgP+ABnjsVEJ3kUhl1lzYicyPSwTnMO+rOjl4mlivwsbf23Tl1jXknwAeOsAv/0Yt2bc5cUfmeFXIQcX3vCHFpamLdoRIOFxKenr2DukBV2lb5kRCzlUOyD/Jtk53yImK1McsHeE2f/K2kH/S08tu6Ndwi7Dm4OmAsw+zzA1/v9Hf1BATOFosbbHpOF+Auq0WbJysp53hFMt69TAq4m1jnQI06EDu12o7mAG6LOyAXbicC7tmWY3j2M/XZ+A5S9wBqd6fS7+ZNOinqnVtiWxdWJoHLXF3p4eIrfnMQtrcJp0g== 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=kC9qoiiTk5aho6nh9kG1e63iqErJ44ltVWzsHb0Z/lE=; b=Y1Xs3KDUT9A7XOgSxV0JERubbDlGku7ALsJNtxfRRaR3026icsYigVMQpXlbGl0GSxPTn042lvYIJWceGDB1+/AXKhNg1TWro7i71XpCYGhJ61wjoINWW8O/AN3Oa7JSDbNC81CLVnJDFIylK1nmcviwiNvCnEnFhWXlp+pX8sik/9yLtwPYT2dvDjze+7m7N7+tqW6RcEnzLPIASoxeo0Xixy8QDh0Nw2zjLrPRT825TOFmRXErc0R4r22BowZ6bYbo26v0jXh+swLO1b22koN2fmBREqYWuvQbbovlmmLEy2SCATmzBs8pOrJmOOClgHEqRhoVmftpL0O9f0pffQ== 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=kC9qoiiTk5aho6nh9kG1e63iqErJ44ltVWzsHb0Z/lE=; b=KM+HQK+YflPwNgK8GSuf33B2RsXjxax/sR1wsryVWkQkkIDlETI+KU5Fe3IwvdvYj2Ep47dZGTBy7np/OP0iAyLkF5xpuUgNbUXXxPKDAQsE+ZB3dBRZmY2vJtW73cYiGMMehFKhWgqPhDH8RgxWjUdWxUj+yVTgnZAooXuOkDwgjI4zGLztk99ya4h2SHiuGO3JigWSsPmkPwI+0pQKTiXbHLdyLoYm1nlBAVCyHo2jkDA1n6jEEFuxP+yGr/s1sRH6fWAIJ9gVjcm/TyRVhE92294COw3yCuBGPk7swICziDAL1X5EAsPOOaJYUrkUZupzizVO8vXHg7B1sKBfQg== 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 AM6PR08MB3383.eurprd08.prod.outlook.com (2603:10a6:20b:50::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.17; Thu, 11 Aug 2022 15:01:00 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%6]) with mapi id 15.20.5504.021; Thu, 11 Aug 2022 15:01:00 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v2 7/8] parallels: Move statistic collection to a separate function Date: Thu, 11 Aug 2022 17:00:43 +0200 Message-Id: <20220811150044.1704013-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> References: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0145.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::8) 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: 909deec3-db40-41f0-3643-08da7baa4d79 X-MS-TrafficTypeDiagnostic: AM6PR08MB3383:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yG8eW8Aum8kmY8HNKF26EFSGLFavvf74CNLAb9+5Aag9wagXEIK7e7c/Ojjh823xVBHyKXRsA3GMVilQnqh7sN9f4uh5Z0XQcnkXEuUo1elfbOkGtK0tqBAA7cxRRw8vpnCNeoLWM/LDdlW/0G76V12RmD08nTQufkZlygFrLnGNvs7ZEyCS0RweB5xGD1sXqeZ++i2E1+01Jui76D6R/zwLii9RaVZDsMcZ4bt3vyD4fzWMkaKb/UeEGDizHyMnvMxAdKsezrpMkknQpPHviUSs4NQpaRkU+0jacHj0EPIYAg+skYwmSTkaJF9jNuM05pfZrX5B8i/5hX/2MkOycsX1cMff0W/dhEEPH1qOQD1Eb4VrzvZ9Qd9+qwJXFIrewX107h5ua5GCit6ijbytdCY07Aw8GayTzYXj89/03rPGFWh0Z1TIDYeQ183gNoIktOevh+N01EWDJggNALikv+okMpGMMwS/0gRtg7n6gUhLibWJOsw3cNbcWD0GL/MBCuPuhlTT2J/iGR/vYwPAvoeamI6OAKounOSOzjqSf4j4ATbxAF8xyEnlrpRb20ow62qQHbFcScFoPEac0UdnC6wAghPRKBj7CDeOMT7rDoghuNb7sdsuzih/7VzYnpragV2e19ecEi1SJVSRRFsOvAOQlNkZLHAry61bXYM0oj5ZHMqLv/AMUT3PuMvx+xgIbyglfgAive1RG4ye+4XK3LbdBTmb2g3O1Pw8h+jKgvX2m7bpMkK6NwicNav6K5QGvgpQUOgbaswDFmJBxwEzg5bVTVPNbrl87YEBL1fv1z0= 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)(39850400004)(346002)(366004)(396003)(136003)(316002)(44832011)(8676002)(4326008)(66476007)(66946007)(66556008)(8936002)(38100700002)(6512007)(6506007)(36756003)(6666004)(2906002)(38350700002)(86362001)(5660300002)(478600001)(6916009)(6486002)(52116002)(41300700001)(1076003)(186003)(2616005)(83380400001)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xh8OcxcfeiZvwXTdvfnkNwDnluAuBUkJVcHkr1zq1Co4d3mhPAMsr+zYmIfEhnmRy1emnGDUp953jtoOLHoCmxNDwIAw0aosCYZyPKAcv5O4oZBOSZNnGosQzao+IwsC3bYN0G6iWWUlrJcH8bJJulXiyZqKWY/sepYMQbdD+IcmfBmRkRrclHReOzia7C2WGbVFB47lEjBJHMQ+n4KzSkyXSSale8/4cPXL7L4l62LkDW4kkWV1MK4rsMOdVO6KLtPYtoOWemGVAfbzEAifW90Q9Xi4tj/FlYkpGV8Y9ZAlM/X8wzcbL08OOvaSuAXKSdROPnVv2QboL/476plD4/Kvw4wgcoA646/lmyzCIVSUeEpoK/9NeJLnSxGjnQPt6pXuF93xWwAz7IpPMk6E1KFixlQZMwMC+8Ds5/5mv4dsPk9VWl8fsm/iVKtKTFXOyLgLkMeOC5SWFZGd46MORnrIdzoJsYxqZv9M4DjOySJ1ky3ZelzkucFhKeq6V5jRXqfp55Ox5GJNHmz0birrVBYZnq+cvFnRgJmpIhlufHbq9k66vIHoZm0x1zOgMMWRe+9zWnZeLZehvD7y7FMKUYkOP9N68QB0ZTI3nAJlDFMfxdNQBonPqbNk9a7Kj5UXLz/GvZok6/3YkYY05ALnF3LIu3fvnxauIrxHuWtZkSpTZV7IewYfRRHz71EWSfKPNK87LtAZ9EscV0vkWjjJKry59/w4zqx0QRsU5d1Lw/ijtgOZtMwW1Ub6+nWmty8Q7G+obh+PBxsMvuRb19mDTJti/WKZVjV0JoMukyBllYyRPD44whsHaUXZlnAH+Of4jhoQ28s23ng/tNoX61jXxzu84qQzTOcUA7uuTdqHuXfO2fWk3rXngC5IwOi7gxRVMlIHAMNJODXjLfb37KIl1YqUnIon2J/aNlT5ncboSQoXL1Bf3FCCky6bKbrKuR9Iuruf2hmG1xbGWrV8N/u32dDmuMv8e8zOL87C7BkW0hSX7TNJjl252/eVZhdGG35B0a2rfR1xolI+MgNzetJRXaa4lqSMJGFXCr2EDUna61EYIWU2nhpS84++XrhTGZGc2GiG65KaD84/x9Lr/CKDrmVgBfQYloHCM2gaGrq98zGW2qe7j72/CblTsOS90avGLTTIdU/VSsktv324Kr5HvLkszykUiowl8IEKcmxy1Mlx3/1OynpHLGVm8i1FN0YECdTY1EIDvOhRx341GrR9Y5FiYPJkB2ONXfpDH8zt3AOdmnIl0oKM+p2wV5zIsGDhEEUO5xk41+7VmrwEPW8GWyAYhgq7XLmO+bRDbfz3ZcCxFXkmLPP9mdM7JA3xC1f24BaOWwDMLeJ4VsxVAmj5gvnGsRdYWquKRe5N55DAz/yebH9X5reFj3AhI5LZJJw6DKUVhefkK2AZh3RxGQLJzmCp7Gk69IuaIL2M9wex/lQ+B0bRlw3n6KIbz4RxDl7/7ZPMDSGanFcZa4xeRNkgxI9zTcHviSyLBIQUohE6zKUB1LdHiatNmQVNBBWfsQtsxG4f7uHgROGvvZrKYMxVi0bYC1GHfEx0BU5vuoKvNtKRxdXM0hV6y31mI49VSgHqIDh1SDofJEgrfGbPo0OPlrKgEDhe51fKlsP5PNZTtVM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 909deec3-db40-41f0-3643-08da7baa4d79 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2022 15:01:00.2042 (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: E6UXy3qT3FSQbkwbm4nbG/JvbNEHdEvTX3rTCCd4hOOril9vJ3Fg+jY7Mzd4CUQ5KGIkxDLwCq9HfSZ6JcWEWZTsUfNN+A5KdwIx+s1IHFc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3383 Received-SPF: pass client-ip=40.107.13.137; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, 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" v2: Move fragmentation counting code to this function too. Signed-off-by: Alexander Ivanov --- block/parallels.c | 54 +++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 8737eadfb4..d0364182bb 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -518,48 +518,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 Thu Aug 11 15:00:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12941500 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 DE242C19F2A for ; Thu, 11 Aug 2022 15:12:10 +0000 (UTC) Received: from localhost ([::1]:56966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM9r0-0001R3-1W for qemu-devel@archiver.kernel.org; Thu, 11 Aug 2022 11:12:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9gQ-0002fx-SW; Thu, 11 Aug 2022 11:01:15 -0400 Received: from mail-eopbgr130137.outbound.protection.outlook.com ([40.107.13.137]:2827 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9gK-0003bA-Km; Thu, 11 Aug 2022 11:01:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ahMIEYC3HqN9ttnq/HfNBSBHxgko6yvQyBqEV2Wmb/kPhxoKlpP5h/aPaPCypBcUrRBb4xB7/BvaJmUPXX8uwh/po6+0lpP/LYY1dLOWL+5XQ1FKHy4+/OWHR48DciOt0mvXc+aIg0wrGO0KmHxCokg33HqpVpSKil4iSUbmRwLzpCDjVvKXofvdU8JSgHg/8OSwRb55SCXl4EKQy/TwnCoMkFHzapEcch+i9ijyZ0ZYES1ZB8iT93PxoVXrG1sZ8acrqLaxHPQ3ZbxsYHKvZhFcyMWS/AKM8NRoW75SYLgbK6O9Yur0s3iT0hM61hRrtLI1e79w4b9ErsiNLbCcMg== 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=CUkVh6uTzmKJnMhNxvVODYnsGe7IURTC++YBJVYcOGI=; b=Rb+ncNwyL/ZnhBWYwxZx5efSlBN3taeruAjiz6JEVzoa0qxVDYcnstmyX/UQJmRFJ8pgJcXkvas2QQBmvCl/cw1FLMWuTk7c9reAzS1kG5h5o3usLSY39Yp3kOVwrl/mYqb1fjWXRdiArOR/Cti1xHt+6l2up672xQDDV7qMfgZoRAbv5eh81ObfKm98w66OamnegvEixyXcfLnB0kbook/nJNimYQZrGO32NeNlo4hN3GvEHk+iKE0kyOfNwqFQdje51vTkc6ne4tMNtADxBHR8q+qDUojWhUwTwRHFgqAOT9tdQHwJC9Cq6yBcwM7aHIm5j4+Wqug0bNsovoQ4mA== 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=CUkVh6uTzmKJnMhNxvVODYnsGe7IURTC++YBJVYcOGI=; b=ehZfSZ5PsUVg2FIKNqYniure9X6/mZeJhxBuYafRfLCVibH+2VWT9cQIYU4W4SrJ94P6yhOMj+u9gGrS9yUBoMI3zh0VccHwVXUbcRVXTRsizlb86Vd+X+hcWay6oj3HS6q5pXLEdRAt4vtAU6ufltDK8naKDWQDBv/yrc71nyY7zRO5uZARiSRHkI5ZVVj4/rjF2VoGQwTXfxaQ1HWp+/80qtUkBT7aAIpSxA021Z9WYT2xjTsQ+l6nNEOTWY0krxdQ8pb6XF484A5sL9UIP5PU4vUCwYeCpEf3bE4elT03uw4AhXpegx1M+/AwW2xvIUU9VjaZlUlCK7dddkeSnQ== 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 AM6PR08MB3383.eurprd08.prod.outlook.com (2603:10a6:20b:50::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.17; Thu, 11 Aug 2022 15:01:01 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%6]) with mapi id 15.20.5504.021; Thu, 11 Aug 2022 15:01:01 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v2 8/8] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD Date: Thu, 11 Aug 2022 17:00:44 +0200 Message-Id: <20220811150044.1704013-9-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> References: <20220811150044.1704013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0145.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::8) 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: badf0d95-85a1-4175-a202-08da7baa4deb X-MS-TrafficTypeDiagnostic: AM6PR08MB3383:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5bW5nFBYlPCZIalCdg1dVl75C7bdbKJvwSKk3aBNDK8mDyIwCayG50DJ9mikwrazlev0LjgMMC+PUkJ3KQTIJaMfeVuQAUpbtnxe6iywN1tK6Vyp8u1vByGxfTPrs+b6sg5VMUBmXV54qGVo4/HIKQv6ggesTq4K8t7IKkuSH2iya6uZuCm6T8TOGlDC4MOgmZcAqbjRE0uP1DwdC7J3iq4S9YBftYQuoaqnaoJ30Sq7Unbeb1RzZZCGz4SDe7gd21OQ/4q38ETp0hhqZo5dD2mK41DWUkBlk138WTTta9qWIjk1GhLqmmZS4bwbru0djfeoXuvPQdS3un3yiebbJ25UW9hGHYRVMKR+NAdKsH9cJKKrfcyaS2fA5V9Nlesxkq2m+icqaEY9d7+W6KpUyG8BoRC5YR9c6cZSH2ybER5At02Z98rL/XlPKAszQgk+Q15H8avNvN4O0Uu+mSRtg1k512m7WFTcNZplxgnJWjw8o5DK+sJ9NE4+0a0gP1p+iA1j43FYXKN4AE4qkfk5KMnOYaPKrJAXfc+KpAZ62ha08w1uVakRVDV87LLwJm/HeXkQK/VTmhx0DEw7f4uwxA/zGOfI1KD+iYEsjOP+vE+CrnpR8/BE4ri6M+G+Jd3u0NzC8qGhvzdWpjKPRleY/bsdpGZv+ou27XQlIge9If1aah1KevUPvc2+uB5yi+wxysuDL/p0/xH3xj0eR35ie0bleW8mFOUvvk52hPybAnocK5n/zA9RIZpHS4xkjv2JJVNMwSHLjtTkBfJ10OyzMLp/VAIjW9xBL7vVIyuolX4= 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)(39850400004)(346002)(366004)(396003)(136003)(316002)(44832011)(8676002)(4326008)(66476007)(66946007)(66556008)(8936002)(38100700002)(6512007)(6506007)(36756003)(6666004)(2906002)(38350700002)(86362001)(5660300002)(478600001)(6916009)(6486002)(52116002)(41300700001)(1076003)(186003)(2616005)(83380400001)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YFT0jpbh2TK0x8zhCkoQ5c/wmClalrCUg6tE3uOt+ZTqsLYoDXDd8ieTdR5POVgfT9rQKYTjk1+jubKmnpt2tQZ0XjBytsN09HAtDJZDnZIPTX9eR6ZQdO+yzvcjJoROqNuhGulKOBm/4erdU/M/6A/gJUCuaib02DoPRVfF28piCbV/eEyaa11nugns7/n2WGOUWUOfzYQ0x6lwDHpFv/vnDIczEtFst1TokjNk/L+m21I+9AstXX3bA/UyfazzzpBP1TAWK43Tl3zA1yKxH8jzVAx6OTxxfRPyAW4f+WtKkNU5Cr6fLyi3aaHQt2/gw9rQ3xG+DibPEhno5MB98EL8irHr7DU73zmiQWR2+ob6Jyb0w9L1QUd+kvK2eljiAjosNAeEP92SOV19LxaieF7Q6d4dEapCSBOjQZHWdxADIOxB3L5DSkpQsOE2XvwmoZmJL7sSlslMeB3Cm4t95Tq2BLF5RyrYO0Lr+YbAbrCQ9peV+5iguac50k3Ev2Pop4C7yjR+bfhi3lQXEBk/0/0x3f7Dui4kmIr0FRLaAO0zn/ZODh5jeW/m4uqq1qHoqjK1lNU5KR2PmbNmjhhZ7lmZ7foFgsl8V/9o6cEfLfqfNShewA1lcwnRQEVeug4k/9k/MnXQh8DUv2SrjAKW/tFeAm8mKDpnBa+IhjGsze4re16z22pMEpTQCeYuBNWPsOP07/QC10OK/X07iCsAOi+nlfx1VaouZ0pYYWqmbDcVUsj4gYamP4s4LGJoFvWrIzTlGihdaRj1sL4Vif6Xlzrn5nYZMWeU4NJ7rSxq6xteAek26t5adq1xGQTfYgK3TEwMuS53G9boQHllgZ/b1EBYSRuBlPjptkGcpFhVssy5LzfBa9Ehr6z3HQPFiOrbLY8N2FSyF4EOIsZFzEWYA3M86U071JZP2KkaB90OR+N1NDZs50TUYsimGPA2cT1/jdN30ue/bTUZ84ZcLjhcjeESiEGMFi0VBFcis7HsYovM1PmfLInE3Kjo7dihcrUpeADz15XOyq1tC6pyUlo6a//ezofE9F2EAiu/lgeuiCWMaBgrRJFntjji7sQsig9LJkZGL6HG47ZqV3W8gArg35sgOPNvATwH2V2kagh+RwwxaTY69gLoQ7QEIqKGV2b26Yt1Wzk7l3stekMdCHPfETVh0XsVqYAe5a6pqnj9G2xith7WrR8LHK13oCzeWoJy8WCp9zYnKTIcg2zHMdqXPhPQrzD82wzP32RQqrxM4ohwJzCL/BVnqP9CxYVaik3QrPnpb99uVMQBYq6JpJTWsR1NOtby7BYGx1FoMWJRLPuMfQND32/4kekBWcHC3qrEkPscMAo73WURE0z2dkHvocSEvMuV+vq3ofnyKlBQU1FPbF6tQfPKRldYhjAyAOPexCkB7gTDGd19kqf68KFcG1DckAsaXJaVoifPzdY90q+0cA7/6ZWOu/1kvYT39pVCqdCG3ATGIAGD3PyMkEgRILISoFMI8l9esKT4TjCMxX0s+hddrmKIF0VIDC9wC9E22QMDXhfVj3sBUZbIWqkJFSE7yaj9HM+85UV7XenYWj8Zpht9mXXA6Wf2MJF8uxca80gEverXeerf6J32ncpGDvRtSVZUVyoq77pWqD8DgSE= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: badf0d95-85a1-4175-a202-08da7baa4deb X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2022 15:01:00.9541 (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: Orwk3b/931Iuxkks8pVBWH5LDdWHC3KRW3ZxiFQdRcGRyBx+xMWa01SurgIPbna1cbJTQenlSBL/QX2kUCJg4t3Ryl+PhbnoCwB6b9HG1rY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3383 Received-SPF: pass client-ip=40.107.13.137; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, 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 more clean code. v2: Fix an incorrect usage of WITH_QEMU_LOCK_GUARD. Signed-off-by: Alexander Ivanov --- block/parallels.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index d0364182bb..e124a8bb7d 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -553,24 +553,22 @@ 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) { - goto out; - } + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + return ret; + } - parallels_collect_statistics(bs, res, fix); + parallels_collect_statistics(bs, res, fix); -out: - qemu_co_mutex_unlock(&s->lock); + } ret = bdrv_co_flush(bs); if (ret < 0) {