From patchwork Fri Feb 3 09:18:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13127265 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 8C01EC61DA4 for ; Fri, 3 Feb 2023 09:20:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNsE0-0007B1-BT; Fri, 03 Feb 2023 04:19:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNsDu-00079j-0d; Fri, 03 Feb 2023 04:19:10 -0500 Received: from mail-am6eur05on2072d.outbound.protection.outlook.com ([2a01:111:f400:7e1b::72d] helo=EUR05-AM6-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 1pNsDs-0000nb-2n; Fri, 03 Feb 2023 04:19:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NzNsy0f/nVvm8HsRyXA5YPmjKfNDl9UeJsNcfU9jEVsabIZW5PG1ECbkzSzMirLNi/uozHLWDVdRks5Uua/JvFuJ+4dUnfNwy7hophJKwITkmrAM4WP4uvNyutU859k8zmAgSx/5PqRBdEbOaBEQ0zN2nZwqYZyJH07GkO0fNgFNkDhZvw1twmspEDSKei43sRzuzBZmlg0fbw8du28fP/w+dFT5sOtcQ67JxcJz91xYXoYMisTdmxBhezSUgu8XuRfWiED1wFpoFjy/puHycTOxEyIQPWu9BPHIsjOMmi8tCCGs81c0jTPWVOyYb1R2Zzh9znD4WBZzleDGVg2+0Q== 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=tzrCE19U5Bc+4gW+rzytIfAwTYgTCv7OsgBMKOeLLug=; b=FX+uVQT/L3XrOMvIvX+V5wPAERKvLlleTgTuBvCjxx9Y6GpGGJOYvHbHKbKv+7Wae9GZzhBVFMdWijFH1d4EPN6C+AaR/PQepWn2/K1QxfKSE9OVIE8JSg1b1OgTna5zQaxOvlVTqrUATtXLCN6UFEmvqteP3ENh5ynwwNt1Tlp3K1zXMxoyqhfze7ax0125iXQpPP82Sw0TtUava6gjIUxeVXq64a5IW6rzfjip1FKMM3j27+lDty25HAcV62Iieo3/Qu2RWd585hqxLavccspVt5wekBvdnQJW9ut44f4E6oqrpsHz6UTUQ5GFpylSv+wEgp9OExyh8JU9XmT9Aw== 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=tzrCE19U5Bc+4gW+rzytIfAwTYgTCv7OsgBMKOeLLug=; b=XmXM8NwqWUu9kK6KEtI+CaPeR9Z60q2DWv0ezyaCY4OdMIdwpN100oI0bztaacCv9vYdzmJLpXw9k9fpt17S1HJFW4/VPYqIHAN8MImzpFZlHiFbPtHsSyLL3Y4pxqUWJmd+voXbywKiPsnjSZzZroxNY5p7IJrNsDYkZFyc+zw6r6zWinHfA0bL2bye10LUn33DH26pqck96LfZpJRnFIxMApqaBh+ylRdCmC8aYCpog1EtMaIOOd8TegVocJPgHS0FR5PKkGhcqUyZYalt9YdV3UUrSR6RUv+l3NJrMRFcvMqqZ+E2LhFhf85f/hhtxGilVx4jLIL3Yu4PT1D4dg== 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 AM7PR08MB5525.eurprd08.prod.outlook.com (2603:10a6:20b:107::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Fri, 3 Feb 2023 09:19:02 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 09:19:02 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v10 01/12] parallels: Out of image offset in BAT leads to image inflation Date: Fri, 3 Feb 2023 10:18:43 +0100 Message-Id: <20230203091854.2221397-2-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> References: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::33) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|AM7PR08MB5525:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d2edd4d-9fd4-4b74-d0e1-08db05c7b0bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hppDnuIjYdHiSP0acn5VLrXS7RLlOrSb55bdBzQGD/rs3i1APHR92+j6eoEf6hXFJzWha8jXU4gUjIiLT9XSAf9zDJ5rzIKmey5QIQp6X+YXjA5BARQPWS84Uwd4mfz6ZQsiOKv1x5riVCYzmgPnySE/KS+uJkWEDvhSGAs4nzPocSkgIWgxr9Xh/FJVYweqCBRGpfrnRW3UN/fS1vpRH2ELpATrWKnSdag1bOScLXLFmaOUNyBtC07krkW7Uh3dK4Kw8kt4oaYJO0eQvnfa1uQj2VqMR8OG2aXRJb8FY361Ek/w2djykEbCPv+hgLGfAkHAM9mvnxB38AUXxkASjMjV219HCnF32sl7c/rxthKX+P9NNHHLKXmvo0Z6UtIf95VSsPkc0RRxIjzQgBq+UE6UYVcmF1YpDs5tf/JKbgxHUeW1m2kOt3IyiWu5sYt5xLeOYxduqxGdvbRgsN/L+zQTvtAOEaMXlS1XAIK2P/OfZzVxvVy9uIv6ufnv/RuT+7/5DfoCOgjEc7Biibb2qtr6+qI6nFBGb2XjDcbhw1SQ1mR/Xu8pjl/i/BJc9TwC/13bsJZGw7ejSHbYJ8ZbraUSY7Bv6ciNfxxaGdIFONKWbzpqgtB8UeJGl4a66/sbuoZkpyuWQOQsCSYkTBTe8IYYC/hNFqmPgToSG3ei5iMUJd8/Aeqnp8wkDw9MRBWoNsRnnZlZqdil5CNEa4a8JA== 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:(13230025)(4636009)(39850400004)(136003)(366004)(346002)(396003)(376002)(451199018)(36756003)(6666004)(478600001)(6486002)(52116002)(6506007)(6512007)(2616005)(1076003)(186003)(26005)(66556008)(8676002)(4326008)(41300700001)(6916009)(8936002)(66476007)(66946007)(2906002)(44832011)(316002)(38350700002)(38100700002)(86362001)(5660300002)(83380400001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YmhMFErVKD8haC3gxQuB5QrEvdWxa7SRZqitGvJjlmIFFF0T7P5AKBPAN43ltb2fD4NhMyNPJ5gjnjTk/yAhq/JhEpWvgd8YvroACzlnJ1nufpaBH2Xog8w/ZuE4qc3NntLQYUVjxs1I6JJq/Q+HsUnALOAqrOxUhBLgiKENRJvRUoFcRTQ9+BH2IcOOrzgAKnZfBoRUbLARXDRA0n3VP9b7Ty/19fx2zs/a08Kc0VSc9imYw3rgtl4+90jqCcpabcqS+I7ADHkS92EqJ4f2waOfuOv+22JRBiEkoworSOoxByI9Nkc+5VwwlYK+iMIgw+ycid+Dq7aqGk/ZDCM1s5CBAhx9OsmRm4sZ2EuUMz/y3fwl0ay02gauYv48zm4WcwXcdK5njL2wUxVYmWac2vHTmo1LfK62M9AZvrbteB+Yh6Qe9g6xHHyzSgnpmzR6jYRj2M1Oyw9Fd2H4xsHLRBleR7hf3SSnhMvU/wW15/c+Isx3N2k221oq9bo589ldwdHsOoksEmErq1mA9xjDXSoOclZjqkb2flsSxP0MaKlspiF+cmnENla7ljnI194F9aeb2pN2dojorp5sy7NmQUECHhIoPeK0LoJKX27VOo5AjXIdNqlHOOo14hCNJs0Uxd6a/vNAKnZO7iAjqwVOGgsHGqsUGnQcUCRvAYoMkEP5PdYpYRHufZIRqCocehOXzL0OmWxq7Kmcbh+FEWSkXRUIp7Y8cT+qTan9Vl1Tkv8dYrOhbnSspAKsLcQMfwzwYP94FH3Na9Mks05b7/wu8qoFiGtxkydVtVCn42SnHJaNPN3agL9tCfH4M72fxm5U5bX6Us4bs/ir1ViBir3fV2KGz+xP/EhEiHF1+qgkj95n6t+y3/OQYyNAjvZOxxcbprGNa4bqVEc5VLqc+YgXhIlQ8h1EZWiOmWtFuVDx7QWIMHkSAUZM6whck7yqj7k0rNytxOchbPQDxG0lOkeShnVZvChMdZdJp9zoE9NJA1B27rIOkS+e6c4yaQ64FvHnX1JfhU5GVEzkCX1Ub1GGjUSZTOmaDMAiJcQ62cA6gqk7/T3RAwnodCmexthNyBboboisY38oc3z6QQZP3tzb6mqTCX/8Buu/gNmtTj20YBGdPivxas1kueYxR6J8QMB2qUP604OWLzzm1VFzwDmxHxOsVXZGZTlNeyg+AD+cEpyaGWcW5rKsVVEwl46T8K8XcEo0QItF+f9vn5nsV12C0HCFZQPN3CtsOdk0SMAzBojOVa4WKo4kxf/b2HTIG2Eiuzfen2dpYnpqU6NZIGAbp5sKafTb5YPuLyHQp6Vb1ppLwwxfYdFU5l7yi2wcrKIpEYtqjY0V+YbGkHZaLzJVkpL6hpN3Uwf2CAfii9n7LRXNGBzKpe5+OkCFFqKC2Mba+iX042ziSbTLr1iFl+oFQJ30+pbwbUmWA7bvlI4e3WxkhA8FMuOfFtI36TT+gIFttiLRuGjQQt8oTh/0WN2UuhCYbDw/BIPh8GJ5LMsYv0EVxeSp9Zesm7gjto3fIet+65+TK5NPN2jgkhekdRJfXlFNCsHD9PbAf77z9V8rumQMkdxTGEwAmLLyQ6D8dr7MNdOH8l5DRKJDKLN2nDfBsEmYS2jkrp6H/YKfFV6ZxAU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d2edd4d-9fd4-4b74-d0e1-08db05c7b0bc X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 09:19:02.5789 (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: sVvmv23n/T/mkTrP1CjSSl0egPUjcU8CLjl+cNHmMeUT4fj9GTtLUNwEO1o6TQ4ul/OBDx/TzQjobiSgzvnK/I0GUloOZNs+tFliy4ELA/Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5525 Received-SPF: pass client-ip=2a01:111:f400:7e1b::72d; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-AM6-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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org data_end field in BDRVParallelsState is set to the biggest offset present in BAT. If this offset is outside of the image, any further write will create the cluster at this offset and/or the image will be truncated to this offset on close. This is definitely not correct. Raise an error in parallels_open() if data_end points outside the image and it is not a check (let the check to repaire the image). Set data_end to the end of the cluster with the last correct offset. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index bbea2f2221..4af68adc61 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -732,6 +732,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, BDRVParallelsState *s = bs->opaque; ParallelsHeader ph; int ret, size, i; + int64_t file_size; QemuOpts *opts = NULL; Error *local_err = NULL; char *buf; @@ -741,6 +742,12 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, return ret; } + file_size = bdrv_getlength(bs->file->bs); + if (file_size < 0) { + return -EINVAL; + } + file_size >>= BDRV_SECTOR_BITS; + ret = bdrv_pread(bs->file, 0, sizeof(ph), &ph, 0); if (ret < 0) { goto fail; @@ -805,6 +812,16 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, for (i = 0; i < s->bat_size; i++) { int64_t off = bat2sect(s, i); + if (off >= file_size) { + if (flags & BDRV_O_CHECK) { + continue; + } + error_setg(errp, "parallels: Offset %" PRIi64 " in BAT[%d] entry " + "is larger than file size (%" PRIi64 ")", + off, i, file_size); + ret = -EINVAL; + goto fail; + } if (off >= s->data_end) { s->data_end = off + s->tracks; } From patchwork Fri Feb 3 09:18:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13127266 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 77438C636CC for ; Fri, 3 Feb 2023 09:20:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNsDz-0007A9-Ci; Fri, 03 Feb 2023 04:19:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNsDu-00079i-20; Fri, 03 Feb 2023 04:19:10 -0500 Received: from mail-dbaeur03on2071d.outbound.protection.outlook.com ([2a01:111:f400:fe1a::71d] 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 1pNsDs-0000ne-1l; Fri, 03 Feb 2023 04:19:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SH1uClgif8YqtBumg/4/Mqvck9iMKzEl6Ki12zS909th/epMC8SClzweMudxrGTO6p0kcO6pWWCdJeO/Qz/2uLTi2+ygoWL8G/1wZH0U8LBfYkFshYKmDbPmYFGzwHbrTXnmTsnvsIMimBKBzK590G5UFsNmPMdg8Vmc8qOzUJ+XHObCPKzTolDbgncyAV2KbdEFpst+dTdX5u5PMrIK9Kfetnpe50kiWvpy2ajHUIfaAc1N0lXFUpwRqPXK/uCWycxu7YYTWYUU+LQheQRS2vson3d6Ym3XnrsVJ4kKXV4GK8qvLDOblU5oDzq3rOvgRZ5mZOXeDDCrgOWmmtgQJw== 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=qF3NOVPO0k3//yRzQXkyNI1yCckXNC+VUzpe20je6FQ=; b=gNmRZ8DL9Sugyi6RJIv8ebx2gmITHaPXD2KIH7VfmwrCgGz2P6axJY7qsaapD6pW4xPh8E0s5QVRoN4qr4xDTlvrokCJNgI/0/PH7TY3KjeXLXA8Xc55rON83PiyWI/BA69I6+aVb4jP667yRDvdfmKl2q87igduzgS6btnEohjT2JoJTUM6ri4XOaHdK9ELIf1wKXrC7YSdrmhxlNF16g903bQj/165iVGm0BgtTeSYQYRnvALwF6FZJLjI6hB+MGWK4BLkzlyv743AImLmdkIZEqQSB1x1cnhT+0L6v4i0mRnLQuonPMa65vw36ONHh5RH1TadCd75usMt6gkyWA== 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=qF3NOVPO0k3//yRzQXkyNI1yCckXNC+VUzpe20je6FQ=; b=aQLYcqvwd7fn6tHQobWS/4hADPOXzhz2hn0k7B9EH92FkGMklfaVQ5pH1bPxfjvDObg36IvEZ9239DWdPOC9xgfJxZe/3YGY6r4SeBEWCBP7aKQb9VQk0SgmBKQq47Foj1Ud9MaDJgzGmelYuBWRedYRwI/sD8Qmkch5OWiGkpq1O5ffamUDj8ZxYvfC2qlkn+Ou92Gyx5NHAwoW1mp/lNk2xBZYRYDUdTQnmvI/VjW9FAEFbTFRQ8EResV+bHkcgZxBHDpz6L/+dsKKsBzqLakHn4sDxZWZodz7WARbnGsPeMbpW1qbrmWdn8Z8IPyicxMiUWIhWdWaQXWtwkHoTg== 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 DB9PR08MB7721.eurprd08.prod.outlook.com (2603:10a6:10:390::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Fri, 3 Feb 2023 09:19:03 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 09:19:03 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v10 02/12] parallels: Fix high_off calculation in parallels_co_check() Date: Fri, 3 Feb 2023 10:18:44 +0100 Message-Id: <20230203091854.2221397-3-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> References: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::33) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB9PR08MB7721:EE_ X-MS-Office365-Filtering-Correlation-Id: ead09da4-561d-4678-74e4-08db05c7b119 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dtlwPoYzYq6NjZ8ZLTcIzqwx5qOOkv5YY9KagbGe0wYPRueNnpauOxuA8zg5TH8FT6D+kwjYRN2ghi/ggOD1A1g9NRM0RSeNooQmiX7pRP0A8tKJ8nL8guIU2IjH/xfcePac8wvPsN+hxzHJvBy8LLbg2sDfIWUWcjuELsxZbx9kCs1Ox6uCNf4KY8m7qLXRgUOwXvzPjiEc2YOgmXQgC7qk/0OuEBGtJ25ipMPq8oNIATqMMJiR6ue3A22QDoF15P/A9ykc98QAf25eP021AwO4pu2N130L4sHLcaXIC/xGm9DveZjZVja1IGTNBK43EZBqYXyS+/CCl/hQhwRO5Scnuc2scGUB+AWgjDTkFIhabfdQzMlqKKof2DUTHafAbYh24qwQMJx3TtraW703PF8Sr8yopp3lSGeex0+jdkwWFH2zSvoODFHEMvv6OwtxdzoRZSNIXL0xdsbyJ12yPkfV/jwaGY9pszCg5e6MwogL9BEwUfyA1U7NllS4d8DUza0CNS7APri1zLqhgPQRRw/B9CfmK39ZAfjOpOemojj3eRUZMjHJBBI3NCvo0Pld1aoyC6uUu0y/KCC0F4lvOJpmHOIwW7UUfHoIAwydxAF8WavxhO7/iwRQ3TCpcTTsrIN35NqtWCgVA9gIZI6WvBi3eRicCVMJVAq0QtBU+ztY6HyuVkjnEe9oT1qyPc762IldSLpFFMUQY5gVPNPZHg== 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:(13230025)(4636009)(376002)(136003)(39850400004)(366004)(396003)(346002)(451199018)(316002)(478600001)(44832011)(186003)(6512007)(38100700002)(38350700002)(2616005)(36756003)(86362001)(8676002)(6916009)(66946007)(4326008)(66556008)(66476007)(83380400001)(2906002)(6486002)(6666004)(41300700001)(52116002)(4744005)(6506007)(8936002)(26005)(5660300002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gJ5Y1dJFCNmGIvGgkwZjJtrr25nOOEKRMLJkD+O2QY5DMcodOVCf5YhdnzjRHXGzbwNndwd4qVSzRtQmRmQFNruNwNJbcDMgpVvFNYqheVHpOPCB98PecyHDkbLu0UPNh74xBTSnEP2B8Z8A7vZXYGMl6G8TiTH1rQn/OdTGXT3zpEMUVxD9+AC74Zt7luOaUtoXX5GtRB9/UlSQUzKYkDbXCbminp3/+JtuYvr/7JtdpI4wlhPjTO/cG5UnrHkEInw/cqOP9Tm9NykkH4WaQtKqFk8IppzExCglQDCbGS1AmLqPDjJYfnTqXmtW7FU1kRUItQ0/xev+6JUAF0NPAFiCOO4E14MWRK9xOyk5+y4iLna57e81Hw42Ux6wChQh1wOvUoJHFHEaZ4yTEBj+A7EuY25iRUnxMBezPwVclQ5JwldXn4DkXoLcvI0OnX8/pYH3OSoH5Vx7IRf4O4sIyArLG/Le/e80WCti6siEK0xvn4T0i5H0YFOx5SNL25nHVAyLAFAs3pzMzMgV8q9u7HlGFpd5RicGGXpStdVYPsrLSEPLd0LHQHBco+1A8IyjF0OV+JvNjmrREHBRA95Dpiayjteo0xTXxGWTlLZu2RK29Pb5yYiSbteml/LL3aMcXFG4YQpSjm7D2w3jKHxxFCxog/BM8KeW0tu9O2vX6io3sMD/DU8HkQkzF8lmd/zgT3RAJ0PwZWH21Xa8QxxUY73VxeBTg1mF9Ge9IpwV4W9gu8Uwj7FMLC5QerHL1AmiXVWigGpMN5UzqpAEAZamjHPrewZ2s9lAZW2HaLd42O9g4FLlylE/BbtSEQAipKAmSA+hvojYqph4Imkb/5f1tpXX7AFzD/yf/R44/1wHjLqMfCIBP5snsA7vnYMwzKMP5Jg7QaY1Dp40sS+rwqJlBfBFhWgHtE283VC6jKYY05ShyGpsaTwYcl6TivnGcIjssjhDycRdvRVqkaCg/C0wTYuy3FRnbJ5mOnfcmFsPVX8akEXzxvfRzYUwwthpGRb0MhwSHjIry/L1BE8dl3swpRJpOvVZI2ej5NZh5osB/johKfSQSHsC/wkW3wzgGtRL8UZ1N4wX5Nna8JplL+C0Y2raxP+2wiToywBAYZyjxeMXAvxRboT61f3+/k/Gw+G0eSOl+EDK4jzNB1EIypDjQyQhtT2VnXnR3WQMOXFpg4JEUzov7EwygYo7Ynae2KyI1NEgsWnjglNf3xe+Wft1GBp+G0WKUJeQ3/qbeesV+gIV7Sx06g68YePMEIJoPLQkqOkZogyari89HBKj+HrMEHZLb2yIwRYG8xHy85plhRISK7MO+cwehI0+wT3qYaLrKYozF8S1qTPtOyAImc9caodSNcTTedyr5d1dfDluH02tRlGkIRMnKg6rxGvRL0vaVHcjHj3g2G+V1GEX+wd/hfEVHhr3Im+V1j/Xb0zuQUdwFndXJCpCCmkXu1+Wwju1eVQaEt9AWwArV3g2zmc9E3PECfmd9UyNPzFUb3ErIADStq8ualwR1/UtREzI0wvmBRAS6lxCsEIHDqke7nDyCnU7mVR4gLFcxp2lSDAdiRgniEbubrQeNZOnQXfs9FrcOQPko/WJgSvFXvUQ8EZfobV5U4gsWSW4ujDtr8RL/sI= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ead09da4-561d-4678-74e4-08db05c7b119 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 09:19:03.2485 (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: upjSgXhl5xyKDb0nUz/6gEV7UoxjN57L0LrMCPjb/Q2Gx5Goe5E6/wZ4aWIFL06mlx39S5cVRtWxN4PmxHpzPd/ejuLUXCpaYNdEu1PTANE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7721 Received-SPF: pass client-ip=2a01:111:f400:fe1a::71d; 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 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 4af68adc61..436b36bbd9 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -460,12 +460,12 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++; if (fix & BDRV_FIX_ERRORS) { - prev_off = 0; s->bat_bitmap[i] = 0; res->corruptions_fixed++; flush_bat = true; - continue; } + prev_off = 0; + continue; } res->bfi.allocated_clusters++; From patchwork Fri Feb 3 09:18:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13127268 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 68549C61DA4 for ; Fri, 3 Feb 2023 09:20:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNsE2-0007C4-IJ; Fri, 03 Feb 2023 04:19:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNsDw-0007AB-3y; Fri, 03 Feb 2023 04:19:14 -0500 Received: from mail-dbaeur03on2071d.outbound.protection.outlook.com ([2a01:111:f400:fe1a::71d] 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 1pNsDu-0000ne-J0; Fri, 03 Feb 2023 04:19:11 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SYPq6bQ97841bgjRN3DusHlkE1FGku7rVHOdNXhhe0Ugzj8UvFgsaztVujmfI6AzuNnL+dxHITHbMR+B+gkpEo+R5agZe7h2onlT3TpmYgeYLqPeJLFxd4+va7oT86auniEWVuS8k0JscVxVpA4Q2Ck6hX9ei+cbVlGrUY0uO6NZgIqQSwfJZdEXgkVebSNIQurChJUAlz8uCJ6hzEwoSbT3LdrqOL9R1FP3gL94XA60jsD5+Ac+tKol4zBZv2t1XWU7REsHLskiDWHdSJaKGrtveq3m9VOK0AkudIh32GRYgcm7DWUNFROHNapMirRzQoBzlWfpGv8ASJlm/bZgJQ== 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=FllO13ykNHz4YczDSZc7Btd+cBPUJl3fkQ/GSewfQ0A=; b=WbnZOpIuXpT9mrrxqqE6lEr5fDr6CtBolv9q6Mgn5qT3omeZdX2ke9wTTxT2E9a4SDWpQoo/sohvZx0fWfHNFkl67r6hj1Q04qzLDO4N/yEgTwyqDDs0xx9VpMsUdDI+Wp/FZBw1NhJSpROabceH7S4hNsXlD6G3RfZQ69StJ5ATnnrHx2fAchdPi+eguIf48zKwiEiXeJSh/SpFD5E09etAzbnOf74B3s+UXo9rr7pdJpKdNHFtOI4AQ/faU4zdSK4RhV3jCfkbuYyAV1U9RXxBqyrD6Vuw8Jo9VMtAmg/M5mcvy2q20WZhhKVJkxjHTxQpFfd0hK8NtjEmOa7sIA== 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=FllO13ykNHz4YczDSZc7Btd+cBPUJl3fkQ/GSewfQ0A=; b=o6Vb0bpk4rWeyteyksQ6PiwXdjl1kIaLOsJ3SDwyzpYRsZXSJFyDWMJUHhERvrTWzCpAKwul3bXRpdRHwaqdczvtYuy6peRysHE6M18V3VCVm+OyDJdtnwOrEK5vS1IiIDDPoqUEiHrGjCEeuqPm5npT7PBeLEdN2RYzktv9m5zejTDr0ZUDNjpoyUtUAT5SdJJRfpsebiCQslUFvzNeqjtRbdh4bFV+xAQiX7+TzQgQ/nlRR5cL0JV505Wq+X+ehLercaTPjuRg/H2/oVL3iuMt+Kln9lL4qB/Nk1QYDX5g8+a4x6Af+k/rdUPHefs2HWbqdQc0cL0y5e0z5Usp6w== 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 DB9PR08MB7721.eurprd08.prod.outlook.com (2603:10a6:10:390::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Fri, 3 Feb 2023 09:19:04 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 09:19:03 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v10 03/12] parallels: Fix image_end_offset and data_end after out-of-image check Date: Fri, 3 Feb 2023 10:18:45 +0100 Message-Id: <20230203091854.2221397-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> References: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::33) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB9PR08MB7721:EE_ X-MS-Office365-Filtering-Correlation-Id: 57c0ba53-2020-43ed-5785-08db05c7b182 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8jj2oeAoMIjzXmYXOGGrSGF0BSHeRTYNDAYngwPh6y8AUL4CPhwppbp1n8cRbHSN/OxfNXqp2m7ZhppLcAjwMVH7FBaNSnIVT+de+tCgeTRQk9UCudMbYyGoEuzE7qajm7FWi6cSneDvrmFbTOSAk4RPOQkKhsS3MWRjMlRlKhNRFpJTmRpXsbj0MebyhW1jFzR4ULnaNE8HsTQRWq/ozdYl1HxipvP004lxSnXDg4UuLhXHBVNv6/auGUJfW/aZg9uEBuaxpqDDWZiatQ1TcpFoxyn1xX2TyDADypRqHKZmjgZhnvC+EI8hfb7w9F3d8NT9smFyOqpfjUSqZ+YM9fDyuLBQeIfCSWK/y32ON7mcjObnC36JEN5+Mi36PjIiG1EW8b+uOu/dL/fsi/VPsvDtvZ6w91EFL7haDC63BA+LChIVPQLddjgZLcLO3LORPwMJt2bzvGpEnhU+3mgiW09kxEw7XuWJpkHuQYCx0UbzsmYXLDnEzv3ufz8XkvRRpML19Tt48xDHy5eSNgQWTZoQo1/wwiLpBKExFcAKguMSp20NLf8VcpNrh6MWjwinaeidoDnyAAhLZ2reP9EvxjAw/7Ea4fxIjTAKkqydF0Vcp9oOa+e7KFj3WD7naacIvvubRxPq4ZmbgORc5kQ7Sk5XKcAvpgK7kBnFw1NeL8Quu36T7WoSfVI/rNKZBgkPaMIk3sSgSxAX4rQuzOGdSg== 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:(13230025)(4636009)(376002)(136003)(39850400004)(366004)(396003)(346002)(451199018)(316002)(478600001)(44832011)(186003)(6512007)(38100700002)(38350700002)(2616005)(36756003)(86362001)(8676002)(6916009)(66946007)(4326008)(66556008)(66476007)(83380400001)(2906002)(6486002)(6666004)(41300700001)(52116002)(6506007)(8936002)(26005)(5660300002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uDuTdEnoV1bdKB3Dk7RUVau0MssAlS/0Dvky1ELY/QCxTT7JtnmPHGCNmgAeLEiz6inEHkhikIK5caXPU3L5OOGdI259ZJMbvEMDRjI3j1TowgPBbOM1PG/0ot5WCmlI5RqVC+jxTSPZhVKwXYWj3ujNomKwp/mnHS/BNd0tWtID94GHUu5QkBRClIuKuzH0+PWpzKM7SmzwFx0pE8A386MQulGE1Nmf7HEzEc9cni31kRp6g9o11+C07JPQChD2PiO3jyw4rqza1q1MPUGvFoBir0QnN3SKAVEy39nNRz1ly8NaiDulpLMSCJGMbypCrLcRdxLPitLIF/72PeIxvQaLHQa9jlRjMcHgRqci+jErzWJ+jxEtTGXxdabSpbXVGnk5B8/8HjPH69PNJ7S0eDWb42H6gsL05I0vuyK2xWtBZ4g884ZBmfuuj+kZ1GTql2QYrQPfeUXu5ma7J0QNGaZpVuMHaJKPFpry2I1aZcq6r6GylKngA4X2dBSQEc7BbVkWfeosOGw1rARp30AQtTCh1KKkOWbTcg43pzQZyOUxuNyJ2nfJfn7t+/XGFnsd2rmFy1T25my51PCL/cOTCh+aKWlIgbS4yEHLnDO6fl3Y8xUX5bFJZ1H60Hb+y7USVtwmL8zg468wQI8OBW4nQ77o6gYNpAKGGTylXgHzqKGpNowNva8EcJErUV8soAI3AZXxIiysDlEmqwW8sQoADtdMssgdG+yXFk2p/u1Ap5SWgyOIGHcLiUnpCALmEcg9sK0P9Udtnrtx3g+zyFCVDW53nF/9E9ADI1XMXSxjNzpMLorjhQtjn9gvWObXXm79G1MNdm6Ktu2Q3FHQe64YLVbWVt5c/ZFokg7U5Qj8Rzq5D34TIckQpvC35+FvX2xl8tilOVh67BdcvPvEJ87uuqoll7lFHIp0hkvuskZDQxUwpIl2zAhLLp3ifxeWK+MUBnum4QcaGKJGJBx9hyA1CL1g/hngIb0lKENI08ncdTAe7bDGKAm8LaeHPyi4+PBjW26uFYe0KSDriikH0hgBQRPe5DmF2NSiPndVs7W1yfNE0iig6pXlWwrwm22vPvhNjO+2JMYKqM8MoTrOzVx2ioUFFTMs/Riume0a8d627IuRSKg/xKHeU0kk9UIxANww2Wa6p1jVdQ0HW0M44QGZa1ecKexNgfhD8B/KMCPdUDMJ1cXgrkpLEcwOCkghdSl4M71LWFrW4hwempr8/8vEQchXDhLIgBs+dCY1eEvpB0+kDLTJgI1JrFghbCVmqqbVGdKfJiI+LY6FJYVXzi+7m1H37xF/0+pT8pjshksx49Im/pwZzUex5EKih+AknMtzPmimuZrFKbmrv962ZTSjasMC7eCGYj1wX/3lbe9phVh2ChlUTqEpy6Tm0J/VLa9FZeGzAUeJ8Ii/ZYr/P7uH2Mm/aLSehsiGtJOFW3/1yfwbUr70Ypmh1bRr02cIHCNtcM0NV6vncbnPvqsWHHmqDpxoY6reQ2XpFG23AlDNhK83muHo71h61b9NCD51ifAxAHX1RRKValhdFF0hrwLOZJ1Nv1y449Xyb4NNF7kW2wxlgr67uYUr7ChE8lrpKFC8dOqcVXPCxrKE8OCql2DxJBlnI6BGOq6zmE+GlxcgFc0= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57c0ba53-2020-43ed-5785-08db05c7b182 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 09:19:03.9203 (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: az1PczYmT9LOT6nRBys4cKp5ymB3Jdt2/RtjVKySrM1VgowWnwZDqCCzVAhlUsI/IlYk6M5Vxw3caeEZVOTawa2Lasj/UzNFvDQf1rzVkeM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7721 Received-SPF: pass client-ip=2a01:111:f400:fe1a::71d; 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 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 436b36bbd9..2ed7cca249 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -488,7 +488,13 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } } - 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 Fri Feb 3 09:18:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13127271 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 601F6C63797 for ; Fri, 3 Feb 2023 09:21:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNsE3-0007CF-LM; Fri, 03 Feb 2023 04:19:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNsE0-0007BF-Fy; Fri, 03 Feb 2023 04:19:16 -0500 Received: from mail-dbaeur03on2070d.outbound.protection.outlook.com ([2a01:111:f400:fe1a::70d] 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 1pNsDw-0000oK-J8; Fri, 03 Feb 2023 04:19:16 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ltzoWVDSP+e9Jv8NKAPQL9fIlAo2xMV4svYQ0hdFkOIbA4iga3xn4YJXtDHZRBMQTom1uu/s+lXtyAWyIc085tf0dWkqNDk424CLdQ/WUowab6XTEAuF5VnYqVpZ0NmyduG5g5SRcZ4iV7qEY3xW1sDv3M+I/HzvmM+SLd9yZdcqP1H2DJtVwCOnRR+hbH/qXO4Padr4lDVWPP8UMB83A7hWzLQBA1vMsY7I3+Ksa/D1bYxjbtL+ARKyEZjKZzswLn881zq1VmCHFyOhiqQdVk6PEH+RY5xPdN5pvrEei/pxhd6qWUuU5E1NhcYKoqXe+9nCf+L85U4hYmBeX6MIBg== 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=h2ts94JiKDu2CEKEoewinTUcevlr0YazshLv5T+UNgU=; b=jOtsYLx/2JqT0bbXU+MzhGNHE3ezzxGl7pAeJk2FUevvzacPjgEFtINI1S3ALadexYUWv2JQRdTMo5umTwnl66qTLT9AYDZ0rtD3Zh390J2Jq6Ebdn4QOoORXUBTNbNZMDXJScma8ykC2whKz3xHbPcHShsP+eGHLgXaY3zaYs/+eGo110H03R8RgBCcUeqKlH7yuQeun8eFXKs9tSflqhLdJocK8SXYEL6QWHzu1f12b78vxWWZLsHJRIZxJ33xSu/xr1/E55dpCKDzW/FmyhD1/qKZPQzSFQfHg/57scEnw1U6DNNdvICk4R0Iw9KhmOtn3smHz5o/9H7H//dvpA== 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=h2ts94JiKDu2CEKEoewinTUcevlr0YazshLv5T+UNgU=; b=tfgA6kxmCC6YQd+UXKhzOfr5z7d5++IIQtrwP6Dy82ScRkR/I2UGVfeUh//OyucziREIijSiU1XGLTZs0UMOMbXUxQW67nKpM9HlQ2f+vutEP0Fn0VLrnHuk2JvozA2v0MwP1FIBHJKN8dNykdZR0Ecdptr7/fmA/9xBbDsOJBCIcUWrqgBR9c9ZycGaXdKOBxkglYAc2wZ2U9EEXT3/8HJycEPaKzAdh7yEiXHnKT3T1ot55lOX2G5G5JWHvoIF6jrsDIoz6jWGx7GgnlMnWxpu9PtjI5SfJu+y180p4Zt/EyawJ+Hf15DD1I41S6MvEN5VzRKlB7NmAPcvTn+RTw== 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 DB9PR08MB7721.eurprd08.prod.outlook.com (2603:10a6:10:390::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Fri, 3 Feb 2023 09:19:04 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 09:19:04 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v10 04/12] parallels: create parallels_set_bat_entry_helper() to assign BAT value Date: Fri, 3 Feb 2023 10:18:46 +0100 Message-Id: <20230203091854.2221397-5-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> References: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::33) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB9PR08MB7721:EE_ X-MS-Office365-Filtering-Correlation-Id: db1dc7cd-ea6a-419c-75ba-08db05c7b1e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ck8flQlCzZa4JGFYq6HurPF8c0kHUhXhqcbIOzoa6gcxe8fbHvXATUkyxtq7KVpRa8KINwAdlR9dYYqHR049P2N4OGdkH+CiqdrDUkuKhtoh4Y4sD1eReQIUV8fkuEicpPaAT168cD6vK5IM0H2sPEa2dM6GdTvbWWz/V1xNEeAabV6PKdOVdWfw6PBwIlYWEc4/QSNTzGRST8FUpfia8zWp4TKntsOAB95ZM+bSFrOGyXiTfJNfzqJ5ah8s+W9WSdKJKVSlIxa7Lcs/avaTW8QCieIpxPPvMuj/WeZiS1sLHZJyvFk4ekoHQYmVuMqZK9Y1dDLvL50cLY150ZW2O066n4W5kmZECj2Y0ERlU8lLTesF9qrClulBhvnJh3bl7P3bNU2wFTJvc7mAKxXMwxtPGVuF15tvyNKb5ArRkD0Sh6VGqnyn9E63gfAFzvKkTSNkvDIVOz5conAW+frydLR40iE+EOMHit95yY2Zw7Q7xNi1DFQcfESq3/JfUMtTD62gSoaAbbt6OyYqPTZMULYPak7fws7koYKO29Q86ETbHGy1EvdfIBpKxnDcx3YmZ9fRtb9w5n8zkj0b1ZVxoxsZLHjeiCDerJzkB++eFNbCkhFqvdhfv1vbGyY6S4eKiFVlaqYf+JezOKLZfv4qdioJ5GjI/h0Sq08zeYAwTscH6ZpuORIwcRaHvk05vL/k6Mriuwht4o8CrYPHsHtnnw== 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:(13230025)(4636009)(376002)(136003)(39850400004)(366004)(396003)(346002)(451199018)(316002)(478600001)(44832011)(186003)(6512007)(38100700002)(38350700002)(2616005)(36756003)(86362001)(8676002)(6916009)(66946007)(4326008)(66556008)(66476007)(83380400001)(2906002)(6486002)(6666004)(41300700001)(52116002)(6506007)(8936002)(26005)(5660300002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zUNj+b0f5fn4meHWBc85wauhNTq48Ay8O3JRnqo9LjO4kdrNVU5PGULU2e8eG59NhkCPwSMbKyj6w2U0lW9kHbsKfnQH7K7MyOIDU2gt9vOtpTsfwJN55NnncgQ+iBai77WC77lAUo+X44N6npjCW1A01+oCy41klr4gQWX+2wYQmB7k9M83spH/8FneIBDoQL63/7RuRlZqpjr0DhGSgpRUe80HErMaeTSTE3QCQvajkGmQqRcFWfThWHYAUvQcdtABh4+jXRelNtomkQZ7T+YHBJ2Ah5Qr9j8FAPN+Y71dxOcA3FSlFFtM+FSjEJ/4ZDYzMffQTY4sv7K5xQl98mtZDOHS0QOXAmkCGLhP7J4PTdKjiuYOTkBkjfbsCumYJ1Fc1dqp8b9SWxrw1B//1HsAqL+hMfAN87Cpcj+Lt1qoO8q45bG4/dq4LdODG/yITczmddma7b699CpjWsh9FU5bQ2PFjvFdzweGffhBdOKleaJy3gVf5MMk+5RXXAz/EW01BX7YN6tNorUNTW79r0V8W+WBwF5CG5R+MeeZZv1BecVITBD57/2EoPHDpP5ZPPCVyH3U8t9hv0HffKeiOQVYBKNpk8WEzir010R1CMWvS2F5P1fTrZJIDa7gxPhyYCaoN1Xd+MrEWNT4/NL0CdwfBtKKHbctmR2dZArEUuEEWwRpCo16WN9sGc3wowxfJlDn4+H3JxfycYZ0uPm/81V33wEGysDpuKSCnMcz3smywEw7qHvxF3DbipzQYtB9OHh3hslLq6FQDw9UemLqZbxD6bXJF9htMT5oj/TMBByZtCZAQt6B+HGuSGdrncdCsFrpdlX8DIzyEXOfSjq0y0Mgtku54eWNwLdkvN6ff+fuFU68UjgY0RuPpqSWCKPWPLAJtFmjuMHLgi0VW1tfIY4sMIZzXcUrHN7ama2A/Nog3ccZbUKzcVERxs6tUGy4kb/acfo6qKRlDVNo+fprNFKag+/lWXpYD6Wqi90D5EAWyqy+J6JliHUnE+efbdTA7ofgt2cejXcvJptpe2dGcgV2YDTluMIMwvu37s6t3VXgxcFR9r5pIr8GrXJnbO2pYqrxduoOMPKDVHYevmecyM/oR8RBuKhxwhTgfoPwFYoE8uCNGq+HvzkqjxsM2oR46g/vHnzn9XijVyDSdt2o8HRVe5PEAJFAiEKQ9VE3VuoRLqS5FMYvAZNzr9LKGKYzjlfS/eLkTKe9sxTDv7zT9djb3502WYBVrTz5jd3zV7F6p4k+HPnAmskXihV9UCn0ANlcifyzumBOcygAwo/G1ur22RiD9oAUDJThgR27iXwa8QK7wNO6eh9poa0OD2tuVUqE44fwGOFnThuKOxb1LFDF/kaq27IKnghBPZfhrwM2tFqmxHFz3bATdrhREJJJ3Fr1jQVZEDJTSD0JNj5u0A10mnJ0hevalvLGVJTQOkaE3ryUKpv1gg/6vt6GklJdAjgywDurz/Uaymen3zsIXgSCx+tjM+2BdKyi35YvZfF8wUSMcWGYvxEbhsCWC8ion8cSinE33UzrOILn9lEjYeEya/JSoSefllLNoq0xi4ptoTql+nAEzsz//RWHBwdh8VC1Ake0kS8HBgO3yia7GPQSBcw4VcYWuHTbQrxbhu4= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: db1dc7cd-ea6a-419c-75ba-08db05c7b1e6 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 09:19:04.5308 (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: By57qhrB5vEYm2Y8fQFF7M1fnAUk0KFWzRFU7gpvBAJApH3qXXJnpoVdqLlHtsGJ7dFljURlIeyvOyqWYHED9kT0EyhU7WOHBMvKF41jUcQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7721 Received-SPF: pass client-ip=2a01:111:f400:fe1a::70d; 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 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 2ed7cca249..b2e3f5f98f 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -165,6 +165,13 @@ static int64_t block_status(BDRVParallelsState *s, int64_t sector_num, return start_off; } +static void parallels_set_bat_entry(BDRVParallelsState *s, + uint32_t index, uint32_t offset) +{ + s->bat_bitmap[index] = cpu_to_le32(offset); + bitmap_set(s->bat_dirty_bmap, bat_entry_off(index) / s->bat_dirty_block, 1); +} + static coroutine_fn int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) @@ -251,10 +258,8 @@ static coroutine_fn int64_t allocate_clusters(BlockDriverState *bs, } for (i = 0; i < to_allocate; i++) { - s->bat_bitmap[idx + i] = cpu_to_le32(s->data_end / s->off_multiplier); + parallels_set_bat_entry(s, idx + i, s->data_end / s->off_multiplier); s->data_end += s->tracks; - bitmap_set(s->bat_dirty_bmap, - bat_entry_off(idx + i) / s->bat_dirty_block, 1); } return bat2sect(s, idx) + sector_num % s->tracks; From patchwork Fri Feb 3 09:18:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13127270 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 76952C636CC for ; Fri, 3 Feb 2023 09:21:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNsE3-0007Ci-WC; Fri, 03 Feb 2023 04:19:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNsE0-0007BG-G2; Fri, 03 Feb 2023 04:19:16 -0500 Received: from mail-dbaeur03on2071d.outbound.protection.outlook.com ([2a01:111:f400:fe1a::71d] 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 1pNsDw-0000ne-MT; Fri, 03 Feb 2023 04:19:16 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cqPrDK8187Y+Uy2u0m2ZkFOlcmA6627TaFHcM+j2vKjrud261npKhmATfpd6wNjpmwksq28LpdTM3LiHIWXlDMdrH8XC/QreDzpjgMgA6C/AgWSyXM9rANZI3GQ4vPZTt1fU2+t2JBDLBEx6IJcgr18YSXJBNy/FP8eqiQPLQ6fAdbVWJzq8Z3gyxxpAeY5fVJ5mRk+oN6a2Th2kaRYs53HqF9ypgJlF4wZNuCVLmAaF7j5AqTUKKZ86ak2sTlQmK17REilCIWfofFaTpGkwCA5G1MpIdK8WNvCI7O1/YbRDdKXyJdl0ulep2HVL6frWfyKjpuNalziEOFYXR7eJmw== 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=ZWHA8EJjOhuvT0aJtGXbHtecNQioXt+iEQlas045jas=; b=JdZOIxvSUQ5O8gSlRYtdDCzwP3qHt3GfH/r5ghv8SbRSWOVXAp/xZzMhJaOU1Kp4XUySFlrNUhuBPcOGEnWSMhMJBPtH78g9OinO+wLRhTzB2EPE/te8qyrr0Lernj3RLcF3sFNjkDHIg8OD703/DGEV8R+wZgtRFkcJEkvPObmyqXd/F32EOgJJn2kqmTGMnnApD5Ey88yoMDlO4FmNIc/BJl2FrBaOQSG5T3oEMBeUThpHlal75u2jz5QL/mOStMsDfiJ46VP5vTNzOdOUzhZvBi0W4hB062PlD2sbE7d+jp8F9e+vLVhsOKSd3ncFXJ/NW42j+mpXjSmSNERp7w== 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=ZWHA8EJjOhuvT0aJtGXbHtecNQioXt+iEQlas045jas=; b=AaHBnrRbEpdhTnx+J5Uq1kC62SFhOxDNyrPor/8PnR3rJRsiRx/Mqnk89Z3P3uGV6+5/yLL4UqgP7aoBhDIVEtQ8Pl49M5iOw04bo32EUROM8+hQ2dEmXjidIksbnfEhGvkISkLi+l2y/ZyHiDGnmHUUdE7NlFxz/FxHOabW4WNRJnswzZbYOdl3n6JQKxnBaubwxsaW2Y2SGNKLn8XogM5UGj4oeVfAmNsCsK2eHjoiDJcMMGsbAzv+kSL1wIfyCKFI0OI7aIcVI8b/zogQAR1CVK59+S2p3L+q90p4PqlVro1iE7b5/o+Iwlbuq59Ur7U+DAszbp3tEq1rQQtFUg== 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 DB9PR08MB7721.eurprd08.prod.outlook.com (2603:10a6:10:390::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Fri, 3 Feb 2023 09:19:05 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 09:19:05 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v10 05/12] parallels: Use generic infrastructure for BAT writing in parallels_co_check() Date: Fri, 3 Feb 2023 10:18:47 +0100 Message-Id: <20230203091854.2221397-6-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> References: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::33) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB9PR08MB7721:EE_ X-MS-Office365-Filtering-Correlation-Id: e03af629-e9b1-4432-024d-08db05c7b246 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 82vxFBrXzax/lxITquxjccPH4eo3IsR5GMbRrzL4iuB97t5o303sV1wNlfFNYv/AKfbmB9q9Ba+GIPsf89EIfs6fB/H7NO88IwtzehELPd7nL98e3Jmp0z+C+F4YFsCGEH9j11Jp1/yY+qxOXprbn+h8RuVsP0oVIpFIq9WP9aVBoQXLYBYzKMINXC81i3HJ7K+EsJr0JLa1GBAybZ78xpuQL7ih3JyWU+sqU4YxRfaN058/AOMyvcYEV4aMs8CxhqunUuc4s3SLEFEYUuEtbypSe5EY5YsM7hCYCR4Dl+t6PqV8ZQWRtxfIlOVPw4VTDK29SSdFOjX/MLjFUO93ON2DR7O0PBB63czbaBJSdwmekJ7evoTVVawVbsa6KuRRa8tTbVctEBbNsk4wrZ8ZoT2P75rvWsQhgeRLHXDE2/zd5Qy0b1CjZvmXfDESkYiux+A4Yr/KL7EGk5ExYBpTXg1g2l9H/N7JWEWmCyRCg1a1r1zuqQH1PFa4wa09RpYfe11323jTkFMycBNHqEUL7x9SMOKiBSF9BnmLPduJuYGkRsepxhzbvAHXxV2+0ra4Bvy9357ERXgbQfR+M/wjmMoo951oOk932gRPq7ajXK8iPyW/MrbIw0UHtYCvCF7T/3bInJMkq0wN8N0+/Nok5snjzEdsyIz64bfmi3t8SECrOjKDrt96h5ZxMFfw1Yob8KkFIgMf3duGliByU5pA4V2Vv2BYCGIDlmpHuFAGjYA= 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:(13230025)(4636009)(376002)(136003)(39850400004)(366004)(396003)(346002)(451199018)(316002)(478600001)(44832011)(186003)(6512007)(38100700002)(38350700002)(2616005)(36756003)(86362001)(8676002)(6916009)(66946007)(4326008)(66556008)(66476007)(83380400001)(2906002)(6486002)(6666004)(41300700001)(52116002)(6506007)(8936002)(26005)(5660300002)(1076003)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LFYslHmNKzUSI72fx/s1zpP6gTUKlRAHME1Y1PdHwtaZQxzWmTVf83crwGJLqtOzlZKxJ3QXXpnpm1h3HXVxNY/yT/Nof/15F8aMLg1Wj0amEnbvTnu6vY3ggGgyCZJvk3TAVcVpKPQnDgug69MVYuqFVfHVls7+SCyBrWN2nXlabsL7LuVdILbViyOJYs0gI1rRJJhpsKPMB83s3VxXWb/0Ft7xE3DnY9HdJt1V2ZJPsDJM698in/yxKsLOcsrSqBw/9TjmT9hGLKnryYtTHup06DmzEMh0t5jW8RQtBkkwoZPC4tmzQoaAKKt9TtjH2q472GiLvqfd354pVZqIXnHR8j9Kbi4k8hHNbEcyHUmC0QAUDqxqL1Mi6FVMiNAhkkuKJjzE5HJsvxqk7zpGZtg4mQWdMaOTC0J6L3MW2PxXX1IlpAr4L4nw1/iA0CT1y15B0QKUfdrtapPZc25H/SCTUAnla+h2EVhLQSy2Y6zBOVz41Q1nmIiBozz/BlTfYuciMJKIZa3g0Zdc7sgzV+8bNlNNjIhJwYRNiwSnVfs2VQyKgkEgIO8fSkR5KNRrI1jB86Q7soOfQrYEEfTG/eFBRaTc9SHwGtVOdH/33Cq3QiHDXbyXpKa1q3UZX8iUmJWEmwE65X3EqI6NZ/ye0RJVxyOD9x5wzQ7RTQVhDnsdjpL9UnvS68BXFtsu4FxbNmHVai1kYHtgmBn0bfnoT44c4P56wBMp8DrRUWX2AIlJiS3V0rHRrPNqSEYVkYCnPECJRW2aZN7TQRpNKkiDJDBcoXGgZ+T3iWjcIEp3kcphu1Eh/eAG2zR89NNRnB/Z0yKmt5YoGhsUOVIoUdoX50NcYiYIAsw+JNrKGDiZZ22rTB99mas5O/z9ddndbNUqMuvT/rugM861NCkjIREJtMDG9JtHnxGe3pKmKeGtd7B6NWbHxhWPLPILUXTQohtidsAFYL5PdjOX9Y3xRbfeJqG1w8RX7yrJdluxp9LjUul+sRvRXMLT3vUXmYuN7HLBLZX60JR3spIV38fRz1mfyyyq1f+GJQYclhD0ih5b49j3vbQHm52xmdV3gLa+l9drtKxy2L0PavPdjJlj7tg1wrD205J2cPfg6BXhnlDSYMZvN0gyo6agX26r17T/y7AiSID2LEyhOLsxezlujlrbLXfSHa8ThH1G7ajEbBAba1lKOPHXhDpRBecDzMsBbhAk3b9rrQpwFOCTcCYFf8yLElL/NVLc33WA0omutMR673I2f//ev3t1gUSbjSmxjXzTqjsS4/559mdC+qt9uYwFvggbtYK4RcETu5J2mPlAMQMrKTJ2MsJDFlunqGMAPo+5slFHeFkQgkKd4ZmXHrTS/9WiBlSziZxxdpB630Sxyp9vHwn+gzvgWkMRJFJGy5rjWOoy7/plKZYEqtAGw7lO5cjdvokkaQSn7Weap2LI4umhu0gNILfgMe6HUOMAULua8Wsy9SpmAlmJTVNvLkNp6TQMC4GGW24XCMyT1rnDRzAFoM/UUPbxqw0G6xxBr3TrBpc6i3VsJnTtHkFg23nte4EkkxiXONMpKyw/+aJ6lFMoz6v9fK6K6pCNtlLZfq86Z4XNArTu3tutLqN3pt0P5x1+ttryG3OFWBPku6LBaiw= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e03af629-e9b1-4432-024d-08db05c7b246 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 09:19:05.1714 (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: qr6tCcNKw8vNArMmukL6ZPn8xBJkpWWNqJSFEaqy+7Go7vb+wjbRVzpYC2TAnE/jk7BG+NGR+W3hexEHzHLd8Xbv/L/wgspPCB/3zX46jr4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7721 Received-SPF: pass client-ip=2a01:111:f400:fe1a::71d; 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 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 b2e3f5f98f..63bfd7074c 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -425,9 +425,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, { BDRVParallelsState *s = bs->opaque; int64_t size, prev_off, high_off; - int ret; + int ret = 0; uint32_t i; - bool flush_bat = false; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -465,9 +464,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++; if (fix & BDRV_FIX_ERRORS) { - s->bat_bitmap[i] = 0; + parallels_set_bat_entry(s, i, 0); res->corruptions_fixed++; - flush_bat = true; } prev_off = 0; continue; @@ -484,15 +482,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, prev_off = off; } - ret = 0; - if (flush_bat) { - ret = bdrv_co_pwrite_sync(bs->file, 0, s->header_size, s->header, 0); - if (ret < 0) { - res->check_errors++; - goto out; - } - } - if (high_off == 0) { res->image_end_offset = s->data_end << BDRV_SECTOR_BITS; } else { @@ -527,6 +516,14 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, out: qemu_co_mutex_unlock(&s->lock); + + if (ret == 0) { + ret = bdrv_co_flush(bs); + if (ret < 0) { + res->check_errors++; + } + } + return ret; } From patchwork Fri Feb 3 09:18:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13127274 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 8D3A3C636CC for ; Fri, 3 Feb 2023 09:21:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNsEA-0007EB-6v; Fri, 03 Feb 2023 04:19:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNsE3-0007C8-5f; Fri, 03 Feb 2023 04:19:19 -0500 Received: from mail-dbaeur03on2070d.outbound.protection.outlook.com ([2a01:111:f400:fe1a::70d] 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 1pNsE1-0000oK-9M; Fri, 03 Feb 2023 04:19:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KIbNpCUhH7oAgXZP+7soLKLa8bBxDG/psM/iTFxM1UZUX2ZStSYOOLaRYy4Ka2AJ3v8NuiK5vY+UHjfbFlXqwalNAGecgb9GL6USNyF3+ZIAlq8m+Z0NmyE1iE9zCBMBgxCTR3D4+fefmxUkf8G1FQ/wzykRq9OdbqNZuVsjgD3O7HUKqQOWIspxVPcgB5bfJF0bd7OaFZrs6DnI2azbcR3P3DLFTdK8RgrRWKCY8CRe1PATkMtBxLCdnkqlN/qxb6cyu+V35gKGufQHKbS3JeNTzNZH0Hswca8PB3zsjzo6F9NcdvHGBsCJclYveUVjYJHriqahsuGGKWUlQ7JwaA== 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=yHHhH6GkEPcmWeaMwexhl+42aBznDOcUp1XNu338ZX4=; b=nZahZ88YSukzTK9Q/LoUZaHnSW174fl/lKqCEz4TCSzWb8r11ZyG1oj4O4dpNVwgZ+r+9en2kPy9e96y8ZsUehktSZKW2axOf2WeXrM64efnJT/pzwDsWHIIfexTPQSs+LRXcKiP3nyX+5TsApEqVPfVXQydxWSEKL+FuMivu+4OfyokY29veAl0RNlnkXKCtboFEFSX5LKzxU/bJLc2wRab/bZGvgHpMV5wKqhNAQNcAy+il2hhUunagruvN5N0u7RkrIDBlt3zytb5kEPgaJnP83jmiJinj0SVejorfc9Da1o12X9pFkioUYPtsDy+04COnqPunEXvseu54jb7FQ== 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=yHHhH6GkEPcmWeaMwexhl+42aBznDOcUp1XNu338ZX4=; b=Vwpo+M+w0GlJ136mxX2dnPydI0+ycugqlVFBDN8iXA38kc924t+ic4fX+nxoc8mAFFgYDWxaO6XFXmYvLbzq19xon3PKR6XEpQ3Qm7AEjLQCQRT+HRD8M8tOLG9hv5TgsqcQXKnWg4Z/qBZCCeaH6H3wTAmqyHKC4XjMhDKsUhYSmckRq1tjysv0oq+5Hylw7tIXh8wLyVCJKKjLp4oNmW1wksiOwXJdZzjUrzPOi4H4HGO9/IyQyKRzoOgnauH0WjXjSgavUIn1YVAOB+S04+XeX4Gb1By9oVaokK9diU96IoLPEuNFf7PmUX1eJIaaN9my+4chncncDOY6WDyGVA== 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 DB9PR08MB7721.eurprd08.prod.outlook.com (2603:10a6:10:390::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Fri, 3 Feb 2023 09:19:06 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 09:19:05 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v10 06/12] parallels: Move check of unclean image to a separate function Date: Fri, 3 Feb 2023 10:18:48 +0100 Message-Id: <20230203091854.2221397-7-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> References: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::33) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB9PR08MB7721:EE_ X-MS-Office365-Filtering-Correlation-Id: f2c4a908-19ae-4efe-d961-08db05c7b2b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +7d+wQzBgLFEZ18PsGJIXymcqM7gdFuf3CEZ4xoAXwQN6mVhheeMbUHkKSUANR/fQ+HqgBrlbQytcKisMpfWXlvN6VM3l3TPvqX4wy0b7cOm40Qr1C+LXmwXWZmP/ur+neCNWvdOB3/UwkqXWAKxUnTNy3FIEzL8FUF2tXECikQcdPAggeoyn6/a24B6X4B+wPBrr5Od1s1iVyMX/TRo+nSglYMimIwK9NTlOp7oZZVdsyhs/sgOkAo4gJosFxvtOIkLMW174W/AJrm7oxqVfSeefaSTAoOKpqQlEUpDhBUPcT0Z3sA/WuDeFwJbyMpvtvu/6t6QXma90ReVnoOPv60LgatWyTfmI+ZPv5rhCSPeoZuQmhaInQmH/j25fXbmGe6Virt1Sei61I84rDVNogeKEt4K4qpgwXxUD/SdPMZ/RzrGG+iGxy+JayGle+gARbLD2WnqwUci2f4uItDKstpYeI3K2hdHTOFuDvHoGMGQUD/5xbGcUZwa8mmTSjm97gtBo2EmNz+bkIvPtRuVogojtuEJCPxo1wYtYFGMRDzcl+hc+jXv9Pu4C09uwVd7xS7/BCzeZ4fL9pyva8E9LpZendGXcvbkmB5DGvVsrB+ZPldzIeDZ3/H4jSP3exVU1XqNNZUHBhv+eNZrsYv/gB2nEq7LEs6NZxtiJq80bNb1qG14OYjxFCLW75IT9XRn 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:(13230025)(4636009)(376002)(136003)(39850400004)(366004)(396003)(346002)(451199018)(316002)(478600001)(44832011)(186003)(6512007)(38100700002)(38350700002)(2616005)(36756003)(86362001)(8676002)(6916009)(66946007)(4326008)(66556008)(66476007)(83380400001)(2906002)(6486002)(6666004)(41300700001)(52116002)(6506007)(8936002)(26005)(5660300002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Eyzdiuho9GCcJ26WJE0QFLrg8RjBP3rrfmRedEJjE2u8OSQhixJp9jCrbBOlxvwF3bgku9bJXwvBNQu3Lwl4JH2vIpz61Yh9MRbBvaYWA3IIK+lfC8wV0oppyXY0ocoDPvLigXhNKb8QV+UM6a96CvUrS3qfeyBlejp7cqmoAfQ6U3RjicFyVNv/yl3ervna2T41kWfP0cPf78Zg5As6q+xeoZy66sCrPCrITCGegcwioiQRdq5Ob9qer+CqNC1iUmZyQoDbdPVixw2I9fL5c63vnVX+YvNfcXatYt4KwWBaCf9goVmhnedmkLnmVW7zK1EmTKF2TyF2K+XBMIaYV42fhdUtl1qAG+y+5IwnejMcsYPgOsj2Br597YAh6R4w89GWVbpmCX0df9z0CKw7h5v7KbtEVu8k2BZabeByncCURrwOjdpsDStZSRTD21xTSnQIPFcUvmjPpEF1DNS4lD5LAo14FI1zSKmSXc1AOd71lBz4L1EeV/5ZmjMeEPLF+f1jVbcFRW0hdN8/N//WirqC9g5hM2ZVgVySbcIKRzxtTcekKjdtgLN+r59Ywax0lLNyHArEb1acsMSc2aVlQ1u4CFe3iWlhPPg7xvHnTS5xLd9nk/GorYZDl5gcmio8hoCkKNCXoLxevdxPupHqV3+eEKRuxtP+x2jRy+nRMPVb8CL39x3OyfsNa78VnT2cYTGyXxwY+LLm8vKCCsPaCmMqb+N/Vlqnsrml1Qw99skFX5SQjFeC5cy3seEHapFzGBfiAIbuoz90Lt5a3reaqZNiXT+jhKlDnPLFuKg9aB8hZ1TttcFnT2FS+Ejcm0TdPfvGUqT/4PnCqMi7ZOfjI9jDdoIumYf1lwoYqLvt1deyhLw4QuqLthDSfJv1355Q9RGfaNDPwCMmvFLJ7HZj8zfTpVou1dlGb0IBPbK/JP62zt3kFlBWb6EtKmG7GKgNXWNhAH80jLhZpLMZn+nfVXU0oYZvN8WwkSjFl0ymjWCpZ63M3zRMWS2ORqJRoqF61Tn2WehxwoW7fppNUt2uUjjWfy75M+oLT/qZfRVEmXpXclov8RNwJ6KanOhWCANZgz9BkUejqHWb0mBADzIPmYxUg6Z0tG+TEngj6dM841/xCaAslPMDLqUY9tcgctioeMIwk9vh3DI23HjXvCr1HpNB27tKQNhXWxuxP428BnouPX6QzxEfKicGEYzBdTcQqihsJJqrUlaVTUO7iBXcHO6O6bKTB1hgK15ijoC4dhmzhGc1BdufXrMxNhbEWIQU48quC/U014A5+r/7i2YBBg5u5Ufv/OOkpVncXkdgWvXx4A+UavP1iNul03/3hU57+LzaP3fIJ+2UnbZz3ALlK16WEPRg3KYze9+o/SOIm/Y0zfKhdXK0pXOq18vun+OlI+kqqj+Ml6Ejgc3W0bSo6BIeTXncqXMg0mEja4vPNBFSo9wtSNArEOwbxLJkwGkUgkOz2wsGLiDHpwDdr4OJygUHAPrpomq2FO/w621JyKbXBNliflhOcNjQ05V2kan1xgTF9+3/q0aI73YXCyhmskAwauBqDRjA5AQ57EyPEVTvl61zn00OOuHEasMmFxBmk68bZvPJhm8Wd4//vAnsTZGZ75GThDWpWIBg7AtEPig= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2c4a908-19ae-4efe-d961-08db05c7b2b3 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 09:19:05.9224 (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: RePV7u3ap16WWbWiKYpgLjsOHtuP5LSQrroBdx7tW6N20PpZDeOb4LMEzbwUC8vhIDK4T2hKU+wieqZO/ywT1mLttttRkLsjJtIg121t0Kw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7721 Received-SPF: pass client-ip=2a01:111:f400:fe1a::70d; 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 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 63bfd7074c..02fbaee1f2 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -418,6 +418,25 @@ static coroutine_fn int parallels_co_readv(BlockDriverState *bs, return ret; } +static void parallels_check_unclean(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + + if (!s->header_unclean) { + return; + } + + fprintf(stderr, "%s image was not closed correctly\n", + fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR"); + res->corruptions++; + if (fix & BDRV_FIX_ERRORS) { + /* parallels_close will do the job right */ + res->corruptions_fixed++; + s->header_unclean = false; + } +} static int coroutine_fn parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, @@ -435,16 +454,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } qemu_co_mutex_lock(&s->lock); - if (s->header_unclean) { - fprintf(stderr, "%s image was not closed correctly\n", - fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR"); - res->corruptions++; - if (fix & BDRV_FIX_ERRORS) { - /* parallels_close will do the job right */ - res->corruptions_fixed++; - s->header_unclean = false; - } - } + + parallels_check_unclean(bs, res, fix); res->bfi.total_clusters = s->bat_size; res->bfi.compressed_clusters = 0; /* compression is not supported */ From patchwork Fri Feb 3 09:18:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13127267 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 7BE54C636CC for ; Fri, 3 Feb 2023 09:20:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNsEC-0007KX-T7; Fri, 03 Feb 2023 04:19:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNsE3-0007C7-5E; Fri, 03 Feb 2023 04:19:19 -0500 Received: from mail-dbaeur03on2071d.outbound.protection.outlook.com ([2a01:111:f400:fe1a::71d] 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 1pNsE1-0000ne-3K; Fri, 03 Feb 2023 04:19:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FQfa8+Bo1BxBNFuXAM14A8Fo37bSot0ZhpHr0DZAmJDx0vLMFrp73xT2F/Ko8Fp116lU6DCY9daoxt4Bmo2fm7mP/4PrvwNvLHZgb6f3hAUc0B1uMIm064BdstldJkyMVySA1yEQMhz9zW9O5sB3S4hgXgXFvy/X/qYrqJnlwSxuqwFjsFXTdDTLvM5HLLHPCTTSN8/9kk7zdbghoBZ9hx/wMEnXwjCwsbMRY41PuDhuDXKtd6o8OMUSt4mi0WE9JC0Jjkocb9BOZPGxoZQhcb+jbIVnx1ESUqEDBhE9TWu0mUiRIDM0+k6cP/izcPaMBRqWuy9ISJypAVD5NB4ygQ== 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=dDPIoAoPKaBy2ZTB7r4RxcjS7Yi69Uh1tHT6M7uhW6Y=; b=cS/F+lwy+d/drFFwgesB5IzOAUgkEMiXIfZvwX1mz9z1xoRmQOw4Mc174f5ew249+xkS6e6AwYnwrMsIfIBsPJKNLchtLMu9OKb8Ztqs2HOj0A8Ku2HEK9J+SJK8E++syyxQ9BjU1W3HAnyPwDS6eAbgPIT26/Foivs9rOMAibQtXnknPR/RZFZ0mP21O7HkrMDNyoaqjWZqZxdRJhFC/Tjz0ov9540vS9ijXB4pIHEl1tOXgcUqAoWXVz7mAT3qyeMHciayUtz4pmQw5haKgyZKmGm5a30tOkwv8DyR05cB3F6EvPhLLRGcvzqV0JARVDwyF5oibaQkN/BW3KNb7g== 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=dDPIoAoPKaBy2ZTB7r4RxcjS7Yi69Uh1tHT6M7uhW6Y=; b=i/IWG6VGmCCXOo1WmziS0HUgDXLkKTEnPb8iTRsGgheLng6fI8urAj5GqZcl3ehigYe5kbpLADApVukN2I9AyIWfPKnQS63oTSrnOHjlKOgfBUtmhhzzfPFmMMk0MFe4xDdYfCOys0hS9oXgDWrmSevZPHv2eigNgu6U2FFztk8m9oxYkcxdKV8Qp2WxIJzidF5Q1BIXH7ZROwasF3onIvWzWey2DauBaMjw2kcOiWL9gsWMkjGgrUX3pVkS9kD/e+giZDbP3TAM/GP6A5qFnkFXsw6WN1NUqp2lM+i1TaCCDmtHIHpsAB1FPawOdMjZmOCTbvWsPzNOYGblB6gRGg== 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 DB9PR08MB7721.eurprd08.prod.outlook.com (2603:10a6:10:390::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Fri, 3 Feb 2023 09:19:06 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 09:19:06 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v10 07/12] parallels: Move check of cluster outside image to a separate function Date: Fri, 3 Feb 2023 10:18:49 +0100 Message-Id: <20230203091854.2221397-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> References: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::33) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB9PR08MB7721:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d54c269-f0e0-4a55-ef14-08db05c7b31c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tUofL5qVXO0aBhUbci0X2XlimwZRPtTWgGBodne914sT+jPljPUi3bHyuzbvnRsAX9m/MPAlvYLzxHhwiVFTp3pWjGrGuAqsQeyjtcwTgwU5W6op4u43T4ZsKHiMRVKrV0yLS7QO73n7C/KsMropU5pqTm2G/KzmKMTs4opa/aFbtjOyfVDUJlYo8HBgKl0iMvWH7u0BZdw+I4AKG98fTW+jAHzuuao8Mukeb2TYNAJvqC6k108dKGOTJ0IFkhj96rp9HKB64UzkncHyMeY4/XYpvjfsspKAmTuW6nDvuEB/whkAKCyl61Kyoeyd+7L9tuj9hVL1e7Go4ZnIvI9xF1FjoRQay1Bk5aPDEbnCNkTIYd2ydx3AuZyMZ2QSZYsaiiK802BHLlc8XVdZ19Pp+ikxM1ZqpD/07a+aWFSfrRn6/YRqZKckRyWH1oWVS3KLrf5YFHufnc38JRDR/9yCfFHJ1SYb8EzUMmZt722R7VXy8eJv3pSFvjH5SR69qDUIEEiCACDZeVJqekeynQ6cKiaSelIRaUNsRqI1T8a/n6wt9+6gyWqN9YEafFTetGK9WzUejhp2opj96/eqUnKbQFq9RrPXmoUXWHszf30CPwM1661hndhWoQ1dWr37PVq/uyVQJLbpCHp58SuELDh77gXKX97kE9ho1/ytvpW/b16rfXqgkHJCVbzID2pyTJlUUhqJasmgd7t4bjgYDkWDYQ== 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:(13230025)(4636009)(376002)(136003)(39850400004)(366004)(396003)(346002)(451199018)(316002)(478600001)(44832011)(186003)(6512007)(38100700002)(38350700002)(2616005)(36756003)(86362001)(8676002)(6916009)(66946007)(4326008)(66556008)(66476007)(83380400001)(2906002)(6486002)(6666004)(41300700001)(52116002)(6506007)(8936002)(26005)(5660300002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Jip7Yd1qKqL9LpnKAjI1KmY39v5eiFmkZ/8q9wh5t8ZtCsmTRZBn1xSRmlUKiMk/G+FyaTm0B8fdcJxCfmNEYsllkvUPDz+uv+CbFYRBRxnQD4lewGILGAYmlNV7keUNXFqopM2hXWirRb23sCUJV/oinuEZ6weaXEnqv/qPQ252uO8Kp1Qf865IiGHIkAxzjGOr4bOnVwy899deC2vMLfslhd8LxQ+1ezu/aQ+8oH9/mZcDTO4FxazJPmD+gzzZ0KBuvGBcB+1tsbI67vHe5gJ6lyAxpCu7H/68ppwIXE4GQoT8mPdn3Iyiq0ohNcgovNmrTm97KwVJRsj9JfYATQXWkW3OyHuzfBzM3CopcyNbqB931yCRW+F0exxF5mR3VqbvIwFP0p6E7bAULBT/PQNA6zVCHQreIF7eu0DTpUHvuCq1NMVqxQMsJvY7jKdH/KKQdFZDIl6LsnZI3htA1JE328RRFGVKF+nAKIjLlRz18eCL1+6kjxfSWPP/jIJuWz+9l11SdQ4imaY7t6foDF6Lun+Dnxq+AR+eNPaGWPwznD7qij1DwpvVLHQXjpXNe1O02Hivv0X6OQBXYdmy0aS+4WwK6sSK+zI3ZvCkHjiedHpqTz6ENM27tN0k/VHzids0DJ/fZzPYyyG5nk2phn7Vv43SdDDpVH2TAgFTexq8dpcMiGG0fNPs2YhOfi5cro+nfhE4KkYeRPxnmtSndUTIiq9A6cCuO33Upt0INhluJDPPqnDZTAC8arwPRJe/EZ3otr4eDStqfsak5MNUtl744urQX0hDU8VIsOJArEm3n040RwMTEpbBYOJoN/Q/fRRnz/icyLGDgWelTWsIzNXKUefzu6Af36cwR06c/cXHUzEYvXYXDgr+LVdq3j0X0ySbfb40D0Dxuo6KksvEjMY00lkQOU/olsu1P9+zDcO0yElkrYGn9bHp+xebAlm/fqtLS70glAolbB0Y9njiKxXJbie0YMQVEgTtv3esah0G6hPLLT8IR0qttoslbwHcv/swS96InW8xryFaf8l8RiyfLHqw9UralDsgxniHOcd+nI3uzaIyY2noC86gCcJd3b7NEJnaWaUNe4wcAbVqLYWx/vLFByAwQSIH6xTRwWHfFC2eBlA1nmR3G8uF30s93+7PgGILSoyU1fsODqUZmhhHBglmuAa+n+qPbH9GYlD4IODZzXkGVW0wLf+Q5tjcDRqmsLT3ZpW5cCe1/86xj1UdIlB/Tlub+z6zxsvQG2fmsQkvRylbhYfZQL9hkpPFa4Aho0L4uZmtsGIgnuqkJZnNXHnmWPp+pIdUXZqbBqPLvMe1sXpAbdc4FmR3F4jJ5bbRnmFAfbOunshPPbCHgFSXShSDdSolH6Dwbplw7XGbo9ZmKe2DXwKf5ekWak7Qc0mcJy7/dT84QEvCL5i1khhJU4Hyjc+mOV1J68YZdkPg0woexJ9B4HH4gOOZ5BZd1XHLTtXJDEEPlGQNb6hp2IWJ+tJWaMklZmhCJjNcEBuO+56JlhDv5ir0BJxFa0DAx5DCm229qR5Pj9Yhb2JTxMxKI++SrirUAmUhe3ZQZk09zRFyN+dXbXk0Z9QCT+iBXtOchFfsPsvl3tyk0yvE8iqgDy89Zpnl1TlRZRLyeiQ= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d54c269-f0e0-4a55-ef14-08db05c7b31c X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 09:19:06.5486 (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: n3iYXMRqGAfUcLGsZPOxEFEMBvHcPBEQ2OHSIK5J4d8L0s5FB3dRAGKSDy8f2i3i99LIUn7W76feBwq+gOJfNiLlhdok8nXkRIjwuurC7cc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7721 Received-SPF: pass client-ip=2a01:111:f400:fe1a::71d; 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 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 | 81 ++++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 29 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 02fbaee1f2..f9acee1fa8 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -438,14 +438,13 @@ static void parallels_check_unclean(BlockDriverState *bs, } } -static int coroutine_fn parallels_co_check(BlockDriverState *bs, - BdrvCheckResult *res, - BdrvCheckMode fix) +static int 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) { @@ -453,23 +452,9 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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); @@ -478,19 +463,11 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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) { @@ -500,6 +477,52 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; } + return 0; +} + +static int coroutine_fn parallels_co_check(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + int64_t size, prev_off; + 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 Fri Feb 3 09:18:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13127275 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 B6301C61DA4 for ; Fri, 3 Feb 2023 09:21:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNsEE-0007M8-Ph; Fri, 03 Feb 2023 04:19:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNsE5-0007Dv-Bz; Fri, 03 Feb 2023 04:19:25 -0500 Received: from mail-dbaeur03on2070d.outbound.protection.outlook.com ([2a01:111:f400:fe1a::70d] 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 1pNsE3-0000oK-UW; Fri, 03 Feb 2023 04:19:21 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R0jME4kgVKXUQ2ci9v4MT7inVIRDhpSBBSaF+zF1+iBSDlNbnnjYt7Wu/RoR6hMT1Zdh0rycSLS11sr6S+DE4GbOs10iCX0+E8Ux/V8TYFF5BNJ0mvcB2A3ptPO175ictpB869/ooL81+k7SNvEEAHUuYlk7PPXtfNK3vz7zuRgLTaA3rP+RIgKKvOVS9Aw1AooT4cwnwrtlaq+4TwP0SSN2V3GH/47R7+nRgVaQUq4Zp4Kzmf8VtprAQebCR/10vTrBR0H9GmZ/b7CNSvJBLkhLqQyuHeYzXxe+cRywBxV/UJXPJJlLTRis5JgwbBMbNsvRKuUrGRifYix6uKhTvA== 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=cSAQfrnNEDCTHhDdggbEkX2oxk4SSHRhYpKMrKpDeHk=; b=BWgDk3nHhRsEoONuxZvqX6TijIfXMyp5rS1R9gk2YEzjiyrYgsE2ebBWvgCAX6IGS+tNDCFTJGFKhuODxZqZEo2w+dE8nhLjkq0CTqUg2+8IWDADe4hTMgTai+Yss2f095yN1V5/C0yTmDcscRgnKLqj1wIHVDPmJn8EDw++2GZpVskLw0CqPL/UaxqjBlCvGrEErHd/i73WM0sgYh2gglxUSS23o1H8Nou3TowpyJSBbeGYIUSgiTTD7ffMAuNsaI2Ds822Sn/+wD+pMDYahPnDSK6I+CM4qdJuoGHO5LHneqr/A+Vwc67CuVMmOMRRXTLDmW9LGqMLLllxql/C5Q== 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=cSAQfrnNEDCTHhDdggbEkX2oxk4SSHRhYpKMrKpDeHk=; b=Hqox3RRqTRtglbp9VSXxSptNnEENPZPK7jDgnF2FtDXg78jI0f7ka2uKOe5EkaCZjqFovvI5/0v9Ocx+pJhFnmWIv60fllBBEf5aeRPdC/LWrFNRLLexHTKXWtbNw9+EYR1o44YpexsiPgKmnoFCJnBmK3KngS0YtjZTZruGL2MTxSfR+qTEHL0lNipPTow3HYbXzvAaSfBj5tiG05PdyXWPOzivcuwWU7+ymtTx5vT7O7Uki9hhPNcWLI+VGNlMEdhJDd7RjCbN5keLfe9IwkT2APlNaVIOlHPCRkoqtA8bW3Mcm+jAVRsCAwWgk1KwOVnQpmtAJjtNcv+5CTdCxQ== 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 DB9PR08MB7721.eurprd08.prod.outlook.com (2603:10a6:10:390::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Fri, 3 Feb 2023 09:19:07 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 09:19:07 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v10 08/12] parallels: Fix statistics calculation Date: Fri, 3 Feb 2023 10:18:50 +0100 Message-Id: <20230203091854.2221397-9-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> References: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::33) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB9PR08MB7721:EE_ X-MS-Office365-Filtering-Correlation-Id: 57630ce4-2f52-4b55-842d-08db05c7b377 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9CY0AbRFvCtmJJrzEStZXOg5PDGrTXKod4CWZ+W1lvXkBdI3i7Rzlzwlw3QIZgQkevCyb9/FLHkU9g2pVETtn+VzKGZHqI5gxNAcRdj6hyFovAbJsLxDlfkyCf8Fim6hV3rYOOcK8yx9erOJo7Waw35iGZwp0ivKGQovN9F0O935dyki47x5nCgHnugAXb4n0G3MogQilcuH+sodrmGcOWuSQXJEP03LucLr0t3pLS6bNxQjVWtaA0jcPOyxYn6ASceHzgA+d1+0L2L/2qQul303oDPctfo6TvIuVBUQ3WllJcwPN+NgfqJ0xzLJcvdIoT3TIl5j7e/FbKQyKGNVvRSJjX3fiVDLpsajwFlfV467Z8JXu7LeckoPlKlVGSqyhyzegkTK9DqNckh63Lr5ESw2mr5MVX3vuqvGPDPzBAt42xonkQOpFH+Rb9otjQ1dxYTkX7awTFCptEe9CQKOKItS8PxJ5K85wqpuE7a2pPO80SS0s8HV8aZzplFF3sKEzC8CZfxwoO/3dUvzLkXMynGxtUVkKbQgIxwuJBRINkpJad0m7xb4n/NBvhR7Up6z8ZWNOfRnEufchXXZ8h/9pU5cjXlY/krwu5wlzrYP4BvMAe/IiRkn23+Y2h2RQgeu2ytr/42B0VLCSsDYbyY5gPvfHAwjwkzG9q4WFT0AW/qJhkSKhA1Wv30BaD760P+eIZxd7PHcahGjTiWcwBY1jQ== 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:(13230025)(4636009)(376002)(136003)(39850400004)(366004)(396003)(346002)(451199018)(316002)(478600001)(44832011)(186003)(6512007)(38100700002)(38350700002)(2616005)(36756003)(86362001)(8676002)(6916009)(66946007)(4326008)(66556008)(66476007)(83380400001)(2906002)(6486002)(6666004)(41300700001)(52116002)(4744005)(6506007)(8936002)(26005)(5660300002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9+jMzguknaXaBbRJPc6BpMKKmelndErPalDbJYv6kYDiwFYwFSvHbEjPiZZCaQ+nNzE7yrM98lDi8VwvgGermls2G4PF1V1lUSz0nHhgytwIYvCEXtIO67SRMJ++6IqCszStMAemkSMzB1qV2EPi9Oieglb6MmrOgwynwca8sg+5/T5jlJaPE0W7DQJXHqixwhhbgH64hdEgkoYdgCTHdCqPaSHwib3hflOzbhUGFXSKzLFq4ezjt98pM2uBtLx/W+Uhac4pzIn7duFlD2HXI1lktED6nJvQt5YWjXzojRBdpekeoqbKe5dQusk6c+Db2LG062BL1TZdb2wYtydQuzb0FV0RKcP38kcloVyEoURfcdG/qwEPL7arIc+JxKuUWLzOcu7WLwee2QJ5mVD8nhV7AXUKdejk/h/niLjzgYE3uvIHIy69OXM25WfO37j9y0t7SrC3vjPR18qpkutZ1KKtkiJJSdKfu2RERKzm8F1yTeNePNhvczyYuPLqFTUH8kxb4W9EsjgosJAWmd+ZzTUk0LGYBgbPaS/6gVvvZvAlwSFLGoroy2Yexenvl4oAEGocniuQ+P1ERGtGE58TBWo18UVEALrRD62iBvGT4JSBLBOGADWRg/5BprpRpf4XtMqDfkrKcg/GF/V+XDKPz9oECjU4EyMidBZPGZZ7ns4yggYagqZ4E3l2FOK1bDzaKAPm6qFwpWubcvWGSNBLD7mKhhH4mj+aKxzqzDRkSf5ezeFdQUlgDHkCyRbn0dqJqJaAUHanse4Y++qYkFWf/8zrgqVb58sAhZ+i/ysLI+99GzrvleRKBjk2IgYvP97kP/r5a1EJ4jKEKxZOLKszaDv3WxkVrG1L0niFkiSrx+e3kl3k68pJQ3134OTI/I6t+cM+sVE+I/YkcdAcb8Mq3CnamWCPuwQ8F1UlA7UYxlQRn9Mot1IpScnYBorFWB5CCDqcVl/cvzVzeBrd5wKkwlb+yoFOGp+fQssJT9awV2/YwwX3Hhn5hLHcf168C3ibUz4NlLSEAefF5T/iGgnwDDbC/vbiMtKwUeWcZJ4LaU5TmTHYknx3EWYhyQC2RzNyHH9q5HzW2fIW/rl1RmQ365e4wG1fvxAcgiixS9A43dc77Rnh+JIo4w8VW1Z2AqT1YFXGUVKPudt5gurMdVqrR+oiReMdhcQRjT8E4MSIrcqvfMl+0UpHRQE1KwcZeevIHdzqQIZwEaU9XpLlPvKYKeYqCMe4SgsMz76dX7nDoC/L9p4L9y1wJe0Z/J4rLaqltc3dx5dt5t449Ub8rBhnDtU8nYPlHll4fS3ADA3z1XdswfsPGoa/3ui9p3l+BsXCLRCLEvqmL4NFpmZ5fjsPA+jNn+M6GFeOmfZKiXiVMNawqvfqUIuT6XtBYFk5SOimdHBkLlYeJM1Hw/zsTCIGcXTZkMbXWyMrSQsFxPoiQtLqskyPCjJ6Ul3PFovK1Q7w9yOg7XtaAXlb7MSmFtyJBGndhlNb1+egQI3gdFtiT3f4AWcl7WeytvE4fU6BYLiyfCE+LuAw3LGLQCxPOyzfSVNe3ZiUMkiJwbHmEeG10QtwLwozxrVb2eV97tgDDmxDk+Bs6MeZFwBo1mJQt9O7k2l8ncpH8MN1vDoiGiQHS6M= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57630ce4-2f52-4b55-842d-08db05c7b377 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 09:19:07.2204 (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: 2jvQTS9BR7RdBXiTOicVAZRfxxJ8Uc9xNCagWfU07CqO8l5IwhOE74BcH3GL05IpsmNjNnvssbsgjFDnTjQTInHc2PnQfRVLTZTWY77J7wo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7721 Received-SPF: pass client-ip=2a01:111:f400:fe1a::70d; 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 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 f9acee1fa8..994528d93c 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -510,7 +510,11 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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 Fri Feb 3 09:18:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13127276 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 14313C636CC for ; Fri, 3 Feb 2023 09:21:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNsEE-0007M4-3l; Fri, 03 Feb 2023 04:19:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNsE5-0007EC-M3; Fri, 03 Feb 2023 04:19:26 -0500 Received: from mail-dbaeur03on2071d.outbound.protection.outlook.com ([2a01:111:f400:fe1a::71d] 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 1pNsE3-0000ne-VG; Fri, 03 Feb 2023 04:19:21 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U2pytdnIJachnwwhSrlMaACu4tbEInjkwMNXMQWLOSljDgIvU9VuT6MIc1Sx7Qc4tRJoQOfnQbwsNL2xxJd21u/97ZyavXmu8t49MHse6H/kT9VI6d1+TfuMfvhkXP3BthYp1u32kkn8GybwDMRWx44og7Y8K5XaoJZZzIJFalbp1DIB7eutNxDG7i7t3QsyPLcPvNscB/ihFyVy5TXSJ+w/GB4VmKg70vlL6sBol0YtkK9/FiEQq3/6VWtWFvRGPm1Tti5ACPjT0nslBnjcHwh8z6SeAMsIhZLy74M+SjQFq7DJdGDLUwt+sHZP4umAOTZuAROMmFTvGZHhZk3ZgQ== 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=vohNuCGbA5uuIg5QyRWjWb1YRZRCkhuONT3UJeWEuXM=; b=RwCXtTLC9BwlDN639o3UUlA7JDOXg2nfvzqUd96C5bBE//h5B6Mb/cH7dZuDD1uS1xM1fIs/MKcJiuD5+O24BFbhde2mpLdzoGrlVK4F+aYaDAcz6Y1Rv38WcnwwP4p+C8IqKqXIyHyFzUhlzqdgXep/nmKLXg+NbtHTUfIDdbJ1MV9qTWcXOyOsYrTt2Vg6OCKhsluK9wM9KpF/10S5LURFxcb8AqjzLYflJT65nt1onC42asfRxDM5fNNznA2ZuS56xFiBIJCRNI6mjLF6ehVzz60AMOhOObK4xbnIFp+sYb2rLKD8cHDM3eoaie/55jHrBnJBlUSwt4ZpYJXAAw== 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=vohNuCGbA5uuIg5QyRWjWb1YRZRCkhuONT3UJeWEuXM=; b=kUyVAWBnntenoSactlFEzjI6RP5/arBT5dy0UqlEiQ25/6QKsyflZl6JHK01/CGrrzqRzNizLPIwqcDKMC/pj54aXo1lCQeegLE/AgA5r+G8KBTY1UnZJSgOKrcofh19VsdWMXemzXNVpb6BG6Q3UwtpGSlM6sm9n4gbI5ymLhPHS4CCArUajp3irvuxjTBmOqcqf7C6lTJdadxtwX6hs23+gPRjrYGiaVsgYryvOKefWq7PyeeCOSHv/U/6kFCgJy07qJgmbfY56i86WfhJCm1w92UrKXi6yuU0pRkZPMkn+u14tr25D5045Ei6r2qtdsF5JYu7Thaiwv9Q9s68xQ== 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 DB9PR08MB7721.eurprd08.prod.outlook.com (2603:10a6:10:390::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Fri, 3 Feb 2023 09:19:07 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 09:19:07 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v10 09/12] parallels: Move check of leaks to a separate function Date: Fri, 3 Feb 2023 10:18:51 +0100 Message-Id: <20230203091854.2221397-10-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> References: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::33) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB9PR08MB7721:EE_ X-MS-Office365-Filtering-Correlation-Id: 07e255a1-d688-4b7e-a24d-08db05c7b3db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RxskcE7SHFTV4yMY10vwsrx0ujeYaDmSDH+YMBSAaj3dt9OSc8JCW/G+yA+1bpFVu3FqdWAVY3HzPndHFWRTlXu/85jQhckkdlcoertuRNzKz5MaAZ4CmCjKThx4dOuqrfRDow4GSPrrzZfpbMsTpyirCyMwcuMamMInTvI14/ppUFgcT2WsjayQxWCwphx5C7I1j6RVOwxn33y+37h8vlfv4u1KqxHDTHqXL0hv4Bci+y5u0JaijlmbBlk/zmq16xRzBrjDKB7O7HQ//cqA1jeMVT3bljCUIxdJ0z0caHsJwVGL89AdN0ktZtaelV7x41IUhwdmj1uqjwcqdTSr9WU1hg3RpXieCHOuWLippfRnVJPToUxF5grc3CUPHvrk1EwsktSitblfJmPBU38GVnO8MO6AWrH2uwWa+wDhu7Kzku/V1dkJk3k+/i2I3HwD6hkIftwYMy6YZA4+gx6125JHTh5esEuKWlK+IImZ15IKIqLvbqJOqTUWMtDy6UNVR+eTpa9Fxcoo2CilcFXigxnfKJ8g9dFs0lih+AcsRIE8WxfHpknPF0/UCCUJ413l0ryEpOFtegmO8/HgZh/EX0tKZHwvJHn4ex+dKvBiTN5JQ86sM6VXYKfdpu5S5BMaHK07uR9D3KBlKNt6/bevFIOX79c5pk9b8/UjHMNgvtO4VRpFUP6iZWtVgvCCmLlxRr6R+IXB7qlGvCq+dW8Bfg== 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:(13230025)(4636009)(376002)(136003)(39850400004)(366004)(396003)(346002)(451199018)(316002)(478600001)(44832011)(186003)(6512007)(38100700002)(38350700002)(2616005)(36756003)(86362001)(8676002)(6916009)(66946007)(4326008)(66556008)(66476007)(83380400001)(2906002)(6486002)(6666004)(41300700001)(52116002)(6506007)(8936002)(26005)(5660300002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HRrhx15Xg3adQsBxkUpy1kASDmFdIdu5og3F4AXbvTY9XRr3FprCfKQAHjRBJ6+9GNsIH/G4c1S/g+2fs/AU332VnBOmOJcxk9Fsw0UlGf96VTFFS5dN7ksa586Gp/zMg43jzU/6/1QZVYeflkP5OZFXpyow1eY31IXIdpASMRlowRrGNNJcTvWD4ZhNrrSwCTGGwUpB2hfv5s3QiK8DwTgpw0vrkkwGIbBh+0vUlVzpZShb5M1tuu31SYg0Zqk/HZIbfw4fgBhy+MQPWfMTVFBpg3btWnBXmXpjoMV0v330Jw1C5dQVc/xqQHQIrcU2Xrp8sxt8me282T70TYbvenmzdwK2ABIAP/ySsQgo/uSZq+pHhzHyDI264Va16XKwYhzGxRDsu3goNoyPVicy/NtPN0qyAqVRHnEesI24vhg5dziwdOTAuZ0IY0rTUtp/L1CALzDyCg4AuqPI31SGlIqoMXwxK1B7LCpkpDvSqCGHdrr22UGAAx1+8XdAi6bbh+Clxi17WNgKvVsBArLy5xotMjU4NLAcyRSp72jCdt0U/9LN+223KTvXmzeDiLCzLHCVuPSEstMA41tw3Z1n5179sj2e2moG7IGHrdarWK2ksQo71t9M2Vr7f5MrmvWBoR1hsmfeaWBt8Pk2DwGqPfzLDZA4Re7hpQVtVIVG3HUxSb9J4/328BAR9if/MqdVK1FfCcsIw0SbqlR+vprCj0R3d1IgepOx50DCZpaJwkLo9GfbD75kRnHC3l/o1XPtqKKDJ99gVgzpYIboLVJIrYP3FDDoBqMEp0oU+AUkE5TgttWMUDJxCwGnLImD0ol6bCo/qWzigk0FqtnFHeRSFamTRyWCIUqeNpOse9XLOrv9mB79z4Af2+tG1K6fH15oxYXu41UsIh3kJxipJfQBDZ9OxneiIgCMJp+Pe9J4+2VrDN0HNpqFpzyloCzqGn67R17a6drc6uWVvhdg4/NgVmJa4+d7zRwIGEnQWFXtVkZCCWUnFNVKM0vJ8w9BbE3n+F0IaWqKOyZXRR4cPCUPIcKQ3NodUkK82vEIuGzpySc/teRERvBUqcOfmSPiRVZgDA6Mw3zM+yV4GnlifbtsKJxSnw4kdUXj1VU78oTwNHawLDsDyCr4+EMoe3sNVnBOSYhJirKVONryyuzb8NMBj/mYrzvlYH+iyXpuNk30cFq074b+Iek70vWn7Dx7byuB//Z3ttW27661rIocqHmNj58HyeHarHzS3SKyQqhg13p2oxr/+2dKmTwjhWVQiHhZYP+mZHDxkukGEqVByfT505jqNKNylUlbJZcjhZ1EnkVp9UgpfMCEluhmA0c5EI4hjGlhO1ou7SGo1wh0LIANxAGEQX1d9TPyfgQ7s/35qb7W/+Aoo+N4Fh8+sdFLPdUcqwJQJFZ/fpY8cv+i8SCqQwUBQjvUpiDzJ8huQMa5RrORWQBm2TtdzSEwh/VVBWPumQHfsSXNsDJ0qIsio7LF1n85BmZJuPfTDJ6PtzaIeOolGr5OKg/urrWU2+kotF14EBDUNk66cTO6s2+D3stEVNi51ibBKQnTMNVKymek5QNs31WLOVCAYq69LhUDI0jvWycnlkqlyB1Yag3A352qoMNyFNsVCdikU6sBbJwp82c= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 07e255a1-d688-4b7e-a24d-08db05c7b3db X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 09:19:07.8140 (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: 5DPl0ADw4WK1PvJjkR+EL2ir7YtxlbIvT7KkxZYV5nEgHbnxD0kDVj4HILUqE0BrXNAqGbXIuXRiTYRKstSV/5a9k4lfzgQYnpPC5TjEB1A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7721 Received-SPF: pass client-ip=2a01:111:f400:fe1a::71d; 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 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 | 80 ++++++++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 32 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 994528d93c..c7d37c4580 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -480,21 +480,57 @@ static int parallels_check_outside_image(BlockDriverState *bs, return 0; } +static int parallels_check_leak(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + int64_t size; + int ret; + + size = bdrv_getlength(bs->file->bs); + if (size < 0) { + res->check_errors++; + return size; + } + + if (size > res->image_end_offset) { + int64_t count; + count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size); + fprintf(stderr, "%s space leaked at the end of the image %" PRId64 "\n", + fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR", + size - res->image_end_offset); + res->leaks += count; + if (fix & BDRV_FIX_LEAKS) { + Error *local_err = NULL; + + /* + * In order to really repair the image, we must shrink it. + * That means we have to pass exact=true. + */ + ret = bdrv_co_truncate(bs->file, res->image_end_offset, true, + PREALLOC_MODE_OFF, 0, &local_err); + if (ret < 0) { + error_report_err(local_err); + res->check_errors++; + return ret; + } + res->leaks_fixed += count; + } + } + + return 0; +} + static int coroutine_fn parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - int64_t size, prev_off; + int64_t 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); @@ -504,6 +540,11 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, 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 */ @@ -527,31 +568,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, prev_off = off; } - if (size > res->image_end_offset) { - int64_t count; - count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size); - fprintf(stderr, "%s space leaked at the end of the image %" PRId64 "\n", - fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR", - size - res->image_end_offset); - res->leaks += count; - if (fix & BDRV_FIX_LEAKS) { - Error *local_err = NULL; - - /* - * In order to really repair the image, we must shrink it. - * That means we have to pass exact=true. - */ - ret = bdrv_co_truncate(bs->file, res->image_end_offset, true, - PREALLOC_MODE_OFF, 0, &local_err); - if (ret < 0) { - error_report_err(local_err); - res->check_errors++; - goto out; - } - res->leaks_fixed += count; - } - } - out: qemu_co_mutex_unlock(&s->lock); From patchwork Fri Feb 3 09:18:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13127273 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 B2470C61DA4 for ; Fri, 3 Feb 2023 09:21:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNsEE-0007M5-4r; Fri, 03 Feb 2023 04:19:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNsE7-0007EE-E3; Fri, 03 Feb 2023 04:19:26 -0500 Received: from mail-dbaeur03on2070d.outbound.protection.outlook.com ([2a01:111:f400:fe1a::70d] 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 1pNsE5-0000oK-U9; Fri, 03 Feb 2023 04:19:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hHGppeoYHA6vsSqKnJ9pz+3YBW05lVEfTX4N4rCpV1zs+CQysLfQhSRHoHtAdxk5OtOW9Lj+PRQ3PHLu4s5BsgQ6LySSFZJrdEyJv+co497Bgjn+rDwzacDVdIbs5nm3UgM3jFpDQwYuLgEqHGpw67fTUCC+dhVv7wYwbcjbacMO70nJcGDt+mDyi2wOi2TL7+9uN1zttlUoH3O8k+VkcIqvyQa9Tlb9Z/PRCuUFr1KQNVGHvt58WLQVFkJ/zlpoBwzw1bLZpEqPwbKWaz2RS4KhAkR+Jg4mc5W4Y8tZ6CeExoQULab6M13eFwgfIf8ojBwbhPE++SXJP13LlxekfA== 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=1gHhZCeePkWzYtLuDd9N9Uifv0FsJ7yzg+b7tUqfNGw=; b=EgUEgzh4Ua5C57PqIXfItRevIolXecSvVTZcPLKqrZatOm6g40RfVW+Wpkfhll5KWhsA2jeGy8nEbPnfNXoCso3CNzIjT/aXdo//995PSRDhMU5zSwYAfZE4vK+Or9s/8hqj3DvOEoluZTDm/tEp3z2f7uuWJekhnuSbLZOPKtuayFBlaYo+lZcKYWZYE94jOT0j4QBHNUKf27Ea39EODkgr1QhDx6NhbXokswxhbi1Ax40q1YLr39BkOcX1Y0peKuEKZHVr0yOSx49wWfzIQsGPizCDNN7XDEn4gzSipe+TwVYUno+47Jm3SrtsfKr0aPtuZ6l3F9Rn7Ktdpr1gsg== 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=1gHhZCeePkWzYtLuDd9N9Uifv0FsJ7yzg+b7tUqfNGw=; b=ICK2zze5st5RIIsrJ4ai40/qRTafz3geKW7qDphJ+/p3TvHscgaE9gFFqvWRlTlRY6UDWTwKqeb2PaZQzDY2+hztlCJCoXAV/wWn1kk5FcRanKh8iyv++MpdWVdHVNBDzX/kg1bomtn8ZohuHOO6fm9MiFeDenico8ebgqugWJ4aLGBY7g/ic7Z0jJ11JZ9zD9DYzg+sTHV5YmfXFZUN+V9ccm6iIA3CPtsEBxU++Qj6l69xHr8c0ImzpWz1Bp58fRXwnTCXusrYJqEh46huYRBSl6sk4RT7jc5wLfFARl9QHvx0iNMDSs2WJ7umUx0+ibf3TlRRGmHohbmjtkLTgg== 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 DB9PR08MB7721.eurprd08.prod.outlook.com (2603:10a6:10:390::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Fri, 3 Feb 2023 09:19:08 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 09:19:08 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v10 10/12] parallels: Move statistic collection to a separate function Date: Fri, 3 Feb 2023 10:18:52 +0100 Message-Id: <20230203091854.2221397-11-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> References: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::33) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB9PR08MB7721:EE_ X-MS-Office365-Filtering-Correlation-Id: cb62c87b-8068-405e-b4ec-08db05c7b43a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EjlimofN49kCqEUgunxwfLYyVy3s/JROQeNTWuX3WS7Ul0rT5/JWIm2Ho9C/DIgDUvUnxLSC4ud0Jk8FxlviTIxUCDAmq0afYGFStwRfR5pyWcWtq7HfvfAeYowFJAfQFunnNqIbtYn7Fle1lPNDwpjeurs52RLVUdXzeme5cARnemAa6P/zHukkTc0acOl4xhjdiX8AT9hHeXK6xqYvX2MgNfzHJbr4aVZMqPdNHCP9GDkNiKrPJ37tXR9r5taedVRHKZIIOZIL0qK/FeshX/N7tF9znWPL1QcyqLVJ8sqLvsiS1GoM+by/OULINzOG51QgavxZomOq13hPn+ftRk/6q+Sx+o3RnUz2EuIGKCGPLbOMfaFIvdiWG5MQro1dNP8PMu+3rEwiRSuTqfd+2syb6AAM2Q/CsZfeM2buon4AjQ/BQL9sKquhrXeAUT6+LRogFRgf1mK/yrgz1xCFU/oDySQwGr+NnI1vRPOOaK9TcbsUixtR9QgCsnnd4JUJSdl/3CE/cUQXtSGK+eY2zwBZ+niLPAbtvJESnL27P07wFyew4jZwmU5/zVbEyRkgcnUcSevE0Z8o5sej1iCJK9gM0xWX49BZS0xa+UEpj+j+Fgb/Mpe3JzAyIKP7Qlbk0mGOfwCAJMOLEoowSzaaestc/HEcqLrKPy8VnjFekUXi3vJGUitRZR1ngItw+qpTvV37QW9JsdehSxFWuDLfWQ== 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:(13230025)(4636009)(376002)(136003)(39850400004)(366004)(396003)(346002)(451199018)(316002)(478600001)(44832011)(186003)(6512007)(38100700002)(38350700002)(2616005)(36756003)(86362001)(8676002)(6916009)(66946007)(4326008)(66556008)(66476007)(83380400001)(2906002)(6486002)(6666004)(41300700001)(52116002)(6506007)(8936002)(26005)(5660300002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rVhPcEb2G15ZGFxTR8BUan66+6cbSECccZuHCikp1swQupXRVP2m87RnbMo5UZTVXfwCjKzYBaVgIginpmW0/D9w3422mUE4Nr/LuDygIzfWG00IbGxttQ7Wq/uDuSms/EnXwu30EpNt5iMnDAMyYMge5AQHZpDJVY58jKXOT6KIrT6LWHi/oTmM2k1cSlyXZMyh5HyyIycAxaifzq5IXctYc4UBg/v18K9TillZWsErMhLWhGrz420LfTa/crVY6HoFupRFACW/dIIApKm7ELY2ELk/LLoM/7Gn9+GxGh1MEQ/k7Yid0bpSGoOlp4EMPgXqhtj8PT19CINBDMQYRs5oXXJ4WSZh69wYzgmCX5LVp/Ogj0qaZY277v078F0OxF4wGUf9sFyx2/6fLDaUr6y4X5mOpvx7J1wnnb79gHBa0kpyuBLyzttTeLy0lciYAw/C1I05cjeZLQfsO5C0owTdpJDTHKioNxtP52w0+1YsZ0basRt9vf2aV9PEDmLdov2LbVRhKCHDGqwQZCSqEAzQUdhgvIyOx14SgrxcOcrLLya6UHH4/F0wq01lvP+aKtd5VAQzBKvrEpJQce7lGsywEbljBNQRZ4LmoQ14Li1Pu6QRrCsh+hDgoTMwXhAboJzjmFZgpAn489PMmGTOpG/42I9/SRmvOSEgHrojNQQT+DnhPbCt0t1FJ5a4gdkzdvRBefgW6s51PKUwGOu9UT3agKOMjC015cSXxVGV3yIUsGVApAKeh8RLznuOvc4b+sbsZQ9k+UGZoZMjwMu6XRrHtacIDFIKiloQZrruZluLA0BOg9+WcdjR4tPvfyLjIQSK5kSQt73uYIfwjgRYIJGeMvopYZRDAMg587WbNqn2eyb+5OuKVTHlawAoH1FUgLwO0KbBvcjEWF3DIJyCVRvqyviXuXDocXFPRYdoQDV2Yi/CYjG9xsYo28/Fg4whykZlUHT4/RNpJ4Po1BqR8Cyc+TMvS8InAgsbHpRCY+G9EIkJiwJYmr5c1Z3r6ZQKgywkByWB8Iw1e0rQeMg3AySWtvKP0HFp1jfmOF1gLoyhUncof0JDOBc9jaXrq9e72MF/v3l0GeWPsBuqP9DMvYJGWmg8P6Mo1HoEkw9WtWbPJ15/8wCfzNoFVIzE2ZpPkIcF/9FtlXHprWYj+Y7ubOOX7qGIv7YI9o4Dx4SPP1AAeFoHkb83PukX3MwJHdGn+QyAcuIncOJ37L3fUpDx1ZOMd/92EymKERRcgvLNSFlL10lgYPAyInLp8kZfnGFPhy+GcT0c+O+ftN6wLJQ+F2C87YXfbobvbFQYHsHn5g3kCmczxnXeHS1lm1xonviIIgSn4prCHohQp9U6Kmmwcf/r83T9TLDy7bSWUX3H8ovR/mfQIHhWiFcC/JcWn1Rp2r+LHv5a7JI0vEL2/uvvAw5Rvp6LRNt1WCtiM3hMQAVwDtyFdg1gvkUHKuXp8e/wFrimaQkku0o3dy2z1OiWHJHWsinQfu9v5UDCREXVFjLvawuHmv4ac4UD5D+BoMC3Ozp2WET8yJPfZlSwjA7AEJwEyyvPfno1tlrl5+8mNuFGp30XPcrlaWBT0HzTez/y1nmByMKwd/Q5zck6VwBT9TobcDB6Qhk1qkPGoNzyWy8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb62c87b-8068-405e-b4ec-08db05c7b43a X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 09:19:08.4527 (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: a/ZQMCnifwi5qfmcrcPBW/fXhfK61IKR9sf9/b7thtrcG+5bSldheLo+z8n0c0u7HxAcKQI5Hfnm636fxT69LYxojcVeBE6jayoLm7BzTEg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7721 Received-SPF: pass client-ip=2a01:111:f400:fe1a::70d; 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 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 c7d37c4580..3c38a0fd09 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -522,35 +522,20 @@ static int parallels_check_leak(BlockDriverState *bs, return 0; } -static int coroutine_fn parallels_co_check(BlockDriverState *bs, - BdrvCheckResult *res, - BdrvCheckMode fix) +static void parallels_collect_statistics(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - int64_t prev_off; - int ret; + int64_t off, prev_off; uint32_t i; - qemu_co_mutex_lock(&s->lock); - - parallels_check_unclean(bs, res, fix); - - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } - - ret = parallels_check_leak(bs, res, fix); - if (ret < 0) { - goto out; - } - res->bfi.total_clusters = s->bat_size; res->bfi.compressed_clusters = 0; /* compression is not supported */ prev_off = 0; for (i = 0; i < s->bat_size; i++) { - int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; + off = bat2sect(s, i) << BDRV_SECTOR_BITS; /* * If BDRV_FIX_ERRORS is not set, out-of-image BAT entries were not * fixed. Skip not allocated and out-of-image BAT entries. @@ -560,13 +545,36 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, continue; } - res->bfi.allocated_clusters++; - if (prev_off != 0 && (prev_off + s->cluster_size) != off) { res->bfi.fragmented_clusters++; } prev_off = off; + res->bfi.allocated_clusters++; } +} + +static int coroutine_fn parallels_co_check(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + int ret; + + qemu_co_mutex_lock(&s->lock); + + parallels_check_unclean(bs, res, fix); + + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + goto out; + } + + parallels_collect_statistics(bs, res, fix); out: qemu_co_mutex_unlock(&s->lock); From patchwork Fri Feb 3 09:18:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13127272 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 44502C6379F for ; Fri, 3 Feb 2023 09:21:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNsEE-0007M6-Mg; Fri, 03 Feb 2023 04:19:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNsE7-0007EG-MR; Fri, 03 Feb 2023 04:19:26 -0500 Received: from mail-dbaeur03on2071d.outbound.protection.outlook.com ([2a01:111:f400:fe1a::71d] 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 1pNsE6-0000ne-7E; Fri, 03 Feb 2023 04:19:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZfN2wLTZbpw5y8fZNn7FgqCwiGjeVzRw5rbtyl8J2iFz2L7USzcBoLAYTmABv6cydzWbwzcx8JjAp+GutWvqQMRGh64IxyghkyBo1GcAgMlMGhrA6l9tcvX39HM2EQynZ172w4wrw4yY3LonAwgpev4+R9tG0glgb0aRQtVlLLP3rHa/0dB+3i9Xz0P/ao7n2mImdyxFMyaHccq3LAZZLtJjj3NFKusXvOSSUtcuMLNTn7Hp0101Ph1a6Yv6aBIg0nr1ePogYxROmuobyNigCiZ1Z/T1rkOhnhDZ+iKFjk0z3N3w3pxMHDao2h1FLoyM72D63J182UXudLvCJRm02w== 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=LGYMOtB3M5Kd9JVr1I1txZcdZ3Z8vq5B9XzuQXqsJZI=; b=XDRUw52TpexiBeVcIxo/wNHnRKnfQjCRhVFkg1/hefX0cxlkL9+sX937Uak5CfIFNxRKR13py35+Os8YjkEj/4Cae6DX720QwXtxXp2NbeGFfTRg5BdEYpmv7HcLyoN9dyWJFopIUasWE8zI2kmX910RGt+O3QX8sB2bux62hN+yOmL+MfCuEyF/K9OnvnkLw/Z5wDJLzoYNvitQt84Sot2+0UTvcgTbvGZyluZMgaNJ//Luwri7+ayApRRw/xa4wZBpwNjYa4cfY5RRbXnbGaozyRZQmHomXAildL0XNxz14gPCd2Mf2YQOIOPTpVt9Lz8FyasbVaRNMFpnEFxPXw== 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=LGYMOtB3M5Kd9JVr1I1txZcdZ3Z8vq5B9XzuQXqsJZI=; b=eurUK6FY7OCU6KbMC9m4pTiO17eCpLqozmz9ZG/KnStxB0bFtacHbRTlHkdzeN80m7ZpE4PXyCITD6eO5Q7UaMjnWbOZLlyKiTpoHW2USFYNcAEi7gaFDOu2XUBKjzn5Fh2LM/HvTvncKzoKRGMpPFwD+Kc1Sil+WwNBwhZ4oOPgkgO3A3Sv6XeLsfVJGw/XV7pfQXY328jH0d8HeggLxxNheUpNthq11Bi+3YFhOUd68PqzXBkZS/8UrDyqASlsISqnhz4XHteWx6g70EVmn2cXebmP/C6hWSFJOSRhT4deHUNW+ynZxGmdcrTb3clGB09y7/CrwZakJQhlkpgWTA== 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 DB9PR08MB7721.eurprd08.prod.outlook.com (2603:10a6:10:390::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Fri, 3 Feb 2023 09:19:09 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 09:19:09 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v10 11/12] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD Date: Fri, 3 Feb 2023 10:18:53 +0100 Message-Id: <20230203091854.2221397-12-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> References: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::33) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB9PR08MB7721:EE_ X-MS-Office365-Filtering-Correlation-Id: 9de68e77-389e-402e-64fa-08db05c7b4a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xVLrw/FjPehlkr0wY9pZTHGiBgdNyy1U66c4kydwwrA4lxABxSuNnkL5ViZ3XDZTT55GGApSrM7TZ4WNJiIK/kp8S/ZWXUhxvbr98/yzexPX3s9zgHjyT67cg0Px+N4iMr78lKGqh/87qpuyN1mSD2F/2ogpLhHrbvxXOyIqeRbVR+ejrHHdSb7qbqFuioMwvkhAd/RY38NX0VQPJC97DhA1yDEgeXEv8OlW3xmpm35lE9lSuL0670iZz5e729Xf2RlSlzzqOzwB8izx6eZboaGK/yJWBoZL8O5RQrTxHfO2/YeW7AraD9lN4+isWpgQqtqr8N14im2Lbp66y+5e5Sd4hC6OMUhQ6aYk0Z99jhpgxXancEa1Ta2UKARjxpNWoWkgPT2X0vZOMqY6jFMO7P7XG0eQ4kGC35c7aIOAsXhM3yvbJuCQ/ZdhqijTxBJHD6LxQoYCc+6qp+Zs7epLIx2YM2ALJKtUTp6Ibz8LLeCoza07Bi89Ol3l6lFdTuxqX6z0/6ZraCzX46dLPXmUg2HljHlLZbaTFL+1Nhf8aLAmcTCv8s6EXLvFh6+AaagvOu4L3AFz5c2qPnF/8vF+25ydPlBRvu736m9f7DGIvf8A+Okb7dUov4FDe0Uy3jl3sVYexEdda4mV7ul+skpbrGW+2SnpcsO2gG5+JOaUUwIAeW2yR1hJOkqeLVAoZ+Bw3Mj3diMwDlTQG8k4kfb44Q== 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:(13230025)(4636009)(376002)(136003)(39850400004)(366004)(396003)(346002)(451199018)(316002)(478600001)(44832011)(186003)(6512007)(38100700002)(38350700002)(2616005)(36756003)(86362001)(8676002)(6916009)(66946007)(4326008)(66556008)(66476007)(83380400001)(2906002)(6486002)(6666004)(41300700001)(52116002)(6506007)(8936002)(26005)(5660300002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yu9JnAe2sBqKDcFbH+CvhCcBJIUKfPa55kdbacE2nFrlE5tatAvo7PKEQrQzGNkklR8MUyhBANu3nMx+EOVIBny47IvFj2skKJKhwfco2uoxWHOhk42fnLCtGpa8e1sSqingeem3OEFziMIZqDiJWItoXA12681c1jLPqq76Kzoap0kmw2SmaJB227hTS+syd60PDJtSi137C5LWA4Ij0Phsunox8qTXe++S1dTooG88Od4ipg24QLeLFiXxUqQBA7AA2al68l9ujHieaOfGEaFi9aDIWrQj2D28fmcN5e5d4AfDkwqJiBwkdafHzbfckmkmmKwC5n3knzHiAPv4nZNLG+dOdLOtSo9p2590WLj/c16FhRBiOurMWUdshDbN7AqJPgf3S+DNJmB9tK0eB9JITY5cQbD5+P7mSV4C9KaG4KSa4+ota6ZKBK31IK70TR+mbK7yNgKlHDoEmSE0A2yIipCnMQ/Y4E9CZttlhxcEemM6XmlTGZx7YRvOpCM0P54pxuDlPFqtpl8iD9KAR8/2vgVsJsVzbs2y6Ar0iamHB9YL0JhaxlmOE7lpQP3oVE9E6Y1or+f33p0hPTzesquD4wAQVEaxcmgy306bcuRVy/lXC3kzFRxt7jycXLOtKsJVpq23OeONz/+D5TmWLFLx1PfUyqk05c+HmVaJFs3h457f7yQPRq/pi/hzK42wsJv4/+ngbLU+WPnpsbJAZp/jH6xAjDAnRvcGpEc1njHKsx/n+LsNYqkGiPwfKPfmczZc4oMmeXmdiVguCbONTQ4WszXBU4h/hjc0s9/+v7PbtGQ/ul5HjwiOx+F6VdVGlgbI0//rvsHKhGwLRpTf2Zvt6cGcs/p4qbvdcCWcKHcQg3Gu7ehlW6hDRLwuZqSejv3r9galZP/CUPttG70y1jxiNZv4oOOZd8xT3/IA6Rp4meFksXJQJNJ4b/EdjbEyb8EkVMNX/jCEEyQmqaPDv1+fgyXM6u7wGgXvQBbBRRwVQkjghkCFyA4gCnn9nPJ8VJkAtE+Q+sElUJ69wAqwnxqONeNhlHC57hX5kFyk6SENsjEjISV25IIfvlZcw3CZFZBJ04W6D9KH0G52v+RkncuWuIlCaLTIn/FVD8E0a3Cd+NYdRLDrkl4RG4dRbMc+sCPFKOHPXVYuLaJf1P62e9D9qVH34OY2UfieX9lVJL/LcIaQecmMtbbczq9etLcJUB2VMQYS+N+5j0pb2FCFBw/3vlYljMBejOxqCflLhZ3GWMjCAdGie19WJ/8tYx1eXLsDr51VgtmFx8DPYtKtMtpsfdB348QPc4D2BkhlZx8yJ84SiCpFNjDP4fyFN1PUedJT9YcC5ebG8UsRmflhiv1tVeALoUY7vlMqETjvF6ocKIma24LLF4ssoA5kkQlWsuaxn6upSIyOKES3u7QRtqMsOeL7lX+sziC2XTK4FBn+htvjM8dH25fwPFfnSA9nM6L5aABcvhFwT5rop+mAdPRtOLWrWCzXzlq4lvWjKHlqx7vvAlaQAqE5MU1AWuuLbuVd0o5HZj7nUtaKxnmU6DR6615rnm8BiMeiOhiO0gd+JZIo5hLYh95LvrScqBCDDNGbcaycZSpYinY7v8oJgpJGhoY5hMTPKh13/hvOU8c= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9de68e77-389e-402e-64fa-08db05c7b4a1 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 09:19:09.1257 (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: DD0a8CgtRZuATQIk5Zk1YPJqLigRZ3N1vrLr8/VDMZ63eJBK7W/IVAZyewBrZGTi2O4o4c2JNoU204V45ilF8aow3H3ROwhEExdS9IqaewU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7721 Received-SPF: pass client-ip=2a01:111:f400:fe1a::71d; 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 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 3c38a0fd09..61e7e4010d 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -560,30 +560,25 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, BDRVParallelsState *s = bs->opaque; int ret; - qemu_co_mutex_lock(&s->lock); + WITH_QEMU_LOCK_GUARD(&s->lock) { + parallels_check_unclean(bs, res, fix); - parallels_check_unclean(bs, res, fix); + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + return ret; + } - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + return ret; + } - ret = parallels_check_leak(bs, res, fix); - if (ret < 0) { - goto out; + parallels_collect_statistics(bs, res, fix); } - parallels_collect_statistics(bs, res, fix); - -out: - qemu_co_mutex_unlock(&s->lock); - - if (ret == 0) { - ret = bdrv_co_flush(bs); - if (ret < 0) { - res->check_errors++; - } + ret = bdrv_co_flush(bs); + if (ret < 0) { + res->check_errors++; } return ret; From patchwork Fri Feb 3 09:18:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13127269 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 109CFC61DA4 for ; Fri, 3 Feb 2023 09:20:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNsEF-0007Ml-FQ; Fri, 03 Feb 2023 04:19:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNsE9-0007EN-GQ; Fri, 03 Feb 2023 04:19:26 -0500 Received: from mail-dbaeur03on2070d.outbound.protection.outlook.com ([2a01:111:f400:fe1a::70d] 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 1pNsE7-0000oK-Vd; Fri, 03 Feb 2023 04:19:25 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z7E7hI39cjnoVw9MwbJ7ugnIj+cAVggWxdadpKuw8aKPKVz7F8QddivqK3Uoxs8fGz7Knt8luAGf7WMyAv9Y/2UQJPym2uzG5atuKRANx/iJzkFp8iKhTDDHL6PEWw9YJ6HZShDTsZ8BBzTb8pQ2zmJBazsJ0GpKskM6ZYvgUmHLp0knngFOT3lSFC1oCUmY6NUwcl49kK00RktrIJrqoZWTde3sIB5Xyc4T37UTBzL17oVGPmjhmqJPqdS3encc4d9C4Xv7TgDy+UTEZoTQcHHQK5AlKPGTVvuQaoOlB2Tm5ndeWIMLTk+dqvaTmZgqLWf/VWjm2OJ25m5+gp2Qow== 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=9IWYtYzVTZtBp1uXtdSh9wt2T3kEkMtzPWWaer+1YMQ=; b=lsnRp/vjz630CuF5ADoijYF1l35pJrKpTj/Xla13Uhs67DsihMT91ZdZQansIq5ynWGRNesGb8+9O9sdmvGoPiHoefPxjFFj0NS/Zv1JAhB+z/TJ6E5wxi8n9awT25uwpwvwcxMJYilnsv7xKV6HQRxhYRfOXwqyH7idgzTN2K7R/gAGe3J3V7jYTIAkZXNxEPSKKM0Rlm0XzJFNQhObyQiGC1ls+wvuA3aQTaveonbMlbER6yOuo5hd1MUfzotzYJ4OxPRPE5wTCUK2qBWXMHQxODXyOgKPWuAs4To5Qb/9xFstsAdJug6QKt2pjK4JcExkvgVjbuHy/bXyEteRnA== 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=9IWYtYzVTZtBp1uXtdSh9wt2T3kEkMtzPWWaer+1YMQ=; b=Pw82ntQvdABN/ad0g3L8caD3bhRFHcvHd7RhF8h2hazGK0YlYxJH+e7keuiP9H/PDj4b2oLuIdErqel31Bl0BoRFEMXQXRokkXVhaqljNV0aerhIo3VQ13psWOdshA/CU6cp4zmU7e3ngiNLHbI9UgTA2BwDZ9ot7YBYUs30j66Egp3kQDSSOKITO1sLMW0KsBgYPBaYJRKSeH42wC6jQx20wIjqXQiSWhMkXzAlVaGTX8SCEapDTCu0HoFPVamvjk2g6EG18b3AwHV5ieUoo/fX2OUwlhpLr+a+xzWpmXfNS8N1wjb39BFyo+z43zL46C6l9wG2D0xPGyYG/39w2g== 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 DB9PR08MB7721.eurprd08.prod.outlook.com (2603:10a6:10:390::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Fri, 3 Feb 2023 09:19:09 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::73cd:4f7a:16fa:e648%8]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 09:19:09 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v10 12/12] parallels: Incorrect condition in out-of-image check Date: Fri, 3 Feb 2023 10:18:54 +0100 Message-Id: <20230203091854.2221397-13-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> References: <20230203091854.2221397-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: VI1P18901CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::33) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR08MB7095:EE_|DB9PR08MB7721:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c6f343f-5330-4601-830a-08db05c7b505 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: huqxDjr1XNcaGsfEgSkra/bCPXfRED/eGr+IxoRuxZoKVoTru7mR/ZR64riu+clQHFOO6B6jXKufg7F6M2kiKnWz97LU6BPxDHo1vmCNBOEJEh+zLUZBmR3vRTcl+1mrdwzzdknHEALVzBv3tCegUINI5Wik5MA6GGDw8rpxdVM/HFlphcysKNSwxZzP8vT4eEuR0TV/WV2XGm/ORi9w7O6o75gHYNGD3qsYLIY4DvSLdGRTV4BU7Ri4uZENfVHyfokh/P97YzTKgBklO/5SAV59VhY2P6FLmBo4VN2Y3+lvn9qL0FBa1h8FQRLccIkuJYkBZJbRbtsTgdVJzcadgNTKbKunvYVj9gO63+JTwnhxQfEvFAVkgGWpF7F3qBdHwfzHoAeDiVCZ0X9mjIG0rJvsaSi4XUA132+bECc8R+MHtKseHKeNjSIjeQyBjUUYbLFubCeDyQ6Tm6PVOpMS+5DgZ5uB8wM+MKMYFftEabXuhZWS0qdACzdVAF9D2xPwA61CrotG1ilykDTyouqgG7BRNNoyKcVtDxKmqByne4tAvniA/3M/Cr57O3t2pTX2OMNQe25eCy2BjwL1AKNitupRYiA7xAjbDLLOpT0pY9os2AQcmDniRGjwB05SkMWZFW6RNMz3U7Twloj1y/y6+FHw6j2tYL4v7IbijV32qrsPnsss+RlRxS5OCzO7IgrkwWVvWStwGMU7tQnA9KYTyw== 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:(13230025)(4636009)(376002)(136003)(39850400004)(366004)(396003)(346002)(451199018)(316002)(478600001)(44832011)(186003)(6512007)(38100700002)(38350700002)(2616005)(36756003)(86362001)(8676002)(6916009)(66946007)(4326008)(66556008)(66476007)(83380400001)(2906002)(6486002)(6666004)(41300700001)(52116002)(4744005)(6506007)(8936002)(26005)(5660300002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0xqSTCw94mtKeqJ+MsDYrUKyCpV+oypeljx+Cyn5KuLSlAxXlY+AviVJMq+BZRC8fstVcyKtBcwjkCwMnDOLlGp/gGTEbRj1ADbdOkKRCy4Jd4DhIOcht9bsDJJqAm5StVx603rUjM+yUAefjuyvO6mT6NVxgKrYRw4xfDKxzCE42wacjM5SVw2vMaUwHyTH4LZ6PbJYiM59yxyti2kXy10pEDHtWasr2UzuHmUIiCBiEok6IsfGJ0dVFwwSuyKBhGTKnZkY/GS8C6czu8aEhA6+R89CYPudskg61CnX7scSl2jTZXaxmMo0+3YwhmloEpUmk3G7bnu9t/y8SHd5OVEcEaQms7bgGfNBUsm5aRTCUco1FbCq6cnDURcCiBBTiawF13IJ7G7g0pNtzn2qZJD8dki8loSYMzKv3AYGrdCsNtvoDXf18fvkvAtLpxF2q8el6rKlYE24uJh179nGEZeBx78B/Y4BTW1xYDJHFJ4i+Emd2zJUVA3U7Njd1w6pSJ80PtnEZ7838bO6NJM2kXwCImq/RBgGqLvrUQqLeyHK/d1zGl2Ohyo0NdPGSwWet6BzkOQ+sDCXUss86rEkQZr+OXBPKmVTy1WeL1DcUBQQDjJdzxnSy7ib7OQIFb5bcWuj5fEsTfJR3A8zRE691fH2g2sCNAM14lWuildg4AKOwFikwRdGR+xGCPg/dKOxYTSxS6sA41+3AqVYCWdR07iq85e8a3avCuPZ45SKTx+bG9llXdSw2KdpWnlrSjLEBBpQxQ/DRhHUKn0gDEirle548rbMzAxlgehgHRR8BTSzFEt0QyifsdYCMJR559kKqS6tNsbO35y/caWH96r5lH6pw5zM9BrBGahoolcMQjoGvE8loOm1hPMc1D+qriwgPN04bR14jawzMBkKufM2NfxqpySd1DlSCmnY0IzAbaTV7iGVepsrGLzuGeSmjtSdpZUsULeAfpx856k91g7ylMjxH5UQUKymYpr5gHrQJ0KbPq79VAi1W1+Z6Q+q1YWdTG/wCcojEpHe2zWqQbWWut2q2VA8QcFSbW6XG1mRl65klKDhoop5CwveFGJNRTUWqepF7mMI7XX2IbApOsCK9A74o4+DVJhVRjNUC0F1YqyuJxVZvwkS1TK8y9pQYqXd51FQ0ApupURDVGGv28qzlCvLuw6AV1hDKnmsfi4XFgSFiI+gh0vwCDrzgg9CYYlGYj6nyeH4+ySKsOJsGL0kl3LF3pqDa+tO3ZV5PiRIRz/uJfc/6Q13kXUBuFE/gbKt4PFlrD6ANVeZsovyCjEBD98OYmZMpXEG8Bmu9nSB0RRqhAfpkhltalwFbA927/vG9u5sv1muU/T8U+3Z7nngo+zSB+2hz648/oqNxsZssDqtsIlFiZe/p4787IBJOqxy145ayjIQSt7q35EbT4KU/k17tpe6okLNJYo3ydGJqoOcJOUyxMd08/HZaZJmK3GK7pffFqjyq2Nl5grRO9+cSXKZjPuX88fz6o/0KFxbzguUpZZy6APo1W2fuFhUS0qjROWzYBe3yJIhqA6CwHlkVVX1xYSYqdrXyDcm7k8X86Ee73U33UpfNQ3G0HL/mvNIUhuDCq/Z/7WDFVyhiOUZuGurzLbz99BIkdlKw42Qq7E= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c6f343f-5330-4601-830a-08db05c7b505 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 09:19:09.7975 (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: V1/iSer+Q0uCW8Kj3ge4OWvaGFn4DP4urEAJlwD42EbKj0dmIf6GGR6KARDB25ojc8ZmmXU5wWfzAlHKMlTJKiCmYm12WcXvVekTppcyYrk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7721 Received-SPF: pass client-ip=2a01:111:f400:fe1a::70d; 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 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 61e7e4010d..8ff7d55c96 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -455,7 +455,7 @@ static int parallels_check_outside_image(BlockDriverState *bs, high_off = 0; for (i = 0; i < s->bat_size; i++) { off = bat2sect(s, i) << BDRV_SECTOR_BITS; - if (off > size) { + if (off + s->cluster_size > size) { fprintf(stderr, "%s cluster %u is outside image\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++;