From patchwork Tue Feb 22 16:18:30 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: 12755700 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 36472C433F5 for ; Tue, 22 Feb 2022 17:03:47 +0000 (UTC) Received: from localhost ([::1]:44182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMYZl-0004fh-Dw for qemu-devel@archiver.kernel.org; Tue, 22 Feb 2022 12:03:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMY6M-00061j-Sd; Tue, 22 Feb 2022 11:33:23 -0500 Received: from [2a01:111:f400:7e1b::71b] (port=19495 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMY6K-0008Lc-3D; Tue, 22 Feb 2022 11:33:21 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CMLhl+zXHli5c3ntbIVvhLg3zpeM1rcva2cTD6WKGskuj41BL1mu0KK1goQ7iL4jaAqOkqVAHodT6iX25rY/TC398E7fITogGLBVS4rOjkw6mABr/BCb6J3guqG0RFv6aWiisQXn/G00j4McGmbMPB9p/DK6mNrJXjxTLwHgk0wY7r8NF/4OLHNAXYbSA9ySPR5Mv3ZFdyjqcYG4yXDXOcBfKRNcwV8T5oE6EuF5AMOGbMBdhvuk+zXnc7ya1uDRy5t9Fsd0qI5FPZ1rBWFsPSMHMtM2/cXqMoywRDQdI0evZx3YuVPE24/jLiuc//bi9YT1i4QZ1ZKjFHAumyYHfw== 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=rYCkIsx9+bhwl6XDNZ+n+3c2V2cwQDr4V3HIXM5vypM=; b=IfwCZxAnBs/C/Q0OGAtRuPEiUczOqbPdbxW0nufSAxilGLbdZvwfn78uqBZz1aHBs2Y+MbsnXr3s2a8awh5u+cL+7KqzlCk9lSaRCSHw/Nl4aVsPHrZjwXmwU/TAuGDks5OYx9iYk4IQCBCc6h5YSciURHDIUloxfTRujE/2KuyzelSYokmZdLjAbXTq+UTk1Y35jSkJ/ODDoH2AvlCTvjwhmglcbM4to3sBZ1TJxSl/WMzWuhIzNyXDPN/HXbb5Kj+GDCaZU+EAuvl27IMVvCu55rzXpJDdlbGLCSxd7EEjueoOWO3kZyXzV1TowDCe/ZQkt/bCo8Tg+Yf+82Xlrg== 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=rYCkIsx9+bhwl6XDNZ+n+3c2V2cwQDr4V3HIXM5vypM=; b=BSH3qc4fRLBJjM+8HqJyM0PTxkmxJhp7oYK1Y7KuozNO8M3EUvTcO0kHbjJfsEbNqzMpkxdaD7ozNSrZxHI06/Qe9zxrpyjVXalquxTTAqTHBLnhcwvSUqwd5tvffBKmmNZFK26l1CwqldDXU3aKZLZmQyuyLmVgpC1HVOYnKGI= 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 DB6PR0801MB1669.eurprd08.prod.outlook.com (2603:10a6:4:30::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21; Tue, 22 Feb 2022 16:18:49 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%3]) with mapi id 15.20.5017.021; Tue, 22 Feb 2022 16:18:49 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, hreitz@redhat.com, eblake@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v2 1/4] block/dirty-bitmap: bdrv_merge_dirty_bitmap(): add return value Date: Tue, 22 Feb 2022 17:18:30 +0100 Message-Id: <20220222161833.1453641-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220222161833.1453641-1-vsementsov@virtuozzo.com> References: <20220222161833.1453641-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VI1PR0401CA0023.eurprd04.prod.outlook.com (2603:10a6:800:4a::33) 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: c3bcca1e-9799-4481-fbe5-08d9f61f01f5 X-MS-TrafficTypeDiagnostic: DB6PR0801MB1669:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kzJLLutTWeMuPkii1iCsSuM3Q80tuAQR5Dh2Vkk9v7ZMV+UAjXYO7HMoydJzRGXyYwrV7BzcuTXxE6jHd+ltZ62BpVhKPBIJLiXN3fsr3fBfu201ptqMVqTMhthF5d/DWS5fnwr0cL4VuXQoH5aVH1WniM16MP8grfnMHI1N4Rmt48Px7EjThkFRpLySMSwNnr7wle/9x2IpgaI8ITfU/OWX5VdCtR3H/NAKTheAVE34YOSzroFPKDjYE2Lms5OLBi3AmZVxq4ffYb1wWZCC5QmfVYQhqRvggzJxTaskfOfZYNcTxh2NpJ80EOCPO+tltQxs9ddEufxUvCJPxaxmUpXpQpjqpgCQDJSoYKeRYRf7hMIYbG0s5YUwfmN8NmmEeJW7ZEn+2ITLzatxzIoSysEBExovg5/yP1GOICU3V9lo+nitS6iJUX7OO/PPV+XVXdjumpnkpd5ph+cAA3rZzgYw2FbP7kX+SCz742nEi0f7b6B/8Ee4GcwIhgDGLdl93qjIyDW5oMlWslfHgg30S0aN6kju3/KZQKTxd19D/hd03qXIQLmlEL707EY+ImvIbVbFMFuCle77Arr9fu5lhuFNR7IXM2p9WytJLkuCeOsH4l8df/JdiujxQASQiAZ1BC/CbiZMsfHgKMou2zby/mT/MLQSits1p3RDcjE22k5Px7oiu/w1BKezi13+UIBkV7cbo2cKP0ld8eYc6WRhHV53BpGC0jewUZxw6NXL1ig= 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)(6506007)(86362001)(6666004)(8936002)(52116002)(66946007)(6512007)(66476007)(66556008)(8676002)(38100700002)(2906002)(4326008)(38350700002)(107886003)(36756003)(2616005)(26005)(6486002)(186003)(508600001)(83380400001)(1076003)(6916009)(5660300002)(316002)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RPcvgTCyiN/w6xtaHaWhTFviKN+t0VDK47WR+NFELS7gaA/zkS05rsaQUzF6PlIz9oxQlPVa/nBxkKOYmU7AlN03luZ9k2a6E9SZl9u9NaJLvn7SvfSjDGkr26QGqU0x6o/L9oKv7qUJxW1k/UnRTgW56lsoF3ee9n6R8uz4W9dkAFUfD/Ojke1ZQS2tPLLZH6TLrGSJco9IN22p46Bclo2JpogRHpCSdEb7yqx5ErvM7fSTrubWFCqJkfpiFN48z68LR1TQ1+5KehQSXbKf38orEThjQofWm8n4DdXK24/FI4kIxX9nMtimwciH8RXBKRv2M6TeChE0zdpJaFILvq/ZqIHGYOp5V85i3vfea4Q29N8h0+QDd0jmTxu34/7ZNnhninzJZbdeRcsdx6ZgpCtAONgrXmE83vGGZJ9/MhWy3HiaW8Eczx9y6Sn0mlN0wYooiGgOSvQhTJpqOcHW3ycI8zXlLL2EVY16/lhG0F2jgBhBjsPK0VUxz0DeGhNGemzW0Cmgi5tVhC6JKfOTDifZ9l4tFSjcs89+d/ZtFYjC+2DlCu5OhSW/GwImnYRVfafWW0TJkxoVk7Gf8A+c0MOzjqSCOO4h/O7bVupK5cyXW840EMTEzmJz4kizNkrv8rw0tcAyMojirr1G6ZUeFxePpDns4LP5cyqe6bbGP6f0avz8NQIS1oP+ZM3tamv5/kiYl6ftDMPhswpXVRKEy7ESI2V6ajxGGnjgSWZy3j8/0LDg6Fa/jVytAebn/4VO1IqU1E3SG5aEm3wmMHV90tVBtdjJvpsQ/Z2eJs8KjN31kUGniWPJfwhXioCKfoWc5anBA8/RVPlpal5EPPDKzmEvjMLGQEv2rXOsfEXvIdZL4PT0BzlMRT3CodYFTtPLsLzfGZ5OV6fBv9QxpuzBArGx5eP3iMq4n8eagl9XS+ySOK7E+1EqhBgWFG4oAUtB/iOpeFa5GogUkSfYMZ79IgrTLuG1Sjydqx9epM08RkC7aNlS3zTWkzD27ZKJygpvYzXVhObbso4DrbB6g02wDgdyhC6TFFSwnRdb3CzA38R1DZZSKPWDiZFNjJyJ3NPOoVp/yf7HEAzbKRqgjOOLcYk3SV2ELoQTYtQFTEyaosql3dPCEzl4Mg4oQVsrYXdqvStyR+ea35y54zmOf06F8odYzD0szxV4BRBrvrbeSh9l/x44Qz8023C+eJrf1+18aZbL9BuiY8WCKWBuq4l9Kt7MrSJDqJ1oTqk64frJUqcitIjtlcpYQe8BemDUkzttUY2vyMyQZedq0YcqMtg7ra9v7dC7q4nWMoUlRmvLizWLCOXxl2+Lxvl9TNOFwAw0ofPm0GTNfLcT/C7LsNcg/5yo0tFmsDgItYtiat3SSi7Cc+dKxyW0R7mMSh+iQXZzLW/DMIKzNoZRDyWhPEx1IxMHQWckVBOsyrDGQR9tK5K4/uYCukOjzkavDHxM97yaKsv8tDsdr6K5s25HsZYN0O6YpT2NaxHkbpSICgSrN4II9Dghva42CzjhpUSRFpRM8okcsV6jhDE+E3CWd+UsfPL48sUqIHo6jiB+JCAd9VpHgXQG9RBgqhioor1PraXk+MODEcXyNAoBUGOaa/IiUUjxXD1fBslhs2QiSJefp3vnpc5CMI1IsLwBClKzDM/y99HN779ARdNfF5oOy4IMOmpYE25CEqfko6Cnowham9U= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c3bcca1e-9799-4481-fbe5-08d9f61f01f5 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 16:18:48.9608 (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: Gh5bj9EedVY4v5+AmzOCiIzEHiAg+qLuS/rTPBoBvYPZklYVyvUxMDNA2eNLy4g+beZVndL0C81Fy0nhRcdxCY8tAOr6qdhf+Q8MwlEKR7w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1669 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::71b (failed) Received-SPF: pass client-ip=2a01:111:f400:7e1b::71b; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, RCVD_IN_DNSWL_NONE=-0.0001, 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" That simplifies handling failure in existing code and in further new usage of bdrv_merge_dirty_bitmap(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Hanna Reitz --- include/block/dirty-bitmap.h | 2 +- block/dirty-bitmap.c | 9 +++++++-- block/monitor/bitmap-qmp-cmds.c | 5 +---- 3 files changed, 9 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..94a0276833 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -880,11 +880,14 @@ bool bdrv_dirty_bitmap_next_dirty_area(BdrvDirtyBitmap *bitmap, * Ensures permissions on bitmaps are reasonable; use for public API. * * @backup: If provided, make a copy of dest here prior to merge. + * + * Returns true on success, false on failure. In case of failure bitmaps are + * untouched. */ -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 +915,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 22 16:18:31 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: 12755664 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 29D75C433FE for ; Tue, 22 Feb 2022 16:47:18 +0000 (UTC) Received: from localhost ([::1]:39624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMYJo-0007gR-OS for qemu-devel@archiver.kernel.org; Tue, 22 Feb 2022 11:47:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMY7A-0007UN-8N; Tue, 22 Feb 2022 11:34:12 -0500 Received: from [2a01:111:f400:7e1b::71a] (port=19233 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMY78-0008Ol-FZ; Tue, 22 Feb 2022 11:34:11 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hbk0wZBLYKSpCbNeeGhJs/JR9Nq/u9WT5eFfGsWcQezlGASzMZWuQe/Mtw/HAUEYsFtrOJk3hpebLBnHtYxkQdJiGFaPDy73syEviwuQBwa92Ii79YxVEmbjQVYxwJnkLXvgnzXXYmXgev7XRpOVG5cAqHB1XZdD4TemnG19yL067COU2cW74RdS2sXg1swdsW9cRLPE97WhH2+WIBmZbw2E8eGng2ZtpoZyBidUwRCT4900Q20Y63IOxBYFtP/33oy0WTJIJEVv3A8ZbX4acHhTPq8bP/lnKXP40sY6Ng5mzSXgUcScvLB5Z9dzTNT5sgNOm9cd4pEgywt373Onzw== 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=aTfKu3ZaEyX9ZZBwD9+ujS3rgOV4ki2CCtzEps/ZhKg=; b=K0Cy2ziDy6+IalCbu+kDoR2Z3ZWABzF6r9XG7NTNv+Hhilzo8VLyPEH092YUb/MhlS2LTG7bVYLPfEx48/iinep9MLeTo0XaqcOQdiU0VNsQdS5+CIa4yIonKL3mMeak7QjyMqAZD6do+Wwk3xkl5ju5yI1uPii+ZRTBjcRpgvW1J35jEG6muio95ndnAGhrPM7hXjAvd+aL0OErPzh6dGTF+ZcU87oMEq3tlM9HTTOrfacwSM/Jq855ouVZKW/zhlHvBk6eD3waM1h8CN3b+EhgrmviT57+BDlv/ELBC3E0de3mzBCWu/EK7XdESVl7DM+j/kxE3f29/7NwsmaeLg== 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=aTfKu3ZaEyX9ZZBwD9+ujS3rgOV4ki2CCtzEps/ZhKg=; b=RkuoQsbQ0MGhfPV5NC6aGzYd+vtMp4cH80f5Bjs6NApV0TbOv+fvNT+NE9oDDIAzvhmKmwwmEtw4I8jJANmZFzgDvx2tonFjDzVkSqWewYL6YD+UFMjD3VEWa128ZhOHslrnTU07Q+wSmBLpVkurwMk+fDizNxanEXF7zvNty+s= 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 DB6PR0801MB1669.eurprd08.prod.outlook.com (2603:10a6:4:30::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21; Tue, 22 Feb 2022 16:18:51 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%3]) with mapi id 15.20.5017.021; Tue, 22 Feb 2022 16:18:51 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, hreitz@redhat.com, eblake@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v2 2/4] block: block_dirty_bitmap_merge(): fix error path Date: Tue, 22 Feb 2022 17:18:31 +0100 Message-Id: <20220222161833.1453641-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220222161833.1453641-1-vsementsov@virtuozzo.com> References: <20220222161833.1453641-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VI1PR0401CA0023.eurprd04.prod.outlook.com (2603:10a6:800:4a::33) 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: 4a117d63-d556-4c39-e4e0-08d9f61f0295 X-MS-TrafficTypeDiagnostic: DB6PR0801MB1669:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hHhb+U3gghGPynf1wNAqcuXRgiW1e4Pm+NPBHqLCudTocer5m5lcuPld4dnw6Y3a9GGzT3v5UjUSxByGqiZxi+ugD8TQvw3JCYoyDRiQMg62nzgwaDDDfOcdoxgOV1D/3zKFOrxVXgkO0LRGslaHcupVVV/YVOELbuKIcJGZWAyesjgL6F8YE+VMJWBbw43G6TvJZu2UDelBOawhATafWxG8bVoqEipREgPL/ae/rfxmOPRhJSE0uyZ0SBK+//UyywxV+aF/bz7S5vj633Vr5UhQnoOgDiDUCOpVAjRjkW+fJmLNnzEvvLmeCLL8YhDixBlEVyV/1UmqwtbXFw4NhFhV4fi0PobXXGcYwK8ztbLaajFQwtMniiue9OhlulhscIn0myOldqayoOTFX8HtL7ABlUJWh9ZDwG2w7016JezMqL1FBS5zuWxo87xl4U5YR7wobVeT3qkFGHYz4hje/LGSN3xxh77ldXNxEJ8ktWwEf1qhbZWUKxox8OO1/ILaidwfYoYC+uLRAf3uKNUyPyTY474/Qh85jvbq+xSQ9dtlAWXuIF5SIU1AurXExNZusMLdGDBP3vWIsjagghm2bHYvtA/xu9x52hHtRHUTdBG0D6mNAFsR5IWuGCbf/M4D1QawolbqnVYOsARRkVS30IVhvC9v/lkrk5WdbfA+cRiQOK5A1j/o8ez+lVToULPqpTMbI4bF2TsveKGSGkGim5c8WXGytUm4UcVyUUfIeBM= 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)(6506007)(86362001)(6666004)(8936002)(52116002)(66946007)(6512007)(66476007)(66556008)(4744005)(8676002)(38100700002)(2906002)(4326008)(38350700002)(107886003)(36756003)(2616005)(26005)(6486002)(186003)(508600001)(83380400001)(1076003)(6916009)(5660300002)(316002)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GBz0u9KmE8XpDaa12Jog53PdJO13uXsilaC7FT2PWGqXbA9HO/BjEsJ78qCigOzspm5jET0IopW6eP7ygUGrxTk9BJJMBCynnfs2Npcc4DTtKLq5Q9GEF/SQ8pnbtbCup+INFErTTgVjt4Pcl76anAefYch07WuUWksXxS8bUsTX+ALmaWfBgPrlUFa6TXvHWY3uPp5L0BiVypmD0xcY32JfPF/D7X5LWM+MtgFSpYwbPW4D2tBttRBY8CbrIR0vmfi/mIdPNeAZVw3ceUos/TiLiPEGbpn2pO9hxfIMk7hUXYeTDTSfIO0Bbeq+90Fixi1Q9NZJ59YvljYsUugKKkIW3wt3n9GeXfPs9mNmvIiK/GYi3igi7mR8VCacztCfBbBEYdSEhWFYFG9aaOUMcnBizutQtEIr6nGSJqgrtq6Blj1pbfpC5EOojtRTZjrax1vAM+oeET+DFCCP7JyqJakfc2UYiJsIKmuNYcJ22LWyjLBWrpLnl/tJu+74T7xvh7G1vYr2kFUKHf+NFklC0kvn6JegBwhOi4CbWGez9BprLbafQSK28sE5TnWnjb/tz8VrK5Z4SYiZQLrr0yNPN7ECd/06Bf/9QbAmh84AyijNlsdJ71nwIoDHSVhlzfBpb5TGuUleqG5nnCyFaqKiF6hdDu9GW1J4u29BSm9BT4EtrrnZ+GZdsU7UDDOBGIY/mg+//5e3L7Vk4PeY/cCkNnefG3L1PYct/D9d3URFNv3IF0cdp8kEtWNVv+9+DTh3G3DOdySHS/PNWndjJhooLKovCtdrhr3Q/Q+rfnZfbL7s7q7jbUDhTh/7Kj17l2t11L9Ta3o1k4kTSOBL1GAhWPkQUlcRfqsCQucRsaZkmFRTVUsw02WWt5L4V33a8VJTxdAbWEPPiKDDxFxCfCUjG4QHmkXBvqgKmeWbq/fgo6sHQaTZU//q920aBIqTpF8+bbB+WH8Fg4uSqKL5NxfPhgq9Ljw54KoXQzecHS+t9JliXB8LpM2gyjv7lHe81I6skfVm01GxiYZivzYoN6z2fPjxXkiGo/I8YWEYr+kzTHR8sKYgbLY9tJn6rGXpRnw0JQgOxSZeBaNbaYzDcFAtCxfIvKRqVnOB/fWMHcO7Mawkq3O744fxLrEibyxVNblFWSKJacRDPeQjVoSRhX8tuZomEnmMb+5jMKEdFcjE3D926sKoV8Zb2POdflTCm7DmGDecc5WX70v83BBJUrIbFFsIO8lOhUdHHBoSqyk0mfc9qTnoQ8M1JzI+XLwwjy0Ao0HvlXAMBFwsFoGH0dQr3un2YNd4rs7oscmrahAtw6uGc3dR4NuoonPfW2laqFOdrZrT0cuPetWsywH1M31s/q1oV8+oeeH2/eLhZXINXjyk08a2PdWnyGFdYAN2votbWfJWEndwKfuD1BySVD5yq1huMNn3QDjGf4clDwA8dTRryr+KGO0YaPzdm4ftAgEKXCq/BcvYgJFpfOKAWuGY7b1TPW32gHRjfdrbcMR13am0l3/lMXQfru2PB+ykETrUdCjPdTc262vqMc/rcNM6RrTdwht2rWNCXVk2rO3zRnWTLqoYFPPhbqMX+EaNVWva8NpSI/3Sfbqs7zyfe+4k4SmXBXStyAAqaJ1AhDZc6/2nQDZExfAvCRHKG97g8c2LzIV6pyVp/lEwzwJVK/Tia0sjE6gxsxZuXM1VhEaSND0= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4a117d63-d556-4c39-e4e0-08d9f61f0295 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 16:18:50.1650 (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: kl8ZFz5gHrj+LqC7OC/AYgoIPDd3+MZlLmymelyHtEsgI+yaaco7X73dp1nqHlH8+AjAIJANfy4YM+9D6nP+wsfwaNBeBC7ZfRxt8H9WLfg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1669 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::71a (failed) Received-SPF: pass client-ip=2a01:111:f400:7e1b::71a; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, RCVD_IN_DNSWL_NONE=-0.0001, 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 22 16:18:32 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: 12755642 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 7DB56C433FE for ; Tue, 22 Feb 2022 16:36:25 +0000 (UTC) Received: from localhost ([::1]:46286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMY9I-0001OE-4u for qemu-devel@archiver.kernel.org; Tue, 22 Feb 2022 11:36:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMY74-0007CZ-Sf; Tue, 22 Feb 2022 11:34:06 -0500 Received: from [2a01:111:f400:7e1b::71a] (port=19233 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMY6u-0008Ol-RW; Tue, 22 Feb 2022 11:34:02 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OtY8neayWKW3thnjsUBIIAjNhHcozbbCWVNda/+evHcFJQririgS6AqSpqs/uaTLEjmM1GAKPR8N4YThxxN4pJN+DoGKIkb5Py7MHo6wpUObJbb7cROUVIs0a4IbV3wHbO1SH+3PVFYbA+UtlbbGcvzAqzIYMkYGjCpu+5PiSOE2W2ePFkknIuAeFjyP74tv7cX5NudUP0Eh6ULDvZjQrgPCn19j4bP2KINOq6CqenjHlYgPLfw6uzJT3G8RDqNij8A6Xl/RCuO9daToLjPdnOGy50XyjULhvB82adzbNB3/SnI16Q2DYOfIKqaiXSyEDdlG11naMC1tjalEx36eXw== 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=vJuYOFqs1zlwp09YsceloG+aPalq+WwZl+C3t4wKTx0=; b=lqFkyBi2JAhI/mjIvxxYpdYnnBsXjMLtMegt0pbeX0QTmQMw8iKUXT+IjuYdH09+ODPWWhuPFUm2obMw6r6BqKy/EYvKkS8nlqf1flyCSwoRr60N5tEsmboLLOoiJRVZ4Q7gOF4DC/VO8AQvbcTauqif7bJtXTTUaXHu5EkBbNk+sPFcW0D46S37MQT3+HGz7z0x2CnSppKe1klux1XjT7zRjbCkBVp1RuDglf9/fbtLfljVKei5gjblPpsCdPk0LJnhL4q9++MhrTqrpSGscxUxhmJgvHV/xxY9lyG0IxbFIpW5qlA9Az04xgCnDF3p5OB8kTRQ4Fc8t5ECBW1M+w== 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=vJuYOFqs1zlwp09YsceloG+aPalq+WwZl+C3t4wKTx0=; b=q9SnHfdfDmd+s85JWLQsxmQr/4/AZrXxdlJd7FR/jt0iVSmSiUcryu8c/fLwzt8f3tND1u6+LLq657TEMOww92zpRknSGhKIyPVctqyDaqLzq0HPlnoFoMPuHZ6mQemWv+vO4KORJThbT9jlq2pLummtYy+v4uzwxyoWwc4kgoE= 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 DB6PR0801MB1669.eurprd08.prod.outlook.com (2603:10a6:4:30::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21; Tue, 22 Feb 2022 16:18:51 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%3]) with mapi id 15.20.5017.021; Tue, 22 Feb 2022 16:18:51 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, hreitz@redhat.com, eblake@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v2 3/4] block: improve block_dirty_bitmap_merge(): don't allocate extra bitmap Date: Tue, 22 Feb 2022 17:18:32 +0100 Message-Id: <20220222161833.1453641-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220222161833.1453641-1-vsementsov@virtuozzo.com> References: <20220222161833.1453641-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VI1PR0401CA0023.eurprd04.prod.outlook.com (2603:10a6:800:4a::33) 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: 460826d3-aa5b-4fce-ec54-08d9f61f03b8 X-MS-TrafficTypeDiagnostic: DB6PR0801MB1669:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wcbmqwNcbJHi73cSh87xyR6osqoe/e7OYUNRIbCrfvXEJFEJrg4hbZBB+mSRo7h+Xth+6rfLf9wsObKFnFARMtRUVZ8GVHwI14naDJmvB1c70cON1O3lsoGIqXk43iyhILg4GDvN6fhJ/oNmVtsjp8tdZDAbeXm4tR39S6sN+LpBllY0+Hv1N5dYEOSb+OQUUNfLrol33wrNYwZxOjAm4ehUWKtkGGWJCvQ7mOOCGZobmkyiXxHV2hLLuryOfc11odMS/iGSsMSLKqo+8gFXWV7ksSgVHNB0NNzAQ64UnLcaztc64sjtfl4lvSU+4ufGGH3OuG6deMoKHSC/sh8pQ/5MIIs+ScvL9W6VGSOqBn4kxYmJ7qY3Yg75QAQcBLQwZ0vWxNrwHP9heKy9EG2bCnCYXqnGpacbIJSV7O1XOg5mGcMKQcnWCYrAlwIFi48C6SL6Qhf8wjz8buCxxz3H5jRRtl5HyOCfSSXO5WDCXwYyutsb6EzsKeSlFamx4i5CAtbZQWaXvP27y/0SX2x+SbGjoEn+QyRo4BQrnLIobH05CVwGpAQQCjZ39JkDrehLXlJeDol+SLwyeswSNmeSRzD9FjM1hXqNJjNOptmoeivdyBxZKiB4gDs0S8Fi9njJPtTEWkf+Jron1YtfvyJ3NDnbtpwrgvQEy6SS1iZoIA2PiYmHvrhfzFcSloBsuLlrxCucybZ0vnvwUWI0AnjS2v/b6hqt9mopMn0yTnmnbEQ= 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)(6506007)(86362001)(6666004)(8936002)(52116002)(66946007)(6512007)(66476007)(66556008)(8676002)(38100700002)(2906002)(4326008)(38350700002)(107886003)(36756003)(2616005)(26005)(6486002)(186003)(508600001)(83380400001)(1076003)(6916009)(5660300002)(316002)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9wmAYcquBhaWcLmWQJ5TuXc695oAAqEerJovQ+D9yG0J+iVxviOc+TFHAXeLc2N2UcUE60s1r2iwiSlJnPTTKoOhICyTDOiZd+598QxQIgnPfzEGYj8Qk4sord0RtnbFdBtxSTSSIJQO5ednJxfRl9hshURiq7YMHhdkM5JoCWe//3Ibw3uYJF0yxVLi1LiEh0azROFFNrLmUQAgiuNPva3Mww58nJ5SLdrFwC6L/CQ2V/YL6ORy09q0PphmXtacWaHr9G6Aozf0XSBAeY7S0U0dCyk4Iz1ODbhYme/gc5J6nrr+IFbMdGpQjDxklLvFHuY8YfixBbWaOlfxkUQ9ztw4DAurA0N45z1ezvqRGEET/Sak520mk5KpvdPYsA/AD3KYapezIhs0ZyEozJpNgHk4mcUMTuGk3Pbl3D5mijypCqsYud6n5/WSBbAhxY/EbL2a7aPFTaF1/KSVrU0MVWMoSeTS3/SLRFhpzj3a1aHHbGbK8PaUJEJstnvii2HwGch+Ekg55A48Gax8yesm0dZeTKxDvTRwQiczepIIy6eSOq/7sItfTC5tbM8Aa3qjOvcs6OkAYAS+teR5PxRV5505ZFKGjzqQpip682shRNzBwMpRAT4OCWIXpFK13sOf6CotlMcEInv7Zq7fRZj0Iu0azFAABZiQ7KfY/fYbWicNzb37YiyAwZdCB2L6r/pdQJQWQaSE1i3O8CiQoxTn1Mmds9TliTwpXPIKZzLtcYJa6DvKpAng1OnT0tb1TlnfC9f1mz+1yEsBcdJ8fiO8V4afH36N7QlEjFP7VBX4Cdei8rTse73MnY13Y4bOSeBZotGLrarRUMyc4ptem2dJqz3pmbXIEHjXBrJAEwprQDpZv5puu3aA8jQ7lCBHxi+E0y6eJskJITNgiw+AKKpO6aoBuga+vEl4YgsObSbbkJBbvXLurW7+Syrph15cGR2M0ThjLKkRjQkDULk8Y6FCLZcLNT0hCdKC9OrvGqulUWpirylRCOGmfILHp2iOdwb6kmUQLRdkhVselNEUzwarf4Cl/pz0/0SwnXN+QmHKdrpoxZkpf5Cmecu/ZFxJNsZ66QfYlHtLhCCsya9OvzQoqA90m9iUIkVNXJw+yfGEkgGm1j32L//t3wuAktSY2RQhfFYCUqFvfCtfry32872GD1k3xTDY4tXZAJo8q88CO3/r5hoNaGOvmsY6DrD08L6j7ZlZzdAC8w8/CckjOV080Cnbo/N3Pp68f8RLIi/9g/OcYIFjmkSXxxX3I/lMvK9zPE1xf4gYZnif0Juz1SX1h4NCXkZi8QyLvCHR4KSF29r2roTyBE8xTk/OEVje53tMsN6SJtKxEbRCL8gdPgGLbiu1FNwUg5CUHqa61ZeaUEwO7iOiCnmEWBL5LN6CrzNw0u7NeAij9Y1FwrZXPYEnEna6/h+wlJNSXczfG0bcYnOKXMYz0jSCnev3Ci4n4x8zf7viKyZ4AXXqOA1RTx+A2nE+DQP/SkAye2bDlSTXEtpDIFJ8UhVZOuTWbYz6BguZ1UhJhAF205KHCsuZNXUfLmIHAHSNpQ8PDMViOWx7SOT01d1absS+BoK6hgBuGOKfk8+vd4N68ltLrVsV20uVoNuq2XvLKDZwNnhKpjg88cUq5DdG6U0d47lOH/jDYF3BuxbkOem0YO7oDtBxD/mM8Cj3l2SMsrio80Ku003WCJY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 460826d3-aa5b-4fce-ec54-08d9f61f03b8 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 16:18:51.7286 (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: Oxxsfr/0ukvcQA7gUyPfIKxu8vzSJ6h2mZLcxPasUlbdhnxxlDU0nurU7rnxFYVgW+3vKOaIXKAHWYB9KPAnwVmBredWKjhr9wb9ukqcGA4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1669 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::71a (failed) Received-SPF: pass client-ip=2a01:111:f400:7e1b::71a; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, RCVD_IN_DNSWL_NONE=-0.0001, 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. Still to keep old semantics, that on failure target is unchanged and user don't need to restore, we need a local_backup variable and do restore ourselves on failure path. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/monitor/bitmap-qmp-cmds.c | 39 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/block/monitor/bitmap-qmp-cmds.c b/block/monitor/bitmap-qmp-cmds.c index a94aaa9fb3..175d2ca449 100644 --- a/block/monitor/bitmap-qmp-cmds.c +++ b/block/monitor/bitmap-qmp-cmds.c @@ -257,20 +257,15 @@ BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target, HBitmap **backup, Error **errp) { BlockDriverState *bs; - BdrvDirtyBitmap *dst, *src, *anon; + BdrvDirtyBitmap *dst, *src; BlockDirtyBitmapMergeSourceList *lst; + HBitmap *local_backup = NULL; dst = block_dirty_bitmap_lookup(node, target, &bs, errp); if (!dst) { 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 +274,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; + goto fail; } break; case QTYPE_QDICT: @@ -288,29 +282,34 @@ 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; + goto fail; } break; default: abort(); } - if (!bdrv_merge_dirty_bitmap(anon, src, NULL, errp)) { - dst = NULL; - goto out; + /* We do backup only for first merge operation */ + if (!bdrv_merge_dirty_bitmap(dst, src, + local_backup ? NULL : &local_backup, + errp)) + { + goto fail; } } - /* Merge into dst; dst is unchanged on failure. */ - if (!bdrv_merge_dirty_bitmap(dst, anon, backup, errp)) { - dst = NULL; - goto out; + if (backup) { + *backup = local_backup; } - out: - bdrv_release_dirty_bitmap(anon); return dst; + +fail: + if (local_backup) { + bdrv_restore_dirty_bitmap(dst, local_backup); + } + + return NULL; } void qmp_block_dirty_bitmap_merge(const char *node, const char *target, From patchwork Tue Feb 22 16:18:33 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: 12755668 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 83946C433F5 for ; Tue, 22 Feb 2022 16:51:00 +0000 (UTC) Received: from localhost ([::1]:48104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMYNN-00050T-TH for qemu-devel@archiver.kernel.org; Tue, 22 Feb 2022 11:50:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMY7l-00088C-Jd; Tue, 22 Feb 2022 11:34:49 -0500 Received: from [2a01:111:f400:7d00::725] (port=23531 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 1nMY7j-0008Rw-6n; Tue, 22 Feb 2022 11:34:49 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T3t58ydJqgNl23nwgYJLl0Qi41neTNDa9YGPYzoAoHRV7FzUgfoCQWyJc8KAqr87UE29fmaw3iRaI6riYbH5jr2oAGVoic7Wte0N1DbLUsj9587YhT0FhowZItMbqShqXeH/ykIIAWkGXN8iRRYl1qr35tlfg0uJHOJ6hxKLrb2DBK8m3mB0jv67oe2Pe06XMxKgClyO4FnBDLHrxaCO7bNbvJftOBGHdRLQ/qLGe3A1ya1dRFN1lHtV4BRSSvXYu3Ge4ybb1Ky2bVhqXyCmL2zzSkitTtctCzo7KW9GTygxqITBFIKz7VO8QOC3QIaeL2wL/Di5SXxvlVns3Ok0hg== 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=kltBaAL+R9c0eB0UHbxV00rvSM46I+fUu842Tt7/jic=; b=eFlsStu2FTG2qqw028jPqCUS0y1OCfVQf3m9ZJZI61XX7ET3Hbgm+fGLsjT0OZF1w4ZKgmIpQEghesRKwfTwYta/Ryp8riEIQdZCr7npZe6li77+PGFhdRDOsBIgXn++5o87S8MDm5Ms2ui390OU0/WhQdVCWqHWgx9ULb2ApoqXb6wO6g6No3+8+eXLQTr8OBhUGYyFKPBI81iz1QQ4xJluV1A4dszLyQ+vDzedOj/v14Ar48f8AhkzwP+5GkBnNYA0b1iS0k5iNwGHO8xisMvgexrnLp+gbMu6V8D5kheYfSGDvY64Na9eQH62jlsijSE1hOXJYMoLqeZ6qyKIFQ== 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=kltBaAL+R9c0eB0UHbxV00rvSM46I+fUu842Tt7/jic=; b=pYXDFkPyIi+38hO+hIcgO+OprNS33iseKqvimGhUrgSI0jx5yqfY6IUsxtb9a5FbhlEbp+YAlZtUQDwSW65YG+rItaW84PFCoj0CnriDUwEcc1a0/+if24F8SF0ZVAJ0ZEpEZ3VcdkVPIwrN+xJIh/eeOUSVBZLxPTXPVnaRwsI= 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 HE1PR0802MB2524.eurprd08.prod.outlook.com (2603:10a6:3:e0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.17; Tue, 22 Feb 2022 16:18:52 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%3]) with mapi id 15.20.5017.021; Tue, 22 Feb 2022 16:18:52 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, hreitz@redhat.com, eblake@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v2 4/4] block: simplify handling of try to merge different sized bitmaps Date: Tue, 22 Feb 2022 17:18:33 +0100 Message-Id: <20220222161833.1453641-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220222161833.1453641-1-vsementsov@virtuozzo.com> References: <20220222161833.1453641-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VI1PR0401CA0023.eurprd04.prod.outlook.com (2603:10a6:800:4a::33) 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: 1b86ab1a-5265-4cf4-0a93-08d9f61f041d X-MS-TrafficTypeDiagnostic: HE1PR0802MB2524:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YuCi8nM51u5Mj0nTjL56yzji6v+1oF3p7Y7HoMCGLUHijwGaqXA5Z1HADm995PqHSbASJWGqwpvqizamIQU8WE1V/fEfNeW8UGkB4yFIwlJHQoDMoQAPAc7DThy1uEXWwC6YImHph7PY7DFjdsj5dOIlq286i6L+gEFuS1Zb+MwbyEDICmFUBN6hGyNO7kIqleaOsVM5rEMemyuHmyVL7l67vcvZO1b3ba2ic/gkt1P4aJ/g3IFjYwP+fDg2Kuihy3nDl9ZKNPq66A5cBfaZqhtUmPhrEatb0zC41Kwz35VRamvHJnP9RxEs31h0JnwtmBj82oEvWLOLOlJUqMokenRz4NOBCpPyd316nXT+tH1La7sqlMAn2l9uJPxkL6qbxyyePpwqfP4leKJDAmLiQWUPy261M1yBMD2fJf4GzsSx6DyccDivtFCzOlMbpH0RHW1tEnwY5Gh6Wj+Ar7cBskaALpVr4yTRoDHnIBWELoNVf+MC8vjgvfGQmFhXuYBsbjv8fCuCopqXBSpYfm6gETAuMuYb4TbdEPMMpDuEkqhRoaYwFOAj5zWjF7Iibp1hhe3SnHPs1qV7sfghM/obIhYFuR0u7YiEPkvEVBXWcvWB9H+F4T52OOyoocxGIF0KFOn12MSS0x4ZLedAb58H8C7SF550jHvWdKsDtVZe81rikJ2cIcRZ8pvmrudNLpJwBo2fnOCLU4vgAVaKwkAAiA== 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)(66476007)(6916009)(66946007)(26005)(8936002)(66556008)(1076003)(186003)(5660300002)(83380400001)(4326008)(86362001)(8676002)(316002)(2616005)(52116002)(6486002)(36756003)(6666004)(6506007)(2906002)(38100700002)(38350700002)(508600001)(6512007)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 231JdxWwCbiBkyBPb4/BJe2MUEkDvAbh915FgDvJsskz0Jjc1o6Eb2fF9ZvjeE+YYfFeB9BuXv7PNJPTZd5niQS9B3+TMA0oZa+00uc8ke2Ya8ViKNJSlpzHNLGendd7TD2X1OA+9+pChuR1CuyBkJ3mitbuhBoFkdWoLy79dvzP9V+/JBvpYlApC06Vh04LjW+MtaAwKQtIlNMHqQC86llI8NmG1z7OYvP9bTldaZ22/TX81ZQ9KGd8Sjm2g0O2w78I1r7Gt+EgN8aYicp/kONgG6PuTv85NpXxDqPDmfSwthnK4ddwjIhPF5SCSR0UqVt/ouya4a4rOZds69PtA4gKJyCEaKtn/nMAiCOuIKUdJ/HglBxqDFmP8V43D2pqjjprY2g/VdJXE6g1PWsshctmj+i3xUP/3Um3LVHHMFsbV4ztMpazNtKPhA0yBJzY5IKxKauhtD1ZW2hGQTg7DqBv7R48ULLgBdNgLqMikgO3QWFMq5d2UT8iO0RDNeMOnNSYE0tJ+PcMVBx9eFycxV+v8PRI1N68tPjCCM/kRd6udilD34ZpS9e/FXgTQ4tP2/Gu56kiwuos0u3kDduYc9lQXkZckNwn/FHznJ1OMoROGPvWPDjwpsmzFPlwCjlNDyf4IzlLaKJKhmfOeqvYd6ibMKm/kumVt7z1zLthu4k2PB5IHCIQFyoGjennOiiaOP8mnyLxODlCEN180/9aRwzsKIk6e5TC04HJkL2BTvnn69szK7gt8Gwx/KS9S7zdQ/pQkmLm8IjA+v30CO8+QzNblAXfDOZyb/a9rHO1cbAkcFEPi9dDrU5sZo6e0H6505XKhqCnze9vBb9W1Uok1wLGFbAUmkwPt0TwNjjQYVpZpqanbUZTMzxzNRttmAspxlKyQZD4dgS3t0RoPbc0oPKonlbDBM00g9cX5VmNpPajrWVV0oPBQXz6+7QXgwf8MCqsdKPU40ezK5qczUuu1hGVgg9XUEWmHApoBf2SdG4p63rIzCtZlRWnq1lLRnxhXKvKZ56wLSuzJKypG9YuOasINeTHk6UEOaRY+ofstwWTe8i8Ph45tjVNNt7S51BqDOOFb7rWjL0M99P5e1ScjTpahN8VDK8EHcDaYl6yFXNJL7SGsEzIWzgmJGtIwHJcu/rxMdDB2GORJxACG3N2brDWYG5mu2riGhsJnS9FyTNdYCOmD1QY8lxkqEFu0BLfbnfqR3A/LOBvYT5NKQr29xIw7XkyrwngsMFaDzH1TudoYW0fGpb8kxzaEWOHaWvTlSfhrSfEPktaYWW0YzEjlFNzcr9iGatIFnadW4x+MvhMlZcDyMvj2wTEwDELBf63b98kg1qLEZFiO6HNaofNOM9ZqIX5kh4TmCavEyI4k8CHFgVJURSrJPDVIKKBJ73gaqw8R2Ss08VJmuOSIOF5PiYkrfq91RLyxX9RNhc4cRLawhbH512DvAy2d0jvYg5sA+aopliSFivYDhHJMFGYzFXMBp2YsenJdAZRgj9sEgYHCq6Sl1gVBrCgZk6ea2Nt/cjaNIVy2+ksHHy313G6Gr0jlYlII1D4bxeoCFWlo8keeKhFj+Ugs/eLboANoBaw94m/5hsqjBORdDgrDi77dqtDiHh+eZ8fD4z7A6aH0Wu2ixDpr4VF8ZV3k3sAfd8gWMdGgJQvBv5vUXlGi8EdNszhlIqCTXIkq4ZZ/m8BKWw= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1b86ab1a-5265-4cf4-0a93-08d9f61f041d X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 16:18:52.4160 (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: 1zIj+MAeNElRnpqC/SUwwm69olkhb+CS6kfSNvAhPY9w0zqFljeJIpZS4Jw1RtgXtGtx4mYO7c+dwVYG/+6kHnsNfJvmFc+e/68s03N/REU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2524 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::725 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::725; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, RCVD_IN_DNSWL_NONE=-0.0001, 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 | 27 +++++++++++---------------- util/hbitmap.c | 25 +++++++------------------ 5 files changed, 23 insertions(+), 52 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 94a0276833..99337e72de 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; @@ -902,13 +899,15 @@ 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); + ret = true; out: bdrv_dirty_bitmaps_unlock(dest->bs); @@ -922,18 +921,16 @@ 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)); @@ -948,9 +945,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) { @@ -959,6 +956,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)