From patchwork Sun Jan 15 15:58:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13102295 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 5F22AC3DA78 for ; Sun, 15 Jan 2023 16:02:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pH5PB-0001kv-In; Sun, 15 Jan 2023 10:58:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5P6-0001gg-S9; Sun, 15 Jan 2023 10:58:41 -0500 Received: from mail-vi1eur04on2124.outbound.protection.outlook.com ([40.107.8.124] 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 1pH5P4-0001Ko-Rw; Sun, 15 Jan 2023 10:58:40 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eLlLlwvrWGVkAehlX7RiFiqO7/m2rr2ysliv1WpwEVq2oYgO/4GwD5nw2Azhx5DoFhXAgLZdGn8/Vx7dd+jxFl6bp+OzMmLKf0PELzEMoC/pZLfMMZ2rOF1rbPbhOciXtqAgUaFXcxQsJHNax7XT7NKh8kd12hQaN3SfJeKpmqTRYOgqP9VuLVEKcRNrSc1oiTwzgB22P9aeI3z1yySg6QFO8xw4HQJ4kt1d2hGHrl3Z8MLtdAI1D382hyfignkeNpdRGUVh2u0hUywUdIRYkCE36Bd1r52itcKX2+kXEb9cNOVMua+QB3vQvXXcWdQvfltfJPgpaG2AVgvToyDH6A== 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=NnMw0iJk95r7t6BWG5x9Pl3zlvk9K+Ts1+f0QrmubT4=; b=eGbcVGQrnp8Hc7pfIqtvJqtEnhzotPdQXx7GtCL0cIQCIkM3LXbg+qmxF5mdfwybjzFE2d6Fg/wg6G1Wvm0ke7agS1gX/FMk1j9PXeKJPQy6HNMusUy1b+vC9bmO806ll6TNESbaU65RlEGPmVpYPARHabWdJquxCQvumIqB3zHkIIS6DJAF+7d3FFL+dG8NliW3w+ceJlUZZ3aYyFhX6sonrTZiFggiFdAe+QXT52Z5z5PM5DDksrOemRNGoR0oPBChpnQ4AJNFsFcrIsxghrlTbJm1F9dW1v6VUjr6wFi7S+4pDQKV5tX0ViV99d4hW4m5TCZDGmBClnXcUx1dIA== 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=NnMw0iJk95r7t6BWG5x9Pl3zlvk9K+Ts1+f0QrmubT4=; b=NKpC83xE03/Nfla7rgyYFq0bczWmaFr+Bvx12aet5SrxX6gePDkhmRPh3EteCWIFh02LIlWtWsQABfdeZTfEQ0cTJPBc64RqCdUTQVJ/vUnXg8d66MqGEZ/aq4EjiiH4yRUHmwXGw4VHSbj6Sv/Pm5L/pmmuJutl5PbETvKJIuVLm3ymQumFQiTpSg2Oiu5IKIEesfVZ/e5Ej/O/rM7Z3NsBGL5XGzs+G8/wjZ3M3Ks3EcmTV5z/41RwN8yKPtLUmkjob51sleF0e/BU/9eEdpA0Y0MaO1kcsbbSUvgn29ykdAbZ8npwN8sQjxaDli5aQuYc71TBtkbRUTmMgyhtJQ== 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 DU0PR08MB7857.eurprd08.prod.outlook.com (2603:10a6:10:3b3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Sun, 15 Jan 2023 15:58:29 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.5986.023; Sun, 15 Jan 2023 15:58:29 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v8 01/11] parallels: Out of image offset in BAT leads to image inflation Date: Sun, 15 Jan 2023 16:58:11 +0100 Message-Id: <20230115155821.1534598-2-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> References: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0312.eurprd07.prod.outlook.com (2603:10a6:800:130::40) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DU0PR08MB7857:EE_ X-MS-Office365-Filtering-Correlation-Id: d3cd4919-cbe9-4dda-5725-08daf7115807 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mPOE943E55hOl3udQmITrNDQuXuDZdtN3qwSKoxjSC/T/5DOVJefOv0NgEfd/cYo9QY6md++Upz/lX//3YWxMOWfBoozflR+CxjhYB5Wd7T7KKJPH9YabBZ2WlVkUhgosNig/hWTtlck/L8YGhU0OkBI/hbCXVsrn0bmzjnQ024SkJpB1V4EsXxTkkFGZF2skP+HHTLEu1eBkGySqFMT29EfkX7dgTmiTyTMA1u47SuXWQs8Q2IWClnoIvUU/zWxTtEyM0oGv9qYaGkh77GpisufQg3e4NTp0lGwLosxZ5AfmLwB28Ea0du9z9oo7x92ZfOwrTBXHomW8N3qlk5hLm73C7LxmZ7FPhaLLNUiT1ZU5jUiChI7KvDr/IRq/2no+ShsM3zDg3WUJr1ZV9jQfCGyZaX0IxW8MEYpZhbb7RBML0ZGUJJYgvLq78KTWdQ0fAzsMmfD7qXX7ZNJZQEHgVCg1m0fO5N8SgafQyCK47JC6Rnw7KZaolDWKElJnmMtrAVakBW/ZjNySYp0G/kIsZlh12S/mfw7IbjwcCvRl0yL/OQ1aZCpKGpmQNm5zmRRTeDWsXCihPXhZb3mqmo+3uvDZPxQZe6EFBX5IXZQEBIsn5u5j5l7R+ii+7teOSP0oKm5V1rCM81Z3QB73K02SM2E6IYhuAo4MmZuYd1LBKSHHQLA5qK0iSO3qOM+zHFcEEYjFZvkzB52LHMOayhYPw== 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:(13230022)(4636009)(39850400004)(136003)(346002)(396003)(376002)(366004)(451199015)(41300700001)(66946007)(66556008)(2616005)(186003)(4326008)(6512007)(8676002)(26005)(36756003)(86362001)(66476007)(8936002)(83380400001)(38350700002)(5660300002)(6916009)(478600001)(6506007)(52116002)(316002)(1076003)(6486002)(44832011)(6666004)(38100700002)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VsHe6jMHR19zIzfvQyE0pRPvBmPV31pAj03q3ToR24MRRjIhTsBmzITPMJjlGR4DOhZYwejyeNrABkfYTlFVm6R99dIo/dDNd2qV0HBbBTiVhSWdzerCPWqTouO7qc4Iv5ZBjFQgrBdiYy3tnEUTX6pfrsNJbOzy1SbTwcBGtauq9g1bJp8K2+4CNKTTec8Itv+6vrXcnUexjSuzS8HDHDng5eGOKJhH3ZkhkQgTHxObAvwC9OisEqk1NP3XxamOi5qHWZzNensj1strcFG7phX8foG5ofIyVGJCMDlzCmJrGvR1p6+ubwI2Qw4rM+M5QptZimIQTUXAPJZchMTJ52Z6vkQbnFJ6YiEQ3J3qgl0qWmDMqvLscBuRC/vmprCKXwutK4z2mxIlXqBDm18X19jxsudewoV1xm59lNJzvGgKnpTkscIaKajwfQO8C7473KuXJU6JS9uTjIDXYlLZWMaKQKFCT3MFuz+E7FlH7NUAJY1vzLaNxs1f4ByTUZ2AXgpORyNZDAcJl5lAHaEEFeJdJ/30ZwtSP6QfyWvUszmswwo0GPB/H6jyyvaDRg2856A5M2wiSbxYbQVb+CCoSNtyPNm9BQIiSc3rLv0nUAMsBfLXRZr2WapAv2u7CAql6KNDRXiBAwFId+ZADI6ggh0fdsrtCfQQRrb3ne5eRhvBUAFz2kmuDDL9HpwjddoyIGQ69RSkXAUJ2UqoborUX3pa1yOu7Stu77DOr3GBhDzFofhHmKsqcW4dbsMiKq9Y3EZwrzP6tZpNTepMt/JJwCPtOPInLd88O/+Dje27jm0y9VeHjw7uYV/PmHBFGDowuehcdB172ADEgvYTIyyqj0bsGCx5Qy7Bzn7e/tti4h0nA9JenrPaewmWHM8dLqpVRR3DGgJd6F9gtq5rd6D/u8CSSt0Sfoea8rkD+FkRv96zMo0z1XG9cD3jzILvLvubHru6aHMikABzqK7tP9Q9D9QatHzNO/WMdUCA9K79CByZBjfCdQAsh/Yfnct6PIPGbwJUAjhKxtvfOPUoQlEkYxKtFQ2hmjuP/NytHdQ4rw8Hy6iSo+y8wVYoCoUzAWiNrWeh3LvRt5th7IypZl3On+b35/oR0m7IRdUat0yrq817vhrlbiPxeQ6cBC222CuzoVwNq3RBAEEO6bYuVLmR/HWyLDlRagz1ptquHpBU+tRCXkrr7lAkigVUl8F5GFGSYfsl9vtO5jqn9kUgvqblfjB7NSA6PmKIdU7JXv27gPcmOk1J2uBwdqCCxndE2cHSHEBa25KbiQJ+FKKlNhZfJ5yaZtOdf+R121WQLEAL5Mtx83R/S+jLTvn5JCBH6goLPxH8Od14Vu/47NhSVXuVj6ytu1FHh4HhfpCyqM5mPZll7HxohMCzkZO4jR4p4A/yu53AJlMyIovtCzU+0HU/LmgglEB0pmNyZ8NLar5BBB6Q/SqzZvDlnDdxx4SmZXQiF7nXKEfd4kzVDkqUNpdspaBezrbO1CfG2Ut5+NHbpHhjb6fcQeEDNHi/sa40Db9XROjpzeqwGOK3O95dZlxqU6h5Gq8hRM1iqhhdBnL+sn/twwAMb3YPLsRDfG6CV7GeuZrzEDej+w60RZiVGF2DzIfOV0ZryF4Ucj3DeJH3uHI= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3cd4919-cbe9-4dda-5725-08daf7115807 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 15:58:29.0977 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EtXfpxHMO/MCvi/pYGizf+gJ+Z4ldxD81wCVxP4qOHRaFZKyUaB9GbCMRN2xYU5jkqHkvDSaWOvnuxBsrKUqZXh4vGEweXCAaddscsaXBH8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7857 Received-SPF: pass client-ip=40.107.8.124; 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 bbea2f2221..4af68adc61 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; @@ -741,6 +742,12 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, return ret; } + 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; @@ -805,6 +812,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 Sun Jan 15 15:58:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13102291 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 BE895C3DA78 for ; Sun, 15 Jan 2023 16:00:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pH5P8-0001i5-Um; Sun, 15 Jan 2023 10:58:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5P6-0001gb-CG; Sun, 15 Jan 2023 10:58:40 -0500 Received: from mail-vi1eur04on2133.outbound.protection.outlook.com ([40.107.8.133] 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 1pH5P4-0001KA-SF; Sun, 15 Jan 2023 10:58:40 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UAqOkX9Y1NCSNgkZBPEXylSyOP6TGggL6JamH7Epw/HOz/yw2ADKMVdRQzf+qPj8oYvWhnmg7c9STVh8CSJb2HGuzSibl3AOOUY7v52JyfEIl3MeeiZPRkUPLC71WiNIu3fkOJbHfgyyThRPpkPDiBW4XMVrDzHGH+snipacMNK90gTemc3qRIfSSogknseIyvtYFY0U120IMI2T0LHIDITBWuJ7NLCMe+y81Cb04oBVDDXRViaN0t/7jHgRJk+KDi7UynpQ4r+VWk8R5l1tmgn0WnA1DmKyvsp4Znz73sPZ6BpI2d14/KoMLm0grkKZnW6JHHo7AmsEYCZ9GLIuIQ== 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=pZn5Unxv56NSlfaaVFjnpzpNdkR+46E0YNsC2j2vs/4=; b=BxJUOa6aO9mSPJBzG/0toJLZQeClgJZeTAsneRFtkJz9hqNQ7GEth2hsWb7ojbabNjuZdxOLgPn/SWPQ++EzSQlHwdqo0k4kmQC10esZE2DDrHtqBjaCvd0rD8qSz4sI9xAAacTXbmtTnctJqyPfAbc+TWHOMS1NPirC4+SxWwRQjJn+njPEg+g0clwmp+sWW3H9qPHpwZCVEaj6EnCCgLYBf0a7vhZZwgfvkWYeMUSjJwDchsbRbIFVyZXmT1Z+iC7dhUqs+7ELQCv+S5e2c83J6cRJK0neZF0A9G6YK7UjZeiZxylrIahuJ2r8xJIBhnRI38WGrHBlHADMzJNm3Q== 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=pZn5Unxv56NSlfaaVFjnpzpNdkR+46E0YNsC2j2vs/4=; b=cdIWThgXjjx0/9tfa74AqVCaXZ6ap/ZXIyu/B7zil1pv0kglwY0xDLVNGjBQDEEfndicyyt5niW8n+T/As/Hga/l50AMZTvZpbsx7kIQUZ4JIK6n2dstFqaJbzZqP+Pmf63xwvKJj1EEY5O02b5R9jl2lA5KDnVjCCgy2G5QUHKIrwwD4/7SqbdnqxZNzr0KI/Qw4+xIDP8blkcdSRH+s61VqDkvSt8LGPrhjRQ6CZ9tiyTU08ynMwMKxfIw1ydRwWrG30734y9wf4/hA//Tue5aEClPm6/+0AO1j9t0Iv6yrAINtYwKcXNBfA7v1dnh1EqxxBs1TEZsfMEBo2l5Ug== 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 DU0PR08MB7857.eurprd08.prod.outlook.com (2603:10a6:10:3b3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Sun, 15 Jan 2023 15:58:29 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.5986.023; Sun, 15 Jan 2023 15:58:29 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v8 02/11] parallels: Fix high_off calculation in parallels_co_check() Date: Sun, 15 Jan 2023 16:58:12 +0100 Message-Id: <20230115155821.1534598-3-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> References: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0312.eurprd07.prod.outlook.com (2603:10a6:800:130::40) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DU0PR08MB7857:EE_ X-MS-Office365-Filtering-Correlation-Id: 195000ad-346e-4b27-4d10-08daf7115864 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BkJwDly2161/LfIamYWrEZiBGLW3Yrr7e/LJHygH55YTdnTPFFcyZl7QNl+uXmCBPq90u7NmVH25VWb4vdW7W+gqsTxIe+K0QK9YoQkiNYD/zSqtDPfOrnPmKkXkFH+whf1LQRB3vmxyb4mm9gqgU4qG2j3RjXIdZ0rzciwuNB4U7pPjGCxf2s6OkdFdj+MfIgk94M4f3xphe/57oJzOqKPzeK53bFfjrqIgxzUCaV6/1GEH/6dYPKvhWXKZ4oNSF/SOxaFECMKxuj6PEcO8mWrlYxRX6zAhYMxSXFYn9Xb8/8iseqMn2O34oKCsb5FbqDnJkx3AVIMSpetRjXYmTZN5ElvQPXSAAvUby5tkakDkqPr17VQaGE/SEj7WQ33qaP3q57qyEe9PPZ7iBEue7rQHYgmawP2EqAUumdWkvM0vPAmYhXWsBOCnkkjtRB+qum4CH9dYKbMdkCTGPNzCNGMP/aT3oyRzYGBGmILiDrXgceO7CGgGw7yREPwv7Kt9dsRUv1IhZb6wq1sZ1bnPVzb9AiXMtNzVIenRt3xOmmiD7m1osseS/5TSuSQZwTq3sWFkfqCD6G1idSgvdOzR2PTs64MFzRzYwa3BhWZ6y5nO4UoTL1Jw+3lu5qR2HgUCXji+oeXhcrPrcygULr240NwnMJu2lFMldnJN39vR3jUeEu7g40TyYVie3qPbhUBJHZJ63EGtkeJN8EzvjAI+TQ== 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:(13230022)(4636009)(39850400004)(136003)(346002)(396003)(376002)(366004)(451199015)(41300700001)(66946007)(66556008)(2616005)(186003)(4326008)(6512007)(8676002)(26005)(36756003)(86362001)(66476007)(8936002)(83380400001)(38350700002)(5660300002)(6916009)(478600001)(6506007)(52116002)(316002)(1076003)(4744005)(6486002)(44832011)(6666004)(38100700002)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: czuCqf9FpI5smWXK6gf2+c9ZfIPlK0KqBywYiF2eF9w80JmMkdzHgzyGsXEWycWCME7bDfv9AKeV03CWlKtQsayRq3pK3dJ/tcmUqpnbi6Hzs1JIchpx8d8aINhg0330QszcF4UKN8e8M6LMoXBgUPNAhqyN9rZq/NimWidMfMZIFLoQHg84lCNXriB3GZ5l/o9CocpqsVxbyw7UkVwBzCvzW/hB253VtCv0fPycynCiwQ7gwS13+OgYacGu5vIT72aBKsPWFtwhhEQtDLvzEBS6cWzrhhe6vS+gkYt5bfrled8c+LnwiJwL4b/PZ5nrtSF8SMIgk6wQrP7pc8xy0R3zBPj7acsYjgqi29sOYnxIuZaREfr5YALftYK2oqHLoPPcwyU/qzr0h11XSTcNidNAkhZzQLNvJLl0jJzXuBh0ycws/nujOsDpwfz90lFBExbvCzdUwbjcjEmqGXZPo3d3zoSvS43wLl+3r0DXgQVzlmpAsTNUMawVqzf910cXP+mxNZeTY9UeLeDQDB9ge5FdiwS4Rr2cmOSToVUwEb7DR/xopvIP/jC4KPQ7Hm6LHhsybBFssz4l2V/jv/1kmYUhQx7FmDqw94f5xWLbWPQ0IINBEkdXDR5zd51fvNhMO8jgTlumACP2uP4dlOez13931wxYh3xh99kVAfHKhOQCapwWYv2NJneRhx7/KWRc017lnEt9ZrSKxkKrq4dQO9U9WIeBiBmQAo+utkCjdA5insKuD68EABIi9h/19pq4ojhROgXshKUv6KQwLRMiI3DU8Tt30AWagqBTNGC3nrpuEwx6vrz8OHlTmrKphXrt8VPnZlOhJE9UEZuIExNNEp6TCSxmWQ4P3UmiGyeH3eIPhHZgpQPRk60lVHKPL33rFTwlxZWBq2gQmGjvenOlLs4uxVm7vRYc9QDys/3COFgJI5/ujx79DIit8uRcba3hYnoSH4LyWySx+ZNC7aRyiFIUErZGDJ2VVsS2cfA+2HlbXkAfpHl2Rl0xCX8r/mBZAVv5tr3VsPmlfnjyu/Hp0n8ibkCEI7qfN0DIHAwSCuYesO5ec6Kh/r6aDJ21+Qt4LkgWTLpjOIQx9pB2gH9OoxGn8nbeSGcuXFRZgjEP26kneKYo/uVfeZJGxx1tx7BZr8kGg+EzzKHagtrVNvr/rsutD1MsUlQxE1sUflQw2W4BFcRNTFzf7AD57csD9SybtVtfGWk/IwndaZ8CxFPqnzZhgTaV66hgV0xGGO8C5jUEfG6CA1b3jBqaI6vBjgtsyaYFmPQgtsab3r5RfXrt18AlrkDFSuY7krZP2dZSMybqGCJmGEzatgyqvialxz/cET9zxgR7GZMsQcz4PinpBDdknDZGqiBpkEBcJr9qYlvzemxzcq+uEH5ZN9tCmVT/rSSBzscaEJ8MDyCYTpH9BB1wB9dZcw6tCW7amBbdabGv4JeTLtpI3EF5WosxzLnNYaAzWiZ8vVwjygEhtyBjSjSS1COGbAQoSbZqkrwDH+ALAlfPiwUuclKDTSNLOm6mIrlrPf5PZl7pWI76bKRTGvxtkngDtnAy1W+rXKmX11HGFqHPqimrhHXsaQcmkXJs3hjBSUKTz73CoO0uAIXF8XMGPLnm54II8IOx40hcSMs= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 195000ad-346e-4b27-4d10-08daf7115864 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 15:58:29.7393 (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: 5PTkqtVH5KjPK2UYq10pDM3ntgtYNm8Z6Y19jQmOR3Nmyi0GgTNwBhW9s1fVepFek/IL58JXq1FEbLdpAejDEWCtRLxZ8i60iWzHkc23GZ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7857 Received-SPF: pass client-ip=40.107.8.133; 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 4af68adc61..436b36bbd9 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 Sun Jan 15 15:58:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13102292 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 F0799C63797 for ; Sun, 15 Jan 2023 16:00:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pH5PB-0001kx-Ti; Sun, 15 Jan 2023 10:58:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5P8-0001hm-Ki; Sun, 15 Jan 2023 10:58:42 -0500 Received: from mail-vi1eur04on2133.outbound.protection.outlook.com ([40.107.8.133] 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 1pH5P7-0001KA-3S; Sun, 15 Jan 2023 10:58:42 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T8rX5wCN85HvU8+tsmR26t9QLNSU86aXBpPNDJDyFp1COa6GrpgwklZckomFrT6xeW+hR/riifBKNyKEuSpAZ4665b8kYkYaV/Fmx4P9Sh0lIdjTmDe//wk2b5gLAULOjKqVC29QQDRx6vYF4kwRUckXq6U9+bCnLKSIoHz2Sox6UGnDzdK4J3QJBScIIfZ+7lMzfR9cvOwNkRjmVpqfPe4zSupENknSAyaJqeOBfkFF0UwU/X4YMkUAxxlEaa0smhIyFcuGsT3tq7HZAL1l7h/Y48qhOV9SwWs2KveyMN0dv47utbF+wBy7zfHZxUAPa3URHVj3yNqpuY4bNijKtA== 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=MNyy8G/nw2Q+j3HECPZNo5x91+GFPYqJlh0OVa6T3Vg=; b=XLDHiZBYLh0Qj5DycLpVM+EHecF3tIBWRu5OG59vgkQXAGvN6yjgzy1eFIiZfoRaIEf3tgK9LebHYz9Z0iEMR3v/nspSmor37Y7SM6DQEfoGKVSelphRTaQ50ZYmBlR3ZFnzpkWd5kWDFmx1iIxLUWnwOFsPogXPI3IELPRblY9KHZ/3GNG1VQOi/0d6gq/8UUvvv8v5MHb8pA1ljmvkqj00aUkIJExM++G/iSHvetUlsOTzJTgWkJFS/oYWXOYSJ1RR/exTm6W3xTjAd1x0JupG2bzfPgkwY5HDXkpB3HujpxPg/aFChkfruyfJJ5V2aiNFO8STTBX6obgs6k/lZg== 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=MNyy8G/nw2Q+j3HECPZNo5x91+GFPYqJlh0OVa6T3Vg=; b=ds1+GFJT9XdoM6BWzkVWzCM6rxcUX0C6tsIHCwwIrm79kExHg5cxbxnda4oyQkujsIsl7t3swiiUaqAe7bR6IRTRN1OjZ1egfL2DVz4pWleunzVxij2soFTNwWORddGvtp2l+CPSBhf1jn8Fsa4wL0uOJIfj6U+9K6iE7rbGMnuYGpqxtP9/xpcvlpHILBTD5R1BXAYFUThvTUee6g5IKsgzmpGGTiTLog1p5BGgoNefwC4lHSo18VUzbSsfo4iwK16VRPWBS8fi7vwVra2+H9eORt5xv/jg/KlpCJoz0Z7saH56TCy5Wdwyp48ntOvNxtZvn2QcDtrtwlgcwbN1qg== 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 DU0PR08MB7857.eurprd08.prod.outlook.com (2603:10a6:10:3b3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Sun, 15 Jan 2023 15:58:30 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.5986.023; Sun, 15 Jan 2023 15:58:30 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v8 03/11] parallels: Fix data_end after out-of-image check Date: Sun, 15 Jan 2023 16:58:13 +0100 Message-Id: <20230115155821.1534598-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> References: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0312.eurprd07.prod.outlook.com (2603:10a6:800:130::40) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DU0PR08MB7857:EE_ X-MS-Office365-Filtering-Correlation-Id: c308ec02-8f46-4696-9757-08daf71158c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y7Cz3Je9tPbXS7OT41b/vdaD8UwDFapZ7xKdOXu7dyfKV6jp1pM7Bp8c+ubVkRQKdoXPYhuxOG3oesLZy3iGDICSGDFXUx1Rz8AsaZ0m030do40RcwhRddP7eSFCRcGlVL8FFue+KWxD1P4aT26oHRbhlLso0Fs3kSnlNWHd3spGHQJQ//dy4/W2V9sGbVlQQVnm5y/5CGVNyS2H/8nEoKhL9l+UXWPbPeAWaCJ7XBFMtiyLMAZP0W1bYfQORUKG6n5lE5wzpDRuXDFzTd4Jq1bNILb1l2juEz1dEEBgaxXAohhrr11MOlie7QMiKliirHlReF1FVb5bZHApRXWpDNNHutUZBMHs3j4iDBvvxz4eq5s8KmgTa6UNW62rgDMXDp44t+yGPE0/Yqb1rUHoc+HGJzGJZh6dPJxrbJFxY+trcw7Fc8WoGqNwa5Wl+7RxcLAj0X2uPO9S1EYBP05VDWKGKuII0Xo+Lrhf4UZB9JgSR362nKI8DHmS++oITXmWe2MATqhkkxMdR6xdnpdmplYcahiOk3EKLGuB8SypOPZfL34UIef8xYV5htSOaOrCpj4FP59E6wJFSs7QWoXwo9LTB6eKZEN7psuR9DzraGRsTHE6SPBhARsSuhFdP1osIub4SS7B+C413G7nn83zSbCd257YPZ0zPAeZpeoAwgTO+Jk0TwJHTSGwBRYusIe+ 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:(13230022)(4636009)(39850400004)(136003)(346002)(396003)(376002)(366004)(451199015)(41300700001)(66946007)(66556008)(2616005)(186003)(4326008)(6512007)(8676002)(26005)(36756003)(86362001)(66476007)(8936002)(83380400001)(38350700002)(5660300002)(6916009)(478600001)(6506007)(52116002)(316002)(1076003)(4744005)(6486002)(44832011)(6666004)(38100700002)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z9VmXmBH4bIPrRCwY4kjq2KyOBnx9EByr2wCgn6Twl7VGe4zG9Y+mNF1MUHD6ze5JUGDMkHG1iKm9cu6UVrubccBqJtNPJarMxWo7L3yNr03ZKFqv60q+w1OVNf8In/M7dVmLaZ5WFuNyOVYY+qLye6ChbxayljUw2GWocSH0vej/vUmLOs0Ik0R6V4sIQ65OXqRRlvpMT2sfyiRv+P/5R2PUFAVpfKH+7tObPZZNoyraWLux92lE0PN4T4Gjd8WemrHmvHb79HW/LFJcsqJwF+oNvixaH9FISOwGmIRPeKV1SYWK0MfFu2A14ywl0zjWnhEGGe8EBqDTslrIUKWL09doMM/X4zFiDgcPqtJ23s77QTK+k+sheGEhieWt5MMwqZniVByYuTUMR+Ymll0UaZ7dBdzrL4uDU1nGKa5FX5Pr+HsurHVuV08EB/f+8Fnipw/uTCjNFSU8+QKh4OOBLl3arX/NPbI/GbfKVZBquM9kD0PDly2FPzInw1uOXVH+N+sjIRjJVI9teFV7UQyqtNbfy8OnpUfgjQSrShs4NmrdmAWVQRihoLYYdFsSMHSVK5ZkNeNuQSoZT2VEjSC40VHvlJ81btgtq5QnGErjhVCy3oFsKyxX7Khjel5vYso/Z4MAbI6q+g+kEXI7mIfjqwFfCAMAvKe760FiojyFq2UEAnvXfystZ2ih0H3gEuVg2qTPYGxDHWUQ8F7qt7kPzkcOcM85N1l6C4c1DHM8uPDthx9AuMfvsrWD741Knisr+XlFr96888AG4jw1daez9QQknXK6UL4UDagnldSCSvssU6tiQdczOUwIKktPCfHjddlHuhWSZzq7P3FWYIaTpKJp3KOmxFhbtrg3d5XFEgAO9XUb/NyOPp6tYY6cGC74vYRZnTmdK23ig+QuehzvKS5uPqcG4t4L+jll6Dru90nX6ERmU+8LXfYgWwuXemqqoN2lr8SjwZSMtUePt/U+oDMmQxfFen/fBVvAd8jMKbm++9GP4kX35qcNFM9Quf650uk91y/mQmGXYnvZHHJYyq88Dyo0KvXbAujpOhLeshPZo0aZNzHRu0z2NnkWDAg9q8AGnr/LFihJtq2apQETNHaIF5YkluxMNj4qHsRr76VOpCJHce3JwKtWeu6nySkLHPnmjJWSIDJm6PcC53dct9jXm5GJQBRp1E3KOrTll2AZ5AiyPe21zytnmn14JRoSD9ejrkJP8/qqd2/hXZfn2DUTh84TKF39thVzN8LtpmyuunJMmDb5DIfJ2uZ9tAjkmW77zjU2ZxAL2ksg2RuI+rynve2/gL/roxOR9OO9VVbnc3cJAvfFxyqgQ+Fwhlb4wa9R3NC0Si/tWbcoxXe6xyqGmcwXZFvbo6TfpGFlPIGqPZCBRzJUFszoeg3y0VLhvYyK0INy3QQQUvbrxNozA7c5FtB8M+Zzg2iuRTnkDIQbhzbZu9fPBZ4z+dnMLQafACYKltnyAcfpYNisfHSJlgkj31bG3ZnucRFGf45XgL71yJ/KHI+MjsFDv4IYDNju82W+jv2WUryxhuB+VD30h3vtVo08ZWhtTRETOWujW3Iqq3UqE6kRbjSPMu8g1n12ZHL1cXTMGKI54nNLvXrRIc4u+LMtG+xQnjE0rhX72g= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c308ec02-8f46-4696-9757-08daf71158c8 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 15:58:30.4111 (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: JsA3E6xFzbhYOVdtE19BKlu3/imbjuz7fusLg49eaGPOK64kjj9KbXLLQanLIUaG2hiaLROJwV3QWhJMaY0345tCZJLmj9U6RuOyMJUrlHQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7857 Received-SPF: pass client-ip=40.107.8.133; 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 436b36bbd9..9fe0f33ba9 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 Sun Jan 15 15:58:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13102286 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 AC32AC677F1 for ; Sun, 15 Jan 2023 15:59:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pH5PE-0001ng-ML; Sun, 15 Jan 2023 10:58:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5P9-0001iK-2w; Sun, 15 Jan 2023 10:58:43 -0500 Received: from mail-vi1eur04on2124.outbound.protection.outlook.com ([40.107.8.124] 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 1pH5P7-0001Ko-Ho; Sun, 15 Jan 2023 10:58:42 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D9M5sbAX5pQXpnba6wQzOuZDOaEZIUdOhA+qyKIiLFzelUQupLbYbDdXJQ/Kd0utaJcls6C6CSY6HRVhh+dgN78gmpWyTkd8WHYbU1DnUiEoGUD6wMIp0Ea5Tw3Dp4ywOREreA4u9Qb5Hp7Xz/qPj9EykPekCxEoxrMlXcy7xdUWwpA56ZHr1vXvTW5haFaaCl8NpR+r9CFhKSg1n2RHrvIEWLznpRuwPgr9e8R5WdQK9K/9LzoA84GJZbhMiXI0vw/LVkoBxLaouGYE6qkLaqxgD7T5lgMcfvIheJ4n0zqdSGSdvbcbDN0ePzxhrZ9kIAhD3dPGeulKX8v0Gzij/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=jN8RgkorK79wVMgslyhH+ZYUxnA8Ie6vmg6Dp2EXz1I=; b=IG9BXYj1tpLkUY+x2kaQrQXchODas8vLTO/S4tQdPnUPt7CzH+HRYIJEaiOQRoHVHwrGALFcRBELaOylOaE3rdqWfeeQoTHHtmQZl3dH71QVfXXen8FvWELu9vXM+nGzKEHyQPuGH4GxjNpf3aNuOozxjWe9jnIdN/2Ue/VXb7+o4rwYxcdEpdzubmeaeSoHcL3PH7dAdu0u2y6mPNHENHOTYjcqH/mJYWxRWNCiqppqHErIeAQYVI8Aou6hVc7+YxHqVqpmcfLpnz17fITwWuYTR4alUHhLazCdFP7WbV83sxCg5ZRrCTk+2AU6xb0yvmghDIyWj3/l0YbgYspodA== 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=jN8RgkorK79wVMgslyhH+ZYUxnA8Ie6vmg6Dp2EXz1I=; b=eaorcscYXfdPqNFwwluBF/g0ATNVENVBVAllbYygk1mFLDtVswyTu9jjBdtY8NzK1sp+7z00lpwsJHMyNyeiudcio9llkW+dyFsqnCjk8Dkriq1zG5QpiZE/9zlR2nKeY4VkdLl54+VtetY5TWpgfoznfyPTG+yC0VeaAK7YTzhzb0TQAQTfkbusLRtkrIEac9B/8cctdggfV9U/rW8gl7OX/K2XZXH1ixtJCkq077TIibV2CiKrsEVfXhxiX8G8uupQU0Q+VBWnaDFzw+AQ+gINdZqsy9Qf7zvRckxCSf/OgSP281InFiT04fPWD4NLBqa172ndVfUXuJf+XPaIdQ== 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 DU0PR08MB7857.eurprd08.prod.outlook.com (2603:10a6:10:3b3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Sun, 15 Jan 2023 15:58:31 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.5986.023; Sun, 15 Jan 2023 15:58:31 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v8 04/11] parallels: create parallels_set_bat_entry_helper() to assign BAT value Date: Sun, 15 Jan 2023 16:58:14 +0100 Message-Id: <20230115155821.1534598-5-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> References: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0312.eurprd07.prod.outlook.com (2603:10a6:800:130::40) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DU0PR08MB7857:EE_ X-MS-Office365-Filtering-Correlation-Id: e5473b6f-5985-42ea-ba31-08daf711592c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K+lbUe0uGxDNpq38pkotjIInSdtlESCgjHA71SO4oV/VMm4mB7gYK4HNQ/icvKENTM+Sek2IwB7FtYKR7ppVM+Ymr7UannHJLRc64qd/+JxuNuHjmhZ/aBg9xVKELHKkCRScVFVxbfzOQIi3JGZm2NG3UXjRlGgv/Rsc8RZ7E3IZI5uY/tT8KBjBed3ALbHiKDtCez3cqqQLWbA5ulUXc+FlUCsVWvoVRAkbBhZyDkLJbFkMTs/OL/1bDTgAdNZtzJ9K3nMiUTSfXxEgpNMwDV/GlbSSx3JjQzNCYXzWir9cCJMHIWOFZZVRy3Xp8PiycHDOCgtaehD/7wCWB1C/uWXxLqkF+JB/uU6pDBichf7BHDz8iKZ8lKYUxz7HGkhS2MuVPBLNLUzZVfN4Q7JGDAoWMYnMaYpdNdggOK6HVITb+pD5J3zlmLN5xsmvsWJKoeLVwc48hUXUwlAzCF7yxG5iA2qtKjzAB8KwElunO2K92fEdXsqTkyXvRldcPJr9BmCtKzF+K15x+r3TYyfAnd/hT6doYaEZ9fAKhQGqJNj0GQbQdqBNFx53PcYC9zENtxIbV54p6M8ay00XZf1a1q7BYOrpKctopOpTwayvqrEzNg5puKu9cXsWo011Syz9a2Rqr8ch2DXjR+YQeBRAXOtfz1T6RhITNgbcyTbjiv3NTd3pDOpU+HYQS9mvkTGp 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:(13230022)(4636009)(39850400004)(136003)(346002)(396003)(376002)(366004)(451199015)(41300700001)(66946007)(66556008)(2616005)(186003)(4326008)(6512007)(8676002)(26005)(36756003)(86362001)(66476007)(8936002)(83380400001)(38350700002)(5660300002)(6916009)(478600001)(6506007)(52116002)(316002)(1076003)(6486002)(44832011)(6666004)(38100700002)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8jzp6XPZCuBZpPKU+PC52ZJMcoNM0cVVyr6jWw8MMFmhcgnkXEGXPTFvHQBD/0+bEB5CE+r+E5vlJIn10F+1DgkXiebRbQa8lBq95xKE2LxMKi8aWVjTyYdNl4a5G449J5yHtqjktLosvnXv0IjqGKZHax5E+kAulWsQSg2PRh/J5YYOVrRslXDjiuSonhTVDNLcQGpxiRzlToKMFvIBvOgIKofqO/LTBWeL8qU1GLTUWsDFSNsI+lc8ArTgkSd0KKYxQrulWzAady7FwDE8jt4N1RjOO/VHYiY4Fkm0pJXuGGB8xKGG+aeR6iqedxws1tIHEk6w0amOKEqhTFdLSO/6wIZ8iX5vYG5TvU2eYMIhDSULiY8A7/h6dG29LsATI32kJ0gHJKiH8GFBNSySp3yx8f2fy6Ih3DEe5k0C4HsQMFuiv4uMrhFJ8d1zaTthY1sHFX9PbRkCmxZ7Epy2+YE2kcUyTuachNDbp9HdDm500KW7QBm8k0SsJSSuFRT1CE0ehJP0WcePmrnBqiETPBR6GwaxaXTB2xy29g7NCtU1UQg7PM1oQdJ86IP2DmKSY1pqtUnEqlcSWIRKu6uEmpxAW27rTa9k942rAp6mhB7ls7VIQ87Ae5Ip5x9yj41145iLRKsaKZyA9kHoNUtJQP88X6w1iTqEeyRlU553EGY63PsE+rr0A8Fk8a28oQ61bWf4uMzPlw6OO7GJjqb21EH71R3rr9twsJs4Cgq7gRggDwzxM8LJ7PVj4F8N/3Oy+2li11HvJUii5DiVLxcxI7nCFtw4Kxnx8cErexjJYLvIn/Lnp/GJxoXx9SEFWZuuwkLxWcoEI/zcRniBtawWUAnbGRiCluI4c/p2K5iQUi7Tjfun0PkJLzLNcWGH6zoT3J0I84wHmMgs8q44dw2822KBOwESHjfhyha1a8bSYlfqX/F3Amw0nIhjDKgqqmuW5lItQzIw0KB54fJxdgZfDLlMRSmzCsIMnl1YgE66c2JERasd8x9JXb+npKUNZOA/Q5mvxwEQUO7zcw+dqGqPq3GZXy9UPAMsfjcLR94VTraH468mzz+nI2pmoeuPj1agTtp5Q747QeBPokD32NJvfpt0Fz0FfGNF4mIodLY0a3G9TWU9rXF/ZHvK5E9qe3+5RVITzVuFZtKDc+I58Fb4eIzQLui8uXTbAdWJCb4Un5gAzODfIaq6EO+epHEiBzEIVglv7BOhZCGemlDpWgbBlPidKAUuI6kC2IcH77wHgDYDFZXatxcxYDEYfetqcG/Fa6EQnBkqX0YHGdHXXL6Mp6+6gYzPg40faICL4dfhHj/A93K+ZJ1iNGmJVEFtv4NVfP0BEc7g0A5zpYTULN/2/yp3kO2A+9PMAWDS1CBbxaGuC4EsJG/dKhfPQ11JTEVRFg2kRHHx5fDDz8KcyN9i/80ecyF+asdwIamhIqEFMKklh+Je58VgjSCNN6wyKtOiPaza+4wRw5/E2wdjTdVju9VUAOF+qeKvzGXDkdwDLAP4P0zkHmgvPaHsSWaoSG3UkaGvzfOeSC8jd2HiN1qItVF/53YXhb7wwCNr12GqHwaDsFF4+guFpqQVRU/QD2ReXNq84LvRVaAYyJdty3KT1A8UoqSJLkxKFS2YdDStfL0= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5473b6f-5985-42ea-ba31-08daf711592c X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 15:58:30.9890 (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: KOZtgwtjznolVm1oxcO5JTFufZieJr+/RzVBMT0S02cp4gjA1t5uXJM+m+qfrEr7b2oy9XG0/DIvIJzz9BXVz3KYU9+Z0EJL9Dk+istMWOo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7857 Received-SPF: pass client-ip=40.107.8.124; 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 9fe0f33ba9..2144ecff7d 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 coroutine_fn int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) @@ -251,10 +258,8 @@ static coroutine_fn int64_t allocate_clusters(BlockDriverState *bs, } 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 Sun Jan 15 15:58:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13102293 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 29D06C677F1 for ; Sun, 15 Jan 2023 16:00:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pH5PC-0001lB-Io; Sun, 15 Jan 2023 10:58:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5PA-0001kH-Rn; Sun, 15 Jan 2023 10:58:44 -0500 Received: from mail-vi1eur04on2133.outbound.protection.outlook.com ([40.107.8.133] 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 1pH5P9-0001KA-BI; Sun, 15 Jan 2023 10:58:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G8ZmEwLkX3n1HZiZ+Czw+nTvtplVfW2q3YWmKgZPFGVumgYYCNIjCCskI6+6cDeXdjPhs63BOM1os/skaOsf395d2YHPZHIJximxU4ZBQYdBaiBMUntqypth7FGoTSeTPMt1TV5Rj969SZe3fg3+fbai1U7EnVR4yvyBejk0b/8sPZfs4TrUZR0xTLugdxzINsyVK7Zk/9mic1GYjVABg+6ZjW1AqnwONyBZEUFx/WbdUw7OTlzF3tAv59s68dP9mhFtF9dE+1epZp4Ti1PCpm3N29ZPznb6ySIelgytkDyLfJ/YdhDFjzKXEbwBZ8WF6O+MRyM3VJ1R7GwRXSc3iA== 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=Tsf78umI7yoZtB7HbQqkE2cEGfOKrX/i+TG7HBLiwaw=; b=lD4kFLkbe3FDQPZvZU2jrtn+A3VrjWX8KlZvoHfS2u3qffObBjlB0K0dI+HX2ixTioHeQ0mjdJ1nVjQ9c/4vUQr67jyISSEIbnzE41P6fXSB5vNv3EtZE7y1i1D5h1SYb1gw9XBur4ODVmgVBm9VcFJncJ2EgZjg141VdSpzAvsdpzCsGz2PV0vyYnvegMtCHp+rTgWnc1PIevVGTtlYaF5erRJlSPn8Lqkqjgi3WBdSy5bp2si/OYXNC+Tggxtp7TGtM1NXhn7D9yvlWZY4/MSjooqbDFf/uRKpjFfC/Vxs5At31K71ApEJt7ZD/qSpjW5rlZKZDxtKE4mnPZ+M2A== 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=Tsf78umI7yoZtB7HbQqkE2cEGfOKrX/i+TG7HBLiwaw=; b=iMyCyJoPSNJcmrUl73wHJ8j6gdj4nrdHjh1ykMceAqSDDcKOJ/Ot9ILUT3V99w+uyZqOgLy4C+xMAf3yYeJantNJAWzjk/T5fHCCJ6W8qvMmKpJU/GC+YqCwUL19ABXwtvAiviR0R3LvzxD2Pj6gTX/NpGZHEkjB8d3SeAKgGcFxmHkD8edS6a+8GaA7q1wruvsSfuusattFFinSkjeXtaxgawc7rAK8tOKP+Y+JcqNHc2SMSOW7scpz3mVaDd7VIQJP8lr6icTlaLUwmGGZKyozRMuAptvwG4LO7O5g0CakRyeAoSFqlCBeoTfopXB+yxE33w9SWsL9uqAuM0H/QQ== 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 DU0PR08MB7857.eurprd08.prod.outlook.com (2603:10a6:10:3b3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Sun, 15 Jan 2023 15:58:31 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.5986.023; Sun, 15 Jan 2023 15:58:31 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v8 05/11] parallels: Use generic infrastructure for BAT writing in parallels_co_check() Date: Sun, 15 Jan 2023 16:58:15 +0100 Message-Id: <20230115155821.1534598-6-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> References: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0312.eurprd07.prod.outlook.com (2603:10a6:800:130::40) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DU0PR08MB7857:EE_ X-MS-Office365-Filtering-Correlation-Id: fbfe8d6b-46cf-4aa9-4c70-08daf7115987 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6EUFsGFnMgoxs/GTuFAeWdTIdl9DTJVg7fM2wNtDEdyIRE+VsYC3HofR/Fz2rspV4Ws7UeOwcbag0TlIRH1vJA2NUsuyNY15ExzI0b7eQKptzXo4R833lpNvIzJ4rDHU4yfY4qN67VJW8Qpwa40//06sJMuR8zZbDwKI1mZbuXHnnSLkkr3KRRQ80N4k+l3+RsQ/7vPhDMRVRI/Vu1qRlyHIp3JdV8MMEiFtBIbq90QE2OlW4tWLPz4mnWEjqesr3AP+TkkUyqoCbAJFxZTikRu3z3ixVU7tYikPWlwPXzKzGhGVt5jup5ctQ9NXzrXJ0JgEW3q20N1h9B4kJ19bL6ruksjAFqRcd52YODIFZAYtwkH9uixlk0bWnd5JYLjrNBeddT5iM6HC0ma7skSI9pXG6dt3aWiXdbhxQbAs5FXxjX07eETdfjt4uJqZSVb9EKMHCpnTsk+7XbykPueROPoPYh1NsrVjl7XBzoWKc6P6hJSTQwaKQ7/bkLW9oUOnmerFnPtqMp5x8+6+iLPSLZ4wPnn9pyo0M9LEWelNtRG1TFT7mSHRSYDnXVytjb8lfiBXZSQVGP/4cR+lbgXO0iDGcJ/3MuCwtSVeP9u++diw6ZDV+Pj11cnLS2sG7W9/0uAeQMtGPTzWn8cZURO5Yru0E8GddFAmSEVOKPnOoSLUMSoDk6LZCtXGK2CsLJCtddt4n5elBCYWOOw29rqdDSaOmRFhw6vkedz4EUBuGJI= 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:(13230022)(4636009)(39850400004)(136003)(346002)(396003)(376002)(366004)(451199015)(41300700001)(66946007)(66556008)(2616005)(186003)(4326008)(6512007)(8676002)(26005)(36756003)(86362001)(66476007)(8936002)(83380400001)(38350700002)(5660300002)(6916009)(478600001)(6506007)(52116002)(316002)(1076003)(6486002)(44832011)(6666004)(38100700002)(2906002)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z8OjKiPQHz3zGIGpyJSKpd2NEWjNljv8miZzmZzRT10rJb8EW7ZFtVbQ0W0LKC/FpT3m5JWmSTqyAYDyjzbbUNTw6K3i2Wt55uw3Tjru0mrw2p3t00pwTGTZ6zHhj+ho5NZftBNqav0ATNkVa8e8UBlEH1xXYMjvSmBWfm0O+i7tJQqIUGiiHoH8F8B9iqk+P0WPwLbdp3BtIyeaCGISTT/2hRWol0pRpnfehlR/l/ma+XoGY1nzRM/9OzBh26JT+ckPrB8O2QA08XtUuH5YxUGvRB7JQvs5l3NrBEk3QSHkW2oEKfmmWcWQT9xsCHM5mDTQiwWiEvshWehgESSpoIDBqHYVlogVisqququUehCWDFEbQt/MjZbzski9lDhS/kG54VrxQnl32lZlehYpIwu+iPbOMZa2t1PrFloizuJZ1Z1aA9/dbLAl4+27L+3heUFwOP/Dcs6nvdGl48AGBB+72Nc9DPtDHEelF3Cp9KbIpfY5fatJW+w8ImhPP9Ht+t5nuOOGXMpSDp2VWmn59J9mg5wpQqtCdwx4+ZazhocMwyRG9+2gsy21rkDufSs/rfAbj7VSQzU0N3heeVwz2cFblV3Y09CfGLOkXMuF4iGjPMPKgYm94c0DVxFSNUvM2rQactT/ZOHRVzFsA71nFDfrOoVoZkLIntWfa+yjmTohT+mjEE0phd5L6gjCus8MqUes2hp29ltNLbZ25mQdZfTOdWp9CDJgUATqIqvqT0grqzkaJR+omxTLxYxS6O4CTC1JLOk/WVvjxPrzj0E0SpG6umJtjkCVwnHnJvs3SFHs1kpI3KoU7HPDvsUG+n6O5gza67st930hTL4Xnh4tpYNmdchnxlI3YO/LJhL9a4In4dwRcJE/dBNLLqqHUqtmoLCMrKjuQcWwUy5HN50CQw42MJXn5FmT1lsc2lSeBRvKe1cqSPrr0g9iALZQN9eGHlarmxkY8EQpIur9Pay8N3J9cMn+TfKZ0dV/urm0AAedzmmoWHKP/NleSlmHGuqaayoJdH8gEeNwG61Vy5GiMPtzTIOHgaZNDpuKpy2RVv9xLqRDQdOOXrK30/dBjFiAG+PyF8H7dtb1iG7Ohut/jjs+x7ftU2K6RRUjKFGxbbO47xCaf3jPm1MXNrPa8GAo1KJ5EbWYqItPVE/gwOPIujEZX9UmsKIPP3s9aCrHBfML2fBOuZ2eaqRfYMajbpPqWTuB/Wge3xTwrAWnzJ+XvcICL+t/+o+jmLy42vBYLqqomUZcGmhTB08/CqyQZ2u8Vy+zMORGkkJSye9zraUeyiLmvi5zYr9DMosZfQ26n3xvDkZGEeejIock3VOIOb0kt84tw8ExJtQzUVSjKQ4gojT6VSgnavqEbQIoTEZbFlBCEQXkYrMrCHddiWnOSSfrKx3YkxyaJJ9KHYbV3IMfM/E1wkcTxxqSZGT2mC3wPotivvOKjbG2jXTT25nw2f2DHjkaDh7pxZCx3dcEldw3o5t4R2f9P3Gkp/Yvhhw3bKhd2rmv/n+rtrl2qaGvG6KCDVM1ntR2kH0l9RPNkRLDmT+BwTAJuYvgY0+H45jxKHfwu87PfiytDPlXMdPkjJA5gAGPINtRlFidiCxmF9ZhsrEUKqooR6UOnyLn2Zr/jMM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fbfe8d6b-46cf-4aa9-4c70-08daf7115987 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 15:58:31.6139 (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: 75ie9uZGTPzSheqCqw+LVnX/7QLnCGmc4e7zUJD5zyyUeqbM8Ar5Yzgu8Ga+uaxV8rnC5I1PYUCkiUEjk7ljCvaspuqXWZ/ewrJexTI4YbA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7857 Received-SPF: pass client-ip=40.107.8.133; 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 2144ecff7d..3ca4ec469b 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 Sun Jan 15 15:58:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13102288 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 22351C3DA78 for ; Sun, 15 Jan 2023 16:00:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pH5P9-0001j5-GT; Sun, 15 Jan 2023 10:58:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5P7-0001gq-Mo; Sun, 15 Jan 2023 10:58:41 -0500 Received: from mail-db3eur04on2130.outbound.protection.outlook.com ([40.107.6.130] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5P4-0001Kk-Di; Sun, 15 Jan 2023 10:58:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uu/n7WoIDJd5PTk14oUkmt7UMBO/rEttVhPFypW9c6lkH8cYaeEkCIlB+5WfGGDIm1XQLX5ijaXo+hG7RnlLjvQ6doGNYOxZ++OGkGlEHDV0yP9lGMlMMoRwEIv4KxUvuhl8pFqyC4OsJIqLZrzC5AMdlxOL2IqtVSjJxtLEcPa2OIeKbI3u+Mkf90L2CVR2AZ2gWMgtBdoeBwHDMRwgLux5MVr2vm4yXHRdVehXIYdKQfSQyRim+skueKRjd3oQuVIHW7zGQ+QepkISNEYv278f94M9aw1xEQcT5UU68uIzbbtfyTzN3cDmlIydWDb7xvQm1Z5fR+zGpYVF27gNhA== 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=3z9C4Ki+nBn658vBnYINdNZUbUC/HBRqTWRxLV64hQU=; b=dgklA/a2e+4kwQ4coV4app3XkHuzdRiyVpaOGYXQAKNmk/pcEfTN1ILTMVxCh1d7pNX+Er1LJnPsjsSD8VnPoDbdKuKV3JGyUm65nbX8t4KCnmIW/uw8kYg6jTXch4e57t3oci7/ceR/tavzp7hEFnlQz7mMK7ZVyB1qCIOByQBg7vNwFurOfDggDmxyxRgK5T3e8QFzZDK8gramYi4yXS9q4T554mN+hnPfqjHKyUCC5yPhdqaMCkgYV2vZaRCRcV+jCFtfkVrp5jOID0JF/4AMA9z+zKYSOk3GKFJ0qkO7+Lbp2XBhVFmZV+dotNgJhvNx8rEmIc1qBlEEq0WAiA== 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=3z9C4Ki+nBn658vBnYINdNZUbUC/HBRqTWRxLV64hQU=; b=PchoVp/aXY6lWCAB22q89TfWuDRl+lQIjOG7ltTY/vPWiRiPA1eB0NOVH1X03CHNnc5tAczm8B/pLMSe7n4HULdibBBNIeav5bqcf2BbR4ksstbAoVMBXLCvaVe9IPKG8Lz71cDPmK+B9GCRqrVtQC5iDVRytRuRfHERSVAKgXDU1FfQqzepC1YJC7LUmBKg8oxO7k9XE/o1aQIf40G0855XmYpOicIaV/oSZ4FBJOE531G4/ScM424/SyPGUI8dRiBHSO1XzJuQ0KHa1cSJbtUPIrCMFBicI4wjLI0xbzJqypUIlBmFSa0o/SfGxQ5HzC2nud1NocLd2DYFIfhv2A== 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 DB8PR08MB5467.eurprd08.prod.outlook.com (2603:10a6:10:11b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.14; Sun, 15 Jan 2023 15:58:33 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.5986.023; Sun, 15 Jan 2023 15:58:33 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v8 06/11] parallels: Move check of unclean image to a separate function Date: Sun, 15 Jan 2023 16:58:16 +0100 Message-Id: <20230115155821.1534598-7-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> References: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0312.eurprd07.prod.outlook.com (2603:10a6:800:130::40) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB8PR08MB5467:EE_ X-MS-Office365-Filtering-Correlation-Id: d10373fd-eb59-4103-1f5e-08daf71159e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QXZIFMOegOWK9WpAGrRI1f1td/yFDQBlti7qYldVSvayetY03kf+VSyGzqgTEFy6K4rXT3l9M3tdRE01W6BW4R7oFjpXHyuDC+5ENHcbg64adPy4lws8TrD2rJVj+dz9zNNv7ds63ZwuLUVnKFtCpz1rzTV1JbTby/u0KEhVWor7CKB4gtvKkq+LmF8EQWjNZrlRHNW21hReBBL9PmFgYMtNGyLyAZjxYbpqBnxNtUg3IM0cCI90WQ2q3IWJtB5uVYd62o5Ur/uSIHoY5hM3FkH85gp3MkWvWRDKT+wAhS8fD7VxQuOYJCyUFz6pWhX7sA6cQ4rXKxzilgxc+I/MAXcAKE7h1OcKWIwQktPKugp776Sfkd3bhJkcQXDYeJxyx6v5eLOwLqEb4TFri7hRh1y609DOm/xkQvc+HTA9TKWv4wZFUYZ7JqGITFsHB9PO4+t5bSUvoQ9z/FSSAMgB4h9pzM37Hc6FQitjTOnRuu8a2L2RB4+vr+uP4oM7OjXdnz4IWsfM96+Ge63WqNgQlsl5X2XRCoAWl94jUx02+TRJFsFr5koc1GI3n8rYHFjHIPV3HqtRpRuJC370k5fEo1iNyyk0Jf3DUkaPv1kifIXHT9u3N6iEswEsDO8z/OKSNjGFRbxfixLHJljmtD+nO5SiFqoglsh0GBnE1Wk3/fbQ+rMi8NgyouksIj/daLwh 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:(13230022)(4636009)(396003)(366004)(376002)(136003)(346002)(39850400004)(451199015)(2906002)(86362001)(38350700002)(38100700002)(36756003)(2616005)(6916009)(1076003)(52116002)(316002)(5660300002)(66476007)(44832011)(41300700001)(4326008)(8676002)(66556008)(66946007)(83380400001)(6506007)(6486002)(6666004)(8936002)(186003)(26005)(478600001)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zhJ7GMJBP8C6GmMag5b954uDGEhXMJ7SQujzAqTSoIHXcZvtzjUK1MhZgsne1YSXZiaHLuLgEOJkibvhskqAvnIJp41JW13FG8DjW76RwZoi89xjzFYLhSFOSkncp92eWqa3xRIwrzepfYYW8A3C2mLQplDzC9jAdl/AFw8vgd+P0/pqSPZPPaG5z0pottorb42vw4r6rm/law102WpA1DeuZ4OF8wlmhZZ8iMVrg/8GKVy6FENayacO7xbNFOvkZqbfT4P1+at1yQTml4fTMD4g7nbu/qPZSwPYMQWkNquGN2NkSk4piU4x2fiJjyDHZg1aU+l0/KM2uYcy0BL9tZ29No7bWIOygVmc+HfvGAdgHV9TiWwAhkqh/LzA5JEHUjL9TwI52D7NoZLa7bdr6jX8pw7+Db7mDnXOpidN93zwHo9ihAz6RtpMxdLCW4FDYBikPRZGH1r99mKuXZPHfFVPIWA+/jbAFsUebIEaYsMPks45qcmtkvOtq73jO3wDTQ6n4BnJXa90rpgfcfBtOpe3CemBs1sBQIjmg2sKYZCqfmohRpMIP4EaR43vX857pwutR5ZXfwkuYtjEG2bn2L4aScM7WY1yUEwmHEgjIZsfjsa3F4UWkiv+LVa6JSRtU+Hy7wPr5qfWqNmd5Q7k0vf0aJUossAB7TEuaXzmw+LO+jN4vscKG0E7VIG0R2QzdicXxE73fHhP6cXXOUJJC1AqcEmjogur0RPbaVh0++d5RLTOCts/ysMCqkwFOB1LHs26Ez69W+56mDDdr+t9WwMbIQnZM+l2WxsQmhxd9WIh9TsBCum6nkq8k0bjcrsoYOSe5YNPCdu71qA1MIzxoFpG+OhAvsVtHkaVPteIVUMaXbCShigo+EgDpxDk1jmOGwFj3TScqSas682XtmjHH21KWwU29wEu84ba4w4GrbptGpS9oV9xMpJzr4U0rmUlpFKGKI7Bx4EJjZwEk86K2EqzOgNu470ew7EFvBcYNDSFM78Jnfwhj7PfKyr4XyvKATLV+WvSK3etCEmSJC2St2ebc0x1iOuoNANTRjoQ5UC6I2roONvqR5oBo6G4n5c6V24eR1z9QZjFKnaOHsnePJBhzabbOJdDHK9kmxuHbZdho4cTCcA/LYANVy5VMSHV31qne1ZMUv/C8/dcALxS4PP1XrK14E8ulp2RRfOIsPD+I0Z9jEJstI95JoOdSOjO4bDhPIze6SF9K8rkViiNaUWFJyO/dAF/CyxW6TuM3z6puTPuBgk3FkR7MFHyb5k6f6MOuVHdpPbp3yod4+OUw2ts/QSK0QbT9gqJSHGmQvD9b/Gyz51m111u94M3Jkn7E0P43vfF2hPTtKDm/yLxQwgu/5kRUqtlZX9VNzArKaxWe1RGmPLfl1cwHDtUNY5yo6UyvSTjQwQgy+Ydj3gKI0eupFhVtg5phXNMv7EBCEkPZ571WG1WccITxGyAwWf06DkvtXDDu7oNozJHZiNm8zWsyoKz+SnzL8ZtVrhBikxlr0G+NUcpf0EqGbPZt5TBqLXQx4yKU4fh/TzFKAJqjkTrOaJ0hxShZ5NffRleBumD9Q66dl+L9Va0e4l4f69R5qKy5d7kZ/Zbc6OjEhTl+L0B0Y72VQ2tKsOS0vdwrrM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d10373fd-eb59-4103-1f5e-08daf71159e4 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 15:58:32.1911 (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: 5E/3eTzTxNZ7Ubx/QCMRJgzsshLdt4DpVKjq5JjAxs1XxhWcXxn5emZDLJeLygoYoi84BEZEbDTX+hGjUM6J1DE7/IqZw5upZPUFXwaWivE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5467 Received-SPF: pass client-ip=40.107.6.130; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 3ca4ec469b..d48b447cca 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 Sun Jan 15 15:58:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13102289 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 7F23AC63797 for ; Sun, 15 Jan 2023 16:00:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pH5PE-0001nf-MZ; Sun, 15 Jan 2023 10:58:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5PC-0001ky-5S; Sun, 15 Jan 2023 10:58:46 -0500 Received: from mail-db3eur04on2130.outbound.protection.outlook.com ([40.107.6.130] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5PA-0001Kk-JZ; Sun, 15 Jan 2023 10:58:45 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TTa3EylP7zSTVuDQTnMlpYvnz/NKeNGPDfRCAFPJ9copeOrc9LpHqWaxbYbjIe9/mnQmyorfMhFdbzJRBaderJzKTNveRcnh80/JuZX6LMOtYmzADJM6J9OnqyTuYt4mQkKGQWymEs01r8q+YcyyjZuf9RfwIoQBouKe82tCCQvmnUFA3NC0OdEPG27bUDFS5tjnHJZCEAQDV7mjEHz8W9J1RQl+Q2A2lmMKF9ZGqHY+mT2lOkObRAgonwd1nZPGPevp/c8UkxlwhLYs9IlZg1Yr3DmBYKKwgM/jIMkMozvYog9d+hvi6BEGwj3XbjVisc7SNRLYvaTDYIAhQczPug== 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=gX82eY9OVKTk3V+WAd84FKsP02/sy2KoJqSwNxgWuVA=; b=FaasdAiwnkkXAJjXvf9rhAUKY0eRPk/iO8sZhvVQWP2iI9zTRi2lYrSa211vPdjBgw/AH6DK+ziJCDJShk+03T256RgJKXl9CEMqiajjr31/VO6W6gez/WReud92X1PV0XoCM3XTRBX8+ofnlWWKrDW8cl88sMiYFYGHg3dmobqOxhFqNO0oXT37c4fLY3dltmYGCOojK3XMdBniTe2WOKYOXlY6J6UDKpEwM9l502gFvV1Wlx7+xNIJl8xkgK8TNqJMvFC17RMY9eRJ+SGSf6s2zOxqM1V5b7F+4x0wiGxPIf5YusIPpF5jlsoGfvzCAgKWYpDcsDxWCo+S6kBHpg== 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=gX82eY9OVKTk3V+WAd84FKsP02/sy2KoJqSwNxgWuVA=; b=K8msVTa0dMRqjeh+6Or0XgpYAQVYHmKRFkpLka9pes9nSIdaddWu81OkAQTkMbvZCKN3VQkBb3pJL9gxs97k57x6r7B1ywBMjdyHW1dUiYaHJWeOBdwaa/OSi6qYpN+BBQ4Yf+SkruMqfzpc4Ds8TlVc+P+o+TEZWygaD0tVid7GpV2dfjn9+781mkSROtJ6iuqkPgA9WbM/r74lVNl3Pu//iomV5MXo9Y12yf3mZ+qcYbbrhiyVdExFT47UNTjLDvGmhvvFR2TpXLh5wFpXQfR520VN6ybyHvku6eLSx2Zyism7UqF8rhUu2aCwgtnZx1fyxKtYyb4zuJoYPBB2DA== 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 DB8PR08MB5467.eurprd08.prod.outlook.com (2603:10a6:10:11b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.14; Sun, 15 Jan 2023 15:58:33 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.5986.023; Sun, 15 Jan 2023 15:58:33 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v8 07/11] parallels: Move check of cluster outside image to a separate function Date: Sun, 15 Jan 2023 16:58:17 +0100 Message-Id: <20230115155821.1534598-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> References: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0312.eurprd07.prod.outlook.com (2603:10a6:800:130::40) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB8PR08MB5467:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d928ba7-834a-4219-5227-08daf7115a3c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NXyPy9nfVIMXGaPUICkVZUKK7/0wOfk6RpUEWahqFRvmiTrtXF5VJ2dbYYgFxqLVgALeoK3MiADHCHySPOU8yy/YyBUKNl23Qmui9yvEDRG8gya+dOb3x5L8rHPeEzS/EAMZuluzEMjYb6MDOT8+Ypf6eztwLYtpl2HYKpEMOj/TOq/s3HFJ97IXoXCTpzEv6UuyulDIGb2nNrGQ9gBtJrhvmkY9UcTePtbMUR3xXz+eMZIAZnl2PLav3+j+VG9iFPTjgPlJ8QaVXGqFqz/khzjLKwADQeFmNkBbyYX7P5ouHPOWhmMrGZTrJzhZfnQmYzQEIBo9KLZH8WFrgyIBBSvD5Aa9bg5tsjcXnow3USn8O8jwbxi+QE0zvvpRs2HcR5pBrpJO5xNFs/GTFI09LEtzTJzrQOAj5X5zBGVFDcf98NNiitiGT2rVbjkq1nqS9mdu1xO26ysX5cMA+Fb2PEmuD7NcVufs7qzgP/+kHccdxZGWJcopZQcVwBX1jikogTkhPHdfzK9Qd52h84WH2MrNTpZRm/P/Y24u/8NRCMRSA57tbJHKeXt6td6vTikPbibM5x9XrAYef8UaM49xxXMpbZAHONdeR5eRaKbkxmu9N9VUWQ7Vo7Kr2+7h4rO4X3Dw8p1UjOsl/V59NL+1Jh1B9sFi3sbMdAqDJUe0VRi60AqXYy6EnNjj7hWkyB5QCxTQNpuFfDpYF6R0EaHYDQ== 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:(13230022)(4636009)(396003)(366004)(376002)(136003)(346002)(39850400004)(451199015)(2906002)(86362001)(38350700002)(38100700002)(36756003)(2616005)(6916009)(1076003)(52116002)(316002)(5660300002)(66476007)(44832011)(41300700001)(4326008)(8676002)(66556008)(66946007)(83380400001)(6506007)(6486002)(6666004)(8936002)(186003)(26005)(478600001)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z6o/SASaOyb5rHEcPNeCLKc2OWQZ05bhKuHhWoS0vXpftogO91OLuIFb8mn6eg5+Sm89sMc83KGAiUtMigFlQL4Kg8X1EGIM17n+dlKUe/ks8eH4hR430XQT+B/KLCYmWHG3uF/hLgH4qAp3TmZPL2+toPxoOCl/SgJ/zubwvox3BcLhVHobGEaPz3C9UO/G20w79gGrzTh0WyABwNXZv5vjESKbSz9eY2eg+ckPsNnk52HpFjwbS8yfaBq6fgQuQHqgx9quzRNr4NTkNHsvagldz9mIHLe6bOfb7nENmlGpBeXojZVcd9FnNosz94BeYYX2psXG1kg2G3cnUO+agVy2FSZ2n/jADZcwTucDISW7mDpZBe4ylvAQdNtqURl6beTxGOFDEEM4tKH/YjokrgwM1I6x+Qj7IY8I60kU0vdG9R0W8CwNFnEVG/Q/kz/tf8Q/yq0xYLcyjRku8qQ00CbJcdR4coKSbUrOlOiZQgsVkONwVxV1+sQvvenmfxJRPYZk77oX/o86A//v2JhrXmj1ILeSVG5a6xBUYYDHAi3tCjLhSMpk3a72gxyy8o9StsTYPsWZGzto1kEhELAOH9zgAY4rvHVtG1JS9iNTD4qyshJDhpsn3Fodn45zEBqpBAQgm2+gEdl49uxM8/qJ38sjUoiHgx1r4XgZNyhsGHB6DqfQr+yfROUkCVtmZbI3Ud9S2rUTXsBnrqyEDUOYHg9bWACBzD++OwceHnJsFwLGv1+EHmsvySIM3T9Opr/azxmAo9CEEimsJKGoa64KuU7xxyWQk36MVMJVjMfgG6Z5Fiiah4dr/thusDh6Bq5wuQG5IOXntxV6CHL/F1QdhUf6zlhqfHPZ5lONG8gy5sCJmqCynoBKBHRIYoaclNrN0+ifyPEXDUnZeXlVvjAKkMRvhQdp5RQxV+iBPw48JquLcTKiph83TRqZFI+10R4PJjw+cAmkTgEN+Tu3z1CILMwDU5ElJnvDfbec8oRUANlFCw9XDSpaU/IPOsR1E3I9qydchUzWglb06+CgzWymm9v55cE3IZ6l20rSFGAlylLCuK0HdGzCJBR7+rW+0UkoUOFcn1cxnUhY3mBNouLsuxFxe291o8f0sPF/EklGl0AFsRFViw63uFNvwuXSbDCE/VRACckMc2P+dNgc3miMYhMmKtO0L771CI9Zlze60qX7V46mtBqOl2aLlsaqJvVkSwhj9ALoIANPXhb9T2w9tAzucDV+EiIL0HzUZJvR5OZxcoNJowpENK0T9ZfaCnRPSJW5pWwmbZ/no4yY/5jJ2U8hXU5lgu4r0mONlQ6LX48Pratm77TJwyH5CUZ6Pzsgi+f9j0422GLIhNQzY5CFM6yqYpDh9WgmB161lIgWWmrsDBIBmv0VvIc7/yp60tdtq9sVhK3KcY8suYdMsHmfIIo3Q+WozFoCuCicrt+RjrXlQ3hCw7V1Md9KEzvLpCpTztzMcCDOJi93CIfroRJIm3yff5lQLk1AvuYTcbhl1rlwURKPjzEbcrCdi520YWfIlTLRMlgOPqy9QPY4kxq7OY6GNaJRglbW4kCMi3XcaorGWE7Q5yXx7ajTmiP4T/nWgNBzIFHrUBPKIA03Eo+3pVPYFrLRFiMsHmWLlaN6A6k= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d928ba7-834a-4219-5227-08daf7115a3c X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 15:58:32.7847 (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: BZW33nvpYEq4wI34vJodMZYm2FgTxOrrGDR/FiZHT4cRuS0N9allEY2yQDxQg9uJhLVYZ8flN/mkOfBXJHnMIrRUmzqE/OYoyoauVXu3AMo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5467 Received-SPF: pass client-ip=40.107.6.130; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 59 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index d48b447cca..3d06623355 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 Sun Jan 15 15:58:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13102296 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 10FF4C63797 for ; Sun, 15 Jan 2023 16:02:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pH5PB-0001kW-15; Sun, 15 Jan 2023 10:58:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5P9-0001jQ-Ug; Sun, 15 Jan 2023 10:58:43 -0500 Received: from mail-db3eur04on2130.outbound.protection.outlook.com ([40.107.6.130] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5P8-0001Kk-Ab; Sun, 15 Jan 2023 10:58:43 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KP+ooVUzmTZnDwxW0NJjlXEtVS55WyVwMxk6bzZ03cj2iPQqXp6bQ0F0H4QznU9aBAjx2ZYEo4kX4yKPYxaIjlL9i63xleNd6LbqSWGlUvCKa2Rq7jLLWzX5mqalwH3ZeXwXKXcuF3rauVMoNqvCovqKRG2s16xptNrHrxdnHnVGHdEBCEQF6G6ZZOWJV7XbM+1TcKXCSNZBPp8fnf+fNJMf4F+AKI+pmbP94dRDVtPWKox/F5QG0n3uhpY3mZ2XrhwTFLvNnNT0Z7U4v39SdpJ2OnViOHGaNKWbApYf4iH1XS07WCcO1X1zKO96T1qedYN0Qv17MHF/Px9rP33TCw== 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=geGN+NrX22435C3Q3VUc7ChRkoMS8dsEkQOqFjwtgk4=; b=PFxV3y3Xx+4l3ptly5gQ0DX92mfjvfKxr7pb6+9mBmt1S5PomMe/Ow6t40AHUCyqnjHfah6E8mYJmVaA3BAhF+rTw1ycPUXzbuIxR4rxcVw4Q2E3MslLu5D7NM3q2qf/rmR/xLV6UkcDN+hsTD4f+NfEImI+4QSpBBRS9IwHiuEXSuU7bNHmzBtFCBn+X1e6bqDl8IbQPRJFoGS5VhfZCR1FdCto6LFdDCcJLP/8xR16xdCyfVKoPYkGQ6646zbPp42sNu4khNa1cTFEvbRMU6LViCW+1pegeo7R/nrJ4+Qi/kvi1lE/+E1vqqJKK7WQvLpjrsBg4N5kbG0ukIt91w== 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=geGN+NrX22435C3Q3VUc7ChRkoMS8dsEkQOqFjwtgk4=; b=hId6W5xxtF4d15lKkYtfmsYIiI3YDXKB0q1lZqLKukch/yZIdRwV0ZNb/6QYtgd0+fRveCntR3C6kANn3UTl1wSx+TK+DP+XCLfpwUQM82KRuvNnfY2LNITJBA9TUtQiFMY1FfECK7MnvRH2MTW4vgHNe0+yoQQy9aQZw+vnu6gDtc6vac968Uvra4qM996T8zVgreQWSgPfTdtNkxdG2hWjWCz8nVWMRjGA3QpKqhvGvqX1lx6wcp9FZP3CskhIR3OxNRqRRMkkI42dmwro/pKRXvJjtw9be7Jvr/qq+GiL4TLnTYRsb15x9zYIep4z5eJLeh9bfZzDI+eyXikuTQ== 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 DB8PR08MB5467.eurprd08.prod.outlook.com (2603:10a6:10:11b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.14; Sun, 15 Jan 2023 15:58:34 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.5986.023; Sun, 15 Jan 2023 15:58:34 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v8 08/11] parallels: Move check of leaks to a separate function Date: Sun, 15 Jan 2023 16:58:18 +0100 Message-Id: <20230115155821.1534598-9-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> References: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0312.eurprd07.prod.outlook.com (2603:10a6:800:130::40) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB8PR08MB5467:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e082e41-4328-4059-49a2-08daf7115a99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Esb5MDPWbK2N2bzSwNeaVzaAU8x5Q/s8r3+tLrqLqWpdKojBu2RTpN5iUOcPbDhbKdiVoVrWsxJ/Ty19keWW+9fV+LfwJuLNXRNU/ttH6nL/eARvTqoJFsCLR8Lw48YqjpFX67NEAKfY5srcMIjjEf7A0muJYNKgxrRnNzBZrS5NHPy3BIdl25HvlKc17K2goeX+825Z3HwPiIfmK0/pwELRdGKcSxQAZq2sr/6LPCtXw+l20wzAvHpqiL341sK152hwZCUfl1MwD6qwpvZhrBUWaCr9PhAhvDpbp8KlIT8psT8xoJv5im3vP1d8gb6VOMfwdnQb1gfmqw4KK6pQix5AbzaAhLjfMoe8FROgy6oreMjWOLmTygWvjgC7DRxHGMb8c/59/Za9be86Fugbtl4Blcmh4nvEAioQoVNNO3cj3Fp9kyrrIP1/bHCmsSVscxZTGvPCtmH8ojds29Hr5UHXajY8/RsX90LhhtsJmYGKBqgTm51sw+PS9f9kxrtAkcdl8k27FdxNajcTv2/q5nOeOI7JKFupmp8IMhQ56EhUdnRB3B04dmtq362zAHJ8NTGZ3mif03KjrZhx+pkHFeoOgFl/nLW9GpxEk+b3nRLfW+se4c3CPdBZkhRySVxmDivO1PjmU4ePMg70mKksSc072pXW3+y2FGH/i2OHrplvTLOQFRQSeKMMlzyHvSkpCqVDtmoub1J1+VeRZRj2PQ== 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:(13230022)(4636009)(396003)(366004)(376002)(136003)(346002)(39850400004)(451199015)(2906002)(86362001)(38350700002)(38100700002)(36756003)(2616005)(6916009)(1076003)(52116002)(316002)(5660300002)(66476007)(44832011)(41300700001)(4326008)(8676002)(66556008)(66946007)(83380400001)(6506007)(6486002)(6666004)(8936002)(186003)(26005)(478600001)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 18Xxw0WYMm7vHxgjd07Sq/lYlc/P8iAZcN7QlSJHnEb8Xamou3fLWVRypqNZJpNaCA4EQPufGACITeWHZON5TKkWTCTfD8m3HRFiGIClIUBPFkC2tlr6n9T6fo95YA8lvguyhNNNZ57FMrij4EYxmxd5DkZhsVvC5xliIlneyHw1AyFWsdS5sSv10w1XcHHm2gfgvvEizNhzjaJxr+EAW4aqD0pTQ8WH81AwF9a5BgSDGjdUZ2fkrjMITlS3t31fuAI2Tz8chYyuBT6EUN1E6UOGD8GqusJhmP2yxhL6W1+qsyMRoR9pAetuBYcllh4dEjIP8dHnlKK9YlLWCxD+R9tdFf+y96Wu4XOaTkg5ejbj6AAskdBiRd0cq/2FHh1OT3CdOFSPENRVQr4hM35pmc9niDLzf2vk2bEevHTXxweiR2AvnufRqzSvjNFM7U+x2tbEVgU1YlUmezCy5CjbbhQ/V2yPSgIWRQWFmqOeZTEbyFHM1JE2F/7clrV7dAA2Topiq9IvA47+s8bH4zCXFXM/e6y2kgZEXY4sD+vZyrbe8219r1iUZAt6fixUFKJ16KCnwIyvrC0vWOi/IP5mxQtRzibX0bnDY8Vy20Vio26m4Nn5CwDQ5WvAr4RYVKJryB/9RQl6joKJd+lvd8BTHvNZvUDGi4wVN/RIkynvlBbAI3EHOkbhzy2uLwPuKhKP+RiEceAW6kXMl5IGXPZO1HCwJgXqm1AGvANhW4hRfiaKX1FocoZEb2fCQhYT372D1JMClDqXgrawtQ5H+e5XiQBxRPFy/d+H+bthJoeT4N+TWD1d2Qv0YdlepRLvNRX9BbihCoU048oQbvnjAG8sNW5cyPlz8IhtRBiwsu3ZgR3DpU40npLYT9iW6JcxEmXXqQhBbkJw0fUMOf0Yz2EOta+KZXMlSny7GrZiqfh4b659FIOvPnTsfofZYLtR3gxJ1B5rt8YeNUo+caY9d16II7m4cW5fA/HnzhjUXZiWCagu1WYmk8GaS+G963rOPwA+glxh5MBM70SZxoIO4yZlynzZx+4q81gHvTW+qQfoA8CEwZxK+AuMFLDw6B6hP9qn3ElCR6mrObMM57IW04z/DxsjKbk86A587Nryp5Uzg9O4mMpnP58PTrKP+BRj6LmlMVlO4YnxYJRkDvUxs34Vd+fLr8xYklmLnw9/PU/SpM/Y9KRt1Pzc7OSVtSnO9Y5rtaBtTR2LIlKVWmlftFflfe7Ed3dqkADEVvocGRADRGVrhxCB7WvAEkQ7zBHpvEC0d2USIQWV45i+snZCYgx+d+xQz3Yz2RlAXKRBo0q440QCXshCLO80MlKSLTVUxaExHqkgUBNJrrHOaKYPeYAT8uYrn28zh0NlyFAmSV5vyd7vl3JAqVB4rqzM3PPSH+EknY0Sa3Snw4yi54FIU17Dbp6Jg0byjU0uDtOuz38L6iUdWGwgh6BND6cdkvCwK0CjIFLgp1E+M3V92E9EyA3CwE6EMarQNHl63yjl2KbJr6F9B0V9emQxnScpK5ivzYBktkd3Cb45nHmts/SLtsviKAtJBF5C6/zR1lHq4xoR7tndyL2oHzgAY1gpe5ZhsTYfeW458bY4MFWimgF6P3FRpgV+Z8Mt5hPZnPqTgBR463Y= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e082e41-4328-4059-49a2-08daf7115a99 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 15:58:33.3784 (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: i2IMNE2snfvGuoZCScQMOcfFJSSGGqxUL8CkZtao0Shidqcp0pG9bbYIPZmPax8ng9qLj0zsKunNmM8EkiGgxRCmdkOyWZKG2Sn6FW0oWDs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5467 Received-SPF: pass client-ip=40.107.6.130; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 84 +++++++++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 3d06623355..5db099b1dd 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 Sun Jan 15 15:58:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13102297 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 BA6A0C3DA78 for ; Sun, 15 Jan 2023 16:03:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pH5PC-0001lF-JQ; Sun, 15 Jan 2023 10:58:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5PA-0001k1-OP; Sun, 15 Jan 2023 10:58:44 -0500 Received: from mail-db3eur04on2121.outbound.protection.outlook.com ([40.107.6.121] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5P9-0001LB-5U; Sun, 15 Jan 2023 10:58:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nSm1VFp5O8FkpbH0+lALPb9fPU8kI/4mBnzI/G6neV6OYqGtPAoWYEyDCZuVQshD9VHHXeCDjUIRJZzlm9wQ1Xu/1TH1nkAKJTFcT6MSzJFIp2euSSxQAUksX6wBZAm7YQlAkZQRALC7ndDcBhvAQB3PYGCx7tOqPBrCLh2ReE0rfb6CyTYpaXKOEvD2TrYqdoSUKNLqrOKCKdUkl9B0XUSsfl6uYK10bfIatSsrIapSG8Fj+4OZUAzQtLFLPxGUlwtRpAqSQxVeI+VkUAu0IqSoK18L6bNTzM3D24PnCJqbh5gHHLkXqXCrN4DPKSB2ufS5Sl68+IKWSQZm8b5obQ== 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=a5ozM9nSTui3o7YQGMy7+2YfilcLFn1crGkq3eyJn/w=; b=j44dFiCc1fFd/HZPH1gc9DV9jITapjIoQ0QyXVGfIXjuUZT2hS95W6TSz/SAZ37dw+Iy9piWomv8VNAhc0IG6EOD0L3XjRhMQaD9m9IDOn6oWOZ02nZV++i19k/XvaUabMkndQsmexKKTc3tkoHz9s4uEVRBL+447CUnO7WRltmHz78ncKYSRdLpC9QjdL/+ZF7YBuNUeSYJuLdrRRRIEGPS5lT3g17JvY2cHmfTLkPK5/zhBeqiUxmDIvN+U1NLVQI7fFfu5KWnVq9VzUZ+nVXnrjVKVtrkhKnW9tYHwNsJTbGR/PNgXKloEFqdPbHVqCbUUocgRumgnPoOGyOOJw== 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=a5ozM9nSTui3o7YQGMy7+2YfilcLFn1crGkq3eyJn/w=; b=uibZYGDUuIHmqOPzXjou5iGIsaigk/bhnK4EW4VtBwss7/U6q18Iv6eKI/mGFq2fTARuE55oladuMgmneusAb8hZ4WXFcXcR26iZF9Hd+lO65zKGH9qt6JsoXWMZ4fHVstrAWgZf9F6SWtvfmhL/r3hl3tghewEaTTPUMW0/GITfCnQQ52pJ//1hoLVgnob2Bj26uZmE37oqWtopRBM9ZCvJxSCB4BZFAa2MGFKWA676L5WByG3+EXVauJoqKy/BhJbxIjprGiR171MaBoCxMUmbAIPHKdQc3/T0JdFiVXwGdqXYbPLgMd+CduJiTZCqnJUFBuCWk8AJ+/ezj5FZUA== 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 DB8PR08MB5467.eurprd08.prod.outlook.com (2603:10a6:10:11b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.14; Sun, 15 Jan 2023 15:58:34 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.5986.023; Sun, 15 Jan 2023 15:58:34 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v8 09/11] parallels: Move statistic collection to a separate function Date: Sun, 15 Jan 2023 16:58:19 +0100 Message-Id: <20230115155821.1534598-10-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> References: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0312.eurprd07.prod.outlook.com (2603:10a6:800:130::40) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB8PR08MB5467:EE_ X-MS-Office365-Filtering-Correlation-Id: c02fa762-1b96-4a47-0fed-08daf7115af4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +fd3gJ8VkKVctOzCMO1soEBwyn+hAieNy0qtT3F8h9IQWuQytwCrRTu1WfDE7CX7Dy0F1Uwt2lfEJrNpCCM1t1ncTjzXls29le1HX7ETISWC0+IU+cWbB6YGOETJz4If6bZwrTELh/lA5sLwcWeYki+JPmvclSof6FUBh1gfDUOP5Pt6Ou2+t7IpSTqlenkokfIDzV6NhUFKe/1n8enF6zzf9JUKU9tGWliuryIaVJoRrQZ7F+gj9jVdeBKVI3yfEBBfeWCMIpE//TcYqqlwVQvdPHn6XLrtUP+GV1GqCfop9dYmsDgsvBC2dFwJ3O94yxLyrxqBXwhx8glsZVSgGpoH79WZxi1OewUGQnYAgtzlgYib3xxZf93J4P3LPIJlswwezOydhYMwzezYZGMYvEKWSBIaeU2PgyyWXmkzX9GkDzQZDqwXtkgXCTR0Bp5ElFPVQZN0DLqALZLLgpeYq1jptsrTAmrQryuswMihhQBy/Y902qFAKq3Gdia3TATClqlWkPvVEcLgRitDeDKFncu5Mw0+XwIg0Cdja4izPHKMnfzq17P0rAFkKPWAF/MnZQ8PNNSVAGwun3o80aeef/yKqXhfMooUY8Qw3wOO8EFKzHNy/bDhKgJNxmrYr05Ywbmgx5TKqgpWaV5tHxaQjzsBa5Ymp58N3ml8k9JASI+lxuGyHCaRRHrR+NHos+jK 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:(13230022)(4636009)(396003)(366004)(376002)(136003)(346002)(39850400004)(451199015)(2906002)(86362001)(38350700002)(38100700002)(36756003)(2616005)(6916009)(1076003)(52116002)(316002)(5660300002)(66476007)(44832011)(41300700001)(4326008)(8676002)(66556008)(66946007)(83380400001)(6506007)(6486002)(6666004)(8936002)(186003)(26005)(478600001)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IrDjHyWENghIqwL+barrZVQNKecGJ/PpB/eIB1bMsuuql9edA1l8ibcDO0fY0KhMCqUlqXG6sOp3vhPz9EhckLEWV4Z81xkarJibbp1KHSciNBtISKu6t3wY9rVoHOjKAsJqq2Q2nWcWSo1knkBHrXNy/ZVp+s4j6Hbb75qzHYUlMpzfeTsgvwbH06/4gNwjw2nUxTrtDhH8IwTVb4O/Hp1hF6B3r1flA7J+9QAgn9H0j/KHWUtnQELxcIWhb93sx5wmCfwOnld37Md2iGfBLm8dNKj094xwoKG34GtkcBywIGutMm8iIgI3MhLd4JMEDNQ0ABI9SFxu0orfYCTRAkMjd1euxpqWAy+2GsXcpYoPGGumcSPUJTF0HitIUaq6JJ0zqn99mHVeIZEp07fcf1+Z76+sW5QyAELhUnLGWVOfJCh9542/y7SJfYzCwNhbc2xhiflQpdZXVCf3Jaa+cM9qM/aZOqc1wCOQbkB+mxQfpwf3UBWy0hLnqvpmNhkndSm+mO1rpCAF8li+GcZxccoYBX9ebXYEIb5aS3b58KrBjfWa7PTeCxNMvFEu6T7529SeejRg/t/i7+hLnSH9TTKhvccu5TBCLiZgvTObs1/yRJf60b9a7eMUR1/BTuhfojQx+WboIF3GmRQXo5on9Kx9pbByrZzYHjnuhoJ3Y76/S4A5Y+krY+ljF5W9/VT9L7MB6rMjjsiKP4w0vtse6cNE967xkTYjzsJFkVXoZfZEkRxO5GUN5b0FN3QA6B7p+ywRTOAMjmoyz0B3igTjyUknic0WtAQzQC2UXDhoYL6VIyz9Bpjtpfcg+8PXpWT9gJ2WfBK6Fbr/YTPZ0hQRfFmihC4GtKj9vcMsJ0fKUg8Urwkszkf6LqY9JfFg/jK1wwNHF5bnpWUsMWbPhxGr8Gn8EWVnjOOS5NMbpBBjtVY8yKAmGc6HotBGDXkW+qld6kHl2c3OzRg8DSz7O/3hbljmkjeVUCL1n8UWtP6f7hoUIAlgpcY/1UpFxFmULvmXIb/jEYQ00x7c40Zwu7AOkWGAC8GiPjHbsgA2TMBYE5KLARi9dreEnZQHsmWpCgZTG+wjhJxo0gK1Nv4qB6jaMQKVXm6P9Avy3LCCsPKMJO6OJ8LbuxmhLdHntBXkKadl1YnHCIY9UWS14lPUgB2Ut/p+sxqwiyKjOzuOfU2Orn8kT5QLkeg2sauJ/6LVlkILEZndrgYZzbsbYeJcpWJ+ixP1WsBuFl5r6Vas3dV+J0gRGsrNV8cnWq8fLMOTxQ34eCpSlG7/HUTq1bs5y01N2fS0PIsjJx8vCL3QB/rMYnOhWmSs4GAbvFTjc2sB3tqMNk2z9ccLKY87TELAbUyB5prGvnOmpYhUJSORepRn5AWdGP5YjF5nhFHLKrY0EGWF3Hx3C2XBVH3rvWcX114a0AAIUE85jB1M1B+AOCvpoDnxtkYv9rSX4mfNTKKfilbOwcL9LoNUpmqRespsOOQUwwn17nMdXRHBTzD7vc7EyLJ3KzOLcE1oqFSKqe+CBvmgDbey/k8UtwmwmoJJ8Oh1e+d0ca6wJdymod5nrsds2/GZrFcxXMJceFs95HWwlkzGbBST6vf3dPsSKbQBDIc6IlWCttZ0+hiaGeXU6oloP6Y= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c02fa762-1b96-4a47-0fed-08daf7115af4 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 15:58:33.9733 (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: TFOK2njxSHr/sEKMPhrC2W/C4Rw/rmDv2RFCML/zcxHEXDvpHvevhs56llYW+f3wHZISyO3YKRx2h+WL9oxhJi+KCgRpNchvI7eZDKiEmWU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5467 Received-SPF: pass client-ip=40.107.6.121; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 53 +++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 5db099b1dd..6e7f140e06 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 Sun Jan 15 15:58:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13102294 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 632FDC63797 for ; Sun, 15 Jan 2023 16:01:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pH5PA-0001k7-Rm; Sun, 15 Jan 2023 10:58:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5P8-0001hk-GA; Sun, 15 Jan 2023 10:58:42 -0500 Received: from mail-db3eur04on2121.outbound.protection.outlook.com ([40.107.6.121] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5P7-0001LB-0J; Sun, 15 Jan 2023 10:58:42 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d4woVqtbF4LGoI+7IzH5ejLaMaVfQzAF92PBCPy4nqrk8fWB1ou7PdX2e+H8WzgKlTotPNeYQkJ1l9tKAXqyH5TgdKCNRgTG8D0JO8uFpf1KT5H3cR9tUhSmpz2pBr7IDnbdqhRy8giuj21yPRXfO/qaKZqjhGcZhB9mnRGHrfkoM4oKB0CaK9ZjnGtCtuRvtM+0/NJEfLlwTYXI3EA61l1SIXDbsgR/U8Ly11fcxX4MTszsVcmbMPAxRrgVgYKQfA7rXjqRhCjCTT5OFpDncnNtSgSuM77Gp7Nw7vTRFOAXrYspetOp+KZgLRxHXJszFV7df5MQqJPjIrGx0sRJhg== 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=FDgKa7HuKyvAhu5FpswFKxZlrg/HxXRtNCC2Jn0YsBc=; b=MQAWsQn3W+xCfQuFQknnEkj8CeZWx/vY1K44oL0VhEnOC6p6JU4k/UhOqOuZJEB45teeiYBuwqDH6yMa4uuQRJFUFqmvpRgTqUEAw26xVjwl5kudfVibgAmsYu3cu2S+qKUhck6cdv72vug0iijmWfUBLHGnST1OEzJacHKm+eE+UK5z9zAvqpK502ZwlwTh+NMoGEipAI9W2C310eKUvVDALsAc8bigsyBrVbJBlMjhQnDEMNFdQZdep3qBO5/DFHSfJrPRk2SkT26dDC5QtsXNE8Lq8DG502aVUrfA/ZOwGkPmKXl3KvgXT10OUS12YTIGxgbDlS9LG6G1SuAaqw== 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=FDgKa7HuKyvAhu5FpswFKxZlrg/HxXRtNCC2Jn0YsBc=; b=UR0uJKr+W66LzNSkrn+ljdFEHIHkiWgMZsMwiiMj8jvpfalJE2RO75aUvDMffHVoIkO2AaQWqCuhsjDsLLhQvOOfa+ZYGgByLe/wNP7RBDxiozVS7BS4sQ0lBIh8AayvMyFBvB2pir38sYIpMYEkcsmcCv+XE5yApimrtt4zWPPnRBQVe0KKrsz789i5/sLFn8TeFBQ7wD96ZzBN6uh23FN+tTCUWLHgPIATmeC//FR/lmDYBOHWAkHxrbdISW5IkFHgxeOWDvApWcBkLe47RARmxpuQYu8p+SVLTUs5GS2oOovmkDwvPPCIPKSQOB29iVbk1r/UFGdILD/FMyQsSQ== 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 DB8PR08MB5467.eurprd08.prod.outlook.com (2603:10a6:10:11b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.14; Sun, 15 Jan 2023 15:58:34 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.5986.023; Sun, 15 Jan 2023 15:58:34 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v8 10/11] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD Date: Sun, 15 Jan 2023 16:58:20 +0100 Message-Id: <20230115155821.1534598-11-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> References: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0312.eurprd07.prod.outlook.com (2603:10a6:800:130::40) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB8PR08MB5467:EE_ X-MS-Office365-Filtering-Correlation-Id: ecaa305f-8d99-4c4d-0948-08daf7115b51 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KZpIQbhcy1tpjuL1hx/aS1cebkp2FMt7maZv8wegKg56AucFJ5bAyLLxkG1reukLZS0kNC4KVne2GExdGmz1n6XbdoK2stsyxcJEA9FF7Wpjpcao6jOZhrama7DWkkyJpuF8D61s/gaLW2dTMGAOorUD0Or3KQZ5FcGbXwnd9fy9jGNdMrmexAI5hEMw1afDakk4GWst1nihuwiXAS7hAYnrJX4KddB9r2HOjpboutoWX5A0CqcDOYSamwtoHdDkTsXCV7Gb8TYozm8qcNRKMbipPev48ooSvsHwae3MhS8uKfr25Qa93NP2NAsQoPHI2dTMtavZSckYQx3EIzsvQXfEIui6w7RmfoqkOLQ/K5ZHM76AV5V6KvJJp1fk6qOfBp3WXMHvgv8LUYc+BnLhnf7Tb2LPIOuW3p/VEhFX6PlPf14Xud2FRnAJicSvdoQk1QY9jdadpElo5SKwK0uf4Pj+cGwb2HiKc5n+oZJ5dAxc7q5K3mLTXDIvdvnB2V16WwfIgWUHLlrW7x7ONXQux1tZPXX6bbg9xuy8PNKLuHk2LoxpdsxHKIBjjyfefZnmtE/q97ccQtvIyYoMH8hfCuojHMKeDF8zy3HKv54Sua14mCABY/sKzCPr5Hi9C55xjYgMUMxoAFefkPw0TQ4V7MWsp+O9ck5ecO6CG3ODnsfjPfPtgkAEk2Fduw2/q19AnJLPf8s+Bbib4iR5lCrDng== 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:(13230022)(4636009)(396003)(366004)(376002)(136003)(346002)(39850400004)(451199015)(2906002)(86362001)(38350700002)(38100700002)(36756003)(2616005)(6916009)(1076003)(52116002)(316002)(5660300002)(66476007)(44832011)(41300700001)(4326008)(8676002)(66556008)(66946007)(83380400001)(6506007)(6486002)(6666004)(8936002)(186003)(26005)(478600001)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: T3saCQQOfS+tBioYXpl7Ta5nFnKMxQm4GsCNoIAawGRKLNpI8g09JL8V2XBg2FxFemI2xllLc7EcGxvPBBugVHylXIxm2LBgyqgJ7UChtnhmbMhyLS8TkTKymFLsGTz2qrjPNpdCcl03HfpB3GgSukvlouVP8Mx7Pbp4KBvRCqx1WbhbDDijQQhQvfxeG6WCLHf5ZGfY7y4qkANt6BAZe0oMEwGMHyMcOhaFtAsFNbvntwiaE4EmTJ3pfj+DJI42zD1ceKYF4XFcooB3EQXlKVFVr437k1QFNibJLIHH9xizp6xXqkcWruj78XHbiqbG8JOpqDD+9uhWCARg3z7Ud15XJIU6ec2qmb1rzJQSj7DqazvfUqTueRrUZv2HjKxmBm/Iw+i7SwidUUJvHnA2XIdRRy+UrDdgt6xYfWLJChAqXQV8naav+VVDsopebcYZryrXg1v57Lq8DrPSGpluTQ4Isb3QRvPWDFtzeDgT+V//y9+ZXkfXXgj9LVtDdr0+4rg5/FC0QGZK4HSQNkSUVrgba0EfHGns6F1aXfbmpPQytbusqv4foJA/ZBOUQsh4i/Pkhzcpvfk5QNjgYUrHW1goMHJAlxDjTLjacrxbeoq4SARlcu3HN4AS/ZuZXYvDkNut3AbgcdPoxwT8VKJiNY2Pvfd1jaeEAPQYD2Lgv9Isetk+ZpgRLCVljPIajMRNRc84opksVWOLVXGpiZX3j0rYPzKVpYeQHxOiRd7QOJ4DWEaBY67y7CgqQ2uGfLfkuKWvzciOHFJUksHW0Wy9JcFFCOH9oEbNGOHz6FfKPDG3ZzME8vuOLlk6zle7orOQ+BHLc1L5PH1wbUfwQvz1e46nrFEMd6AExTIaizeS3c7smVZk2cJgg4j3cvUAcVXzvw+wiBL5e9Xx05bJ93tegU8FyP6UiMIhVjJDfgNFARVqfTRkHQzVyrUOxwspcJxMvj1VvRDCK2GpenqQP/o3Asdu5z2yGoq/ZKuijJGtnd52Wsb90fM/0gf8agUuCDZk1sDy/d5XvIKHmJxpcglPVXgtokSgQARYTR4qVWLgpA8aihexMx0gMHTEO7Dirbp9htej08AAiT0jhHwEJX2/NPmyrYRxtXS7UaSz63Jgeb9aNLFPkL4QZp/AQS0gFrhiah11sTGsz2RNUKtRfIyKw7FpVzg/EwIUN0p1vbnFdB4qXa5iGX4Ln/BK8XF3jxmkVLcHpOxnmfOJuw0F18xG+8V6Og0tOpgONpT4DXfoYm6fkv3TKjvYffKoCoQx5aJ2+Z4ZFQmq2cA1VWHOHXfVGMt/X8q7fcj6+mU3lpuLyLGuMP3xuGQ/DJwnWFUmA0Yevq+ly9XoB3zfdqJ+HPkC/A50LkrP/qWe+Vrdk9ugqMSKfITx/nYImcAZ89ipMM5qeIkLAF5SjKsHRBVGNjaI8JYo7TpQTyvPBlzWO0qwgn4YLrjoYCPZL4F44T/5qsmDDsCwTsG2tibRmJD65qcx9crA2i5mFTnpn7YvsQo0ldoI232Z/AbSJ/ECl6a94+QuOjOCLRq0QPJYLbTh/Y9WeGNeujIwiVl1hFs5mj70LqmEnEg3smp2/OMBfsGLnIR9n1xgQ3x4DHgpZcXJq21nX/BpVGmDuC3ZpqWe6Nh/b/M= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ecaa305f-8d99-4c4d-0948-08daf7115b51 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 15:58:34.5825 (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: BuqMxweHmOvfc62H9Fn7fLflAsaWBGvQcpHiTUa0z4EH4seiRJql1WJn3CeGEr5apoUutdldxim20K12dw+ivp8chKsvgIji/2Q1F7I2UB4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5467 Received-SPF: pass client-ip=40.107.6.121; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 6e7f140e06..621dbf623a 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 Sun Jan 15 15:58:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13102290 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 16F93C63797 for ; Sun, 15 Jan 2023 16:00:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pH5PF-0001oa-94; Sun, 15 Jan 2023 10:58:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5PC-0001lI-KH; Sun, 15 Jan 2023 10:58:46 -0500 Received: from mail-db3eur04on2121.outbound.protection.outlook.com ([40.107.6.121] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH5PB-0001LB-9T; Sun, 15 Jan 2023 10:58:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ne3V7SqNiMUgByr4rHCY+JlT2nyjRp+ESsrVM+kCQcGZvHx7s8YnUP1IFZ29aGwTdxhBAas4xpCq+IWR74ZQyxV3iPv7aW19t3mjbwMbCYNyNdNqNLW8Ie3IfiM2BMKuhF9CKMs1EoV4C6gKPLt14fzDglk3o5Rg2wQ0Npuprsq2eI2fyPuhxJO1ERnaggF1LePaHEyiTnuI2jvjN/Q4hMrWW/heH9czsl/z3fCwRWePvVEEvbr4m8l6UobV+hZ1q2MOav+S6SJqNLkh/Nu2HW5ghFVJ1T2K5MVFcbfa6BrRtevN+AD9uSoigQ9zMr2X6RTwJxBHKKKi+gAeBdkqOQ== 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=0cul9dnN2HoBNMYyDTLJLoytx5FGQ3oWVvLVgPjn/rQ=; b=mFXWA2JP9hEAAtKV1VxW6DTkj9uyx92R0JwlYROjd/I6t5ZWsFDrqr/Ikjz6uR4IZ3n4bZmYEs7slNs3jLHYBAGgfOm8eNljLLWkF7dYLjM40y5O5Uvx1AOvG+fQME8x5smm5pvg9iIzYLZUKBgii5zgi860orEsj5evBQrjH3eLgrN7zYVpDlxUvd2ORJv/yrT7zvuV4bdB56TQBA3Wf1ui3npl/J2hm/x0iTukefLFH+8lnvPQQvYXxB/uYHP6phljDMVLeP7blVuqM8n7y5weRqkQplh0RiLhSDIgSVK2gHn7oexxUkL69U7Ghz/+0HWYzUAhNoPekqPvEb+t4A== 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=0cul9dnN2HoBNMYyDTLJLoytx5FGQ3oWVvLVgPjn/rQ=; b=Cdhnq/Z0dpgMvIHGMKFmUjFo7Lgu4AeT8MZ1Kx2c4dzsy7GqqmLuiiYLUekL58cg56gy1uKzQIQsqdavBeR9JKdWvt14R0wYstojcM7VSjYfog3wo46ScabnHXmSQSChFU/d8L7epLMGn2pWVM5cP18KCrbyVtXD0GEqeb9lZmGRzvtED0rYCzfYWpbgfjCBjaFDYc3PAIRv0GTUYpCGdfdUEfL0k7GBV4SyBf0+9D30Rqealc3xjR5TBYSrUOf737wBx79txXsLQ33WWWKoFAVToZUw5EIyKXKK0yzDBXEzq84+acQGSTfOGLsx/qXeXyLLIbY1ufqxX3FsnDpVxQ== 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 DB8PR08MB5467.eurprd08.prod.outlook.com (2603:10a6:10:11b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.14; Sun, 15 Jan 2023 15:58:35 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.5986.023; Sun, 15 Jan 2023 15:58:35 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v8 11/11] parallels: Incorrect condition in out-of-image check Date: Sun, 15 Jan 2023 16:58:21 +0100 Message-Id: <20230115155821.1534598-12-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> References: <20230115155821.1534598-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1PR07CA0312.eurprd07.prod.outlook.com (2603:10a6:800:130::40) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB8PR08MB5467:EE_ X-MS-Office365-Filtering-Correlation-Id: 63ae1ea0-7365-4719-feca-08daf7115bad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WzU3CLXVQMEtYwE1elCQHtu7Px/xjSer/CR3lWyNy2frInLwJ0DncsS60/i03JZd7IzGY3zBRvK4BpY46cKCNo7IT0+ooYHrCyiyr6SHrLhv5lX3fU3Mc4Coc7lOMfeo6GZZsQAb2mi8lRwTMXO7kpLquiye82Ipgh5n6u8o3Ss8qFahOzfTeu7hGiXnM6fQixtKeWYsBb13xHvDymoJPuiKMLx+MZp4zB+ToWO/mXasmI+H6R5Z18WvW7J2fV0bZAL7IRCQZT4k9yMNjFcB78yqO0zxkimXqUuzdNeY6y+k1HtOBQ2S97XDhhaxSWcCksmHV+GPCHOTY2IyWn6ozHhbzplUVLPC2xoOJaGnFZL3ZZArbUfJS3SbudAWXvgdVlKj2WCUGh4aXaPTrHDTBenDixL6gVqsNH9rkE1Wa4UmmP4gN9jdZM5zSQwbdS7qiYv+bJ+in9bD7ha7MtNgF4rIpKtT0QmqZxSq9EyCJvYMEj0b2H9l4B770Ih+GA9KMzYHMwi16T/nlZB/kLcURxTk3HkmprXMKgrpFni6gpaE0NcLlyfUcon9g25Z8KgIsviq8kzvihkluqUA/TLsYeA9tk7/YrOTCDdpSViT4zojEvMSym2luLcGMl7oAeHgQHBgtfz5U37UTpEt9zzZj2gj+EIR3s1hwTnc6SN5yOgC0jV+wo+7+ktjtRTPAEVR 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:(13230022)(4636009)(396003)(366004)(376002)(136003)(346002)(39850400004)(451199015)(2906002)(86362001)(38350700002)(38100700002)(36756003)(2616005)(6916009)(1076003)(52116002)(316002)(5660300002)(4744005)(66476007)(44832011)(41300700001)(4326008)(8676002)(66556008)(66946007)(83380400001)(6506007)(6486002)(6666004)(8936002)(186003)(26005)(478600001)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zHdkoYY/6pg3eBrsOV3ZR0wJQVBx/Ge2+5WIwdf1y773nf/UtG7Mh332tLI5S6EG4+nZl7/1nYkeeoGVtBZ0kJEs8U7MiIwUnN8fmkGjovd3V8ILzurzrhg3CwT9NKsjqRPlYqZQj7VVTTafQxJDpgOeXzMo+nyXC4GKqrjTpRb4deNPN5/U/SekyRBl8CPgnHkhlTSQqfy1AzB6t3mqkNk8KCf+wnTNFS5FF7z5Gd7vFtdYU5jkzNMbu1HmSONAzwLf2cxaYip14+YlplirVVRHWwVI0Q/fTpbByXa+UooOOQzvUHAkTN0wuMdxSBuPeIdqfBhKQDFippB62ZFopqYpeBouUo7P/riJmddij1UtDfsR124OLcz46EvLGha9jAzAxmInKrqtcFoeWIAM/e6QvXeEBJpg7v3NZj7KKauvKws3Cbn6VM+Yu4614W3iXRBg1hKTq4V79DlWHI2v79j+neo9YVYgE7rV1xE8jadDwEhShjbzWJgSABLZdtO43UgH2IkgbmI7CqNusXAkHC+ymCa0em92IGR1nO18hxcPl2wKkqXHLbQ6CcbCtMmqF0iYQcxFtPmvWmorERmkRIAQuexwB/sq0T3aPG7K3KsM7kem+fS+4zn+qMCt+/9iTx7FvwIcYLPPzZXQIq2yw37HApcBLGBnKVEoPdiy4A756n2cNNacYXHNHVLNdU89j2G5v2NxSaqaJNz3K3w5teyF2U6to3Mpynz6dMtIwSFqXLOekcUK/PocRqNtnXaE+qTjEzEHEwkssrv7eO2WkDrCrHLJwxBY+ameThoqL9kGylmHjyz3Vodx9Wi3fASJpg/S1BjUh8aAe4YcbPTDiZwWv+Cs6BoWOgSoe33QqxImaGk24pRnGVZwriqQMl2530taVqxJPiCwHl069k5cfcpgVev+cqD5ZWF7fNFLWird0lhTRw8yoU/+0h9vH3hCXvRPS/yvEhUn0uUjCcRkXTz94Z4bVTntILKb3VDXyG8+wFx6ZCgovdknGPoW8kMhsgrHK7xNmWF7y0ytavMTiqcEyfWlpqDkA7pG68zWzzUgB/sLSPTh2lYAoM8Q3ptPaqUbb49Xshf57doPtPvn1WjuEBwJBzltENgS8sOuC+dZWL+sEZI6dyY9+mol3mqswREShDrWH89CFkuKiBpV69H58i5LJXuR4Fpw3tb62Ie9Dbqvxe2MdJxJK5OlP4DHTs/+5X5WAr7qoGwDdjalKxPZJJdOk4zY102RW6ciqFV3VN3OEXF8urjAZrdGqcfXgJUm//wvtQLoI7xR9sxOb7tsesmNpeD7YTjNMZCfUYZK4BB8WL9n2KHf6yx9j+MNgtWsTmU8yBhXuPcTYWfOOUun20MmAlXBan9Ir6ACXy0odiLnpbmQE7+jL3aC6ze17Y7DkCfL9t7x15KQ087Lsl9dyNtoc/djQtZWfVKfzWwpMorhvzKbK/B7v7tFa9CGBvXwHTUg7vMXp3vunKcxX/QKWbeJeX/IhP1d853+enNBGzx7fh57ahkvlCBPmIyNYO3wzqUIg9gfwCISVzc7s1AJTWwqy+CzwJ7+cYGKTgF6xThmkxp2JfbvscPXfqvetXrAYCAC0HP0mw7jg0KoCVRu6a5TJf04eD0uT1dM+5U= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63ae1ea0-7365-4719-feca-08daf7115bad X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 15:58:35.2699 (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: jEekeEf4lcJZcmB7BGzKIpneumt09lONbYTWPbfUbmKAfDNCK5/Wbnuc+PMdDCJzNoKLP5UCOjmhDnTnfwVFw1S/pA6pptoOt8ITOJN+BkQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5467 Received-SPF: pass client-ip=40.107.6.121; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 621dbf623a..eda3fb558d 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++;