From patchwork Mon Aug 29 10:12:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957648 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 1551EECAAD2 for ; Mon, 29 Aug 2022 10:24:48 +0000 (UTC) Received: from localhost ([::1]:34052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSbwl-000249-4d for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 06:24:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblL-00010l-QQ; Mon, 29 Aug 2022 06:13:00 -0400 Received: from mail-eopbgr80130.outbound.protection.outlook.com ([40.107.8.130]:50395 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblJ-0005zs-Vx; Mon, 29 Aug 2022 06:12:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aEJb+0GVAB0x8Wy5ZAgHsyERBJPHkI17hnh9G0SWeLvw+wy4KYQ5k7aTqy8uymZHJty8dv0KWVW0QOIiM7BMNoxKGbJ4b/AOIXSWWgUaJ4idqkiBR7OoMom4FRrhZjlQcFROODuMOaZ4+HDxRWi3I2AzR9vj0awOfPdUv35Xju2TAu6yy/1t7Eyzl7RuJGdByArM5KOTBnK9fhbpIoRg435sSBy/Q3aaBZ3BMttl+aet4Tt4K1qd+64EyE33P0IBzZQW0Rd/UbHVFCSNTWwwQ26BXlx6PSYUDm34YMjTMXDh8GPaT7bfrhmPpd7xneLRX5bnu9PnH2DoPeJCA+C35w== 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=5rzYQDMuEqZ44aJNahV9Td4BHVOEFdrgVxFetwvyKCw=; b=jH7UZI7e0tb5yXnXl5gdY2LM48Do9WUYtYiDgPDN8E+n/+6DOjkEjW3WF7y96qDPLfcC0YWTazLBUYHNAGCq00r00Ya3sgNYdx2A4eMxATUnNgUcF7gPl7Mok+HpCNLMJ8x5QjMeWjfJKTKdclI59rMH5+oOHs/hFDgluCrE0//IFEoy2sNoiK/CR0TJcGxEFErJWw1Tl3nXVu7co730t90pdCs6OQiu5sMVxIKBBUCVKrvwCcOdV2CXqCeX++d9nWYqcirMN3hjztdx3HIWsxlKiRj/5uAE/W7obaIeIMqU6ZQ0rCyNoxbFzQuNhIjcMlKFxy7tSMeEjPiDkzx/RQ== 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=5rzYQDMuEqZ44aJNahV9Td4BHVOEFdrgVxFetwvyKCw=; b=vSENmaDSsbgUR72TEBUBQu2oyqBSCTDU8qJsB27oX7khAWsILCNFh4ukXHG8RoaT4/WOgGdgmNq27R2/lmbYk1hVl4KdAr32QiUrS3q6u3611nCvueq0yeb3Ly74jfX+Dg60SygM1zMjU+UzqSpkpBLH9vh0szggdoIghU9Q78l9VFjdgFgAS7xZ6ZMj8V+t+HbZAjgbxochZZtBBwWwupV7dHexbdC19tEGVxX+Y/PQF/oNmBx7Y3SIJ2R30q7oKF+10yU/S6yGMrff5lfjUKSBoP0wmqdRrzZZIfFbKwfUAa7tB/eioESuqJS12IfnPpaGJpqcgDFgh6jmFkgJzA== 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 VI1PR08MB3023.eurprd08.prod.outlook.com (2603:10a6:803:4e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 10:12:53 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 10:12:53 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v7 01/10] parallels: Out of image offset in BAT leads to image inflation Date: Mon, 29 Aug 2022 12:12:36 +0200 Message-Id: <20220829101246.343507-2-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> References: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0139.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::14) 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: 390ab1da-e2a7-433f-346c-08da89a7095d X-MS-TrafficTypeDiagnostic: VI1PR08MB3023:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JbhyqaxAeqJQiCc2O/NH7DdVdSi6bwPRBNW+hLWO9BV8w2BHpw1eV7Pm4DtRhmVCXYJxSSVDtqbElpxjOuEzVR+nHRAbnohE+oCeMcgER1ApfF+04vYKtnHgBqBNpcVJAcMP6WZtcoOu/7p73FI3vwVGKB/bwULzM3NJtBQdXSp6vyAvK5/LdmNCdYurTZvjowMzDGx3oblst0Xfec3EN1nm+1mt8uCTmQqRpgyTqxCvZ7p1uYmxpWrULSrXhzDTQsAV4D+XnoNttXi1Lez8IpmXgMfE5BflamMnP9ItCBaOKpBEYZ2RMFnh1mBkb/6oqZRK+9XS3BgH7cg11spOxB4nRZfSzI8wtIRNQNXvOZ5rKd6OF91Y4Bu2GdWCqUCT9eRoswlFMsWgnL48T9FGQAKFskorRX81EeIhq7FanASLz1dBxBCZ9EtAb6amFwAYC37NBWpZcTU0B1SbmdUBUtAXXbS4T+wU4orPsd0d3ZTXL0J6e41j/L52RV/ZoazbiAojmvOsaxG7fS84U8cJ36G+5mdbD6c8Y4W2EH9uMCsCqPJtFWSgMsULEl4zXuhsteOTqBbEIvj4JZcqk3zYOoHczRTBnIG2VDEHOvi2MHlUTY1UfFLGw8ppNr0bJW7JGwrhlPcypbRSw9PKO0G28kiNgulczy0kLVrVrH8rRNHSY9LA3KJV1yY8NNdSLehi3JKvH6ODynXk/zjYfwBbaGlAufj4twZfYSMY3SzPR5PspqoUjjfhHDHfgpUpEFwYK8vYsWBbQ1YuPbq1ntwlXQ== 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)(39840400004)(346002)(136003)(376002)(83380400001)(86362001)(1076003)(186003)(2616005)(38350700002)(44832011)(38100700002)(5660300002)(36756003)(66946007)(4326008)(8676002)(66476007)(66556008)(8936002)(2906002)(6666004)(478600001)(41300700001)(6486002)(6512007)(6506007)(52116002)(26005)(316002)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0mKBD0bF3SVP+K9uYuGn3yPDs0nFKDp5RuSo9P6l/kfzmwXZ2R6qbCmHDD74lbXgieQoC63h4CeSZFVoXm4zNcRhE6SNCXxmrtSU0X07y5n5IGsYTol8bSSOrwlHwSCuykdlGughanzbAPHUINlCgC8yw+2ztRXiSRSDDKqE92u82FfZvi/VhGe8AFgF8jpmw6tzJi45dqFxNE/O/XENxoU0cChD9YgFqU8vnx4jnd27ECa4NBvkfKCyOib2u4ejCjhk6zc0F0oOc7bFOb7cHmccJgF06wye+3wy99dSF7Ys/UC2+CKi+oHSV1s69Og0vXBK9DC4w4BcqKpf/0hPAffUpdG8KZXaa1g0+vGSlbN54ec++S97RYQP7ys9KzwSr2MSUE6aUJDLCjYkYhX8x7Wn71Cd3kdxER2y82ehRYlwSjahWEpR0LH0sVzD/BqkqzM/Fbr1t/6rW3dAxxONE7SzqWcnBM9l5EZB53Fr2Py5Q8PcjBm04AE/4DikC2sfvyDn5wynjrqcUuUzLIYVdrTYPSSalAOfgiCL7xm5k29+z6vKxXZjDxTC2+ltT3PKz9u38fXouqFaX0KB8jMF7k4kkyI9rEI7LY8CYRtWyD3HZRf2LK2QGnA7GwpZjZ45s1JFnTgrWeU3oVkeVse/2ZZ6oaKarm9aJlt1Z8jb6ITfzTg3T3VooEZmv5KgmKCTnUcghIGenobifh4I+bmvGLllVYIc96sxhMlUMHYde8k1aDr0zjGMBaowlaJjJrNqAEeJKNHHKbVYdAD6EtwlUbyxs3qUP9cXSRDVGakiqU+Xgk5sauEsZtGHncTeijT5hqPGi+3RlbtwmtwWAzqWhtmWfZR+tmcLwIsWDlH0JFyGMzNwYPYQ/7KRqTuXWh/2tXBizQEWqFOEry4eMqU86InHpw074fbWv9rgdr6UyY6avTVivK92Lk/ggNTlD5eyAyQpwxWD9+iy4VEwdyYTu2cM84A4sNjjF+Qc+iqfsfb7nTr9raLAp8sCZbSyZggBI8nLcdPPY490dmjxmkNAVcpzy7H2qcwWIMSdLaVyNqHuQUYsUZk4bNhlAvro7KabXak4HyzwJ7XkFdvAKqx9FEsn+QrRXKTxMzMfR4989faY7nZSjfFgSTuMrTTcfXIitm4DmuvqFs+H3tjLCmWtm6QdXLhtRL+BZnnzqr+QjEtFpRAyBabyj7gYH2TqlpNqJyZFFV322iMmKaUicLeHvXKB5n3hPUZU1TOjBOBN96aFrUQtjDDxTwlP/2L5PAEcLvqNNnCLZD963pn5oYmyHBhjaXEgO6n5uKfYhINz3V7CfKFjUPPuBQF3/BNUQ1a0N1hso7nxcugoEVtzWtT4EQ4nMuTQVJfZzIvolIjn5TXq4eWHncPyg6nKixZHIBfpv+Jtuo4AoBKUUZxhq05310k/6Yf5FstLN93SvEWTyPL1U1IhIvHpewb8BbDHAQkh0K2xTxHjdkAFhzNhWTaUei08/vdZHWuf89BVy1MlDTrP7ZErpK+dHrTSZP+DGlJ+huKUKRn5+9czzMeVoKXGo6vnAOO+ElewsB7s0NwSnwFpZlSc2WA8yPfiDNhbIM/1iHFMJcq7eTyXzMxeyxBF97ypQIrm96ZySfSG3aN67yU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 390ab1da-e2a7-433f-346c-08da89a7095d X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 10:12:53.7243 (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: ZPFwh/B9gZvY/l43q27iF9yWlhj2Tld7VFbPmjLDwl6D49FOcjuVrYZUnb/zir5nzUJ/ar0NjqfXBLAHNynHZPpIMWBJ92EHWqmcSnbX3A0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3023 Received-SPF: pass client-ip=40.107.8.130; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, 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" data_end field in BDRVParallelsState is set to the biggest offset present in BAT. If this offset is outside of the image, any further write will create the cluster at this offset and/or the image will be truncated to this offset on close. This is definitely not correct. Raise an error in parallels_open() if data_end points outside the image and it is not a check (let the check to repaire the image). Set data_end to the end of the cluster with the last correct offset. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index a229c06f25..93bc2750ef 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -732,6 +732,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, BDRVParallelsState *s = bs->opaque; ParallelsHeader ph; int ret, size, i; + int64_t file_size; QemuOpts *opts = NULL; Error *local_err = NULL; char *buf; @@ -742,6 +743,12 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } + file_size = bdrv_getlength(bs->file->bs); + if (file_size < 0) { + return -EINVAL; + } + file_size >>= BDRV_SECTOR_BITS; + ret = bdrv_pread(bs->file, 0, sizeof(ph), &ph, 0); if (ret < 0) { goto fail; @@ -806,6 +813,16 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, for (i = 0; i < s->bat_size; i++) { int64_t off = bat2sect(s, i); + if (off >= file_size) { + if (flags & BDRV_O_CHECK) { + continue; + } + error_setg(errp, "parallels: Offset %" PRIi64 " in BAT[%d] entry " + "is larger than file size (%" PRIi64 ")", + off, i, file_size); + ret = -EINVAL; + goto fail; + } if (off >= s->data_end) { s->data_end = off + s->tracks; } From patchwork Mon Aug 29 10:12:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957647 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 298CBECAAD2 for ; Mon, 29 Aug 2022 10:22:44 +0000 (UTC) Received: from localhost ([::1]:55898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSbul-0008Bm-4l for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 06:22:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblO-00012h-4y; Mon, 29 Aug 2022 06:13:03 -0400 Received: from mail-eopbgr80130.outbound.protection.outlook.com ([40.107.8.130]:50395 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblM-0005zs-B1; Mon, 29 Aug 2022 06:13:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d49nswmOIt4L6LHOKAsuMV7J8Zjg+n9AxHjfGhcfyHDYG4q7aqpHd+GNvMcYXXqq5mZ7Ch+eks2FLH/uVVj13w1NK8q7oy4wuiIr1X52+WDu1xJAkQNTsvwIgDPxm1rTZnyqCiiUnXPaIDoPLSg9S5E9oyOY25gBGsRt8eyhgCDLxpuUF2XM3C2Cyo7X3Nq+BUiAlpeagiC+e+nJ/WX6lmSm4C6tp9Z4KoFHgLmr0V6y6jhieYrwZNG3YxOcqr3ty//8WfdpVw60kmO8Fd3Uv8khLdHdetWRu5Fp0525R5WH8SnmqUdH1pCg/rikIPXywDQAQbkt8MZ7Qn8IP0WPrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZGP3DBjWL1JXmKfgIkKAcZVSum3f8b5ClOKzvr9OcT0=; b=NcalQAvNi/9TGXYKsQTaKgVVfeOnJAFoitWxMDJVphvyAxwfCVDv4NbuQk4t9PQPyc+oPzOg3wVe6dCMu120oRQmJ8mWCF4W7TR0zLQYj0nF+UjYHJkO6H61BQ5MARfY8SKjmYqlN+4Eab2/vIPu1f9K1SKWdhDFPW6COtEpaG/MjVDPoqsSckJOhnH/Ajr55ejM+fvwnsyH+Y8OJHIzzaRsEgiAADZMIkcFj6J+OD2jXkQME+2dZeb82r4KLWKplV8tMxOuufbj5Ygjgwjo7Mv/vcCC3E52AY/0WpKNRxa5wDkaoaccylWmSxJAIj9y1sPcryU0Huq+N4/hnD01OQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZGP3DBjWL1JXmKfgIkKAcZVSum3f8b5ClOKzvr9OcT0=; b=Y2K4BP8cVSZrSDsjc27sPUG0reQE899irk54RpZiDj/RhlZdrs1thsgpjrneKa21JEytpHA2j7PBygWvXY8lkx9WEYygq/eoAztY2AddIlxq7XYXUShCDwIA4GX+FkBqVD5uor0ljK/7cK1vH7gsUkWOxsQ5T4dA83j6GyevOboctrLuFOJP/D5Rvoo+adJFtde5kURlvuhpjM1DeAN75FUGndlx6iE5Hnx9NWG8xXUgHxfBldXlBHJp+MlSmQ/VGyU7QUNvSyxxnzIfXhd+8032biJeLf+y1pBzBSXFk7CODKFtC+S5EPAtfrv1iPTVcOmwjLX0yBDK3nUTqNP3Vg== 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 VI1PR08MB3023.eurprd08.prod.outlook.com (2603:10a6:803:4e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 10:12:54 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 10:12:54 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v7 02/10] parallels: Fix high_off calculation in parallels_co_check() Date: Mon, 29 Aug 2022 12:12:37 +0200 Message-Id: <20220829101246.343507-3-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> References: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0139.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::14) 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: 9e55ffe6-b440-4c95-9d3d-08da89a709cf X-MS-TrafficTypeDiagnostic: VI1PR08MB3023:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zLnaX4TAZ7tzIa+0W7aY6rAFGFuVbihsl0KsW1CNCsFunPoNJ7U2mjuBD+Ewg1SiRN0Baca3JynJaiB7cbVXWyeaEublQYQVyUnLSzh9jgjIWcowXZjxIkTo6myDlBrFZpsJnJpFHLrvaVijzvNeO19m0yo9g/acSn2Il/OMrSYbd6pKoWSfu6i1WxoydGJbzgg94J65Q1JEMG+5Ev7pdu1pmx2sG3kqz6TgLl8ezzrCBC+6N/fT+BD7MUPsJso9pI//poRdw/CG1tJdnaTJEPbifJ+BVRLjrohmJIsxUmgrq2It8X0G5CtWUYedfuZUpe+P48+UT2Jwe6g/nJUbGzbGqIcfhvplDbilJSUKTKJo77G6JwhnziEGMZvASizDZYd8EjjLgK0WVuynNbPEzLUqkJHzPR4ROIafi432dXedps1+2EvDcH2VJWJZ8R6pyId9MNzgPqowJjtOu1H/zTs9rFftYWUkkFiUdlwJM/+CeYTrdg4o9lp6YWnLCEqra4qMtn5Ezly4i97Lhk5wyIiL1xz4CjTVyYgNiwKiqjGPBt4eLDcbrXg3I2YinljVkVTzPi4c7kKcLu62UmMMfLZB+LonzQ9cllkZk9//Lkk+PjA2iqZc0/0q3EN+uGg+UoUW+zTqjgUYx4u+1/Okde5ONoXBsZ5CpvzLQRSJowzHSb8n8OF9fe2I7+hsNbWfkuVT3u5QRNrZBhNAbyxqui8kAcgms71DYXXSGtNucdCw2IkyyU2JbHVeGnGaRgadS0Elc3xdapMxf1ZGZa2dRg== 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)(39840400004)(346002)(136003)(376002)(83380400001)(86362001)(1076003)(186003)(2616005)(38350700002)(44832011)(38100700002)(5660300002)(36756003)(4744005)(66946007)(4326008)(8676002)(66476007)(66556008)(8936002)(2906002)(6666004)(478600001)(41300700001)(6486002)(6512007)(6506007)(52116002)(26005)(316002)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eS67mX9Glw25q4BvkEHinaLtT4ifLivGdXqAzXM+i3nrMGDLdpcR8pXMgD+LZvmxP7o4uOQjPD8QjLdSK6Qp/hl7HWmv/4KA4CjgUF9tqxzoMKhdLK6ynNg5xRP6nynHDsXMcfgiX+M9zyj/4JEWRHBViIF+aj34RBrgHW1mFBrdhc/elVO8eprEWdr5YePl2BcUp3crYgw8bkj5U6GzgbbkLdkpxn8VlKlzUSoZSfZ2UoZ5/oiMGn/38PmL7pAozsCm3si0ohY28klGM57FnrV4xtT4gjMvuwf7IOBgeRMEds4iD4eJU7UNEYuU8UvlVFEUjxYv+Ie0IiTS5Mt50miralbLMPPrgSef1nu7qm9cgs2Nm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lOOatpizomZ6UavAGB/yd1ScLBIJS5ii8CpZyTdnIaDI/myFB0TgmY5jr7AKlxXK0DLYDvpAYeLorZzn5SvOVgbayNgURCAlGZttHN+79LePCl6s227sntRjc1u7fY9Fe1CdqyTtoocFT7rNTd+pE3pqshS/izobjlGrYyiMu4EPQPyZ/ZDmBMLyM3/1R3ydrBKg= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e55ffe6-b440-4c95-9d3d-08da89a709cf X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 10:12:54.4741 (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: sTyGtb3zXq0k9B8QXbx/KJpX7QEO3sIthi8zc7+X1hH+Q2YIgW7WxXPHXtAjvJ7Ipk2WKvHjiTweSf84IdqCL29gYxwbgMyPR4pIY3z7OK0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3023 Received-SPF: pass client-ip=40.107.8.130; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Don't let high_off be more than the file size even if we don't fix the image. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 93bc2750ef..7e8cdbbc3a 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -460,12 +460,12 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++; if (fix & BDRV_FIX_ERRORS) { - prev_off = 0; s->bat_bitmap[i] = 0; res->corruptions_fixed++; flush_bat = true; - continue; } + prev_off = 0; + continue; } res->bfi.allocated_clusters++; From patchwork Mon Aug 29 10:12:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957644 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 0FE93ECAAD2 for ; Mon, 29 Aug 2022 10:18:19 +0000 (UTC) Received: from localhost ([::1]:36374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSbqV-0005DS-1t for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 06:18:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblQ-00014W-NP; Mon, 29 Aug 2022 06:13:04 -0400 Received: from mail-eopbgr80130.outbound.protection.outlook.com ([40.107.8.130]:50395 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblO-0005zs-PN; Mon, 29 Aug 2022 06:13:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ol3r4StEo3pLFFwYP0cbXvcwhbmZYOEEq/pguE3B3H6tpEs16HBVbDUy8HZSsP//1RjI682heLZlslypEwrmbp8dlX0NyILVpo+aqZOw+0XpdWm7Y+VUMDCTxUZHMCEW1TH49c5/lLFiMsj5eannN/RFPNvkr2cckeboWlAhA4M6+YTAOsTQfYrWbJNH1M3WAen9YkDPSXU512ZvgNWv2Ew2uY+pWXTmQ8UtxG3H9zrQFymiB1OA0LZxnCXYnOxALugSqy2cHDW8jIbLHZhvUL8AMeXw8WMRLXKXxhVI5gWqB/+8SQEYnbK81btcQHiH2FgmtqNgC4XddPjal8a49Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dYRFUpACEhkX+bXhxRNDhGyqPDgF7Ofp2pS31i/7POo=; b=clE34eexSJ1MiefhYomnlek7YZdMB5JhXUayFmp/CRWReRvZaPH8z6pN+RXJmCFmMCah9HzQXdu5bsn6ITWDT/irxd69fJprYq0bUVaIHPb91r4q+nwM/nGTnkjTp5P9j/IRjgnCck06QrQSHt28LotwUjmwIAY/sNB1gGK/xTTcjGljaMOJix0j6xI/589HDtGF/GgEFz44RYdrrZBkTH9KoHHbf5MhzSFIH8BWTL0gZWHSJpIsbpwTeqjPIapYG9YidiRj1b7Htc4EB+U0H5xzzNANb7dy7gCgsNnu8WhLr4eMIHM6Pjofkxqxp3f6DphebvIbkzTFgs9lyTf9wQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dYRFUpACEhkX+bXhxRNDhGyqPDgF7Ofp2pS31i/7POo=; b=wTn8vVcrZfwDasaM50Tztk22+XMVA5UsWf5uUY/uiwc8XsZEA028s6Sr1zvLuR8d6tFTR668iWysLpRALNMK8SFvM7ViUazddeZX7EFw0RiU8ztPpvXk8xabnD0K7S5WFP5C1VjkUhzBvsADUK5bFFToOc78kOFzO+GqMa8rNwroalEbyNXPbaoBx56G7KRpkGsw2UEQvh0BgwRujg3tyZwVmhNE/3FT6tIBngBqP510j6vMIy066j9WPijwmzeT3LfQrXugEIYD1MTrcbeCf9pYRvD7uJ+GuJshD7rq0foVuTAXdhvsNNfPHZipyCkgkAC9jfhNQ8iU7DeNjnNUug== 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 VI1PR08MB3023.eurprd08.prod.outlook.com (2603:10a6:803:4e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 10:12:56 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 10:12:56 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v7 03/10] parallels: Fix data_end after out-of-image check Date: Mon, 29 Aug 2022 12:12:38 +0200 Message-Id: <20220829101246.343507-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> References: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0139.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::14) 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: d012fb92-1fa0-477f-65e9-08da89a70a49 X-MS-TrafficTypeDiagnostic: VI1PR08MB3023:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H6NdlwZcREKvMgBPaJw12E0ShyYt4Ld8ckE9wQGJbflRQ5a7kVHdqtTM5fJpav5mjL7P0H63W8QSH/BwWIEjzME3UZjk4zrsBX0noLGQ4ta+9XNkNnSATmJXraoCmhxi5nMfPqhtqPK5lTOIIir5rmHjt7NQfh7B2PIS6tLH9iw9GFC1/N5u8llofUBupSaAODAaxn3K2Dj3NfGm8pDJPf8qJnRSjv4iv+1QPU9X6ihSD8UuDZDpxGx+C5wHqG25c51SRhGaYsnimY5yOktLCIYxtH95Egd2PiF2JIv7NuuBVfdhQgEshUZY0XnqZyI97s1pkI3gKJJN4IEyKxIABVusrZi0z41TXjToBfMF+TkkKwirQOdDwWoiA8O7Mm3Ha7e8qxfTxvVWWSzhlCaSccfcrNVG8wfhtmAvfWwL2wuvMkq8EJa6w3JZxKnOF3WAVQf8sgS8KiPjhXlq6qpE9X85tkjh3RTAuRDsjritIvZJoDg9LUi2otSS9O2Pk8Win8gineFxZgT8HaZf45f5Co8PaiKKT1rcOTH6OhDn6j6mo+G92BVOo3ETNkZaQEPMGnmEZfRUZJsRDSrd8LLabCvTMiaUvkPDVCQhh+tR8CGsa6ljkv1H7kZIy2nBgbyIHmEfqXWuNc1x/dGfKMbYmWD2f3qgxEpPSav/uogpqmnGaWCCNy7KWcek2VmApumbclMw5Q/R7I0cwvmKp7vIuhwf4sNzU9GMzmhCDQGkuO5j+FbBUIiSlDJxHzmibo0xxLMlL+dmNfnDzkljPszizw== 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)(39840400004)(346002)(136003)(376002)(83380400001)(86362001)(1076003)(186003)(2616005)(38350700002)(44832011)(38100700002)(5660300002)(36756003)(4744005)(66946007)(4326008)(8676002)(66476007)(66556008)(8936002)(2906002)(6666004)(478600001)(41300700001)(6486002)(6512007)(6506007)(52116002)(26005)(316002)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OXm02D3uwOTeGati7dk8AzD+f07YW3SN8kdJ4kZ7OXysYqEdbJXgXju+Nrpv4aA8ZloN4iW0l8jNro0Ww6syuUQ2zLe8W8OOuTk7+3ijd3JKckYSySm/y5voU4Chbad1rJ71/6uyci9v4Jd9zRn7uVyreBbtF7NMMG2/Vz4ebhtvGaDYCF1jdAYxnvoRqJTXh31Lf4S0qFr7UhzCfAcgWA4Jjb+j88oW8Xl5CBgmBNPOCnFgshVXvWxKq3TV1Q4Y7r10KUxqi5xuEz4q7nc9fzD3J/hVs5dFfvPL0zsO0QaTcaClNWQMii6+DxBWv2gS0x8NwwxX19yaE/7Z8+vI+jSM1YcyM1ddw23ko14mMu//KfSl92krDkzjfNyH2bfH0uZLq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ZDkusPDpBhpeLUmCRGArI+Tw0EodI099xC1R8byx9VeCiCOwhQjGPGr8v8bIaD9UBtoQaggFQw2lMxYamQKVkTDO4ewYPC4nsnxZQ1Ra2DnjVw6p3iXUkb0VY5i6pi+h6e2cy9r3AwApCvabBB9g1PDVxxuaRBUeaGhhl/RuvWMKGfcG96ISE= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d012fb92-1fa0-477f-65e9-08da89a70a49 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 10:12:55.2722 (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: k0h/gTIZ2k7i3h8iDlCBlgVoEkBI07P+xsi88rC4PTvOfeT/dIppy8w/9J5dctxCd2PxBuDEvYx9zsg68XnpLxrZulhGKauctDZitM0BXdc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3023 Received-SPF: pass client-ip=40.107.8.130; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Set data_end to the end of the last cluster inside the image. In such a way we can be sure that corrupted offsets in the BAT can't affect on the image size. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index 7e8cdbbc3a..c1ff8bb5f0 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -514,6 +514,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } } + s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; + out: qemu_co_mutex_unlock(&s->lock); return ret; From patchwork Mon Aug 29 10:12:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957655 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 1D6F7ECAAD2 for ; Mon, 29 Aug 2022 10:38:20 +0000 (UTC) Received: from localhost ([::1]:54954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSc9r-0007QM-6k for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 06:38:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblS-000176-UU; Mon, 29 Aug 2022 06:13:07 -0400 Received: from mail-eopbgr80130.outbound.protection.outlook.com ([40.107.8.130]:50395 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblR-0005zs-EY; Mon, 29 Aug 2022 06:13:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ISZyzsuvMpO10FdwclOlfUWw1ONKmo/yqei1/NFuE6oaROsprsRBkIRW8aw0Fe/7dLIX+Gn4NOQXkBaMc9ZukFONEyzwNcpxF6UifFSONAotiuEQTTQXMACAl4VB9TY1r2e3B3FMiaCND9VJn3DX2k0ME7lCpuS9p//wFWoWt1BSjZCQ0QPFoW04ZPMcMdwF4klfatsjZgDkCVf8EDXALDWyfQYp/14yW8IxyG3A9y24aacIxbzxVvlPnMQHrwusZ81HLWO4ui+Qj6240w7zgiREgHcYNs7Xsngn0jPq3+92jQq4PEzPXOxiE1wrhiVjrvsSnXVWq+ZMmUzA02vU/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=C/w8TkRCrIOArPPvjz5ambAyfqUEJor64AjcnOtRf7E=; b=EZz5KyZpwr9+oMZxtenSr1ZUNcqtrcnPywBoz8/TDH3eR1d833xzmA2FqqmmED/rt4Hx0aK4mNt4ZcogPdZtTJjepRfLjibVadLMXFiFbiKOmAg0+bKsiCtApnI0sWjNoGqKS/Aqik+3+wEMh4X39kN9700YtSg0sNq4z/7CUc9imsNNf/GDrqi1GinXiZaa/9LjTJX9cEIqVMKXrajwNmILfXeQ9GvCM+lHKxsJWaAcS4T8EhVcWm36JUuyuUUrFoGTEAGVCF1L9gFycsZJdxvfnLJa2M1Nr5/ToAMlmrV43SkbPSJTUfXZjCMBYLjc+8afECjx3lgTUHQnljtaOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=C/w8TkRCrIOArPPvjz5ambAyfqUEJor64AjcnOtRf7E=; b=hh/fyfnAA5lFbUjKJHCAcfOH76G3ArWUEYBU/A/9vRvI8vYjyvERoX6soFC/Gkxk+iSyget2G2/h9fFkqgGVgAtYzNSGzu017zXhfc8nhtggIWw/ZT77w4cAT1vifRteRnAPJk2iBM7KGM6yj6KYhbewl4z+iAiGXc/CE+Dh8LqaDkSScFAMfeAloU3FKePFzcnRwPDJUJynjAdoZiC3bc4hr8D1IHP6lq9NUAJ++uDe0yRwY3/JpVkf+UtVj9sYCVl6oEWHD8P8XAmlew+Jf6qo5eEibaK/fqwlnf5fw8CJsy0LJeXqvxmIJwpVkdqksw7Xh1La6KMi7msfobdnsw== 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 VI1PR08MB3023.eurprd08.prod.outlook.com (2603:10a6:803:4e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 10:12:57 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 10:12:57 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v7 04/10] parallels: create parallels_set_bat_entry_helper() to assign BAT value Date: Mon, 29 Aug 2022 12:12:39 +0200 Message-Id: <20220829101246.343507-5-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> References: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0139.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::14) 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: 9f16a52c-f684-40ff-49c4-08da89a70ab2 X-MS-TrafficTypeDiagnostic: VI1PR08MB3023:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YlpKRkpd7Vk2K9zFAjY7EX3P96LWZvrfHVZYJORV49xp4UOxTg5fC2UjVCI47OZY7onf7ZXrGlyy5FaFOsSHZqBS/sR/3E8WjfQTk60C5PlLxDkgk5ferHHRWEUSgE2qeSMXATdo4idQwERGElvQrD6QG4fYmESkOFArW29XJj4VbJxwTe47mVqSEOC3g2ukX/wPePN9Wvlr85R3hnFpDVGr9DNZnucddbJV8EDVYzCK81wOC5VJt7V51fKS6iKlOXKkqr/OrJN7WnxwfjdQ7ekIwLVHh5kFg59zMHgNEGpEzzKdxOa02rInIscOuTB6iqKMgFxxvqfZSNw3Au7k//Ga5FWRR+duviBrxEGsJk/ov3VSqyPfTx5PUgk9DeHjZ5XllkBO+m++AA0UUhWBXjz1QSQXn2RBD12uckCtDwixi1lBvDwOKIALAO/5Ajn3jwz7Ot37FUbpT/tMpDwRHrMngBLd36EzqVHWZ9MNmV6wAn4rgGUacvXElPPV0RDffBk+4iI/Aq+GjeDmOYfXCJZBaCNXinjCLRunzPqeKD+0VxThzIJiP6UwizDSl9HzNaknV+C8Eu0QlwWxmjOCUUhoFruEuS0VvXFpVSsCOHcvnvPe6XKPnDSPu1JOff4x+ivogyCyBTtG300EmtUBkccJCBfEMwvxg1pdLbYuX5CyDGQ/RPFckyuxFLgzjuYW5ba53zGLiWlrHxzcpx9eHFQCJlY0UCYO2vPvxVqM2UH3abQb1/UCCj+jiXF6tv8WfSUwPf2CuKvFIbe+ECZUXg== 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)(39840400004)(346002)(136003)(376002)(83380400001)(86362001)(1076003)(186003)(2616005)(38350700002)(44832011)(38100700002)(5660300002)(36756003)(66946007)(4326008)(8676002)(66476007)(66556008)(8936002)(2906002)(6666004)(478600001)(41300700001)(6486002)(6512007)(6506007)(52116002)(26005)(316002)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kmXyqDxZgDoOTLYvsa8DzTP+SU/oaCdH/ONEzQJ2wUNb+YxlO+2UJ9z8/S5cBlCTYBM5zCy9w41J6aNGyitN6CowJMSriZGBBh0WObJtbk2wYBMnG5XojcH0kIlJeaDndCEGU6BS14pPz/FAxsN267PQgF9W+Ge47SZ2Vwpnat9mPh6bun1prM6ZacMOJgbZnR7Nmyq/n7gRfncIEz2ve9PQ097Uws/gCw5UMCHsl7QG12JF02vxETGfCFjiqZqeKqnAWSEnuG1EstVw+BNkHGKHXyyCetN4hc76KRVmi9w72iQ9bgAC2yBc5zM2PYvem2sGTbuwLzvmLsO3avpvY8TombIW82OuVTvZF9hzYKkS1uN39NqLbzaMYOUJJVzZRF9pVR1ySvTbM1oWWX4s7rBBgzTk2xrxFBtJ6iDrGq5Hdedd3IYE82LBrOhEdj8rNlFYx/4x1b9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0SXqxW3jnlifm9RExZLpsAllqD5OQ2AuCJDint3lIbAfTacjSLs7fICeubt2+HxtYRVs4zNh1bsdbCfsPgTaFjX79AD1j4= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f16a52c-f684-40ff-49c4-08da89a70ab2 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 10:12:55.9908 (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: zEyk+Fo1IGt2x8uaVbVFNtWlkOoXrCB3fQ/nFPSD9NPgc9/ctKhJmUAcJyOmQulN29tXKbRfqK6QNA5qh4Q1mU6F1RNjw6ya2BGmr6Tz4aQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3023 Received-SPF: pass client-ip=40.107.8.130; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This helper will be reused in next patches during parallels_co_check rework to simplify its code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index c1ff8bb5f0..52a5cce46c 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -165,6 +165,13 @@ static int64_t block_status(BDRVParallelsState *s, int64_t sector_num, return start_off; } +static void parallels_set_bat_entry(BDRVParallelsState *s, + uint32_t index, uint32_t offset) +{ + s->bat_bitmap[index] = cpu_to_le32(offset); + bitmap_set(s->bat_dirty_bmap, bat_entry_off(index) / s->bat_dirty_block, 1); +} + static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { @@ -250,10 +257,8 @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, } for (i = 0; i < to_allocate; i++) { - s->bat_bitmap[idx + i] = cpu_to_le32(s->data_end / s->off_multiplier); + parallels_set_bat_entry(s, idx + i, s->data_end / s->off_multiplier); s->data_end += s->tracks; - bitmap_set(s->bat_dirty_bmap, - bat_entry_off(idx + i) / s->bat_dirty_block, 1); } return bat2sect(s, idx) + sector_num % s->tracks; From patchwork Mon Aug 29 10:12:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957649 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 65E44ECAAD4 for ; Mon, 29 Aug 2022 10:26:56 +0000 (UTC) Received: from localhost ([::1]:58664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSbyp-0003CX-7H for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 06:26:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblR-00015D-HA; Mon, 29 Aug 2022 06:13:05 -0400 Received: from mail-eopbgr70135.outbound.protection.outlook.com ([40.107.7.135]:32646 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblP-00066Q-OY; Mon, 29 Aug 2022 06:13:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MiIJGsYvzv3lLvaxdCqb8orJKvGROXaArw6+wmzONtxKLRVvuSFgDzdLQeItMFFMVUJ/VddAIkL34fVj4XlmSrvRbMqYlnIghsOrp5hH62fEWSa9HaWBhdNdK6EJrQCz8BOjOjY7O9RI/qhVW5b1PseVZy+lTo92LWOJAd6e0cQpaddeMp8ugVOVjYdiEvHTpR2eQ9IpRi71KNnYW+jAvQ4k2jyXsbZ7STXX3lw2Zqkw71NM4OJZzLM6PSgq4WMtB6DjZFDJuxRfQxfwvHg9eTWNEbsBBmbq/fPmNOh1phjzWLfH9NAICPUL+CjHIuGEDGGYuF8sx5GWAJguU5V3xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=j2iHD9ZuqkW49ytEgmewpRVI1oNPJycke20yFKQs7Oc=; b=lEpVo52NYVxtMdIA6Kf8N+3jOZvanE5RjTlZr35+PQAUHm+81vEgtCCikMTlrGeJLLjHjJeeVpDjSBACL+odWEL+99+PeWPtH2TU2bqg3WGs3pOhD9hTAaDhphDhq3KmFneTvEydsuEojswms0Ldk8usg/86QjxPO4NLDgn/hj4COPoPbsmx3aqOQJQSoUSl5CmmlcrDoMKUb2rsV2WIUaGai5vrNMdT6jN9t8m1BnL86QKKt0mvu2yWrSH0eeYyCdfG3VbH2dSgdKuRcz1IxqaoRUUZsaKxJb/nVA+/VrUQYIob67qVZMNny5vNcayoMbZwHNNsbTdT22efjOmDeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j2iHD9ZuqkW49ytEgmewpRVI1oNPJycke20yFKQs7Oc=; b=e2XaYVZR0xdVYdntWkHzAlkALXAP4LdFYKPudhwHDcp2VDYdKH0zhqRr/7YOUMe1WVbswTVoK4IFpwsz29CMgh5bhfNyzSrfAT1weaYcohTHf9FR8aDiJlKR6ZyQ+ceaBzRdc2LEuGzMR7xr94lxhUMHaXzivefwcFniPr+kYCZurN9ArUKobg6yTGtpmN9CSyblXPvgGiXojqpMoV/xtXBw8ncifiuMiYzAAKZ4G0iVF0ZH8kF/B3bQk8FXlcgz5JfFfcvEIKP3Blaj8MELbpDTSDztKG8UEogyRjeC/7dDfqs35hn+gofZxzsGErMTJ+bpaHDF3Ec2irb9XguHwg== 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 DBBPR08MB4725.eurprd08.prod.outlook.com (2603:10a6:10:f5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 10:12:57 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 10:12:57 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v7 05/10] parallels: Use generic infrastructure for BAT writing in parallels_co_check() Date: Mon, 29 Aug 2022 12:12:40 +0200 Message-Id: <20220829101246.343507-6-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> References: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0139.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::14) 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: bfc3c0e1-7b3a-4397-dc2e-08da89a70b2b X-MS-TrafficTypeDiagnostic: DBBPR08MB4725:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vTcS1J7mPANmzwjf0Sd4Xv2BLvLTdKU73XIeIxe473pBmJ777rfy39zAuKRbHxeS4G0Uy0KKniKfhSsZ8oCF76k4BS7xVyJedVwBDT4xfC1As+0Yd/WRYOmucXZ/LWF9DKH+tURiqb5BD9SWO/h/dsKlDsXuVOLXlWZyY7q9SHrXGGohi275vOLdHBaSpJDKAiBU/vA1u9wmQnSgeavHj23/igTF1b0gFNckljBDt8zq9yqFHBEM0c9LCaUpmQjDhx4F9dEJtL1Yodujoj+V9xuAkV+R6OJSaZ3qpOJHA7waNuPtcLvyVao/ZItxsfozYS1sGZ4qy4FYU2+TJPfkVKFITU7tMJiIL4xIxquIQiVqr20AoZqEM656yk9Yp7gkGXdeIh98IiAPliN3SoMviILsrRl+Q2wQsMsPbKk9Vag4Na00Qg58G9Kvj5H5kZGi1FceQWw5eT3vKYSFX1CmJtFqUxatBmxSk4eCnIcnjsNRwVTd73EFshpXCA7bAucxWUM0TxOYeNkMEPo26MG/q5K3zr5Uhthj8klgm34RkJE3KyN5WUYSazPebF3FKwDcxXDc2mC0kphkikM9fk+W0WWKT/M2cK04zYwgfY+x6oFXBykSEmCoxSI2Bm41MbU/xji/24y9CA7yXwj81UcKb+SLtAgHy+9agDq/l/LW0L/jy9EfXUFPnwOOqxLABBVJNrdBbLoEA0KkUSvA4WHJVomjl6wLO9zoG3akF4cApYHroZaC1E2wLHtMzmz1jgQpP6xIZfowVBF6VfzfUf8MNcDfbiRAkGFp0gG5SfFm6b4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39850400004)(346002)(376002)(396003)(366004)(136003)(2616005)(316002)(1076003)(36756003)(38350700002)(186003)(38100700002)(86362001)(6916009)(52116002)(83380400001)(2906002)(478600001)(41300700001)(6486002)(66946007)(66556008)(8676002)(4326008)(66476007)(44832011)(6666004)(6512007)(6506007)(5660300002)(8936002)(26005)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: svm0HfQyMUgpTv0uC+mTtJmvbCHT/q2LkZfXw2ole59REeiDggIF03avM0DqNXpJDY3OcxQsW3FPCXR3IL9odc//wwkf3tbM48JWYd6uZDG2akTgnLBOtb4Vww/cpttH6SCpnxC31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DzpL7Xf/jkEeouSMHK98d6tGlwuXn6acB6q7qr2rDI3sxwii/FA6ROYISLzYTATWDn2YNGHJjeIY/yd3zEBq9VflU241z7BpPGJbpAcV/ij9F1tdPQK7fKWWbsp5IlfPm5uLkpT6mhsoXtsQifugV8GXVjC4G05qPpPF3WQTzMXcBl/tE0Bhf2XShteURlgGd3Ha4KCqm2JqzzL1sIUK1QfSBdR00SEeNhmgnOweuxkzar3yhmNr1U2G/NFHXAuW1okkslABWwBLrw8vbJ5Km5zXJ57mwHAnTfskI3iiKj4HjGPa7C0vLFs85VfO8oYGl48VA3gKIv0EW25seq5F2XvHKgKAA9LrebtuHswgy3mv53zO6uJNSed9zG/yNEppDlTipf3Jwa+y+k3DnpCFJIKgcxAXJLXZJxKjbC6NF/RuDU2ZWc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: bfc3c0e1-7b3a-4397-dc2e-08da89a70b2b X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 10:12:56.8188 (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: dXyd7Vn7v92JvDy97uui5IKcZrQict7T/PAyymhDif4b5NoMUSLgbVprG/NcE1DtzDZDcotlxrNbY31yelgU2/jd5KLigt2B9H78SOt3eu8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4725 Received-SPF: pass client-ip=40.107.7.135; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" BAT is written in the context of conventional operations over the image inside bdrv_co_flush() when it calls parallels_co_flush_to_os() callback. Thus we should not modify BAT array directly, but call parallels_set_bat_entry() helper and bdrv_co_flush() further on. After that there is no need to manually write BAT and track its modification. This makes code more generic and allows to split parallels_set_bat_entry() for independent pieces. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 52a5cce46c..b4a85b8aa7 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -425,9 +425,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, { BDRVParallelsState *s = bs->opaque; int64_t size, prev_off, high_off; - int ret; + int ret = 0; uint32_t i; - bool flush_bat = false; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -465,9 +464,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++; if (fix & BDRV_FIX_ERRORS) { - s->bat_bitmap[i] = 0; + parallels_set_bat_entry(s, i, 0); res->corruptions_fixed++; - flush_bat = true; } prev_off = 0; continue; @@ -484,15 +482,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, prev_off = off; } - ret = 0; - if (flush_bat) { - ret = bdrv_co_pwrite_sync(bs->file, 0, s->header_size, s->header, 0); - if (ret < 0) { - res->check_errors++; - goto out; - } - } - res->image_end_offset = high_off + s->cluster_size; if (size > res->image_end_offset) { int64_t count; @@ -523,6 +512,14 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, out: qemu_co_mutex_unlock(&s->lock); + + if (ret == 0) { + ret = bdrv_co_flush(bs); + if (ret < 0) { + res->check_errors++; + } + } + return ret; } From patchwork Mon Aug 29 10:12:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957652 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 EE49CECAAD2 for ; Mon, 29 Aug 2022 10:32:05 +0000 (UTC) Received: from localhost ([::1]:52466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSc3i-00015Y-JB for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 06:32:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblU-0001Am-4U; Mon, 29 Aug 2022 06:13:08 -0400 Received: from mail-eopbgr70135.outbound.protection.outlook.com ([40.107.7.135]:32646 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblS-00066Q-9Y; Mon, 29 Aug 2022 06:13:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XhQLX60CDGHU4P+uujYkchnmcrUkdOCrixhva/2N4Kw6uBYfCoNih4mdrKL6nx/gEDMqbsSDmuKBPPEt/kNUscowe6rFjfIB2rXROhiBueza5J5CPbbUhdkSZV3I1EyrvKRQBS6WM7UyZWUZgs5UdtlyrzE+0uyd/dBFGveM4oKOfyfLa85inFYxXvSxzxhmd/q471psFClNQW70keDBgBROlLy0McYOkmWmuzqCsgey2CKfU0lxUisCwXUJvTmtizh4Y1qwF1mYjpMhMqWUAhwNIt8vpLNRsKQVC8rcpqGTcMoG5EBHmNOstYUnATcYPnnOcLJHWeDlrTdtic83rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tHAtEScGJd+8SaeeRRtxf4JjrblIDlJicxwATC0GIGY=; b=EEL1BxxpvSrjwjViQ0OlAngOzQKYBAd20ECaLwlsBEphDMQoKEDYHcLRKHsqG9w0KN2SLmIsFzKUhptj7A7+Meo5WVNKG9o/UGonXTfEDJMdEYM8ks9ipqOYjsEP/Zap4aRl/XmuARYxZa2QkrayYK0clV0H8vP5ntfnxPYw3kRc5z5x0i9L/AblHR+M74MI2/aDo/ukoijuGQYLQ1eyMZDLLlCv0Bipm9R2F2WKiRQ0erzjF7eJz3C8JeKAQeV+0gQ58BA58CqaLx2x7K3yxlhC9SokR0mQKw1V74Yy9LDqtJZDqm5za3D9W0VPWNTQlSrisLoyvfeRYfUArUlx4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tHAtEScGJd+8SaeeRRtxf4JjrblIDlJicxwATC0GIGY=; b=lXNyPifjxOXHMGFQByUGNRfBd6jn81eOAstFU7fBEOXqEDt04NTx2NtTsto/W1Dov9SH8/cTgf+eq2wv7rRWM60+/dYVaXpadct10pLgh9iiXLB5brm7Drdrro+GLX+G0z0F09dv1AlW5QQ96MP7YYretSz1V6hXhcx8CCVzpyJU5Tihk8kLhkijQbdAZ2lnlgJ9UTBqNshf1FkEeCEjm9hmvOSVUkge5qfHQFQ3dunP6ZyBNx0aCCzX7pnzsMaRzYg33hmmBHBQMxzLwHiKI6f7yps8boGq/VYjWAD+c352DDuVVqOylAjq21qpIhFDgeJQd770SX1kmt2EoPu75A== 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 DBBPR08MB4725.eurprd08.prod.outlook.com (2603:10a6:10:f5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 10:12:58 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 10:12:58 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v7 06/10] parallels: Move check of unclean image to a separate function Date: Mon, 29 Aug 2022 12:12:41 +0200 Message-Id: <20220829101246.343507-7-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> References: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0139.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::14) 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: 9a3a4fdf-c947-48b0-2ed1-08da89a70baf X-MS-TrafficTypeDiagnostic: DBBPR08MB4725:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BhD84fsywEa1nH0zha0dbxU3PaRP9grN+9+U+sk33hKPb1sNleBty8jsoNRIhlgFBNw5t9VX1O41ho9kcXcServxJ+KTNfW1wxMbiYcj2FD3K3TXuu9Rg++vPJLsaV7p7EC87WmGmMMsKsCp1eew9ic1F031UjzGtL6gnQiEBOFHyxK1kqa7/HLgIsVY1X0BRerAWHUvYa33BI6D6z3b/i82RRaZzOZFL5BUOx4KqvkiyvZzpqFRBrcOn0quP8Rhbhgefvp1b6qdwt2+Ta6jdGteLjsJ12GWdlGnfaGvPdhtGvuq1uMyQRCsM0x0ThBYTgHffVpHl+TJMrEKs2HBzZOmRFEd5dSw5RqPk94Jy4JCkMRSHOqOTQicQnZj6DjsYPQvrzp24eTiCiXtx18GMZ1x4nI0aU7++XdDPX0TWrrQtFfyieGQH9K0FVK8F1pqofVDIyHQ09qUS6XvWnZ9kRNA/RHMq2/7XcGWSPonhca0d2vD0uFXjgNlF5iAvGrsv+RJm0cAyhfPleNeHWebtAHG7tlH3MH9nVwUS1ujvJYzrFnNG7/RrWH6Qq7XtEJan2uDvCvw4b5fd88ozYCVXyWRCXAEbr8xGhlF0VohFX7u/0LbxQeSv2+x6BjTeS7pYjhXvjxuhZ0fNq1B+TO9X2sVStxeJdVkhPsMGDcMaefVMlGlw0om7Vu1fbxsTWLz2MB4Wtu9iwBT4cANimKsK+6QKtmsrdTQfwRS5hOnM/wnvNd0CnuYdfUUyAHSIDu/KgiuH6EdJ9MOaVzJUbrHuQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39850400004)(346002)(376002)(396003)(366004)(136003)(2616005)(316002)(1076003)(36756003)(38350700002)(186003)(38100700002)(86362001)(6916009)(52116002)(83380400001)(2906002)(478600001)(41300700001)(6486002)(66946007)(66556008)(8676002)(4326008)(66476007)(44832011)(6666004)(6512007)(6506007)(5660300002)(8936002)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cqZbCMGCFP75+lRoFa/S3tN3R22isQ+4ST50mGRW4fKYHVxnvhtwec6l7O1sx2BKg6fou7uxuiehyeGLLkcFBL2NxjVp0xmg0/qNohf8gB/erQKMQwvbbTMkJtTlpqBX0DXSDuH3J9yKhUJc8yc9tyyGvEhef90ZpTPNyEbqEhMnZBm+vzgi5CO8eMSJLHxkdS0xcVk2epPOdGdYQ+w2oJ0KYMAA8Y+eVA5QuAPpd5GWoi1L/FcAPguwGYFm2IGOhQa6nYabnnlHl4fM6dYLhStwm9El++YQmI4pG+7lLrKf17rFpMdVC6wd0phF1+SA8LOoOvU0VL7G69THJDcPHyItFfWOqMHtf/FcO+kB/ebkhYddZgmdT6TgklI22g9Db/2XmlBeClFTJyxKIt0I+jVJlCnKp0XeEEEAtTUUs8KdvUcCOeYUou/bh8Ev9RZlxqlsab0VQ7d+cvDDTolKHuIVSN5ofG6G9OUlgfp/Dw1+zaRankJ2W0OOGMv6XaJPQDNCZeHrW0MlpmByLCjIjVQAlkZfcRJwHnk8bf1dJNu5rX0LzZ0Kck/K52a7vnb48TpdSYdIDIkVtCyzJtMYIiTzX9PraZm8f8tuyslj92bOmYCEFGfjXmn+VUSJpTuarGOazW6uDIDuo+H6Pu+Gw9hHp5l7NaPo9pI7bdp+BexlTCPLtlM5T9vp3uJVTAvXHraLy2raT3W1V+cS82UF7cF+ACQhRGeaQLI8k8Lny/m77osxUPUFd6EA18/Q4GChicTM/bCb/1e9pHKzUptQooukueiKx7iPCn0oG4aQ7zcJLrFjiM8jKEh/jkFRbFaSU7vKI16RWNzdY4hqycER0dapK5fA3EryUWRNrfqTtlA0whDh/oz+S1TR3oBf1LHYvcV8/3hVcrmpIOGfVB7QxCBww06h1cvG+mvdlzOhV+RN76nXyIoBcVWzZ+ozuiA2960vtz6FJwZ6y2QTPffBvFQl5Br49zcul6gHRQt012U8huXUlvRBmClozNDNyDhqbn5C6bxyjnumGakE7A3swq6L2cfhRwO17xRkNJQGurU+DZMwOUJ0iyrabBpxloq/uKC7529DSeCn3MweqcSNZEu8s4BovNvYNjipf7PE22h1jPTWo/Y3rle+etVbDDpOfldWVeWo+iP+0hSEijAHGuBdqoW/K1fG1yvXGabYXftmRiqgChKGQtIJiFRGDUsD2Wu4OceXXCYZbMkwNf96pLjEuw162eL9JMgfgdUqIIuF7K31CrNQAQYpMFxrr8fCzEsukamYoCrBS4xb/iCRBaN2PXg2PWLOEy3+fPee941pasaoNZlFWBM6/T9am2d+vuapmzZXnGdwHwXvkwWO06J3r5kSNdp0s1pXUZqZc2bs7YyPecyTWXpCWxkcLrHTyd4EUFV8ySBEk+2McOoyGSbJ98sa5jUF7f6Bs0aCJ6darKNuCJ+KeAzhoRQh77tiBI7dgh5jrGbO9toFy/dNTyBLMT47JZfM953XZ9UT/mYcfo6BT5Tn+EUMdvY0d8Iep3l7651qJzVzV6cDcc7ZAYyWMI28LxL2Zf/TsLZEhQTD6E5U/NRxCOaeElxAwQsr0AdggsN0jYvpeu+jlYaKIL4/wpWtaWxXFqMzFtbvB9g= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a3a4fdf-c947-48b0-2ed1-08da89a70baf X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 10:12:57.6482 (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: tWLE176YEz7Rq/ilKa+7fMtYpuvLFDReVErvgNaWAe0qrOo8eSqvPOF5xaWWltEAzYMDqYT6w2ip3h7LrayVuow6C2oX77LUm9CwmIyhtAw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4725 Received-SPF: pass client-ip=40.107.7.135; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index b4a85b8aa7..eea318f809 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -418,6 +418,25 @@ static coroutine_fn int parallels_co_readv(BlockDriverState *bs, return ret; } +static void parallels_check_unclean(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + + if (!s->header_unclean) { + return; + } + + fprintf(stderr, "%s image was not closed correctly\n", + fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR"); + res->corruptions++; + if (fix & BDRV_FIX_ERRORS) { + /* parallels_close will do the job right */ + res->corruptions_fixed++; + s->header_unclean = false; + } +} static int coroutine_fn parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, @@ -435,16 +454,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } qemu_co_mutex_lock(&s->lock); - if (s->header_unclean) { - fprintf(stderr, "%s image was not closed correctly\n", - fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR"); - res->corruptions++; - if (fix & BDRV_FIX_ERRORS) { - /* parallels_close will do the job right */ - res->corruptions_fixed++; - s->header_unclean = false; - } - } + + parallels_check_unclean(bs, res, fix); res->bfi.total_clusters = s->bat_size; res->bfi.compressed_clusters = 0; /* compression is not supported */ From patchwork Mon Aug 29 10:12:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957653 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 43D7CECAAD4 for ; Mon, 29 Aug 2022 10:33:01 +0000 (UTC) Received: from localhost ([::1]:50314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSc4i-00022f-3Q for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 06:33:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblS-000177-Um; Mon, 29 Aug 2022 06:13:07 -0400 Received: from mail-eopbgr140108.outbound.protection.outlook.com ([40.107.14.108]:58593 helo=EUR01-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblR-00066e-Ai; Mon, 29 Aug 2022 06:13:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LP2w+E5/C5ojUkqQU5d23Wczj42Wnln1bNDGHu5J4bc8Nk7A/HsVdtVWzSlYhYLAsA2wjg5Ny5z08OMyjwgSSGIp35i5VXWmkj4rgQf0Rwtxlbsn8oYuJUahV1AP4QjQFBvGu+G+b8D4uZgcJUwlJIDjEu7Ff9V7DzWT8dLUb3AZ97F0JoExfDrUo+QqNYcXs/xFZ9AblheFB4XzzHZnGUsflOvu0q+4SVyuhyI0go2KctSMCKEQBgjjMIQEg55qKqXmrw22iTK3rx4fuoM/9rX7b/TNCBKIB3d0+jnGVl9k8NY57ex4waDBeUnO+F9b9/WybBvssys8nv3s0ySZEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LHDIe4Iu3ENxd+Rq6crXwWLf1mk2dxrBPElvAXWaSC0=; b=Se+IS2dva+qQb1i8wXl9pHuZufdQfcOWQ6aVthUHrNtr9dTbpA2EdSr2ajRxkGJb+TCPzh1ZvtGlDMa6xv3qNN7UVjHwEYeKFOmpCwr7MuZMj2mZwcE6OiJoeiFEQb2EIFRa6WrIrHwqkvA4Ivd75pODZbWKMZka6XIwz7tcUoVtgKVqZx4d089YqdUZ7/RDZFFxLia+nIf8eXa7vw/XwY0+AKnEEhN7BCOB9Tw835RTThPKgQQA0Y4lrxsN3OPXXBnUlJ45eM0gl3/ePvArU5F1hXNSaxOsW5mF0j9Bfl0kk7XOBXk/IK0D6brk7yymgITe6YITt3+esFiltPUlQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LHDIe4Iu3ENxd+Rq6crXwWLf1mk2dxrBPElvAXWaSC0=; b=haq6ZmW8gcMtVDf3fKMXm4T666Jna1lwdhHgGbKJEraBUszp9we9KLx3mhRZeKt8STERzgUd+HqFv9dw9lw1cIT8bMgYIiDibVhgve2DtjDXNIW76dmHe7Mwwf2BveJiXO0bupW1tG08HhXtqegFh21aC3t0MQbkObmbMmKFV5OzhTbOF/8RMIfszIH4KFHSsAft6XD/U+qyYcJjELJjQRTOuyiRzhdgSnw/gR0MT68CurO+toxvuCF0U1BEpPmq/U98iki9t3LAkVWyPU7pKIMGuPKHLmJyGaEIL/fmNKEFKWRq9/YD2Kg7We+eCuheh0fYckB4i32EBt1veFQgxA== 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 DBBPR08MB4725.eurprd08.prod.outlook.com (2603:10a6:10:f5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 10:12:58 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 10:12:58 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v7 07/10] parallels: Move check of cluster outside image to a separate function Date: Mon, 29 Aug 2022 12:12:42 +0200 Message-Id: <20220829101246.343507-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> References: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0139.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::14) 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: c384daf7-0c08-49c8-3828-08da89a70c1f X-MS-TrafficTypeDiagnostic: DBBPR08MB4725:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gHVyc4CLwAawmaMQ+wi9DDtdmuJBdUDnLRr3BYysxVw5GgZJ13g/djf8pwXPEYKCxBjhsNUPE288NGPXXlP78ngQonHfvNPBN27j13QEfMwCgZkIPahBUC3S733GTdEjEpI+uI4uZzOIlhq5eprzESJSsVCxcmK4pCGuQF1SwZZ8K9lozIPXpZ9S/Ikfh0JgcZghcCbtzmSfyArLjWtaTFOS23LCCkteLFf8AuXqYVfhD/4B9jFPRLj2qtt8xW83TaL+Goc6epSuJnmI9N9oDVwEg2tsA1G3KrKf6MBC3VPcSlfkju6OUCV65UUBmX47DABwxPoknsjJwlqf9YskP96jvOvAGiRHtRg+Oa9D1iFhpzPLGXOzsb2N0l9JB9GMg/wrR+ucHvPpjs5G2Peb+cv2ifgwnK7GPhnbfn0Zopfp73DZeIz4Qie0rwKPGsbiGXq3CQTyn83Yw/8SEtu/1SwcAXDsIfVp+yu0jJwPRn13pPDCxJuD0v9U3ETajpBVXtSU9jC6Z9UJrvjJHvPrn3wh9Be98J33aHdPJTGvEc9s6j+iJRnxAz6u/bx6b4HfigjIYAmsuNn1POAX9XjzxLtIcdlFFgJgVaN5xR8R16k6eHOGaCqJ7mu2AoCcbiMqwXit2ro4Chi8z/5luSSPRYKR6GTwWcO7OAvVuFetRa/PRd5dY1t8Q5WfoCbqb5fbqzNeFV3Y5Im42SfICAAazqbzEMFFnoyEbyNhoIlP1yivLGayRLEWR6wZZOhdzdmIRuUGoEZApjO8YSSqmEwL4w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39850400004)(346002)(376002)(396003)(366004)(136003)(2616005)(316002)(1076003)(36756003)(38350700002)(186003)(38100700002)(86362001)(6916009)(52116002)(83380400001)(2906002)(478600001)(41300700001)(6486002)(66946007)(66556008)(8676002)(4326008)(66476007)(44832011)(6666004)(6512007)(6506007)(5660300002)(8936002)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AmjTbOm+mTZtUkwjYN2MRfujF+fs3zbKY3WNh5LhfEIC66BxalQrZjJ9CVukZGzkldASuMl05zd+ZbQQ9QbnwlssEDnzMBVK4PEUCAjj/hX//pFhgVcsY5uRV4dy8KHL0iMw5yAGH6gte/uko0WMyILFw+eze5EPsV+adu54GefACYSNEbBTAOkp8yCUE6i/k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e50M8Ckc0bxWnoEvKeSENBN1KABxhpIytl8w87da9kERL7NH5d2u0XCbqafhuaRY8JROlP8ZTIv3kx+mYePiiTufXHxv0UqPpZMCBIsuPnvh7nLStZ33SxHO2ejdrVUjPSlYiASEc5o5Rg+sGjsqCvOv3ICbrYjvT+ExKAU0uN2/MrBrXk+p937Qi1/0qCD7nBWNjy/qyYSz/1IL20u+LzirxxWOtR07x9nIPTrTRWyt6YN6WSTEI/rSYDJb5xJqX6iYD3ES8ynAhT2/CY+hwKGU7tknqyoujzm6gsQWNfsmDaK3OSqrAJJefRzksPT7w69asnF1UEbx/MnnVbdFX0K/swtZD8IptKehvJtfnx9fyKl+DIk8ml3VDU6g= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c384daf7-0c08-49c8-3828-08da89a70c1f X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 10:12:58.3512 (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: ZjtmiFcA3awxh0/Lk9jnmCKvug1DawNBus6TWhoDqACtJK1zeg6Tkr+WvSl/7yIIPJjd7nwphfLWcyqia4KAg2wy3iuD9EyUFtEVm8pLhfk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4725 Received-SPF: pass client-ip=40.107.14.108; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR01-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 59 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index eea318f809..f50cd232aa 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -438,13 +438,50 @@ static void parallels_check_unclean(BlockDriverState *bs, } } +static int parallels_check_outside_image(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + uint32_t i; + int64_t off, high_off, size; + + size = bdrv_getlength(bs->file->bs); + if (size < 0) { + res->check_errors++; + return size; + } + + high_off = 0; + for (i = 0; i < s->bat_size; i++) { + off = bat2sect(s, i) << BDRV_SECTOR_BITS; + if (off > size) { + fprintf(stderr, "%s cluster %u is outside image\n", + fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); + res->corruptions++; + if (fix & BDRV_FIX_ERRORS) { + parallels_set_bat_entry(s, i, 0); + res->corruptions_fixed++; + } + continue; + } + if (high_off < off) { + high_off = off; + } + } + + s->data_end = (high_off + s->cluster_size) >> BDRV_SECTOR_BITS; + + return 0; +} + static int coroutine_fn parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; int64_t size, prev_off, high_off; - int ret = 0; + int ret; uint32_t i; size = bdrv_getlength(bs->file->bs); @@ -457,6 +494,11 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, parallels_check_unclean(bs, res, fix); + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + res->bfi.total_clusters = s->bat_size; res->bfi.compressed_clusters = 0; /* compression is not supported */ @@ -469,19 +511,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, continue; } - /* cluster outside the image */ - if (off > size) { - fprintf(stderr, "%s cluster %u is outside image\n", - fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); - res->corruptions++; - if (fix & BDRV_FIX_ERRORS) { - parallels_set_bat_entry(s, i, 0); - res->corruptions_fixed++; - } - prev_off = 0; - continue; - } - res->bfi.allocated_clusters++; if (off > high_off) { high_off = off; @@ -519,8 +548,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } } - s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; - out: qemu_co_mutex_unlock(&s->lock); From patchwork Mon Aug 29 10:12:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957654 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 1C74FECAAD2 for ; Mon, 29 Aug 2022 10:37:20 +0000 (UTC) Received: from localhost ([::1]:51384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSc8t-0006k4-53 for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 06:37:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblV-0001Dk-C5; Mon, 29 Aug 2022 06:13:09 -0400 Received: from mail-eopbgr140108.outbound.protection.outlook.com ([40.107.14.108]:58593 helo=EUR01-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblT-00066e-Ml; Mon, 29 Aug 2022 06:13:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BCFSSOLH7vQY4g/pwD1CrzANawIEHltnnU+juHkTUYeOAYRlKBxj8pOlBKWHqAANu99IUeC/efn1iRYD8leNdf0Fm6bgxlpA01o2U4KGTm7RJd/WaiisDxqaXp5epjL3IUQE/DyJZ8c/wolmTnvWLzQ7B3Vp7ZRdAcAOdOFqwPYuNHdMEM/P41c/S3JL48ilWDgXorB/oU72LQl4YQSy66CxvRPvEYmB9nDHpCZi6t1sgbIUf9eNCmTufqsb0vRKItga0PT7I7bJoYkRw5rcE8FKdZcZrnOzAoYjvZ1ag4WokgjmcRfnOtAJWSm0g9i1Za1f0qbI20JVtPcdgGjJRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=f4Te2roYcHG1HhYssh3Reheea3kGA2fWHp/VW6Fo1bc=; b=CczIxBG4DBa6EyU7tE0gHPO7WrWPhBRf02HiHUTGApiMWwX/TMYJjSgQlQ2p9OIO1WCfCHydIjxCL63H+q2L4giDArIYyq8a9kP35lrGyTn8s+6ebp7jpHKRS8EIhjyJXvXd/p6FrgRiyKlskJXTznAK3rIT0d9eZbUuFP3vRVpxz9AHzkSf4NloUakbXGXGJUzL5Zsex3cXQQ66fZ9SW5cCxN3d0wJ0tP76n2r2fa2OGkGteP5CeqcULfjqOvM4pFoW0NzGbsVoDKIElHqMgIB7dFvAQJEygXi8hv3bZTiuuKAisZ/z1fIT12/yTl7ao4B6brdy/tBoSUikliK7NA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f4Te2roYcHG1HhYssh3Reheea3kGA2fWHp/VW6Fo1bc=; b=EX1Vse4XEkzctAWM3xIkfoo0NkwsYvyTvok2eIefV5HrIDCKcOFGWpHWOb/55s8+EAfWkV+1D8Q6CpAP6He5WsO9WoiVYjwfIU08zLDPiNW7fxphVdZxxiEYkB6yCJt2SYf7ECQFbyocAzKt1+ZSl/Sfl2mDrcbO7pnQjqdC2cO8sdxLuFObT2p8LICuDx4BJ0tBmKorbECARuSYagfXs8ZmuiZa7E8HABcEchgd6U04XsVz/qggkYEdZEsKr9FAB5n5XNQwZlUnonuZN5P5GxukOnPjbQpRci/AE3mc8v+j5Gq5txmo+QcEODlHbo/egCXGrJ8TIwcv4/R3uOwY0Q== 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 DBBPR08MB4725.eurprd08.prod.outlook.com (2603:10a6:10:f5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 10:12:59 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 10:12:59 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v7 08/10] parallels: Move check of leaks to a separate function Date: Mon, 29 Aug 2022 12:12:43 +0200 Message-Id: <20220829101246.343507-9-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> References: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0139.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::14) 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: 46d6fc5f-ff95-47f5-2108-08da89a70ca0 X-MS-TrafficTypeDiagnostic: DBBPR08MB4725:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ijez3AIB+v812CNzFdd13zBBSP5HiDIIaOqov52yzwYBjsnarJqEPg9mpF+clL8HS7kGJQXLW4usXX1m3Zirme69cezvZRoB2K0gH/x5y0FDYnsLPuakxY7PXAuxFy8rLm6jKE91tGz4z2mF0N98104o5ERaPbujlNXlWb7HVnUr0ikoigAXuI5bGZwCUXcchG/ycL3qe8Sh+i0di4fNYG3Z5dJixpbm8o3DI1WeBbw52qoxTjD+P9nabcVdVet6KjK82XIKc/j7knDMbA8rSCLUvVpPgJ4vQYTf0vQixS/dwCeukRqmaQtmQTM7CXJr6KnwtpRmzfTA7lSsn2HPcAbFnAvyvzviIFejja+3GGSl0VPBMPuUkXon8bbWP+uItSFRYPUdLmiTZewljXxMlZ7ZBUSsIdRaF+KL05ypjU32gAILsgUppAPKYa8Hj52MFvVuNJYMaKvKWv6S9WCTQoWGB2sasJ+yKCtuI0RAtFd5yv12FhjppT5o/6/0qQ7wgXD/BrYnKPcFKbikc3OT6odB2GSqGMnIUhQC8FGSBwBFsK4ltK33pydFVqlLQHCCfT/yFDaste+PV+j8Rrzoqu5j0uErlFDGiNspWWAa34/w/8buJ7/8zPUhMVE/XJYIlHG0yVe3/mFF7uRhfqVO3WGRPX1an59okYLsEQ5KT1hCb48oq78x7Rl5ocwkciEFTHL0XtjI7V8qQUzFbhSrJ3rArBzLq+NRKSMn7x/ckNTbSbQQT5191ovC3Cy6NbQLditsaABgb2qNZaz7cpa6Pw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39850400004)(346002)(376002)(396003)(366004)(136003)(2616005)(316002)(1076003)(36756003)(38350700002)(186003)(38100700002)(86362001)(6916009)(52116002)(83380400001)(2906002)(478600001)(41300700001)(6486002)(66946007)(66556008)(8676002)(4326008)(66476007)(44832011)(6666004)(6512007)(6506007)(5660300002)(8936002)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tWieq6UmYH+F/3g2cwiWRQ4mOm+yg5wsfUfL6skW5EYuuhwECLgRiaZYEbe47adRnPN1OBakscMv5avt0ubVKhsIRxPMdqtlL34jIk6/DbZeZl6SUG/6FkYM8fhWRWh+/O1qvLTzW5BdlbKPqdgKInWfl2QbePEc34aEBQv1fnFBmT3P3W03UKKWsoCWGZFcK4dNtLkoQsL9LZOST+D4UeVaG+U0cEfhsw8RZI0tOhkkE3hhvSm1f0uh+wYeAE4l5fctVYh7tCjM80pu+9+Bkh1rCl44ogGCGRAA1cOFqyOYLz7Kc787Vqi9EhrtzwLaNNs1bOzHhbid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OkTrKR4JMau8EFSqf1NZnkR9/gMQ2rtZZLB1XeSQjQOUQUmWaqvU2SpGKK8FpD3qIXT00FtEdIivQ1UE8IoYS5mE9WnO09hRvuD2HkQ1uiQNnYhHlKQhbhd6g5gBWu2+gBS6oEhU+DJU7h84d9WVdptUzUW6G5XkNXC1NW67OqLdOIZYCkBa9CZyj7Rly5+OSYv0+/QDPEnQIWBvHnDt5u31qTiidC2SjyaaIc4OWQb0FGdMmI64= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46d6fc5f-ff95-47f5-2108-08da89a70ca0 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 10:12:59.1960 (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: b+bfYUt6zkvYw5vDXQzEx0exwZsdlmN3mENSku3DaTKlg4g12wGahOfbND6o8+idxPFb1pzCBN7D7tzjrISW1WkOdXderr0+txmS+3DIGNM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4725 Received-SPF: pass client-ip=40.107.14.108; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR01-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 84 +++++++++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index f50cd232aa..1874045c51 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -475,14 +475,14 @@ static int parallels_check_outside_image(BlockDriverState *bs, return 0; } -static int coroutine_fn parallels_co_check(BlockDriverState *bs, - BdrvCheckResult *res, - BdrvCheckMode fix) +static int parallels_check_leak(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - int64_t size, prev_off, high_off; - int ret; + int64_t size, off, high_off, count; uint32_t i; + int ret; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -490,41 +490,16 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, return size; } - qemu_co_mutex_lock(&s->lock); - - parallels_check_unclean(bs, res, fix); - - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } - - res->bfi.total_clusters = s->bat_size; - res->bfi.compressed_clusters = 0; /* compression is not supported */ - high_off = 0; - prev_off = 0; for (i = 0; i < s->bat_size; i++) { - int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; - if (off == 0) { - prev_off = 0; - continue; - } - - res->bfi.allocated_clusters++; + off = bat2sect(s, i) << BDRV_SECTOR_BITS; if (off > high_off) { high_off = off; } - - if (prev_off != 0 && (prev_off + s->cluster_size) != off) { - res->bfi.fragmented_clusters++; - } - prev_off = off; } res->image_end_offset = high_off + s->cluster_size; if (size > res->image_end_offset) { - int64_t count; count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size); fprintf(stderr, "%s space leaked at the end of the image %" PRId64 "\n", fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR", @@ -542,12 +517,57 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, if (ret < 0) { error_report_err(local_err); res->check_errors++; - goto out; + return ret; } res->leaks_fixed += count; } } + return 0; +} + +static int coroutine_fn parallels_co_check(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + int64_t prev_off; + int ret; + uint32_t i; + + qemu_co_mutex_lock(&s->lock); + + parallels_check_unclean(bs, res, fix); + + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + goto out; + } + + res->bfi.total_clusters = s->bat_size; + res->bfi.compressed_clusters = 0; /* compression is not supported */ + + prev_off = 0; + for (i = 0; i < s->bat_size; i++) { + int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; + if (off == 0) { + prev_off = 0; + continue; + } + + res->bfi.allocated_clusters++; + + if (prev_off != 0 && (prev_off + s->cluster_size) != off) { + res->bfi.fragmented_clusters++; + } + prev_off = off; + } + out: qemu_co_mutex_unlock(&s->lock); From patchwork Mon Aug 29 10:12:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957657 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 D425BECAAD2 for ; Mon, 29 Aug 2022 10:42:02 +0000 (UTC) Received: from localhost ([::1]:37946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oScDS-0002tn-0Q for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 06:42:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblW-0001Gb-CL; Mon, 29 Aug 2022 06:13:10 -0400 Received: from mail-eopbgr70135.outbound.protection.outlook.com ([40.107.7.135]:32646 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblU-00066Q-Qx; Mon, 29 Aug 2022 06:13:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oZQuNE1/8xgIMgiQXkHwBW4YZQwETU0yz6Pm3uigO5wtLK0KfaODR1g93PcVuJOjuhIdMJJw6E3Vi6mwHWV/goYN5wPTJWBNtIwMHKznFd0DxCjfCr22OZwYdbas8uFCMlK6O/AP4Z9KxEV2HBtx8entUEtHWJOOlSpyzXGCR4+w/I29sGT84NZIAlO2P+3j8CRDghmXaYeejRuAjNFEGDqaBiBs4NN2JDBdOpe+VF/XTsJ4a05ZJlzHmtHyYwexZiizkTZk+Ypl7sc/Z1t8tohZsq/W7Y7LMyQRKPNjjvOH3anjFmLax5zWTutyrqVofSmx1CL3UEwmjHvTTI7Rog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=arrAPOJikaGyeNEaTWhS7yx8/exfEpCQTqDC8N98mzI=; b=b9mqK/+oVXb5XjtstjIXEQgKk4V769WvBJ9KKY0B0hJRjxwesF46lSUiI6Pa3W+LrS5m/Se+14lzVtcK5HWrNVoKncfXwIIyjYMXs0qSqx+M0Y/h1tmseF7QAa3Ybxya2lBMaomHn7/Y9xcLJaEbg4P4ljvKk7+gNNtQEj2TdVB1Sh1CguJ/YuXrGKie/KCMzgffiXP6WZkOzQXW9YYNcWX07YmY+uMJD3CDsCE1rpvdWjc0iHQ5XkLUbUKa/0XOZ67JnSNwNALJF7fnzZXNZN5ftOx+IH6qjZZouSUdAhsLqIIQaPpcZQxys7wz+zYfVQmxDmkWm8QX0f8/5n7YJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=arrAPOJikaGyeNEaTWhS7yx8/exfEpCQTqDC8N98mzI=; b=M+dzMC//wCsQaXFiyJ1pbkM5pqGLIIMmOJfmVf5ImrzXam41GF+pEMOE8qBie1Tfv5ARyrBdquug8WJQ5ANRyuQ+5Q/icAf1oY4l5LAnM7oMsnSQE69rO9QJwgpBtCtOIlQO7mxD0LF6pbP6+V5mBuiur2RXdbfaPdZcQj83XCkKVx+GgNUKx6kUX3ZX098naIe1UYS8RDuqfd1oqh/RhiGW+GoIoFEVpagSeShUMpSvw0gsH2wm9IXw3umSfO/pZaIXbslEaxXhxrqNZfAEpfQ4hTY3ar0qI7KSDukETJy2+GlVDkoThjRKUcxUpHGMOBH8ZflAbxrVnfAeYV306w== 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 DBBPR08MB4725.eurprd08.prod.outlook.com (2603:10a6:10:f5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 10:13:00 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 10:13:00 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v7 09/10] parallels: Move statistic collection to a separate function Date: Mon, 29 Aug 2022 12:12:44 +0200 Message-Id: <20220829101246.343507-10-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> References: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0139.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::14) 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: 2ced4e93-8c9c-4270-27aa-08da89a70d2f X-MS-TrafficTypeDiagnostic: DBBPR08MB4725:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BYKNeVPnudkDGWWyZXdmIF76V6JL5vbHQmJcnlF02ACI0LWHt+fgIQzts6jWIFoWhM6MsSuIOeTJzAV7cKWw0zidnmnz4OkqDRW1E62NzjSM32rp3Cajg3xzXlpnubWTTnnh1fjatStuwDChZ6CpDlP8Qn3GofyH8n/c63FrcoVFy4CUTgz/Ko3cTMBh+UIZnFw0Sn3VcOGuLm9xq1QksYHaXQxoCLI1vdtKSLhJPw+WgFD1ZtrE52vw5A3UU+NHJJy8zQ/InUYDLEA7mTOuwQrxzFR4bowyX29qdCjhHNbBA9OeCWa20A69Dzc4FEm3fPyHZwjRL20LRdKxFKQmksT6HCfEcoyAhABeV4M0aaX/e4ZyclPSmUOH6y2FpNXU6bBMkpXyEpaKOXpEHzi4gsuliOO9AgyednTRs0ng0vu+MzAJPZpQDCsvN/ieatOGkwqJJt3bBwkjSvEg3FGNzLfMdxEm3c0wetQ6ftocVGEHjgQVKqc8xO/Z4+SsH+aVnltRnHMYXs/zzktWwtT/KPfoGNBumayHh3OZAxUB7QqHyCv3wHV5aMw53pwuvYFMBzfnfq5ipwZPU0dgKx4imlc8hP+RddxmucyigJ/Am1fU4nAes4ND5J+fGL+NBGcA48B61WAISlhJUC8R6MkCDu2G0lxAMpTdQG1TAQj+Zlr1EP5haBTq6GIHXH2vs5OYVgef4/j7bLXZ4FQyQ+ieWT6EMR/ZVkbc3S1R9UIAaBqg1cSAls3WP5Cq1I2b5RfIISHZGX+IyEtIWno/qLtiFg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39850400004)(346002)(376002)(396003)(366004)(136003)(2616005)(316002)(1076003)(36756003)(38350700002)(186003)(38100700002)(86362001)(6916009)(52116002)(83380400001)(2906002)(478600001)(41300700001)(6486002)(66946007)(66556008)(8676002)(4326008)(66476007)(44832011)(6666004)(6512007)(6506007)(5660300002)(8936002)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /TEIr7+tZE7lfzInxYdvDhfWTxI9axJvdemI+wav7bp9nUnJb37ETwh0+oxcphu8blFt3oVM6DY+aOKOAidpGvR2H58bmrPWGdtcQjS6mEvN0uD/eqPeeqluP0V1r/2nxyIamdoN989gcZ5hymdvHnN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fWsqmSPfZxPrBCQi9jBntN8LW72aZJi3qr+JUO56f8Z4JX2PnXfYKQ0JohODOYvdge4z2HWmLVQSSGNv1nKdI1udHbYuh3Xy5wOmF2bvdwLicD/UjzvA06rrXwNRckSHUdpwxnVdvX53QMq4QI0Xq9z0WBAqaeXrrnZ3HGRG7AOqVFkABwyZweP+XaxzwZ+4eAh7QZ4wALADD7rh0zFS8BM9zr255QPoQbi/9Q/CDXFf3Nvm7pKpb2aC1HIe+pAVrB6TivVAiSqej1fH7ocs0HawNrjaot1uVwpQe+eB6/0PfEeM1WuoN7/gjBVYIF5u8kM0C6qhXVZH4qxtBI2gQxEdeWNyqC+zmGcJqqNotqXNXMOd9okTVPVlSJbb2+uO8bGYHZhPV5LddAdHElqSKVM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ced4e93-8c9c-4270-27aa-08da89a70d2f X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 10:13:00.1177 (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: xHZca0H4nuLnrd+f10RMEn0gcOU+GhWuf+OxEU0a9Wz2hz5REBb0bLC2eG7LHahnuEdQkegMnkN3qBqy85TsKANdv9YroH9whOor3KZYep0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4725 Received-SPF: pass client-ip=40.107.7.135; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 53 +++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 1874045c51..eacfdea4b6 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -526,47 +526,56 @@ static int parallels_check_leak(BlockDriverState *bs, return 0; } -static int coroutine_fn parallels_co_check(BlockDriverState *bs, - BdrvCheckResult *res, - BdrvCheckMode fix) +static void parallels_collect_statistics(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - int64_t prev_off; - int ret; + int64_t off, prev_off; uint32_t i; - qemu_co_mutex_lock(&s->lock); - - parallels_check_unclean(bs, res, fix); - - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } - - ret = parallels_check_leak(bs, res, fix); - if (ret < 0) { - goto out; - } - res->bfi.total_clusters = s->bat_size; res->bfi.compressed_clusters = 0; /* compression is not supported */ prev_off = 0; for (i = 0; i < s->bat_size; i++) { - int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; + off = bat2sect(s, i) << BDRV_SECTOR_BITS; if (off == 0) { prev_off = 0; continue; } - res->bfi.allocated_clusters++; - if (prev_off != 0 && (prev_off + s->cluster_size) != off) { res->bfi.fragmented_clusters++; } + prev_off = off; + res->bfi.allocated_clusters++; } +} + +static int coroutine_fn parallels_co_check(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + int ret; + + qemu_co_mutex_lock(&s->lock); + + parallels_check_unclean(bs, res, fix); + + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + goto out; + } + + parallels_collect_statistics(bs, res, fix); out: qemu_co_mutex_unlock(&s->lock); From patchwork Mon Aug 29 10:12:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957656 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 6D2E9ECAAD2 for ; Mon, 29 Aug 2022 10:41:27 +0000 (UTC) Received: from localhost ([::1]:38728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oScCs-0001kz-Fd for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 06:41:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblX-0001JR-Eg; Mon, 29 Aug 2022 06:13:11 -0400 Received: from mail-eopbgr140108.outbound.protection.outlook.com ([40.107.14.108]:58593 helo=EUR01-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblV-00066e-VY; Mon, 29 Aug 2022 06:13:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LppWmxNpuQsjL/JYA7SHIbzkzG9TUNt7n6LpNUIX5H7VG1JfS4bVhuMyWXeAeZafkXAmj/K/+7dxEi64jiEyCQOUPJewygWGZmGo+saAV1+SlmLphDIs4+4a8C+6KLa+fJK63M/6alxHUOlwJkbvdxIbQeOK8110baBwoYIVFMcTiiaH+cc/KF1Sk0i6DZUznV9NqoM2u1BAGAc/FThMhg/9cQV5aLiCD5BaO8SuYtHxE26dOyTdVR0jYj7kyy6FoznQF4WdlSf73dOz/PQLc0xpF1cR6oSvEdsnFP5wZ0VmKOuKmn2C5RPu8ZYe5PNkRtR0ldaEV/r7nSWPujDp1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=muZhga5Mtg2pyW235XbttJqM6vST9qzQe7PQGZbXvSg=; b=PzzQXRkZoNGDn+CvIFpcE5dAL6MxJtzwuGsgNKy9qI8uKp27AJft+i8RUfJO2c0GEYrERDcPoBRriPUKM0nGf1uiwL/Oj0CqULa7TD8YA46Vg6jRRHeRN+otybkPwMebqP4KXnRAdRjo5dmQFpQT66gjWwHazg4Z7qwo96Im7AdVrXp9hyjpRwd5owvwhgvgHaxlOFicbxXAup5VqM9Dp6tVsHuCj8IyQSS816vjI89fmGe1zROc4/OT2y+emvbnbucyfGrY30GuTTRTJsoYRAUsNNfiQepBb4ze37ILWdhaJJqzzO8qXqySY3tesWvzD1ZPGAhM7C7llEzvE5M0VA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=muZhga5Mtg2pyW235XbttJqM6vST9qzQe7PQGZbXvSg=; b=nT7WJryjFZyZCDpFjBdRyBkcV9dojwHbOEnxA7D1RU2HpPN2i8rULmhOE94lwem2jC6GllDB7jRMOtftveNaxvnZKzXA5sNbzxqjOtSi0xlqK57hb44XEx525Q4A8n0O+Cb4slH7fbRZC/aQO0BaOg+M9Cz2YxQDca65pg7EH1nLI85GngCHyE1Oxtwo6sMhgSUxYZ+hoFKXENNG3LzOUlIwidfwKSoI/aQHEEh5DqNh6uTUYr+OBHNiZyShadHdtKoHSLyACWBlcYOdSopNPCZK4GJZWq1EVAbQKubVIdNtKbz8gXUWcNSA/bChl24GL4F9/rgAJ07RWzsXuWMZcg== 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 DBBPR08MB4725.eurprd08.prod.outlook.com (2603:10a6:10:f5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 10:13:00 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 10:13:00 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v7 10/10] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD Date: Mon, 29 Aug 2022 12:12:45 +0200 Message-Id: <20220829101246.343507-11-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> References: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0139.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::14) 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: 184a8a3b-0011-4252-a5ee-08da89a70d9c X-MS-TrafficTypeDiagnostic: DBBPR08MB4725:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VKWPbBWwJjARYKWVySnna1DsYsYoXPRNvnMj/kRiX7ZvL51ok6txonHD+nDpJRjM1BVdiy8D3RVJfAlcN7x2DQll/DOWb/ajRVdA+Y6sCW9pBMWt/pnTrZ1eETrUmjQj0xkZ0OoHTzHQ5kWbejZ9TSqoyd2kwlGyACoSZ5qCEBF//6srQtWC+lskH1iNuBbmCPvd5t64xEiwOoFlCjcrM97yb24BrEvGwDB4nXyElgDiZ2PG3qGorM12ukYVz05Phoa5Oa6Jmw8Hp7bw+1ZQCnwp3y/ektDy2RZzsJ8hGz3WApkAdVPmcavIEvBS1VazEOtjCCxheAR3CMwQx4z4SCGH2lKn+oFLqSKDnp5qI0GiaD8jy07CduRK6oXFuXolpCPuuIP5bnrcivxnCAmbKoNfhQVHak6HnqyMoPhzjKQ9iodoyiI6cxDHcU4Xv8weCVNLAxUE4SQDpddUs3rxSO9/QuSH35prQTfZJQGAdoHdcjwOzBGuyDmr8lcNl8M7IesNiVXT5FGQxPEAITd//RQRxiMAnjaI4+fNtaegbodvHpnKYFOe2fJVnKmK9Iiie3QuBHURFBYj45HZBk0WG/XgeykXN6b+buE2p5kuR9LaRWMozxZNOE0ZFcZCTUv1K6h1CY0Liw3W71Af4jNOPl+S387eFmVz3TBcCCqgQPSr2RAPfGvAB0ieu16g2JgjtBadFSszGAJuxUTtI4n7qp5N9cucIMsw87htqqOpLqMjsuoXwKggVhJkb2gOS7MY4kDfg+HSr6sDHHshR1Qh6w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39850400004)(346002)(376002)(396003)(366004)(136003)(2616005)(316002)(1076003)(36756003)(38350700002)(186003)(38100700002)(86362001)(6916009)(52116002)(83380400001)(2906002)(478600001)(41300700001)(6486002)(66946007)(66556008)(8676002)(4326008)(66476007)(44832011)(6666004)(6512007)(6506007)(5660300002)(8936002)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4HLz/j2pEMXMiA/aFdrOnMAHElsG1c/OuVe5M4Nm1PAPVkSUQ/ioNgTiEzMigmCyiexmR9no8RJO/dYLeQ1uBL/hFXpQIjKgGwXMITMSOxHVS9Iqu2mBsdX7C5RFZ3mVDu60iaZkp4lwWThlx7dCI7G+DHFBUCpJEEFyeupWAYc5JC19po3dNG+7EVA2SRkcmhlRXA2HaA4DZ6avBy+7JfSeSQ3qqBdViLRRmQKKDoIf7KUku23E7U2jQuNGLiuum9doXuacARoOFqk73GD3pnyoxK1PDEDisFysni9ZZcD0clz4I5xVg8SLqUF8ezrkd3WKDmyhNOKdtN7xmLrV1PsmcZ9pn4DtUCvDwi3OYPBAS0rBHJ6Uk0pPIKh57+azw74AlG4JD/L9DvJ3dtzae7zqeVn/+gnWQx4Aa8ko1D5OrZlOmvRc2KRaQQFxN6HtESdPANLOt2SxsK415xopCdSd1zipbrj5DqG7rQCEolJEzm7qR4QmguOX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pbnLo7t66u3z9Ke4CG6pl+9Bns1n5qLc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 184a8a3b-0011-4252-a5ee-08da89a70d9c X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 10:13:00.8353 (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: S5lF0rYWE4mvB0J+k2J7SoAdyIxAYJ+DbtPV6SjWjk5OEH5+HxPll6Vl/494974uRjDODl0BJfv9OaSgqmcX3ZbWB/S/uSiAXvxX9K/kS54= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4725 Received-SPF: pass client-ip=40.107.14.108; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR01-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Replace the way we use mutex in parallels_co_check() for simplier and less error prone code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index eacfdea4b6..8943eccbf5 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -561,30 +561,25 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, BDRVParallelsState *s = bs->opaque; int ret; - qemu_co_mutex_lock(&s->lock); + WITH_QEMU_LOCK_GUARD(&s->lock) { + parallels_check_unclean(bs, res, fix); - parallels_check_unclean(bs, res, fix); + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + return ret; + } - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + return ret; + } - ret = parallels_check_leak(bs, res, fix); - if (ret < 0) { - goto out; + parallels_collect_statistics(bs, res, fix); } - parallels_collect_statistics(bs, res, fix); - -out: - qemu_co_mutex_unlock(&s->lock); - - if (ret == 0) { - ret = bdrv_co_flush(bs); - if (ret < 0) { - res->check_errors++; - } + ret = bdrv_co_flush(bs); + if (ret < 0) { + res->check_errors++; } return ret; From patchwork Mon Aug 29 10:12:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12957651 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 A86B4ECAAD4 for ; Mon, 29 Aug 2022 10:29:04 +0000 (UTC) Received: from localhost ([::1]:58714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSc0t-0006VR-La for qemu-devel@archiver.kernel.org; Mon, 29 Aug 2022 06:29:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblY-0001Nh-KF; Mon, 29 Aug 2022 06:13:12 -0400 Received: from mail-eopbgr70135.outbound.protection.outlook.com ([40.107.7.135]:32646 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSblX-00066Q-2a; Mon, 29 Aug 2022 06:13:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jl1HXEh9FKZ4tdflrBaMz28oLdheCOLofgobefR/LvdZwipfVn3DpnsZeY3sxQVVIlOWT59WiECZ24lAQs4pJiNlEEu+5Pnod4jkr5vrHY2AD8ciQSxqpCE+PuwSC/DktxXfaWsSyBhLEhDIKutRza/4kBLCbYhIM4zvLJOoyB4TYHl3Sl1+sHZPTMuD5cWELSmyj/cqriSWUCJEHT7PhqixiwvmhY6ZUeCHlfc+glfVqM2hkXHuX/mV/VZWWJLJ8ON+e1Ec+e/xzVNrS6oGzvhI7l9bNNQjBJTK9U2OIjSoFzlEKU3oFHZqm8eKu5CT6mgoqdo+tPrEXNlNpXwJrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5iYReJi0zV4ezBFk28gCUFO+tGQpkythYzHceVAAbYo=; b=WpocpHVylO4QkGl5FdFNikSRLNARFabyq0teKTfdf57mH7NnTzm9ceUsF2D5WVtkdj+p6Hr7jph5d7h5nwLUbCx/N5LNebiblLj4oCCwynw30eLTE3X1cyC0fbAlkC34FrzWqP0Jl4VGUJyK4dPfyWloBJodH0mHAzMO/Ac6YrOWuf+KZRY+EyRYftEO89h9IPenXd4mJIb7MtIujW4+VbH31IgqlOmLC0BxHVVN7x0Eq8ioI8COpwKzp/TAcrINnVl4BjOav6Fo7EcBuEVAoytOTLNZ9++Os43ulei/pvIdsuyrpAFyALPWaSf6634JW5S5hMCtdbYnuBJI9me9bA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5iYReJi0zV4ezBFk28gCUFO+tGQpkythYzHceVAAbYo=; b=xZfJmIfa85y8wvM0hXyZPmJGCUZcOmAFjvYzyiIUQcX9nfhoh/A9hUaFd5cH5ldPdXb8E2nr3Tt/i5ubSAHQ4qBMjeolqqYFuxb1trxt7uY4TdqMOzIrI3mBS2jO7YDH3S+up0TfPffwb5WsFsh4H5dPOsbi5hSR+WLedxlXfjZ8QxO+0CG9FeLJN2zqd1a4P/kP5CtCuX38ylRJXqDrwqj8tBYLs0XANbW46LrI0M1WMBh3rZ5E38tlmuB7kpJ84F5Ne77Rg+QHj74rFvObvMvSnPIFVZr16oTK5v1TB6KnbDUPiU7jYJxCT7P1/Hi7rEvvijXwqdPtqHh99P3XmA== 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 DBBPR08MB4725.eurprd08.prod.outlook.com (2603:10a6:10:f5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 10:13:01 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 10:13:01 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v7 11/10] parallels: Incorrect condition in out-of-image check Date: Mon, 29 Aug 2022 12:12:46 +0200 Message-Id: <20220829101246.343507-12-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> References: <20220829101246.343507-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0139.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::14) 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: 757c30a3-b5d7-42a2-1ce4-08da89a70e08 X-MS-TrafficTypeDiagnostic: DBBPR08MB4725:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ilw+4lNn1p/87SYkNI0N2vaYc9DYRY8qM95jzLof8BBSk2Y7+Fykt0vqKHRXo+4btrxwzYiiIqvZYo9gQqCzJL4KOu+I9vLo9bY1fOmzJG8cXi4xje+rVDy1LCnuY9laWhVHphuWINCcLBnbZ/ob5baGc2du4CTsnl6GShH5qGRUB3uSiMoOj88AM5+WzF6MZXYIsa2iw/sNs8uEpQWDXDKJyOsTzBPU7jajCbsSlVAIGNT7WQqLBs2hC4mBkPqYaLBsk6RbbvIbViY3qkCPgQLi1/+2WqE2pMupm+ILTr90j22DwRy5uhmg+NPZUmVwGLwubLDFB2eSXz1jQh8J9WsLJ3Fa0ZlEXU1xQJX4GZ+9+twpVfzbLCA194QxFbmgjiIyJikblYVmh+vreEWY6FRMNt73R7lNoLzbJhzrcG0xGaWSuIJ16q9xE2kJwOB56LGlKH3+zeN9CyE9xBkZepW3frQf1sOeuXXs7DjJsKfx951wS9H7Tjo/ZkXRp06tiHD1MhVq+J0/iqKH0uQitxnEpQq38WVJ2HsY8j1W1ExKS/3Tnq8XhvIM9dyHceZh4U/7UphVrQ+hmE/++cbAEJkfx/m2MQDWmK4HPywMN6RhtbAvvUSrEX/n+kHvif6Tmo2UbiuA8tIsPQEq/Tp7uVezwTwikH58nseP6NrSLZE8s/jj7Jt6JKvgH9+GbVp3bHJKXUvj54tnwl8P3MVtQmpFqNpS2D5cQcsr8KggI8xYD+4KuMA2n0y3DRJeKsRZuFS5byL1Gf41RPEq9H9cfQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39850400004)(346002)(376002)(396003)(366004)(136003)(2616005)(316002)(1076003)(36756003)(38350700002)(186003)(38100700002)(86362001)(6916009)(52116002)(83380400001)(2906002)(478600001)(41300700001)(6486002)(66946007)(66556008)(8676002)(4326008)(66476007)(44832011)(6666004)(4744005)(6512007)(6506007)(5660300002)(8936002)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZWPoZm8In10iz/AdbPAsyrvm74zCbHRjKQPskhHskN/ts/40AOEljt0RjjYZ/3Hz7T2nbTB7gtb2L4+UKyam8l/VXkkdfMtoaaXzz1exs7RygUkG4ZtEdnfViA03jvFzx4O2rKBphZu2lXLGcKObLobsPdKZqcHk2qqHfTyfnqh2S2VsprUj2WyKIN5wqRzK8M5s3oyfjMgS9tZ1leV4XugiEXiEt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an3XLj3tZwi0VPh00t3NerJNCc0ma71rnWknTF2sR/J0oFpFHSLM25Nr2cNjrFyVvmTlQL/CVMluNjCA2hlDovuTuxy0Ftx7LX0zwMsUQE2aQCNki6jMKueUTHVs+zV9cw5wKjKb1i2t3OUNzfijAcbdLAfm1c3JBASflSHmSq9qrR6+qCy8b6z/0OvRdHQksOuZb6DL0TDq1HEj+Abe8yUVzr2s9X4oXsH0y4vBJbyl2G17euUI5A3M1SeaVpBEw4AzVcLcNzFSlu9q6x3WiirDkPpNUwz2M0xlWRCd2p6U/vAhob7qvG25132zAFJ5VLMBReR+RA8zuXDd+rfYssXJWBUrO34tn49kyM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 757c30a3-b5d7-42a2-1ce4-08da89a70e08 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 10:13:01.5708 (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: eGPCkOHfoY049BzKsPfBJvKGTJHR6plYyPZU2BJhBr31GSE0wF5m84wnsJ/jUHwOagUPV+IuL+kG2DsbFqqFvcfFoQgivuB9nw5mg2U68r0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4725 Received-SPF: pass client-ip=40.107.7.135; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" All the offsets in the BAT must be lower than the file size. Fix the check condition for correct check. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index 8943eccbf5..e6e8b9e369 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -455,7 +455,7 @@ static int parallels_check_outside_image(BlockDriverState *bs, high_off = 0; for (i = 0; i < s->bat_size; i++) { off = bat2sect(s, i) << BDRV_SECTOR_BITS; - if (off > size) { + if (off >= size) { fprintf(stderr, "%s cluster %u is outside image\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++;