From patchwork Mon Aug 8 12:07:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12938740 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 E5644C00140 for ; Mon, 8 Aug 2022 12:10:52 +0000 (UTC) Received: from localhost ([::1]:38094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL1at-0006AD-Ki for qemu-devel@archiver.kernel.org; Mon, 08 Aug 2022 08:10:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL1Y2-0003I4-N2; Mon, 08 Aug 2022 08:07:55 -0400 Received: from mail-eopbgr60132.outbound.protection.outlook.com ([40.107.6.132]:10881 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 1oL1Xy-0001SH-Qv; Mon, 08 Aug 2022 08:07:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yf5wCUyt9e+ufpt5ldADmX7lqkTnrC/uMntgzLkCsKqCwrOIPQiyHyPPTLChj8/P7owXIWnlRV7UHE0Jboa6+h6coaVfOcEEPdRUAXpgyRkmTNkXo7B4b8YTRMHKFucHDAzkElwvkdUgaeYHYE5VBZtwgmHIfSzBAa6zQF3dfDKU3Ze87oH+mzaIQNQtVBTrWGEtCwXAi9FVMN8b1/JgilHWxp8yyIjpf/l6vhpxqIHDwyMzwEo+Sl/598x6e9rEunXujWWCnGu/diNTGReYBdDonMDSinxunAfZVbbB/71Cte8JbwIvZti/efYfiO5SBM84aQQZleO48KclhVHbSA== 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=pgRGQwf610QJ3ZASdRH40FzTi/051uU7KYKerSYOSBA=; b=R41+/MRg8+JqWSZUx84ZDNGitwp+s4hFbAR//GNG4lig+Ok9Z+bZ7wr/UI5UjEcMZJEb0kCNxE26NyrYNl1+zJ2Wd75cDf30lJXeT8enbAwVOHIpBtkLOo9IflfAiWSKym4ORTETjCx6l9Bp01kF5aMXml4k0lFsj/eXnRbRlQcsZ1SmOIvFWtgOPnETsjDDsbWowZG5W5o+J10qK1lsQZ6CrkRqO0fvhGxsX+zf+iBoLMPqqrSZ5fCeAWegsiddbCi7St3k7/5WZ8chiJ9gF0FfFFradeXHaoLf5fFRP1elc9PnIBMy8Fcf0apYhl41/MmdZd2euwlhnYIVGKRBnw== 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=pgRGQwf610QJ3ZASdRH40FzTi/051uU7KYKerSYOSBA=; b=SOe74NNi1cyDnPO5JfasNFGqmrTeEJdhF8Ykh0qhgw4gomLvtV9PPGHqr9cjJU7kXrb3qa5yer1VPMkrVvPfAMzdHHyGDcdHCp6j6+GptJb27mOJsdra3QOq+lvaWPa0F1v2Kq1DkjKDpDZMQ0aesmuAolTYrCZJywY0FaJkQxkRgFgt02UgNS9vhrOLVtA7fnVYbBa4i7J4yK3yNAhjhcjgun7HZA+wiiYLLuUxl2+1tZvyNR2rlMjT8aiAEoO2SyZRtxeUxRzuu4KfLtor3JvEm6malO+xOSdwbKgQRsv6wReP/8j93Zsyzr6aom55xq8f38ThuHzR+NLu6/5fRg== 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 VI1PR08MB5360.eurprd08.prod.outlook.com (2603:10a6:803:132::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Mon, 8 Aug 2022 12:07:44 +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.020; Mon, 8 Aug 2022 12:07:43 +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 1/9] parallels: Move check of unclean image to a separate function Date: Mon, 8 Aug 2022 14:07:26 +0200 Message-Id: <20220808120734.1168314-2-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> References: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0042.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::13) 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: 1ca6f7d1-cea9-469e-f792-08da7936998f X-MS-TrafficTypeDiagnostic: VI1PR08MB5360:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LXErBvJwN9FqIdMKFX1wuDYLohxCSaYmbHtns+cRh4VsJ0SrkZNOKy5T6KcEj1P/+iosdcxfjrMD2MX+ZXtS4RHNQg23AHQqsdSY5iGyeVZHtDkh730C7fPGq/PfeazIIgv1SyDPH0RS9GubIVjMNhrRDDiiSlcJjkZSMbuNB0bSZLLFH6vj2zzJO1YLBE9CPZS5pNk4sD7fficG0/AMILlv80LpPjZN36hKMiTGWAJAcpd5KcOFIb3HieWKjGBuwFn6lLYX1bFULxtmpuGgnuWrIFuFykbgm33AbhD4Kvm3bKTk2y50W8vGTMOZH6gxOIL52mDj8rs9HT3O2c8JKEbJEKCoYFksed6tFiFy6kLOdiF/TdQZ6aUv4uOSj8rokKfZF3Sf9a8zw7AA2EW/5e1WkNlmmw1c4z9sJqDdhJNUeOwIOIr7mDP4Y+3jBWZP31wpngljks4CuiC+cWM8sOA0VqTfZycXxlli9eovobvPVGrvP5H6sTxX/UXRNt6s8i/2xu28TZoD44Xgdye8xBLG+/0XoH+hARla4x/hiEc14pZhUMlJ+KmM6N065Q+cqFc+2G/MTEX9tl50F2NuwPfXW6igITe9TyJ6L7o9H3Chh8c/8CBByfje+6HSrS0i+mcbD6MSUQN20nX/kE0MxcboTR3160Zfr+JpA8UIt0swIgGnKuOb69oZotViZf4J8+xWZ/yUeWS0hwgz7t7/XnHfpVUo6roe6RZxF/4+56FxLGUBieIuEK+SFazbTvHEzuh7MTAGFxqXekypFfROGMi+wHSdl+fi6SvPo3Gd5Fw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(366004)(376002)(39840400004)(136003)(346002)(66556008)(66476007)(8676002)(36756003)(4326008)(8936002)(186003)(1076003)(478600001)(316002)(6916009)(5660300002)(86362001)(66946007)(6486002)(41300700001)(52116002)(6512007)(26005)(83380400001)(6506007)(44832011)(2906002)(6666004)(38100700002)(2616005)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jJDwTgZuQXxKH5nCGOC4VncfT30PTg+VGM+ksC7QY/LxRCb42cSL4yPXKGjmOXlVbXRt+qDVlr5/H/82PvIUzZxWUeXm0hpkQCWwduXN+IPGRGxfR5Hj3BFTeFQ4Bj31gDxGrbPyUeALkhep0YJMMerADPDKe+xtbAW3Z6VoXcXeBPFk/Sf7I2dTcxTteic2AqirpenriiSJGjISAuEzPDBeoKxj55kho5FFEDx/URuo8WSmqXw21Vx9HJw3w7nR7NKyV7UzR7Uwb1dCf7TLUtLuQxjGIjmU5TOuFrnInUmgpP8SG2CvIclWuEH8droBciGsA5z/XgA8FfSHTcOU2u+Cy37uMw3SljyUX3cTYOX5I4I8y/LYOpFl2yQ9AK/j8HNFY5HhT2Uaz0CcqVbffaVLdK1Gj05y120X83cPV/KlpCrdmHajk8QAHHlhy5TqjDk/E8ITBVP9303Zv8om+thSm4Axpf6CaNeu7DrzcqJoZZMIJ7L2ocmcOuWgdW+C6dEathdBPXzgQ3a4tQDieQbfLbkjFiPMlsPg8ZwuSROl18eWBoWkaIv1GW8MR86X18ITNd/kXLwiIxRSu08HFwccBkILpH5nY6mLSUm3C0Qs1AbAIiMB8rRlw+ep4VI0dp7FXQIIhu9V+5sF7w4zenSWPXZ2ERBEbhwq+LQNU36jJJ7FGxnrJH3XggrhtjbKfoEhVqlYNUzDkc7Oj8ARb2QuYne1g7ujnMheib6KeFUbXUlSzmBeba2p91GP7G7MvCaFGkZ8QRHFrj38XAvfu+j/VOzQHb9Pqt5i8Lra3HprBTVmOWMf2nC5Wpp7MKLccxIjotGLOBkYqhfWmRdcCROuMAkxdEHUXElrJkWKKwzLJKq7qIjn+le2TCzpmD8URXVSD3l332+npwW5oS3it9ZVubW4p6jk5AaBJYulRiDM8ef2upXI/i1SOKKEVu+1vT/k/w2SHvCcmMC7UFZm1DnVJuxvFkB3W30zNm/8NNFwqAjhU8Qshq014u4pyEhoOM0/A+6aeP1KaNM6XXxLFs0FHv9l4f/oU4ipE4sHNj7QhkqHUdC5CiUpfKm9tpVRvdRZQ84B9vn8eY2ilGXYOwahfxsKSbGJBB9mdU88FaSQhEAnoHhoYVRPU6UDfM6f9/ZWF2NkqahNBekZcyeNQRfUL401+cJyYiWlUvKQlVx/7Isy7ILzgYV5/MR3n8x9pxvtEtIU9TX0hzeegoMG6iRMz3k94w1IBd3MVOQbeD//yCvB97lNg61KUfPpKy232LxGvl7Kcgspo/ZG/IFbruvbNPbEfRNeONOeljwyTPbMST/iglDFk03aP+02bLtb17jneJhAKqD7DazVOI4xGwa7zHQu3wm6/jGHxJyeJyckbB/Eczf/UWwxVFW2x021xAFYla7oEbJJnmrHAkG5XeiqZ6i2zc2QNNQyJXyUJk2ThQkvbj0AdnaT1sAACQOkOakbLnutmUiE3cI0G1ggusdk92fhSvmnCvKn+QwPWEdO7ZbT3c2LZA7urSTv+IqsvuHdf9oyptWYPIX4EreF2+rWU9DSxQ5ERCUixO3a7IzMcBxGmyx+rOYUJ8tewx1/Ron0f+OMn6ORbfGlqVj+ncfp9jnaPiqQus9LK4MJQqg= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ca6f7d1-cea9-469e-f792-08da7936998f X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2022 12:07:43.8984 (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: +Ck++NpcXN6IHl1lQP9LUEmq+xw7+zPU/37gTVdBAZ1qaD6Eu0HsI5QHyjaRu4cB/OvCrfXZPUxSlO1kOErVOjpAL0o4D8S8zn/Be76F+14= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5360 Received-SPF: pass client-ip=40.107.6.132; 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" Signed-off-by: Alexander Ivanov --- block/parallels.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index a229c06f25..108aa907b8 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -413,6 +413,23 @@ 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) { + 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, @@ -431,16 +448,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } qemu_co_mutex_lock(&s->lock); - if (s->header_unclean) { - fprintf(stderr, "%s image was not closed correctly\n", - fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR"); - res->corruptions++; - if (fix & BDRV_FIX_ERRORS) { - /* parallels_close will do the job right */ - res->corruptions_fixed++; - s->header_unclean = false; - } - } + + parallels_check_unclean(bs, res, fix); res->bfi.total_clusters = s->bat_size; res->bfi.compressed_clusters = 0; /* compression is not supported */ From patchwork Mon Aug 8 12:07:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12938742 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 71D1BC00140 for ; Mon, 8 Aug 2022 12:11:20 +0000 (UTC) Received: from localhost ([::1]:38946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL1bL-0006kZ-B7 for qemu-devel@archiver.kernel.org; Mon, 08 Aug 2022 08:11:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL1Y7-0003LB-0E; Mon, 08 Aug 2022 08:07:59 -0400 Received: from mail-eopbgr60099.outbound.protection.outlook.com ([40.107.6.99]:57061 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 1oL1Y4-0001TS-DE; Mon, 08 Aug 2022 08:07:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LiIaTWxad+Z/I3tsns8+HIiXrqKUpEa29JraKPvzA7b/gYgj18oSUIgelrmveFsnSYz8EdA8jJh9q4IaV76+LeVr6lzHP1TBjT2PbCdeRc/0wlZKnKUsbcOz5SLNGrix/AJcndAWtQ0k49BoBIieZKq0KFl7HT8oVaIdkLnuKmF0Mv8WYONNAUHjMowDsOJMofl2PDH2RC9Y8kkB1D8MEaq60vQGxE/7qpqKG2PVwXbetXO65rlTQRLozEzFVuoo2NyG7oBWLvnTJrzwvCN+KfdbViPmsSoU9YNsenbevL/PG24RFwDl5T7r6RD6ujZAzj9xxmiQkrTnmQuFlLbMFQ== 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=dnQBcDLmLO/jBSPAmuZLQWh9gNsQBDW125BevzusMuM=; b=U8wuH8M8xKbAmAGTowc0dPuZBybSew8zRY7fBh3kk62al7+gUWmkLmkV3CQM1jNcbJfPppt2hq2xHTiGNel2K0B2GGdwg0by+d/9MfM28bJOYJbYA5iWivHiRvP+THoHLU8dtyExxmRJiJm99BO22u+GWrudRvirs/Ww/jVf+WItmtkR+pKWwgW7khff0NXYM5ZOT7LeLamiITvoE7L3gcpZl9fVIl6IT+ePqUAEMAPg5qD8BZXD9UDDK/k00Rk5jfxmqPLqu+jYSrvejhMCURzaCIPrMF9Is1eJ6CYiC9aLLp/DFXE5Kl1VPGpeJPTwwhBnZsE0Be08Knl6eKO61A== 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=dnQBcDLmLO/jBSPAmuZLQWh9gNsQBDW125BevzusMuM=; b=zAWWzU9oXQNyb3f5hTFWKXoAXEfi23eulYhFxoa0eiTYHLB+qjI6MBQY+foqEV5h5MrbZgEHBZ2nAg51lb4S2ZP1Nou39k6QxzE2aymn+E0rQaeHmiy64jK+3mrXIb281NchYc079UHpsnc0Ucd3/SDHQ4lGgSf0nlwN+S3c5vKebCojqfw3zM5u1ZJO4wb8Cgvv7wwiMiOVXboiBjijwChJWSK2H4GJO4qjlfG4epFTpq6geiuFm12VUV81afOwlJe3NXRRn69MmAZdgw3VFmpUnkoSqC5pxpVvKAtmBR782fcTbpkDTbJlmxl0f4HVN8w0eQiUeMZdy8dzlnURZg== 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 VI1PR08MB5360.eurprd08.prod.outlook.com (2603:10a6:803:132::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Mon, 8 Aug 2022 12:07:44 +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.020; Mon, 8 Aug 2022 12:07:44 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 2/9] parallels: Move check of cluster outside image to a separate function Date: Mon, 8 Aug 2022 14:07:27 +0200 Message-Id: <20220808120734.1168314-3-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> References: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0042.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::13) 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: 8871d6fe-8432-45e9-6332-08da79369a02 X-MS-TrafficTypeDiagnostic: VI1PR08MB5360:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: imRmzQhrJTpXUa8uOfjOfMeZSOw5dOppFsrsyVuE8cjBV9rOsf7N4GTJMdNEfN8/ntF8umt+RPAiwiu/QdgG2Tnln9TAIoFGTkLdRPRpLAyjQKfyLa7EpSGFLijiW9Hd3ZzX9FX5u42UneuvcS9h3/ltMI/ZQu96Oh2YWqq8BERtZtZsWFoAUOg1sy7dWqKhLFi/FzMMsJCAkmjGMle+32q9r7zdkZfzM2ow7Cjm10dT1yYQQ54YvTsVNOwtt4oETN5TLsIG4U/GS8HkARQ+h4Ex5YNLu9ozOSQV2CmrbhUnpiMMMGhKoxv30SbU3bWI1H1DSmS1gKge0wS+rRD46XGbH9Rf/U9Dwo/VFpj9+FPkscm9YnAva1EAtTNsEssqoikJTKuH8a97/q71kCyfaNtCGwhJFPo9YfeeFzdWK4VPbQG0uZgb4SYvvyFE33lengOtgL/K1HG5DTqpPPD9fSq7n8HrjqCW40XbPOFl9SGR26zRFvCEtpL/8UnubpVi4FX0GdKdcfQGq0ucUhHwF+X+vQNvVnl2HxbdPLumufRchsj/mMzMUhmjmiwouZGM8Abq6F8Um0I2n0eOeCpsENer5Rsz4L7aDCZvzIwTxm+gjc44lXgtyFR8c388XZxuHQlmDeRDiT/c/9yYHbEjsyXzKHsQdmoREKqy0gkFMbY5i3TajV4BDCpwb+U319q2t3yFvQL/R3lXnVtHS7OuOnAzosCODDaVo8KXGaXpPM/SBvYurc6jzpehUMdRgkSb12sN07GN5/VMrHKSlAHz6yhld//EpP5WwDtMLbyzSMw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(366004)(376002)(39840400004)(136003)(346002)(66556008)(66476007)(8676002)(36756003)(4326008)(8936002)(186003)(1076003)(478600001)(316002)(6916009)(5660300002)(86362001)(66946007)(6486002)(41300700001)(52116002)(6512007)(26005)(83380400001)(6506007)(44832011)(2906002)(6666004)(38100700002)(2616005)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8N38wQ8+l2izZqZK4bZc3fbvB+AxT4CugqYnKQ5I/6NjqmhZEN2dP66yECZdRkt0Ryj6zlBlNVuxBAl4UOMlZTYhMteZd/6IqQxCX7ih7RIUo/kV/KG6KT6gsNq+0KEikp2pNNr2L7dCR+7Eak11T+WpMgSSiZJZFD6fza1Du6zWtclkTWD5vP7OwgDVmEvZ610Vl/EM8dOYUOlodraOOQEKnkTVHXG54QSMmE1+YaWQcigd9lIWFyYWSfHI/iBTcJQiwOM9vJ7s8XzZrp2ySwQse3K2nXt8g470m8pJLp/6gYQb5qgmf8YsIXsbddScZCqU21zmhzcBQ7QMawFxyaE2TmvWpRdyy1m7um5blDP3yAmbbEJqUL53n/SVLj+crO+zF6BQeCANGUYJefsBE7pSNQLVadMNs2pEW4Xg/SW8fQeavxBhNvyQAn6IC0+Io77h4yfP4GWMztrjvOFn3LC14S+cV4ujFXzV90h1OxzZuHUjww1h93Ou6Rudqot8d9HWjsnJr3yUCSnqb6ONLxeie5AK9IxcCVfr5kD6qkXPbgXejL+WWNrNr7nWzqrHd7oVnaFGAx3XmVYHANOhhrkpAN/3/xFP4qian+lFeLRSGTRfMeUSNTpkit2mxvBrkOrBcdFP7ee0wWAWErcCjgfbjAdqYq3f/d8h7kB9ZeRl0VEea+jUupU2YUagYLEW+uftuS2RCEeMSFRBaLgqw4eMBf1pfP+ob+Bzn3VskUyLByAu/u8FdvN8nRZgYusuthTtf9FOb6WG9RL1PXimPIh+9DxG5Epnv8RwUabalKNjGA0/NIOXSlANJ0vGZgMXTuh2cOcTgYO72OcRGN/tqUkC2Dhv7RwO+Nctz5U3PcOoJm+M5DYOx+ZqUACK2C7745pDEgLNWUqev8UkDR8gcHq/vhwvEeUHoGwqU20GF3m3m+STilUQZYIoMg9GrrGdw/AEuFlPKcfLxBkTfu79OLtwFPhOfv1lQPLQi7GO92Fvvkdvkj47H73hewdXzMo1XZJJlsC19jonHhq1VhpJ1NKbdbwAaep5qT0qmJ+ERwjhhl1fTFy439sa4Jmf4Zkr0TQVyOBTB27NSmqhuAiZ+ZuePUCc2H9fNZ55NmFMawaD8IPK23ptfnYfiTVZQ7YrKqdEf+kGyxACIV1t8jGvKGgzMrGbFOCJknbZumaQdmlylzkqawpXjTvfZ3gkwKqckEtfzniMzHp3Q6xm9vGgA35HlhYKyA0uR4I2cTC4JdQCP5tWtxr9PK2HaHDgRVdhOdLMNY0U7SIGsuo2plhz56Kv/xTewPepVTU3gGp+OKJkfMx5v2rF10/+qy9QDEuynUctuw20QFM4yaZ6JAbMs4v5pDtFl3GW3PnHL6K6uQWTacREYdMVUEtTZwJzE+g5qJ/KWZchsaXYxUQqvFZFewl6QfKDnHf9KxrZBbM2/C5v0+YRRv4x6SHBPgmFYOC+TwgZt8wfMFcK0yZrk3W8eMuHo3cq1tTCbLy+U2oCraiwy+oMdRkKQJDxvgfJyhLy+oB78LZGO5TScTkNdH/TbdT3QGDo80v/5anX9Eu9qG2uzgHEdag2p3fz95Vk2Bsj3h+3+i0jOCDS73dbqfnGf6O6YR11AI0lytLLETVPTpQ= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8871d6fe-8432-45e9-6332-08da79369a02 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2022 12:07:44.6844 (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: XmAzwJtmny3r6lvXwXZ8SQLdQewlH7mWKewSJvWqU0DLJ4izzkTY7J23XvZVzWWqY9EA/jGbWBxzGJj2YwXgvtL8AzEnY9iYkGfxj3QsKbQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5360 Received-SPF: pass client-ip=40.107.6.99; 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" Signed-off-by: Alexander Ivanov --- block/parallels.c | 76 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 23 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 108aa907b8..7b400ecdcc 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -413,6 +413,13 @@ static coroutine_fn int parallels_co_readv(BlockDriverState *bs, return ret; } +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 void parallels_check_unclean(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) @@ -431,6 +438,47 @@ 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; + int ret; + bool flush_bat = false; + + 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++; + flush_bat = true; + } + } + } + + if (flush_bat) { + ret = bdrv_co_pwrite_sync(bs->file, 0, s->header_size, s->header, 0); + if (ret < 0) { + res->check_errors++; + return ret; + } + } + + return 0; +} + static int coroutine_fn parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) @@ -439,7 +487,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) { @@ -451,6 +498,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 */ @@ -463,20 +515,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; - s->bat_bitmap[i] = 0; - res->corruptions_fixed++; - flush_bat = true; - continue; - } - } - res->bfi.allocated_clusters++; if (off > high_off) { high_off = off; @@ -489,14 +527,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } 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; From patchwork Mon Aug 8 12:07:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12938744 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 2E282C00140 for ; Mon, 8 Aug 2022 12:14:33 +0000 (UTC) Received: from localhost ([::1]:46558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL1eS-0003UT-8R for qemu-devel@archiver.kernel.org; Mon, 08 Aug 2022 08:14:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL1Y5-0003K2-Ct; Mon, 08 Aug 2022 08:07:58 -0400 Received: from mail-eopbgr60132.outbound.protection.outlook.com ([40.107.6.132]:10881 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 1oL1Y2-0001SH-Nf; Mon, 08 Aug 2022 08:07:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y5V5W8MK5I4OVDhMbgnNNXhk73UIi4Ej1wJgNMiCnOF12mwwRxwxjSH/LLwj1npUHDev69D5zQBwH53Xhou0K3SDMSQGRgVNfoCXoT2rZAcEeJbNkAnQbzQPNjGscAkGxCEXzkgqaGqtXUHafq74/u56BLgL6/jE41c2gWmmU5JmqNNe0TeB0renQllbQ6CWTIwTSxoKVUYMFP9Y5VGv4y0YmtoxgLc78IisDwk6AwElW673VCJc5rW8CaZnZSDvJaffZZH1pbEL/zb0m6bzI23U5t35cOnZ/vaw9lVmspescJmVNVBD3EzwSjyPOnOvuCFcxxSD3XmQLMHZFaTurw== 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=HFcDfmR1Qjj78VRcQ8IkoNuTq9DQzoWLtIV/LUSDprw=; b=KKSpYBzet6Z1ahEgXE9XDUaIT2oMGqaxGygI6r3NvHNYsDxDf0Dc8gDGiDSV3fYPuMPvgTgsiu58A449sw/lUo2K5UgY6oOHZyvpIu9p+KWIeo9e5kF0gPqOGsmQLS+B98pmgIaWVDh9qo5du8DS7fObbPrwZ0QC7yMq33MclV6R5JHWYJSlsj0tdnl/nNAAf9FBHmxvNTpsstsH4QI934QEpRkF6LvunPhn+yQbd4rBrj49C4O9XsTM0cXpj2Xs2b7H9uKn7sRTvpMpIfOQ+ImJJYi2x7x4yXo8jmG3EJk5cidz/5aN0pGyk5bv+5lhxkwTq93ruA4ApNeZ88QThw== 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=HFcDfmR1Qjj78VRcQ8IkoNuTq9DQzoWLtIV/LUSDprw=; b=CuujgKh/+MtwpJ34VsveFOKkr7o0JuFFaZJSBWVRKAqNoU9b+2jfZgSGETyd/dI4ZTmYmhESlzHKJtmfUKlyeek389n2SP/ZGNGIGrUkvik8GG1UcL5RTuUlSWORs1zbQt14a5jEezSW3wLTgPxDwJdr8VtkK2ryax69IboQBfStc+1zjJ52/T5v2dhzkYjphBPM8eeXsG4XW/7uK5BiQ29zpUipGItWNe9qYg4Rl1JDuZ6EUX30cmeGK94gqu01urPysq/b1PFIKSUgBHtRdE8ydQmZnmCT/8k/fSEA28mVUd3tvRdJOo0H2ANki/jz3pzdw2BSEziFHDHMRIumGQ== 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 VI1PR08MB5360.eurprd08.prod.outlook.com (2603:10a6:803:132::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Mon, 8 Aug 2022 12:07:45 +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.020; Mon, 8 Aug 2022 12:07:45 +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 3/9] parallels: Move check of leaks to a separate function Date: Mon, 8 Aug 2022 14:07:28 +0200 Message-Id: <20220808120734.1168314-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> References: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0042.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::13) 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: 3cc7d091-64ed-4cf4-8e37-08da79369a75 X-MS-TrafficTypeDiagnostic: VI1PR08MB5360:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tvYJ8I0zgXMYoPBzrtgnqz3musCqC0kL0sTWkhrw/Kuh5FfRETZTj3Xi3vSqJ0bBcZrsEXabhTqRVBOyVN/OpjQyK+o/pzf7PjyiCFs8iOdrm3//hROFG3KFMED4Yh0CnxwBIo6WuvMd2acJGQh4J3sPLLnrA1Rx75P8GNdyy41JNpDhEFUF0nR0TEnTrJiX8XoLAw3fwcJkt2sqO4LwV5VH/mPu1TCvWX2ciSJCf259/bbS3VZavp5M3yNiCyJ10p+JXDjAjnCa51XtPSN8RDCqaz4zOjx8J0iQX72YHu2UQ3H1KAyVra7cHdTREMk87ndbEmmCRuUnp43+DsG07CtTdj6cHSqdtdcv2czl9SkJw/zmqmRf3hRq/u8JoYy2M428canKooCejN18A0Xsr6vvB1aAB58Y7maEKwdUAsj1KXS+DNP3ugstgmNOBcuBlzdTZShuSvKBpH5TD85DtvBJyoAjLb//Yf1LYOrzZjqzgqq+66cEHeWEyy/dqRPKKgbV516UDkvFVETo/2M1BONMtaJjR6z0So/gvw7YgOa9hID2+oFU0yC50sQi90RU1Eezxg964NK8KceY2NTsGTv0JzGlvgEkdN3+pxiuBBQIIx+RMwxm31Q4Xp+/qpMkqR5BM8y7KCZ9L8qmYpawoN3oDYIzM2PkqaxxMiCsoyN9AD3I9kJSkkrHg/7g7GUDB6mGFJQHU8umjrkB4+XRoomZ+Hnm7dVQMK2z7d7rgKCl467prl0h95ZFaPUYgVnvaF9v6lihiBOlKdvpoOY43Z5ZKlNoU0nHgK8Buwp2B5w= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(366004)(376002)(39840400004)(136003)(346002)(66556008)(66476007)(8676002)(36756003)(4326008)(8936002)(186003)(1076003)(478600001)(316002)(6916009)(5660300002)(86362001)(66946007)(6486002)(41300700001)(52116002)(6512007)(26005)(83380400001)(6506007)(44832011)(2906002)(6666004)(38100700002)(2616005)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M7Ww9MQyLvP9jBVvCAr9aI7WT1DSJ94eDzHtAtzLBCNuO0pL+1PGJ0wxRw3D6a9J7umFBAZzGhtkyXMaa5aSOlfUMmOSYxcR0J6NS97YSs0ByWZn3RWJJIsd1NaiHHg9oYHzdi6/RQzPqe1AB8Y3e43GWQ7iqncRM6H3Lly5k1RR5S3T+gJXClzex9DmsTw2u5Yw7+uCfR4TQcPBxo+HHNVikY8/CDmlxlGimUetBf0mGrpWyzSRh0MDRQ8v7E6he2mch/hA8D3dk9GZwPUaiyphjl3AYng3qfobM3sWPQLbNXrjcHsE8Vstv5XyrU4qMK8SAUz8t8rgDc5d6esVPKoZFJlWCUMpMhGuR0WdKHW0qv2eN0lHiyIKX0DYo6OOt5bY6FYNrNR/3n75x+Ir4/rlBblcCarAGp8DyE+NcuJV3MIQk/I+7RfdOFWyJ5jZ8oxDiPctEDT4pGg0E6spxg6y855YfrhY7siYMb+WNQK7YycBPcX/wnawLy8psX/kRUzVLJRQJK9PZAzzNux4GS9qjAWnzbgSLQvSZGkehYUfiDMJbhuvmN/w0S2fi0uY8EN5KCWcH9ueHlDY0foV5GN8qoklNw2QzSOihhDtx6gGmAx009uCqPZw00sryUxl0CUAHq+yubkpCzkj4M1JSeMudViNOELT9ObtDXePpif0NhWn5cOi7v3gqcaHsc58iQLEO/SU9QlKbf4Z4UDYIUhzZWe6wAOR1Va+kNO+CBHm0GKmSqj08VfiyQ8EvN9e2mtaS6kqlqIhkKAAmXXnwFe94dBXWMzoqrWD26dntQkLesayNGfeiuvT4vkz45knBMoU3w7vUB/Hymg7SN7lrabcyt/dKyvl103nTiuVEp/d3hqEeuoqy2lvi/ymuoBy6bXdoiTljtJoqvYXDEwiosLrTTUrA/TY2+MPhgwz7dHf9ru7WbMF502b8amA5t4/Nle9BqUewh8dK1caE54QIZitNhJejfObDkUdPg8Mf40sfe3wiHWVINre5pe+XWlSHtQShAPx6v1JVplqhGAu8rPsZ3Jd7199cCFeMwbpKBIdR19KeE1g3u4x1NX22PoA26IQqyiHcMqVpSEfLuxdppo/6LfjL6sUzUJJuZm6Em9wnfzgbhvI7nSUxqMrE7XhSw9dD4tTalQ70vI6rw76UdJNnBQ+GgGcc4WU1SaXwl8LUnJ6pjiOotJLYXkoVRhr9uNmWsPl8CwS46yuYLq70Y9Q0aFBCyHMh4XEIHa+WwWUj2nJ7Ou//byQWuzixpk5ROVHngGRcGV5RGs2pEmgwxbIhapfnm2EppdARFwQSOiM2AxPFcxyugh2FjTqrXw57HXSqHTsb+tGF62poWkQPTyRgBuVJrApnQqfaGQqr5Hfz5MtgJn8SLWKYBDsJKlEpSu7a8W0KbG8pEa4CD2Fk4aKEFLPTCJ+LNu+EKHulTHmMCrKTzYceG93Mce5Mdmbl4QGTcjMf7jaFQ7briQCBmKYhfM8WUWFRB5YrilXvVgnsC31Q+RmWl+UzppNrOiFbFtoI5AChlz/4PW8T3CdxDQ8p0CWC/3USy36ufjTh2xZN+3UM76+jpPycyWtphXaG1CmjXIHed7FhDGjkIB9oA9qqvQam38G0iVWyJUUCq4= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3cc7d091-64ed-4cf4-8e37-08da79369a75 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2022 12:07:45.4030 (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: Adpe0hak9KOpQyTTBIEgVMSHHqZUVab6677itbIWXanLVGNgoDfXj0oN+meVPrX7GY7jCvW8Fwbdz8W+w/gamuc7YmqflRk3goWLRl0jvRY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5360 Received-SPF: pass client-ip=40.107.6.132; 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" Signed-off-by: Alexander Ivanov --- block/parallels.c | 96 ++++++++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 38 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 7b400ecdcc..6d4cfb738b 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -479,57 +479,31 @@ 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; - - size = bdrv_getlength(bs->file->bs); - if (size < 0) { - res->check_errors++; - return size; - } - - qemu_co_mutex_lock(&s->lock); - - parallels_check_unclean(bs, res, fix); - - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } - - res->bfi.total_clusters = s->bat_size; - res->bfi.compressed_clusters = 0; /* compression is not supported */ + int64_t off, high_off, size, count; + int ret; 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; + size = bdrv_getlength(bs->file->bs); + if (size < 0) { + res->check_errors++; + return size; } - ret = 0; 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", @@ -547,12 +521,58 @@ 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; + } + + ret = 0; out: qemu_co_mutex_unlock(&s->lock); return ret; From patchwork Mon Aug 8 12:07:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12938747 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 9C2DBC00140 for ; Mon, 8 Aug 2022 12:19:13 +0000 (UTC) Received: from localhost ([::1]:52436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL1iy-0007bb-Ni for qemu-devel@archiver.kernel.org; Mon, 08 Aug 2022 08:19:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL1Y7-0003Nc-Lf; Mon, 08 Aug 2022 08:07:59 -0400 Received: from mail-eopbgr60132.outbound.protection.outlook.com ([40.107.6.132]:10881 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 1oL1Y5-0001SH-Vd; Mon, 08 Aug 2022 08:07:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h32o2RbX/CqASk4hIqdZJ1zIyczOfflfa21M99ebqHJg4UlGe9e3Hus1e5lv47ivxLWnAfWR80I1GL+WRIEgKBbXbIdGMjRkiIPTQHwsCzsGxfRPqq+9rwKIIPOM7qst7CGWeNHZHT8MwggQjyXjPX+PrqvMAx23FaXF1OUaBiF2JAiHZrK+1Am2F077ofmDpVbW7PPpUBQJgfM8KccpRgLEZTMQ5fOQ6MIjYic7qIfo/hXFIa3gxnlhA3x3YfkVUy0P88JnAmGfkU4jXWwSYqEI+PcUMC097BoyQzNCXshQ8laMINwu5Cy7KcTRltjISSlrumdgjWePqQCEWUhxgw== 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=k6siispsn1GEgvaRc3ICIsefMQJFnkwN6SydQ81DXgc=; b=jQ1gzpLz2CMihNr4lYAO7quoD0Ce3C44XkIVe6c8ThO1le1iB2RfCpfGCTfVEQHR14WFDH5FmXCNH/rgkTJHcdHdmbA+jb5dDK7GeZKWFQWq56dKeFlcQviN6fGprcsi2wb2Cqm3NgoYdpBFAP/qbjd6lrpglilNtG7pNIdA/zpSwnaajd4G3BFUi02/zJiQUNcJV950Z1QLXLs71YHFX0JWnkTlItaAFDP4JdQkjdfJ6cbnXtWY8jRfdhFzJfFCoSbWBRRbUVobjvroo8bixxZnNp9VNhmMSGeZZsXwSO2GbgG+EiJwqaK6vHamhvT3t1rufucedMOzdD8Wnzp8EQ== 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=k6siispsn1GEgvaRc3ICIsefMQJFnkwN6SydQ81DXgc=; b=cD5HS2S7lYSr9yp+EedOhfMBFM7pAUuj4Z+brOtQrE8yX0GWE/oT8puDOBef8RTHH0wYERfmVOIk/KeQycUMOqTyBEZKtHMX2GTULVPtgr4xAIU9lXXa/MZ11TvPPxmtcjIDqu+3Qt6WeebkINOa9aTrinnASYPLubL0zkmbR6NOodhsLOxURz3KDNMmb/MZV5E4l6CT/CfgtIy8td/VXm+//v95t7eSXaaCVoCgFdrM77UUM7OMsPR6ZcHi8FG+5lLPJ0SVZ/nWjOKyedzNBzzC89b8Tf7wAsq8qNQDcp8SWUFGas61S5upmR92T6L35k03OCi8Tw0TKEFMWZXhOQ== 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 VI1PR08MB5360.eurprd08.prod.outlook.com (2603:10a6:803:132::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Mon, 8 Aug 2022 12:07:46 +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.020; Mon, 8 Aug 2022 12:07:46 +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 4/9] parallels: Move check of fragmentation to a separate function Date: Mon, 8 Aug 2022 14:07:29 +0200 Message-Id: <20220808120734.1168314-5-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> References: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0042.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::13) 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: ffb384be-2841-4964-dd8f-08da79369ae0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5360:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aqOFIzOjIBabyoKBcP3fb7sj7idpr+N1ApCqP1u/ibOe9hzk2IAKFIJmngROLQJCKNYetehRGqqprCQZBxwhzk82gwM9wyohvA4f9mbv8v+hNDlXbv6DLRbFuWDCFV6ZEkRwjLPxb599CFLnBgDlLSMt83hgPAZ4+9apzuAXIuz9LwrHdWkJGSs5O+lgYRN0d1exWUkdpGSsE5adyynAfJqPU5hv/ercHfy6Du4zZK9a31JZ0h6hJ6Xg8rlP144d/QBYr+u+Z2xKEWIO1C7XXhwKuOMp8bppUv2Orums3qmT12A4731fKEkwxaVgLwzXJb4YF1g0ZxrvDtcXkVGdPuQM/q4i2pSD1DogfY/+2Eg6KuT4Nevg2v4sR5EyPI8Q7DAu1VOHjO60aoAEzJjiPfGRlbUsXH4Ew2vlZVVOGFHs6fq5FJAhNhYZkvAKSRgLxSw8vsn3Jfi411Kx5rtHrJSKZcd0D12dRbgZEbfqxtoe4rrYME2XzvMAPi3g+kVKZBkD+X5v+tM//tJpteQpl1uLgHLeMW7gJ9Y5WQ+7dNrKs9Nshjxr/JN/nlLfD99CSd0AfeP6FXWXhDHkmvjPKRcxujN1eD6HZWRF0zIffkOdato+UrzGOxmZPtI6ynuiq1JI0QJ9lub1FeKCZBw0v7nPZp6tUYs0PwQIOJ0TjWI4AGp8E82Mza67S9M33QVhopvdM6VsqnAJ2Gg3B3H2GwiT1/cYw7vyYQoH9rbxzbUJ32ekpWUE5NmF2Fpu7a+rEca67B40KWBhxExmtvRaw7LieWzJpEZP5JG6gxDiXg8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(366004)(376002)(39840400004)(136003)(346002)(66556008)(66476007)(8676002)(36756003)(4326008)(8936002)(186003)(1076003)(478600001)(316002)(6916009)(5660300002)(86362001)(66946007)(6486002)(41300700001)(52116002)(6512007)(26005)(83380400001)(6506007)(44832011)(2906002)(6666004)(38100700002)(2616005)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ada8Cad8W55FPUF/CHes2kAoBvQ6OJTFpw14CbP0D+eleBJa0JrXVW3dSrqooukf5ZQlZTzroOtktyoMupMHP5Tsi/DGLNL18Gaja0J/li1aw5Bfiblu4Lw/J3p5bQINnYKbma8GjiekofBLJ4NTbOqqb46HBpxRsQBeaoa72uESfLsaThe6U/6NKdhgK0xA7yQyAM8tagFB+hP89PeMXF+Ss+77hVTW3JH0xV5EeYbEwvUKDYZ04Xv5VlaBs9avO/3k2KGb5ZEnJKtrK/Sc2zegkoxAKENmAp41RgYum9CKjwN9BrujUglN8PqTVcceZYLr/ClBAEQykwGRLV1C+6dhet75XnN4x1X5sXjYjiYzcCIOkluJG/48FwEmOrPK9UiNO+5KxYP2Q8yi/cNmyH8tPUmTqZa0Zyg3xNdaS0ey8/qu1F6j2XndmiMXoMh4zpQizJBhiMwQ951317frZcLxykYMkYgX9R5eswoBnbIxbt9kf9XM5U4ZVPb9/vzDOnq0S3AzuZW7uifyNj+KLQxApEIBtKqJ6HfVs4cKWTahiW0AyTCr6X6fsi4+aPA+tpOux3j0GCP6xZmeLLIWhuv7xCB4ZXqYBhrKbEQuBbo+JOJNrj4CHRkm9v9RoUNGWXshZODYCI3zxizCSJ3Prb1K4YOw4Jo5ddE5+IqdF0j+6X2uaOlkAmiJAFHOEg9O1zJ60UiQBxgTXGbq3K4UoZ4G3LPTU4gRfBwXFPybc9BDk8Y59s/Cn+5AOJfH0/rjMEiMVBptEtBE45ShUmkIjQUZFTwFJU/shu2554tfwKTYN8pLQEVBWFkIYLTkEdMB4alqaI3gPtYgL7IvBJHbTBCQ5PnW/AMhniDFiFp8HECESG5PYhlKcWwsI7WBV42YJiZbV2hZ1IMzPBemW6lxsOMaOMAEdife4Rt6A4CWx7s48uR/hvDRbzikIESkLKrEeC7nIp+alicBIwTvgsFjEwswtsdCp5ZRVbzgip3K37+9FXNnXH0HMmFUOpvhDJaQupWlWlH0ci4cg4J7VBEAOi8tjpMD5LKLqENwpm91sFL6kwJHZi4ca8JbGCQ+ug7nwI8uyAvahHCxrNEECsk7ZlhTR2unvS3J3vs2TThFjcMaMBiKThZyxMvIcsZwOcsU3PGaNgTY17gnAUScDSZa0lGMAtWXmPEdQ/7SAtDn/PuLID+Doa5NNel34LMyBoknzRonU3SOFhjcMjxtR7mXOLcVK5ox59Kj378u9XKWeA96T491qCelwi/vqx9a8LFXBGBhU23I7mzzuT+RZLBN71NO2uiHUOPbwLlj3Fy4nzrtL0joNWFy/gKRYDY/vv0sdyA35ti+oStuyf/CvVZFJqha6sHyIbA9Be0cWCp+b2cWdwrFVMgCa9XsavqNPOpur5k2C+dGA7CunDM4BZ+/Fy3/E1accoc2JacAxsZQuzy6feHxPi1sQNKWByzi/JS1IPWwTzdeLSkRjuU5X4D30y+MJ/ISDxCa5wPzD7NyrKpiFwaCd7eKEK+0i7urnQiM+ZsevJ4u1jw0oSmgcVxeFbrlPVJ1zk/vsVhLsaep2wBHHPpzhSVKAbPv5f+ZFjHsd2W7ouqChbs55zIUhTDY0bRWFOT9/vFVL95MjSYYJIc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ffb384be-2841-4964-dd8f-08da79369ae0 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2022 12:07:46.1063 (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: rC8cpREd8suiRYzRBqCLwFINGRXk95nBgrgtMNmOdVJ0DdkNngsAjM0D2nI3N5rmVt9i7by4HTupMcOpGkjosM+7Tn+ox30vWQozXIirKoo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5360 Received-SPF: pass client-ip=40.107.6.132; 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" Signed-off-by: Alexander Ivanov --- block/parallels.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 6d4cfb738b..0edbb812dd 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -530,12 +530,34 @@ static int parallels_check_leak(BlockDriverState *bs, return 0; } +static void parallels_check_fragmentation(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + uint32_t i; + int64_t off, prev_off; + + prev_off = 0; + for (i = 0; i < s->bat_size; i++) { + off = bat2sect(s, i) << BDRV_SECTOR_BITS; + if (off == 0) { + prev_off = 0; + continue; + } + if (prev_off != 0 && (prev_off + s->cluster_size) != off) { + res->bfi.fragmented_clusters++; + } + prev_off = off; + } + +} + 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; @@ -553,23 +575,13 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, goto out; } + parallels_check_fragmentation(bs, res, fix); + 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; } ret = 0; From patchwork Mon Aug 8 12:07:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12938751 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 5E141C00140 for ; Mon, 8 Aug 2022 12:23:35 +0000 (UTC) Received: from localhost ([::1]:59836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL1nC-0004HR-DA for qemu-devel@archiver.kernel.org; Mon, 08 Aug 2022 08:23:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL1Y9-0003U6-IK; Mon, 08 Aug 2022 08:08:01 -0400 Received: from mail-eopbgr60099.outbound.protection.outlook.com ([40.107.6.99]:57061 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 1oL1Y7-0001TS-M5; Mon, 08 Aug 2022 08:08:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k6aQji5stGlwfihfKILtp+L6YtQ8YjtDvcyW9BcOvfgF1zJ3rHbVDGqYJtLOAXBtPHn4RKd4taSfBAxGPQgExlJYSCrqaGb9eoPtMcrijn+b2hxHrGAq6NxRtJNCAzQbw10psSeCKWw/54lllzCZe48SmlGt28a1gL3JOuvzh/mySMljiTN1Hzo6OsKkzALoJ9f5mUbYXPNg5S9L9AIOW4jBfDO/qdjJ4Dcxo4IFMxFmLQqKWEIMW6o9vSTd4n6amu7TFKnFYjKNEacWh8eLwr+pQ6IFiPYuUXuljWhKINluJwQNYPrzPqI+hmaRMgRjFJkZnh79JG8kqeibVHy4Mw== 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=9kkBbvM6Bd4jjGVn7oT9aQjamzY+He1u2YUCafs1kpk=; b=K7sOrXOSAWdYH8k5TwZjOJopEMK9omvQAh83H99gG5IAI83f2xG46d6XwDthZrX3/6AYV9BalDI0BFGerZ+EQGUSJVQcMEV1UqGKevYjVM7fxPHYIZorM+IkQ21vxbZCdbXSO6X3xUEXp5jZD+Ga0OQ1GLgns/SRnEToKr+6VH8AP7ApI8hfZtOMVxnHTllkCF49hq0cxokPXjx2SlyDE6I03XsIpRK3YPaEfhPyY8HUxnZeg5n6HWnmR2oSgW6a5LatoEJ2/K+ECVi4ZUplWK8xmcIASif4XJFOVfTXcdnfg5guspStUism4mk1ytagbTaFu8C/jdm97JkaCzVT5w== 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=9kkBbvM6Bd4jjGVn7oT9aQjamzY+He1u2YUCafs1kpk=; b=htGSOjSYqy6DVdp6GhVjsT4LeToa8KQFWTXdEodjdqtIVSedJZ9G7CXxTrIR/6PM1leLrY5vgjuEMfUCkU0yNWhWfjdkopxcrHXd/d3JjuKXagPrZhJksYT318FcHGlRmMgvS/ggiP0mud3oPh/kDT7hzLcYxbxeZt1OTXzITXuyT/46onyIm3iMaNasFJzfqrBD9dNH9y+kIGHMf3Hi+NOvEjXGpTF8MBzgDEk0oRq7pFnQptBIq3MfagOuw26UM2ydoSbq5EoJq5iKwhceGdDTQyxtDFy4l1a1Z1v63inaKKywpw8DW+Ze/g8ERrbKiSu9nN/Q2I7XYdgwO9iCwA== 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 VI1PR08MB5360.eurprd08.prod.outlook.com (2603:10a6:803:132::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Mon, 8 Aug 2022 12:07:46 +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.020; Mon, 8 Aug 2022 12:07:46 +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 5/9] parallels: Move statistic collection to a separate function Date: Mon, 8 Aug 2022 14:07:30 +0200 Message-Id: <20220808120734.1168314-6-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> References: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0042.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::13) 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: a3c9de7f-098c-46bf-84bb-08da79369b4e X-MS-TrafficTypeDiagnostic: VI1PR08MB5360:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oy4lEBtwhWKePoBejnS1uJKLL9zmi0jhW5A0PKUeefc0lomDqJUNgrXgOh8Z4Ib5zCiMTQgdfnHaRI8RUoKAAWx8EIUfmgGShuPvdlainAOHZ/CerRWQgJMZOBzOPvU4LS2xtYklZFx1OJLgTqV4ujs3Trb1xH+GSZvbx1IJ9eBYk4QHMBqJ5PykDZ91dBTMraDa6guNbZp2epgS4U7tQbY+G8MVcdl75TFvOeUeCh1V7qmwnlsgZnSWt+UNGzNCFrkQwYEJ94gk9ctjA4b9vkt7juQqJK3qnvVbH+bZUP0NJ6eutCOLKrKUHtMmW9OrLHYr1HtqxU/bAovCPcvkpcuz39IfuDjAeBlBCYn+Y43ZuuAnUwz+S0hFN8nQ6jAC1IQ3GMrvwHOpQFY4vNzye+xWeuLwyIUGCGwTO144QdAOJpF3LNz75BiOSsKwuz0Tc4NU+iHSUwqd9EfUjeftqr2GaoHlUedFUEUln0ehJcuY/qo52fGSfS7LXCHTDeXRHBJF/AygSAM06n9Nqm3FMctnwIk3ZsXyUiuhwuFGV1gR1olrCV4qK7SpfyNhJ6iyTfk/ViNsewE3jHmyH5GDEH6NEncxcEXbCa6gFVNqfPUxWjn8mzHZ0P/dgRqUej0x08agiLSdm40V832vDyVrAo03grWk7SrrTvT/0WHX4692S89hAQStuglerwhDtNIZJ1MvLHyA3RbT6oKBJQGCK252e7ik4/jG0gGNjheEA/XmvfcDuOVLWwGTxYR0zpxpH3R7Z+lmZdmstTB5hMHH5NR1zviwnECRVsMhUDhodZk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(366004)(376002)(39840400004)(136003)(346002)(66556008)(66476007)(8676002)(36756003)(4326008)(8936002)(186003)(1076003)(478600001)(316002)(6916009)(5660300002)(86362001)(66946007)(6486002)(41300700001)(52116002)(6512007)(26005)(83380400001)(6506007)(44832011)(2906002)(6666004)(38100700002)(2616005)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: H1iFDmoevvTLNuOaURkTtILEIR87sXE91C5yOo8fzZ3DnwI0/nm+RZ/wX5IdhEfFJFs70uqAWo0P5sDGGTGjs+tWfb3nLMoKHcCFZDdZStFDnIzn8VgDw10OaVX7+xZQRGfccB9n7sH/m6k7C72O24whRsV75Tykp4HjSTtOxO+EKuaOyzpUHfCuNXUA4gcvcn30oX9ArFIA6yTHLaJlocwPPZC5SR9W5AWXsWbyCt1rf8nrVgoY+PTb3HLkz3rfLMinrWxpqosVJrGycTk9d7gk891/uLjhIsLZp6ubveIBac5Tj7aLrzPufzQzl8qGC1E4EZ73jPFoy11u5uOn5oR7YB3SL11yH47TXuvsKrsE0cYnS41W8RoF0T4uOLDesyH07Kclhq6keJQJBWFqWhunAYBG1rJYMkN/08NE5UZUdc8SyXQzhUZypZ949adNgXSozH7mJw8PcaDiaX+w68ORx55fcxssndeX/GKi5ci+3Sz0MiDfJ6wScXsYGJSfgK4FMCiHv7Ky+Ggm2gpIgrrLbdoS4rVQE6KRj5rLTTXhLhfZfPG+0aHHQHgU5xHXgIytGnJ8D2SVS7H1Bi1U3jvkYBRzfS4CJL1y5zvm8jdVm4iFCGlUJuPrzdgEglgahzCMc9zKDZkag0sHRWEom25TiDlPTggh7apciJqEs2TRyHJHkIpnflhkRx2i2U6vmaFiQRTjYJFnLtutXhma2mb3ElQ05NPtjy0yx6nnm5xJiF4sv0lTo3cCDiICaYtjQfixEUzyP99gGdXDSDdq4DFY3XZM9gz3P92/9PcqeVBxFPbZ9t0+vKsVbB1sAjZ3OChb/Bb5SUUgvs9pVd/M8/1SLP0PmVFwd1NdOX9n4zXotm6n8pzh90gsldimX9ykY6n/ix7GXbf4Tip3dyLGhNxX87/7uzuD519EAIEKdmfkrpr9R3uuZa+ARV/rYZRK061ho/3sJpdPI27rCtA5OadBwYokcEJxHdNDDCvERBO2cGFXD/pPrsiH35obZ+TLxGWkSy2G02YyDlvutHjPIlQuI2eEsJmySmM+OFgOzBgiJgSjquRVE3sP72JJA+fqfF0xdzdDfWqcboCeG6RbJnMmbjGjK7K18sra8guUfCA1PwV/5vKSMvquXYXBoeGGSMtZeAieEc3JRIhgs38WJD5j8D0BrGIihKfIxKdRv2K1Nkr7aE+7iqmMa0D0zh1qq+DZFH4pf63V/E5sLNwSzNRKdg5eNyVyRYhTII8jNrpHexp4ONOztjhWfSCUy8XjoPG8aVP/76NIquc2tPx04dvvVg2lxhIEaiF59p3n6U0YrIXRxd68EvyUo/W4oWyU/4BRYYdI1DJCPTITAFxO8cX1sCzCaLJ1qT54GgpBCHmHo4gBVfeQHclv6r54I+bxtsuhFhyFDjgLu+3XD2J0/N1/ha2aK+Ri0ulm5uqnRfFj43vy92TspXWSn0+OPfwqiRA2IhQyHSLBUCb0J+HQP0ur/cuq2Vr67O0GWgzHxfvhTAMC/EQ7WAlE+SSYgTOTHygFuIDqY8B45SEa4jj6bYNtJEUoHci8ILnBzYpHv8LASKg1jYwpa4YHa769XWtdGhPjSz89lFvngYgZILBed3sjHzwv/qBrRLQjfaAHwT4= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a3c9de7f-098c-46bf-84bb-08da79369b4e X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2022 12:07:46.8249 (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: gIFdv8CXYY4fcQLmjX+actK3WIk8LGuWhLRWkd4sFjt9PBQnyov209LF+q+wJR+JlHhll+fZHV3764qjxmOCutl0bkHX/UjdKSB7+Ni2v7g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5360 Received-SPF: pass client-ip=40.107.6.99; 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" Signed-off-by: Alexander Ivanov --- block/parallels.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 0edbb812dd..b0982d60d0 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -553,13 +553,29 @@ static void parallels_check_fragmentation(BlockDriverState *bs, } +static void parallels_collect_statistics(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + uint32_t i; + + res->bfi.total_clusters = s->bat_size; + res->bfi.compressed_clusters = 0; /* compression is not supported */ + + for (i = 0; i < s->bat_size; i++) { + if (bat2sect(s, i) != 0) { + res->bfi.allocated_clusters++; + } + } +} + static int coroutine_fn parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; int ret; - uint32_t i; qemu_co_mutex_lock(&s->lock); @@ -577,12 +593,7 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, parallels_check_fragmentation(bs, res, fix); - res->bfi.total_clusters = s->bat_size; - res->bfi.compressed_clusters = 0; /* compression is not supported */ - - for (i = 0; i < s->bat_size; i++) { - res->bfi.allocated_clusters++; - } + parallels_collect_statistics(bs, res, fix); ret = 0; out: From patchwork Mon Aug 8 12:07:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12938754 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 A2C06C25B0C for ; Mon, 8 Aug 2022 12:28:19 +0000 (UTC) Received: from localhost ([::1]:38440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL1rm-0000Zm-KD for qemu-devel@archiver.kernel.org; Mon, 08 Aug 2022 08:28:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL1YA-0003Yu-P2; Mon, 08 Aug 2022 08:08:02 -0400 Received: from mail-eopbgr60132.outbound.protection.outlook.com ([40.107.6.132]:10881 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 1oL1Y9-0001SH-2t; Mon, 08 Aug 2022 08:08:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bllFbtdUU1BziVv/n1aAPpXO77gtSjPRaBF/6dAhBrgUOArpM/skw70F0bHq5lXJT857RwRqkz/bFGnz5ON2Qz+zHCFNbuIPXgMuvnAKhfKudAxfGgPgUDuiHvps9arDYs3E6UA5ux4/7prFnIT0ocgzPVjisLgGm845Xghv5yTldE84BVJoX6mT0+Idn166RQoBZ00BmqAXv9/S/XvEbuIY2RciyggG8K75mEZK8YHLA9aCsabkYy7+k5yihmikoD5wedcuvBXZXqitDGp96JJZpJvf+m8JcpxNPNDM7FzuI8L3DcONI8rKao6iYJyhMD7KMi+2m/dCkAMalLmGvg== 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=lg3w4pQOvSjLZ+uKSta0My8qpBcODSKEG3aNIExn7XY=; b=CLnWu+n4jtAAyX/C8XmFY08eYV7dqCTBWtobo/jc0VBwqjpJDXk+hhHUzIXRL4M1VKkT9dQhmMOXCXz+zOQxxFah6hUOSIq6bksuPQPs44MfQkv6QTbIvn3mJHFJcox7vJxTryMn4Tz16R0v5f/UhQvGyo3PxV0JbAjyp+9YnajAdeOzfC7Pdv4JL48j6PMQmNo11lMoOyms8MBdH9Z5wvEM6KH9JTXILbhilKDulOePDOp4IJGfELM6u4Eza/jIhGSm2uAFsx1Em+wBMWqmqAqeLZc2eRV9bVZuouPOSufI1MzOO0VYvjrQ1kpdgbNB2COg7eXWhKJXeMxjnR5sBQ== 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=lg3w4pQOvSjLZ+uKSta0My8qpBcODSKEG3aNIExn7XY=; b=qIZPZoMavMi21eIt3BTrF6bGfvuN8i7+hKRETwBRJAbN93xfir95SDHpz7lCKMWMtv6KqTeZuJOW2WbT56K6KAJcmNKRvFt1cQkBFb5zfeoC42XRq/gp24gJ+nWarN5fz091iXVUNeBpAWmts4RA4lIpgTh+ATq6latYlreCQQWPvb5y3KF+xxw5kLH2bCI8k9fjbtcUhk0KZtatB32FngRt4cjI7Mb/MIR80dLqwDxEt6BRGqkXmVgvMgWXJRI9Kpx/yTGlySUiKowcPiJzd5ho+CuCTWRUCKMoZHBN722oBhlxkOpslmn0wXEcjt2Up3AgH3oWRqJr3Ei12Kctwg== 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 VI1PR08MB5360.eurprd08.prod.outlook.com (2603:10a6:803:132::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Mon, 8 Aug 2022 12:07:47 +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.020; Mon, 8 Aug 2022 12:07:47 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 6/9] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD Date: Mon, 8 Aug 2022 14:07:31 +0200 Message-Id: <20220808120734.1168314-7-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> References: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0042.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::13) 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: b54ef5cb-8c72-4136-c6c5-08da79369bd8 X-MS-TrafficTypeDiagnostic: VI1PR08MB5360:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0f2vvqGIuNaTiZPgPQW36bz2OxU9nvzS78AL/Cw6BWGGNXxHdu1ipPMI4g24Bh+3tJe02PbntRwA8mbDTPJUR+siyuO8ZS6H6ZwLU228h0oQO9vdb3tTegEVlVFz/sQu1bLU3WnnkhiFs/iuUTaT9YKYioaySJ0fmUKHtOsI139KCS97eW9GjxQFEBTfRg3dj4G6bZJjSbVaEpaAeVOhY6HQj1VQMNKQoSZIwyXkFT4JQsYziZUjDz/y7cQwspeR0t40XHNIc9EvBcyVnJaNmIHkLtIQAvVVzVmrBiis37687tXtJ9H95abDK406d80Ae8r+8njLzjQTp2Kb+Dybbx2XysdoIfsEFMx/ifY0qEysh/WWeoTbRA9/Rq+D/xJQFGAOia0TRzO6EPdCn3rsvnmwG2VwTMMlXUsWljaFFEGLz2SZNjW13Xsyj/8DH/WoGZW9KS+6fzGZ48rvcaRjcdYYRvVEyn+zEJ+Kk9xwmtIMcPCTUxiBI/qenHJ+KbHpv7h1pvgjx6K8Eque9u/6ZulTSUD+WicwVXINs0FJPNDODF0BYSzDGzMGBT31S33H2rnuTVGxgpVutRVUQ9ubYvghDrSPQdCEKFCosN0citi9o6XuQuXNERCF5fsIpVtLFbKfJkmUqrDqitqN4vIJZggAN2lwZ96N8LXWMsaCD4bnl1TajBCh7RAqTLwomocFUJdhCMFdrMMncwyWeQFLHQvqUHTXrd5QHjQWpS9vlr21LFTJysYiazeiG7pIw2gISYGBavT8HLmqE37FUK5Ra+4qjRGy6Vs/7Ml+zXmqPJQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(366004)(376002)(39840400004)(136003)(346002)(66556008)(66476007)(8676002)(36756003)(4326008)(8936002)(186003)(1076003)(478600001)(316002)(6916009)(5660300002)(86362001)(66946007)(6486002)(4744005)(41300700001)(52116002)(6512007)(26005)(83380400001)(6506007)(44832011)(2906002)(6666004)(38100700002)(2616005)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qJJdPc6VQf/VQZyM1w3kzvo1ZAXZ5QS28/Nk8hq2udMPCDC+aFpWJiKZ0NSkYCO3TchXLRAI9JQh05fcQpqu8hpjsVTJfaxqVue4c3IKNYn5uVgp+AisII2hdDQB9+AqgCtEajEcchwp61A9/5+mbEQ+JrHTo8di44zb9MjBc2u19jESgUuKU9/oPdhrNCuWJfDQLw4IAxiE5NkZBCbUl2EJ1zdAPvC3J5IEMYbxnw1YVmIlir9Gtjmg0AZ5zHwJ8omr1Juz0AJDTd2pXyeaOjbLiksQaYLUFYGuq7h23ObLt2c3n921Xscgze79vqA/35yo/Cb5wdAsPjYVHhATH4zSZOlejiF5dr1Q0MuaYGgB5ECXk20O3s5lBeKa/Nse6rgnRwSpJ3w3DLragYAzYcgH7VOJS4QQ8MFVFAFPemFAXcS7YFrS+EGZlL6a6LFOFA5av6wF81gKFrcSsDHZiTEFJkdAJUUSM+GENavd/t4KAt+iLiPPBXd+bdPzGP3OGVKNAiUd1QaEc6g9r/r8fX4f4yM9haWVtv/Q4aD2dCFrtFQFvXGDA4jbAoaYJyDhslGMqzwBMDJDsLXrXfcK1I3dkVbo4s1oYl7VjpLRmHleML1sfeJzQGWMxpj8E6NyQk1zECn13DcDCh0saqVlTfpcdA5eqoTghbsou4xzQxuekYfOefaH/dWpYlMhIgR0kmu4FmStbV8J0+bxuD/ObskjTqmmpLOn6NYq+Q8yR/rHK1R5+X9ZX+R10rXRr1Uh1AHKVjYncRrnQq2B3EUHibsXb+8Me4mOtCpJ6lC7slUU02ehIt59Sj2lO+m//bM8nZHsynXqU8GcK+rlqX0JaIwj0SLC/7MUi0s/kh4I50kmxCZpq/iHPcHk/PqBat4DXADokuMxNlSszX/khRJjhTTZU//xJQQhZmuFb+LPkinIu/HiuvKUTmbcqTX3XrpQcGULooz0WNJzgmRjbgbqpxguqIH5C9r9JAP2+BoqMS0NhjsMDZknjekDSLQfeFjrl8VbYvTb5mRh6ovAl6O433fLjk9JgF6S45BRTGwKazDHk2tVGCfkJc3R7+yWihCKHkX3cGOBJfu4VjNrQEODlZWUxWDiJ+PQoYKBPwqFWPAPXdEfrvTLYBSR4V9Aysv7AxAy08eAAye/ecyhDyaDFK8hEfJ/UkUQ4Di/Q7mrzTpVVsNPha4NAbRy/VjXQeE866a3g/GQoA5IMW6YFFGQsp1x7V/9eeSJsIAnzCUsgdLm6BoeVQ7ZyhgHZlK/mSeHW9Mfa0QkTDMBCUtYLGk3chh0SVX6rQ/h5WjAK20tRUgYtO7BXCJMgyEkyqLNBYsab2b/W9yT2DlLva4agV4p76BJ2DnsAjxbdUi7YWPkCBN/Ra7IhkZyQ3Mg1XbeDdMtO/6CWu5UWvr7AW0DkzG8yIdXT1Cpj6e73zfTnVCe6Fh36ScJvCZnxKGjFxoQH40n+x3ERmO9k3zeYV9rnG9XZDj6yd/ZJ+zjbnoXqzWPr7xj1Qh/Xc7xl+lSz06C31vGIfLh2ZOmugl16BFMu8gEuGIWvgz9wbQpqhNxcakAkWMi+AMuK4r4IkXflEZVwvE91tyYnYiG4GdNoMjDJJr4BPoXGW5ZPfZNjHaw+K0FPgo= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b54ef5cb-8c72-4136-c6c5-08da79369bd8 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2022 12:07:47.7635 (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: ZUbKcqFmPKaJPILpL4sD3AUNJxGxNQM5aXKuAaUR+0LzkFGpB01R5cbX875Hw53NsoTwLCVpXz1WriFp8VGYi9AlasReag0BS2k2gWNY4pM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5360 Received-SPF: pass client-ip=40.107.6.132; 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" Replace the way that we use mutex in parallels_co_check() for more clean code. Signed-off-by: Alexander Ivanov --- block/parallels.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index b0982d60d0..3cb5452613 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -577,28 +577,25 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, BDRVParallelsState *s = bs->opaque; int ret; - qemu_co_mutex_lock(&s->lock); + WITH_QEMU_LOCK_GUARD(&s->lock); parallels_check_unclean(bs, res, fix); ret = parallels_check_outside_image(bs, res, fix); if (ret < 0) { - goto out; + return ret; } ret = parallels_check_leak(bs, res, fix); if (ret < 0) { - goto out; + return ret; } parallels_check_fragmentation(bs, res, fix); parallels_collect_statistics(bs, res, fix); - ret = 0; -out: - qemu_co_mutex_unlock(&s->lock); - return ret; + return 0; } From patchwork Mon Aug 8 12:07:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12938743 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 E16BCC00140 for ; Mon, 8 Aug 2022 12:13:03 +0000 (UTC) Received: from localhost ([::1]:41848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL1d0-0000Hq-Sh for qemu-devel@archiver.kernel.org; Mon, 08 Aug 2022 08:13:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL1YB-0003bA-JT; Mon, 08 Aug 2022 08:08:04 -0400 Received: from mail-eopbgr60099.outbound.protection.outlook.com ([40.107.6.99]:57061 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 1oL1Y9-0001TS-Rx; Mon, 08 Aug 2022 08:08:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K8LTNPzBCVEWyQHzPc2DVm/2Jlh91qKDQq3tCUU4YyMy5vEs8cZ2kWYlQMwpmU1PJl8Wi3l3sZ3XBTJ5plNPJuhgKIjhNy/rqufNR2AsAFuLPLjd5CoPBCdEUmvObVLUJQ4JGbKwIusYWh3SifVQthPv8mhjkVm1RzrXi9+OzYr/kcbyj1ag0+ZMAplxKHm7x5Ev9a3RSTRo/6jD6Nl6oRbePLg2JbnvQ+kB6mEgz1V02MhY8Kel+l0EV3cw935j8YQjOqv+DY17aof8YEyr8eiBWet8UdQtvVn2SHgbReVLznLc6EHqF6yriD49aBZ+KYwiLE1S2+ytfam6pC6qzA== 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=HG2KlUBcp1uC024PFTKjBzFPV5NG6VwXF9hqlxzj/jA=; b=RzxaA9/xqQsKTAOZBsSAZZfiH0O9EbBcIh6sEFyPpXo3uK0nm/qyRBvwz6y0HMv9fk3nubgsjxrgz1/m5dEOX6G9ExJybhy+7Fw2NGfTNUEg4HAz7Rj7HfvjaoK9RpumP91DrmC0HMtsJ1gh0gPS9w0dLk+qTMvrEXLcf5x4D3bx8vX4XZtST3s9YD11Gt9eCIIPHEfsMc0L/f0jraLooyFfiUYnHimo7uFmIStD6d/aWtTD4Rmm9/VN52C63Fj0VowL1IlXWeMIxoXg1Tvh7DzLO7Yoxi6CRlCivDwPtL6AgmkEoJ7rsa5231CB+BbRQpXgRXxRHALeengj9SkO8w== 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=HG2KlUBcp1uC024PFTKjBzFPV5NG6VwXF9hqlxzj/jA=; b=eBjESQpMnOsIcAv4aX6UtlnLVknEOmDS/yBTaiXS5Mb1JzjsWXL3A/I0NBRYuYdzr3HLsBfQ+GafQco4tQoWhGJAmaqmYM252eATgybRo5JdbIq4mjLcmDthw54k4Co6gqF9dLj94sKGMWoi9TCFd5STUJrk4ml1IQRJXWWq4S7HwDNrVIY3Onb/OPiQrXDVmwKz9r8Nl0ddn2FS81xpNm2TRXLqMB592CVYJBq/cywYLY723bEUubNaz84+QukmCZMpyQPzNjejK1SgjHuc09GugXc9T+4FCvB6PcZ/ki6gtLSklPfQz1KEqtHn0fMoXHBDpQ6hiWvlYudcalWmMQ== 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 VI1PR08MB5360.eurprd08.prod.outlook.com (2603:10a6:803:132::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Mon, 8 Aug 2022 12:07:48 +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.020; Mon, 8 Aug 2022 12:07:48 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 7/9] parallels: Out of image offset in BAT leads to image inflation Date: Mon, 8 Aug 2022 14:07:32 +0200 Message-Id: <20220808120734.1168314-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> References: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0042.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::13) 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: 03a5c2f7-5169-4733-25b0-08da79369c6f X-MS-TrafficTypeDiagnostic: VI1PR08MB5360:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IUbfRyIhnpCZqogZ9XiYprQ8/QZsugDA+7TZ+P8yYQyPfF7m1Q8RhsAatkqyWPPcy4OXO9rLgYh4I6XNPIEhXFYin1XgOrU2fefrAJhsnnO+xef17fYSNraXtCykNTkL4H9qiQvG0A0GjsBsoExIHJoRyzD3STbXA7bT5jXu6neDDy17Hf5moqUi1nlWb/Nqpr4r7V1kO5+ZQ5UgAIaf+0Ongu4hHb3d+FxxPJvmbH43YWLbwSqzV5t3G6ui4sO/RMrZahwcwCgHbfiUQ0caOak39vwWlM9Paose8YiU8cWZN9xSe36BM0ixMJPpC755hSAw/F2VAIHjRUJfbjFUPXJd79USGRHJb3daJ7cDK9Q1t1DDP6aQZtTshIXFDD4z2FrOXlrexVt/2ExDSJu8fljPuyA8HG1EEEA4NNUbLpmQ4JtUdDAxCI13IxOFEuq1L00nKQPn0GD7nd1xIFjSPf2q0/rBvhluwYYG7nef1PvB+BAUcieY3WNPtkZYmyjy+fApHQh7iN0m2nAKRTHvWe+/ocn5WtiNFGvMnmFdpwNMGmWYcGTYU5dtwVbvbxy6HJXFpj5A7jMOggGIR6YAON8HeE/8HEzKTxK/yqCFt+vlRUqPAlN7vmFecF5I7aOzbDuRG6kV/TeyCCCdttzRUfvDEuG6rPTSz75NkjTafzL03QoEW2pdsoV+feszGMCTGHmTktUlx0wGImbOo+NNuXB9S3LCUyZb5KXAQhgBAHf/V9W8ILwA0DFI6mJjhWQtFmjRPPSdLdeO+lZ0YIox0lNzprma25bEuEG7nzgCruo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(366004)(376002)(39840400004)(136003)(346002)(66556008)(66476007)(8676002)(36756003)(4326008)(8936002)(186003)(1076003)(478600001)(316002)(6916009)(5660300002)(86362001)(66946007)(6486002)(41300700001)(52116002)(6512007)(26005)(83380400001)(6506007)(44832011)(2906002)(6666004)(38100700002)(2616005)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Xlflg74cZ3xKtAQU+2hqL/A1EMd4mG57o/B74eukj4FnvbgYeBMvHSptNs+9oPInCYuFPYBcsjuMw6mx5LHqJQB9BQ9b2KxTrEaPBlM8XoLXo1CGzMTHbdAXQGHpE0ViiZ6PZqh5RbVlY/8K5pxi7lqVUjaQOvPr5xjaVZbFYyF7MOrS2LifBRgCA9qCe+s3IzinpNOXgr+04dheVeZ+OybU455A0DzrvuJaQDnkGmlMAvzlkm+gaMmRhSFcFmxT6MukcWoAXLJFHbq20iExOb+AwLH9WQBshuUNuZA1HSp5J+dUOSKHMDlPg0Sb4eKedsTDXa0C8+hHGOz/HMDZe37LMOnDJAmlLOsjmbaBlpIpX7nM1AktXdPmh/uEojZnvFwmE4sOWaOYzjWcJLWEZYAAz9tOhsn70E0cg7bywFzw1or1uaFKxn3szQIsO6A3XYTqZzhHotkIe8EaffbTyKKh2dvew5ik/EJRo/DFvotX2+CzQ2Ng58KeluyA1pBikgAKspuchxQahC1UQc4oagIw4ghxgQ1sHw31MegdxSkfkQ5+eFK7fKoNScd6QimsaE9zwn1gbq5HA8L97+sP6wPVdle/lJazFuhekimH8tEGPbJAaEi+tsLCIPtf6dv3hnxCm1t4vTDB3Anglx9gtCATZNKVPvU7zwqpJ0yH/hCP9SB6JYBYE65D58GaNuPKjRQBHZds+iLHskkLQtaE+Aku7D78YPE3/FQx2LlXpQ51tFx3oZC3xrWKJhQ/WW4H65C6zK2OY2/desEBQr6pq0Jzvu1LxvyxZr3240oTTjvY5vu2KhEuBSg0TLaZ1CXNUwefua3GE/rt+5xFzOhjTm4q0NpiPPZC60LtGXniPJwzdj01q9k71wa9kNBCBF7HqjP1zrCzvjabWj2YjClyDBdCfo493MXN9HiIRxAadFK18sMP1MM9j/N0KL7yI3tGcldGaFjcbGw17uFa/IRfkjOy8k7Cp2a1S/u0nqbXkEx2szl8UFrkfio+z5mLWDHG6azhIdnv2LX2eCe+GrrlECC/w8wkmVemAvW/asgHVvqFcnXQLzubNKcnQX6fKRzN4kA/qZDCP/elxph4fZFKykhOiiRSEy6Lf7NJ+qzaZQ5iohLhGKaRGy/bQwJ9+ryzLsA2PYuP0cEUuEFDd7HJFLSP7AfUtyrzKERwagM5STWWrPxXkBMNWmrHqNvW7OMPOINPO/0WYaXLrC4v3Q8cf1LGuLwbtRa+FOFJkGC1GpC4sBL0RGzzDllSk1CavDVYkPqm1NKjKiiwxlGv55Xg2bWbxdcMviuyUdj4j74X95//ZvN4VyEmvRVC3S20i5UcW5vGcetbcQJEUqBDXOkvOPo3pXIXXmk7nUZBVGfcD0pfAe87GstP2yqkmqhvV+BOQ5h0Ex1MSDWV+PtHFU3wr3XGPXcB4oDqoXQ9oSQHcHaO2Fz8KM1nCDiOWECMkV/ShFBoCgh25ZmEo+iwkqGZey8J2VciXhYPg8w1gZkmcDNBlAgqzW8PZaCpH2NHGTQjF46v2/2pFeTxXo/vJZ8rMRRZ0NFS+dPRLSa+RPQv9v/X4RXbyAXnUswU0JrntnDviVu+wBNj3OwZUHp5xUesoNJ6jVnkZKe/fXl3iUZXE9s= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03a5c2f7-5169-4733-25b0-08da79369c6f X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2022 12:07:48.8258 (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: 6wGl9HSwCl2w8plOnsB/Z32od/vgyht1SZ36Wltz4Xep3lmd/+jNgDmdt2QAqu+SX/06fNpp4Kgr7p9Nvpl1W6uOZ0WyDOHAQSR5Fd+VZ/o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5360 Received-SPF: pass client-ip=40.107.6.99; 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" 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. Signed-off-by: Alexander Ivanov --- block/parallels.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index 3cb5452613..72cf7499c1 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -811,6 +811,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; @@ -890,6 +891,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 Mon Aug 8 12:07:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12938745 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 8E741C00140 for ; Mon, 8 Aug 2022 12:14:39 +0000 (UTC) Received: from localhost ([::1]:46878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL1eY-0003hb-EQ for qemu-devel@archiver.kernel.org; Mon, 08 Aug 2022 08:14:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL1YD-0003cj-Hk; Mon, 08 Aug 2022 08:08:05 -0400 Received: from mail-eopbgr60132.outbound.protection.outlook.com ([40.107.6.132]:10881 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 1oL1YB-0001SH-CF; Mon, 08 Aug 2022 08:08:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QBTfKZou7beIy99dM3UvpD/IZ5cE17+UGvabpEh/sgU8OHihlROuLEbN3dmkYGu+t5AGONsnXRc+o/RRXnhQfWdHbcodrxKRbp2IaGL9UvN2Hikno+KE+f6REEu5KcBE4Jkv/iskZjaXJWzjuSuzy8rUg5DsbGIAIZleAv8oei6AAGTZJ/lq71Yj/xuuUIsq06kikTuM4E0c2xrAx2/siZLQCzFMc0FlXygtl15yCx0QNUjLF1J4L+p+nfCl08H30c9vh02yohZFlv5dEV8xLurY/ltKqnjjft0lnheovUZqIcnW+cyfrop2+ZDQKzpcS0GqrqffUdT9IUWugBAjXg== 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=4VdphQqlCT/vIj0REPpVfTCqdLcP+9kPa7/JO7/DREg=; b=SEJ3sUMx6rytmuFbk4kOR1S4U2MMOTpXxYKviHK/4NnH4UsFr1D1fvLuARE5YQAIX5I/d0p7JXxtYhAQDTA78oFC8GV3hRl7h3Lm9xIz2hPUkiCZWI0v4QK2jMVDf3nid2juoFtaMe7azP0ZjcQXFz9MBk5ezAIGxh009CZAlBuw+za882Sk7SL42+MTXjfJo81etE2kOLBpB/Ob/W6xx7hY9OWo6PbVhUpL9gAFYHps9BQg9bzakJRhegWHY9twk/eRjxbMWLdMDbrBBx6WKlXq6PdY6W1IFFiiVJthyhNQq0Hm17RAjvCPAe1K4cy975qLScvWMIn2BYEU3lZNZA== 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=4VdphQqlCT/vIj0REPpVfTCqdLcP+9kPa7/JO7/DREg=; b=Yt5DbF9brmA2A96KXaFB/ET+aKm/bMsaIrYX/jg1YItU6lwGYqMFjBpRF/ClVbRMx905hKOsxqgDjWWDznhxfl9f+mFI7Aau0UD17YWS9IhleKFtO3+Ce7RJCsNhfB5bbOGafYVGOWPeovtEaqVKySyLhkfMQ/FLI27018byOa/mzakGdO2JMi+ivjG9pHqwZ5tAFq9r0jrFGx+8V+qYcQIV8LnfsIS5DWJGj1WiYNPQhwRMw3RWWmJ3Q2iR93F8rYNMi5Ynay4d2msIfKKarL3m8qMfLz0Mc/0epAJT29dnr2c0Awi+20xy65t1Q7OMs6UPJg+SIUtGws8BZC45UA== 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 VI1PR08MB5360.eurprd08.prod.outlook.com (2603:10a6:803:132::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Mon, 8 Aug 2022 12:07:49 +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.020; Mon, 8 Aug 2022 12:07:49 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 8/9] parallels: Replace bdrv_co_pwrite_sync by bdrv_co_flush for BAT flushing Date: Mon, 8 Aug 2022 14:07:33 +0200 Message-Id: <20220808120734.1168314-9-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> References: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0042.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::13) 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: 020169f1-cfcf-4c91-1a51-08da79369ceb X-MS-TrafficTypeDiagnostic: VI1PR08MB5360:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P4ItX+ps0aKihbxSQEk4C74+QK8VorhoCAuq3sIdcTqAnMSZJIyk89lAViswPECDw7mwPHDYcXxUqUxd1I9/pErMWyqfA0UrZ+62+VeO3OLR29pn3hkIosdsBoLOKbN9AlGV2zIeveR1V4qchVVFG3npm3O05Yb+icNtqqwviUlAZcJE14nl1GCFusWfSye7ffTIR4o2YGyzF6Y/2LdxTujuundwIqLSI5mBw9nPyW/6r3pWypLGc4P3VT0vFCIUbdbXRzj13ectYMX1Nmf7wlN2beKlrb5/JXbtmYRM6jvyskgI1dPTzRA6ELXZQlqCrK4zaoB9o0ZNOHfSBSSTAlzsOjzidzH9yfvVJrBZo18SbvYTF/8AfGXjDycQuuNwx42CgRie7hHD9kyI1a6JAfjgFL1wB/XpcB/Nd+ub0U8rg/nMw1c3BgcMrkeeQSgogR/x4cMSV5ifAF8LiogOVk/STIEtFaTYONC1L77xTfagKIDZfXqzx+E1Tkj0fAgpqsPDVXatGgBbn7f4WIRnKPCTweNePPOqvoEEhP15mHdQKg8qRH/Xzd03c46gSgwzYaFgc+aVgQKlmw09KkptAmsfq1sPSFKw0VJf5xGS9z9Q3ZOd6yAoqLy3KTgRFe/6UG2OBLiIiuZ/fhlIxayrC4QXsMAhApFhrqhFJjL7rWug3wQ8IFWws0T7B9ubKbZsmdSx2u6ImKQ4pdUXZGCOE0YJHfSz6VJRnmbSFz4IF+rWVD6fX/P2oyiVMx7Xr4lC6m8qSTI/Ag3Y0TSfiqInbL2waOlf2G08wdtuZQ4i1hc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(366004)(376002)(39840400004)(136003)(346002)(66556008)(66476007)(8676002)(36756003)(4326008)(8936002)(186003)(1076003)(478600001)(316002)(6916009)(5660300002)(86362001)(66946007)(6486002)(4744005)(41300700001)(52116002)(6512007)(26005)(83380400001)(6506007)(44832011)(2906002)(6666004)(38100700002)(2616005)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: K+YQdNDp3YIhw9H/WdcF5cf0nhZ6JExXEJVMqiZBcigAEf+fLSUMMDRCU8qCKxW9lkx7dphECmgDjEL336sWAWx8dTMouVf1FW//mecg75FOsZir/oWDebJvTcYdd1FQ25BTL8TY5R4D1wPr8V7SDNhGCjk5qhX0lDqT2c+m0KPCMI9Z9PZlOEZjn6AqxhFZaI0X4AIkdtopwlWKm/qnbwycggeYQgXVAT2tmUTVPZ/Gr7N9AVbkQ4fuS1NhT2abYr7YyEpEd+tugL1paB4OV0Ws/M7otNia3VUfoOLKiH0G/78Gi8kd92RQiDtxeEQ+X7+jy0IzG+Nm7vFIuLp2NZZAwiti4JxwZeHwifi2ipbKWJQSWapJnNd2qWXZmtMVWXeIz0c/fJmhsNK+py0BLIEsDR7bNtzPD8aDr+j3lJtfSw6aX/IpA7wZAJKq/nFI+LLl/RLC90DIBOKyQY/ByGAqvsY+7l90KmHpabYBXTH7o5TC8R+EEd2uRdcEPIqXRadjoUKmEw6NI1ycpT37644R9RK61bvEWbmwwFDcmPPg1MvF44IzeKReRrfoFMuRnZVcnok9TbFcJwk141u7M+QqwJVf3j1tGeZ9uw0hxJ2QdF2JqxDeTWGhyhtTWqnJ+H2juG/SLEMAIpxDe+nb+zOJtLzmIiz5PHL+AMLHBnqrno1vPLytHgnTJKabVkLnzfxv3toJ6LZjV5AU6X6DAls9MhYZojkObNlLssiUM2gWH3ILgBxuZK2rvDMTAteJ64NUAVWv0DUlNF3c4SAV1uPQJrXLsaApvK9hfZmXkZBAzRfReAvN9GBPkrUnsFA+dV2gcmVBpXqFsp3zDiX++8TR/25DWYRpyj/GFdYVtPPlmP37mR4Z3BHxB9Pr6Vz3WcXS/8lA8xp6AlL2M2M+fsxFf1SEXlGs+oF47m3TbOVsqzFMT0kpfG0VljAMnq8BIQqUQk/xVxrY6d0PC1qHnork9jvERE+c8lVM5ok0Iv4E1YIutFdwPz2l5k2XQlp/DIgPyIn55iRVfijyb0pSxyqjcOpuFdmnzHcJK5u8hlM33CxDEpCs8RK20mSEztKpyOTbm1gWtuyLLnZDOO8lbvKkAteCq6hMMK19Bn07ce69PV1urBlFW6tZXRGFeuIpHcctycK1dldFYt/nUmaO4NlJ0OvtUtSeeqS+7Gw1F7v1TdjnQc5CjwbIndbRGW0OIQoyEfZZeH7w3wAzgMLm9/VMhQ2hHSzZAi6XoN1LYpFbrhMrcHSJK3/qZREwbkbActTy1kFdKhb7mEcBW0aa0/IRhC59RAlM7nCHk8llL6ziA9qd+upxPRT/brOA7E/Y5QaY1aLh2JyGqwgYhL0InFbDjTwVc9LKyE2VGLLCydPPnOubkvgcHJjpUDHpC9SbwPAlgrfbHtNZ/eMkbc8MPYd+8W+qFgbLRhm7I+yjYr9sO7Bn4HZqV8d/wDfzSR8skwapTpv8wSE11JC55WhKqq3EVCEUz72vhTMVogcmW9zJNLkUbGBuN//4MSGJk62/BWnDcbB7dnYm91QZ41/HDSl67DKyNx4Sr+U7+u9A1QR3avvIz3K3qBF+/d78E1ky+n+VVF6FUj/tid0NV8Jt8wI1DLYTwHydWqr7AL65rVM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 020169f1-cfcf-4c91-1a51-08da79369ceb X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2022 12:07:49.5913 (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: LbAbPUNxGEMGc7HHfSkXd5s5Y97pHLXRYPXVl4/seibEPd2pOrXuca4rzGEBfHI3+LYVLEstdrvTpwFqMlw32xPuDeVDRmIogQYV2l56GnI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5360 Received-SPF: pass client-ip=40.107.6.132; 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. Signed-off-by: Alexander Ivanov --- block/parallels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index 72cf7499c1..38b1482e81 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -469,7 +469,7 @@ static int parallels_check_outside_image(BlockDriverState *bs, } if (flush_bat) { - ret = bdrv_co_pwrite_sync(bs->file, 0, s->header_size, s->header, 0); + ret = bdrv_co_flush(bs); if (ret < 0) { res->check_errors++; return ret; From patchwork Mon Aug 8 12:07:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12938748 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 35795C00140 for ; Mon, 8 Aug 2022 12:19:28 +0000 (UTC) Received: from localhost ([::1]:53054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL1jC-000818-8z for qemu-devel@archiver.kernel.org; Mon, 08 Aug 2022 08:19:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL1YF-0003eH-Hf; Mon, 08 Aug 2022 08:08:09 -0400 Received: from mail-eopbgr60099.outbound.protection.outlook.com ([40.107.6.99]:57061 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 1oL1YC-0001TS-67; Mon, 08 Aug 2022 08:08:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RcLsM+4pITOHZdukQHNee+JK2BNYGZMc/RMGuZ7F6doW/1ftZCrua28dRCOKZLABsxtNN44aahhUYr6XrSpN4VvttirdVcQ4OAu479cehWG0Df6u3lnVx3zjlKWGhx0HZLOHtA7GO1c86TKrDpZE74mBXl+M3OQnVtQwKK89ev8JpC14NqW3rnuLjmerKpGq6bEWgqGZhjrhXVF/463jgdU+/vy/5ZjBk4u5NqpsQJyB/ZxJSkFm65U9Tk2aP7DLb0cVtmdecSSnW1CYCCBnCNfbusUZs0AMyGFtbTyyAx3fnEdTjBW5blEI1/HjHR4hxI6H+1hlvH5X8dTss+V8mg== 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=S1r3Wuv0aagv+akuD1n+bBJQFK2o1L/CZvJtNzv/Sck=; b=dgbhLC2R2EBnp/Q7tR5esmDwiHLctxviREDgIfjKcymtLElfhB8ipn4mo6XFr3MujqcszPW6ecVizlHAEXlmFYuFY45wFVsmc5K11bbK/dctMgJ3qy/EX9s2Aqn14OUYOtQHxpxiIZozyXhznL3Uv1I/Dc2bOjCJU8T1xQz1rQIFC35pIV3KJz5ocQex3w3fhNhe2nueOtu4UJWd5EudDNxoUrdEX1ilm726cv3b18hkOFv+HdNXOH/sC9Am/3sC0JwfNp2F6JEFSK//y+A1Qz9xjdLudRUutcY44EjOHHIS+tX1UVchqDn8wussSIKGi5eApqeJBQEVFA6kEm93zQ== 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=S1r3Wuv0aagv+akuD1n+bBJQFK2o1L/CZvJtNzv/Sck=; b=HJHzq2WRRLQU/c+I6d3ExNDHxUYfHUZ29DDjgWzekk6UIm78yvS1WDMPWu3wM2SMD+omYZv+90X8FE8gzOz0CAm3J4gekokgHP4LqlRUAkZqEsoCy60BisSFIO7reXyh95JTlG8hEFjsCGPRKF0chZn2yY1o1jm6oD1nG4fwfxUmRQ3dxTXPKCD/lcp6H8hfrnFKGtSR8eZvouXzippmy4aMmxyup6mmX57+8ydpdP7DWm/vlQT6pwus1S22QZRG6ROK1/yOzpP+geQoc1hTVkciWimug2V136EkCoA9TMc3ZyB7YPu8HYbBzBsIIlk9ZSix9p278wCYt+FINiLj6A== 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 VI1PR08MB5360.eurprd08.prod.outlook.com (2603:10a6:803:132::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Mon, 8 Aug 2022 12:07:50 +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.020; Mon, 8 Aug 2022 12:07:50 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 9/9] parallels: Merge parallels_check_fragmentation to parallels_collect_statistics Date: Mon, 8 Aug 2022 14:07:34 +0200 Message-Id: <20220808120734.1168314-10-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> References: <20220808120734.1168314-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR3P281CA0042.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::13) 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: d29f5119-4358-422b-dcc6-08da79369d64 X-MS-TrafficTypeDiagnostic: VI1PR08MB5360:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eYfhc1ZlarCQBhq1D5tLEI0Gval0tMoO1WpP/Ic5NK7FNQ2lNlkEF62Q0DP2kNxm1D4knFGOZwXl+K6AkvwrgzXhq0Mt932lI5N7AITLo1rtZ12OoI1HHroOWKLh2K8XO7cF9IPyyyzwQRYDqP9p9EErYQEC35RZ1MgEVxb5FLQmekSyTQepJ2hAnSlupj8xIR6+wSJ5JXCUZr5DCLx/PQIHmDmVD77HYq/d+AQz0EaBR8zZ2QGKGiaE0e6zkE1m5EQ4CIFEJmZQ8G57IoLMKFOkk2Y1ZyciznfCAKbU4fmTLYle5Rn0blwro7EF04/MMW0yUVObxSpAMjwuhb7xDaw/HADKDNJniV9ByX4YFTbsxJlG983ym6GSauN/KHyhtRIXyfW/q00NpVKv684MFpJ2OdUysKqfYLMEoNYAxad2oSpLqTEebKmQNDpX36S+3kqbNm++M5+eSUSXSJFtpHMUxyGGD3ZeFmENy/+zUGM+ppO8beC+3axNHYm3xswluVAeV1RHX4Zt4xgu/dJfo08Pg8Is4a8BssvEHg1y7/eGJfd4+2u7oFVAoMthptH7YYe+t33Aei1xqEhYK9TIOmN6RqSAd5QkOCYTXjMSXcMqxQJtFEjLSGkEW+Uyk0PQMWSajkVHFMHHbDx8P3Gg1IIO2Tnnl7sCshNrHBOQHlhMRwluRo7cf/kP/Do5l3Htv59qT+QvnYVUeNIDo0RM1h410u5wAcbWtvY+Bbf1dZUBa+kGoIvHV0qleUlw53gjBd/e7pHrUoZ+bHlM427AR33+/PyWAyc8fuPKWCqyOzM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(366004)(376002)(39840400004)(136003)(346002)(66556008)(66476007)(8676002)(36756003)(4326008)(8936002)(186003)(1076003)(478600001)(316002)(6916009)(5660300002)(86362001)(66946007)(6486002)(41300700001)(52116002)(6512007)(26005)(83380400001)(6506007)(44832011)(2906002)(6666004)(38100700002)(2616005)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2cm7tWZQMeiSbwwPZ301n6x0CfKjA9ZGGYQdGwxrcjhdqHOvP83yf9Y9u0TzUdU0WVP+xn2qQHzHMjFHv0MQF1221Ebo98t7UUifMJXLPZZHpTLNPtYTR8I4XlALM1ISqbUni2IZLt/42Z8K+1Y4/U9TZUmpTDw2I6rycBYVQJJJB1apx5vLEfvSFOh36iKbTanTe+oE7YvNAccN07rJaIxGjbE/Uc6KiqzJpnABGm6+PhG7esPZz2TL+Wn1p5CvD16THLgVRzkcPtgkUU76K4qCT691Y40Qb99+BBpMcdxBfxaNyf4YSQ1g4KrmfYQCYZGiTBPPbv29EAiNbl7Bbx6ZHyFc5k1oKVV94fAKzmmaLWBNFDIsf/4oiVnKH1xGpnhjyI7495utM1JWqBUePEW3HW2U3s7RcSfv9xQ9zFBJL4ordU7ktIZWHv2DJ/G4mkzBkXhxNBxxKdaWn1ynbukfrHErhG/8iefyW72E7ejxY6fDSDTLjNsw4z9VZVwt3s57gYmn9anR0GLZRTHe3l4/KIRpuEnMUjiYbXsY74PXBmT6KaUXaV62x8XJzuuF+Y/4UmuwEdyAE7LYo7uNFPe6ZN0xPr38AIv9kXPGNVhfKJ9nX2vWV5MLOkGMH4oqtVdRvPgIDPTVpFuBx15lT+KdrEU86Kew6cxHM041tRCvOCSkUPZzGxAVqOEh3ozVNY6ID5s4BCO623nQeZpSQxCdQ2kBeOKAKlybcgiObu7AJvHxqxzU8R9K5qpR5M7JV5GvIUaXeW1/OoMFWo2I11ukvIYqPuEKOtj6x5sA9PoTVyT96GzwMdgfj7i3q8JDLQvTt3KSqoc/HB0bYVpK7JCKu+dpFKbFq4789MQGcMyll3Mrf2Moa/jOOxsRmoEtjkseYWRkt14KcKuIalSuyWPp08ZDGHspe4kmRU9oU/GLRedcSV2KQU/01TURXBCb4G/V2tZ1blyRYiVOf97j/KarDbNqSFrLrSmY3HdVDCxus5OKQkTdxFOC4kmgGFJP5np1324qczlx9zZ4a+I9jt3qhDG1tDFSu/KNPQe18o3jpze/82/QP/lMCM1diCzzjjvZ2c8xxRu9UNkQC/wOC6doK2CZskLCwm+YRWm3G464OtY1yb8x/fO47I40JEUcxW/vZDbnTZstTpvV0ZWLQTp/ZybY74H21gK0aRFs0c9UklORvSgm2/qmrFsbC/C4D78u56XhddFpaYD7/Mp3583hk3LXsHlq7eVjRtEhLBxyTl8R/CNOaLELbLWA3ZckVzGtDUQrkj84biNZwQReUY6q+uQNLshToysjh1wMpBFelBd8Fdm+m23U1Pg+KMRYDoJPyPphEycygquIzVxN9D8vPmmuhzTC2uqS1lSWdpVqt56e0jUs/n3vdRjD8zFujwUCmmLa3xzgFNMc4fwNIWCLAK21t4GflWfr8/Wb3phJHAvzFm6QcJ4ZeTQFj8awdKSl4QqXnGteaoE5jkM5cDpazDSnB1iforusmwDfx9y5KYPfilaY2cPcESCFsvIyR8PPEhxEg5HmVuQxJt3KEmdy5PinohMRCGrNYARXvDFdYl+5Si09DZ7n4IZDwZH0PXNMDwAa4eF2Ce1v2SFoFg5wYBmtGtebK/7Zzxw36zg= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d29f5119-4358-422b-dcc6-08da79369d64 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2022 12:07:50.3267 (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: CwDLDsfycGRjOrO3astlHnjwosO0U2kbWPn/7gPREGcZxa6ei6QBFcWW4ig/qJMdKIBIkKAbKajCcaKnX4lel1W4UoSksiE1Va5d6FgRepU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5360 Received-SPF: pass client-ip=40.107.6.99; 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" Frgamentation is a part of statistics so it is better to count the statistics in one function. Signed-off-by: Alexander Ivanov --- block/parallels.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 38b1482e81..11597c5dc4 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -530,13 +530,16 @@ static int parallels_check_leak(BlockDriverState *bs, return 0; } -static void parallels_check_fragmentation(BlockDriverState *bs, - BdrvCheckResult *res, - BdrvCheckMode fix) +static void parallels_collect_statistics(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - uint32_t i; int64_t off, prev_off; + uint32_t i; + + 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++) { @@ -549,24 +552,8 @@ static void parallels_check_fragmentation(BlockDriverState *bs, res->bfi.fragmented_clusters++; } prev_off = off; - } -} - -static void parallels_collect_statistics(BlockDriverState *bs, - BdrvCheckResult *res, - BdrvCheckMode fix) -{ - BDRVParallelsState *s = bs->opaque; - uint32_t i; - - res->bfi.total_clusters = s->bat_size; - res->bfi.compressed_clusters = 0; /* compression is not supported */ - - for (i = 0; i < s->bat_size; i++) { - if (bat2sect(s, i) != 0) { - res->bfi.allocated_clusters++; - } + res->bfi.allocated_clusters++; } } @@ -591,8 +578,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, return ret; } - parallels_check_fragmentation(bs, res, fix); - parallels_collect_statistics(bs, res, fix); return 0;