From patchwork Thu Aug 4 14:51:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12936536 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 EC010C19F2A for ; Thu, 4 Aug 2022 17:13:32 +0000 (UTC) Received: from localhost ([::1]:50352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJePc-00044M-1D for qemu-devel@archiver.kernel.org; Thu, 04 Aug 2022 13:13:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJcDW-0003QV-0s for qemu-devel@nongnu.org; Thu, 04 Aug 2022 10:52:54 -0400 Received: from mail-eopbgr60105.outbound.protection.outlook.com ([40.107.6.105]:27575 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 1oJcDS-0002DQ-KK for qemu-devel@nongnu.org; Thu, 04 Aug 2022 10:52:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y9hQ8jAJsixUcWZU44NiJgpS1m6rFn6JMpVjQIxevBcA0FBgyeuAaPcOtSxukIoDnfb6im579zh4pQmLa698ty0o+PBky2J6vqg6OcXqfY5vmLWWatQZ1YV6npur63hwCWYGAiehN+qjit+d+sBz92XdzowFyM2og8408mRLyHY9//UFO0JzGnxH98hTKiHL8xVaYGAkEkhUtE+y+x+6+JPpBcAzhPHpJ+Su1NpvoRpO2azTAGzarzeO3AsqsA/YrxUO6d4BuCEVb9YRkU/EEYshBpXKd9ep8w3zpsTsGLYw9XFBlB/13IcemSx3v0sTUxxXf1xVXinEGE6Z62hzQQ== 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=K4DZffO6E142Wt6JwJal59fuaXjFpQa88yMQcOAFRAE=; b=Z+9Ckn+W0u85ryA0oKPATPW9fCJKfb2CIJq1F/wrLRYYVFttQ08R1jTvMcrqSlbflqRxn+w8HJKgzRCy+HserAyqEpfTcrcY33okl8JMvH7vW1xe94SHMA0vN9eugJXN1fqPFZ/jnDyC1KteLOh66K3pahiCtist/5vchVDFHAS75fNPZ4XDYGPo4k3JSYiJ+D67oLpnAUpreOVjVxyLPPGUc9MPzfbHktA/2P7tbQ200+prb8Ug6Q1FHxgOCIu3kER415FgFk1MhWmSLHo8xej9tLieC+z9dvHGqhuQoVj5eI5gLNL4WIlBJRnjLTjg/SVdrrujelMGzgkL0Lt18A== 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=K4DZffO6E142Wt6JwJal59fuaXjFpQa88yMQcOAFRAE=; b=CqEVBn/2ruBO1O7XKR1kPDiDWTFQFliInznqMGPedno1G9LLlJw1voX9hwNlJXdr32UzHe8LRqFhf6I9J/wDbKMRRykcuGa0rwVO167jKG0O/oEcpTVgRpcmIbHlp4WgQygzhaSRc4kkjsU3AIRodRPcoMmWlr5seQU70S9JR/9k8cbADwpzVeKeBbCSBxqnr/kQeRGm49x6iNgE9kaD9/MBqOy+oiloKCHNXTAoXht8pdWgFHA2SWuOD0fN2NKzf/hoieEEhPZSQTMy7WPtgW1Uzlzz6Ie8goIcUKMwz6nNfrms/DAjecvmX+IdPqf6kQLi/EnMrtmXlDMF+h7mvA== 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 DBAPR08MB5624.eurprd08.prod.outlook.com (2603:10a6:10:1a8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.12; Thu, 4 Aug 2022 14:52:10 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%6]) with mapi id 15.20.5504.015; Thu, 4 Aug 2022 14:52:10 +0000 From: alexander.ivanov@virtuozzo.com To: qemu-devel@nongnu.org Cc: den@virtuozzo.com Subject: [PATCH 1/3] parallels: Add checking and repairing duplicate offsets in BAT Date: Thu, 4 Aug 2022 16:51:58 +0200 Message-Id: <20220804145200.564072-2-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220804145200.564072-1-alexander.ivanov@virtuozzo.com> References: <20220804145200.564072-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0146.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::20) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2debf98c-f14e-4a37-0479-08da7628e8ca X-MS-TrafficTypeDiagnostic: DBAPR08MB5624:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MZsPUiH3hbscSzhKgk5bjfQ6DxgIjVvyG4NN85bKT2GAtESs7q7jQbcgLWlHfXq6S1Kt4pJIWBPDSx4VVFWR36Kz0UWr1cM4nTR7iAJMSgvj0z4c5Xl8gaGY82kmxV8NKtIysPi/U7SM66K543vZhZdl3njkFMdbF51NmRgxc+YY9t7JFc8BcgJKcOLlYB/J4ngeQJdRHiGcwQHe/WIQveFQUTL2Q7tBpXinn6XE38wsIdTtrN5vm+TyD55p+B0Ej/cz7kiIV6/Fg2VdMtCXul+V+r3AVm6EF4ScisiIkmqTtKRooy2t3emK/Ds3C19DX3AuxzyUVX5RLyx6++xDPIfLmK/6jJctePaxBdL7lrjwKIquDNL+SGhQV8M2hZcjX59TNSLswdVqJNx4D/RUugD/KxuW8p6yXRFt1v97J/vlgYlSSFeu8vshrOLs8hnNiDXK6ecboJ9vVWG+kEua07QiPJanbvSrUj+Tc+OEwakSn7pEL0x457Z/wd36L0igI1wVU7Ap7D5eSpFpkSZSQYbo3UIm4liLsgRfwGxrLife6WvfCnC1GEF3PnW7qVTRU/ozzZI9wjxEkAmcKVahcLTP3o2ccu+JdUaiR0m3kdRTgLgAfDsV2fLz1KCDiwIs9OY90hLqw4SfKCOuRyUOZY7X7LjCxmzkQ/0uxhsKWuB+2GaMSTbHhssrflAkUdH4zhPlzBzkF7KkxlEtSOOIFZNvaxYdmb/mhmiTlnzS1HPu2Dg6jLkWk8Gc/Hyiy55E7yfRiVTGmTkHc+BRpnQ1fqoS6Br8CC22MJmNwHdsguA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(366004)(396003)(346002)(136003)(39850400004)(376002)(66946007)(8936002)(2906002)(83380400001)(2616005)(107886003)(186003)(66556008)(8676002)(36756003)(66476007)(1076003)(5660300002)(4326008)(316002)(6486002)(478600001)(26005)(6512007)(6916009)(41300700001)(6666004)(6506007)(9686003)(52116002)(86362001)(38350700002)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MsQeCmrX2a/EqIv+RjF39y7Fsm72W57m9kYxRkt4l2rYXhDepuVvOkezy5PHUVhO8JrlwkLNuaacEP2HzIkkFHxdYczuLwFJEgtmpcfG36rKUuoMsnaW03xcbaHBWqrjrMpY7fM9/iBBgBZEYugfccw9Vd4fBQSdWWsEpl3S3OsK3V8O5OeH5QP2fGZaTJsHYR8w7w38o+1vAGG7ehzlzF3LevZuLQ33So2jKb6RfkRwNr80Omk3mi5oOZu59dDHFPbQFCoOcnOl/3+3Wcib99ZaqMJZfVhfWDzCGb6a2lF7WB6VLxHMzEBIKmrUkijlQH9XQptbhqH0yAhcJlCm/P113H/jh26zfqMZ7eRpfQM83zJ49z3o7tLPuL3OySSWqmfGisIJNfsIIR8GXfSF35eNEDwVqL5f/2EED2R5XAJqec9t7zEpk0+T4S9ukJSJzXjKaxuf4Rd0WozjpHxVMtoW2pfkQO/QiL7va8hEBJkgflm70QvZkamhX9PbE25zUjLfZ1HuWrN+kcTimAvoZ1Jn8TCTwoY38WGgcDqDOi6jE4tBA4cjP6IxH3zJh09xUxLRLzzEnt5oVTaM8fg+8NuP0OE8G2gVRO3Sd0B9eKtYsMNIQRqdWzNQ9cQeb1AIwvkntJU9RT47fAwFa6zDits0gjwG7/ZK2p+4nOQZyPU6XNvVkT1k8hulMMLBt1OuNjt2QvJdMfnEnh9dsTpkHhvqTkkPB09B0vPJL53cR1Q+D1RNvP/n3NH/mYSYnfAxwRtXGuNsF+/xNxbO7adDxIesL5XEKzUUKE39oXPkCdpJ5pE7O3Dv96r8vx3PEJpknerb3DNdaGz/a85B9STlic9H69Fx5SDM9PLcsvNmj2M/WvEZoAJisP+lGpCxRaQPxTj8oweJY0DAoPKmn/MSJs6+muSp//V442egeFtuCRfBJWBLq1PZVsXiKa5tfF5fz3mwrZjOD5qPew3ud+vzrdWW6n6NG6pbVYnjVEHvk0qu+vDPp7skyFJvb9HJwqmiGkqZgvuBhmtKnLZFxwTSbtEcWGhOFuj29mXIzWpadogFmRPTkzIOP+94b+4PF3t1dgNyzz0jvt1sQzWFouJHgrrk2kYiqfISrJxsNqURR3FzkGjs3X2Z/kciaw8Ak4lK9E0+XtqWWijfGijsa/4KxbyiRVxb6j8JAb6hXVTmWdUhsRR5K/nIl0Ux/FFdOPmgWO32TZnxhqbP5TYV+UaLfJnU5YPMoGD9RHXqjWBWupGiwbIvUG9I4tgPd+BGi3OFDEMtUEuj6LVk40dQVUhQS6YLKROskVZwEhhNu9zJN/LipztYW5toM4x1e9Dy3J7G1KMVYz1kvattT41v/QNuMzJEq9+STJuD2Cwl31wYDiaISqQfeHEIIy4jpfpKrW7lhOBKM28JnwvO87k8DfSWW/n/FkFug0B0Sfj5dry27WpPTdGs+hn2L23x+dHsgnanCBocRwzCwr0NJ1gRWW3n2BXC8TXz6QRxowt/4gkgTGuTPcDBEPtdwzpFLA0BX4LYZGLp8Ilj2D4+QjvOl/pDW6CrqOovL1wtGbfikgtxT/3du/a0ziZHq2JVzDcya38kF0pr6zi1ZUrS/q5LNbCItIGjP5Y9WZMG2aCQ5QPI9x4= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2debf98c-f14e-4a37-0479-08da7628e8ca X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2022 14:52:10.3763 (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: EUNYvPnDl2b3tNKcWIVeFT72KpmtfMdEHP3kgV66cOzcjKA9LE+0NXxHYvJvx6IXvyfzaYshESG664wFCcZyS7GAJhfi2vODJCYWwroxFQQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5624 Received-SPF: pass client-ip=40.107.6.105; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 04 Aug 2022 13:10:06 -0400 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" From: Alexander Ivanov There could be corruptions in the image file: two quest memory areas refer to the same host cluster. If a duplicate offset is found fix it by copying the content of the referred cluster to a new allocated cluster and replace one of the two referring entries by the new cluster offset. Signed-off-by: Natalia Kuzmina Signed-off-by: Alexander Ivanov --- block/parallels.c | 93 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 3 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index a229c06f25..6a82942f38 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -64,6 +64,11 @@ static QEnumLookup prealloc_mode_lookup = { #define PARALLELS_OPT_PREALLOC_MODE "prealloc-mode" #define PARALLELS_OPT_PREALLOC_SIZE "prealloc-size" +#define REVERSED_BAT_UNTOUCHED 0xFFFFFFFF + +#define HOST_CLUSTER_INDEX(s, off) \ + ((off - ((s->header->data_off) << BDRV_SECTOR_BITS)) / (s->cluster_size)) + static QemuOptsList parallels_runtime_opts = { .name = "parallels", .head = QTAILQ_HEAD_INITIALIZER(parallels_runtime_opts.head), @@ -419,9 +424,11 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - int64_t size, prev_off, high_off; - int ret; - uint32_t i; + QEMUIOVector qiov; + int64_t size, prev_off, high_off, sector_num; + int ret, n; + uint32_t i, idx_host, *reversed_bat; + int64_t *cluster_buf; bool flush_bat = false; size = bdrv_getlength(bs->file->bs); @@ -443,8 +450,31 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } res->bfi.total_clusters = s->bat_size; + res->bfi.allocated_clusters = 0; res->bfi.compressed_clusters = 0; /* compression is not supported */ + cluster_buf = g_malloc(s->cluster_size); + qemu_iovec_init(&qiov, 0); + qemu_iovec_add(&qiov, cluster_buf, s->cluster_size); + + /* + * Make a reversed BAT. The table has the same size as BAT. + * Initially the table is filled with REVERSED_BAT_UNTOUCHED values. + * A position in the table is defined by a host index + * (a number of a cluster in the data area): + * index = (cluster_offset - data_area_offset) / cluster_size + * In the main loop fill the table with guest indexes + * (a number of entry in BAT). + * Before this, check if the relevant entry in the reversed table + * is REVERSED_BAT_UNTOUCHED. If that's not true, a guest index was + * written to the reversed table on a previous step. + * It means there is a duplicate offset. + */ + reversed_bat = g_malloc(s->bat_size * sizeof(uint32_t)); + for (i = 0; i < s->bat_size; i++) { + reversed_bat[i] = REVERSED_BAT_UNTOUCHED; + } + high_off = 0; prev_off = 0; for (i = 0; i < s->bat_size; i++) { @@ -468,6 +498,59 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } } + /* Checking bat entry uniqueness. */ + idx_host = HOST_CLUSTER_INDEX(s, off); + if (reversed_bat[idx_host] != REVERSED_BAT_UNTOUCHED) { + /* duplicated offset in BAT */ + fprintf(stderr, + "%s BAT offset in entry %u duplicates offset in entry %u\n", + fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", + i, reversed_bat[idx_host]); + res->corruptions++; + + if (fix & BDRV_FIX_ERRORS) { + /* copy data to a new cluster */ + sector_num = bat2sect(s, reversed_bat[idx_host]); + + ret = bdrv_pread(bs->file, sector_num << BDRV_SECTOR_BITS, + s->cluster_size, cluster_buf, 0); + if (ret < 0) { + res->check_errors++; + goto out; + } + + s->bat_bitmap[i] = 0; + + sector_num = (i * s->cluster_size) >> BDRV_SECTOR_BITS; + off = allocate_clusters(bs, sector_num, s->tracks, &n); + if (off < 0) { + res->check_errors++; + goto out; + } + off <<= BDRV_SECTOR_BITS; + + /* off is new and we should repair idx_host accordingly. */ + idx_host = HOST_CLUSTER_INDEX(s, off); + + ret = bdrv_co_pwritev(bs->file, off, s->cluster_size, &qiov, 0); + if (ret < 0) { + res->check_errors++; + goto out; + } + + size = bdrv_getlength(bs->file->bs); + if (size < 0) { + res->check_errors++; + ret = size; + goto out; + } + + res->corruptions_fixed++; + flush_bat = true; + } + } + reversed_bat[idx_host] = i; + res->bfi.allocated_clusters++; if (off > high_off) { high_off = off; @@ -477,6 +560,7 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, res->bfi.fragmented_clusters++; } prev_off = off; + } ret = 0; @@ -515,6 +599,9 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } out: + qemu_iovec_destroy(&qiov); + g_free(cluster_buf); + g_free(reversed_bat); qemu_co_mutex_unlock(&s->lock); return ret; } From patchwork Thu Aug 4 14:51:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12936534 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 D0671C19F2A for ; Thu, 4 Aug 2022 17:11:56 +0000 (UTC) Received: from localhost ([::1]:47904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJeO3-00021n-Gr for qemu-devel@archiver.kernel.org; Thu, 04 Aug 2022 13:11:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJcDX-0003UE-F7 for qemu-devel@nongnu.org; Thu, 04 Aug 2022 10:52:55 -0400 Received: from mail-eopbgr60105.outbound.protection.outlook.com ([40.107.6.105]:27575 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 1oJcDV-0002DQ-F5 for qemu-devel@nongnu.org; Thu, 04 Aug 2022 10:52:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KC8TDyWiviyRQ+R3R85LaYvyXi+LpvxQcEM2poW2sVkVWXrRbQq3YIi9RbkfSu5yxEflVVYDcCD5VjLQohZv1NBb2CFLmLN9cfVG0/j9HqJYVCUGemyj26fwH5Cc5s1Y7ik+XC5EijkvfStDkZRw6wyx/6mtcafK3Gg9VicKhW8trAI869KASFjUy5cm9jYT/Y1MTmym0qoD99YLmN0aJPPL6Py9NEkPW0iHG9OadYV97ShVFf9EUE4k9yzHpxLUumKX7ANNuUH+NLch+UQTcOI4TkOX3QvP8TEIUXGqdeMJZim1matddMDEiEfU8vv6QKh06oDqjrFNXQgnfqP+1A== 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=PbjUQOpCIcF3DzKRDsdn979UmE2ludBXwyiWbrCBb08=; b=Ni7GU5e8C9kEJI2an7ZDJ+SnrlenQ82rsrdE+rQCEoVLsV3++s3gUFSOOKSrHQV5zAH/ARjwd5mN+gXYwoY8bH/snl3MyWKtcIya/ZC7Clo9AhaGDP+hIkvwUGHVp0Uc8Btkjt/9Ac+1TFtvVhHcopq9KUdPvkhsrGLKigLFd4radNqSU0mLiSeY/Zn7w6QgLgrUVJRGsq/MxLyqyztURKLCFb2UNKsDYfObgg8peCezMDdxhT6KPuqJnhlDF6SVpcV/A5iO21bkSsXbt/SlX24vA6yxuG9dzbAK6vefurDc3+ww0db+Ef9xPz0XLR+wyMlRAXzzlnAdmI+LUWYzvQ== 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=PbjUQOpCIcF3DzKRDsdn979UmE2ludBXwyiWbrCBb08=; b=LVMv1bEWzupf78ZKtYK4i2uAEr1OaEodR2hKnt7v5aXHnWOhA7UEetpk+j85TfBKAhF8U7Y2ZdHmIJRX28I8sug5UJWY4rrwxBqbkdBPq7nyR9oap5y7PnsqjB9tCQQZ+l48iJeCySw/SnZcV1IoebCPh5hIIR0+ibROlBsl8c/YPD8yHFdWLm04bBgNjEpDEW9pkBtKrYVLc6fTeiQzH3PNL03HUXxEiWteePhx6v/iZ+w6XKVLzGqbm8b0nV7S6J6fncnYwtFS8qo10WfQG862ehY0awqN4s7yyDLUwKC3kQ7T2Raz0AGKuhOy+Nl28tahApxVTlj+LvH7AhI73Q== 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 DBAPR08MB5624.eurprd08.prod.outlook.com (2603:10a6:10:1a8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.12; Thu, 4 Aug 2022 14:52:10 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%6]) with mapi id 15.20.5504.015; Thu, 4 Aug 2022 14:52:10 +0000 From: alexander.ivanov@virtuozzo.com To: qemu-devel@nongnu.org Cc: den@virtuozzo.com Subject: [PATCH 2/3] parallels: Let duplicates repairing pass without unwanted messages Date: Thu, 4 Aug 2022 16:51:59 +0200 Message-Id: <20220804145200.564072-3-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220804145200.564072-1-alexander.ivanov@virtuozzo.com> References: <20220804145200.564072-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0146.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::20) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3c37502e-4690-4ab7-ea21-08da7628e913 X-MS-TrafficTypeDiagnostic: DBAPR08MB5624:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MJ3qykFk6L/sYgm2r+lMdD738iiv2b7cdnpX4nDxtAFCgZOnKIQMlcOQLt5Chg8xIU7XdbRKMSZND7mSPpv3C1e8FfGLrAjwO4g9dG/h+J6e5tGEFhVjOC3mjTmn8i7owZIVYdU3kecf77N4wu75tne4lgpu5Gd5WexIOZOvLkNagds76XvjIw/rKJZXFm8g/d7Wus1xSqAFAP7IVnXRksfWtV4CjacxCQYWZUs6zbmpPuFckBo73I3xQcuQep6XomZqOJoCcf5/r+JVNMouw0KIz/3Koxyu9i6iyrl1jvuMgoBw7KdXYipesvMemBFrG6Ja/NZPLGPUbb4nn8b6IIWf/JnJQZlIeoTPKGZSL6arQD5rtXfKgTWLIAZzeNnBLNCxvwK3XVuQuYOrNHXQv/hgco75HM7SPqcX8CDXKYpdYUfVAPWGpMrwn7CCj4wULNWTWm2JKOpRbflQyOBgqUOXxTtb5VhjxcaKRErqgnA80v4ncyEvt265KuJOIlj+NNAFRoMMiuOvUkfw4Ti/fCmeYpvByVA2qhfPwMb/C852eCjMCaU80UMikz3Kc89AtVptkQr5wVT21OJya7MRS8LtG+hV/SFMQ7c5m+IDDDXhZnYv4NaDcYhW2D59OTR0B094nfyiJdqkLU7HXST3RHYhhYjA04cfoZAPwnyAxpV4XTquLr7z7rmqj5c/eD71Huf/3wsOx4Y5LO540R+RM3sriUg5S+VnMOD6cPE2nE48xzpKMqWZ1IsLr1wpK92VPMWC0uacX6vxtBXwTxZDdSht2h5LIPQmFSoHTQDKDdrSuBTl6ZMMrOJoSquGaPqlwOER7IankX6PK8nP9HSiVw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(366004)(396003)(346002)(136003)(39850400004)(376002)(66946007)(8936002)(2906002)(83380400001)(2616005)(107886003)(186003)(66556008)(15650500001)(8676002)(36756003)(66476007)(1076003)(5660300002)(4326008)(316002)(6486002)(478600001)(26005)(6512007)(6916009)(41300700001)(6666004)(6506007)(9686003)(52116002)(86362001)(38350700002)(38100700002)(26123001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ReBJDC5bzhZHzQ5zURycDDFX3EJCAB2Un86YsAY72zth02L82xnM2BPXGGIrU2OUvxB8qTCCe8Gx2GVnDGCnoI7wxsJ5KZ5EwtVmgUmI+39eCB8UN0v7ObuANj+xctciP/MS2deadPfWfPHwRXK3ir18WoBrFvHbGrosuTS0u/5RJvtJtaHwY1buklNKEJKv2bNh2uUjKQym7NHaL29RUveONvT5ti8SucqUbTFecw99zZfxRi6YDS96TC/SAZn75hspuKC3WGMTCEUQH2AfGVPL/ydJM6ZBfQ8NWF44kGshV2AthP8XjFFKjY54kM/mCvt8UX3P/filaWDcnPUHN3c28z6i6EKb6fkprreB2RKBFdwdz2DN5sd6PQGZcBzVdScHRSd0yef8uVpLKoj4rZvsiKZj/aYfjx5veXICWR0JWunoNDMIArtCfpsRpKAZg41j+/aILmT0kK+NJaGBu6T5lgSnlSnuGwIaoLMFdjiwslQ8ybu3XShn9vJfZWMWGCUK+g8V7l0KGpXijxyy9MPyMmlYYps1884GbWqPnRMOnwiyW0Jnot8a1gdt48SXZKMafBTzl0pbqAll9R7KaCJMXYoiEZNFFhOy0GsrGRbBXvJfXqB+UoyC4vOtuuqJzH2+f57hxmXH+6nqP6Wb/Ju6UxTCb2dpNsUI7fYLFH63vhefvrV4uYqg1fXmomnYO0vZF/BJvgNEZQftfk79sgvWdJf/UMDWf2SpxbSk8iA5xZXnrnM9dxPnWWe4kwMjVlKeFVdh9iLxy7YepPoSHOWtZ6MUIG+mfsQhq8jLoIk021tDDBcdShJfZQieByYdeP1dR1q3cYGwCVvlD3LdMAT4oHYHrDBtGSGNll6Z5uq+Up+oKE6OIK9cC5ekeXv5aw7dU+aUulXnZx93AwbWgXJygPoV4G4aeIQGhdLqXHQP9merT++53xsnpEmByWQ2QbtacepxhWW0a8DnuFHN8g6zT/ehP/GpeHK2oRtfbLqm24EeEUmowbf9PqD9HX+lvi/NloREC2mJbHFqxHIi8lJlmJjTjEmR9zQNK5JSZeINxPtEyNoM39MGYKHiMZylYymLZSYFOr1CQaNlfjjk1GcuYMCUeiGKPqb/9nWKN5szjkRBz6FQWW3tWFONS5Awot3N9uOHj8lUMjmqkwUlOEPe6zXnbB+OnCtEtVAVinquSMGxLpKllkgiZLGPdUHz5l5ud4Wvi1pNorcIRead/4TPyWGpj5vJXW00FI0/GoZmMWBoRgs9veXibSfwBS6Cj+y/N8Oix70AhPVUvpRLoHAM3a/zQsInhHnJ9YxdAafS2UBR+v4eMFWGWUJe+W3IxFv4q8T0gyiyMyIc8SKZcY0KXKciH4QuYKNAnw4AjuEqCciWMBkynN7JuxEtnZ4Ir1j0plMhieUSenFQR4PadMCC4nhunvz3LF1dCAwtfVyaoVvFcMsNHqy+lMFI7zbZpSjaEhnfwGP+7ObZEZP5MHMtprXrlnOCzjk/bQhWOEPwq+NZ3b+MEJOxIEs2nzYP3TxIdylTndJdYojpbaIlGeFxGP2J4K8yA7NIU+rzyzCLvkrLGsnm314RLf7aFS9aF6BFnQ65UzJPm4ok4t0T3c68K60SwC4/1J4GGzYcJpI= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c37502e-4690-4ab7-ea21-08da7628e913 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2022 14:52:10.8605 (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: Dy2ctZJmF72xo4AX0/dV6c+ZUwLQQgbjzGC3r00WuzguBb56aOwwA7WYhFeTAQTbSYjUlGSSkX8m6Qa7HpV1lec5xRTfljo1zW36LRXzNNw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5624 Received-SPF: pass client-ip=40.107.6.105; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 04 Aug 2022 13:10:06 -0400 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" From: Alexander Ivanov When duplicates are repaired a new space area is allocated and further leak check considers it as a leak. Let fix it without printing any messages. Signed-off-by: Alexander Ivanov --- block/parallels.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 6a82942f38..1f56ce26e4 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -429,7 +429,7 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, int ret, n; uint32_t i, idx_host, *reversed_bat; int64_t *cluster_buf; - bool flush_bat = false; + bool flush_bat = false, truncate_silently = false; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -547,6 +547,7 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, res->corruptions_fixed++; flush_bat = true; + truncate_silently = true; } } reversed_bat[idx_host] = i; @@ -576,10 +577,13 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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", - size - res->image_end_offset); - res->leaks += count; + if (!truncate_silently) { + fprintf(stderr, + "%s space leaked at the end of the image %" PRId64 "\n", + fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR", + size - res->image_end_offset); + res->leaks += count; + } if (fix & BDRV_FIX_LEAKS) { Error *local_err = NULL; @@ -594,7 +598,10 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, res->check_errors++; goto out; } - res->leaks_fixed += count; + + if (!truncate_silently) { + res->leaks_fixed += count; + } } } From patchwork Thu Aug 4 14:52:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12936537 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 2895EC19F2A for ; Thu, 4 Aug 2022 17:16:25 +0000 (UTC) Received: from localhost ([::1]:58906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJeSO-0001yh-5R for qemu-devel@archiver.kernel.org; Thu, 04 Aug 2022 13:16:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJcDa-0003Zl-7J for qemu-devel@nongnu.org; Thu, 04 Aug 2022 10:52:58 -0400 Received: from mail-eopbgr60105.outbound.protection.outlook.com ([40.107.6.105]:27575 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 1oJcDX-0002DQ-6y for qemu-devel@nongnu.org; Thu, 04 Aug 2022 10:52:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jRcclT1FTHnXbGJfkIWs73YfxJuA5ywDPgLPPDw7XDL8Y+l+JT3HuiHVzhvRZKeRsGTWQabRF1cPTraVryRtzQTf6Sx5pyA3pHjRd69BmI3OcIO2itC9f3Okhlp7eAxUhEBSOHxbSLkiMSl1w/sPccRxbV1mwcb1mD5Py9ft9EN1MqA4D9TCda8VrAjHNwcXRlwHKjiIFNfiq6Ncrm3RUIc1PggXiCCo4Iqkl66/sw3e9ys4cl588kWDPigzSFim515CdKv7zQF6rMX96F7DH2WFiprh4YfZOX40n8B9uhHQx6ntPjY99d84jFHrNzfexdVaWuCr362OfppErd5q7g== 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=qWcWeG+uxj55j2p60tMLMixK/1LjyViLxQo57wwckBo=; b=VY/d47pWjGheyKap2oTb5asPGHTnGWP9GUh8RLzZQeMTL/ruCv0bREYuCMgaflZbpIUlz4zuy98RORpP2WxmAMJc9IGoinrSUMiLHWV1yugdihcpdkDZoIQgcCxOYiGq+7MLfTWgE5jpAJddQz+v8vvgrEzcs71ymgEaGWkTXGgmhp/+7CXpqfrI+Uq1+veI0IoRhYvAdN12SIwZZ+yWmCa7fGB53lnPOFQGa/pE8P+nA439HNCtYYTcIV/7ZHDd/c3UE98C4zRGv+uiZE/qlrl7Q40BWU3bpsYEwnCYQkjfMmHlMn0S+boRQHQZLjQJpPTsm1k7EoPJnPmwdGee9g== 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=qWcWeG+uxj55j2p60tMLMixK/1LjyViLxQo57wwckBo=; b=crZ0+/l/xP8yaQailXpuOpq1OPC6jolD7p+qvkmfcZn3PDb/JHg2cqVVY9MXjvz6Zzwl059gfbO+v1L8bGiB/Lkk8Ock5BQVgZe8gU3PatfysTtARYqgUP1/kE/cENfeInItmMsppMWBjizAEMHLzJuqj7JgPEKGVnCKR+KMXP6EvrVtCmQSF0BetU3Y4Ohxb6LoV/dHmyca46wMouX/xeCx/nLypVZ8Ntfqv1KYdeHYPgeke4nue4EHEnpJmJ640APDvNg7EXNK4GxucUosrKH9Fa7EK3wOSWEnjTQ8ha1G1W8Mq4sVuO7/H3V1E8pkX3NSTeGgMCWw9kVRs/GZFQ== 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 DBAPR08MB5624.eurprd08.prod.outlook.com (2603:10a6:10:1a8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.12; Thu, 4 Aug 2022 14:52:11 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%6]) with mapi id 15.20.5504.015; Thu, 4 Aug 2022 14:52:11 +0000 From: alexander.ivanov@virtuozzo.com To: qemu-devel@nongnu.org Cc: den@virtuozzo.com Subject: [PATCH 3/3] iotests, parallels: Add a test for duplicated clusters Date: Thu, 4 Aug 2022 16:52:00 +0200 Message-Id: <20220804145200.564072-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220804145200.564072-1-alexander.ivanov@virtuozzo.com> References: <20220804145200.564072-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0146.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::20) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4c2f5bc-d6c6-49b1-db87-08da7628e956 X-MS-TrafficTypeDiagnostic: DBAPR08MB5624:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8MOBg8VCtnQQx6SxEM4Mqip0BqrEiexNSj1pU3uZMoix7yzEj59E36fqxGxh0MG64rWnsGB+DHMqRY69mqmymVCZY+B/CZzBBBkjiSLw2sek0vOuNuK3tqjCxV5lQozJOU6mxVss0Ac7AXbkWqH8jBzlrPjHR4fNWcS+MTmMZA+TVMk8n4Ji70M44+UqwiKVEQ18pDRPzZbHIdVAE2lJuzHBuOKYi8bd5FW+QhOdGgKTE2hp1UYuXnbEwEnyQq0Xph5HS5CvIFVsrX/UmF6Tj0Jc5Pf77r90Ei5559yhECXW65WZYTlWT4vT3jZn2dp7q11uMxY5o4SewwvT2Y8EcdOSe6mwf76mbQdgyJgkA1Ac+b2g/hL84L5hm5kMteqH2NwQ+ocVKewRNkS6a6LcrauNlqaSIu1KtnErg+EEGEceH8j9kfLcJ1hJInuF42w933Y96ggzR0PGkNaCCSFdp9YieW8541IICl2DlcIdVUXkhJwruGcjzStHvMHyIxkcG7jmkqKJeT22BhKUJ/KKUwmo+HpoGUS86scLzYqnamGYrEApsigSLUVwqh6DNFJNBLuKI1LHOhVZrwmEg+Xrb1qgYiyWj3PXyjPEJYeIhtSzwK/JL5tvMZtugdh0rIE9QGXohlT3thfn8orRjk2hEh8riHEs+lzSuYPZEo8Z4+NVh3rL6E//XMjZAvFqJSa0tN5dg2L7m5JJHRw/hJO+KcrRxFevmthiHMS1QeVQMjrXR7sRqPlq+/PLP/ZgJPMXl2AXhqTTNlUmWiDko6ZlqI9nUbBGJvoC4eUKHHjzD2+2fPSRen9edtQLmSlaZRhIJzWR/vHxMrF8i3HfG9Zz1vEMiST2ua/0mqBUhmh1Nkw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(366004)(396003)(346002)(136003)(39850400004)(376002)(66946007)(8936002)(2906002)(83380400001)(2616005)(107886003)(186003)(66556008)(8676002)(36756003)(66476007)(1076003)(5660300002)(4326008)(316002)(6486002)(478600001)(26005)(6512007)(6916009)(41300700001)(6666004)(6506007)(9686003)(52116002)(86362001)(38350700002)(38100700002)(2004002)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lnpRGLgDfF10Tkg8D00VODGutMiacYkpIJoSQNbwbnHPIwQO52PX9I10+U0G3FvnYBkMvbDAHY4QtZDjgJ0BbVHUFV0fJkb1d8+Qb7XWWbLI7PDULbirESNcIOiX3Z6r2qJpT2jh1qW1fchWtSnnZJDyI2g+/Y3cILwuyUcbW9rOYPVvPJHER/G46vivTIZVkGr3m+ZQxUgNDdpF3pcbKtIXj01hCEnGO7Rcu2SVR57j04NrKt/Jitb3XmE4hzfVEwkbrVYgJ0ogSwzrMJwOGKv3qXNYT/vf/JpT7C30eumlumGhb7kBibdjR9Rf3fBGRKQOTpEjVVTZWM8erCUmhrNhRQvksN/zPoJF7Fe0X9zHAb1Zbf1Ln/0tuSKubX4Vc0PekR+Aa6O+HS0YCCVosCgJF4xnQmgh8GVSyrb7jrLGHjp7kl/Pcd2pe2fIiCOCuwIuL1mg6yr0FdsX2l+dSzPvxPfgiXv5EtuBWTqg3HYfNxMHLRxqaGqQfS/HN13qXfqAj72mO5jQpObwc791cZ1k4JfVLZgWJ11VRoXM6CVWxgwu3EvPvMlKCrXWax9bfo0UDzsj2tQMT1cev1PttEFEKy5du/qL5f9fbNHGveKsSi9JlVkMY+bOPlsckF9AIHvcdzid7t3Cn3h19SjuVfz1lgvdRyd0DVKHjvYZJKj5qi8qKzrHWW4vcS27uaSCGMsy1xdOsQ1lmgQjoJVfOJ+LIaexhA/Z1aqEvOCfBFpBwXR+H8o948bPM1iRS4RJeh7ayrCstLM4IzJ1567GqWw2KtkEF7lQszbwiy2XdtFzUo0+yNJcUlRajhN6DitbiYF6PbnN2iMwHYJbdyx+zQygEbdPvdLD8eAQ6uPxZvU1+EYpqT+VmAqAkrdqMWg4Uje+BfR1FnzXqTdd2osk6g9vSdPQApNT5BEVxJxVrI23/wlTADwaVWfzjQ/NWVnRw8pJ6PNzq/qC+6y8v4E90RwXfA4iSx/H7bCqWa/KSdGmvVs7QjXL0elSLKW86VhY59oq2nQvVhpm/6H2C4hGF+Q07RL5YzfrmdRvd69zn1MebX/3b6QMDgSyoqZoVKZa/LAV9yUIq6x7YjByLOcP9N0iJ/68dfhffSRu+CsDMTZFFw2GlagA9cQ6hSe2P7mGW0ErlggpCf1n+wH4p52L9c9KL+Uqf59ErNkJY811Hc9C+M4MIMkMoUalv2hqYozPx6wjnKtwSk2KYjBP5YEAKuhAF9cSiJ8jRBAh2cRlRD2VjrA+e+iNUontTmhgzC6yYs0iNEvjJzUZJPp/JXKcZiNqM4BuCxFdOa8oI48tcPG/Ucg8VVg2o94lABVeQO6mo/dwp6R3a99sbL49+XsrDufjQq9bkDqck42Z9/k43vnyLV29SrWf2Hhc8Jx+vAOCe4wySzIW1Hi9iMrmppPl16Jc2mSLxi3D7PLSuF83zByVNVAgy7WSdteCzltpNpQXD/k4aEKtSu5ptiAvCpXYYmuw2H5GbUS4+nSREjo91CQO9LXGbwPIHEiSsJGS5DgUT841qROM9vGqP819gyPXu8Jxu/qkTpnqTJe7Ss1bwT28BHlVvd8jvt4ILGEPr8C5F5UJdbzYRdzQmbJHtVDP5isvfdcvb2ZqACGIvcdObHc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4c2f5bc-d6c6-49b1-db87-08da7628e956 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2022 14:52:11.3149 (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: XNEZj18nb98NbRHprLCvUfJjsKsLZd0m//F5DgGyEV3+7IZlrjhZ6SqesG8M2cssLyw1zOdr29yvZF/t9Bs7oWmsQzjwda6qh+B6auc1jao= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5624 Received-SPF: pass client-ip=40.107.6.105; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 04 Aug 2022 13:10:06 -0400 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" From: Alexander Ivanov Check if original and duplicated offsets refer to the same cluster. Repair the image and check that writing to a referred cluster doesn't affects another referred cluster. Signed-off-by: Natalia Kuzmina Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/314 | 88 ++++++++++++++++++ tests/qemu-iotests/314.out | 36 +++++++ .../parallels-2-duplicated-cluster.bz2 | Bin 0 -> 148 bytes 3 files changed, 124 insertions(+) create mode 100755 tests/qemu-iotests/314 create mode 100644 tests/qemu-iotests/314.out create mode 100644 tests/qemu-iotests/sample_images/parallels-2-duplicated-cluster.bz2 GIT binary patch literal 148 zcmZ>Y%CIzaj8qGboOfsS0tPO%`U`(O5*Pv)I2hO&I2yDPt~od`068263_Exd7-leV zwiz(^Ft8k0sa3TsBZG0}Vv}35zt?O%VET5A+3Q2o4%bdpm~pLC^&`WR2CW6$VGH;& vm{u|@;OhXBE0|U>d|v){U)AOQJ)h70iu-<&;S?CYW~db}a. +# + +# creator +owner=natalia.kuzmina@openvz.org + +seq=`basename $0` +echo "QA output created by $seq" + +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.pattern + +_supported_fmt parallels +_supported_proto file +_supported_os Linux + +echo +echo "using sample corrupted image" +echo +_use_sample_img parallels-2-duplicated-cluster.bz2 + +CLUSTER_SIZE=65536 + +#read one cluster from original offset +$QEMU_IO -c "read -P 0x11 0 $CLUSTER_SIZE" "$TEST_IMG" | \ + _filter_qemu_io +#read from duplicated offset (data must be the same as on original offset) +$QEMU_IO -c "read -P 0x11 $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE" "$TEST_IMG" | \ + _filter_qemu_io +#change data from original offset +$QEMU_IO -c "write -P 0x55 0 $CLUSTER_SIZE" "$TEST_IMG" | \ + _filter_qemu_io +#read from duplicated offset (data must be the same as on original offset) +$QEMU_IO -c "read -P 0x55 $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE" "$TEST_IMG" | \ + _filter_qemu_io +echo +echo "check and repair the image" +echo +_check_test_img -r all +echo + +#read one cluster from original offset +$QEMU_IO -c "read -P 0x55 0 $CLUSTER_SIZE" "$TEST_IMG" | \ + _filter_qemu_io +#read copied data from new offset +$QEMU_IO -c "read -P 0x55 $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE" "$TEST_IMG" | \ + _filter_qemu_io +#change data from original offset +$QEMU_IO -c "write -P 0x11 0 $CLUSTER_SIZE" "$TEST_IMG" | \ + _filter_qemu_io +#read from new offset (fail, now this data was left unchanged) +$QEMU_IO -c "read -P 0x11 $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE" "$TEST_IMG" | \ + _filter_qemu_io + +echo +echo +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/314.out b/tests/qemu-iotests/314.out new file mode 100644 index 0000000000..c36022c407 --- /dev/null +++ b/tests/qemu-iotests/314.out @@ -0,0 +1,36 @@ +QA output created by 314 + +using sample corrupted image + +read 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 262144 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 262144 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +check and repair the image + +Repairing BAT offset in entry 4 duplicates offset in entry 0 +The following inconsistencies were found and repaired: + + 0 leaked clusters + 1 corruptions + +Double checking the fixed image now... +No errors were found on the image. + +read 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 262144 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Pattern verification failed at offset 262144, 65536 bytes +read 65536/65536 bytes at offset 262144 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + + +*** done diff --git a/tests/qemu-iotests/sample_images/parallels-2-duplicated-cluster.bz2 b/tests/qemu-iotests/sample_images/parallels-2-duplicated-cluster.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..ee8f0149b5ecffc4fdc5e2c0cf45b731610378af