From patchwork Mon Apr 24 09:16:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221880 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 612F7C7618E for ; Mon, 24 Apr 2023 09:22:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsOP-0006C4-Ti; Mon, 24 Apr 2023 05:21:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsON-0006BE-RU for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:21:51 -0400 Received: from mail-db8eur05on2114.outbound.protection.outlook.com ([40.107.20.114] helo=EUR05-DB8-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 1pqsOM-0004XK-9g for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:21:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JHkROZUqptS8Wvj/CzAgic5jSNb5sNkG8crzA4JPKeiTe5hPsZzXAfqNgOwQqjd/NhvsQv55GgB4g3SeUPDogC2BJnleMn+9hDsZIEbIvnAhqJMFEuo7yeIbVCyVoe08CmfFnyAQZhws+q1Z5Lo+wyzjyuE6VHWYu+LVxhI3CH6oxySAWnB86QDWMxjFYmIHaJSl03FzazM3xCPMexLcir/G/4C0ZOED8n6SCfHW4Tk9SkOEX5BdNS8A5M3azrOmMq/Xrfjk3To2EUJvMbGLutwFQftw3ahNRl5/9n9GmKmnfCrpGvj7CAMK6gExtt1Luex1pDzkq5qyJl33lyXkmg== 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=bXOwa/L67joB3+1DEfpVcK72jpfn9Lr1WBBHTA2x4Wc=; b=MnLsaUq/UeoU2xH/jd9WE1fo1CLnaPvo/xA2Nkh2I3mbbAAmfDukNFRrsTzX7s51YA1slnjOtWhwGT5uSc0ViTF2soNvN1l6dF1beq0aKuiqKwF9bRefcw0Gb22qIjjvANsRw93CcPZM5bBEkxnPlv6QhIpWwAozKSHN8cf0G6CuEEc4r+00/+pr07SXammTa+2Oe546bLrqxj4k64ODZ7nwPdSPfLZGox+QkhqK03Hky9NlHBbisGTRWFYt0VziCCVREzawCkfvu8Ss8vm3h7ekGVZHl6hBuCdpQQzVlA0sasIpTZddMesxoFYoBs+nmOGB1x0ccg1DWv+2TEPplw== 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=bXOwa/L67joB3+1DEfpVcK72jpfn9Lr1WBBHTA2x4Wc=; b=v+eLQ1MuY7T7OwU/8rRl5GruWcXc8KzYOo8oNWeRgEZDRYI2ubZOhbeSJ8AsMJRtU8vdlJ50kiSBWTtLlWQmUfkbnXwj2wSYRJmmOgiWx+W8LWTYr7HttpeNeIBXnKck4uvTg8McKCAYO0Hn+hQy9Ffjerx+CmZYd//5HEU2XA8/KwRArfv5mQYv9hH/qW8ImC4WtU6ofH89mk07qijyfnHw/ins7WP5/H23AZyDbARf9DPcMHwIPtR+YtG+ewIUmgkHvCMURexNK07mwr9ksM55vooU4Y6YMTt999TIq26CZr8ZOm3JgKa6ksfD82h9iL5a975F6vrrgOw8sd4TCQ== 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 DBAPR08MB5832.eurprd08.prod.outlook.com (2603:10a6:10:1a5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:16:43 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:16:43 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: den@virtuozzo.com, michael.roth@amd.com, kkostiuk@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v11 01/12] parallels: Out of image offset in BAT leads to image inflation Date: Mon, 24 Apr 2023 11:16:15 +0200 Message-Id: <20230424091626.195590-2-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> References: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0008.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::18) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DBAPR08MB5832:EE_ X-MS-Office365-Filtering-Correlation-Id: 002ba3c5-4853-4916-1588-08db44a49cbe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t21mQyVUIbsP0zv+U3cwmwxhoY5r7CFyw8F/wQqKG7hQCRC9HyvfYRgjeB9DvQ8kI9LVK1gxt06tlS9zOeUBxvFuI2uyINLnTXhXtnlRYiKEkHsrQW8HkzxTJ/auGTN8FaqmBxYHA0SXrSOzLTo0o9xKK1e2UYkNrf4fSVtQnIDe+uaK9nEqxiyWo4doLS+JrTvkKNuFYdk3XgynL9CuD4b390iPRgP/EvU5WPqVuQlKi/oVTTjIstoGnOP9GjyDiuyPwvkZ45Uoum3Cm65x+ydsk16cJ8Ea4+TwZHdk/ewIoGHrqLnT2AmDVX0PqEUyZDt/3+ib85gq7EMupQajFT5uQi0njw/L/btgFqSlmamiMnqMdBN2G9m15UCsHA8zh7gmtS3rY7TfqocKsq7BQYJicm+2rYTuJZPxUMdBkUuhS3Jh6Ah4QZlPaj/iJhRAPdwTn09GpmrIPdc7YHk0wI2Ey1tXP0IIoOpkeDyTTfH8BFIUNQVItRw+NSpC0rOqPYKz5wUp6ghAAr61T63k7aPsmFliW82uqq9z2By6fTCrIHYneG2nrI0/I1nH+oDodgsT97Grq+NI2YmkKeGbKeA5QVa07S/pPyLkpIQJrJR/u0bIP/y1PowZ/veIWvJ4 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:(13230028)(4636009)(376002)(346002)(136003)(39840400004)(396003)(366004)(451199021)(5660300002)(44832011)(2616005)(86362001)(83380400001)(186003)(6512007)(6506007)(26005)(1076003)(38100700002)(38350700002)(8936002)(8676002)(478600001)(316002)(6666004)(6486002)(52116002)(41300700001)(36756003)(4326008)(66476007)(66556008)(66946007)(6916009)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: auK8238dAOo3KBbjxPZ4p92OcqV8t59WhN9gfxmJi+IkMXxcCaw700E35wtPFq/7ElfXkWI1gZKjf3oizc6D3TmulGhsOYSUJ859eLXpxc534hSJlxm27gO+804MtTyQ63VB2wDh8Zt/cDqaCBAXcq5+9Hy3GW5gy+zW/BXs1+6LG3neEJ7HgIADnwBjwzRwAJ9yro8+NECuAgfdtk4QMHCLrCgJb17MVrnf6qckog+vZM6nfk5Clm7cM97QtQg9pZ7p39eNNz+ZuzYHfrVPAnMd7ARyYc78fQn5/kDiL5hOJDuPDOlzZoMXcZFLvxm0mC3EYyNESbUwiOcEVjlZ7Qp3qqyWyiILJkJNxYXqxY+xM97T1tku4pFKbb5AwUsyHQfh2KdM75On13PqHcAYiIIYCCoJnmRbwKoa0XzXd/dsniv6V04iyQUI5esIiEtRWMF8iPgN48UxYUjwUTZAZ3Cpld//XH/ANJp2PKbBrYEq5Wi0IceGqI8/i6RKjashYwUuJVBxxuyff2vxV7I4hnqPBe9FYG6sasYpTTXpM/OzqBfYqNq9xjGPp9Gi75bd6Z/fhr4MM1GypEyC/ek3hpIC3M/aX3oaG0gJwIoxfWLusZUAKBuvwHu/7U6S2bLIt1RqNS0h535l6xgqyNUhREdRlOLF3PBSvwL01kDHxei6tHj8va82HLddMrxp1peFryeF0cLYoflX6qRgn789v9kF3YYYknYYA1V65C2ysfz3STPTViJlPLbnuxAeARF9iqyRJLBK0ADp2sgAOuRElMJSFoFzrNuSsH4CiDotqDnd9RR12Tmc0iOt44ZMISfqOVAW0ZMtnXIaK56GKHc3XrRKH5qAuB6Qg4pKsQHEIJSz3WYgLawOCFWqErGYw8E0Q5WPmuqSO4FjWlgBvl0xq+wuSWe5diUT9CAtl4kHsxDxL/Wc6aXuc/MHK+g/VSZT2B66X8I8nuxOzwh5MKzCxdtzWPJ7aSrtx6acBjc+Cfw1vvJ1MWj98G3rU4dnAaqRc0xuQJ4rcBQbPhbLrqzK6sd6r+3Ys7X/74v+4u+Dhzco/8koQ/XJAc9l7atZ7ggIwKWwmc0vfyqXq4chOqqjsEyLiKHDj45vYa2kLh2MNAbjN26rJDkpoVddEiDUP42grtC9vRiFws5EI9fdY5ibFbE/Oa0Tgd0FDzhE43Gf8bT/696v2Ox5iBBusFbaQaRMY5ISUFlCrLzwSStxcA5O5aNO3qUkL8t0IgACZc1NY6cniJ8s9nnEkH/qOh35pkL8Mvfp7vRZF5J6sLzWO+Jw+pQUZ8IOlqR0HDaLGNkMVPDvAZ1/g4MPivSuxr5385zr0T5RaSAUE3/581namQYWJ02DRkYht30zYQVA5JNNtxg9SvNQ0w5g7geJzh1YQ0GOE0FmqpkwSVlxjLsXeqgG0ytCQNxoZUXsGWtplnlBjrK+DOPZos8WiMQwlknx/u1bb6DWQa/25/R84eDAMqHhlS4cHSEVEGtMAoQRoYzR6EnhjcF44cjcC013QxFEmuWpVZBy9Ea3t9/DsmeD+iIbXRBKNJFT8kqr2qVmu+ZjLiCeLl66PcGwUJBh/qfs3DB+gvJuqtmEndW5j9ZHG7CrEA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 002ba3c5-4853-4916-1588-08db44a49cbe X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:16:39.9155 (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: 8npTYyVvsJ2fNJi/UOWw847pDlJNNTirfZuRveEBgwcKuxgAmjPOS62W0uJe/ZSEzAMIG8nywCZ8vcuw2524fIM51DNipMrKS+9KUQR3XAI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5832 Received-SPF: pass client-ip=40.107.20.114; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-DB8-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-bounces+qemu-devel=archiver.kernel.org@nongnu.org data_end field in BDRVParallelsState is set to the biggest offset present in BAT. If this offset is outside of the image, any further write will create the cluster at this offset and/or the image will be truncated to this offset on close. This is definitely not correct. Raise an error in parallels_open() if data_end points outside the image and it is not a check (let the check to repaire the image). Set data_end to the end of the cluster with the last correct offset. Signed-off-by: Alexander Ivanov --- block/parallels.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index 013684801a..7e563062eb 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -733,6 +733,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, BDRVParallelsState *s = bs->opaque; ParallelsHeader ph; int ret, size, i; + int64_t file_nb_sectors; QemuOpts *opts = NULL; Error *local_err = NULL; char *buf; @@ -742,6 +743,11 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, return ret; } + file_nb_sectors = bdrv_nb_sectors(bs->file->bs); + if (file_nb_sectors < 0) { + return -EINVAL; + } + ret = bdrv_pread(bs->file, 0, sizeof(ph), &ph, 0); if (ret < 0) { goto fail; @@ -806,6 +812,17 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, for (i = 0; i < s->bat_size; i++) { int64_t off = bat2sect(s, i); + if (off >= file_nb_sectors) { + if (flags & BDRV_O_CHECK) { + continue; + } + error_setg(errp, "parallels: Offset %" PRIi64 " in BAT[%d] entry " + "is larger than file size (%" PRIi64 ")", + off << BDRV_SECTOR_BITS, i, + file_nb_sectors << BDRV_SECTOR_BITS); + ret = -EINVAL; + goto fail; + } if (off >= s->data_end) { s->data_end = off + s->tracks; } From patchwork Mon Apr 24 09:16:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221869 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 20C76C77B61 for ; Mon, 24 Apr 2023 09:18:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsK4-0006Pr-9m; Mon, 24 Apr 2023 05:17:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsK0-0006Pf-MT for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:17:20 -0400 Received: from mail-dbaeur03on2071b.outbound.protection.outlook.com ([2a01:111:f400:fe1a::71b] helo=EUR03-DBA-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 1pqsJy-00035C-Rp for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:17:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dm0D+Js6Xm50vTg8DpJa8fnORnO6NgAtgRnHLNL0DrtplxmKlMa7FWTzxta3m5om9Tv+XXlHa9ie64HZaBJXrB/u96JgIohb8CZ+t7kX50+SCL5uJr6/eCXj3apXczHcGcNisEUp1O90F4OYCl3InFjHJNtot3FBF7O8A7PmYWyJIYDF34pEcOTfsoBkvgqHE+vhaaKRkFHCge54gKoyneZObJSyPzG4c27hNr/DpenB6S88Z9/6IKOFcRRjZ0EjBMO47GvPV7VyXF+xfTZWTbFDiEYNxaF5JvcF9jPJraHMg7LB34ymnpDnWjuBQ3s4DuK4RKLZZAYKVBgecZSBJQ== 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=JtEFLY65U+CF++IiOCt2WtqxvIgTt86j6zZCeu6sYcs=; b=b1UNLkYK23KXesdOMMKTA0AzF1b76wwtgUuWzmfDksrgbq83XU8QlHYF50J54857rjEzFgXbEb1DPkoDuW1GS8YhG9jjthAgmQkYtWT6qEyMmULGQUf6KTlWrbiQ7i3s973KCj51LyASxtH8ek1vHQ26PTeZehFPaOEf2A8LxsZPRaTCNHwPvARScTl1k9KGrPbDuwixcPKId/7EySgZzOwuOGdBoGARUScClDaq1wbuahpGzCiPMa5HqPed26VIWUHAK+ZNh69/Lzd2pkua/r70R+9PoupSIK1yE5OXNzcADUmxhqpyDIWt73tg/uIJ9hDpwA9Mqg8khw2t4wSFXw== 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=JtEFLY65U+CF++IiOCt2WtqxvIgTt86j6zZCeu6sYcs=; b=jsgTcE2tlTcm82WmDzROjdDEXkOh+/5V6JP+4rSlj6H/jkFNnoFXXRO4yzik9g9ce+jg8ZyFCvNntB3vKNHloT+Ku5XV1PmSnvq4i7ivXhmhgk90l5cwWRHnqnKxuF5vS78wcku9j46/O9xvIyrQJr3+mnIL4sNNN/bifdFDcE5XaxDIV9iGNx9w0TUc5AlAe8QxLm6I3wnVfaU9Wizo1INd3zmEqdMNns67GaatnhMxXGHHPkShle1NHE40WyR+iLJlLoW+B2QEYlWntMVxKdcTA6Gj9+4r315mWhDZN39t+4P7r+z5ldWlQybJhc3UbjTbgaYlSycErZf/jjhUCQ== 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 DBAPR08MB5832.eurprd08.prod.outlook.com (2603:10a6:10:1a5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:16:44 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:16:44 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: den@virtuozzo.com, michael.roth@amd.com, kkostiuk@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v11 02/12] parallels: Fix high_off calculation in parallels_co_check() Date: Mon, 24 Apr 2023 11:16:16 +0200 Message-Id: <20230424091626.195590-3-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> References: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0008.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::18) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DBAPR08MB5832:EE_ X-MS-Office365-Filtering-Correlation-Id: ef42d7bc-69c5-4636-8b29-08db44a49d81 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lB/+Hn+VorWG4h0oQ6TUgFD74LkFfJds25tefD/p3CELf2ACr2BYpV0bUnCSC1+VKEznkJ6J68RGhXPSDqk7S3BKqCAxg+JRXT/YV7qlT0tkEYS2xi9/hMCezBFJ1bEObSUL9KeJ8dqHUhKse/iQldwZt39R5uZ/t6O2Wz1+4bsu4IyCl2c1M0ZjqaU7eN9fCjMB6NVecGECbXAup4EPYlN0nHwi2/f1lEfEIyCJGEJ/X17zGuWiXlLYCnndFsPjbHE/uk05AAy4QZbnN8FY9VD4jr9GvEh/vICLU/rAsGoXHk2V6gKUAIi/In/2mInyI9ZHRdT4V1Jx2euQurrpJuE/EK49tEGaJnvIF066lkLrELkugCD0O1U7ZUe5dzlHDHEqWgh5Wy/o6rlYq2QkrU/du1GrRYm153V4Sohm6bG5brci2qu5QoUtgDKmjxvTIRglSwWU9DtT+Ajl6jP9jvJT6FZnkDAq2Wy85SEkmpXxIrxrEBB8m2lO+gIhZXnQ4sjT0tE6GhQ4HL/EiptNFEZomCiwrE18823mlrunqwcDJibYR1f6AG9kGRTb3Jv/6lHEZkcvh95YtHqanaODzdpJYaSvcsnSxPOFfxAlGxvr/hytngywBTISj8QOH3Gh 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:(13230028)(4636009)(376002)(346002)(136003)(39840400004)(396003)(366004)(451199021)(5660300002)(44832011)(2616005)(86362001)(83380400001)(186003)(6512007)(6506007)(26005)(1076003)(38100700002)(38350700002)(8936002)(8676002)(478600001)(316002)(6666004)(6486002)(52116002)(41300700001)(36756003)(4326008)(66476007)(66556008)(66946007)(6916009)(2906002)(4744005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YNIhRrkV46EK7gpTaktpHvlVwui7IUMINclupjziN+VMGY1an6tNNhg9SPLkgwGmEgyHLRrqdOtjHVGUsfWoJBKdLABWl1f2yGkdU0SXpi6qU0ABtxoOZLQfv9CPBrCBj/dZ+qKT/asbc327st0jNBi+TV/1nFCjPtU83H39Zt1xl+IC0H4rAmAi6pImWz/PPILF+BR6As+y23kXbjca9flvzGsSuAo1nl59J4eSCQ5qc62fFt2MbWnp3ygD/3o/GkhatHkgzXf0G60ZM8LTw0nQJdNV0Ua3EIq4XGJoiLDoPhZ/a+i/O5hhZ+Xerxs+Q0mnLgDYuha8o/r4VUEg/WXtOR2nmlpO/UA3wWNB1W11Vr0vEOd7TD34f1wyiZl9XXpUTJgrpXPhBAIy7XfFHETi6xEifqv+X8pNBPNAtRDRxyljGveYwJvFyQ0J+8u+pT9TXaH4vpmzv6CHI2StxySWQtAjUuGZOgSC21GPuXNp+I1o3s3LWt8Inb/3LQLPUIbj/v7S4NNTnEtrdvCLXFGN4Im3n3rB3mITINbWFD320lrr9/xdxFdCpXKHupihzCELKwXQYWh5BOR8uoPK6WcRpOB29GJPJzy0+G9tIV5nm5ln/cOj63dtULbAAAGCuL5Wvr/GkXA4W12O3umTttekm/b+m4rukyS2lDA0ljqGHWKdoS5npkvRQXj+JqKBMbYy8PEVSv7b0mDjFfWREqP8sJ/KUn6krvyC1WRFhKFCRgyTPk9ZpleA5D3Xdrl6YH3wwatp2xmoaJSG2G13P9pdgDvnnw2G60mtVFWnImUNmG7GnXFkaKZbDBv3A+hL/3aaztyzSbmDgBJzMhXGHSccsAYfNoUIirNvzX+B1kVF9aahKDSD2xFQiTcwrow41o8AbC96/0E9W5/Ow1rrGXqgRLg5h0Z0aikDhxCpv0Bk+odZNsppZTYjEU/xEVvOXpVbV97sAxYixwVouDLbcJEwpifLb9fQoeG79TsHNUZ8n7nyYatimnaGJWM9E9bF+OrEBXUrGqd0UQLNPm4KRkn9RpO7AIdjf/ngA+y06Y1byRhuXK2NC09+sYJtOtQwPAAym7fjBpknvCI4MGS+LELf/QlI3U82N2ZWlzmVEIx6zFagSVO1fmPtvW6VtiLz9s3YPl43qMq9229OY8kz40WfM6HVpcix8PH48Jg9i2sUtWC/O6rp+w9H1h4RstNbUtX2FauWds8odcFYeVUgq4pZDplhEyZdkAY1TgaPISjiUUp9RQR7HFlEobPWfgPwNrzE1kSUjaA9OjKIn7ZsBI4KSNT4qfw4lCVSsQVAR1sGYN294cOCUgSo4H90YFHLv/qzKWhYHwtlxNNpExdwGkf/qMoWgCP9GLTLMiwoHW7RSGRWG1Jby9WN//ahwCGVA4SOvCN5apJcrW4ndwpN5+BzXt3FS6i0dWbVCxIYLY2P0a6oD+g3H5oW7nrm+Jz4fD3nKMmrZOvaSW86QJ1fIEhnhrnyVlzQ5kK2GpyW/EPBjg0FEbwYcx9oYxb6FY3MZ0yXh3tV7PtboAI91Tt8HXAFvrG0p5c269kTHsRTccrQBOh+HLNtTpLXg0cCBv4tqNZqPyIkAoYQBgPCSpRSGw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef42d7bc-69c5-4636-8b29-08db44a49d81 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:16:41.3857 (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: U+ITSW0edtwKLagThMzlowr5+K9Ddh/Ju9yfcvGbubuu6NrQ6o9dcezlc9LZVEKKP/r1PikFtXwl3q0j30TI+4nDjBq3dzz9jmv0ZW/ooJU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5832 Received-SPF: pass client-ip=2a01:111:f400:fe1a::71b; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR03-DBA-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, SPF_HELO_NONE=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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Don't let high_off be more than the file size even if we don't fix the image. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 7e563062eb..4d6284a314 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -462,12 +462,12 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++; if (fix & BDRV_FIX_ERRORS) { - prev_off = 0; s->bat_bitmap[i] = 0; res->corruptions_fixed++; flush_bat = true; - continue; } + prev_off = 0; + continue; } res->bfi.allocated_clusters++; From patchwork Mon Apr 24 09:16:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221871 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 E2A69C77B61 for ; Mon, 24 Apr 2023 09:19:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsKV-0006gG-Tl; Mon, 24 Apr 2023 05:17:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsK4-0006Q9-MU for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:17:26 -0400 Received: from mail-dbaeur03on2071b.outbound.protection.outlook.com ([2a01:111:f400:fe1a::71b] helo=EUR03-DBA-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 1pqsK2-00035C-PO for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:17:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Syj8fH/WLulPk6OpEi94sTZZmtH9hDHdzFANezdFvB1e+7rQsPVzNCTT8kFW8hQ3jqllc08alOrdISe6mwAov82yqTlCtCoNArlbiA4JTXphGY3pRqpeLGTQHwt/ukOCMg/o49en7orMw3R+Mg6Q72yuVTikZ3fgNA/3/8on2oJW2LimpwRCct5aKiJUlWZGymxYgGxkiCRq7RR+4ry1+v7tOYO30LNuJd90GG8W//jZxZV7GM7Q39+dl45dBu/hUVZYYw5MYGOZe3E2ke21awnALWjuCHIr7PrSGbjLIjEnqLTFNXXhLm9xWOKflLok5jC86d6VsZNVrxLwt7wofw== 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=zT8W6VkfskeNZk+bb6qA74Z5tZiFUW3i0tPgZQDqOfY=; b=DNFDJMi6nIhPtGHrw7c2EC5zeWR8xjfC+AOgxnuwsp4yebww1rGIIi6Lg844ZShK9maghgZxYNlQrSiWHhVY2PQ+BChojb4hZBX4o9s6gDigODAtdstrU2n9oQfarHful9Nzu4diipfui0YSoO7yjIRwIGtyGgz7XpayjwBJhognWeLpz4z5ne55Dfw4wxvBXlXLuqWEqAFKv1hBZDntTzJIjPQe7bJN1yNTYeth1rfluKnzVp98BDrsaTlcsZatlZdC4BAyJb2I1uYAzVqWbyCfo7r1f86jWTwhTEqWDN0qSNd5D18OVUmV4xdasZ1KhpBvXbNA5CTJNPCKysVFtQ== 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=zT8W6VkfskeNZk+bb6qA74Z5tZiFUW3i0tPgZQDqOfY=; b=ywaZTggiFKx4N+VRRaWTgScQvvDI3tHQtW3NjBg1VLl7HZyOWXEweQILXPtJJBasD5wz6Rr5vWGInk//wBhJMjPz9JjDuNl1IK65sVjOy1haop6qqplLKiPP6nM8ujRDfBeFDCCJA62HjxMPNcwmBySdqCBTzWprj824Jt+V8TsB/psLcEVVicLuqjYBdTHIvVA7zpFS5jG6WqqF//vp8XWoBLPzV06UCaYmZtFqg8AU0NtX4rMKERsnOWGzFjQxjq8Iizhw3uYqO9KCuW56Y/Nnbkcg6jCoN90HMlwGuZWVSvkhz7cxjUbSWkwisjU05uOZoJgI7bDgC3X2mkPgKQ== 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 DBAPR08MB5832.eurprd08.prod.outlook.com (2603:10a6:10:1a5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:16:44 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:16:44 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: den@virtuozzo.com, michael.roth@amd.com, kkostiuk@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v11 03/12] parallels: Fix image_end_offset and data_end after out-of-image check Date: Mon, 24 Apr 2023 11:16:17 +0200 Message-Id: <20230424091626.195590-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> References: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0008.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::18) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DBAPR08MB5832:EE_ X-MS-Office365-Filtering-Correlation-Id: 56824d51-f826-47c1-17c1-08db44a49e39 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0vUt79JB4L+5201f964HlJyamdCrUH5vJNF4sbvsqKp18ORpx0wKjzJxTvB8NiKqkenLpkKOkte/OI2d5hX2sWIns2ivaw49HgdWAnhqdE0oOsGf8Yst3gcUBLdkbQC8G3abLIltuYLPMl1CbVUnuihDVQmx5liflZzBIVcXwJUOW4B083nT+EyNHAA2giwmJ7RZWKhGgkUb91K5av7PFp9MRFzWFE2dmWISd5u6GdmQ7s//1s2njaMrBakFfTcaXNU5UUoqq7puw7En/bm0gPofIaYfGFY86GwlKjxHT/8AUgPU2Wmm4AldkjpH7r4LbMzVbxeoy1exmzUp70Kg98q4+RPEkCxQWxs9zihwTUuU7kKtYrGKyoNsirOBmPwkJ7xmVsx4mTh+K8Pju+HMDn/JWRrB4OLq9R4OIwJ0EhWfCuPTvZL13J5/+BuaIIHbDzO39jRp8dJVrvhKnf+F2Zn9FHwSb67JLkFzJVAEZQJWFn3qwAmdFix14zW1e7uMGa8zhjElXrgitvQLNLy4nvuoLbjtMEQ9y2sIgJmtdjn1k7k3O8Js9dZSOBVryIlnJT11h6YBRxDrdxCdSvWhHwwW5v5yB/HDhW4yX/eQ9xZU0ITk+X1EzzBaAs23y1+0 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:(13230028)(4636009)(376002)(346002)(136003)(39840400004)(396003)(366004)(451199021)(5660300002)(44832011)(2616005)(86362001)(83380400001)(186003)(6512007)(6506007)(26005)(1076003)(38100700002)(38350700002)(8936002)(8676002)(478600001)(316002)(6666004)(6486002)(52116002)(41300700001)(36756003)(4326008)(66476007)(66556008)(66946007)(6916009)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QTfHOCkTtzjiYtWtw1vr/KHA4qYslfGo0xwxJ3czTzcFWx+RJEJAalpvnFbSq5Xbk76KQDyZx8fJEyat7pDl0bB352HD9axEVny3OOZvyPa9vcYg5og7kZjOqxKjF/U4CVmQOzhyJSF5pwgaGK1o5Fm3a3U/HzXC5iG7S1blCBqqGSUfcm3TDsBea/Q7gSVxGfPGJo+P0LFZdBLSh6Rxxyh6qA1WyRCGkPMMCkMVS67LNaG3mfEt0GRDIEqd8xQAulUN8CX3SGtj9oF0EkQ1rWjaL4LOatfDStfzcR80Y05Gw882WMNr8RugT/tLNMuv+CdMpyfmVnJa1tTm84WYmHFLRNpCFuzDHdQOCF+G6DNTeo39fYQEgTXXdH6bzmoH9e3jU58NSI7NKp3/tuxt2FAtGEPc+YC0x57kFMFFo7NfIrKRzw7Xc4LtjnowOrFPwWtKfBQ1zkne+ZS/dxW+l0+80XPpeFNf8sjdqi7Od+mAGAz5d1vEkBF40mHOLxurWAs42ZdnTW/rdezXKSWe6qOqVtS3hGWcEnyMuIenyn34sGvg6kE7glN02RWS1gDGmlHENDLAkLjLbZEimRa8Is6Pmvr5bnXCzN8PedXmLVzyP96yc3wCCXiP9Z3ECWOcIYmmvWXk6Kb9jkaEvBi3a6v55kljfreCsCWwGTgQfee6yz6E0mwJgEu7QC56+6VdrlTmdG9j9YNY/ghb1dr+C6X1n4zY5ycA53NKu/ExhGl8xbXprpTd7/6bGdzbJToLIrgCsTVNFf3l5X0T0ZL3D5VaGd2vhdHCFz7Ncn6jZGU1zjDF4L5gW4ujZWs7q8RyF0vpOkDR52cXzfbh7+R5DLMLJnnljOVT0/QbrDFRBHPVf/pBQNpJdhGGa6IIboukX3U4vM26cpfHEdvoVNT63VN/PJW6higOinT3GRehRPixZXdVElOYrn1dfl7zBuuMhijdWlwdo1DQy+shyQv0IrYbHesZZFPjo2eg5PF5SOipb8GPEn/y98QJK2YU1io1bJN2M8+/C3JlP/eqtUXhp5nGYUfR8CNthIVTASMjg5qvShkV2yJ48lUZ4QKL8+VV13j303qJ/QM0+c+ZBzU/C0n8zMoAN8FITqDquVAuU41vCWNx77hyWt4j0kOE/W3DYTuBXey009961b2DTLngFi3xvYU9C5Kty+X87qq0Z+8/HM3+GohaFTM7YiAHnPGT9Q/JGWeXtz9rHga4dP4zOL1ut/qf1R2p1pC3HIUPeTQLhdbCCYrZDL7vRYf0JmHrT1eaRpHCKSq6lB3Cqv0Elqyr/LVUbUrtOB6dJL2jHzoxwavB7zItIFysJy/UA2Vp+d+TbuHTuRMwPe319KInZ8Pxxpg5KmnRA3S2keBqUU7N5qQRLP0oDVwLWmuzP/w7uhxvkDyq9WgdVQPBmp7ySOrYg10b9wT1FGWmpum+LUzYl5KCStWiqPedfvL9wXLkyqQHJseimDCjwYSufo1tErJ7H6aFYuhP1p3VKNN2lks9TBzKysg/ITZPCOlnhp+g1B9nfqV2JW32GBRRkgnYciWnPWY9nECtjLKxz+kn15WJq3R8NFXuTOTjPM3Itx1Vcs49rb901qGAZUg9bcnf1w== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56824d51-f826-47c1-17c1-08db44a49e39 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:16:42.8846 (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: o9xnx4b/sOJ6uLQHqp5XgaCODScoWuEWca8VEzkcm66AMyZ9kMUVj1Z0lZq1AlcC4warJkp/x34CamaquclddLJ8wEx0o9S84zFoNeQcB2w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5832 Received-SPF: pass client-ip=2a01:111:f400:fe1a::71b; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR03-DBA-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, SPF_HELO_NONE=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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Set data_end to the end of the last cluster inside the image. In such a way we can be sure that corrupted offsets in the BAT can't affect on the image size. If there are no allocated clusters set image_end_offset by data_end. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index 4d6284a314..dec4fe1f06 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -490,7 +490,13 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, } } - res->image_end_offset = high_off + s->cluster_size; + if (high_off == 0) { + res->image_end_offset = s->data_end << BDRV_SECTOR_BITS; + } else { + res->image_end_offset = high_off + s->cluster_size; + s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; + } + if (size > res->image_end_offset) { int64_t count; count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size); From patchwork Mon Apr 24 09:16:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221872 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 7AC0EC7618E for ; Mon, 24 Apr 2023 09:19:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsKu-000755-1D; Mon, 24 Apr 2023 05:18:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsK7-0006QX-H9 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:17:28 -0400 Received: from mail-dbaeur03on2071b.outbound.protection.outlook.com ([2a01:111:f400:fe1a::71b] helo=EUR03-DBA-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 1pqsK4-00035C-Vn for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:17:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oBZoIZohxl2XxACPo9JqHJy2EHxflicnoBLEcE4huhdNeAZsY6QMX6AIR4unnFv4zHPVuy7bgYTQamFDAhlT5cusD2zDB93ftZc3iHELesSFtDKUNrFv+WU9CAG7u8hRrbAaOxPzO6S4T/2wtHTRgah74y40RCUt5zP2jUmqtOoftKhuh2RqREe8EGXP/rWbegiQcVtVRJyU4MfmzJi9/8sjnF3CBS0f3ZlH6HvYfRcBeIZAZnkUeg6Lu35Lm+ofjnDP2t+G3x+AnkuiEt3GifeHsfDjN9qKWvTnSHSUs3nl48rFOXEAcCrsG8EuCCTm077ujBLB9bTGrDOW81GotQ== 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=4K+8ywx4jiP8ZR36s3ypqHuxr230ENxlQ6+8WzsL5nA=; b=Q1fnao3eGOYFSBjrNxRejiFIiK/wfhGzIY9RLE8qPUgvJVlsr9xoP9z7rZy+IhUrzUdRJdsPXN6krqWs58sbpjuz4oMz9+B9W6R9irDSMI6nAwu40t4LnxRwJo2qhnyShvV+jivSCfV2O7JW4d145a+RYnPF4vCHaFsinrqGExIjyP7WkMMcXgwWtdqtl+pgFxEEDUDM+q6euSWJczbGDYkrEwbmgIZn3jDNqwJgXTh7P9ChEC+yTIcK17WIAUDSkWZQhSjPArKMeCd7petlcr6gyuPuw/qJZOWC29PAC/wWAkTkZ9CdRAkNYkmzC/z+/zRvsrJKcozMd0VZivotQw== 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=4K+8ywx4jiP8ZR36s3ypqHuxr230ENxlQ6+8WzsL5nA=; b=KwjSJNcjjoKp7PeqCeiErPjJWOwj1dzuJpXYevRIihWTIFEa8st8UIl+80Jnv2wcmznLB4rIEoGYTD1Dq+YZ/RixKsDsF7DHr7udJwZAcZ1QRskkvI7HWnfwfLtF+PyaZai3jxz7O+c3Nm/+9ZgYX21TgP7tiS6bKWszk1lPygA1t43q9wG8ziH1IXbhnymAMuV039XKiC0UwFkggKPIFCoRC3UvN3h7BG82Jueo/9gN5vWogooXq53J8uMh8T7VGnp4bpSHWsCohPPCVtdruDJe+GR3Skn6TFvH6dWNKskHnHSGydK7irdRl3Zbxm+XKIXCmLk8tbUbNAI8ZUhcjg== 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 DBAPR08MB5832.eurprd08.prod.outlook.com (2603:10a6:10:1a5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:16:44 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:16:44 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: den@virtuozzo.com, michael.roth@amd.com, kkostiuk@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v11 04/12] parallels: create parallels_set_bat_entry_helper() to assign BAT value Date: Mon, 24 Apr 2023 11:16:18 +0200 Message-Id: <20230424091626.195590-5-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> References: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0008.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::18) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DBAPR08MB5832:EE_ X-MS-Office365-Filtering-Correlation-Id: d343ef31-e832-4505-51ac-08db44a49f20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ahLxfGI2za2YGtHt61LyAUwieWGIEH2KzBV/YpUQj1xAaHdTBU5NKU1ccF170mgPyk/Jgtr94tBKE5dBncIwJ+YaCpQplBXedLxZlITHsyzJ4qEwmOIvyVFdE494+FK9h9UoEF13FJZw4tyhI74USpH+vaFGHa7oyQK8GOtm/no/yCY3MIl8u4oc9DD4YDEEZt4/1NqaGbJ16N6I/kY42emvoVrziCpwdY9a6VRIjSWmq9V5mTCXCuwqrG8yJQlD4GXiDmrGn5gQUmOWGe2QN39tJdeFNiC7odMbNL/vb2/2myaN74uJYiBU7UnwipJB79CmPNDfNF/d70jnndwIlW1Xa+nfgbR/kCbdRnQtm9fTSx1mma9+5esEBC9ax1945tax7YyTGXWWd4fTbA38pM56yLVY/i6jSJcXi3WKpIlix+JMJhaFqNzC4nsPnKMyR3e3JbI0bp1RGf6k7PY9tmlGC5U12y89FrAbVa8o0+bXr9oCLeo9VYW2gav4ofQY2e94qagqZ9HQY7BMzwelAvmOwuAxNS7UmXMZZhMtdeU6PRimUxtvN9MLoJmXP/re+bYO26B/8yNH8azKi0gbknLi6n7bZOUs5Zd8G1Iv8f5GmUKLwAMcFzbQNiYBzRNj 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:(13230028)(4636009)(376002)(346002)(136003)(39840400004)(396003)(366004)(451199021)(5660300002)(44832011)(2616005)(86362001)(83380400001)(186003)(6512007)(6506007)(26005)(1076003)(38100700002)(38350700002)(8936002)(8676002)(478600001)(316002)(6666004)(6486002)(52116002)(41300700001)(36756003)(4326008)(66476007)(66556008)(66946007)(6916009)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jPzxuk9fP2e2PdygzyLW6DLl/SbisEQ0bIshLKdcVWVCfPazmOlcBZJD7fy/wkNqXB/z3gdePlREL3AgHwtzq9dYos8WNxn/Fyko187HDL3gqNkNtx2PC9exTbV1+/VSuWpUsul9NqEPuhXi6K2gXTTzWVDSy22hyDAind3zxaS7JgxCXBul663phf6jDkbuem9RdNQ8mRXU0Yrnzg9HBM7zHdCjbNejtacSXFXjfZqVW7YNjyHNh+toDJhDFOEVonUoq7+wq/YhNFyn2ceT3ZbvRz8YHckVvhFQemP1cuvkYj7lQBvxRofayR3QYgzIILnxU3X/mDQvgADGD0cJF2OQnSBdq8mBEKfep3Thp2oAZc04nmZhGnbRXygirxl3E77NDIcpCRpYZa0eK7uo+1wdHCCDGF2LT6wqlkeDe19pt4DtssE7SeZilI3iso7kg1R9sy6vgeYh5PZbKM7LIq8yIUl8MeExMHdOIwcaJKhIP7CLIAsQ2WiJ1nWi0nWYOugCXqxfGSdrgUrm1PxDI5SHJJgx5lvowrUrpE7yQZdrnjCFb9MSJcJpPa1mMqPLoPWhkHzYSS1leJTimTZHNEiI58t0etiHgHPvtVns/mac1rrzZ+9cl5XT7YjhUv2gJfzmMWzRGqs5m/rCD+TIfOWyC2A3ozyItixoeRKDxTRDvSzIjWETR2fnoiSCgWufaZL3XazUSQERcdoj4DhonPGEQGvbmhCpAcCGB3M2wnyFnJG0S1kYFZwUu/XHdqo8q4VKxd1lI+FqBXcKUSYIF4lmDUuM2ZhG4bLiFMHbdiqAPsZny0tCb7Ksaht3XaMgbbjIVzFIGtELcwdC8ZEPXGIqqG/WtYBsHuU7PLRv6s2TH9HQcWeRWrf44lLjXm+o22YLiwvm56qoz+EgfaZ/tKMq93YPep+emH4ExI+9pNfnugXULboFjWcMVV7PExXTDPNOj/Qo4epwuv74lSVB4ibPfXPJlaCRrwueNM6s70UFokTYWyGoIY4t2j1pr53UrC0Di4WRQiszd1CTeUK+1vEQzgG3h02dcCmSivcMFmBA21a1EcaicaaH0h5tXIatK6GbwUilrIY9b/Jm1xd5GDufjQaVXfkOX4jTGj9ICHnQ1n13i7XzskhVfmD6uwkvDqFnJutFyh4zOIMXHwDfs94zx/C7VpOnwwhczOelS6Qg4vcSMJ5UyvTh0F7xfd3BvvaRHePVeZYDkD9oHAFbIXenqf6gyuntJd1BksO7eOYq4eY++6hnS8UsNJAxXckYmp6+/M+Hfo40a8IeLuUPrQ3qbriHDe04+aC3CAxAy51Sx1uC0X4ZVhS1IT7dw8Chn+mnKgBg1gd9mKBhfuXVnIXh11I2fjYVFg+2J4Iem7bro4ti7etNREE7Ugx2BON2AtUURG2n5kVxbcDmnsbTu4DtiZa6uOKnyXVhvqH/9h8XUKcHZ/Xzx1UR6aP53Ui9FcuzLGAy0aKRrR4DeyaVMgNMHewwgyc8yJQUXon5mlAnH+DbeUtrZ6KkXYZZMO3OKvlsGN3qcg7rKmYBONtVDXAVd/XWZEpANGXb0Qn8U0zA9qQXBXMTBpqNID2qGeUymzjMwlk1aLukTYLqZFKfpA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d343ef31-e832-4505-51ac-08db44a49f20 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:16:44.0191 (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: l4fHFcKeoVv7XyuIJKSRxQv7COWH/x19/ESuQa2dsV1h2x45k4skaarFASq2afoaANG4Wp6v/lGU9WSWZhlZl9X7j5YugBWcqfu5G/ZhawQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5832 Received-SPF: pass client-ip=2a01:111:f400:fe1a::71b; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR03-DBA-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, SPF_HELO_NONE=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-bounces+qemu-devel=archiver.kernel.org@nongnu.org This helper will be reused in next patches during parallels_co_check rework to simplify its code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index dec4fe1f06..14fae04c99 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 coroutine_fn GRAPH_RDLOCK allocate_clusters(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) @@ -251,10 +258,8 @@ allocate_clusters(BlockDriverState *bs, int64_t sector_num, } for (i = 0; i < to_allocate; i++) { - s->bat_bitmap[idx + i] = cpu_to_le32(s->data_end / s->off_multiplier); + parallels_set_bat_entry(s, idx + i, s->data_end / s->off_multiplier); s->data_end += s->tracks; - bitmap_set(s->bat_dirty_bmap, - bat_entry_off(idx + i) / s->bat_dirty_block, 1); } return bat2sect(s, idx) + sector_num % s->tracks; From patchwork Mon Apr 24 09:16:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221876 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 E9475C77B61 for ; Mon, 24 Apr 2023 09:19:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsJi-0006M1-Jv; Mon, 24 Apr 2023 05:17:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsJe-0006KO-S9 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:16:58 -0400 Received: from mail-db5eur02on20710.outbound.protection.outlook.com ([2a01:111:f400:fe12::710] helo=EUR02-DB5-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 1pqsJc-0002zf-Nx for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:16:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mceaxe/WGSLyhDzb0PoeqBc42X6pqXRxzTpwa9vAnP/aGHN8oWblcClOg4avUNwy3Sw64fcDFWVjzesmRlbp0+0oyGNaI9RBXQK/lz/9Tz/cqTooeaDYr5qGRjEzksoBFjDbd4+9QpQ5x8siRf4RiMEeBDsiAKr8hmVKbVAjHYZmmr5Pmni+aH0p+uPOgBHqqwrceMLi+2Lw2httSNxJ/Rhaaz+uvvqMWarX9bEctuLlHdb3f7J8/XYc9ebhD4EmvuRAwjyUe74du+5RlzXHZ8biSZhpphbfz9596nVVLrXAhSJ5CUarp8zqHss1+u0sTTd9EUpa6/LT+Fz7HAwwIA== 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=WEN6uvzL47tJIlWemMWFzC2Yw8mGEH1Iu55bJZSXHf4=; b=SnMRaDZhfY4FYXx/nByN+loFoib9LjYz8HYBF5fgsR5eRtMXIZUIAG2eyACIzUJuDirMkCoyWyIfVlgKoke8OQoiZ+5cC5l47Fr38t6m4v2rAOsbCgbf1F3O6IYTq/SW7ha53N/09PFynTEpUd8mOxVwPC9g1cxrBgG4q+PczcQSReY2fRPUksz7tsspAeCdEwU8kCAUNqz4AZMsqsqabBkR1mfDs6zbmmwIpwhtT7GZpMEk3F+mKS61gkB8cs/nQoo5/RK6Jb/6ALh1saumybZX7iYZ80YlmDyQa4+h2D9bXM1oUEcNnp/Fu3iBjgZMmIBX7DbCPa74Xm2JFH/oqA== 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=WEN6uvzL47tJIlWemMWFzC2Yw8mGEH1Iu55bJZSXHf4=; b=QQVyPHgY7tkpedYmREzSAV71rL/JO/K2BWwAaW+Yrih+KDcg9pMUXzQ3ZIRHrHSGY/SmwpQxzFLl3/Gc1F+ygi0Gz0kIeT1AHBmp2oGcRziYJR9ED7oTuJeWEhuoMgk9Ie2tEtNy4EPBstfQWqTOtnU39LbqGDhFgx5v2gr535wanzW2XpYymty/EKxwnalFFF4WxQqOjtvDxIhh74ncDaQu6RjW196a5tT0toybwziWiVFj/zXRhBEb1rG6P4rxtRLrGnbfMm86iWwseNIZGoWnzenJsv4JZvmePHj5s+76mBSpT96trJg1LrK4c8FF+xU3m3khOtYYz1/TBfoNug== 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 AS8PR08MB6534.eurprd08.prod.outlook.com (2603:10a6:20b:31c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:16:45 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:16:45 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: den@virtuozzo.com, michael.roth@amd.com, kkostiuk@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v11 05/12] parallels: Use generic infrastructure for BAT writing in parallels_co_check() Date: Mon, 24 Apr 2023 11:16:19 +0200 Message-Id: <20230424091626.195590-6-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> References: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0008.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::18) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|AS8PR08MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: b3db6f63-dec0-4382-5c3a-08db44a49faf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HhW8kKQOUChP82k28L0qSK2URdt8bFkhsk3mLNfCBVYf9stySYpRFtCttvKfig10FfOml8HnDvHuhISlQCZ5i9pdZtrxVWComcJarpJu20Asgk1tgV33x1tOQe88c69BdCU29zTATB5QcVNz6IgfgGQAJ2uNJ6SZHBABngTG2Av05gH3xQGnWS6PbXXpX+fwybOwqW+TarNeRpEPvneIP8BHokBkwy9aPVjwS5nXZwJCojqejNVJbeDgFiQXmbDwBoOm6h5xCoFstd8XpFvYJA0gLQtX2ddqszCkbQQxMbt+LelB/7HHNTEqc5Zmu2te+MnQuQFNdr00NOQxacYlGPJr3CLSowmoaSgZMPB/9q2FXzCQfhgF9zf3a++L5umsxQ1DCLPJT7cTdfL4kB8o/VOfiuzdydf6kTDAoKQZREgtAXHf0lQtHJwDEWsIjh5/R7LUdVeF96SVP6UjtP4jVSZyU2FDD+AvEilh/H6P+uAkAgvKqsLKUWrTvfz42+ttqAtd/YwtFB3dfNPekSNFiXJEQlkTl+kiwg5oKmYjMsRxRskb2CJg1hxuas0UeUHBJwPH948oE6fAW8NzmFAkHgDU4KO2A+pvG57oodguFb9scy3l8ANxuzRN3LVZzXspsn+eVbdfZ7Y7skAd/UbIug== 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:(13230028)(4636009)(136003)(376002)(39850400004)(346002)(366004)(396003)(451199021)(36756003)(38350700002)(478600001)(316002)(4326008)(6916009)(66946007)(66476007)(66556008)(41300700001)(44832011)(2906002)(8936002)(8676002)(5660300002)(38100700002)(186003)(2616005)(86362001)(26005)(1076003)(6506007)(6512007)(6486002)(52116002)(6666004)(83380400001)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SFu4N3MtGsD5cYIGLbcdv1TC/dghNV71vCjCM/+Ej9tkIBQP+UGVmLEqQ53bTU9rsXqEeZQtVmqKhVnVPW6wVynmDO95DNokxKiz4bwbnOoVoWseFgi4DKbaH+hvqRZo4q9psyZ+jouwg3ODehENogWauFz0RJskTp6s10nAWJgJYB/jxGeIIkFTsATDKVBcko+Sqcejsrga3UQvk3rpbzvBDLCdyFUy+xbKu9VyuuQ0GGsBnwn1tZ75vVwn9Sf45l4/DG+CLMeRkLwQZnzp4a4tPPHBfldUmYOREFIb9WUJhiXIOEUOOury65mZAqbDhUbBdn0WIZJ0eWxto8cu7Sh+bfmzigSUPcY4ZwoJqMSC+huW74nR3S04qtpryk4UKyb1V0KQW+yMHkYFXwf144MlmAL4xr4zrmEKv60pT/2hd0vmIs8dPWzmSNqIGITXwiRiktFEh8BxbwZ55C42kuMoZAQ9yxdJVWGdQJqf/Zzm+wbJL2JNCCbhhy8rbZlTNfv6HshmeTlkK8wb79B3a1BA/nLPjpePH4AvNSWZaE5SAGl3YpgZPVk4+HjQpO/iOZRu3Wml5DkDHJMWF3EPje6IblhLoowggraQFsGFopoWcghVnhLuAsmBH/n5mYrFdX3H4q1WRw5PkBmj9DGW3YYCuu71MAU6Bf25EhDHtGQdTs4wIInfkrtcl3O7wfqaYcjqasFhSBT6Oy+5Orv0Imv0e8d9nzKBtdoH6NMGZ5O3qKORVgzucbU9+DpWQc7qDjXfVjsJzRlaU5g75mhuRcYWLGZ/Y2RV4gFuumY1dl4/bUKdtMBQU4/OUEE1D1CGwYsLxGV07uV54IWgX8TcFe9YaZrBYfG58YrWgta1TGGdBbd1ohyX9TX3RgrP1wpgwr0jUFGa1ROCd1S7NtqJP3ZO0poKkvPBZc+6Se1v8efk4Uv0+U1TEjK0JuBJrUSxkQfCiXvQis/TR/jVnDSC9DR5sz6LqUxSJwZW59Ttb7CszXA38WbopxYTJF2MqDrh5enjbcwNyYUh7Fq7llVPYLmfaMMlj3wvYAhJqzx0Qs4syojO/gB/8n55HQEYqGST04xzU8Zd7pJqzW4i4Qu9fjjEQWfSVrHks9vMc8pA5JS02S17FaKsBPgzFYTQgQi8xB0CWUlQEBPlMYCgf6gLl7qkpTY+RKg6uxOCInzNkFO62XJrtpI35lKx8yVqKr4tP4SEgaWZATQa0wrkvpWXf3UMq7i0BQP94v0Lz0a+5V8YuKKx5R8uMyhRSilTZiy5V4HeXjp3dMu5FjzuR/rZ8Ttf2wb0LUc9l9CB6Qypfm7zGt8pOk31kMTzdCdq5CmjsNUsgfPNl3+Vh5rNwcIolZfGvHY56apOkhCCIhs0B1o9pesR8oH8zknoSB8h/ni96duebDQ+HAi6nMlYrtrOQ3J6eACeJ/1irPskciOmbE4k7vSz3n//sZKIZhlcQ6UkPdklbRRxxRO1lQAqn/qqsH4Ych6JDuDcKg29lo0+Dm0pGB9k38nbzjul7IU6CyZAogmeprRhNTU3UnkF45O7+sAKwHbGUGmfuTs445ORTkdUtajWohYO0fKt2KnNMsjq+Ekc5fiPWIblCIDaLYkrYQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b3db6f63-dec0-4382-5c3a-08db44a49faf X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:16:44.9196 (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: 5s6IIBQZUN4zuIaGLZQze3EYnbkYn8bZbBArrcuCcuofKisYos7yy026Ml0gIsJK3vQ0w7A5cVyS6dcDuAkwiMGgDi8K1YcSrnSwJuvislI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6534 Received-SPF: pass client-ip=2a01:111:f400:fe12::710; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-DB5-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, 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org BAT is written in the context of conventional operations over the image inside bdrv_co_flush() when it calls parallels_co_flush_to_os() callback. Thus we should not modify BAT array directly, but call parallels_set_bat_entry() helper and bdrv_co_flush() further on. After that there is no need to manually write BAT and track its modification. This makes code more generic and allows to split parallels_set_bat_entry() for independent pieces. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 14fae04c99..7f076db001 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -427,9 +427,8 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, { 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) { @@ -467,9 +466,8 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++; if (fix & BDRV_FIX_ERRORS) { - s->bat_bitmap[i] = 0; + parallels_set_bat_entry(s, i, 0); res->corruptions_fixed++; - flush_bat = true; } prev_off = 0; continue; @@ -486,15 +484,6 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, 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; - } - } - if (high_off == 0) { res->image_end_offset = s->data_end << BDRV_SECTOR_BITS; } else { @@ -529,6 +518,14 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, out: qemu_co_mutex_unlock(&s->lock); + + if (ret == 0) { + ret = bdrv_co_flush(bs); + if (ret < 0) { + res->check_errors++; + } + } + return ret; } From patchwork Mon Apr 24 09:16:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221868 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 C7E38C7618E for ; Mon, 24 Apr 2023 09:18:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsJe-0006KK-Qv; Mon, 24 Apr 2023 05:16:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsJc-0006Jn-F6 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:16:56 -0400 Received: from mail-db5eur02on20710.outbound.protection.outlook.com ([2a01:111:f400:fe12::710] helo=EUR02-DB5-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 1pqsJa-0002zf-VO for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:16:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kryP2crSj6fxEGRIj6WQprtrtqyTooWwoJ5m/oETa2rD9/O8E2i1j5Sm0uSKoi7Zw44JW1xUIB3zvEtiq+TDAZIMRMTmIK4YSllzH/jer6d/rYlA2+7Wc4GoFv9SqH47156bn4ykx9nHb146Hyc2CZH/6MM04BKl8tfgPTf3krTYX4dm4JGXbut1M4/h4rqGNKN6FUzyzb7mHqEEUoSz0wiuIme3I2ysqpj5zljRnJsfKhc0EZqCjrVGoESKtLylkyoyG14Lhq6yUACRRHuWDotliHbwSIVJxK5bS9tAmCrMXOFuQHXqc1X5N9bLZDljHhykvHcR1k/Ok6W8HIuaPQ== 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=KK3P1C61R+xQsw5/2/BWqWPfe3WZoCYaX3UuCzBp0Ws=; b=l71Sys4+Qqq5rT7NfbFFO3gA6SPuLACvmeUfJvaGtDhcwf6mnd5xTVzcXWj/V4UKzldVTVqumAGFT16RT7woDZOpg0KIllwvxMhhNMsd9X65POZXJOBbmQ/Iq/t1xIcGaI24G4Ef8Zsgv2Vr6+7YzPuwBFA0mRDC6uCGravu9h09xruyByT3Kz4iNM619xWzODTCBPAfJkf1cIFDrUpDokkth6ja7UQ25kVOoVMv1gNZTIbRKJwPAN4oMFDIcrRxklHcwGAzK9CBcS+xok0YhhHUkqPJ0epnBGS/bg71AC1spf9TW1NDi29Mh2lh7cEgnWUqXSl6oMRC3LP3IjMvVA== 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=KK3P1C61R+xQsw5/2/BWqWPfe3WZoCYaX3UuCzBp0Ws=; b=hrmtJlsiXwUe8jyozGgUkKcaZLzU65YtHerM1t6O6qkhz0rQsfZK66YFXHWg8fd/as552leSxZCZ6jvthb2pzq/AEa/TmFCd93UDj+10+vaJIIdFSI3MHlik/oCzvvoVU6yq1EMpbsL5OoQQjfYR7nE6PnvoaMlZI9YvI02W1WDfeWRXFMQ4K5BEbCSy6Melu/GM4C7zp2A33daQXcCbF28mxHpwiOBC6/ni1tlxA3gFblePZGMz8xz21kGoySn8jdx0E+glNIHDPdiypcbSfFH4D7aIBlYnmpKPl/5PT+Hhd9WEYKP4ORyvB8W+eJPqEaENRe315YoF+Bcvh+sSHA== 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 AS8PR08MB6534.eurprd08.prod.outlook.com (2603:10a6:20b:31c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:16:47 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:16:47 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: den@virtuozzo.com, michael.roth@amd.com, kkostiuk@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v11 06/12] parallels: Move check of unclean image to a separate function Date: Mon, 24 Apr 2023 11:16:20 +0200 Message-Id: <20230424091626.195590-7-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> References: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0008.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::18) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|AS8PR08MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: b9fdf6e3-8cef-4f39-5016-08db44a4a00c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X4pLEdJP/L6ZTn+PNtFCUgUMCNYVXnL5eyRse3Ft9cfNBrKbROrtGhn5F5saAZCQzzqtPc1NgLuNMtY2C7xdWffPuCUbTpf6UlYxsfPAVGgQ0HiIT4S6UTmLsazMvG0FpjbGfBky8Z0N3c9/k6CfX2E00oWpmzxgUr697U31iGbb5cROJ5eAY8UosJs4uk1X6kcWQnX/pyVwu/pDXBJ16AoJxGhebfSWlji5SImi7gEKb+HRYOEv0aztos9K2wE/RYrdJpCZpFhpas+gBYOT+SYfTSuuky1z0AJDjqJPZYjaCfnQyCzywmIIfBfSu+Jv+u5RMFTdR3mrPYsEoGi5f6wN1nYxsvmcVGyT3F8XucyFN6KZefn/HNisYuEIlzhSDZ40KBLH2EZcSPK9Ucvw2uyJreQ2lNKEHLi2yH/FAVHgvv+6oKjJGUrTJlJTYb3J8XWK40tbjdaZefdlJIumjvNab+y8/Y6BTh0ZScWCKfzKAUZZpfEGZwleKBbeZ4NPAk21zgHAqNHAh3e5fd5wvDKuIUZTw1+Xkh5AaVvRvQj2whOADXW2JRomDQ/+RITzoqx1UpjLekC341j6eQm4fcLinXIPALakyPq1jDeJ0m0= 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:(13230028)(4636009)(136003)(376002)(39850400004)(346002)(366004)(396003)(451199021)(36756003)(38350700002)(478600001)(316002)(4326008)(6916009)(66946007)(66476007)(66556008)(41300700001)(44832011)(2906002)(8936002)(8676002)(5660300002)(38100700002)(186003)(2616005)(86362001)(26005)(1076003)(6506007)(6512007)(6486002)(52116002)(6666004)(83380400001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E+dBTqdoTKEUcx4WfjRvUsw1z7pTI89EuDvEuYu/OPeJbmxQbIgqJrPSGixjY8ocEROal4GbpP2aWxRyNaSdQk+NVhR9h9+4CkCuy4z4CCmG1WDVtkbFWUtfNlbg3qBgEJy0Sm5yY53UvUAukofd9AJlJQp6RO757X20RCoCLDwW+pnNKS5QxtTXdmHjILe2aSGwGKWKWt9O0znQQ2fgU9Xu+jOBTX/kdQH07M3odDB9gza76/Jf7MLpp/BNnYR6ol7Kp4E6zoAAPJsfVzLYUXKILcKEuzDEC5vC0Ca1N5FFLwKsf5+ALPj3n61Pat6reNG9E1Auj2ijMjJGDEB9hH3rRVPgMIGZJfkKoniyr8ghg4dzDxLsvtzVRlbljmNTCZ4yU/aqhXtxrAhY+7Ji4fMcCMi+bc00u9GN77vnDtLjwStfZifqgarskv+haz3b8fGo1eOAyLQD5MOcrCdHemt1L6p21w1lJc3diLnWAAXfCd2PMVifZfVif8o+eZodsHOQ+yqUttbJNp1FHhEVYpPJYJ4nFX2XuvfwE8QDiY7LErvdLZ4ZUsiIehB78laM6d0o1njwCW9RylMvajfDAwz3NSqLUckPjt8PbdgbbWPLfyAj3WPSw8ayT91FOUWUy4IzghXa0N7zJQj5iO5kzucY72mzEQUEuKvfr2IzurDVGzdcMCs0jFPP0KX/AOvB6aqNHj/POmnRcL121BvI5H0xEX26jCvNN7xsKs1o4fBM9ZZ7AGMWOaF02UJ0N8yeR3myWEDaGjXUT49srVxgEPcw9QZg0zKYMK9D6GZAKhaNJc4+WEeFP+6Sm6r2jgICmCTtSpirUIN18zhCn2DPmdHd7bvJeKlcWthryM9p/HhthPrM4nKxvZYi8RD1sqHruAbHnDcG8lshIdaQ2kNpGk/inbijtlWdiquGf665MZGu/NZuSooiy+6WgUMNWdnhHx7yDa6mzh3kOCSK/tDhD1dsGGrPK8fyifcPs1UVD59Gt8XVT1xa1tgK3gjIxBfb10iOeAXTOWWd7RWnYqHMr7AXwFMpmj6YIv1zHEc+PiBZDFlkawPjYU1vt9nPWp1h7ng+tOND+c5xstxFPiaB8G2AcBibQi6I/PnVmkHgO4eMRlT8tH6Yn9oZobxLt44cN5YguIBwPqgj4pnyGxfFLkv1GgneSoTez/NBYfIpqDDoYpIyJJawrlSPCOFbwZZvl1xd9zV2hpTHDYRoLN5bbsFmGFx+R6QcV4ucBEEsrBJtUiMuDbCiuZdIAy27fkbmMAiHMAxHAvO9MxLZu86NktIhbtPP/s1OPpFb9sFprAFmX+C5GA/tNBMY5tU5dNyRcL3OXBN6SD3k+F70fENS+3HVa7DGnB5LiWp5PPoiVWHhm1KxFCjukSqVJJ0QPQVO2wJUyNWNx9CrLCv6u+FJ+fbLmKclADKuFd8jRMAiK4kYAAntkY4727isV4sIax75u6Wc5KmwezTnHXxhZvkSlCQ9G/kO7nQ1KtxXJzjyDkzz44ceGndylNfjlxU6hkqwRq6HPxVZb41O9tYoPuod/1rA0/Uer4URKCrX/0c8Vsvv2pRa5RlT+nECKQmA91aP8uYgVjKscrxqE9HJKi6mDQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b9fdf6e3-8cef-4f39-5016-08db44a4a00c X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:16:45.5047 (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: s7Kb3ycPh17Lw8eo8hEqdlhwnEYDlu+SCzEiu9tpuyU5yLvlL9bvgy0TG+HvefjqbbAmZPkkMiAJO2y5B+1JGjKCilbaa34KTHThq4oyRg4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6534 Received-SPF: pass client-ip=2a01:111:f400:fe12::710; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-DB5-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, 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 7f076db001..4f14bac616 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -420,6 +420,25 @@ parallels_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, 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 GRAPH_RDLOCK parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, @@ -437,16 +456,8 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, } qemu_co_mutex_lock(&s->lock); - if (s->header_unclean) { - fprintf(stderr, "%s image was not closed correctly\n", - fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR"); - res->corruptions++; - if (fix & BDRV_FIX_ERRORS) { - /* parallels_close will do the job right */ - res->corruptions_fixed++; - s->header_unclean = false; - } - } + + parallels_check_unclean(bs, res, fix); res->bfi.total_clusters = s->bat_size; res->bfi.compressed_clusters = 0; /* compression is not supported */ From patchwork Mon Apr 24 09:16:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221879 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 E29F0C7618E for ; Mon, 24 Apr 2023 09:19:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsJj-0006MG-9l; Mon, 24 Apr 2023 05:17:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsJi-0006Ld-56 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:17:02 -0400 Received: from mail-db5eur02on2071c.outbound.protection.outlook.com ([2a01:111:f400:fe12::71c] helo=EUR02-DB5-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 1pqsJg-0002zR-Do for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:17:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G8muLacHPupYAYDvLFKqbiQN+Pcph3lXWRh4xC0xWE1GLA98dY/F0wrXmwSZcM3Wvcu2NjwnCxUjyU6Sj0vrsBApRrrLfdHs6g7eKzjv0C9lX9Fzb5w32mKXv/2reD9ihwijd84M0X15opX7Ha/R+T40R3/8fxIApreAThJtdb8SuiELcTRJQpgNSqgNTTOg5SzSBMLXvMVoRoAtbf/T+3g/tcrHIFljSRYLV0DrE12gcOz8i4tRLiZvCkLCqL3tGcoCQrkHzRBRtR4difqI7XwR71XBNyBMdaPLfNlWED3/1yrSVQWwZVRMRkvSuJTXiAgXEMzlvPOfO6YcFA/TtQ== 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=vMDOrMQOAEcLzCo+0O8hmjMAoxZudV/fIB8RrFdBEuk=; b=c1GoHy8UkKcq9qoW2Xs2YfP8f6TIzPjfwO88hFo1GW4nn6Cdp7Qe8jr5cjJck4ClwX3ZsybE277pGeSF5fGPn9psT/XIYKSQObBmX/G23+jVxVeWMXDm2PvBXZcd6elu0MlF9/gu+rGvtAhpg91hhGz7k7k4mNURkL8VoHcPlf9PVWCwesHet08d9EZxgnQ0jKIB6AuQftHxuQMN0eyELEFyW04W2rbF8SOf7dyme0D6Wgn7CkZ+kzB6CuRnKW5PRwzAgMMBsNcGbFDmonTJjwY5up3zBR8OhvUFi4ZMpfj34NceXHfXP5xqoAyp1WFpJEyKXVyXyFQCUrw7T3Fxdg== 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=vMDOrMQOAEcLzCo+0O8hmjMAoxZudV/fIB8RrFdBEuk=; b=mPDP+nMU/baaUOMRe+Bbsz8j+7WGtR0PmLnaY8IpihZ38SRh3NaCcoIPkYr5DI/HbT9D+1wmHtJGg9ELe79/fFnfX2oLFQ0tWKWTsptQ+dUAgCL8waAwug/rMn+2qzKFCYj1wNryF08yTZYbTCN4AExg4iHMr3CjKbnKEVmclJW+Qx8H+3makGn6EkkswYKL3gkxmxFGurpKkwklYZGUmfe+lBbe3tX43vpCfE0j/iMHFjpRygLsWj+6zTr8IgUv+TlABH2Rk1QMrcjNZ6xxy123VzfwJYumc2ZVAIGxIBqS426wgkh2HCpW9rlTLAEX08921hHrRrMuXIxXnMh4sg== 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 AS8PR08MB6534.eurprd08.prod.outlook.com (2603:10a6:20b:31c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:16:47 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:16:47 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: den@virtuozzo.com, michael.roth@amd.com, kkostiuk@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v11 07/12] parallels: Move check of cluster outside image to a separate function Date: Mon, 24 Apr 2023 11:16:21 +0200 Message-Id: <20230424091626.195590-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> References: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0008.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::18) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|AS8PR08MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 814ac9e6-7749-4744-d0b9-08db44a4a072 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XqIhS1L+rKlm0sTvOFZmGHiSgdmsFNXmMPWlY6kLmiZ0H+SVpwChl+x3bbJV4kC/JNunwg/UpCoTo7eVY8GUGGgAxtAbof23KaZup6HK+W2XBxzVeTdKeOQxsq2LGFMOaqfCpNNcmmKR8f6Tq35+O4cpYBJ0pRMYD+Mz+yQqjIrd6Qay90T83o3iymwwEgD2uibIFUqH/HtL+sQ2+bp61jl0DSEa56ymF4B8vse6Ja8Dq1ivwFNfca9kqAVCxte+GJec014Ohebmz1R1qEe58EVQXUgBYuPgm/hVTRhq4C+SYby5F48XmKuO3ry3Y5QxZNZRPZPfejlerasX+B0+QVMHwTPf84ANEfb5YyiyxK6TF7mlVg/B5ZSPF7jvkFhL2i+8DwTB/XGngyqU7vydA1ro7JISCwiKbhtN49PGFE3m4grj7ThM+7jkOmXIlHPUHmeH/24ytlgzIqoVZ/EcFb3YIqchFNBODIsQgxBFXW3gCA49FOd0ZDUTvNA8XRSkxC2IBzJ5RvLP5kE381OWpk+WDaUG6Q9wugvnLssGh+1qNyaXHZFQila61QBr1/ZpUpFRbrDUjNEdMiN+Pbm01hVO7fANcWW7wKM6VlLERFZXG7zcoBoMgzMN3bfUaxQz 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:(13230028)(4636009)(136003)(376002)(39850400004)(346002)(366004)(396003)(451199021)(36756003)(38350700002)(478600001)(316002)(4326008)(6916009)(66946007)(66476007)(66556008)(41300700001)(44832011)(2906002)(8936002)(8676002)(5660300002)(38100700002)(186003)(2616005)(86362001)(26005)(1076003)(6506007)(6512007)(6486002)(52116002)(6666004)(83380400001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LFJnSKcKzbQ0cvEqHG8GhiRrOxpAAuueBRa/Elzjts9ZcKPm74jKcIQjzFz5l761PfyW4VpGVKdlqlgzM+tp26XyBrrKdg4gf2rrKA8rgrb3ggFAMDGmJiSpoyHhJJxx2AB+Po+ClzRuncDv9eCYMxkRd/Q1EQV80C7mCX0qc1zTBlxxEK/qPQ4LDla8dwTs0cUK8g3d6XRCQ9JoFf/A5dQy91B0tntwVBwG20bdPQspRxhpT7WLanRq7lLDv4btZz59f9d9ngx/IwSRFDPGDACUNKO8zNkigGaRytREVbtWR6y3CQeJ0l28Lx1AZQFGjRUHiMwyQt3R23jBCJfYRj4tNpR+pur0VEfJnsun8TuJ3vzisV3Nw+8QsrQmGrFNSuAJ+slyy0kTppWLpx6Pua323MPfoYhQPPZ07faQPrd0eiuNZVxT4ehmqU719y/4DEomhWugC5aNjN7W6U4b9Lo3t3e9xqUI8TzdZxLP3IptcOyiaRBG7CkVkYIZeKq3BpKP8Zu4cXxMf5Uc8k+5OuQybo3C+MWDWLZibse+deiprPfAM141Ymrrw4RgGanRF2UDCxn4JCLRUcNjPNJFb2Tnqim3jxT88zN1kaoy9hZatmdddCUtIeXAMi4EFZvbXZLqc/f9tk+jDyWmE/tLUuaig6PUfVnzlyghiPyW91FCLmWCHP+Iua3UAMo6MUYq7lF2IiGyWllJnf8ndtA57AeYZiTV6+l0Omo9pXbpftCI0tBpyJcpYwQBdpA1PjJKzdzyqh2vsvtPhESEFkIQQWmjhKesFZ1hIfgfD3iWlJC7ESC95196r1gv1/fckWieOr9ae3bVBkn39OjyuSajjopIy1tZOTBnZj9tMVHIM8UG2i3r/yZFayrc2lIfb+Hg9m21cqO7PxEZ7r5duBC4rO0X/ct+broaHYpU6+BPNzDO4ubrJgRHEAsWcmedUZjqaWAxpogvlZC1Cj7s9LKen8kodIL1mPQiyetwUbpRzhgDFJh5Iy63eeaunq6uhMXpetiCuOAb18X0HAVW1FCvvh+i7FIA0zqZRh9bzgzfUfpXAcsjM1G2FYc0fhMmgDpBXZtB35iU6jv2+EbxAQHV7Wid6dkIQpgWbuSVT6VY0Ei5ZoIGblt8FQ6k2b4ISCuPiLvrLdesIdBtP29jdDYE+/u97R3+F1e3syswRhidzGgo0Ixe7LndNwpLMCOM4mYYPovQ7DFP7V+GHOLYhEO6LhuuVxpjfvUPC7IK3B2tIxswDUx0KYwdQqqYFFqvvWhU2lblcREER70uffelnTtGHHv0rjjk8PRWA9jupZt79tW4zZWyhZ3MZJhW3OL8IkKoe3oOp02lpIZMc3yeBLiq6SCP2IO5Qgpugu60wv2XjUau41GZzj3u78FMhIYkwLSNAQmCXFEpYziFqN6+QjQhFa2T8mWsReH1C/vXFDRu2joFxzcfCq97GkWrajz0iO1uFcAes9bOGqoIK0ktTknOQUzansyKNx7yGmEbWQtqW49aM5WgVa18Qv7yXokg3SP16fgNMvhIC0IUH1FWhZBXUklFwd6NxWeFdPVn/QgDHMGUnuW+IHQ3ph+05bO6v6/cherW6qzrGZXK4ecVNetIng== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 814ac9e6-7749-4744-d0b9-08db44a4a072 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:16:46.1559 (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: db/V4S0VTFYDf2k9wBmSlhWWdIjUmNaH5s24TOIkj9TtF6t5P2E+J5TWnY+ao8upPTX9TlH5DkArflyhkRJ8n13M77kE4bkgBodbK6HJ8FM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6534 Received-SPF: pass client-ip=2a01:111:f400:fe12::71c; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-DB5-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, 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 79 ++++++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 28 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 4f14bac616..8588c3d775 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -441,13 +441,12 @@ static void parallels_check_unclean(BlockDriverState *bs, } static int coroutine_fn GRAPH_RDLOCK -parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, - BdrvCheckMode fix) +parallels_check_outside_image(BlockDriverState *bs, BdrvCheckResult *res, + BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - int64_t size, prev_off, high_off; - int ret = 0; uint32_t i; + int64_t off, high_off, size; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -455,23 +454,9 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, return size; } - qemu_co_mutex_lock(&s->lock); - - parallels_check_unclean(bs, res, fix); - - 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; - } - - /* cluster outside the image */ + 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); @@ -480,19 +465,11 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, parallels_set_bat_entry(s, i, 0); res->corruptions_fixed++; } - prev_off = 0; continue; } - - res->bfi.allocated_clusters++; - if (off > high_off) { + if (high_off < off) { high_off = off; } - - if (prev_off != 0 && (prev_off + s->cluster_size) != off) { - res->bfi.fragmented_clusters++; - } - prev_off = off; } if (high_off == 0) { @@ -502,6 +479,52 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; } + return 0; +} + +static int coroutine_fn GRAPH_RDLOCK +parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + int64_t size, prev_off; + int ret; + uint32_t i; + + size = bdrv_getlength(bs->file->bs); + if (size < 0) { + res->check_errors++; + return size; + } + + qemu_co_mutex_lock(&s->lock); + + parallels_check_unclean(bs, res, fix); + + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + + res->bfi.total_clusters = s->bat_size; + res->bfi.compressed_clusters = 0; /* compression is not supported */ + + 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; + } + if (size > res->image_end_offset) { int64_t count; count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size); From patchwork Mon Apr 24 09:16:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221870 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 AECBFC7618E for ; Mon, 24 Apr 2023 09:19:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsJc-0006JT-Bh; Mon, 24 Apr 2023 05:16:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsJa-0006JC-9o for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:16:54 -0400 Received: from mail-db5eur02on2071c.outbound.protection.outlook.com ([2a01:111:f400:fe12::71c] helo=EUR02-DB5-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 1pqsJY-0002zR-Gb for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:16:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lp0SDyrxDcMe6EX/QsF5y47eO41HWOOxF3XG912+phB2gCTR4Ek9nQPK2w0FVeUfP4x1nOg3oHCsAbLI3a7mboI8kVp0QjXDdNLwa8d4JyQa9f32i9VVMiH3X1v1j5uAnSxKdH6ztbXFbvphRFvBHzRR7WURPHDB0fj/G0JwAbxSf5c4BuXu18rH55WibYr9f1j8qdFEQtLPwFs+svNyFZquaHXeJYRT73q5ZLMndNUvpDVh5TDmHNUa4Y6x0XC+Oa/g3+rtBQjjw9458lAITBNWYS1IUxSuGPMcLlujFs+Q3+847bY+oKAQ94w35Z/R0g0vGkLnlDxCQPlhqT1pPw== 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=YzdUYM1t83GtJ+XUwNuVoTU1WC9dIlfan1AXZqmH9W0=; b=EV17KYwsQgu5BAR0b6aoryyYQvvfMgKRIvqRJ0XnfI+Frvn7v6wJtkaJo6ihc7mFzzhT6jjJCeWzIlRDJOaQ7hJjGOp2bjPE2P6PcvS7NEcSjIZp9E8/HHp9i4ioJSpGwupyrmw709y/s6g9QLzNU9et31AJwiznDHyeL5Oi7gbrmFrtNXiqlBrvF6bo/0lgwpXOVqv3dsG1RXRd0IVXXUxRDJE7qKiH3aO8WZ+66sQ8/n/gKh+sQ3nkFAwvfrpuxKeI5B1pPwqUcbH30WhKTWfZ3OPoBK/tP9SxuYB61m/7ZbKPvbBAGBmxWyOY9kKplXW5A5odyCUj8GfAkmIAXA== 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=YzdUYM1t83GtJ+XUwNuVoTU1WC9dIlfan1AXZqmH9W0=; b=oqGRWFL/norjVWX2Y3QULX4mTHysqlHnmaQ+JzTUWnOOp/M6cAio0ARBACTxjgL03mipE0T08cHNxbgbJc9rbwMFEA+eo8UYAezRwzzL4XNJlOeSbBy558anxW2hxlEoz38xvzdFjm8lkdLI88CM1NYZ2jwXkA4srKH3nUYFXKO/E/VupkMjD81Q+0depeBVn3chDNUBQ42vsgv6tFgxBWLXNVyFV5xdB23Bje1wu3n1C4oMz6IeH9hRs8u85FA94TMqrvLRqGpg9hPS2qLEkbtZpLDj3HeOHnz94E/3Zra+xx9g9ohrTBuZkXBUbq/DAqeGQ0KsvjbF62R2d7UrnA== 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 AS8PR08MB6534.eurprd08.prod.outlook.com (2603:10a6:20b:31c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:16:48 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:16:48 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: den@virtuozzo.com, michael.roth@amd.com, kkostiuk@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v11 08/12] parallels: Fix statistics calculation Date: Mon, 24 Apr 2023 11:16:22 +0200 Message-Id: <20230424091626.195590-9-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> References: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0008.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::18) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|AS8PR08MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 18b95990-120b-4219-27d6-08db44a4a0f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8wgyfYcesylhnmLNOy/HjJOIp3XhjkHHbmDyVaz2RBG9yt1/MZByrBJBf05iiH/Ve0Fc0FNelX7i1++6FBuSNqz+TG3t/jYH/3fopswHSsYdYZGPVRqR0OEhmGwBrlGIMZW3XonUBWwQP0kh3spdGVeONQC5YvGQ1m8NKdb6bfAUUnxXHg/Pu+2vGIlFtTe4EsCNJgXh+XIRAA0VhmUgGOeqc3dkOQY46N9C8xyJpvY/mtj7nkmZLwiStIUfdpPPXHA/lQtW1VEHCNse7ypy4U2zDpeteaTe+bYxnrwfc6RbP3/6X1vcubV+Iy8ob/sRLAzu7cb3/JruklyyHEp1984M2RnovvhV59RzQGZGbmwqwUt0WXQaVWFHZnfoukEdgoubLDjsktNdFWoHZ5tgOsblKKrXdaGs+4isfiqp2NE6FNBfFY6PLF7v4fdV0tODPorkFjngnoUAPR7Gxu+RLkf4IFAUeWYlks1F5tShLnPfbEmUvXURhjfwCNHEVh+wQrDjFoaZm3STcJpSsjBFRo9vCJVm6Bd96mIP4QLlUOUdSIuW5295BF84i+crCumMmXwbgo6ZMrR4FSA3dORyvvlm6aH62Bf7lkRfjNGlPPDnyecIWoxCvcOUuuiplqZ5 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:(13230028)(4636009)(136003)(376002)(39850400004)(346002)(366004)(396003)(451199021)(36756003)(38350700002)(478600001)(316002)(4326008)(6916009)(66946007)(66476007)(66556008)(41300700001)(44832011)(4744005)(2906002)(8936002)(8676002)(5660300002)(38100700002)(186003)(2616005)(86362001)(26005)(1076003)(6506007)(6512007)(6486002)(52116002)(6666004)(83380400001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Wcqq+6GSwpBUXudJEQ+oECwKVOOdLE8/SQ9UC92MC77H45/4hQMqcLWYE9hb/DR1/asst70smgCe+IfZx0i1TpWahGVL4KpoaD6qmHb+KSlhSI16zgbzba48SSfgb5/V3KtKHgHFRvyCW5ckPslAVRdwE3Llcju6IOo+J7SwPIdC7g1Fd0ZorNEb6ga8VbxfSMz5R6//Zy6viJkggQrBeCW32JJsb5kC/qTQ/pTYEXnVENNmxrspApwtVF2i69LXKNWC/XYGX1B2qBw5ka0MibIs5vlRUx0x1J4zCaNPRGVZpCMc7n5H6idh3nlFdYR7kY+Oz9eiaR9ZAcCjKe/V5Tj9mLtP3dkBZWINLP6epWUGtkT+hCNkm0xq9bgGECXt+NzEmLedt6fxw4VTH50KMHQbd1HndeUq7h1PXMt/bsWVrS4ny7ZyMvaHjths1jBBf+PtaV2Y7yLTsNs4CULIaut1Q0OVnvjWwOCLCnBjgwpTyOac0luryoXUvRsNwPCLVwIz6hW14eaz8/vrCOLXBf8mIiHvhiW3VIkXoO7icFwhApdjqnfh+Sgyn+5GLG44lENB3IguNHkeV5Ij8eO3J+L53K+dWa8hQDaGNI+o3AnZfNqVZmVEsFYzLE6puziD/B1w4ub/huACSIvHrZzgE1zWHx3H9gRJNnI9W/KAeWaNkGiUm043XW1tmRZUtCDsKTpj9IojvINEVYIDFzKkgcTpHouFcZghQvb6aLnlVl0MhKRiMPUDFqx/ohW6aVhDt29NLEvKd7QV9s0Bry4KWYpM7D8bWUizhe+/Esh6Ap5KryOk3Qx/X6bz2IzISy97cfRg34U+rAw0lYvxCarS6jTo7ycca7pwK7+4YcKRXRg+v4DFCCB/KHhh/Jql0qt3AxbgmpVsKsEp6DkdGtohLSuYRDrxrAm/leestu09Ug2ts7i99QoyKanwLP8EIGfF8gTMAKh//HwhqCXkTQ2cSQAwYEW3K4jOzVbUc0vXBYV+hPF32bQca70g5SIIemP4LBGbf4zBnSt6aju4iT81zoaOjLNGlbcPK1PqLNQwHB3vYbcGiBxDpsQh65UbJnLyY9kh0RQfciqgaE413g7ARTwsCWf6s/JaGcRHZ30AYUTqwwj7eP2b/6/P5zcADTY9fllgHLvmjhVK6JlssZTylHS6zaAqQLLdkW9XiDvYs4S8VQXt0lSIn0zq/ExpX9ZYG8Qa2+vuk6NYqkUi6xjh7qL0WQ67J5PFiFd84uF4zpXDDR4fk/ltHfGxV3CK1abvI3Gqnqb/QfvU3dr/Q3vpTdJ3bDiY/Z+VQzahy4Tedk2S95aA/tTPXBCwv152occTAmke0OJ1aiLDtHQIWbQ0sTn/6e48LgunJB+Mea1r8Xp7ZPWw3/TuRUELZDoKmsICJanjGCCJfEqA41hXboFlxEGnZN2lxsPiK1YRgBR4exMHk5Tti+LY1I73AXXxnsOBmtBiTVx91gcYtbiFZRQATNG5ipqEkltofeLD1bkx2b7uWooq85Aez/Jf3imTNPuBInjX3QMXKvhUrVCmnnTYtgM/5HxHmsgAzwGRGIEGTieRXWuUhHoneQxaWS/QwgtFtJTzg0qpL4pmpcFuIflYgA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18b95990-120b-4219-27d6-08db44a4a0f1 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:16:47.0035 (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: ouguxOdE2PQIU5nC2JUozC3w0l6vwBHZlztA+gxpo3qU2VOqX5lVUXTZ6zWWBmauY5j4RwBnBPsh7w7MHwZINdIMwl+QxT8a9gYcewr7mDg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6534 Received-SPF: pass client-ip=2a01:111:f400:fe12::71c; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-DB5-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, 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Exclude out-of-image clusters from allocated and fragmented clusters calculation. Signed-off-by: Alexander Ivanov --- block/parallels.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index 8588c3d775..f389a74466 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -512,7 +512,11 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, prev_off = 0; for (i = 0; i < s->bat_size; i++) { int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; - if (off == 0) { + /* + * If BDRV_FIX_ERRORS is not set, out-of-image BAT entries were not + * fixed. Skip not allocated and out-of-image BAT entries. + */ + if (off == 0 || off + s->cluster_size > res->image_end_offset) { prev_off = 0; continue; } From patchwork Mon Apr 24 09:16:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221874 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 94EECC77B61 for ; Mon, 24 Apr 2023 09:19:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsJe-0006Jy-47; Mon, 24 Apr 2023 05:16:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsJc-0006JU-4d for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:16:56 -0400 Received: from mail-db5eur02on2071c.outbound.protection.outlook.com ([2a01:111:f400:fe12::71c] helo=EUR02-DB5-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 1pqsJa-0002zR-Fc for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:16:55 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EPKy7N8zIqji1fyqdTzYoiClvZIvsHL0S/rwxXAgKdGI028tO2MYQ3whH8v1znuzE/aPpBpDEfcX3aLJXCZ0MThpLgoGKsG/iDYfhznJObM1RQHFQ5x6KgZBI98/szXGAC6QpmzFInWlV+C6w/W7Imr6AOQcxq1e7AezgMIW2DS6MrirqelqqGuyyo6UON44jeDPGLhpPwNCTOJZRPhoZIWKE21ka6btwTxpDqPfZ2V6N2BNBLXxNNAUquxyHiZY2PRSEPZsRORrJvZYIZ8zNPzYhito47exTCG0asKnRHz99FckwOTv8yDWYXZgxtMWjOwSJOJVvNDjk4ZXW3dEFw== 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=FlilXhw4n7l5bywa2l+Kq87+Ffa2JsvoDKGDo7EQJHU=; b=hYEpAjN3ZPXGAYLM6MnpsvBpTAEdB6L12px/4I/fNvYaM05uCLE3Rz0j/Lft8DAD2JZzsqGUgdetCgsnhJ7DChtYeFeT8KLDbDpp9X5nc6AaOyIdFsEVxY/bC9o3c4PtAi3QwnWNXTjBLf3J7WxpfjguvqUM7U5dEllla2spi86R8U1XC9P7gmp/rF6MQIUUbp7q8Vz/UkrYGuJgeZ3UZDveKsNA3vUFU/EaK5DdDMUPEpaWQ/MIiP04cAezUOUQCU1FPwLfAq5LXGFNMs1GHlpPJTHmjYgHmZ9/OOmbIFXLpW3ZFmN2aXH+3VMpLf2XZzLB/v5i1CMvjipIKjXEjg== 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=FlilXhw4n7l5bywa2l+Kq87+Ffa2JsvoDKGDo7EQJHU=; b=ObL8jf3155LDQ/qAfH/P/Vw/U3p3CEfVzSdezOEmKuVWtVeS9iYSAMaZ16B/RHSlWtwvXoHlJUnA9VGLndR3CIWMd+2IA0OMcZlbf2d6jYYJDEn3Qj6/7pUFJegdis1QKjbxyavdO0CEAgM1CwKSoysRYe/YzV+mG/PLfwwmyQu3JBNuwk4yTm2FACWHeE64B48elW9z3SLfWI99cv9IM5FOWAVKHzmd52ABC8ziHtoWlsw3zlVFwEr+VxzA198MGlmASD/SDL+r7Zl0BV9jRn5GJXy7KIdXZF/z31PHgpfk9Bdt+CXIW/caNQVZoHdfYsZ06YN9LF6/21oZgDGR4w== 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 AS8PR08MB6534.eurprd08.prod.outlook.com (2603:10a6:20b:31c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:16:48 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:16:48 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: den@virtuozzo.com, michael.roth@amd.com, kkostiuk@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v11 09/12] parallels: Move check of leaks to a separate function Date: Mon, 24 Apr 2023 11:16:23 +0200 Message-Id: <20230424091626.195590-10-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> References: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0008.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::18) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|AS8PR08MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: a0018657-7f96-4896-c6c2-08db44a4a1bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SGK7pgUrO7CS8HcMPny6mQIQFK6cxuLGmI5paUDQWzSzMZY8xc11/1fyEfKJJ1g8ufWhtZTWbXnccWuKBX1U/QwOaPGoE/oZEixSUODHbahN9TufkxHElTw1AioxT2g4DlbMHDhhhcVzCWLoIhgf+CWCJ3SFOyKUstqM1ly/wNkA2zWZDM+jRuzK+PFz/NUUYouqPPd5OdVNUrdjeQmAok9OtnfV+Hda6gUTRCx+ApwSjLa12TrsA7aekb2CNhsOVH0v338+JsXts6JTxepdS5Sje0jp0I5mE3ivmYYEkrNi1QC/ybzQbKPi1PXsp2vNyqc332WYzjJjxOg4/r6Dt1WDnvGAutTAZa4AQFR/RX+yFp3UDqPPvkzy1iYi72iImXomx3UrgUrsehkqxzM/RObKhTOjWK4ku6h4as8M+sbw8HFMsMOmmjh4kk1ptrd/ghDZY0+AmZtM2c1fiQVqgvtN12Gn2ATbjyHTs2zE0vM5KdEQ9BctqoXEYjgu94J+qIrjGGknOD2Doc4VEH2qUSZ4Rzh/hWWtAM7ujdXj8nKFn3A1q8SPcKFCCTAnhulFidsNZN+tr9oTITKV/vflq+jJ/tYJ5mir1xeFoWym1mJYFd6H5WF1hmqoufWgn/MQ 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:(13230028)(4636009)(136003)(376002)(39850400004)(346002)(366004)(396003)(451199021)(36756003)(38350700002)(478600001)(316002)(4326008)(6916009)(66946007)(66476007)(66556008)(41300700001)(44832011)(2906002)(8936002)(8676002)(5660300002)(38100700002)(186003)(2616005)(86362001)(26005)(1076003)(6506007)(6512007)(6486002)(52116002)(6666004)(83380400001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zkkcteLn+4l675qO23V9vokzX3RMTcRZ4/0r/Bt6eeW/acC9m7y2hdnYUs+BWJ/xjjH2krN61ngjBjLf6yAD3LXWCIviIY2etYnpGc74eycodquj0Q+3EDtSHaSPWkcIoAdZQHc+ewjGvjDcie9OSBLZFURiiTQmjGtovDGOo4ZU1N3g82idwAT7rC1/OgGZxgK2TQj7RHttEfy6h54WdmeAJzwRmHnV1G91NRzF1R0fE05xP2gPCU/a5TN0nL9LcecnzdcHdbXJOoOwTLywHZ31yokt8yD8ECKX99OjGQudbMcJGk0pO2bGhhiOMSNZ2lHQaDeqqkCX7JVHpDrysKozcIhG9GwyUjCRJX0mq4zeD8QWJ515XfBtVQ9LbxxJUZnh9ftlPeTi0AWRGNfmTiuYMMY7mvoTWq8hfZsDFf6Ka3u+bc7bBZnggrp7YjnrRa8w/O5hSGcxteYTnJH8mo1rAjWciwc6XpO6hdpVmrKmd2VFbchiKccrbEg98RLb95MTmwL5CRAkZ2RUET9FE4uAk56hIPs37K4QeVdi6NNSn/y+Mrq1ivVgEAqMi0TugPpgzFy/0u0pgEX/ubFaL4Ws3x6A9YbR+gTvbvKbmQRPcZeThZsPCelN4ghKiqDRNyJw3QN9W8OeLaOXKiGhIa7g9GxGpktH2hDPw2rSnWeKS4RY4ulBkXAONv+qN1M3NlUXMnbAmz31pZNmrtzBLzcrtinKq5M9C0WLO+p9wWekYavv2DWBfA7tK4D/vxg5HrrnNEZAT3c4Zm/ok6A2RGKv3I7iFDIWzDRrCc+xWWR9q/oatkARh6Ol+N4zafWZFNmAygBoJRHsBckqDiNVh4FsnMGwPvt4mHgisRzDTd+VNI1pAj3JUbFYGbaPL/Garw1NQiDIE/JTRn3XPwGpok1yCjtgvaDzqPJUbj9N6Xe/sbzYZHtYkNAZg5QvNuWeashiHJ7eqknkjZkI4F04bcyaUmAkGqH+mJNO2RpJC7FOchAXO0ZFNJfkt7tQcTaEvSjnJW3kVYF3mkMggKm4v5zy6zAMQBkRDHPOL7DG5RgoN3d4bNCTIw0TXnb1BOHncJPq/juJudXkd3iXqGya4xf6TGqgWvzfXMvIKHxCU2tkoo1IM3r/5XAV/Ae7ZvHMDipMQ6ag2EdqgniZn0Q+uNt5IUzZfYeTGrmh5shHCkQ5V2n5a5InyrSKM7fKRLEnHD+S2Cs2JAg3ETqGJJYg7lm5tjufN68r90zZjpOpiK8+1TEcbTemsI8RT0qoSaHEXwziL1d0UcZVBoL+hWSYz3cwJRFQsGWTbGB6whkuv/XmAu73N4jFZUy2Ecwt87/gj1MWUOsTvbR0leOnUjtCriEWSBzAW1eyQgVFOT+7rlNjMyu1Qytyed1LsKYAQC6qkaiG9kYUdGI5gk9c/uyzEsfhNpV3fZegbG4HxvJ+9hvgXR5znz7gd8aVAUSSBCy7a9iGsfaZ0XXDwalMWNQJspPpmZNhtMkMuYvKbn4KSvD4Gm3aYNvFI8Z5VUMnDLxKPWBfmgAEMAb7y/zI7oPzJ68n9Jrpu2Kzq+wDa3VSlPVybxRenZC4TqeXyuTVa1RVke8stGhsPhtas5vrRMO/bg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0018657-7f96-4896-c6c2-08db44a4a1bb X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:16:48.3640 (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: 1nJg8uodpqvN8nTcDfBx0fsr+zLPJ2Pq+cn4Y++UADSYGJkgJ/nd9Hrp29hcz6JunbLst0uv7ZfBbk7Cy2rimpwjubOW31F3yVRAnU6qA5c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6534 Received-SPF: pass client-ip=2a01:111:f400:fe12::71c; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-DB5-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, 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov --- block/parallels.c | 90 ++++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index f389a74466..c3e220b60f 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -483,13 +483,12 @@ parallels_check_outside_image(BlockDriverState *bs, BdrvCheckResult *res, } static int coroutine_fn GRAPH_RDLOCK -parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, - BdrvCheckMode fix) +parallels_check_leak(BlockDriverState *bs, BdrvCheckResult *res, + BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - int64_t size, prev_off; + int64_t size; int ret; - uint32_t i; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -497,38 +496,6 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, 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 */ - - prev_off = 0; - for (i = 0; i < s->bat_size; i++) { - int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; - /* - * If BDRV_FIX_ERRORS is not set, out-of-image BAT entries were not - * fixed. Skip not allocated and out-of-image BAT entries. - */ - if (off == 0 || off + s->cluster_size > res->image_end_offset) { - 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; - } - if (size > res->image_end_offset) { int64_t count; count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size); @@ -548,12 +515,61 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, 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 GRAPH_RDLOCK +parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + int64_t prev_off; + int ret; + uint32_t i; + + qemu_co_mutex_lock(&s->lock); + + parallels_check_unclean(bs, res, fix); + + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + goto out; + } + + res->bfi.total_clusters = s->bat_size; + res->bfi.compressed_clusters = 0; /* compression is not supported */ + + prev_off = 0; + for (i = 0; i < s->bat_size; i++) { + int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; + /* + * If BDRV_FIX_ERRORS is not set, out-of-image BAT entries were not + * fixed. Skip not allocated and out-of-image BAT entries. + */ + if (off == 0 || off + s->cluster_size > res->image_end_offset) { + prev_off = 0; + continue; + } + + res->bfi.allocated_clusters++; + + if (prev_off != 0 && (prev_off + s->cluster_size) != off) { + res->bfi.fragmented_clusters++; + } + prev_off = off; + } + out: qemu_co_mutex_unlock(&s->lock); From patchwork Mon Apr 24 09:16:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221875 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 D238FC77B61 for ; Mon, 24 Apr 2023 09:19:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsJh-0006LZ-H8; Mon, 24 Apr 2023 05:17:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsJg-0006Kw-1o for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:17:00 -0400 Received: from mail-db5eur02on2071c.outbound.protection.outlook.com ([2a01:111:f400:fe12::71c] helo=EUR02-DB5-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 1pqsJe-0002zR-C7 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:16:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EuVrC+PYwMErPRbg2TTdsvQJNgUOME9qfhFy6TiIOG56O9VJ1TvF6mVeBjopfYI0QF8/8OZ9lgLJnhFsFSV8GQsMvaVG0OWmjaX2HjTRy5w7u9Bomf/2wa0QeosikbCVnU27BCBzD+9VK7KO4t+RAWHyIFr9XT83jM71E+TjnF1+qTM18w6je/LyARIVeJgRBp7NZI2B8xiXDFa3VtEZD0C8WEXVbsv+800xgU4mM6Vd9mBJnQwzANG2MxMhLMyi6Ui+AW/jl/Lq0SHxy1n8P+684kXmDjM2nwDujupLrZXlaH+8M5zpP3FRU8ekMxYe7FZZYIhk2UXs2O1GeZr5fg== 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=M59z86ocTmWdEiULiva7UwJlxeM57dsdQ9CRBOMRxpA=; b=LKKpDl9zqRGN6UbZaHa+bxaknhgOzV60ETJq+pYjPUjghiO6VWzG4VEepMhVF1MAMI2XoITUE2jg8lJTHv62FVLfL/z4PhJwHMxEYX6VyyHRel6w7HB1/en7tJSoOXXbh+9BHiHtg4QT+md2tpBjomTP56iUSIfts8taiwwl+/jE/6R1HrxiPhLwkXdnUk8fntQkS2VIl0XTO6GS9GwGiRDmOuvFlo1BwoQBViv2dNAgpkCA9rc/7/Ud/vounfSpYUqh1jwsF8lebp5piFJ0iE3zxa9X2wrNObkn57+tPj/4bpJT/dab2iGo/YXKCTtysNoYg3F6wmMoLZJ0FxUckg== 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=M59z86ocTmWdEiULiva7UwJlxeM57dsdQ9CRBOMRxpA=; b=BDZAZRxRAC2+TSU5DHfUa1gNgT9mJv4k/fnCz/AC/2az6BS5p9MZl0T7HQ9aZ2AGiAxWzRyCG17GZ9v1CxUCxPbF2XDJSHFUbVoMykm6y3Mw6EmPW8QPGr7zrXGYtSn0+N+kJDIwbflzYbXpLVQ0o+sYyYfJU17l8dMJUPKeiD/W3aRtYX19BYhXKg/HFM+TD9y9cEMpvJWLtJOrXn+U6FqmqFwFi35XQHYKYwMeGNeIC4GAL/E8UzFvpgjN3Yxb1Qud5WhSAK3RWjZ3rnG2n/NmjVnLGzKnCXtBc6mh9a1CwURv+HgtKp3qtPSGU4hzyG6voDSyrxnfRwyIiorRjA== 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 AS8PR08MB6534.eurprd08.prod.outlook.com (2603:10a6:20b:31c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:16:49 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:16:49 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: den@virtuozzo.com, michael.roth@amd.com, kkostiuk@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v11 10/12] parallels: Move statistic collection to a separate function Date: Mon, 24 Apr 2023 11:16:24 +0200 Message-Id: <20230424091626.195590-11-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> References: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0008.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::18) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|AS8PR08MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 32322146-d861-485f-3193-08db44a4a24d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4vT0yqlWOCG0cEez4Vz7d8pPPYZHtNv8EjYD9kPRiesAG/LIMpoJ3BpNO4Rz602ci1amKdGREfsZRnGzx5QhVruSGVbqrQ/LfMm8gNW+wSDg0WeX8xmVhRnJs1nG6ROZAdgc41M5daD5J/ead+hxdDpYkNDFw0F0j21VQejXbRKZe7UQXAAWbX8+NF1gOIoJRJFQ7ZEUdPBJ78B/MjjlpWdrNqPmSSAUHArQpQ6VZXU+0NHo/DUqzXBH0u56R1Xn97caRnBFHbDW0s3H1lmPPx7O7Ok735DGKH9GHWGDQGszbHRIAJaDSMLmnMZKuijWLljObe0nFqSdfkisr2gHIYkebJIbZQGIB3r3GDHlc2EHsrnM9E+pd1Qb4hBVri8PpIZrvx0Upv65a2/+16R0QFXnnG7wggj0+OBlSBoEXIvvsxrVQEwExP7mpELjlsd2Asuc16Vafmm2DS7nO/oL1zMfxdgNo86XPb+wcqKzaapFBenqGnEZDa8HYpSv/a3AqpoKpQ9lmoAioLJPa4YL/klnlf3AOa8kaXq3U1IJp0vqIi9XYMTYxe4TxeSjRGVclKlO9zzfJc+TOH9PaZp+Ap/dtG3A4mE+2ePCjEfjZg+ynOVe/h6dCibI7EF5k1vT 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:(13230028)(4636009)(136003)(376002)(39850400004)(346002)(366004)(396003)(451199021)(36756003)(38350700002)(478600001)(316002)(4326008)(6916009)(66946007)(66476007)(66556008)(41300700001)(44832011)(2906002)(8936002)(8676002)(5660300002)(38100700002)(186003)(2616005)(86362001)(26005)(1076003)(6506007)(6512007)(6486002)(52116002)(6666004)(83380400001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ra+bsqVxxNTKUsZUryRceKKZ1l9y6lq3LFE4WpQwjcEeaXmvdBxzBK0L9XH9Y9BKeanyQvXZi92qIB8H7pFSqHbuLIfe8y4JcLzFPxccHmVmiDdnrk/ISvPzC0hdJDcHs5Anr1LvNl+hAO9nSNbik1dVFZsQ+sxLaiQRIcuHGyDbhOQmPicX2c5OPrzoMUdELo96r1EEKu0xO7UD1jb0t7aRt4Gnh1rGqqymHOLrGbgXp4FQs3WZ6/2IyFlWeocasnderQ6kghznobbXNqga8Ohl3mzjhMWnz/GpbABilbPm5K2EFTD7S3CC0InEb79Nv1385mKyTcZ9lj5YB1ALseVqhpVEtI9a6pFPAC+V8A972vDi702O3vsjb5FJNmWU5ABec7gP9Oxer0Hfj8T71Lxzc5afvQ1dpUpSYlveCWBlXJ0MeFxE4iNd+d204elUsud9FHG62AstBz1OpHRzzZ2+JW5z2/fqKQc4yn1m2PGWNvSyPA7IkZSX60GCzLLEkg5bXGol9WC+gn+daozh6vEf0nRXsvt3BVztFQRGukX07ExgwzqfYTk85hpKynBu1jhfhU+Yo4aOVubea8wwWrjC46AQExUL+Ja7Jdx732hgGbRR2X6hgFAitZ9qSLfWlT3PhT21GgsoRkgAhhFoFl5Z9FXQEcvs6vT/AJfMhRH0PNf65Ja6OJhw3+XNcXyaSMW67x000oPJDgmJUcE+SQPeAkCrZHhU2dmLm3aL/GKBR+S4Md7uQWALyEXD3wh/0XdAJRyDhwjjjc2vbIirB+iu+LFyP6LlPM08Qy44NV3OQHkVikuiFeJZYIVSXyq70+FOKyfa8BLB5N8JvOveUewiSF07bYfmapD+7mbENGh0hrecuItVcZzgB76rSAsaIqn4gTCz7oQdCnKqsN9f1kvh3RdCFnZ97Q0s4NoYkea+cim4eJSElfYG7eYaM+anNdLwZ8NenSCYn3deYXinXnzd9uNndsAxM2UdcnTf1EeamHnXCmbkTjquy8BScbWbN+kq9VlWPcYrr2rEA6eKcerS+VRLULx7Z06PLBXsJECVgj+RYbJi7CvhFflO6dJz6TjXxm7acoD+MYGbQQQW6fLHG2OLzyAhTV7ANVBEwdHvFGddXYXObQcL1DY8qzYxCYchBUSNqb44/4XdQjsdwMQ6E2baAdQ4eK66RxeKx/4CGPZ1PT8NbqlQtgzq/T6Axlhq1wjssTvZNEiPm6PZi28j+iOPDL3QkL1+RVV0iShzOEupEuAvY+SSNLAU/mMCKdtgmEyUkCec2hZTh6jMSeAvj9F6amSoRZOk8KFiegwF661QRFqO4P8EGIWkR4udvVlJe9wIqVlkIOGUY/JDHMHMF9mpWe8xJH1N6ptZ4spzEF6+Pu6raq1Eo/gimgJ4vodH1C2FFQ0LhjBAQssztHovGpcJmHdzlGrVtiFuV3NJKiAWJgGipI0/A9/bYCoJnSmLFSUciQYWiEFheNf9lvgF9/kKiNGy5Duqj6dZ4MVJvCavTYUKqjFIKiIn/gxhuyl3qRIUcpfvySJIDh2lK+vvYj84pfFAy4lgqzGN4WTcz+uIy+BEfUDhuv+Gcn4Utf+VDXfGanNNH9Yv88ykTQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 32322146-d861-485f-3193-08db44a4a24d X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:16:49.2493 (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: EZ1X8FuRR8pVXGfPHkH0HWIMCNuhbSh+pTuxuX7zEvcRMIa2OJ9MBNj1hTZms5bDCzwO/0xQEWTviGPjytVVV0WBAPO59gEtEchRBO4RKRA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6534 Received-SPF: pass client-ip=2a01:111:f400:fe12::71c; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-DB5-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, 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 52 +++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index c3e220b60f..48ee5224c7 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -524,35 +524,20 @@ parallels_check_leak(BlockDriverState *bs, BdrvCheckResult *res, return 0; } -static int coroutine_fn GRAPH_RDLOCK -parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, - BdrvCheckMode fix) +static void parallels_collect_statistics(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - int64_t prev_off; - int ret; + int64_t off, prev_off; uint32_t i; - qemu_co_mutex_lock(&s->lock); - - parallels_check_unclean(bs, res, fix); - - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } - - ret = parallels_check_leak(bs, res, fix); - if (ret < 0) { - goto out; - } - res->bfi.total_clusters = s->bat_size; res->bfi.compressed_clusters = 0; /* compression is not supported */ prev_off = 0; for (i = 0; i < s->bat_size; i++) { - int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; + off = bat2sect(s, i) << BDRV_SECTOR_BITS; /* * If BDRV_FIX_ERRORS is not set, out-of-image BAT entries were not * fixed. Skip not allocated and out-of-image BAT entries. @@ -562,13 +547,36 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, 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 GRAPH_RDLOCK +parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + int ret; + + qemu_co_mutex_lock(&s->lock); + + parallels_check_unclean(bs, res, fix); + + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + goto out; + } + + parallels_collect_statistics(bs, res, fix); out: qemu_co_mutex_unlock(&s->lock); From patchwork Mon Apr 24 09:16:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221877 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 2F35AC7618E for ; Mon, 24 Apr 2023 09:19:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsJj-0006MH-9g; Mon, 24 Apr 2023 05:17:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsJg-0006LD-J2 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:17:00 -0400 Received: from mail-db5eur02on20710.outbound.protection.outlook.com ([2a01:111:f400:fe12::710] helo=EUR02-DB5-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 1pqsJf-0002zf-5w for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:17:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dPF6YHnalMO1swxIdR4ec4jrHLeQiZD6f4/T4jcr0CWs2M2azL2UAxerMi1IsalHZ1wzjRSwOTvRAJ8D8FFKsD7KKw0F3Xt4eulsixiffAWEQ9Id9v0YaPfW9LkOgJ5CX3ECrNrOmdAcICDCVrU6uo3kAdc8dx2Nl3hM/4E1mOu0TFMyVlTq84qK3nR38DIFt2d2V3hB8OcotJAGCSXll8f/7uKVNOPDIt/9VsO6VxYCzrl4XSd1Sz4ZhsOumF4vyJSwtrh/M1ffJMNsLp0SitHq5YjrFFG/vpUpEXEFTDWXU1bSk3OovtTn4ZC2prCOXhW3DyGrulVBQI6cX22DsQ== 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=kedXKnE+fbWyxSCs+643SW7HHz6rEerQzrdQaqVHiyQ=; b=BZQ2N4CGE/SuibgcEMEbLtSeyG+8Ez5NrEQtl9UOxMElzX837fJWDg+K3OgOC8RkX72O4Ey26QEJe5+2RvLv7RvWd08tI9/1iaK7bA0RqhfHXjKzTQAkJXhwpestVo47XRpl6rHxSRJXK6lcEpxz3sX+chjYCAdUkpOQXgObF805oX9vA9f1TE44e1OzOTUIi5UjqdAcuqXq8SXsi34qmLq6eex/+uRf0hS8/SFrdYvCLyPfz2CD0v88OjWeP2fUF2Qr2/dEh9IN63Vu7lkxQlOY5Zs9uIZHfJCRXhvFYdtP+eEnXnOZPxLHokwHZ5k4cWd8bBUWz5pn4eQ6yRsJcw== 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=kedXKnE+fbWyxSCs+643SW7HHz6rEerQzrdQaqVHiyQ=; b=tgxB2t8p6ZadppavrsLHJch8PAXXWm+FwA5g270q74QZB6KSeXBgl5qE36QEJ5Jff1/VvlMCR6wZIUH9geFTXbWFX+/mJVglqZ1Jlxta8Zgmz/sdfm5K2fPHpH5xA9CPDwSnH3EyqpLhqDA18HD1VI/8XCUbJ5Iphmaixhm2418YaqHEGVmaJgGJWXL230RZYr9cLRprlMeUXszz/jr8kZOX4M3ao/x2ObpmrDnItGJBJGHhWGy+NNcRQM7XEKz5qiwXbCcb5Fkv/RxWNlKGe2Y/NPHG2QcrRbjGE4X1da1xuFArqMBriEnftSorFYEYK/+UMtDF3o2dwn6k5Q4sAQ== 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 AS8PR08MB6534.eurprd08.prod.outlook.com (2603:10a6:20b:31c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:16:50 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:16:50 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: den@virtuozzo.com, michael.roth@amd.com, kkostiuk@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v11 11/12] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD Date: Mon, 24 Apr 2023 11:16:25 +0200 Message-Id: <20230424091626.195590-12-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> References: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0008.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::18) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|AS8PR08MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: ec027952-5ce3-45ce-3b28-08db44a4a2bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AJ5zxdQSaJH+5LgjBJa4Z7s0yszwG8OnsIDMf/U9DabeEe5JwgmPaG1brgEs1jIpExNw7F13SKf8v7csUSZPRDBF3prGOSyJYsxobxebina8jfsY/0mJQNBZ0z50/CcOlRlsuu1pJaat0aIOPTlyrF6Zaj60DY8wOCZN9U8sficbpofDXfS3gUTK5qbzYxfrvRgXpJH8xLVZ1dQneVn8O6tIEM/xYYRBMli/6WA29gPoIFLgE55TBTK4Kr/HAMQhT2yboSDRLyII6LKFx3CmSB6NVjJvIYFrP349yyvCGzsa91x2+VlNmCuGHy1c6Brtk1dsEkwhEyjOcI7zJT6cdGDV7ajFaxJDZ6IgP2AFyhiLp9MARLRrKKNCOZeyMKCPPpH7aj8tStOKPVKvCJ2Fa29h6LJkhIHTRuUW9LIu5hkTvK3JRll3zJU4LbmYTcior0mJ3+3iIaFl3AePjfirMH/bx5w27raT1G32jm+v4wqBLYjU9eR2XG0oG2gAkap0KJADKJ2hMQdp4RwuiKBDAiGzyGatN9NPbNDkLiNjuJwXpuz+xVtwSw7nxKwNTxzu4qkSTnsFG7bi3MS+oLgJTg18lVus5o9lQzWpCnK5DndzfkmlajqtM1LOFedbkfZ2 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:(13230028)(4636009)(136003)(376002)(39850400004)(346002)(366004)(396003)(451199021)(36756003)(38350700002)(478600001)(316002)(4326008)(6916009)(66946007)(66476007)(66556008)(41300700001)(44832011)(2906002)(8936002)(8676002)(5660300002)(38100700002)(186003)(2616005)(86362001)(26005)(1076003)(6506007)(6512007)(6486002)(52116002)(6666004)(83380400001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ur7rdU+1LkBS3yAFq80BPPbFT4eADy2pQaOuw40Qfg/EgaIpCdmjKAA08XJZysKcaydpOKi/Dj3rAf/LK4+OcKW2ez72k6Vcz4Q52PNVF2kS8cpowxk87rBtqmvg/H3SfYn7+3DOob9Judxg/Pnq0305jIuqLJZhccSyZv3wK+yWxTvxtoxS4iiiVmBycbF0jxJOZWtVsBPUCfytdORtbfrGMl04jFOpP/mHi+VfPLgUQef26rCLUKgTuFPvCGCPsuDZ8zA3pQVSgm277gHA06qXrIVhWvKl7714pykd1shBv8v6K9YVQjQJnvbgpQP25yl2Xh1Akdt7RsebmG0VoAUyWc+ttnafy2o235Cmjim7Qg7w8lE3OmehoGeMbcApsueWBJILjMEkUPjJoljv10JW0VRzHupxk5LOeMI/8FDXSFvdS7XNtDsRdOk1JtJBY7uPDakR/C7bXXqN6r3/uZLHjVa55tppvSTUgQ6nWb0nAbvDyIpTsRHJVylty5m90nMum2EdqvJmelJXIbLS93ZzH4BunQpExoEx9lePsvMG/UEbM9gi99J8DvBMh3OO4yf5WCdj9IvNiRUm+6ZqIh9hOqkvfLad07dobYt/yXdXmxX/abIN+jOWrUjUS7N+SCqy/B/62l1+24wcbW+57etvPH7+7fBzFxI+kvpAZoxv6Jj/WPSSmHqn4CClGZu3Vd3RQoMBG0Kwpaaov9X/RrzpDDJ4Rg8XgkKWM5vW2Fe02p4IG3ZhmX9xG+YSZ1fNb9IG64/SeZ60oFcGUZ3OZQT58Z0gUabkAyql+204pL8Tc54SNQK4IMrR+u+5W5lhUyA017ZA+Zlqzis9BfN08US7OuaySLTv37+3Lx5JQgCeS3qEiDo3XDhVFEXYg2hHoQhtSwxDjO9c8PrsDUm9IOntf53BeRedKyZ50prnwMlkrCqhik4j24TI5iv771YL+iygu9q2CvaeaKLb1Wn33udEiU+5F8xLZODprQgdcFpe5wpjB8S7pUqtoFE77M38mUnR9Lq0XvN32nOaScln7DGNf0pvz4Pl/dFRRMGr4hjmWqinqiL9JYBetc6OsF+jVQA+wdGLCuDNGJXjhOUEwnHMKFn5dLcawFxmc0zlIsr7TTZ2/P72f6YA+L9ns8KShz00SrZKpmVhvOC8TqSp0if//g5EdAsm8s+oA1bCz7RryQ0bkSfoGcoeqj/pIQUvsoTHe/pjTHA8vzUy+FStIkaL0u8kE/hx/GCQqTLKAp6v34LRhz8omdnm10be0qLvG2DCH3c5jHRSjA+j5NcxzGFlCeDdGxoBcawfa4jgi66SyN0b4MMNz3nclz0y7sJw6hptBvR42WEanHcn35kyXeuaNEl/2KlZsQygGnJJfyvUeE4tjzYxqRKR1kvQbPsZQwYkPGCrx/fNnnVPnx3i/1BG8ofQheRNGZAd0bn43b+DF47JC0WzGFTHis7gR2SlMuYb5xG2hroNg7xsaXax1oli7u+9PKfLzrN4JUM2sFeqJHrArJtzcoJ4Bnz/sf3JZbV8J1IxeHazk+Z141syf9IKLZeFnamh7paPPQLJCq80KxXrp+tjGKT5wpVG3O5Yr9xfJnYDcM3dDYdn9H5P8A== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec027952-5ce3-45ce-3b28-08db44a4a2bd X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:16:50.0171 (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: jZt2Jzpz2SQwtXrX72GF/FmkgpTWtJzXaG43iE2OWE4NkCRX/QnlgGHRtP6FAya+1r/pR5Y+vWw/gZFuik+akFlaTeepnxM1k1DmPYeGtNU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6534 Received-SPF: pass client-ip=2a01:111:f400:fe12::710; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-DB5-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, 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Replace the way we use mutex in parallels_co_check() for simplier and less error prone code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 48ee5224c7..a6a1c7ce0e 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -562,30 +562,25 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, BDRVParallelsState *s = bs->opaque; int ret; - qemu_co_mutex_lock(&s->lock); + WITH_QEMU_LOCK_GUARD(&s->lock) { + parallels_check_unclean(bs, res, fix); - parallels_check_unclean(bs, res, fix); + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + return ret; + } - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + return ret; + } - ret = parallels_check_leak(bs, res, fix); - if (ret < 0) { - goto out; + parallels_collect_statistics(bs, res, fix); } - parallels_collect_statistics(bs, res, fix); - -out: - qemu_co_mutex_unlock(&s->lock); - - if (ret == 0) { - ret = bdrv_co_flush(bs); - if (ret < 0) { - res->check_errors++; - } + ret = bdrv_co_flush(bs); + if (ret < 0) { + res->check_errors++; } return ret; From patchwork Mon Apr 24 09:16:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13221873 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 1B10DC77B61 for ; Mon, 24 Apr 2023 09:19:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsJe-0006KN-Rb; Mon, 24 Apr 2023 05:16:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqsJe-0006Jx-18 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:16:58 -0400 Received: from mail-db5eur02on2071c.outbound.protection.outlook.com ([2a01:111:f400:fe12::71c] helo=EUR02-DB5-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 1pqsJc-0002zR-Fo for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:16:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FUifEORzeTR0nwHo+xXnnzU4UH8laqMzjho5HkETIWf6NJu5sNaJ7s8V2Uz3dmDnJ2T0DckQs5l32CoI2xwB/TieWMoOdSHanZ2jjlQH/J6/YJIhTSMhqCwhVmnhpq1599Fsrs/SZ1NFiA5TjbvDnv+rCJsJDM7gS6aR78/6pFkO3XxHEh31cuMvBgFKsd5zpYzq7IENXkNJyWRgTomNf3m7nZCii41clzdZGZwn5dEgu3q9tQ9k87eT7jnvOYmfE7PDmVMoQWKLnkZzpe5nSJQ1S8TWvITOmu34xixfw8X/rivuj7NYwY6n283JhPg8TGgf79f93pGpvbOm8GFznA== 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=nx4ydLakxGaxs4rP6xdhzZCIhq1dnfz5GYSH+RoWka0=; b=W8psnfkm+oHTcn/zlj6GaLkiZ6hFqcgX0U9Y8OOTDCg0aSdAeYTDkO31w3vhUi2dqvKnwLiOZLK2dM9DzOT/tsM3N1irmB9LEpcDnGerJh0PQZs3mcuojiQRoMcIwA32SUvX4QqHIGAR/3SNnWx95juywC/BTYUWecC7G0cB/NvwHGZ24FHr4lZSB/WXkBj089OeQ6PhPtNeHKtB44lgZGm9V7IiqwecYft4CGdFwmb6X08VDU5gPbheyaiPPsZEsMvpeEHQ4mEHndqTx7ARG8T30G4xOxeR6KBL0JCMHW8GmhshQa6MI9zb1GBZ0ugE/H3fTGdquNPl69GRRiUwaw== 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=nx4ydLakxGaxs4rP6xdhzZCIhq1dnfz5GYSH+RoWka0=; b=Do4YiMqUBytI65uYwK/Cui7EFS7Ex8nbYv4+FLPWD+gH0HjW3kxxg7ZH7I1ipFgzEKAHPncHgOpaYxik/PWaWsVsoa3VpT6BX/8KPwPdGquuoD0ykjwVtV/ceDOjq51en8eyOCjd4WGQbDvJOWMW3ArNBLqzHS49BTtW8NB0Hs/XFlr+IRgTT8UMp/16YZkw8w3Bld1zKOlqVYkHAwJwlcB9wSq1N3qa/8z077Tw0PgN7cv/jgSSFSwAEWElJ7NRbyOLBe12C/E3yJAqA17zLgPqClUUweycg/OpcBeI9PTN0sD1hZhqhBrmyFYQLb6TrkAD13BDMylTF7A+tRG1GQ== 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 AS8PR08MB6534.eurprd08.prod.outlook.com (2603:10a6:20b:31c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Mon, 24 Apr 2023 09:16:51 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::b630:c4eb:fba3:1158%6]) with mapi id 15.20.6319.033; Mon, 24 Apr 2023 09:16:51 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: den@virtuozzo.com, michael.roth@amd.com, kkostiuk@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v11 12/12] parallels: Incorrect condition in out-of-image check Date: Mon, 24 Apr 2023 11:16:26 +0200 Message-Id: <20230424091626.195590-13-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> References: <20230424091626.195590-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0008.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::18) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|AS8PR08MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 13de4301-cce8-4acb-4033-08db44a4a34c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SUUllHgzK7NkR3WQjD6yB6M8g6KzJHHL8lL9b/QBw4YZXQysn6sSIZREcuFTtqR9oFDAmVCSiKllFs/ASEgL/WFIOsQ5O+P2VCAHgKttLavsan+3GL8xGD0fBym6fJYuuvKx60te+zBTv36JH+YgE8PGaJy4ynR26Qy67rg9ykNTycvXuiNXu6jR9HyZV4asKa+SOOn7gC2TNt5MYEwOFMjKFle9X0sq0XuLCdUrMQjgbWxnIv6wnuhiWVrQm9hihLarb8KRhMMSOkuwkSQ+Z2HCTW9mhX2P1IDn3erQWVh4gyHsBIfnn4ud7W7dDzNpuswLxwQLCKPi1pZwrXKQ+4q6v66yEAY6KZcIQeTJGaUNDDpWYYd53SH3QZuMyE21qG7BQsrHGFp40LhRICluycVHQ9zdE5zOzgdO7XUMEnPQurZNpMzzRv3IQebHWGqTGlFZOF1a1dAHvvUlS25Hc5ZJiE0l5xI0l6GZDhrnDZ3ooQADkywwMUb4OSp7aapvRBnRjr3kAouPUJEHfFwDKr4SoPbn7oEYCYxUfUFadDriAzzU5wVPWJIaaJbgBaFFXVXojeBsu6l+MEbMdV1R2STDJvrLeMKx81BjXfKwfxQOAs682wwF4fBYBHhFTDvE 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:(13230028)(4636009)(136003)(376002)(39850400004)(346002)(366004)(396003)(451199021)(36756003)(38350700002)(478600001)(316002)(4326008)(6916009)(66946007)(66476007)(66556008)(41300700001)(44832011)(4744005)(2906002)(8936002)(8676002)(5660300002)(38100700002)(186003)(2616005)(86362001)(26005)(1076003)(6506007)(6512007)(6486002)(52116002)(6666004)(83380400001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: obb4W8sPeeqeRn9484GNUod9f16qHETQnl3vBvphWG/14b9xQ64aJFpyVATV07bdvb0a/YKSKO49B9vVNzLlb+0iNfkwowKu67NP/oRgOFSH+Gm6JwgPAsotdOQiS3N4LqGh9b0QfivSEwMa9S5sT80QaZZdpG2a28JzxaJvFefOqsU2ZNhziRlELs3/7EazvHhzK3Un54J+LEJVN0wmDVCTnNdaM63rxwL0b3ERymqFy+GztdnJl9Hq8lSVI/eJFvbNz1+NvNdS2dMUv2ACB3Nfg605WOXcaydHclUUZIUYLjSMgF/6As2NbqsWOR94ZXmsoArog6mTsphOEavWaVzWe8p+pYZR8MEWAgd2aIeqKMSetPSy+0K/vd+GaOvUPYuljSsrFFJ0Aq6QSQKCfHwwPC6rzVStqizigjqzmuLjhzQk1v6UyBJiPeZ6mClg9Kq4CxOrMgBjlK98t2pBCrpVSGj3TPYx6VdcWqSkcRgcckBlbwFB3fg1Voq8PvoIuCB6DGk/yxbvg2kuBzWWWk2gMrtDgwKonucdrvRceWG624lOV8b4FPjStzxPjP/1ZT+djtn8Mmwq1erUa4zIQPYThLjEYlHFciJVfHA4QuzX1UzGBWMVC+jzZDYyHunZlrK9Cvdw7Faj5pqfSGcuyIZZWKPPQ1gWh1MgzQrV7didUBv1k1WH9p102G91CEuR3/AvV9m07a0RWnPCSyTD7XtSayyZx8OjgSybFHVr5l5IofJIpxAGX3thjMSLQkV+QDVRXE+qayxbUKfD8i/MK98BLPGh9XEj3/oNuir3YM8T8quhPo0n6ltFvBH+JvuSkoiyvPPtqSrdhKDJ4PxWnX+Yuj2BbLQyW4fwUNtb8+scfQ327QhuZ5FDezfV6O93SDaWBLdlbcQx13QYBTOyAYQV3FwaQwsZAAnZAkhWNhSOTBWUgOZRuk8VP+S9RndaKEQWqXRw0svnZMMopMdH2Qa2bp2eW13WmlIUptKvhGfMuyzhUCcrfrf05RqZ/2Frn3UKLnWayjcJcEGi4Wc6kdYszezAk7K/O05ayVnyHHal0nzlp4/5Y6SxzPxsy4/S47hEus8sUCqZkKI//AbSeX74VSi30B7TIygk7+NceOiC3h9VziXxQkV7Nw8DrhvSptXAqEEWI6TcHbEqeY0VmlP/pNTwiYasC0OoLeOeXWFbODDuIemVURmykZ1yZx4XQUiBiDl1APscrd9MyRPauNiPF/1hrMriX+kaNe0EUptsYMusEjoUP+H0zfecjvY6Up7didmTsiuNJJW+Xqr4R5ihprYEH3ULRwKEs7Spc6+q15iuh8/6HIpunT6dw4Bucgb+Gmrcacg84p6YhsCv6FnLF0rmrbaFuTIpjnf436BTDr5HNykptTydB1f6ADY7vofCA1kG1+1aQFdlvoRlrFHbBHUBXCWd3tFAfTkJdog9HpPtk4VVJIcKTazdggAsGiLxwoIpQjAFLGQ/ueqI/QolgYkRs5LOgLYUAyMmVODW7fHgmcqG6Y1Pukfq5/JSSYlzl0E+81SCDqSWHvsiy2lvMouRqNLf2CsN3kG60ZlXouuGElV9eBuwXGhMBlG2EoWLDw1CeT7g0ICdJWTWeg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13de4301-cce8-4acb-4033-08db44a4a34c X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2023 09:16:50.9984 (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: C0zmazudqfALq42qSCpNp+/HCvdwPg9/nN369KAOgHih6nh6rFaaqQQBfq5lNVjng9JsRbPPfZT60P0pgxWVd4uRtiPOUk8NPiMrQdRubwU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6534 Received-SPF: pass client-ip=2a01:111:f400:fe12::71c; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR02-DB5-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, 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org All the offsets in the BAT must be lower than the file size. Fix the check condition for correct check. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index a6a1c7ce0e..ce9ac47c55 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -457,7 +457,7 @@ parallels_check_outside_image(BlockDriverState *bs, BdrvCheckResult *res, high_off = 0; for (i = 0; i < s->bat_size; i++) { off = bat2sect(s, i) << BDRV_SECTOR_BITS; - if (off > size) { + if (off + s->cluster_size > size) { fprintf(stderr, "%s cluster %u is outside image\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++;