From patchwork Thu Aug 18 15:14:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12947290 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 582B8C00140 for ; Thu, 18 Aug 2022 15:20:51 +0000 (UTC) Received: from localhost ([::1]:45782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOhKD-0000US-Lj for qemu-devel@archiver.kernel.org; Thu, 18 Aug 2022 11:20:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOhEq-0005oE-9R; Thu, 18 Aug 2022 11:15:17 -0400 Received: from mail-vi1eur05on2109.outbound.protection.outlook.com ([40.107.21.109]:61536 helo=EUR05-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 1oOhEn-00071h-Ko; Thu, 18 Aug 2022 11:15:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L0NEhGpaDJaeZ4IPNhwQ6i85x3bskRe68V9IUjANDvR28KrsYPHuL0sJZfTYwdyZ7BP6PyfcCJQbQg0cHHchI63s0yDHCP4Yh3YzalNfyDwYBrreR54zdpR84UaRHZcqe3w61FvhGztwMb7TQ7mL5lYVMrZylEmUx1G9lMqN3RIPJq3bY4+N/wU74ZdI1HbczC9UmbAdavbI9cjs0UXSgw5KnzwrGm3wIdmGsRIKYqrQPUtTLr4rleK3tLfxjPHAgyAGemvRbyeYbTiNrFHcJQSPEn+0bghnqWcxVI18GIc+7iRm4HkWpcD5ESHNLYVEtMussEcbAbYo4VdCyu8wbg== 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=bfjCEB1XhsFtO2vnQC5cI2LPQqJ2CsUn3sTDnhFvbmU=; b=Y/4KZ1Xd5KxMKqIa6RDnWx86UC2M9QuZzn4M+voVplavMTC1Oim+I5O370rTCv7j8uGxlo5Up45BxplIXZ6Au+o0UQ1y3Z/JAFRKEhBO4Mx7OTh/d+okW6eGEzwrIGPNbRwItaWX0NwJz6fJbMSZJkF/aztQ6TOZYkMebHOE3NE6RVmhdmFb7b60tdGRXHA1OkolMJz8mcS5QJXKbARL+4xz3V3ifAuUgWuJxNdYZFz42LhtupALl9U70eN0HEATDTIL08WhKUxKH5vzs9ht7bpKFHzhPTZWFiav6EyFvYAM4It48lQgIMMaWVr/V+Ho9VCPJcvNLh6lvIW5oXUdTA== 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=bfjCEB1XhsFtO2vnQC5cI2LPQqJ2CsUn3sTDnhFvbmU=; b=ymS6xnAtbhOVkZPUkH8Sck0VnGy+akF3TOYgv9Zei0axDlTgyoQD08iwWuLF4hCisQbDc1R82n87r3SinfMOhXX4n1d9JECvis4saEXdpTKSH4/N28vlMgr5t4oUH7dslUvrK8Rv/DayldSh81oC1NIMYlSlrzqq0K77sg2EiwF+x5BGJ4sBHjzsVUgYujfTo6OVk8Pjp9nHjpjee/OjJ8JaPkhAXxl3E4gG38N13eA8dbVFZbVI3HLZf8ZiWoZI5WLszlDPTnc6paMzx4j9pyxCuFwlG1ZFk/s8go7hsk6EPZVRQ7/Q58Rn4FBeU/7Ssj+8O49TnCtzyRyDW2w+2A== 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 AM0PR08MB3715.eurprd08.prod.outlook.com (2603:10a6:208:10b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 15:15:06 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%7]) with mapi id 15.20.5546.016; Thu, 18 Aug 2022 15:15:06 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 1/9] parallels: Out of image offset in BAT leads to image inflation Date: Thu, 18 Aug 2022 17:14:48 +0200 Message-Id: <20220818151456.2118470-2-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> References: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0092.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::13) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3b5b394c-7cc0-4840-fc1e-08da812c6e8f X-MS-TrafficTypeDiagnostic: AM0PR08MB3715:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C/anH2KNDKZZn+Mh9B79+Ec4jKNEC+1XTaKdP89UyDZI7EkcNO/DjmTpqQAyFDCeEVznxCdbdVnI+0yVr2WS7mNPCsiSWJxGZXEYkbo/8CmGa5lSupkca2dwyRThIxTNfWZcHgJFhoPpGWruEt4q9DdDYjw6s99fuXvE42/qqNlQIOiL7dssSRY2nqbEncwupbCHc8VE5bLEKPJqKgnNzro2XiDeU6PGCg9NVR1bSc4usTjwpP2s1yPLWTk88ghkcGw4g4P1FFSpgOdRKY/YPnNlec+bjkKaVHVEIm8lT9U5I4K8DSMDwXHi8ThFDNLZ1HdH/O86oIdcDtEOfC+9Ros7fcGQkQGrRzbaICWT0aPVpPKsGdknGTknLe2GClmiy8xxMY3wwiEM23LTB0Ki8JAtGSxzhcVEHGyKNXNdgkedAexE+DlTCQUgifDnU/11cFxUQyTmngUwDz4KwlTS78QrfntumGOf8J+a6NN7gfDdNDCy0eCC3y4y8E/6EsZ24uXtuN3J9inw7HZAYm7McCwp/KonyXsSg/UMEHNETCwOYWex0Yzlv9ExWAKpsUEeMd6S1jyoplv+YiFEmqWyH/hUp2MyGsM7I8YoyWU6+PkvuOVComR8c2WddiOa148jydXSShrV+stcU1hYBe3BCpLmrS+bwOcQMrzp/x/RB/T/gOo7fcNMKobfUTQPptZ5+lyq/j3135Orq8qoBmEdZqwzflPutrxHWN3eMuLso7HPPyVYn/69DV7e6jifpyveHacGcOXO5Aely2VWWtGYKQ== 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)(136003)(346002)(376002)(39850400004)(396003)(366004)(83380400001)(52116002)(6506007)(6512007)(26005)(2616005)(186003)(1076003)(38350700002)(38100700002)(66556008)(4326008)(8936002)(5660300002)(44832011)(8676002)(66476007)(66946007)(2906002)(6666004)(478600001)(6486002)(41300700001)(316002)(86362001)(6916009)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mE1QtbRsCPti84ky6eUGJcNXX0YdvUMI8wCIDpCnixOX09/WK4u1zPJwAJvVBKXpd9LOJYekM7PWphhBOcAv0rrtuvJi++qY2ulm/Q6pE7KwWeao5wARWPhT/lRbMCvODl33lJAROuA76n/iVgsTCc4ovfH2hS1fHIbHZYNSJvy4hOmGNIe/Ak6kpNDzMGWjtgNzWOH/d3+Avvp2jlJ6sQBQZZgJ6IMkX+MPrRMa3Zkg6mPj44uk48Js90jugzGLmjeL3wc4t5hWXDIG6LZNsMpssClg1WAnrVrxCwMzN4+VYAN78/56IW4Zi/VsMSxe0ILaX0GFKtvjzd6JA5wsii0zZd7MwlYl8+qAbNl7X86mry04x1cUoEKfuvfNAzytdH0BL9eq1/ahSiT75nYD59E0pXOn/FlKrEkT0lNaVS94clHJvBdt7uckATSSG0HjKgtsgU8b/Hy3THqdShtqHuI3sebMI/jrs4szlpA9SDB0ahRJZ5gsC+XwQfVZaOlKE0nqvfNaUQXNws8kk8nhYNiuhh3qNDEmaOMyDjNTakNKlw3WqUbux5uWJA+IV5LHlhSUsqHJ8HBQPzSIsVIfjstX2YOtCKE0p5uMu+oqrpKIpVHIHGoERuTQF1/ZAccs8ZxrHSbGCme1EwQF0iFA4VJHlXZZmGpO+rqpZIfktLxUNi4Iz31D9ViR0S6qpI/c6IBh5v4kyIcnxdcndt8Sbw9QlqAInLmDjXYIkXP/lOSHMD/loHalX0G0UHZm3CQpmY2iMwrfAPPyyNogTv8WB50ijqoTEIlWeFktgF+joF1xlY0dohY4CC2I0JURSxtp8mV8sNVdT10irHZdq3G9lGluW8qCx96TjulLrS/Vx9fhjWtVCg6n9IiVS8X3SWL3fAr2LVGJs4PW5yd1TYHOn+nq3h4f6SSzGikH7+ASyyylPsLqS/78PdhNSqbkL+QWuu+t4suCDOxCi9geV51RdVMss22nS1MyIq2kasBT4F8UNQDnXGIb8dvoNeFUXZXQOya6KnOgon7zaGo9RPt8kbQfmaSYvVGQ9AZZhzFjowSWD3IPA3V36EzRaxMzp6HY53ycdGTQodR0qK0IYdrPAjD6/im4v2eS7CKanxWDi9Ouiot42in/8m+UbXmJQGT15IDjsAj61aKC1bx+xvijaGhTCcJXFj0n0czy9Hrda5WS44SXxRHOokF63oOxVTS5lDqnwUZmVqbsvhr73ZAivcvjs/EW6Tpq/ox5kPw+KstHREVH5XvisJMudtkYqbqPxG/oua/fFY4Tb8T+uTlt2cUrayVjF/F3drssnhfvOk+BMUqZXhZV6OticzNvU7U9t3b6MGXd9OWCjiKkrOi7b9VO0epILkIe+D4+3oaN5OJkG5ourV4tfuHqFWcmj7aZs5vjCUQ6NxYw4tT6yyzvcyeEl5+2exAL5u0rxP9FLAvccTdgYjkbyi7A738TESoUyralJVhiAMRcQAoy1PSETBUowLpYK8Ifkr7ATI9JuciGz4swDEWT3nTPrRHAobPK+qzyZuhh8sC6gldpc3JQmBB9/hJhgKhSJZfTDAG5bVkjQMN1JYjtnkT9CopKjY2/B/uQBgklm7b9Ngkxz1B7rCw7kfPoyUynawd2Uf8FIhc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b5b394c-7cc0-4840-fc1e-08da812c6e8f X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 15:15:06.1070 (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: KFPaIOJDEy5+iw6HAcaBk6nOmcu3IRbWmARNdgzoXhDtHLjalrZVOX4q5vgSnaOjbEEhJP5ZYKQqQPy8+w+FApe/bOKuxcNaC7xCDOrEE9Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3715 Received-SPF: pass client-ip=40.107.21.109; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" data_end field in BDRVParallelsState is set to the biggest offset present in BAT. If this offset is outside of the image, any further write will create the cluster at this offset and/or the image will be truncated to this offset on close. This is definitely not correct. Raise an error in parallels_open() if data_end points outside the image and it is not a check (let the check to repaire the image). Signed-off-by: Alexander Ivanov --- block/parallels.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index a229c06f25..c245ca35cd 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -732,6 +732,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, BDRVParallelsState *s = bs->opaque; ParallelsHeader ph; int ret, size, i; + int64_t file_size; QemuOpts *opts = NULL; Error *local_err = NULL; char *buf; @@ -811,6 +812,19 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, } } + file_size = bdrv_getlength(bs->file->bs); + if (file_size < 0) { + ret = file_size; + goto fail; + } + + file_size >>= BDRV_SECTOR_BITS; + if (s->data_end > file_size && !(flags & BDRV_O_CHECK)) { + error_setg(errp, "parallels: Offset in BAT is out of image"); + ret = -EINVAL; + goto fail; + } + if (le32_to_cpu(ph.inuse) == HEADER_INUSE_MAGIC) { /* Image was not closed correctly. The check is mandatory */ s->header_unclean = true; From patchwork Thu Aug 18 15:14:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12947292 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 79025C32772 for ; Thu, 18 Aug 2022 15:21:06 +0000 (UTC) Received: from localhost ([::1]:43316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOhKT-0000jO-GT for qemu-devel@archiver.kernel.org; Thu, 18 Aug 2022 11:21:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOhEq-0005oF-9n; Thu, 18 Aug 2022 11:15:17 -0400 Received: from mail-vi1eur05on2109.outbound.protection.outlook.com ([40.107.21.109]:49772 helo=EUR05-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 1oOhEo-00071E-8U; Thu, 18 Aug 2022 11:15:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bR3hURJ3cPCjl4StGRvy6H1pmX5+gIIaHskHph4iZjeo0As9XMuDHUMzuglAO5EoixvkojHOMfwTvaTbL5plzm9wkseNei4LGbAw2mRGY+tns5pDbYXXXblGVUm4w0KJqehdpJMErthOTY/Kc4VLaCOUKtHaECS67xjvyjFDGg4TKVtOrIq73q3CbSn6r+IRJcTp8Dky4GMV4Q2Xtzy4FEDa0VVutMah8ehOFS2XMb5V5KZR6FuvC0IGoidHfuRoDSrVPwSHzsIkwB4PsLtokq0JUVg9SvIiRM3frAV0oMFKv+TPOyUldghMXUeba5rQO6usR5s/pY9eCz/xSMy3nQ== 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=xWam9sk5//UyvlgJCumWTo9rqTjzPn9kNwCbYVSYCYY=; b=CTX3uCElsR7NWuQW0Gk+uMQRPDBfRjjL4QIg6vJN0N3Z/l7PbGv2WdQZjeW+P10qxrimVzaLOzJ2sdEsxQ7YbFwqSfou1nHUX6J6SLCBI/XJllPdv3e8Ua1PipwoG6pIKSwcwREpqcv5iI4k7RFa0tfs2/VoClDIqd7KHdo5oYf4qkqzug2tp4Ov5HqSQ6x01qrKPKCZmt2wYxzaqPIgfBotI9CuOze8Z1319M5MU1GV73xLaKD4fH2l0Gn37EneKoZz+VpTnmf4OYI599KLY8WFYLx66IQOnD7qeQgkjTIWdyIqcGOk/wdj6gQtoztD+f8k63j5uKNeofaB6Ae3Rg== 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=xWam9sk5//UyvlgJCumWTo9rqTjzPn9kNwCbYVSYCYY=; b=WqT5RdqjDSF3vOob78x56nkOvwvlp4na7pka7loBKQDP0RAOlxezmwbc8vzMTgjpHqP8uLDVe3Pmw8pQnc9BOXOz1jpQxRVKH3RizuX8CFiD9wsrEqytiRP2rodcMJ3RK1VALf7kyE60l4uMntZtIAfKQO0oT5eBqF9Wu0hRyZATnBitk1cGn1vVomR3J9EnyXzD9X9saqHx+MC6ZB/D5FPXRW39nASKt/Xn3qf+LcfLziMET9/hhGfqmv4u0ietlYJZuWoYu9qogQnOeza8WZ55TkdnxndoPz1B8BbH3aIOhAcrXeM5n25ujq8c2ni9eTYWqgFxWC9NsTYDYZYOHg== 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 AM0PR08MB3715.eurprd08.prod.outlook.com (2603:10a6:208:10b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 15:15:07 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%7]) with mapi id 15.20.5546.016; Thu, 18 Aug 2022 15:15:07 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 2/9] parallels: Fix data_end field value in parallels_co_check() Date: Thu, 18 Aug 2022 17:14:49 +0200 Message-Id: <20220818151456.2118470-3-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> References: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0092.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::13) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f5e91b67-5d16-49e6-40da-08da812c6efb X-MS-TrafficTypeDiagnostic: AM0PR08MB3715:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YzQBAWWUAhmqMpW1dJbNNyNl5AARlElj6dtifOFWXTrCA6XnT2MJSpU1lollNzim8DFS6KsQQVFg2fN4iDCNjH/nN15zWbYSHkzOozz/9U9ogbkYhk6uFeprPDiQ1cN29Q/ds84eaHSqJHzPJP6AaltUQR2OTjtIAZQ+wTgPXRwzQItgEdJd4h3g/yV3sfhi0T7rWBWXrbZ9s90OsrdRXLIadG2UoouEIQyZxhnm4aFiOu6DG7GqjRXbx2CeX/X/dBdN4Gznk7NTe3WnHAdZ3a/YibW/+HIefwJr8SxmKmB/k3n30Wf5SwhWOXDHfaVWdJErDjrstVUX4dibvLZlOXOPk+eJr9E8MIGBM5NgIJQSD4WjvxgPxBAHX/3yzLANld4COHbopzmdDMsTlU8dUvcFmfWM003DTEzMuY7neAKgS7IDgSfP5wItXNEm4zwURYiWPpvbNwOcB+adOddIeF65xbG5WV+2CI5caXOAYDxf8s7aUz5VUt33+0yYAIaw4sLwQIsUktmzPJTHPbynoSbXK1QWtbWss8hOHoqSD543EbYBxKaSzfCBhc/+RPrBX6B10kcmT98FgBSbphe6M3UbPh7uS5Y8BrTCmAEMnXzD9XusfX0s7z2QRKDZerABsTIQsbpBCVUfbinl/Z7Rg/3hs3YgJMu4LmPRrMPU1mS6vh+11FxBUSyCvrdTHC1mU+e0X2kJe2hsDCj9n6ZYCPj4ofKHSpyB1SRpOqQZ4fEzMfeX7Wva9oe0EMROkOPr9wBorfFA7jjumzXcclBaUQ== 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)(136003)(346002)(376002)(39850400004)(396003)(366004)(83380400001)(52116002)(6506007)(6512007)(26005)(2616005)(186003)(1076003)(38350700002)(38100700002)(66556008)(4326008)(8936002)(5660300002)(4744005)(44832011)(8676002)(66476007)(66946007)(2906002)(6666004)(478600001)(6486002)(41300700001)(316002)(86362001)(6916009)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7sHTP09oD60FR/cExqE/C0hu+DBgBqquNM9x8YWrzfMz8YoW8psduzYRt1Ozo/JqPTXMj4XwZmHQ+LwooAkx4ZR4K9PJPHtJ5IgIH6Vc6TOvsVKHSbQf4F3IXdcYrwsu7m1DUFFb7maE+fWEtNhr1KvrRFjjAL/SMikcGW1QsNTpnQwaPaQSXchLcp/K5IJRTgAzWyhkDvNfp12AapIC9wcSbi+dEkXJCeMHGuJUcI+AcaHq7lJMs9xfcNrmVmRbps6IraD2vlrRp8L3IC7p+/mz9Js8bKoFko5P466KdzIQMF5y/rsJ/N/FENX8MWQhREJZVukcTqrrff3QmaJZw8N64DOdBwYWpOJ5XCLKkKWmpHWwrZ3MgVhdZbHgby0D8OL1Q4vFPuSQ6BcNM4Tui8pB6j3tTyC6EP1NyABbHe0/2Idcax6FncuqZ77qV0p4IsFrv71K9NVzS4vlbbdGO1n73WxfwtFdFSzvNSWpqFEDF55AiRG4C5EDqD5RakvZba6tHhr9IlI5+0Z0IbT6GbHZocpJ/Ws25wc9yYw5veesjOpcGvyFckzSRMnRbDnfEkTtQrT9Stf6Vl2lXHW7Pk0CC/M3tcDCteVbkuyn99ElhgCZJRw87xA4LPejl/jjO+saMCoclQTpmYeENmEVDujufTw3japS7qQsxWexEhX/Ba0799b/S66fq7maFqKIWPCpp94GVKLvG5EuWQrKkk45ZazPFj+Tvk0ZhOrsc7bXAN1sTGYe5lZSxcY56yfhx2f1I+6+Dmvzg0KkU0+9B5DzO8WkwrFBwRoEo0KiSR4BQGvmfdRBgw4Fle5vaIOkCQsajAQgmN8Lb4rYhtNExPjGDMdhILbSRihMrgI00+LN7Ap6A8/kQzK7xphCNU7yL4SNu5rmUvfV/TY55xTgK6ugvsRNlJ0s0fg+iNYNAFKXp7uFsGcvZg7T2Zyip8gdv5qmARzPcD1RemERctfwULbC3m+iUpq7RxNTVkA8Er56SwtNijbfWmImFTyVy4sQxtc91mc0Hqx6HHs14Cx99V98AGPzIAy5aXQM7VW0qlBZFXMQpDaAo7ademKO6VB33warNo3sq82sLfZmnbT79NFpoe3tNSnZWu8xOxf68UR/n9NAm+Yng4UFk2tEWAsMG73QX/mFtR4Wdcj/16ct1GxIVQYa6VQu/7UH6s9X+B980XkN+LkJCJuYxKxNBS68VsOoZSo0JN7SH2aJv57Q3B7bHEvkK6+crZGkY16nkcwNrQFGZietL1F6bevDXNi9+l0/iKAmPWeNIfGXPpmtaySmwI+ks1qgfGeAgW9bK/GKxuHhpNHWEMXfDtF3IST2fLyNDnkMge1htkL0J4OT14yPK2fhOo497rKU0wrIv4N2GOodHklpRHJivjgDJ0M/Zn4E8jRLliv3m81d45psKV2pkE4ET5COJSZNpczBRKP7mV0UTgclSbrTl+ogSG+D8Lcm3sG7xwuAEIx/BMWrgsKfnqRLbgsVLEA80sDJvNAw2BNCFav26y50nUjAnjXhgao39VTiK6HY40sJ2W4dyPt9FPChjX2SANlAbz6g8CI9JUzEm52hTBT0dZhKqiEy7pDa4s0w9btqWoAtiwb4vJQ1dLIM0du7cd4FsxzFs4A= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5e91b67-5d16-49e6-40da-08da812c6efb X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 15:15:07.0600 (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: 6D2ExoU5etqSBaHWIAEh6qQzv5Nb30BN34PkwH3ZVP2t0lGQzCxAAzR+IK/dDq7SJkgywjKPpJ7B+0PXpgQq0v5dBMQBrNx7pxd2tM80lA4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3715 Received-SPF: pass client-ip=40.107.21.109; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" When an image is opened for check there is no error if an offset in the BAT points outside the image. In such a way we can repair the image. Out-of-image offsets are repaired in the check, but data_end field still points outside. Fix this field by file size. Signed-off-by: Alexander Ivanov --- block/parallels.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index c245ca35cd..24c05b95e8 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -513,7 +513,15 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, res->leaks_fixed += count; } } - + /* + * If there were an out-of-image cluster it would be repaired, + * but s->data_end still would point outside image. + * Fix s->data_end by the file size. + */ + size >>= BDRV_SECTOR_BITS; + if (s->data_end > size) { + s->data_end = size; + } out: qemu_co_mutex_unlock(&s->lock); return ret; From patchwork Thu Aug 18 15:14:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12947304 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 5FA75C00140 for ; Thu, 18 Aug 2022 15:23:09 +0000 (UTC) Received: from localhost ([::1]:42286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOhMS-0004qR-EF for qemu-devel@archiver.kernel.org; Thu, 18 Aug 2022 11:23:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOhEt-0005oq-0D; Thu, 18 Aug 2022 11:15:19 -0400 Received: from mail-vi1eur05on2109.outbound.protection.outlook.com ([40.107.21.109]:61536 helo=EUR05-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 1oOhEr-00071h-1m; Thu, 18 Aug 2022 11:15:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PiL5RYIP9QcmOEPvStXc6a/kFryIPA9AZHwlTIX6YbXMpOlE6KYX3WI70gSCVbS4gNYsf5bAi6x1l0bOrUGdE6xW1SZ53Ll/gQAqZXxPbwEBhIhHNI2bXm8Frpk6XkjYuGO4DCs6g4bwBdJqvOlT6s39dXx1dBYXKSSex8UnTRg0W5Ys4bAHKQ9+YD0jqanqkMtv4vuVzug2U1qm0iRG5FBvylsYXFgwYXOUhFjnTetMhQaVEhHSHN6BEWRiZW3LjQVTL3bx0B4Sx0fN94Y0eGlRCeJilKTjK8vcX1Yadw9b5eJBNQvyF0YnbGmuFITe56MMRmknRnwaiDm+Zlv6Xg== 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=H6KwQkp0tEh7yGj4wK5mI32zLTvcnDSdwNcVTFkP4dA=; b=B/q/GlBU7Q/jOGKrAiJHRklyAkSIpFCZ1GHjkNQcFyCholeKxMl/yOlHLMNtv0dwhsZJuY2oOFjHKZEceN8yV6snLdY89n/ZyYR5PE/8JBan6RBW9NQMT91lMFt4A3gMOc5YAqALfWgfe+BV8Xw9masUGpEuPgsB5kamEz+xyxR8k6J7Ck78c3zppRA3qhGbFVuWp8Vzv4U0kvbCeBxWZ/dn6JtKPx7BIDQfA4JS/cvIwYdJ3wEDqR0rv0axhH7xBd91c+obwjsDvAp5FwUkYz9ldhZz3FZnLLR4vmM1V+lKmi6kztv2WcZKwzFVu/n+N/AehD3q35iWPrc2g/eVqQ== 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=H6KwQkp0tEh7yGj4wK5mI32zLTvcnDSdwNcVTFkP4dA=; b=XA5ZsokkjnF1UFkGZJG1Ak4XTMSLhrzn6PY5DHMbp13hB+SWG2e5JksKwQ73Voi6eTl+ow1kRcqqiUTM5J9vvp2L6SAG5nr2hKlqU5PM825UJUbrzxQc8xfupntylToUtrrWCtcmuWZMcK+/Q7J5hqNYW4wPpvq73nDKAYHVzUlNpQ0C5sCyDxEBpTV5mvmJq4KZAw74Ix2QVIVPS+zlwHM4+x0FbJaYBf5At9OnOWFKRhQQKj/n4lYQ0sZ3tKlNtXGz0ah9BUykbi43OmQhttXyaky0IC097lHy6RPbrCmF7q5fd+z2ReqrTDvgvv7IEHaNGu3RsOIHnoAgEnUASg== 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 AM0PR08MB3715.eurprd08.prod.outlook.com (2603:10a6:208:10b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 15:15:08 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%7]) with mapi id 15.20.5546.016; Thu, 18 Aug 2022 15:15:08 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 3/9] parallels: create parallels_set_bat_entry_helper() to assign BAT value Date: Thu, 18 Aug 2022 17:14:50 +0200 Message-Id: <20220818151456.2118470-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> References: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0092.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::13) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8693413a-99c1-4ebd-2dc4-08da812c6f9b X-MS-TrafficTypeDiagnostic: AM0PR08MB3715:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dwJf48LeCrHm9XPaB3PIT5cv/7MgvAjWM/LDnD0L88nOtV3eG5Z6W4MVeh+6Njvq+PL4g8It+TS5pQUx4k6FVz7YneqEQn6H+R+CGLaLLEJCHQAt/lcg5kkb13ndwrNmJqIURayfEjPLtg9vdTesAaUT98PXnP5043C2875HoRUYUSa0YOU50QGWfrP2u8xiNSlQJEvf7BvWNNZxx6Iqs7+NbpGaubcwoIwGolnyuc4J6KC9zkpsNp+y5laulHcSu4VnUq1gS3FejnUdU0vUS8rtzFZW/S9UXxAKOVRjy9e7yV8lwmgJibeF5ZhchVIJjH778ZWuXI9G4c0kxJ99Us6DlU/bD3WbSteO8xbds2KdvG1ulafw+Yj6mqgUNUYI6Ji4hy6xy1zKv8rpFKOTQ6kS6lJ5CuSebCrIAu24gX2ee4YxjbJhTOMU5ntFfzjLx6wo8HLruFAITSK2N5OR1DWVBqDdXwmrUax7if3V21xCdgqPbRppx67oGwhfakH3FVJgk/VvMINKg8JAKvkUQ4qjRallPVwe35lk4ztjurAru/SGS626CjzrJGh2vMeqUbv4Dot2AanUh50TYmMvz8gCYtgfrc+fuJ+LRh7aYnr5jTXrq2qfCl5/f25i2STm+N1LKYzOHljXHgwT4/gsnyBALpZgDVlhF36tYV1UinnntZ2eVdGDkoABmd2b7nUToISJyJDJ6GSC6QC7vVCBgW5lBoGTwIOq+vgN5r38iRLbnk8/0nHMBfKo19leRwITBQf3SGZoeY5d5TttjYPqgw== 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)(136003)(346002)(376002)(39850400004)(396003)(366004)(83380400001)(52116002)(6506007)(6512007)(26005)(2616005)(186003)(1076003)(38350700002)(38100700002)(66556008)(4326008)(8936002)(5660300002)(44832011)(8676002)(66476007)(66946007)(2906002)(6666004)(478600001)(6486002)(41300700001)(316002)(86362001)(6916009)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YHSR5R9ThJZQpj5eUkvt4cS3FWLlqBzt43BY4Tsi5JLczSLoq8eGwJVHu9NBbO4C497iaYlTx9HYdOye1WztA7Y1aUDiDqicMCfJVmngfSDyuRizfx5dq7166uSjULQ/syyp8YQvksAAkGMNXtlzSug1lLfGnfJyFPRFCcwZNZYLRN84p3FhGhB6nujp7Ipokrp/ups1aSde2Gta6E5eYOp5SicZ8InNwmniKkVe8bg+taI8T08pBWm0iPSHU1cTleUtyUDUchuRGuGpq+le6imNMfymqbOSWEdEvYDSujF3IcYn4p6I9m87eD9uKwy9N0Wgg+wtmECvG1459cpCBLqB9J5kbho9eOJRqeM1EW8Nazvt9fwf5S9yHfxlpgdTZWyKcbGhrbCifYe3myMBxx10gVUwJQnuNfnDiC3MIggAZQlOWLzcIWPkDV6SUhSiQqpeYW3JkNL0ZKRtAlHi2Iiy6cJgLdgp+K1FLSjm8XHlD7sy3Na2b05wlUvYAalQB/J3hqr3m4XLVUuVwUjLDxDubO1NBaQYKCE7FOl3khgzDQ2sl3oxWsAi/NXEFtp1ygsioaIO3SnxmIhp4BXENlv/8MB0yiu+zEzHUNarmAzHy1ilvZKGdFwVDK8jkHU5Tz1c7jTH1bNZgf6SbXvQL1u4VPeb5HdYmTscn/nLmNyuNNsSJLzU5V3KDXi/PIuiCnZEsWEr3vc6FLjD02hAmS3IqVePAe8cUNyrq+NlvahD313FMvyOcBVfOGur8X6zKxTH2OoaWEqFDDgKqTqum+rj0JwQGy48upHEJ483lQc7a0mWF5QoAnG6wveCUkyZ0h3pqjFCQna6TROBKsZ6WTNHMxHjtAlzKGlhq0DE9SSoJmgrqqkoLVbromlQ7wvnD7bcTZKlGnwMbkh6XxjLvNNShYFkCFIINsdz74HtC1TF405EmZfaWRxjOPS5wkZjf6kuiqZ7jc9HvBG1QN+DGjDld8BLpPTa9mgAxfIFlSKXlF6KTLrNfQpbTrHDGWwPUp/9pGt41Am1ru7/B5qpbDVZzofx3fX2EHZkk10MDg7m4IQrhDsJShk3+p89HSo/4Qk4oZO5xHhS8ePdD2+HyJ7xECHSfmGBI8xyetdaUDFGraHlB52zprEXYkiHsQrs/3nAPuBTeB3oywqotoCsPzVFedRI/jYD+RA6GD6WkIQlapXBevDgWKmJHbxiLQSczmdMyOQRZaUyg1e4cCslekkSqq2jVml2phRVdAFeY3WNgyW1VPUnzDXPMF4Sds7p5tfZCZ7uPxKao2pLs+iJ0/LSpmIEqw0+7j1hGKXMfQwQPmpv+66boArmZtmSFpP7jul36wiiCLObVG82Om3GNdIf2IwCqMvyetXrKP/b3mYVUFtW1hzzSEwULYB15HnI+nOLbcFoW4F1HuTgYGdhiav53p8Qee2gdT1WN1esoSAea+soJFGkEKA14Q8LL2AzPpuGSHHkP7cu7GhlM/a5rbEEw5Le/xbqO2OUy6KqpVDHAmlnXmgZxeLy/2FmupLhYMFPL6bcNwzMaXsRBMXBAK/qSSO/6WoOu7drYbYPz1njSLzrCriCxqWRmoCOe/4rpgw1Ps3PHM8sBKT9oI3ucLwiHQFQ5MJTHPPMWAoLNM4= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8693413a-99c1-4ebd-2dc4-08da812c6f9b X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 15:15:08.1715 (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: cL1zM6N57qrEJbKB+piqlWjQMLNIHx+rVYH3gIEapjBlp+xXermuqVSVE0Ce1bP7VxVsPOLwqczRgK9vsekRoJES8ajrT4ag6/jPrHj2yp8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3715 Received-SPF: pass client-ip=40.107.21.109; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This helper will be reused in next patches during parallels_co_check rework to simplify its code. Signed-off-by: Alexander Ivanov --- block/parallels.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 24c05b95e8..f460b36054 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -165,6 +165,13 @@ static int64_t block_status(BDRVParallelsState *s, int64_t sector_num, return start_off; } +static void parallels_set_bat_entry(BDRVParallelsState *s, + uint32_t index, uint32_t offset) +{ + s->bat_bitmap[index] = cpu_to_le32(offset); + bitmap_set(s->bat_dirty_bmap, bat_entry_off(index) / s->bat_dirty_block, 1); +} + static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { @@ -250,10 +257,8 @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, } for (i = 0; i < to_allocate; i++) { - s->bat_bitmap[idx + i] = cpu_to_le32(s->data_end / s->off_multiplier); + parallels_set_bat_entry(s, idx + i, s->data_end / s->off_multiplier); s->data_end += s->tracks; - bitmap_set(s->bat_dirty_bmap, - bat_entry_off(idx + i) / s->bat_dirty_block, 1); } return bat2sect(s, idx) + sector_num % s->tracks; From patchwork Thu Aug 18 15:14:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12947306 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 48BF7C00140 for ; Thu, 18 Aug 2022 15:23:31 +0000 (UTC) Received: from localhost ([::1]:48726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOhMo-0005Zx-EB for qemu-devel@archiver.kernel.org; Thu, 18 Aug 2022 11:23:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOhEs-0005op-Pi; Thu, 18 Aug 2022 11:15:19 -0400 Received: from mail-vi1eur05on2109.outbound.protection.outlook.com ([40.107.21.109]:49772 helo=EUR05-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 1oOhEr-00071E-1u; Thu, 18 Aug 2022 11:15:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aiBdBG2c+G0+Q3RA7Iuw5GrS2O6wHCqtjNzoLvVVtuncz6HCX9SFWXApk6m7jNmMOsBkyYSvo9MDbeur+/xOBYVGSkvRTXPhKZQaRTPiJoX/4v5B41bXr3u+coPNgYSEGO44OEKTwkqEFytl5+BKUkNRoZWYsrqCGskwzGFs6LGjLWqo6EMp1z4P9gEGrD85nTJYbVXF4SiJgeGbvB1Th5fYZ/Dh3Jz+FyUjDxL1nxtuWXij5Xab1aG6biHngjbs+tNmpWR6p8I12KLkhlNy7mGw0CL+44HS+kUDY4rY5m5aUCFUSr0j2kGfyqjFqVPlfKTPE5kIaX77tmeg+12ArQ== 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=Iz6VM5km79PkRBVWfJ6kxwi+m/jf3+/vMC2Fl5GGAJ8=; b=ARQ6MskNAMofWJ9U10Oc5Eo9y9FxLTG5mrWcXwac4NeipBRL2LBanHFPAA9NbIzzaeMp5URj1GlM+4tHQM3H6R59SACtU53jyMQ9gdEEHSQZ7DNo7s6XQO2PXlXENrG+0o4UVpPzloXLH7BQLxAIkFcF8zDfVEzFpSIywCwp/x3i3jHI0wNaWtiZxPT9Eih2SJQ1Yc+vPNCEKrTvsFdrP+rbCgFxW7jBFn7convkJxMwcqrgIRrLJsP9D0MaVBdCTaic0saIM5qCr9mVUwo8tto8qw5G1L6XPFmPcw8piye14d8ViehUHbpDOJRjWcbfXQXmszivXPPdpbsb7WLlkw== 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=Iz6VM5km79PkRBVWfJ6kxwi+m/jf3+/vMC2Fl5GGAJ8=; b=Wj85HZnwyR2zDCtweEZwTZRjTOfBkfdDpUsr89aBXJ1Fh2ZuIYNEXinTn9iCwNLDAFlSYm5PQQo+o6i1LE9V4FyNL5kg19Rb6USZAk2iQ0/yjHZ77I3w/6Qk856gnZntnWvi1yPA57r4c9WXwkcPIamfBcjp2j/liIcch6PhBL3xa16o5ql/SfFMYQxAf7xva6YsC8GW29HxqWLHQYJ4/k9cn+mYzByqTPzqVUY8sWWrL6AMGEQyz1VonpL5DA1ash8a88mDuDjQrias/V38DvAzAG74qM8d1LHM860Clzi/Lh57npUXwULAu+yOt9Su+4h3/VM5IWLTlxTRJCjmlw== 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 AM0PR08MB3715.eurprd08.prod.outlook.com (2603:10a6:208:10b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 15:15:08 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%7]) with mapi id 15.20.5546.016; Thu, 18 Aug 2022 15:15:08 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 4/9] parallels: Use generic infrastructure for BAT writing in parallels_co_check() Date: Thu, 18 Aug 2022 17:14:51 +0200 Message-Id: <20220818151456.2118470-5-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> References: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0092.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::13) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7f67e8bb-cf0e-4673-e885-08da812c7033 X-MS-TrafficTypeDiagnostic: AM0PR08MB3715:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aDm/Jon2IeNjiZIGl8R3jKX4tYFGiHSxWjeUQNIpWPqLqIIOM3mZrOQGU6vpyKpWy5J1XdgJB/O57xU11iYtXgys55qFSxECwv9fTZdkA/SGC1Cc+vDxRRjI/DH9OhwNwhWx/9IzyYZWrNeWsqGbjqa43YxQDYggzMoJma51gqQ9+gqLaqyDS88QoaV/G84grcfN/WOOxn+dGuC0c1XbFsdUj2GzvNIFISW6IWRCiI3jUZ4pmxGjKVCEmjySnWGvaiBMPKqPPtJbq9sI7koEiFm8eQ1qrNeBPQbZkwUdo18pqH48+Zpseqz/QlgEHBI+ozdy9kylUy9bsJIZyUCjDg7rN2oi+l9f/+3V6QKEjlmIYq6oklvASySQh6dME95Wgq6OSqOvTDjw1q/ViczEQCtB59lS5ESnR5/RFTFO1SqO4/63X/xsg1s3ntTmv+VMReA99ruHxqAv6C48VZGdUlD8a1lMBgCPtOj0kkIMdFdMBPe9j4gJ6fhko9B1EAhlkE9CYIn2PmU96fT8nHIoIIXMuykpWahWF1E6soh2WzT9BPt/DDyDPBn3MATG2KoCCiarqthDC6rItk/1K4xkHe37vHEZ4W+fOWonQOuXZKn9m4vsDDFlIkPqqfCE19YiHveBvY57up8q8j77rrAnNzNQfie+osiHTwlWcCGvzPVHBAPGCg2fZxe2PeAAEUD+SOF3G2XRoSr07MepeEDk+NWrhQG8ExLOB7LC5MqTZE2E3SF4yrozyKWSocGHxr4opULRv1Hrz+FOEma2K2orwppttMsQ+YGfvFC8BFwdIoo= 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)(136003)(346002)(376002)(39850400004)(396003)(366004)(83380400001)(52116002)(6506007)(6512007)(26005)(2616005)(186003)(1076003)(38350700002)(38100700002)(66556008)(4326008)(8936002)(5660300002)(44832011)(8676002)(66476007)(66946007)(2906002)(6666004)(478600001)(6486002)(41300700001)(316002)(86362001)(6916009)(36756003)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U+JXR29uvv5Mz7dQn9NjbV8gXxWSf1JY6bPdwI7MJkjV8uI8fvK8mNYtQZLZlJ3WIF3xDUXblIALIoA9uCicl7N8AFcYpJjXRtL+ADPrzzk7lD54rO7cRQx1qvv5rMUWB0mX1ceOtelIZ2MBV2ABQ95FGa5tLId/1aO1k+R62kYrZm8nPZT20nDvjdanWjBn1EWfE5s87KO+3v/pz4mGYsR0IySjbv8gFolyrDdqEa0Lsck0kK8fOtsxQbQCIRZ1sHcYjobm5U9ijzF2//WAgmVINBdp0yqIK/oFJEw6LErcaah+kutz1fVRof1h9az3LP2FUyOTJuft/dS+sKRu5r268hKfKBdaEth49OgKbHZI1P+ijOjyDWTsp1utwELaybVAj+oQBi4laWxhArEMniq7HoVKjd4lntOUVVqjC3gK3sn5sm2aJ9GjWhX9sWD65C1z+IVIDJIiphU9MwV0oX0UiX/cIm67xwreFIsPLfhRCliOC6ngW79mgMh7JsrcMpTsXH6nUmDweJa8PEqiAYV8FjO3SfVSvNNWyHSu/QqdNey71rBOAPs3Fs/CsFWM+yaBewXZQkicogHfGMjXfSXyL+050VSM0ERd0tlfS0gZnYsiP/8FQsKxXY535YL0GzQaHgMO4QoX735YIc/cObMznbeSAs+F2nlc6aMfAIpHNIMs3x5f2VVN7kxBDUxzF/xOtbuBxppufmMcyAfr1sAuDT4HKbqVy3eMAu7c9SiBLVlZnCPLCgFkx8GUAZ/ToafBzh7F6hTgTdjNmF8fRP7490qk5nkqp0j3QnhxY5VXJTWlfrau28gOv2Ctn8hJycCSDD98YxCsYVrZFkyESm9PemiU+Vi/68u5PKqSboqOPTgxrpUGfFjhVWVQC7DwcwxpXDgapRjl3JGR7c7Z+NBuU+xXuNO40L5fdv7iDckZZSUXYQTM8zQJUU/yk+lvpq5A2Z1SaC+P35atgL3no19iduoAYE/hsO8SjE+vG/S4DC2saBsUde16tGRtwHMAoJAiV8HdpxHCtSbTTj7xGxgSyj1gwlFu0HQR2xUFngcR6Jna5DL2gy4OQG6PYBlbgs3SI1eBjPHU+5btiH3rClAM5kNjScHGRGOLci5OvRhre8RLACacm3ReWW4mpaROntFzUQnQf2QBLGE5B3l2X2DxDc+ZXlkIu9ASF3MmbAPnzTFMrJv4LxpmILoHUvOS20TUkLcWQ0T9cp6rixQKfCFlvV+e2sK1lOWQ8gEHs7T1ZwcpN3wHuBWZyQc5FGgyq6qOc3ggR5++YChObZgv+DuEUAISOwoe7H5psRUSV+aq6pF9nxpQCj+5jqdD9X6XiaqDbP4XExjvSXQkTidlBkbHXz5NtAsR3mtgV0awbm+iwVfRHRRUtG0E+zrCDdHDlMnG6D8mtFN7Lfy3YGiaw8vNW7LNxdTq6s/D/LlCl2v9RJQJcEdMuepbcBvAVTHz8hHQRZXFEyvLhU21z9vmebV/wbR1g7RL7mndUTkvVOGmNa0dh7/Py/30jZxTzZBIDZ+Aj7gVByNT7pHKpRKL6qNcU/Oz39MpgXtKy0BDxpsceJXpS+d4VPWGdYK1PjfRsVc09+YU1aW4LtErL4Jfv3eo08lznzFxQQ0ceR3w+Uw= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f67e8bb-cf0e-4673-e885-08da812c7033 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 15:15:08.8433 (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: LLLbudINi9wUHMBGvpWW/el2yUv3pcSlmj6JgIOSlo+5zbczNqGpqH4kTbCphb6vS3U4iMeljO0H75PYvCIWX3o3WsIrnRBSzMotCAa7ZwQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3715 Received-SPF: pass client-ip=40.107.21.109; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- block/parallels.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index f460b36054..7d76d6ce9d 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) { @@ -466,9 +465,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, res->corruptions++; if (fix & BDRV_FIX_ERRORS) { prev_off = 0; - s->bat_bitmap[i] = 0; + parallels_set_bat_entry(s, i, 0); res->corruptions_fixed++; - flush_bat = true; continue; } } @@ -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; @@ -529,6 +518,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 Thu Aug 18 15:14:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12947307 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 EE87AC2BB41 for ; Thu, 18 Aug 2022 15:25:09 +0000 (UTC) Received: from localhost ([::1]:34430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOhOP-000158-1Q for qemu-devel@archiver.kernel.org; Thu, 18 Aug 2022 11:25:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOhEv-0005pU-Fu; Thu, 18 Aug 2022 11:15:23 -0400 Received: from mail-vi1eur05on2109.outbound.protection.outlook.com ([40.107.21.109]:49772 helo=EUR05-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 1oOhEt-00071E-Dw; Thu, 18 Aug 2022 11:15:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZsdgIGUQ7YDHGL1kO8LpIrbH87k7jBSA45Ofjqrx+OD80MsMD3q0BxGmeRbCC4/+2JzqOwgjaMmf8t2lYhjNsE/O6/R+7TrK//vg34UZIu+3DzjCxeYkRGpG1Ki5/LhAOXLON5/F70NZwBrlR3GlDRPVbcpiBFx79XJes4Nn1NfCD2q+y3PvEsgWe/K1WzA4mH3sPlxCxKmJbiy3Nv9ncjCM0EPb9dF19RmLqTgNQLukvoK88r7kGItGN2WG3PtMPWsNM30bn7kPY2dBxU8VrsmWysEeR/+bW+wgC6kBjtFnFbK51vZxRd6K96PiKioDLR8rKnpOSs1RiV027rChfw== 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=KvN0sK9mTsGm8puGXFPxxCO1Alc4YZm/Ra6InPslqAM=; b=hiYH/Ksl/4d1oJt92Wzt+DoX7Q1hAHV0Tp2qn+iihkevuH0M2WoTkAvqcCKk7YeyO39CS9mzhCJQdpTvBVxDOGw+x04nAv9CT49Vh/ZHkka8wG+fa1L626zOr8TAvwDOWcH74CBTE/GRCVrnWZUkdelsJPh6j4bBlUvhi7N9ZRpbJ/yIYusFtil4vwzTH7u2knFk7FrGoiG8acM3tsRvRzsIuSywGuhA5eAksv7e2u0u0Wf6Bra7EfW8kUMk/i8UD1fj/sOPwdHhkAKWrkrgbteVovang+S37sFpiM/rmMlaZ+Jl04oxZGy6xp4ma5Sz6DpX/wxJ4ZvVU29IPTtdsA== 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=KvN0sK9mTsGm8puGXFPxxCO1Alc4YZm/Ra6InPslqAM=; b=QbssKW/eAAvSm4sYmR2EX3ELkDeQwQE/EAJhII4Ta1Bw4feLveB/J3HDc498cruNRlWWGT8jNs+4xJkFhHEQn6dvYnp8nuRqJBAlGLINfn99ZkEKEH1IUDDoZsD9x3EhuOGzy2wXkPBworzm9SnZOyBSg/7Ipx1CCbptNq01jKTGPKRtJH+BvgXxU9UAxejsg6c052+3mWfH1qtTOA49/xlN6k3x3K9xZ9d16nf8AS1rZowG5Kb+XO07ji4WgAFSKvw32GBwx57L1ItUTNcqqCnuT7RTKiDejFnf2y6blnUay1OEHIglNaptkr36yfqx6kyspvw9hmdz/F4XSAygyQ== 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 AM0PR08MB3715.eurprd08.prod.outlook.com (2603:10a6:208:10b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 15:15:09 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%7]) with mapi id 15.20.5546.016; Thu, 18 Aug 2022 15:15:09 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 5/9] parallels: Move check of unclean image to a separate function Date: Thu, 18 Aug 2022 17:14:52 +0200 Message-Id: <20220818151456.2118470-6-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> References: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0092.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::13) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ca71259a-925e-4873-97c0-08da812c709a X-MS-TrafficTypeDiagnostic: AM0PR08MB3715:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 36v1lhyHToMwqp+00NbyFVvZUe+qeISQyMdyoLIxlbas2hzsFayCpTsKN+sw86im0LqiEjMGxDwWbuD0FWjaFBYIUqE02YQl0HN2h9AzBoTQWMMjrTX7Vc+PVShxyXyV3GcFlEJ261sBtKGtGE4NDFEuouPwVz5cE3OnJDRAmW5RG0ZI97fcohm2U/UiLcMCUl1HPDw23yzfVs5W+OaBcbGossCjxe62PRgGmm2pcknTeZ15QPuxz699cnOzDoTwaa79zV4Ca+pQh2Mrndw6mGtt3lsbp8wnmYOVlRjwYMvHVQ6pSXjLaADgobuRybMXM/ggTylf7zsroId2EthK0yN0p7YzXT/w8AL9c/9Xfjil/dq1/2QHyiWdEblGiUPXSA2rIW71DEQc9BzR1tm9VVUAHqS0Xik4f2rxZKUCVWgNgGYHnD7R6dOsswpZX0QJ1lKjUpiwWATQtoAZJkpP5DTQmAhbSFNhNCVc5nfEf1X7WMXD5EcPC9m83x6kY/Vto2HrEP/KsZ8H8+tcn1s88BM1bdG4rf62ZWYtCrrQOpdqOwwqlTJ1mfRmotlM3DjUjcUWwgNfbLfx+dOK5kpPU5nmG7rfbLTE9WxX1YeUvqP+uqEXOxUs+wqYI2kVzZ6XiDD+nrYiLJHvNA1nYC8mce5pyxwQJAhAZhWoV91r5wSPre+FCGqXTOXPEnpqoG32Zb8PBlPEcAlNEhCmMRJeIOt+SBVrkxIKrHcon3DzzjTsExKpUaGMZKir2jhQKGjgqERJhyi9b9stQBEaPZdZoQ== 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)(136003)(346002)(376002)(39850400004)(396003)(366004)(83380400001)(52116002)(6506007)(6512007)(26005)(2616005)(186003)(1076003)(38350700002)(38100700002)(66556008)(4326008)(8936002)(5660300002)(44832011)(8676002)(66476007)(66946007)(2906002)(6666004)(478600001)(6486002)(41300700001)(316002)(86362001)(6916009)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VzjhJ0D2gG75+yiqJ3m8q4mJGsGzUKgtlBHO2EC6GX43g36yGGQQ47goQmyGcK6NyQVZxulo64BaSmAMo3zmRMZoylpnsnnM4BlkVg+y/PTN95+cO/fUPVmNNC8/ObB0UKWFu7qzExoWJL5U0Y+Pz4X8BAo9DEFoFE1tOUw7vnWJc+1YlvfiAYbvKALcplOBG7tCJ2XXbA0osNwOdZ7ZX9r4yEwF/YSlQM68IIJCRVCJ6MW3bO1fnqWHqeKkYQIjqg+rq5GZkuagtJ9k2szRDWRTHEFMOPkqDxyShmIB5eA5ansaqOZPPOILmFY/6BU+QHFLfTifYxptuof0nzZxe6QEvrIUhTXc9bZ27x7WY0euiClvK87Ryom0iqRJmQ2bbWU7802U+6U+F2eYWYoIwa0RLvFW88FwNRoyeM2nXYdU4RFHpNN/y3rMqTWEhFkMDB2KegCmdixnjXLwmWm5ZMY8MpbZzjJf03zBC1pKammy5rMT1A4gbdr9ROix/BrnHuWPXZeQCEhRR2TVwA4hyj7SBuANrI6KgnwYb3gLQ902/LY1Eg4Ko9zoyiZCkCNpua158FYLr+TKCQByF3md9Mml+kEvnHBpWrqCSdkJtDfaMob2uaQc3MDAEySlcgvoCQqfYRCSC42VsJoDaShiU9pnZLn/QjfTMAty5G+/cHfcHfu5axcUQ6RF7nL3PeEpr5mvVt8y/+rLbsrfFAnoDsSm2iKUgyqMuZ3Iqw4B/Nx32JSjsukOFHPm+uxs+/ygBjOv9h1LV0ntCnRvO/+4hL2z5BotVYavm97ZNPq+/iraBI8b9ZCYm7mfln6YfYAP//8vOJipUEkJKZdZ8AVWhj+nItUcLQv4mfERs3OoFq/80NvJvbDhyWr+GY6iRuPEUDqybchtYXpmIG+HBtbPum59evz2kEdakUC6cKtOdEGPjTFmJmmj2aexA5SSXxR23ckoj5PmE/PRYqV05kjP1AtCi9q/t424kPS5PHBUlAiGukILMibG8SURVf7wfP3t3xuZZlLquI53x+D0MRK1Pi8IV3WMlGa6mRj1tp1p+dmntTkoujIYjoMKeOSdtdvPpAT++d4vLwPqVj/1Jj4VTeqMPMVanh6zEcmVq2AcloLnRp/qX9iCPG67q/ZJbDHeHX6oaSsCjQ848uOkTD/Z/yhfK1nDK9H2xssgNVQZFYwhCUMAecyMH2LglwyI+NjNpvoDgPc1z9U2/PZ806Dr/q7SR+4Qmu7X5HcTZcbDJWlVellBYjp5WkKlSgkQd1s1MSJGwdNkv7MiiaFQCLjICaNiYNgX874N+Ll9UR3ZP3emFudIPtVvRq5PSPdcedCG13X7Lw4/0XyH9ruKHzuTWtfVoLoKp4tM7fQQoafLwHrGVjFzA8u1/zAo4xXeCpa9BCgcUbofJUzHbOD+qarcrMEaF0q59AtH0+Gfs9x+OVXlJkGek49+bG64OtCvL9wVAACvpIvW0zwqt1twKe3vSfbeQFAl+RAylNkzmXot3uai6orUMoJ0CkuipnWo3i/6q/8Kk/6LyQHb6420aTIV7xeH/CvCn1uMrwx7cdQNDvuHQGbwJNQhsye7+4DQkRsvjUf/ZRLHAq9FF/dKqclrSjJ3DjDYkdd+T1RUM1cq7P8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca71259a-925e-4873-97c0-08da812c709a X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 15:15:09.5319 (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: HlRJXuC3E/5oCdPLknnXUiPC5tpfEDk01CpmBt30Pmrmv5Sduc1pmQf9mqud6IxjWB3B6rf37gKsKHEYBBMPK/NQ1qOvQsYQZR7bzwD6Pm0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3715 Received-SPF: pass client-ip=40.107.21.109; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- block/parallels.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 7d76d6ce9d..3900a0f4a9 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 Thu Aug 18 15:14:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12947308 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 4C5F4C00140 for ; Thu, 18 Aug 2022 15:25:34 +0000 (UTC) Received: from localhost ([::1]:37770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOhOn-0001SR-DH for qemu-devel@archiver.kernel.org; Thu, 18 Aug 2022 11:25:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOhEv-0005pV-CI; Thu, 18 Aug 2022 11:15:23 -0400 Received: from mail-vi1eur05on2109.outbound.protection.outlook.com ([40.107.21.109]:61536 helo=EUR05-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 1oOhEt-00071h-G4; Thu, 18 Aug 2022 11:15:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lq1r0UuPTAc0s9mUv+12tj5y+lE2j84b0xsiFlgbVdEgfNbPWEamEeWges7XMDurE0vdkYOM6JvUgtBOMZaxfKYaXL0Fq2LQuTnG2VuI7rMcxdtMeuwzy0w784gld34rP1vYV3uD3LPfZtwNickiIBPMn20zQeD48UDjUyQYjREl1pn1YHfGv5uPx5ulRrFdVQKNZr2iXteYCBn2E/9Ad9L9cniSEG9BLf16VcDZNALyFBO7RB2ewsmLhM5s+L3nt0TG27pfvM9NrXcsO5fEAhrs/tTiDFNZwFNE6Lh4WWisPAAHei2mXDfE3YGRjQo3JIoIJXNO3myqNYE3bxj7fQ== 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=lFtQL/SOeXs1p3XSdkNaSBXF9WP6IOaq+YWROZWtD5U=; b=e3dDXIwAkPerciqvQmf6+4ij9A0pieMW2ezbbyznH9J/6ASR5CgrFEW8gfC3y6O9ZSAzvDuTVs7JX2CTm6g6SEfAOSi4XLaccrdKl5nA4PMGtff3r5TuDYMaXlJkS2WF+R3faV4qCnS40p204ncKJyAdzHg6gprGQjls4yoAxs9e2hsw7h5MQ6MguKfGZPnSHZgOAVOhX2gTtQeA3vWge0nRNzCzpJNPxpfZFTqzGXgq/MzUp4eS7euM8XGZ+4JMvOt+XD7eIFDtrddVC1M/Pk4gsUhi9yEWwFht/DrGPj2zX5UBpe9y9FMuM+TMDc1q3iEVyEY8OJKM/yoNHqLVeg== 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=lFtQL/SOeXs1p3XSdkNaSBXF9WP6IOaq+YWROZWtD5U=; b=hMd4qM3beADVqBVEVgEc1GsLlvaUr03kYZ3qy48G5PWrvqPJV4gGS1sEY2XKoI6zCXGBVYr8dRyVIqf/e0j+/SHj0Fnq3e3T12kkegyLz5SRccILk4yQj1+/fzVIjJvTPf2bWR5Q9jZHRucetypdHSemzhjuWQTmITd8oos1Jf7/av+xQlaQfVYX+PeIVRBC4eI1b8iz0qGjwygZSqPmLzNvVJ68MSSh1hjYnrld+bG3W2tqfImqEzr9mDLKhcCdMXGrpUW+sFdjiBLBCuEJA+qaSL14E4dubfu7lhRDm9IuRANiCRhY2oY7HXrsE/FwWoonPYqpmfltGD15QhQSlg== 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 AM0PR08MB3715.eurprd08.prod.outlook.com (2603:10a6:208:10b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 15:15: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%7]) with mapi id 15.20.5546.016; Thu, 18 Aug 2022 15:15:10 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 6/9] parallels: Move check of cluster outside image to a separate function Date: Thu, 18 Aug 2022 17:14:53 +0200 Message-Id: <20220818151456.2118470-7-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> References: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0092.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::13) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9a84b30f-2eef-4b84-4b81-08da812c7103 X-MS-TrafficTypeDiagnostic: AM0PR08MB3715:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FqFuuHzK3umqVa9SIvtbcjDfJk6HUjaCShm9uf2uPCoC+SD6uASGyo4DMigDlQtsMBWw3HCvqZE+wc2W3ZPuqXPKrNamhTJGiUt2Zsm16/KvtQPd6wd9S9WhLfycorsoxykcIkUZuyjO2PZ9zgVh5bJc/t9SFuiS4BdIOc+NiEIWVRyuCNJqjwzo1UeroRKathAo0TDATMxTRFdrQWrFtmawMRHAi3cG4OViaLKTA3cn/1yTLNCHXFBIGxiP8FrluQxRm4MoRpnBoR4MaUcpdrzq6iGDoA/xrw5YXbVoKz4LHNfKXQna7bI5Hg4hYSzCNldpDr0dH/YSVBS7Qg7NzOVUCeffEP69rmoZ9dXUAo35jZdOtVdoO3qq1cbZeVu+i/gAqmIByEjaNKBm0MqBsmuaV4qWRs3Skpj4CHbvHCQ5A0pAk9FQS3/enA8T/WLrLeRlhhn+9pM+oiVlAoT9NcEMV7oxQwsJ1PIO96WVapLVhSWr+U8cyjJoifpzBIHs0QDPs/o22y4n7tv9hDxOsehFsY/E7Otco1q+X6/eQc7YLrJUD6dvklZC2nMAuveN59mKs1EihDCtScNANic1H5Df4yxLyNE/MF2edZmswhGmqPuqDwez0PWBdc4SCFZPlZNs5WMnycsjb2bJtVfmosASZVNhPzCBbvGoQHenbagkpRQA3wmPvuqzYyH0wPrt07TpWbC8Gr26RNdI5ibsWv5H7S5C97C7N28SZjexnVKcxqBz5qNLMk2qxA96WOrIT5J/YNnB866IdLWmYNDO1A== 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)(136003)(346002)(376002)(39850400004)(396003)(366004)(83380400001)(52116002)(6506007)(6512007)(26005)(2616005)(186003)(1076003)(38350700002)(38100700002)(66556008)(4326008)(8936002)(5660300002)(44832011)(8676002)(66476007)(66946007)(2906002)(6666004)(478600001)(6486002)(41300700001)(316002)(86362001)(6916009)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pxlnpujuqfrwuITc93EFqrBGJW4UYIdn3QPJQJSV8Zp/ajaBGU1DjiBWL0sOptXFdy+wlmItP0Lp7rtPorGqswtkItENb6WP5Da1dJNxyH2nrL7u+mlVuwXvwzveHLCV3cCfso94c6Ak1lHj9uD0EXvWKiMKPXGhrG5knss2P6vnVS5FFyGWSnfRNAL0NNweGJFFLSrxz8ZuJJS7QFC8yVKvLBWi8+L1XcjCFqK7UDfAbDMipHZnlC6UTwak6EYQUOIEd9ZXTsWI2qmWbRmlEOFA7650JQWtDwZeDgx8+ksHkL1CibggrESfq1dYU8yua82TjCRWvcWobotdSoPtJJzpCXR7ZLgEI1NtJsvCrlidyyIJ/JvjhET1PBLTEj+0mXPENWhckZ1st/CRcDtBt/LiEqONOy+A8OVFLiPrsCoj2MePfp0x1oJXIpp2nFislW11X/2VoyMAbAVGQ1puHTY7EQ19va8NHmbDfD4q8eeeNKk+oVIvgKZF9T/RX2tIX2oq6d9++Unrq5/+75NTKBkau6PHh52LA92mpE3TgML5wNmKgsiFJf1LH4uktFC3K+Wzyx+NSzXxMeLrlcIfhj24RrYJ6wR/dIxO2R8VqKCwh1cviSXcnDjEdcEzte4nMvFohT+2kqTOfx2/mjI+jXcguwaFp6xPsK5X8xIfB0eNdJ/MiRJ1U5Eop/GJ8fPABk9Ta+9PdArXvDG9rq8f4zn3hDiKnZWY1Ta7XrNUu94pvR7wuOPGzAEuUtuSYTEp0NC9G+t/qRBSRTCsjXN5ENVTwM4mg6wrkbFmsWixxDbUDcFtwBPwzAcp5T//clUFNu7k/vXfjDDYH6bx55qW1/13X1vEvDDa7IoojD8ltkATQ/UPHBdT5tnn3ciHtkcvCiM/CrVhEl/DJy0/w4tPs4D8zoYg3e64TMGkecIxvlx4jz2FUNcbW8NkZF8keQKEVP1y3cFuneeXbS5QTRfX9s2h73z6gq/ZNNf0PuNVXDgKi+0+I+715xw9eHYQo1lk+6dYLoFaxNXGE21IDOCINFU9fKtIvF60aqaSd0dwIYox3Vz5hPnsC+tw/diqx54BMR1+tRFDtQjD0B9Fn8mldfo9mNsVABcJXWKl+AmoUc+yZ/WBphBIn33MN0GUkKhzzbSO3gWTedGcLEjfqp0MxoohATCZAnSc2vsHA2ylBM0O5ErguMTvrdyuU4t3ckqGyF+110v9DUekvig7SkKgDuR/XcPKdDOqcvN4nCuJSpkP1sHed1b74+XUx35qmycS+Q6TeeK6OJgWvRmoQSD5R/iJksBlUErKkWF6T/v2Ur8wpeJaz6U2pk9JjHgbRikNgKixmOIJCKoNd4P8x42Hyv/QY3dfafuU0eu+UL5H1AK+dwS1/LynjqV5TAXOgt4fIbaS1LdJjlpESEs1Z8Uek9y0Ms0BFJOFAgf7++vEhc/c6xqKKmwvK+VLm743E9k7+a2zj7W3SFwMYqq11JmZfp7sJKieUPYwFlO44RCZiqhh12BmDKijyTIGLglvp2zwR8ysNT8L4uMbdRHMczprcj7I40uTbZ6I6koKT+Ywl7i94WmA/pJ2P0Cd+PMRWKDqZ0pKPBxEarCpl9wVYl++ozVPSJT/UPOSizFSt16dfm8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a84b30f-2eef-4b84-4b81-08da812c7103 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 15:15:10.2181 (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: FmgXmluaWRYpFEvufKSbGcZS+I3z3M7m9hLLZtMGI3sYTktpbSVGnFx/PLO5dU7JCqFy8pCU+HtZ8dTVThl7KjvkXnZcg8m9jEUVVm6b3qo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3715 Received-SPF: pass client-ip=40.107.21.109; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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. s->data_end fix relates to out-of-image check so move it to the helper too. Signed-off-by: Alexander Ivanov --- block/parallels.c | 67 +++++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 3900a0f4a9..1c7626c867 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -438,6 +438,46 @@ static void parallels_check_unclean(BlockDriverState *bs, } } +static int parallels_check_outside_image(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + uint32_t i; + int64_t off, size; + + size = bdrv_getlength(bs->file->bs); + if (size < 0) { + res->check_errors++; + return size; + } + + for (i = 0; i < s->bat_size; i++) { + off = bat2sect(s, i) << BDRV_SECTOR_BITS; + if (off > size) { + fprintf(stderr, "%s cluster %u is outside image\n", + fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); + res->corruptions++; + if (fix & BDRV_FIX_ERRORS) { + parallels_set_bat_entry(s, i, 0); + res->corruptions_fixed++; + } + } + } + + /* + * If there were an out-of-image cluster it would be repaired, + * but s->data_end still would point outside image. + * Fix s->data_end by the file size. + */ + size >>= BDRV_SECTOR_BITS; + if (s->data_end > size) { + s->data_end = size; + } + + return 0; +} + static int coroutine_fn parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) @@ -457,6 +497,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 +514,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, continue; } - /* cluster outside the image */ - if (off > size) { - fprintf(stderr, "%s cluster %u is outside image\n", - fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); - res->corruptions++; - if (fix & BDRV_FIX_ERRORS) { - prev_off = 0; - parallels_set_bat_entry(s, i, 0); - res->corruptions_fixed++; - continue; - } - } - res->bfi.allocated_clusters++; if (off > high_off) { high_off = off; @@ -518,15 +550,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, res->leaks_fixed += count; } } - /* - * If there were an out-of-image cluster it would be repaired, - * but s->data_end still would point outside image. - * Fix s->data_end by the file size. - */ - size >>= BDRV_SECTOR_BITS; - if (s->data_end > size) { - s->data_end = size; - } out: qemu_co_mutex_unlock(&s->lock); From patchwork Thu Aug 18 15:14:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12947309 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 07122C00140 for ; Thu, 18 Aug 2022 15:25:44 +0000 (UTC) Received: from localhost ([::1]:51872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOhOx-0001Wj-5G for qemu-devel@archiver.kernel.org; Thu, 18 Aug 2022 11:25:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOhEx-0005qW-Nc; Thu, 18 Aug 2022 11:15:28 -0400 Received: from mail-vi1eur05on2109.outbound.protection.outlook.com ([40.107.21.109]:49772 helo=EUR05-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 1oOhEw-00071E-1g; Thu, 18 Aug 2022 11:15:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jVVFGcXCKntWg2ECPJVM/XGAZ5IY7k4DHuQZILoWgoKzWZzrcK5bsSQg6WfDeFIzJqvpB014rhBZ1TXnhJAAdh9PjLi2WSoDIwbkZ+2jfi1j+YEEUfixEwrPvvn0n4oSVzZ6/K9M1USgreQjz3F70m4VMubSCM454m2SK/106OGXbtyN9dc48A2llthQB6CmlcaFmnUdus7EBf23pSGwGVlL1W1XElntT1G+bdrRHsoNkKGXpD5p20esdI8x3RODBcSG0HPeIBLaLLfGy0ZdqYyJt/+hIoX7qjfe+nZ504TLXjFBXftcoatS8B8YRz8hdidRICKCPn8TMqa9dVkSNg== 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=R7VoJmaMl+FYUR/h6vJALIjCqlW6nLCERRsskjqFa8w=; b=SzXAoJ13VgZ5lBmZK+g8MoTqRF6EL2eEPtf2LOXLUJ2Wtb8JBhgqqWgtPtRtwvj7E9Eix3jqlQR5MThPIAFPI+ezrEJqbZwRgE0lYYmN/LbrRcO84xfqOffW1MoKvW585aff4NJ4UJgy8WYltTNc8Fez/7fE68dDY9gauz5/4qgb+EuTBcORU4SS3mIRNZDdr7xFS/N22j2Ndc+iwzX9uY9wR2RdvKwVHhGWugWusTkr3+pDpFBHNnLu4GfhGnUR4JgL4C20PVZUmekDTGt0ocg5M+dtkdzXGgILnocvnNDkJEZIg6fwGsC2rA5fCczhTPZDeEv3GmKnDv8XJQ+vVg== 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=R7VoJmaMl+FYUR/h6vJALIjCqlW6nLCERRsskjqFa8w=; b=SHm3jpeFWrEeY+wFSFUEX2rwGdiVPRNRZ06mDzaePpo0WnZXkSEluVovoOBSdsH1U6fYjDn9bTuUeLRNYcKskj0aeD68fSMDE5w9R+Xz6lHXLNwWYmpHB76tVioUfocCEsyaK/Z1OWr14tPYYe1U17qvW5IACcb1KFgO9CQjAMjEGyDDFXPaGgU7WBJZa8eDy9oV/8BBuKrBK44r9ae+Uo4PIkdRparneT4KulOr7cAWaZzOX4sv9IywFDf2f+4rqE1n1yVDxpryio6wohY4ni9OnOzklE1DvsDDo5ha9c7M/uGYQVkChDEQKqjwhsHfOcJlxI7EPfKPl5/5Fb2kqQ== 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 AM0PR08MB3715.eurprd08.prod.outlook.com (2603:10a6:208:10b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 15:15: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%7]) with mapi id 15.20.5546.016; Thu, 18 Aug 2022 15:15:11 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 7/9] parallels: Move check of leaks to a separate function Date: Thu, 18 Aug 2022 17:14:54 +0200 Message-Id: <20220818151456.2118470-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> References: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0092.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::13) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b127cf97-f759-4ddd-b6e5-08da812c7175 X-MS-TrafficTypeDiagnostic: AM0PR08MB3715:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AFBBKezJYsAhKlsw66/nVQD8EEb/4pjnC9F2PcHNBUDXTaKOHOpgDhtuInny5rf/6Nup5n4ZHCaLts6TkFZG4PLRU8yQbt2SSqcxKIuZqazPgSnGVaOZsAZA+xnrTriMyUJ4Z9aPJTiM8K52H1dZyx0asd/pwhuTBLRH5KrOwll9n98Oj/gZBuF5rHknLVY/l8QaUtgCs6HtQV+ZWGHyeBaJkNeWbAenLuBTe79A0VDjdwuYrrmfYXowX60PSo/5gggmcd5e0ztA5urIDPIMhSgbQQ2oHeymNq+TO9APbz4Rpheth/Bbqz3BF2gr69yX6K7tTzJTSFHTUIWG752Yk53bpBm+f2wIX4/ooEb+B/6iQxR33eESQcJGjXYhZ8zzmjqKC3BH71CTlD6Fjskkg8oHMlFwBQ79+vaucAD+kabA4mUTG906HUg16jTQ2s2RqnMIGjiWloMZ4qfxFpQXeFKLkqvlQ6BeW2VQnof0/iWx7oH+OIJ8L99pJGZYPdvE/NutF3QTTTa0PdJkFdtaKQ15v2OI4BV2YUWMCUO/V2Daj6RRqPLrx0mz01CWyIRrTZKKElXxh+5W5LgXhfFb9SqX7o1Z9iWLvxNZbW8jPE8iUhX6WEYIj3ZRYCnv1+ELuHNwRZfZPcQTPio/il5nSeeXWZ+HBCJR9wAyue1n5RpESgSJGAxT9ufpLdHD99sC8eHBWl4kh8UsraMbcRuF3U4pvL7RukJ6YRkw1IHcfN5fG67lkIzQ6dfKvLNKb4l3kqqpsLWPKwmqw4G0spNhMg== 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)(136003)(346002)(376002)(39850400004)(396003)(366004)(83380400001)(52116002)(6506007)(6512007)(26005)(2616005)(186003)(1076003)(38350700002)(38100700002)(66556008)(4326008)(8936002)(5660300002)(44832011)(8676002)(66476007)(66946007)(2906002)(6666004)(478600001)(6486002)(41300700001)(316002)(86362001)(6916009)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9QY9gIEMLDIx13FKCSY1ZhwCItGJ/68o4DOG8VrEy/rSNjQ1RGYITkmWAL9XMsElZMDmtJfddkzTWkt8ToM1PNGKZrnWCEQt/qfNmSvsVILegUiPYXOa6w5ISDXin6DHVg1K6UIlxuvizb4Z2D0Cw+bUIdU6yUpwUt9zHt7bfFij4VpGmX+1Ft5TFefNowGE0meAg9+m8S8n/1Q6X5ddwWRCIeXwj95wOurgtSUzBKEM0b8XRQk4t/qZPk4SzN5ECnI45mfTa2P8ZubeYsfT5aDWC24J4LXEXOUYAr18aBzkRlJlgTZMCdE0WLZGs3yWQ9IFXUpf4cOPo0s7QiVNc8JrSw+gn9NLL7w/8xTchcc97klv1VezugoJJrY04T49CiZvHD6X+oQEwDDG6J83jft+a1gbck/QpIhiVfzzSEwvIpPtPYbDh+vakeo4fcQqaR8oUeV2HVZJqBPe+lusq7nCF59lVaXPUhUBVr/q6IjicjC64wsEY55p5tFA47r/Rl6Ueu6I+Ckq7H8fMZm3swiCLJNy3/OUYPTGC1x20hv3dwMMDGA0EzGDDGZSAumocSilB3maZsSNV16MFF32f3JfzGben7HkvrmtnaExbCDJC6cJmkWVlL8oHZcV7ZHocuvUftigkc8UxYF7yueohIMFQ2nHWd9IImRpvHZqi7sOuL6uLVkIoGV3P80iZY1AcVw/rMAnvaoMClpF3Yww0zo22lC2qVHcfAFhHl9MRZyOSkJJTj0ybH3dxIMIOnMS91ZyIHjsWU2a3fEPJ2LDX3MwqtRCFiR/Qi1e1Dl8z90RQ8Ce16juDnYmoeF4QjZ72+37InwTO8FUfWCntDrBK/Z8nOJ33QiFbpC40BcH5yEV8xRNsE/3DW/oeWp6kXnaqBhKNMtUCMUfSe06R9FQ4TllvlWCL9qGWxIz4+ARHIJixH/Apt00yg4u+LT4F9pjvf7tjl/9MGDTKAXCEseMzEmz/6WtR7SSCJNo1wgrUeqYv5b9MH/AijcuR9JS4TUZ7QuPN2ywfDkRjFURWf6BN61DIvYxHfDUZoRTM1yqsXvsELdvfzAXJtSXn76dZlb2xCFCS5w3usDnuUoIa8rB8NeTFrT1f9/hd6U+1V1/jHLnr4m5wrMKjvOnanZ5T74HdlHQkJ0f+ifF0XkmWRdFYB6Z/YUPXv5fsSDGVFke62kPlz8qfzgE7FGG1TCA1RNQTmslNigskTx6pwxuaYlD5WOhxCpBdS9NNPUANSpG+pINnzwjuvVrSJdaxOtF9dpbjx8J5/v1d+lGdKssLyrtrvkiUCmAL+jkUw6NjhxzhPbDRdG2OKkoZbyclEAE4GnM3jTUQrMwhwwzDM2MhbZdE73vqCiHlTyNbn63/VXrSijUMSFgypjY7p0Kh71YD45hPtk3suy5wj0c5FtS4s0aBpuX6D4g85l6gg/f/q+A6W44GLA//ukYIRmrIdf9UWi2NQlqSAKP1S/u8LI8+5Ar0kFiCeEgWUQBH6zZJzwKChH328cRLo0XOesL1yVJoVzYRrxX56+2nTRjH7XaT39v4cJh9nHVjs2qdLXxjuvY9OjkNVuq04JoV0zB8bP5LJx6bGfBIHxHKXHTeR3oUnjVc6GeMmWDw4arXFpTuAj+YNk= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b127cf97-f759-4ddd-b6e5-08da812c7175 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 15:15:10.9992 (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: /D4XgpIE+LfxlYpdZz/ggzYdZwflYu4Dlpll+Dz2hr0wL2t1A+NR2bqe9oAzwqFUP6zF8N3xnHvkeBKnbW7pDfR8OSwsFMqv1ZykOw9XHEM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3715 Received-SPF: pass client-ip=40.107.21.109; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- block/parallels.c | 84 +++++++++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 1c7626c867..6a5fe8e5b2 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -478,14 +478,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 = 0; + int64_t size, off, high_off, count; uint32_t i; + int ret; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -493,41 +493,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", @@ -545,11 +520,56 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, if (ret < 0) { error_report_err(local_err); res->check_errors++; - goto out; + return ret; } res->leaks_fixed += count; } } + return 0; +} + +static int coroutine_fn parallels_co_check(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + int64_t prev_off; + int ret = 0; + uint32_t i; + + qemu_co_mutex_lock(&s->lock); + + parallels_check_unclean(bs, res, fix); + + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + goto out; + } + + res->bfi.total_clusters = s->bat_size; + res->bfi.compressed_clusters = 0; /* compression is not supported */ + + prev_off = 0; + for (i = 0; i < s->bat_size; i++) { + int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; + if (off == 0) { + prev_off = 0; + continue; + } + + res->bfi.allocated_clusters++; + + if (prev_off != 0 && (prev_off + s->cluster_size) != off) { + res->bfi.fragmented_clusters++; + } + prev_off = off; + } + out: qemu_co_mutex_unlock(&s->lock); From patchwork Thu Aug 18 15:14:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12947305 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 5AE36C32772 for ; Thu, 18 Aug 2022 15:23:26 +0000 (UTC) Received: from localhost ([::1]:48724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOhMj-0005M3-El for qemu-devel@archiver.kernel.org; Thu, 18 Aug 2022 11:23:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOhEu-0005pT-Dv; Thu, 18 Aug 2022 11:15:22 -0400 Received: from mail-eopbgr60114.outbound.protection.outlook.com ([40.107.6.114]:10693 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 1oOhEr-000726-1m; Thu, 18 Aug 2022 11:15:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ga/Bf/2q8LV+skMbTrq8cslEL0IzKzGP5lSub/uLiouRUYvBK5GHo4E98/OPpUgzzD8HV1Hu61dJ71AbHYMVITCd1PwnGdrrP8t4+3VqtLpHdc1R9qu+V6I+LstgYJQ36+uWNVCWEffJWZYxj89RFwshvEfxPLVyy2WZK0/W+AqJsY6GF2eveY4sn3bnn8GhDtuxm6tlomNf7NWtSD0XejE1BbC9yoSjxEC+uES3hgsYzUi76bGWqz0MiY+k8MSaUyrxwM4zKQ0lQRwfbzDPqPcOgpwVRnI8nFBz2t4R81A320CQ12UIbtlrRqhmFJsT63yFUP/5XzZRkIoTFFValQ== 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=UCoHrF5ZQlZn/u8sCfQKIc5seuWTtcxwjp35H8WVCkM=; b=Na8wfngIwcc5lsPcj1cjVpTt5InLT8UrUGWDw12FSR4ORo2nhF9D51s/JmwSgGNE1F1g+/i7W4bli12nOJQcpcbHJ51l9nl/ms2aE7MSxov8min51xDthAgRV8CsSrwd21Y2hSqqPvlJ02xiaFcrMwv3OSpAAhefC8u8mCjZtz6XYNF5mrElAlOhiYWOKxzC3r73eIzdC+ZXqU0Y1eckge/R01d+BGcGMArfaOnTv4eSFLqEEOFE0zfq6fpzyH10zja2tABu6K5zDo1Abxfctnp+iP7wCTC7prdgu6NuQWCxXVu2GNnjHVestGW0Qwblm1E7xeifuPTBBNTdLSRFMg== 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=UCoHrF5ZQlZn/u8sCfQKIc5seuWTtcxwjp35H8WVCkM=; b=arlzI5JPv+hMycwoTZvtdqYXHV+Ry8G+ml7EJkc2idhYuenSxwX/yjqTMi6ripN0itSnF8nl1teGDFxd+xVVM/Xv5TR/QmnakP/8jekAZ3ay/hFvGWljlnzvf95tFgqCX+r/Cf8x3QhFr5cXC9K2A1+5vXYLzS7/9uuwiL8lVHYYr6J73LaBJKuTqf3ZxwESmTj6/3IYPxjDWL60MS1T/TCiuIzAbNMWJvDtbfbaYabZ4hE7EMvpMQoo2jQ33fAU8R+CwKOI/gfQM64Tkt+eONoHot/KHZroMA0wzSyKbawQkTmovd2T7+IRUZjfTLCzHItUrYfkd8+1U2NgR8cxSQ== 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 AM6PR08MB3335.eurprd08.prod.outlook.com (2603:10a6:209:4c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Thu, 18 Aug 2022 15:15:12 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%7]) with mapi id 15.20.5546.016; Thu, 18 Aug 2022 15:15:11 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 8/9] parallels: Move statistic collection to a separate function Date: Thu, 18 Aug 2022 17:14:55 +0200 Message-Id: <20220818151456.2118470-9-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> References: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0092.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::13) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 27c68329-928e-4131-a576-08da812c71f6 X-MS-TrafficTypeDiagnostic: AM6PR08MB3335:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OzWw+XFcHwRZTF4K1+thc+ShnCZiuKAUmumBMzbcv8ecsPLFiBr80OzN3FneOI79I+fRzJ1OXQlFL7KSyOGz8WijigEmHuoMiEHG8Mft1ocjeIxp65wOzWgxXmH1gClXIFVIWDGBW4G2IyeHWIiKZozb0vzzkxHpT2bE8vMruqo40AFoN8Lc7T9kXcwZHLcCMx3u8fvK88N92jPD8NW94xdT9e3Y0h3RipFdctBR29kgdSL72udDAuQxjAxtSAuyZ4JcLke8y3DBk+xUNGMdP3pv5nGiws8mcTD5EtmVPWPu2jz+lnaz0Dr61oM7RgkTww2JiN+KFeb8H6xPadvrNY5saz1J/qK/QqkCEnP2Uc8JTvVbW7IRXbo1tKaRc9QEiOWWlhz6uEpRw6B9Bg/hNoFbwXwH8rJJ3so8BIMcRvBFqMcE0z7v0XpQUC+bMOE6FSK4dsRYsUP6CBhGwfqYZ3gRENmkMJZoyMtFSgUhv3nKsgB9dbTNFRfcAPTQ6qI8jndxUJgTEgjvCjzi1MPR83wICYRpUvgDwQUKRQmWaejIpb3Hwgyf5NYaFUciEOKK6pbkjc+q5syENFFK4N1dtdj25oU6F3iuDbcRVdXN8IjY5eZk/zDM4lhbQj05DfGfkZYqTI/FjiwVh2Ykz5D+MYH7iqBoLTwbrIWWO4GMhT7s/4Bq7gYQQtv/L7IJm0O9J/uGM5JZiCHjSPhpZ/Y6o7msMa5WYYzEp9VF6gyuc7gpaWx8BNwtRSTyLT6UxNbh6gHOABweGbzTH1/Ea9OeJA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(396003)(39850400004)(366004)(136003)(346002)(26005)(2616005)(186003)(1076003)(6512007)(52116002)(41300700001)(38350700002)(6666004)(316002)(86362001)(478600001)(6506007)(38100700002)(6916009)(4326008)(83380400001)(44832011)(6486002)(5660300002)(66946007)(36756003)(66556008)(8676002)(2906002)(66476007)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nyj3n3+EJY1YmFX4ewvDOQs22fT/kyuwXpQncw6Ylg8Ip/LCx/wvhSOX2UzOW4ekjb7x6iJAt/XI5PZKy3W4OK/S2996lruPPUkPWFNe6QbCYo+lU3CqegZBQ8B1Fj5ncuk8/+gSDq9zXajDfv8BMDXlKjsl0/CjdGvxO5JECzIIhiq3Aagr2T28+oIZCfOTx5KllTuFXa1BNPhCedsRgHk6OLYIJJZez5WH1KBkH1UJQPzXQzzgaCMwjBNw7I0wloJ/RfDki1NNDzfWYTFX3D5jWV1z9i1AV32/zfXG6hHz92H98ZvkcegU5b0ZijrFB8XeZCsgYqZpl1kRnVA89gzSZAeENmZai/GW/DG41Dy/n9eajkm+xferwjtp5KISsC1hrNIwRoJiGuuiSzOD2SpclAn+20h4IaKPbSoTmcMvQrdHTUKllq2dyUC4MVDSzgb1wp7ot3F4YjgG7ZOfeyJtr5179cUyF2GJlY92iytB64P9vN10ndZOIStadBE7ldRhC1INizA31f9TpwjoL7mV+dtHr4ZPRYv6ORfFExwmLjaGezw1nMLmtiesdrcuEpmx1hh1GpIYU/v4oblsAjOBpKLtVjKtCeHqmSN3yt3pxxY+Taf7lH/tfY5uwWeL2Z+6F6t+9zeqmYJIldk+IMJjm8IAWTqjn9oGlvCTAUx1Z6z1GiCQW67k3lvIciE4rYWsw9iow4XHSG0OF5gycRTqpAK0Dw+RylJXkqsrHlq6HyFI3pihkIVAfuGQMjgbzbcSQm71Il3XvjhZJAdEYCSdkmO7egWOTDF/3U4AVwOnkyO3HVd8EHNUdFrefRct+vfojtpDZbYzUXr8uHpVVaoojMgyuy2yIcsC/J0dh5nJZLM/ARIJfegaHRaSRC5Z5Gaogg8dWizij2B/DDByHVQlBZv4+HHReREhGd/dj+Rs16O7WbJ3JgIiYC9yd3M35pLZfwrCZgNU9dWAmZj2vKwOqT5WNLv5tzAWvlz2Fro+Y8atKNlMYxlnqTsTefjYDGvX1Vm0+r4ATwWdvUm1UyRK27XpdZ65pa6TBzHJj2EeoqeKt+5I9vDanTyYtl4Sy30VSt8eWUcWR0x9cwQ3aJmMtw5So1RkccGWdsqWbrj1MalYZKqDUY1QVRHawZAPwy//pImxm2eTm+jAboGp5RlkMZez6v9m8vaggVeSRypwOVYjpVG4scSCq2JXPp7WH+UNtqwkctXOsOSvuoVOQzBf8Mb2ENNAhLHX8FtAwK9liduRSfppbRB2qxnVZ/nPMlA75CUwoErY/43jdDkDaS5alF7munSsumErqaaEKZOpwR0SxYahVCrKCnOOspL4eMi+Ck0pF7sJs6TW4O5M4/hgfSeS04lQAPCxzFD9gRsaHLdwJkFH7pnDv65mkRDkBXWDEGA2AlWZS3KN1SWITIqkrs27XsojGJLmakGF6DI7by+Oog7M9h/UvF5o4DWBzeeSsLxMg+byQqzeW6qs37BBwU8VfQ8AGqv5mA7lU3+dy/oGJGi+Cw7E5f7sW6n1qS8oeiCONFlcv4HCnDOKKK4TrgZZobi2/q0lREWxxMuoh1iAVNJkE4WB6llPVDCtp/oZQOKOqLel2uhU8/wirGX99xG7gtuIEV5X9nY4fwA= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27c68329-928e-4131-a576-08da812c71f6 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 15:15:11.7973 (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: 7Cwu2P7NTutK2DkwHh/ikJmk0pVp3jmc443AsPeltX15SQxPvFJ4LacQZMzweS77I66v3+5VXyVrgWRQdjmwru6HILQUntqg2CYXxMwUtBk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3335 Received-SPF: pass client-ip=40.107.6.114; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- block/parallels.c | 53 +++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 6a5fe8e5b2..f19e86d5d2 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -528,47 +528,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 = 0; + 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 = 0; + + qemu_co_mutex_lock(&s->lock); + + parallels_check_unclean(bs, res, fix); + + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + goto out; + } + + parallels_collect_statistics(bs, res, fix); out: qemu_co_mutex_unlock(&s->lock); From patchwork Thu Aug 18 15:14:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12947311 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 02A58C00140 for ; Thu, 18 Aug 2022 15:28:55 +0000 (UTC) Received: from localhost ([::1]:56258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOhS2-0005Xg-LB for qemu-devel@archiver.kernel.org; Thu, 18 Aug 2022 11:28:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOhEx-0005pf-5a; Thu, 18 Aug 2022 11:15:23 -0400 Received: from mail-eopbgr60114.outbound.protection.outlook.com ([40.107.6.114]:10693 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 1oOhEv-000726-Jl; Thu, 18 Aug 2022 11:15:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hD0kGjnz4ROtoLMAVnsII8O6O7644SXU2GZFs2ZUOQhWma/IbhLepB2dbg+m8nnG6Teu9JbHy0/rX2/KJ8qD5gOrzBRu4uV0qgE76/GRakB+B+WgZW3Fo2ndV2XO/ptJUDsPlpNosj4VfqfPD0KbOa+3MemgUR5wGZZWMa5R0YuABXSQ32nfV537mS/MJUlyOc+0FxF8f8Ai6ThnwyjK0RjiBCCNKHq7wcsBnw23otl9lwg/Nqs4vjr3RBg82DgcSWaNx4qeIPeiLKEqjMXCLH/u5UtHLDVCtS84tLWjmYSS8dqQbyW7yGFlBaup7uPYfhydX2G/Reznz3ytPKf1xw== 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=PJnMNwp/a2PxEmYwg2k03vzzhEm6DFca4Y2NriGGeVc=; b=VK342eto40kh6vC4qz9qGE3AnmC4ehhYOkx9Ws1SVPmwTfvELT+2QMk89qP0eYRbOJ8YCsC12c4OUyyhZpnbbKkAoU8kK8BKmP4vytSyxxiBF+UMTtdD4lHEa2ZsXtoI7haoZ9ZDXuPjnHafvOMoFGDQSv0UiczXoTiS1WtIWHkLkMBwjqRxffpdDj21rELvBvNEtOyiIf4EcEfhlII5fIoLQ9BYLs5xuxgTByKOrBrbzMPdS7fa/Yk4iJud1hBU2U/IITojxTgh4e0XVsQQEBNa4GAx5ch1pKdWRfE/POyC0esVbEBmCXifUFy07NTkis+WvjqfDoDBkuM7zl0VVg== 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=PJnMNwp/a2PxEmYwg2k03vzzhEm6DFca4Y2NriGGeVc=; b=GetfwkCZMExmsnAHC4y74CsMXRKr/bEJ2p6bWj2lCBucUGX9s1slygGBWxFXlMdlm5D+N3KhrYSRe/xY0yAhZeBZ6gqbAs5LamQTUaaBF1cxSMAQ+4apTiZn/+984nqt5MJLixhw/tNpd9+D7rz/lpVlYExd2pNyWdwP2ZJhMw152x8FS6vfCF9VTFux/mkgd8oAZZDIl1WQLHga5h5kvlG9mrJyjMMKfS2NAZ9s+36tMqSRrYKq3qntJ8qKMvZi8ChrNkVg+as1aBANzCQOrdamKEtkOOpiTUmXoQYrElaE1cYXZbDc8d/CSjuFXyKdV0GzPJsyzh/GTnliWRlDuw== 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 AM6PR08MB3335.eurprd08.prod.outlook.com (2603:10a6:209:4c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Thu, 18 Aug 2022 15:15:12 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::7da2:4a5a:2854:26f2%7]) with mapi id 15.20.5546.016; Thu, 18 Aug 2022 15:15:12 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH 9/9] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD Date: Thu, 18 Aug 2022 17:14:56 +0200 Message-Id: <20220818151456.2118470-10-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> References: <20220818151456.2118470-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0092.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::13) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 80c07167-024b-4dd0-7363-08da812c726b X-MS-TrafficTypeDiagnostic: AM6PR08MB3335:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8nvD4kqdh5mbpuYE49gJuN3lAm57w9VxRw0YPfA7Gr6ge3tSXkkddQXgHY/kIOd4L0Xe3XsZ/7PEdHcPTiDGFhtOQb+IBoLVvQZ/7CoJVSgxe1tX0XUPeOTF5IckRc6JK3JCtYQxmolPdhrdpsdwT1X64dTn8cKSEmg48YfbAggFO7TuRrmHttjjSSEchT2Daj/BeE56gQd/m0I7pElS5mkjmjDCIFr211scEBigmQdsUdvdqAjXScz+4J6HEIAjScVJf50nI2Lnr7j/4JpWsfus72pVnTsDsAlzPCBFTTBbt9Kh18rP4iQDQodQMz0TRj1F/JHd5bwkubSOulMA4MrAmvohWQPgE4WfIXDsLSal3/1M3JONrch/aXkBesZZnK86avrvA9Df9rbbms3Nqu6sd8jvoGpQnXZBQvB9SxGFHPVoGaZpFjnRqfTSSz36ObyBWKBPUi0/4ZyxjhwuRl4CHPMMRVc9ysBlLzILb8/K8hrbGP77UWb2vSIHkEtJ9qDMG4OSyCHPq8LwvMYuJA8csNR8qNcEPde+L0fv6/812yMKQmKXeajHjAFmXH2Td8wuWnpz+ADB5cNVu3qe57/OHwVwLgCoqxMfrLYA6PxeIO0L2g2UPiNyUHqmxo73/4sALOIOSeQaKO23F4oUTeGIImeUI3+kdimFcCPMmK3UcIewK92qRam5JZ9ZP7Y157VPZISVRHDL7GiHXnCWVPxTWYeqao3ss3DrhCIuYQ6cM9vuzYNoltuXo76uh/xl59mjJupR/67R5YRQ3alXdg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(396003)(39850400004)(366004)(136003)(346002)(26005)(2616005)(186003)(1076003)(6512007)(52116002)(41300700001)(38350700002)(6666004)(316002)(86362001)(478600001)(6506007)(38100700002)(6916009)(4326008)(83380400001)(44832011)(6486002)(5660300002)(66946007)(36756003)(66556008)(8676002)(2906002)(66476007)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JkjPJQSA0DYwOU7n6m3PXoq6lsNhAgX1UZ1oBQKD+5j29Sl8sLD9ACdETy5knSmCFsHkbP+XkaQNNH/SlP1z+Bz9dMsMXHNSEn8A8FXmpXqvF1HeZKU8ixg3F/A43Kqnhz+iV/7diKk1smMoWWx9ppb7nvKcBdT3mg/+MAvn+gRHzTSqw3ur6E2L9/f+33NuiQ3r/OPcSdbvCgaIE2I+AVh/ud8FGOmqKOp2WhJYmjaBI+LLVe1Mi/O/CYjMdqgEs3DV/MwVcm0+9aoFBFe50EiBxDLLZp8A3BewySd7xXjfWeKsbudRFimMuUCtTXBIXeRaDN99RUK+0zoUlWU+VjM73vUBpR2ehfNUZMlA3rUcPO1LMmSHbSANfxOd/Vw11X8E8Po6aD+3Pou/UApJ35vJtYD0h4QldR8vr9U+U3xsr5zebCkvEegiWscVVI44TmeaPD+fu0DGK/jtmqCQGaB4+DoW6rTxIatpD7cGN0y7zLMb/ErYnt1/1WVgxtF1+rFJgFfj2Qe3//mheTangp7S8QoaXW/2Jk8qgHVByBlN5P0UrVFB6o2a8qXtBkWm1/eA3RCufmr9fIz2jwOZ5moAj9suUGclEwbqW5bRZlIAnsLbnlQrvoUMyo4ZrOpl61yO+WhWzlvPMZS8bqM6UFINQesrP450S5PEkHJltWI+Q/jfDqpR2ue1YHb4I+WPTuc7rfYux1yHKecqQ2+uCTnTeva8ywUIvJINbely5yxktLPJn7uyca1pnGCpnC4MOAFtCWuYz6eEhWdKyHGEYA/pPv0A1Ejt+Bk/DARGFqKFOsV7dMtoyTzpcXcxZcAIMbxAEtgvnjcW1pXv3tYLXTs39dI2No+A7KuFrrPCCjAW/jujsFNmblgwuOw7OVKmHqC1ASn3jd0LRqQ945uc3wb5hebVk3onA61+n6EB0N3nW7ROo+Cm/lZhtT5EWThBTFa2zLUpZybgy6T94qCYn+1KoR3QS0S9lojth2sM0tu85e/RJu47+ut9JuYD9RPuq4100aluQyJcznqJ1t5kqRt8IT3313goUhrQJGddwUzXbLZnJGZJWLoNqh8XM24ZE3+Wv9ooC3zMuYWAYIPW2oYun8KPbL+KgjqlMRUYCt5PRzLUcwqQ6gRrJHO4EZL8M9DX/ze3Ko8E6aDY438ldANFTzOspqOjVmJxwCATBQkJFPwxSHamYb0nez3lO5/BRBM8xQugx36QL7FqeK3Qdy1Xbrz3sk4eMYo+6GqCCsNN/ha85qFMCW06H8wmshFGwjthV7ktThA7VLIPhgotyRpdtPeeosaTtvVj6F0pXvh7+TriOZ3XXGX1EruGgEjcJphqbURLUFYltSfD923gvzW90XBPK7ufMp1gWI451Sqyu8e/oy+2WGsMwlVer7aQLZqRv6SiwPnBUW8h/JBf692SSS/wxy64UmaWDmcNPOTfZkN9TnJTXjo+9QRDqJ0RExms1rbAzgNSoByK1u9l4UrBjhFRlSBXspOWEaFtofoN/NQkTODpUcpOyKYvmJZFMQHG3PDQ/HF6XjuJ/gZnAkqP+WhoCehsJ6cdHmc3/kdDmQia+DotzoQVxeYlfWzzwrRzN78FwIiTY3BkgWDdeMyK1rwnotcTBWChyPom9F0= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80c07167-024b-4dd0-7363-08da812c726b X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 15:15:12.5473 (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: M13+DB8wdgHgPdloQtjUk8/H9A9aeqOCv8W7ThnxENIRCJ9K8RY7bs8gLYpVbjJHjJdHVWEUW/k5Qc9ugeSPAG9S59itkNDJo/YQIAjNQls= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3335 Received-SPF: pass client-ip=40.107.6.114; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Replace the way we use mutex in parallels_co_check() for simplier and less error prone code. Signed-off-by: Alexander Ivanov --- block/parallels.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index f19e86d5d2..173c5d3721 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -563,24 +563,22 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, BDRVParallelsState *s = bs->opaque; int ret = 0; - qemu_co_mutex_lock(&s->lock); + WITH_QEMU_LOCK_GUARD(&s->lock) { + parallels_check_unclean(bs, res, fix); - parallels_check_unclean(bs, res, fix); + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + return ret; + } - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } - - ret = parallels_check_leak(bs, res, fix); - if (ret < 0) { - goto out; - } + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + return ret; + } - parallels_collect_statistics(bs, res, fix); + parallels_collect_statistics(bs, res, fix); -out: - qemu_co_mutex_unlock(&s->lock); + } if (ret == 0) { ret = bdrv_co_flush(bs);