From patchwork Thu Aug 25 14:31:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12954808 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 B70BAC65C11 for ; Thu, 25 Aug 2022 14:36:37 +0000 (UTC) Received: from localhost ([::1]:52954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRDyG-0004JH-Lr for qemu-devel@archiver.kernel.org; Thu, 25 Aug 2022 10:36:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRDtR-0000Wm-P4; Thu, 25 Aug 2022 10:31:39 -0400 Received: from mail-vi1eur05on2096.outbound.protection.outlook.com ([40.107.21.96]:43230 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRDtP-0004oG-7Q; Thu, 25 Aug 2022 10:31:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gdChmIzHPW5tFYyJQUjCmZv3qJHlKDaCc1GAe5drU7yEjJl2qcardtZZ4xp3RvaTVvykKlr6YLhIrU5ArsrIh6s4M3d7Ch9xPnQF3uMiqveh5aAgOOJADnRAnH+Clye4ruouidaYP6vhxSaKH4T+7gxnP+bm4XJtEFDqxL1G/JXVWHLKLZUDAJvxPZIS7AWHz5FTJEitki9YSmyqwSKj4oieFOYKp5HIkbE5qUhfrSAYX+XlguCKPOvj4XJclgqXlNAVoaBBwIvQkfQTPI6WuGCiVygJiBX1NNOvfyS1q9i9ghpALzoA2HopmMr1IxGDKdjNBQVt3saS2lDX18fbGA== 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=Rq5hwGgaO6eNpjMhSkXsvgMlf+r/yhu7Q3ZMuq/welw=; b=lqxk3k62NL6m60tF2/p6N+WeVecv6zSo8MAC9bAg+AuajCCmQbZ95wFYYXA+uH5ZpmjXiO+syD7Qndv173R5f5i4D9HRNOIe++p5uYDKvlBQCLJPql85Z0sIInxOvVCvlkrL4oBRVMMcO/RJwb1UnS3RKQeUam79nii6Hd9BBRHNvI2jCNauGNJCFi/rx9aQY2Hl/jky1xw7nPzFAJRC8rgdnJAb3Quz19pqGyjMwd/VNrHxHJqjed8yHRruxCxW9fg0YZz3ssagYImYuXW9pnWD9BHKjoRIeceu0edocMyfchu8KB6i8c9zivo3+r0ukSp3I1/J0/H0NWI/uoVURw== 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=Rq5hwGgaO6eNpjMhSkXsvgMlf+r/yhu7Q3ZMuq/welw=; b=wj5IvuRn0nWvtBwjk/gM57nR+DwOlja7sKn2h89BYj/ZDnSOV2+1HpGiQpjacPcWMbU/tx/TkSy259uWej9qbGVpx+0lFYDokTpaDgVVNqD1IR/P9MziTRGU4oscTvt1d39LoOTcQcSj+dV/oARYxnkpPkSXqBLIkNCdvab2oz1IptD49FpfS0KWjIaMaM3f7w4oNO0r9GwOd1OihavL6FYjPqy47jIvdI0bDVbLHnkOYx21Dv/HQPHWfYFR0hlF3+w+bWz+p0QuY4UKdix4ANnpGxDdR/IWA4+xHWxPBymgKlYQaBbnjbiy8LRYXrCOrE4i7mhbXPvs2dATZf3UBg== 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 HE1PR0802MB2298.eurprd08.prod.outlook.com (2603:10a6:3:c4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Thu, 25 Aug 2022 14:31:17 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.015; Thu, 25 Aug 2022 14:31:17 +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 v6 01/10] parallels: Out of image offset in BAT leads to image inflation Date: Thu, 25 Aug 2022 16:31:00 +0200 Message-Id: <20220825143109.176582-2-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: AS9PR05CA0046.eurprd05.prod.outlook.com (2603:10a6:20b:489::29) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b6774e6c-f228-4d30-0189-08da86a678d5 X-MS-TrafficTypeDiagnostic: HE1PR0802MB2298:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VV60teKEBYROOI43z6t3uiX61dVG80rcderoW4S8jPC66TvciRX3AvyIxJlPdvLH7FdERZrrXXofW3xcLCYczOuyhuf4+VkEk5A1f96y2wtTM6SGR3tbXItPwCSWG/cTMd9H+lQ63KQX9X8uYhRAMXGyuHjncxYI1hJZr8q0+kklXNxZpFDJ+EG2XN3mD4Vu1plrvqD9bMEbVvMQPzrbAOFn1ODpgGhDSVbK8VeAJ0tSR84dyPBaqJZr18uWrlvf02Xcot1YwXbbxFDLOO/vUqcBV4IA0rYZi6fylJXH4wa331vSglnhKEUnBeS9J53IhJ214kdQc8wC5JyDQk71n0hJXbUxRQwZsr49Oj0PIQ8pSnhkaB0fptkTS34bFsdgv+f7b0/Ek1iWwIjKb8vZvdwrVzV8gNx8r/vGr1aQi2zwT8WhZ1U70dNEYL9CNtgV1+FJrvDBFGExp5g+mcde2Hpo1mpTW+Uq2E1mvOmd3ernQW+a/iVgvMS4IDlQV2+NKxks2inEwIIRodhoS3/pM30OXHy5E4anQ0aNo1/RizFBw6F2CeXO3KneOBqJvNcFNdDT/B1FjmftQ0w6HUwLrvyPg6obHEecWmyUH/U6xQQx+V5K3Q8vttqSkZuenkOP+NQ2xUlhfPDWO6g3ZyYsD+QMkAOtgiQw4xmRlP+rxYj5NW0/d3HfPCTUP9lwZ0Zq7dSpf1zl8HXFXAlR9byNaD5OFwROuHC+rsFTEuOC6dqZBQjBcinEns+h9qDtorTLZCRvERW1kWTek7j7kGgQkA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39850400004)(376002)(366004)(396003)(136003)(346002)(36756003)(83380400001)(186003)(1076003)(2616005)(6506007)(6512007)(5660300002)(52116002)(2906002)(26005)(44832011)(478600001)(38100700002)(38350700002)(8676002)(6916009)(316002)(66946007)(4326008)(86362001)(66556008)(6666004)(66476007)(8936002)(6486002)(41300700001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lhAxyLThY6/Ctzk5nwQVLXUoRd2FVSEfZpkWJ7xF977dvuRb68746DqXuyrraPF0UTK6YuqIMaNtO1lZE771tvMCbccjIEs1LsysEwnJuSPjLgheRTATX91XedQnFp05gxsHIFuv8z+Tbq3QQzSjLbQ+t8X5qJCzm8CQKz/xjinuImdql0oBfstud6nPgDpsNE2o6CYSDOpSoidhnCPoZAZ8rvi171t2eYtiUTD5XFFvMbdEF0xiybAvvCBj04UVn3VleK7cUXNHscEIkRYWfvJni5nG/VwkZfFuygD3utVtfnH/fVGnoOa1vtFUlorMpLUppk+BTlicXe4knBqpzeHP9eYqaqeb1NLiQTxeruQ/XxDdkxRGpozq6RMwBEUTN51LcweSI37TCcOs5NpIKeDzUrWfGCiOisSso9tEpAhq6WbI42kj9pMzQkjHCzVm+wCvLSCjlwhwZZ7vomxYafSU1mlADIsbCtHW5wYAVaJdXwwIr9TtuticcDKrZkYOxpIgEEns5VwJFpxmv8hT5RMid2wgacL30KvRiQ9ztNxwGve8/Y62HTgpG3USaOHNwQFaUimwG2lUykgCah0c7ZyBCiPZ0HvjniYXQtk8y077KG3z2ZenuOTxsov9Ugh8fHfkaT0HBGz0EqWQZpUS8U43VBQ5Q5va4YATuHDWKcd7SjVWXxOFHChg+nqIYOjJUhfpWDfmw7kmG/BkXJsWliXyJz2ZS3qM2yKTnHN9LxpTIJuC2HAV6stQNiv0bh1BIy1AeSjHsy37dJ2yztmYma/4aA6M9/8i9LeDqfLjKWjX3G4dOJKYMN+Z/dbN/MD6ULf/ad57wbZh/bNoCa3vS0o/dM5inyy4xRb8Wkz1Dch43hvW3/6XXdN0CqfJF1zRWE4dEYaW9ZUiC5R3CSRoCk1u1rGHsvMRJoRDMLBwdMhBeJxHXG4L2IgiGwtXHr7Wrm8lxij6ljDtd7dWP4PHJ53iP3/KzpJXz4e0hVOuJspHfvoFR+/qGQVngv8TEMoozeEVqxq4hPLOtxGyvxm5QD9nhHZkMoYheW1BOgW5WJLkErnpzn0rRwy6xqEp1vAGUyzyTwr6Puuax9zrQBP8B4aJZ1PM1R/5PYxl5ta9jWIIXcQRG6SzxKMXuZDYu83uI7y+UYprIABNphAON2HJIn23B7U4sUhE7PsI6bal/8zpskvrrN1BfMveqj1205kYGnLt5kHngxZaDuYYLEWI2TJxG5JgWIJTWJpu1XGQN1gXUIWfxZZPJ1zWbtIkELxp9ViZK/r/Bj1vUbZE8Cf93sWvna56u5/eAVdjkqqPCazCgtA4ffTSX38kUee+9eyPp+nn4cDmHKzb2hdacH+OKepJ/SP7pj9DsTkDFUous7VBwuLFk6I1eiPzCwXmBCubJKtU2bIAsJQirp90XcftoJnzMER+J1RFqVELHk7zWJaooqeQZjKnka6Yc3DYX5fEqhqyp/iD9kfcb2WJWP4+6C54Vivc4A4YoyK6ED091OCcBya6zYPdRUBfqFRZEF0uNRv6ZPLj5biaSRlWP5cqRIErhRwE3nUbNjKH46DCzD2olQz5GttMgceAB3rtfX0fxmPnnepo5lThC4LuZ+X7ZSAFVqNs8bVQABiMhvy3Hf8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6774e6c-f228-4d30-0189-08da86a678d5 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2022 14:31:17.7357 (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: tebQDigtuV1xxMNRQODCfXNWgslC3MD+68fxdw9S3WIu/pmwIkkV/1ev+JR7OiZ5DaTXgDadk5e73x+93N+Sq1dkcWK/mcsS7lRmjFdMllU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2298 Received-SPF: pass client-ip=40.107.21.96; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" data_end field in BDRVParallelsState is set to the biggest offset present in BAT. If this offset is outside of the image, any further write will create the cluster at this offset and/or the image will be truncated to this offset on close. This is definitely not correct. Raise an error in parallels_open() if data_end points outside the image and it is not a check (let the check to repaire the image). 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 a229c06f25..93bc2750ef 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; @@ -742,6 +743,12 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } + 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; @@ -806,6 +813,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 Thu Aug 25 14:31:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12954942 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 3CA4BC64990 for ; Thu, 25 Aug 2022 14:41:37 +0000 (UTC) Received: from localhost ([::1]:35850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRE36-0002wh-3D for qemu-devel@archiver.kernel.org; Thu, 25 Aug 2022 10:41:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRDtV-0000aA-3V; Thu, 25 Aug 2022 10:31:41 -0400 Received: from mail-vi1eur05on2096.outbound.protection.outlook.com ([40.107.21.96]:43230 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRDtT-0004oG-Gz; Thu, 25 Aug 2022 10:31:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RMBSn2F4s683ebM3GS6FDpd9OmYyYzDDjenPZ8a1clBbvIx+huVug9Gy8KkCrll5v/g8mTU8ClStVD5jOSuPsdCJDZ8gqq+AN2YJL4ncuJHhVWhB76zr6yNBDIEY9zEhsc4ktwC5/o6iV77uIDOLz6gJ7Jso88UtkUrch8Ioy4TB9eZRZr8IkoR0aUGsMgrxYlHbQfeBn+x+lCtKy/qU2HvaZaf8o5sugpB+N35IyY+ntI6KItBbCLmoBbM5ud/2rScEN2IeviPYNOC+JtPgjQQqlptj2hr/wj34HX6H3anZuRIookOvEsFYnnIZuk5qtJFZEjPd3HJm1xnFAAzorw== 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=yk9li7uTihtYm0CYbs5JOYbF9rA4KmKM2Fs2RDAdLcY=; b=HBwXARMkPBjFRfKBfMZT/anu/DFcV8GVCN6WR8slrxgdep8RaeepPcyO+WzySw8+vD4r5ka5qLcxuc5HYNhnFCATy9tEBXc7q5j46lly1PMNqEC5UyfauesuO9YR3N4p4s+TcLSaKCy47XqUru4Fc40Zkmlb9om0SNDcPnNWdvQL4i8Ik7pfjBy/AOSgbio+uUtWWT59ypD6thqk+P+yAiPrNXupdxyJ9XJiB5iQ4uahAdutiMwi2ZHVbM6KMByNhTzS75JQOgLxAOtoYvAbWXEav55YtkCoL14PLT/fYZ3Y+b70u3Z+jC2bbb7MhPwiPQzuNs0usjgHE/RZpU2jjQ== 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=yk9li7uTihtYm0CYbs5JOYbF9rA4KmKM2Fs2RDAdLcY=; b=MtdiaVO3hxbLzmCDn5zjyPsL5JV5aOqNTC0s7uIYLnqr/8xmQjdZ7q79H3eXoVRUutJeOnb/gaAN1QoU1YsIhXZLfF0y++35rKwfFSOp46RCXWTyQDjFqntTWmJBDcYjq5/7nKq2nfjGftlGBtLpuLJbtniK+mbjaC5SYQ95SQxsljM5YKzCFYYxWsj7AFUWB8dvZBRf023NK23YywXN6zP085Rx/GMZGptt6R43eob6/AZbbyCixKuc/tCBy54QGBgkvksknqPSX6eEPlQ/AF4+TddlUHOxNwjuXRf7uUQ6Dp7aaO7F289e8mSM595i/7LsgHrkl4sD5sDr0eusLw== 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 HE1PR0802MB2298.eurprd08.prod.outlook.com (2603:10a6:3:c4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Thu, 25 Aug 2022 14:31:18 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.015; Thu, 25 Aug 2022 14:31:18 +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 v6 02/10] parallels: Fix high_off calculation in parallels_co_check() Date: Thu, 25 Aug 2022 16:31:01 +0200 Message-Id: <20220825143109.176582-3-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: AS9PR05CA0046.eurprd05.prod.outlook.com (2603:10a6:20b:489::29) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6392704e-b374-471e-1842-08da86a67940 X-MS-TrafficTypeDiagnostic: HE1PR0802MB2298:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kPcvRTAShXKOcZCueBJxrBpuTMeaktSFGbHYpTCJdve++wUDqxkYwDX3l+STjLuH0f8hqazETCacVZ20mfTqimlA1M/WD8Q1IAE2cFN4LxEACGR8Inw33odZvvRBKGYFIk2wygGNrs3hXU4zJ/Zm5ryC5W/EpwekZepVwtxuY3DA3HxYlq6tmmFB22Kb8QmkmhtwT2ixIJscxppSP7Xmj0J1yCCFT4tKQ27Gt2StB1xXvz7LuSTk+/yZBdQ6MQ+Tehmi2wlNrvV3E5+TDHYTBeX3KHC4Mm5NLNjVIRkuHBCDmlRhwpmr964UqR2Z2mzAHtHaYA6bq4q4nj/NSbI0X09sVxWgW9J2yX80zOtxZVQxIFHrWq8yqPBGDwRrlfKpmikBk12lebklI3RHaxQLacC/sxoo9CLYs8a15f7l90sxG1ejpPEX5TMjJHrC6HE4WLIzh+UA+AlNPkI4T2EN5GDuysGvrxxyqyx9tfulYvmooKNY/E4oAhHaiqm1T9q93NjCh8gStNdL3h9LK7C/wttgD1HyPr9pEJExidhcGf1q9IHeERWhIXOPxVmWKFH018rWncoEffRTAUwsWAB1zuBhOaDzJbEV/+W1rHy00C0BH+64vyKXNiZBtN9HPHhcJhX17ov6eAd18Efi2kS9dNha10lu4gb5GoCHiR2w2N678vuoC1Hr7jvt/7IEAYhzkLC8JuarRIUqWly/qDjy1b11EyncQsQfpimClSKEkZ5L0A2oAl0fQS0s6TBBnvUCC6PwHWhcsW5wmo6WKc9+/w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39850400004)(376002)(366004)(396003)(136003)(346002)(36756003)(83380400001)(4744005)(186003)(1076003)(2616005)(6506007)(6512007)(5660300002)(52116002)(2906002)(26005)(44832011)(478600001)(38100700002)(38350700002)(8676002)(6916009)(316002)(66946007)(4326008)(86362001)(66556008)(6666004)(66476007)(8936002)(6486002)(41300700001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xCMB8l77BkHqpdB5/OqrXAbNr1Z2utSiVwxpsmH6HCOJcgHOP7fc+Qtca50O/snNtxqHFtWua3zDqkw7EQnF/mlZMxWAnDQcGycwC+O4XujD6PMnSqUvYJavWLopcs7W1JLqAGILlULTg3Yip4+6K7/aNXUCZ7SS8wTTCSXV8vj+Ob+xWdYQV1lSqDnHIvmMA1wrJMbK1mZN92PhsMm0Ur+YYrBevtMcMckveDS+FZD94Z12RdARdc7QFjO9ScEt1D9BOwxqNYJW5favmZc/FbKhMS6iHX2qr47oDXP6LnLywUaLui4SIqdRfzAb6nvBAcwFRFjYdYBmT0hUlAbEetSHtJKYimlUEHhXSUvJY0/fHGEm8CLxosUYaG+CRW52TVGLQ9MiFI8Baa/DdY6fSjjajBNcV+lIu0LMUaSh+HWmpZ8j51J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hH2MbLEcgnjDcHyatMIDz4MgT8gdEvJXsHYRUck41NpP7kS+2n+zDpIpe0n0eKR240K+XQUm/cYvUtm/Xen/XDzcrVXQDDZrEuTu55c9QZalEVIS2hXfpG7rIhWfVbZf68HwS6qfhL50I= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6392704e-b374-471e-1842-08da86a67940 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2022 14:31:18.4533 (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: t5YJQPAkF6Ih7y0PhD9Pw0gqigV2G+p4Ju/M0WbjA0yDwN9NmLeoPX7IzMeHijjC9+26eklusc6eOmQFxTjFqAqeNjlO/CnlVwONw71T8bs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2298 Received-SPF: pass client-ip=40.107.21.96; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Don't let high_off be more than the file size even if we don't fix the image. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 93bc2750ef..7e8cdbbc3a 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 Thu Aug 25 14:31:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12954955 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 9552CC28D13 for ; Thu, 25 Aug 2022 14:47:50 +0000 (UTC) Received: from localhost ([::1]:42890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRE97-0004lS-O5 for qemu-devel@archiver.kernel.org; Thu, 25 Aug 2022 10:47:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRDtb-0000hy-5m; Thu, 25 Aug 2022 10:31:47 -0400 Received: from mail-vi1eur05on2096.outbound.protection.outlook.com ([40.107.21.96]:43230 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRDtV-0004oG-Qb; Thu, 25 Aug 2022 10:31:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IXriBhO8eYPhSkDfk2fZNN7XTDBxEVRR9U3RQfXe6gxTMZ/gCXh6CClgc8FbunY0vBlcksr9QFJagZKE/Mc0T1cFjulSAu/4CJQTpPyjpQ9Js36uDVhUKt2op+iIqA6UsKzxrkBIDihmIdD2VqSXPwubB5tSw4uikOzdMn93rTH9iqV72pKQRgkW+QkmQ+JuxL5bYF/V3jkWO3zVayi4+tZFKoB27bHJEZi7j+NdlbqYJO7SNNcBfkUIa2uEdXyFkJcq0p0QVIWKozdSdoszJpitz44GVwbUJybA6S5bMQpwSCC44jppLIs666q26hVvWRJZzroQjREhaT/dS1zQOA== 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=+jATsGK6+z1YnaYs5f/VMZNISXlEIgalFXU/VfbK/g0=; b=bein5J6NqrKD9jBr7NH3rZSLZz82rmWYuMDR7mD2PznnVMju4hSxyZx98+sOgHZL+wrEnfqffHCuFbjaFBoZ5Z2sCdFC9QFat9N9SrVQc7fb82eHjXFHiA0yrPrUjwBspk7lH4QQOKlP5scmGtS9zwznShjCK0nv6oIyW5ZUcATqysYpUROowDsJhI/IMzoK8F3mHmD4dO1CubykOkRiHC67ha5azxWzDFoqjEN/tfsXPTotDYokVHukzyXgoj81bWYw35hlQjx0Cg9wAaVGOCQE7HV8yhT9o93UX3cCC6bN+KXmMjFtJJEbJDAqVf6jWKqvLK8Hp8badlfJjxddsw== 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=+jATsGK6+z1YnaYs5f/VMZNISXlEIgalFXU/VfbK/g0=; b=ymrvZcr6EvBB8mPDjc6xWamk2npthccKSIUOpK1EUUIy3BYP4csmO/lfbURKeRSu8p3lppmiSdZAhVXwmIHc2DRdxb4sCgQUZw0cJOq1uYYzUCUWSkqpzxU0fun9qlVrXBTYk2aw4hAyVcNOyJpVJiuhjFnj2GDdQkcOoVmekgxD7wZbxhzQ2stO8Aud/RmSbsu1wmhbbQkWkKbKHWbVtFxfcH5fbtnb/HUp/eryjF230XV6tNZm4txGSRpxfgzKpHmiRZvtfpAz5a6QlE65KzuZ9EhxsSHcKN4y1bzaRkDprwHLEoMd5AM+GjkyN5HDE6CNQB1pFhvlvtrQnurS7w== 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 HE1PR0802MB2298.eurprd08.prod.outlook.com (2603:10a6:3:c4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Thu, 25 Aug 2022 14:31:19 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.015; Thu, 25 Aug 2022 14:31:19 +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 v6 03/10] parallels: Fix data_end after out-of-image check Date: Thu, 25 Aug 2022 16:31:02 +0200 Message-Id: <20220825143109.176582-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: AS9PR05CA0046.eurprd05.prod.outlook.com (2603:10a6:20b:489::29) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ab4a5d3-6cdb-449e-bf3c-08da86a679ad X-MS-TrafficTypeDiagnostic: HE1PR0802MB2298:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vj4S73XAAzDrJvRGVsiRvxcUGpuNAc/9nWCL//CbmkF2F7khF3823rJmWwaQvXh17xLJfVufESPIDT/N9nuavcDRnCraesudYR2yprKk/GnyWbprhBII0d+ciGDImOcuCVd140FC1NLTWdgKew09C2SyVuGQhA2vXrc0WmovxN/Jph4LRwgR4j4x2RINDZjBDBKXA+lQlPgPXPX/+7lHLvbwMm/8f9W3cvepmq50sY1w/OY3/37JAj9bTpXFPoM1hmXgX2888zL6icIxZTiOKSaWMqUlURIB0AIt0MZSLwZnkg/evhs8/0QcYLhIBSzX7hTU5MW9r2kYdrldkiLB9wwAsNDjb2dpm0ktOG6Nb22WeNJxF0FlWQ1sgOa6M8DAujr2vSr8S6QDivsxUn4pmMnBMIVyLd3rrmh6mePTW/MJDu2u9S6YWUHH97+7BWng2DlES5ssnloLKnrD/WQahLOHDgBy7I4WEUN9k3qGd1LhblBvqfxd+50QwB3IT1dcaahZs1EnGAxKAmgH79X/8h1GkrFt32CO2kQW0prvS9RBnO28DwdEwVIr+2WlQ4g+zwjI8vj0GZf2fKARi2OoJf4dj//CgCD5v0XSNcsUMxQ+4GOdZXB4WObGBKqEoicrKlUNpgtfYhFS48KInMDKIp854hI7K53XyR1MxkvzhXYryNaf0+SGzw3SJwBtSHDsOhj2EybQO5DGeR7mXg8tCHxBQmOgVLvxexl4K5HvfO44spz+MCqlBE2yXdXNbymK71o+tf0ZH4R5ae5A/WY3ZQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39850400004)(376002)(366004)(396003)(136003)(346002)(36756003)(83380400001)(4744005)(186003)(1076003)(2616005)(6506007)(6512007)(5660300002)(52116002)(2906002)(26005)(44832011)(478600001)(38100700002)(38350700002)(8676002)(6916009)(316002)(66946007)(4326008)(86362001)(66556008)(6666004)(66476007)(8936002)(6486002)(41300700001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HYKJ4fS745uy9D4rg6AR4CeZFhe1pNpha0Fej7IU51iaJqMzzLLRdkgdKX3e5SBdUXWazTdLmf4VyAZFlJZJ+7qcSVUDIDbSGdOXppj7jPpi+SjlGHN1Kq91D9LWzKIej6cyrDt5kfCqamlibho15ckn9M//LQCn5DsC4i1riP+BOw5XwxaYZf8gnX4MEDceL/dIKBoBdUbjDnwIzQ2OSL1RGbXaHV7aEc7NuEIHQ3qSFy3sq/IanmBk8ksibXBA36nADfEWrOxqwsmtc3Vy2cF2IwqsMXCzH8jlxQAXsKgXdao8kQBGo3rLYx+ndlBa9UFScMqG0umJgcgH7hcaHMla3fuM9wnMmbYZw6t7At4bY6DOgM6uFKG+cNdx1GdklDb/xgoqrkgv6a4XgVbO97TAzgJkYIJsqhhUJfCSE/FwY2U4NcnjzjNvgiZNHlKziUdl/CENk0AOy7w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U4n7XKrb28c8cY+eHtroN3ikcI5LtDRyXElE5QQ/1QUgPNov6ynnUgVIJh87nQEUAYsyTep0nNtbwHPCMyyBXAI= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ab4a5d3-6cdb-449e-bf3c-08da86a679ad X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2022 14:31:19.2514 (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: De34/IgWESD9CTruPI/RsDGZjta6CH6zRVdAAeQCQw0ZBW76jPlOostZYWY+HnmG+kmnUS3Z6Dw26MrUubKP0O/Tt67QF/ZZ7rDxU13EGG8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2298 Received-SPF: pass client-ip=40.107.21.96; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Set data_end to the end of the last cluster inside the image. In such a way we can be shure that corrupted offsets in the BAT can't affect on the image size. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index 7e8cdbbc3a..c1ff8bb5f0 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -514,6 +514,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } } + s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; + out: qemu_co_mutex_unlock(&s->lock); return ret; From patchwork Thu Aug 25 14:31:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12954956 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 8FB8BC28D13 for ; Thu, 25 Aug 2022 14:49:07 +0000 (UTC) Received: from localhost ([::1]:36106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oREAM-0006XP-Lr for qemu-devel@archiver.kernel.org; Thu, 25 Aug 2022 10:49:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRDtd-0000p4-I4; Thu, 25 Aug 2022 10:31:49 -0400 Received: from mail-vi1eur05on2096.outbound.protection.outlook.com ([40.107.21.96]:43230 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRDtb-0004oG-TZ; Thu, 25 Aug 2022 10:31:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a/duL0OMHcspmVXK0lKQbmtdeYg7nDQIYNt+k+S3/bvc+47JvwG3cX6h6xIIgZ1gXpE8fzpvZGzwlnnwZCJNAGFm+tamlBml0nGXCGX3q4FVyCXOeoXkjU4XByhVtl+A1YWVEXVFCYdh/2x84uQCZMeVFla0wXoZjl9lXPFYajfJMqsa+OS5VUcOEMITu4BQ/GpLyz+aLXqQGHomRkCneMqYjOyUUHuMz/7JSvcu36uMLXkPzh6vuYxi8O8cRjviIVMJs19ln5rods/kNDyAPhwnwgZp/R5s7EHPqoYqb2gT9jE1ORLvqBXmwBFxJh08OcmW8K+7NyfVJhIOgKitsQ== 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=C/w8TkRCrIOArPPvjz5ambAyfqUEJor64AjcnOtRf7E=; b=UdK/mgc8TEyS0AoivR13k0s5P2HwcUPz1olfeXAtCc5U2viV9nYit/a0A6V5en6bW6O4cM22y4bfTZq9+tj+HS+Dy8AhN1SrgpBZvzaJJrV7AQOTmjXOGK+L+5QN0Iro5WGBwrdmjmf4UyxTEIjLdYBkUCwL47KTQPNRr5CM80Ms5BEnCSmJWyymPX7g1tGQanNOU2BbY+TlbZkPzX8vJRST3+EbhRlmaNg8d7cEwW5Q0tK/KQW0wx+SHDBTiVps+dMQ+aLBdvgGv3Xz1165tb+ahPuiGDHxwM0Jd3HQZAB05K6sf89q+KCJspHbYQWf01hvdbY0Fe6t69xL8LZ20A== 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=C/w8TkRCrIOArPPvjz5ambAyfqUEJor64AjcnOtRf7E=; b=AYoDSD3n4x9ZBwSQ0Z+OapFAGuDQ/x1Zp8OW4ff3aKLDCLLF4S4Tej5HDICUhLoab8nxaH8BVVrqPI1pcAE+1zo6RNhsfmFVwQ9XCObp2TUuKzkUTxqu2l2YtK75H865kEgfCXH2J3vAvVZiJU9qVDK7yRPz8nPIRnNQbagrEVlBcJvM0mDnS2AnDFf3OkWScv9UZNzFdbMp2WHKRYRkk5rHNRZUXodQOcx2E2BELKcQAUTbBOWOxT3weAkxtZlYbPrTn3MplhwWD6XCKjH35UJ+gJp0Og5Xrhh26s0ulsHWUk9PZyR8jI2LuYp28SqQ40TZdg/yRo799gqElBRiUA== 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 HE1PR0802MB2298.eurprd08.prod.outlook.com (2603:10a6:3:c4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Thu, 25 Aug 2022 14:31:20 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.015; Thu, 25 Aug 2022 14:31:20 +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 v6 04/10] parallels: create parallels_set_bat_entry_helper() to assign BAT value Date: Thu, 25 Aug 2022 16:31:03 +0200 Message-Id: <20220825143109.176582-5-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: AS9PR05CA0046.eurprd05.prod.outlook.com (2603:10a6:20b:489::29) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9cc14f99-acaf-4165-1038-08da86a67a31 X-MS-TrafficTypeDiagnostic: HE1PR0802MB2298:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dfR5QmK7LZCtjkiAp02ST+TZpBWSNdhPkYsRSs5NXkTxyKVHevl5NcrirMUt2ySecL3n8+joLbUBwHY9OysTtrG31Vh9HOFyMQHS2jwNPbrGPqad8ie/p9JyROqMc5xomaEFn7TxE/mmtgmFDZDCfs65Dd5rfON2j7SqIZlUXPUtoa0PJYqs8B/9z4JNoIu2c62z/bufeBcWZI+5FetRReHZqXjRIkkSGxzsE3J83kCbMkUZSQ5eNK13B3rJkzf3IZsm5AeZRbwMsPd3LtzVPdJzfz5hlIBf4nqydk2zVxB47cDGYzDQWwxkEeuPmpB/+3lUinM6+8d1wtIoV3NaAL6BjqpH04jdDclDKpJ89Itti0uXn2XesGzydN9n5LhIXNYX4LTXrf1BvP4h3q1/3AjnsT2rzoXPa7n9enfMN+v/De08vvSn0hjhGumyF/l9Hfpw1T1IJO9Aci6udGYU58sMA3XNIdvecS+Is3WUMFA7h0fM6MMkhoVPuIaLxVqcDqvhsEW6qPshn9Opep+ZrkZnmdnRyD28p29M0ZmGWErCC60OeX/RofbW7TZU43C+31SOmIsiahbK0ImY3Wrw95JX41YVk266xolLK6fMJ5QL6YOjLPnhV8AZwrJDhLw8Woko50xP4o7//sQl+aszcaSl0dUjQ/KE7Ds1mFetJgHfB+3i8xfW/Yb6sTOjrGd8ekzOWlkGVMbRvb5w8KPzddqpal5MteLQOce+zBD7VXwVbpSr53aR0/8cBVkXjgEJ8FKp+rn8KIOq65ZQy/tvCg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39850400004)(376002)(366004)(396003)(136003)(346002)(36756003)(83380400001)(186003)(1076003)(2616005)(6506007)(6512007)(5660300002)(52116002)(2906002)(26005)(44832011)(478600001)(38100700002)(38350700002)(8676002)(6916009)(316002)(66946007)(4326008)(86362001)(66556008)(6666004)(66476007)(8936002)(6486002)(41300700001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aU4D1MZwRmKV+LCVCddk4UTXIoG+dy/XxbGaCccacAv5cGjMvO6AaWphfb4fTIt6WqrnbzmvDHWowZ8vLIbRtajzvJY2vdnuI4MI7uYTscf2E57HZrJBrjq2wsLJkYHqi/H06WrTfZAZQD1QSqyfMKeSlcqPRP7A4fHFSZvMRkLs3sY97tIM7D7ACv1ITktdI2ItkwVV0CeQBOHcORNmOiaI4H/JtGo6P21gsbqisnDSZTa4GDrU+HwiE6AqdaPFz4W0HgvjmSuoFLr02ev15WaCzR0urN/GIceiDiFoeLXtM6fqcD+mGwjsba1wVF9VDJwHuQD0f+12Hd6d81GHIMt8bGOL5dp5mQn9VRedYFdMG34/luYwj80/cWlS3lu0dkPElWX4tabqMl4AdQjWlRfWnrx+R+QqRXyX+vZSfqZk2okGHj6XHn+nyxol+DJnBkoAPlB8wWK/yZ7vMCGhYUlcE67mepCPBUWuGNS19SgpPiV3TS91IY8fyyUQxNTb7gReesHkvE94QmzaNaXjzv4GjipzhdtlvR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ComQ= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9cc14f99-acaf-4165-1038-08da86a67a31 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2022 14:31:20.0169 (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: eFSjQsH54WWsfvNfs3hJoxV6Q/EBS8HDsJEUiQYsQbWM3KPLe6ZP2bOl5WF5hozp3nIZCmXA+YVK/PhImUUlFLsYB9WWNm571ZNADFEKThg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2298 Received-SPF: pass client-ip=40.107.21.96; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This helper will be reused in next patches during parallels_co_check rework to simplify its code. Signed-off-by: Alexander Ivanov 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 c1ff8bb5f0..52a5cce46c 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -165,6 +165,13 @@ static int64_t block_status(BDRVParallelsState *s, int64_t sector_num, return start_off; } +static void parallels_set_bat_entry(BDRVParallelsState *s, + uint32_t index, uint32_t offset) +{ + s->bat_bitmap[index] = cpu_to_le32(offset); + bitmap_set(s->bat_dirty_bmap, bat_entry_off(index) / s->bat_dirty_block, 1); +} + static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { @@ -250,10 +257,8 @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, } for (i = 0; i < to_allocate; i++) { - s->bat_bitmap[idx + i] = cpu_to_le32(s->data_end / s->off_multiplier); + parallels_set_bat_entry(s, idx + i, s->data_end / s->off_multiplier); s->data_end += s->tracks; - bitmap_set(s->bat_dirty_bmap, - bat_entry_off(idx + i) / s->bat_dirty_block, 1); } return bat2sect(s, idx) + sector_num % s->tracks; From patchwork Thu Aug 25 14:31:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12954946 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 CBB79C28D13 for ; Thu, 25 Aug 2022 14:45:08 +0000 (UTC) Received: from localhost ([::1]:59606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRE6V-0001ih-MA for qemu-devel@archiver.kernel.org; Thu, 25 Aug 2022 10:45:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRDtU-0000ZG-S7; Thu, 25 Aug 2022 10:31:40 -0400 Received: from mail-eopbgr130132.outbound.protection.outlook.com ([40.107.13.132]:23550 helo=EUR01-HE1-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 1oRDtT-0004pj-18; Thu, 25 Aug 2022 10:31:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c/CsZMo5Dv2YaObVJhdU9qRbJOCJ+5oaZZm3hFvTfdi503MZg/DFQeFNNAF8H+L1N39I4Xzyrel1dIQJ6zcZhcuHiZG3sq2Z+Aniy5E3nz/sAQ2pKXbeQN3m+MLt96yweKtyPPhUyO4sz5nA2Q8X6w7ZE+h5dnXSvqIIAh7cBTyOC+5vL4rEsmaKeCyKY++A1480C4ePCeGeJ9CxJb62mIaHZIFXkuhCq4mj7q6Z7IJDQ+KlwxuqtIq5bmp0bM1P9wM6CmOkQZfDrfxEsFpkLk+JYBlMfNap10PTehfLiPHlnpwjGDZgsIa7NmAp6NwK26yJNStMXbowIeuSS3B4Kg== 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=j2iHD9ZuqkW49ytEgmewpRVI1oNPJycke20yFKQs7Oc=; b=FlqXpOcim7+TAkDU6LTrXr4OUvA7nVbnaHRg3jhCoHF1HlNknDrPeaq6PJQIRT6QgjqJFYRMlPBI+eS8exzVFNMZML4kJDbhg6qBjc4wJz/yHEVYMlp2YDXb0BYg34Ad/eclB4mCdI0/Q1yrpiMK6OhrMAGy2pttad+H2bfjcVBNA+xwjHInF8hByrUkUhvqlt1PcoO/af7bs/KgFV1mZ6ezapdi1sb2+PZ/kXOKqqb613NOa+f4NcpC9T9zcm7M5agpiA5VR1fbTsIhBWIdP+OyuciMuDVvOUnsKL/hRgon2PpbGmPThAnER09ug8rfVQl32kLTyviL1Nx/6V5BzQ== 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=j2iHD9ZuqkW49ytEgmewpRVI1oNPJycke20yFKQs7Oc=; b=ogKl7WFyb9Gg85FhKTFFA/4d/2A359OKW+QpTPJNbvQrOILSgQGN2sLkzBjWijnJpaTJm2iylNPE60hDZU0TLIi8sXdZBXeImAwdvbbLYcDQ833I1u+YHp5MajJliyZTIJP9QafwMgsBUBlaRX72YO6tVimIAXZevuYCVtjtybmfTl7cfKJTcBvQ0EJZl4eXmZVLHno6RPCKGorz8aILKZTJjHFiGW27Csn+ANJMvitKP5YkQP9uRMQ4WO/pDJhwS/K8dz3qLfB6+cIQxdpghtdy41l88YDo/awNCxENN6qAT/9VTY8TMO21CQqaf2qN3NrXOCZpsct5ofYiMry7vA== 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 AM0PR08MB3569.eurprd08.prod.outlook.com (2603:10a6:208:dc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.14; Thu, 25 Aug 2022 14:31:21 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.015; Thu, 25 Aug 2022 14:31:20 +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 v6 05/10] parallels: Use generic infrastructure for BAT writing in parallels_co_check() Date: Thu, 25 Aug 2022 16:31:04 +0200 Message-Id: <20220825143109.176582-6-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: AS9PR05CA0046.eurprd05.prod.outlook.com (2603:10a6:20b:489::29) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c5ae2c29-a53d-4d98-749a-08da86a67aa3 X-MS-TrafficTypeDiagnostic: AM0PR08MB3569:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5ugIHSu04K0fobGdHqcbFNU05niwdCa0veLYuV/tWbYiTiD5oeHszl5CF+toB/SjP4ZpvYVrUWkvxuSz4ZlS8cHNrygs+N9jK+5qHBFl3cOs2tLQLo10wCGV6kbSJAzKqhiegT/vLvlTMM55BErztlu4j+OsqPKj3EmOA/MKr6U3zYq/Z6AvHeTtmLxlQMMZayLo8+a11uNqYTDjNlHgRKiqFCmXJ/K5cQDmhnCZ+r4uQtG33JmfR2JSTnBJpEv6jlDBz4PPGCgHr78vWgsEeXbgxq5MZMSwlnD5ml79KoNMjGY1gC8kB/BYx8trSjgRxTykrPRXFDUc91mrteg9/XudBx/ZUUfZXm172341oHizPjGuFpX+oBrGvqCIEW/pD4JcWibcnUdSk/Mrd048FHp65Ocu9OY1LSUxiiS0w59E7BFYVvztyuB+Ls7aQ/dOhvKlb1r48zxj3d6S7XeozUMbi7Gny1OcEUw6KnmOr6Zt4DLBmYF8te3zX0Q0bstzfx5BmUhm2xxZQMQUMUjdMvWC1RQ6TN/zKGE290YR8EiRzFW0I/bZgoqzkd2beR4sQmfwtwaAtWc93GIlXyHlZg8XefA2mQyXgkfOqMXXC+22dq7bJIMi4wP6EwOXy82hCezJWq8CE14eArQfCQft1sVJfYZsJqRIpJu4r317hDPRIr7bFfeXsTV6mU5kiUcI6k+oh8/A2jo0bMPA66osIR5APCtUpJ9v+sIoYJUg2U+mHv4B1WjacBGnqzKDBV6pLup1FZKqjFKAjiG1hP8xnr0NPgG3pOuRn3K6OQFecG0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(366004)(346002)(376002)(39850400004)(396003)(186003)(2616005)(1076003)(38350700002)(86362001)(66946007)(83380400001)(66556008)(66476007)(8676002)(316002)(5660300002)(8936002)(2906002)(44832011)(6512007)(478600001)(6506007)(6666004)(52116002)(41300700001)(38100700002)(4326008)(6486002)(6916009)(36756003)(26005)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hL/YTVEUJiY1hb4sErUvqLMxoYtJixe6erbeEVseVzAbfgGOU9qiJ3rcoVgVk/w+X5xOzUr3Wms/4PtR1qMCrUVQsUrGG3ZXNLprr28ZKSmHqg5lV4pQ3uvUOrDox0m0Lvw8fit0CTa/ySgxBt325F8HgM2SqQdr1EBo0umhU+IyIbUcr0PAy9dOhpmXu21GAewjpLrJbzDv+CyggdbobSNqS8+T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tay0Ewgq+/Rpvx6tnxtQIZJuWe64EQjchUCoU5MBfJiP+lzLCQcrxLfX606LtqnPy56y7tTiiFumtaaHPonp7fQtF/NSixb3yODWCnUfEpko1d/+/FbYsxlKoZpbZzXHSzlniElxo7ASd6DKjTtlVhEaMAy/2FSOPFUssVRj+yVJDxNPJDVJwSV4YbSrRUzgCsPzLPfj3fPeL3XPRpBO+XiA/7kbdiiG4wpakLaiIykFNBOaW+T43X7mfoWJwosxIJqdfsjhxti6j+7ogsXVcmX3KmLeRfn4ZMtNEsJPUW2M3iboi4U3Vzm8C1gKOjXL5YejcmmJl0iydWqQ08nFw= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c5ae2c29-a53d-4d98-749a-08da86a67aa3 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2022 14:31:20.7665 (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: T2A+1czN25JwyWklRXS8b6LZOxdaY7l1xhH+baEGTQNuY9WnJ8R/eWwtuvuj0AjkshkBn92bHpIKS+dQuAxGaoIeOWyG78syQ22zzqxbiik= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3569 Received-SPF: pass client-ip=40.107.13.132; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" BAT is written in the context of conventional operations over the image inside bdrv_co_flush() when it calls parallels_co_flush_to_os() callback. Thus we should not modify BAT array directly, but call parallels_set_bat_entry() helper and bdrv_co_flush() further on. After that there is no need to manually write BAT and track its modification. This makes code more generic and allows to split parallels_set_bat_entry() for independent pieces. Signed-off-by: Alexander Ivanov 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 52a5cce46c..b4a85b8aa7 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -425,9 +425,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, { BDRVParallelsState *s = bs->opaque; int64_t size, prev_off, high_off; - int ret; + int ret = 0; uint32_t i; - bool flush_bat = false; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -465,9 +464,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++; if (fix & BDRV_FIX_ERRORS) { - s->bat_bitmap[i] = 0; + parallels_set_bat_entry(s, i, 0); res->corruptions_fixed++; - flush_bat = true; } prev_off = 0; continue; @@ -484,15 +482,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, prev_off = off; } - ret = 0; - if (flush_bat) { - ret = bdrv_co_pwrite_sync(bs->file, 0, s->header_size, s->header, 0); - if (ret < 0) { - res->check_errors++; - goto out; - } - } - res->image_end_offset = high_off + s->cluster_size; if (size > res->image_end_offset) { int64_t count; @@ -523,6 +512,14 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, out: qemu_co_mutex_unlock(&s->lock); + + if (ret == 0) { + ret = bdrv_co_flush(bs); + if (ret < 0) { + res->check_errors++; + } + } + return ret; } From patchwork Thu Aug 25 14:31:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12954807 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 6F5CDC28D13 for ; Thu, 25 Aug 2022 14:36:18 +0000 (UTC) Received: from localhost ([::1]:39862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRDxt-0003eL-SZ for qemu-devel@archiver.kernel.org; Thu, 25 Aug 2022 10:36:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRDtP-0000Wh-Gl; Thu, 25 Aug 2022 10:31:39 -0400 Received: from mail-eopbgr70097.outbound.protection.outlook.com ([40.107.7.97]:64553 helo=EUR04-HE1-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 1oRDtL-0004oN-MJ; Thu, 25 Aug 2022 10:31:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j6EdXQFX1pzzo/2/UQBDNYC9crsLvv1LDVRjAAB5z9+rabb5FrEyJuTCT7K48hgAAg30NAPXrXXUdp89F1qeL/Qbu0sGRLjeglCHpzFjk2rIemUSQa2nUqAxXsgLvKXfYdO+mPcQmjN17C1iA5/KOlihzVZpapZo0pD8mzG1vXV/0v0fcXjHw9JoU0CVctH8Mego8HtkQHld6v2Rcdk/qiO/7oWF8X30rxDyZWUj3GldE6LhRaM2e+XYsuFOJkpCGjVONipFhtKQtqD1L6tlS69k2Wq4y9njbJ7SfRoitLMde62zxjF6VMkst8fSKkowGS6htVxBoiHeVKGfzjHTUg== 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=tHAtEScGJd+8SaeeRRtxf4JjrblIDlJicxwATC0GIGY=; b=CmnBHl5ysaxyIP8zjaJnAnPvekQl0vk6E2UlsBeQoBMQYqnsS66okV2CWGyKjpHOGmZbTJIUvlH7Z1lfFNtvfrm0K8wCOek5VfwI73eBnLeL8PM4bpz26ty4aa4kTv8+GCzIm+9B9omMTXCLaSonIqp1OLrWCcE6t7SRftAO5aeCYdh/uDhJejHXAg6Z+osJU12lXDOQkk++Qasc37yJs/hDTk6SP+wK5H0lYP2ZaAngGT9YG8prso0s1YalghwF+cPsJjmG5taKzf4aclsUjZBUPczcvT4ce/8ohdHGhAwHzlU2GLwvDvgz4iHWXBsvkdIoSaS8tZMmHB2Lx4gU7g== 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=tHAtEScGJd+8SaeeRRtxf4JjrblIDlJicxwATC0GIGY=; b=Q0NszIFpIceeYZ4TzaLPZ1mHF0mRjH0vOKkl0CHI2gW/syHH8EobbFx8RJFhGl0YrjyQIj9xYs7RDxCS6kBmIWm4ap7hhuVGS71hIs/cGoGSoqgjxqQ0fsKy77VzIYzvDrEchTGiItuqcIo6n8ohC2/nhHJoMADhfRX2PMRMTmqPmakOv0JkZvKEVaTgACQHHRLKV/M8KnpCjoh5AxU8sBaDXXJjnA9M8BD07RWexVJo9zL1ulofVvB8W8QxVHVOrm7i9zB/xToAOJREfGgrE/QxPrzKY6CndJH3ct23Ozh7NS6nZhF5ASqs7B4Jfs5kJvEztSzhLseTwfBBMwSilw== 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 AM0PR08MB3569.eurprd08.prod.outlook.com (2603:10a6:208:dc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.14; Thu, 25 Aug 2022 14:31:21 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.015; Thu, 25 Aug 2022 14:31:21 +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 v6 06/10] parallels: Move check of unclean image to a separate function Date: Thu, 25 Aug 2022 16:31:05 +0200 Message-Id: <20220825143109.176582-7-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: AS9PR05CA0046.eurprd05.prod.outlook.com (2603:10a6:20b:489::29) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eb2e8dc2-318f-4e71-77c7-08da86a67b18 X-MS-TrafficTypeDiagnostic: AM0PR08MB3569:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5yYAciNxrCVDn/DHCnHY6am1KvezQ1HIw1eYspJ8DgJAXTMtVa+DKojg5inPBHXQ6D1biiO1O2nuMrcE2xvVdBn+MJ2nPLHg6swsjW+OBs/FBiWaEof4tnJ4IQe8BAzi8/o5tMEA52jZKGmTxlP6dopCeOg4r+gEbHCaJiqLfDJHHiIyVzq7LyX0VsSDV7FjRe6iTOZSu5/HYcxwpRZ/cokrhJrd/lattdDiSy8dHrOWW7FyFNPc1NCm8zQ06mZIqGHmmqaPKtM3fvPuYJeJMbjr6rujJdHLRX8IRm9VHhz99QtrVHZP7Rng1ng4kAHjeYisv7akjnUMay7xQ+HK7yA/jYMPpPoE2lus5LdXs6J0VWvjhVx2x0aneRr/toNXxYDJKlrt6dd65ZhM1R8j403m+aaiT7YKm58xh2i6GPSueFrxm9LbQzUYSItWIPdOLps9PaJ5nUdUmSKHZme4wlCM6DDq/Fraa0OUU95F/7366lIxg7yCWxoqPu78jC67N02/K3MCpD0qOxEYS0cGqsbPfQywgUBXZL8O4QG/uEZNEzIdkf0O4MByl5FExzp3penmW7JVK61FiD6e0afGT7wmlP2CSh9P8Zn7O66qFzToAqhkh1TGIpG5gZ1neBIg95FeGrgyCU80en2qMIXrwL61NmnBglBEt+/YXMshP67aKYyowx8vcd4pQUR03IzLnYNf5Yi3TXXbKETMYNZzqkANKmBGk3fSjHvxKgR3tH4eukd52ml4pxvaQN+SBdIEPqyhU3rcvadCUKTHmvN69g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(366004)(346002)(376002)(39850400004)(396003)(186003)(2616005)(1076003)(38350700002)(86362001)(66946007)(83380400001)(66556008)(66476007)(8676002)(316002)(5660300002)(8936002)(2906002)(44832011)(6512007)(478600001)(6506007)(6666004)(52116002)(41300700001)(38100700002)(4326008)(6486002)(6916009)(36756003)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aVJl9c51VAo2gvDOHrtTlbRV0+LPEhh4HSQaq6wp/w7eLSxHzCBAw3miHedOtmc1Rw1WJZwmtmlLHeuARjPuvp3u9fWNHhZFNmVdrbx9JL18mK7nY7dHNXgKp5TfOS/A9LevGdzvcYJrbQmiGPSvEcyFl9z0AjccFu+J53sqy54uM0TSmChZMXJ0NbHHWWRSAT3YgehEMUabR69pMPM6nLYBGlKKzCH1UMxN6nlxSBAMpKK3uwlQJ5ce/SnlqRkRxl/WYH79yskWhjtUurkSPACCcg8yJcUF3IF01t+5g5rjVEMmSwYahyby7RzB+ihdNCM6hRFYqz29MjmyU6/EWWSrfskat7B9IJpfZ8Oi09FYwZBAl19QldKqzp8ar/Vik5MbbyggDi+pniSdKfwD4IJ7Um3eF8IiGpkfO/b+DsCoYbtU+LNkBKmACkVqR+zJZFVTdP5y3QCcy4g3Ui7T5h8C3VpjLD6myCkPJwaryMC+y6BfdeqH/XwYRIWukwJfM0k/am9Ab09mBlZE2UHTV0z/fl/HmaElizSDaWgwL7JnbZyHNqlNGP2hyUcHsHYceI9nZ5TrQ90wfBJjy7zAtdAMkPS2TBrPe1nXAdcCAAw2amxmJUEtVF6Em1bWUVV+Ck3Z/A+hEKQmSDYwT0JbZv5bweMRT1MmqwIZs8pp+nTrhtEUtH4eXRNpatrjBLRRzw4FpDTYFXtHTFbmGTuXPJ4ZMagH6okt9uCFJUOhvB3F7rfSkXT/r5yie/yrf45ShMJY5p6FUIg8o+jEY0kTPQwJ1og3M14NafAEAYo01SJk4XWa9FI9ctTHUIw+bjoSj6mBOmhkpra85d/N//DkINqQ4UT8A1mhYwsc6aKgwSie5ZU81cJOQI4wqqJPbaRRuJ16EEMQ3FLPMuQEaBweKYSHR/BEc8u8kiVjNbKZPsk8bsXMpDJkR4EaaQN0h4fiB2Yl739bd0YnQJVXJ6Bo52k82WIs4B3zQGTOlDJvqrsknbMU5liCnh8NLdPPKMOdDothBzvVuFLuKna45DYFB8h5b6WwrrjHBLW/xOrc6rxL5LC9ceRUi9BhY6vXYtBE3Bhmd409eORebTo6nkG1yG3OwFHpLphlAIv0n9jm9JfvJck6FZSTWi+wD6HAigFJlv7OxHyk4ZvTJyvE7uthjCdIPs1hX/VjBARz25YVvylhaN6xO1eOdNG/OXPIp261ic1weBODgrn1IE+G0QsywXOYt51oWzZ36S2WT6GxyMS/B2DbTKOGLsNTdXOj4EsRipWbNUhWGdTbB1Kp/dNjC7OdSe9r4QzrQvc1LGkhlsirx5lD1biMbOa7CqIeUijuxsoVgU+2qxqCwY95NV0SktLfB28D9m3RXaThzPiszKvQRa+bHOZ60/3mtRAqBQjN89MmPhjxZZN/awMm48qNWsmV5Pes6lZwQts2m1OCxF04Kmkq+LCMSQARS+Le6p+FViMFD3PFfS4I3078kJILDZ8miOdmTHB9PgYvEyYdUVr9vN6Id/bqBLATUVEwf7MCOoAZQqhZc304BXS0ZpIjQ5KlXdM4ICpGuoueKjpxL/4BLspRX1eH6MIsPAUaLPBh4VqRp7VQSs2OQcpcyV+4Owz3rrjDAoHiNLja7jXiy7w= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb2e8dc2-318f-4e71-77c7-08da86a67b18 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2022 14:31:21.5490 (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: JF45LKrGgl8qneQhAhn+ZrqONXAEqJpk/0N5gw4Z8LF06ENLYyWGDEmQdVUD/nBIQ1z2Qs9gXCX/vFFfQJfbZi72Fq9zJnRY4G/ukxdY3EY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3569 Received-SPF: pass client-ip=40.107.7.97; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov 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 b4a85b8aa7..eea318f809 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -418,6 +418,25 @@ static coroutine_fn int parallels_co_readv(BlockDriverState *bs, return ret; } +static void parallels_check_unclean(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + + if (!s->header_unclean) { + return; + } + + fprintf(stderr, "%s image was not closed correctly\n", + fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR"); + res->corruptions++; + if (fix & BDRV_FIX_ERRORS) { + /* parallels_close will do the job right */ + res->corruptions_fixed++; + s->header_unclean = false; + } +} static int coroutine_fn parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, @@ -435,16 +454,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } qemu_co_mutex_lock(&s->lock); - if (s->header_unclean) { - fprintf(stderr, "%s image was not closed correctly\n", - fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR"); - res->corruptions++; - if (fix & BDRV_FIX_ERRORS) { - /* parallels_close will do the job right */ - res->corruptions_fixed++; - s->header_unclean = false; - } - } + + parallels_check_unclean(bs, res, fix); res->bfi.total_clusters = s->bat_size; res->bfi.compressed_clusters = 0; /* compression is not supported */ From patchwork Thu Aug 25 14:31:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12954943 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 31F94C64990 for ; Thu, 25 Aug 2022 14:41:52 +0000 (UTC) Received: from localhost ([::1]:33504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRE3K-0003MG-PQ for qemu-devel@archiver.kernel.org; Thu, 25 Aug 2022 10:41:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRDtT-0000Wn-1J; Thu, 25 Aug 2022 10:31:39 -0400 Received: from mail-eopbgr70097.outbound.protection.outlook.com ([40.107.7.97]:64553 helo=EUR04-HE1-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 1oRDtQ-0004oN-G5; Thu, 25 Aug 2022 10:31:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fEP3d+c7k7MzWa4mBA/W7x1PpSx/T2bo8AYtytg0FTMKaPIsyQDlkg9xQ4Xmdl+ij5RLoKNoW3DNqbCNMCQnpvLaGwsetxuXwulbdLB/mgtStuqQ18H+I86gc7AXf8CAqeoBv9UqTGY3Hdt+zT6ZBdYsMJcv+eSNc+kAh8vMY4HrPuYjGXAFuRrYMC+H7PpVzcmmq5CnNXF4Bi1kG6Y0vXwGlogiIljPKTt5XSWEYZ0zdWLARawa4FU4+1L3z5GNcH1NgEX32ES0Awukyc6+5+W+940mv6lf332rUE22fcP2f3XRCc/yHTsulbkySb6hUx59NwLYIBRQKi7bxjOo9A== 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=n0euhobaKcgaPVcllTXGZlFSG4HlsGZ7oXKT8kDjHa4=; b=e5cs1QWH6eVTxxHaQDIYgVFSkAtPCAud3J6576lmlzATURiKR904q4R3cqRPI6ZjE2A0TsIO0OUVlE0kuO+H5+kUPndyytAcINfYG1Z1FDgb4ekaSHImiNtk9e75YFGEpBQUnzFkSBciU93Ak99Ag1/9lhMugr7ZkOKq9zYd0ASOXrCRtyQy/QqLvGwb1FchR4wCm3D9nbKrRPna1BC1Wh4wOacDL6iG4b5Sf5stYGhqVqqNtGpfmvM0z8ocmjaQjuNHKqebdmJKHLEUXSfYopaIsTqU/20NnaTvWnsIJiMhDnhuWntBsY2ZqdUsjDEobPilVV0KD4eZ+CEpeZmXVQ== 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=n0euhobaKcgaPVcllTXGZlFSG4HlsGZ7oXKT8kDjHa4=; b=gHvss+U9/XP6pX6q+fOShJMx6agglcj4H0fF/k0mN95qLyzzGNiBpN2jW1VooD335GIWTqMgy7r+X1npjwRvXA2VQAEbPUZp1FZ52tQA2ZdBQhA0wNvmQtd5KargGxCUYKaoypz9CKXVmeFeMF1ZfO3Vzd0xqk5cBAK5EB90qTl81U79cvxPIvnV4Nnt2wUba3rlT+fjW3Jj5T+0zlS+mRC5/dChzqjwB2V6hLkniqTyw56i3R/JipoVGap7GYirZYAD17uaJxinxVhlRRI3gaVDNi6JjdG+tEE1sFZhDqTg0xnnllaYKshAgUs1AVTmd7p+0Xwzxai58x9dh/dPgA== 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 AM0PR08MB3569.eurprd08.prod.outlook.com (2603:10a6:208:dc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.14; Thu, 25 Aug 2022 14:31:22 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.015; Thu, 25 Aug 2022 14:31:22 +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 v6 07/10] parallels: Move check of cluster outside image to a separate function Date: Thu, 25 Aug 2022 16:31:06 +0200 Message-Id: <20220825143109.176582-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: AS9PR05CA0046.eurprd05.prod.outlook.com (2603:10a6:20b:489::29) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f28a8eaa-92a6-4fcf-e069-08da86a67ba9 X-MS-TrafficTypeDiagnostic: AM0PR08MB3569:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XP10KJIWw1VfmsCGximMBr34D6pPV5u4dGbxbH/1ytdCnT4Y4kPhmQvN6xAnkVRrTjYNLF2BGt1ZgiGV9oJNcBPvs6qcJybtyosIEb45Him64uHh7ATloz0bQTgROfPclUjSoITsyc7f3mZcaaTZj2H8nemtsZpSDryP+2V8np3JBTzVF3mEoKcvGO043bxo38PiAH9ybRTJhbc6u/EShm4kCgbpQU8UFAS2qA8sxuk1lcg9NeGfNcxJ5ALKyKodCV47VS964U0vlSl00TdDOz7chily7yWgNXQ3cRjko3z/Bbps/HdiqSHpbYfaEzPYtgAai5RFd7+Yh0pg/+xmrpHrhGXEt55p+1xhGWC9RU+O5DMfwBMUlLfKO4ugKG+BJx9qlbAoQ/XwWjRx6keZGHdQnACdy9css0A/4/1Odk8hVKgca+z9fIiBdAGbEboRCZHFa92J7z6rByvNmqRA/4gQPaddp16bXMIRzWTM3hs3z6cWlv/mIhTdHH+6ywJxIdnt71tBr5Q1P4iNfcLqQ5cebTPQZFRSFA5xFPcF+tNyy654H3giFPNIVU9+deeshJwFs7dsrVIDWIR78d6QZ8/UDTlSXlRw/gCluADtIRIAQiuw0hKBQMVRyyIXgB7tUkbWvjBGHQ4sFo+2Q4Ww5mcXTnQ2CyS8KveDhWlQb8LGDJZE4fM6tW+k0BohXD3GV9KG3iTa9KBJ+LhQCBHMhiRDzDgQuZG7AjPfOSDaMe7t1vuqvL0kYGJlLBvRsEEo+xfaX5yqFUkECZWRuEp/PQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(366004)(346002)(376002)(39850400004)(396003)(186003)(2616005)(1076003)(38350700002)(86362001)(66946007)(83380400001)(66556008)(66476007)(8676002)(316002)(5660300002)(8936002)(2906002)(44832011)(6512007)(478600001)(6506007)(6666004)(52116002)(41300700001)(38100700002)(4326008)(6486002)(6916009)(36756003)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iRAprenRgQLYzVJxWqT3aqMmu+h7Ys5CEEwpHcAh0WBDtu75h1vQYQ4jnTxG8pinrsBj4Nz61T/T9UhZDvg/y7rdihQ3+TLqHly3W6hVAqUN0zAfY8lDlm/Srq4mBdk9yAKsDt5z14edPr2jBGE206i/MnyMZYRY8s0iFoE1ogYMBa/z98o6QxhR6Gdgr9g76B4nzHntPyqwfeJoN8IqcCkKERHsQ7cFSzSzRtciHWC7Cr8cK+/AUlF8+Cuj2f5vp3x85nd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Ji+DcDpCJqVZxLY2tMJzAOxU4Uuyvw4/CkCred+ZDj2WD+QiRmym/esZM7lglGfS8YIwJCrYwkXuGa3Z5pa41cvdNvdxmGv/5fP6vT9Eh28WroZoUgTUd3De0UwdmhcYBbirt8dsv+DYrriVdZ2jPueIh23IAb1aUxpQzc7ada7rWfw8fUBqjTGTJBbIvGGJFsvhhcZDOaw5wwLjJ5kJ+jfgl0ZDCjK2+tpFBiYhGq8z0A41tBveUaERbw6M9YPRfhA/a2yQzwqspqu66A+oi0qwZ/USx/owscqekWMQR0aaI= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f28a8eaa-92a6-4fcf-e069-08da86a67ba9 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2022 14:31:22.4863 (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: CU3gW0TE1jRukbSlxs3W5jHoc/K+C9E6c+92gKrskEc8IGLtMU6QbZLrVwISAsPzScEGEpSh6rR3KylDFFL40clgXV+v0se1bTsZfi/wb9I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3569 Received-SPF: pass client-ip=40.107.7.97; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 59 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index eea318f809..f50cd232aa 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -438,13 +438,50 @@ static void parallels_check_unclean(BlockDriverState *bs, } } +static int parallels_check_outside_image(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + uint32_t i; + int64_t off, high_off, size; + + size = bdrv_getlength(bs->file->bs); + if (size < 0) { + res->check_errors++; + return size; + } + + high_off = 0; + for (i = 0; i < s->bat_size; i++) { + off = bat2sect(s, i) << BDRV_SECTOR_BITS; + if (off > size) { + fprintf(stderr, "%s cluster %u is outside image\n", + fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); + res->corruptions++; + if (fix & BDRV_FIX_ERRORS) { + parallels_set_bat_entry(s, i, 0); + res->corruptions_fixed++; + } + continue; + } + if (high_off < off) { + high_off = off; + } + } + + s->data_end = (high_off + s->cluster_size) >> BDRV_SECTOR_BITS; + + return 0; +} + static int coroutine_fn parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; int64_t size, prev_off, high_off; - int ret = 0; + int ret; uint32_t i; size = bdrv_getlength(bs->file->bs); @@ -457,6 +494,11 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, parallels_check_unclean(bs, res, fix); + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + res->bfi.total_clusters = s->bat_size; res->bfi.compressed_clusters = 0; /* compression is not supported */ @@ -469,19 +511,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, continue; } - /* cluster outside the image */ - if (off > size) { - fprintf(stderr, "%s cluster %u is outside image\n", - fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); - res->corruptions++; - if (fix & BDRV_FIX_ERRORS) { - parallels_set_bat_entry(s, i, 0); - res->corruptions_fixed++; - } - prev_off = 0; - continue; - } - res->bfi.allocated_clusters++; if (off > high_off) { high_off = off; @@ -519,8 +548,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, } } - s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; - out: qemu_co_mutex_unlock(&s->lock); From patchwork Thu Aug 25 14:31:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12954944 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 54885C64990 for ; Thu, 25 Aug 2022 14:43:55 +0000 (UTC) Received: from localhost ([::1]:48656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRE5K-0007QA-9e for qemu-devel@archiver.kernel.org; Thu, 25 Aug 2022 10:43:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRDtW-0000dv-9c; Thu, 25 Aug 2022 10:31:42 -0400 Received: from mail-eopbgr70097.outbound.protection.outlook.com ([40.107.7.97]:64553 helo=EUR04-HE1-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 1oRDtT-0004oN-NY; Thu, 25 Aug 2022 10:31:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bD8DgZVP/8VAQ4CmKXaz4t4AcV7lm52xh4nVCKejD3d9cUcCD/LVPrQH5jn5t9xYxRZbIU7UeY9bxVCk5sDTBGmcgnY+tukp1qTHEoLifJL2Yce3w/GRPI0RZGIWaPy7rlDWTXzAZMZd9YhXQiNd+YiDZWhUl5AYZwXev6jVN5+fih4ZelZjo2CFnxs5BEaFEpcdu7/9Qf6tRHnbKwLvQe/V1/dUUPWIfCqi+TDR1zf1OnE9Z19hxika9TiiR9OFONrS7swec60I0CQvGfiO4ZChaWLoNkFTTjWYUSXw+s7XJF1lkkurqnIAus7kVLLU+bf4kstcTdlGGdzU3tGMZg== 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=1RLosViAbk8qUg9WFjEWcSmxFxVuJbbxPqveCA4kGgY=; b=gf6a+SjsxcrvBEY5Chq/nZP9O7dqXLk+R7seaEgIMNcOmGYmiasVXG8sYz3N6OSCzrjyqWlNd63gJlUWSx0KrwBvJm6gdmmZIFPx0B3dLZJcLkeEHX4wAi96So1TchMJt72ZzSFajACx/dy9Pmn7pM6pPmfMaTlenYQ5B53nvGGL9uzRzBmfTAdSKH3GbRqg5GKkkBdcwZtzDhMvnzYfsAk1CGWpBJq6TPzdM29hPQY3Hnk+pbWqzei+yGc3IEXpfMQMNfNuKJAc01e27446XhXunzQgBUwCE2ugXUI7vmBsPWb2yjvhZgODpsaJ/hJxbgD7W5Px9d+Gm6BqQu50Dg== 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=1RLosViAbk8qUg9WFjEWcSmxFxVuJbbxPqveCA4kGgY=; b=nTq94feWYACMPKT9iq1sLfoAQQ2Qw2iNrNZAkK0fmXRBjgKraJsauLjxrwIRIDjeBcBi7oI+SDFn8wy6mpAeZnEYnxPREOfED6tLJflVQPUJi6dA0GJsE+nwCt+fxCJzov9b3LBZc/I3xYe7uKbomCkIlIPe7hAIPftbawVKeG1+L/WLKRtquxVJHHwRVcJPBLPSXQ27SfEIGxTl8fgGFiqPC2X7pGlBEnBy61t7z8kmSgO4WOlDer8vIPWXRMb9bc9qG7SpJMyEvF3HpmAcObm4Hy8r4uOz3PqsnIO0HnIT/z9wPzmcw8bTqLDIryU8Fmqio99MhdBmvnJiuJjhYw== 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 AM0PR08MB3569.eurprd08.prod.outlook.com (2603:10a6:208:dc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.14; Thu, 25 Aug 2022 14:31:23 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.015; Thu, 25 Aug 2022 14:31:23 +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 v6 08/10] parallels: Move check of leaks to a separate function Date: Thu, 25 Aug 2022 16:31:07 +0200 Message-Id: <20220825143109.176582-9-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: AS9PR05CA0046.eurprd05.prod.outlook.com (2603:10a6:20b:489::29) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 241a1a87-05f0-49a3-a024-08da86a67c36 X-MS-TrafficTypeDiagnostic: AM0PR08MB3569:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lsAt0xEolwig5gqZ9UsFeaQViq2VgzdMnS3RtQtNrDDUDkkAZVxvQbyggLyQXgp4pjzwbL/Vd6TXt0tQ/AbMJEhYxdZSxyiYwmUoQokaiB8YCw5vw/tXqje7IV5pvKLFy6GMNkDeUMKXujf2PuDNrGGm4E0855VWzI7TbXaM3Kk4zu8l1rmaMcxUsvgHlO03/6gzbloY9RnIqH5zOYhs1kFWOlomlx+smw496aSQJTNbT5yHb3BLuZY5argztCJdmyrAb69hWZmWe8K1YeBTkwvfdfNFiPHRq0ufXNWlOKQAdU7aICHB+ACq84QItRCuqHXr+2GJNrxPL71cXH/eCrvnFDpSUyrAmsctM/rJ3QtSW2gTo+8lO6rvoucXthlIs2SlbHRjb/IlAV14zPRJsl8cBtLNUVsaHmZYSyn+LZBMIqTcauq8aPskU949QQ6itT2gMcf//ygNzTuu1BOA7c8gSF5YIUr2f9p7Ul36IsYaSD7IER3RBIDZDbSQPzNFrbjqdeAIL5RTzcTNIhhh19iZtb68A883xAwkRxvZV5i8c4sesCK1/NFCyvp8UpXcN3cd+PohCrWJ/qO1TgnC/fjDTcfoyOFJyopE0NJSmuUpOYzy5xkEIzY/uycXeL4SzhCV0ojFNCX1CTYfk9wkFkb51nS8iZwsBS/xKMZ96uLegjbbkyUZV2z6IvZOZb8nS25BkK7cKwxGM8k32kx1uaTPi73UBIPrG/P9AXFeWPRBQg3wJSPc1axR9KM7ptM02hDVHi6gxjZP/wkzHm7LTw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(366004)(346002)(376002)(39850400004)(396003)(186003)(2616005)(1076003)(38350700002)(86362001)(66946007)(83380400001)(66556008)(66476007)(8676002)(316002)(5660300002)(8936002)(2906002)(44832011)(6512007)(478600001)(6506007)(6666004)(52116002)(41300700001)(38100700002)(4326008)(6486002)(6916009)(36756003)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9BYcu6X5wnYkzcqIqAv/3SQ+Tt+eQDe2sOoZkh/5Q2MV/tXHsWb/XMDUwDA1vUh+VgDImZDXj/J2lR956ZrHgG7VKeAx6Vcsgibg4of3jPy46dE6iYVLbu43hSFqfNEy0KgKUR3H4P6mtfip9Q48rB3u5fsVZpMwglEZn1AfrBRgG3SfdJO5mG6+gyqTwry38MvyD7KTMwSPFNYYUFwALQUJelpbovAgLswh/c0zTh1lNHXtcsS2xZSHzrSN1jshmv1wD/f5HPZLNXtpT2qTL24PihopaKfLPoIlEHaPYu+Y2NrCBsjMlzlTt4LzmHyQc2vLbkevS4CCHHZ3/4EeCrhTpTd9F3khvTCsDz0SqeYqA9eP6pxTnnE/nyabQcWn/iIZmvAi6J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ILk25y+WReuC5iHotCVDY6t1Lwt0ErlIu9SFyHW29mwqpcGtPGoPGfaYf0aVbqCqMiE+k0fO7L+Y5JciRJUjSt9VOh1qQjFmZU4EwyjGJYnxUx1hRzJcxUk36Xlrpvoboj4byU8a6GBgWnxHHVb54Yd/KlQnTM0Mb8n3XTEz9ChRbGvDd3s4C1k= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 241a1a87-05f0-49a3-a024-08da86a67c36 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2022 14:31:23.4400 (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: Glw227lemmX2xd4HYmb5nOjpiKpZ3QY15U0zn0Ov7qmFumt6tkHO86hBdfQO+bXv/N45Pbzdom5xpwYryus5e1TO3CzQx4NOAS0an+RJgdU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3569 Received-SPF: pass client-ip=40.107.7.97; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 84 +++++++++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index f50cd232aa..1874045c51 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -475,14 +475,14 @@ static int parallels_check_outside_image(BlockDriverState *bs, return 0; } -static int coroutine_fn parallels_co_check(BlockDriverState *bs, - BdrvCheckResult *res, - BdrvCheckMode fix) +static int parallels_check_leak(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - int64_t size, prev_off, high_off; - int ret; + int64_t size, off, high_off, count; uint32_t i; + int ret; size = bdrv_getlength(bs->file->bs); if (size < 0) { @@ -490,41 +490,16 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, return size; } - qemu_co_mutex_lock(&s->lock); - - parallels_check_unclean(bs, res, fix); - - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } - - res->bfi.total_clusters = s->bat_size; - res->bfi.compressed_clusters = 0; /* compression is not supported */ - high_off = 0; - prev_off = 0; for (i = 0; i < s->bat_size; i++) { - int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; - if (off == 0) { - prev_off = 0; - continue; - } - - res->bfi.allocated_clusters++; + off = bat2sect(s, i) << BDRV_SECTOR_BITS; if (off > high_off) { high_off = off; } - - if (prev_off != 0 && (prev_off + s->cluster_size) != off) { - res->bfi.fragmented_clusters++; - } - prev_off = off; } res->image_end_offset = high_off + s->cluster_size; if (size > res->image_end_offset) { - int64_t count; count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size); fprintf(stderr, "%s space leaked at the end of the image %" PRId64 "\n", fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR", @@ -542,12 +517,57 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, if (ret < 0) { error_report_err(local_err); res->check_errors++; - goto out; + return ret; } res->leaks_fixed += count; } } + return 0; +} + +static int coroutine_fn parallels_co_check(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + int64_t prev_off; + int ret; + uint32_t i; + + qemu_co_mutex_lock(&s->lock); + + parallels_check_unclean(bs, res, fix); + + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + goto out; + } + + res->bfi.total_clusters = s->bat_size; + res->bfi.compressed_clusters = 0; /* compression is not supported */ + + prev_off = 0; + for (i = 0; i < s->bat_size; i++) { + int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; + if (off == 0) { + prev_off = 0; + continue; + } + + res->bfi.allocated_clusters++; + + if (prev_off != 0 && (prev_off + s->cluster_size) != off) { + res->bfi.fragmented_clusters++; + } + prev_off = off; + } + out: qemu_co_mutex_unlock(&s->lock); From patchwork Thu Aug 25 14:31:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12954945 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 1CDD5C64991 for ; Thu, 25 Aug 2022 14:44:29 +0000 (UTC) Received: from localhost ([::1]:38092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRE5s-0000bb-0v for qemu-devel@archiver.kernel.org; Thu, 25 Aug 2022 10:44:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRDtX-0000gE-3v; Thu, 25 Aug 2022 10:31:46 -0400 Received: from mail-eopbgr130132.outbound.protection.outlook.com ([40.107.13.132]:23550 helo=EUR01-HE1-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 1oRDtV-0004pj-Fg; Thu, 25 Aug 2022 10:31:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ETWhT1oB+R1GNTeewXe5SEW2ewOeqKkeL6N5A8RD592thSevlFdaihszUoKf9rb5AePQJuP8JfVCF55T3JEZ2k8RvwZ229iymYaGf6GHL7P26z2x4+cZ6nu4lflnWSCBYfIaPKQwfJaZkQ6JFQSNZTgD/6C+Hrw5ZpSLmkQOcDpbGWxqO5/3pPBmlRPFQKbVUdIkq/IlNXOCx8LeN3XeFehw5I+rgazW/2+DyF6yMl5iFkWbNS5vxl61TkuCRBqpElhgkB5xl/2pOLGvcIgUfvHBq7nGZdw4qfCCALsfb0cQKCL+Yy2FRg3euE97Mfgc714NbBHiIdM4zlTB7wwGRw== 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=arrAPOJikaGyeNEaTWhS7yx8/exfEpCQTqDC8N98mzI=; b=geyDsA3QTMFMVUNL/RVoKYuC9/n8H/oMUV7Q6gpE6Rk9n2lybfndGFkSI/dSkZX3Pc1V7+kjDsOynC3Dn6SLGaJVjiHetWqJKPylA5d//Aqs8uqMoMjhSd2wPY+OHfWJBWMCh/BdFSxtjbyls/5tLuJ+bqyIcRDZ8sOgcbsXUAqESKyeUI2tb4/tx8I1tpcta7e0aFyyjrgyrMd07CjPox2DdUFgzr8fkqWVQug8vrv4bh3ikE4GNTWiB/xBSn+BBhdevS/D5o/057+H03AecNDo61l/Zus0yxOa5owWO0qmHTu6QSsdiUQ1zNDgPcoBs5Ud8N7iGdqC+nEbrGSXmw== 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=arrAPOJikaGyeNEaTWhS7yx8/exfEpCQTqDC8N98mzI=; b=jg3+2riBRJDEMm8f7BGLI5/lAW0aZp4uA0SN59p4OcXb+nHC00UB7gU+7dBTMZ2t9k1nOimd1g0nfubvOAYc2GVzJIuersexaExMuQ/rTe1+eCg1IPCLOQ7UbYdMxCpCUXwtL3nEdC9RSzdgTkRAvEodIA6fRhrXCjF9qs+YpW7qS+I1AKugdm0v/0rIdpf585uf5PqpmLsFxbsrBCm4YBqtopHD77fQfkjZV8lTgH3/AcW8wERWGt0gdl+B9qe7pO2aCrFgKgJsSEi0Alc+mgUmN3nCYaHP7BO6zmXlwQ2bFv3yWVlXJEEw8gUjcQ2KCmxXstr250sg6qzF+OWd3g== 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 AM0PR08MB3569.eurprd08.prod.outlook.com (2603:10a6:208:dc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.14; Thu, 25 Aug 2022 14:31:24 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.015; Thu, 25 Aug 2022 14:31:24 +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 v6 09/10] parallels: Move statistic collection to a separate function Date: Thu, 25 Aug 2022 16:31:08 +0200 Message-Id: <20220825143109.176582-10-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: AS9PR05CA0046.eurprd05.prod.outlook.com (2603:10a6:20b:489::29) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9b0deb3a-4b19-467c-5f05-08da86a67cb7 X-MS-TrafficTypeDiagnostic: AM0PR08MB3569:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MKhXRdFVuyrjgA6XpCRHFdUQSbBZ3laUexFPQ/RD3Lxg7Qvr8kZrmCj9pz1qeiVSqHzLlpZsMkJXQyVbaJxKGZ0pVPjygcwZSUkPcnwuV+o8UxhVo++W2qx7v1RTBLhAOr0JQdz8Hl3kHkhkfS4wXC7+GP+QU313hT5GHXq7DUNLaX92fLAMNXq0UguLGdv6BYshzH7bbeX9am+o5RaBzNCwaXdnJFbCbwquEicahLEFAt/1Wevf7GcoMJcD5s0GsYueJ2SdmZNyp4Vn/cCTUTBzBFbVX9UhQnorUQr6JWtth5763K3nuqh1rMCZ5Rd+Gi4BS8egDm0PXHVzeQd8a+rpvuL8Rx+QyNxECDiiCNY27UVUoKPhx47XSBzW3J+l/nvW6VWSw1V5akNH7a7Caik1H4IJws8FLm3eSum9QbT5RgjvfhbWmQr1ykLt0ydPR0FGlBWyHqFWc+En42h2IIdFxye2uP0Ae/GV0Ke/Wt9FxG8NeML8oKvC4PTblLSxkwS9y5ITkLQkQ4Ck9dpPxyULBLzntfLzugOViv4ciWtPvQZH9nLaD5qtGF/llS/SpN31/iPHzEX/pX7SG+LDTSt+zbTBhVlT5n78PKUKXdULbR0rQXYE1tbl1EHhPAugM4TUAevS+8l4DrnemgppDGRVFgIoMwKSbraez6BkZaZVbYqDk4SwzZ3tutqsFUK7nofby24Y7O3TZqYxNDADWMcQV6VTTpHDzpUPECXo4vv9eU2hIDfb/DdS58KbWoaj3Hx/p0qxqPK9GmfMc/V5zQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(366004)(346002)(376002)(39850400004)(396003)(186003)(2616005)(1076003)(38350700002)(86362001)(66946007)(83380400001)(66556008)(66476007)(8676002)(316002)(5660300002)(8936002)(2906002)(44832011)(6512007)(478600001)(6506007)(6666004)(52116002)(41300700001)(38100700002)(4326008)(6486002)(6916009)(36756003)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h8o4iGXkYnizTWQwTH0e6VPHnosdKcaGFs6SVriTY5wgnsYgazMszFBoJ/20VS33965eyM3m4seLvU8+JRdiua4FvOuOFmJxPtnls14pt4yN3rVlzEJgy5L4Zv+5VAxnkzNjK+saC+t7JqCs1XppSjifhj+M6oxT/wcXtt3BuB0Aplkn+lxRCM5RbeBuknBwUH80p8FRDU2iMS2FwJFGNICr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y2xJGa11QRDM9RX2hqlHO4J7vb04WqWEBjeAfrjWxhNTIo7xDYpHr0mqpvEcbiMheL2jliDIpds7hXPg3E8XSz18Cr4bd6oU/zp/xX7/p0qolFich9gTtdu/kYGlNSqbCv0Zc1LH9vX2CVxks8gHLz/sNs3eX9EYYbWwGWK2rZWZilWZEYzy+oozK3vm+jVeYzsTSSHB25AVK1X23gU5kii9Kc/vrTRIf9pBFTjpM00a8uBUPU/BBu0QrtNzLrGiuU9KnDTfHydGK+BhbK4b1Vu4ZSjIoO9anKQySuFOHpHtaOgcMQEHhDlvu/H0mrqOXXVTucIJphrYp7K5yaB9BsDbTLV8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b0deb3a-4b19-467c-5f05-08da86a67cb7 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2022 14:31:24.2524 (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: fwQfGyYEGgZexpeCd2ftmKZEsVCFabuliQFd1cuTq8EptJGd6fMClkwbRBySiVmB27+4gcUwIC99K55gHebHOut3HHlVsDxDB24swMjLvSw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3569 Received-SPF: pass client-ip=40.107.13.132; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 53 +++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 1874045c51..eacfdea4b6 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -526,47 +526,56 @@ static int parallels_check_leak(BlockDriverState *bs, return 0; } -static int coroutine_fn parallels_co_check(BlockDriverState *bs, - BdrvCheckResult *res, - BdrvCheckMode fix) +static void parallels_collect_statistics(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) { BDRVParallelsState *s = bs->opaque; - int64_t prev_off; - int ret; + int64_t off, prev_off; uint32_t i; - qemu_co_mutex_lock(&s->lock); - - parallels_check_unclean(bs, res, fix); - - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } - - ret = parallels_check_leak(bs, res, fix); - if (ret < 0) { - goto out; - } - res->bfi.total_clusters = s->bat_size; res->bfi.compressed_clusters = 0; /* compression is not supported */ prev_off = 0; for (i = 0; i < s->bat_size; i++) { - int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; + off = bat2sect(s, i) << BDRV_SECTOR_BITS; if (off == 0) { prev_off = 0; continue; } - res->bfi.allocated_clusters++; - if (prev_off != 0 && (prev_off + s->cluster_size) != off) { res->bfi.fragmented_clusters++; } + prev_off = off; + res->bfi.allocated_clusters++; } +} + +static int coroutine_fn parallels_co_check(BlockDriverState *bs, + BdrvCheckResult *res, + BdrvCheckMode fix) +{ + BDRVParallelsState *s = bs->opaque; + int ret; + + qemu_co_mutex_lock(&s->lock); + + parallels_check_unclean(bs, res, fix); + + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + goto out; + } + + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + goto out; + } + + parallels_collect_statistics(bs, res, fix); out: qemu_co_mutex_unlock(&s->lock); From patchwork Thu Aug 25 14:31:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12954960 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 EB8DBC28D13 for ; Thu, 25 Aug 2022 14:52:32 +0000 (UTC) Received: from localhost ([::1]:34318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oREDf-0001Bb-Sd for qemu-devel@archiver.kernel.org; Thu, 25 Aug 2022 10:52:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRDtc-0000mN-GL; Thu, 25 Aug 2022 10:31:48 -0400 Received: from mail-eopbgr70097.outbound.protection.outlook.com ([40.107.7.97]:64553 helo=EUR04-HE1-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 1oRDtW-0004oN-V9; Thu, 25 Aug 2022 10:31:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MwTuTSwCqeYa5z4kM7kfMDX2t+rBzhKalP6Qy6/VjvZA9HHAKOZ4xNq0+GQoYVJwZpyLKdtV1SXLVuHdZ1PIrLXv0y4L0bbgT+Ai5axW8lCUKtzCWRBoTeBk9eptZ99BRe8jBSlQ8pCrAmVa3/oDGXNVIizgb3IVfMSIcwEtek+E9zhSbmlIz5h6MJUkoC9zn8vUaCPbGWLtpvkDe4TGhE1JHpDaCEpM67y5b09ZcqeRgCun7cPrcx2eItccyeBwKQKvFGKI0AsYv2UB1NLJiBsoq6xDNrmEnz0DA+DFW6ItNCTEEaSXYKALg9fPnJI3ZQrbqEdgWdsVInDfoKF2VQ== 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=muZhga5Mtg2pyW235XbttJqM6vST9qzQe7PQGZbXvSg=; b=Jn1vPcyiIryx7V+5I1JobFePnx8fLK9RNwmT79+Ge6azXiNe9CwjvxPwp0HuL/wjoMcDCA8PLmphSivWn1w4gMeLWjpDxwsk2LwB+kSgqXTeqJUfH4mazf2JIEM/RXro8rEY2aM04du4zqJP23soKWxP8F+usUQg0qkjDhNByF5QlW0twHJZbpWQlbV6273Z1m/bGcRYZQo0eAw/50smq8JY1EbcuvB63Gg2RtHcANa8Zz9fueGF5ayKnLI7tvFkMwbTpnDYqEt8yHtT3+szLp09sr/E95qoxVgaq6pgzKh7RTYZuJc8OTSgldKGI9UfjjulUL+l0uttIgqArIVHVQ== 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=muZhga5Mtg2pyW235XbttJqM6vST9qzQe7PQGZbXvSg=; b=bsOhRfYm95B4jO178FlGiSl79m1Eb1ZQa3iTPwpjXVKcDRTYLuKm6DX5e4IJReelyXqnfA2EG51xsQ14q6m30OamhDccRc4eDp5UCjQ4L7uu9+DT8TR8ebWxxrN2MrJ8D77NDnFQOOB6NARWRE+fre273j78Vo9uPuDsusVYYcb0EnTa9JeaRsh2aErCCDku5yNLgxwo9tfA69h2b96I5EwrRRf1TdB82ByaYO4wgmyg1Phsh0cvXppuZc5EhorbwpVkVP20wG0zjqFSuOiwbL9WgBHnNIANiHoDfAycAmO7x/ACU8I5JtyO+iF8Y+gI9Wv7XGqdZ12dnFkSg7gqjA== 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 AM0PR08MB3569.eurprd08.prod.outlook.com (2603:10a6:208:dc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.14; Thu, 25 Aug 2022 14:31:25 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.015; Thu, 25 Aug 2022 14:31:25 +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 v6 10/10] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD Date: Thu, 25 Aug 2022 16:31:09 +0200 Message-Id: <20220825143109.176582-11-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: AS9PR05CA0046.eurprd05.prod.outlook.com (2603:10a6:20b:489::29) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: be77bfa0-cf7e-4169-7448-08da86a67d3a X-MS-TrafficTypeDiagnostic: AM0PR08MB3569:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nbzF9TGCk4Lxsh2Vu82HWNwG9gKMBR0sCAgKlYl3dxBD1wbm8ouOuZFKkx0F0oxulcj1CAp7D5gKFMVbcWONeaKp2Wl8cFcY4NPcSHkgAZTo1VQu86vM92jOE0drEbhCM/6GL0f8KL4oM/x+hcETIqzCSCwxAuB62YIEOeRamwGOPNUjoNfoIpXBDr01mtTvQmrZ2qFZomg0qwtYkMCKaa6Oyk0rQxg7HC2N1f2NEV8KkSBLKHurwkkqnFDQuHlIs74RfvB3hzgbSzvVIRhrAEcUdQ1/N+tDDdxIRUKIsiF5a9gFjUlDlwpbMyMhsE5JDZwZr/U6rRClmuDQ2ddGr5mQcF8eecA/tUp3vAoMY9BmitaqTCngeCJhJ8N9jPzuCwIHeVGAPHNQMHuUDfroUQ24+jsy2SGF473fpRsVEPm90O7iEzzr+eiDI81LSAEaUPpGiWzkjN8fWXIVkSnGLY1Xal0Q2fpi9mqooj2FSRoH7W/VtyHQyScXVRe17Q1wNCblO7ZMLoGUoYZvkwrtrPcCPburllpTaGvhZxAJV7FKCeI9p6iPz4u8O1TIjAVHeLrwUgTW5tP17vSNJX5L6w+dLQ897rLDmooFx8Qhe+V099PAkRP2KLub4MhFkSBhL+iOr4BkiaTBi7NICFnwutrwIWHXrOshWS/4bLqHXMFJxb9YNin6dRcj8DAJFvT1VxOSJPoN855NFnsU/MCMP/FsdWPx4g3uo5Z+zay8/PbMenRv+DCSHWndECuXo8SV19yh8OoS8Gbqi7lgIEtA4g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(366004)(346002)(376002)(39850400004)(396003)(186003)(2616005)(1076003)(38350700002)(86362001)(66946007)(83380400001)(66556008)(66476007)(8676002)(316002)(5660300002)(8936002)(2906002)(44832011)(6512007)(478600001)(6506007)(6666004)(52116002)(41300700001)(38100700002)(4326008)(6486002)(6916009)(36756003)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uArCNsWz8gU/UakQsJWVT4AZ80nde2ZrlBMGmgFZdXiynUHMUFxQexmGmzx8/UOuUg6JECZCGcophhqLmFqBlJ6lOeV+wEF3NiJ3BaFkp3Td0u/9AqZJCooJpO++uxXKjjUdJC7Y6A2CfIWcoEB3H+znxtJ398zT2J0kndHQrn63uuOSrhxIOYD1V1KUUAOEhIMlD2z85xVOjBoE234EILk0k2EJczIHje1ZhTRjFU+PBjX5cXOMakzM9Pbub0qDGCw5gqQIb2RIM9/KLL53PVFLWPFS+IXQKZCOLUwfXKIW1VdtTnxHgeiNdQXJ7IP46eIwER+2pqtaKJA3BUBJV5/8yp4ehvWxrGNwFt/LwOSwo+zwv1nMzL+ByoKATBneJdGiSzRmxxHsGU3gAt3vhUTDp3S2WDNsuwxzOtrcMzVJZo0k4Q4z52GZjsE/tRiG1peA8I98xBIT26VTdY/M7zTYx7fK8gHNeRY3F+GccPyxWk/cohFhLlNBUvgZrEp+2yL6aezeWbIhaXUi/CMPabvaO5m0jTMCso6VnpC+iZT6yYP9Q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virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: be77bfa0-cf7e-4169-7448-08da86a67d3a X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2022 14:31:25.1599 (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: ibsXDSG1gnTl4taA9wAwZSiUc+Ev94Hlfcf7i0+m7yL2sHAZHgRlV4tXL8LfXqLGDE7vXW0nWIDDG17++C8rHZloaF5aUlvpdc8gNQ/JjSw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3569 Received-SPF: pass client-ip=40.107.7.97; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Replace the way we use mutex in parallels_co_check() for simplier and less error prone code. Signed-off-by: Alexander Ivanov 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 eacfdea4b6..8943eccbf5 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -561,30 +561,25 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, BDRVParallelsState *s = bs->opaque; int ret; - qemu_co_mutex_lock(&s->lock); + WITH_QEMU_LOCK_GUARD(&s->lock) { + parallels_check_unclean(bs, res, fix); - parallels_check_unclean(bs, res, fix); + ret = parallels_check_outside_image(bs, res, fix); + if (ret < 0) { + return ret; + } - ret = parallels_check_outside_image(bs, res, fix); - if (ret < 0) { - goto out; - } + ret = parallels_check_leak(bs, res, fix); + if (ret < 0) { + return ret; + } - ret = parallels_check_leak(bs, res, fix); - if (ret < 0) { - goto out; + parallels_collect_statistics(bs, res, fix); } - parallels_collect_statistics(bs, res, fix); - -out: - qemu_co_mutex_unlock(&s->lock); - - if (ret == 0) { - ret = bdrv_co_flush(bs); - if (ret < 0) { - res->check_errors++; - } + ret = bdrv_co_flush(bs); + if (ret < 0) { + res->check_errors++; } return ret; From patchwork Fri Aug 26 14:27:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 12956152 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 3BEDDECAAA3 for ; Fri, 26 Aug 2022 14:59:10 +0000 (UTC) Received: from localhost ([::1]:52970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRand-00065w-DN for qemu-devel@archiver.kernel.org; Fri, 26 Aug 2022 10:59:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRaJA-0005QA-En; Fri, 26 Aug 2022 10:27:40 -0400 Received: from mail-eopbgr140135.outbound.protection.outlook.com ([40.107.14.135]:34511 helo=EUR01-VE1-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 1oRaJ7-0006Ps-Qr; Fri, 26 Aug 2022 10:27:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PPLN8gFY42nQTFL6cpUZOMK4+TRv5KfmkvuezsluyEGpi6t3pZLf9G7BgRLV/GjQdS7uBBxVBgQNAl0nQ3jAM51rzLnmSSGAU8S7u4extjOIheNbpI5enOty1i5HXl6X3S5Kx1TQPvCEf0Oo2n/rjLA5SS1hihXkNXeEdl4wte3G+8GLZiu+qhMx2CNNQrKzx7GjGU2Rin2tHcF+KUWpQ3/qbP1QGNdJN4TicQG75c2mTp0IuYuIhIxZ79LwNcZkdamvVesPtYLXZ84GumFe4b8RTU7w6PouNP4lF2U5vPEcWuzAv3+8v3b20OS4p2yUhfQtFdN1IRtpCXM4SoGxpw== 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=ctzXVS0/9aST8COtaWSX/WPENtUU+qsaZgKC8zjk82A=; b=VKjVk3OXR7zss6akZ2PSPITX55GehkJEzvjWUnAiQswyNB66CMDiubbVus6Lw2ATHMIn9dCGuljqyhtrCFmLaKUZtXliH4K3GAuk3XArtaHrh1/hfuBauXZGH4E3Qr64WfT3U5N4eP0BM1dm7HRkSgOi6AmoT0iOt+A835miS/umt4mbhsqm1O3ILpntnknEMWVTJTB2OXpNrgTpDNtoPsBwQ5MfUbXj/9FpvziBitmBFtki8j+3RLwT393Ju+DBU8Ol0sf+RTJRjogd0zwY6LFf1+OZNAlQbKBbRcUNcuqS236g+wDoxNAR/iDcNa9gy5df7QvURFmeP285All3dg== 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=ctzXVS0/9aST8COtaWSX/WPENtUU+qsaZgKC8zjk82A=; b=C10r11IpDLRwKg78MkV6HYSNsPC1bSP/VfXMohDV9DFw+slmgl6n2MPPb5eiQYAzPzLK6nwQTAs1XwDQYbkS0eIMJ5EnJoiduyCpay0j4h+VOJXwWHDxSFsWH5QtMqoAK4QHqPFWQ7vFA9xsPHF2iXpXaAPrPVK4e+Iz9jFZeyqwE7f6FB8Z/s680XxrrDLl2LIyKf30dqx0l1Hgqso5CTir4qXLQdqqJF0Ry3RCSsbNTiQr9El4ktb8p41TSSazZYTHqOc2t32tz5YDdkdOcYYDpE1aA61GrMJO7H606idMNjVfAncd/qwQCC3vcDHdEBDWwQuWGw7HhmzNtMWJOA== 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 AM6PR08MB5253.eurprd08.prod.outlook.com (2603:10a6:20b:ec::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.21; Fri, 26 Aug 2022 14:27:30 +0000 Received: from AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b]) by AS8PR08MB7095.eurprd08.prod.outlook.com ([fe80::5174:25c7:6df8:741b%5]) with mapi id 15.20.5566.015; Fri, 26 Aug 2022 14:27:30 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v6 11/10] parallels: Incorrect condition in out-of-image check Date: Fri, 26 Aug 2022 16:27:23 +0200 Message-Id: <20220826142723.235636-1-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> References: <20220825143109.176582-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR0P281CA0053.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:48::17) To AS8PR08MB7095.eurprd08.prod.outlook.com (2603:10a6:20b:402::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0e703075-10f0-4d43-c8fb-08da876f1ba1 X-MS-TrafficTypeDiagnostic: AM6PR08MB5253:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sw9VSAz7pNfWRDY+2cwphbpDIRsfi/LPyAvKf4+BkDUHTcyQvCqmTyAsYuYBlMmlQIYcL1NtJ7tCz6NlQUwT0iW97s903RheHjF1GurHZgixyysqdnCEKFpQJSRIwj5yYZG12CqM+k9qqaKtV0FsqyY3euhjw/ztGVmat5zGe1X0bAPoGGB+R/5MruOInwBHyGinE4fwDSSG1n7OmqKxnEnlKzzkuM0Xv1picjnUjcO/Vcq5l9AzR6Ru24DUNL+6lN9MNjbCRzdpXg9zFnP5+CXIuctDPgcOvCezA26zrWTvkLPQIzCLPhivFVqAjzVjLRrAEOiiMEeFDB9JB/NkU7M7uavjrdPEeVPR8/pqpN1havMMBR3vvb1P31Uv4vvSlORhhq4qxtINfBKYOJN+ohtsCLMWA7P/0BSr+4pRhfjj8Q4XLiq4zRbASO/UTJoZIOYugM1UfKFQutdPYiImgKj2ecWUD8sG+edGLhtQdJ7sgr1mhdAVSg4j0adIIZ3XLIAPHiL1uQOKwkErsBHSUJT44eJmsvaD3xh5EdMAMNajc3e65IhIqBdJ5+iRiOKg19barrU7xtEtQ1jdM/ZhKiRTwZ16dKjtaI2sw15LX6MKLcLjaB3KSqLkLx1xp+URf/qtCBJeHStHy/RB26y40f+eyY9RCNbxnzhZqvfFvla+sY/Z3Dka53zXZ2tJsABVBn8mXRj4C1fdMDeXxIkFDnuGXluaMRCxxcz1dvtUyHeKELU6kFk1mjMVKCoe/GAV0Fe+KkP+/fp1Q2Tap4cmnw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7095.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(366004)(376002)(396003)(39850400004)(346002)(4744005)(8676002)(66476007)(5660300002)(66946007)(2906002)(44832011)(4326008)(66556008)(6486002)(36756003)(2616005)(186003)(26005)(1076003)(8936002)(52116002)(41300700001)(478600001)(6666004)(6512007)(83380400001)(38350700002)(316002)(38100700002)(86362001)(6506007)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lmFMNXagaAUVxlIHY/naD3YA+ShVVO+Sku9Ur6nlC5QFojMDxm9FTjreBVb7ux1m5S0hdJ5r5M5Nv+O0T23/L5bjlaF+8i+aIEpmohTszdnRSnQKByrEVmtnHwRF47tqXbhgPZk0Kqd9ftuqHGiD0apwuBC+kwt1XJYh0XzRODIoITgnww9iHlYqNSQgo52jra5cpwPkKszhsFr35sXqzhIAkvecqQ89yXVQeu5Oy3GgF0JmkbxQW6CC8p/8IvJpYX9B7g9UgUtJCqVnv/Fim7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0kWRlujcpRVnqxEThMI4ksPRL7YKQsXleG4lV/oId5BMjF2n5l7/E3aDtsLAhMOcrWBC92inEgQ6zlWrXz4bFvIWd3fKPBX5bktCMSKnTAfPLFNfZtvAdsZ0bSSneU1IRNIXwvIQpoBNx/YJyDD0IF0qosSo1cpyuJB+qKHnODTHrsCLz04TaRo0ObRwM+HRS1IyZLjzDh0aqQsRJWc3GFGCyTjZ6LG/YeRLkd+y+RxgZV2O9BjRZnoHC6R6Bnfz8tbb2qFuO4v0G5IhZ5jQvLk/l6GM+f/fWvw= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e703075-10f0-4d43-c8fb-08da876f1ba1 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB7095.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2022 14:27:30.2615 (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: pBrZ69HuWrKkFOFVrB+hDEBVlJuv1GPZY9bCqJEcBFOdtrKd2jnrMy+p9LclPWM69kkYPeOUygCPSX6/TeXNbgDiSZ+lJqq+Mjn56Ky0fWw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5253 Received-SPF: pass client-ip=40.107.14.135; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR01-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 8943eccbf5..e6e8b9e369 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -455,7 +455,7 @@ static int parallels_check_outside_image(BlockDriverState *bs, high_off = 0; for (i = 0; i < s->bat_size; i++) { off = bat2sect(s, i) << BDRV_SECTOR_BITS; - if (off > size) { + if (off >= size) { fprintf(stderr, "%s cluster %u is outside image\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); res->corruptions++;