From patchwork Tue Feb 15 17:53:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12747445 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 B00F7C433EF for ; Tue, 15 Feb 2022 17:56:26 +0000 (UTC) Received: from localhost ([::1]:36038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK23t-000189-Hi for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 12:56:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK213-0006Cz-CE; Tue, 15 Feb 2022 12:53:29 -0500 Received: from [2a01:111:f400:fe0c::71d] (port=64834 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK211-0007aW-D1; Tue, 15 Feb 2022 12:53:29 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eXtNU13VJbBXzjqc1br6MsZLGiXwj2wgxeIEKLbpIdoXRgEqBvp3CkMissthj/rmGkrWrfDTJmQ3Vi0jTdiO4NBkSnVs0pxC9OohO9ZkEq8Eve34N++8yhQJjZNb8YVswdShkekp9+nY1Bd99osHRhYLXSf1Ide/Az9RZtA+8+kp5UBylbzq3WYDfMbJBxyl2ImMCpAcW/IfXZg7bB/poRzkW3KzA6rnk3hNObp6DUA9+Un91xxzSLs8+SZZ3UlDlkZ4DaAD9bPc9dXqs9xtLzIesSheAkPE5cGu0+xJD7ZW7cMvZ8GMf47ElQ7/T3xYbJH7dgqwPwr5YnIHViYQuw== 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=00mF59kZm41Y0m94Xc2xzHz7fe9xhoLcFTexJNAxGGA=; b=EOkKmuZtHn5qRK+kmYvxZ3o6TCvIagGaQ0tq4YNE/P8K4vezVsAnDkx63m6ngqMD2KK8XWlYOa2sAdul/pgfd4Bpcc/CboCSVjZIySbTL8vR1zc7pBm7vuYevymW4/XyqwWGyVuiAbcZyAbWIDcoYHZIY+3ZyiuzR2EBXTiLb7YbUbmwrO3Tl2Escel5s1Udd3wY2UJUo/vUuvUEXIg3PSHCZJMCoVcp7Kz/b4EBkCeeFWoFrbXT1CavAD6IgUBPPCmRpzuJbIT4fNHlEEEZy07DnpfZE698bt/DsxMJukSMxBzNO4M/XuvZI8fpzJZ6V4tHrYUt5tSHp2iUTH1MoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=00mF59kZm41Y0m94Xc2xzHz7fe9xhoLcFTexJNAxGGA=; b=fbmvCZHbIxvnvgGZcGnF3AlfoLNBimFggmX6Oxi0BOgqWl8b2iGSFl3EyHUYbhzTOzNdLNaiGBBjp2p6SmbxhhNWdAw7VqQDUpCvnorr5jX4Aq+6Ajr3U88hlv6fqqvNzprut8pPtuHyuRlJ8USIrI1pLB/ivUok/3aPMBSBiwc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by HE1PR0802MB2235.eurprd08.prod.outlook.com (2603:10a6:3:c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15; Tue, 15 Feb 2022 17:53:20 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4995.014; Tue, 15 Feb 2022 17:53:20 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH 1/4] block: bdrv_merge_dirty_bitmap: add return value Date: Tue, 15 Feb 2022 18:53:07 +0100 Message-Id: <20220215175310.68058-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220215175310.68058-1-vsementsov@virtuozzo.com> References: <20220215175310.68058-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR08CA0013.eurprd08.prod.outlook.com (2603:10a6:20b:b2::25) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae07d560-d56a-47d5-cfd5-08d9f0ac0d85 X-MS-TrafficTypeDiagnostic: HE1PR0802MB2235:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:69; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SjSFIkSHcAPcWs2QroODNzgs2rpDpVDuVlmvtqvyj7MDVYEgy19bJZyu3gHvJbmsMYIeW8A9z22KV3pymThQzrbruGWmzXBAbKDEgSRSYV/b9ay9DxaLgBBFM9SVzgb0BbIvL2gDsjJJ3iE1LEeX41nwakl90xCrhO8BOq+Sj5N+RoF/TDTCBvderGuiUw1fPlLnO33V3d08yVQX/08Hi6p12tPfBiQZp1QKvaWwXoCIVMy5vZkS8jHO87Zh5Ca0IugWEVB1+3FEE3F4mRWaczy2HSvnp3+N91mIW2rpeIMOF+Vo1AcJzZkauAIShot2SopdTzydmP/GeBCpOJ0/TXAhMO+0mljfkXAhaIbGZe17A4CLAsxeXUHa8MSu1HJ9CrMstBRBw5McBo2Bgjo0Le84RpKBfmNVcCEWzlMZXaAXN0WaW8J4kGGLMh06mEokPiVvxAO4x3treH3olIuRQcy2cNm5fgx8cWdcfmC/Up75LfDBpnUeOttwyzWt5zqejIf9YkhH9f3QK4Rd0gwk8iapVFXhK/KSTchdlSLpz99RGDZeYiKPyi252KrPfWofAibbNvKLYiZz6ucvTB+k2P+h3Vigrk+6PyOkUU53iOWibKvcTl+WE/LJ6IYAnRGFFQzYDGGS+KR8ArO0TVAM5TXCxJNAiBaZ8bYKKX/KvkNfqN9lo5Wyg9NLxYC66zPAsaqr7Epbpf5yJTUQI2nwRrf88OWJSRtrdLUc+dGl4/g= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(2616005)(83380400001)(6512007)(66946007)(4326008)(8676002)(66476007)(6666004)(6916009)(66556008)(38350700002)(86362001)(38100700002)(26005)(1076003)(36756003)(5660300002)(6486002)(316002)(508600001)(52116002)(6506007)(8936002)(186003)(2906002)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XHT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fJFcuIbRJLUHYJD9kojBgdQs4XDnlb0LQ9MWS9YU3r/BfTwK4AcgzMmzyfTtJ5QLIRoXcHwnYUN1rhP1ipz9wV26T50gRfO59hjKCKyw4CowSUxeOs390Wgu8lZYDhL335aOCPefjXasPtcYccAhQ59+KxELr0PkM+GIXTjKsV46Bd1G4i8UPcLqmlMKsQxLJgVjT6D1VK/hKg2MLe/yyNGovc1v2zYyq8qxnocZbBNBlqcRNywOpIURGOoH7aMAb9GkPgofBKnJ6mWZlezsVYrj7l48oq3U1TLKKg+g5I7pZMDa4doDlBbIg8y5Xyp8DiEWOLHeqr7lXR5nvKiIQo7C2cKBcMhY3m4iS06n4pSDQzjsmYm7KzaTPuwpqxizsCn1IRo03Id7ZotStdB9HguYg41pYmd0Ii9B78kAZz++JXFir5D1uhw1yLiThlVFv56k0LV9mQcrTeVLwQXGLM5m1ZbpjqxfQGAsDgoNqaX/U14M/S5C2fSfHPSWG/onCIHqqXYy+KQ8nAjMKdqKraXOeGyTrNDtdwjcSlWTUedmvql+T51G7Xf0h5zDNCzOT0b22jguu7OzXXrVv86L/wP0OWrWtARKyQjga2P7iwrSaGWJXxpoFAQ= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae07d560-d56a-47d5-cfd5-08d9f0ac0d85 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2022 17:53:20.2330 (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: BI+8QC1xT4cJJgYIlVIMl20Mj6wMEDIGKc6Qz1rWec2wek9gWT2zqZZkc5cDOqUrvRJVIbecON4UIsD3kidmZCin/r31hABb7qZb9vFQZ5M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2235 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe0c::71d (failed) Received-SPF: pass client-ip=2a01:111:f400:fe0c::71d; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 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, PDS_HP_HELO_NORDNS=0.904, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" Add return value to bdrv_merge_dirty_bitmap() and use it to reduce error propagation. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/dirty-bitmap.h | 2 +- block/dirty-bitmap.c | 6 ++++-- block/monitor/bitmap-qmp-cmds.c | 5 +---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index 40950ae3d5..f95d350b70 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -77,7 +77,7 @@ void bdrv_dirty_bitmap_set_persistence(BdrvDirtyBitmap *bitmap, bool persistent); void bdrv_dirty_bitmap_set_inconsistent(BdrvDirtyBitmap *bitmap); void bdrv_dirty_bitmap_set_busy(BdrvDirtyBitmap *bitmap, bool busy); -void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src, +bool bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src, HBitmap **backup, Error **errp); void bdrv_dirty_bitmap_skip_store(BdrvDirtyBitmap *bitmap, bool skip); bool bdrv_dirty_bitmap_get(BdrvDirtyBitmap *bitmap, int64_t offset); diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 0ef46163e3..d16b96ee62 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -881,10 +881,10 @@ bool bdrv_dirty_bitmap_next_dirty_area(BdrvDirtyBitmap *bitmap, * * @backup: If provided, make a copy of dest here prior to merge. */ -void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src, +bool bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src, HBitmap **backup, Error **errp) { - bool ret; + bool ret = false; bdrv_dirty_bitmaps_lock(dest->bs); if (src->bs != dest->bs) { @@ -912,6 +912,8 @@ out: if (src->bs != dest->bs) { bdrv_dirty_bitmaps_unlock(src->bs); } + + return ret; } /** diff --git a/block/monitor/bitmap-qmp-cmds.c b/block/monitor/bitmap-qmp-cmds.c index 9f11deec64..83970b22fa 100644 --- a/block/monitor/bitmap-qmp-cmds.c +++ b/block/monitor/bitmap-qmp-cmds.c @@ -259,7 +259,6 @@ BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target, BlockDriverState *bs; BdrvDirtyBitmap *dst, *src, *anon; BlockDirtyBitmapMergeSourceList *lst; - Error *local_err = NULL; dst = block_dirty_bitmap_lookup(node, target, &bs, errp); if (!dst) { @@ -297,9 +296,7 @@ BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target, abort(); } - bdrv_merge_dirty_bitmap(anon, src, NULL, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!bdrv_merge_dirty_bitmap(anon, src, NULL, errp)) { dst = NULL; goto out; } From patchwork Tue Feb 15 17:53:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12747446 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 CA47BC433F5 for ; Tue, 15 Feb 2022 17:56:28 +0000 (UTC) Received: from localhost ([::1]:36238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK23v-0001G2-Nz for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 12:56:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK216-0006I7-7H; Tue, 15 Feb 2022 12:53:32 -0500 Received: from [2a01:111:f400:fe0c::71d] (port=64834 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK213-0007aW-Vj; Tue, 15 Feb 2022 12:53:31 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HgFWvCwbUZbNpZcXiitZTb7qKEY36PW3TWM1OAqnwJCD2n5JqTWw7hOG5aRuFMCr2bo2lJUmdG44e5Dcq7sBw62QI3xqcncxiIx5UpqujNqtoBINzgV4kTIGMqpei4/AvQmCJkL4/KcDMgN7DNog+Vhr6RVWsMY1flXYP971hVZDXcP/n3/LIPGX4LAlFqc80WEv580tICLx1fbjZ5oA37S0vCsW8XqdyNiW9izNkR0FNVnejcK7RWSbLSwv4kir9V7hPjNKuxrnczu9W5IFo6M5knCTXG4vRrXaZ/bjuEwNaO+x9LaT4+lGkJKJAIItAXtfbvDWqKt5JkUKCuAiHw== 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=rxU3LhKvBse0KPOF2r/W5QyGfMZLXkFjUbyGmf4t1Rc=; b=C+G9RH2TnrRRX8oNb/+/29coBS77zMSTSZ+A1VrdlBKBUwOGr8zw7fKgsRScUADDzB+iPHHrXLEzXVr72+3iRWgjVI42QYw2K9O+k+adeD41Suw01fsAvIp/pjtmnxiTJExsUSq1JDpEvpqESPbyupO2sAmvikH55W9CzussgWBh/gVF/Jo2L0bru2jM5DnLUYJP1mfbM2drZ8QoQYHMVJPeHseGxw4ZH45yz1TfP4hDMBJSg9JUU6OwLT5xAxPT9ySA5g31CsqHokatQEbmylAwxFQ/IVPHFBmGVYpFHLCyHHPyTTjjKOKPtAoy9VELJU3XGaRevHsz110iICn8hg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=rxU3LhKvBse0KPOF2r/W5QyGfMZLXkFjUbyGmf4t1Rc=; b=YKQYnqKR+7qrY5T+WOqGw2iV2e3d3T04FpnHkuKBHvDG5tr+IosMwiLPJBC2bZimuq/R88vz61Eh2OPEy2IOAbFrSmAnARletjfNpwkQ/4QmbuKgfqvD0tDeSZVz7brIZxvGVtAeX4TXmTIgFbQKBCQcYdr93JxMGQi0grd3joc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by HE1PR0802MB2235.eurprd08.prod.outlook.com (2603:10a6:3:c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15; Tue, 15 Feb 2022 17:53:21 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4995.014; Tue, 15 Feb 2022 17:53:20 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH 2/4] block: block_dirty_bitmap_merge(): fix error path Date: Tue, 15 Feb 2022 18:53:08 +0100 Message-Id: <20220215175310.68058-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220215175310.68058-1-vsementsov@virtuozzo.com> References: <20220215175310.68058-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR08CA0013.eurprd08.prod.outlook.com (2603:10a6:20b:b2::25) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ea521568-c819-4972-667c-08d9f0ac0dc1 X-MS-TrafficTypeDiagnostic: HE1PR0802MB2235:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:91; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2pnYiZ+1DVkSWRwQBCnvXTENj1W4sc/cPi80+EWwjPEjczGrOnsr3L/jbhXOtW8xXoiPTEGhbEV44EcHMt/eXQbq1RWGrO2BsT1xC+GLLhDwEYWJrHc8mQo068RTdOLTWTQIMwADW/26P4RQ7m9IwNWYMyexvQZ9BfXBsqpf1GxS9TXzP6nyoQIWk1+7PyBZQSyFnMuyTz6wbQY2RbsyWnWirlFwKDCLd4x3aU9KlzSrvT0jxd9B2hVNnkmLmx3jcIjmTviuwL9cvuZnODFZej6NRgv6G5pjkVE45iH/EVlzV/AumsQ7JO6XJzld1mOCS1uuxuKwjot1E7p0e7Q6i8hb1UIttYfdtuUWC4G0Xannd0/WvwMAtyOgNt+5A2dbzWZiSFYnZ2K/lexzrEeR0O65oJT/oSoipR31v3cb8C/LGvvJxQsTOHLSTgaYSq6lNPufe9KcfJzG9yYdXpxeURtGhhYgqK2dDeN7iyMgIbvQyIn6HHOhX11O+eR1Mtu8isb2x3BM8yWNU6apztoa2bxxNVroa8Sx5v7A/8r8swXX/h4tPGaCxIdnMO1ERtXWz2YFOBJWQ3cQHqd/TSyLTdwTMHxmePsTJBW0bH4O5HqJZCMfdDCdiP3dHKn2NOaEm3RVV1+g5DwaGRgidC4xNMGn634kwGXQTb6Z6etzsJPDda0KE+00bwNgqvx8PiocgdXKs7EaZHhRoqNv5kbGUrteGzDRY6WIzMdrFbZRXdE= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(2616005)(83380400001)(6512007)(66946007)(4326008)(8676002)(66476007)(6666004)(6916009)(66556008)(38350700002)(86362001)(38100700002)(26005)(1076003)(36756003)(5660300002)(4744005)(6486002)(316002)(508600001)(52116002)(6506007)(8936002)(186003)(2906002)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kucS5FmRIc+qk6N4raTBh2j29cMrt8xBDk4VBT0bH7VdTQ/9gORKT0qIc68+MxDAt4t4VBrTV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63NQeew4znb/XgPYNig9MTyrPm2XcbtjnB+RiKXTrhyEYQQpF2kEG6BRNXDVpgdXKYl+g1+/+jTNpm7oz0Meai95OF38DZxsLleDZU4LE2NZEfSacCd/1aZ0bo62CKDowXHIC51m8eezxnxFPHml3ObQ5ksXAxGqjGaPPiToRKYuJZAmZSlaUiQktm70BVCfOupwPDblhqtn4aIFtsy26rI2WVfguNdDU/Sj8qKffkyD0F5G+kNANahjwBlp7rbuhSndZ1rvAqm6YLGUnG8xJ758i0cIWdG7+vgfHxdXVkfp9LSUXYhhfhEzyufx211goA/CNM8Mxzg6VwjAdCyZjLLbP4Wr32XTZR3f9yDUOrA/J6bM+wDKjn/YHJxtHfjx8MWxpgjFq4xEnCDQkU0Wd1DaSEqhTwAXbmucvTdEJtbJGZ6UmuiyR9tkwVpP9SmFNKYI3x0+0vOjrzNzFszRWjUkWdsIui5jYDSVV7577uh2o0oPlGuR70tTR95QbTmirbU/wJDxifwrg9mQ9ZBp3JZ3yGHQ= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea521568-c819-4972-667c-08d9f0ac0dc1 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2022 17:53:20.6704 (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: VMoocFyoM3P5mTjzLCAdWDJwQmmupviF2usTeTuiS0vZNDruIX0uJNKVDZZNiOAyYkz0cLinHUg4xSmuHtgS+/2gTQIUSBXo7YaPYhxrdzM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2235 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe0c::71d (failed) Received-SPF: pass client-ip=2a01:111:f400:fe0c::71d; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 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, PDS_HP_HELO_NORDNS=0.904, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" At the end we ignore failure of bdrv_merge_dirty_bitmap() and report success. And still set errp. That's wrong. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Nikita Lapshin --- block/monitor/bitmap-qmp-cmds.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/monitor/bitmap-qmp-cmds.c b/block/monitor/bitmap-qmp-cmds.c index 83970b22fa..a94aaa9fb3 100644 --- a/block/monitor/bitmap-qmp-cmds.c +++ b/block/monitor/bitmap-qmp-cmds.c @@ -303,7 +303,10 @@ BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target, } /* Merge into dst; dst is unchanged on failure. */ - bdrv_merge_dirty_bitmap(dst, anon, backup, errp); + if (!bdrv_merge_dirty_bitmap(dst, anon, backup, errp)) { + dst = NULL; + goto out; + } out: bdrv_release_dirty_bitmap(anon); From patchwork Tue Feb 15 17:53:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12747448 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 8F712C433F5 for ; Tue, 15 Feb 2022 17:58:36 +0000 (UTC) Received: from localhost ([::1]:42974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK25z-0005oT-J2 for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 12:58:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46708) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK218-0006QK-L7; Tue, 15 Feb 2022 12:53:34 -0500 Received: from [2a01:111:f400:fe0c::71d] (port=64834 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK216-0007aW-BJ; Tue, 15 Feb 2022 12:53:34 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jBS2zoJ84HJBRHSt7DGjzlRiNtpzLJQp5DKAv73/ndUGohbTG//NZAcsJKRr1X6pPNR+PkiKKuYTuzxhJ1qhySLhvFlCQTfjskko+WcqzWOMncGaYvjhrQ0zcS2lYtxxkOUD2QQ7ba3WODmTEwp6Uk9YuFst+H7bv0JCzs4S7DZav6dQbNximNtCaaUbVi0NcKcBTEgoMxRyNYBfQw0XFrHLamux/oLvLjJx8LIN4qzFMxipkpPXiWZ2abIC+I4T60jYjhJ9QXV7ymdYOSvlCJdWEHhCCp82XQn6HybTadtKXy3mUM8lBLk7+35oQ6lTWr5CqAXt4ZSfLx3ADRMWHA== 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=1sI84jtDtTHyZ/vJYtTfgGW2x+nk1QWJEqHypZ3Lc8Y=; b=J9XpXwvYEHCpo1Z6TW8hEtfdkkYLp8e4GjhAceLPUVJ+3hpBsApFTLRCDL5AyxpCSfFb0wIifAGRv18/zTHUEJ9nb2OJIx2gihp/6UnJYNj+yQSLis5FJkMLy6J3mj51xwPwWIXA+1ZSGSeSLdV9qWFZmpIipGg0j8roZfwh1z6UDwq/DtxaYQ8YYZUGn0xbXAmzKNJakyCcmIEVhHiRKLwIWVwjvtA+rUtAvLgUti0EQdE5ZpYN4TfbNm/eEQ7F9y8UlenLc32cmOEhyD9YVTkJxvdZWlL/dITqAIQ71vDAtjuNuTtevHyJgxb8HCC+0TNSNuCq8/llvRmb3N4X9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=1sI84jtDtTHyZ/vJYtTfgGW2x+nk1QWJEqHypZ3Lc8Y=; b=ne/qEgXCV9foC0zSOjqtqF74WGYIHTpV31ktzVFuW4RVVmV3McX0BPcJRK0ZkWVikdCcfPk6O02txG3mDqWo5LW3cdadov8hW+D4vlh09dn8tK9Jb8Yl/+Lp08hG0VP35M0FPPqz5vzAnxMQc3ZhvEuU7wFYowov5is74wI0eOg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by HE1PR0802MB2235.eurprd08.prod.outlook.com (2603:10a6:3:c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15; Tue, 15 Feb 2022 17:53:21 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4995.014; Tue, 15 Feb 2022 17:53:21 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH 3/4] block: improve block_dirty_bitmap_merge(): don't allocate extra bitmap Date: Tue, 15 Feb 2022 18:53:09 +0100 Message-Id: <20220215175310.68058-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220215175310.68058-1-vsementsov@virtuozzo.com> References: <20220215175310.68058-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR08CA0013.eurprd08.prod.outlook.com (2603:10a6:20b:b2::25) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9c1a7ae8-3215-4445-fcb1-08d9f0ac0dfc X-MS-TrafficTypeDiagnostic: HE1PR0802MB2235:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:660; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zapjNmrcjCv1AOQBRwWcyA6jWajboak+4FyRSoQL4OfXYOVbQD9xNV8MWRqMuA/ZwEd283csGcpbfxJgVPn6sBqwiqpE0W3xhqWB/94nnIxiFikByvweGEp1Kf96uOhgXF1X90Uskd7AznLV4DTUJt3pOgN5Ed8Gn7lHbJuDzcqt5e+tEB+CrsCLcaxTxf/FMk1Ka7uOCMUXuw78igw4Dw70fTav9IQcvErjUItyKb2soC03xCeMrnxOMEdgFBQdIp4FcAL4/2DaJZpho73F6LbxwPISjrRCcAgSfpLB/MAu/uu0SHBt7yuj9rM3op69xk0RKvpWAVYZPFPggU+KySR88HAVx2koUufKWepHKLd+zgxKzNNNs7WpaLJwAVguvDil/QNv2PRBDB6ksK4bCV/F5Us/C/xQLFKwv+UOQrCOvDwRpYASTFUt0by4D58i+VmYJsVsCi4cCC2/O990xLUQ4yuJ23hyOnlQ4qfylwne3lVvTKJifn15eXK4f7HXWjrdTDlgIalIlVl3/l8f6Jq4JxGKBHGux6/0wky8McR2qBwPWr+maess5dPZxAdSOZnsd0f64EVGt5gOLumwkLkCGoa9PaWO/u2sYb+bwQY5uxOxa5qXIlsTmr/vU0IE2GQolY/93+YkULwti7gLnywHlzr68h+9Mi9BujcVqoBn7J65zKXspcb9k1w6Ep52Z/t9koeA+/iDfoyUnyBUGkYSs9/3nyOWeEpphK+kUQ0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(2616005)(83380400001)(6512007)(66946007)(4326008)(8676002)(66476007)(6666004)(6916009)(66556008)(38350700002)(86362001)(38100700002)(26005)(1076003)(36756003)(5660300002)(6486002)(316002)(508600001)(52116002)(6506007)(8936002)(186003)(2906002)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VdGzjivJ0DO6qqS9jYQ402qJ/63DMei3PitgZQWZjqC9LqdqI00d7VWVGJNewXV2ZCWwM87JB9MWoKekNBxp1tmi9DEQgzVLv3qX6/l1G2w1R4h53BH+V3N4FVhqLkyzm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0gqKP0ITE5gl7JdFwJSplFK0fEtB+Lrn6ZbrRxWTdpmhBE6I/b6iAQrkziFgbxfaS/T/9IQmgk8mDeRDDS1AxVhJ3K8sAj14DRqhlEEqJPoBQRpcD/w+uaeHNP/7hHNYmYt7E81o6nAeDKJHUXlw/Urpr3yPP3cIUDYmGhSlyT5tM5qhVdnf5jWQCg66bflu784LBL7xIbgQfvOnzk4Ug8+JL860j7WU03NSCzwQzUuouAVCZ51jUYvyKG0hGLThOcOyHi7oW/Bpqvrfk+gSXFZJuFkh3+lQFp0jJ0mclMwdrTFbr8uOlw0WHUqp4yJvWmU/WcO0dcNlgHaQPy6bBInUlgVXMCacYTJoPrZnfk8S5txTJHXB7iQnVCUJFOkkCV3YhXKU4JYsY4plMd44B9IO4jIb5TokF3Y8FXthiEqc92WTkI4MVt6GwB27gYzCgd4HYb6QzAD6s9hD9BL+yxaxzn+9FRM8LU/WlFP/w5r4rfw62amtDE= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c1a7ae8-3215-4445-fcb1-08d9f0ac0dfc X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2022 17:53:21.0780 (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: mlfTD0jDk4HiUf2t8NiGCmo+C1oQQv/GDNtJPidVlJnEjjNB6ls0fB7Ojy/Oc4frHvFpbBdyRNpCxz4SKljZQmI554liEmp5Lv4Thdn0gnU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2235 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe0c::71d (failed) Received-SPF: pass client-ip=2a01:111:f400:fe0c::71d; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 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, PDS_HP_HELO_NORDNS=0.904, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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 don't need extra bitmap. All we need is to backup the original bitmap when we do first merge. So, drop extra temporary bitmap and work directly with target and backup. Note that block_dirty_bitmap_merge() semantics changed: on failure target may be modified now, and caller should call block_dirty_bitmap_restore() if needed. The only caller is qmp_transaction() and ->abort() is called for failed action. So, we are OK. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Nikita Lapshin --- block/monitor/bitmap-qmp-cmds.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/block/monitor/bitmap-qmp-cmds.c b/block/monitor/bitmap-qmp-cmds.c index a94aaa9fb3..2ce1b4e455 100644 --- a/block/monitor/bitmap-qmp-cmds.c +++ b/block/monitor/bitmap-qmp-cmds.c @@ -252,12 +252,15 @@ void qmp_block_dirty_bitmap_disable(const char *node, const char *name, bdrv_disable_dirty_bitmap(bitmap); } +/* + * On failure target may be modified. In this case @backup is set. + */ BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target, BlockDirtyBitmapMergeSourceList *bms, HBitmap **backup, Error **errp) { BlockDriverState *bs; - BdrvDirtyBitmap *dst, *src, *anon; + BdrvDirtyBitmap *dst, *src; BlockDirtyBitmapMergeSourceList *lst; dst = block_dirty_bitmap_lookup(node, target, &bs, errp); @@ -265,12 +268,6 @@ BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target, return NULL; } - anon = bdrv_create_dirty_bitmap(bs, bdrv_dirty_bitmap_granularity(dst), - NULL, errp); - if (!anon) { - return NULL; - } - for (lst = bms; lst; lst = lst->next) { switch (lst->value->type) { const char *name, *node; @@ -279,8 +276,7 @@ BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target, src = bdrv_find_dirty_bitmap(bs, name); if (!src) { error_setg(errp, "Dirty bitmap '%s' not found", name); - dst = NULL; - goto out; + return NULL; } break; case QTYPE_QDICT: @@ -288,28 +284,19 @@ BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target, name = lst->value->u.external.name; src = block_dirty_bitmap_lookup(node, name, NULL, errp); if (!src) { - dst = NULL; - goto out; + return NULL; } break; default: abort(); } - if (!bdrv_merge_dirty_bitmap(anon, src, NULL, errp)) { - dst = NULL; - goto out; + if (!bdrv_merge_dirty_bitmap(dst, src, backup, errp)) { + return NULL; } + backup = NULL; /* Set once by first bdrv_merge_dirty_bitmap() call */ } - /* Merge into dst; dst is unchanged on failure. */ - if (!bdrv_merge_dirty_bitmap(dst, anon, backup, errp)) { - dst = NULL; - goto out; - } - - out: - bdrv_release_dirty_bitmap(anon); return dst; } From patchwork Tue Feb 15 17:53:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12747447 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 1227EC433EF for ; Tue, 15 Feb 2022 17:56:38 +0000 (UTC) Received: from localhost ([::1]:36848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK245-0001ea-1y for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 12:56:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK21B-0006Zb-Vj; Tue, 15 Feb 2022 12:53:38 -0500 Received: from [2a01:111:f400:fe0c::71d] (port=64834 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK219-0007aW-DY; Tue, 15 Feb 2022 12:53:37 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gsseF7LdjbXgmS2a3e56EPCigigOo2WvZ374BF6EejgkLG5BLywoWTUltZZiPBWW6uwDVR+zxVo7QXkCLWUqItqx6GQFYKiNB7vq9ZOSICEl1Mm/Lljc3QYBK+Jh5JAMcCHMqYHJREqmPWAPrOmkiJzlxoq6d99NHGNhejC+xGLX0XxZTfZAoT4HrVeR0XWsq3c3ukGtj+RCZCyH0PmelHOTwUwffE5zUIG+dSJXHqAznyKGVyU1l9x1o+5ODpBub0ETWCkYgN5A44JppnB2GcYVaZkKc12sInPcqRhmDGdTCtYcWce5stnjp3Ni2jZHiyYI8U5fHMHFEptSTWgRDA== 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=fk9jL0/pXLmWd43wu4XSjKyQM8QImMC3DNQPDp/BIoE=; b=h2Mn3EXq3UoS2ahwgk5GpskrZcRYZRVEI0cQ51BEQ8Lv8RYPviAaDGCvvXWJkQkHWBwJTw+HFfq4bJQkTehqmLphra50tj93mPAjAWhvv7HOJBG8H5ho9x58IbRGaFDjIu3mZwisdB8mSmQayXlvWJf+iaoS6ZtMg5MWhxn/8cT8muhzv6Q/7P9vJnt8DYUHh3rzF3p5keuUgBr53dTOuyR4LoyzWYRkelChsgtZn/TR4jZlPSOxWgrlL4EDgRg1GD2BZehljtknQO4dJjRc/N7zkjo+nFqSujDcO390XrCizpsw6JJelqcCbficvZsDl9NrqBKNpr8D9Oszd6lbMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=fk9jL0/pXLmWd43wu4XSjKyQM8QImMC3DNQPDp/BIoE=; b=hgU5jOBVAeUO0sfWiqx9t9eLta08cSe9+Wp9tVB+G8TF94DnFFZckObTMnQI/Kb/mEVZxvPQxP8/ZnBXbL2qtxdy21Sr/HId8ukzoabqD9eK8S7yo2I+f4ZkU3IoB/yljg7A+ldQE9/FkKQDxY4lrWcR/K3k0L1ssRG5X3EA0pI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by HE1PR0802MB2235.eurprd08.prod.outlook.com (2603:10a6:3:c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15; Tue, 15 Feb 2022 17:53:22 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4995.014; Tue, 15 Feb 2022 17:53:22 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH 4/4] block: simplify handling of try to merge different sized bitmaps Date: Tue, 15 Feb 2022 18:53:10 +0100 Message-Id: <20220215175310.68058-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220215175310.68058-1-vsementsov@virtuozzo.com> References: <20220215175310.68058-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR08CA0013.eurprd08.prod.outlook.com (2603:10a6:20b:b2::25) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dc906c23-7e91-4822-14ea-08d9f0ac0e47 X-MS-TrafficTypeDiagnostic: HE1PR0802MB2235:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LTSCcVkiAY3gbxbQS5HO9F+TmHWLClHCk10g7JRBITH0opSTkGlQyCuvT4UOumoG8Hbkc1FSYSVobhFEnB4YBzbfPNHSgBY6CCVp6wlN36RR0aXvBcorpYpxRbzYwLvldyNGRIJ1uW4W6flRkeeGm4gdZRmqiPS5dlDO0cOV0JvZZ0Kca2Qf6VuWqDFfBbLs+c/mp/TdcTG+DKSUOU4W1GUztu1HFRPKydXQiojfEPY7iXkR9Hvs8IGORMivVL1bIqzyrKQfQx50MDEL5nvP0UdMnD+oZu2OX1noYkjTIpL4jYCBt9cVPNt1RZdNXXRtRsAFYkGxhhPjNKaXJYVcWZmlBlyVuOyYs0bkEGKyPLVvhMieyaOz9mYi6gTMHdX9NODcleancxwztHJ2oWDNqZ6T6xm80ApoRAuny6P1vR66oBhfbQ0mEJuU86P3w01G6eezMyigwoRkqSv+pF3rvxVNr6ICOn8HWgCVgErs0ppfIX60g44U3elI08uPdllTXG3/Apcw3UvClFlzJ62URv4vtsBmlP5ySrVfNbI4kKO6PfvfRt4vnc0FH42pRfFoDlkMQL6AxujME/CrEcf35zFjfwt19WP9rCG9n15OuTtIHI3CACLPe0BYUmpwWswIOrtFZevmx7bA931yp0mM9Pl/BypPA7rF9ubkv04EAHnSWds8LJ9c7c/ddc3TKVwihsCzu5J9clevnUIhooEUEQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(2616005)(83380400001)(6512007)(66946007)(4326008)(8676002)(66476007)(6666004)(6916009)(66556008)(38350700002)(86362001)(38100700002)(26005)(1076003)(36756003)(5660300002)(6486002)(316002)(508600001)(52116002)(6506007)(8936002)(186003)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EWHRjMo8/ZR3RrJCtrr2Hjv4xGuS7S5X8GujslZBtBsPZFkyUGlXxZgNWbgixYaOuWtdKV0lwTZTEUunqt4ag6jMnHlmf3CSxFP1KjCbSUjeC3QSjv+6p9IIx9JoDIejnHzMw2fZKsNOAxKOkmdwaQqp0puvZd/JeKV1V4HhwCenV0d7I85P/ptLpTcCOIK4W46nSdifmnYsOp6DYyolWunyTLoM4vpfbnW3v5iWGEJM5vPAx5PyzXUaOKRlKk8iYhaP4EntP/SS1W0/7vkFjwkMzwCOjjh2Jl7RUpe4jLcovfCBSgcvwY0DoGmUFoewhC7609M8Y8vzu36eMQ7CUtE50XwqFUoJEqI32V6rItI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izS5Lpk8QrhdTyRmx8ROOiIa1BrdPcp2xrb1rqBwXCymPIb4fvUwPNtMVv3hg5KGxBd0352LeINDUGH5Ka4sYY5/EdoSazraE3TdCdJm4NXLsVDOPR+03tJ1IpS4PI9KCM2sCD80OHEeDHhzhp5Uy8vuUv93MBjGAuI66Rg0umFH/a6ZPYeidLiWksK1eTBwF/ahyICtNKzP9EJyIxble2SqzhjzACua55iBpWFUm3sjg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc906c23-7e91-4822-14ea-08d9f0ac0e47 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2022 17:53:21.6872 (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: 4gGGDNoUdOQf8fHaacS1+C+SVMvJmAEnqfP50hq6nh5wQYuirZFyBrayti1eaxFPFAtvE8NOtWCnGbKpDqV3Vv7Vy6sJ1vVfbV5/A8+yrbA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2235 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe0c::71d (failed) Received-SPF: pass client-ip=2a01:111:f400:fe0c::71d; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 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, PDS_HP_HELO_NORDNS=0.904, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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 have too much logic to simply check that bitmaps are of the same size. Let's just define that hbitmap_merge() and bdrv_dirty_bitmap_merge_internal() require their argument bitmaps be of same size, this simplifies things. Let's look through the callers: For backup_init_bcs_bitmap() we already assert that merge can't fail. In bdrv_reclaim_dirty_bitmap_locked() we gracefully handle the error that can't happen: successor always has same size as its parent, drop this logic. In bdrv_merge_dirty_bitmap() we already has assertion and separate check. Make the check explicit and improve error message. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Nikita Lapshin --- include/block/block_int.h | 2 +- include/qemu/hbitmap.h | 15 ++------------- block/backup.c | 6 ++---- block/dirty-bitmap.c | 25 ++++++++++--------------- util/hbitmap.c | 25 +++++++------------------ 5 files changed, 22 insertions(+), 51 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 27008cfb22..cc40b6363d 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1382,7 +1382,7 @@ void bdrv_set_dirty(BlockDriverState *bs, int64_t offset, int64_t bytes); void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap, HBitmap **out); void bdrv_restore_dirty_bitmap(BdrvDirtyBitmap *bitmap, HBitmap *backup); -bool bdrv_dirty_bitmap_merge_internal(BdrvDirtyBitmap *dest, +void bdrv_dirty_bitmap_merge_internal(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src, HBitmap **backup, bool lock); diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h index 5e71b6d6f7..4dc1c6ad14 100644 --- a/include/qemu/hbitmap.h +++ b/include/qemu/hbitmap.h @@ -76,20 +76,9 @@ void hbitmap_truncate(HBitmap *hb, uint64_t size); * * Store result of merging @a and @b into @result. * @result is allowed to be equal to @a or @b. - * - * Return true if the merge was successful, - * false if it was not attempted. + * All bitmaps must have same size. */ -bool hbitmap_merge(const HBitmap *a, const HBitmap *b, HBitmap *result); - -/** - * hbitmap_can_merge: - * - * hbitmap_can_merge(a, b) && hbitmap_can_merge(a, result) is sufficient and - * necessary for hbitmap_merge will not fail. - * - */ -bool hbitmap_can_merge(const HBitmap *a, const HBitmap *b); +void hbitmap_merge(const HBitmap *a, const HBitmap *b, HBitmap *result); /** * hbitmap_empty: diff --git a/block/backup.c b/block/backup.c index 21d5983779..fb3d4b0e13 100644 --- a/block/backup.c +++ b/block/backup.c @@ -228,15 +228,13 @@ out: static void backup_init_bcs_bitmap(BackupBlockJob *job) { - bool ret; uint64_t estimate; BdrvDirtyBitmap *bcs_bitmap = block_copy_dirty_bitmap(job->bcs); if (job->sync_mode == MIRROR_SYNC_MODE_BITMAP) { bdrv_clear_dirty_bitmap(bcs_bitmap, NULL); - ret = bdrv_dirty_bitmap_merge_internal(bcs_bitmap, job->sync_bitmap, - NULL, true); - assert(ret); + bdrv_dirty_bitmap_merge_internal(bcs_bitmap, job->sync_bitmap, NULL, + true); } else if (job->sync_mode == MIRROR_SYNC_MODE_TOP) { /* * We can't hog the coroutine to initialize this thoroughly. diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index d16b96ee62..9d803fcda3 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -309,10 +309,7 @@ BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap_locked(BdrvDirtyBitmap *parent, return NULL; } - if (!hbitmap_merge(parent->bitmap, successor->bitmap, parent->bitmap)) { - error_setg(errp, "Merging of parent and successor bitmap failed"); - return NULL; - } + hbitmap_merge(parent->bitmap, successor->bitmap, parent->bitmap); parent->disabled = successor->disabled; parent->busy = false; @@ -899,13 +896,14 @@ bool bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src, goto out; } - if (!hbitmap_can_merge(dest->bitmap, src->bitmap)) { - error_setg(errp, "Bitmaps are incompatible and can't be merged"); + if (bdrv_dirty_bitmap_size(src) != bdrv_dirty_bitmap_size(dest)) { + error_setg(errp, "Bitmaps are of different sizes (destination size is %" + PRId64 ", source size is %" PRId64 ") and can't be merged", + bdrv_dirty_bitmap_size(dest), bdrv_dirty_bitmap_size(src)); goto out; } - ret = bdrv_dirty_bitmap_merge_internal(dest, src, backup, false); - assert(ret); + bdrv_dirty_bitmap_merge_internal(dest, src, backup, false); out: bdrv_dirty_bitmaps_unlock(dest->bs); @@ -919,18 +917,17 @@ out: /** * bdrv_dirty_bitmap_merge_internal: merge src into dest. * Does NOT check bitmap permissions; not suitable for use as public API. + * @dest, @src and @backup (if not NULL) must have same size. * * @backup: If provided, make a copy of dest here prior to merge. * @lock: If true, lock and unlock bitmaps on the way in/out. * returns true if the merge succeeded; false if unattempted. */ -bool bdrv_dirty_bitmap_merge_internal(BdrvDirtyBitmap *dest, +void bdrv_dirty_bitmap_merge_internal(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src, HBitmap **backup, bool lock) { - bool ret; - assert(!bdrv_dirty_bitmap_readonly(dest)); assert(!bdrv_dirty_bitmap_inconsistent(dest)); assert(!bdrv_dirty_bitmap_inconsistent(src)); @@ -945,9 +942,9 @@ bool bdrv_dirty_bitmap_merge_internal(BdrvDirtyBitmap *dest, if (backup) { *backup = dest->bitmap; dest->bitmap = hbitmap_alloc(dest->size, hbitmap_granularity(*backup)); - ret = hbitmap_merge(*backup, src->bitmap, dest->bitmap); + hbitmap_merge(*backup, src->bitmap, dest->bitmap); } else { - ret = hbitmap_merge(dest->bitmap, src->bitmap, dest->bitmap); + hbitmap_merge(dest->bitmap, src->bitmap, dest->bitmap); } if (lock) { @@ -956,6 +953,4 @@ bool bdrv_dirty_bitmap_merge_internal(BdrvDirtyBitmap *dest, bdrv_dirty_bitmaps_unlock(src->bs); } } - - return ret; } diff --git a/util/hbitmap.c b/util/hbitmap.c index 305b894a63..d0aaf205ed 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -840,11 +840,6 @@ void hbitmap_truncate(HBitmap *hb, uint64_t size) } } -bool hbitmap_can_merge(const HBitmap *a, const HBitmap *b) -{ - return (a->orig_size == b->orig_size); -} - /** * hbitmap_sparse_merge: performs dst = dst | src * works with differing granularities. @@ -868,28 +863,24 @@ static void hbitmap_sparse_merge(HBitmap *dst, const HBitmap *src) * Given HBitmaps A and B, let R := A (BITOR) B. * Bitmaps A and B will not be modified, * except when bitmap R is an alias of A or B. - * - * @return true if the merge was successful, - * false if it was not attempted. + * Bitmaps must have same size. */ -bool hbitmap_merge(const HBitmap *a, const HBitmap *b, HBitmap *result) +void hbitmap_merge(const HBitmap *a, const HBitmap *b, HBitmap *result) { int i; uint64_t j; - if (!hbitmap_can_merge(a, b) || !hbitmap_can_merge(a, result)) { - return false; - } - assert(hbitmap_can_merge(b, result)); + assert(a->orig_size == result->orig_size); + assert(b->orig_size == result->orig_size); if ((!hbitmap_count(a) && result == b) || (!hbitmap_count(b) && result == a)) { - return true; + return; } if (!hbitmap_count(a) && !hbitmap_count(b)) { hbitmap_reset_all(result); - return true; + return; } if (a->granularity != b->granularity) { @@ -902,7 +893,7 @@ bool hbitmap_merge(const HBitmap *a, const HBitmap *b, HBitmap *result) if (b != result) { hbitmap_sparse_merge(result, b); } - return true; + return; } /* This merge is O(size), as BITS_PER_LONG and HBITMAP_LEVELS are constant. @@ -918,8 +909,6 @@ bool hbitmap_merge(const HBitmap *a, const HBitmap *b, HBitmap *result) /* Recompute the dirty count */ result->count = hb_count_between(result, 0, result->size - 1); - - return true; } char *hbitmap_sha256(const HBitmap *bitmap, Error **errp)