From patchwork Thu Mar 3 19:43:34 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: 12768025 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 B4849C433EF for ; Thu, 3 Mar 2022 19:48:35 +0000 (UTC) Received: from localhost ([::1]:51108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrRC-0003or-TI for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 14:48:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrMy-0003g2-Ll; Thu, 03 Mar 2022 14:44:12 -0500 Received: from [2a01:111:f400:7d00::72c] (port=28672 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrMw-0004Wu-S2; Thu, 03 Mar 2022 14:44:12 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JQbTkrb6z6b2lFwJjb+3iUB7XFCDa4alGB6JOk8nnA1hYWF6R5aYxcJb/YBnNqfPPXg3TWVyiF0G/NPvkizEiJsAs2WIEVhpYpn2zP9axsHmz9vCs6tP33/U5r3LBvzCzNZvam/Nz4oqNPkT1jPpodsKKCq01NM95fZ7KCNo1z4KoTqJHTxOdXfgz9fHvYNyp8pUVKTgHLFyGzP60u2EJEthcozV4bDSH6PPgElMpECWODloZDoRjaYy6yCyVfp0I13USjkoQg7cPnwy5VAqivvVOLmuroW8UZyxWQFNM7baXPbOCZMN9dmSak9o7aYC9v8sSHSsdBUFJV7Jx1NbRw== 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=f0if0FrD2Rq0dNVXMxc/TbXBUrSrD0qqzqqA4Z5OroHwX7fwmwmbPBOKTA0xIWJrG/VBzGGW4JQwq1LKcJvX+k4t3LwR02mavA8idRbzPDS1aFaiISqVRIOjyB0fup4NSSKc4KT9sU3P6GYBYQQJDVRzUmwX+vb8gUIvFK+HJ8/5lbYHjFtVvT9H9ez3pGz/s725On6DJhaR/lSJXSA1cjyCrJIY57k0YzPT5KT1/9xAukzhDZAiYndu5HcB1XeojhHbHwGd+3pWaTpBvY5a3zVsKc9N5djsAmQvVl23RLX3hJ+k9C+mbwC7AMKsk8p4hA7ITeMm4N1drQQh05CMxg== 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=BNeX4YrfPoSPfKJcnJJNxF4v9+Uk/V17IIvvKQPeBaFGFAFgzjiDz5tQA2bZRr7O0YfWoPYdjfzPHtqfP+DJl4ysM1mXKURGsmeWHEltWDv0emdc6hvjGp0ROo7aZ7NiR6oPIqGuEUjs9T6vP83iyEVXQro7+yc3UHloJ3l3UXE= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:05 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:05 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 01/16] block/block-copy: move copy_bitmap initialization to block_copy_state_new() Date: Thu, 3 Mar 2022 20:43:34 +0100 Message-Id: <20220303194349.2304213-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: fee51d89-38a8-4d23-3407-08d9fd4e2ccb X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Eo9u46HgJrTeJD0biXY8IEQa3uIB8JzxsWHy64g7ZvNS7Ve9J+i0W+pqigOTdjLWvYQohxUM3p0x1iYceabTAGO3R0xYr7cO8cXHpJagO8lOO3LLyi3EfZj2izlSr2HESLoUWamrBDvCNlrqHzXdCbWnp/RIBaGdRzdg/jM9CLdk9dhW19HLb0absr9YLbM+SFCy4uYIPa6tvCSP2ib/Jm4y26gBx0BwThQM00EVIoG+1d2EXRLyMZU5fDdwOIT2VF97EjFQmMstjA+A1auKE4s2hZyUTT9f31f/Cj/aoUsQz3+oNGdu0Jag4nth6LrPWwE+8E+NCWrhklbRWzbGI6cGCde66TdI717LSeaYbOYClgH1DvC2Obyzkow3ACAVrxB/RTHxMsoyIUGXi4EcC02LA7a5nFLC9aLVzKXrxMmuGk5z3xJgxAMq7b3ESGn8V3mg0P9QfT3XgnythpLyTIe3dQpl4p/glCTjjUX2aJL5Jmnm6KfAqdCkCD4j0IxjnGKxA1B/eOujXRxWurOHkgTGZTHTBiBch1qQfg2tNiCTxrv7hwZQrOO8f/buuB/zBGtdsppcwrtx0Lk2KGnvR0Z59qrEOhgHLb4fTzk4RA96rP7O7NygfFVT6lTfqZ568jVxgEqJPlT4YrNoJp5rrEQDxDf0ejpddvs1GxjGcledyf6NvQ2cdUVw/jkcDQA/+ImC34qnvYE5QIHMYSgdWQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aRJ/K+i6fpiMZCyBoUvjX0wxXjOcLRPFxw9SVIm1ZBUQ0nKax7Z4VchRTemRR36so6i/f7lNrVlDZyDNgdNf7pfl1N4LtDnMsE18o+z3BbARNyf9xHDhAGgcQ4aVQJus8Opx4BALW9nFuYIJiPmMiKmDmz5wdc7HjYvXKouKWVkYWsf477iBqXEIa5N4A3UGtJMocsOKWwnLbEW0SqazivfwInmHqvVoq/pqtW2CyE1KnB777Q+O70pIaDbTu052KJVcxD9fdwyrOQoFopTRGBrwnUyaGXhpKHoxdCXWZQk1al9jd4t6z9NYZav/kX39MtuN8mOUssARHNcTmpPA9knSnd3w9dyk6XkLnD+jQjSSrRF1kSypO15OX68g9SYniJvRmYqll+idZO4lfEPkqgEo4ehcVip4gN6gWgzDA3ZZ+5T1/40l2wRBqvJLJnYY3l5IKm8WEBbrXQ/YOz4cVKoYR9bftPR7Ua6vKnU627n7tzHxodpXaJkKSay+OZQEu6SU4ij61VUAxQxbadmuZ0Eu3DS3XNslZhZ301s1VXIYltebvq80jBwpMoOCyEFoNUa+zepUV5zfY1W4Lr5HbWlKALsN5pojdXePlj2UcKzTE+7S8wz7e36mg9DwHbIqgfOBAACGxrFjfu8R+Vr8q1M0Zf4N0vhbEMp2dJ2dCzk7qXp5i4ad8nHyncrlZUSh5nI4cmLGUo05IRjvXa1Iou6eEX8kzi3RLzqBS0qbIbQJROIqqojGqPM0naPO1UUKBBZEs2w5JLZ1r6wqmWNxxGP5tS8DVAKIeD9LWKe4T56XIpyPZMHinJwUrGo7la40LrsB+Ld2cePUpb9B1Aq6E89XEBZP7AJINXNC/G8wM9CR5Yqpt4tivopTvJgTTfW19KqTRdNMEO1ezdiBdNalBh3tzVISDMeUUhRZEEAq1CvNr7DjJG5sva3WLGaH1GCyEX37FrIw8Dz+qWnhwBBpEFr+g+uNazQNCCMouT4CESw/xaO3cHNJjGvQz04kutL6OXXeIjC/GDsdA/8Wl6H/CVPymVWQNhFB8RIWpTYIaxXS+KpV8Y4rhcENtEwCD8jH6rT+8r9YY3XNPZTGN+P0PzXSKzGe7GE+VnjVdwwVLrQuzH5RBOL5McJARnRQJfsPFemMLrd7A+3Lt31jA3exKFfNmd5mq2lhi0PFTURCg1cwpqUsPelNipuEJtvLzkhSnO/CFwSsYDFDpEnzKzV40GlQPL6dsctLcLPATgssf4w5w3KIxsYkKMiVaN5Gj2l5tR7lHKcqKB0kVAc3AKd9sytEdrs4vEAXDlUUkkUdOhxCDHej+pr4V3TrXADyL3y0/VKwMBtcaZ0a9mgQxEfrBntF/T8DhOw3n40Lroua/anhM/+QFIBqrEELz7+/2hVQTLUq46QyJ70mE+p6dX3tim1KO8aHm/UtcBtz8iwIYoTnMLFBd7dqZ1YwG7a+5rnuepQJlKVAu86HAiWzszb7JGZl2M2jRI8hhltLi0YxbEKLbo0XDTPXFbykFPklpARDS7NCILJWM/q8BHTYr28Kts55ZNFbDCsfHoVteaBFbXRy1a+EWdsuHb15Oxn/y46htf3M2J/BVH4gupYUd+TnEpYeTodOqplKeDxDmyC4iE6gz7gFZLm8JVC4Np9nsiEHpK5mwznQBHcTyzAEwppQwQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fee51d89-38a8-4d23-3407-08d9fd4e2ccb X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:05.1676 (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: cKrksIFvbjfC+1Av2zdGE7js2g0iBouDpaoX29tQe+f4Gl1AOR10E5V+KbyfuN0mdvDO/DJ+dly/1pvsoHhG6xjncnc7rc2lFzLM0yCfg6I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::72c (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::72c; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We 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 Thu Mar 3 19:43:35 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: 12768031 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 335CBC433EF for ; Thu, 3 Mar 2022 19:51:41 +0000 (UTC) Received: from localhost ([::1]:59602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrUC-0001Ec-9N for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 14:51:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrN0-0003jg-FK; Thu, 03 Mar 2022 14:44:14 -0500 Received: from [2a01:111:f400:7d00::72c] (port=28672 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrMy-0004Wu-Vq; Thu, 03 Mar 2022 14:44:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qs4r8XSiXb5/tuVxVTpqCPl7Ksijt3KjNOjLeqdAq8fyMD48tau/cIkmNpdHIcmkoyqSWcchKJX+m4UxtHY9DXkq+YQaNPQ7C3rUoospGETD92HadiJ3gt6aBl/V03CZ62mPYh7FxmRk5Wc4rG9K++LkxKa9e4wU+DHIzhte8ubLKDyCCjf6Z8u1BvO4jR0JMc2Cm6zieS3oU/5E9+j4vMBwIC/iu75N1MWs2DFSSwoAfFKLxH6PjKN8bhk0ACEvpBVgMl6Ow4vrWbf5NomgEqRWECuBYr/Oc4nGJ/vXBO7UzIAGLJLZ4yY998ZgqPabnaXUXZqQv96spb11kQBzgg== 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=aUhQhbKzNuYYmPJL8+RBO4S2gNb+sd7X/aJqwULU1KBSlUffCoe1ioIdYXyPStSFguJBqicJmLU0Dl/J2Q8+mpbR2+shRKTBh2zlGHFoKzHOWRKWB+Q4WQHus3ZvE+lbNxm0zRPCoHNcSFDHqRDcwddmwlEc2BDULaidz74i6Q3rVtM8Z+5RH+KpgVqtXaUjPgsMa9W1hfErvtWsPjXD0SE/e0RAF7Vj4Yh1ZaC4bHNkTPhHeR1hLYutMpbUwe6+Nh0uKgyE9V2prMLycmnFV5AP90DiR6psUoYruwJsnbxzKiOvsgRjzSe3CfLVpJsFYu+70xKXwh0Uay94Uh44QQ== 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=QBPRa/rGh2JPpH4189bAvqE0xtvZeEAkBDWOocJqgMPS+l/yRz/vbrIYIaly0K6KeaSMIkGlNRFtC3oQYFu7+jAwh3hHjtHV23U+9TGYi1kq19ioCu86o8I81bEQXAO4Ip5+mtB5dMRuoeNGxMTEub38VXygMpNjiN0yGiAJcLY= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:06 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:06 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 02/16] block/dirty-bitmap: bdrv_merge_dirty_bitmap(): add return value Date: Thu, 3 Mar 2022 20:43:35 +0100 Message-Id: <20220303194349.2304213-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: f480e729-cd1c-47fc-8afb-08d9fd4e2d49 X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qjUReXPXmtEXuj4cvS4NG2cbyK+kmTpedorHcCMqplwj76fVE8Z3szm1qN0cxscNXKOW+7/XN5O5LfmtYjxtTfE6rmlsYs/lgOYGq2KltK9PNLGiL0fhI8qadfLnIJZcEKj9np5z13mfotwR4f7UXwHoOpjWRI0CTSj2H/ZhXAYVWt7SzEF+ilHW/rgh3oNTJvRWEYjZXHr1Dg5Zg8BNvumB6QnJCMk1x56X559cW6r/Mz+FmJ9dgOT49oiIeXlpCcvEFdG5dhxmqvf9aU1SJnuIyxvhPIHWPHhJrLXd2P3byyFCyIO98547ZhNevgsyaL4ASTY+t09zS5k0wwIVtTgnG0ZxCiC7ThvUUXrZs8YC4uEotO/uDKvBdfBSqMpazr2JXh6SZ19Rry9p60XTF5tLKiDPAQkru6DGgdH0dnPobqtAtn5/YDqmFBmo24ZYb6sDhGJ9t352uOBIm7Q92FMjnQzNtLexDM2qjOskb7Xf8DquhWCpxs4IEoaIbrt93Y0qDk05R4eqybV1oYCMky89Ey/0DJby/nfOI3sY9SJJ6cAjgeSzwEWyJEVSbH0lmotLxZPC+wpBsStRs5aUeDslMaCOYL1bi/dngCttED3BDe11pCz10Eamki7qBgBarPlHH14giBTqYJ2xNOLfNXtP0tKppy2LZThyXmG+A/HdjVG8QXnvISMo2FlpnSJDK74ClNBUgrlNdJqQNNfvF751OwWLSc8swU3QbQOnC04= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0FoPBLowm9zH5ZdbKjdhGnoGSV1ZAnh1jO2VhlZvm6pXLx2IRtNp2ZVIJCC1Pgtsz5RQFYgHhl8RXV2VpVtLjKeb4VqGGBwAUtNAhY5QEBCAoDvwmy9QkmW3GbNrjnnEc11i2rBVC39rOC5CMwpTPLzW4ORcLA79C7AQzpHjOwg9duodAD/FZMILBsVzU9oMdQMUfWUm7Fiq4dMKerta0rZ6SECg0TMvHlcQaQyJFNT4QBo0ezgFgMByy0KKf4aaSYgSobgJ7GE7HfzaeWZdyA58YEok8Auxtit5UIEu0jpHrDsmZGQzEvqctv0i/N8H0B1fpuBw/WUHL2JyKVfBK+C2erOK+21QIVr8iWWcqiZ9tkBKWkC45cCd4agbslG5/4mrk8LTXCcdBfzOsmA3JaUEujxdJ0T/cK90la4E5Org3bauCsTEYf46LZXLm70CKCA5JC7sFD+O7AaV8alGimmF247oWAiqYlcBbj7vYtInbAwq1w6Lbf29eXuIlFASDH+5vVUy4isGS7usF9RLsGF0YboDT7BBqPi/eiDJJwHCnEVh6pGMM7Bk+KQS+3Tthwl/LP0XYtDW3tTT9haEtL/gbEQpmT6mSOY3OnnaZyI10LICt4g4EXCVkFL1ryN2I+QCaK8xmdW1XAZKtCY9fCR4qaPyS7oJhkmXslhw3E9bD1QqCjFBTYxZ+tGttE0kj+htnjEZTH+jicJD1gYKTG+VjkA3Jvbg1SK2YrORfmRsOcTIpiqMtgIc7AbqwqHri0XJnZ5hQ7l1BeKmytLMyo2BF7utaBxmtV7KQSk6SjELcNGZ43GkLa9+ZmXJh7BgqwSslNHL9knVpxS8GZzW9vUMjuJzqdq98Q7ka5TEvm2Mad4/1s01YHgTSPrRqzGrNMEtmIlLknpu45lTj7wnPvtmpasMdXUcdHGkPhndtrxK/Fk4E0/9iHn/fLUUAJuxIDG+XZaTPGHWsZzf1zWvuGSHIbmpV6LrlAM7EZFbU6dag3zaIufZ+ftPcIiNClqOSz8z40vVsqDiI4kBpwdtuAI7iFhP/Ua7Y4cn6fguYXJnQDUic/KivSHcLPGptvkXjM5onoOMuZQ5xiDZg4af3tsbF1AuXhpE4NJTcfjFj9VN8ubscQ4bTzUVF8kmqo1eOhjgMC4SDS5CQ0588u2qSTnynBUr1DiAu1fDwJ5R0c1uTrjDnUMB4a7Lce3SfvWgthEqdKvcfYkYvxqMwsJk/qEsSax6oOwlGxPGATydph5w5l6m1DX8awUWcyebpNG6WoXukM5JLo39llxtdDMyrDWoDSYc99IVr58roRH0eayvT2IbzYg6owWr1Q6qWip+VX/k2HVEPSFGZHxWHQsleZpZYkAMy4aZ/wECIQz56fqW4wfvId3IZGVT+ZgGQbh5xesqpHpx9TYqFMikytqjWr32gSmeQqY5sPru7LP5XFxd7LKnJQ/m9yAzwHmLzHBTi8uW0eoaU/chxXDP6EVr48OsKV61MYSHxB3XZBJdpzFSLK8kRHezCXV05t6WkaSeH3+53k0r2tKQNO2vF3pJYd/P1iHFBX6tA6dTYfrjN0/dWbHW4sZ3zeIkRVLN1gApSu+aT4lYUySo70484ckgZMBiBnjRMWHr1TCCiFsLkpEOoky4Mv2qbB8/ejkKQr5A9HQC3vjRuLPsMqam7/IvIQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f480e729-cd1c-47fc-8afb-08d9fd4e2d49 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:06.0112 (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: mDWdrNe+/2+Gn58MoUWNjRoymGWwZrfgp9SWTsH4abRaV2i3z3Asmr0NHQIcuoASNUAmpSqT4j3kMjsTxohXUcd8PtjNRgBOApucfqcxrUI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::72c (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::72c; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Thu Mar 3 19:43:36 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: 12768043 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 6CB0EC433EF for ; Thu, 3 Mar 2022 19:54:30 +0000 (UTC) Received: from localhost ([::1]:38318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrWv-0006PH-EB for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 14:54:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrN6-00040P-Fk; Thu, 03 Mar 2022 14:44:22 -0500 Received: from [2a01:111:f400:7d00::710] (port=7585 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrN1-0004Xj-5Y; Thu, 03 Mar 2022 14:44:20 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WNogrxWS0M2g0uLmbIQaFAXs63Fter1QPD0z8W2A1Joy9iXt0HYdnvaxfctwxDd9nF1i2CxYh43c89oTcLnG4/y88CyQHBlDzMnvVu4Iqs9ucU8vMahHFs5mI2E/d55D8QXl9ez+28TGMGrLz3s/pZX1E7R9tNlDXvnbO66lcG5S4C2yJh9y22YTqjdpXBE3eaUBHaSSFZFX/QBSZISf61RrtTUq5k0G68bAG4qCEFkf6xs2f21VJoHsfJ0JBPDikekOhfVVj6lIyyI2hnnFvghxQR1/YxjfIvwAomBlsJwuKcb0X2T4azQ7kO+3daNU0l1umd1tQrltmAnbad8sYA== 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=NmMZWPsXy6sCn/KTx0rcRRhgXC50lQ65Ci4s+q4S0Dk=; b=cCjdHYSNZGU7099yIA/6wIF5lGZYWKHCDw5mpRLdOzJPC88Oe750pQX22Il1mNJpnrQVQrRktGDvWjlkIFwpuVPBFNqrUdO8QLh8ytaDw1xXmrPg2+7ZlVtZamzCAzwx5PaLb2ZwKui6k/lvbkCXsJCur2JwhJH+rIPXOqvQ4/V2iBnmQ8znaqhVOG4mx9TYo/ybSccUvUQR3w7WwSfVmAhFntaT77dTpQyqbpQyDTft33ZWGL6uDZVetpGOfS6nFk7CGl69cgQnuRG2xPQFHfm6FNKPkeOkkpYP0dfQsiR95wP+5bAT4Zf3NLCtKPGSstZTFB1BH0yeo5KdAyD0QQ== 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=NmMZWPsXy6sCn/KTx0rcRRhgXC50lQ65Ci4s+q4S0Dk=; b=ZXCtrIM32sqEwTDXrkz2oMCKsO6DAo4CRCvNAcAm8mA1HUzqjZ6JEYBif9rN3vwESF9em3uCZ7t+VTzh9Cwpc80u7t8UIYD4rxlZp05qzpczljgz2y7ca8+IGYllgzpuHyTv2hwuFEy2bR24Tiu0etlHw4pfI92JWLMZ5Ax6cZ4= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:07 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:06 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 03/16] block/block-copy: block_copy_state_new(): add bitmap parameter Date: Thu, 3 Mar 2022 20:43:36 +0100 Message-Id: <20220303194349.2304213-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: 5e784927-8c28-4b6d-1ef6-08d9fd4e2dc3 X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0z3OdpCiVODHMp+Pi8ghuFzap3nqexBjI6B/iGErSBE4pSVn0pjn+e8GjCLgc1NpXsLeUsylKORWyhfl+Kt1kk5HpMnD7fGi+lqt7WTYgmfEDLUxUd9bLN0mxzs5N/arY1aDkqHLFzZ7HC2djEhqzgGzaiiniCTEd+MsuFHcH5Cysrro7VZT4hTqwrVgwb5sHBwce5EsU0G6eDgrjmGDYjaLj62Q0oKFyIv82uzMDvLln6OFfWWA4LB/xYc5xnaepb6WPF/nVjYE+/oQcqMKtRj8/TF2nL9UKnJMTlk2YK8P7lj03oxnSome8qh402JxXjjxKubVr2Rt7ekfPLtOdq1fl4UPbkyvBjiUjkaT4VdDDzeg9RgPNaq/X1CKezBbSgCqeEXZLcAPusTTRQVX+02l89iFMCM5bbm0n8bG5rhMIsLgt6qkx9tvfrwXiibLZq95pCydxOtd5QUQ6+eNe7BriypCJH0az9fgifX1ASb9PLLFDkEE1dTkjAgxXzbuggh2vpax1ioEyRdCd7jJiJFv9ne/553w+K/sxDmx1pW6aCDSyPcBEGtTbRwkundvfD6x3xZY4OuhmFGtzm1Oxlw/TsTCPZAe2h2KCM5UtGRpAOmZ1h/IEXYj3Br19jDdDo6wMMsKQJQFkq0xUnodGAdLfLeARboSUu0g93sr6FL0HbrYKMtpHRta+UacS2KGdLGWPnf4PgQzAPkh5vZ4RQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CjU+mlrkQID4Z4WXDg9b9is7GBbSrioo+1f9VK9JMacf1QRW4E77YsbroYKprCsHPU6LUhK+CfSI40buj7VyfDCw00g0YhvZGMoLq5MzaQWj/5aSMnUKjZL6fJNaTooMJqhdaTl/8wewMDOrKQ6tntJBrIbJhu9ni/wKyr72U1pACwv6UAilFNi5DwwD2roeX6FYnFWEQ0Xk2qrZ/+zX7+EZwrMQZy3CKI5GtlXb46aZvh7LYAhTdEBspB7dMPn3HGksHi+uDxtENI74ApMePKuDF5TEvI49zgesjIEEApoF/5J992x8BhRhAHLmNvRf5OCMOLHuVQ3BDbOTi7NqROUKDBfSFX7HAakjd/Ay3Du4j0NRaOqa2XJMG8aiyKcLbcqDH1bVpDkEz8H+j2IwYzcB4wl2aWcBGIR04fPDAaK3XOLQNkIINmvJ/zCanJ0CQQiTnlkGwsHfdhuF3zi8Bp0t4U3nJ3Lj9Ql7Sc+kyZMmvAP9XXwTaPTbtxMbBm4RdWteyBugEwlEG8STgiQr5aVPeO8pQe1pb/es9+uQj02o6J9NpQr4+9qV+qVkLxd10hW06HQ7k98HDwvzDdOW+QtJFolbD3ZdBa/41ilBW6H3fZGRjJehYCtGNFPAbOq74VoQBSrpwhXe+8bWPkCHeybn6bpeLpYp0YdrNECQyaNkRYpoH0JuO2HBouEIazMyecbPGJYPLdR21MJbKzKEZWM4TIgS9Y7mKziJhzK9tTB/hCBr6/zCRGZHIRnCR02dav+uXBnZDua1ZcNl386S5c03esVLW/0t+Zh/b3qn0HKI3eel5zWcakirQbM2KQnBPrt8NGli/K8LlFmV/mxgTgkLqaajIq3h9lMkNDOw1I3iCVpS0D/3zkn9IBXVxlHdWvBM6wQ7+19d1LhI02JGlPnDw8FZ6SH31cyjisYaq6kou7nAaWPPYTU3WG530bZ6OKeBy2fY1ULvdOW8Ud0srdv39fKF4H4UczR/ThpnPaQKss9DuioQWPRbxF2QeQdYiO3D75buNYCOQpRxELyT9Y78p6/qvZQFa+H8iTOAN8bZbBHEJ+ec9rcZt55Xev3RZT9EO+rbtkYUY2uc2Z9gFkaFfaVuX+Z1aRmlvT1WxIKrHTYeG1NxC0l33dmk5cmOS27ITT2zrcaJ8lvlWOT1RQcIfd1Pi0U4GAJBbONZnEvQyB6hDNOf4CkhQBeCe7WuAXrU9L6VPQFfSa4Ndzv10fXjne6tZvkpXnAyeJxaLIG4N5ya+6F8iAMjWF/nPCpaYBg/PSDBOyi4ZCghOYHYKoTvEidh4hHj+AusilOfIbkNVQqcmVaIV/Ncr5YdchnKXqDXfFAcNWiu+K8NR2cmsyq7RGsu+9ksdw3U689GLxtIR+70wNTSD7Kz3yBuhUSN6ZsCcRjLPtTbznq08ETRNqrqAm3QjoAdvBOECF4e9XZXEwR400tARkWXfLq49vQPPHJaq0mgTBxQSX6gHkB1bqT42pSkO6RgViIUxeJ1mDCAro4iW60sfyqKX/Afp8V5Zi6oiXqZLZQLGbH5h5FWFky8XRnUcG6uTopkNpmtpl9VKMNbhnmmgTTqCX0KaGrHfannFEXG0Pu8v9+Ss4/FS/C7LwMJTlX0SZOHiPAU1CleJs8FqmBNKVFWjW7Wi1XVHOiSPbxTMKdGDexpt16wfg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e784927-8c28-4b6d-1ef6-08d9fd4e2dc3 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:06.8080 (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: tnwqFoGd6/unmX8LUB9DsSx0n94ELLTCJ+TLyBjX717mS/TQlU0bsuSE56ovBZRYJl1PMPfu3SaMf+0pOuFWWuFlgoCmcuGGerS1pjCQWOQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::710 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::710; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Thu Mar 3 19:43:37 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: 12768032 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 4ADFCC433F5 for ; Thu, 3 Mar 2022 19:52:20 +0000 (UTC) Received: from localhost ([::1]:60476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrUp-0001pQ-Cf for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 14:52:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrN6-00040O-Fr; Thu, 03 Mar 2022 14:44:22 -0500 Received: from [2a01:111:f400:7d00::72c] (port=28672 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrN1-0004Wu-3H; Thu, 03 Mar 2022 14:44:20 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cE+bC0DrmokZu0vp3f2Y3bCovjh8B2QVWQ14wAyVYEIzRfxODlgPb7Vy3u1f2b1bUzuFVKqGkIFSwtTf8W+8uQWM+Lyk8tjVDQEP0SBP3NGUqGfaJrcjv+r6P6iw61UaD57V8cPqJSla8MiNthg1SFEOA5sXwpB3sDbg3fQ35aOI5X0WJp1sMKkCn4XYiWYKwyi6MgH8cuZF40MoWci6qlUg021Y0VC0EW3zpom8Y3+N47yUgAkyeFMsSbXIjsHoIn6Nmv+idVEVPzIKsh+BAB0PCKGftXAb6L5aBAsxVJPZpWuKUfAxvYdCeNLg6jN10eWLl2N3+rn68mzGcj62ug== 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=nQJuR97fa6FiCUtWQahNlOBLFee18TTvSO1rbHVvPVw=; b=LTkPpqqPhw9dsqsk0MCyuubyKQ1k5RLrooqBs2KwPqTYtNdo+3WJ3en2cPuFFTtwxN03dayfb//XD0Pj07oy2Dy6KWOBL4msHA8LFode18ocDOrQ89mpGamDcANPiiE2IoMuhAF8iWRHWS41a9PW78Zteg/rMKr+HIvjJd5xM/cZPOlnne0+VOGdP7b/F3puxaNyvD1XxUn0iVWhHOuoafFDbvXSh6G83vj+QuCElbzfs24KcgDth4thXqE5CMFJ3OM0LQfmENxEq4EkBSa+MlePIqsX8LhDEjc5A+oqlW+W5Ptjky/AVtiE57aaegrcWpw9cHBcqQ89+bdcummpFQ== 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=nQJuR97fa6FiCUtWQahNlOBLFee18TTvSO1rbHVvPVw=; b=RHfiSe8Mql1Ii1l2HFlhdn2tWsRrcdtY9uWJiitMR+sbP9+q8Eqa/5CrjDXqVaWnZEEX4S1kTDyME9DFd/YpBc00ymP9Il/cGmqTn5OkPBbe6boT1mxCn3XW+LJZf6HeQ8oNMFqtkwY4tnlfq1IXcRZjOla+a03ygPZnqTs90lE= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:07 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:07 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 04/16] block/copy-before-write: add bitmap open parameter Date: Thu, 3 Mar 2022 20:43:37 +0100 Message-Id: <20220303194349.2304213-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: 2090d477-ed9c-4ed1-4f21-08d9fd4e2e3a X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CdIXyrhOQmu46KojViB/oDt5Qn2KuFin5+rIpQKhvSmy0+lRF5gsGOY1O8kcBEiAPOQ92uFdulAqnZfr9Ij4RU+3xmROKGOHO6qhUJ+4RX0pP485STEXDxTYKnpZSpyqfrbxuiFnYXQ3fGELwZ7hMDxy8SRzNQ+4DNCf5eglhFTKhh4jV4dOE0ydYIeMU8gZVfeQbjNutY5K10c2bHEbsl3rtLn58n94QtYADh9lWwoSxO01Ymc3AfGHKa2zetSiVVQs9sPCtMBSvYBdAyKtsIuyt6pluD6vzMx4YQUrBE5cmZFCubnLPItWDE/QNQtcp6U0l6TK9k7Ab5T5Uh/0C0zzTtUWr1G39Ak1OI96p1usCDiczJ3KsfbVlurOVp4qPAmGoB6ZcKNIw7SJOIb6JKxAtTSpMd8osMDRqvcosA7y0+7nnOJNllCVqcPcUTAc91a5OeWLoBYWecY8uHhzfFSKXykW/oeCtCU6Uo/sG/8TBjYMOGZwC8rhkyNiARCs4jks7UXSOsLKCLT1xTCVp+n9qGLx+X7JOv7bzYRwIGwtEjUe1nc5qJeFArgTNSTRr7w8/f4Hwi6IcpoATUs8lhBVK3eKeC/rMmrIbSiW5WvoZS/ajMvu7JJ320eVDjxQfc+keCpN30B6bcjnWHEU7lC4fOxrQJSm36sXFpu35LjKRAuhzpyA2ls1oiSqL5gfUyFqfztA8QqSZJ54y30s5Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uwILKC7dfUfb6WP/WYQpx+3WkuqR6SQRAzKwQHgae5aI2ryz2T2NsF0MstakgDspKnjMa9WGaDERMU6VToCz1feFCU8KtZPxhfO4IEgis5Kst4UwdkSHapoWhRP8UtEucgJaBLRbXmcMFy1ho6S5/o4oMsLPpimmQRvn9zT7Se9BxJrfE3sTHJicGRG7nMSibFMjA3yT1yxYCgExKc5grMuj+VdQWU2oN+umR6xaxgOX0ixNPEO6NEIyfXdGXdZPynx5eU/sO7O9ScN+DlMIyF55NMaYUlv0HV01NS8omBriU2Rmj/l1pyc/Rr6L77GYqHJd3ka2qm+QWyq8wzW18wdaOnIyHlAXCuQdDS99cD3cZgmxudVC7iyLH+/GmuKOM90QnZ76UMDQJ7WOEBdN3U7qEd5e94yYRByXgLgOXqACgrwqte9JP8ipPMeSSx2RIKxVUfpLHIsj4kBUPHjAC+q0OOy8w2vwa8faIHeEhCD9ARJn4DI6rryydU63OR7OIFSebydmMHfVFwIDy2plXKSy2nkC4LFeZ4pDjDOtlt0KqhqgIuPH8wKZWmAfKP1JOI65W3lnnOCiduwWgLEn/79mxk8320XtP1gMr4i21Vhlg6bICaKTBrO/BgVo00Yslucl8YgpSYRjs5LIDMYtcsWeRYZayVWfcp5XIv7C+OZanuds5INv+ExIRTxrzIjCIh3uEbLqx7vu3/ugVlldYcUaKfdHe8wShR6MTMDq4hfsMc9gP/zsVdD2u78VXBZ+ZMQKHvc3fBuGsgZCsRc3RYu0nM0VqjisKW1Rce6IHf/Ko3GHO1L1ekEv1R50AIe6kMSA8XZfP5WS4OHbRR5VHycPkTwDp6WfnozHZFNwtylmJaX4T+4IrulFf9UCKClUPFvFS0SgsMRrcSxxY4Ik/nca6xEoIHa/UCyYZ3gdPVS5khY9BydqaRV/TsI8po31b57QRWZOAr/SJk515LYXwNGk0hiPeV6VPK5W/wXMJgfRaFsDD/Qn/rXe32IW6ksrYA9NAybjsj2twZPRB1mOhw7BxgvTGof7vc2VraXiO9VX0VyENQ0oRsFnYNsFM+y/6Hp67OKChleLRhLdTqBfBnAXWi0yUBknTZRySjG9kRSKogvVTNPu64oQkwJWL2BxgR7ytkwMjodo7eoIdqywcsfFG+HR6G0xf2n1qKdgobWSz6HFu3HXjZlYU9D1oGRr21IZiNeDwl+Les0HJPvzrteEcEdzt4XVNtKaFNCRR9/KamSnU9uclZbqN6TQsPGP7UUQ+SM09E0n3lVPcrZwZApRhJ4vaEtGpDsA5JVmtTP9k56QQd14R7TaWv5ic8k8uehzExAzD3LThRQovDM1/0hoeuhOszwghKua2zdEWZldBNBhGqKXOV/6/bbtC4l+BlKlkZw/xBebFf0/DA3ochh4lSZZrN2S0NZ2R7XXdLVFPfLemDSNJ2W9At81GHpRVYgO3KhTHxjO8+9GDTERkcZ2y8BnQXPRzUBiWlK8iiwrWXC5Q3ViDxvr+sRuaO5wvo5OmWnPVvI98ap3ynVQQp7xS0BD/RKrl+l92fhPXMz7ACGoIK8Gb6Zx8YLCWWvJzGeFEs7x1YgimbaM0MpXA9PTQjw4HhD4ad+zjol8bxVPPV5NH5wTxkPfpao309sH0pT4WG3mC/rxTVi5KZruvw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2090d477-ed9c-4ed1-4f21-08d9fd4e2e3a X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:07.5891 (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: norE0Ur1O5xDyaPXHDFe/py1KGO6kNNZwdrQlzWP7dVN0mcVXDxC9stLoVfoTOOLsNkG1W7kHeNvhxG506KxJBN79FW6EXv8e2+vsvZOVi4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::72c (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::72c; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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..ffb7aea2a5 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 7.0) +# # 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 Thu Mar 3 19:43:38 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: 12768022 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 9B94FC433EF for ; Thu, 3 Mar 2022 19:46:27 +0000 (UTC) Received: from localhost ([::1]:43378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrP8-00074I-OC for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 14:46:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrN8-00042C-TB; Thu, 03 Mar 2022 14:44:23 -0500 Received: from [2a01:111:f400:7d00::701] (port=54113 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrN7-0004Yn-5T; Thu, 03 Mar 2022 14:44:22 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VLiiC1pec9ghapWBRfNopMAM36LMtjMrOZJqxzz/bo9L+yfmERhz4LGJ9SBG90U0NNzTTaqMAeFIk6lKUfHHLYJBx6ZW6dW286fYuAC/i+K+lamqnmWRGFFoUWRkFmjkIstkZ6KvlT7b2+ZsxnVF0toiDQvklZ91W+yM71TtP1dU1NmXb1EX0adpey5Tyxvw5qucBhZNEvStm/iJWadu7RWjA2D2UkokhuaVG6ArVGuktEKjZ/lgoRrzqrmP7YwFtCrRqfB5F8RmTxGIunxgKpL/Yb+tzgu75KxJZRpnYE6LO1onhU6mIzWdXUE4kLIrGx1YX5BgvqkNe7lZpX1uiQ== 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=TLsp5D04YNDEkYgzVb9qeOVz9FSpIv6ZMF80plbMeO9Eco2HjBdWrTLrHyhxAnqxXLY8Wm1W/YpN2zde+Xy6ET8SG7ZtEmYEBEohB6jtB/Vp0xukwX+rnQHRp4ZdzJflAF17ACH61khdHUFkXiJ8/TfJMtMKUCL9lRfG084kbq+b4KV/mgZCyD0FPXwsckW+d5bgqZVdX3TaY2nDyYZJ/0ycGu4dXL4kutxwtcl5yvlK6fBFiYOdAz8j94333hTH7jYGnG8qAgO/8TmFxt6RlJ5sfws8ew9a7ymL8c6Dhlu36V9NIX61cDsm3utp64g66lM4FaA1U7Yjnl3sboZOHA== 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=jxj+LjJzwA4L9C7YG+6FyBkYIqYPkU0zjZIYEGIZLhD3C9YeN9LvOn67wDmhKt/e1yMNDbnxSRXs/2fHs2yKr+fDseBSenB1GLbh5Q+wp9d+v9orqvKngvqGfEEiSxNPbqe+3lqoUjfm1ZdmT5bEew5wOzoH/TzUvEe/XgWur9w= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:08 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:08 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 05/16] block/block-copy: add block_copy_reset() Date: Thu, 3 Mar 2022 20:43:38 +0100 Message-Id: <20220303194349.2304213-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: abfd5851-bbf1-448b-1171-08d9fd4e2eb4 X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dY/Ze2MzJVrTHonPv/Qht9Aahrv2Ky2qmTzKMmtWhzLA4tcq3c6gsEds9YJc+D+MdA0KKOsChf0s36LKOj8AovBeuNEjuwEWASx8iMouAjUj/4bASjuO00NOyq7xaUDfN6LCXYrIJIoVVgoafsQ++Uqwz9hEg4Cjz/6M6AauIipvnBf0xUAvkMKkYKi77VSuJNnmJ6l+OkZ0YM0p2USIlNM7VfQkSH6VsWWqJn9L1qNa3STp5JL1Rb8fL3v5JVqH+q13w0Y6c5b/Kuh+OUOnG7PQC51Il0T+QRyPG1lVt2XuGbEu4UC5aaLRX042CknYjALTgks7R8FF8XDmEGgX9FojmPZg9rr4XhM0oEGgAK769mjAAzdWIIM/lLK+QMjbQrG7XvpB9wLm6H2SAxKz9qTX5W4DOjP2yVOUSEM6yejUyfB/L0YpBUEbcAp8SZ6GAgjjb0LHQVZvUopOzDKCvpOJmN7AVB63awW0fhOLOqwS5w7hLHioTLa3Ez2Dsey21xHmZPJC9rLFjvF3PRangEjEfzbD78Iswy3mbDdKePMq6WqmUr9M1wDA1sycluS6iLwKkE/WvmBHPPUjNy2eot5moojQEHl2Mg5Mtz7Tk9dDtDTyzD6q9x7QUM/+SfSWxFgslQTeQU2HnxiWZkKig2iIDU+9XbR9mrc5Ld/CQ8zQ8TfjgXV5QmzFSFcPii8UzvbSd2PtVTklOxNjuWiZsg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +ltiz6Jrfu4T+swJ72x419oidioIn1ai/gnve0sBzoUimX1QTOLM/tmYg1Bd8vfltOwIFKScJXzbWAa08o6CF6YSap4pKwghw0bUmITT8PQOv1e0iNBT6/MVqM9EQhbrdBlDim1jb7oid4QEmJrMEMYKRMY3Z3d05mDxwIwB8Kr8xSCr6ugaRYxt0dqGmdDokBr3JuON7rCPwO0vA/sFyU/uTUAnbdXrW8sao6TwO3Q9ZgEZ7D9dNSY3lJ1CKG/TLmzZXmYHtE9hAq+HDyEbM7E9S9mUHY82dx85iPysaVWngTfAxR4S1ltTXy1JZk5vw4PVbAhiRLpZks3cOo9qQAwwhPAOP2iDfep5fAoqpAxIZbseVES9LhzuQ9pWxmyz33Of7i8n+EThGtpQHb5mAq7KPWEBN5kmJVRQjRjfYZ2CZDbu1w+kZDGw1ujrGmrVBzO9uHeCYFrgCKS2GMO7VxSs0eFHyn9GTUnIRUOBjpfgJRdYtvBVc28d/irBJexR43nW7ke6NoHgkHkjUbE7vs0avZtx5yC1O3G0l9mworIDVLkFHmAo0/31AlGaIJbaxpbwW2Ym7AkS5XPrAynEU5U9mOem49uKGUQCWYZuaoLs/FpcuEXiV39JOI+fiEgR+ejTKZXiomuzpc/4P0jcEz56jRyzAT0ZlUB1d+6ko2ij3CRHUm5D8p5Xab4kOJxaYPEJxr5qRQuUICQDiofUU4ml2rbst+Ojc3qtEBdLfxdBMZCm3ZpkTwysTopmw0hGtyrgTrdTX+AjDe90iFuoARscsfup9X4PQPZyIcFwHbm3mIG+CF02gz4SpwBhgTFZMbKAd/Eny+MaNGPkOAN+1+uRdetAqHiSPBCNigGYBa/fkSQ0KkaOY8an2itWngHq542lKQ5x3CyqkBieoLguTD6WYBmg2Vg+zbM1KM5vM2FuZnMv0bROPx42yzJvs2Z6Eq9+DzU1SrLc/s/CQZmZmhC3+XTyX4ehZ6pe2zd5ytrIGNnIXGtThuwA3zIfPaYOL2XS6HLVGv1gaFITtHxpmqvkjGKqTcsuTe6GdimSIYfaIqm89pFcW9VTmgHcr3SNnSgTSfs0hCTpeo0QnVotF061bPA7lp4TyuDrKlsI1Z5Q4JcQQRYOnAn/+zfpCR5ySwySkabcPyc9LRVK02SMxNv0OUpLKexKwb6LEcqN9IDg9Wo6vHxuYaUu/z5Wccp3AVpXvCBs0JzA2fD04PGNRXJqx7xF8HYTct1ZCOMvSw6hoRm6wnw7uW4sZY2Bq90r5tUl+HjFqxvDQVJyH1RxiO1VL7SQuyLdx9uaSNcFEps5CFRDcSpwX2K/70CqncIWK0+NPA75L64RMEAzD3Ha1WsD7vd++nLteCZwQxnGFxq8ZNIs0MtdxbWqtsq6RooU+SKkP+JlN+44x1R9q3jv8ZKq7cVt08Jy8KhBO6B4RuHgzht1AK4/jRSB4sri4wQ/HpNfQMK+NWKGfD9bB0jVo/gFVJ2Er3ZuVsuA0/lX6AUO2t7Q3vfVzE+x55CklBfwhMTLubH8biPTsR1EebnH+xpeocg3MWh8zinZ4ktkxa4FSpOVN2LMnMFfkV/8doRkpgKxyHPaafPzZXAdRVW9g10nuwQc2Lh0GXI8pVzR1ADB0ino4HM592RO4hxhd+AZrgZEbQt2LU8BcF8RnlmIkA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: abfd5851-bbf1-448b-1171-08d9fd4e2eb4 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:08.3402 (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: 8QtpAhziEnMHGF9hlOsVAvXLG2Z2jIfZLQ3/ToTWriM4o4fA4ZaZE/VaNsP5iVeCOA9dwo+g4f25MFl+YuOV070uq84ox/+EMoZDVKFgtv0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::701 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::701; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Thu Mar 3 19:43:39 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: 12768029 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 E28A2C433EF for ; Thu, 3 Mar 2022 19:49:14 +0000 (UTC) Received: from localhost ([::1]:52790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrRq-0004xg-38 for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 14:49:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrN9-00042F-Im; Thu, 03 Mar 2022 14:44:23 -0500 Received: from [2a01:111:f400:7d00::72c] (port=28672 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrN7-0004Wu-49; Thu, 03 Mar 2022 14:44:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hdh6n1EByZo5//hsh5fj0zylEPYPPrxrlnfg72XtL04pq3Zdgxu3AUeBBPRpYTmdih9XAj8jOtyoyiJwn+iIS3Lf6cfWptQ1FodcoeoZMD9u2KK04YnrCEbMA2c2DqNvk0jbeswke3fUfztZgUeeFo6EtOVayCw73bRAYyHaSZINPUQ06d2ZXfwao3wLBS5JujNUrWsSDAtdVcBhnnZj4R6OnTjzmC2bbeZxv/4vuxFQZQB7k4j6+9S5XPQ/Tb6yf6+GQF9Gbme/Y22IHi5yOi+4FjIJan+dw09fkZf7iB1NVppDQP2skSoQae6LBBndlGvMrNaLou0oRX7zC2ev7w== 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=PTYxUruk2BC9BKuOqqk2NLVJaD+C49EkEw7ZvJgoBkM=; b=fNkaVz5u6iMspR5WhglxtUOozEFLKwvtLluLCitNFKfMNkwdzkRQsHOyyRP6ExyiKlNKFvtwkNHSlaIVbSzCctDygedIFo9EXNgc4cHQ5fVHrFN6Z4YB3fFTtz6jgKhW4fJ1/SlXuute+bLIkSsHwXcqeWx8NWTtfV2S7J5GeC2xX42wQSAZ4tXXz3jbSbFvGfde3WV7mrzKMndCG5QZQKBdk8FyxObYC0SVcQaoPl+34R4brKJmzViQoWS9589vQjnv9h1Lgzwxz7PAkwZkusKlgg4GwiOFxi0a1PD/UOEk5twVh1yfaEVC2mpnQ0LDACnRJV1anP7vfP91L8tdMg== 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=PTYxUruk2BC9BKuOqqk2NLVJaD+C49EkEw7ZvJgoBkM=; b=h3e0hdv2ukkX96XKqIXh4VuI9FD/uFLA2lhsBx6tuyuScqJBBbib7bGeF4nWKQrU24pT+k098PrTX+MP+P1SvkXuzeQcXRDK0cxpofL0APRAnPKHWQEusE0/VWx7mhlofsVxHLINMCOkA19UwqFAhJ9PwTlFj2AXDE0zl1t5G0E= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:09 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:09 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 06/16] block: intoduce reqlist Date: Thu, 3 Mar 2022 20:43:39 +0100 Message-Id: <20220303194349.2304213-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: 36462020-ef95-4982-1acc-08d9fd4e2f24 X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PwV7o4hDWoV6cHsCH/OXf1tXSFNML7qznk7cGIbMNnTrfSFJINYx9cCAxDFJO02lxV1Nlfi3WFWF4IXkVzb34ZdoiCgfvLKYVzKZWgqoZ3DuIkQCg7bdFW+46T3vNthzJawytoD7CfqOWbdSYpbwTlzJVGElM7GRHL4igbr8kDCClQhuROnCdJuxN7UOCfJyv8qVGBVyOkbHG97Kso7AqbxmveW76fEg5IE5LQTQMCPeTVBFOV767QM0Hzg7aA9RRIbeOGopZ6B2uLemUEzF4rpplHxFrK9GIhZVrYgPHd5wrqzsgD7vwpguCXzasZxVxDBfCfRp7MvG1IE/4tz+3rZjPIl4Gd+YUH+taHYti9R0BfGQMyk0CBvXCn83is3ejg2QkvU+XTqviUMf+Qhhk6W1uKJL7PHICAWrHPG5H/KH/jjWVq+3Wyd3NnzhOOxZ4/MFVloic9BXmanU62C0tZIzxyGEdJVyF9BFWuyH54UwGHNha03HtkiotBk32d1+2DJqanOGXiS4febfzofBIcIMfQ9JgoBW83btn7wRFShnS/lOgeRF2rQKZh8MiI5EcP1CAUB0Stq3BhjhEWUe3upb1BcyqMq9S+yHmaMV0cYb19iTqXF0IrKtwRfRGF33PTq8rYuNmqPjRD1hPcR8/n/s1FLoYbMpBCXaCgBep7Vyt3P1n5aKkbT78FguFpCLWsJRdMLUYFnIdidSHDuVww== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(30864003)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: y+9d617NGcBekDSEK4BRywZ1Ux/4GjCrWXX0hXYqMKCnZ96UJnigxrEs3Ro0wxaWbcQ6v87xgpXj6sUZkkWKUqE6Ouh4zm6qe3u9Wsnt6vT/vN+8FgdLTVT8ASPXfJVdWkS7EEahE5Ruvzv3e1Nhn6Q1s+QBWRE7g+bNzLN+84S3StEMAVWoNFgXfIM3F5W+i5Xa96QFmQetb2rmQYRZUReekdVrYdo0K7tGMfUSNwEXeQsg7enclKL3s3LtU4d/uPbDjTC9XXkfKrHkomT53HambG66z2cfbVFM2kkzY5soDum5mRbCRJ9hamzbcHIabCUfbRafXdP/+ZVjmeY9f8jwdAfs7eh1ObScBT4+xtgrAtBgEJ3JYbbDb8BzYqNfEgMEA1ibv12pI4NnSnixOl3CcafrKnq65/Q8UkaRLvFt5urXsMZDpIemc3ZOrPd0LnRTMOh50SOcUGiK0g84uXmaimnLYn+n/tjX1XWYsz3lTDrZerUq+bxKOs+WnwBnBAGIYaMoV/XKLj3Z6yOO4CiuB6LypQkB3tV8fEkkGHD2jil0q3XpskJZUlAU607EjZVFGYgXRghW86i3vRoW36B/0MMlUHz9JIEdNG4cUYyljTq45zitP90apV5zRvvfQTYEMIBmPacAKvhfxXAxlM5K0O8ldsmXZvqZPCeJj0PNyiwb0ISoCoYMPy/Dq67yLHn+bJxBtWW1FgD/35vkQ7WEBa0SUApS8vcf+8pSP8cKnCblYoY1NC2K70fRaBhQX2skSfeKXPTfZQZcSC+V3tjlr3DQqJwC3OeHXoXs3EtK3AZFTcC4sMXhquqDJCdnn3I3SEGbp56WmUyogmgoyrhLbxw3HjWYw3uT74vZA5Pypu+tbMTdtoMvRuNITeQSn4FZEXHYp1jQLqk85GCzqcKCn6n5jbEmSfJupjbgMaT2i4Y8kMhza5gQt0ReUqK0aDbLBu3yN8M091kScCyas+CGQE+IlNWus4hZY08tuigKp8pDBgKtQqo7iUWj0judNRwglWkln0ob6N4lDOS16HikOyAmnHYmXRwrYlIi4P9l0VF4RqsIfwoSec118NIAzap/HmJh+3c9gJpwiNSlrxi2lwTcZGvygJkAOWADvDAqSnOJ7aciq9wOjvhEdtL+0j/u58iGg2oxqz9wYtNsTFatk+Ehtgw1Cf3OoA6xqx3znWgilmI6xzaO8vrFGTm+iifYxvpYbYhfDrXD6kcHFNClbPIoy1BoAosqsG9v8t/30QD76nf8ow33soyLUoVuc9C/IEE0J2svxU0hL94iAEqQdJTrobm9THi1cHRLaavILqkJVGAOPYdmOoZ8FjbWneO0lrXcMYKyeRfriSlS35+JO4qRvPguYJkOrOXkGNjrZplIkcXGvAYZ52vQDbfh8vwDnvzGfZqDZRfvFKA9q1xrU1UkHqMUBm2zfieA2WgkTGidk0BxHcuhrhlAv5lrfICJfEvxI912rGkY77EGs6khu/cSIPfbJXE1nwUJCMOSX+99v3RxYXSFtg9X/jz+UrinSY3T49CYogfV/qNaVLU+POCDoQ1WigJhVddENJherpX75h7Liu7MipH761ZUX6mSlMdvQCQsEaOpxryp0Hu72I9NtAX4sMSvUgYtZaAAWnUIjnKUgFOMZ0nwyCuj4wnoU1G9EnoRvUf7LaR/MA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36462020-ef95-4982-1acc-08d9fd4e2f24 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:09.0901 (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: ezKBSEb28lQzyR4dXiwEVXIpsHcLCcV0FR7wkhuy0C/T5LVtxwQhti3iR5xuWafhQCsp1nQ5sMhoXooCJ1fh2H1wHcMDabWxdwOrLfPfUnw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::72c (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::72c; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 68adaac373..101eb50619 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2515,7 +2515,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 8a1ce58c9c..41e9cc5dc3 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 Thu Mar 3 19:43:40 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: 12768030 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 57D31C433F5 for ; Thu, 3 Mar 2022 19:50:29 +0000 (UTC) Received: from localhost ([::1]:55050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrT2-0006UZ-5B for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 14:50:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrN8-00042A-Lp; Thu, 03 Mar 2022 14:44:23 -0500 Received: from [2a01:111:f400:7d00::710] (port=7585 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrN7-0004Xj-4e; Thu, 03 Mar 2022 14:44:22 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cd6UOBthZ+wMoXe2/0Z3WJ6P5ZWvbKbqtZ5a9JwO+vfNAz/8CYcYGPZD371BYYNQ4U+ZGXSPvbhk0ba7qLZSHz9DToLUYUOABp2vf5GYgwQFbd7Wq96enwu2bgD/m2U7+uBvvTg3IhwAW30J0sEYHLmQjzWHF22ufTNTX4Xz1dDSZZjkhIhxAG7mwJBtKPVJwoKhZC860XSGJZHfaJZQ+N15Gy4O+ZfjJgaIH+OXvH+RK/LUEZoAhmIBlTVSRw4vSs85WMeU5xaY4dWKkWoJQ1HxjzsVF4CH962Cop7Q+gvclDuM/iwjnykh+5bXKAasxjqbfbJAOXPNz1N9i7XuZA== 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=hfaHUhbRyFa1HNmcSpumz+kghFfvZXfWDVh7vE8MydY=; b=iZvveBAQ61vsxsRzXit86fCZwu2ubUf2eZXlTWhQoBxSvPPVs1KHaFb9R7DsJnRzvI2K6TX1RpSRYGsCGJ9tOPpcWG+WaDUgi/Ylor/v1+y5AD+VI3pcsHe0OapIEpDBtUkUcFcfpQqdDk9pXjRUvQciWbw1yP0N53chax2tn+YwhT7jS7e/fwehoujg2UabF/HP/wCSk2cveWdK1bUicFUfBbxhrXz9tUvTmV9BWb1WFWJMayvbIJoP7EiHFTyObf6mSeIt/T7LDi0mNjugWl0I9+zFNg8FFeU3ijkTzjlTEwjpNknsqzPK9BcK2K0TZVXT5OFkW63/6n5sB6J/1Q== 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=hfaHUhbRyFa1HNmcSpumz+kghFfvZXfWDVh7vE8MydY=; b=i2LG+FQfnD/4rvTHceUaOYaKLgIm7rwdOL9GRUByi5CtrkEDs/y30FVEE9SRybESzbo++AYIjoDd+Y8w2GsmYZvM/dCH2grADNRpGzVf63wUWXUKWabakjB5nd4k9mLVD+M6Yf7IMUyo93d42auFvluqNB9tnrLAcrnFXwuXwac= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:10 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:10 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 07/16] block/reqlist: reqlist_find_conflict(): use ranges_overlap() Date: Thu, 3 Mar 2022 20:43:40 +0100 Message-Id: <20220303194349.2304213-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: b655ecd5-f2de-4e60-e8a5-08d9fd4e2f98 X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IWFMXbDEAuMdRsjrmZVhm4oGzyvG2RO7VeENwo8k9pVKI5rY9rwcthEWmxhWqicxpCO08eJNjZrzS8RnMALb05PWSIGT4qbCUGt7EIzKVbuznkdlNAi9K6EfaPHX1CdMa0gMg8R1+jfHzkiDN7XUQ1g6gIGRvYGHXP+gyR4J+fOf45yoeibyEpM7yerHoqr0qjLJY/LyYmozZJGUiCGLzaRy8GDEL+MStWRfxChcMB+vwE0gwXPgEzRblPNt6zRyCcO9z6hv2NnYP2TFVgbergyBdfMEOLoekdw+xL88pvvT/wbe3lpyfUyCDbS75xpOOSRxWPjlFYPg6JA6PI0tslrQUg5dPlIy0Hr6s2rC6FL4dD6tt5L/9R8RGWaFU3kD2ekZgK/wN5In0qqPF/Q/YM6mr5TpndUKv3EYyC61gGJG3guQetypL83dp6HnrvcELeZ99DRgAFh22GHrULmh83fWB9b7bRgDBk8WNLd8aYU/mPagI2994t/g/VKsT9pB7G6KEbzq1UEHkH+zvFOPGcBwKuF2L6pBnpQNFAhYY6nKBPY7xBVmCofIL571nD6oZJ8gXWXarm5XsL4vrx8iqmoLTC/9BDrsCKJv5skyqfe57Wo4a49KUgsa160JWHgtfHy9zmGxmNwMA6Va+x1bsJy8U9bf79mlAYvXnQy8tq155AwuGc/3Co3w9POg1A48uXCVE+/dbki2S1KwBdgPPA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(4744005)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +abzVjYIvRxZObYbsJ5PtqOOlfZi8V6eEVdcnfSklhGgD2J6LVXjZVTmq9Khlr/LjAUyPgsz8lknFnAP17eGNAzjTXCnmN4S/cAX00vi/QYdYiZFJ6pI5+K5H9vdzQ7Sx/wChtqsnHs6pH2bczSLUIhFxfZ9Z2Dn7a1fUr/9owDMufhZjoshl1M8VFIa2JcyHFATAZ0kpu3Cn3JK5tXCxheWUWz/eaLzxrDxe0vX2ZpE4N1zdRWNjZegmPYdN6yrml+JKSKztNDVbOUE3CGeZHyZ7kyIXIkQtLZKiehnuV4M07bEHWKz0dE5m+CC6Lx+3DvvCERteqT8LtSpw4HfLd34faxHAFMJgFnqeDV3o6bX23y+SnLHrfTp+chyYpGvu2bzq7MDJCSKL+p9uT+qRk2sF/hrHXPWcjAVzyK8X+GFY/RsKyXq+IV8/OZ+RQ3G0iCtcbw8/lYgSaZHYEFQNn3sxO0TaMf98rFuB3Wg2ZJtBKFMShsDKbd8llD+T58puVcKv8PYkfgsoa1ycV5Pj8X+hZj7Lt9NcXgN+bdnbhysRK7Hf1rkioSKfd4rEXcmO4Rwo8lC1/aHa5R5r4z+02DlhTPwu+oqht7gXCtK41IHS6bf/4LTCpHlxOLUxUxyjHfV+71mD37s8MFZ4IlPDaUmhEe8oJ9zIyIb92d6Cp6/dOvRTXUGegFUhCOUNZRQ27Vq9r2zgrlNXXqgb4XpoSELfTOxA9kHZPhfohW8H4gzyO+ob1C688soRIsEvjolnLY8i7Hw7qV6vxce7BMvyKA2ysCSDh2HVr6Gy2uoRZeQ+l5lhLegJNgIt4PkPYoFxJMZOOaK7rZ2Cqp2oVCVN2J2+EsLDTD7gK7POY0a4AFItICwEi+yFnc26ABvOT6PJxYBEMXIPnQ3h9L9wlNavpuqqdrDnYZWPY04SaqRh1JNwaKWO0dfZQ6IqRfpsUIPH3zrnV8DHtTTGLr9BQllQKBLYHqZVio75tdlOlibFtnBFxww/weAg7EQW0kemIALEtN9fE7ebg2ugBM8s/uxxdOFww6d33zig+1USruIYigiV66hcO3mwJV8aTEibpgEm1iq6ie/Jqnh8lsIVoUw8bnbTXk2UKGr1cmZmr/RW5CRSo30qZpS3E0cvgRRAMFKUnKmGoinYbHbNaxGUkjGf4HLyf1apb+6X0cqs13JLTYXYdWt4UqfWzzyJalX+u8j3T1b6pOEfPCqXsJYvSUiBVsF1+XfCloliyFs+QydiVAvD6yRxxX/mA0sUHGoTp/QZfW/k0H5cY1xhr47RjHou010VLKJZU5TUI60+QEPT/zBdevbrGoXEfZRfqLnh4MD55bENBNdmutF76CI4OYVIeWiaa8NnmbgNzSGhMpVHrvuYv6gNqf8caCN+Lz87pPdCzZVTdXYnrAaOxk/3tmuIOcyKoBMsninAdXyALlfGA5tqnaD0HobBiPC0Bt2uVqbMPHq91SJ4Qfsi1KJ3AkrQVmUi/OcnBlBkUf0NmoXQux+DyiGKocG+EnzFaHNp7iFg8UyhVVWtJv2EM8wTZdDhcqaKk530HS1FER+vGjWBWYHtwTFVBbI6CAxbL0jL3xfTCoApcv0ad3oxVVyqGxS0sY3WF2KOJbjcTnafTRI0bGlSIdOI5Iy4ujQ/pLK14Vzb3nP9yJD9neShQHkspTdDw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b655ecd5-f2de-4e60-e8a5-08d9fd4e2f98 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:09.9024 (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: qV3yE9YA7BnR3ApAhQ/cz6+zQKJoXcuChffSQMVCtaK6VneizEEJVeiKQbdac/I/Jqxv1zwhvHtZIBBClGZlVpmS86BiNqbxv/05okgxeHY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::710 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::710; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Thu Mar 3 19:43:41 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: 12768026 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 BFB39C433F5 for ; Thu, 3 Mar 2022 19:48:44 +0000 (UTC) Received: from localhost ([::1]:51924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrRL-0004MW-GJ for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 14:48:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNA-00042n-U1; Thu, 03 Mar 2022 14:44:25 -0500 Received: from [2a01:111:f400:7d00::710] (port=7585 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrN9-0004Xj-9I; Thu, 03 Mar 2022 14:44:24 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fFthBNjgUs3IN3zwTrSo7ZJhTOb9kiJe/HIqnV/PZoXHpNBcrtPsr7SAmvgm4D3549qh9BDT8UeV7Fmv5FOxFY+As9+uNUqbCRlYJSudqYcDoU73SvGhjgTUpgDCzPWxWsjA+9vdcE/eCT6mwLlSivUlEtJYvVDWfRFmz1xXoq6Wvv10DgTjyE1l5lOaRE/PiYFwXaZMTJoGsY0XhfhNXSJ1g/x2oMvWlEMpHNJk7LMyZQ0g5M5t7L4Msbcrd8EnWL/h0aINznp1wam6XLnu5IBs22LxaMq2dEuM757/zNl90dQRexUqF37XfC62OacgxjdnO1kqBSvAJjTb4wJpFg== 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=ZwcI7D71CBJ848rjRlKBiBn8VxIYRQiF2qTE9/or4IU=; b=oTOzsyMuvXGbBa9uwosxXfyZpUQeU+5Gvtl5LekpEkAMGGnmVX37B+rrCW4eEkzAhGj2ndyq0FrVjw5BZDt4FoWrYxhiGWKXZiJ1DCJnw4YAba4bRabsGvfQHgtSLBRCYVq7bI+WAhkUgpyUMksjGYZ86w1E1+ez6nOpaShsBZ/3SRTwwYwtklJbD5hjPCybA0wnCls0Nv1iyduS6E6TSoerpV1idtt5Ol7jVrMJoqcP32a+6WEmhYSgBTEQXXDthnV8CAZrRULyc6Yfo61SBMR/hErDGGs8889NEnfDxNxnigvj4buEL1+jBp0vo4KI3r70wUHbY/aqzDcCAbZyRw== 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=ZwcI7D71CBJ848rjRlKBiBn8VxIYRQiF2qTE9/or4IU=; b=NOmlevVr2p2AKOe9kTQOnnGM8eI41U0FReB1w08qelGPH3QPccvJrN10tgID+Q2WHBwvzuXY/r36jnZwokFqf0G0GS0KiS+NXWj2of5ti3YQSIgBvUPodkne4394Tl4lmjtfef7QfLbf0rjuBp695VckGXwgrR6YOHgdesVK4e8= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:10 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:10 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 08/16] block/dirty-bitmap: introduce bdrv_dirty_bitmap_status() Date: Thu, 3 Mar 2022 20:43:41 +0100 Message-Id: <20220303194349.2304213-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: efd4a457-088e-445a-73a3-08d9fd4e3017 X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nGf0XPgMSldWnjl2CYifDkG3CZ9kOLTb9O455vN7KAhSiiGg5xsQhJ0qBbGjnMPkYpnr/BGOMIddD4a5XeMSjc+G3W4A8CtIT6tIgIRioH8+x30axJbBIwt+ja0wx51QV00vyLB4b/cWgfbfOnMCWWIVDxod6DTgUMYe9nNDUfS5k3cvy5XSfFO1P74r2Ip9HN3VB9v5iSgyD38yrchbfeoX8KiyH70opdqAssq0p/jIOTxMmtkNJAwUqsw4KNP/7z1QbmrkwYkL9QOt47J34XyhVQ0s/qzj/d4MTJyuzNga8s37ZaKQMVzmLQ43DyZdfBh4/jyadgcUmgjIipDP/fIGU4oOJKRUqwZQr0+aYx974inxxmKj0DZpiBsqh2AuEEq37zQfjCmNEnhCvl/t8FAUb57Tm8v8RvlE/wT1DvNYDWuDDqKQSo3FWt/p0xamy0bo7U61l2CB/qMvkAAGmutv1KQzgcV7RgjuvbWATSsgttxdOWEDr6CBdND2XJQ/boYgodWhwCJSxWpO8N8JkjMiwcRVETH7r2k+BzLsqsGLpxWatlVR3nVmS07yAWNpMxCvPcinzGcWAV8fvUoLYUrzAcY/gVRU4S37+TL250tbnhGa2l/Ogb4HeWSY+YLMukxzvflq45XjEnwFNlE3480Ndm+zyBfXPqAMCYeda/ac8uawk5lWxci2AIkb0ngjW6jF3XTxFkS4H8usomRuUX+XLOpurcZD096KMxviAG0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JGqQM26wfLLeCj4eJPxoPoI/Ry+l+bAVyKo2qsXKUAaIE/mgQSr77tpO5vaPUKxNinfienprAiJM4YQHwrTSs7KywTsmirzhOZp2Ud5avla7cnUv4QoTv/xNBlUBD7PRtgQpzTYmbIEBgsamvnxFMAagTtOQ2jowJqrJTIW/52XJDra51k1aHycpoolTW9xmtK6s8NOreRBtSXK7ryHww9vKMhp/LShGazv+mBudjoMnq8xxvNwhx60et4faYUwzixP5cGjOZlxurBxBMDMSzCajp/i0ZyjAPjscDGHJ+VmmtLcPlCKaDxISQ0mcvzO2WuCdavtQq4NdR3+F+N/BcUhNIaAOC2nhrg6tT55EZ780IVhJYt8jgpqbV9YqvXsxIYnZV6snUEls9W9/nuGCiC8OTc22H/bhNeMhF5vxP7yjyUfuymc2YjQmBLtsC0keh0c0M1elscdiTShn/+/4/m7FYg7aFK5jFCzFPepTG1k9J5Oep0BD3hU33qkhobSJ2P+u2nT3LoDTggmRfXTBPDM33YPsxtGIwbylOd3h6DjLdhQZsOhs5O138z8xuJISVrmvmy58Ef+n2e8+OxSESQ1VhuX3MzyFK5X1UFFG0V15kUHftLVkJIEYtp2EBEF4U46w6wHmkGkZg77zgF/dmAu4sMczdGsVOtprq20jZ0/HLFBYK+5ShlP+XzCfaE/8/Rj2tPBvpwZscU5wBxvl3cAJ5jBmKnbjT06NjQSroOTRETEihCvJf6HAZM2bW+MgwLjt8HuIasDLpVheZRRGo9OgumZVqXXSYqkadgN/zap2JMM/ZUCS/fEe1mAyi9JKOgxa8qVqE1LB9sle4qXCz3wCovx9T4Ih5RbIbIG8SZnPH7ZE2zV8xc6MMdhUiobfTLdqHNN88aesV2GHjWY2PTY+4ia0ah2mUuP9/7WRvCSfBCv2XcXsfwCZ8ekPqzU+YZelPvhtwaT/KcloMP9S4uyceIUVZoaTF/eU5vByHskLH6Gjxl37AMmw64pCsq76MaJkBlnJTWy1xGh/7YY2lqQ5oc/NXm+Gj4j/jnu7IGkZQRaM+8jaRF2pXowcQjG/xKf0hEmtgyOtbyrqaNcTDai130PavvAMmkqzuffwKSNyXEiYrd/8YY1DAcFT60xAk8iLCGOiQeJmI4k06CMyMK67tLYGrsZPU/zm3AnQVdfBsiSjUhtU3SxfdQJAdoJytcl3s0lA+0Tj4pabZx4tXS/dFIEIsSjaXKsOfgjibnYZi3EeFIazSRip1DOCDCIeqDC1OggfDfISO7/mbWBeWTDDz3f2YSPdse9p0AuSsvrS5Khbl9psA+D5awNaCSiS5oBaB5yIKVM+Cwz5iN8NqrLf7ayGLHcUEtW0UWabP4TFCjBpRU0Se3TelLBn2yGzfZ4/it2hb1UGhAoJ215zH4Wzpo7y+NnDeWfebAaPOZLw0ujWWQAP2aLZG3pLJSFGQcjozMn+Bh4OqImHkEJpGgyp50CAGep++sNQoVmq9OrihvtJiVZ1VNGDNxuF/NdAifplBNpDdgwIPvNHwXorPE/4Dyb3EXUoYDnmNYJR1GBDQ/5aAVo0tRO2sH6zj7t4AEaMZhN93lDYhhVHM0gBvaHT6OyzkgTFUsMEgL2LNwqpRyFGG3XvH4V8dIKe9moZp/Ap6UoYcBSexSwxQGDsDQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: efd4a457-088e-445a-73a3-08d9fd4e3017 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:10.7017 (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: WvDN1I28Fqjj1Dw63VUdLPEahVw5EX177hE8zAIM+Aak9d8BQa0hLfmlwtDXboM5p4GUDJV6IQVvtBr/etjje0UEa9A+CKtunCUCumCjPQM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::710 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::710; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Thu Mar 3 19:43:42 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: 12768023 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 E8BDEC433F5 for ; Thu, 3 Mar 2022 19:46:39 +0000 (UTC) Received: from localhost ([::1]:44148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrPK-0007bw-Jx for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 14:46:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNA-00042o-V4; Thu, 03 Mar 2022 14:44:25 -0500 Received: from [2a01:111:f400:7d00::701] (port=54113 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrN9-0004Yn-FN; Thu, 03 Mar 2022 14:44:24 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qo+F+D+37A5pPjR7JRWX0umf5CqEDeS8yBzvJ8GWwBJVXDoZV5PVijUdlqfveXzsjkle8+y6+84EboVjX5ugYZD7hgewUCt6HS/7kVuej8ErOdwSn+iNcIi67HWV/CodtlhvspRDeDR1PVH9vsPfvTmFKOkLEpGiQpol5eWHe2YVsZ8VySzp6cXgIntTPKdnWixEOfLVrhwfQi5Mlrtw25SXWsH47MiWiO5CgdLv7tCNL0KJ0/m9Dk/0jUU6U+3PQF9HsncHmkt2pBNtU1JE89z81oG6TdDUN/bKGLjpswvvDwazWbDriSqLT8C8IMX7WBzZOkCNNOGup2SQLojuhA== 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=PLtKk3LPVk0wPi3VPg+ZXvFQ0fOeGrI/drhAOs1JIwbhsKMmLtJETj0x5AJ/RUcIkBViXIJ/hK4Fpn7tV+IyRLuddUzBbMNRBiGMKww8eCrdkezVdJah1QdiGcE4PSvDr0613b8b1MRPyof9SL6BsMd+snocvKRQZuAoFnWPftOvNvHJwcJMbsJsyuIDsioAezzvMnNfGrUrMpaMMVK8slnsal6XkBDqP+junQa+f777OWgH6FoxOFiGse6rBEuO+a6xwwLb80AyOWqBTdM9YNs7BuraudjP82HTMt33/VscKQIbKwCyoID3O4NYK8zSFANh/4M4JyYfzLNkOWdK9w== 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=sDa9XfecpTH8qux/8qRryoZmO3wG4gFsC/dJ8s5XdV5rrx5B5EetTgsq+spxdBIvymdrQ6cng9qAGTMBT06ijm5UeQkhf+VMUuAyx7hjwNfjaeA4B2TDgDVCKe8PxoFzHykIFcYtsI4kKyYVccHhe/DiRDDDuCzZITt39xsYD48= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:11 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:11 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, Nikita Lapshin Subject: [PATCH v6 09/16] block/reqlist: add reqlist_wait_all() Date: Thu, 3 Mar 2022 20:43:42 +0100 Message-Id: <20220303194349.2304213-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: 97405140-2de6-4ce9-caa9-08d9fd4e3095 X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s2B1+j4dLC3xGzRXBy/tqJ+AOsI417bUuXioiNExpa+6ssSVW8WHgFmZgG4BH9NTJz4reUvSDMlqMgGw3lVBtXJeITHnQ9TrS4bXygSKfIGElRJk2N7ZQfO4yXkPE6YFal09BWUn7Jg1s/QveQd6Vvl1Su8ogrSR269Q3Gohnc1tQ5k4c3kHnZ0KW7CcS8JgJqaIrWrMAYNkGGOCMK0FUvG2s/VO+y6uHu7aY/Bu/ob8Hjt2EIyphmJSD2D4dZxHUk5q5wBpPqVXA+CTFhC4GnaRZvXONTrx0eBtjg9mGUeP8ATlMshw7/yw+ZFC3tKUW6jyqCqzi1TmSljBlS5LxnpqARc135DzciqcRtS+WI1b0F2jdHnwmoS3WtKy/glVgqFWTnyF+JgeWMFePmvTqFFVE3wL4NS9GN+zR7IqXnRqxMooMDdkpjWTbEHDqn9BJ4RG/pDP2hemVvdudYE8ucO45P/cWMhSCFM67l3qnZZeOeRDNw7R0+otR9aDF+O4pnjnZJ71F7WoAF9jbRmsk4vQDUBRgHl4pPSD+f4HgduP16i84989Bm3yaxOKoVEOZctvXkJ93jHu8b6XZFBnO56/xyGMyZNOPobUqDhdgXoxopiARKynO5BCnJ+i2FD32dLsNTOyEqUYVQKcUM/bIry6fFaL/bqnDjQ/DT/DbwRzowHqKEjluWQkPKkePnQtpo+HnU4qyErhW3qXsIsdYw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(86362001)(8936002)(107886003)(5660300002)(52116002)(38100700002)(2906002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1dP0KBwCRi36gch+2LeGLwKSMH01Ghsys59U0qcqt5YX1IyCQj0ilqujo1jZDELZ3xY8HbhBzAHen7pPmi3FBAAT/LIh1REvsfQiCmnWGY47zdj/75r8is4W034rWAutVNl5hC060DnZIeXztI1reFmEIuZX6uCrRAcM5uw7qHqE6fCzfjRApkTFBn/x137knPh2isJC0bS8+wQt60t9413EGfLZCwkfEwHdFfGJchb0x2xi3L2jzumegpgc7BovHlai6QMdbsUpbI1tWyWikl8qq0miP0p7DzQR0wqVPjPHzPii/ZX/l6eROhj9cdjyPQLlQ3mO7NolSR+udSWkZQi/uf/3qgWtl9iSW+88bDmk9c/1Thgt6pXdajvvW/1j+jtrU7vVKXX4QTV1mFbHXrqfKvbFAGYUv7dSU8dghiV+24pVINUIPeIzd2VjoDQLZ5SI5Ors1tObIZlvLpQ8gZR8wmKj4jftTwWcTH8lY1QPfe28A5baQEZY6BqemWcFh0xWfjrGpO69fO4sopJ3B8XQHlLN0syP6zQyccH7pVYWKMOHd8CUZFYfaALW9r/t+r/ap4y57ui5djg6xWo4SrOzEM3PZLgs2t6nsAsIZZhCe4D/gnMp/0gcKHDBeTZgKgVNHhe7fRugliZvBljDkR3b3+HOQ/WyxUD/HeIVZK24yJasCVZcSFXAChYNET6WFSnL4RR6Ij1MVoNlWUMrZKeRKYaPlYFGi5wA5qRmel9XorIM/Y8A+0rkcXGngne+c1o0b1tEH+YH//o0XZTEot4g3moGmwCnVB4lXHixsnsqrg896AqMgDdZbZSrvj8N3wOCFBKtTnRSCPl+Sgw7qeif/1kmXYwKz2JYlog2MhUGd+QAcAJ23dRo+yMCtn1a/+skppwP6ZSTefF3LYmo+RzQgrrxr+FU35HqE51/b1tNnik+zLOIKQNZJ1SII4XzgCY4dBaJD++gM29wGpDCgDtFoNZMurMcUO495O2kd0uKLUt0eOJ7bfqJocAijyu2yutg6ft//jhsTa0UIMVs89mu9bYx/YAvq8IjuQcNJgc9UgdpGmf/WKkTgp0oDNfSz/jIeKmUvSZR3xz/f9BrTLW3lRex5x5ZNub0kGqotHUWrUKPPs38E0HNIRICjQgH1eSwZbfIni1+kzrspVsYx2KUD8eXZi8qsnxe1bq69doZmoEUIe01w/5r8rJuOm2oSu037/K7ckqv8OFrVgyr/2jyydsDI62DQ965oi4O5Ka7Ebzwz8btMZy1Df/GQ12sxHjnfxyj47fLM8S52IqlzuPXlA7VqBtDb8tTvrW0TDK5qCGsIsAYf1fKzZjyXGqBN8cMPHlD6nMP1I79OWMI/iFncbOTfZyv7A3HoN2Fy5QaiG7F/ageW6U/N570BinIgIv9AYWuV2b0ePNMeIkGEBO3mZi6o0whYc3bgVYgCnvKpignmp6PLvaQRm+giL5TwZv9Qy8nMA45IUKX1J8tM8qwDXovpayXBYZfBTcKnzxkMUpMz6fDrJ3nahqU6CQUUgR9ifAPMOVToAmOFy00KV67JhR7vmviGty5FYQVDCyiz0pmClS2KjvELiM3038kmln5DY/M8mmBWCw/TslFDNEWZ1RpSXHCnNgbh9DiDNg9LMJleCryP1KBuoZHhbOoG5tyLZoGBYznYp+P7hAQnA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97405140-2de6-4ce9-caa9-08d9fd4e3095 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:11.4816 (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: l4AiKJSBvmjT0/RAzJY+O+RPpLBNj8qQxKEEzvbllAE6qoTqP4qd8SaiEy2Ov7LHri91Mb5Rpwqf8VclYbj0uKvE4kYJXjwdGHEYp87dU2E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::701 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::701; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Thu Mar 3 19:43:43 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: 12768024 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 C9935C433EF for ; Thu, 3 Mar 2022 19:47:21 +0000 (UTC) Received: from localhost ([::1]:45770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrQ0-0000Fu-SF for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 14:47:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNC-00043x-DD; Thu, 03 Mar 2022 14:44:27 -0500 Received: from [2a01:111:f400:7d00::72c] (port=28672 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNA-0004Wu-4q; Thu, 03 Mar 2022 14:44:26 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BRAiqGuRRU7V3VtG6lYfox94ePjtZhB2RE0S1OBnG3AJFNe9xBz8HkrkT0tCn8U5pJJ1sQA9mOQRSxUPPp1CgnKT1vXKu0gDTNRqp4ONxt+nJ+KNhw3jEj1qjlaeUFWePSXLe2xE8pBbdtlYAY4wbIG94qJUeHK3HWkWhaPRmY1x+Fi+C5pQVLA7m0DXfa59ZIwhV5KEqXmh6llotGEYNo2lsInfkubMN+yoRv86YpSBEWY2cKcDR60UZ7v9LHw+xFTqWGJSwhbOgvEpy+V8jRatEjkPqZj2NVI2JbGqlI9RRvE2IUCZjrCvY4D4G7WSuWzALaJqL5MWG8swW1FlEw== 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=Wk0CPYEsGMCibsoooULP+lClkB+WEx4/8kGPfI0xzIg=; b=alFmtYkN2qdR7d99kaG6z784QpfNKja6QINaADOal2wL50NWBP02iVMILF6MlEvLK8dT6S6KWdpXewHuM84fvjjvTAvtxnRx/dyJgwGKcOKd7d81+z5d1niwGN7OPTuMvwhVzobVKkLZ8zz7ry+SWavLNcsbGqIGwjFM6wJmFFGkdlnj/lw4UrFYVZHL1dlm+VXvNqUuFbbNTLylQBvcUQkB1F0eOvYIRrfAnsgt1waKIKEH77qXVvGcVstL9RV3wSDres0ONi7y/DbgfkPDyDvWIiU+bTJrDviLmT4k/yz4YpXuPtm7fS5RlgvCzLHiAcEwtYghIcKLIfIHzCYu3Q== 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=Wk0CPYEsGMCibsoooULP+lClkB+WEx4/8kGPfI0xzIg=; b=ZizVFDRvHuw+nU+yO92e91NHIrkUtCmevRSdFfv0OZe8+XnBg6GOzYnxYvtIA7l7qhy8S3f0jyo5eJ4kCvUks4CSWlAbLcpUyb0J7MCaBQdxLEiddpkpWkLglJ0zsVOXTH5DInM7cMYL0YGtlRYIiLe4ZPi3Baiy9jasGp2SQFg= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:12 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:12 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 10/16] block/io: introduce block driver snapshot-access API Date: Thu, 3 Mar 2022 20:43:43 +0100 Message-Id: <20220303194349.2304213-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: 5bfe365e-f716-41b2-4175-08d9fd4e3101 X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eeJNGSYBi1b/8z8L1Ixq0rOtLaxRbEh+RTTvRm1n5Al+wnn5XszUhscgnRqwalpx/J+bvuAA5XbCPzSRmzw43u0uJpDuow7nnIz+BuAGlgJdwNthbvU1PtYFNTwO3z1j3V2GvEwDbqcXxKQCVUvn2j8VuHN87eClF9ty/+xi5f5dklXwPNOnCdXsclTctfeyZBIuqKYF5R93aoU99oXF7wTnCP7vNw2TfNF8v/TZk0VL4c8WUhHLZ2Lub4omciXWntZWeU3CeqCAU/om4sdB6Dl3ZCCJJMc9BnrBvsTFIk34LrFQvEgK0nEaCtsjDfDJ6IwFnJICRXiaqmsCTIZVnO5gyu75bYrseOTI1UX9pxsp/jCdXmOfOahciEWAf5FOUmQnowgdh9SAl3zfPZVtTDQtwZM8ahPuya4lJkPMLNe9bmIQNdXsrhRpaWSfV5GXrw5BScSowwNfKReFFBqKApCMocgBrcuGBYz+Y32TvwM5JEbp5lItrwOvuiYQS/XJ0jYBuaiqLf0rO1FHJf3idrLBB7hQBXhEJ0s3E9v8BQ8q2HcLMWw2NFMF9lobS4gHyIuJ3+Sl7/IH7xX4eymAhaRHJn7bcFcB8X6eRb9J2HBA+N/XKcocacf+67LEhXTeWvpqGM8+vaWXg8ILanHG4cqIq94E4azGRAjTOUe4nVaGBMgmUZuW6lAsyYyuQKBxIixDqUV/+eebzJQHBGdmTQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h5vZ0n7+mDcXS3CvbGOYjVcf5n03JDA0+aGmXQDZJv1jgOgAJINiC3M5k9GGR+WVeaqEjSjldjGD7EZxTX4om07LePCJMRHDgJrBvEOhEwwDzmh1PVTarEXpGgqDcxszhAX6j73MBxZC6Q1QGGVqQjIDFb2oNM1UQWMuoJ6kzl3OtVOgcR2kLWKsINEVh/vWqM5b0Tz099HNQ+pK4TGN6yW1WHxdT++l7rcHDYECksIvtmSyA2JXBC3b/YWJFt5Lt9xGPp7Wdif35UHqS4ILG8+pMqhPT/WK9Jmj+J27EqJBVlroJ+lU4e4hfW/IpznmjSUqnJ14tTb7m2jagwuBrRZ1qf3ByHUHfTYnpEu7umdrAf3G4rrbLbnisqP/9dqU/Yn6adD+7S4DCjfitxdvkmVqomXFU3bGRmg9tURVvsizv6EFVbTiaYc2p8zAwuWNb1Fl0rmn/5AMXtKo2tb+5NamUeXlKllAHH1yaTlo5uF1pdBH9NW5SOD1nZx7TcqEAb6C+Bm6O2jYIqme6IbhqgqBZvGdcWQtXttcc1rB7jYvutk8NS902p0nyl54r+7nG19bU9VkMEQRoIqGEbMRRG8W/pe9uCv3PJ/tLLJ8Gt6K3kXYoKfXzpIetRKwJK5Ey8AKSBzR700O1W/osrTRciIUT6j/AsEfqplSb+08XtFhVSuna3oNn8fGxZ7NNE9y5T8bP3BOduhhBM0v0U5Z79w26e9fd0VurnLd8Syz43cA8m2Mk6QWhZk1tcENuNlPPwKd6fTi07+9ixmqGC4YCuDL2sIEtDjTY//siRfJdBJ6JBcT+Axj3a2CZE4LSRy0FgJplPeFVIMt0a4uwG0ABLnRJJs0+4hVc8SC/zBhjIpRFJyAyqE8rnI9PtDLnHIkIihew2eVlL6Cfn/B9Am80nIttdiU6XzOky6UP4DbwyrB6YGUJkk+YLjviSsRfhJSLbpOVI6aI0ZCb+bnnMeMhgL/5q++Y30o6tuCOeuEZ9RF7FFRR9a5YTuVenAtSdrG9ImkPTbtGQEQhiuBF7X4wLxooe+OtrCPPWP0DAwS1gdKpb54bVkKdJGIxNkT+lnrEnIHvukeLdWEzsEGqpK/RXFTLv79DuXrKqYo5S0w3u8sZEzO7bsU+zKlNTdtRb15pJJzx/uujUM6/M1MDdJ0QUIr97LFdy8x111aPnNGrxyaBh+bHqOvbGOHTG4AwzzDiC3yEjqnfM3Uw+f4SodGmV1kXgAu/ccjSJp467jyxtjyONrfD0S+zGlSqbAWbWGO7J1N6KHAJ/3UaxCR8CV0zgJOmiJ8VtcfMiySFp7GX95Cq1m1ukrcWePut5CAP/xMLb+wwxLif2bkVdbxjmPN+Fho7VnuvdfpkrENRROan8cJ0j/Y4It8wffFrbIOUM64L2xmxV2DX0U5CarByMjrDmSyqTn72dZqNgZN/RcRFvVgLo+Wdf8XxdV6/2tT4UfvTTT4FJB2csaLwXN84zu5CXvKkPOk13CU9QlwqO+LEHwOEDcP68FCw01RHBN4XRFbzlFYcPAFJgcZUkarG+pIQMq+hR7QJTZer8BuNe/Vw3f663yNOhGtljhbzowa6zdsa0wi2/nYtRdJVe93dQuqS8wLZr5pTe8l9hXbWabtgxce/KWwjznzVT2Fo52Yk5NXVBSmkc4Dj+5RG/VHlefNJg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5bfe365e-f716-41b2-4175-08d9fd4e3101 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:12.2484 (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: 9TLFypu0IP8KWb4XAY3pGFnGiA2dQe8zZl292+eLsDuyRBPkSOkgacWr6O6EgNHa7/4RU5xOyHvtn0VIeYP7ygiETvjge3f7hLHRHULlo+8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::72c (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::72c; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 internal snapshots, 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 Thu Mar 3 19:43:44 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: 12768044 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 80AA0C433FE for ; Thu, 3 Mar 2022 19:55:15 +0000 (UTC) Received: from localhost ([::1]:40704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrXe-00085V-HH for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 14:55:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrND-00045V-VN; Thu, 03 Mar 2022 14:44:29 -0500 Received: from [2a01:111:f400:7d00::710] (port=7585 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNB-0004Xj-Hz; Thu, 03 Mar 2022 14:44:27 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SWjeKkVmi5KjgiWZVIa7gxRn1Kp7a8iRzSUC9XjUEO2seMAGTT+q/ZwGUtWBTPglvAF6vkfFBQNWDhJ8e4pSqaWf1pSvHMkPz3BVTDEbefiyyCjcTqWGLaX9bygByTMLb/ggzJYvjKYeRWh1q0VZG5BUEI9GGbv9UV0qCCNuorVgPuDEN5FKXY1rjGthEeqI3ACZM5EmL+uFLI/7fGwut7A94OrhhwSKwI4bz1JmFGpvT0mxD3iAEOZRaJ1jQuZpwLEQpe1vmXl99H0ZxLlLcmNx+VmJZEI+3M6aGIxwAull7mL3FU5eFjgw371E0W2Z+Qrz5PzZyP8KrUHjRtBUhA== 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=0HtyEbIetknDkkiwoMp7l6ByM0scW5D5ktNgrms1+XI=; b=DtPjjku0v748tWqHzHbIAOOIrjxbCi8W6Lm+SFlvk6mQEjTwJlSejIuZCm/RPT6BqxlAe5zS2n/z6Ql7DsPqcfNOHRgpl+4oJs/IV7RGuD7SQ/F7p0GlUzm2hdr0Wty2SzwZhqmD8xyTBeuIVgzVp83RbPtWsHB7vDNoNLE1w0sOUUSISGP3D7niWVp8mdrCS6NAfwdjhWE/FO1igIx9JlfJr+x4E6n79tLv3bvGKjQMuHncA9PGvNFEvMEJTCJhc/O/EmXr2hh+s9A4enaJec/jfp+OIwkkLXK1lI59xSeMLJ5AGiA17ptt5A2xF/FPrLL5Nkc2i508MOiY6p2YDA== 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=0HtyEbIetknDkkiwoMp7l6ByM0scW5D5ktNgrms1+XI=; b=ZXaeSq7zw8URoSUvUmDK1i4RrRg+VeGlHvRpis8TUdhQX/qmcMBHbXTDnFtrHtf7tLBchWwfgcMWhY1bDZZQ0pnI1GZGz6SJCyUHejz3IDxohWjmcW7f52+hNpr/0QQCDypRH9771ebYIg0NW2GyKYvK1LbYzbF9jIBudcHCUAE= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:13 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:13 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 11/16] block: introduce snapshot-access block driver Date: Thu, 3 Mar 2022 20:43:44 +0100 Message-Id: <20220303194349.2304213-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: cc61fa07-81f3-4be5-983f-08d9fd4e317f X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pkzMhn1bNde2B+lQAyg1ZxtL51iQTfTIjcmE6gy8h3SzTrVsNEbbmj610zHA6vXdDHJDQ82BwqSqw4EwnMYcPT+B/9Lbcql94lbdTkIH5JA+fIIg9RsjUHqJ+xyayxXYnQcTpLA9AObuw9i60POJAmAXRwSwOTfvF5rxSvwKITfU0ZvaKQuLnbkxg39JJhJu0j0KHSloOwC4VXDmO+CRvUKEKRb9WPGGQjvipANq/fweYMN4O3Iq4G/41DmtTPZH0bPJQMfMGhhcAIW3uY5rOOYJzsRwdhU5d3Z72efgHInyjfQK5yuZ6cLMi1/Yl1khYvOEIhpOJlQcPwwYG5FGLVvogBvcfqMQf1zJL6/AujQwdseBrlxtp/Kq+V766a6Jwwuh3QGkh8b64nmTZi+TF6tMDv/Hu7mBrswzFaoOI8SeHlOJ5ABb8qGPAezEEpSc2Lqs/yE8f+5PVsT5a5MB5szd5JgCqzb0Af32njrLNYN1dzHxTjkD9jNhsCMp24U2TGuIDt8ViSUrOfLWA5eElJNvglUJQVUzukGR6F/asvErSh/8HfftoFGGMrSXDsm2iKjzKke+ftXRTNBEVAbFP3DK7Swti4nC/I7B8/H2F3d9TrzRFIpPrw2Uq7wqxdf6XvG1hkV8O1fniWDbMVOr6dRvuRmLaxoB4ICsEhpfNcUIt39q1ogar+HbKZVVh+wAdK9qswFYIoDDeBJCd6CWAZRc02Xv0b01yOwrF/3Cua0yXLwyznptAp7dmpmcZTnQRb8YuCUoP1LYg7o2vMSrqFbCdbQlGpNBs/TqbznTmCashGwqo8FePt8t9RKKK11r X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fZcffdD/yp+ktLcOcQu5m//RkZRl7t/s/iWBzXigSUzQaV5xZaSK0j2G1FXm+nSVNBg2fZJqDUkuVsQs5/Xx3BVh1i2HtdLeYVqM5vshvZE/RHtWvz1buP85qiIT7uvQJlkLiURFc2Qdwa7fV/nW2Lwa3CHVGCAdwEHNUkv9DOOU2N/FoxkgYhv+6Fs0lGyD9YIzAroUwTrRvZwhPei9WjFcocQJk8G777WwVbuLbLT+BXcAW1IK2OcMHf5BixkhsHRTZw+gCmlHOIYfY61mHIkZ8BR0Q5cz5NOgWkSB3uKRN+TfPl1JZOYUaD467x16AtP5b9gGfqGDJgL4VR576HD04RUn+G+Ia4iu6zrb+H9ckqwfBRApyr+WD519eFcV6qZRdrQb4nR4m+2D2iVBWNHo0q0EaCZK9rDe1KRgWp9XPtv6Qyi09AV/rrV5Pe0lpUFqjnMnL2OXxGCbI1VR+pru5jijRxcX1bZY+H22E0gLpohah7mwO1P3JYHWtwnZQc380kdQxPK8JPJsslcAiPNmG28N+FZ/XCQtl2T3pv4f95B8NvC9EC/sBFTCMMTZqNAO7jdg011jJRuJ8hC3tu/deiveQ0Jm6nGV0w8U6RkC1tDJpTs9oa/Oes7DUJAUex/+I58hno77/1lOsTIkM7g9Kb74VTVSBTfsJ0Li3j3v6a4HQFtlkJvS9rezSNsAeDNlFn7zPm13RhnZkC6Ja8v2q1w2OScStYMf8ZzDFOlF6I+eywvsP0lxfntjUoCRIV7WrrP+xxkYTnMVLUSGC8jh1BmCl6ccHFLgrN9UQX3eF5XrW7DgBsEJuU2DaG4lqYa9QfkO2yoJGTcT9dBE/UyoNOYhW0SeKVR8DdGvUtEGQreUaH/WXx13lFgPCwLOnXPS5aVUMsGkeZMinCebaRoOqit0KTLaItvwFn2OGaRANsc3oiDIRwFLpDEMfK2gyLmrr9QtVonC/QAq9crKwgM+iIsA2osASSEpI32yMBW4Fbg4AzHOqhgTwvTHIFoK+euCjz7buyltgxzi3dGx16WjKGUt1Po70n/hEqL0j3cimD6ndCVISpBP2FxcHcOORfa3mfHvV8GpJNhFxmoWnjtfFFNOJTfFKxK1DOLS9fe6IXfIEkBDjxAJxUtLEIBlmCckTQUriL0rlcLqk/tl4h7X2lu/dRPoO3C5geI4IoCdWlhceBl7EedHVG5Cb5AMZS8UE+j9UXh2vuaaRDCCHOgInn5YNUGtSXCCcr53HBRf1UakK9aIMDqu+cpwn2iQi24wwUu8RjIgkHzDxFl22bt3sVPZpPc2OG1ZgNGIp8788fuUcodX5f/jWdAckcrLMXG2d4Z83E4J276kRTqO1HXke6EIPo5vPYyBfAMAMZxpU9nA4yToSa9ZWrfwzhx2sRUctKoYfzfYNMH38O3h9b2IX278Q6UpFWIMVD+wS2/iJdrWFh1AjfAo8csq3w0ycbboZobv+h0CfIOmxRIBzEmIvrBZqpCXNN99jJ+Xf77AESjXUqpv2Wrb+pKgscnING9pCeJ/+8TYk0vDgsNXmgBAjbgbc9GQFu30AW9IHYaATxMj3xRkpdIA2jyhMssriVCLMa8NIqyVh3xsn15iL+nvfAV7KYEs23jzjo041QdLF9abAbNJxynnox73GfbrImlxFcXcdqs5FTX4fvIPOA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc61fa07-81f3-4be5-983f-08d9fd4e317f X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:13.1701 (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: ddfeGpbhnDAMem93U8WTfVuIlVa3roIvlc1Otp3EPRNAqmLbAyPjqYRP9urJM6gDmrXnVgj0vW3L/9aG5ix5ApjE8FYPU6MFsc5JbWsC7cc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::710 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::710; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The new block driver 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 block driver (and API) to make it possible to select snapshot by name. Another thing to improve is size of snapshot. Now for simplicity we just use size of bs->file, which is OK for backup, but for qcow2 snapshots export we'll need to imporve snapshot-access API to get size of snapshot. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 4 +- include/block/block_int.h | 6 ++ block/snapshot-access.c | 132 ++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + block/meson.build | 1 + 5 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 block/snapshot-access.c diff --git a/qapi/block-core.json b/qapi/block-core.json index ffb7aea2a5..f13b5ff942 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/include/block/block_int.h b/include/block/block_int.h index c43315ae6e..5c8ad9ed78 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -385,6 +385,12 @@ struct BlockDriver { * 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. + * + * TODO: To be able to support qcow2's internal snapshots, this API will + * need to be extended to: + * - be able to select a specific snapshot + * - receive the snapshot's actual length (which may differ from bs's + * length) */ int coroutine_fn (*bdrv_co_preadv_snapshot)(BlockDriverState *bs, int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset); 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 101eb50619..4f0cc1e448 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2520,6 +2520,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 41e9cc5dc3..038a95689b 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 Thu Mar 3 19:43:45 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: 12768033 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 2CFF2C433EF for ; Thu, 3 Mar 2022 19:53:02 +0000 (UTC) Received: from localhost ([::1]:34074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrVV-00036L-8E for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 14:53:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNE-00045q-PN; Thu, 03 Mar 2022 14:44:29 -0500 Received: from [2a01:111:f400:7d00::701] (port=54113 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNB-0004Yn-Ja; Thu, 03 Mar 2022 14:44:27 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cajdnQR14wHtWv8XE9DjS+g3QMIvp2gJD5U70PQfaSK3jJfqNjAZYS3M2I6sNnghZyrBXeOpLB+yZu24HuZQWra5Yd+qdPaEPRWoznjA5VW3I+n5fVP7aMPComCTDls6Gb8mrxss6qGzZYF06QPBwv74bWj+SEibVLdqALGVI2knjDEhnyAZihpjpFYAKD+huJSCzzHr+zi+q5iO4OMUZJXR5U81/BXKg8MO544ab32P/3Hllh/vfDyy6lzSc46eDIXLqOJHdp+qv0er2ETRei2Hl/FME9RQcNR27AAA/Cx+4pcflcpspXVtum7htPLBHLefedgjh+L2ihWL4F4dDQ== 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=a8qT6l4df7zH8Odw5sbvg5lpWLiA1hTk9zOAAnhZZLA=; b=TPkbPQ0fcZc6Y078vRGxZ7ZBALYDCUx2PMr4vIjqV7HzfcEg8Srj9wezi7grGJS38Com8Aq8541J3Cdcg6j4uYLS+K8YW+9LtTFfayUwq0RWilP30t5KSEgAFJF43yXj1mJgTCSISpU6VF7XqWVNKWlUhFs6IJNBJ6/cIxCH5RgjTb4ZeAjMbfse4hiXmKtkby5wDiU3BEHbFaUJSWtZIwouG7T65uG56P5PfPjGrurPS18O84Di6pDcjJQ/a7A6Zjq5rS7PzkUXXnPpqJkV3aCRdcd2d9YvRXrKbYlrgSkdH/XCgxUcHuQ5QYeTXYjp/jdC93Ojry1P6mWaNcbf4Q== 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=a8qT6l4df7zH8Odw5sbvg5lpWLiA1hTk9zOAAnhZZLA=; b=VCm4DuXE0DWn4tIgB229t9kX8t1BFtHOXIf8oLGj3cpiJyCc/C+rTt9WbKeb2P0cEl9FKo+o0JE0D55vuf4+kpTI7DpcR3K3LsO/5oG+rs6HTIY4qnsGcC9daSfc4bP9ddLkzlgLsbiuHy2ksDVDRAYF/OFdpTN2yVRJsQfyo6E= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:14 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:14 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 12/16] block: copy-before-write: realize snapshot-access API Date: Thu, 3 Mar 2022 20:43:45 +0100 Message-Id: <20220303194349.2304213-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: e55ae214-7262-45c7-3c87-08d9fd4e320c X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Db5YMJ2JMNpuUGn5IruDDCNmGgu/j6Xy4za2RmTuZ7u6CUgre6VnamdnOc8ZNEWRHUeXs3dxYg9nqrlJuQR/13+gMezhAqtSdJEmQrLKqFWGIq1Cw/4IVVh1h68ArUqQG+ieNCTCA6qQWPMXbdDOJt0p74wmaUzVaI2IdtutewSbgNe+nOROT0P2nn3cyY9hgIft+c+zg34uG2NL5Dqt/wh7f/uf9o2yFyojalZEP88a/7hm1qASlXrT7qSGp2YvxH4DRH0Cy2PxNd5+9sedj0SiSJtVDfDoZaRmiE/RVHw9Plavhy2QiHIxO88t5atXbGyTCGyWHuml/4KagOfDAWURsszeckhuju+qbITrX5T+Q734vECI7hk038ySeayJPry+j9vGdB+hO3EzPb8wHQ2fdZCEt8xRc77QWXkWnLqcniv/pCmrYFZMe/PzCCYR9PGaqggPxEHUZhy+IkvRYCfBb08cnJLDZ9j1v6+ffF5Gu5E2Ljn9EQ01nNiQ2C8ne9dxL4Ze4u2M33mItPVESLzlj2yshV1gq764NvnJ9Zp6JXQLKyDnJJfQTij8MtMXrkF4PMXlOTrzufox1SETvK0fDgx9l8HE4a8WYgX5j4zuZ9M/FN2iWY4RBF3ccRBQspfK0z3HXGP6DjHvXAF06mIDvSx3xKnKoF+iTYW4BIqYMjB/S5GzP73O4BAH/dM4Gju63a9+xMd8sAbzEM7CPQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(30864003)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5KK//0amId0oY5/IjcxAJV413c7r1hy+UwhnyUQj06+25mLXixcnAOVNGEoKaM8oyrbN0zu3uO+JTwk4O+7AHgLn718UAkp8deVI76fFxPTNL/Ct8EL17uDLXePiYZGeRpdS/4cvqXQ56xig/9FtCRvyHEr6MAg/JvJto+xi0lXblBfJSIxfbfFsdp4Dk8VfapUBJm0JyZ3I7iNYci/WkSB+rekwyq7G63ZKuTi5XbifZf6+//ogAsKgLkwn/cTDnePgYQmw0jAzboAYKyI6wlqioE2BYwl47KF5zUl7QAOj98r3k/nfhea/UwNxeqL52cgRwHnb7rY1QD0JJNSGL+yEFw2PcEGoDKen5VJsbHvAg1BSKoj0UUMoOVw/W5xZi5mVY9HbF6j44zpAv2Iz+QrvCihVgoTVOPwfaV9dvxERzHMZI3ZG7nUVci2MaBlME/iyisYMkFiBqjaHH9UDPkI5We/KFkiUVekY5zhMizWBHyhBVa0TBmJH7zjJRX+jgWhr85qc1gU8VZmEGpQMRYhxErjtyeRVGtag0jxfh5P/DBEuO0Jr2hSQsPyRqBDdCerKvTVl1pFlFwrqGrbW1klvS8RBbH5AsjEIRs1IEGDVG60ezzQ8Rxe6Hct5GZFlhi+7EkebIgsXt7v2femUD+H/Rtp/3gXxgEes44TmgD/D9RsWHaw+xFuOhdU+aGl1w+IqGTOU3RQkVeintJ84iKAYkg/5bFyDoZsO0rIdG0OOJ618Tu534pg6n+CdUdpS7s0cZt9F+yf3xIyMiAIQRYrUSWOD+595Z33FIHcGwouCpBwXeifWR9S3JpukuAH5iqC5Pu9Hbh7CCYsKyTeQotmfqq3tz7zJROKvmxmLFBVP3ca4crn+SB1cy17Tkw1mwrfBTVAKUyNTmcULt0K2quWCkvg8HCpxcxvUAUrqofLLZcLA7kaAM0g8yYUZxQphD/hp/lOIRuZiyI59zhRGeRD3xo7EgJQGAvgLh+HV9LUXJ6KA8fo/nnIB+DQcPhFi83CaZDyo/NqP7icF+mG+ZQGmGDx84jlCdfGy/1lc4iRhPqBuq0ybXqYy/FN3QslwutRRFSU8735JYwFEri7jkmeRp63Xzgo2l4Oiy5mr+74YTPRiND4snzdsCJFldQRlIONUj8GhbkuGT8Hp5Iad128KhqHYYkhIVi4OvP+e/4w2fA91bEjmPlKUj6xIU5j1GQaILpLBxx9xNdu5viBBpbbHSNQBLsQo3FkkLU/OJsaQBQQ1R6JiSJnFrlVjD+Jv9wwS/SBPMGQqApC0B+PDah6He1FcQ7JDNC63ADyCYaVF3DkOHB9busKoz0VORccz6RvNou2a2uzYaHG9LbJInfyN7Afs6lmFfdAVtgW4H7nFLCBywykFtv+LVsd3NTxXz1/Bjtqdd0eA38dc7Sp8ZiISRFMOGLelByEAcNXPbLcaSwyVoSdJ4SRZaWJYb/OYGot52s4L5Ffm6/YtOrYwqOfNOtKHEkPNpl/t0snX4TxB6AtXJwDv0kUDUQgEJJ8twOqfneU1CZj4ZwIQ8PqRcY+86Wl4VjW8y6UuQuVf40pVuNzNn+d4ezb/2q58eJFRRaxMmkQYjqz7J0JkEn4UyXTEA0AM6vwYv0shml3PgBDUVItpkJGEdFQa9Uw2Cs4BaW3Y7OoeJA5qxY6G564yXw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e55ae214-7262-45c7-3c87-08d9fd4e320c X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:13.9824 (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: uCWGf6gxP0vM/r04XpfhmFc4TWK48o2UiPdZr7tdP3YgjSSHg/d/DmyagGmaG7p3t8ZQftlVyJgFqXIvj4gpqBqFZrc1S8brQAmtDL96IrE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::701 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::701; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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]<------[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 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. Iotest 257 output is updated, as two more bitmaps now live in copy-before-write filter. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/copy-before-write.c | 212 ++++++++++++++++++++++++++++++++++- tests/qemu-iotests/257.out | 224 +++++++++++++++++++++++++++++++++++++ 2 files changed, 435 insertions(+), 1 deletion(-) diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 91a2288b66..0b6d26605c 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(child->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, diff --git a/tests/qemu-iotests/257.out b/tests/qemu-iotests/257.out index 50cbd8e882..aa76131ca9 100644 --- a/tests/qemu-iotests/257.out +++ b/tests/qemu-iotests/257.out @@ -106,6 +106,22 @@ write -P0x67 0x3fe0000 0x20000 {"return": ""} { "bitmaps": { + "backup-top": [ + { + "busy": false, + "count": 67108864, + "granularity": 65536, + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "persistent": false, + "recording": false + } + ], "drive0": [ { "busy": false, @@ -566,6 +582,22 @@ write -P0x67 0x3fe0000 0x20000 {"return": ""} { "bitmaps": { + "backup-top": [ + { + "busy": false, + "count": 67108864, + "granularity": 65536, + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "persistent": false, + "recording": false + } + ], "drive0": [ { "busy": false, @@ -819,6 +851,22 @@ write -P0x67 0x3fe0000 0x20000 {"return": ""} { "bitmaps": { + "backup-top": [ + { + "busy": false, + "count": 67108864, + "granularity": 65536, + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "persistent": false, + "recording": false + } + ], "drive0": [ { "busy": false, @@ -1279,6 +1327,22 @@ write -P0x67 0x3fe0000 0x20000 {"return": ""} { "bitmaps": { + "backup-top": [ + { + "busy": false, + "count": 67108864, + "granularity": 65536, + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "persistent": false, + "recording": false + } + ], "drive0": [ { "busy": false, @@ -1532,6 +1596,22 @@ write -P0x67 0x3fe0000 0x20000 {"return": ""} { "bitmaps": { + "backup-top": [ + { + "busy": false, + "count": 67108864, + "granularity": 65536, + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "persistent": false, + "recording": false + } + ], "drive0": [ { "busy": false, @@ -1992,6 +2072,22 @@ write -P0x67 0x3fe0000 0x20000 {"return": ""} { "bitmaps": { + "backup-top": [ + { + "busy": false, + "count": 67108864, + "granularity": 65536, + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "persistent": false, + "recording": false + } + ], "drive0": [ { "busy": false, @@ -2245,6 +2341,22 @@ write -P0x67 0x3fe0000 0x20000 {"return": ""} { "bitmaps": { + "backup-top": [ + { + "busy": false, + "count": 67108864, + "granularity": 65536, + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "persistent": false, + "recording": false + } + ], "drive0": [ { "busy": false, @@ -2705,6 +2817,22 @@ write -P0x67 0x3fe0000 0x20000 {"return": ""} { "bitmaps": { + "backup-top": [ + { + "busy": false, + "count": 67108864, + "granularity": 65536, + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "persistent": false, + "recording": false + } + ], "drive0": [ { "busy": false, @@ -2958,6 +3086,22 @@ write -P0x67 0x3fe0000 0x20000 {"return": ""} { "bitmaps": { + "backup-top": [ + { + "busy": false, + "count": 67108864, + "granularity": 65536, + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "persistent": false, + "recording": false + } + ], "drive0": [ { "busy": false, @@ -3418,6 +3562,22 @@ write -P0x67 0x3fe0000 0x20000 {"return": ""} { "bitmaps": { + "backup-top": [ + { + "busy": false, + "count": 67108864, + "granularity": 65536, + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "persistent": false, + "recording": false + } + ], "drive0": [ { "busy": false, @@ -3671,6 +3831,22 @@ write -P0x67 0x3fe0000 0x20000 {"return": ""} { "bitmaps": { + "backup-top": [ + { + "busy": false, + "count": 67108864, + "granularity": 65536, + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "persistent": false, + "recording": false + } + ], "drive0": [ { "busy": false, @@ -4131,6 +4307,22 @@ write -P0x67 0x3fe0000 0x20000 {"return": ""} { "bitmaps": { + "backup-top": [ + { + "busy": false, + "count": 67108864, + "granularity": 65536, + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "persistent": false, + "recording": false + } + ], "drive0": [ { "busy": false, @@ -4384,6 +4576,22 @@ write -P0x67 0x3fe0000 0x20000 {"return": ""} { "bitmaps": { + "backup-top": [ + { + "busy": false, + "count": 67108864, + "granularity": 65536, + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "persistent": false, + "recording": false + } + ], "drive0": [ { "busy": false, @@ -4844,6 +5052,22 @@ write -P0x67 0x3fe0000 0x20000 {"return": ""} { "bitmaps": { + "backup-top": [ + { + "busy": false, + "count": 67108864, + "granularity": 65536, + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "persistent": false, + "recording": false + } + ], "drive0": [ { "busy": false, From patchwork Thu Mar 3 19:43:46 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: 12768046 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 ABFE0C433EF for ; Thu, 3 Mar 2022 19:57:31 +0000 (UTC) Received: from localhost ([::1]:47184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrZq-0004D3-RB for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 14:57:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNE-00045r-PR; Thu, 03 Mar 2022 14:44:29 -0500 Received: from [2a01:111:f400:7d00::72c] (port=28672 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNC-0004Wu-Vz; Thu, 03 Mar 2022 14:44:28 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lg00l2rU6dShmaEj3zR6udgfWJ3FE4TAidXwHD/kwQLPYXa1NXhGiVsSQtaWJ/yMxiw6chHd5IxW5jQKf0eOsSn6IbP/FooAPb0Eg+szeDj02FBkFao572Tcmfv/wNyF5s0+BBSzajn8BJ/51emqX17Q0I4Gul0VlwtLf6grw87l37b7I4LjZk3fc44XMJHXIW/YQTVR5rWUh9IEmVvn237rzR6qeMN/DllqVWM956pXAoRHGsOmcspzE3F8vjl028ZtV72JSwOx8guRySz1vCsqfgSzonbr0iwLqECI2aMStrBaDAKGEerMnGGTgM1hczDCb9NlAzVz0JaffWr4NQ== 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=wEpH+HIzXiDTHUzHBNTB3tdUmabNgivX1ETxG6gdcEw=; b=VQsMDkUmeYLFXQBlNmvk6W94XGJv0D2QZ2V7rAfE+SCs0sq2Qs34MKEFY6LQsmOi5UsNQ8zNlQ2yW8ZFr56k8cSI8KYxtXj1NAj9wNdWEVQJrXL7i+qUsWJyJefTnz8dD1ETojsfyip1KtUP0F2yW4fhA4LT6oyWx6yT3L/dr2R5FdD74ezsfMHj26uJmwFRSk/eO1QjpFZC3rky69C4PRvJbAR7aUOmiH6I22rJ0t3AJ7DLJBgeSZVIoPDXFt/ydIbKsmBSXvAcdmL4PXSo2LAdnUbSrdLoO/1i2+RrivZC1HL4kOOtusDqn4Uax1kSQwwORpTzgxmrVtPjw/BCVA== 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=wEpH+HIzXiDTHUzHBNTB3tdUmabNgivX1ETxG6gdcEw=; b=TMcyXtT4uIUgrpxlY0heRqVZWTmMJPpU6oYHnT395cqIj8q/hQhZ76rWfRp1WV95EZqooYQAQQwzlzxnjlrqWBy06VDgiIM5ivj2PNNatB9pU9OYr+huncY/FXqHFe41pBtn+xAI6O5QDjBDTDxUEqJjBLRRqfVJ1+LfnVKNVhI= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:14 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:14 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 13/16] iotests/image-fleecing: add test-case for fleecing format node Date: Thu, 3 Mar 2022 20:43:46 +0100 Message-Id: <20220303194349.2304213-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: a97ebf38-da6c-40f1-db17-08d9fd4e327e X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1sZLUEyyfKP0Vjf1gozzwe2uSrjRA4Zl/mao1AqMis4tum5PttQMw0vqK4Rf4SPwoM3cQWwdoLgrvobrWeGO3gqu3GZuxjQ2c9iHzzL1U5S3Wf6QIAFiAhA9GmKik4PHLNHUmRS+FIrhI7TLTnJxu9tbntGqa6Q6Nv4GOF8DuaBQKcsCRWzoCwSvhFuYJOkeLdkB9FJ+HCcHNxQS4TrVhXVtCeqOXLqSwxweeJ33BdJGI2LaitbPTyhQVWkgj/hbXqJ6x9GCbwp5MdP9yzJkBQRNJBYVkJBaZRrmGkCf4QZjcOOAJT+C3SFG2KOjlY2Q+5enr9x4f5I6Khz2ZUXBQ1nJxTjrHIFcc+W3XFrfxovPLje1mafrXGvFdQgpen/i2ePiKY2oUAR8fgt2SqhS5gopLjKhuYwTvwESacM+Hj7pEZi69eTSenBlCTATVHUxcXF/OUrQ2VA4w2e3bje5ohjbFwAoILfWu2Nr66GMuSxU9X/yziQnR8o5DAcDaZaVKslDT1YgrXMt4+Pxe/CoTRQO2uAG+2SeSyGtSNYGwNL89vjTYU8aniiBrQLqkGMAVUP8BQ+nFlFGFpkagDoxrlodd7Jgqql8o0YuoHncINs8oyP8D4ZnWKy55XmN1RXTW5qTpgPL3VU8qjPmRvc6lg0GE3LK+G37v0VvbDcYhB58E2CnZBRBoy663/Czk6eZbktwi5pjBpaZk3QBGAIGew== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LK5TLASZgIuXbfI0bt1pO3qflLj3U0WH99RHqQX4YItGC/orXCMqAz6cG2taR7pX88yfyeCKNW9GgJ9Zn1Xe47NRU9/e0ZnkQ9/9a0mn753DAkhTj6bAYYOOXDsPSmFr8nOulcqdcjh2u2OQxiwf5PrbtW/O7b7QiFKYwrwgT/yKGgu98RGgfsI09AQjUQUYgxtJOR1iKqo504aBpH6JejyIhD9Dti0FiBKCitMna1SOWCfPyA4YPDfHf0f2rJ7rYzekz6UeGRv1C6NtEEVLGpu71oM87Fylby1IA7EJvkC8cnzZMPXXXk7HOTOG/tBEnAAJNI8IcSSrMi0PHo8TQyI30Pnooq8WoCtCr/QUch8SaZAARBhzlJXtDzWqKqLjR3P4btHBaPSQ4YdFjynXtVijC4FRIq9gJF70lKBonqdmj6BGC1ywpl0YJ6FruNxIElW15mWWdakAmWwjAsip2Hx9cA1ryz/UvBy9gKYTQu/Pw2nJDcM/UitZtCS6qVGr3jiJLHoj0epODrceWwSWhaYg8HGlTHig9y3SFtRBgYHVszravjvkPaRGnGpSMWwbda8BZH37PrNhwfgQ9WGG+Vbg79KKEtinvJgIyorl7BPciHhvqPCZrpJ3rJAFsCr0w3UJs6hY8mdGA7AXTRxRoQCLuBhSqtmKYGqSmEBMOlo2LCRkcBIt3TuYsUA1f4cQGRs9ZsuYXNgwi2Uzv+ygs7KFMSNpqRH4iZlU1qsVjFuRqBJrg+R0Lzx1OjTLrXBf5PfU6DFkmnCheMEwRVRnnIHEE0GQSjzXj5SpIGDxcicvQGyVTB3QekDJXUW0mCFMwWeXjKFNw3FBXvif5vtQLbbJ9BZRQ8uDzxZZxJzNpxoH3K+IjRPD6ZPomhF3NH3Gy0X3mDJlcbmtQwEnQpVT9RYOEBhbvHHihWqQx9OJGQ+q+DtP04vhJRP9rjm4D24LVV+ocGzWRZExXoxwFLY42Fhfr/9zDfPyue9NqAdocshrJRW3PQpIUDzY8SO5vHEpW3eTIieb4Xn1liqCgxQvQMKE9+pILRlOF9S2omi15PSnIRtu3onRoWv4fF/nWm6lZVHjKOFv9j/gtSzVcPdz+RYU1klwPXWKioOtye+x80ss/MKisGPWo3ybv9FBnbqgfpL0g0j+H4/+McLUQ2MAtEtuOP7uRVJ6gB1aOlbHJl5b/NXUsjxbnADSbmCLLz0fKhnhd1Mb5Yc7yqIlnSNekJd37OIjYoKCjqoEtm957ZdNcfC+PCXZqEjtVmH32vRttPYFeD5NLGPxNclwwAdzGpWMGoIvbrk8+E4ClnzpllTY5CUZV0Aev8rY7xIfN1ci0hFjsOYWWreoU2i2cSu6ZVl7x9OYF/Hq+3RIFw88prMkiLinms/1IBQ1k0GvKgNz3h2jPyS/KyAiIlt6Hsd01//goFDz+nCby1wZ/bG8HcuIQfG7T9NyVajSFnBK3MtetzgHoCat+26ew6mi6vY2RelMP7C8Jw2YdHZjRGrZpeKOCTSRJOnje7Bg42XVHiGth4WibxV3g3Vp16XlaxPv8qVIX1JYemmpI+oLqiLGQvyAHWupj6KGsCrqmkPsia7kiSaEMjkuoTkMI3z/ky1YA7KiAZCmvNcwLPWPeySS/0h9i/Tc+zDpga6Kd1sBj5TSLkbNMZ468578SeC8m5NvOA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a97ebf38-da6c-40f1-db17-08d9fd4e327e X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:14.7180 (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: 9bn0YEreYc0i6abfXFK/E0ElAjq3FEHj1VCdUyUq5LeCdwA4dHOEwgtcynRj/quldjr3u4QRu99xkCqRZ1Z4aMzASw6bhL92Y1tVEi41MPE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::72c (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::72c; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Thu Mar 3 19:43:47 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: 12768047 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 88566C433EF for ; Thu, 3 Mar 2022 20:00:13 +0000 (UTC) Received: from localhost ([::1]:54438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrcS-0000tU-Fj for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 15:00:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNG-00046q-MU; Thu, 03 Mar 2022 14:44:31 -0500 Received: from [2a01:111:f400:7d00::710] (port=7585 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNE-0004Xj-Up; Thu, 03 Mar 2022 14:44:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jrUn+rUMT27NNDLM2pi1zP2F8ZsgCQPZL0Syv9141bN/rcVvzMy+hSK7zzqnu3053GOAkbUDnAc/0XR2sMhjgopjCz/hMRBQMSK7UAEJIGcrwdNlYj1Fj+XLxs1vv2Baw0qx62Mcye0nIRonHHSFKM6IyDji4nOgtXIU/4kR/NKf/RkNAQza80hJVrlTG9LnkpX7gWP/XEVW27Qd+3NgFBXlx4SCECdFXV4JdKWJ+Dl53K732ug4BzAUkYGVXi+en0/ICEtp5/EvlYexJxHGq1RwY8Y1xWiuwJfm0XZYG8y0Hmcaccg2kebYxUwTMYOt/Com34LHVSt0cleN28WfzQ== 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=gaYYTHt+J27XJ8iUeKAJ7iE9wB98iZR1jC6tKdNEJ4o=; b=ni/AluKp6zqKBQeQ5b4ZOKrCjmcJnVcUjH7zWvKgD2SgL2QC+0CCnbmewY+nw8WBrruoIHPhOwfUib9MKUFv0cg9hTi182pTAuf16FWjs84hf5DDVzz+b4QpiRCDri4f8JUTtx+A1L06G29+BF9ClwW+lfNDk3oqZFwwgm+6D4Guz2jP48vXDdH0S8Lpe9czNn26YOksu6H8oasis94a8KRoVVRFWA/kU6LKtNps2Q4AU6swWdFszh4KHAF2tjuOUn0gJCEkRFwWdzxIc2IY6OY9YG/wtxLQbZ/rqXwJHMoBFbc035AoxNiNi5Zk57FRvf+LbFCKBg0JeZh8aQV6Cg== 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=gaYYTHt+J27XJ8iUeKAJ7iE9wB98iZR1jC6tKdNEJ4o=; b=R2mXzVKM7aYgyQmZ6Akw6fQjkEQWqIIpoVlP3TIsGN3zzowkH21V88HH6BXkFQcoXOXhbYS+GoGiVzO1VJkSE6Hr3WaxcVF8PwlnhkD7CfA6cdPTUzQf52wPXWq6EE08oaG87Gfx84Eh221i4SySACnjoQyDgR1EIVGF+dsAi4s= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:15 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:15 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 14/16] iotests.py: add qemu_io_pipe_and_status() Date: Thu, 3 Mar 2022 20:43:47 +0100 Message-Id: <20220303194349.2304213-15-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: d7d6eead-3f51-4942-3203-08d9fd4e32fd X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PoRF2Cnuk/CB2deOL+yZTIkD10TNuHCjF3l53DsTky/xc6SM3UAeN7tUZzW9r171YyK82EFfuxseMgTVFgU6UHW51cSlj2EJwPwmMha9kE9xtctbUg5BETvhLq66etHyl1mu//8PVBJck18EcsV+8aq55ksYwCpGvbN5Jbq4UxyRHni39pTdAYbj1RSWG2rBMgUFOam083PtBCfSyQyNDN2QXsRhcFovmuYT0XIcOgXzykgImODm1PtRq5pKXjIksEPw7aRTPl7UQE4vyIhmFttjcdkpTbERkVJnfR0rZx6GKnVo0wGbiNpP7n2EPB1KfQU4gDjduRhksFo+gafH8JaiHO+FQIJxS/YnzsrpMCg09O6thTE/mRurv1fMTjB0eh9no+TpdpmDdGW1htDp4fbqw4TJtcpHCdK1qoa4YOBhmXgt9bk6oUsMjLc3ABDK3iaWg3SMB4bDIsFYEEhV86erRG0HsmqL1yDzxlu8zQKCYuTrNzI+yNzU3HUtE6H+bVi4GdH2kv+c2Y80CjGb0WycC8JbRoKblg9pg1QZCLNmHkFHFOtPI7WN48HUoPTw0BcC+Jj9pwpaq92r4zX0aC65D8ZVTzn/SvUc4XCuTTvMT92vs8jRjyK01lKGtVT+oVn1jtz7/zu3h/XxDRujFl68CjbDLSReqWW95jwpRnk3ci5m4BuYVmuS1tG2CJ5hqwXG7WpTgyEnsnBTR8haUw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(66556008)(66946007)(4744005)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wZbto/kR5ta+iip+2Pj9cNR8NEIM2FrN1/9qZVTWyNzGAkKnXpO8DjhKpsRE48ROUbMXh6/yO57RNbNYVeLiDQHVMjXiNFXNs5HpdY2OO0Ud3AEbfD/ZfCE1PSFAwqVPNVJ048nIswsrmauyJBnadKLbLzn7UHzGNnb6Q+s79kTbhCGEJBPASSnrXLq1Hh+72jOZHCh1edVki/N4Z6/kp6BxlM4x6oXtqdeyCT9yd+W3vd4bzeCyxS52uFcElujtM6Dz6r8JdIwq1C9V0lI9AEmoODKYuZENfDrJ6XoxgodR5EqsgG9+NuONJdZUrF1G44t8Wi/+ef47o/Ugt+JKcHSpct7H02XWkLh+Cw6bJvOFWmuNQ005B3hv7F5WcGrgY0CRwfZH27bamAqAm9E9gC7rL7htgJ9VIYrDX/U4nQ1W5brUxsUG37/vHJy1Ts8ivHNWWcs7jy5Tldz0Fpf1dQRmsvh8h16pOE+IZmSqddBiI23n52H/MmohP0ZeevW1i7C+3BzUktiUJQp6XeIvd0tOBUyrJ+JgX31e6LA0ISTxnksOGBCAJbOdlwIgY9nIiQS9D3o0soETRAPyZnee5Lm6byzAivy4BVQSyzyPtbjei7JMZQEONmU3b/aAVrpR70D+oTyI+HJHHlv0qk8kLCP1B00VP0SqkXX1FvDi/V1DUt/jzvT70weyZY4ux8Rx6wdbKm/4zLi+9WmxmiFEzv3cLtoPcs4jWz64mMZoeQVDVsKiueuGhb15WeqhRcOUVWpbB+qjOHJcaqADk5Ee95qEvhqA6xMziz016HKZrathaSXhCOYpLvjHfu3ad3d/0sd9KdgicUFOOYg7JgBZeaBuri/J/dN1h4F6KdzWRw0bs/s8R5cZJ0OnLl3l7bB5c+oWMmRssfu7NpC4hFUcPNVk+agDxrslh6pTMMQP/4RcX2MDtl3yrOgXcImX1RovpXtCKpHgoKkDiClrChSpNfekEfRbJQ8/IAhRo62gFWr5VhL5oreaAHvXT6QQ2s2uRjjSUdddlzMQOPEcYZ7eKcuQgeKnoQYI4L90L6kOw3ZHHJDMHoPjotbCHuV9KQaAsbJn/zkh49Kts1WAk6utN5Kd3lmfx7PqKCNYxxyql+c/t7eEWCCPnZb77WDjqONt1UagRWBzX0tPXVQWwO8IW7Kk0cifDWHKtfZYDxt68lgg5q2YRMuJcztG7dQi0rLvSC3UK+SOAflUwDInXaPTcz/VlfiOtGOcl1pdCR7tr0uoS3tcOJGqY7qv1Km9YSijejJDe0Q4d3chSZaZUfxDNixINGhBVO95Cm8092Ak8+mw32rQnIs9A1a/qV1Mz7N4k7ilqQOss8CzqZJ3ZsF5jajdlbBuE/QUq+DnAktbIcTBLUtrRYGSZF5UcPhaVRUtsSPK0RZfDfVwrG0AELR/SkXoPnJsu/2BU4RYlZUtHy2ifSpPfmpmF3R+fAa8EYQb9Ncyg9C/dlGE4PXtT5YoKVW9IE+3TYjNNWw9ckZTE6h5wm7oL38zfh59qvmGjcO1dTlutS3/aF+Ht+1vMPP040ESyXJx4e/SPWApCUen7QqPy42GbksdRdp8Jf11VWYtFEEBWlTEVGnFqpKhS6EXOxfHxE6Df+ale2Pl0dcqi4BQ2TRo82c3MSBOwe+AkeN6FSf2SKaqwLwEBsoWNNpEBA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7d6eead-3f51-4942-3203-08d9fd4e32fd X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:15.5772 (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: sCNqgfPFFm+C0THrWhs8dWm6ZNqPLcg9Bgnh3REna+13SUMtCW6ViL21fskXrx259/BKCr4F4K629rducoGRHaPdsP743w2uOyYPv/MUmbE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::710 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::710; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 6ba65eb1ff..bb071e5669 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -278,6 +278,9 @@ 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): + return qemu_tool_pipe_and_status('qemu-io', qemu_io_wrap_args(args)) + def qemu_io_log(*args): result = qemu_io(*args) log(result, filters=[filter_testfiles, filter_qemu_io]) From patchwork Thu Mar 3 19:43:48 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: 12768048 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 27949C433F5 for ; Thu, 3 Mar 2022 20:02:45 +0000 (UTC) Received: from localhost ([::1]:60362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPreu-0005iA-84 for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 15:02:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNH-00047A-Iz; Thu, 03 Mar 2022 14:44:31 -0500 Received: from [2a01:111:f400:7d00::701] (port=54113 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNF-0004Yn-D9; Thu, 03 Mar 2022 14:44:31 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eExPTqBT8C/KV958RZRhXpDGrjbkMowR46uqeIOmY2/XG1B0KuZwAyz5NG/nga2JiWqsxths7niYDwxutwpcp9whHCnghT6ucKunLIRM7I9icr2+h5rMu3nc+2vIIHzLJvGwbC3KMCuudCx9ohNTEhXEhPWc1bZFatk/Cm786GzadP3WbS8Hx0Q8/164ubAcerTBqezj2nxxWqa3Gn9XDmClny+GUi7qPLAg2oFpJptKdM8oVWdLs7/VC9yg57KaTgrgpauPvqDL1zXQe2FkPYdTxY6l0JKsRs+Z+YEX6G4wmQel/xfd21HoaZ8BCm774lunU/YOONpj1Eo73sB7hA== 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=JnXEeuoL4Vv3p1Q4s5BuJZZqZVqTZWvpFCi98qbgHHU=; b=Cm9QHeCHRu75zO9bRZbBLYVlDL2hp+JoheQzWE/Qir5d7kvbdhrt87ADJ9LmhEgNx/7ZRuXLC17zCvNZSwDHkOaGfo6n3AqMPT7vLG716CQUQkT1Cd9pE6OyIzKNUmGwCCsUDAew7SQjyVgGMq+4EFGUeX3LY+xoNhKT+wZHE+Z2eFV/VdiLYyMauXh1sI1XFJl2ey+A6SycRGBgsTUeCUBqA3PgufYLgfrMbGAHUSzTZ0YcDpwPifmBcUdd8A22t4iui/5fH+/rHNeyShZ1PR3A7l6ZwLdpLdORRuc0WnqXVj5pA4K2G0q6PqoWZSLXG+fmuPCxA6uX2i0VMqvjrg== 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=JnXEeuoL4Vv3p1Q4s5BuJZZqZVqTZWvpFCi98qbgHHU=; b=A7TGD37+jDKOa+AG3jQQ2cP6M3Vu9va1RXSBnWkYxN8t6/4N8DnE5M2b3pxRa/p5m2RqtiY/ImycicrpK4qjfFcO8w1MVi8Y9NH+97stYEZ/g5VmP72aJ6Zi+q/gLXXU71WNKzkjjYLQDgul9+8+Mhr/xQmqn05kfAzXQkifi5g= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:16 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:16 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 15/16] iotests/image-fleecing: add test case with bitmap Date: Thu, 3 Mar 2022 20:43:48 +0100 Message-Id: <20220303194349.2304213-16-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: 3e5ae0e2-5ffb-421b-5b1c-08d9fd4e3387 X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ln2cTgUnd21c7lQIsE9/W9kASOPB3OzcPoVyNdx/8V6VjtE7ZB7Sp419EBLc46517fQ7RA9+YruZtbPXDK7SaEjjh2VZFFVQDZMk7Y3W+Y3jvVLYi0zUwKz7th3w3gIOEeKnkw/02C25vgHElBUGFpmwT1jPKKMttc+5NhBZweoAfg7FHoXd7KWktSK52Me2Wr0WgAMG6dZ5Mm+g/wNU/Phh6TFhtfEdHZk0inNljyopI8Y2uU9zjQE1yuhca7Z7XMfqqV0RnicmV4yQWq+N17S8JuhH5a4EMCt7dTPTJ89ou/DU/jcy2kQ21FcEFtux2qO/CIMIm7uRT60/FoDcfayWwejc+EQisCGvXuS5uM0GK/0QLpCfjp5G+CJWMUAQ6aoMqBeA5yXFgXtZ4orHgBE0X0VRYMpe4AsEtmtXNFAvwgknztB3yTHoM/tXeEnecms8G779JZo3OS2zGJxlRWCA/LsFpPN32L3+bl4X6joshcd93PdHke73EQ0cKvBt8F9p1s5nUiKhjLUZZPgipZsFWZ+EpDoUWx0uVVqde3SAHWy5tWlgMIh/GkRvbhbasBCiPfCI3m09r4xg6imSLq56OCxxUwSIV/ai4VOWyMNns8FPNPaMteD5K4u05HZ+uu7fCD5qy9qWcZX2tepkhr6uKxof5c42jCVUcGJy0H+GNWcGqx7eTlwRve6lajlR2KZiFe9CTPmvaagUo7iPsw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZIIaysrtRvVJ4v2i6BsxylT6+BsGlavfgUT/CKokJiXYt3YXioyV/MzuEZycDDIyPF0U2/45YvJv14QPXDLnc/6lWGR9emBhVCm7eBF5P7nDdFajtDgYdNYrAgJoTt2IbKkq1b0MGVHSN+wQGsOzxUKfoZOnCeydWCXQa1tK5LSQ6RhDRuFipLp1i7jT+/8m2Wpri4kAml/3AzwCkfvmkc7yszkrRQTHGEBSK7b2pT9WnHgeWjpYEAppWGKNDrnZlbUBh1Ghy0H/UvVrWIymDF7yefenuobfXyylEmny1fSckEN5y1wqg2V1cDSSwAyHt8fgIozu06xDEb3o7Cz3uWC5xSovJ4MGD4H4/J8sYmqp0JWxUW+f+xxgwMHsqJq24rpN1WTTK60cJ4Cwe//S2mYISB1aWIyHmClMafweUwr9E26Aq0udOZYr7GvvmMfyu7efhxn4hblc6sHpbq9t2+BVieQ6lGnjVxSt/bOtVlmUGFi7aGzZR2ZBRESrXC7i5Px8A44mSMFhX9ADsTmLMjYiZO7Z6vk+QI69u6xtSXhUROTTpxjWSwTarQy23Wc8dKDWqrkdchXl2XU+MXT6hItTfPML2VfjzsMuBIXYEV3KvAMENJknDyn9iGYkuAKH3lGVKMyqZuL0YNUVRRaPUZg4tdKCKh9czbndaQa4Vqkje5NnrF4NcKZ1fa+w4VqftJggmJ0u/iQU+OySd+O75vfvw3pv7czKCoq3XFy/BGDATYk3zaOeHy7nk5CUf2oIbamgaJQf7RiB3W2xgxEMEqFVRD7hXoSZDqpYppaD898hgqoeLvhwH/LXCbKs0jAYIzxjINotB9/ZVsR/vK1FVprRowxdrxEbVPp8fySMPuSw2Y1TRStOy19P741LQYASOOswJ9H6j5DVFhDKDtfOa0EweQtVaYVmnr3ZnZOSx6rrucj4w7Jux173875IihfzUkdwx7imDFRW/LOmPHXgch99VzOgIASbFUzg3x7e1HNbIo0DqbXNW0uwcAVEliYjS+YaavrH2Xeocx1lyfZLKOS0tsoFsxf0DsJt8N5S7xRmguvd8se+roOIQ+SFtNhnpgqiIYGd5s/LtB4AsAw+kb7A9K31BDJnImCpZMxnOyv/WvXQCRy+D9TElF/EzrDYfKNmOKzX3h0zJcFnjF9+X0t0y9JB8t8DDW9N7zzzomg6JH1reBQwR70+L2zLJQYBa4i60/On1BvL+MvECCtiI8atkYluVshz3GWSa3HTqoQfPshSY9flNpBNP5Zs14M4Dn45oBBVt++CCFqTPMBa8Ykth7ij03qiCvQWV2esubHZ1UMEgTGOdQ3wLoyePh62J8oZiFQgjmmMePeS5YNoifC5nwQtWGOFKfKgWrlKvm11Y9uzxVyRQkHcuPqqq8EwPaoFEHsJOhJaONOMSE/3JP3eG0jc7HyuAp3TZu254dgxZHAwFCu3tadad+cC6yY4D+lKm9JTunK6YwLsqzBOFsKReyMo+Tan3zcelp3liI+w18suVbG3VmPNj4bt9b7cTqdeIIO+s+KitNKeUblOJOmI+SOM9OhLmsUvGsjpsKMFdJmOJ56oxNVbi9iVuN3EWUdEYlYw/z7kBL7fxWkqboB1fXkqG8xTe592fcVYVdYlmH334zzpELYk0+Zy2pA1KN56k2v+MLpunxBhOSLaJg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e5ae0e2-5ffb-421b-5b1c-08d9fd4e3387 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:16.4202 (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: 3FATXL4TrcvQQW9TEJxnOaB+olkRM0AGFg3b3yAQiD6jUNgrqYdb9uqiS60pclVB0jZtnNc3b3zh35vloRTyelJLSxfELBw5j9Xq3kgbCCg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::701 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::701; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 | 38 +++++++--- tests/qemu-iotests/tests/image-fleecing.out | 84 +++++++++++++++++++++ 2 files changed, 113 insertions(+), 9 deletions(-) diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing index 909fc0a7ad..c9ffa6647e 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -23,12 +23,14 @@ # 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'], + supported_fmts=['qcow2'], supported_platforms=['linux'], required_fmts=['copy-before-write'], + unsupported_imgopts=['compat'] ) patterns = [('0x5d', '0', '64k'), @@ -50,11 +52,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 +112,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 +159,10 @@ 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 +180,10 @@ 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 +218,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 +236,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 Thu Mar 3 19:43:49 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: 12768045 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 605CBC433EF for ; Thu, 3 Mar 2022 19:55:23 +0000 (UTC) Received: from localhost ([::1]:41204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPrXm-0008Qq-C5 for qemu-devel@archiver.kernel.org; Thu, 03 Mar 2022 14:55:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNI-00048L-8l; Thu, 03 Mar 2022 14:44:33 -0500 Received: from [2a01:111:f400:7d00::72c] (port=28672 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPrNF-0004Wu-Qs; Thu, 03 Mar 2022 14:44:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ajXrxEdq9xfM0sOTBGPh+bWD88bPJ9+oD+ThOrRxlXgiD4Fz8bU0/8YxMpRYv75PDugRtBvdeJPP+6SVz8sQmzwyxBC4gIdEw7D+BnN9OyVgj7KtW4yfKkkIZLvI2WUkKUDZ5rQ72F93v6qBdlXeOCjrTrRzX0jqY8quYkaSmvBfLZH/7YuRwUxKSNluKjjHQrteUbMNv0SlZ97aUWuMzaBRYDqc5RF6F8MpTnjzYmDzg0QNP59w/df/cbL0h6P7oyi1DL4UklXAxz9f593TAy68zUoCihuZ6LcNVDibmKXxsOuutkoW+meU+iFQmDwVM31MWh4vgicWinx2HS7MGQ== 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=MPWq8WNPK3dD6vDdPAgUea/YC405nYdzt4CdrYSUjO8=; b=K4P4Kb2u7SXcwLxo9y6fBjeHGw5CT7t5+X72HpZFsfEOB1NiFHkwVoCbpvVKmMcKvVdxVhb1Q/eBIZKBbRYJ8W2hokPUW4SrPcPKUB28/R+hV0pDdpbc5SxVfMMyAWdr5jJAEGLMzraE+M43m3daZsUtRxTz24dFPT2bzNrJ9YlYUI0dddry7UIfZVLf4IL5T9GSewAwYcVOGLxAfp1N2saPAWb9BPsx2nBcXb3INCB0b/KQkDD0DlHuvfeeF6oHEinIyzYYEETjCyKpjv6V6f/rXPjFfXSxMQoFucjgfDuahn/qouPLY1g2vrjeEkEzSuvSbqWREaM+e7/lWF96Jg== 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=MPWq8WNPK3dD6vDdPAgUea/YC405nYdzt4CdrYSUjO8=; b=l547U+j0kO2q1WxfEvHwXbFTz/bpgnIsILuXxzdzB0mEzEYer7DURsFV2x0hOVcKDsc47hD5WwrHYJQXwfY+nXFrs/KVYpHO7Zqmr4/1U//RN3YiICMtSE3fvFYw04RUQdjsuFQEB1bAgArwBb46LT1VRpHRkolioHwW9dFxS6c= 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 VE1PR08MB4736.eurprd08.prod.outlook.com (2603:10a6:802:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 19:44:17 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::4545:8e0c:19c7:2a6d%5]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 19:44:17 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v6 16/16] iotests/image-fleecing: test push backup with fleecing Date: Thu, 3 Mar 2022 20:43:49 +0100 Message-Id: <20220303194349.2304213-17-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220303194349.2304213-1-vsementsov@virtuozzo.com> References: <20220303194349.2304213-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: VE1PR03CA0038.eurprd03.prod.outlook.com (2603:10a6:803:118::27) 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: 7fb3ead7-7a4f-4c5a-c6b2-08d9fd4e33f9 X-MS-TrafficTypeDiagnostic: VE1PR08MB4736:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0nGzzg3eL9rcLonKqhBIAkybog8QwXWk27x98urIHRjPdj87nxjJvw6IMIGErleF/4cDzn0nk/H7tgDbkg0HwL1iirlnK34xugHpPY5CYe3rSlSIcorL+RE4lmSsJrNs0g4iiGKU/qmdkp8jRvWlEl0FWj3c6NvpHcDNNCLMfNgceJ3XMDRSzjeDRcwLY/OeV74qAo7RtuO3MTVYNBWtK/4zdZmRkAvm25FMB+qsJUfouMJHQIwTNppiydtMQt6+vGPEeTid6MfsCeifa3ibg/n/uCyXO3OZSBYIBMaU67g9RKc+aBTtToZz4Wc+HQ72Akt9Bcre5A5kTCzLEUoe0IF+RHl83nssE6PFdel5yLDiDbxFekslJdAn7m045kUt75b0balCx0g4GizTZovRuxPGHnoCdOblny1oIj9qg32odvMFpTMO4JEtJ9JJcakUBpALWOnQ2fsXW3qtF7UbWyD5CTEUvojw0VAInwfPQ/l5nRAafqSZPC3r+AhOtGyo2CJRArOMtxJtOIRZ0RfH6BjuRFNy6qOCTSaUeV/LOpa/OlcQxLKwfVuzgzCuKAxLnF8tUDdvV92GwYkts8XzgNbzGRIlk6uB/0I61tQPN8bJuqbXzaPB/HMYDCdmxNHC4z+hOOyh1yykYi6NqzLvTfUGEhSCilfGuBU8aOevTI4zkJppAe+Xe2WRyhterRkLWHUxGYGXsYOkdQZ2cd+IkQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(6512007)(26005)(6486002)(6666004)(186003)(1076003)(2616005)(316002)(6916009)(508600001)(36756003)(4326008)(8676002)(66476007)(83380400001)(66556008)(66946007)(86362001)(8936002)(5660300002)(52116002)(38100700002)(2906002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BxdOWvjyzvoimWchdd/NWU6w7jFrvJdnDcEqBDrWrIMlFLUkdswz6erYTaSaUeWQRk1Sp5yVDJ01N5l+KYCzhBcLlRBMrU0Fhqf+xvKrhH6wzHhmnqrEiPQ0iEto6tD87+QcWDIotTHwlnWIW0qi79PjJIQmHVdo72NwzTIlAS9uu29IOOMygfIseSvXu/LMH+4fevaDwZiWsK8cMgeQo4DMecG/mjkKlddiQBwH24uLPtHw3r3OenOP78WWctM+sKMu7cOXaKknJNOvn2/UkJqdVarrjuPCO1mPoCNqTicBYbTBJ9eBRdp9n0OUVUVXXKd9aPeOxKkzHttHIMqmWcsEVgb5IdC7OIdird8YS6vYeVF1XmkZm/+sReFZC6jvE6biVVLTJgEx+l4uK77dLllqsm2Ydui318UHPDj59RHAQwpgpUPvF8IIXtgRMo4KutBwy10mXd7PyMah7HiyfUIN8deq9klYLSDEwpLhNlzIakEb1gHnnjT7CcIsZ9juPSp9NVBFVhjgpmuD4/zB4zwIksoyUZIHFq59sLCDbWgCz3gXokYl6IMRl6OofSsenjvlMIp2177nwmh4SHvJ6i67rUYxbraeyOh/RvxEJcO3Qbwz/w4TlCTq5C6pewq1lv4mqh5/yW9XBMnNIDR3sM+5M5WIcdpuq3uD+gy9PSR2OZVo62e2F2Tn3JX17RNduAtWYKKyv91Moc1u+cy4BQCVNa+ye9kiSpXC2+cXTYBupp8HJn68uOBzWL16faBuIIJ/nkQIB9njF8dockltN/2XpZ3W8Iijfr4q3ZxYbuAy8vil8zlZbi8JkcQE4JwVl9XXN0ThuBrdormN5Zn5fXAK7gmL5oEUoWTJZYC/qpyMAP5nXazZgvDUJvlP6rfGwTkksIVIkA1WSB2nOyizRNJMgadpDZn4zfJ+/C1vcz0CVX8OJaWJwL6UI/u1Y2vXYwWXhwfIxIInG/AI0k9OJcH1UQtRr1i3K9Sj5qDnjSP0zhs94Wd2R1AHQCtmeTA/x/5mP4OXOoUiuyz1p5yC8GLGQ/VFKtkfszs+5B7VvkyboK1fxFDSGd+F0M4kVkWB5DfIrn6haTeIFDoOLVfEhnkU0lknc1RFuuAcbvP5qk1Z5BQV8vowRUvsdRT+6BzLTvezSUMpCE7Ku9uEYaLn/0IcTCYSP73+q8e3QuoSgaqLvqwHEhAb+yavBq4UK25M6CSjZeAkOmvtx6NrZVpdFWDPQoMG1aNZ4IU0eYCIPGFsByt/Pw3LaloG0fjiZYqY8nqteh3sFyLeK1S1IASWKsgIYt8QdW0FVTecYWq8D8wh6+pBuiRNlOzMVUXQIgrQTvYh+Tmm30Jl2MpkAvzfNkAYq2HB0JERGVj8h1QeKt/xhTF/JW53QPVl9YR7PcBeT7bVLdPNqmYFlL2b4MQkkfEj/0uW+opyFym9lMkqpWvgg2jDC1MDvzX1X7Jwuss31oRUym8316zNX+S/J3s05n2wTJ/gUeo9mZkjvS2NiK8LHvDWxYWI1I5BL9PWl2QmZUNU669qszgDWNL7osKz7Vc7rcVikw0GKExL5fzDc7cIXSzc6oHruViyfToCth8fJqnDJrYLVYh3CswCvWupxfx9qIgV3mmS13uooDXWZhu4dKsmR3YuX5Si64xCrEpnN+M8k/ZWgj3SJhsG81gYuQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7fb3ead7-7a4f-4c5a-c6b2-08d9fd4e33f9 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 19:44:17.2013 (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: kK12NazOddUJV1XdTB4MP6rKvevORldifmKT/dDEgtJOCBtOJQj6AhnAY8ONIQja67cmxE4G/tRLBlUfb18pRb6TjC7gL3OfG7E4eFJ4k+A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::72c (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::72c; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/tests/image-fleecing | 125 +++++++++++++++----- tests/qemu-iotests/tests/image-fleecing.out | 63 ++++++++++ 2 files changed, 156 insertions(+), 32 deletions(-) diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing index c9ffa6647e..c56278639c 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -51,9 +51,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('') @@ -67,6 +73,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) @@ -141,28 +150,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', + 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 ---') @@ -173,6 +199,23 @@ 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 + # If backup is already finished, it's possible that it was finished + # even before hmp qemu_io write, and we didn't actually test + # copy-before-write operation. This should not happen, as we use + # speed=1. But worth checking. + result = vm.qmp('query-block-jobs') + assert len(result['return']) == 1 + + 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('') @@ -180,8 +223,12 @@ 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) + args = ['-r', '-c', cmd] + if push_backup: + args += [target_img_path] + else: + args += ['-f', 'raw', nbd_uri] + out, ret = qemu_io_pipe_and_status(*args) if ret != 0: print(out) @@ -189,7 +236,8 @@ def do_test(use_cbw, use_snapshot_access_filter, base_img_path, 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: @@ -218,24 +266,37 @@ 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