From patchwork Wed Feb 16 19:46:00 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: 12748970 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 3F118C433F5 for ; Wed, 16 Feb 2022 19:55:49 +0000 (UTC) Received: from localhost ([::1]:48346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQOy-00043r-56 for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 14:55:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQG3-0003jT-QX; Wed, 16 Feb 2022 14:46:36 -0500 Received: from [2a01:111:f400:fe08::723] (port=55682 helo=EUR03-AM5-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 1nKQG1-0006EC-3t; Wed, 16 Feb 2022 14:46:35 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HmppisS7Ip/+zrx4YsdYW4MiWGzmUndzMP5cyeppHlrfr2vSNGHxWEfGVhfTCo7+bjx8SMP6lPE20oKV3p+ZusSo+Vas/kyK2oIdWZpz/rnEjnVROQMSIGlx6oMloP0vZEc0ZW9vdHha3rshekcXEJn/gCgtgZC6ja+Cw6RACkTz/oNSrx2g/MnAnN2s7I3cFTm/NbjfLfOd1jR0AcM5fPI+pJKzmq0VM9/VRwTrvMNsSXMI97MHroiK/vuRp9cz9hxP+wdeoXT2EzV/8ip2iyUd/V9pmxKqWJQPXpbdz08Ivx+gRwVJZLLmBZ3BmBwx7xT3lv7GkvdAwzvEPOY0bw== 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=ROBLmUnjTfEeaaULPZCviV08zafu2jajs93fHjc5LNg=; b=ECjDE6vPuraf+uiQxVhE6LqaQcmr21kmY3WsDCnnI/qIPpfpEWJyQqtag1LuOhGDg0qddlH9OzyaTPSk/9YuYglCqQlGm1+kjeWrzKZrlpAeO9W5cguBX/Zsy4ax6sMz+CN5QIHajMynbadcC/F4JgkpI/vaJ3EV/wseMAJi8aC5Z/iODcUb/BtS8kyFjtzJQ4DR7/T54LHTtR7OucFMVqvjboZKdNsbj5+OQqgPtT8Vk+avvgk1iMsfnFtyN45/V9kyHRj2cBKa0DoyG8UoLJ3OeKUOqRFNWKfmKV/7Eo+puNVTPLNc6FjQVNRtV3kcSSjoyAywB/gUwMFuYkXYWA== 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=ROBLmUnjTfEeaaULPZCviV08zafu2jajs93fHjc5LNg=; b=isWbSKqvnzhK+900enMdcJdRMx1QLzNqKMhj+WchBhFQZ95n7gX0A6HDrzlMIcFqfDgim+9fjpwiqy7JpIctcVdeb9/liNKHhoqanxlxeWkBjxaUCBADK/UcyAuZr7vPfHoFTeZ7bbb5JW2lAWBPCppgXm/1Le97zNsmxS+sqe8= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:27 +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.016; Wed, 16 Feb 2022 19:46:27 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 01/18] block/block-copy: move copy_bitmap initialization to block_copy_state_new() Date: Wed, 16 Feb 2022 20:46:00 +0100 Message-Id: <20220216194617.126484-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: d0f73111-40b2-41a6-ce3a-08d9f1850540 X-MS-TrafficTypeDiagnostic: AM4PR08MB2851:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:48; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lEaNmx+uS04F11kBbWOf1HUwhHB8WMuIpGHyaK98GdaIm3WQT1I9cYHPaGuoetKZhDDmJRnc9XRrXJEoYFkHCpMx0lLph7zi5ras2/JtCxPpdbGZt+JfXNm3ipAoA857E/WsNf7AAF3MR8ywSCricRol5zpzbFki+VcV1ExbPjPUv91lUAbTdpXAw0j6EH4PEdO6LUkxql78zwMT3UvfywypspM6WBJoW7HZkEqHPowRvSLCjFkCbPDh4Yfc/gWqetVMIxd8z9lzyV9K8vZbUWxUnMFTLjppT+bTGWRxRII36uFclxN9AQxpno1OypEq+f+PG1F7JBuBjIRaouaBi5HZ+bB9puw6gTr3VhozQUCUBOpqEaKwt9sctNxmRwgEuVB0rVsyadvkUc/apXvdv2kDxOelrk9U9ZZ+1nOlgeDTxFr4tsL9pJaz1TpGtDnMMClgNPOG5Uecig0ubkV/35VuJead9IJ5KV4jaTpurU3dNUo/r1JZ38ybWiDgWtcg+Qtbugb0xtQTGkfv2W6Ox0JkUhlVZZmhdP3XQM4N7X/2uWMHeffksMbl5u8kHORvekXpk9ydSs0GIjTtd5SmZzjeG/iqyNotxgs0n/gEUiMMJuMIgMqj62IWhR/nmQ5GqbB7ORI0KAf/we5d8AGgJ05KCFehsW/XJiM9skTMaLa3kEYInVJpIQKOVgs4RlM8IuF+usAdSedllWnA1qJ9Og== 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(83380400001)(508600001)(316002)(6916009)(5660300002)(66946007)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iLZzBw5j5Wj0USU3y3qhGkK+G3cKa/ctcUr3/fngPYvNHcHecB5QiO7qvI6sWkasXkGYCAWPNQHVr6cllB+n1v3G0MFOfrYQaVOTrRtXbuXegnWT+uXoWUyZCK7onhWZ0tfKYGvVcshxrmtHpFa+8b5vuLDjF3Js83fLvq5OzHy/rDhcdvXGu6WTbRVtIfekbrWB3xOVi6HFVsPkLxTfZZFSHomMx4QwMCfbqYP9IzDuPAFFWJsACuPhJ3MK2cJmjdj48nIbKA2rTcN3sTVOlu2nFSHIZ0lYEpTH0RW51lCnhvoVMPI9QdwIhD4iDP4YbbB2jIsXOIN//+IXtpBRFMcrz4FGaSPr5QH3B52ItpZeTkgYnjG7RBIwioRX8dEHKvjURUhTXG/UMOHxhIbOHuaiw3RmMzzprhJNgHzuON3DPG9BRPXCc3muXAkr6PKkpe/w5s8TpMau3JNZIWzrg2cUjU582Abcsn8umXL+xixqspFQL/ZVZvapHbOT7xcbhQ7ZIhfFTR4vXPOQSeR70cpykNb5kaLiua/EOcUnWzZngXc5f9rsZYwyqCDSq0jqDZ5wqyHxb3qHR/A7CTly5YREOiO9wb9AJ12+VI9D5nCF0vlvyJO0MYRlztgXlplbC0cFEFGQeDMvzvoyyguOsq3rdBADgqrZPD3uD6p1s8mNDSH0Eb6P8Sv8SoUAV7IBcUHhvyxZHuqUtTXNcvZffRWhFJj1w6wISWWLzAqSWQyfeuQWAENllSySkRTMVJBAgBCjvRV2XFtbJLeJc8HpOxm0LqUl3xXWP8ttYrYy+AE/IlhzoPkbJuqIxj6EreWcYyB8VkRPq+bLTpmngZnzvePuXMfNTpyiwpqc2FiksAwJQ1s2bxnRoHIabVRUkhomJO8fUv/djFC8a79G5g+NXSvBRR8Alw/1TR2wfMO1XKqXjMSHxkUas0jVCw8lGthZHOnpXy0uiAwlpNK/6K2vlkFUsD1l0bifljLVLcLysE8ZgvBnI+BhjRnYxXgrOFhWTk1lkVZRbrMAr1QcU6uYDIBGZEYSCEH/ypfJSaBsClC2cSNHvfV9ITMlOiZ7wmZOyZ5BFc8+gBgPu+Bz/IRcv1zio5v/8qDQWWcyWY40RtYS1LmkMmcVnaNK1SWGD/gxqv1B5tE+EqDpQWiUD3ubi8t4X8BskJavCPmRn1tMBU5+Dvt39GhEG2nlGJYVYMB/1t0nhmSxXZNeTMGZOP/24JeqhsdPiKxN2VyGhu4f8dTY/iN9D/a7RDOAqabHtw1lDnjtxQkP/pJo5iO8ehfo4Ev2BLU1PtHdxOieitv4B0YZh7kEj0P2iRRvDxoTbj4HX9Jg+8jDKJVY2XKTtFSK22zRrX/M3jHOQ9iFNNdVETWCPhRlol0v8AOU01GNA8CpAtns0sRl3FXgO3TRFJ1oRoV0sbJ9JdMYNMN7DVCDthe6lHargqiiYDBk77+i0EEIkumrfazzg/O3IvX9EB8ZQCwg8gB5xAIFqmQXXMSa6LfSXriIiOdhVq974maQ3EKdqR+s2y2U9YBs5XGeW1LS3T0fOcy/1KawoperF4h2ot8AzNdMGCstVqQI3N8rvu659ki3tmA3H5XvHLsDUKsuRFUoo48FZtbdXFCVgItwTyp/EXFmd32tUVkRnNUA3dYu0WF7eTRiJ3JNk2QtuIZ1Og== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0f73111-40b2-41a6-ce3a-08d9f1850540 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:27.2745 (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: uAJ/+cLz7/K6COLrx34rnwhtYW1U5XfzGfOaly+VqXfqdNT9pLihnFjrAVhLIj7oCzEHqQJcMjGCqRu8XkWfB5zpHpB/qqpqUg69ZOhOVxo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe08::723 (failed) Received-SPF: pass client-ip=2a01:111:f400:fe08::723; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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 are going to complicate bitmap initialization in the further commit. And in future, backup job will be able to work without filter (when source is immutable), so we'll need same bitmap initialization in copy-before-write filter and in backup job. So, it's reasonable to do it in block-copy. Note that for now cbw_open() is the only caller of block_copy_state_new(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Hanna Reitz --- block/block-copy.c | 1 + block/copy-before-write.c | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/block/block-copy.c b/block/block-copy.c index ce116318b5..abda7a80bd 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -402,6 +402,7 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, return NULL; } bdrv_disable_dirty_bitmap(copy_bitmap); + bdrv_set_dirty_bitmap(copy_bitmap, 0, bdrv_dirty_bitmap_size(copy_bitmap)); /* * If source is in backing chain of target assume that target is going to be diff --git a/block/copy-before-write.c b/block/copy-before-write.c index c30a5ff8de..5bdaf0a9d9 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -149,7 +149,6 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVCopyBeforeWriteState *s = bs->opaque; - BdrvDirtyBitmap *copy_bitmap; bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, @@ -177,9 +176,6 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } - copy_bitmap = block_copy_dirty_bitmap(s->bcs); - bdrv_set_dirty_bitmap(copy_bitmap, 0, bdrv_dirty_bitmap_size(copy_bitmap)); - return 0; } From patchwork Wed Feb 16 19:46:01 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: 12748968 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 E6BB6C433F5 for ; Wed, 16 Feb 2022 19:53:09 +0000 (UTC) Received: from localhost ([::1]:41238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQMO-0007SM-Sk for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 14:53:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQG3-0003je-Q8; Wed, 16 Feb 2022 14:46:35 -0500 Received: from [2a01:111:f400:7e1b::707] (port=17600 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 1nKQG1-0006Dk-Pa; Wed, 16 Feb 2022 14:46:35 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TMWk0jVHQugcXZRclm3ZBEr3/4EF9TC34hLcbZXI/On6ttWQz+xtK4Rn9Jag/VFzgL729eZoitdx0HIo7qNOeYBvFox1mXfrMwCjO2W08RfmTVYtEzlv4m59lvYHY/hml0mAFuX/ZbXjq68msArxZwdsHPz92O/Fvjs3d/ZxsuHAF3HsToLHxqEnDx/B9S/ZRKVHmBujbZChO+N4KcQX+rW/itm3RoIG1exB6c5SJWk1WCCBBg+nz0AGXkEymxOUPc8H3kEN+7RMzEAgt8z3srzwM0rd0QNlR85WQe+BdR2+9WSJaG/Ih85l905kY/qQRxmnil4LxHdMLXP8srbrgQ== 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=X78PVxGgK08FWbBD6xjVGoFrCTkcONKnJlKOUeOIEFWmQaGbf9NLh+lPKTNny5VrGZkyl8pxgdE4KlLZIIOt3HxEPD+g371xtc8alahqaoMr7C3OSr4Hw01nnKTfiEnLIw951jzFtXT5alCeOaMtJM3L95AHwHbFXBk216kOWj+c6u1H0z1Shb9TDbELu7IO+LwuuRJoOGzh1NdW9HdjIGnYEQJ1M/k4YCH4GPP/R+okghusjftxJLAskLdSfkG7ZsHNkxPv2LiR4jbwBIRLVongMu66QcjhEclBoPm23yCIpK+w253Rafw9NGxZjnLN9KWisI7iwLWFhWalv4GV3Q== 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=Wi/EFvt/m9/NfYDSTc7KAkqd7C8XzEqG2u1HuvOUQvZsNs0YZs4HIttrWfWispCPpFp51CiaqzWS2kyeaFnjGiFiHs4S8mnI3hSAHqNISu4R5iVJzMWEgEGILIA0A/N897fUKx9m1bFWehgAQ1M2bJrWWe1OnXQ1F8ETMFXcMgs= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:27 +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.016; Wed, 16 Feb 2022 19:46:27 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 02/18] block/dirty-bitmap: bdrv_merge_dirty_bitmap(): add return value Date: Wed, 16 Feb 2022 20:46:01 +0100 Message-Id: <20220216194617.126484-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: e9dde527-aa0c-45d6-9ee1-08d9f1850596 X-MS-TrafficTypeDiagnostic: AM4PR08MB2851:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:431; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HjkpVEGjGrL2bm4XRX75cgiTANTyy4ch5JZnyyrzFvvbjhgy7oLu5n3dz0i/PobdJJI1LUdmn6N0LIFij0AfbLX7hF/8YdHxxZbawMk1M6TuePawSBKDbSrIs6Pp15WjBS/QB8qd5S6aI2uB8mI+fXRYLIqGHM1uoHV0k71CqS34+pQQQRBgw01rd9BJqU5wFTUay7RVgUwDLXsY/KR2FfnisWIovMcKkYTLl+lrhFjn+spk2oy8sI270l2TMzkbbxfcw2Z9a31psjJwaVKNCp+BqDHuj8IjDqLCrP6COKSsZwc2q7C1nEcyXzRZBORE4GqLt9Tn/oqzmcBrWE/hnTr5lflEeGKrfiTk41hapqVcAae22FI05sY/PQmc3SfzA0EoXWZ6eC1e0BOviba/fPIh7bNR8+T6Ph/lC7pcb8m+DHWLmQljSNDedQbuBEfa/MBq5maKjk/pZnB/hKtcvAO6IA6kcqzKqXQ+1/T0d3QdEuH+DcAxwRXSBhNjViQpW8+XVrpPcNMKPKuMem58m57aCsyDxVyWsNG58dohpZb0gbqUKqBJp2F/Ux90OfPVvsJZFWv8P1ce+wnrzW61QcRuwHui61ImdN1eQxK151YJLAocQKqyYCi/wL5OXZI33hIyTQydbmGu44JuR8ZIfib0GVlr/+xRqKVNLRdM+2+YD/QHdeDd4l++1MWw91sQ0eMpi8v8rNOOjIzG34nzX53ZVVgeoWv8IrT9et7DaPQ= 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(83380400001)(508600001)(316002)(6916009)(5660300002)(66946007)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(38100700002)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tk4Z5iCJGdBPy4SyE8w6msEKpLkdjhxhgadcUuNstEi8xF5iYnkIucfRH94BFWSw2XJzCtP8vwYxJtpmcvnSlXx4Jee2iPwDxDr7+npYI5FvAaqIBeq/sQy0HhzF9VwGOTxQIlSbujK6sAP+LAeumb8r6Kar2G/yEgT4Exhax19/SQO4gJirCFxwv62F90dx9OKRSPna+w66NVnPHYtv7i5jd5GZ7NZzB9M1oeOYJdLg9AgYo8R7cWlrVPxiah5cHop1+TQGZwn3cwSzcx/C7wdkB8h+sR7mcRQ8XkKnOAhRTpJSHX2MsY5qrvLnuO6OOEusSiFscSVUiYxrLktJIFe+rx3K+rOzUbyfkzFfvGsBL9iNjr+P/sZsM9m/VU6gRJAY/pgCEvPJo/jXwMZ5O0J5sPOdtVNOmPodJ0zo9wlt3SAHcyMf/ybfID8KUbYhshDSxIHIPSuO0pvNGSUR3OhrBZmtvmIH35ob69HZ6rltxQxoXPZTRDQnAo5cUxez6Y2StI4qehqre9vP2zsGXt/9ojxfei1+i4GUptppHPTeqT2p04MN/VMtPkuVVGibjSJv2DULxdX16oOb1scFLD0ZsnjOxMg2EQ5nFeIvrzv9VXas6JpHA+mzD1kVwTJWW44BnHPu0MPSzljXeeqmwEdm9ffStbfVkMGpC4N4hgcGse+bEQ0nGxV6PET5XH5JUMzm6qWdEVS6vkOMBxpD8OWFDPjvE5YTL1bfO9+5n5ScFZZqwi9xfwuYgQmBGOsmdzAK8y+ARtFWD4kcNyH5uZ6gsZTz0K8o4bn19mhQVhWFsDXsaei7hWGZBFRNT/KPzZMNxfHtwmFIsMtb3wrNCGWC+7iAtm/hyoiuA8ACCfqWfK6TohFVqI9kXivswXE8TT4Rn9G4yQh60z9wqYSjSgXE4Kq8gTcLMDMmh+4C7keERETtcobL4ldvuA4qWbNgqKLTv3+OTP+TtQM/mPt0hLmQ9Y173wwDPrGT8bAIce6UHp/cfnt4fmMtTKJC0WVMA473jRpVcwTygXcCDQfigYxgte0t2vC+O+cGSvTftP4Eys2Id7DlHefzPd4lHEjaT3o4lLY6Sw149PhoPC47qumuBPypUHYnMC85Muv+EtgFK5wHc9y2PGSHn9dpXc7PU0u7M7+Vm+aDTV6tskqim5HEYUwQoIXvWiDje7PAUN+4Od4wTxzVAVBI+H65HhmM7Gujv0QzGVBo6rypk0TS+J3dZc/CcoORMCLSWb6XQuSK+YWLVIxjCyF0j8X6suN9j0CnCz3HakNBqwIhdoCCIi9SP989HC+RVFp9NcjoBbW5q0CiwEg+6V8wCx5z24DIwC6pHn99Eo49kNKOR+TOviM7s6GqOi7VVy1KR2nm2PmniPw8+u21IXv74qlA8YZJYnW47DPIn0XvU1hq+twEnOLl2r7KhMTG/sH18xSUTZNRFTM4ROoWnH169dQ7AWepO661N922bc95AYRTeLXDAwWKqi4p+T8n8tZV8aUvcwS8b6GjlIQiCbHB/ZXWHT4v+qdBGbdgG5i0AWzaiM0fN6N1LN+Gg+7mf3PmV4r8zT2mK+XDDodYcnSzw6+6NyrB+KrYYiBbYnHJLSsRr36GE9V6SyTS1XowopW/P+wo9yalWnjLWmD1jw00jKoZluOt31vODzl0YvYJKeU1VvlujQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9dde527-aa0c-45d6-9ee1-08d9f1850596 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:27.7430 (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: aXhrh7a+lbcgtFKgGapcUQm0AR3DHeYBSmyzmMH5ydBaMgMXze8yeVM4cyGoC4JeEEkIb2ASzh4l4Pi4HZuQKag2wd+6eTBj3qcpkGWAIk4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::707 (failed) Received-SPF: pass client-ip=2a01:111:f400:7e1b::707; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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 Wed Feb 16 19:46:02 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: 12748971 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 4899BC433FE for ; Wed, 16 Feb 2022 19:56:04 +0000 (UTC) Received: from localhost ([::1]:49264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQPD-0004iO-6a for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 14:56:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQG6-0003me-Iu; Wed, 16 Feb 2022 14:46:38 -0500 Received: from [2a01:111:f400:fe08::723] (port=55682 helo=EUR03-AM5-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 1nKQG4-0006EC-57; Wed, 16 Feb 2022 14:46:38 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KU9y8vVumbaPeqkGDmLAnGeQYmyoZXU7NgY/C2m6ufyDPYJphovf9fYQX1idAw+b0rI2ByELbzL+Hp6Lv4aNt56unt5vnFT6eywg7nV+dXhJ/4RNkBTdXBjGASHHmxEzoIiJeR29AIUoGDLo72R6f2J6hIPiReMR6q6mchT5V58CIN4jz78Z51VWUeznpFTqu2R/OHZwX2iNAJPSjSWQpnYgJ4r14z5PJkxK7umy31oUtxgwyc1cZak+0z5MFkFfxdGuR+tDZWQ3MLUOhti6NKifY5x2+A+jvaBrmt66KYzKoSWX4lTNXbPFpwRT+2kNUVlr8S1ebAqjoY83bq80zg== 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=kTbVgi111p9ie3iLsxC0pOgHY1Obwf7KDXQPxiJ63Gk=; b=oBSugvH3RwC7Oqb0zQcICPftg6MuQSJovCxnThJW9yyepyO4MZ8LO65nEKnQNILU43B1mWbw8SdBYchmfuUih38vGBVdaSiKHrEkJ0cevqrAurDPcz8FQladhmz33fwyrc9+bDza9Op7EA1FAfST4Q2cCofr3UqNYE5UfyD5T/cN0RE6wL6sfU8V8Vgznlxso+w1vKLdeFuoEqTWzW5dxMKH1W9Bqu7ED6OwQmbpqY/HwU2SKNRaM9lN6NGcJbpXv23VmoHwGsucPg1rTG11DeoYeNikjHAiLMF2vnockP1YOzupq4rNL2C7Bds47E+NxZZs+OWwTRBeVVGjaxw9fQ== 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=kTbVgi111p9ie3iLsxC0pOgHY1Obwf7KDXQPxiJ63Gk=; b=UCO3LVZRSMvoReadm27oBaDltYJJSg9n7tLc1FkTMWHfXXGP0VqvN5O3IzMNuNL1xNsnH3CO8087y/np/KNGZwCYWdQSKFdBMY4x9MyedoMEwHXgDW3RKqWOCk/0GE9+lCoSPMS4w7Q7WR2OiHNqMoU9ZvlXFfbGFpHtDLtVL6Y= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:28 +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.016; Wed, 16 Feb 2022 19:46:28 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 03/18] block/block-copy: block_copy_state_new(): add bitmap parameter Date: Wed, 16 Feb 2022 20:46:02 +0100 Message-Id: <20220216194617.126484-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: 30edab47-f85f-4397-f4d6-08d9f18505db X-MS-TrafficTypeDiagnostic: AM4PR08MB2851:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:27; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1rJfxJJrNh0wUZ+eflbb908+p0foaLlPNRo9u7WBVLBW4cVdgJ+UGH1kgKEbRg0DVjnjo2O+43u78k4wO/7fX+xa8+w+w4wwGO3KMKKJA06xJI7qfW0D7IZpYM/WV16U6dNPGcXEUBsftHzwT2mIsueGD3XjVxuaTi7wWcf+qZjgvA9SSyO82PlL2KU83js11FHYSEaWmYrpnc6GxngBAA0fTroMR41ycaVPECZnYsm8VxLVZjJKvTayu2mqa3piC+4t36RindnHuRap2OOSBhSpXUG7lzHkFc0XoFvq6URKgJ1+ae/XD0aTyc+ts88PN7xqqO/erS8NOvYPrnB1p0/gDubgF8eUbmlxPcCx6KzFGZ3yRzyVJhyTweNz5NwZIXuQeiGaqglUHdY06q8r86sKJ3SwNDVaYtf6ZjBgPrCryY9/5+4QMRJZy+TTLNfsWKy/crhYsFosgu9IOqhIAUTx752my2e5lFbx6L7HMRqwZGQt1zP1Kga7YdvNa6s3TGzOxiL4i5eLI5oR6K/+uwD/YsJu3KrFCeOFmdOoLp035BHkbV/i7VfsqLP0BkCh8fPvJkGM0CFb0qeYLsN3zQ+EpzISeTOW26qBWLPqoXBZ8yl6re54pKSlI4dj7OH+BrdtY0IJ+2BxmmhAha/SQcBvGwQxkBIH2X/w5oeEl8IH7O3KM1PDZpoLys/Idu7bkG8t+jtxi/LVtWlI9kkqFw== 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(83380400001)(508600001)(316002)(6916009)(5660300002)(66946007)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XafbmGZ3dnQ1zeWNu/dOFncSKPz3Bg7GGs0hJzzqZLduZF9uEAyJrJwWJYzOfZo2O/bv4kKHQeC1068g5edqTwQXPTwW/8vDdJ7PjivBtpbavdOlJM6rLQ/CyK2B8UroiQWuK0kzItjQqrAZ6Wb7a+sk1DeUteloK2VsAkiLf8BnOKv0iL1LizTWqQ/bTU5SkhsF+7kd3xFNBt42SoeWRdVSE8ZCzFEgdejcoTLLxgMe9r2ihrAt5FlHieAsf0TPG8EsINl+bvw0ZbYV3kNsXSmsywpGUFLPG14uSSe7xXpHtuNZXvcWmtppFAfIwlXzNl4zJ9hHNO5o3zy7miuxHcQ5yjvS+pniEsJIK3104TzmXtAiNf/rD7zWJ1TYvYM4S3OPv7QG3n1CyDM2pMIjmWN5r6I02NjfPBjRV8kp9P/0zTlrQgStC8EFZMoCVelpEiiFn8V/uN3MzSl4011ylYj+WHJw62TRb2rQe9TAqtEazG/lZw4pnB94xJnemnQL92GRW2Ed3W1EFvk5WVDNzGukfiXljdYTfE6Cx3RRpdoH0ui5GeTmUAQsHYVxjovjqjP2FFEfjZMlduU6UzY5yVT/tk5XFr7kVuKefE5r8ljWueH9QNbjETDACRJ8y2k5dIHLuAmzAyu4o0EdmOqvyMNiwrFk8tEq1IlYnpLQB9f+TrZbckNIWWd8pWSwCVNUJTLn63z9RfEpQ9oLHCQZ35UMm4Qyve1Ws211DNQ5AvrJRnP1SyXvlnB/3v33t8S190c6UMgcUMWNGJk1AswmDx3jrhdKXzOAtg/AozrReTKbDiSUsrgoXD0zjLiRau1uAkqEIUPLQkb/g70EmU2JIgdHCQme7rHoipcSZ4fZB4QCH1IEH4qRB486ektL30iiU5gBs+bRTB/4EeDIl8Oncm37eLnZABID5sg+tFQ6PTeYYlcQcL931YEZYDA5kNPwqjK0gvgfGWXKub8Wtz7DkJr9FvSzLITkwsOrmZjVQZTHkafl/rUiV5neoFjfxF3rCL5EWj6xAU8ccfquAQlafvdUPp5R/zA1tWbRshGJK2JLk6YXm1B2vV9Ey7WDaMOWOz2CJI1YFlSSZVhCabPdSsJfLA/EFNdGRZM/lqqsJBaEamc4QUh117QqIzJA1ec+CnH/ZdisIltwOHed9w5IkYy0QUmHlL+r5Eqyh+qryIhxnTV8OIlZyh5QuvdFjRlePrqYaI6hGN8O45m+L1f6y4AiA2vfKbTMDWMGacMZBZ09pPNiBhIn9KTmY5/paPwVJKjhxBMC71DjavbFLU1n2/8Ic09kUNqh0qrpv4MxfOEAPHtIv/McxAcykoya4b/UcM184H87+4SoYR96YYGF5aFGA6BXLmNUoJdMvLnKLTy44F7p6HKgzzfKq4wxptayp5iEMs60TVCeDIAA6jl96xY3LbWVbV9jwL6DVk2hst7skVWK6SBcHmZZHjwbSCJ5MPvinHNVSzymJX4nryUGzm4NI9neq7dvdHQiE4+lv8FhvWg1RLDaQlbEp6GfrQaXvo+tWqiLUN4vV/E2e2FweXwPsDjhWsNT9tg0l0kia0YEBca+zmuobLlbzcewv4A6eZKOL5CGHVb+oQCXgpeO8EquMPoKU9spIHePO1BlduuzdwtVs0I48s0D0mx2hguPDF4j03g/M8L4oGmbCvzYvA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30edab47-f85f-4397-f4d6-08d9f18505db X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:28.1818 (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: seCIls8Qpl3AQSPhNk/XLh/XnMNFnrCvNijrWMi63+Kvi1ZYKJKrSe8kWEgamda+JU4i5Ax+l+69JnmBft4KA84jTKAvpkR5kuuOn4DsIKw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe08::723 (failed) Received-SPF: pass client-ip=2a01:111:f400:fe08::723; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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" This will be used in the following commit to bring "incremental" mode to copy-before-write filter. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Hanna Reitz --- include/block/block-copy.h | 1 + block/block-copy.c | 14 +++++++++++++- block/copy-before-write.c | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/block/block-copy.h b/include/block/block-copy.h index 99370fa38b..b80ad02299 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -25,6 +25,7 @@ typedef struct BlockCopyState BlockCopyState; typedef struct BlockCopyCallState BlockCopyCallState; BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, + const BdrvDirtyBitmap *bitmap, Error **errp); /* Function should be called prior any actual copy request */ diff --git a/block/block-copy.c b/block/block-copy.c index abda7a80bd..8aa6ee6a5c 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -384,8 +384,10 @@ static int64_t block_copy_calculate_cluster_size(BlockDriverState *target, } BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, + const BdrvDirtyBitmap *bitmap, Error **errp) { + ERRP_GUARD(); BlockCopyState *s; int64_t cluster_size; BdrvDirtyBitmap *copy_bitmap; @@ -402,7 +404,17 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, return NULL; } bdrv_disable_dirty_bitmap(copy_bitmap); - bdrv_set_dirty_bitmap(copy_bitmap, 0, bdrv_dirty_bitmap_size(copy_bitmap)); + if (bitmap) { + if (!bdrv_merge_dirty_bitmap(copy_bitmap, bitmap, NULL, errp)) { + error_prepend(errp, "Failed to merge bitmap '%s' to internal " + "copy-bitmap: ", bdrv_dirty_bitmap_name(bitmap)); + bdrv_release_dirty_bitmap(copy_bitmap); + return NULL; + } + } else { + bdrv_set_dirty_bitmap(copy_bitmap, 0, + bdrv_dirty_bitmap_size(copy_bitmap)); + } /* * If source is in backing chain of target assume that target is going to be diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 5bdaf0a9d9..799223e3fb 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -170,7 +170,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & bs->file->bs->supported_zero_flags); - s->bcs = block_copy_state_new(bs->file, s->target, errp); + s->bcs = block_copy_state_new(bs->file, s->target, NULL, errp); if (!s->bcs) { error_prepend(errp, "Cannot create block-copy-state: "); return -EINVAL; From patchwork Wed Feb 16 19:46:03 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: 12748972 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 CE738C433EF for ; Wed, 16 Feb 2022 19:56:05 +0000 (UTC) Received: from localhost ([::1]:49334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQPE-0004lK-Gm for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 14:56:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQG6-0003mD-BW; Wed, 16 Feb 2022 14:46:38 -0500 Received: from [2a01:111:f400:7e1b::707] (port=17600 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 1nKQG4-0006Dk-Gu; Wed, 16 Feb 2022 14:46:38 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gvyYKLYY4zwncIyN4kvY5LIzh8m/wNbn3iFf8Pa9tHyAnfq0+gU9TxIcmo7zWNe1id7MCGhhqwEgafTP4EZYq9MHySrfsGluPRyZomc546a0m8cgrQ++0jEaSNKp+sJ1r1VWJPHuWoTv7AEjj3E6AUeAUuc6RPwx2N+VhEBuedeLMAgpt4uw9iqZfMy4XFO6zRyKQ7CGg8LKuy9YShbgGJxTmrBU/6j3p3NndIsCY7VnGUiBnJMdjKghHUZRPDJGkEESSYV+jvQunqg46/T+GJL1DTHpP42yLMOJA6W+erKy9AVSoICXzKFhdWLnhNT/Or/TgxVuW3J7FHtJemXRuw== 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=pSeJFcaR+Y9z/xfrWpjzrvsrjHMBseTfOpFHi1tqows=; b=cDPEkj1sSZxfMwcvnnhhQi348Dg8MIA08MXRsmld3GusuNPO0SglCucm/2Mt6LR+sTg5CBJBzVbs+vvI/Xg5NW21p0dsK7g2U6otz9EskWfa+9Bx6IHXIDysNHycviFjd2/bXHvPjUtScdd1pu6P0KAUyCTBMkie5MSrgPVL9Eq4tDBQbAjFfRCpOn4nFch6yMO0Bb+8MJJBdXyFM/4NIVfqOjm/+PAKSWd13mzhNCcp7Qtw4BZdO2eISJGrWcvNYdiLfce8sUSMNsmtwDBU5+CFhvtqEV5Z0P8cZdQ3t/k6qORI3MuLCz9T0nSNh6YdplctQJwFXVbc+K9oVin6JQ== 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=pSeJFcaR+Y9z/xfrWpjzrvsrjHMBseTfOpFHi1tqows=; b=rgOV2K/O15yLywgl1ScgR6JGyjYbF1it3ulmlJp2siiqMb7alYKylvB1/tzSZT7yKlBGI3Ge0P0oqBh19fHMBhGbwzCbrd2BGeLJSKKohQ5v3xuYxvcVtEPZfzHwfCsd13AbnN6c0Q2LzMpsydmE+TrWTu+vMLUz52oNGMcg6W8= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:28 +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.016; Wed, 16 Feb 2022 19:46:28 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 04/18] block/copy-before-write: add bitmap open parameter Date: Wed, 16 Feb 2022 20:46:03 +0100 Message-Id: <20220216194617.126484-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: 19aa0161-22ea-4ff2-b1be-08d9f185061e X-MS-TrafficTypeDiagnostic: AM4PR08MB2851:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:262; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 34nRb5rbANSMRJSSbRGKNlClyN1/TlzQU8YbEVuuF+DkC9gQljW+eq5rKmEbsAZp2e3cxP1E823Pksh39cZ+1BCWDj4D9hhjzlpmMj7UoSNuOsO2Lo7e2pyL/VPTp74gF3G5tTX8nzO9X9M8JMuFA9oLeHcQpArEn6SFHMUZcrAjWJsSBdcndhstTWDrjKASMoip2anuwriPvRYtYFfMSJCA6SO4VtGliYB2HFT2jz6FTXlK+FnxhsYVOCSIUKlUcKJD0kANLmy83MNSdWaTwt5IPx7E3RICcTSnUto/Tov2nqS6w2INHZKTJ6Dcy1PcPzuLWiHbnLe/X4cTZTpEj4P5BKBJkkMO6pr4zbvsNS0MmMU7/8bz4+Ftnlu8YCnRELX1BR3B+RosHRZy2qQ1hWfDBjGaSSE3dGBcbn5a1VYBwgR7Qm6Om7ib2LAYt5zGSjIv8DdRAsXJU2C3wsSMZxJWxfnQj3JWI32yCT8vSLSI26iqf55KRoRP1SDa1ByJtn/+2bHSnJN+VnU7wPhXpb9ZdzbbQuN5DHDoR/mmrkw11u9UeI3XI0VE7IgAgib7Socy3vVr543uvx2UTvrZYYySTaKQhCpTWQIvnfzEy6rUY8K7TCthpkIJg8WabGhGd+ErMxaJUbfRh3cWbk8cIOpepZOP4NNuC/b6VbpJHztAv4jypRLGDHzqYb1Ba8ABP535tbpEyJRxnG19lG0F7w== 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(83380400001)(508600001)(316002)(6916009)(5660300002)(66946007)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jW6wPnK+WGRbbRvEnkQ+V1wKJx7qVNflyC2AoPGpAM3ViTc5ZOx6MXy+ZVCcP0jCAXE4aQhik/Edanhvt+vYs6HUdGLqMIBW+KJL1rTcOtphQBcScp4O2ae0NHUVp6aBxwFo/97PChkJ0+riWLwJfeiUD0OmVWnIp1Zt/KrYEmE4S2uWwBzg7GUy+7wfEnzLErsqT/7IUWqE6b4+OMCpRlQLf5ao7m29uX8FxhqqsRQzwyku8shYkT4IsprulEYUFO6ac2MHVMK9PYg/ZJ245G0ytZi6P9fsz5wTqGleiJi3iAbXDfV6AmoCSM9MGoihhaH50j+s3L6oMJ5lyCtEKIbsV6UAQaeWWlHxr1euBdXzLOHuGdz48Jp7QVYQqZbcVlcnDkCgnhieWrhmmPu5IYJeN22aA8eljL7itsu9dw6OgchWtttXEOUiRbji8XBlJxK3kUuZ7T7xad8+FMLHg9kVvHEo30rKVmk8g4eRaH6VZFbmkPJjUkU/aGM6O2txqsb7pCNHiI81v+Sllcb35ZwUXTrD/jeIwPwMEKvJwio3epIg4j2lSKhdPHQNppO75tb13gSUFRTnB12BAY7TN9JVykl0fKQCIknuM82VEEaGkzrQC8u7LC9KlmZubD8+Qy01yvhB7lrPCt2dke5o++0PTJsc52EgEAxbEjriarrPYllcF9Oa/e4ldYo95s2OOe/HERYgdeYg4yuV5y5tpdjIqpDMSOmOj8qyLrJMQGTzZ2MxbL4JyZ5nEFT7gsCYsEOGkWN+Ai1tQzFAcCAcYsq9kbTIj2c4by0vAFoZ/SlLFjq4aW/4r76B1WJSg0G+j9udJxVhVGvfPXlHviEtPqxzPNfKVEAifGLvxDp0FTuW2qFeZ5uDfM47dbe0QWhVTaZnkOTDvjUi2bAKCFmkSVgHBZ1IpOZh5ueKoE/LnDa1duPdz8qQx2rW5TakaHtl+Zjl0Wb9nmGMAjVY72mabl26AKDj56pIdnH2yvwXL/gNfQ89iS7PkX3LH+QXBv3A1eTE0Wc3DHAJllRNVYDNBbbdHusxoi+IxBHHUBP4QTOB88RC8uxX8tFEihkk1kw+AWmWTTa2Zxv5pyV36gzzypp9Yr/+Jkze4A47ri84BbfxeL0t0wQvoze0He+t18MieG9cm4kwfi1n8YiOAG9kUbcdDz8Zr+OT6VRIbTP+zC0OZ1KUqTeHfmWXAHBkWBkf2Tbih6GU2LZUyyRwfW2FdpfvemtT5M8Ui05+B95zQhbqMiGUinFMwAkwU46Asp3gBbBSNyLyDzAtcTS7AQbI1RqAISWkDr9nQguPhnHFt3WtOz7k0jEZaigtAgAFkJ3krRXYXOYXFzdKNSrH0wBYNsg0VzEWX8gie++Sw+Sb6hNvqvm/8ne9/zRtV7Nrhw92zXpmCz7X5PlC6bbV7U2m6CklvtSBLrL1zet2d/MHNuaZGeljdLBnw/1VeJJ3o0ghq5LHvD23ewEr60DqUVqZJow+hRNOeNQmOo8eLtUYJ/3KCdfAcGzvQ46/BYvZpWRcyNsazG3IRnsKeF/EiEaFU7xxOkwMI1nwGk3+NMHq8GC+jZfsNQUgVt96vCvUxavYOfg8xQ5InVN/GgD5UnL/DkEzmQ6c+5W1xp56VVvDFkS7weMfrHJwgiZopibKEP3zcmxGDZ0l8HlR39ufT7tYHg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19aa0161-22ea-4ff2-b1be-08d9f185061e X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:28.6192 (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: eb7inxvi2pOe4Dl39EsYSNhyfIzA/eedTBXDphqOtQQGCinhoUj7F+qTvsmKqHhOUMOuWIRiJJZeFtVNAK72CfT/y6hK7smO+B2pRypRQ90= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::707 (failed) Received-SPF: pass client-ip=2a01:111:f400:7e1b::707; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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" This brings "incremental" mode to copy-before-write filter: user can specify bitmap so that filter will copy only "dirty" areas. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 10 +++++++- block/copy-before-write.c | 51 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 9a5a3641d0..3bab597506 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4171,11 +4171,19 @@ # # @target: The target for copy-before-write operations. # +# @bitmap: If specified, copy-before-write filter will do +# copy-before-write operations only for dirty regions of the +# bitmap. Bitmap size must be equal to length of file and +# target child of the filter. Note also, that bitmap is used +# only to initialize internal bitmap of the process, so further +# modifications (or removing) of specified bitmap doesn't +# influence the filter. +# # Since: 6.2 ## { 'struct': 'BlockdevOptionsCbw', 'base': 'BlockdevOptionsGenericFormat', - 'data': { 'target': 'BlockdevRef' } } + 'data': { 'target': 'BlockdevRef', '*bitmap': 'BlockDirtyBitmap' } } ## # @BlockdevOptions: diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 799223e3fb..91a2288b66 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -34,6 +34,8 @@ #include "block/copy-before-write.h" +#include "qapi/qapi-visit-block-core.h" + typedef struct BDRVCopyBeforeWriteState { BlockCopyState *bcs; BdrvChild *target; @@ -145,10 +147,53 @@ static void cbw_child_perm(BlockDriverState *bs, BdrvChild *c, } } +static bool cbw_parse_bitmap_option(QDict *options, BdrvDirtyBitmap **bitmap, + Error **errp) +{ + QDict *bitmap_qdict = NULL; + BlockDirtyBitmap *bmp_param = NULL; + Visitor *v = NULL; + bool ret = false; + + *bitmap = NULL; + + qdict_extract_subqdict(options, &bitmap_qdict, "bitmap."); + if (!qdict_size(bitmap_qdict)) { + ret = true; + goto out; + } + + v = qobject_input_visitor_new_flat_confused(bitmap_qdict, errp); + if (!v) { + goto out; + } + + visit_type_BlockDirtyBitmap(v, NULL, &bmp_param, errp); + if (!bmp_param) { + goto out; + } + + *bitmap = block_dirty_bitmap_lookup(bmp_param->node, bmp_param->name, NULL, + errp); + if (!*bitmap) { + goto out; + } + + ret = true; + +out: + qapi_free_BlockDirtyBitmap(bmp_param); + visit_free(v); + qobject_unref(bitmap_qdict); + + return ret; +} + static int cbw_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVCopyBeforeWriteState *s = bs->opaque; + BdrvDirtyBitmap *bitmap = NULL; bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, @@ -163,6 +208,10 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } + if (!cbw_parse_bitmap_option(options, &bitmap, errp)) { + return -EINVAL; + } + bs->total_sectors = bs->file->bs->total_sectors; bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED | (BDRV_REQ_FUA & bs->file->bs->supported_write_flags); @@ -170,7 +219,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & bs->file->bs->supported_zero_flags); - s->bcs = block_copy_state_new(bs->file, s->target, NULL, errp); + s->bcs = block_copy_state_new(bs->file, s->target, bitmap, errp); if (!s->bcs) { error_prepend(errp, "Cannot create block-copy-state: "); return -EINVAL; From patchwork Wed Feb 16 19:46:04 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: 12748979 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 C23B4C433EF for ; Wed, 16 Feb 2022 19:58:48 +0000 (UTC) Received: from localhost ([::1]:55322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQRr-0000Uw-QX for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 14:58:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQG8-0003nl-Ng; Wed, 16 Feb 2022 14:46:43 -0500 Received: from [2a01:111:f400:7e1b::707] (port=17600 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 1nKQG7-0006Dk-6U; Wed, 16 Feb 2022 14:46:40 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PQfs5dmjo3EGylAugLqf307JPMrt2NtoZkifagSaiLVMCkd5SV8T3YGetODTrGsey6UJMXhLj1NG4iZtItDZlds3GA9fA+BvuviCfQ1fg88jFR/dUcmC4rTq+MPrU8701uqE4z/7gfdUZWvMO7WenAzV4mE3IPuNFKHE8HQY/8jKHSamoaX/E7tM+R5FSt+rIeLi789c3r3WgaF0ug6hPG2CoSQJqk+JafPQj1xwUwx9DBx2eaNscq49VMjtcLSVh2T4qxd0/yTDe7cVqAXc4BxnpCcqOhlSvZW3or7fbJduOEi/VoldJgArEybg/clSEDjD2n3/rAfEn85qSOwXvA== 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=ca8vM/oTqjTB8b5Pi2Mz4F8t/yw948dRrpl+Gsj2CCw=; b=UNS4WaXXTMijp8exlF3d7TzqP8tnnYhYBvEz+dgSztSXyBsJ1j2nUFeSuXksRSbUiovjuUV2PKrpGxsp7ftOBQQJCA1x5xBZ8B1KIz5MmVBcl7/1KX1XynrczrfW0dRBb4DqCq7C3WsMRwyIPDz3nB+H/ZpkaL/2peHD/LAM5//MmmbqEvrDYd4HbyJVLxccOSIz5g38sZyIiF2zMxa8AaZsKbjigjSxKPrQFUX+XNKoCw3REa+nRzOPyvps0WUSulztSPdVu6mbTIDY6i6O7FzVgDjDRUstJj35OJqX0fBToka37EEoQgLcbkgz/YdiDZHxJx7DP+oz2GzO+R3WRg== 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=ca8vM/oTqjTB8b5Pi2Mz4F8t/yw948dRrpl+Gsj2CCw=; b=wvIKkPYtggrynRMRpkq1bjGT7PNOV1YjdH/n9LzA4XSdwCvWVbadvBwPsd4i0kGHjzaqD7xWdSTmAiR63pu/9LXWZ0OrPW4DUTDqLnerEogzzU4TiPuJgnvEtH/6Pd8NsMXTqlHBiayI1sNCdVprjcTkesD9QrbbSGWNYiIhMv0= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:29 +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.016; Wed, 16 Feb 2022 19:46:29 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 05/18] block/block-copy: add block_copy_reset() Date: Wed, 16 Feb 2022 20:46:04 +0100 Message-Id: <20220216194617.126484-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: 5041a10e-00de-47c9-06c7-08d9f1850666 X-MS-TrafficTypeDiagnostic: AM4PR08MB2851: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: zLgn30JjW4vJwGxlM7jkKJNEwYrG+CwFZTCHUlR6nH9FAnC6mPoosn2Ht445/IX8u2WI5+L/r5zeZhf3r5cqV3etMFVIBVqTrLZ72uJ7A9G76/s32v+9S/h7/CyEqzkSLwBj31z799a7ujRsyuPXILTrJwRfIfZ5AQUSjJy8d2Fg0l74qlPNt5G2xmB2fNE+rawuyVdZV4GZlkNqfAZXjXI6dptjzUM0rbtYRpb3EY0ltoj3qaymem3cd79F8Mj6hJjAJB+sBEYM8b0JwLrY2ak75MCXWMkO6uPj3AEecrD8tMWiyIX4gAm5FZwMMl2mikFXwZjj5EJzMeiuPe5okgfuw/7POE/pnKLx/VqB9qJ74PbkS9eXWgnVMzXWMy5sbK5Wd/aVszmAyA+kMETS2xmyD7loNJV87mO979Ltpz0Qzy4IoRwAIeYj0VD27JmPh7JvUKnCKzTX0jAFuheB0mEiLyJdMJyuut78K5mQZh5HzpMBSsh7RUIh2Fz9jFgH6iKSeUaKaQaraV53nssFyX/v+U3T1Yz9Z1k+wgDcXuGrwwBqi8DxCLefHoxengA9tNdMIOc30RVsF7U2BuGI7L0YTf34aUBN3un4Yu+vhfzmhAykrJTGH0IZSDsqLw/s2lk7bLbbX1ypmuGLJOZBedOJLc+AO7Z62BXoiQ0DlvbuGiC7mLybB63k2BsaBwz2Nlg0KeYMGr1vzVTEC/9X9Q== 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(83380400001)(508600001)(316002)(6916009)(5660300002)(66946007)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: g+0Sz2XLs5zzwRt5Vaew7fpSrphq1drdTmp+jUnGKWKnS7NaiTi/tmWIhrJ+PPHA5MRUyibkvGt5mI2ayqSQ4vceynFffhxSLLnC7XZPuoug5PaqqWoWKXR6bfHuPbeOoh4eTovT0uIhqFWkoedoXhvAAkG1gVJWDTfTMH0M9SzBJ8/OSAi0vyBX63E+SvCzHuxsoQZhAWQaJ5/soY7ufjiuGF855nhaaoP9dRqYCWL6Vn1NQZvHDSiUZc1ibaaUcrQSmJY0W//f/1ySYy6rGSv+Z1VIcb6tjQ78Z19wIEB+IcIISUgkDfNnr3/0VDAv08En3wQTUxPb0QY0af91cucBw4+cY75v4ECB3anGVoO77Px+19IrZXpW2M/dO8P28wVkIyKS6w4ESHMaJMGDyVR89VQoiiKNhea4ez0+5zj7PbN7PkLz1q1WKaZcmbbFk9zWlyj+iiAkWyAzFk0mbfXYGnyKmTgR75VLu4iTEoeCX39kblnHe7/p09jmjRErJXnqVA73KyjQ6PYWDVQ2uQIbEhVwmpZvI30rwGTJ09z5zMwgo1fNIofE8ZrGBTjI3nEetfK6VZ/WlYkf+TueJuZ16TUjWjhbWznXn+1gjpxLGduGqFQrYsi6MGQ+uXVPijKM0qQ2jHhMJfaaqeAPBlKEhHOa1lb/dyIC6zzagmY7azHTD6zeolYy7RV4UgdjzHeRLCyk03Yct6oAen+WIwNpReK99ON8g0DboVANjj3xaKAt3zX/xNw8kPV0BXipEe3ebprfWqqfw9UW8rlRzuntVkheMUi4+nmH1T4aCTWbT0ZigRQ5TDPFtNZOlwX8zmkw46JObTQtZgksrGWHypghUqx5gbGP/0ZZ0opZhavFaMU1GrkDeaS5sgAsfXpBIyu536ClWe3Y+b1+mOLnSsnlKWx3exe2T59jvLT4L9obSMGiFObywo3bRlT8nSAj4A+HTpebsRuB5UCnhJ/EYBlB2SrPeAoejta8eN3yCA+gI/i4mF1wDxqS0EGDX7YxCccWsXax399vZ0xzrMTk6jTcmdp+YBuQXGjmjGFohgQPRCMzgHsssSpMFQZp2qmlHTKWrvAaZfNoHVu0zH9AjiSeFRbJghFOcF7mHmiRFhLBJrxiL+RyYKfRiDgbtYeQ6oKZrOKn866aETmJwcJgFH93R3bmfYYu0iBIxqaapK1S5d5hNX3laWwolY6C1MLE+he9Gh8znEWtS+xjQsGIUcL/mzazJD8yLmx1LFCOnyRN3GdUj2MXzOA0T/c35x/u/lHDZQC2ud2lzBe2tLke2ck+tdOWXfnk2OtDgTqnGfo0HbQFR5IYDRKmQcrJOBw+9jInFE82PSHGB4peCT8yq+dpGxprxswjBckR3pTW3JI5ZgrAokh91MHXFuCVIt5x9n7SzkJdv5dsWItm7EBry4zr8M8MjvJswvqHCuvn4H57gwRAivMvpm/65l9KiCK6XDi5n87hOGQDs4jaFdjA2qOvtM/OcLKXm6MZee71H84CGEUU65dthk6uNGfX0xo+grv5FCcXi/2S5wjDR/nCgJcXTU/dOyjq+Z08+ykNGjlzLnSHT+7SW8gfSNCZPcMdIGgN+Lzxe3NT+MWaTF2bL+APQXDLNCAiYVBR8q9LcbP6VNPQAv13tQc4x36BgGdOs4SHZhVGNTsGl/uNFkuHcA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5041a10e-00de-47c9-06c7-08d9f1850666 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:29.1023 (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: ZnrIDEyvRgE6GIDd3+gxkDCtIVaZAU7hqlsFGG/hYDckVRzGksNifCFznyxp8Ygl3Q8BFCE0lbel3Nds+VcRpOhvX2TPVLsvk0MWGsf+C04= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::707 (failed) Received-SPF: pass client-ip=2a01:111:f400:7e1b::707; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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" Split block_copy_reset() out of block_copy_reset_unallocated() to be used separately later. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Hanna Reitz --- include/block/block-copy.h | 1 + block/block-copy.c | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/block/block-copy.h b/include/block/block-copy.h index b80ad02299..68bbd344b2 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -35,6 +35,7 @@ void block_copy_set_progress_meter(BlockCopyState *s, ProgressMeter *pm); void block_copy_state_free(BlockCopyState *s); +void block_copy_reset(BlockCopyState *s, int64_t offset, int64_t bytes); int64_t block_copy_reset_unallocated(BlockCopyState *s, int64_t offset, int64_t *count); diff --git a/block/block-copy.c b/block/block-copy.c index 8aa6ee6a5c..0834e29b6e 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -692,6 +692,18 @@ static int block_copy_is_cluster_allocated(BlockCopyState *s, int64_t offset, } } +void block_copy_reset(BlockCopyState *s, int64_t offset, int64_t bytes) +{ + QEMU_LOCK_GUARD(&s->lock); + + bdrv_reset_dirty_bitmap(s->copy_bitmap, offset, bytes); + if (s->progress) { + progress_set_remaining(s->progress, + bdrv_get_dirty_count(s->copy_bitmap) + + s->in_flight_bytes); + } +} + /* * Reset bits in copy_bitmap starting at offset if they represent unallocated * data in the image. May reset subsequent contiguous bits. @@ -712,14 +724,7 @@ int64_t block_copy_reset_unallocated(BlockCopyState *s, bytes = clusters * s->cluster_size; if (!ret) { - qemu_co_mutex_lock(&s->lock); - bdrv_reset_dirty_bitmap(s->copy_bitmap, offset, bytes); - if (s->progress) { - progress_set_remaining(s->progress, - bdrv_get_dirty_count(s->copy_bitmap) + - s->in_flight_bytes); - } - qemu_co_mutex_unlock(&s->lock); + block_copy_reset(s, offset, bytes); } *count = bytes; From patchwork Wed Feb 16 19:46:05 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: 12748980 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 CC9C4C433EF for ; Wed, 16 Feb 2022 19:59:21 +0000 (UTC) Received: from localhost ([::1]:56832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQSO-0001W2-Nl for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 14:59:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQGA-0003nn-E8; Wed, 16 Feb 2022 14:46:43 -0500 Received: from [2a01:111:f400:fe08::723] (port=55682 helo=EUR03-AM5-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 1nKQG7-0006EC-7n; Wed, 16 Feb 2022 14:46:42 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iUkB6RDovaZKroVwXsczGjdvHzCZ4hD2eBnvGEJ6a9GDr3nDS7cN5BTOt+I/AKbqKc1h6aZ9uJxrSpztqIxqYJuzscAVvAmFBauo1Ing6WGLp3PqszYcBDhvpBDFAf2xBpdbv/Zb3aMh2fNxtFvg5wD4pFbftzW8uy8dNiSmghWRLv4X0OYzFK58f7HoBsUVDBpDeD73ZH53HqyIeKQmoztVwVhMuOTKDpTj+Fjvogn6MovhKXn0Yw4h7Al7xxYdbD31abbBFEeUz2/KLPpjQnKsQyZf/JSGp0xhSn1KuGa0MsL4ipr15uTE2qwb5kmc18k0MnwDn2Oolnu00tbWnQ== 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=S6dc/zNnD3hT8qEfRXNx97O9vAyWyRj5sT9atGrrEJM=; b=DKxmCnAmHPpLkQCUjC0xYJ11A0jbX31RvDHpx62yf16NzlkixmlmDMaUSuYiQHxOo6C1PtnMZey1xc+DtLTHX9vEAAIEOhCxnCurHfLrxGx23afarWhO33/xdmnboc7WjSmDctQ8m22+ZqlLmKlsj5fIPqNzGZWKdW3W5QlLznY6np3UHxs5DqTHRsGwV90AnDb2xqXOK3NAavlRjOjHCM/AiEsnCE01QnQDK3S3ImKnC4uYITlk+YQLeHKvqq8SSjoUeJSFK+edVGCzt8elc7QTJFvTlsPwcKPihadgr9R1tja8YTJS82a83udBb7LbCZQzyBxVt3yQlvHD/uYfHA== 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=S6dc/zNnD3hT8qEfRXNx97O9vAyWyRj5sT9atGrrEJM=; b=ZqHWrLMppk4lBl5cjatE6ybAquF/qdOfVAjRMevo6lto87DtSh8SMAoiSq2H8HL6mfKPlSKl8i6FT7jQYSQ6mXlwlHMEsQpRfW73WBFGlUcstKXRo2W8EW0BU9FFJzYlCTPrVq+wyZ0F55rNN/e1YnYPqYJL1P2ZPO53Qwd+pJg= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:29 +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.016; Wed, 16 Feb 2022 19:46:29 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 06/18] block: intoduce reqlist Date: Wed, 16 Feb 2022 20:46:05 +0100 Message-Id: <20220216194617.126484-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: 82075196-4c53-4efb-2a1f-08d9f18506ab X-MS-TrafficTypeDiagnostic: AM4PR08MB2851:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XfZ5CVgLm87Fu9ZWjgQekC6HY3i2ZfO6GEaalJkmHeGQ5TpZPGzpxebfDIrhPbWBZxP/MNHhRuEe/+fZp1IWZ5kgkpEo5Snd7ThR2YpO7HqTM/7xSjBCbBMuRHnRZNY1pxjfd0fdFkT6wJS6VGpNdth4dEztMe8RqxG0OFhEOaE27kRp1MFPSD/VaJQ/IkT8kK3P8F8gBJ8rwheCASne0HUF0UkJXvncdwKrS+9ZOCo5hiq7/XA/iThK4M3VwL95kfJnxaHuYIHG1o48h6ZuPoSJl+JENMVawRQfW3aaZwjzhDdfMqgQfzEFUHJ8IlIqZL3N1FVddB6xtAEJIMmDm1UH2RD06NjUQ9xeGpGKQ5xCSbyv9QJoNf1hz2vMAeVZVvqc3QezPVSz9CAlQcgFpeoI6c355qbcuLm4ii6pxkV+VQHr3hLmJiixFyvZb/XLyBE1fN3t2a7jDvDxWn7DXngQfNZ4nNVuxMafODgFWGW7rmVHjFVLtD7HWd+LxdIokcbWHgENLYHnqJtTf20bN3piswD65jmhPpsIvd1KqsB+yYdOiBeg1voEGrt+2JkZrfnwegsKhUgcdHOsfRlTx6si0szMaofBzzQNBvQaoA4Tigup3h9t9ZARNVaJ/CbTd/LJsdjOqem+8hMsc7+GZfCAA85JQnKILweBv0OfVm6leovk4G376FzGwhGNnZxC/xXfsN0MWWflxU/6sJijYA== 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(83380400001)(508600001)(316002)(6916009)(5660300002)(66946007)(30864003)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mOmsnNTvSGFgqDbCAhXsg/H7qctAYoYvxOirku3B1vNMjJ/MLI6Z0JMsePgTsrFrUoBhr7zwdwhboRsx2rZr1Spb9jc/QtfYEuT8/alqrNggrHf8VCN7e4BGk35kZ/+WNVKaZLc+LChhhbmY4lD1PhbOqRtxjgrAuON0zLZWbUjMtdJmXrNcvSWQS2/pL5ynEFwsx7wqnrLUg1Y80hRAXFMBa5WFqtoSHQguUOh0WP5skhV0r7U3zVc//r0xfqjtfaTQPea9iZiD32boVOM2kdEJTWfGGIWn3mW5JR4gS69Fv/MuqVnZ8lkhzidKT2lUq1deUCROimwe4/tj+4JLjfHM3YlGaDBqGqyQrU+Svpxm5vSeEiNGjOSvhhplsdbj9AMyboVYUMMJ+DcsrwANM1q0I+Vo2XT5lV4gksa5vBGBFGkzRxffyxOt21/gSon6s7rgzRxERN5XpmlH3BM4S8seKd2gmvSkLW/7BxYXsM4FA8aXHFKaJ7L/zOCGh1eRqUQ0p5zwTfyWXzl1IsB9dm+aI3jItxGBmwzAlNVuUBTHfYzn0CkbXLNIaTwxvSemuarlDQgxYMlT9epEn7n3Xw2AN43Dm6XjTiOp55e2L2z4hMmMXCJykTfuP+9G8T/zIZpM+NFOUKw7V3wYGgWQ2PqS6ca+EC1/UufnGxCLZnHGRtNmdqFQqtBKCJvDnGeIGTmRGKLJJVl5ChAG9j8pk2J+ebOrcAWQlq5Yl5x3p/Eo37bPShrqNzGJjR7+sVNcfhTOXUb9dxgjbVXhzOsuuUgfRWWkEo3jHeVBRqfpmdh3xJnTgrS06bQwZ3dWcfCALGu86eaBkLP8T9gbkqe2nlFGmxCpA/eVToBdRWkNdzMsBV405U9/QDbBeb3qsODCNt2IwOTeQFx1Hhu+luBefWechcL1naJTUOP4jtzTGH90nYgFadyWvLvEblhZFGk9sthP/hhMQ2bjRGyRbiGJVin5PIgSnPnEV8iWRiXdu3NivkvKlq5VtKG+vdLcOgkXHHQdxNijwLEDIVJQI3VjipMPZTqic4lhdNZnGU13qbOw4jF3RdCP6RJEzYgjzOe/4DO2GOcu0TuXH92q9iYXFta5m28GdJThNgCrJRNU3UNL8uAzo6S1SmUjYz5VExoaWIGUnOq+COjxDwNfCbk3JqMP8XZLQ6PMtbGv41BTNhyLFX3iACnZlxK0rXHxx0hnz3DWmsof0iYjAfisO4mX18j+9H0KM3sY7U6o1EvhBpHIpq9RBpdOPCn8R0fB5IiwcHuw58bjMHm+uR89J0tnW7GuaHpx+FrZCssJu33CbymXySGNcuUP49DWhsFw2PxvOKf4BFkGsmRZ2GtsJ0sxG4+RRkCbuW2sa+kW9601fOHSTeeUkjflUWaAzRpHIVFLwzu1ACddqEJIwavi6V0LH5axHpr2wf89dWf1uDIQcqLnOctDTbbkcTbvnJCPiuPf+e/uTNQj8eQm8xqAF4B9dk4CFYY45nIYyGgeSZDHOl7TYX+sua9nwlD8pR8PbOr1I5ECmW4RwjrSGx2RTQSFMsy9QTcl2hA9a0dYGwKoS+AIjcSWlDxadc1sd9h6DgX+RW56m03uLbNdMds5hLTjESIUedq/djG3hceS2BQjm5NOBkYU7/t9r6WoDNFKE5YutXroobDwbYlbMzHCj65EOw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82075196-4c53-4efb-2a1f-08d9f18506ab X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:29.5866 (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: RSLHKvVlXnRAhDppdOfmZwmjxj4R3mAsD9imrOG4F8X74YTE440ba/Af0/bLSmuEfatVG/bJupqctd85uDU/5u/wx/rGAGxNneyROXTdWVk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe08::723 (failed) Received-SPF: pass client-ip=2a01:111:f400:fe08::723; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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" Split intersecting-requests functionality out of block-copy to be reused in copy-before-write filter. Note: while being here, fix tiny typo in MAINTAINERS. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Hanna Reitz --- include/block/reqlist.h | 67 +++++++++++++++++++++++ block/block-copy.c | 116 +++++++++++++--------------------------- block/reqlist.c | 76 ++++++++++++++++++++++++++ MAINTAINERS | 4 +- block/meson.build | 1 + 5 files changed, 184 insertions(+), 80 deletions(-) create mode 100644 include/block/reqlist.h create mode 100644 block/reqlist.c diff --git a/include/block/reqlist.h b/include/block/reqlist.h new file mode 100644 index 0000000000..0fa1eef259 --- /dev/null +++ b/include/block/reqlist.h @@ -0,0 +1,67 @@ +/* + * reqlist API + * + * Copyright (C) 2013 Proxmox Server Solutions + * Copyright (c) 2021 Virtuozzo International GmbH. + * + * Authors: + * Dietmar Maurer (dietmar@proxmox.com) + * Vladimir Sementsov-Ogievskiy + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef REQLIST_H +#define REQLIST_H + +#include "qemu/coroutine.h" + +/* + * The API is not thread-safe and shouldn't be. The struct is public to be part + * of other structures and protected by third-party locks, see + * block/block-copy.c for example. + */ + +typedef struct BlockReq { + int64_t offset; + int64_t bytes; + + CoQueue wait_queue; /* coroutines blocked on this req */ + QLIST_ENTRY(BlockReq) list; +} BlockReq; + +typedef QLIST_HEAD(, BlockReq) BlockReqList; + +/* + * Initialize new request and add it to the list. Caller must be sure that + * there are no conflicting requests in the list. + */ +void reqlist_init_req(BlockReqList *reqs, BlockReq *req, int64_t offset, + int64_t bytes); +/* Search for request in the list intersecting with @offset/@bytes area. */ +BlockReq *reqlist_find_conflict(BlockReqList *reqs, int64_t offset, + int64_t bytes); + +/* + * If there are no intersecting requests return false. Otherwise, wait for the + * first found intersecting request to finish and return true. + * + * @lock is passed to qemu_co_queue_wait() + * False return value proves that lock was released at no point. + */ +bool coroutine_fn reqlist_wait_one(BlockReqList *reqs, int64_t offset, + int64_t bytes, CoMutex *lock); + +/* + * Shrink request and wake all waiting coroutines (maybe some of them are not + * intersecting with shrunk request). + */ +void coroutine_fn reqlist_shrink_req(BlockReq *req, int64_t new_bytes); + +/* + * Remove request and wake all waiting coroutines. Do not release any memory. + */ +void coroutine_fn reqlist_remove_req(BlockReq *req); + +#endif /* REQLIST_H */ diff --git a/block/block-copy.c b/block/block-copy.c index 0834e29b6e..ef948dccec 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -17,6 +17,7 @@ #include "trace.h" #include "qapi/error.h" #include "block/block-copy.h" +#include "block/reqlist.h" #include "sysemu/block-backend.h" #include "qemu/units.h" #include "qemu/coroutine.h" @@ -83,7 +84,6 @@ typedef struct BlockCopyTask { */ BlockCopyState *s; BlockCopyCallState *call_state; - int64_t offset; /* * @method can also be set again in the while loop of * block_copy_dirty_clusters(), but it is never accessed concurrently @@ -94,21 +94,17 @@ typedef struct BlockCopyTask { BlockCopyMethod method; /* - * Fields whose state changes throughout the execution - * Protected by lock in BlockCopyState. + * Generally, req is protected by lock in BlockCopyState, Still req.offset + * is only set on task creation, so may be read concurrently after creation. + * req.bytes is changed at most once, and need only protecting the case of + * parallel read while updating @bytes value in block_copy_task_shrink(). */ - CoQueue wait_queue; /* coroutines blocked on this task */ - /* - * Only protect the case of parallel read while updating @bytes - * value in block_copy_task_shrink(). - */ - int64_t bytes; - QLIST_ENTRY(BlockCopyTask) list; + BlockReq req; } BlockCopyTask; static int64_t task_end(BlockCopyTask *task) { - return task->offset + task->bytes; + return task->req.offset + task->req.bytes; } typedef struct BlockCopyState { @@ -136,7 +132,7 @@ typedef struct BlockCopyState { CoMutex lock; int64_t in_flight_bytes; BlockCopyMethod method; - QLIST_HEAD(, BlockCopyTask) tasks; /* All tasks from all block-copy calls */ + BlockReqList reqs; QLIST_HEAD(, BlockCopyCallState) calls; /* * skip_unallocated: @@ -160,42 +156,6 @@ typedef struct BlockCopyState { RateLimit rate_limit; } BlockCopyState; -/* Called with lock held */ -static BlockCopyTask *find_conflicting_task(BlockCopyState *s, - int64_t offset, int64_t bytes) -{ - BlockCopyTask *t; - - QLIST_FOREACH(t, &s->tasks, list) { - if (offset + bytes > t->offset && offset < t->offset + t->bytes) { - return t; - } - } - - return NULL; -} - -/* - * If there are no intersecting tasks return false. Otherwise, wait for the - * first found intersecting tasks to finish and return true. - * - * Called with lock held. May temporary release the lock. - * Return value of 0 proves that lock was NOT released. - */ -static bool coroutine_fn block_copy_wait_one(BlockCopyState *s, int64_t offset, - int64_t bytes) -{ - BlockCopyTask *task = find_conflicting_task(s, offset, bytes); - - if (!task) { - return false; - } - - qemu_co_queue_wait(&task->wait_queue, &s->lock); - - return true; -} - /* Called with lock held */ static int64_t block_copy_chunk_size(BlockCopyState *s) { @@ -239,7 +199,7 @@ block_copy_task_create(BlockCopyState *s, BlockCopyCallState *call_state, bytes = QEMU_ALIGN_UP(bytes, s->cluster_size); /* region is dirty, so no existent tasks possible in it */ - assert(!find_conflicting_task(s, offset, bytes)); + assert(!reqlist_find_conflict(&s->reqs, offset, bytes)); bdrv_reset_dirty_bitmap(s->copy_bitmap, offset, bytes); s->in_flight_bytes += bytes; @@ -249,12 +209,9 @@ block_copy_task_create(BlockCopyState *s, BlockCopyCallState *call_state, .task.func = block_copy_task_entry, .s = s, .call_state = call_state, - .offset = offset, - .bytes = bytes, .method = s->method, }; - qemu_co_queue_init(&task->wait_queue); - QLIST_INSERT_HEAD(&s->tasks, task, list); + reqlist_init_req(&s->reqs, &task->req, offset, bytes); return task; } @@ -270,34 +227,34 @@ static void coroutine_fn block_copy_task_shrink(BlockCopyTask *task, int64_t new_bytes) { QEMU_LOCK_GUARD(&task->s->lock); - if (new_bytes == task->bytes) { + if (new_bytes == task->req.bytes) { return; } - assert(new_bytes > 0 && new_bytes < task->bytes); + assert(new_bytes > 0 && new_bytes < task->req.bytes); - task->s->in_flight_bytes -= task->bytes - new_bytes; + task->s->in_flight_bytes -= task->req.bytes - new_bytes; bdrv_set_dirty_bitmap(task->s->copy_bitmap, - task->offset + new_bytes, task->bytes - new_bytes); + task->req.offset + new_bytes, + task->req.bytes - new_bytes); - task->bytes = new_bytes; - qemu_co_queue_restart_all(&task->wait_queue); + reqlist_shrink_req(&task->req, new_bytes); } static void coroutine_fn block_copy_task_end(BlockCopyTask *task, int ret) { QEMU_LOCK_GUARD(&task->s->lock); - task->s->in_flight_bytes -= task->bytes; + task->s->in_flight_bytes -= task->req.bytes; if (ret < 0) { - bdrv_set_dirty_bitmap(task->s->copy_bitmap, task->offset, task->bytes); + bdrv_set_dirty_bitmap(task->s->copy_bitmap, task->req.offset, + task->req.bytes); } - QLIST_REMOVE(task, list); if (task->s->progress) { progress_set_remaining(task->s->progress, bdrv_get_dirty_count(task->s->copy_bitmap) + task->s->in_flight_bytes); } - qemu_co_queue_restart_all(&task->wait_queue); + reqlist_remove_req(&task->req); } void block_copy_state_free(BlockCopyState *s) @@ -450,7 +407,7 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, ratelimit_init(&s->rate_limit); qemu_co_mutex_init(&s->lock); - QLIST_INIT(&s->tasks); + QLIST_INIT(&s->reqs); QLIST_INIT(&s->calls); return s; @@ -483,7 +440,7 @@ static coroutine_fn int block_copy_task_run(AioTaskPool *pool, aio_task_pool_wait_slot(pool); if (aio_task_pool_status(pool) < 0) { - co_put_to_shres(task->s->mem, task->bytes); + co_put_to_shres(task->s->mem, task->req.bytes); block_copy_task_end(task, -ECANCELED); g_free(task); return -ECANCELED; @@ -596,7 +553,8 @@ static coroutine_fn int block_copy_task_entry(AioTask *task) BlockCopyMethod method = t->method; int ret; - ret = block_copy_do_copy(s, t->offset, t->bytes, &method, &error_is_read); + ret = block_copy_do_copy(s, t->req.offset, t->req.bytes, &method, + &error_is_read); WITH_QEMU_LOCK_GUARD(&s->lock) { if (s->method == t->method) { @@ -609,10 +567,10 @@ static coroutine_fn int block_copy_task_entry(AioTask *task) t->call_state->error_is_read = error_is_read; } } else if (s->progress) { - progress_work_done(s->progress, t->bytes); + progress_work_done(s->progress, t->req.bytes); } } - co_put_to_shres(s->mem, t->bytes); + co_put_to_shres(s->mem, t->req.bytes); block_copy_task_end(t, ret); return ret; @@ -771,22 +729,22 @@ block_copy_dirty_clusters(BlockCopyCallState *call_state) trace_block_copy_skip_range(s, offset, bytes); break; } - if (task->offset > offset) { - trace_block_copy_skip_range(s, offset, task->offset - offset); + if (task->req.offset > offset) { + trace_block_copy_skip_range(s, offset, task->req.offset - offset); } found_dirty = true; - ret = block_copy_block_status(s, task->offset, task->bytes, + ret = block_copy_block_status(s, task->req.offset, task->req.bytes, &status_bytes); assert(ret >= 0); /* never fail */ - if (status_bytes < task->bytes) { + if (status_bytes < task->req.bytes) { block_copy_task_shrink(task, status_bytes); } if (qatomic_read(&s->skip_unallocated) && !(ret & BDRV_BLOCK_ALLOCATED)) { block_copy_task_end(task, 0); - trace_block_copy_skip_range(s, task->offset, task->bytes); + trace_block_copy_skip_range(s, task->req.offset, task->req.bytes); offset = task_end(task); bytes = end - offset; g_free(task); @@ -807,11 +765,11 @@ block_copy_dirty_clusters(BlockCopyCallState *call_state) } } - ratelimit_calculate_delay(&s->rate_limit, task->bytes); + ratelimit_calculate_delay(&s->rate_limit, task->req.bytes); - trace_block_copy_process(s, task->offset); + trace_block_copy_process(s, task->req.offset); - co_get_from_shres(s->mem, task->bytes); + co_get_from_shres(s->mem, task->req.bytes); offset = task_end(task); bytes = end - offset; @@ -879,8 +837,8 @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state) * Check that there is no task we still need to * wait to complete */ - ret = block_copy_wait_one(s, call_state->offset, - call_state->bytes); + ret = reqlist_wait_one(&s->reqs, call_state->offset, + call_state->bytes, &s->lock); if (ret == 0) { /* * No pending tasks, but check again the bitmap in this @@ -888,7 +846,7 @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state) * between this and the critical section in * block_copy_dirty_clusters(). * - * block_copy_wait_one return value 0 also means that it + * reqlist_wait_one return value 0 also means that it * didn't release the lock. So, we are still in the same * critical section, not interrupted by any concurrent * access to state. diff --git a/block/reqlist.c b/block/reqlist.c new file mode 100644 index 0000000000..5e320ba649 --- /dev/null +++ b/block/reqlist.c @@ -0,0 +1,76 @@ +/* + * reqlist API + * + * Copyright (C) 2013 Proxmox Server Solutions + * Copyright (c) 2021 Virtuozzo International GmbH. + * + * Authors: + * Dietmar Maurer (dietmar@proxmox.com) + * Vladimir Sementsov-Ogievskiy + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" + +#include "block/reqlist.h" + +void reqlist_init_req(BlockReqList *reqs, BlockReq *req, int64_t offset, + int64_t bytes) +{ + assert(!reqlist_find_conflict(reqs, offset, bytes)); + + *req = (BlockReq) { + .offset = offset, + .bytes = bytes, + }; + qemu_co_queue_init(&req->wait_queue); + QLIST_INSERT_HEAD(reqs, req, list); +} + +BlockReq *reqlist_find_conflict(BlockReqList *reqs, int64_t offset, + int64_t bytes) +{ + BlockReq *r; + + QLIST_FOREACH(r, reqs, list) { + if (offset + bytes > r->offset && offset < r->offset + r->bytes) { + return r; + } + } + + return NULL; +} + +bool coroutine_fn reqlist_wait_one(BlockReqList *reqs, int64_t offset, + int64_t bytes, CoMutex *lock) +{ + BlockReq *r = reqlist_find_conflict(reqs, offset, bytes); + + if (!r) { + return false; + } + + qemu_co_queue_wait(&r->wait_queue, lock); + + return true; +} + +void coroutine_fn reqlist_shrink_req(BlockReq *req, int64_t new_bytes) +{ + if (new_bytes == req->bytes) { + return; + } + + assert(new_bytes > 0 && new_bytes < req->bytes); + + req->bytes = new_bytes; + qemu_co_queue_restart_all(&req->wait_queue); +} + +void coroutine_fn reqlist_remove_req(BlockReq *req) +{ + QLIST_REMOVE(req, list); + qemu_co_queue_restart_all(&req->wait_queue); +} diff --git a/MAINTAINERS b/MAINTAINERS index 4b3ae2ab08..7a5292b814 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2504,7 +2504,9 @@ F: block/stream.c F: block/mirror.c F: qapi/job.json F: block/block-copy.c -F: include/block/block-copy.c +F: include/block/block-copy.h +F: block/reqlist.c +F: include/block/reqlist.h F: block/copy-before-write.h F: block/copy-before-write.c F: include/block/aio_task.h diff --git a/block/meson.build b/block/meson.build index 90dc9983e5..e2f0fe34b4 100644 --- a/block/meson.build +++ b/block/meson.build @@ -32,6 +32,7 @@ block_ss.add(files( 'qcow2.c', 'quorum.c', 'raw-format.c', + 'reqlist.c', 'snapshot.c', 'throttle-groups.c', 'throttle.c', From patchwork Wed Feb 16 19:46:06 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: 12748969 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 A0830C433EF for ; Wed, 16 Feb 2022 19:53:23 +0000 (UTC) Received: from localhost ([::1]:42002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQMc-000818-NA for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 14:53:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQGB-0003ny-OJ; Wed, 16 Feb 2022 14:46:44 -0500 Received: from [2a01:111:f400:7e1b::707] (port=17600 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 1nKQG9-0006Dk-Dk; Wed, 16 Feb 2022 14:46:43 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H3f6DIzzLbFiipgjb0LlMR8W9ntNDBXdCrYEeG75HghJ3fSx043yToiyiexkzU8lC/4dNTKnPyMgzMd3PvglVqEJmh236okn5UXpg6yH3kJkScFCbVPQgUniPIRPrzKyhvvoLICY0EvHVjmZbXvxi1zPthlquqgooCmOq61NnU1uGz4IIkrO1Q2WbdOk0sgwk6qNKpOeZe+bAEzS3GD5TegkF5HzKDpWlfzOP4jB7iT35ekSwcf5KvkuEum7X6SWcIUmb3VIcif1pwhs5x4/iEtuHxcrUQrJnT7cAJVJOtjdbFusZaoB8I4PM5jz9iduHTxIxsDAYJ9/6au23Qezhg== 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=jJ+dodkR0FY4zseuCiVqlZI4z730SbpvR0TOEEUVAM0=; b=RHWR3eSUJysCfiDoK8COz8+WysrCqA+hBI4mJfopgaqevAK/R+m2V4paah0QI1s0KEZVRaTz1zZvu74b0hD9iBCK2OiqLUy8zPGuNesg/VXCUl/RHFhxcVog5ZT43UBjlbMuR6K7TFg2DecRuy/TKRedWW2ZYoAHcH9ax6zSf20lCWS8Gy3svZo7Lw6mjHD8UIGkEJ92RKYZuUKwxv7AIDpREFK/XauUsRHOtrWtG5tN+pwztFt9sXWgJuisTj6yskaHELxIrOw6b9KQhVMo6MvJ//G8zxbRadmz9Eo2Zm5zUyunewiJy+yJDU7+VdOXkVEQHecarlvt2qeXqRZRcQ== 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=jJ+dodkR0FY4zseuCiVqlZI4z730SbpvR0TOEEUVAM0=; b=MbdkJXeSCeW3pPNnRDYsPCdJYENj4HFnHiT2SNQAX4iI3Ruj9QcEBQro91JC5AgAqvaJOj11X/zOzMuG/ONkwM6MW7+2LaUOuyuha4qgv2w1ks3upZhe3XZidFy+pTEk+eFBQfvrgAc/MJjPGLb3Gv2IfQBKC4T7LqL5CzpPh6s= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:30 +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.016; Wed, 16 Feb 2022 19:46:30 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 07/18] block/reqlist: reqlist_find_conflict(): use ranges_overlap() Date: Wed, 16 Feb 2022 20:46:06 +0100 Message-Id: <20220216194617.126484-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: 30fa6540-878a-48e9-0d2e-08d9f18506f5 X-MS-TrafficTypeDiagnostic: AM4PR08MB2851:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:265; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eEG2PdqTjbEGINrt2gJOrRsfLBDa/gzU17QE26M2CspHfaqPCi+whckA/Ut8fHLfqRNHdfCwqGJKoo1TC2w4A1bKgX8oC/4fm134Nki27lKmAW9DQkQUmkVdNYeF711/OBS5X4X7dM6Hw5+OUPBTbCK3+QTsaMsvAZb9BbXJzu2RX5I6Y0/RLVwXsLA9+H4TvnDNRZpCwjjPlwdRkX/SioYA3yM0sMEcD2RGl++CoGFg+GXUdWnosMS1rqOMPBlODqV3a7oSM0A7fZVdXVtcL18DsABX+4kuXFGqH7sA8e3Ul1WkYc1Ku/u0fcmzQ6sL3+mmg2PU2QQl+fQLg50FXbALQfNYpC1OcgbAfcQOGMMOX9TXGnslKofw8aOcnGutomYT0tRIiVEL6yU+VKo8HVidZJMzcoJ0KO2zc4YTKLDHgnXabzcU3vja5MxgoCXpTPbs3OWpC/ar29bdB92wKmiENAmTJpBEG1EKMxrL7GMk4ayo7M6lgQB71hSgtJB4g82/vjVcRmleT/goOB2YKuN99D2rCsH5SoN/GnVXlajYiST48FmlDIw5lhAwHa5WYA2vV32ijRb9672NgjxS+ddakEyKIgWLcGHBLOoYppaYWd0oguFT/rBm3dCt1drG18TjK8pI8/9bmE2EGYzUMr84yRu9oEBlx32OVF2lwlX5SdYMaPlGQ0qI5oB2EmUWylUMNFFQADNX6ntqMeJjmQ== 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(83380400001)(508600001)(316002)(6916009)(5660300002)(66946007)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(4744005)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a0txt4pDjsl69cWHyjKj8gzi06eSUDEGWa5Ecj11di5GtaC2H8HnlKHAiGovRtbrVJh1vr+YWsCjEMV8Nt8b8w/ULKO/MgIEf9dZxAoyfTk146/B0f9C/tJJsOBN08+QdI+QVVRFncMZHmPvoRKQ0E3CnJ71341zLywbbjJXp41H3bM8RoddROnPQIM7ho3U/f/5FelTtUDb7BiW+KLmLb5Srw9Izlde1pQhVekAYPEWfNS6bLC/MpqYfuATeqO7p7+nLFk2cyd/sgzOwi6m0Fb/v9+b+pApJN3xknpMgh7OzrK+xBztugRCXrLxSCI4Lvs6cm4HzeqWZa7nmEFSDCqGWYzQsBZdmukMMp/kOjhkEL4/6X3SBvD29kpkbjoKeXARzbfPaM29BZwROIKuc3qGxCK5wU4tsEG5wkfE8Lur6l55xGSwHD5dpLArhKgb2YaXrWI4kw9Oig7IQB606EWjRToo/eH/6YhGF8ooGNrmHBUSqSNMRjXz+1sotQ2fTB40vdEKQ2ReqCGQjYLB6vfoZR4sKmWffQQptvB8IBEyBYOcuv7CmjoQTV7MYqJIjtg/CjvSs26Quy7EdM3j+8ukIWMwFhUI5wBMJzh+i+2Yww5uLwHJS4W+uaHu3lG1i2N4Pj5z9GkPrEQP7gqhbp5DaOyWMh6+Wzot8h9KxbKv83Nay8vzslwsOaJxaaTgLFch+hQDVpoW64a2z1Ti8ZrjF3thy3AbDeluO1oIb2Y8V76zkoJK4XD5o1PcDBJiVxj8NMRkSKVBLhdJnklZ6tZaGSgs7VoQ/0BO3FjYTnU6p0MIdV+kDzTtLlV5lIcmQ9dMM+ngdtxhapeen1Y4ec5GyVBtxlAxuebFE8NZImFedotffeCC39F/Dey4iskIjs9ZboHQ9BmhHBdhKUrWyL1Ut8XDpQw/qx6w8/X+CVWVSX3fbmGRyHVf2+hVW8yZtYPjx+d/+WLeSdX6eW/dtO5i1Xj7Vp4mnW6025XUSabp4eCnVth+yN/Kz8E7iHlKiATslwb6jDmqxINPCLintrUgnuja3CB1yjZ5eQ9U6SYu5otQ5ZfVvxEAeyGbtjjz0AyZuB2duY5jehpsN6EAMRoi/fm8x1/bUgtmPwmGUC2NlfcXrB+RZAv0LT2HcEx/XFQqDj4qZaR3mqwkWBitiT8yTE+diUwvklbVJFl0x/Rclut37CYmEOhqdpF+t+oWwVYqVP+qMjqBIdEjsLRAj1U5bvdaDjCdbFgqmcSm2ujoGw4T2mD876g+Qd8OsEECZZckp9+/Gi5U/SrjqpfYvDItbyWtGzdB7FOfVeaSa9pW+u4Yx1WGoLtKffFcNIGajBwUUeUT8eZFkYpWph4OcEUD6TsAqRwVnzsv8S5Ob0cpCjRZXVJ/5hvcdCUO7EaCSrxbCPsst3JSHJp84vjkLTm8wTW0RubggHD88CbCHij/1aT6QbMvc7QFcugRbc0jYJ205FLMpLigNMIEeYCqr80qRvFAvXeVutHuRiSiVCXxwAs46inzAr235u6qdNsuNbzIeyi9kqpkje0+Zj1nwVmz24zAtcz7+du4olychSJ/BJYY/4n5BeLO+mY0QMQhbd5dLXjBeGsh04YGxoRTMhmRBxH4szZC59r83FpaYt+y/lMlvHe3+pRB6XPsluV+wtQXYmJLb+Rm74yJ15EySw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30fa6540-878a-48e9-0d2e-08d9f18506f5 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:30.0240 (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: dclhk810qv/kQlHr4MWvZIM2/6qIXxPaijunQgVzriu25l6NK+MmM9P4j5Qk4WYb42dSjIQggL89KxoL7Qt1liXYZHcLP9dwmO5yiVZeXpA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::707 (failed) Received-SPF: pass client-ip=2a01:111:f400:7e1b::707; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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" Let's reuse convenient helper. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Hanna Reitz --- block/reqlist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/reqlist.c b/block/reqlist.c index 5e320ba649..09fecbd48c 100644 --- a/block/reqlist.c +++ b/block/reqlist.c @@ -13,6 +13,7 @@ */ #include "qemu/osdep.h" +#include "qemu/range.h" #include "block/reqlist.h" @@ -35,7 +36,7 @@ BlockReq *reqlist_find_conflict(BlockReqList *reqs, int64_t offset, BlockReq *r; QLIST_FOREACH(r, reqs, list) { - if (offset + bytes > r->offset && offset < r->offset + r->bytes) { + if (ranges_overlap(offset, bytes, r->offset, r->bytes)) { return r; } } From patchwork Wed Feb 16 19:46: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: 12748982 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 3861BC433F5 for ; Wed, 16 Feb 2022 20:01:31 +0000 (UTC) Received: from localhost ([::1]:33360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQUU-0004so-7X for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 15:01:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQGD-0003oy-0s; Wed, 16 Feb 2022 14:46:47 -0500 Received: from [2a01:111:f400:fe08::723] (port=55682 helo=EUR03-AM5-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 1nKQGB-0006EC-0x; Wed, 16 Feb 2022 14:46:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m/kPMsAcbEq3pgYf47mbvfpwlAwVj5DUh4GMvpePBOO1XGLQWHSvR6pCprkFauweaIPAoFbKgknSG6Mi9XXR8jKPTG6PMzcp4bSnxCvuiArylZeDCQMTgz1utgFEPLKfe1N4EBnGz/ITwGAhp6VHr7gL7qBcrsjmZ2kJTVIsTtJVWS59ukbMpcIotriBzCpPB/QidAXDr1UAwjuxeg+5oKuD+yhWF/QedCushKLlxpSPyawxC5nJbqiT70UhfjYeIFLIxY8lSGx9h8KVa8ddLzdsxC/aYG6kKejnphJXDZBr78V80+LFM5fEFFSapb7FmNTUORSCaCsOlg3LwfobMA== 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=LzU1OaVgW9BswqeWbpnWhiOAqn0FfB5qKBAUJUKlZOQ=; b=ZRKypbisiWtikBDJVb1bdPMAMfL2XhNkCseLZKX+BMqNRMpfzleA4sPMA5EQ0fsolYQX4CgX8tp0CrUDA0EJ+wxewZdZbkdiOAQNEoPtYWYNruYW+Tb05GQ43ipK+QhntOTJF8zrR5XT6PrWKZ8HkseEvcVlvbKTD/tEdlFf2HuydQQS2b3lSmxnXR1Xpnlt+EhlF0aNJinPnVi0b8f74acDYwlc62V58ghzatOIQg9LDX54COi+9jfgs7ZFxroGIMsCqw2NoG/ZN5NVz420BGnG1oHlckGlk4KS9/d11zJ5pqErey40T8x8CocpxJqnwl41hJRVCIW3Rlt9uNSPtg== 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=LzU1OaVgW9BswqeWbpnWhiOAqn0FfB5qKBAUJUKlZOQ=; b=M4OEIkp7o4QpHs3q1BP8GZxTFXO0FJfsK/zKBrKeKuucNsWUK/o4HzxCapXcRrfdP3rhtG5c/88XKvGieeIiM01fVAYgax+6Q7HxBmUNUr2YESZlp9+M278yOR9WjgvwRIR/CwKbMitnj8NuCkD9OSk0LqHly1uWwQhkPRbR8VA= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:34 +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.016; Wed, 16 Feb 2022 19:46:34 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 08/18] block/dirty-bitmap: introduce bdrv_dirty_bitmap_status() Date: Wed, 16 Feb 2022 20:46:07 +0100 Message-Id: <20220216194617.126484-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: 97aa272e-c67e-486c-7bb5-08d9f1850837 X-MS-TrafficTypeDiagnostic: AM4PR08MB2851:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:901; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ko9QHDR8p4POdA6DfbXXqvGb0qla7Sa8sky145aIKjA1mbt147eflaVwmf01IaSdwztuHgvlo4JdwyLk2LJx1CMwq/ZkZhQvEfrvVIywretUPj6yF4ZslmwvppYHzeItev+9xphv6+xXuZ0N5QAvqIL/qeeVPKyIoitdl4sfy4bqPxYynoLpe3UpTxCKEpuwKoPRzSIaB0qfshUjI01Eyv5sFVsFSUy3YQMbXB1I67RumtdJGN49vwJV303zuwlQSssr9GBzjaKZaMroWDN3H1oVch9RFvTqmXfSL+TE8ryqcBPoKqWbjM7WTdf3SGUVJ6s2CcpVIh0DdcWWpMcNUy1TchNXHdO8ldm1szz5uW4adw0AhGpbQD8eV8IJY3X00mk6ty8y0INvrgAeEWsV/ApxBoyPhkkRVNLNWyGf+UVTjYMPIXtbkpIqMcwXrWyM+21cOndmVTsbj5ksMKjs1YsAnlSzrGor8bOy0gfvDZL/gmq3ZBE3146y7aES/m6Kdn5XXjtWIrrV5j0H82YoZLE6YBNYW30X4qYXs2ROLunH3E7oowyL+4epzBCXc0UWQ76d5Kjdhyehb1Yjz/IdvijgRKPf6xedtE9/njH39LJpndx6j0Ptx1tbhoxFkSFj1dBBKtvon3327FenqLpgtLSWolSUYe8lrk/jDevQCck8ZjpfbPbkfxdH0mxv6osmnEPt/W4cpXBqXjdiozizxROlJpd6xQDnAg/l8QSWLjU= 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(83380400001)(508600001)(316002)(6916009)(5660300002)(66946007)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(38100700002)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZBFbtHJpAbuKnwExoLg8Lo4fbUt4/3mDfxZYjJA+GYJJOlCPrvJUZLZMX+8K7KZ3zW/wTs64xce0Ok0Kmcv6c4NA8mCYHBjv+jHwev8yYzMPwEs00fttDTtPvRZkmkhYFqZnluqn0jhS5QPDJ6So5LYccQoA/BAKGCqPHU/eAtpqVbM4M7sSWfhlADMox4PXciBQckyk8qLoNba1bvVxGE0jQMnmXbUCeMhmp04dmIkfGDTBYlHU6zLD7hgAX2moWlL4UlmUlj5xaiVqebGoNeLNkNN3IujiRxlYAP8yhr5C2wpN2wtZUPHWpsE4UaYG03r3amIclwCFOWtjzdfImFM2ke/K27dfIsVSQiPGxGu/nqPkA5/io35V/Z113lW7xJ4SGcteap4keBLRXMeLMuugx7rquNBQHbXbYlybH/d9byJVSK2BuyJkRI6gxWLaNLFBRpczzlnEkX9FKGcdfbnuosGlFRqjJ2+JMfUwkZGvvkBlSDcLdJELOfJr/Ta6kHpj6gSOtKQj8moNxXZsp7fjpySOPkCRa9KX7sn0uWiXGG3c3X5UENcWr/7SIC0nFqUzWlq9GljDf7JISFKwOnxpoJxSfEA+wYls3q2qNMOp4JIn4cJavY8p0CPLGFPOklfB9F6FOInP2U8SQFynGAC+oQQOyzxCO1P6sSTndVY1mUH8fvkURQ5DwEoclKEEJWaLQQxgoY033lmGyeUNgat37myNMbFY2MznpHtIzKOuyv/0kLqPZhmiIjPwIVtofcFQOd7JMoScoKExEkikdYlQHfAq0pGbv4aABTprFM3dfir+skaKU9fMRvZiq1MBHBjVmQ7buKY9DOwpdHVDqNPKcL8d4TE0TdML3nOLl/wgrKpQeTYQGWl0OPwSShgSHZXiuSRJKBGMrO/UFfsOnVIPxag0jGp/oy56yHShsGzKaQO/200mWmv/0PWBd/3AqlWuEuwiWGIkog+Fgg0TxTrdzx/bQJxKu6MYLwMMGPQNlgSWwSzsKYsyZVqa1/sIVDS3qWTpRJBeWinLUmRk+OVjXCeqng9aiK+MlIzaYPVC8T2eiWnLmOoXcVlNJFX6G95JZTLqfLvkFoUpxBJUSNu9orzq8PIIOtD8LNg2NWe/8IZVLlDKILUKmvc3Yuws4upOMm/vafkVb/5KqA/lA7qXYOuWPtirEAG/vOMIkQbIpMHp/pPisHufhYvZarAAOiamPQCZBdeMKp7cDSdae3sKI6W/1a6cna+BGOwKbJDzzL3LXrZoQrRlEneiXsqhJJR7VOU/9Kwvl1+XqSdxsFVQe6ZMaJ50R3tfZ1iwKSiDpnC9U7PHDKZL9Z9I1s5X1MtX7n68Hz11rgmDl7rVuPqXz8StrjhHAZTNtC25Mp6kOGX4riq2+BMYgrMbPq5x7/GeGEG78SAIAcAVRAbgXGIwZI9YqNE3I7ogodYfq8eMJQaOS0XslsB01mQps5bfLDJoPWnBFLzBKtyczgubdMJNNJnkFN2KhgNm6jSYB63rdYCXXLzPaVwZwqEs2M/6ROoCLxvPDkcv0+B3tOR8XIiEMTQKPls91E6g3HXr/1WB6aU9C7r0vXxtrDPvd1mptY6ZWK5Vg/lKHVe044IXrgm61Jz3uV3AK5+zKXGroS9eCt+GWeAJKnsd5hTxMGsujForySUfEkf9wO6oTmheYw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97aa272e-c67e-486c-7bb5-08d9f1850837 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:34.3716 (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: YfQND6ZZtqMceab7ZSf6SrhCgmmALXepmZ89WUGbCRge1MVK8iLQmdLf9+6vLnOGGp5811Ka9JWHFjOrEqDjZvk7Unag2Bbwy1CKjZBraEI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe08::723 (failed) Received-SPF: pass client-ip=2a01:111:f400:fe08::723; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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 a convenient function similar with bdrv_block_status() to get status of dirty bitmap. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Hanna Reitz --- include/block/dirty-bitmap.h | 2 ++ include/qemu/hbitmap.h | 12 ++++++++++++ block/dirty-bitmap.c | 6 ++++++ util/hbitmap.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+) diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index f95d350b70..6528336c4c 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -115,6 +115,8 @@ int64_t bdrv_dirty_bitmap_next_zero(BdrvDirtyBitmap *bitmap, int64_t offset, bool bdrv_dirty_bitmap_next_dirty_area(BdrvDirtyBitmap *bitmap, int64_t start, int64_t end, int64_t max_dirty_count, int64_t *dirty_start, int64_t *dirty_count); +bool bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap, int64_t offset, + int64_t bytes, int64_t *count); BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap, Error **errp); diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h index 5e71b6d6f7..5bd986aa44 100644 --- a/include/qemu/hbitmap.h +++ b/include/qemu/hbitmap.h @@ -340,6 +340,18 @@ bool hbitmap_next_dirty_area(const HBitmap *hb, int64_t start, int64_t end, int64_t max_dirty_count, int64_t *dirty_start, int64_t *dirty_count); +/* + * bdrv_dirty_bitmap_status: + * @hb: The HBitmap to operate on + * @start: The bit to start from + * @count: Number of bits to proceed + * @pnum: Out-parameter. How many bits has same value starting from @start + * + * Returns true if bitmap is dirty at @start, false otherwise. + */ +bool hbitmap_status(const HBitmap *hb, int64_t start, int64_t count, + int64_t *pnum); + /** * hbitmap_iter_next: * @hbi: HBitmapIter to operate on. diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 94a0276833..08d56845ad 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -875,6 +875,12 @@ bool bdrv_dirty_bitmap_next_dirty_area(BdrvDirtyBitmap *bitmap, dirty_start, dirty_count); } +bool bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap, int64_t offset, + int64_t bytes, int64_t *count) +{ + return hbitmap_status(bitmap->bitmap, offset, bytes, count); +} + /** * bdrv_merge_dirty_bitmap: merge src into dest. * Ensures permissions on bitmaps are reasonable; use for public API. diff --git a/util/hbitmap.c b/util/hbitmap.c index 305b894a63..dd0501d9a7 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -301,6 +301,39 @@ bool hbitmap_next_dirty_area(const HBitmap *hb, int64_t start, int64_t end, return true; } +bool hbitmap_status(const HBitmap *hb, int64_t start, int64_t count, + int64_t *pnum) +{ + int64_t next_dirty, next_zero; + + assert(start >= 0); + assert(count > 0); + assert(start + count <= hb->orig_size); + + next_dirty = hbitmap_next_dirty(hb, start, count); + if (next_dirty == -1) { + *pnum = count; + return false; + } + + if (next_dirty > start) { + *pnum = next_dirty - start; + return false; + } + + assert(next_dirty == start); + + next_zero = hbitmap_next_zero(hb, start, count); + if (next_zero == -1) { + *pnum = count; + return true; + } + + assert(next_zero > start); + *pnum = next_zero - start; + return false; +} + bool hbitmap_empty(const HBitmap *hb) { return hb->count == 0; From patchwork Wed Feb 16 19:46: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: 12748990 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 3A39BC433EF for ; Wed, 16 Feb 2022 20:06:43 +0000 (UTC) Received: from localhost ([::1]:40036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQZV-0001Ee-UM for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 15:06:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQGZ-0003sC-Cr; Wed, 16 Feb 2022 14:47:07 -0500 Received: from [2a01:111:f400:7e1b::707] (port=17600 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 1nKQGC-0006Dk-Pm; Wed, 16 Feb 2022 14:46:47 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=feacJGpDqY8X/YB70M+s7+ZhCXpbbQGxognqouUvhLdDghRFp7Bou4KSO0gIMA+HS1TJkq9IkifZGtKfBJUObnvYDuhrFk001R+pE5B7oXAETIb8cyB4eJ5LcCJyqTLo0JcULDiRY8P9unbNvY3ypK3WNuMW8GScb1f8AfMB/afpcGFreL5LAvDI4MjS8G6tlwbQhySeOn6qNiyoPyUffEUqzInI3Kkeu8n2wP/P0CC2OP/B0BlHjoDAfE8ASeSM2UOH//tX64uGRInipu6/XqIlrBVQptG3QpNL0F5jyOGQCjMii/kPWxnXXTK0vrqBcwf4Hvme5pJA5tjlnPLApg== 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=HwtkRFZsupCHj5xg46xDbUv6v3iJOt4sHv5qvsVGsLU=; b=gd7enrzqtebqk4nGGX6ZvX8MKHJcUa9LDjWCfYj9Yk1CTFx6LJx47C+vEeTbC3rClx7yJQiQsWPF1LJ6TzwmEPWh3Pe5KGqkNycrFlLZ7eRFN04BbYmkSD3r3/WTYUS1BGbdc7SZAjBOM0CMo+WGnbvtudxE5dfl84cQ9a2iXK023rFx3zClza1DOtHLv9T5f4Kyjw6eYE6GB6OUQyRSwtNfRJoPKDRJlVkZ+S7EYdkFEhtgAITaxkljriRMeCHf4QlW3eNVmgyLXGXGLwln6Em4fOMwhlEWOtE0eUFxeP2CzRFc4hsDThw9klabjbXqhCFehpxfezCn5zNE/aw4SQ== 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=HwtkRFZsupCHj5xg46xDbUv6v3iJOt4sHv5qvsVGsLU=; b=itdyTigYz45nYFJGoopoK0A5btnGMHPC0ZVFp2Kfllcka9LUFQ40mBWfHTWWB3Mthdl6wd4jjQhIcMLsovc3QK+Y1X72xAjIxBw9L62iqWFcQ+LCg4o+uAppY0uBV0CnFOqhgsDGhvruNizG/BwYYD1LJFX44+52xBUYtVSNXnI= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:38 +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.016; Wed, 16 Feb 2022 19:46:38 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 09/18] block/reqlist: add reqlist_wait_all() Date: Wed, 16 Feb 2022 20:46:08 +0100 Message-Id: <20220216194617.126484-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: db266209-abc2-4e19-1b8f-08d9f18509db X-MS-TrafficTypeDiagnostic: AM4PR08MB2851:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:411; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: louF7vqY3MLwRnBhMvoi6Y/4ND9rl03CDXyXgo4MbnoZmMXlCavuD37phI4kFB6Gnp2IjRrJHQPBdBZ/CSIdSq3uXzDKaD0WtLr6Y6yf5VwgSme05kGaagGCsDauRHXhnaBsIZnh8KtK4OQYyhYsGmmR9+OGlmEmUXB/+RhAqwsIDbidQQOt6b2Gk0qV92KMI+/qq8UmSsX2W8E0HAZUGR7/LCDDGsLSZ6DGSYAMr6W66q53/QxWr504ZJIHZCr8WD0sVUEJoWAJmwrYHjH4r8f4SJPPs0mVpGV+2FiuF2AvMKQ52YIWg2qMt/Mok0N6KwcD+j5n/Home5VX9clCMaG3LO0hKlWAEdxEBwt89pxYVQbPhq3fSc7Ln0AlJIFFLHBE6bIGBzc+g2BlLvZk9zx56v1MtDkxQJsSwcXFCgfYZNFmLQ3HP1/q71jgORE1Fs1NCltAz1RvJa0BC3HxT7+n7TAjd8PmGh3fMpm/GuIbEyx/nhqasjBYmOm4h7wfNDNo6oqHo29CSwajiwtWSvqhzZ/Hv8TyocPQYMBXVYziQj9jclOvTKNmtvUoVC3RBlOJaDGav86/hrnmwWhj3hyQK2jiXAXdpS+zYn/WKrOr6ZwHohK1rnqoPa3v3kxDVbo+d+Ln4n7dEykZWFvJj4QlhpN48J/XMjbSJwXGsn4FbSi9lsJrcTKNY7icrpNNdzHH3O8n57NBXxnRp7eZfQ== 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(83380400001)(508600001)(316002)(6916009)(5660300002)(66946007)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Du+qJanFesRzcmAJ4vYjE6f8pt+QbKppx7C1ylKl0yRzdpMqLqwcab2rBgfv9M9QU0YRsgB5V1ZocUwQBnYWrn17KAw6tkntKjrljhMjIB6vCile2P7Ds0JDj9VdVQTiF732z4exYjj+5zvoPO0ciSJSRJAHomAfJ9pBsM/nIQQ8KlpPWUG0pRtwxU+oCOV9KdR3HArWrCTSWMTkaiiuH247fl7Y2l0XfY7xRsJfQSCsp9yjl2hulx8Hai6NzE5cy9X/lq1JFXPx/w015K8mM9IJdIn3GnHIT9U2wxG/Xm150zOsL+NiD6C38yCsme6CLnhnpNoLMViIXZJPYEmYsXe8DOrkcH3ylPlZA8by+C0KBgW/5QrmGLLaF4U4/6cRF7GN35Rd21xFNY9QmBllXimm39wo7qi2QnOVWPswXB+1eZ9P4/u+xaGzOD7A5VB1S4eKQNVZYuhDlRGBQ5YLejWkMdqWySgq5ZaPEemvS+6tlZLBRU6pgv+m26j6xPNWK7sa1ym1EjnWwqF7gj5iGJD4CcOTeEGELmYjpO8y69CfMvIB69VZG2oVZC2AaNLsr0FlJFtAwHgqPxsm7MD0gfd7JOiHuxKI3aVLojvrC1vEjJOz9CO7xgPcl7amZiG4yDGfewYMV0bHq2sBPEID5WpHrAuKj6LqkEjmnasvELiwsMYLcFkrl4yJW5J9PurIu+iFwXynlvMYI5KX/E6GYRsLPOZNKDXGhDXn6mvE536fKFwHoWDU5nfAo9p02GzYMzm2y2iwHxOBVc+71c6At+GBvqrhQyiqAjZEqm6S5E4QO/gkI4EItDhT8WOAJlq9J/IB6WWejDGcnGJ2CD6hH9ZfePC860rropijfRlzC4OEMSVTz932v8KzQosOEAcNBWq0py6ct86+tVaaAuf7aoBP9GxB0ycwOSHq+zJA6f0UPtLPJ3MoxZF/aXSl8cwmUCXH/pzSic6F258Q7mByz/7CqJ7C8wj5+FbVl9mh30uWsFmzk1NjFdz0m3CAHMSnx4ezNmsiJ+vpEH0LT9h0+f70Gw8jwVDqhMCpIzR1GP2junt1x/VSTJYJLE3QqOfLwR/PN89zgNAtIP6j+ZgTNPJEQTqGKydJjFDe1qyVfejbFiaRA6rHpHsfZLC97rECil3VsfhAfqF264E1eX7/3G5vxavTCUkHrlhQ7MXHiV8pWd2t6HJwMutwDthTeqKBZy/aV1BXoCwz1THjtl8AZGgls88JJtozrnF/Z9EgGZH/utt8jHONR+KXG1w9iOYNo6Z4hF9NIoAMeDffSQ1D3GgVgZwFtu70neGxgv0SygHjYaIZD7onilvorBM1yRvqJp9JxqB4CxVG7IjEplKPLkg2WaAsDHOSrzF3fx6Cvszq/p1o+RQ2l9xhv4ReUKlZlhibUvZ0iZmG6bO24y/62A7AvkRGcxPN3Mu64JEpqUMt1vrjaex64E4bAWbuGiVhHdFD24FrCWJ186s2t4aFhVUkpzmk8HeeSxr5FRt8V8jM3guEhNlQneisFo0N+11Xhek/skvecrGcYnjZ68pTNL12A1UlJfBj1w/B5+8/Ty0jDiYxMTdD5w6R67qVxU/H7nhgzFoF6KEY6wKT9Tirnopry2z6G+7f+lPXzHdCwuTi48C9ZNhhdT+1njXXOvhXE8jLKveBm77nclZOX5mZ7w== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: db266209-abc2-4e19-1b8f-08d9f18509db X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:38.2485 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zbXzE0fDO8XnmjjjwvsTS7AZ9Kexr8saKhxPzqFj/CAcCY88L5FHs0dDdVJSMXV7sDua4GJvnn9K8axp771hgcGxyxvg7PbbrWOHOK6i+eo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::707 (failed) Received-SPF: pass client-ip=2a01:111:f400:7e1b::707; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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" Add function to wait for all intersecting requests. To be used in the further commit. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Nikita Lapshin Reviewed-by: Hanna Reitz --- include/block/reqlist.h | 8 ++++++++ block/reqlist.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/include/block/reqlist.h b/include/block/reqlist.h index 0fa1eef259..5253497bae 100644 --- a/include/block/reqlist.h +++ b/include/block/reqlist.h @@ -53,6 +53,14 @@ BlockReq *reqlist_find_conflict(BlockReqList *reqs, int64_t offset, bool coroutine_fn reqlist_wait_one(BlockReqList *reqs, int64_t offset, int64_t bytes, CoMutex *lock); +/* + * Wait for all intersecting requests. It just calls reqlist_wait_one() in a + * loop, caller is responsible to stop producing new requests in this region + * in parallel, otherwise reqlist_wait_all() may never return. + */ +void coroutine_fn reqlist_wait_all(BlockReqList *reqs, int64_t offset, + int64_t bytes, CoMutex *lock); + /* * Shrink request and wake all waiting coroutines (maybe some of them are not * intersecting with shrunk request). diff --git a/block/reqlist.c b/block/reqlist.c index 09fecbd48c..08cb57cfa4 100644 --- a/block/reqlist.c +++ b/block/reqlist.c @@ -58,6 +58,14 @@ bool coroutine_fn reqlist_wait_one(BlockReqList *reqs, int64_t offset, return true; } +void coroutine_fn reqlist_wait_all(BlockReqList *reqs, int64_t offset, + int64_t bytes, CoMutex *lock) +{ + while (reqlist_wait_one(reqs, offset, bytes, lock)) { + /* continue */ + } +} + void coroutine_fn reqlist_shrink_req(BlockReq *req, int64_t new_bytes) { if (new_bytes == req->bytes) { From patchwork Wed Feb 16 19:46: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: 12748983 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 E02F8C433EF for ; Wed, 16 Feb 2022 20:02:58 +0000 (UTC) Received: from localhost ([::1]:34976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQVt-00060t-Pr for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 15:02:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQGa-0003w9-Me; Wed, 16 Feb 2022 14:47:08 -0500 Received: from [2a01:111:f400:fe08::723] (port=55682 helo=EUR03-AM5-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 1nKQGT-0006EC-MB; Wed, 16 Feb 2022 14:47:08 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CoMPLG0t6CSoSeTMANEOx56gedT9Bp72CN8zk2hD7h/RkN3HV3hVsJj1jpfDF8R2WNAepXJiuZ1rUb9E6RZena8xv6J4l9gpWdOs5rrWgeDOH0dmzSrvpflQgFgC0F7SKXaW84hZCAC/rFgTk53YY1cebWiHldJ0WYtSFDiw8wBddNldy5lQmO4a70222VS3qoJtoumzbFptNC6ddUELhy96tccPGnwrTLF7RZEEmuW+Uf2qdkew9+J5xvv3xHfb6qKQ1zx6KeeMVbOKTfMrLQs5pX1DopDDi0Fr0C9b6BFgSkiiU0iYd03qfmcCP4Vx/uH3ocgyieFDkyZUBfqkNA== 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=giIsqwMQ/SbM8wV0PiBL06+2PzS3/KTOorsF/WkowaA=; b=eX9FHn/+/I5FepCpyyU1hWPF6S31zxX0sU8nKzOol+HyWe3gXBOpSuYTt75hD6+FSs7SNUjbLJd6P5xwSeULi5CTT/r1OYTkbMH5dvOwnmfGJeix2/+mBXG1blgXYqxb9c4Gv0Yy1nWEejdz8Waa7RrLXJNd4Q4fg/87z0XMvZ+Dm+qBpwgwmHWg5S2yanDu2OB4DU7Mn7d0UJEgByzqhoVOuB47Wnor3s5haGxsIe5xHiZMJ/2WE24LM6BBAFitUWma8KyIrkWri74USE49Jyk258dKD/iGQGe7BDrvuQhg8iEGTUde3JoWDgAnYeOnj2lr6UrfmMbcv9k7IF4JWg== 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=giIsqwMQ/SbM8wV0PiBL06+2PzS3/KTOorsF/WkowaA=; b=hzxnbDlYNZVp4LHaaE99YEEqz125NIEeYrC6YMa8zHyGMDcvGVLajYW/D0/Whw3n6/4C6NF9MaGqZUfsWiXCPWDAbN3Hf4KMhPLXKyhYz32P6WnbTkoeo4uJpegDM46KSUkc22qkZwR5lrQ5eB3zrXHf1G4woxaCYat8NY5dr4M= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:39 +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.016; Wed, 16 Feb 2022 19:46:39 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 10/18] block/io: introduce block driver snapshot-access API Date: Wed, 16 Feb 2022 20:46:09 +0100 Message-Id: <20220216194617.126484-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: a257745b-c7da-469e-6704-08d9f1850c74 X-MS-TrafficTypeDiagnostic: AM4PR08MB2851:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:359; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8dnsSOdILBc7DVnbJLYBzg4Vc27yczPKiPEaygAUWnKYWiFHtM896r3t68gUOxJzKq7+kqsqCp7nfmcc0aoMmgVmEp4gxWxpsr2FPTmtPdiNsajVozk1J9DiJLRDv5vejZUxGKwSFugGPIOO/OsMf/MKFRkBbxtq+s2oGi621I5XgGr+cbTWqDfU8NHWBjnOq0UtnhINEdvs6g8IkudU8LjTi8KjwNWXNoGvmfP7ZoUtzq893z9G4jl+yWwtW+cNZGAdVRvWNLXDzI59OSA7tR8a5EqKjKxW+GXwFmreDrteRKRzJM1ITwm14kRDj5sd5PEH/iYZOMThpk+L6CXYMnPh7FKv0AZ2zs9LJ/UxiqROSJQNy5AnkX2J6/XXknIwmwzHy9HhXGo9aKhlxT8VBVgzTCFBJyFJFIU79N+TVZeIrn82cd9ghUdZ8hHvbusLyprWtBu7xb9WSPdo2sq7M0RZgaxIptI3FF7+jwSCR9s5yzMJ+i6QFFIBsoVEYvQp72u86lu6gSaeqxkJ7wnDR1sDGLCMR1Bl8ncSx/K66wcQKChT9Owniqy5bv3eXggnBhKmswVWtG4i+ub1qMMz58x2v54SMOLgCrJV6mvQmaj6w6etDijbU4fW4X7Y/5mY+oYnUB0MnUxXD3lxEBJCqFqXxd2guADUPYxNQDjJ7oplB/vqb0vT51gmvXcCrKDdLLTkjVo5BwGtJ5Jvxgh6eQ== 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(83380400001)(508600001)(316002)(6916009)(5660300002)(66946007)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: b2DKTx7TYkS+lxuADhEhLiYstzd+g4RqGZFgQ0kWlCJDYBAIxmpE7zAJjt1ZjGBssk3Z1wDv0vW7U7aLDUIwwvQJC0IGQFU0VuArZJYPY0tGQ2exolykDUchCKSZacccgnw9w6pLyqS3kKABsjYKcb3cZxTR0ttXufPbAI2NELkPWgu+sGyWb0Q6wB1o6EtQNkQ6oQGEXKEV/2me7TFqLv1Xv09dfK2LP8W4pOxqbDXF/iz+zh/6Oxj9i21wgLRMIAePBJi7hp3gON8VK1rw1nGwJmY/IBuIyg+fwi75p8oAWH0JDOAdjzHtRkVqcA1na68ji1GvEmJJ8vImS9zgIt9amxB/FEdw5X/qmbNzuma3E5cQR70J/0KimcFIOV/fwpv2Ip/Pw6ZfWJjYHAV0V+D8ObfpBhEaKRI/nTjhoD7HyucVR3n5TbeXBnwn5s3YObPJw3AsZNpXsPzKjgOoBXfVcIwiUD821dnp91SquBwBJuq2+ZwGjYjGXxddRZq/15vHgWXxGKv0hcgsGchUboV+1juGL74cIhYfQGj3XsgwBHfXkTk3dTbNW4lPUSYUM04vzFCS1+h06XmCElLsKCSjR5K0fu9U0LqVP+mVRUq8n3/W7KUUtUjZCAnp9aCWfV+pnC8Wd5KwIkxcI+uOS+9/DtEKsKcC1NKiaoSu6Z34NXkL9ttmqLv7qqhrZOnxhGltHzFWGhQc/wTVtVbAWqrgVR5lDnwLlp/iEylvm5nENCS9fwYcEIfYqnuD5Dn0Ru04a+Grs1R66iFqZhudNG0m3ejnkEApM2r1/brg9sKW0VEaU/bssddKTG4H6ykXaTRpINRBzxuGb2OcFdUQRQrLzeKy6M2znU1rx0bpnl5FU2uwN0jmpfZVjrZUvoleh4mopX5kfRTB99pP7dJl51npgy2slLbfjRgAj+YBi2sqtj4rzyDJTHQNlWd80C3T52ObPV+OYZAOpWjMyAb0OcVes8aKSvqTe9cHnn8hBH0DRbf4vee0A8zqX3d4Pqh+NXH27XFjXfNXGRHG4k5zQadiO0L2jM/90KQXyjtM0w8fbSyEfQ8Wb3IGv927WVPUCryx1yzfvon/op/0jLU8ESCB3Ecgcneh/8nsb0OsdJMIa3crnsAXLH0FuqeTVYZq0W9bhNTu6F5UTQHLhdMEvfBMIF0G7y49xSzfusEMxIf1KOYAkZN8oxGjiulRN+71XdDnC4OLPyp2J53WpxXOYMxwJB3CvK/sR2L1LKJLSWYVAu+vt36niDbYjncxN5C+zNVttUEXR+0WTxwVGrQ4SbQkkenFBJza4jf07xgBiubckuQt580WXm2jsSiHlj+P+ZviHyiLgEeIiFSPmdVRfhPTsLtjjBc1Ws8QvttOwK7JQw+bNZLnb7mi99KeGaRfFlkdM+wo61aVDeF/H5emoeoNDGUJPo0eKAliBp4U7QV8tszqUZlTa1zOdG+xDPFUxRm+Oaykxslj690YwMPviP46AcDZldUDgn+oLSJyHnxFH7g25x9yRyUY8tASQArgjv/GXJmWIwhl3VYg24xvPWjjXAZZO0JjsZi4NfLVXwHsvUKS6KJw1EVwbjJkUY3gAbAXB1JTIdWcW5RVQDHpBNJE5yyle3QcRtiYumo/f+EUhnlwbKmLgRZVAyptI1rgfGe1h445II3yUTQBcCMPBg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a257745b-c7da-469e-6704-08d9f1850c74 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:39.4503 (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: u5zzYKGRmNkI46/xOk7FxdJZQ0JX0uZvPL5d+hmTe7xQsxcJD26hQHbcVzNrIy06GCl2xTJ7Pdu1VBCRbTtOtp/MSxtnJSvsQiH30trQJfw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe08::723 (failed) Received-SPF: pass client-ip=2a01:111:f400:fe08::723; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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 new block driver handlers and corresponding generic wrappers. It will be used to allow copy-before-write filter to provide reach fleecing interface in further commit. In future this approach may be used to allow reading qcow2 interanal snaphots, for example to export them through NBD. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Hanna Reitz --- include/block/block_int.h | 27 +++++++++++++++ block/io.c | 69 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/include/block/block_int.h b/include/block/block_int.h index 27008cfb22..c43315ae6e 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -376,6 +376,24 @@ struct BlockDriver { */ void (*bdrv_cancel_in_flight)(BlockDriverState *bs); + /* + * Snapshot-access API. + * + * Block-driver may provide snapshot-access API: special functions to access + * some internal "snapshot". The functions are similar with normal + * read/block_status/discard handler, but don't have any specific handling + * in generic block-layer: no serializing, no alignment, no tracked + * requests. So, block-driver that realizes these APIs is fully responsible + * for synchronization between snapshot-access API and normal IO requests. + */ + int coroutine_fn (*bdrv_co_preadv_snapshot)(BlockDriverState *bs, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset); + int coroutine_fn (*bdrv_co_snapshot_block_status)(BlockDriverState *bs, + bool want_zero, int64_t offset, int64_t bytes, int64_t *pnum, + int64_t *map, BlockDriverState **file); + int coroutine_fn (*bdrv_co_pdiscard_snapshot)(BlockDriverState *bs, + int64_t offset, int64_t bytes); + /* * Invalidate any cached meta-data. */ @@ -1078,6 +1096,15 @@ extern BlockDriver bdrv_file; extern BlockDriver bdrv_raw; extern BlockDriver bdrv_qcow2; +int coroutine_fn bdrv_co_preadv_snapshot(BdrvChild *child, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset); +int coroutine_fn bdrv_co_snapshot_block_status(BlockDriverState *bs, + bool want_zero, int64_t offset, int64_t bytes, int64_t *pnum, + int64_t *map, BlockDriverState **file); +int coroutine_fn bdrv_co_pdiscard_snapshot(BlockDriverState *bs, + int64_t offset, int64_t bytes); + + int coroutine_fn bdrv_co_preadv(BdrvChild *child, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); diff --git a/block/io.c b/block/io.c index 4e4cb556c5..0bcf09a491 100644 --- a/block/io.c +++ b/block/io.c @@ -3587,3 +3587,72 @@ void bdrv_cancel_in_flight(BlockDriverState *bs) bs->drv->bdrv_cancel_in_flight(bs); } } + +int coroutine_fn +bdrv_co_preadv_snapshot(BdrvChild *child, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset) +{ + BlockDriverState *bs = child->bs; + BlockDriver *drv = bs->drv; + int ret; + + if (!drv) { + return -ENOMEDIUM; + } + + if (!drv->bdrv_co_preadv_snapshot) { + return -ENOTSUP; + } + + bdrv_inc_in_flight(bs); + ret = drv->bdrv_co_preadv_snapshot(bs, offset, bytes, qiov, qiov_offset); + bdrv_dec_in_flight(bs); + + return ret; +} + +int coroutine_fn +bdrv_co_snapshot_block_status(BlockDriverState *bs, + bool want_zero, int64_t offset, int64_t bytes, + int64_t *pnum, int64_t *map, + BlockDriverState **file) +{ + BlockDriver *drv = bs->drv; + int ret; + + if (!drv) { + return -ENOMEDIUM; + } + + if (!drv->bdrv_co_snapshot_block_status) { + return -ENOTSUP; + } + + bdrv_inc_in_flight(bs); + ret = drv->bdrv_co_snapshot_block_status(bs, want_zero, offset, bytes, + pnum, map, file); + bdrv_dec_in_flight(bs); + + return ret; +} + +int coroutine_fn +bdrv_co_pdiscard_snapshot(BlockDriverState *bs, int64_t offset, int64_t bytes) +{ + BlockDriver *drv = bs->drv; + int ret; + + if (!drv) { + return -ENOMEDIUM; + } + + if (!drv->bdrv_co_pdiscard_snapshot) { + return -ENOTSUP; + } + + bdrv_inc_in_flight(bs); + ret = drv->bdrv_co_pdiscard_snapshot(bs, offset, bytes); + bdrv_dec_in_flight(bs); + + return ret; +} From patchwork Wed Feb 16 19:46: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: 12748991 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 6A0BBC433F5 for ; Wed, 16 Feb 2022 20:07:56 +0000 (UTC) Received: from localhost ([::1]:42940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQah-0003Ft-AR for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 15:07:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQGd-00044H-62; Wed, 16 Feb 2022 14:47:11 -0500 Received: from [2a01:111:f400:7e1b::707] (port=17600 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 1nKQGZ-0006Dk-Vl; Wed, 16 Feb 2022 14:47:10 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c6wSoH+ukDLhEMldmnDUj9td1RssdGoRsI3zBcOCp1YFKLnsfD/3ZzaJ3tauwvsQ48+5X7yyqqJU1esTBCyxhBpYgMMgCn9ohZH/29YNFr09mVzWfIsYz+9lnIov6mnjQ3s7DVE1mWNO9LIHSRtEmY5S0QqWTGXjVMeMVPIf4CLPd5RTTEks+n/snS0MIDMBOqXSOQn+na7khydVv2oqJy2pbSunb2xiu+mGxVYmfgx62t4DaO2ysm3od5Wq2GU9Rr/P5eIOA99MWKQW5mHS9Fvf4D572IHMLaoqE1kWU22zX/peu3cSsW1/5Pp8MCrP1hc44YGWxe7PSYpz4MuhuQ== 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=hVzkeFH0R1sIXZtONO4gJXXS8oiED1uzTni8gHLm97E=; b=emxbpTK/Up+aZu/9WvXLx8WZClwP7Cjy5WdNr+6jq1X+62rHBaw9aW16V7Kp3JLltrkIz63fiT5M3QccwPCuUHkO6y45MIEsDkzXwOmW0C1qFbV+1qugz2zbBwRi88Pg0whYd8naiLaxPoXGUvGqAPTydzgRQp0ZF546zRT93W2apIt6q05EXr7Vm8s44kC52yoZYzZRRYxPn2CMxSMKnp7NA3N43W5VmoIVctLEHPJju/bpsxQFFv6cBSWTJ0FUA808UbXYEtMsVL5EmQYBgjGR8O4lOnzvpfaR/7bjuXo7bR+jYhpDs0A5n0jic2uodUFxtnIZyKZNtp0P3yIALQ== 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=hVzkeFH0R1sIXZtONO4gJXXS8oiED1uzTni8gHLm97E=; b=NjELU829B7Fk6ThpGcNOrc9OVufLIi/9QIiZ9uaojPEd5I88po1xj02CKAQ1FZNCtnwG6WTM1D3DEKFYqWqQz5i5bm3D5wlv9Qtpmv6vE++PHicXTcc016Z1z7W9qaCXVSwjDM8L1/EAzpV9LZ93fbv2qfdHjyAKl5MnGWW/05c= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:40 +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.016; Wed, 16 Feb 2022 19:46:40 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 11/18] block: introduce snapshot-access filter Date: Wed, 16 Feb 2022 20:46:10 +0100 Message-Id: <20220216194617.126484-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: 473206a0-d1a6-44a1-a8ec-08d9f1850cfe X-MS-TrafficTypeDiagnostic: AM4PR08MB2851:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hSWABbmFlIQSnC95mWKs2Fe/fcZ+pW1xV8bH4rnYzZaS4YBlml44AaqdQx6IJ/vMPHI/QKd5Zd9lxLXkHJW0O2HmzRjx3Cx0qfCZXe7LHG3up5RHXqxJhCFvpGjDeMeMLVvWjhyankwmqLN96OFXQPPCv108ALbkP7YzLclFe73ZNyrWYQxznTLnnMpLR56DXO0uZXCOoGfBOxlYmIpxe9JlbmN3ClciJ5OBGOxjccGg/EosOcVngjaW4X6fAZ5wusmkuIApj7PqIusUtN2eynADAUThCLfLXNVV7X8Cp1ccqXaXR/VNC98/PUvkWvnMZajWI+Kw3DrFZDvtwgXsli1OLz+vvJK+VoMVZtIJMyVk+GxiiUR7uB1tFfRWui9b2swojfaICmggkEk3gxtxi+xGsP7FgsRoHoHt+yI3DK/ogMTxemiImeUp6N0urW4Zd6cBgszJej83He6msm+QK3wvw131r0VFtk+7y3J6CEbMe17hB4/elJRZhZMGykj3dzk5KHblx8p9sfU0ItSN4XVq/xIdqv+mNLTZZSdnemVwDISTbMSb3bVX0Y7txYH2fb5eWLICVupfPWBbB5SdWnfX9QY3LVqa01UUBTeMnDTfgJ/Rp3bcki1IAZ6I0k/CNE/tXCMF6c+mjVv5/TAp+tG3MmfA978WOyYSIQ9al/vy8SKnnUANMxOvaJBoh/zsV8e8/+ecIxxF50LGOUXN7uicQ+qmQBdCh41/qbS1H4Rat8h3/OV8gSbwXVeMkIyf3K/JMyOhFaDl47zRbS21Mp0IubWzPEmnsUbJuY0QOKQA0/jPebg8s+Jc4R5601Vb 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(83380400001)(508600001)(316002)(6916009)(5660300002)(66946007)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(38100700002)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: n1pn36QuQ8d9f+vbeM7nEsUr7wE9OHiRpPFdTciqZBo5VOTkVuW0iJs8MBgt+KC41FTySx89u9EkhIAfQcQT8B92eN+90lshcK3dr3iok/qzpZ2EjqExPx0xYDERVO/L3dEjbi/fvcicTgzRHEbXL/FKvxbjSb4/5rXUmNjjTj0GsKHiKMr3Szhpur7z5bQytOk4rNM/TEOFWrCaRY05p+ii9ceWlS6SlcQ7aF7zOT2tPINc79RhS3db+M6b84bIhXaGJe3mvWtI4AhDwea4Z4LkdGYHFjjt02lIqUPfgqe6lYxRqGYzAuAHih7qlB8dcX3MjeGj04MNLUyP+1e7uFFV/DyLze88wxSsvnj5AsDiuP52lZUuDwq8zw6l07IkjtDWQl0NeEXiRI/Z2Zt6AvGBgqo9WpPZNt3dUpO+E34EYWR4FQuM9Pn9O86lTDLS77my2TMAuEC028bxFBAqEa8Z04BDRlQ244HMYQONO1JtYvtdybcxXUlgyaNjG2VtPvHG/Ixj83mfzVdZYcuRBjtK787onI0ctlRQuLcWqvdW6ZI7zytx21D4AUmnR1ReBN3h4Mw4SuqHhZamgX5s51iOoHGFv4zHrgSD4NlZn5an+lEmb3SlPNC0iJuZyHUSzndqPXEr3767TZcejqB+wyj30aKONqSLvlBHuLCC1IvJigOV5r1I0N43okMohY5u5jgnTzCYQJgkf/mlzwTZXnpM5jGP6O8J5MbtplSrwTA96dwPANldm/gh0LVhGiagCKwZxWcMAujaVB0dg2wtY9f3FYi0BODfBpnR1hGR1meMg+PH4OOL8bYHtbMNIGrBGAcH2MUEj2cy5B920FF8I2y8nFcU49akwlnc5tR4F7EJK/i+/qunqiEYSLhesp3LzY96vQegkz4J1KO/OciaY/XVKyv1l4ebCceundEOSeUcoekUVEMOFSk9S6nVcBaOufEioV82ILbK/7zMa8kIexzd66/7wWL0TUPNXKvFuJiz6pU5ijjOS59tN53UD1iygSD0JxgztQXocutH3+HFOKHNmDwY489C+WC5flauEZbJp+HVELnry9jCtzq25iFHNtCQPx31ZHYbbg0KXRgHubCrDVsx6rFO1prEvIXU9hQk5Fzxf/WKLHXYCaHH9BVH/ogxyEza7y14hGIkBulCCtzpv17SiFsDxwaS6vK+2ljzYbQTUHRyTp+jZxAgbf3yO6JZmpo5SZKcnDKQiaSoc/7nj7JZcX4OYgwQ3TlOm6I9a1jxxgs4nkG7zVCgoi5WmdtbaZEQpRO8UosoTaw7nS33UsECijc9P9YqVroWjJEzk1nDjP7gXF2rRhwsPGSk6pe0h6AqV+emMeigzWkpUjy65fDtKNVrilGrUhk0ruwPO/1FsIWd4d6ECqaAtrG99JF0p6XuGaDS/sjDTMeRDxMQcI3VauLUDLBzJXTbrV0FJOLWSsQMyn+wZbsLz8pVhwXIlsxfa7JYn3ISy3LUHQpLk4G+PcSYybtvcFKch+QInozGUvZxEh4JJqka1TjGzJsWV+q1qPHNoRF3xirzbP+WuTYoJ6riey7aBtCh7UE6n2Agmup57exPSJYDBkWVMHHpS9vEnjGIo4r8hlsWqwSb+VIXFT4ZXtYmOLydx8+VIrCzdGb7oVt2hH/P4ojdAgMONDj2FWpCGYE7mb+qvg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 473206a0-d1a6-44a1-a8ec-08d9f1850cfe X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:40.2015 (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: rFfI3orByMthWK5dlx9Ce9v8EABDdCKFj7vYPewQnZ1jOSw9tMi11zWUWxCf+rJ0X36wxwNTLlsNWFAQN2FHMZkEN+aodhsLgmBZ4dhc2Cs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::707 (failed) Received-SPF: pass client-ip=2a01:111:f400:7e1b::707; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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" The filter simply utilizes snapshot-access API of underlying block node. In further patches we want to use it like this: [guest] [NBD export] | | | root | root v file v [copy-before-write]<------[snapshot-access] | | | file | target v v [active-disk] [temp.img] This way, NBD client will be able to read snapshotted state of active disk, when active disk is continued to be written by guest. This is known as "fleecing", and currently uses another scheme based on qcow2 temporary image which backing file is active-disk. New scheme comes with benefits - see next commit. The other possible application is exporting internal snapshots of qcow2, like this: [guest] [NBD export] | | | root | root v file v [qcow2]<---------[snapshot-access] For this, we'll need to implement snapshot-access API handlers in qcow2 driver, and improve snapshot-access filter (and API) to make it possibele to select snapshot by name. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 4 +- block/snapshot-access.c | 132 ++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + block/meson.build | 1 + 4 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 block/snapshot-access.c diff --git a/qapi/block-core.json b/qapi/block-core.json index 3bab597506..a904755e98 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2914,13 +2914,14 @@ # @blkreplay: Since 4.2 # @compress: Since 5.0 # @copy-before-write: Since 6.2 +# @snapshot-access: Since 7.0 # # Since: 2.9 ## { 'enum': 'BlockdevDriver', 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs', 'cloop', 'compress', 'copy-before-write', 'copy-on-read', 'dmg', - 'file', 'ftp', 'ftps', 'gluster', + 'file', 'snapshot-access', 'ftp', 'ftps', 'gluster', {'name': 'host_cdrom', 'if': 'HAVE_HOST_BLOCK_DEVICE' }, {'name': 'host_device', 'if': 'HAVE_HOST_BLOCK_DEVICE' }, 'http', 'https', 'iscsi', @@ -4267,6 +4268,7 @@ 'rbd': 'BlockdevOptionsRbd', 'replication': { 'type': 'BlockdevOptionsReplication', 'if': 'CONFIG_REPLICATION' }, + 'snapshot-access': 'BlockdevOptionsGenericFormat', 'ssh': 'BlockdevOptionsSsh', 'throttle': 'BlockdevOptionsThrottle', 'vdi': 'BlockdevOptionsGenericFormat', diff --git a/block/snapshot-access.c b/block/snapshot-access.c new file mode 100644 index 0000000000..77b87c1946 --- /dev/null +++ b/block/snapshot-access.c @@ -0,0 +1,132 @@ +/* + * snapshot_access block driver + * + * Copyright (c) 2022 Virtuozzo International GmbH. + * + * Author: + * Sementsov-Ogievskiy Vladimir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "qemu/osdep.h" + +#include "sysemu/block-backend.h" +#include "qemu/cutils.h" +#include "block/block_int.h" + +static coroutine_fn int +snapshot_access_co_preadv_part(BlockDriverState *bs, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, + BdrvRequestFlags flags) +{ + if (flags) { + return -ENOTSUP; + } + + return bdrv_co_preadv_snapshot(bs->file, offset, bytes, qiov, qiov_offset); +} + +static int coroutine_fn +snapshot_access_co_block_status(BlockDriverState *bs, + bool want_zero, int64_t offset, + int64_t bytes, int64_t *pnum, + int64_t *map, BlockDriverState **file) +{ + return bdrv_co_snapshot_block_status(bs->file->bs, want_zero, offset, + bytes, pnum, map, file); +} + +static int coroutine_fn snapshot_access_co_pdiscard(BlockDriverState *bs, + int64_t offset, int64_t bytes) +{ + return bdrv_co_pdiscard_snapshot(bs->file->bs, offset, bytes); +} + +static int coroutine_fn +snapshot_access_co_pwrite_zeroes(BlockDriverState *bs, + int64_t offset, int64_t bytes, + BdrvRequestFlags flags) +{ + return -ENOTSUP; +} + +static coroutine_fn int +snapshot_access_co_pwritev_part(BlockDriverState *bs, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, + BdrvRequestFlags flags) +{ + return -ENOTSUP; +} + + +static void snapshot_access_refresh_filename(BlockDriverState *bs) +{ + pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), + bs->file->bs->filename); +} + +static int snapshot_access_open(BlockDriverState *bs, QDict *options, int flags, + Error **errp) +{ + bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_DATA | BDRV_CHILD_PRIMARY, + false, errp); + if (!bs->file) { + return -EINVAL; + } + + bs->total_sectors = bs->file->bs->total_sectors; + + return 0; +} + +static void snapshot_access_child_perm(BlockDriverState *bs, BdrvChild *c, + BdrvChildRole role, + BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nshared) +{ + /* + * Currently, we don't need any permissions. If bs->file provides + * snapshot-access API, we can use it. + */ + *nperm = 0; + *nshared = BLK_PERM_ALL; +} + +BlockDriver bdrv_snapshot_access_drv = { + .format_name = "snapshot-access", + + .bdrv_open = snapshot_access_open, + + .bdrv_co_preadv_part = snapshot_access_co_preadv_part, + .bdrv_co_pwritev_part = snapshot_access_co_pwritev_part, + .bdrv_co_pwrite_zeroes = snapshot_access_co_pwrite_zeroes, + .bdrv_co_pdiscard = snapshot_access_co_pdiscard, + .bdrv_co_block_status = snapshot_access_co_block_status, + + .bdrv_refresh_filename = snapshot_access_refresh_filename, + + .bdrv_child_perm = snapshot_access_child_perm, +}; + +static void snapshot_access_init(void) +{ + bdrv_register(&bdrv_snapshot_access_drv); +} + +block_init(snapshot_access_init); diff --git a/MAINTAINERS b/MAINTAINERS index 7a5292b814..b16fcca98a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2509,6 +2509,7 @@ F: block/reqlist.c F: include/block/reqlist.h F: block/copy-before-write.h F: block/copy-before-write.c +F: block/snapshot-access.c F: include/block/aio_task.h F: block/aio_task.c F: util/qemu-co-shared-resource.c diff --git a/block/meson.build b/block/meson.build index e2f0fe34b4..85f2b03216 100644 --- a/block/meson.build +++ b/block/meson.build @@ -34,6 +34,7 @@ block_ss.add(files( 'raw-format.c', 'reqlist.c', 'snapshot.c', + 'snapshot-access.c', 'throttle-groups.c', 'throttle.c', 'vhdx-endian.c', From patchwork Wed Feb 16 19:46:11 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: 12748993 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 4B9A9C433F5 for ; Wed, 16 Feb 2022 20:08:14 +0000 (UTC) Received: from localhost ([::1]:44242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQaz-0004AS-4z for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 15:08:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQGm-0004PX-Nx; Wed, 16 Feb 2022 14:47:20 -0500 Received: from [2a01:111:f400:fe08::723] (port=55682 helo=EUR03-AM5-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 1nKQGb-0006EC-AM; Wed, 16 Feb 2022 14:47:20 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y9j0zAYm6iPV6uogsmeN2mj9knPg0Sd4DOATfidFJJP0i4GlgcFUxt2PTFSyoHRmTrZ833nmT63EdkivhYWULuo+fBJnws/UydjIO3zGXgki4TZGw/fU4DQ10WlT6ZOYziNX4stjXC6Szldc6ZrSuw5y9scXekc3xodjtg1tfgdOw/w+lcSPgJzqDafMev7Zv/bcrtroOmeXBVoME9Ufg8qGXoclEXKF9uTPnLhf06+rQP6+r//cNrL4UimX8ZlrRUtfZOTgOREG3XTK9z6ybxgI20eIKw4l2adu3YeOQIxWEwJfqo7AzFN+xIuPf+w1rx8kLba9U2UrqnYQU7WawQ== 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=PFmFtwmfjB62d+1WGO9GnDc3H6KS+9ooj7oKcSw5TDk=; b=ZvANLgTXB0MdGd5fUML4u2vbPSuFNBySYH1HvVKyVvea4UJ0PLnv/bqPpWFnaLXAo9+wMv21ul9IcRHa4clalL2cbrgFKNHcwoZOcMTVqtYhUwxfuFZd6t5JHpWjM37x9ELChD11HGrdK6ARH5IVg00CisenS6Z17LAFhPUe5m22eobKHo0yBrHpNbBkYsNkTNd55qdTu3AFPAEe1XAEAxTVTbi8eHw6K7UIUlr4u9ZTUEGRUEvEx3hc56ZuoF2Wf5GoYfIuPaB3DrONCoU9i372f9s9W/FOcySrsgxtJMPJcf8wBcZSo+CirFvunC1Iyhn21/mdMM6pAwtAV7yQZw== 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=PFmFtwmfjB62d+1WGO9GnDc3H6KS+9ooj7oKcSw5TDk=; b=wpKjn93dj4sH+hQmPH5SAg3nIu1o38Y6KRl+p8aQN2D+q+fh4yOduEhWamOJmC7v1iLNgjnSkoBKiIvE/SThOs0kf71bHt/bxLGEbHp8PG3g+75DZn9IjnmByMuR7GHXAmG3K29eC1ZttiMUhwD22HpkYoehkuEniBbk0Usdm0E= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:40 +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.016; Wed, 16 Feb 2022 19:46:40 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 12/18] block: copy-before-write: realize snapshot-access API Date: Wed, 16 Feb 2022 20:46:11 +0100 Message-Id: <20220216194617.126484-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: 03c63704-4bd9-43ed-254b-08d9f1850d4b X-MS-TrafficTypeDiagnostic: AM4PR08MB2851:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:190; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ytztWuzuLMWy0pi21uQPSvQ4XvNxYIN2HSEKtGUpo4ByCs1h+DCf9B4I+S0/LRrOhHoJPP4zeZO2DBmdbra00BTlFlwcoSZKB3ethxaMqv+DdomAYqVrxjBQ2YL+Vyl1tDWQiDJZ0qIARgQ00PEO0NhwcxAraVVzwXUdi9iuYD4Sr4DU5znmuAExIHDNlWt0s+V9gZy8FZ1xR726kc/RJd76TO3AgCt3s+kg4QuBtlKDCra7jO58jXZ0V/Uiq+BiNBY/wNMw19FgnUKCWfH/drcjlHIp+ItlMIYzRKX8Y/lH6xJquVDdVn/MyN0CnKafO305vRHTN/ehCUqcbdYN0gcqYi7cRJdD/2lpZTzcymws1r5bhUZBKp7rrGEGD6VdeAl9Lmd7zJB4V/O9/S6PZLCkexssoFyRoRuRItb/ITbaCHHPd4+cAC8BAaMxculkBMxn16XTOytvWUDmTyFsblY4pN27Jewo+5s98UArQso921maAb9dnoDz+uPLw0sqU/xF6/30UdIzwV9uIcMtioZHt4AD7L9uKQWTl5gdMSu+QmnUVtGhid5xgMI4vCjPOkOhPfsHX0OQiZtpqfG1mSILX7gVjlMJ7jyS3RX8+PGYpKIbH8gpuG4mYksAZcuZapFJK1mnxmnvRsASzmXRZjXOzEBj7v2c1+aTlc4rMadDL2k0scYB3ncAk+b/tzuKrY0VvOgifvJx0f5366KGog== 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(83380400001)(508600001)(316002)(6916009)(5660300002)(66946007)(30864003)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jwVXFVWGmj2pHzzJTL2pgED1ZOdZ/3BHWQ5MLR7RI6gZn9m/9YZo9DXp5CraFJYKt6ARUMDKeHARjwrlv2MMdbvSXIczP1i3svLnvpdu3d2p1s6epnod3/fcRJ8dhRuXV7SyFCoqMh1MpVcbLGTtitqjq9Qret6kN8dHdRvuiwer1Rr9gDQ3/yATOGBK+5l5SWxHOzclfYnqFTZUMGgv3CfJtTHJ/YcqAffFtnswyZ6HTNkOW2JtCjBy3hzKnFX10RnAUfVEisNrJmhQHWpGhVTeZxJ4rHR7H4Sg2OyNB3FQWoprsrzyFO34EATZ/EGYLDCN+GgjBOKxkZJfHjPcPuArI74XjTSKmL6bYdnQDzSlOrGPOkLtlv3mpUaNjQRsZrzsIup1Vl1/GTzFkGZBQSuqT4kjrWklFD+E5QK2oBfDlly13dXXZ7rpOSQ288l5dAGDyZ4CynvnhWCuzpYAm1xWj1Zd3O4FK4Bsd7k84UAJ3t1OgmTVDiYR02wDyxPpPi0VmfLhCjweVc6w/r+6Z+pbhTJZcMXIIs1kMRg/u3UUZZkb2ZJkaYo3knTW9zTWsaw4sbBYEucuIb4LQuvyRxyuuy07wuOQQriPvZykQJ/B3rxO9nWak8IF0Yzo9FxWD9iNZROwamxRzy5XtQAtr+z4cIH8dLoFikL+ho9q27J6DC8kEa+5uGLl/Y47WTNTQDz9F2bwI5jWv3adUj6dWJJGUENoiK6ou8bGydN6rlcwznHVnBcgxbD8O9qq8AkY243d9wzR6GLYkJ9kN5WyBh2XYK+mteTcpTYbEcYKwiiW+nXG1U/hTIWOW5kWwMVHue/gg28Q1sZ69JkstKbu+3TfglqiUn2EfT+HiuRoR244Ryfik5XbjXV2HGrUketwjhpiTPDX35Cj904fss3ajDQiCFVqlEja++MxPgL7hLGzTsmoi2hf83/ygkcnq/Jd98kWUYhQk8aGOOsXCflPz72lUbCfqK9xnjULOg9ldvLbKMnbtYHgFyTBzVmu8Xamzs7PbOLCNVx2cT5whW5WYzhchX/V9u7Btdh3wzKMzq6nAUaKyaRCdOwZKNkUK1D/WccqgK3Zd2FRX1qJZGzL55P5Zf37UJV0k7cnonYgWwoD2LryCzPs9V6Q+pUHNNtstwuSZ5yjtnyRp/QxWQY18R4kL4Jt95gTSYsLbrYRRNjdNGiHWrODTohed7NHJJ21ixxfwjcbYghMdqkq5hR00/WeghisWZtzpDXqhBI2r9zNwa3Yf86FDKP9yKJJ5LR0wx0S382oHLlCg79vTVAFYQzT3h3hC04+0O8YoNxMh/nSw54nZ0o2S/lKTfsQMGIUlk9BzceBC54MrZuawY68lioFq7MSZ5zerzROQCk1p5e0O5X8L/8umbGEy4wxzKIYzLrVrnfBcEjLAWYQ+v7mQh8qFxpUZYiuc1KKmx3jDna/uCpDAIwFOt93hj1lZwuHfvTxO76V9imKz19rhp/WovyjlwweQ8s+pSVScX3J0gjSzLParDC+IiwhtGvaVGJRwZlzFiJm1CnwMDQVsm5aFC5xoDL6nzwHXY62dasm4TXxg9BBf+30fM701ylNEoCOLnWhO1iG+kAnjFqOmfntfOZGXYo9181e8ANeH0c1MuRjgAXCYd5J3jybc07DgC3VSsY1mVeGqIU7kv7z+8ZUtg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03c63704-4bd9-43ed-254b-08d9f1850d4b X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:40.8108 (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: VhqK73dgZG3al+OKFP6cZaRBgq6YM82V+Ta240IddvGxqvHsntFgzrpf/pGJPbWU1qN1soMVtqGw5B4rz2PrQgvD1dI2R05tQUeEvtGMOCc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe08::723 (failed) Received-SPF: pass client-ip=2a01:111:f400:fe08::723; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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" Current scheme of image fleecing looks like this: [guest] [NBD export] | | |root | root v v [copy-before-write] -----> [temp.qcow2] | target | |file |backing v | [active disk] <-------------+ - On guest writes copy-before-write filter copies old data from active disk to temp.qcow2. So fleecing client (NBD export) when reads changed regions from temp.qcow2 image and unchanged from active disk through backing link. This patch makes possible new image fleecing scheme: [guest] [NBD export] | | | root | root v file v [copy-before-write]<------[x-snapshot-access] | | | file | target v v [active-disk] [temp.img] - copy-before-write does CBW operations and also provides snapshot-access API. The API may be accessed through x-snapshot-access driver. Benefits of new scheme: 1. Access control: if remote client try to read data that not covered by original dirty bitmap used on copy-before-write open, client gets -EACCES. 2. Discard support: if remote client do DISCARD, this additionally to discarding data in temp.img informs block-copy process to not copy these clusters. Next read from discarded area will return -EACCES. This is significant thing: when fleecing user reads data that was not yet copied to temp.img, we can avoid copying it on further guest write. 3. Synchronisation between client reads and block-copy write is more efficient. In old scheme we just rely on BDRV_REQ_SERIALISING flag used for writes to temp.qcow2. New scheme is less blocking: - fleecing reads are never blocked: if data region is untouched or in-flight, we just read from active-disk, otherwise we read from temp.img - writes to temp.img are not blocked by fleecing reads - still, guest writes of-course are blocked by in-flight fleecing reads, that currently read from active-disk - it's the minimum necessary blocking 4. Temporary image may be of any format, as we don't rely on backing feature. 5. Permission relation are simplified. With old scheme we have to share write permission on target child of copy-before-write, otherwise backing link conflicts with copy-before-write file child write permissions. With new scheme we don't have backing link, and copy-before-write node may have unshared access to temporary node. (Not realized in this commit, will be in future). 6. Having control on fleecing reads we'll be able to implement alternative behavior on failed copy-before-write operations. Currently we just break guest request (that's a historical behavior of backup). But in some scenarios it's a bad behavior: better is to drop the backup as failed but don't break guest request. With new scheme we can simply unset some bits in a bitmap on CBW failure and further fleecing reads will -EACCES, or something like this. (Not implemented in this commit, will be in future) Additional application for this is implementing timeout for CBW operations. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/copy-before-write.c | 212 +++++++++++++++++++++++++++++++++++++- 1 file changed, 211 insertions(+), 1 deletion(-) diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 91a2288b66..a8c88f64eb 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -33,12 +33,37 @@ #include "block/block-copy.h" #include "block/copy-before-write.h" +#include "block/reqlist.h" #include "qapi/qapi-visit-block-core.h" typedef struct BDRVCopyBeforeWriteState { BlockCopyState *bcs; BdrvChild *target; + + /* + * @lock: protects access to @access_bitmap, @done_bitmap and + * @frozen_read_reqs + */ + CoMutex lock; + + /* + * @access_bitmap: represents areas allowed for reading by fleecing user. + * Reading from non-dirty areas leads to -EACCES. + */ + BdrvDirtyBitmap *access_bitmap; + + /* + * @done_bitmap: represents areas that was successfully copied to @target by + * copy-before-write operations. + */ + BdrvDirtyBitmap *done_bitmap; + + /* + * @frozen_read_reqs: current read requests for fleecing user in bs->file + * node. These areas must not be rewritten by guest. + */ + BlockReqList frozen_read_reqs; } BDRVCopyBeforeWriteState; static coroutine_fn int cbw_co_preadv( @@ -48,10 +73,20 @@ static coroutine_fn int cbw_co_preadv( return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); } +/* + * Do copy-before-write operation. + * + * On failure guest request must be failed too. + * + * On success, we also wait for all in-flight fleecing read requests in source + * node, and it's guaranteed that after cbw_do_copy_before_write() successful + * return there are no such requests and they will never appear. + */ static coroutine_fn int cbw_do_copy_before_write(BlockDriverState *bs, uint64_t offset, uint64_t bytes, BdrvRequestFlags flags) { BDRVCopyBeforeWriteState *s = bs->opaque; + int ret; uint64_t off, end; int64_t cluster_size = block_copy_cluster_size(s->bcs); @@ -62,7 +97,17 @@ static coroutine_fn int cbw_do_copy_before_write(BlockDriverState *bs, off = QEMU_ALIGN_DOWN(offset, cluster_size); end = QEMU_ALIGN_UP(offset + bytes, cluster_size); - return block_copy(s->bcs, off, end - off, true); + ret = block_copy(s->bcs, off, end - off, true); + if (ret < 0) { + return ret; + } + + WITH_QEMU_LOCK_GUARD(&s->lock) { + bdrv_set_dirty_bitmap(s->done_bitmap, off, end - off); + reqlist_wait_all(&s->frozen_read_reqs, off, end - off, &s->lock); + } + + return 0; } static int coroutine_fn cbw_co_pdiscard(BlockDriverState *bs, @@ -110,6 +155,142 @@ static int coroutine_fn cbw_co_flush(BlockDriverState *bs) return bdrv_co_flush(bs->file->bs); } +/* + * If @offset not accessible - return NULL. + * + * Otherwise, set @pnum to some bytes that accessible from @file (@file is set + * to bs->file or to s->target). Return newly allocated BlockReq object that + * should be than passed to cbw_snapshot_read_unlock(). + * + * It's guaranteed that guest writes will not interact in the region until + * cbw_snapshot_read_unlock() called. + */ +static BlockReq *cbw_snapshot_read_lock(BlockDriverState *bs, + int64_t offset, int64_t bytes, + int64_t *pnum, BdrvChild **file) +{ + BDRVCopyBeforeWriteState *s = bs->opaque; + BlockReq *req = g_new(BlockReq, 1); + bool done; + + QEMU_LOCK_GUARD(&s->lock); + + if (bdrv_dirty_bitmap_next_zero(s->access_bitmap, offset, bytes) != -1) { + g_free(req); + return NULL; + } + + done = bdrv_dirty_bitmap_status(s->done_bitmap, offset, bytes, pnum); + if (done) { + /* + * Special invalid BlockReq, that is handled in + * cbw_snapshot_read_unlock(). We don't need to lock something to read + * from s->target. + */ + *req = (BlockReq) {.offset = -1, .bytes = -1}; + *file = s->target; + } else { + reqlist_init_req(&s->frozen_read_reqs, req, offset, bytes); + *file = bs->file; + } + + return req; +} + +static void cbw_snapshot_read_unlock(BlockDriverState *bs, BlockReq *req) +{ + BDRVCopyBeforeWriteState *s = bs->opaque; + + if (req->offset == -1 && req->bytes == -1) { + g_free(req); + return; + } + + QEMU_LOCK_GUARD(&s->lock); + + reqlist_remove_req(req); + g_free(req); +} + +static coroutine_fn int +cbw_co_preadv_snapshot(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset) +{ + BlockReq *req; + BdrvChild *file; + int ret; + + /* TODO: upgrade to async loop using AioTask */ + while (bytes) { + int64_t cur_bytes; + + req = cbw_snapshot_read_lock(bs, offset, bytes, &cur_bytes, &file); + if (!req) { + return -EACCES; + } + + ret = bdrv_co_preadv_part(file, offset, cur_bytes, + qiov, qiov_offset, 0); + cbw_snapshot_read_unlock(bs, req); + if (ret < 0) { + return ret; + } + + bytes -= cur_bytes; + offset += cur_bytes; + qiov_offset += cur_bytes; + } + + return 0; +} + +static int coroutine_fn +cbw_co_snapshot_block_status(BlockDriverState *bs, + bool want_zero, int64_t offset, int64_t bytes, + int64_t *pnum, int64_t *map, + BlockDriverState **file) +{ + BDRVCopyBeforeWriteState *s = bs->opaque; + BlockReq *req; + int ret; + int64_t cur_bytes; + BdrvChild *child; + + req = cbw_snapshot_read_lock(bs, offset, bytes, &cur_bytes, &child); + if (!req) { + return -EACCES; + } + + ret = bdrv_block_status(bs, offset, cur_bytes, pnum, map, file); + if (child == s->target) { + /* + * We refer to s->target only for areas that we've written to it. + * And we can not report unallocated blocks in s->target: this will + * break generic block-status-above logic, that will go to + * copy-before-write filtered child in this case. + */ + assert(ret & BDRV_BLOCK_ALLOCATED); + } + + cbw_snapshot_read_unlock(bs, req); + + return ret; +} + +static int coroutine_fn cbw_co_pdiscard_snapshot(BlockDriverState *bs, + int64_t offset, int64_t bytes) +{ + BDRVCopyBeforeWriteState *s = bs->opaque; + + WITH_QEMU_LOCK_GUARD(&s->lock) { + bdrv_reset_dirty_bitmap(s->access_bitmap, offset, bytes); + } + + block_copy_reset(s->bcs, offset, bytes); + + return bdrv_co_pdiscard(s->target, offset, bytes); +} + static void cbw_refresh_filename(BlockDriverState *bs) { pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), @@ -194,6 +375,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, { BDRVCopyBeforeWriteState *s = bs->opaque; BdrvDirtyBitmap *bitmap = NULL; + int64_t cluster_size; bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, @@ -225,6 +407,27 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } + cluster_size = block_copy_cluster_size(s->bcs); + + s->done_bitmap = bdrv_create_dirty_bitmap(bs, cluster_size, NULL, errp); + if (!s->done_bitmap) { + return -EINVAL; + } + bdrv_disable_dirty_bitmap(s->done_bitmap); + + /* s->access_bitmap starts equal to bcs bitmap */ + s->access_bitmap = bdrv_create_dirty_bitmap(bs, cluster_size, NULL, errp); + if (!s->access_bitmap) { + return -EINVAL; + } + bdrv_disable_dirty_bitmap(s->access_bitmap); + bdrv_dirty_bitmap_merge_internal(s->access_bitmap, + block_copy_dirty_bitmap(s->bcs), NULL, + true); + + qemu_co_mutex_init(&s->lock); + QLIST_INIT(&s->frozen_read_reqs); + return 0; } @@ -232,6 +435,9 @@ static void cbw_close(BlockDriverState *bs) { BDRVCopyBeforeWriteState *s = bs->opaque; + bdrv_release_dirty_bitmap(s->access_bitmap); + bdrv_release_dirty_bitmap(s->done_bitmap); + block_copy_state_free(s->bcs); s->bcs = NULL; } @@ -249,6 +455,10 @@ BlockDriver bdrv_cbw_filter = { .bdrv_co_pdiscard = cbw_co_pdiscard, .bdrv_co_flush = cbw_co_flush, + .bdrv_co_preadv_snapshot = cbw_co_preadv_snapshot, + .bdrv_co_pdiscard_snapshot = cbw_co_pdiscard_snapshot, + .bdrv_co_snapshot_block_status = cbw_co_snapshot_block_status, + .bdrv_refresh_filename = cbw_refresh_filename, .bdrv_child_perm = cbw_child_perm, From patchwork Wed Feb 16 19:46:12 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: 12748981 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 86734C433F5 for ; Wed, 16 Feb 2022 19:59:44 +0000 (UTC) Received: from localhost ([::1]:57802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQSl-0002As-JD for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 14:59:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQGf-00048T-JH; Wed, 16 Feb 2022 14:47:16 -0500 Received: from [2a01:111:f400:7e1b::707] (port=17600 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 1nKQGd-0006Dk-PW; Wed, 16 Feb 2022 14:47:13 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZCowZXw7vD8m4XDF5g8VRAuPYpLStmTV9/Zt7e50RkrMbeZF3GpbZ9Pw2qSxXrrkjHvAHoduuib0FoVlknSHCOCP8fV1CLtfhK90Imtld6XfFf4KTh5rAM/wiz2LQaI9tnFmlFVeRNgQVLHgeIOJFR2ZODVB/dc4G5bnU1DRg0KqgFOKK4uMBjSBpVHtLATsNz7eZra/di1TnZ9Ajijj52iYNBdu7zXsh3VkqaqrfQxhuGC2Woz3Rwxr9xGHQgptPOptkiN2bX23CyFsJA18R2DuLcHERIMy1lkQOb4reuYqysgJMz/sDFd7JhzWJ4acTBsS2a3zwNh2bY2xbvvfJg== 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=OjQf3y3wQaEnooXwR9p9murh9353ZYyAsP2SYaXwUsI=; b=gD/t4yasfScwsVsnFct01Li4SxbMMIDk2ccbRtwZoE6jTnGmx0dOJCuEWEm4ijT/W2NZitWc+jop0lsnfr5aseGIOqfu3ZKbVzJwsLCLFiKCmu6ZGz1KuoOT5lo+vJPS7ekr86p4Jqy3xEhxtm2ljO8kTYE39QuB6FcC8XTt1Wwjwvko76iB4CHogfnL1owsQ7l9OcBLB8zTC4cwWirJHGgZFllR676YJIWEo9pxJiXXjm5GkmK9Z9VkJu5UfFSKX4k04T0xinXeZ44Kgx2ek4z3XzYyFTLMVl5aKDWFw6Xr/59hHdSZpVY4RrMtr0ViYulRUhiPMod3+VVBouWZ9w== 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=OjQf3y3wQaEnooXwR9p9murh9353ZYyAsP2SYaXwUsI=; b=JOlkejnJiAhsRJWeq9WJ1QXDISKlWPQOAlR01O7Uyp68fW3Bftq8xRLYsF4pOg5lhKn8UCdqIOHWBi89YfRivP9zfvYiNY9mMtE0YnFxdbPoaINXOaCARwK0X8BxiHaUPOdbtOS2S+5hfLrmSFJH3CZRRdN38UYr7F0NaotTj6A= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:41 +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.016; Wed, 16 Feb 2022 19:46:41 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 13/18] iotests/image-fleecing: add test-case for fleecing format node Date: Wed, 16 Feb 2022 20:46:12 +0100 Message-Id: <20220216194617.126484-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: 55f40c94-8b7b-41c0-3bc5-08d9f1850db4 X-MS-TrafficTypeDiagnostic: AM4PR08MB2851:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:422; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VjdGcmP5bzfN5N61UyqCKufr5oK4x9q84NRC311OuUWRuE4nww49vn7RU/2aHPg7u/IQjDU9JDMstC+jcSa43HF4VpJwBxSXnxZRhXhslw3nmWo3Nv8bXFnIkmDI8RLQXsyMNnQ0X6MaAZ+YiI2nbfM4I2uWChfSvH5Cj9A4FavvcBHmdt7+2Sth76ZrrznxAW5BtI89txcjf+Avy3294gV8vZ5AdRkP344gKF6Kqyj0k5Qtktgr2IJ/dOP14bOmkUSrc4xiB/ld1hUp3jzQhtSgnCDtopsTHTEIhGD+WDaaj0b0mj9vUWER4ZFyzL0pIgZVra06P9h8056eKETlbwYLkG2NFjwqN2PrLlt1iVkA8y3X2zQQO90vRu3R0soGv/foRKRkuhwoU+UzhhePueQTH3rvsMWrsjNhqYy8F/a3Mb7d8vAAaQ3Ihb0OXsSca5APwhGKd+evVN0Auk8TV5X4MDP4xkl9ZQA5sv7QPf0lakz+JPVUHlaIBH3DPgf9XhDsnLqWwyghsZP0cvfFfPoV2cNo1+DMVYNf071SgW3NLbs4ZQldi2M74rAcUtc+C5WEytB1gJn/uOIVmTBBNFLHJBSpS8lK1SXjgdYsxz1EO5egLnYkjI9MJQ/L3rolFTZ43dXjpMPOqt4xIg3rmJAiVVSzYPbqLLrmZRqC30O6DC/XYhhmkkIljH1JaJI7Cia91sdRVNQBjO4uhlcEcw== 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(83380400001)(508600001)(316002)(6916009)(5660300002)(66946007)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uvJUqJM83Ieeu0yIxQcQhtihfuiVQ05aOC/cgbIyFlAhdrk5gNtjbh2TuIUVSzVTOd559MZ8jQiwNJnLu1KJUi4vPoQhkD1hA+jCjNurnZBzeI3jHji4Ph7EjpTj7hnr1VPaMuqqjeAVIn5mDNUail17ImLCRYeSmc9PhezK+34tIrg0lWFQtVHZHzYKkH4PnM9ZbvJ/j94aXNy/AEQQMErIR146+OgFSoTobo+Mvrxjeq5Ka3GxSBZ5Tf20hduoQoC60+zKjWm7xCN0BFnNIPulFqTTiviQZfHHjeL28byc4Bl+8X93srkG36jm9WRMgIUXdP2ICQHcBhjzhmfgIjEkAZcfEe+5ESI1fn3NQ+8gtPjqY0Zzxed1kCT3IslrdrYm46Ipa3YqI1fszv8dsjpVdTYWmX3ZVZSWKcgMGNp1lckGds4ohejCQy9BbTIWk0Hjjkb7YuaWNkbytscfv7/r33uoT69zMw7At6N8hwSJyjbtqJqvkWDOOvYGLgCgoU3cTKj/wy38CEjKIbddtSdyjhbk59hw0dXoapCi/oqLA7FHZHe7AdsPIj2iZ4xrOrzKrng5cumAbyheeTgjBPB7FoKNwt9ltxqxm7rolOsRHar1iJ305kDIAbPyvIYFBoKwdF5RrFnneP7wPFPprM3HwvRX5fX+iuG5sJKUA0bxemK8UP8Y3bJVYkUdOJTOjH/gNQffd7kqNchFOZKfAnl9T3yvvgrWLGWGZMIZzPbU/ewXzrnjaGFqASNXVip56JQVObLpAunIkSfG7kNRVg2TDXWjVePOsEK9vqzjMq7yxfv1QFOgAmkQDXFo0wZuyd2iXls6iIMpC8B222FpceEAnLFaEFK7R7zV3uwCtjAS5nstj8tkNLZfSCKxRNoliEs6Z/b1KnBTX+9PPEaq8coNL/+IBywgYYsYrYbL6+C0Qwv59MeSHJgZglNJcGRqmefRLE2M/NCB62LGrAoWHGoBPSIJiF75FnJsJ67/jyUkxxQ+CTBtGn8ivVXbYbfR2kFRksiEwTAgcJILalAqqcwZR9M3nHwnDLCvx2jK+E8S2HbfWtVTMCKRjHffj9+nN4WzVPLQAkj7VMmw0kUKqKRwiGXGf3aOrBvfKijMWrlnfxuI5okp1FAJRl+Lvh/aWWS6n2fy5t+tuzwz1nS8xhaKisjKbqhM1VjQ+RotEKJqdIofEyg2k0mpSJnPIEAD8nW9EshzmSYZlHtOYHSQeib6uREVKa25K1bWUD/W7NKWXrxO5ApWXnKlIzzPC97FIW7HJU8fPYZt3ivYE3VzGNWb8dKPLsHzGZN8jBP0r+plgwxqngUaBTcGKJZJp0ItFXlVPRrSWx4UQp1+S+Wnz23uGzY4eoyFJlove58GdCJRKOivtGRIfKNRmVKNPc+xmbJgCM5irZ+63bi9d3O0s6u3qG2pBq2QdkIarplCG9Y4+wqhDEilol6HchEnoEPiraEp1cgUSeL7f5XbP+ECScpx4lb+lJLiGdmxeABx1CG7E6n4NT3ApQdBef6gkOF/XFCxfO3iWgWwdtDOI4tAWDIfaEOCJNanOG1YDFo1plQ8tH3UuyD4PbZhWK7AHDebl9QHlQ3pX+yrCwSiGFm7HMC0l8odUQlkOnuWJF164p7vvK88ok4pjhCIwd5KV/A04ag/aUnYHYWmTDH6xpmCGA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55f40c94-8b7b-41c0-3bc5-08d9f1850db4 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:41.7182 (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: qpjF27yvFydZuPLJ0k23ybEBCphWdIiMe7frKw9YS6p2cEqcJzPTccFJwJMIs5nRkcVxwdiorowDcMKKeEGOAB6qA85y01u8lxD2kuYgAUs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::707 (failed) Received-SPF: pass client-ip=2a01:111:f400:7e1b::707; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Hanna Reitz --- tests/qemu-iotests/tests/image-fleecing | 64 ++++++++++++----- tests/qemu-iotests/tests/image-fleecing.out | 76 ++++++++++++++++++++- 2 files changed, 120 insertions(+), 20 deletions(-) diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing index a58b5a1781..909fc0a7ad 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -49,12 +49,17 @@ remainder = [('0xd5', '0x108000', '32k'), # Right-end of partial-left [1] ('0xdc', '32M', '32k'), # Left-end of partial-right [2] ('0xcd', '0x3ff0000', '64k')] # patterns[3] -def do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm): +def do_test(use_cbw, use_snapshot_access_filter, base_img_path, + fleece_img_path, nbd_sock_path, vm): log('--- Setting up images ---') log('') assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0 - assert qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') == 0 + if use_snapshot_access_filter: + assert use_cbw + assert qemu_img('create', '-f', 'raw', fleece_img_path, '64M') == 0 + else: + assert qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') == 0 for p in patterns: qemu_io('-f', iotests.imgfmt, @@ -81,16 +86,23 @@ def do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm): log('') - # create tmp_node backed by src_node - log(vm.qmp('blockdev-add', { - 'driver': 'qcow2', - 'node-name': tmp_node, - 'file': { + if use_snapshot_access_filter: + log(vm.qmp('blockdev-add', { + 'node-name': tmp_node, 'driver': 'file', 'filename': fleece_img_path, - }, - 'backing': src_node, - })) + })) + else: + # create tmp_node backed by src_node + log(vm.qmp('blockdev-add', { + 'driver': 'qcow2', + 'node-name': tmp_node, + 'file': { + 'driver': 'file', + 'filename': fleece_img_path, + }, + 'backing': src_node, + })) # Establish CBW from source to fleecing node if use_cbw: @@ -102,6 +114,13 @@ def do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm): })) log(vm.qmp('qom-set', path=qom_path, property='drive', value='fl-cbw')) + + if use_snapshot_access_filter: + log(vm.qmp('blockdev-add', { + 'driver': 'snapshot-access', + 'node-name': 'fl-access', + 'file': 'fl-cbw', + })) else: log(vm.qmp('blockdev-backup', job_id='fleecing', @@ -109,16 +128,18 @@ def do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm): target=tmp_node, sync='none')) + export_node = 'fl-access' if use_snapshot_access_filter else tmp_node + log('') log('--- Setting up NBD Export ---') log('') - nbd_uri = 'nbd+unix:///%s?socket=%s' % (tmp_node, nbd_sock_path) + nbd_uri = 'nbd+unix:///%s?socket=%s' % (export_node, nbd_sock_path) log(vm.qmp('nbd-server-start', {'addr': {'type': 'unix', 'data': {'path': nbd_sock_path}}})) - log(vm.qmp('nbd-server-add', device=tmp_node)) + log(vm.qmp('nbd-server-add', device=export_node)) log('') log('--- Sanity Check ---') @@ -151,7 +172,11 @@ def do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm): log('--- Cleanup ---') log('') + log(vm.qmp('nbd-server-stop')) + if use_cbw: + if use_snapshot_access_filter: + log(vm.qmp('blockdev-del', node_name='fl-access')) log(vm.qmp('qom-set', path=qom_path, property='drive', value=src_node)) log(vm.qmp('blockdev-del', node_name='fl-cbw')) else: @@ -160,7 +185,6 @@ def do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm): assert e is not None log(e, filters=[iotests.filter_qmp_event]) - log(vm.qmp('nbd-server-stop')) log(vm.qmp('blockdev-del', node_name=tmp_node)) vm.shutdown() @@ -177,17 +201,21 @@ def do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm): log('Done') -def test(use_cbw): +def test(use_cbw, use_snapshot_access_filter): with iotests.FilePath('base.img') as base_img_path, \ iotests.FilePath('fleece.img') as fleece_img_path, \ iotests.FilePath('nbd.sock', base_dir=iotests.sock_dir) as nbd_sock_path, \ iotests.VM() as vm: - do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm) + do_test(use_cbw, use_snapshot_access_filter, base_img_path, + fleece_img_path, nbd_sock_path, vm) log('=== Test backup(sync=none) based fleecing ===\n') -test(False) +test(False, False) -log('=== Test filter based fleecing ===\n') -test(True) +log('=== Test cbw-filter based fleecing ===\n') +test(True, False) + +log('=== Test fleecing-format based fleecing ===\n') +test(True, True) diff --git a/tests/qemu-iotests/tests/image-fleecing.out b/tests/qemu-iotests/tests/image-fleecing.out index e96d122a8b..da0af93388 100644 --- a/tests/qemu-iotests/tests/image-fleecing.out +++ b/tests/qemu-iotests/tests/image-fleecing.out @@ -52,8 +52,8 @@ read -P0 0x3fe0000 64k --- Cleanup --- {"return": {}} -{"data": {"device": "fleecing", "len": 67108864, "offset": 393216, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_CANCELLED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} {"return": {}} +{"data": {"device": "fleecing", "len": 67108864, "offset": 393216, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_CANCELLED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} {"return": {}} --- Confirming writes --- @@ -67,7 +67,7 @@ read -P0xdc 32M 32k read -P0xcd 0x3ff0000 64k Done -=== Test filter based fleecing === +=== Test cbw-filter based fleecing === --- Setting up images --- @@ -137,3 +137,75 @@ read -P0xdc 32M 32k read -P0xcd 0x3ff0000 64k Done +=== Test fleecing-format based fleecing === + +--- Setting up images --- + +Done + +--- Launching VM --- + +Done + +--- Setting up Fleecing Graph --- + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} + +--- Setting up NBD Export --- + +{"return": {}} +{"return": {}} + +--- Sanity Check --- + +read -P0x5d 0 64k +read -P0xd5 1M 64k +read -P0xdc 32M 64k +read -P0xcd 0x3ff0000 64k +read -P0 0x00f8000 32k +read -P0 0x2010000 32k +read -P0 0x3fe0000 64k + +--- Testing COW --- + +write -P0xab 0 64k +{"return": ""} +write -P0xad 0x00f8000 64k +{"return": ""} +write -P0x1d 0x2008000 64k +{"return": ""} +write -P0xea 0x3fe0000 64k +{"return": ""} + +--- Verifying Data --- + +read -P0x5d 0 64k +read -P0xd5 1M 64k +read -P0xdc 32M 64k +read -P0xcd 0x3ff0000 64k +read -P0 0x00f8000 32k +read -P0 0x2010000 32k +read -P0 0x3fe0000 64k + +--- Cleanup --- + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} + +--- Confirming writes --- + +read -P0xab 0 64k +read -P0xad 0x00f8000 64k +read -P0x1d 0x2008000 64k +read -P0xea 0x3fe0000 64k +read -P0xd5 0x108000 32k +read -P0xdc 32M 32k +read -P0xcd 0x3ff0000 64k + +Done From patchwork Wed Feb 16 19:46:13 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: 12749005 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 C94ECC433F5 for ; Wed, 16 Feb 2022 20:21:54 +0000 (UTC) Received: from localhost ([::1]:49212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQoD-0000xC-QY for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 15:21:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQGi-00048Z-14; Wed, 16 Feb 2022 14:47:16 -0500 Received: from [2a01:111:f400:7e1b::707] (port=17600 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 1nKQGg-0006Dk-6N; Wed, 16 Feb 2022 14:47:15 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NGyCXXrcRm9YXpt2c2vdaFa6ODa2ZbY50K9KVUOwUW+X7DeAqMTrXXXbgAk+ofu7jSmS0wD8HwAe3d3t3iUAZRXctrF+9dms+w2S5qmu1YPngaV1QcS8+qYpZptOTrbGlEmDEE7LyaH6kIBk6MKxjbhQcx9L/a0q3Vp4XL+sxDE+LzAnrfaO62TkEcoGovKl1XzI3d2bA1la1H318s03rtoaw53+f205uYVMkIbLnWO3ReHoIobOcOipe3EyLjpBAYQRhIaGSCh7wbZkiNWzbRwEzX7pzC1wFf1p6EbWrZQllV2PkafZFuMFhEV4dCSUyDRr6fGZXGO+kv4nzvKuXg== 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=O6Lv6n4aDfXbnWlK6Y3BwZkIoJKkuHgj/qSRgG393+w=; b=PFrjs1p/k24ShrZ8r8I4Pitq+WLfdolnFobZ0y1Z/n/2gXzItqEU/yIgDakfVekhNITag+kCQC9JL8GbaJfREl5J1lWLgZDUvHipoCUT3nnWPFKJfPOzhBv6KpzjBMCNcixGgmcqFHVYSUYJPMFIh5fXOmBFGtgKj9bC7LbFgyG6DCpzPvx08CgJgZna0Iu+sxpCL/yNwVs/oB59rj/4lPr88Lc3FUUKPG7qQKsfYGcAi4uMFC9cQPhBHs6YNHOc+TUb9XiGQSE7RWRFevSyoPXSs8AQ/dmeq/kcdVtmRc3LHZMzsuPYR8urRFMgnuMk5WSB1ZaQVNedCDc4B1Pcjw== 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=O6Lv6n4aDfXbnWlK6Y3BwZkIoJKkuHgj/qSRgG393+w=; b=Rdf5Yxf4ylEmLmgFISoERVDWy60LiwKfqCMC84bdYaPOLgeTCSTZVbmNP+b5wGAl+n9t0Gms+/FqMzqQkuxadvVe78xHoeb8iuTu1bR2JLqJUDxNQRLg6fU9nPYpmaAriQdJkpFWWqopofQFxZTsn06mozbh4HFYgQwWdcF/zPI= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:42 +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.016; Wed, 16 Feb 2022 19:46:42 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 14/18] iotests.py: add qemu_io_pipe_and_status() Date: Wed, 16 Feb 2022 20:46:13 +0100 Message-Id: <20220216194617.126484-15-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: 1eed6a08-6410-4160-eb9d-08d9f1850e39 X-MS-TrafficTypeDiagnostic: AM4PR08MB2851:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:421; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sprBzTMitKOKxFAkG5jtULGJdaQX6M4Esz0Q3Sea6IkHLTh21cksaNqOBXRyhF6IticMfsV5Qogl9qvhQqAGgz5I3TORhX4wo5iaOh7FH/02M0j3XQVLygpsaycpKgXl0PxGF3fR4XZAS9Cgi/aUuyOMz61tO9kMD3inDthYlhk+2ZPLf0VZQrOInUU3fHX/Jcyc++6NfnEPVoFM5mP4cemvPYX68Y6p5fpNp0I3zte6XEpJL4JQpf8mDJuMKOBhb14FAnlsl5aaSPDBfrEmnXjqBzWQzvlrcwWkgkdLzCPVPw3N+VfiLS6v7BcML7KYay/yLfR36dFNJ4PRhOkjVGrA7Lnqg6bTuypNaz+L6sH3GdRR+CbOeDZZEFJrRJBL47NJluElc2NxIb/eCtj/J7zwTLObBBA1f/f94F+Z6DdQqxITBEons05I5hfSL/KysjldpQPNlB7KbfK/g5xfGt6bUVGF6G4UbQGj2eYMZpoc3yIgXGv/ursuSsf+v50fY6tDAHQolayZ64PmvBpxehPIIr4moiFGdycOOhb7g2nP/O5dne7DvDJR7tXq7zUX13+LlQzJB+N6R1B6g34Svlej+Q6G0YOLc47ltJrYxRPUk22xKP/ID29dq1juaZDzrKMRcUkquhaYdKw2ZWn/MVun3+cKIvm5//717wMt1l2VdOkv9DTkrrAwAcnMrw/q/PUcskbbpXz/aM3NibhFLA== 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(508600001)(316002)(6916009)(5660300002)(66946007)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(4744005)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yazlqsZormULIHIm/x18V+fEdRaQF+mDuRiFOu6wmzBQQD0x6zpnIoiwMBfCs9TILrCCoOFDD1ZXB4KOfCHy6I6uLILVNgVc5bgEPZ7RuGRkO1WM4bwZng3EYxZiPoqdrmeg3gMUHXyEuDTwfjjv1NLCuZR7fa9mOn6oBcApbbT/8J3IZwgY+fbLRzmpCyqfiDVlfXZ0+7aiK/9uiu6MXS/L0oniTmL37gQafnVpsavDnaxsAMjVe0A5Ijn62ei3hAkgqzWo4xMIWe0bKK5ln5031iOH9e/LbHinzd4uO1COhnify3S8zHyDvBADXGiVTrkeH/+c5Zkk/nU9t8cyM2gwrl9wb1S/9dLA48p9rG06fQH0TKXgGfuFlo3Pnanx8bC5/ITNguHQ2A2o1decY7uUpBfpmZuNCCenHFmyd4egLdEC+9l7JGvCzhR5xgz9KY9/23GvlGEdk9ifuD73J+eFMyDZVLHtla0+NpLhfIpeqeQJ+gOlFVr6kj7Bc/BH+B9Cj8W5qa7zsAD0RQpaLARapFWOhOI5UPQrNprbOgjzXGLU1dcHrRj9iqs0YZ0+Ofxn99+ijo7OwmEZFcDohwMurH4p1a8NlZ9cFpZu1l5REu84aX99B2QQnYdVZvE3LL6Ju88jaSvq02rQ+pJh/U4JtnpWBqN5MiEpibsRx4CvifDhSkaTIOwwlv9+r3tAdrASC/SpMo5OlMwiHV0AeHNIzgdiXy3t3b7iTUghLm/2X2lTrE/G+61FZwNtsoGQ4qmsgMXdatbb1xa8f4kDTkADgOHd4oajDGTYWoS2ccHgrQnJu6iPV//V37z6+o3r7oWMA0jfJiXTOtHKL+6GGXu7ZHKhhQ7I1/okjygKd0N5NUTqJKfLjydJNs20DSL5dVE4FkYH8ETXrUFE3Nmowf0UEIL+GKVS9Z9KWC0VWKj58NCjL7v2Zen19apQiDBnUIHm7lv39xsFefSb8xOcv0nwwb5yTQ+lzGPwWXCnMp8LGj/GvSQdSxDlaAACMEpphhZPReSl/rD9rJEoYu9cPGSiewSyX0Vb+pe3at/EMV39ZxCexLpLJM3Td/+bbG6zWhgmyJyr8+1evoanQCuLQpkRt5ehuWP34+w+up7jUbbR6aIDf6FHjZI3szelqh/FhGzPcB7bVASjVjjwfhTmPTpmqE6POVxIMFnZJwZfGIZosXmYx8IP63YvYxVTXI/OMESChJ/kQPUHaoR5Bwl0G3Dp2EYkWLXohquKfORTBoB0IMnr/JyI8I2uDOyrFUTvq9IjBtoqIWjNdTG4xaHdVBkIvhKwu5+vH+XNie303RAHMLz5HRBq3ezkVn1PoXJVJDJekraSQPMFkv+YvEl1vxIe7ZuEdlXoww+j0wS3Z/1V04+RbpCKmruFyC+Vuya2syTVio7lSKBY7b/dh4OjIoov/NgIZ2Kom4KXrBy22Mcj2jghyxTh3lQcmO8djNli2lrwVhpxpVTmhruAV67NEyai/WlL662ZiQuKYtClBNtvZFtVG8mCEwTwzEf8DAWx4Qovr2f7MpvthDhyk6d5BFf0RQWASIgiZsHg7KThX5kN54+muf+0epaPNaKHk0QsIed3EwCmM6lOugxjFQjDYfYBNIkWR2StVlDY1GehduM1JIUrE6EvfqHux9Oi74tgsQCWprAuroHDTak/+NyIWQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1eed6a08-6410-4160-eb9d-08d9f1850e39 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:42.2663 (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: ofvx2gle/SptIBrQL9UvSvrcIIiJZnuDi9LCx3iUUdWRAg1Ksz51ZkDDFbHFtWSyyYNK03zSeWN16/tYA4n/36+3f3ExdXnBY/MsJOxtDF8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::707 (failed) Received-SPF: pass client-ip=2a01:111:f400:7e1b::707; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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" Add helper that returns both status and output, to be used in the following commit Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/iotests.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 6ba65eb1ff..23bc6f686f 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -278,6 +278,10 @@ def qemu_io(*args): '''Run qemu-io and return the stdout data''' return qemu_tool_pipe_and_status('qemu-io', qemu_io_wrap_args(args))[0] +def qemu_io_pipe_and_status(*args): + args = qemu_io_args + list(args) + return qemu_tool_pipe_and_status('qemu-io', args) + def qemu_io_log(*args): result = qemu_io(*args) log(result, filters=[filter_testfiles, filter_qemu_io]) From patchwork Wed Feb 16 19:46:14 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: 12748984 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 8B0D6C433EF for ; Wed, 16 Feb 2022 20:03:13 +0000 (UTC) Received: from localhost ([::1]:36034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQW8-0006jq-Eb for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 15:03:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQGl-0004J0-5g; Wed, 16 Feb 2022 14:47:19 -0500 Received: from [2a01:111:f400:7e1b::707] (port=17600 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 1nKQGi-0006Dk-Ko; Wed, 16 Feb 2022 14:47:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iiUI6TkbS4xOa1xamq/Eg4LPbtBNQs4P0ulRDaULxpR1BoG8JLTrL6gpxiryGP1vhDegCt/4WE9KQkYJU9q89ShIoSM1i06hg0M44MOfzkvI0vjRo2D4kPy13bCNi2UUy6iO7d/jyu3Sdt870hMjLzO7954mWD3HYmrLnAIgJ/pKok77WrocRygGof4X5GHR3wJulLS6diK2Lx0M1a+1kdjkZndQnlWiZYXGRYE31YOR9ABTqTq9hOxZTJEIvw/2trflfBGun2lCQcY726/bRzAw4crjWMRpOvBqDjOC1gxhKhgka5imjYv1xZWBAQMerqmoc7IpKwVRn566WeJkeQ== 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=lZl+Umi061k76sgBQrDNahljTxYMMdNE0wxhbC4RHRs=; b=a2tjG91ObeCpwLJfDVOUA2sLAT6a5tHZqYPt9LidA9Z1PgGTSQgJnBzjJfGxAtG90IUbFW5S+jqGeMeaI4D0WfX7onPQozHgkRHn0DUyUzLbQtXW2e/CGmRUN1stDwzKfFkWgQq6DmB8qATPRnE//MFULp0yBlN9YyixRhFxrVVxrCTxItIVSC6mll76EFnKMyNHJ5BtvOX3Ugm0CDWVUegN6gVGYw11M2NtSjspN+UXAZ0j8kxXogynce8nzUXJbLXErL5jCejth2I/QFZXMegv6dxp68ZQW2U/jFa0mAI9ntWC8V83FVzqF7Nq+0c0f3G4ZCmjHBdRX6tWUKT5bA== 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=lZl+Umi061k76sgBQrDNahljTxYMMdNE0wxhbC4RHRs=; b=sk5It0mVm4q8zywC8HPT0m81ubKPdnLxX1OJ+4j893svgRpwZv+8TKJK4PoppxtnS9xHMlEbkSmKDz8YyLeLw6yXtMF97w2x6liGHdA288borRnZ7jn4LQOpKLNrgf306UatFlh7BaalO5sUQeqpF1p7WQNAfmySqlbLzCsQEkw= 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 AM4PR08MB2851.eurprd08.prod.outlook.com (2603:10a6:205:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 19:46:43 +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.016; Wed, 16 Feb 2022 19:46:42 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 15/18] iotests/image-fleecing: add test case with bitmap Date: Wed, 16 Feb 2022 20:46:14 +0100 Message-Id: <20220216194617.126484-16-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: facb36a3-44c3-43d8-82d2-08d9f1850e94 X-MS-TrafficTypeDiagnostic: AM4PR08MB2851:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:88; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KbsHiJRK71IeIejZcPTpezGXJuuQy7pCRYAfVNtviv73VKmZlommx7aR+x0+5Lhm2XE9R1PW56c2cK8b900hhFSuOtJGrqekxdEdkXdmYyI8E0P6e3pCQyoOyZJojM9nAHKmRlhLq+RHQo49JvLT+IDB82las7swVMdG1IX8YKT5Q22+ZoEpZSUN4+6ufnVrzLc1YmOhpG8Tk4IOsRc2pOUZocqbH2VhIbFJ85rqYcKrHsqf8YuJosYZigEghk1YgKWTaHKY01pQKUqlcvokZhY+p/L7+UE+77ByNkfrQmA41u00kwKbqzQn/99SVfOw9BuJivD7hzfYGxnoTrqpPHN6nQVjPsni8JTgkKmwygLLjpVLRnc2hkVnaqMuzkhOazetcikWCRpAt6gubHLc5eyXtJ8Md8X61WCtWIR22+PgaVgKazbahTa41MB7wseWGt4w+73GotStORTUB903oXd5zJf2pWWpOAtSAGfnpJlydS16RnHd0/HRPRyn63W+k6tBUG0Ihp2C1InMu3RQaWaYAxQNkStTg9SCUWbbkfTAdMS2Hd/SAy1aF10yrUSaHShd90D1FJ3Gyb0z44LkkOk8mkTneZiJZy1tq3ulpfKpm1/AxCDj+ZjuN9aZt8dh/WfrlfFYvuDRUev8T5Ox7xeTfuT+8dGmHHBfUJxqohPCzo+VQxHD87n5MgNp0VdSqXmmm85q2ranoOPP09yxRA== 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)(52116002)(7416002)(6486002)(1076003)(36756003)(2906002)(86362001)(83380400001)(508600001)(316002)(6916009)(5660300002)(66946007)(66476007)(2616005)(6512007)(66556008)(8676002)(107886003)(4326008)(26005)(6506007)(8936002)(38350700002)(186003)(6666004)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E2J8tRVN6hrpTqopHCLg8T/vVhQS+HEiGPhSdf2dYaTJH0GRRZRwkPLaEDFo+BvJEDhOiRmzs3zRjn1W/fr/1chw+EGQDTUXxHhfGx4+DGEi0HnEtarmkVirJVWbRW9pHPV9Y2En+kDM5oFDkIHdZbVHQLOHBcRtKXzVW77nJL+/4Nl0/UlbA2TqVDWKrZc+9js0OFr1Sbk8JBCLMODN078Z1vZKdk74VHl1MhqkeAdYdbqBp9n6AoWrYfYNt56l+Sct6M//HZnseo7NGcAdBBJfJRDEP+TyC9s0ZJj1uHJFIXEyWL1wnQPQDJ12hbN0kjfNUMtdLvnz2j/+X5WoGFfEGb21X23GcD8F/2fwKFyNEHklW+pH1jjrCzOiWHimBoPr1/NFw47MTFOrDzUKO1rDnWFYNtnlBW/lRiNpe1CeI8cNfDoCEaI1d6MbK8N+5UmvtvFaGkU6aY5Gwhgdo+JbO3rvQvx3dVKPwKLGUfrlslsCSGinjr7wZiFYDvEFz5N/Tt3Z5S27P8KiDxy1GL4vfKyykerITZhCBDybGGQPcM3HXGHmqH3hnP8hGpX5Bv/0MLWfZTTA26L+4H7nSqYffcZSDsVPXUU4kcP+dSRLUmZjLWZF7oDvfpYApE0AoEHeew9BsuHMNI+W2B5UdaHwDN137Kezc6AkUrRdOoJWePwnXaxvbuQo2oqqF4+5XdIyjG4jFUkUUEf+peWyA4fnZI0P+VfYvbvuhDdJaA5Y5ceLXDIoWm252LXaPFounaNCqln6tXe6yqUiXk47X0o61o/TYzX+W9n/q4ukxeFExOhN3MiRkp6m7TFB5rLerTwgQKBVVfojqFgLadHCDWPpZl5Ojn6nMlXL5UNJiQZJ3TDz5qCwT/UZKN17I6i6J57fF8FuBOJlTlYF9iBGpNbPuUtA++RYnHzjJTWy5TfmMg/XDMyr1vn/lpEik4ujKkwRE1jsmj+7u5Vk2M3AVOf4U0vbVE71I+DbbUlWifPRcOFs/SfM+7kdTLiI0QCjKDpF6H0h41kO+d4PI3I9lifYBOGotyJW/rnNY1t4YuQYQCbR0a0XxC/kPevH9iwWkxswudOt45wDDP6D0dJd27tCv1GromJx3Rc/QBEqPb+YdlnHVn4BM7QyHiHPoXLPkvckw4SJ2IjAMAGiEfcjrh43beCuBVe4VZ47F1RtlkOdB5lEMiv75Z4OBxJe4pdMgEYj3wa9YSiyBOFzR6qkgLp713hNpQ68qMh2eBB2BRMPat4e/iiJbdP1jctelIH8Fr+ZHL/NfM9tHNdkY+aUQ2njyO384YpXdktiFw6DRXUIXolVRzLov1JKyJDt2Ys5wcK4P1wkgs+ta4kdrbbGlHOaEWyA7L7FNMxONrWmtW/Wqu5PU6lozlSFlfofd8r0KYVQtky1+NV6KfrNU8liWYTAVeL6jdRbwBkwYfZ0PiEqIDVaq/dvokAeWIg8OsbRjDOm9lbnHEvVT/Ubq4Wd5iwY8mkem1dEe3S8LB/19reLUVkm1EAXTO+ZAr5pk7i/3OpnJftK9yNatL5dyEhdLi0yCFo4/+jtyl2IG0aej7OTf1cKWOQayAFY7uHGd8z4A2fMnhXN8uuxp1MoWsEKEegT7HuocQDFnaXPrmI/XbwWoRCOpNqdgyAB4M/aIFmwh33JQSfnoVOt9x6wPkfmPA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: facb36a3-44c3-43d8-82d2-08d9f1850e94 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:42.8443 (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: Nd/R2mQZCDsvMMue6u8J/dRVGkBmI1FuI+9XcxKhQz8krhNkt0IGLwzyStWzvoy0VHUkNWcrHfx2uHjn9XPVg4k9KoJ7ierd+k3dpB1fb48= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2851 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::707 (failed) Received-SPF: pass client-ip=2a01:111:f400:7e1b::707; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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" Note that reads zero areas (not dirty in the bitmap) fails, that's correct. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/tests/image-fleecing | 32 ++++++-- tests/qemu-iotests/tests/image-fleecing.out | 84 +++++++++++++++++++++ 2 files changed, 108 insertions(+), 8 deletions(-) diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing index 909fc0a7ad..33995612be 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -23,7 +23,7 @@ # Creator/Owner: John Snow import iotests -from iotests import log, qemu_img, qemu_io, qemu_io_silent +from iotests import log, qemu_img, qemu_io, qemu_io_silent, qemu_io_pipe_and_status iotests.script_initialize( supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk', 'vhdx', 'raw'], @@ -50,11 +50,15 @@ remainder = [('0xd5', '0x108000', '32k'), # Right-end of partial-left [1] ('0xcd', '0x3ff0000', '64k')] # patterns[3] def do_test(use_cbw, use_snapshot_access_filter, base_img_path, - fleece_img_path, nbd_sock_path, vm): + fleece_img_path, nbd_sock_path, vm, + bitmap=False): log('--- Setting up images ---') log('') assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0 + if bitmap: + assert qemu_img('bitmap', '--add', base_img_path, 'bitmap0') == 0 + if use_snapshot_access_filter: assert use_cbw assert qemu_img('create', '-f', 'raw', fleece_img_path, '64M') == 0 @@ -106,12 +110,17 @@ def do_test(use_cbw, use_snapshot_access_filter, base_img_path, # Establish CBW from source to fleecing node if use_cbw: - log(vm.qmp('blockdev-add', { + fl_cbw = { 'driver': 'copy-before-write', 'node-name': 'fl-cbw', 'file': src_node, 'target': tmp_node - })) + } + + if bitmap: + fl_cbw['bitmap'] = {'node': src_node, 'name': 'bitmap0'} + + log(vm.qmp('blockdev-add', fl_cbw)) log(vm.qmp('qom-set', path=qom_path, property='drive', value='fl-cbw')) @@ -148,7 +157,9 @@ def do_test(use_cbw, use_snapshot_access_filter, base_img_path, for p in patterns + zeroes: cmd = 'read -P%s %s %s' % p log(cmd) - assert qemu_io_silent('-r', '-f', 'raw', '-c', cmd, nbd_uri) == 0 + out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) + if ret != 0: + print(out) log('') log('--- Testing COW ---') @@ -166,7 +177,9 @@ def do_test(use_cbw, use_snapshot_access_filter, base_img_path, for p in patterns + zeroes: cmd = 'read -P%s %s %s' % p log(cmd) - assert qemu_io_silent('-r', '-f', 'raw', '-c', cmd, nbd_uri) == 0 + out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) + if ret != 0: + print(out) log('') log('--- Cleanup ---') @@ -201,14 +214,14 @@ def do_test(use_cbw, use_snapshot_access_filter, base_img_path, log('Done') -def test(use_cbw, use_snapshot_access_filter): +def test(use_cbw, use_snapshot_access_filter, bitmap=False): with iotests.FilePath('base.img') as base_img_path, \ iotests.FilePath('fleece.img') as fleece_img_path, \ iotests.FilePath('nbd.sock', base_dir=iotests.sock_dir) as nbd_sock_path, \ iotests.VM() as vm: do_test(use_cbw, use_snapshot_access_filter, base_img_path, - fleece_img_path, nbd_sock_path, vm) + fleece_img_path, nbd_sock_path, vm, bitmap=bitmap) log('=== Test backup(sync=none) based fleecing ===\n') @@ -219,3 +232,6 @@ test(True, False) log('=== Test fleecing-format based fleecing ===\n') test(True, True) + +log('=== Test fleecing-format based fleecing with bitmap ===\n') +test(True, True, bitmap=True) diff --git a/tests/qemu-iotests/tests/image-fleecing.out b/tests/qemu-iotests/tests/image-fleecing.out index da0af93388..62e1c1fe42 100644 --- a/tests/qemu-iotests/tests/image-fleecing.out +++ b/tests/qemu-iotests/tests/image-fleecing.out @@ -190,6 +190,90 @@ read -P0 0x00f8000 32k read -P0 0x2010000 32k read -P0 0x3fe0000 64k +--- Cleanup --- + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} + +--- Confirming writes --- + +read -P0xab 0 64k +read -P0xad 0x00f8000 64k +read -P0x1d 0x2008000 64k +read -P0xea 0x3fe0000 64k +read -P0xd5 0x108000 32k +read -P0xdc 32M 32k +read -P0xcd 0x3ff0000 64k + +Done +=== Test fleecing-format based fleecing with bitmap === + +--- Setting up images --- + +Done + +--- Launching VM --- + +Done + +--- Setting up Fleecing Graph --- + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} + +--- Setting up NBD Export --- + +{"return": {}} +{"return": {}} + +--- Sanity Check --- + +read -P0x5d 0 64k +read -P0xd5 1M 64k +read -P0xdc 32M 64k +read -P0xcd 0x3ff0000 64k +read -P0 0x00f8000 32k +read failed: Invalid argument + +read -P0 0x2010000 32k +read failed: Invalid argument + +read -P0 0x3fe0000 64k +read failed: Invalid argument + + +--- Testing COW --- + +write -P0xab 0 64k +{"return": ""} +write -P0xad 0x00f8000 64k +{"return": ""} +write -P0x1d 0x2008000 64k +{"return": ""} +write -P0xea 0x3fe0000 64k +{"return": ""} + +--- Verifying Data --- + +read -P0x5d 0 64k +read -P0xd5 1M 64k +read -P0xdc 32M 64k +read -P0xcd 0x3ff0000 64k +read -P0 0x00f8000 32k +read failed: Invalid argument + +read -P0 0x2010000 32k +read failed: Invalid argument + +read -P0 0x3fe0000 64k +read failed: Invalid argument + + --- Cleanup --- {"return": {}} From patchwork Wed Feb 16 19:46:15 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: 12748995 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 E5155C433EF for ; Wed, 16 Feb 2022 20:12:11 +0000 (UTC) Received: from localhost ([::1]:50658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQeo-0008MW-JK for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 15:12:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQGc-00041J-7f; Wed, 16 Feb 2022 14:47:10 -0500 Received: from [2a01:111:f400:fe0c::710] (port=6627 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 1nKQGZ-0006Nc-Ko; Wed, 16 Feb 2022 14:47:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PwiGOKGKYyuo/EdSjDYv7zbCsEodaxgbSav2xo0g/Kin417IUYRmeSsts5PtZpR2LwJ0xt1TmoUYHZpJQEtwAtQFGfG+3Z6OthSwYimAs7jO6hPsP/KM/UMGfXdpvTcZ1XjT+MTDMVWJOHtXktP2DSNBuai594gh6KC6V3BK8zHloqqW9bRWH7NLts1OQZikwRSYColgI/X0M/DqDXMGsC/QjTzJZzvE9s916ZW0vXSkEI+BJtAttMO1rOUohcXxCdafB570SZhrmDt7qdK/+/bJMXCUZBPakDRQLzbGFCnGa0OG35GrSedylgNlILgbJPlp9jE6ttyYcHkPmVRYJQ== 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=3/xI1bwVWeXrYH4wm9UVaY0DLc7UYdQSVr2/1c+jy88=; b=JpgvbDEjqbEMlCfjxDxSUXqx5l1gEj0SsUBRPSh3I5DGNLdwxRCJf8fP/psFcdh/2Me8YYFobo1cGTc2AaRa2CNIjxwr0AYbsq18wvzSpEW6mI7UI0Gv7ja+DoP/872gMvSZ/cSBiXLuJoK3LLp3x1c39a/RmwIL1sQSy9PKzu9vdDCke2X0BhviUu7s0z5SIFlf5pnn1CoKdHPSxcLCxoKXbRNaF9Gjm5taGDr+rbk4Ojt+Cx4a8JLoL34EKn5hjVRMGkRl/sCxFLDn3hp0TsM0U8vleioD23uqxSHQhBC/LNhSgelxg7AI/2Xns/Mien3jzuApwWQWcJHKbdgV1A== 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=3/xI1bwVWeXrYH4wm9UVaY0DLc7UYdQSVr2/1c+jy88=; b=ZMUo8yAqs6sTKHy0t0U50JG5ClLMtDke1HxsQHTbRWQhSvl+FasVvnr8SsIoosr2enRdoPSi27Sur825yDQp5pYS50q35Wv93s4aeU0ANP5QEqbdR5T0vVkNL2nbM9KDdL6CCcvutJ8l/Kvatsujg/AIO1GBGFXHpl+oTr82Q/k= 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 AS8PR08MB6856.eurprd08.prod.outlook.com (2603:10a6:20b:351::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16; Wed, 16 Feb 2022 19:46:43 +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.016; Wed, 16 Feb 2022 19:46:43 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 16/18] block: blk_root(): return non-const pointer Date: Wed, 16 Feb 2022 20:46:15 +0100 Message-Id: <20220216194617.126484-17-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: fb75a533-a721-4e22-ca54-08d9f1850ee0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6856:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FEJSIVqNCDJDJsmUzlZFcXHhRqyGG6JmfJXueJ4cQJT6ytKwo3xu2P/Fjc5y3Et+xDJ4MZ40h/wZeroAB1iDplqJ+SPnLSoSGfD0XySlE8ORytloAVJCrY3k4XojVoCwGoSfVY/gXMVpEXa5VQWEto+t5xyjC3kqiv4ozsZ3BaR8ynRc/nWYu1akMUDR24S3vxnB1qQvqz3Ytnt3Vgm6tD6LPeIVyJg+GQ1nBDvmUu2iD4CRTlVOIx2tjbgopSZ9cT6AQo0fcPFWLIag2Ebi+Fd0v+m/5VcqNjYLqXRGw7D8M8mZy70DHCXaYuQOb7vXY5FJ4106IJuner/eILGSGvIYTQ2gKCabEH4QNRQeJFpfsDDr54VKPPjHsoZwo8LkrC+nBsetbHLCUqqOyiz4y8XoyQcaAxJoHVgOUe0g3Pmk3g9qqKFzNnPrxn++QnL9GB07w59amAb3+pO0g3Srk9fKjsTTm0oNGhc+4kK+FYYO5PtnHAS1unRf6X9SB9mi4bo9zYBry5+BZXX81riZcAzZvbQv60iODpUTgF5nT8HuxtHNQmHyPT9fWaLgztLf6SVZ8N+opVd6ptphEbChPDZ3AHk9cjEMtsyDCehl6fVQtNbnKeEYOnx6ci9sZ2ofVxoxdVc7n659oBZV7lni8HvKQ0TeW1Sybefb6Np/JkdEXK9IVhtBJAHC9Vv70MWjmx/E4RJVkyzAUvnWp6WHkA== 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)(2906002)(6916009)(316002)(4326008)(66476007)(66946007)(8676002)(66556008)(38350700002)(38100700002)(8936002)(86362001)(6486002)(5660300002)(7416002)(508600001)(6512007)(2616005)(186003)(6506007)(83380400001)(1076003)(26005)(52116002)(107886003)(6666004)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yHqD8f99maPBasS10TSlmeCzfuZvsG9JvH5G99Dnmidww0OOYt42DgcyPP9LAAgwcfUgz6vzDP0FZH1l6lwualm7Tx3XICvMbiGJUdQC9RCF+xnSDBeEQo3QhcQ9BM3vua7tlGFH+Vat3peXFSdQVpVfPl7JdT1DFykehfYt2nsFYsdDzap61PXBFSyFzVlxQ5Wh77uvd+3QPt75fRjOV8JAnuuC8O1qGlUQZcu5sY/UUlWmVNuMmVcvb2La0ygl7CoiAJe8empQSue8iOVGU47JtA/2d40uAJSSR4xhQU6lGgwmYhufNPwnSKuFqlbdGvkr3UgDyRq83jVkDXiWQWHMn+mfZZvgQ+XiSx4YNV5dnfbrqzH6Znj5J6C7OB6UwbSzHDt3VYngwZ5lnqU5HRfzlvQC3Y345tChYTKub4tVhiSTKlnkql+mtLjt7R838n35xle6KG1BMWjxjgqlXbFDukuRW+xr6DJ9+jzQkFf1wOXTsI9wsW0OdY76pZhL4rfcBGmNjT0d0oMYti48OAyqzCQ21pfnz3rRc3xJd0U5MWYczbs6Th21sZMy83Vc6afohf0iI56ceADDk2QYGNBL6HO2FwB8pjckhPZAQNIjNbvUPGQM8e8owRPdPz4xJx31hwTAM+gZ9+Apvy59gqIVIE85uqfX27Swm/oJlnruTGnUkriWO3gsuQgGfN9CCh7JzQdGIPgmC7hCgFOUR3ggXj3DKaD08BWOdkYEVx1gotZNC4zWwtYjI56gN9YLidYe0iqjal1dDOl6FVF0h4JJeqJS2Gf3rEycJiDgf5PAsE6tz7DAv7eBORrDih4I7EgAFAhVqfY+fW7xBeGar9lTj1lC2JCM6uuEMWyAdwjb6eYaFd22LO6TpujYTOjOGa4Lh8SEhKxyAJ8CGzbsfwqXHDNsDDIWod8H6iYD843hcBn32CjnT+KybBC0qYw3uSK++BPwIMwjXA7TbJJGosSbAEbOzqzmmo0rIKpRYhzFAqa5vcjQUAtZyVnOSFOFeS0wxRQv/5jlR9PamZx29gnN2/BrwrCPiNzgt12TywGXRkw5I4hIp3kGWXzA977qV6WqZ2Xzt6H68Vxn+y4s1nBtXJ6Y+COpi5p7Lvu0Q55GQT2h681/7ovzAAWuHak8QDbvHjAUhm9VawgBLe50HJEvX4gFYj2R2e6/YuRCmqoUTi2rIGQ96dNdXZxjyk58Mk3tPM/kfkvAEhq+UxGhNGKOmnGkags3Lma1Q2e6CtW+0a9WTvSCfrgo49wO3ruTGIGtHEyGbWkHuL53UF07E5L4aUYxZeUikpu7SNB7q5rHiOi6NxuCJn2nQilkSYWY0uxRGm2ymeBH/bu6zdwkknooxW5FW5MHhpGeqpol3Xdr4pueTn9X4qf1sBXgG5wlyw3HK0yn6BLgN2xO+TLEfi97+y/+qq57SihlV9OUsG439tXryDwc7E9DeCi6qDtPO1vkUgcFQnh9St3hZZUCe8gQHSn3QHWQP+eGLjh3fbCdsh10zz/0hAoOIik6TRU0VI6M8xeDi1R8UqhjDRiZ2JBRcWA9Up8xyPgLEGAa/4LlaVEXbDnj009uiwe2psMcYzfPSDIAKBHvyx/Sp/FrGHD0HZ/49ttQVJmGStE5vPhcJjIFf0oz4Ary6OgdUaDt8/PdrBNlmLu+uIgEObxCgw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb75a533-a721-4e22-ca54-08d9f1850ee0 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:43.3130 (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: m4pisq6rQoXPdoRnaBIfmLrrQYwn7ALPy2SK+WONDmkUcBWjI7XQCWbNWEkRK1YgwJFgPw0WI8OQfbwrmBn9CvHgpq2ZN7RbhsHQzTeCULM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6856 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe0c::710 (failed) Received-SPF: pass client-ip=2a01:111:f400:fe0c::710; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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" In the following patch we'll want to pass blk children to block-copy. Const pointers are not enough. So, return non const pointer from blk_root(). Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/sysemu/block-backend.h | 2 +- block/block-backend.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index e5e1524f06..904d70f49c 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -277,7 +277,7 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags); -const BdrvChild *blk_root(BlockBackend *blk); +BdrvChild *blk_root(BlockBackend *blk); int blk_make_empty(BlockBackend *blk, Error **errp); diff --git a/block/block-backend.c b/block/block-backend.c index 4ff6b4d785..97913acfcd 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2464,7 +2464,7 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, bytes, read_flags, write_flags); } -const BdrvChild *blk_root(BlockBackend *blk) +BdrvChild *blk_root(BlockBackend *blk) { return blk->root; } From patchwork Wed Feb 16 19:46:16 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: 12749003 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 348F2C433F5 for ; Wed, 16 Feb 2022 20:19:23 +0000 (UTC) Received: from localhost ([::1]:40928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQlm-0003YF-8n for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 15:19:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQGf-00048Q-BK; Wed, 16 Feb 2022 14:47:16 -0500 Received: from [2a01:111:f400:fe0c::710] (port=6627 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 1nKQGc-0006Nc-Rn; Wed, 16 Feb 2022 14:47:13 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R9K/Bp5/h395Vd9yFG8SHyGQCHlcuBd7d0Is0u0mNZ8SB6LLpdYD9Xh3/zp80lAi+5IDo+wL19bfN/l06zLMr6Q9EYeWjStMf+c2Ep9BCVhvY/GLFhcK2LBnwr31gbuyhRSHqHQH9WGRVR7iprL4rX/9oZRzU2cS+rWTH0e91aG/8G/NeZy0PBV2DPA29L+sVevJajX+usoXaB5NCadH+26OwCwSG+xjXfTWxNtAfxB9g3nRsoXfIsab7cRuAryiqrJ0Ul51DGlBA+wa8z14K2MKAz/C6pqf9fatYf/EpERnpxaQeHBoRVk4YZW02BttWiZtTPOLkJ3y73VIesITVw== 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=LH2v8hJ8u7bgt17tZ4+pwgJVfZcjnzhkcFxdy84axr4=; b=gVL3V0PPGfckPyLgWXAvay4M/G9PExV36qgRp3rppBYawJcXQ65jrR01ruyK7zBA0qPe2Yz6rX+wuQGN2O6rd70YAslToWwHrAG/lJpOpQ9y1CtfY0QZTZDzv6j3VUqXzX9LZmg7ojhYjjYgZYCQiz5UbrbnpmZSJutNGwiqzH/getI67xx5oZo5BM5STQCLRFB2bCc1qAUU05Cgg0OyrwHf3HPzcEyoxY0IVdHjSnogjfxg/Uqe8MjimpQTc61iBxI6e/aHqHX1NhxFLtTUVaUvZ524LADeDa/iZWEwH7m1ARiRZw7jaGIpeWh8vKJWXiiTejvmShPq7BhoPfiJnQ== 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=LH2v8hJ8u7bgt17tZ4+pwgJVfZcjnzhkcFxdy84axr4=; b=j89ujDaNzls8Xsr3WmfY0cmrKZLVSDadK4u0KfJejX6+a/TsyDKPHZRnrRIIKA6+l0kTEy7x4sRKs9U8aToqgJOiRMheIimtzAejvL0IlODIpSFsmyYpgWaSWL91HX0D14HmxoZyRTxvOvkiDTXr+soSC9c/G72lUt4Nc4x+894= 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 AS8PR08MB6856.eurprd08.prod.outlook.com (2603:10a6:20b:351::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16; Wed, 16 Feb 2022 19:46:43 +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.016; Wed, 16 Feb 2022 19:46:43 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 17/18] qapi: backup: add immutable-source parameter Date: Wed, 16 Feb 2022 20:46:16 +0100 Message-Id: <20220216194617.126484-18-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: d6f4936b-0997-4e5f-4d8e-08d9f1850f28 X-MS-TrafficTypeDiagnostic: AS8PR08MB6856:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KLWV40Lhg/NNl1F5ZaiJZLls/HoBeAXPY+OpXKZOF1aEjRjF2iWcb5Yx6qaNWXmKZlOibFdABGu/aAyFZwb5jMwU0dGECUGlOHGIS9e7jG5Mh1jP1/w5x5f2ONCdtCN2NBrEb2mFGgN/20OBqnANGwqeqNE8PDzX6W9SAuWvVfEUl16MR1Msrggx518LU8Tbs1YJvRZ/yKxpNbQcJfW0RKucx4k7TvI9CWFIH1aYivbGBzqEAusAGDetGX606ZGb66trMkJxSK2QrYpaZKZ6u+mD0LVzRTf65Hxq/4qSEuljemVCc6IK5efDWEMLP3ELadyhpT7/EgCTITq1NMvGDfXtbFLVwG0r/KE4FzyGQzWi0pu9kJzhq92YlksmjWkLdlgaMIvE/cgcS2lO+/xwPx/WvnMxC33OfZ8KtedFg4ta9Swon4NQBhngWbITI4oe3hJJijECra59e9zBMbBFuflqZsIhxAjFEMYGgzPhhACvsLTPll8xeEshq2aJpblmmE/g7+mCXogWOKS3JeRUmSj8YyjIx5MoubmOB76gsuweo91MVrfU5ZwZsUVV7jCvGgqzNtIWVMBZ29Dd0dEzEDRiUglhY+t9X0rp4gSdQaciG/rOMYY7/xjvDSxOtriSQg8IK5X3VKSdhhrpVm812VD/InnKZ2jZ33zRweEPID2oGKpONju/V2RAZIHvJURrU3STNzZpns08TaDk2mOJ+w== 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)(2906002)(6916009)(316002)(4326008)(66476007)(66946007)(8676002)(66556008)(38350700002)(38100700002)(8936002)(86362001)(6486002)(5660300002)(7416002)(508600001)(6512007)(2616005)(186003)(6506007)(83380400001)(1076003)(26005)(52116002)(107886003)(6666004)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JQNU2BbnWfYbMBN+guokUdVCh+9gQ+wTmjsj9gPgw7vur0tKCqzlAwUjhSXxFtbHcUBNz6zR6zfZGrnlQktJesSUko6B3HbCAUJjIdosXd9KWef3rTbc3QNlhFQyClusEeAk+XUzW+NXr3BNWtYxKjkpEn7PKLodZGLqJP6YC2JIsbCmqk7AYO1gjAw6DOS61Yb8FLcnpVjoHuDo3P3C0Knjout5DN1/lGmnI9CDUOO5FL2JOcqP+viaam7557OnuM9tqoAKJ1kTFDY/gKeBoPGdRShcsREZMz8kuhgXfWgjHXSiKlQVuuAXoM8TVen5CZlRs0boEbXGrhlxZHLkkDMqT2OMxJjAyTmcl6JMja+BiBUkXiUhIngGYyzmmTCROx4PqsSf1fuUQjRIlzVAmxewVgqVOEsecekd9FcwedsReTJEfXuiCesNqD7QzT7Sb+PyRyiRFPUpcJZpN3oT7QjQrMhs03zDqVR1nTrtll5fn2SSR36Gs+DDoa+phuD8KD5tdx6+3GyN7iwlBLdVi5RF2sXkSGzMD3/PXtOaJCbPQRtc6zowIxir5EbXMZao7v6CMJ4cCLBRBSk5qmzMdWj5yv3s30xgL1eeJhfL6F4Yxrp4EOUgs+H5/vbz0nrhhg14ObhUTQWVqTSO3dBbs4ool44NK6wHj87v7Mtpcf4dIotk5GJKlm4rIFQjJzaRwQkV3PFwp56OQ5r7eCzq0byvZ9vOpVdkdF9bDwP6fs4A6HEytkqvaOUU7c5EG7JelZTkHuS4/4bqrah4J6bco+8dwOmZUtd2a9MbIPXutOI7PimkeoTqu8kRZpjINrNoxZfP7WagrtwYD7NMtMfB/XFuIyzax+JPO0SaInYPk+CtRR9aLeU04BUaQ3/pfaWFkQXvOJnhaxnCeAxSIWHrwe5VEimRlPKsaD9/6v/6u2aIPKNwxQo5qv0msfIQX46KpxbWSLvYmFPQws/ZPdLtJyiM4kWPb+E4i4C7RbFSs7umG6FeyiZ6PwvINENBSUSARInFMMjcdazDXEErk9TB1MEanHc9IEU788LhSdE71ZdiYxZKPofuk0KHPCIZ4TnE42m5SxP08SZvzb6tmSM1azEUw2C+//9ESCffsMERj7TNlKpgzghjir/jXBbLgNFwNr24jzborFk63vOlsNI1G1gWN++FZREqXOfcEqDfusiypQTv2VU//XTaKZNp8/k3PcamKQKReqbVFwfi31VRP3LAB81ZzWhPA0cX9g2aHjgsvNp/MMtPERR+MS20wx52o1NxpDHSKcJyPiqx4YydZIsK5yUiF0Q8RWndH+Z8/aRQ0TUN91J9hXlS3y9mFiJk46X9wEL/dkdNg9tpBfLrcYtXj572rKXLXudg7jp2f3NTzR7sJzTuy3MI0ZZ56QIzJe2PFT6DBoOxJtom/nQ2i1kVHdc1C0PSdwVYJT5y//0iqjRq/5apBI3+d9HYkiN7HOlU9Jpk5XnS99vNWpAiyAGoMBMVbKNHKcPWfS/vl2I6wdp+3r0BvRpplbOHYgSivumF/mzARtG4qSfkkkgCYnKCjtHXTWyfbNggfPaoOK4hZO+LeT9I3HvbffOf8wOvROA47SyBTh1XWXLRt5X//tfd3BXsw4o8TAeZ1D3vdNkODtS3Mbl46YLXnub7hsxpg4giqaA0dqWSWJKgbIHvlw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6f4936b-0997-4e5f-4d8e-08d9f1850f28 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:43.8129 (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: eYK/N9qGaIx7GC6AoR3iUNTPKhD81a+OGF49ar7EQUpIprTHH+qgMmUR0c3C8gEn21SWhyPzJTSZB+PHYiMzTeW7pMT8PqLI/tRBSz5ZRRU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6856 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe0c::710 (failed) Received-SPF: pass client-ip=2a01:111:f400:fe0c::710; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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 are on the way to implement internal-backup with fleecing scheme, which includes backup job copying from fleecing block driver node (which is target of copy-before-write filter) to final target of backup. This job doesn't need own filter, as fleecing block driver node is a kind of snapshot, it's immutable from reader point of view. Let's add a parameter for backup to not insert filter but instead unshare writes on source. This way backup job becomes a simple copying process. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 11 ++++++- include/block/block_int.h | 1 + block/backup.c | 61 +++++++++++++++++++++++++++++++++++---- block/replication.c | 2 +- blockdev.c | 1 + 5 files changed, 69 insertions(+), 7 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index a904755e98..30d44683bf 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1436,6 +1436,15 @@ # above node specified by @drive. If this option is not given, # a node name is autogenerated. (Since: 4.2) # +# @immutable-source: If true, assume source is immutable, and don't insert filter +# as no copy-before-write operations are needed. It will +# fail if there are existing writers on source node. +# Any attempt to add writer to source node during backup will +# also fail. @filter-node-name must not be set. +# If false, insert copy-before-write filter above source node +# (see also @filter-node-name parameter). +# Default is false. (Since 6.2) +# # @x-perf: Performance options. (Since 6.0) # # Features: @@ -1455,7 +1464,7 @@ '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*auto-finalize': 'bool', '*auto-dismiss': 'bool', - '*filter-node-name': 'str', + '*filter-node-name': 'str', '*immutable-source': 'bool', '*x-perf': { 'type': 'BackupPerf', 'features': [ 'unstable' ] } } } diff --git a/include/block/block_int.h b/include/block/block_int.h index c43315ae6e..0270af29ae 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1348,6 +1348,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, BitmapSyncMode bitmap_mode, bool compress, const char *filter_node_name, + bool immutable_source, BackupPerf *perf, BlockdevOnError on_source_error, BlockdevOnError on_target_error, diff --git a/block/backup.c b/block/backup.c index 21d5983779..104f8fd835 100644 --- a/block/backup.c +++ b/block/backup.c @@ -34,6 +34,14 @@ typedef struct BackupBlockJob { BlockDriverState *cbw; BlockDriverState *source_bs; BlockDriverState *target_bs; + BlockBackend *source_blk; + BlockBackend *target_blk; + /* + * Note that if backup runs with filter (immutable-source parameter is + * false), @cbw is set but @source_blk and @target_blk are NULL. + * Otherwise if backup runs without filter (immutable-source paramter is + * true), @cbw is NULL but @source_blk and @target_blk are set. + */ BdrvDirtyBitmap *sync_bitmap; @@ -102,7 +110,17 @@ static void backup_clean(Job *job) { BackupBlockJob *s = container_of(job, BackupBlockJob, common.job); block_job_remove_all_bdrv(&s->common); - bdrv_cbw_drop(s->cbw); + if (s->cbw) { + assert(!s->source_blk && !s->target_blk); + bdrv_cbw_drop(s->cbw); + } else { + block_copy_state_free(s->bcs); + s->bcs = NULL; + blk_unref(s->source_blk); + s->source_blk = NULL; + blk_unref(s->target_blk); + s->target_blk = NULL; + } } void backup_do_checkpoint(BlockJob *job, Error **errp) @@ -357,6 +375,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, BitmapSyncMode bitmap_mode, bool compress, const char *filter_node_name, + bool immutable_source, BackupPerf *perf, BlockdevOnError on_source_error, BlockdevOnError on_target_error, @@ -369,6 +388,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, int64_t cluster_size; BlockDriverState *cbw = NULL; BlockCopyState *bcs = NULL; + BlockBackend *source_blk = NULL, *target_blk = NULL; assert(bs); assert(target); @@ -377,6 +397,12 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, assert(sync_mode != MIRROR_SYNC_MODE_INCREMENTAL); assert(sync_bitmap || sync_mode != MIRROR_SYNC_MODE_BITMAP); + if (immutable_source && filter_node_name) { + error_setg(errp, "immutable-source and filter-node-name should not " + "be set simultaneously"); + return NULL; + } + if (bs == target) { error_setg(errp, "Source and target cannot be the same"); return NULL; @@ -451,9 +477,30 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, goto error; } - cbw = bdrv_cbw_append(bs, target, filter_node_name, &bcs, errp); - if (!cbw) { - goto error; + if (immutable_source) { + source_blk = blk_new_with_bs(bs, BLK_PERM_CONSISTENT_READ, + BLK_PERM_WRITE_UNCHANGED | + BLK_PERM_CONSISTENT_READ, errp); + if (!source_blk) { + goto error; + } + + target_blk = blk_new_with_bs(target, BLK_PERM_WRITE, + BLK_PERM_CONSISTENT_READ, errp); + if (!target_blk) { + goto error; + } + + bcs = block_copy_state_new(blk_root(source_blk), blk_root(target_blk), + NULL, errp); + if (!bcs) { + goto error; + } + } else { + cbw = bdrv_cbw_append(bs, target, filter_node_name, &bcs, errp); + if (!cbw) { + goto error; + } } cluster_size = block_copy_cluster_size(bcs); @@ -465,7 +512,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, } /* job->len is fixed, so we can't allow resize */ - job = block_job_create(job_id, &backup_job_driver, txn, cbw, + job = block_job_create(job_id, &backup_job_driver, txn, cbw ?: bs, 0, BLK_PERM_ALL, speed, creation_flags, cb, opaque, errp); if (!job) { @@ -475,6 +522,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, job->cbw = cbw; job->source_bs = bs; job->target_bs = target; + job->source_blk = source_blk; + job->target_blk = target_blk; job->on_source_error = on_source_error; job->on_target_error = on_target_error; job->sync_mode = sync_mode; @@ -502,6 +551,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, if (cbw) { bdrv_cbw_drop(cbw); } + blk_unref(source_blk); + blk_unref(target_blk); return NULL; } diff --git a/block/replication.c b/block/replication.c index 55c8f894aa..c6c4d3af85 100644 --- a/block/replication.c +++ b/block/replication.c @@ -590,7 +590,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, s->backup_job = backup_job_create( NULL, s->secondary_disk->bs, s->hidden_disk->bs, 0, MIRROR_SYNC_MODE_NONE, NULL, 0, false, NULL, - &perf, + false, &perf, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL, backup_job_completed, bs, NULL, &local_err); diff --git a/blockdev.c b/blockdev.c index 42e098b458..6997eccb4d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2878,6 +2878,7 @@ static BlockJob *do_backup_common(BackupCommon *backup, backup->sync, bmap, backup->bitmap_mode, backup->compress, backup->filter_node_name, + backup->immutable_source, &perf, backup->on_source_error, backup->on_target_error, From patchwork Wed Feb 16 19:46:17 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: 12748997 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 2F5C0C433F5 for ; Wed, 16 Feb 2022 20:16:32 +0000 (UTC) Received: from localhost ([::1]:33518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQj0-0006lu-SV for qemu-devel@archiver.kernel.org; Wed, 16 Feb 2022 15:16:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKQGi-00049S-IL; Wed, 16 Feb 2022 14:47:16 -0500 Received: from [2a01:111:f400:fe0c::710] (port=6627 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 1nKQGf-0006Nc-UV; Wed, 16 Feb 2022 14:47:16 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DoA99NSt5dj9I8XgSN5og+uD87bcXKa7vcu9kb1wElnwPbOKs7vVf5o9LrlvCo/8GKBhjUH6zNZv6ISJMZ9qU9a2rYPv03J/MQpONsMyLoQTehiyR++kG7Q13o0rDYzlTOhDzH6206qK+jreoogck7uKdwVRzNsOFR5mptRW5wI81qmFVRnLbGVRMVK74ka7hm5HCXxOvPjw41J7N6X5lW4eGpGsSwk/QxLr8ntS2i623xLzJuZkr7qW9AT+5SP+L/ofgPOqJS7VFvlpy+hDBWVPws/hIh33rRovo8pIeGgCXzNsKFrKNq+kyZo+2rY6WuHJbCU0kHEQ0HrKmZTcDg== 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=8FoFYGMddrGc+CMUYmTun1Gd52uC9HsURxCzDf+uuow=; b=A6+fEzmpyTGHm0piCNJ9PKZTRTLHMgrxdz+QEpbRffMXPgpty9JQMS2S7Rz2DlLBtk2HYHivHo54vILZ25gLIlrU7g2r8FIcCxXNOpu1Ez3YbF6Pbs+RdzCZ5gkUiaMOA+bbr35v2lGf6+MDnN9QpSMQxyaQDtfqxwpK2tL9CUNLc9qocFA5nm83V2N2sip4VekF9bnMTlULH66EMlOMyFWXUw4peob9A8NYVWgB6/Gmttvz8XJTS/X6t6IKZrfnpWWt4H8U7juOgDVrGVlWlHajXLKqvciZLTliFP22Q2L2CnkubcAqNr+8dxjQoeFwSf0mvF+2yyrz/QBuAeGW4w== 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=8FoFYGMddrGc+CMUYmTun1Gd52uC9HsURxCzDf+uuow=; b=CjStleWYujDQQzap5MHaFZjWETcjZR6pZdFO++T/BqNigLcByy6EgHJTi+5bSUelakYPCEe1s9oeW3QCzUdzO3lJnHWa+WK+7z4ir+R+LpOkNcxSljjtv4aEJTTSv4Du9fXnK+Y870qNfMoJ08LsRWxU3V6OnHFnOlLsZilB1Fg= 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 AS8PR08MB6856.eurprd08.prod.outlook.com (2603:10a6:20b:351::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16; Wed, 16 Feb 2022 19:46:44 +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.016; Wed, 16 Feb 2022 19:46:44 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v4 18/18] iotests/image-fleecing: test push backup with fleecing Date: Wed, 16 Feb 2022 20:46:17 +0100 Message-Id: <20220216194617.126484-19-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220216194617.126484-1-vsementsov@virtuozzo.com> References: <20220216194617.126484-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:20b:311::10) 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: e006c310-83cc-484a-34c7-08d9f1850f72 X-MS-TrafficTypeDiagnostic: AS8PR08MB6856:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:398; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c9v8rFSXIaHI6lBX31ikKC5CLiMe3r+6+S9so6PULHgEUJsdQOeJiMEmXi1o7UsFQlfmGYPNg5joY2XK2cThzKKsfktBp0TUL7/NppEoU17DygMqsRNMWev0RUdMcQw64o/rkPnpNEZJNNC8D57ReZK76quSYCzHOPUUbmtRkGdj5d3jc6OKdOlJkEOz7xyCh48DTP7avSVn19BBEJ1JCUvwvnsSZdWi+YgCOkFA59u6J5xnpAoNXEfnP77zybT495XJ2J4ot5yunvZ11HnorUmxmHWeLtlWHKiUCwJwH4+Pl94FcVCCGQQxohfaM8VCE+hJ0/gps9nMl3kfkr0YJoiF6Oo9n80e02Qrarc/ade46g4gXm2Gd0TGXykgO9SxXnFJmGXBGLS7m+djUX+eaNoBtohjINYYSt2KIzmGqSwGeIvy7ylQoJ56gAprLJZu5CDyJLINl/IV2qAlGsRjI/J90Nbx36UvzfZvIiNkMUIBpgrs+LHXuqUKwC4PsKny1mqcrxR8X10Tui8Qb0t6Z/kX95HXJ+zo9Suc0aizUaOUGdUsV+QV1fZarynTBQm7G/FYAviltiPRqFXD7oLE+TFnL7/s09SkZZCgetqbgf3q2PWL3z3mLXuvrrpdxNa565kTzmNlwERz9u6JKc4PPq36GMjqm4yg5OqJ3l+6CCZJns0nGLT+sbYedbhMl0AdgqYP68YAhzFv3TGooDxUSA== 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)(2906002)(6916009)(316002)(4326008)(66476007)(66946007)(8676002)(66556008)(38350700002)(38100700002)(8936002)(86362001)(6486002)(5660300002)(7416002)(508600001)(6512007)(2616005)(186003)(6506007)(83380400001)(1076003)(26005)(52116002)(107886003)(6666004)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xhc6GBa7BUL4KywZ8V4+pg0ECPwSIif018de4BA5p6Du4temdWv8QZb85IAob9fTLgG1IMUXlU3l80cIoPAf68IYkDoFg+5ra+VTgyYc0qOwjiBdFpcNd9aWYHzuamwZbaunvFsWdUd1aAvG51CT8lIPdDghIGBeSP9dLjxhY4mqxsXe41foIMwiDyckNuqxTXnBCv+NBbtU9HKQfdVepjurtMGhYqOe9VdlaanqV7+Qw9As9tpcr1zfA60RZG2lhJHnn8SMuMbOMJT/v5Z1P3OjNjytz5K9FAfP5kAUXlm7hKDONq7LXl0tYGHFdNGE5o6AX8YiLSByjCrzjjvzlFcGJQH7hwx9PQZBSHNdk5Wgoqdo5ECFUfh+YCk4ZSFQk6wUUCq26S0415J0XhPuuofe7Co/aw0ntjSHmbi8Ktf5+4Fa3iOiVqxQQCY6hOcL/V9DAaf9RQ3Ngb4WLDmusMXQes3FnvmHo6caVTnx8FEHnr8svQEpNQHWvy0J6s5Tlb8iV/LeGnOfjo452d3ty4y9s/QM7zlyyP2FPXBC0xQvmf8IsUYHXHFPhs1gP23mU3Kjf9htrDq7GXb643i8PCr5X4MRfR71E4S2NqX9y0kDM/M8BRoSzVkGWIjEFCLlmePPoK6AmBuSI4X/HmDfXEOaxuoO+lJoNyGoIfQrcLmRCz4MSPIuMIvmJvjqEcd4+dJ4pfWNrhuUK67EZ9GAfy784IRc7qlLlhF4sKAPWgssrlNwLpzGtZbtiI6yGWFR0pPdMrqhGc5Q6BoEM0Mox+Nk+Nd5xHuDXs48KkSA7213epsQ34JQrENHU7j+kH+zLyGoTZWYFZe4DY7B+0yhYxK/uaqZPcQA/ut1lN+JZNFUCKWK8A+s+UW86JrqdqFxlaXyr5AW9wErJaA25qDgMWPgARqYQj/nvxrHhicak7LtwK+J+HWcPV/uiMtF51kHPvgm/p0K34t3kZpG9BuXMNW6DRtD+HCnDezw/k3zMIFwpSDP+mK8vVDECMlie+iGlLukfGSxcxahltcyNcwzrgKnAGkErX02gOrXFslSUc1wtD+uUEz3Xn4ACCr680zFNpS2f+LW4+s3G7gF522QGpfKkC7goMuKaQSImsdYoz15ffSiIatPEaYPAdt/Bb9IcRH8diIF9KP7x5yyj7Nj/oRjf7RcKfqMATByni+WxuXIoO1gbGflkY7HkknJfWYPrjPU7tw7KhrbiXI6H3ZBLtVV67EYD/LwaHWsbpanM6d4wYNGEDq5RnKy0Fw26EtbvWHoPLhXQWN/YKyjVKmySLtldRarkW2xkV9N0aosQmq6tAfpNv6nulDs99285WDCXcQA4tS6a2DxOs7baodpNNvYlaR5rIOiz7dFFtkSVILAYRRK1tv0C0nOFudPBTHHLpcGezq/BdUbbMeyMc7UOxNl5pYl3qDm6UBF0tFipZQrYUGEE5ZeYIi/xrTGXrevFKBU99aPwbbU/2Ltk55huzbe1DukluA8DNZl6DrQHhI/09g5OQzKBwB9qhpgUF1kfkRJFq1+onjcDQ5CGdE8xW0wDGdOh52O+mQZjD4wQwYY+UKyrvmn+5EtDbZG4Xfv/wl9t3USFaCqLDnu9HnO791ITYzLXsEM71tb57oz1HzA75/JQ9OiSvY+TdYY3J8uuYqAiFh9Rpi+L+HeYaCvZg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e006c310-83cc-484a-34c7-08d9f1850f72 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 19:46:44.2816 (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: PtV99nihyd2q1x8dASmvhZo74QfF1Ak4HNYQ2jOJ/6cnU+h0fdJrAeCWiwS3xb1xC2iUstBAfh35TnSlgBAUZsDjdX0kGvKoit0dnfR/UYg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6856 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe0c::710 (failed) Received-SPF: pass client-ip=2a01:111:f400:fe0c::710; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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.978, 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" Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/tests/image-fleecing | 121 ++++++++++++++------ tests/qemu-iotests/tests/image-fleecing.out | 63 ++++++++++ 2 files changed, 152 insertions(+), 32 deletions(-) diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing index 33995612be..903cd50be9 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -49,9 +49,15 @@ remainder = [('0xd5', '0x108000', '32k'), # Right-end of partial-left [1] ('0xdc', '32M', '32k'), # Left-end of partial-right [2] ('0xcd', '0x3ff0000', '64k')] # patterns[3] -def do_test(use_cbw, use_snapshot_access_filter, base_img_path, - fleece_img_path, nbd_sock_path, vm, +def do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path, + fleece_img_path, nbd_sock_path=None, + target_img_path=None, bitmap=False): + push_backup = target_img_path is not None + assert (nbd_sock_path is not None) != push_backup + if push_backup: + assert use_cbw + log('--- Setting up images ---') log('') @@ -65,6 +71,9 @@ def do_test(use_cbw, use_snapshot_access_filter, base_img_path, else: assert qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') == 0 + if push_backup: + assert qemu_img('create', '-f', 'qcow2', target_img_path, '64M') == 0 + for p in patterns: qemu_io('-f', iotests.imgfmt, '-c', 'write -P%s %s %s' % p, base_img_path) @@ -139,27 +148,45 @@ def do_test(use_cbw, use_snapshot_access_filter, base_img_path, export_node = 'fl-access' if use_snapshot_access_filter else tmp_node - log('') - log('--- Setting up NBD Export ---') - log('') + if push_backup: + log('') + log('--- Starting actual backup ---') + log('') - nbd_uri = 'nbd+unix:///%s?socket=%s' % (export_node, nbd_sock_path) - log(vm.qmp('nbd-server-start', - {'addr': {'type': 'unix', - 'data': {'path': nbd_sock_path}}})) + log(vm.qmp('blockdev-add', **{ + 'driver': iotests.imgfmt, + 'node-name': 'target', + 'file': { + 'driver': 'file', + 'filename': target_img_path + } + })) + log(vm.qmp('blockdev-backup', device=export_node, + sync='full', target='target', + immutable_source=True, + job_id='push-backup', speed=1)) + else: + log('') + log('--- Setting up NBD Export ---') + log('') - log(vm.qmp('nbd-server-add', device=export_node)) + nbd_uri = 'nbd+unix:///%s?socket=%s' % (export_node, nbd_sock_path) + log(vm.qmp('nbd-server-start', + {'addr': { 'type': 'unix', + 'data': { 'path': nbd_sock_path } } })) - log('') - log('--- Sanity Check ---') - log('') + log(vm.qmp('nbd-server-add', device=export_node)) - for p in patterns + zeroes: - cmd = 'read -P%s %s %s' % p - log(cmd) - out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) - if ret != 0: - print(out) + log('') + log('--- Sanity Check ---') + log('') + + for p in patterns + zeroes: + cmd = 'read -P%s %s %s' % p + log(cmd) + out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) + if ret != 0: + print(out) log('') log('--- Testing COW ---') @@ -170,6 +197,20 @@ def do_test(use_cbw, use_snapshot_access_filter, base_img_path, log(cmd) log(vm.hmp_qemu_io(qom_path, cmd, qdev=True)) + if push_backup: + # Check that previous operations were done during backup, not after + result = vm.qmp('query-block-jobs') + if len(result['return']) != 1: + log('Backup finished too fast, COW is not tested') + + result = vm.qmp('block-job-set-speed', device='push-backup', speed=0) + assert result == {'return': {}} + + log(vm.event_wait(name='BLOCK_JOB_COMPLETED', + match={'data': {'device': 'push-backup'}}), + filters=[iotests.filter_qmp_event]) + log(vm.qmp('blockdev-del', node_name='target')) + log('') log('--- Verifying Data ---') log('') @@ -177,15 +218,19 @@ def do_test(use_cbw, use_snapshot_access_filter, base_img_path, for p in patterns + zeroes: cmd = 'read -P%s %s %s' % p log(cmd) - out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) - if ret != 0: - print(out) + if push_backup: + assert qemu_io_silent('-r', '-c', cmd, target_img_path) == 0 + else: + out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) + if ret != 0: + print(out) log('') log('--- Cleanup ---') log('') - log(vm.qmp('nbd-server-stop')) + if not push_backup: + log(vm.qmp('nbd-server-stop')) if use_cbw: if use_snapshot_access_filter: @@ -214,24 +259,36 @@ def do_test(use_cbw, use_snapshot_access_filter, base_img_path, log('Done') -def test(use_cbw, use_snapshot_access_filter, bitmap=False): +def test(use_cbw, use_snapshot_access_filter, + nbd_sock_path=None, target_img_path=None, bitmap=False): with iotests.FilePath('base.img') as base_img_path, \ iotests.FilePath('fleece.img') as fleece_img_path, \ - iotests.FilePath('nbd.sock', - base_dir=iotests.sock_dir) as nbd_sock_path, \ iotests.VM() as vm: - do_test(use_cbw, use_snapshot_access_filter, base_img_path, - fleece_img_path, nbd_sock_path, vm, bitmap=bitmap) + do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path, + fleece_img_path, nbd_sock_path, target_img_path, + bitmap=bitmap) + +def test_pull(use_cbw, use_snapshot_access_filter, bitmap=False): + with iotests.FilePath('nbd.sock', + base_dir=iotests.sock_dir) as nbd_sock_path: + test(use_cbw, use_snapshot_access_filter, nbd_sock_path, None, bitmap=bitmap) + +def test_push(): + with iotests.FilePath('target.img') as target_img_path: + test(True, True, None, target_img_path) log('=== Test backup(sync=none) based fleecing ===\n') -test(False, False) +test_pull(False, False) log('=== Test cbw-filter based fleecing ===\n') -test(True, False) +test_pull(True, False) log('=== Test fleecing-format based fleecing ===\n') -test(True, True) +test_pull(True, True) log('=== Test fleecing-format based fleecing with bitmap ===\n') -test(True, True, bitmap=True) +test_pull(True, True, bitmap=True) + +log('=== Test push backup with fleecing ===\n') +test_push() diff --git a/tests/qemu-iotests/tests/image-fleecing.out b/tests/qemu-iotests/tests/image-fleecing.out index 62e1c1fe42..acfc89ff0e 100644 --- a/tests/qemu-iotests/tests/image-fleecing.out +++ b/tests/qemu-iotests/tests/image-fleecing.out @@ -293,3 +293,66 @@ read -P0xdc 32M 32k read -P0xcd 0x3ff0000 64k Done +=== Test push backup with fleecing === + +--- Setting up images --- + +Done + +--- Launching VM --- + +Done + +--- Setting up Fleecing Graph --- + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} + +--- Starting actual backup --- + +{"return": {}} +{"return": {}} + +--- Testing COW --- + +write -P0xab 0 64k +{"return": ""} +write -P0xad 0x00f8000 64k +{"return": ""} +write -P0x1d 0x2008000 64k +{"return": ""} +write -P0xea 0x3fe0000 64k +{"return": ""} +{"data": {"device": "push-backup", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"return": {}} + +--- Verifying Data --- + +read -P0x5d 0 64k +read -P0xd5 1M 64k +read -P0xdc 32M 64k +read -P0xcd 0x3ff0000 64k +read -P0 0x00f8000 32k +read -P0 0x2010000 32k +read -P0 0x3fe0000 64k + +--- Cleanup --- + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} + +--- Confirming writes --- + +read -P0xab 0 64k +read -P0xad 0x00f8000 64k +read -P0x1d 0x2008000 64k +read -P0xea 0x3fe0000 64k +read -P0xd5 0x108000 32k +read -P0xdc 32M 32k +read -P0xcd 0x3ff0000 64k + +Done