From patchwork Fri Aug 27 18:17:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98A95C432BE for ; Fri, 27 Aug 2021 18:20:55 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2597760F92 for ; Fri, 27 Aug 2021 18:20:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2597760F92 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:51386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgTG-0003io-6l for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:20:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgR0-0000qT-D9; Fri, 27 Aug 2021 14:18:34 -0400 Received: from mail-eopbgr150114.outbound.protection.outlook.com ([40.107.15.114]:15647 helo=EUR01-DB5-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 1mJgQy-0006Rv-S2; Fri, 27 Aug 2021 14:18:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QfeUfGyTPF0MCHlxtSLXvPg/HW247qx24BQtAn6EqK3aVy+3xLHkPAQm2c21E3EVyyLHZqjktx9+hCneHn9RPrbwYdBKfzL3HDroJ+3DcYQ91VZMLxkmHCQquyszFj9Y7yNFB3/AI+E56a+FeWFODQVlOhO76KH7u6OGRyYRnbtSIEhtGPla+UF0tFkeeYiT3+XQs6vL6ZNy83vwteiDs7q1zG2gei71Hsx/Pte7pnZDbfCM2lsSPzaHCZHJxZxeaj3CJIz+lt8bFTRFBFr7ErJoG+N8hxqJAxN8PYboeCmwFtleivZ3wE5qs1AkZtRiziyp7LjkKt6skKZMyawLMw== 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-SenderADCheck; bh=4Pkt37Sa/W0n39PLCj4OE+z9q2/HGzFYHIU9wxfe1So=; b=Cb0ElP81WLeBA8SITPz4WiayVi8KayQSn+CnZoUDScvhFdd1CzJkX7RHAMnp9rL0Hm9LshzAeUIA39haYt6r74cdHMw3TSAWcsAGW5yocQFUYmLtTKYyHzL8zXg/Rr7tO4fFslzv8j0PVroVbSPiEaeawB/DSk7DViIIx9rf4B/tIc9F2d9F9p0G1VukFijt6CUdKni2lgOkNjfwYnsWdsKi6rdKvrgX7PQf9LJvDvVue/XyymHjG4mpc5QcfEUbzjToWjxg2U7NaDFOBgayQqn6iWD2wONF3iG0IjkccxxNLfI3FXGvfvyucOEk+DWvcIRJRMM16T8a+vP17T9Vlw== 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=4Pkt37Sa/W0n39PLCj4OE+z9q2/HGzFYHIU9wxfe1So=; b=qJHN55cHY0y831OJZpR690rw+DNZ+dl07rrph+RYi/DmWg9BAilYGs4OnNwyQip7UCIh5/RrMzV1mNIqtf/7fRqFDUxdtBRWY9sw5risXPO4Wm30+CxMFGmoHHVUUvm9g60zYmTKDAw/hfgErfayLIHEfd/i7/TL6WamOZxEF5Q= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6870.eurprd08.prod.outlook.com (2603:10a6:20b:39a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.20; Fri, 27 Aug 2021 18:18:25 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:25 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 01/19] block/block-copy: move copy_bitmap initialization to block_copy_state_new() Date: Fri, 27 Aug 2021 21:17:50 +0300 Message-Id: <20210827181808.311670-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7e5dd417-fea6-4c15-7c88-08d969870fb1 X-MS-TrafficTypeDiagnostic: AS8PR08MB6870: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:48; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pGuEG0G3rFhupO1J6mtTj+2B+lTQjW/+UJNmzNl89/y1Q7HF+CSH8/hMy/8T/MJE15/shJpP383Q1eZ7npzmCTz9YgEfdcsXyOBOs4PCPExIJKsWI3M/AmIBgx9JjrwOm8NPywE+vz3i3YnN8cSHLEoeN3SUjL5ahCFSx2bOZd6c9krAFaQJX6HtREqTdAvk5EE8JgItBn4DrUjWbbLVsiPl/Sm9dpJKhqJhbWeewvQyzdmnykSoO2Ier13OVfyeXOEVnpv0QgY45tOR9LRmWRC4H+R7bpu/lEzeOM/RD853cx84os9AtSQAsf9PLI/UoJ36mUpixHfbC8SvsjL2KBt89Cg5Z6Wppir0Kc0VnzN/helmTjdaKw+EAWPbP5iqB3RASPpWOoaXSezZSPcbDPlO7WH/Ld2XIYxcd9u/Xgu7L6QV4WQZzKsTvMGWUvcwTkAtrXvDzOpjV18RZCTPigTmT8IO+VwXRRyokOyfUYn3jTJRQ2wSzFuWWsa1I6F0H5q/8OJsaRVb188uPmlZWFFndIy8iZ8srkkSz4c6D9pdEcVDTMw/2YEbzV/H1fKjbpJhdBV+1l5291AoVC2B3xEvyMzhOSTo4Of7nsUoYrfpCPOQkCm8IIwSZndyeumwtytSRgcClf/6TLayoG5JIAXyESeR7W681uOSe8DRlxfogdHGhS7axJX/OfNZ//i8pLuDTPRZeghSXfRT8GD7jw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(346002)(366004)(396003)(39840400004)(956004)(5660300002)(36756003)(8936002)(38350700002)(4326008)(6666004)(52116002)(8676002)(83380400001)(6916009)(66946007)(6512007)(6486002)(26005)(86362001)(66556008)(66476007)(186003)(2616005)(2906002)(316002)(1076003)(6506007)(478600001)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: m0K+G2O3QcqyamAKrvE1zd+sJlOie5nK2WNij/OXjQVAVzcT5Bw3lnmjNNJ45ghAh8AwMwRLilu0btSy+wi4lG/v5cNWf/YiA1owJjYYO6Q9iVfuapXSkgZ2SQ0wFzdf0mTJVMBxjNZaoiYHK1Ovm8zE03eHSvZzg/DgGZ08UojhkWZCde1JzeYqjwhZrdGXtknkUWKPVatRROLVXjDPKpSV/VtHhoT2/J0OLV119aKq6AO818sJU76W9Ebm/UEZxtboFVyqyLZQML+4CWWlyoH/Mat+r9OuUZM73lvug5xl7k7bGK4TOFxvF58benWjd2TPCIJvbWs71/l9pmIgFEFVcyl7HVumXoxxCnRkCbFu0ENhCSrOLw8q96zQbtvEPDugy0qgL5Sx45A45Wzg779OdXqridE3HMDx9UXBNxBKw821GrudQB8W32/aCiUyVNLUYaNsX/Qnaj/4ymyDCjR8hKCig0F4DY0+fBeMXeFAobUhaZi+Hslmcj287L0KRZv6Tke10JniB05PHMqSmpc4QivbOtekAau1uJiWixzJtMw9fw1NkEjMJBh+oF+/QaiyvHuocAjXRc2+i3Bjt+ah/cKH/h/WDfKtWum3Q3Ro47CXF1yJ8jB3mryMfWWqh0AitbrysyUc+zpwuOk2aM5FcchqCqFh/uTYKX41SQYyRxrQTrJGwamzbKPwH4tET3MFEblUXaq8YxdquBLU8rCdBcCIphb9I8LYs28J0zpL7qrmi26b6jo2P4XN+4kCJwHjWObMhu6N2TtFTJirdA+11MBIh+cpbDBmlm8EAKZoxGpnHfuS4HZABy3UewiZ7n/IiTer6zWn+E1v62sQ5WL4Zg3zp3P9fJp9zQvqFh6JiDSRZf7sRGAyxB5Beo01q7FiDBoVYWxkxBh3TTVWNPfkoHzx28sVLuPAQRWi9A9rS8BtZ904pqJMdUeAOTM1/T6Zt4/oceXVIjGQkIBb4/OaMtkgUN/fC34SHFmOmIm6TNVSq5IEIVeDx/+l3jniiEirm5DlaHPzYomZknZqUZ2jldoqUIeUZqR5Nk1oVolRJ3Fkwqiej+jxnCilWMdzaY1iJXoe7qF4d4402iblrPSwxy8OoB2Ug5gwt0x9yTy7yvutuSqxtCt13z3n7fn7Wg1T3SxzGpG6TwaR6tHKCOXJLkHdZwcCLrRfswCtoi/3IQ2NHY9v67MrOQK9RaZiXH9qUDaEbn8cebCmqp3cfIuO6RB/+TvErJsgnYaDeG7L80FcL2OiKm8jODqsKgnKKyOWDRXJ+MMJnQ2YoyIyryZZmVsN2FmW6GhcUBAMxigHY1N4VXA/+Eaeac+8vBH/ X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e5dd417-fea6-4c15-7c88-08d969870fb1 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:25.6050 (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: /XhFxAFm+TB1zIrguTWXBn87ROehG898e0Afy9Yc0NlfN8p2gfVDa/0hhmP0E11IN7YRDQkrjC16ZvuJ0V/UDVuRyE9W0CKcAn8noo9wIiU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6870 Received-SPF: pass client-ip=40.107.15.114; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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 --- 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 37d804ec42..c39cb5fda7 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -401,6 +401,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 2a5e57deca..f5551cd15b 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -148,7 +148,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, @@ -176,9 +175,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 Fri Aug 27 18:17:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21B5DC4320E for ; Fri, 27 Aug 2021 18:24:52 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id AE5A960E97 for ; Fri, 27 Aug 2021 18:24:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AE5A960E97 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:33128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgX4-00024M-Tz for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:24:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgR2-0000uN-KM; Fri, 27 Aug 2021 14:18:36 -0400 Received: from mail-eopbgr150114.outbound.protection.outlook.com ([40.107.15.114]:15647 helo=EUR01-DB5-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 1mJgR1-0006Rv-3S; Fri, 27 Aug 2021 14:18:36 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=br/WiBHfwQcwcapGOnDTVH92WlqF+oLIRBlIfG/9NBw8NimMWxtpsbXpW3ddJ1smw6ikzmruxeqR//48/dWXmtVZkMxCJNJicW33vN0HSYE1r7HrFI0Z/soCcprhFzF4wgq5b0j7pJk+TpUUFQ6FpPeCuPEcOKe1mSzOxaoYlKSgqthDWAgf0miSDv4KND64vKuUmYWz4i5TOGDE7XOgLcRgKnAQ3KkrTAjeZTGPw8aaTSi8PFrmrEnvIouZRw2N5EisjK7d74Vi+NDbf5y985vA3mhywSe0k0+Ot6vV9/8xL5wlBl7attxDmXXQlghiE21pRHI65TvErcGCtduURg== 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-SenderADCheck; bh=z8jIK8WJ1Yy7NCcFvveIlYBvCvwBraFlnEj3KEFBOwI=; b=AU7ukyGhEOuuMxQlltdaHLxA4/2bUFVqxnsUO7z7Fq27wigXgVnMrrDQulp4MdxlQ4hDm+VamMGwYJzUt+gglCm1efhL1p+9KVtq08hUEc8hs4fIBcM76ckpwQEhfE2410GjhAuSYZKCsoelv6fsoXSKnXqC281E098msVuFFR+/K133fXPLVi7N7muiRA2RZFh/nOIy15DbCT7Rm/1cETGsX8G8bty6bfCP9SAqu7mP1w0g7ZDxNCxBsq8cdDNF1bVMERrhfX8GEaZqNe4EXNPZFgIczfaZyTZ+SHzrAEMwTYcQs7e/rj7sBF4SzY5UcqvAE4AXYh9bOYGOQSC9fA== 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=z8jIK8WJ1Yy7NCcFvveIlYBvCvwBraFlnEj3KEFBOwI=; b=Nw4Dyw46dbfCnddu0EECOWI9nhKYmqjegwIqPp00dFN5OkyQq6P4lRXyEx60PZsxk24fEArOGEqFDzO2814lcQDmBO/9tDly63Ls+GW4Yt8k3IM6rw+Pp7Y72nkMbw5hd3dME2Hi0vNRjLYqRZBZf26IlNYiwvNMZ4FpqTXo3jg= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6870.eurprd08.prod.outlook.com (2603:10a6:20b:39a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.20; Fri, 27 Aug 2021 18:18:26 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:26 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 02/19] block/dirty-bitmap: bdrv_merge_dirty_bitmap(): add return value Date: Fri, 27 Aug 2021 21:17:51 +0300 Message-Id: <20210827181808.311670-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b7b9c49a-a0d8-4ebc-ce20-08d96987106c X-MS-TrafficTypeDiagnostic: AS8PR08MB6870: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:431; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z4V4Cr3diTR+njrld82yhYM9LVcBYgfnhGFDL7keorSSAiVrx1TFP6iLQZnXA3NTgA+6H4cwXGxB764adh5sfPXqQ+Ssz9YWIB9jylUsuFlsZ3/BiCT3Vji3VFAuOkK8phmz5UlD5mswAfVwq+t8cHgRiA4E8jDocvov7uUVr6aJjlN89M2m+mCqONbEK8xoyryXTOJVPBBcbfWG8VHkZnrkde9/p9kzB2wys9RDLc2Tn6r9v+jfYnLDLv/1Su4O0Tgaz+ZN39ZvaorrHfrvzf6JP3jSdN2ZF9Q6fMIB9E9fFDd1ba8avyYfHA/GZkfazwx59Pe5DlTI6tGLbYFKNlLu78LE1UWAhYSWklzdPk+FW8wuOuwkzk2jDm6MTLGinOPr2EBP6vI7XvghEyhXlaBVf07slJGUuMcS/7WRn6ZeNRlUO5pMqO+WaIIJPYuNH+BzxR5Oyy0h8i2TRtJjCR23rhE0ZTgD9BIwjz6BzPP2SlnDeP1lA9sKfVQqu27+qDqC8MjqEyXOot3WG7IiValmJlqLhnjaEodp1ZfMF9SS+QUUm6JlJUHu5M/MyMu9/h3C6bj1duUJ24TtIza8WlBFDeU7g4CAyOGU0wtt2hjSmxFqrl9nudA9l3gU89EvLuvT5lq4BYVC3oWbsX0inaUSQLMxaj6fOz+jt1YXQNueFKH/ljX3L7ehQDQy1UQebCxBGH73F+fCtk97X2o7kEis9PUJN6wNlac4oEVef1o= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(346002)(366004)(396003)(39840400004)(956004)(5660300002)(36756003)(8936002)(38350700002)(4326008)(6666004)(52116002)(8676002)(83380400001)(6916009)(66946007)(6512007)(6486002)(26005)(86362001)(66556008)(66476007)(186003)(2616005)(2906002)(316002)(1076003)(6506007)(478600001)(38100700002)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f0HF8RUMi2b/qSrQiUVui2tlz8hcTudh78Sjyyk0tEDXmRmXKPEbFWuKAx1HxcaDfBzfWWu7aZ/mXZLgcHOPHfDw8BXw7b7c0G/Kb2wHyniQvafeayyvbV3jLPezByxXwotYuneHDmi8GwMrBjqxoQA1938KKbpnijvvEIJJzNGK+mlP6tF6eEGiNgNxABSBGbozOFUzAc4I9qVcRZzGfpI7EYIpsJYWRWNP4fWHQl+VCKRUUP6p5RdNx39jR3JMWPn5RocdrTWf35pVTORSwY1RXHqyzQKjZzsEqU3j73UeaCGp9DjdOCm+FAblvjLPjID660MXNBoI95n61hqN24RbNwcD4NdcXG4mrOFhxRuYTHqrn9o7BgPVlIJFPhntOR2Q0crUir/AA6yrfuyNApZewuqWeoINY2uWmcE26Wo2vAde+GGGdSDcmk3UTi22NW+8qNX4q2XnOyIKzEkhD5v13NB4pxs8rnbjvysGA5riS9h25pDaP9WpBggmmTifccFt/PK13qklUOLXTc+8hrlDUbKE/0XFU6ueGQUVjY3COiRWJchKh9Nj1XY9FvOsYzbcNMiWdRVFbSXTEFJpE4hsIQ2QXJaokF9vsMDfn01Tm8+FA6glKViMsqZJUsqLqHiToCv53fTDVnnt3tWOnmsSWq+DGPZaOlk7buLKfBvF4o05KX2lDLRKP+WHDSj/3R7Z/rBZsj5cDw7kTfj42B2NFzV7dUkyl6EkJuuA663u9VktLxtmjDeBq7FHKhHhFSUVejOrWvkhY2/gKRJ95WbLpm30E09ih+YRfOQHDD5fSoyzblQQiAKiBFlFGi9Kew8ZmFcbYPJku43qzj4cdNMjHU8EmipiMB14S6epum5eiS+twNB9HTwsl8GifoVx25ayCtGi108pAReOy01KNOEt4HMGJkCgTzCZNmV1ZM9HEBGT1qbXS8fgs9xQrt2pqouPkSco2YL89xEfuv4SKPHcqbYnUSlaSoo9RuKyVbBVCy8MYFYJ+ijbXHKiId59mfmG67+pzCtNi3iDX1+x5VhoeIrGxnyRZU4GsDjOM4g3CkyK2Ukhk1K7A/CuSFNFBFcvulH1bz6qTXJkF6o8bd+y1uPOlTWRpASqwPLKXzfNKdzLwNJMGdSQl5usFlBXoI7Jofayg0LsiwQgExcwZ2vOvVnSP/yl1f1u8BBIHYha+/EnWTYQi/LthrcYzj2/P1lDM5PK6mQXy6vkistKqvUDR4XqwN118jG8l0caxVeeIuO0Y+hMbA63XyB7jTmeNRiT00PNbDlQk1r1W7Xt/yAmGTgQdNbzpSvgPAjwgBfFpqs3E6DLrxWTYCHHyYdP X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7b9c49a-a0d8-4ebc-ce20-08d96987106c X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:26.7808 (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: W2rGzATMkS2jwN6JtwDhV9FUGIblBOayfN9CRee3nTgZ+J5Tvs/9k2q1RQ5ecBcgI50LP5Z68IyO7Z7poWEhGLNh7/s++MMi9L2Juo4JR7g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6870 Received-SPF: pass client-ip=40.107.15.114; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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 --- 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 Fri Aug 27 18:17:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CE38C432BE for ; Fri, 27 Aug 2021 18:21:05 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A7D3960E93 for ; Fri, 27 Aug 2021 18:21:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A7D3960E93 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:52110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgTP-0004EZ-MM for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:21:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgR0-0000rL-QZ; Fri, 27 Aug 2021 14:18:34 -0400 Received: from mail-db8eur05on2112.outbound.protection.outlook.com ([40.107.20.112]:12641 helo=EUR05-DB8-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 1mJgQy-0006Un-8v; Fri, 27 Aug 2021 14:18:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ag6RWeZsoSMxXBIfpZIDMIdzCAg7Fq9y/Ki9Vp/oC5qyuPx/L2465N53jjvdJkD3HtrHiuk5be293jOWLb+0jpBc+kzU3Vm/KY1MPN0jpVFcAjXcEKnSJN577kLhiNDsqJPQC9fBAwb1/aECoii26DmJ+6RSP4OeEae5sbIi08zf2dlHeDqEo5Kg31JhlwEoUAe2fB0TNZN/rRMFN5Ghs5aIVreK2nxZTaZBn4tJJF5Lrosnejboy4Nm5BVa/aAAxX4bzP+omj8Z7FUodRedUHxkKmwQVZQGvNbX7hnUwqFhHa0v1UsDyxI5/45fkgxqExzenmGdNMlXjbK7GmJ0/A== 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-SenderADCheck; bh=ERx0QOyKgDuRLKmP5snkSgAmYfq4Ol1OvZ28qxkEEJs=; b=lYIEoX9ivGFIQ7eaQ2OxZY8P1rqi6psCEYobrvjYRVEhMOwtntwZwwQB711kfYhgmP4glbYkB/xh1Q1ZoVBOte4/vEhcZufyW02TB3r05Zq5E4rqi0UEEureT+13JdwlFZUhEGTDjjGPiXOGLRZpGsoHyQbG1Wf/9o/OqltqbBUvJKqDWmIutA4HfC3aLYksYfhAqcstCOgkhU7ZLR5SbZsUGMXByVtWXMhANAk2IlkDPJCL1ZRsv+NYA+u7uRqtGnzX2VKKE2wF+xX/XoY+wTmtvx8iIyiP4YZ3wGJWodqFPhelMz1tQ14D7lYwjpxDLBptJmkGxIFeoo7X/a4a1w== 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=ERx0QOyKgDuRLKmP5snkSgAmYfq4Ol1OvZ28qxkEEJs=; b=bL6lbXya9MrFtyVcGfCQ6ODeZGvOcmwAZJBU+4lm7239ZdHQP6Igk5I1sye+oFSns00smAj9Yf2IZTW1sAVolbOp6WPP68MgX5tQUaXEx6WGRALSUEzO+cDO58P2vcwsz38yN5p0wbKwNATDGj4L6MbE9ew8rwLt99u0r6DE3jE= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21; Fri, 27 Aug 2021 18:18:28 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:28 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 03/19] block/block-copy: block_copy_state_new(): add bitmap parameter Date: Fri, 27 Aug 2021 21:17:52 +0300 Message-Id: <20210827181808.311670-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b6075a9d-324e-4a40-22af-08d969871121 X-MS-TrafficTypeDiagnostic: AM6PR08MB3765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:27; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zvI7aqRROcgXiUCxDnGf5O1K93WSGtUdIz1bMqpAo6572SXHjwTkLwKGIyf/FsyUB9sxg8C8/nUS69INmUOnUE0DoB6IWK0cTKtZ988ORlnYfQnXRY9VatA++mlADxuDKJgaZoEy+ZEfRWXLB278MEAMexNnS4GIwbMt9SIZU6Sdy6hJfvMtdLioJiJkNn532rsdv4gNrXXXYoYMm++v0TmQle4+ZUp8JAqvju+vXRRrvL9E/6MiQ+AtTkfwCB2qFQA/SWh+t28KmkV9oHgRcVYHGsnpUiJt7dIr+1b9FinDv94ukTi+bY10S0/4wrXFI1z9qPOHVQaFDQXPwiBD1f0dHa2TtzWq5obDRx2L77QFTp7G/PFMbeXYcpiQI16Ra0Sk9j6VFrWk+7mfEy9L4Rj6mCOjfu0W/GfGOL5z77ByJg/a5kEHZb/f/jRPazvtzsFNpedwFfp6S5FuEFd3npmhd9nGwYbD75QRGy9EV1H77AY6c3N+O99cMPlO9/xYC34CJduLtrHFoqA6g9Oi3bkdoRRm+ADZcz/vwPwqicFTpOkpF0k2hDpVYAcstSPOyIg2/LZ25k8oEu/Rs57ETN8POIL+Lb0jxMWqepsypSYu+M2Z9Meu8wUiXrHkMlkweYzFr0opWb0qE+L6MXilItXFVyUmqEL3yr0GVYp2o/BoVJImsCmSMJczX5UuHdlVXQayX9oageHiAR1ZSQ2BHQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(366004)(136003)(346002)(396003)(52116002)(6486002)(1076003)(26005)(66946007)(66476007)(8936002)(6506007)(2616005)(38350700002)(38100700002)(956004)(5660300002)(86362001)(8676002)(186003)(6666004)(83380400001)(66556008)(6916009)(4326008)(6512007)(36756003)(2906002)(478600001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QwV95izIWbSTEYnDITi76vZUJK8G/wGKSbg1v1kCgJKkhdK1RuLZumrX2TFXmuMaXg5Uf1TCdzEU22UFKrJVGUYGUZot0ExB/KXkh43/Ug92wagBqAf+6W5sMZICo4/qXE1wHVTvvXxE+4iT0SusOlDNetJdN0wT5y9TSRHiM2E640h8K8W9FgmxlLHXGWsj7bMhKF2JMGz3PYCvprnTpFzfvxTNrqq4mPD462uLr7GfwHtt4/1+r7PlGpY6zKLTS4gaS5MZ7oeIBi9GKRBXON6E7+GN9KcMu82ksIQ4c6FKW/SFYvty0c3gOJGRrgFqbA8uEkk0PLX/tm5cy3+ZhPqtqSIAy7ud9hKNHSEib+OweGlzMI+yb3Se0hDgjkXTnt0WWoDM/+NniFDwcYmKnPlhcW53XnhkREOzLLJq3adtVseh3JzGMJosxGJIMay7ZxnKLabEfV45hyu/JGogV7+ntpuQ74i5MFwStMjLSA10XZiQV1y2rNgOCML3t3V/32dL/q58PAvdfW/oK1JnN9YhgSbguX1mnVSM+/xOd7KYPIAyP6oVQQ3JslRDX09adC6EBDdDhllP7r7WNTih9AFfh0Z2cOc5+aqu7s9qdTj/zXtFly+TAKhSi0TW2CgoKL2qN3zZd4trYjs5fg85d/N8ySUsno/3m8YFyjlfKiLGSjE/PpgN4n6zbk+2NdDiNQqhMky0W7eCCgBG3I54Tz5t37DWtlYsWV1sKceg4JffDaNT3GLP8WHicrLHHiyHvIMlp74OtsZTP6i5qTnd0EAv/3Lx5D6gAR/Ij0HbHJlNqZv26SB+lbPpG+k7gJNhKcvU6AWBFxCO88pf6za9gzFn8XW9dASntqnBzWMdIfCrEDfeeO+eFAFcbP8J3zkWoJtR59BI7zmt4xcSAJcu+VRB4hzHspGac+sP+tbZgvMXDZLweSATeSOYX6xOGVZRXFWTphz5D08usnvn8kwRLwJ1RJ7rAThln5aJLA/q5b787EcDnecW8QuIzl22m/7LwkyGquBoDQXQVFJclPKj4MOiqLgeq+rk8/a66UsMUuSFJqdq21f0t+wHgmon6UIl8bhvqo6Pt+UbzB7W3tLHuuK21irQqm6sLF5+gGBfX0qqz0xa3UmwMQRSW20vrBaDXBYQXhiMD6cXtgKDFbZQFfRpoZn/vmwZ4KopDlelbddxVjmPYp8aPDHQn93xnZ+Dy87/KYY6SlN0pFsFhLf8ewBG1jT11IgoZDDdPPRi9Z1zVINoqNbT7ruXu69Z6eQ6VGRalXTAaP4EI5s1ccUmajabkLSQfMxNj1GoJC2z3hsocqqEghdZKaYY61ezxS63 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6075a9d-324e-4a40-22af-08d969871121 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:27.9776 (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: JIMHejyvh6T7XcvsvYKyzuoowwBoWmoGQ6gswLWErJYeV16i+Uei3vPCeF+gg2CEPVNlVbQ94bd41aYefc0QgLj8GPHsHyo1TlC0HBxotTY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 Received-SPF: pass client-ip=40.107.20.112; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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 --- include/block/block-copy.h | 2 +- block/block-copy.c | 14 ++++++++++++-- block/copy-before-write.c | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/block/block-copy.h b/include/block/block-copy.h index 99370fa38b..8da4cec1b6 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -25,7 +25,7 @@ typedef struct BlockCopyState BlockCopyState; typedef struct BlockCopyCallState BlockCopyCallState; BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, - Error **errp); + BdrvDirtyBitmap *bitmap, Error **errp); /* Function should be called prior any actual copy request */ void block_copy_set_copy_opts(BlockCopyState *s, bool use_copy_range, diff --git a/block/block-copy.c b/block/block-copy.c index c39cb5fda7..65019d0d1d 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -383,8 +383,9 @@ static int64_t block_copy_calculate_cluster_size(BlockDriverState *target, } BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, - Error **errp) + BdrvDirtyBitmap *bitmap, Error **errp) { + ERRP_GUARD(); BlockCopyState *s; int64_t cluster_size; BdrvDirtyBitmap *copy_bitmap; @@ -401,7 +402,16 @@ 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)); + 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 f5551cd15b..d31ca61111 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -169,7 +169,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 Fri Aug 27 18:17:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75E14C432BE for ; Fri, 27 Aug 2021 18:27:48 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EA2E460F45 for ; Fri, 27 Aug 2021 18:27:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EA2E460F45 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:41658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgZv-0007u9-4i for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:27:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgR4-0000zJ-BL; Fri, 27 Aug 2021 14:18:38 -0400 Received: from mail-db8eur05on2112.outbound.protection.outlook.com ([40.107.20.112]:12641 helo=EUR05-DB8-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 1mJgR1-0006Un-EV; Fri, 27 Aug 2021 14:18:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hbufT/HHFwVliUPfK6cG8Z2OMFEhPAoVbz+K3gD+E0/pe6FpX6mkSrc17VU2E/0N6eSmz65zagSaFdAX656lLMfjofM6Yeu3K8x59D8iqkSQCOpk5/Cr3XauI3blkxGOXF9sPQytnbyWnyYpeOn8iioNM4mEIja3RDfqCSRxoq53MZnTGB7m6cHjxPMxKmDuygNp+FMIocFiK+GYA7CB66VLbz+1l/Sp/f3qK4GTuHDwEgjfMNOlReeu4RJlZy0lu8JI/cF2/xA7a1xJh0wuRcTw5Ai2vxTnFDarAkidYP4VafOHJy49V4JlDcpYP+zbxJGjwEDlldkkmdp3ZZv/Kg== 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-SenderADCheck; bh=qFtcBZJgamPgS39MVptkX5N4hMH7c8jVfQ3cJ1EfEsw=; b=aNdb8kxyueG4L1PitFFvJf7rqBCCL3Tba3GHHjc5Yn7AxlNQM+l6cufbuc7JWoMesccXu2L5Cd/kjQndiAsoXx9xs/nFWFIL1IJq4/x48gpygwrfOheZZzOa1LuZsX1zIwgVG3+BT/AfgucuzshhcqFeoBv8VtWZs3bCXWEFWiMB3m4HCQy5FaPtoCm9NzbfO1AdAC/b/0ofb3sswt73kBbrGmXelE1DTMXg6nW/qYNgifGcyj0QCjx1alCGUJSzjBOqzWN+pOTT7/Nw6bRqRUNJbyHK9hNp6iA0vaBC4yw+AwT9gk3IUHq3dzIg/bHcMzt/R2HqcvfDVd3MFOYHRQ== 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=qFtcBZJgamPgS39MVptkX5N4hMH7c8jVfQ3cJ1EfEsw=; b=XwMi7dIcDlZJN8mx3yWcxMJQ+ovvf/ajZALx2W4y1VFd4wFvODnKO/KA4cTWd2m7JtogWgX/Hk3BGMqyNs6l2mNfW8QKsjMs0s9VqCPOviAVJEsqsom/yIRIMG7Vg2BMSNtoHJMP5yv8lflOAf6TtRzGCM5cIoaKVbsZd2TNNcE= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21; Fri, 27 Aug 2021 18:18:29 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:29 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 04/19] block/copy-before-write: add bitmap open parameter Date: Fri, 27 Aug 2021 21:17:53 +0300 Message-Id: <20210827181808.311670-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 702edab6-9c53-4af1-a193-08d9698711da X-MS-TrafficTypeDiagnostic: AM6PR08MB3765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:415; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vHdkgVAMTHnDlFV276oBcMMreMPfEGH9wYlDgaPYn0g5j0Xqi/TkAmhrr9U6LD+VHMi+1OnxcIFmLgrgNTtrUa5cw8hy7wo4/pHTwdR0yRZtZVljWpRi5WkQPNku3F+KUo5jWK2/RiohUVSgQvS+kyt5QqImcwHEzfdptH7hZvK+RWaVWxXhXShOtI3u/hD+9UR5pJnUiHyn+zQfe0vRc+xjJq/I3oJXtJMqbLnoqKa7sW+UR0cHmx0P7wBEcJDE/50SZnYZUT8Qj0wFQLv/kHrIl+cjJWNIL3xa1mHcbtS7IbKyys3KQT7327mPHWd+s+CHrdqCHlDFneBu6s1yipkmj0QBVSNnq9VSfJQiArn8MY8+68TuFkpnzJCdc1bgaUzlj6GmYwTvjhgUub4AHItFHQVqAa00HmjcpD6BxEF5bVwLhL2v+ElWk3S+xrP7p5RB6BfruhRhf8gNAhm+OXqL0mLwO4t9dQHsLRaWV5LtX+RdZc6lwbXJXY4HtBrj/8mBYFVDsRccgkOKOkTh5OSFVYxUE70HN+FYit2yDNtibZHq1iL1JDiJGzVoR4ZA3FXkL0JJuxoACArepW26XiMROD7UoAeUMDZ8QS1uP5xJ94UJHt1kFscXPUqaQsYgHH6SLImwHJpvAHJLgLrrYeLIkLprdQDqNRK9QQOzDpu2k6/6ZgFI0U1oWF17U/twk2Ekpq8UC3WyzdpcSmJBpg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(366004)(136003)(346002)(396003)(52116002)(6486002)(1076003)(26005)(66946007)(66476007)(8936002)(6506007)(2616005)(38350700002)(38100700002)(956004)(5660300002)(86362001)(8676002)(186003)(6666004)(83380400001)(66556008)(6916009)(4326008)(6512007)(36756003)(2906002)(478600001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tPXFcvVn7ey8beR6sJSLQUPcMePuK5mGkRbss0GDZbuaI66RQFciAOB4gA5x+6eB+vhW5LOdQQUO9yNW80gMtytNnIb2Cly622DFg65r0yNjf7ondyL/jlQ55ikarCNs8KdrxjygbwI024aE4DoM3f/bfs6EwtkbRl93cafS+IJvqiev1y0ClEXPgAN201+//y902ZJI8QjvBaUWuy6ZtHF3E9MScgqdATYcnSG1Q91/cQTfbwJpdSUelFIOYfmC97gQxdYBWuy0w8HSCmGa2gtglywDS+uLCCm0ZeJj6v2OUhIzAJow8cVKqU9IhB6zIJAeFSlPsTtCI7GlT0v1BvZPTlS3zCOVjLupVRRwpDfS6s7LCYXLT6wxzErYMIBshzbIA8v/+UzLLKAU/jNK7lupkrPibVUq9XZx4AQVl/SRsOGdjNNq60IHB+oOu3XPOwD83YhEooloaiWxiYN7Wu0yfDz/jXr5tTSiVp13XYdifSGcFPkiaFhkT5YJf9Y7bC7pkYYP7Mai1q9s4nEGATSFHK1ZpNbCUWbAmqrhFwoDU2ERiBTIol4OE7mECXoKE4hiPIfTPE9eYbyzMJfBeGmGDtMT4OzkAbuliIIMJfJk/5o/aqAgtTG6g1QbXUZtx7uo9x9JzO2UPe7aiC6X7I0FlSM3n1kk/law2cxN7DCuPmIK7ot22tN2AcZWei8LTNn2PJA/5BbOMA28gMunH/DfHYUhUtf4EQMn22jeRaYPxtPi13MlD+0rIgQ0Gp9DCMl3V88sPWqdd+FQHePjrG2vX+m96/u5NJYlDRC6iZlo1AYVga+14mAY256p0RXMR1wwBYLXjO9ssKAlNoguAS5q58N+YJe646BZzhP9i3mjvrrLnfnzco49qK6fEVykTWhYpzflH8YnKaU/9BcmoCzA1bf7YtZ0xAGY1s6hdjW3DgcUXnmFbXtK6ieBuXhDGyb7idug/p2k67yua9xm4jYXHrlqrUh+Rtj+VZtqmf0qtpCW1LWLZHVMI1LTS0y7/DPfC6DQUxqfPYpj8jq3yp5ATIfMOn5A4W5luoTo27YPniu/qaNTEaRKjmJ3fwpbhuM4IVBXepyTTrPsFQXSxS7MTf+n+BJerU8fcpr8zwJHPNfYeqflD2h1Z7e39ORDiRI0OIcsklC7HUJMd8LBRogi2OgRP6lLgV8Dsac3ebPaA5fLZc3kSubPA+Ng10qsetiEi+aK8nWevtQzuuxrbkwhVD/oLkiAiGWMJXpsWNN1vhUrkwB13Ey/zG6odOXiSBVZnFYDucGzFpyZgo2VdwCSOenfMTj0v3QPjfbxUuvijiF5PMmx2EtacQ4otne3 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 702edab6-9c53-4af1-a193-08d9698711da X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:29.2042 (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: GpfaE8BR4GxTwKMZ4oxSCeYruTKJJ5AFHHbhV/A6HlWX1p5YT+Gplysnb1iobeKUB7BUD1QQWQ+Pp/R6X2iz2Aqbq8M0zN041/YJzCPz46o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 Received-SPF: pass client-ip=40.107.20.112; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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 | 30 +++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 6764d8b84f..c42d23752d 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4063,11 +4063,19 @@ # # @target: The target for copy-before-write operations. # +# @bitmap: If specified, copy-before-write filter will do +# copy-before-write operations only for dirty regions of the +# bitmap. Bitmap size must be equal to length of file and +# target child of the filter. Note also, that bitmap is used +# only to initialize internal bitmap of the process, so further +# modifications (or removing) of specified bitmap doesn't +# influence the filter. +# # Since: 6.2 ## { 'struct': 'BlockdevOptionsCbw', 'base': 'BlockdevOptionsGenericFormat', - 'data': { 'target': 'BlockdevRef' } } + 'data': { 'target': 'BlockdevRef', '*bitmap': 'BlockDirtyBitmap' } } ## # @BlockdevOptions: diff --git a/block/copy-before-write.c b/block/copy-before-write.c index d31ca61111..e3456ad6aa 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -148,6 +148,7 @@ 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, @@ -162,6 +163,33 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } + if (qdict_haskey(options, "bitmap.node") || + qdict_haskey(options, "bitmap.name")) + { + const char *bitmap_node, *bitmap_name; + + if (!qdict_haskey(options, "bitmap.node")) { + error_setg(errp, "bitmap.node is not specified"); + return -EINVAL; + } + + if (!qdict_haskey(options, "bitmap.name")) { + error_setg(errp, "bitmap.name is not specified"); + return -EINVAL; + } + + bitmap_node = qdict_get_str(options, "bitmap.node"); + bitmap_name = qdict_get_str(options, "bitmap.name"); + qdict_del(options, "bitmap.node"); + qdict_del(options, "bitmap.name"); + + bitmap = block_dirty_bitmap_lookup(bitmap_node, bitmap_name, NULL, + errp); + if (!bitmap) { + 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); @@ -169,7 +197,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 Fri Aug 27 18:17:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 935D5C432BE for ; Fri, 27 Aug 2021 18:21:00 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1419B60E97 for ; Fri, 27 Aug 2021 18:21:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1419B60E97 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:51748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgTL-00040A-9P for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:20:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgR6-00013g-Li; Fri, 27 Aug 2021 14:18:40 -0400 Received: from mail-db8eur05on2112.outbound.protection.outlook.com ([40.107.20.112]:12641 helo=EUR05-DB8-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 1mJgR4-0006Un-Tl; Fri, 27 Aug 2021 14:18:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XtghcKRL0/l43m0faeLeRWcyuXlrk4rU64l+JHxhaxijVjEVQgeF01YkA37dqpnypLkmRkCzWGwWW5anxb6Mclt1Zea2m9dOryLFZjMvdvPfvVU+PD9FMPk28SsaXHojNSiug8PR8CrBVwTf1rugE6KUf9vregoyF3sQ8ELNklWmPbWp9huAzdWcAgs15Erze1fPntS8TWKR9AZcNj9T/CJelUuzFWcwneLmfB6C3iWhZyGqvkJ4CeVkhSlzbiQMExKSL637bfSv8/J13NMMsmgyauieTyUwGM85VM8ZUqAEi080bQWwl8vN9SERMt2KWx8K5zvHy+P5SguLAYwbUg== 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-SenderADCheck; bh=YuQd5gQe7rRebxcPWjlO2ZJZ3QIlfE9b4AMlG+KaCSg=; b=Qm4ElqLjr357qddEEgZcgVSZ6SRs5ryUf+p77QenUXR1if6lBDwjUdh7PoVUvqCYnu2vc3UW0JrdZL2MyjgwVefptLOEbCSQtTlKRGd43J07YEWyBw0QewCphUNv79vm696ePJLZzeAC9CcfFatoib4z/sblWri7HFLxn+CdErOV13p8SEPKfRS+CyGxZHvFvoE3M2nUr0zpKNsEGDRRGgsJArJ2+rRusJj+N70iFRE8Z0hWZPM8jYztCxLae/vrBZrieyUsVOPKkEoOoKG6oe9oBoXJZhZz9LfOLpMNX9mUZbkj1z/kEEHullfkaukUmuS3lxxqPC45LKv8SX3Png== 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=YuQd5gQe7rRebxcPWjlO2ZJZ3QIlfE9b4AMlG+KaCSg=; b=DepXHa8I52A6HPKtciTB7gX0+jVRBh4Yr0kaLIQiXHo8yu5b57rIcNUlKscsqceXB89O63SsngXYOv09RvabXSB+kbvS0t2FgeYGhC3dwQ4dvZBvBspyxK2tTc8D1kh7ooMTs8lnsGo78QImB8FuaP/ajU5IM+BXVKB6vSWfu5M= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21; Fri, 27 Aug 2021 18:18:30 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:30 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 05/19] block/block-copy: add block_copy_reset() Date: Fri, 27 Aug 2021 21:17:54 +0300 Message-Id: <20210827181808.311670-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1259983b-0a05-4ae2-9b82-08d969871292 X-MS-TrafficTypeDiagnostic: AM6PR08MB3765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:69; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bAwBsIt3mTGzjBKy0lN0UAQPtV59O3SrkLRMOzKGg5hyPCfZsLfeKj5zHC0x65ysrq/Wb+XQGNyQNbpMJ1Dz2l+jZup5CSorq2pZloeaBPEFEf5bK7z2adB5G+JlSKHFK+ZpXc9ammxOEbz0KilvnShUcxQzZ6QBm0ip2QLctOj8/BTHznKHCkYDw2ccEHv1dxG4U6NgQhStEk70cwIj8ZKbv5nq5vxL9MZH+yw3aBqheETxjBCT9LGHvzfVqB+niz/UeomOJYHAqelFtdlsJHWNquzvTl+/xlp+LCpyjaVmYUFmvzZj1UBTzGAXLi7J8ctGp/wSMM5ish6itoZBVeF+8M4DKPF9INdEUtG6YjNTXTCb9Y3MMjzpVcMreVsAe16Di1exqvqbf/lB8l/E25LT0UZhl+MyDP07ZCBCd3K5nxnDaaDfHvtE5/9U6kNxG+i62sRYSDdKMU+6AYj/ukjJZDEsqNo3dcuJwzbUY37JQBm2CIfEfQMQdAr7Sk4jT2U+O9l2a0S3RQ37efQVr8z6bDOpPQzg7en+WKqvhf3HRpDQwlGJUOdlQAzNcfEVcy9/LCfXWrHonWR/5U/9eC8ybboWptTLfToDDPgwiuFzpzZ+LotG4YF7EAF9EyalHB/cBcSSrfd5mCnvZ0cZ394JhsTLl25LN1FcLcckFGmzirGxK9RpcYXC3acWiiM7Us+cE4NBDEcJ3FjxMZw8uA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(366004)(136003)(346002)(396003)(52116002)(6486002)(1076003)(26005)(66946007)(66476007)(8936002)(6506007)(2616005)(38350700002)(38100700002)(956004)(5660300002)(86362001)(8676002)(186003)(6666004)(83380400001)(66556008)(6916009)(4326008)(6512007)(36756003)(2906002)(478600001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: g6RZZGvsRZRCDTRAcUsICcu5m7TNv8mK8EWebzjLiSYeptWM9rYWMIyslW8Hb3nsc9pL4ivnV9uXgSmf+hsg8QnLPUYJrslFyCIgACtjnbQDQvtkBY2QaOlAddaz9CKJUMWbwULray43U1HQVtzeNHbB6AhdGmma4V/8fABexqCXKpf7vj5hz3gSJMaWfdmv3lSOdRBRjKhRsvtBhetIuFsg+Q7pbwVyIf9GTi/pcZWRUpKEohkx7S7Oq0gyMABYqJR+RDYKy0r3IB77g996k8Xg3zRMcJwVS5+ZyZjaUgjmenNUjS57Ne2a+n/iYUTsTsdrF1Aroo4ozij13mZJRQfm8SmgWXwMaDG+fD7GbxZvTenS/QKfz7MsXE9TXLeVGn5YfRZpHxzqa7hZkFNNnzRUJfKohaN4Evi2/ExYdeGLGivebiq1s7bDf8Wr8jeQWH/EehVkb7QW3RdFvm4XiJoC6WaDTtMyM4aZQ0g/r9YotTeH45CXm94EcbXRVR4TyUVXm4EaoKW/3OTm6JaxaWzVB6nQcBWmzeqrgCHVhKxm90xw5SIGk9A3hwD6DMfyJhWxArK6gKU8l99/u+pnw9uKTqpVel6h5J00cXyRBPZcqHxXw0Fq3/ukW1ith0KlNgosAM2sgONe18w0LdhNva+JZ2MRtjcfvEWgO2zXDbLQwA2XYvbjTxra/ngz04Rj39Pbs0NG9JdfW+G+EI9oLe1ypHuGKY9Nz3kglQEtHrkAb1mrIczn+gAN9vOaCqwZLXhF+B5uriMGOfyLOTjOUu7CMHJ0fpLczoGPrVfYBUgBKMp7GGHiNF/7j4HG5ibOJA2CH7V1MLO0F2bXuamCqoU6EMTVgIJa1iYPGFKTof0JxgK5M5DvswXGx8EZq/5U1mf4BSXB0pJke4weicaSJMLYJhTr5T8/N3hqFvJ8ahIeC5x9LrWqRx9eykBK3z1JIpDIMwsZpuxWlEB02dWx/+/JslzRmh/P8PSj/ctOu83rmK2maM/QYx0pWIpqGJMtjjZpSlzmGRi96B19D+UpO7/epiqdDvTCYU/CnO43pB+gR8Nl93kIzFMrcIYhx8AM0svN/Yaa15xWOBhv4fn/g72sdft6OWKDS8u8Fg0velYr7c1yz4EEG2EYJiEGb2rHGHf2ITO59b5MEUyZQsIwPH41gnrYkiErA0jsP0c8zX2Ow4E5C190zQLBigkfokkmVOtLLKhxSed332z/yRWoew37cWT/0JUzyEh58h5vzgDfWTHD8pNHeHMhyT0LoXPgM8qnsZB025E4FUs2v4Ip4yixDz3agUGz6OmtnSqJ8h/ALmwnmwLOTH5V8uTnwVEQ X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1259983b-0a05-4ae2-9b82-08d969871292 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:30.3939 (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: RiAnFeSwMpNFvkHhBdIdnGPKCzZkzL5kJeIeEm804xv0y/SkefB0ZwJ9najlDiHzaZPi5NfbS62r7kGuabQ34h3qMNwZqA/SIoi1sS3IBHo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 Received-SPF: pass client-ip=40.107.20.112; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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 --- 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 8da4cec1b6..a11e1620f6 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -34,6 +34,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 65019d0d1d..ca51eab149 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -689,6 +689,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. @@ -709,14 +721,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 Fri Aug 27 18:17:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89CC4C4320E for ; Fri, 27 Aug 2021 18:27:50 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1F70D60E97 for ; Fri, 27 Aug 2021 18:27:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1F70D60E97 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:41620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgZx-0007so-Bh for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:27:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33708) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRB-00018F-P4; Fri, 27 Aug 2021 14:18:45 -0400 Received: from mail-eopbgr20112.outbound.protection.outlook.com ([40.107.2.112]:14422 helo=EUR02-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgR9-0006cC-AI; Fri, 27 Aug 2021 14:18:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kGKPkClI2E+KYhw+2rD9WfkqqtoLgiG8XmwiwMeJFQ9tGwfudwF/Jt7pmky/GbDL+rhvazwq+WBz450wBf+q18u38nKi6LfWps8d2FfdkyG+yjv/60wy+HuFRQVVWnL1pzKgeU2vaIsavgL47GQUgDtM1W2KBGdu5ChqQD41h/T51Uf0Weqm9UsiSS9UFFWBd8m8hqcMSFRMOPk6rX787QHuts9Mw4+sR6jZ5LgI7W+phQuy+96XDqnt+NzAVkQ5QNYnNK6gdUCjdLtCpo6eax2ztYUMnaZ6kH8AVJeOYvPGSuIomme9PKATyuq7FF2Tb9x8MXBDMO2XdHZ3wFTDKQ== 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-SenderADCheck; bh=tUqhcqqCmZtsCbd2cz8PpLDKH7AY66a78oeMIbCzlVA=; b=VuNnt/s7s6YoH0xWZGbIOxf2YV+PeiNwxIJd8Xc5uiZgwR8z4MrRCKKmQRI1sEKk4lAl6kvuMs6Ih6ZL9pGtTTZ7tU1AAStXsrzIao4PRdEWZQMu2RXLanz8pBbNxHzY2FQoCA+pLWWA0XzqzmKTy9OLsSs63ZhLGOxSo0Dvq8Vv9ulDiGb4d3F5T1A6DYnVhvAMmQsLZ7WHCp7EBSXyI+7wyRSFVEHgIU6/7MMoIiBd+/AhoRgybwciEAx+Ffj/k0gNrQlAnyr9hM9ZfqeBM+97zZYXLTU37BJhlO5/NGn1xSwGdQN0L2j3MFZ4lZ9Mpy1BcRLC8ztXB6wMT0DqXw== 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=tUqhcqqCmZtsCbd2cz8PpLDKH7AY66a78oeMIbCzlVA=; b=t9WuHj5iFWk/pO8fUD0kSztZx52hczXQSgo3wCKOQbCVWanmyA36hGA8cv9ctCvYlmJDeT9abXKBu8JEYrf/Rl+yp3crG1hJEA4zeIaC4+31R8EtHmDUGTWYWocA73SspXPbnrtGPsn9b7KzLmjCzEKsvZeOLKSik1RsgExdMxA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21; Fri, 27 Aug 2021 18:18:31 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:31 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 06/19] block: intoduce reqlist Date: Fri, 27 Aug 2021 21:17:55 +0300 Message-Id: <20210827181808.311670-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a10418e6-7ab4-4616-9579-08d96987134a X-MS-TrafficTypeDiagnostic: AM6PR08MB3765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SO7tNSG6sSzUeSOuhUqz7Zw4czPA6iJEdseHEckECJF3hkcmqmFVL8XHNQ4oE8Oiyq4tJAxfy9WEU83YV6JGb2+ShP9eutLMu6tFYY8l1Ms3lEBZfbWeZ6X7UeqgMZnSgBLhQwUvICgZIweE6OX+ybJ7OLiGXqmlyECSTOGwI8zygOKMeZ03BT5fpj+E8XdRGYKEwbgtBb0vICR85EtWi64lP+s97nIKvilUA+f5MlPqEJ/Kxh4A+01ryv69r2wv+u6KSNoSfdTe/d2BeWwO2qlNV5iSGvD1zzGffmNUD310zqKtoEUh/RXCB79UOgS3ZZGBzeMqk2QUxKORdhquTjOFo660awHsFnOfFW5D0cLQuNQxICPySpv0nWP0tiL+87Q/pA1MBv49gTSsR4h47RA8BB1JS+lE8oIqs4qQxHJ3W1TwnG7lOXCxx7fUTK+xP4FtCWYZOcr80G7XMPsIrP2fDQcgzoXoUHUvfVy4LCmv8Cu8Wff86OClgPJGcoYxNryonvVYyc12ksZUl+6L46aQmOVRqzmmk60SNv6uJCQItvMcXlGfINyZcG9yHazApp0AlLuTBSVZKHoNBt7XF+9i4xD8zTooc+7gM+Jt5JNM/n2RJ4qoCGpGf/VcEJp4GY7WIy6H2nJDvsUqrd9f6LHXrJY/nLbQBGPNlQiIyfbt/CKs5zk1pcVKtX3FsvDhNCdO0pCjEkSgNd/vqYejhQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(366004)(136003)(346002)(396003)(52116002)(6486002)(1076003)(26005)(66946007)(66476007)(8936002)(6506007)(30864003)(2616005)(38350700002)(38100700002)(956004)(5660300002)(86362001)(8676002)(186003)(6666004)(83380400001)(66556008)(6916009)(4326008)(6512007)(36756003)(2906002)(478600001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QauU8i8PT5jelBGm8t9iAg9rKTiYvh8I4Kn371nPOXCLxNrScFkT++nu0Wo8RMJXUmXtf5LSr5krNaJwOgJiBjrvNaaZqU8QhWZwrsh3ff+e+q333coDER7gVGjJwjfW8aBkZH+NF8HT3dtanDZrHcLq+GYaPg3Q/GIwOxxYn3PizV47BW4ogjZVhnavdRwoqfEFWWA5/7xZz9n8GYFI8MEia4AlSOPCsRbLeypnxNpYE3A+zwJg1/uU+9JggLfbvLFxacn/KmT8ob7WHE5jaLicQm6fruFPo9MoCGi9ITweK0zzd5a1lsNXQa6IYd3bDBvwaUDIeTS8NP3ilQff0V3zqt7Yr4qb/h8SLBuZ4RjBGmTZUgcQUrLRArdLywGQYmpsXFcRMM4e7iuYGFSW36ToHx1gRpABmnvssle2Xt/V9hTbTvocRiYINtN3K3ZizC2EQ1MPZgnv+gAxAK6iZqAI3dxjil4WKTmInMEXg7IBQtVzJX6I/qc3v2a67VtxV+GShFA70lGNtXQT4FYMcmi7rIUGaefvXik26fcCHkOQ59njwpZmWwDxmJ2LlqA0JdzqT9o3fbUQhgnxvWAte5nQkBYzaPtbiX7Oq37MRSaYbW+qKKBNjg6LujmXMeh8DK6aIKeF9Cr665rn7yLexd0zTgEr74AcTqArsKlPoZu+8ntaYmUZZ6657Tu2yhu1g1/ATcdfg12Lc3+4Jl5py10K+1nmXZUEfaj+MiqUk52bBC9BIx/N//p4sThbMJHsMzT0qcERG4GDALNWigYc6OLLVmOs0ADwxgzUAQpWy4VoAg6K2u+JMjoRNfP9wsY2N1Ipfu8uvq+9mqQWc7MP2CgRRKZkfcpEm8UxSMugwEMGbyhEg8DjlxdL70OEIClYRWdYsEWto35oISb8Ml1jWZI+R+EYiUtRxs7K8v4vCRzYcvv1jhLOzqHjg3X7LqGfvTVgiVqewA6H83uYx7uPDfbDB7GCl2TXu3Crm0Q0rjDf1y5F8KL6j7ABPiDGzF3kjvuJY/Bnc708XFI930LxUP9PXOQ/5G3DUcqgkT9seYE1jP+bgumQYfrbqmOgzPD7arzvuLcDaLJ2J5II5GJ9+7iK2R5EqTf/XUJGSRPqQpvLH6a11Qy6x73yG2ncQmlBTmQUd0upRxviaTWlkKJNisOth9+8rkiOkAOMA/s1LOwDEqEXXXwnbpM6TpFEK2kmXgBfWF8AKYoXWL5L2Cz3VI/pevaZZE+/JFp8THudrhiuz6HXJqB61noUMG1UF719sUkdeu6c80KQH263QDwGUacfnaZeI3V2G6a36DTqqsBd9f7L0ileeNXKD0iO4TVe X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a10418e6-7ab4-4616-9579-08d96987134a X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:31.6365 (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: Ri8hx/Pqw+Zl/GGveQJL8Rau8RxEapYm6axNIlSnpC2+hSvwiDGTZqK1yDRfbzRXgMgbPyMlYI4e1UV3VA5qIpWktf8zUxlwqzEv6yjjrQ8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 Received-SPF: pass client-ip=40.107.2.112; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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 --- 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..b904d80216 --- /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 should 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 NOT released. + */ +bool coroutine_fn reqlist_wait_one(BlockReqList *reqs, int64_t offset, + int64_t bytes, CoMutex *lock); + +/* + * Shrink request and wake all waiting coroutines (may be 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 ca51eab149..46e6a6736d 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" @@ -82,7 +83,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 @@ -93,21 +93,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 { @@ -135,7 +131,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: @@ -159,42 +155,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) { @@ -238,7 +198,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; @@ -248,12 +208,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; } @@ -269,34 +226,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) @@ -447,7 +404,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; @@ -480,7 +437,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; @@ -593,7 +550,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) { @@ -606,10 +564,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; @@ -768,22 +726,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); @@ -804,11 +762,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; @@ -876,8 +834,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 @@ -885,7 +843,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 ece044bd25..2d58170224 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2336,7 +2336,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 66ee11e62c..c630e9374a 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 Fri Aug 27 18:17:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11273C432BE for ; Fri, 27 Aug 2021 18:24:50 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A7D1A60E97 for ; Fri, 27 Aug 2021 18:24:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A7D1A60E97 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:32920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgX2-0001w1-Qa for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:24:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgR8-00017h-Py; Fri, 27 Aug 2021 14:18:45 -0400 Received: from mail-db8eur05on2112.outbound.protection.outlook.com ([40.107.20.112]:12641 helo=EUR05-DB8-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 1mJgR7-0006Un-94; Fri, 27 Aug 2021 14:18:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ne77vVWV8BMtaRYwjgNgZkS7sP3Yg8h0Yae0wrBhaTYM680mkvyopExxo/EMmg4ofoE7tIDfYeTA3UZ2ZEJZEB606lbP0QxTkBSEAQWQ+1NJJch3Wi5Lfc4YffJMuhzIqukj2Ibgxs4eoOXpktSZ8mHy7l30ewfSqzp2/qNZO9JGVDa3Eac5fo7k0K0bWslnm1vxRRKEQBWFJXfCyhcfwLTBBaC6NVYrJRj9Vh1pI0lJtElUH2xL1yC5KAyUCeXVMVjWm+p/aaN5m/VpeMbj8zZaSOMxZ6E5o93Mok6WGxjPalNBqApvJsY34CqR++jNT1O9kjNXD3fdasnT3oX3GA== 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-SenderADCheck; bh=LQ755RN4B88us0Z35oknYvrIcdk7clEi9p4Po8f+mAo=; b=PeBZ6u7O42oQAEi6S5jyoMSqND771kjs1EYsZhYgnAtCR3EGmRa3RZJzeiZKneHrjVlNOC3I1VH7QA+X3drDM5+hn+g60HPbpc4JHylh31x95RakKD1vHJbOd/BdaV9UMyQhVMS9CE3Vb6FJuhhxI06MBvdmjVbt7HRC3/oz2SGLKh3LXFOKuvvp4vzNg/MIpDHwEzCs7fZFS51ZmB6ulrJsf54LndD2RWKFzhvzq7hRfCJL35Mo5On+EJPW1rWuchIQ24aBYYnNyP5tX48GHDYnhqDpCXS5r2R447PPo9PizM1DF1C7bac2rfRjZ3Iz8LTWmjy2bsQM3F88PGO7zQ== 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=LQ755RN4B88us0Z35oknYvrIcdk7clEi9p4Po8f+mAo=; b=EBzhvFeH5bdanM+Eqm6CGtDeYS2MRG9q2NI6/CxQ7m+r/gD3nTT71RDQnZwiVrOunxFLDqexc6mKKPQXWrNghm3ZZoVy1TTBgQPLHWKGzrFygtnSrrOdqr6iR4+4dMd6B3CAE7lb4/q5CBj0Ojznkx/xKOfymiH/tn7NUFhP7R8= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21; Fri, 27 Aug 2021 18:18:32 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:32 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 07/19] block/dirty-bitmap: introduce bdrv_dirty_bitmap_status() Date: Fri, 27 Aug 2021 21:17:56 +0300 Message-Id: <20210827181808.311670-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bdd46f94-a260-489f-7266-08d969871405 X-MS-TrafficTypeDiagnostic: AM6PR08MB3765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2089; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M1Mn1vZyUgtxxFJbmkFMBSzPySVVc7Slw4RPcbCrWUd/3+Q9+8qNdhB97QkVY8LrHmBw+eQyx6zq5EYbRKC/h6B9F6nz2aIoFM/ZFQmWOE8fy4ydybasbBqxPCfUK2gTbGXac+gFf55VWgz6S8mNcuZ1bl7r4cMFv57uRllTOT8vMChfWVaFmhL1uIgKU6GuxG6kZpGJkaLtSYILw5Rip0cl32wxP2800aV+tPdiBsXLsVggTReCxbAflryCuek7XUPuoWcz20CIfLqTseIblUMj+MwWm9v/wgfNomGh1soTo+MMYL98p6QO1zbHWjbZuWsgNQKFwomewcqAOj5iLFcf4h2oRJgByOBf9pUO4MGPT2Op7jNPrkKhjZoihO8PxnjpEXIPPFIegOL6NSL97lvPke1kbJejf0PprW5zjmMGZ38wPaVE0spV2ZL2wwESsaPL+OwvHPHj4H4qqqcfOzmvqKSqH2/a2hxkKQHWmc2dtWuVt6+NhEGu4lxlaKd2dtBGrDS6/sOlITezp8UrDWBzUv76dFYbnk4fSAGgfVyXl/wlYq9+s0PteMrACtUYVYW7YoXMD4M3KVgeClueEo//b+bNNRb2eyR1vDBvy6ZHvQNWcnOWUROaS4w4+iLm9bwhPFbMr8IyB2ifEnn4Q8jaMa7zA8dkB+WkfD5cRkQQwDTR6OIAQnYt36WXyq6Z3cqsP/ZEuKLYDeT+Bn/iuwvaknN/h21nq/rI04DpoSw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(366004)(136003)(346002)(396003)(52116002)(6486002)(1076003)(26005)(66946007)(66476007)(8936002)(6506007)(2616005)(38350700002)(38100700002)(956004)(5660300002)(86362001)(8676002)(186003)(6666004)(83380400001)(66556008)(6916009)(4326008)(6512007)(36756003)(2906002)(478600001)(316002)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4eiQ30fEc7TT0OJgkecBgeCHSNKHZGyLJUuPlb0M9h5lrJbPGBoT9UkBx9kxSVQW2dRZdZa/qIh/9NTMPYGK1KebthwTLiWMhrA6QJzjwbFcR9OfxiP5FbAm+kzQP4FTUpMGMkpQ2wkW2Uwf8n9tWdH/b2C9kS77/2vdXjUmLs/KguZUsp4PK4Gjun8Iv0oPeJ/Mt8X36c7ydAZEnS6Td7bqhZGK5Fw6s+huq9l9Jw4pdFhXYv8UR4RPMtVUDmyfcHC/GAABJcB/VFOi9cI2Y+/e5wWDjj7C9At0bME2ycpG7qoupmWQ8vVpb6E8z3CItFQVbPBbY38jHLwAtFaA9RkRxyVdXCfDTmr0oNPWKCOIkY0tuCCCmVPk35QW4w0faik0DsyX+cq2/sA6vItEU6Qln5MOw9+vvtax5D3xddyPim3DB4Ape/eF14qxgI69Z8IS1di+nK/fUYNVsYL/ubBKhIH6LRsTOpiNZJLig3rX6vv2TFDlcg8zP6BgWaORgPs1SfiOZkd9OpvE7ysDm+xAA9D1YsyRPGFj4mFKdCu9E/BKx1T0akh1NiwszjNsAe/gWh2jE7lt4KTtnkCo+1bpov6MRlXbTqh2zeHDB9eu0nQ9OX28srrMM0QkuxtY4TKojut/1Bj9NPj+gSO1Lzpyipa82yhqLvt/MFUeOLn9RtQ+NmAM/WmuF6qP4QiuJxQluAtRJ9rIarKAfTYzTCnBiGPfjt88MCv9HFJUiSWAC11VpFnmx4OrA8rMSf0bIyYHIqWyP1LyU4EaHQUB44bTbssITrXONGlC44d3snTM06hsQJe5TdXzc7dXalBnvQ3tl4XrkViZpGF38v1fxJDy/tvVpeYt99FAd0kaq7gNBZOSft/cSJxTWH3bhpr8wdhjsMb8aHuIrou+IdQ/dSTOFJGpYL0KRxo/aptte08wAzAFyuSXNNaoJY0NE8FE8N1bDezqdr/x+z4c40xaaaYadMIRVBByCUTmjBCTFnTUvW3rv8Gv94fNFgYr/+GzNdarmjSIWlkCoSOYi7t2LFt7J6tgbZEd7IzeCyLYkT6zm3Oq4bNtF30oiBsUg34HtEAa7ZNqh9t54HxI4w0E6pLSy34XW/dmxxkaMKy/Iekytlb40Cvw90Ip/N5WHBtSYSDoX/pzRHlmt/jg61046vVt1wDPzaHRbEMuljdbCyczPVAIBaVjEztLuR5zQwGYZHnNJDpEt342iBS7hecwQks97uliD0tpRjmV3vWOTn89PuusNQaerOxuY1jCxpWCiMf1WtLYXJuBdNnC+nx0Tl5v/RFNTph3vUyMeZA6ymsReCfFTgekRyBYcH6e0ucj X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: bdd46f94-a260-489f-7266-08d969871405 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:32.8153 (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: XCLxRx455g49L+pS6QlIgEVttt7cq5+4U+VrPYkbRDJp02CkHt39XlCRTSE38VrUC7AL7nHcZ7MbLU40FfTsWoBZI913iLa1pDzeGekg8GQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 Received-SPF: pass client-ip=40.107.20.112; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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 --- include/block/dirty-bitmap.h | 2 ++ include/qemu/hbitmap.h | 11 +++++++++++ block/dirty-bitmap.c | 6 ++++++ util/hbitmap.c | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index f95d350b70..2ae7dc3d1d 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); +void bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap, int64_t offset, + int64_t bytes, bool *is_dirty, 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..845fda12db 100644 --- a/include/qemu/hbitmap.h +++ b/include/qemu/hbitmap.h @@ -340,6 +340,17 @@ 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 offset to start from + * @end: end of requested area + * @is_dirty: is bitmap dirty at @offset + * @pnum: how many bits has same value starting from @offset + */ +void hbitmap_status(const HBitmap *hb, int64_t offset, int64_t bytes, + bool *is_dirty, 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..e4a836749a 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); } +void bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap, int64_t offset, + int64_t bytes, bool *is_dirty, int64_t *count) +{ + hbitmap_status(bitmap->bitmap, offset, bytes, is_dirty, 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..ae8d0eb4d2 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -301,6 +301,42 @@ bool hbitmap_next_dirty_area(const HBitmap *hb, int64_t start, int64_t end, return true; } +void hbitmap_status(const HBitmap *hb, int64_t start, int64_t count, + bool *is_dirty, 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; + *is_dirty = false; + return; + } + + if (next_dirty > start) { + *pnum = next_dirty - start; + *is_dirty = false; + return; + } + + assert(next_dirty == start); + + next_zero = hbitmap_next_zero(hb, start, count); + if (next_zero == -1) { + *pnum = count; + *is_dirty = true; + return; + } + + assert(next_zero > start); + *pnum = next_zero - start; + *is_dirty = false; +} + bool hbitmap_empty(const HBitmap *hb) { return hb->count == 0; From patchwork Fri Aug 27 18:17:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462663 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77DA4C432BE for ; Fri, 27 Aug 2021 18:38:03 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1ADD760FC4 for ; Fri, 27 Aug 2021 18:38:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1ADD760FC4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:58084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgjp-0002ch-1T for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:38:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRK-0001E5-J3; Fri, 27 Aug 2021 14:18:55 -0400 Received: from mail-eopbgr20112.outbound.protection.outlook.com ([40.107.2.112]:14422 helo=EUR02-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRI-0006cC-RM; Fri, 27 Aug 2021 14:18:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F7XO9R2IisyXty9YWiTpTjtOl+AUlnGuBznSXZN3R5sbTc4H91Q78AFk6uKVR01LESWnxd1+zoNk8iW4AIrsSJW4OxUw7vqgggEMdc2mTY1CaHIY5mSY8LLe4K79N5cVtJjSOFj4giTQWwT0Iuos2aKwve4azZjssJdiJtwWYRY32fD6iGo4y+CdDn7RzsBL7j63l+enxi8HXwb+jKVX+/2vzEyW/tzQaK3DIo/7+SfATWzM4O4ZozNBSP2NgKWtYEppe5nHNSL1E2HArAQUJJyy0W+zft0N1/XESmBBJs9UbRXwncVJngEJYcfyfHYlfIlCE/VAeJQDs+EZOZ4MPg== 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-SenderADCheck; bh=M+RpOKe79nwzKYG49VUEqSLmaamzBSZo+oefqE94tPI=; b=R8xOtkAvqCJG8xlRkRPmxAc+F9D35qHsbg9UCfgmpy4U8JO1lNDmzYrgnpOgEM3XFkOmjDXJ3rw4Gw3sk2uMNT/gGLV9YSu6XVmHMypJLeL827Ye8D9gpVekMc/J6g6FKiwhdi8Er5F2svE4BEnDk4BOPx8oJ6T+YLJR4vcuobdc21sTXf/D3GbFAHnGqgbW3IcH6fPzeeHQ4933aaPwjeV8CpBWHKbqdKF1nxAFmwHkj1YmMCRfutG+vQJvR8jxYZiFTthIX6/3cK1wnlebspdpRqSZ2altD7PhTUCqHrCWJC2P19o2XVvQgdwMybGAj7WF5yvNJI0XXquG2TXcmg== 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=M+RpOKe79nwzKYG49VUEqSLmaamzBSZo+oefqE94tPI=; b=k0n8SCSMUP4AfD9PKQuH+jcvRx+wb27Cxaip81ukndNurEJsozPORRpkRrhYuPXtTvsakX6nbGn/5sDmcMeoj1uw6p+kxkWgBpEmuvjeJMSf6XU4hJXWvmiljREIfSnjwkH85p6crD+o2FkktXh/dqFHwramHqp3A8mVUbCEsD8= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21; Fri, 27 Aug 2021 18:18:34 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:34 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 08/19] block/reqlist: add reqlist_wait_all() Date: Fri, 27 Aug 2021 21:17:57 +0300 Message-Id: <20210827181808.311670-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cbc627e7-ac62-497f-591c-08d9698714c3 X-MS-TrafficTypeDiagnostic: AM6PR08MB3765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:411; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6s1BQbbR5m0+5b/GjEho4bbHlSrRQVLMVDDLHyoFY5UWox8oaCjtxyOKSn3/SeZQmLvTumeCJhUuxJ298p7DpYeZeh0yPllhIFCOOLa3UxpnJZyW7MlrCReY35DhLHwBdDTG/5hDTDwMDsLSgyWX0yUZYT55/HaL+575CkYnaL/fBdpHPxWyl+h2M287lce0yjCGkiV7agFl3e0WuxP7TxrwL3Hllre0CcU7lTgmZIDz+jLUcbQlvvngaWxvbduV+jVQyf1vdV10j+vNKvWmfIqsvUxZcCTtNL3cLGbHz36K3WPjS1EVQ++99QFvdWZnG83O5COlNfVtlA1w3kvqbI9akcCmgmwdGHPARtKwrc7+acdsofRL0SgYTzB9VJvQ4L6iNSJFPVKM82d6+Cqw4Z6mLEutssrUEjQxIYmEqsrjFgV/WHhUhrfhCQPA9+O84LmiUFPjjlEfgXW6yJ+cl65s0O1F2n8K1LbLHbtOw24hDbMWhR1jPkJqI4RhqeTIJ9q3YVOklu8zYQJlDhxPk5At2grZLUrkQ/2peVqyALp5Xm0IH9l6CPElbBHgbw2uw9K4I8jh8iThcHo0tvGSxSY6HhpVK7pWGhP9LDGt2fBHDGCobR71XorEuH0zKQhLEuAu0J0se+0wMLt4uJfblH5SePhUlYgiOVxZ4UKVOsRY6kfH9MNBptVGF59vbj1ng/3LubCokr46a9c6lT2k+w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(366004)(136003)(346002)(396003)(52116002)(6486002)(1076003)(26005)(66946007)(66476007)(8936002)(6506007)(2616005)(38350700002)(38100700002)(956004)(5660300002)(86362001)(8676002)(186003)(6666004)(83380400001)(66556008)(6916009)(4326008)(6512007)(36756003)(2906002)(478600001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1nTcRI7DKVZJX8mGqiX4RsOloHOtE3wyU+Sm/xuNvPQw/aCb0+MzzGkCkiwKhSPncCMeK/0KYgYv8y3eS0g3Yp7v0xgQa4C1M+lgwQitxH4/W4OUwfN5/0JU2csK6ntRcOuIFduLpj0SKvJjqG05Ag7ZMPKWiZGcyNfFWJ7NAud49fuVeZ4Mfx4NUgAArTY9rLUROdZlLbRQXSsvKsJJfD36wcDimdH0ja4KM3fVCe3dQSG09q1NMt3Bfj+nRZpHex9DEP6VVxGKr313DXt6xEK+KiSFsDvAB2h3TfwagGPIyKdmUkjaMRHoFwcpFlYzgIw+uFPKYWSZ+IEafUg9xZsZboj1hzFWZGpoovLtbgjnH4V5wGVGciXzj4BmqtGoyWGnF35ylmK7xWWol0iDJ/pGU9w52Z5Anue2TcZoKQg6e1Y16syQZuaSEPAUWTOgTkQEZD8Iazv910tBuCHJBJFivpbhmibR6PJV6Ey091lZeWqhnLQra0ruVbmVeF9t2K0ESR0JGC4Aa0RcPvtL4MHiahYE28DlN7yy7TU8Kv9lQiHVwnySeZKOtmT0Ox6RxpYVcJb7aODMMVRWdowSNQnsXfH3KvYchJkjKWaPA3AhpPKvSBdXRs98bIHSXFwJoL8G3bxJonERiJ6bapyz4l7DJukVOvj8RnNioyPoC+9Hpvh1HFYdoX8KQNmvZ7qkgQ3Gcilka7ZQCauC0fn+d6Sxs6KyFgtGiYUIJ+tzaVKGM5oZwOK0D4He2NWoaX3Y1oMYNXjSsPFPGEG6DE3MbnTZ1Zna0tYz7NhEDQWOfzWV7rtUo5gNRtDN3A87Epc/NtORyqx+pZQjOzmhNJiuyXz6y3gSOy+WglmMrs4rbffZSKSXQygGg5S+cYGjW6AWrJBQe9/vr7fLLVYR2xMkrM/IrmxBYLOEuJBQ32WCQKSuOE1O66LJbQWDoL14APVo58fP3/9bOtRfxt0wav69lS1uiZXJnWmjN7z+uxLp2OiTR99Ukcq92zFvkcuD6O4oSvd1i9pRdh+6F4Ygh6ZCV9ZyoGgoFiPuxG0nIUrlL/qv57Rksf9V+kLoCWdBsEWYOgmIkhf4wQ9ZsCy7Wt1a2wt28OHrVkyFfCOwFsB8DtjB+jPf3cNlpxqIVzJ62SHuWiMNwcn/Tv/wckxzAYnTvcKwkUc0xmDvULKQwusu/lxiGKgxEJxHwY3UoT9DD0o+nCDFPlmCU0+Yg9K3ipFYoG13duNJeJFwRBmbcvgx7hI/H0Eg94un/3KvxvJ7ALErrCe9NJ7pZSdXAhZQq/lTXvScP8EhvSQDdAMmBebTHNO+LNLR7iLlnC1XVUb1Mk5b X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbc627e7-ac62-497f-591c-08d9698714c3 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:34.0808 (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: u4Z7sFVqnDVpQ1kgwA9xKfGpSWpm3gKuhJWsmpcTa6fQwdKxHtQnHB5hqCfL48QgNEr6ICavzVZhLooggPCy34gf8A2hf3nXOlKE1E3q/Kg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 Received-SPF: pass client-ip=40.107.2.112; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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 --- 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 b904d80216..4695623bb3 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 + * loops, 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 (may be some of them are not * intersecting with shrunk request). diff --git a/block/reqlist.c b/block/reqlist.c index 5e320ba649..52a362a1d8 100644 --- a/block/reqlist.c +++ b/block/reqlist.c @@ -57,6 +57,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 Fri Aug 27 18:17:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01FB0C432BE for ; Fri, 27 Aug 2021 18:33:32 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5A82A60F6C for ; Fri, 27 Aug 2021 18:33:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5A82A60F6C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:51138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgfS-0005yW-4Z for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:33:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRF-0001BO-My; Fri, 27 Aug 2021 14:18:51 -0400 Received: from mail-eopbgr20117.outbound.protection.outlook.com ([40.107.2.117]:18413 helo=EUR02-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRB-0006di-1T; Fri, 27 Aug 2021 14:18:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I0yxyR0zVLJbGt+uuws7sqlIfmZkM8OyDh/i/bkHpCaq0uVs/0N/ap5pwMW/3YJw1B3bk/7Jta/pVkksefW8++v7b9kwunVwFN7wzvynTHd48O5Se8Lpv9qrvqwU+iYuBfMy09S0ktez9Be+U9x7S64aMmyWSMd8DnqYc+YXvwOpZ/Ost0I6WvxlI2LEnDTfU6Te/NHrD+ZcZmqkVjkk5d3heCEy1wWlJ4uCQV7P2gKvqMV5sP1TfmxFQfmAjQIcf7ZrbM095k5c4SZXgqHsStqlQ7913Eh7WjMjxdS5HfpxjxgA51xjJDyTPpu5I+sdNHtLpxYluPFcg6i1EBLNEQ== 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-SenderADCheck; bh=txiEbjPgLG7Kzqjy98pe9im+U38ZNZeQcV4HP1w5oPs=; b=TVOuCcnmXFijIS6Mrjl2WBu/yQ38hXo7dRpe9/kriNEXJ37MMkk80mwVF5m8u2MfdhkGyu5nu+nSFZ7nXqpE1Z1rVN7Bb73i/cv3Qd4tSuIJGN/4qFJvmaokaR8NKIzv3Gsx4SzoLVpA3yWBwQ8jOddhfq5aImTWZ18k28+4eoaWVsqspi/MqagkQQjRcyZcckWq/MU9COMbBrCt8XYTsSMuZOB+FfbJm/vy29z9WlBA8RkO8gOa1XjtxDRrxsdACzVEoroIfYf+6T7h+fe+r/MFNTzI3IgnA7LNL/WMKpS17yaj2EX3UU4QGpkglL9ILYktj3MPyA2IDR0/ZrNJZA== 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=txiEbjPgLG7Kzqjy98pe9im+U38ZNZeQcV4HP1w5oPs=; b=o1ec+z6y6mV13kx9Fx6BN+IqTIj3P7ohErlS2+ur7jhQMhQoj3wh9xP8nVsp1PiG6LDhm2mBiTnCqOtAIZGkYaVeJfAR0fEZa0k/GTsgtQ0idQzc4uePCJkKPW+oMz1Fv73JDRH2BC9WQHz3hKFAW67Qa2CLF1FBWOPU6YiIcZA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21; Fri, 27 Aug 2021 18:18:35 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:35 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 09/19] block: introduce FleecingState class Date: Fri, 27 Aug 2021 21:17:58 +0300 Message-Id: <20210827181808.311670-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 92de3920-08c5-4fa9-909c-08d96987157a X-MS-TrafficTypeDiagnostic: AM6PR08MB3765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6E51eO5NRgss9rYwuTD8MfGd0jvgtaHIB4MlH7/GAYBD8PkWNBcG8iJ5ueyKlSvrzc3HkwLV6IDnPt419E+4S6XhNNW+3VrX78HZcYKCW/DSIiYS2DWPwH/QLtheFUN/rJjkbWRy7fFNJmTkGtCIbHA+G3CLPnpm8T0Q+1TF5DaC3nYz38PJuVaCAonPDNFlLeMhQ/82+p6LWVXCjdJwhkbzgYziNgcBl3zfPAUHz5sh1UZyjuC871dZAwmyW723Defh9+oD+dXojXlv7YICwMGpaBC/jov3bUf64BjgBVqc5T/49647WMowpOLwnMN5g0R9EzxSyUMkS8ZI2rCw+ihypRDPTyQQ3r9P7feTxnERj0w+WmDMre26ki9UsZV3FiDIjnsYQ+VzBOzd96cB1VsAqeRITMf8ab1DWROJybSeaMQ/rJKhCdswwPCAglbgheaq6pEigwk1B0VfoBpgFdtbadne7QDpPsWMPrMyLoGs3rIOc/nnl9m0/kjMjJgwigdMaavAFMcamqBmN+UlOH1VCnFQJ3cMdVNyz5TbWxdFrYKPpMp/a0cHNQjHgj+llct+kknA+Y/biLosmPNVfxT+V4QF/FXIxKRwwAGkREz2xHOGMNiBE6Ld6WuJqsc+sRtH/CEFwATa5gB6euQ+FewmGTuVRTNNIaCCZ4OfRe84uU4pyxAAkkBIVKlyjnuizEL7MG0eME6D0lec/R26ts0rE3YQDfdpCRtmgPQQem832/CEp4EQge1zlK29Eyj5gUbjP+wrURoVvhPFt68K2J2YmypOK0QoritpJ0gjdKA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(366004)(136003)(346002)(396003)(52116002)(6486002)(1076003)(26005)(66946007)(66476007)(8936002)(6506007)(30864003)(2616005)(38350700002)(38100700002)(956004)(5660300002)(86362001)(8676002)(186003)(6666004)(83380400001)(66556008)(6916009)(4326008)(6512007)(36756003)(2906002)(478600001)(316002)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vq4Qp6E1aWVCeETO19enKBN7gqs7frMB6Dkjm2udAkhkaDnEvwZ9mSC01dIF7laNNJSpdyDG/uWHcInI3oovTNyoxXDG2Af8a/GEI5MIV8/R2Jttu9c2A9M7BIGGAWIF2UVJWZ2drMen7ZGmoaeLhToGbONF11QRsPMlBRCrGkVoAFwvHC0quLQOIGOrAqOkCoAQODNtS7O57GModI5Im92ihUvlUGXH4UbRx6z4m+TGsU3X7S3AjITZPt8NH0zNJ8+f+ivLBv781xktdLyE3nCizLXwEKWwr9bX+8oLkjZ3UjkXTWxVpAnMyQe+nqB1G4vjdNvrTpSiXaWW9tWoXbARAYFBKzkn5YrBaP0nOMeB/qxgCw+j5YhJUd9oWruF8s5imzWch6lw4JvX4mu0ofxfvSQLFj3qiCuCl09dfb8277lTIuviBerRYbmbv88CmDh40SrbtoseNlOwNk1LIick2cBi70BXgiBFlCO76sbLPLZ8ck2SSYjSBsr7EOWGW+I5ESH2EZV9+fcaV7M5XCLSRRh8gJOG5JzZILPqf5hIDcG377/+SrXfdtrxu4wbsHxaYOzBKxJOjO5OOyA6Yt/+jwUM8188L9I761odQrYTviBec+tBcRHnSDmiTpHqf2smnQ4c8P/UlwHKHSBcqSDcVT+29UBMyryMuo0MJ01Lidbc6Gp/xBrgh+SMUfKTms/C/BZfdZBbKyMdzGocOEqIMqd7HM/HPxQAQvLSm54w6Y+BKObp8kUyACTc5aJ/zkiFjlbXqiyLXFndRKj7n+G6TXkoGyZ/myUgJXaB4YCgoFqq7xzmhDn1z7kpZhAdGbfxMHI/B4lQxHLweqZAdFYlyPJtkdpVgh4+IlYJaVAS12fOmkSed+eT8zJKErX5rzJlIB1ZXAiJqk4phja2RKXRsTU1JZ9Unuyg2nAVHTo6VazD1S9nH6qJRdTHiNcR9Sv6/1zx/0XykhFAdCS4T/WsDQ4fzjlDL4qDXhwZIZK5zYShokfYc+OTI29EXNk2rNtrdwKAuq5IQeCK6v06zLUR8sDYYZqTXdvQIKus+Fzw+A0X+L8VZVjq3BbvhKefuv7Oq5VYG9rmq+bX0A78FRqEm8gaTbAg2LUsSXSvLgmlkwn6odlV5PgVsfpMmjCDUexOqUmLr4QgdMiCUgrQo8m7uyoAfdf25rRjn5UistoPKm1iBNCZwgbN30JNVnwJsHg8bHWw7dtLNEAQZOLyBFhEg0r+da4ly2ieNqslaGE2D1oeOMuMPh7SNgGXrX6vCZdu7AmYUrp2RkDeFejTh+8mpmWL63YpleYtJKi+N/n0uQB8dBRgWj40/KQjFh4o X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 92de3920-08c5-4fa9-909c-08d96987157a X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:35.2895 (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: 4W7qnxy8eKtq7K2kppxoGMINxHeA6OwV3BDSwHAZ9lnwkyAYGYp7LHu4vCJmJryYOnRQYVVwr8+wt5oOaPia+DO9j24Vhh4AS/AQeF9miOs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 Received-SPF: pass client-ip=40.107.2.117; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" FleecingState represents state shared between copy-before-write filter and upcoming fleecing block driver. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/fleecing.h | 135 ++++++++++++++++++++++++++++++++++ block/fleecing.c | 182 ++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 2 + block/meson.build | 1 + 4 files changed, 320 insertions(+) create mode 100644 block/fleecing.h create mode 100644 block/fleecing.c diff --git a/block/fleecing.h b/block/fleecing.h new file mode 100644 index 0000000000..fb7b2f86c4 --- /dev/null +++ b/block/fleecing.h @@ -0,0 +1,135 @@ +/* + * FleecingState + * + * The common state of image fleecing, shared between copy-before-write filter + * and fleecing block driver. + * + * Copyright (c) 2021 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 . + * + * + * Fleecing scheme looks as follows: + * + * [guest blk] [nbd export] + * | | + * |root | + * v v + * [copy-before-write]--target-->[fleecing drv] + * | / | + * |file / |file + * v / v + * [active disk]<--source-----/ [temp disk] + * + * Note that "active disk" is also called just "source" and "temp disk" is also + * called "target". + * + * What happens here: + * + * copy-before-write filter performs copy-before-write operations: on guest + * write we should copy old data to target child before rewriting. Note that we + * write this data through fleecing driver: it saves a possibility to implement + * a kind of cache in fleecing driver in future. + * + * Fleecing user is nbd export: it can read from fleecing node, which guarantees + * a snapshot-view for fleecing user. Fleecing user may also do discard + * operations. + * + * FleecingState is responsible for most of the fleecing logic: + * + * 1. Fleecing read. Handle reads of fleecing user: we should decide where from + * to read, from source node or from copy-before-write target node. In former + * case we need to synchronize with guest writes. See fleecing_read_lock() and + * fleecing_read_unlock() functionality. + * + * 2. Guest write synchronization (part of [1] actually). See + * fleecing_mark_done_and_wait_readers() + * + * 3. Fleecing discard. Used by fleecing user when corresponding area is already + * copied. Fleecing user may discard the area which is not needed anymore, that + * should result in: + * - discarding data to free disk space + * - clear bits in copy-bitmap of block-copy, to avoid extra copy-before-write + * operations + * - clear bits in access-bitmap of FleecingState, to avoid further wrong + * access + * + * Still, FleecingState doesn't own any block children, so all real io + * operations (reads, writes and discards) are done by copy-before-write filter + * and fleecing block driver. + */ + +#ifndef FLEECING_H +#define FLEECING_H + +#include "block/block_int.h" +#include "block/block-copy.h" +#include "block/reqlist.h" + +typedef struct FleecingState FleecingState; + +/* + * Create FleecingState. + * + * @bcs: link to block-copy owned by copy-before-write filter. + * + * @fleecing_node: should be fleecing block driver node. Used to create some + * bitmaps in it. + */ +FleecingState *fleecing_new(BlockCopyState *bcs, + BlockDriverState *fleecing_node, + Error **errp); + +/* Free the state. Doesn't free block-copy state (@bcs) */ +void fleecing_free(FleecingState *s); + +/* + * Convenient function for thous who want to do fleecing read. + * + * If requested region starts in "done" area, i.e. data is already copied to + * copy-before-write target node, req is set to NULL, pnum is set to available + * bytes to read from target. User is free to read @pnum bytes from target. + * Still, user is responsible for concurrent discards on target. + * + * If requests region starts in "not done" area, i.e. we have to read from + * source node directly, than @pnum bytes of source node are frozen and + * guaranteed not be rewritten until user calls cbw_snapshot_read_unlock(). + * + * Returns 0 on success and -EACCES when try to read non-dirty area of + * access_bitmap. + */ +int fleecing_read_lock(FleecingState *f, int64_t offset, + int64_t bytes, const BlockReq **req, int64_t *pnum); +/* Called as closing pair for fleecing_read_lock() */ +void fleecing_read_unlock(FleecingState *f, const BlockReq *req); + +/* + * Called when fleecing user doesn't need the region anymore (for example the + * region is successfully read and backed up somewhere). + * This prevents extra copy-before-write operations in this area in future. + * Next fleecing read from this area will fail with -EACCES. + */ +void fleecing_discard(FleecingState *f, int64_t offset, int64_t bytes); + +/* + * Called by copy-before-write filter after successful copy-before-write + * operation to synchronize with parallel fleecing reads. + */ +void fleecing_mark_done_and_wait_readers(FleecingState *f, int64_t offset, + int64_t bytes); + +#endif /* FLEECING_H */ diff --git a/block/fleecing.c b/block/fleecing.c new file mode 100644 index 0000000000..f75d11b892 --- /dev/null +++ b/block/fleecing.c @@ -0,0 +1,182 @@ +/* + * FleecingState + * + * The common state of image fleecing, shared between copy-before-write filter + * and fleecing block driver. + * + * Copyright (c) 2021 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 "qapi/error.h" +#include "block/block_int.h" +#include "block/coroutines.h" +#include "block/qdict.h" +#include "block/block-copy.h" +#include "block/reqlist.h" + +#include "block/fleecing.h" + +/* + * @bcs: link to block-copy state owned by copy-before-write filter which + * performs copy-before-write operations in context of fleecing scheme. + * FleecingState doesn't own the block-copy state and don't free it on cleanup. + * + * @lock: protects access to @access_bitmap, @done_bitmap and @frozen_read_reqs + * + * @access_bitmap: represents areas allowed for reading by fleecing user. + * Reading from non-dirty areas leads to -EACCES. Discard operation among other + * things clears corresponding bits in this bitmaps. + * + * @done_bitmap: represents areas that was successfully copied by + * copy-before-write operations. So, for dirty areas fleecing user should read + * from target node and for clear areas - from source node. + * + * @frozen_read_reqs: current read requests for fleecing user in source node. + * corresponding areas must not be rewritten by guest. + */ +typedef struct FleecingState { + BlockCopyState *bcs; + + CoMutex lock; + + BdrvDirtyBitmap *access_bitmap; + BdrvDirtyBitmap *done_bitmap; + + BlockReqList frozen_read_reqs; +} FleecingState; + +FleecingState *fleecing_new(BlockCopyState *bcs, + BlockDriverState *fleecing_node, + Error **errp) +{ + BdrvDirtyBitmap *bcs_bitmap = block_copy_dirty_bitmap(bcs), + *done_bitmap, *access_bitmap; + int64_t cluster_size = block_copy_cluster_size(bcs); + FleecingState *s; + + /* done_bitmap starts empty */ + done_bitmap = bdrv_create_dirty_bitmap(fleecing_node, cluster_size, NULL, + errp); + if (!done_bitmap) { + return NULL; + } + bdrv_disable_dirty_bitmap(done_bitmap); + + /* access_bitmap starts equal to bcs_bitmap */ + access_bitmap = bdrv_create_dirty_bitmap(fleecing_node, cluster_size, NULL, + errp); + if (!access_bitmap) { + return NULL; + } + bdrv_disable_dirty_bitmap(access_bitmap); + if (!bdrv_dirty_bitmap_merge_internal(access_bitmap, bcs_bitmap, + NULL, true)) + { + return NULL; + } + + s = g_new(FleecingState, 1); + *s = (FleecingState) { + .bcs = bcs, + .done_bitmap = done_bitmap, + .access_bitmap = access_bitmap, + }; + qemu_co_mutex_init(&s->lock); + QLIST_INIT(&s->frozen_read_reqs); + + return s; +} + +void fleecing_free(FleecingState *s) +{ + if (!s) { + return; + } + + bdrv_release_dirty_bitmap(s->access_bitmap); + bdrv_release_dirty_bitmap(s->done_bitmap); + g_free(s); +} + +static BlockReq *add_read_req(FleecingState *s, uint64_t offset, uint64_t bytes) +{ + BlockReq *req = g_new(BlockReq, 1); + + reqlist_init_req(&s->frozen_read_reqs, req, offset, bytes); + + return req; +} + +static void drop_read_req(BlockReq *req) +{ + reqlist_remove_req(req); + g_free(req); +} + +int fleecing_read_lock(FleecingState *s, int64_t offset, + int64_t bytes, const BlockReq **req, + int64_t *pnum) +{ + bool done; + + QEMU_LOCK_GUARD(&s->lock); + + if (bdrv_dirty_bitmap_next_zero(s->access_bitmap, offset, bytes) != -1) { + return -EACCES; + } + + bdrv_dirty_bitmap_status(s->done_bitmap, offset, bytes, &done, pnum); + if (!done) { + *req = add_read_req(s, offset, *pnum); + } + + return 0; +} + +void fleecing_read_unlock(FleecingState *s, const BlockReq *req) +{ + QEMU_LOCK_GUARD(&s->lock); + + drop_read_req((BlockReq *)req); +} + +void fleecing_discard(FleecingState *s, int64_t offset, int64_t bytes) +{ + WITH_QEMU_LOCK_GUARD(&s->lock) { + bdrv_reset_dirty_bitmap(s->access_bitmap, offset, bytes); + } + + block_copy_reset(s->bcs, offset, bytes); +} + +void fleecing_mark_done_and_wait_readers(FleecingState *s, int64_t offset, + int64_t bytes) +{ + assert(QEMU_IS_ALIGNED(offset, block_copy_cluster_size(s->bcs))); + assert(QEMU_IS_ALIGNED(bytes, block_copy_cluster_size(s->bcs))); + + WITH_QEMU_LOCK_GUARD(&s->lock) { + bdrv_set_dirty_bitmap(s->done_bitmap, offset, bytes); + reqlist_wait_all(&s->frozen_read_reqs, offset, bytes, &s->lock); + } +} diff --git a/MAINTAINERS b/MAINTAINERS index 2d58170224..20f3c7eb68 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2341,6 +2341,8 @@ F: block/reqlist.c F: include/block/reqlist.h F: block/copy-before-write.h F: block/copy-before-write.c +F: block/fleecing.h +F: block/fleecing.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 c630e9374a..caa52f49c2 100644 --- a/block/meson.build +++ b/block/meson.build @@ -18,6 +18,7 @@ block_ss.add(files( 'crypto.c', 'dirty-bitmap.c', 'filter-compress.c', + 'fleecing.c', 'io.c', 'mirror.c', 'nbd.c', From patchwork Fri Aug 27 18:17:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36AE4C4320A for ; Fri, 27 Aug 2021 18:38:27 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id AB5C860FE6 for ; Fri, 27 Aug 2021 18:38:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AB5C860FE6 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:59020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgkD-0003G2-Uj for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:38:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRF-0001BJ-M9; Fri, 27 Aug 2021 14:18:51 -0400 Received: from mail-eopbgr20112.outbound.protection.outlook.com ([40.107.2.112]:14422 helo=EUR02-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRC-0006cC-EF; Fri, 27 Aug 2021 14:18:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HyLPI4N8xEhpApHIv95j/A32G50ejmDwK2Avc2GY0B6DZJoEf3QTozZMGCvzHJk9tulYHcy7dwVPBiAqyIRRQJQaGjyXNz0dFDZkyrkQx63578miO9ypXSmXQBY0ioK0YZHToMAf/y5IA6gY3s6g199Jz6hxl2GtvY0JCsJ3lG6Cye8H8+nUhCBsMuhEGNMoEj3VLB4/JfKHvhX0FAjRl0qReyk3lxJ6yPhsjSa87f/P3RjyFKGhH8pbJOplGSH2yx4tlH7oWOpxCKQSfSbE39rfc+3Fg4bGTglDwvnlcqs6T5oj4iptolET9u7Ph75HgE6f2DAWUTiAKAuFNNQUQg== 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-SenderADCheck; bh=dJwsSMpxre8rPTk3/yhoKFut5BoKBXJ29NtDUk3IrbQ=; b=bUisssrH+5b9euRSt2SabgJtVVINHI5oyHpb9pMk/Anr1GQ+vBztX9SC2sC3Bwy0TANvVqiBUd9+t7VWo11hDXxTl5Ohm7EzRkuUQ9HuE+/59Q/Tgc1LGpqiWXdAmmn12LE2un4cLfhKTVCiLBnq7TRh5OUStdsr7X1NZvLVJAF1WI3LBKRSDPAVQpZdRQDXeBYGxR8z/PRNuHvXTgy7QbwUaNTwQCKpwKBu4GHWiC74R6g4thvVaM1kjqkc5Evxq7IemJyskHE0v3QIUQ2MT3jMlxRjaKZ9XW5z+B/ZwrwlrYvi/t5SWuKTDdS+kiY1yqR6GGzn5X6IfaVSaLYEMQ== 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=dJwsSMpxre8rPTk3/yhoKFut5BoKBXJ29NtDUk3IrbQ=; b=P2FjsiiBZWP85+QZ8voQSzKD4IkHQEUNsZenDbuhEXKsimLRv3ERTmpzkrgk2bt7qD3QHeZ5wEhYXEQrM30Z7W173gE1/s4/Ltj+iMD7GfZE4bLyOXqCBNCjpy7WUIZAbTKbWCYtYUZKFMijSfzlIXJZtA2YKgZlqXjlXgvNY2Q= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21; Fri, 27 Aug 2021 18:18:36 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:36 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 10/19] block: introduce fleecing block driver Date: Fri, 27 Aug 2021 21:17:59 +0300 Message-Id: <20210827181808.311670-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 517fddc0-e93f-4e00-c88a-08d96987163d X-MS-TrafficTypeDiagnostic: AM6PR08MB3765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w7huqST5nElVG5M8VXK2o59dzKJ9nuLIPUga6iJ6cx6OKNxru2gH6vYR5X45pPcPWLjoa7+Bf0lcsuHMfD63148COPlsP5S5Ki39fmOqPL/KDpi2A4soHmx+P+m7HXnjdUCzAvZh9Zmrq7K5umpJuPP8OcSxgra9iLR9tp+wt62Mb/U7wwpOkvjsWzQd/Odlt4SOxFOb9FmVjn2v5VQz4j+3A19JVv08kB4BmThf3e0BYC+as1RPOXL8GgTKoGmmRHQgOawWpI7J9x6Ctcl6A5p4PeVb7Ko4x288ZWjqOvJ40+YJTR2fJcx28XF3GgPkGlgDbXfzYiQglU5h/1WOH2FmwDYJnEE3HxfQ0bUj2SyJC1QJg+ZSkE+kBOe+kylgMnKstjIcv9bAE8+CyYsCP8fjz1NmmLwNKDpztiozcEzO81RkXS358CNdw/gtffWGXbc90+3ZXHN4SDjp8jBynT1QpB6SNWs5Z5b8SubJNvWqUg6+4I3qljqs9na9SPKJYAZcmsx+nMwzmZGofLz1jYwaI2TTgKINowPdHHb5l/uKJLjwML7Fm0k0yGUVxu6DKjt2cQnBf1kTRdu6LM8ZAY3qkmuoY524beDD5v41VNNHd8t/npAdH4E0xsNURlMEnpETVanqyqtauX2XZVjfYDQSlRBV9qbu6pYysQDMmn+a6/2eKg+HPtCHEgQ4dDpbraB0qqurjKNraDeppflvy2+4wucpZN7qL5EGc/mzk1JbMYUht/KN2TjA5o098aGBrmSerhQbYUgBjoDrXRSDlkZfHCfnmOte7FU3c0sOFfc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(366004)(136003)(346002)(396003)(52116002)(6486002)(1076003)(26005)(66946007)(66476007)(8936002)(6506007)(30864003)(2616005)(38350700002)(38100700002)(956004)(5660300002)(86362001)(8676002)(186003)(6666004)(83380400001)(66556008)(6916009)(4326008)(6512007)(36756003)(2906002)(478600001)(316002)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8QVyUH1g8R8ucLIavxX2uxMUh4PVoNCpzv/TkqwAlWtTdpze2uuUWejQFTrmym3f52Dq+UqsLKvZ3b4bB2jgHFbObXsgvEqAxqVQYdFyfg3qMSpbNGNOBxy6Wh0eHnEwIWOO3GgKL3x2o04UysRWMVSKH5bF1NX/QfAtFCqXspH8H+K33cIY4HnfH5VINu4Zvo3tfUKJZlQIHHmOOqVtWZDr1yAuoWjoAaK8SaveNI02dGvh3JN75gOU4rh/bw+dP2Mg8vdoPufe1DdGSDrspSdiCRQcHunAPHHS3X8dE4RTKLSraApplrF45gHYlrUvVtS63lHyZvofLS/j8utNAik1IKkRU6blGzfoqsnnDExpbr558oNLoCQPu1rYLOso2wSVQEh3wMKt+LeLz++XMm9nNKrOX8TJPeId5BRyJjWcMR/87WFgYSo8AnNLNycImzJpNHBXuI4jvl4Dm3QOn0Rcz9eCAyQKnLX5qgWYSUFxSzBl5UUi4x34fSwGRI1HNIjVZXdrHJZy9DGxWR0unTJcqA4XlkBHGE4lIhznPA+UoOMa+6qrQwA4suw5knPy8iOl/HA9+iYag0DE0aXOQ5owHsk7ougqREG0WX3Gc+qvPtcZeBkRLsmqPInbUhsR3LzmemPWJPHexEBW4pPxUJfGI8pVtr63QUrXDcV+7may2yZ4Ho+1XF/H8nQqARkhTIa6/CcJlzbYV/Qbd3ZojnfekWVumb+eCd/NIg3lzyuaMmh/qOJajAPtDais0HQlsWBQNR9JsFmc4Uv7NOg9VJgBlNr3s5F+HdokYasPN5AYsSw26CCxkoHHW1ISEdzdvFu+sknPfn7l4YWWCLDlrwgCrNo0uM2BfOo1EfmXiEyJRkVX9URNkIGnv5RRe/h/q5wzpsreSvXKPe0GlCPVD8s0Jp2STDb5XCpxkV4PcmQGwa7/a3+QcXCwpcAITSUHrTbcrEDRWTa1wA7ExgOlOh7OSVuso8miHe6bvd5E4mqMk+VU0DOhMfgRT3BOyazfGFT5n8ZIQaxmKlfMayCjDMIUY9Nqf4851vf2hRu/9pDFevUQcVcLCZsUWyePP0DR5LBb3BTNNpG1gbJwW5jdRWktVrS1hVnFXvq3QjO4pL3a8vgue5LHHhRh+CIqHVIY93L4SF/vJxSOdU5XFT4HvEWP/RGHLrt32qtBso+eIG1pCSsoAmz8BtFEZvpDKcm8QMHrnisDqG+XcG+PTPgFMUtnD9v5B4il5bKVfOrzbaz2WHXeBlde7feadt5TM8RBYJRj8F8OEo60VUcNZYu6jBYnibNsFn20+sq1BhD3Jeg0uCGPJrnrmkLIL5gM6Tqt X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 517fddc0-e93f-4e00-c88a-08d96987163d X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:36.6555 (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: Zbmxs4UW50gYRFGJPicVk56HAUE637ptatb1/QA0NT9+92ZxyKHP3fjKEeCuq1dp0/jzIBq/ul79saSMtBkSb/hPyTisd7ECLeKAmgmWssw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 Received-SPF: pass client-ip=40.107.2.112; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Introduce a new driver, that works in pair with copy-before-write to improve fleecing. Without fleecing driver, old fleecing scheme looks as follows: [guest] | |root v [copy-before-write] -----> [temp.qcow2] <--- [nbd export] | target | |file |backing v | [active disk] <-------------+ With fleecing driver, new scheme is: [guest] | |root v [copy-before-write] -----> [fleecing] <--- [nbd export] | target | | |file | |file v | v [active disk]<--source------+ [temp.img] 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: it doesn't block intersecting block-copy write during client read. 4. We don't rely on backing feature: active disk should not be backing of temp image, so we avoid some permission-related difficulties and temp image now is not required to support backing, it may be simple raw image. Note that now nobody calls fleecing_drv_activate(), so new driver is actually unusable. It's a work for the following patch: support fleecing block driver in copy-before-write filter driver. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 17 ++- block/fleecing.h | 16 +++ block/fleecing-drv.c | 260 +++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + block/meson.build | 1 + 5 files changed, 294 insertions(+), 1 deletion(-) create mode 100644 block/fleecing-drv.c diff --git a/qapi/block-core.json b/qapi/block-core.json index c42d23752d..8a333136f5 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2826,13 +2826,14 @@ # @blkreplay: Since 4.2 # @compress: Since 5.0 # @copy-before-write: Since 6.2 +# @fleecing: Since 6.2 # # 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', 'fleecing', 'ftp', 'ftps', 'gluster', {'name': 'host_cdrom', 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, {'name': 'host_device', 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, 'http', 'https', 'iscsi', @@ -4077,6 +4078,19 @@ 'base': 'BlockdevOptionsGenericFormat', 'data': { 'target': 'BlockdevRef', '*bitmap': 'BlockDirtyBitmap' } } +## +# @BlockdevOptionsFleecing: +# +# Driver that works in pair with copy-before-write to make fleecing scheme. +# +# @source: source node of fleecing +# +# Since: 6.2 +## +{ 'struct': 'BlockdevOptionsFleecing', + 'base': 'BlockdevOptionsGenericFormat', + 'data': { 'source': 'str' } } + ## # @BlockdevOptions: # @@ -4133,6 +4147,7 @@ 'copy-on-read':'BlockdevOptionsCor', 'dmg': 'BlockdevOptionsGenericFormat', 'file': 'BlockdevOptionsFile', + 'fleecing': 'BlockdevOptionsFleecing', 'ftp': 'BlockdevOptionsCurlFtp', 'ftps': 'BlockdevOptionsCurlFtps', 'gluster': 'BlockdevOptionsGluster', diff --git a/block/fleecing.h b/block/fleecing.h index fb7b2f86c4..75ad2f8b19 100644 --- a/block/fleecing.h +++ b/block/fleecing.h @@ -80,6 +80,9 @@ #include "block/block-copy.h" #include "block/reqlist.h" + +/* fleecing.c */ + typedef struct FleecingState FleecingState; /* @@ -132,4 +135,17 @@ void fleecing_discard(FleecingState *f, int64_t offset, int64_t bytes); void fleecing_mark_done_and_wait_readers(FleecingState *f, int64_t offset, int64_t bytes); + +/* fleecing-drv.c */ + +/* Returns true if @bs->drv is fleecing block driver */ +bool is_fleecing_drv(BlockDriverState *bs); + +/* + * Normally FleecingState is created by copy-before-write filter. Then + * copy-before-write filter calls fleecing_drv_activate() to share FleecingState + * with fleecing block driver. + */ +void fleecing_drv_activate(BlockDriverState *bs, FleecingState *fleecing); + #endif /* FLEECING_H */ diff --git a/block/fleecing-drv.c b/block/fleecing-drv.c new file mode 100644 index 0000000000..9161e13809 --- /dev/null +++ b/block/fleecing-drv.c @@ -0,0 +1,260 @@ +/* + * fleecing block driver + * + * Copyright (c) 2021 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 "qapi/error.h" +#include "block/block_int.h" +#include "block/coroutines.h" +#include "block/qdict.h" +#include "block/block-copy.h" +#include "block/reqlist.h" + +#include "block/copy-before-write.h" +#include "block/fleecing.h" + +typedef struct BDRVFleecingState { + FleecingState *fleecing; + BdrvChild *source; +} BDRVFleecingState; + +static coroutine_fn int fleecing_co_preadv_part( + BlockDriverState *bs, uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, int flags) +{ + BDRVFleecingState *s = bs->opaque; + const BlockReq *req; + int ret; + + if (!s->fleecing) { + /* fleecing_drv_activate() was not called */ + return -EINVAL; + } + + /* TODO: upgrade to async loop using AioTask */ + while (bytes) { + int64_t cur_bytes; + + ret = fleecing_read_lock(s->fleecing, offset, bytes, &req, &cur_bytes); + if (ret < 0) { + return ret; + } + + if (req) { + ret = bdrv_co_preadv_part(s->source, offset, cur_bytes, + qiov, qiov_offset, flags); + fleecing_read_unlock(s->fleecing, req); + } else { + ret = bdrv_co_preadv_part(bs->file, offset, cur_bytes, + qiov, qiov_offset, flags); + } + if (ret < 0) { + return ret; + } + + bytes -= cur_bytes; + offset += cur_bytes; + qiov_offset += cur_bytes; + } + + return 0; +} + +static int coroutine_fn fleecing_co_block_status(BlockDriverState *bs, + bool want_zero, int64_t offset, + int64_t bytes, int64_t *pnum, + int64_t *map, + BlockDriverState **file) +{ + BDRVFleecingState *s = bs->opaque; + const BlockReq *req = NULL; + int ret; + int64_t cur_bytes; + + if (!s->fleecing) { + /* fleecing_drv_activate() was not called */ + return -EINVAL; + } + + ret = fleecing_read_lock(s->fleecing, offset, bytes, &req, &cur_bytes); + if (ret < 0) { + return ret; + } + + *pnum = cur_bytes; + *map = offset; + + if (req) { + *file = s->source->bs; + fleecing_read_unlock(s->fleecing, req); + } else { + *file = bs->file->bs; + } + + return ret; +} + +static int coroutine_fn fleecing_co_pdiscard(BlockDriverState *bs, + int64_t offset, int bytes) +{ + BDRVFleecingState *s = bs->opaque; + if (!s->fleecing) { + /* fleecing_drv_activate() was not called */ + return -EINVAL; + } + + fleecing_discard(s->fleecing, offset, bytes); + + bdrv_co_pdiscard(bs->file, offset, bytes); + + /* + * Ignore bdrv_co_pdiscard() result: fleecing_discard() succeeded, that + * means that next read from this area will fail with -EACCES. More correct + * to report success now. + */ + return 0; +} + +static int coroutine_fn fleecing_co_pwrite_zeroes(BlockDriverState *bs, + int64_t offset, int bytes, BdrvRequestFlags flags) +{ + BDRVFleecingState *s = bs->opaque; + if (!s->fleecing) { + /* fleecing_drv_activate() was not called */ + return -EINVAL; + } + + /* + * TODO: implement cache, to have a chance to fleecing user to read and + * discard this data before actual writing to temporary image. + */ + return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); +} + +static coroutine_fn int fleecing_co_pwritev(BlockDriverState *bs, + uint64_t offset, + uint64_t bytes, + QEMUIOVector *qiov, int flags) +{ + BDRVFleecingState *s = bs->opaque; + if (!s->fleecing) { + /* fleecing_drv_activate() was not called */ + return -EINVAL; + } + + /* + * TODO: implement cache, to have a chance to fleecing user to read and + * discard this data before actual writing to temporary image. + */ + return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags); +} + + +static void fleecing_refresh_filename(BlockDriverState *bs) +{ + pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), + bs->file->bs->filename); +} + +static int fleecing_open(BlockDriverState *bs, QDict *options, int flags, + Error **errp) +{ + BDRVFleecingState *s = bs->opaque; + + 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; + } + + s->source = bdrv_open_child(NULL, options, "source", bs, &child_of_bds, + BDRV_CHILD_DATA, false, errp); + if (!s->source) { + return -EINVAL; + } + + bs->total_sectors = bs->file->bs->total_sectors; + + return 0; +} + +static void fleecing_child_perm(BlockDriverState *bs, BdrvChild *c, + BdrvChildRole role, + BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nshared) +{ + bdrv_default_perms(bs, c, role, reopen_queue, perm, shared, nperm, nshared); + + if (role & BDRV_CHILD_PRIMARY) { + *nshared &= BLK_PERM_CONSISTENT_READ; + } else { + *nperm &= BLK_PERM_CONSISTENT_READ; + + /* + * copy-before-write filter is responsible for source child and need + * write access to it. + */ + *nshared |= BLK_PERM_WRITE; + } +} + +BlockDriver bdrv_fleecing_drv = { + .format_name = "fleecing", + .instance_size = sizeof(BDRVFleecingState), + + .bdrv_open = fleecing_open, + + .bdrv_co_preadv_part = fleecing_co_preadv_part, + .bdrv_co_pwritev = fleecing_co_pwritev, + .bdrv_co_pwrite_zeroes = fleecing_co_pwrite_zeroes, + .bdrv_co_pdiscard = fleecing_co_pdiscard, + .bdrv_co_block_status = fleecing_co_block_status, + + .bdrv_refresh_filename = fleecing_refresh_filename, + + .bdrv_child_perm = fleecing_child_perm, +}; + +bool is_fleecing_drv(BlockDriverState *bs) +{ + return bs && bs->drv == &bdrv_fleecing_drv; +} + +void fleecing_drv_activate(BlockDriverState *bs, FleecingState *fleecing) +{ + BDRVFleecingState *s = bs->opaque; + + assert(is_fleecing_drv(bs)); + + s->fleecing = fleecing; +} + +static void fleecing_init(void) +{ + bdrv_register(&bdrv_fleecing_drv); +} + +block_init(fleecing_init); diff --git a/MAINTAINERS b/MAINTAINERS index 20f3c7eb68..9b62f99557 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2343,6 +2343,7 @@ F: block/copy-before-write.h F: block/copy-before-write.c F: block/fleecing.h F: block/fleecing.c +F: block/fleecing-drv.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 caa52f49c2..10cd0c0ad2 100644 --- a/block/meson.build +++ b/block/meson.build @@ -19,6 +19,7 @@ block_ss.add(files( 'dirty-bitmap.c', 'filter-compress.c', 'fleecing.c', + 'fleecing-drv.c', 'io.c', 'mirror.c', 'nbd.c', From patchwork Fri Aug 27 18:18:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72B27C432BE for ; Fri, 27 Aug 2021 18:34:33 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D4EE5601FF for ; Fri, 27 Aug 2021 18:34:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D4EE5601FF Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:52500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJggR-0006yg-T3 for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:34:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRI-0001CV-54; Fri, 27 Aug 2021 14:18:53 -0400 Received: from mail-eopbgr20112.outbound.protection.outlook.com ([40.107.2.112]:14422 helo=EUR02-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRG-0006cC-HX; Fri, 27 Aug 2021 14:18:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nUO+Bz33yuvLLG8h32a9XCgYRRbkrnRyGP2oZsa9iGmKXRDiz/nkzz/H8teX4rzTtrzP/je08LnhkUyniX2NJgMagQ2KpBbBRajKIZElhvjLGJawOtZtd13p37ebFJZZ0TeJnzG4fLamcvrUDepCfso/M0J7VcCFYo5WhdnS4dk40nU3r8HE/e9NsV35Hg/6my9gW4TIdWIr931dQ8uNcdTGwqWF45k2/Vqv6qnWbng0IwOfNrphpaq11cwljHgZ09zGlGUuX8tYbTkpfPXEBrTyPfFwIJzwm5tu1KI09fuxRzko9LpgSVHXR4lPni3BAL4OVqWjKLUOewzXChEp+w== 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-SenderADCheck; bh=3+V3Bo4cmsYrYVsU9IWJEGuHXi3CRaeIdC92Q11Kkeo=; b=ldox3ZJWVm5+UhdimOMrGlD6nDd8VZ3TO9dTysp2U57bwTAlZMrSvSOli0+H27wrpx7m11sSORQrSS8p3wkyiQw0OYGwRzqLfOibxMI9HzPLPd9jcF9OiuZ6KoukvpY8FitVioP2xO7DSab0f9ykaXuTfXeGzeAqOPAu0jszcgiCrj5O3f4ikh02b5lH08rJDikfUW9q1uKEHyZWXPfNSBc7OL1bHf4yac1PS6wnpA5Co+NUisX/mSAxrFbnPG3P+A0F20iAP+4pXTPaVr0L1670ZrnAzFyIvlKTr+wBf4M+5AbFyFjDqOzIT1qw9w1aXYjvAItkTgG9XYCYZ0cZhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3+V3Bo4cmsYrYVsU9IWJEGuHXi3CRaeIdC92Q11Kkeo=; b=lYS/nISTXbliTXYMIMe9mBP4Q75M8aPMOCMC+snzmNSKhLg4kBB1wlUIveTQhReByElTEPbpYG3SjGHj9Q6BqcfqvKTNmg8ZBtdxyNYWhmv1Jbr8oJ+Nzj0bbXXq7hF91To9HQOrwDIMjjWWkE5N8u+GhL7RkkGi3vGtCYBtLKI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21; Fri, 27 Aug 2021 18:18:37 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:37 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 11/19] block/copy-before-write: support fleecing block driver Date: Fri, 27 Aug 2021 21:18:00 +0300 Message-Id: <20210827181808.311670-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 14822b89-aa20-4ba4-142c-08d969871707 X-MS-TrafficTypeDiagnostic: AM6PR08MB3765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:55; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oyyZDKEFXnqzWnglc+sL+opWexDulCbXafIHxa0594T7qrqctU6aCwiAfFk+EQtVndnx6MQ9lE4DBdeQ5sP6+QX+t8i/Gs6FH782ZAhR/VoJhN5uxsrkiUpVUC01yIvcFLLGFhaMjL3yZHhmDW+a6by7dMUgPs91WfeygYFSgsY0a7zSkDHutlih2NCVjxAxSI05SpzEAY80GTOuWLlV5rFavaM1pbYsWJrs82W7jg+MLU03YaApFzwHySbg2I9RyGa7oVCVK6eMkclEUCLbRgbiFp80AHt5WLZQ7OAWCOAzxmfl1xLH4ml2lPNVKpfCUDmJrh9ZKWWxIorZ4eQCuwW4najpiL05Ku4P4DPZA8CVwVS2aX3Os797/trFi/7AsQW8sAkGIfQHVaYJA0bepW6CYBXRGmvY2MWgOB2Jus3aIf7gbKj0HX+6aVJ4Dnq01kdWOlx6l8cZRRxtTmtoJ0IoTbN5090uBUilvLV4Q6u6tJzM57FseIot1biBgVMZVDgZXX4bcLWpkiYqe3pWdRfeBkx0QO+bf0lOBKJWsivqe3/9bhsbsVx1pX3PgzZ1Ev6sjNpookmLXB7X1LHX/lkpWyMTFAbgY+oXlvuOFVYOTCQjJM5qk5aNrZLOiemDh9dsqpMRarYsQUN3QjcPhUHDuqlvipLrHw8e+mFpVTPbc1o7v1QhkrgHdz2CkVWtB0X8Lpzbde1TvqjScUnvWw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(366004)(136003)(346002)(396003)(52116002)(6486002)(1076003)(26005)(66946007)(66476007)(8936002)(6506007)(2616005)(38350700002)(38100700002)(956004)(5660300002)(86362001)(8676002)(186003)(6666004)(83380400001)(66556008)(6916009)(4326008)(6512007)(36756003)(2906002)(478600001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xbWOg7Q6jNuZXwDTbNbCBg1fnC7ybWELSAo6ULOYh9xUQlXb6ZZrCyXUd6kmaVWhMq5h90gyXOyZbviE9g1xuUQjahwVE3xGnhmDsJpS8kJq54I81oySgFCxRejNS1hDWRa5J2KFu6mZkTLdeRKJYjNz1i+TX+vq49jyG6gJFsR4x5zFpKEji69peaasHt5+pwFXyAhVNC/fjrlvS7RgYXZWaAG/m/B29dZ2HaA7tuXIGgppRyjGzBTk2uatZLTE062A5X16TJwjjVZefc0Hx9JuR0FdvoV/WTZTTbM2xGxoRzOMXgmf7zOpgzY7t0KNVVMTh8hNb3e4/GMkJhYn7YjL1Di4yICP4NWRdaxAzU+7jh+q2om4qSFaOS/3qqBcO6m0VTy5hddHrcpmRFC6kNRiQVP1pLEt7BlbtCO4W9bB/J9iFUJBgMYeIqoL5jjKywt6ySm8azroK824//dL1KoXii1Lp2Ps2DLsChWAqouyLM3yMkFWFINqzAyjbKbtVI3FmpWk3tlBd5yGm3Mo1n+iUh6Z4RwzxdZXmBPXP12nsTyizdAQYir4ccrnqfwg+phHYUcc1+zhKqBubv7aGhS9xXZKVqlIHls9DYx6ifPBO6YJJM6z+eVMzePuWUD1aDQbdX8JxObTpybyPrCGzbxoDIbWqaMBpjY02jgWGaMfhJqW7t2qPNWbh9hXWxlpw8skXM13E7aDO3CyDf8keNLn31gG5ZB589JZ592GGlnDZM/3pon08KVSYFhSFal3ExvONSz1QnO7AwRcDKvYq3vp4FFQRiN8zjuQNSDqIKNbg4PHXRPUpJ/RY8EGGDeF0BIOlaSZGsaEFATp3yQTHysVAupXvgvkDzCxrDYbSFqQicywLx6lSf7MTszfZIQ6FiADjZhQQizpNaN79o4XswvWVw15V2fwBGBpR3wrbMkPZrenADCkFho64BfPm3ZQg/wOu8i1icdAFBLvaOEpnK7LJ1NaGor+72xjVv0PlCbIB00mo0Tht9cwB2ECqffTYeD9cnM/iHv3AA0QeH4LPt6pw+gqvRdkNDAd0OF1NmAK/csQhQqEfuTJRgKEcWLvNGN7LpJnnB9Uq3rjt9CzWTQX4/Os+t/pElMB00SbHx67iJw1MPdl8aT36GSNkp0+H+vns5EZkZ+lBjhXO6Noh+oEvmU64zb22uCelXhMDR3BJ0aXgKTIllSSRYy8Og/jq9RMDcjYOXBs+3DpCNunVIQFEWesZeCISimsPaBe81duclZzB5DuOLjuQv8nrEx6icOz5FYU5o1ErwY2ZnVi/htp947ZksIwqzPQXsYT7Byog0Je7JetG+5fILGyxyPz X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14822b89-aa20-4ba4-142c-08d969871707 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:37.8721 (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: 2mMdtOPkWk6M9WjYN7hpcGOhoH4TAQVvwVNiS2/51BubVoNl5ay5HqsfFGMFSpiReFsrAPP7AdQ4U5xLDHhl/R4cwHHynhoiiwuqPRKeqzA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 Received-SPF: pass client-ip=40.107.2.112; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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 last step to make new fleecing scheme work (see block/fleecing.h for descritption) is to update copy-before-write filter: If we detect that unfiltered target child is fleecing block driver, we do: - initialize shared FleecingState - activate fleecing block driver with it - do guest write synchronization with help of fleecing_mark_done_and_wait_readers() function Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/copy-before-write.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/block/copy-before-write.c b/block/copy-before-write.c index e3456ad6aa..686a085861 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -33,10 +33,13 @@ #include "block/block-copy.h" #include "block/copy-before-write.h" +#include "block/fleecing.h" typedef struct BDRVCopyBeforeWriteState { BlockCopyState *bcs; BdrvChild *target; + + FleecingState *fleecing; } BDRVCopyBeforeWriteState; static coroutine_fn int cbw_co_preadv( @@ -50,6 +53,7 @@ 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); @@ -60,7 +64,16 @@ 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; + } + + if (s->fleecing) { + fleecing_mark_done_and_wait_readers(s->fleecing, off, end - off); + } + + return 0; } static int coroutine_fn cbw_co_pdiscard(BlockDriverState *bs, @@ -149,6 +162,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, { BDRVCopyBeforeWriteState *s = bs->opaque; BdrvDirtyBitmap *bitmap = NULL; + BlockDriverState *unfiltered_target; bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, @@ -162,6 +176,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, if (!s->target) { return -EINVAL; } + unfiltered_target = bdrv_skip_filters(s->target->bs); if (qdict_haskey(options, "bitmap.node") || qdict_haskey(options, "bitmap.name")) @@ -203,6 +218,14 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } + if (is_fleecing_drv(unfiltered_target)) { + s->fleecing = fleecing_new(s->bcs, unfiltered_target, errp); + if (!s->fleecing) { + return -EINVAL; + } + fleecing_drv_activate(unfiltered_target, s->fleecing); + } + return 0; } @@ -210,6 +233,8 @@ static void cbw_close(BlockDriverState *bs) { BDRVCopyBeforeWriteState *s = bs->opaque; + fleecing_free(s->fleecing); + s->fleecing = NULL; block_copy_state_free(s->bcs); s->bcs = NULL; } From patchwork Fri Aug 27 18:18:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4B8EC432BE for ; Fri, 27 Aug 2021 18:25:51 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8037460E97 for ; Fri, 27 Aug 2021 18:25:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8037460E97 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:35898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgY2-0003wT-I8 for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:25:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRI-0001CY-UY; Fri, 27 Aug 2021 14:18:53 -0400 Received: from mail-eopbgr20117.outbound.protection.outlook.com ([40.107.2.117]:18413 helo=EUR02-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRG-0006di-Iq; Fri, 27 Aug 2021 14:18:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MaFjtlBdLkXH8fYeIFJbxRkEM3MYbRAUNr7TMnRrzitg3D1NkHKPi/vwvYe8OEUVeXeAPB8wSmLAbhggKbGJXAAtzUbmqoBE6vc6JWavEkhPfi0ax6J6ow1tpZJtg4U/NVLN0UMBO/9uRK9gnFB6k8PN/DeHUtkimrNzBqE4ZGSk6UT5kf5jDFpyibCV1ub3MNgpcjKuKn2vvZqFDbgSI8y+ri/DbU/cg6B7p0OK3t6GTQqZS+b0U+YUWt0ZlSlmpbzcdWE8DkKgsmuCtow2K2IR+eCiDP4AXC7QXO6cq6qhmqa+Gqj5eAIdCfZy3lrQ6RfciC0wyBi9+x22CYsDKg== 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-SenderADCheck; bh=4ThS0OHbhrTUaHtV/zOstkWXV/QRWbMzz6HXVPF2VBM=; b=ATgW/5GpqvgAWMySiscrGXLjPZ+XvBjgGtUjPHEpWo+viT3odpqRXcHtS4+cVBvjPhL/1NwTVDBK3fSWx3OHAkX8JmxHdAigqimDsi3p407OmPzqLwcPk7Ivrbl+bPEKEFJ0FCYMIwXgCzrdp3R3H5pykCWeAZFU4h803kUEMqOB+I9QF5UCHJsN9RZVWxX/wF0SkSBOPAU6hADg9JMgwRvg869YskUWhBWM8eDlAPYngHUnWQJvuTVTuznREZoHV+tt5/fUDVzolul3mdjeGZ+XMal4FJm/NVUY3VmHB/JthtityNuagv/MDQNjn93cX4uK1PMaE8ByTpv3Fj0wjQ== 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=4ThS0OHbhrTUaHtV/zOstkWXV/QRWbMzz6HXVPF2VBM=; b=naAMQHP2FfvYIdqCK5NujecR4HRefc77cCRwBPXArmhg2VnkWDhwwelfc9puQz4H92a2B/QcHmxcWMw+egRDaMRC+nMHX2Fw+SddoInB9oL7N/xJHBmAjaBF/JZcRZicPysrwBbaSiPxxpUF0p+eOePGVyKaiofW8CKay3r+XrU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21; Fri, 27 Aug 2021 18:18:39 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:39 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 12/19] block/block-copy: add write-unchanged mode Date: Fri, 27 Aug 2021 21:18:01 +0300 Message-Id: <20210827181808.311670-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c06e2ca3-ddc1-4e22-f782-08d9698717bf X-MS-TrafficTypeDiagnostic: AM6PR08MB3765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:109; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NZscTfFPLFZybLQKe9+413UySkd1E7DrbwETovXKYSRyLsVr4PnqOTaDG+E/zObaCFaXz8SIXDU8Fxm86UmjqcTxZFXVpK4DWdzOhr4BeK7sKC6lIOzbmZfmQC8dVGhU/RtKFtuBGuS2mso/X61m2N81y8w5isIj/qsKosL73N31lbebFT0bLwh0N5I3St48oQ883PaDjiUjXflZUlUeO3O1vhbZhKWW+HasSrVWzw6uCrhqxiELtuymBfTGo0sm6QSsuoeTz1OAJshGOa6KtcDyPs8AVCtioq2JSi3RaBSN6WwGutesVOy9Fdc4dgKoRaMyrpvwnohdJKKyqk7V4eCGC4l5MtKsoSfNHLN4v81JY4Y9tT3ArDWHlmKkxpr4IQCAxswamLNQExrYxhBNAP2gzN+CBWKXCJoIB11HKFIvCcR2JVXgCeWMNzfKbx7tyNuXvQK6e+Jsf6pVqbzrfozKuOrX5uLNkRr4zrH62gRebt9BUyyIP4CgAhe5kgfIR2T/N9C5+xjImJ22wbB3g8Z6PXEhD1iPzLxYmi1ygZ2b4L5cPcCvwytCW5N1Bq43Z4GfjpCqD/PxbRMjEK65alW9YyPIZBrETatDaFrRNgJI79aqHr9NhjEmO27asI3Wc0wsNSgBiYb+h7hTssC1bTlM7FcwgccRRZNpoEKF6b3pOkousnzlzbAF0Izbghe0VrNEzzCQezH5P92zQAUhCA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(366004)(136003)(346002)(396003)(52116002)(6486002)(1076003)(26005)(66946007)(66476007)(8936002)(6506007)(2616005)(38350700002)(38100700002)(956004)(5660300002)(86362001)(8676002)(186003)(6666004)(83380400001)(66556008)(6916009)(4326008)(6512007)(36756003)(2906002)(478600001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1MtoPsDC1GkbQ3CBRPMnKTwW3wcjSajvPa+A394eCrG0Mh9LurspPPw8/6LOtQWDB/+rQUkLPIvMb39kAyLyi+Ig25K2gpZFn2VPk/xH/dIK7dhwd5+jzy3my7YHtLXQfj3Z2DIW6pPqzXCOLXtTNtw5e6Z3T8ajNBYjc8ruE2p/L/Vyt/OL1O/aU44aSa0NX30m6/4zy4bV1/K7UF0CdsetrfyTdfDUtsI9BD51KwXem+eKREZx125I7blPtBoL7s5R7ylQmuDNpCMaR2e0puqua6XUhoZmOEHD3RFmoUZQL/ifCUdR1DkGqCaeUw7yoK2iLbXEHCNDSCsSXEDXZ7cXSViVcGtWRQFbvEBBlKkJfJZarTTXtiOGGbMbLFhFVmKryMSVKVnVaE60w2Ygdv0IeVTPs6v/nNcAzA58JoeHOq2bMXsbvqwyPc/R41xkEEODXPmAe6E+8mLd1h3nKHhUoZVYUBrWGU4Y7pahNPvVFeX380MFQoz1KCtexV4/tFNcfJdVyB8GrfTIDIqXzG/dJ+dZy5/wU6OGKc2vb18QP1hBI+h0l4mZ+YMmoTVXOfDxljs00LDrYs1ks0yPqHEp7R53kr68/1DsglXceqVOvX+TMGzWrqUQuIXI57jBDqt52yRSA3R2gOvJ6gNBKb4mPLuPOqn8/sxucG9dwZLFyVzfkQpg6K/NQDmLuso6cd/+L2AZE9JIsEtudaTXHtolyW7Y3E4wKCElecMKSQpgjo+0+5z95TTg8vdW4JwePkZBsHwAvbjKVnm7u6kWueDXL/bzT34tX/bp5caJ7TuOAfaI+4XL+sJkWZRtXfH5ojYqHBYLUofAtm9wSRUrVHwTvcWtgDgFQqbfxZAj9XIHGsgKb+KUzno2EZ5V34VlOXZmiIsrusRWj6DzYwL1Jnl3jfGM7znLthwd1iYLMDUaL5jDkOOpP0YViXd/3gBf7kb6sXU2cRKmvyzN/NudiCszTQ7WEf1POLaJtXTRl+hpiQpsQxrK20EKGt+M21G5AUnlMaHHz6s6rvY3zJpR0h9Z9sg6c6zUEZeU6vZNiGGbE7MUBqdN7FsCBgixCd3fAL5oThUBHELMj8Cq7pavZgri80SwQEao7T2CH5OEdTcJsEs9VJ8352AtKeXEQ0NUCDSEFPmBzx1Wy0wCnVUJWFDQKm5kV5s/bcUddZ6dI/nWJFTR+W115UB2ywV8ZWpJtFSl1OVZ8jA8WUtq0PQ3P6dNaIet8TLqKftPFEGsSpBpth/tECQi9+qQcz42XEpANAk2McNs5UlMEBQj9S7EzGKJ5y342bJDKUPP0AhsmVvHgNOAIfONemlX1NgRg6Nr X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c06e2ca3-ddc1-4e22-f782-08d9698717bf X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:39.0838 (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: Nm1DNtwFdJ6d/34I3U8Nc9/9nh63gS9BXCJvYf3z+X6UcsiFTHHnBN+x0YvMjKj+vxjwTpjlgLOrW7nK7/aPD2Jegv2INNXanuwjDmVoYD4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 Received-SPF: pass client-ip=40.107.2.117; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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 implement push backup with fleecing scheme. This means that backup job will be a fleecing user and therefore will not need separate copy-before-write filter. Instead it will consider source as constant unchanged drive. Of course backup will want to unshare writes on source for this case. But we want to do copy-before-write operations. Still these operations may be considered as write-unchanged. Add corresponding option to block-copy now, to use in the following commit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block-copy.h | 3 ++- block/block-copy.c | 9 ++++++--- block/copy-before-write.c | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/block/block-copy.h b/include/block/block-copy.h index a11e1620f6..a66f81d314 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -25,7 +25,8 @@ typedef struct BlockCopyState BlockCopyState; typedef struct BlockCopyCallState BlockCopyCallState; BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, - BdrvDirtyBitmap *bitmap, Error **errp); + BdrvDirtyBitmap *bitmap, + bool write_unchanged, Error **errp); /* Function should be called prior any actual copy request */ void block_copy_set_copy_opts(BlockCopyState *s, bool use_copy_range, diff --git a/block/block-copy.c b/block/block-copy.c index 46e6a6736d..6d5d517ac6 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -279,7 +279,8 @@ void block_copy_set_copy_opts(BlockCopyState *s, bool use_copy_range, bool compress) { /* Keep BDRV_REQ_SERIALISING set (or not set) in block_copy_state_new() */ - s->write_flags = (s->write_flags & BDRV_REQ_SERIALISING) | + s->write_flags = (s->write_flags & + (BDRV_REQ_SERIALISING | BDRV_REQ_WRITE_UNCHANGED)) | (compress ? BDRV_REQ_WRITE_COMPRESSED : 0); if (s->max_transfer < s->cluster_size) { @@ -340,7 +341,8 @@ static int64_t block_copy_calculate_cluster_size(BlockDriverState *target, } BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, - BdrvDirtyBitmap *bitmap, Error **errp) + BdrvDirtyBitmap *bitmap, + bool write_unchanged, Error **errp) { ERRP_GUARD(); BlockCopyState *s; @@ -393,7 +395,8 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, .copy_bitmap = copy_bitmap, .cluster_size = cluster_size, .len = bdrv_dirty_bitmap_size(copy_bitmap), - .write_flags = (is_fleecing ? BDRV_REQ_SERIALISING : 0), + .write_flags = (is_fleecing ? BDRV_REQ_SERIALISING : 0) | + (write_unchanged ? BDRV_REQ_WRITE_UNCHANGED : 0), .mem = shres_create(BLOCK_COPY_MAX_MEM), .max_transfer = QEMU_ALIGN_DOWN( block_copy_max_transfer(source, target), diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 686a085861..7e4e4bf7d4 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -212,7 +212,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, bitmap, errp); + s->bcs = block_copy_state_new(bs->file, s->target, bitmap, false, errp); if (!s->bcs) { error_prepend(errp, "Cannot create block-copy-state: "); return -EINVAL; From patchwork Fri Aug 27 18:18:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A640BC432BE for ; Fri, 27 Aug 2021 18:25:11 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4770960E97 for ; Fri, 27 Aug 2021 18:25:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4770960E97 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:34886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgXO-0003Gl-Fk for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:25:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRC-0001A0-EJ; Fri, 27 Aug 2021 14:18:47 -0400 Received: from mail-eopbgr50135.outbound.protection.outlook.com ([40.107.5.135]:51459 helo=EUR03-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRA-0006cN-Jb; Fri, 27 Aug 2021 14:18:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B7OJ9g7w0tSXbEHw1QC2UIrlqTGdLQXnzVhYTBJJWAPgORIT3uiUMsUm5axHKNggbzKSBMMJs4QVzfe8MuBkTvSv70hIKbPS04ldvH7esZnud6cr0+RWl/KT2aSXJrtyFkeOV4+W00EQBsoLqrZ8SQvQW2yED0OW3gPk8EGgSN1dweCCKw8ziDNJw0DdWmFpU8fJELjT6adyu5OF2GEmjXk95fpkmWxSN273alfwQflUrapl2vBf4cRCT9JmAJf0lZPGl8K11PBP6MLzjOWfcGg3JwkOnbSec+u3QJ0+qnqfxx2FX8FceYIrCsDlZDlZ83lT3NhF+Cstt8Mb+n0vgA== 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-SenderADCheck; bh=oz2e5FWoz2L/bowX4vUdc1F1h28PnR7YuPTjoEgbQ9M=; b=E30QhFcJcWco3dqXErBj/d6TTjzZYVXe9zsu4fvjkjbeDp5Am6GlFIv+KYGIk5lotlXPqtzRpwXaqUwDMK7FxUOVG/vqmf40UCKM81H5yRqngkL8wMPMj7g0U/E3pLhXAJkwuF1FxspgY5QDPIVEpHMgITsqjPIO/Ee+Cy9ut11zlxZl53J2j3GkPyUegogFYoeHcMlD4CUDDyWz2FvAQpT26KJh5n5lg2jTJpdvRXtr8E6CoGXmQVU7n8zGPToRtGgUC19eG3PUB2RL5Dv9OCEm2taYL29ScHCmYB4PniTdDaGvNMY5rCR0Bw9EAlWrIbuO1hgXsuiJz5jdXr/hjA== 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=oz2e5FWoz2L/bowX4vUdc1F1h28PnR7YuPTjoEgbQ9M=; b=i54O1YkvlMXFthnFQBgt5tyWkLvunqKKL9Uf7GGignKFb6MWsuEPgjAmqp0jm9yaY8WrDvXdo+WOrZPjbImpzMB+fa6lZIzDpJTHX4nQcx+R1aJe6iiMxCNcFvuHlKr5FVdwrghxW/855KABy6f8ArNjrHoSKySh+w7xjFNnIi0= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6774.eurprd08.prod.outlook.com (2603:10a6:20b:399::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Fri, 27 Aug 2021 18:18:40 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:40 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 13/19] block/copy-before-write: use write-unchanged in fleecing mode Date: Fri, 27 Aug 2021 21:18:02 +0300 Message-Id: <20210827181808.311670-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 74df608f-ee1c-42c8-936d-08d969871876 X-MS-TrafficTypeDiagnostic: AS8PR08MB6774: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:62; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i+RH9miEWyUhijPz5I9G8UechZb4mDGFe7xTBFOmcuYXaW2V0nUVoL5QEf3MxKdCqlFqfy/cU7WNYUur+b1KqDXp54OBFhY0LuoxXS+ox/SAdcnDsyj98CJM1KDZGVfyXbvG3vVjOWKA5qeYOu4og8DJXwZYeOcqyk02auTs9pxXF5CMB/YAPlU7VceadUio779M2TSfrp6fnJ2V9MtRwKvSwA6XciCDkvOlDTTryrbhgZDPewl7xHe7ouNIw+HiXYEbl1KHuyENr+C+lEsX1P5ZRL4V34A8v0l1otXY/83Ue6INxcHLVFozTnnAV9l8rrNRmwmDd2KGAxCrbxaPT874Buor/Fb2uKH/dTDPyciRmyAQb3vO0rma7Sg6G3sFU2XWBhdg0WaldxzfsXzoeI1LPttLCXdnOF4Rf3NY++aQBcqoq79pF253S7WgRWDzdwN07vHMIwj2zQXitnYReI5WpyvpGqyRdkr6IhkvhL4Pi2ggyujM3yrkLZfCQEHW8xMKdIwdm659UQziA17xhiabh4w4N3yvAB7PUdHXge9uadrIMQUp2QW4Vb1jLiQF6sinLM/wQDNKFLOlhRjV5i03zdON2JIMa7eHZ7nC2WHu7oovtXUo9eCamdK8YzLQ3i/hhezVyMwEk9ppJK6sZZPhDUgOsbDm7vSaKcx49QLk6ZXkTu81u5HqkCZs3sHTfwA1LqtezacHvUo8CYq8JA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(366004)(39840400004)(136003)(396003)(346002)(6506007)(52116002)(38100700002)(8936002)(26005)(66556008)(316002)(6486002)(86362001)(38350700002)(6512007)(4326008)(5660300002)(2906002)(83380400001)(66946007)(186003)(478600001)(6666004)(956004)(66476007)(6916009)(36756003)(8676002)(2616005)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FX617tHGv8JQlki6tEvwdTmIzxqQ234kPyBxuRTLbINm0YwTQopaAiDBPBCvHdmiQe/q8WIfFOhXmH29ammwcRHr+Zw5X+9FOULBLBd28JOs/ijLrx0tfn+fvCe+0sxxKoabshkqm0N7CTX4BBeR2Xqj0WQDqHL+/kaOToIk5hQ2A/Lk0UOJuSpPeT1zdcd4tx3xEaoda7catVCExh1Qd3x4b98/tzfd+1g9buRkBotcO313rQbbrcgvPSDziJ9DvmyxUgNeYQgrtpDtU+I3yYeS4cu+4Z78220PlJEbh+Es0TO4jLdOC6Uq6vLSF2KM4M6JHhn4KjXPxQXhglrSdeKv6NM4ws7sOkfkwdOzg3i5vpBLmQ+Ic+cLFA1iOva8wXqlAcwTEdAvBu6Bl51EIwQbdOdQn8yercZxP4ghlBlYrD/PFNGyP03i7jxLHmVLW3KcmlM3ygjsjnHy3nIftrHttu+8H9FJ/r5uh7HaA8YqLtfIEcwZtBDk/3x8rLgGF+Xncvpt3IID2TjsJUN58zA2ECYUbCLfr6gRelq2VOHgdtUyYsfD22O/ViCYPxC4ai6ZGMpTaAZuaF0krRGyhcu1VrZX7T32cszAijvwYhqaG+MfCcNDeK19+Cc+x8/PQysqfJQAfclVK/K4qV1I7Hx48K04OSmN5LQhoZG1gCX8SvTg80+XYQk155dKEjvrRXX51CFoMBnQqNQVQWtlaHOTvvpzPP8TzUIK9JEUVb3kfN+fA8Ggb4HxrixWB5etSSqxhJGXMlUWiGl3UBah8jnlCceeReGIO1fxsW0pJFw91uQKwGP/lNsEwr4lMM3TtZ6Oi3WyCi+24pcAYNyWrWTgN15Ok9S2RLrUakHSbrMbi0WNouPMUAoyqIuZ06Yrnz02+eHDFvi7EBYDWIDgPtC291tURCPcU+BFM6UjxfyYOCiyQO6NCzTS7VolwQYPFHRjKKcjZJhMPHxjyEFO8uDeMBbVDzyYOgmSdqZKRNopjJ2R5madIp80orqIRDb9XMeGNBzsZf1nSnqiVlt9SLw0XucvF2lrvgs6YNk/BM5tCSDcDKem0kQBUzUCttdUPGV1xGNTjfrb+ABJTpsbXjjKb1jkgiLDpGkjL/1lUSsMiI0LBkMpUlNsyXlp/czouyVkYGGAkHQuPdVBvnN7m48mo3L8VLmyZmVAYLvS+NRPUODIrTa2pm/GjWda2Yh10oTwbkjOzvS3JbFbD1MvK5C0lEeXtkhfhKiyxy+wLhhI/OxIpPmaRaUPelJQju1V9eerDMkCA1UpEn5H7Mdrw9/2CVbrM4VYAqumCgw9fvMAVc3Xh0EryTB6jqnUZq4J X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 74df608f-ee1c-42c8-936d-08d969871876 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:40.2547 (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: wv8UDQYOLSA2oMNSZqqxoQPkFJPVXqtXMFKKMsX0oLgEKilZHOjouwVceHSYcDKWeWFND/C36RBYLxUeMoqObIAGiSTZHPNefD8lXPPrLSk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6774 Received-SPF: pass client-ip=40.107.5.135; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" As announced in previous commit, we need use write-unchanged operations for fleecing, so that fleecing client may unshare writes if needed. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/copy-before-write.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 7e4e4bf7d4..91250cc634 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -132,6 +132,8 @@ static void cbw_child_perm(BlockDriverState *bs, BdrvChild *c, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { + BDRVCopyBeforeWriteState *s = bs->opaque; + if (!(role & BDRV_CHILD_FILTERED)) { /* * Target child @@ -142,7 +144,7 @@ static void cbw_child_perm(BlockDriverState *bs, BdrvChild *c, * only upfront. */ *nshared = BLK_PERM_ALL & ~BLK_PERM_RESIZE; - *nperm = BLK_PERM_WRITE; + *nperm = s->fleecing ? BLK_PERM_WRITE_UNCHANGED : BLK_PERM_WRITE; } else { /* Source child */ bdrv_default_perms(bs, c, role, reopen_queue, @@ -212,7 +214,14 @@ 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, bitmap, false, errp); + /* + * For fleecing scheme set parameter write_unchanged=true, as our + * copy-before-write operations will actually be write-unchanged. As well we + * take write-unchanged permission instead of write, which is important for + * backup with immutable_source=true to work as fleecing client. + */ + s->bcs = block_copy_state_new(bs->file, s->target, bitmap, + is_fleecing_drv(unfiltered_target), errp); if (!s->bcs) { error_prepend(errp, "Cannot create block-copy-state: "); return -EINVAL; From patchwork Fri Aug 27 18:18:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12CD5C43216 for ; Fri, 27 Aug 2021 18:28:16 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9D6C960E97 for ; Fri, 27 Aug 2021 18:28:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9D6C960E97 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:43528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgaM-0000j0-Nh for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:28:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRF-0001BM-MJ; Fri, 27 Aug 2021 14:18:51 -0400 Received: from mail-eopbgr50135.outbound.protection.outlook.com ([40.107.5.135]:51459 helo=EUR03-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRD-0006cN-2R; Fri, 27 Aug 2021 14:18:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S+H6wXu3MFk+qG/Z1M+g2qrElr+eFb22naDu+4x+GkhPw1G1MqGtsIWMwpYIsnzobrJURqnO2Q9rkXH1aYTK9nCE0p7UMbkReoYIUR+ksh7zSAQqJa0nwaW1JVtut3Jzib86NFBhmGSUAeqITBXdIiiY62CGgJo4UOYRjjTcGEhFJY+fli3t2impvQ0/yZj7Kg4dclh2oqEjjfx+4zGeGrgFQWgoUxv30DySdi3ddxm3HZjcSM1Qzh+X3RxMwkVZSAt3rrN61xJCZuD7hbqO7MMSyw2Bp6+txfKtXceFY9AGEyU64p9MKUG0hGjBzPa/lsoBi1vtOn7KIB5SNtSdZg== 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-SenderADCheck; bh=e1/rfww9y6pHiRO4VH7beSnKqbM6c2myvkv/iotlFyM=; b=LcYZ7bNvn8lcJfsdZZvRFrox8vmWs8vhhpDaN2AmNPwP+pDSAd59P+ZmvsEt0Ngk+pN+dr/kEWMEpxivtB0B9z2QUmhbTeWa7ZCdYWSATjPBmN/UXtKTh+FgRCzMDNYN4V3XBjZ+moz6n4kfK3JMyUEXplV8GWtA6+6JlcDRvzPPFWeIKvemYAsKP+HbrczEEpMR38nIyMtF/4nWGplVQHOwsfuuspGRVxRwpnQgAeH+L79UetNP9vGMVwPj1FGfNF18mO5vQqzPU7iXD0eQTLz7AY4TEWDk9e2uzWdDFxEbaqDCR4l+QAB3+VHAA61UkzIXpKJgX4HeNGWz1hW7BQ== 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=e1/rfww9y6pHiRO4VH7beSnKqbM6c2myvkv/iotlFyM=; b=FNdlrP56KJnwckuHX4b5UWD4KFXnYkhkgV9+pqPNnAg9Ys0k+t2ZI+6NALB//LHIU8o5CRFoyDAalfZZmSWQ50Byu9NySeNNJ2YnDckjMEpSkTjzE3nSL6WKKz8iNctk6IWZQXywHrxIwbag0/7//MGPdJDs3NsSVQclEvGk0SQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6774.eurprd08.prod.outlook.com (2603:10a6:20b:399::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Fri, 27 Aug 2021 18:18:41 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:41 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 14/19] iotests/image-fleecing: add test-case for fleecing format node Date: Fri, 27 Aug 2021 21:18:03 +0300 Message-Id: <20210827181808.311670-15-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1e7b1f3b-3944-46a9-89f1-08d969871929 X-MS-TrafficTypeDiagnostic: AS8PR08MB6774: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:459; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dbEbQL3LvcYYWGQkm/dDJf+uR13YxVgZRkLbSaEDXTLh548EXdIhN2to/D2bqlvmE3JSpxLZItU8VA8cYRKsSUUhKVLw7UifkMyue/Wyr8Noov3Uh7Z+EeQpvnE97CWMp4fYRTXyYXOvRDLWbVMzLclduSuth+eq5JUL9PDiZSPmgRE6D/Mh7KYb9WFzspLiSKWiVfYVkeqLH+qfkSm798j3GdAz2uRxvKuRUXkJ0tGc780UgJRmQOZhqIRny6c8bi6CE3vGlqiKleayPXiAvbOkYI/AatjlZ0+Lbc+Q2yXa/xtCWKRtHQGRPMJ6TfTG25wLEH67zd6sSVHSE2TDwdJlZi0z+rlIBwZKR1Thu9jlIOGUv5yN1pzbY31vwSmDHN2NJb0ieV/juL4zQ5UQ7ZS+6g3/9POv4NHEZeJPmRg8lc9Xn7MgJ7f7rVJTzClUGQOn36x4QaTkFl/ph59QXIpuTsq8GiZAl7zr5mQk6Hhhf/FG/MNBK0kmIq+1N5uE43wPAQdf6OPrRb/qdAGsqK9pZsuiRL9OF2SI/daT/ZV0GdFi1DK7oDEdAJaE+Nqeo59B/tmS6ulCy2v7idHJmuQEviEmsyiuj6/A6/DrlIrBqy5UI4KU5381oJ6nY5KQnoG/1SHChsDcbzDHYZSZ2ahk30ewyqTj8QJfH73fwuPWIe0nsv0glrmE/lN6IFlsMn2J39A08Gc7c32zfGxhaQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(366004)(39840400004)(136003)(396003)(346002)(6506007)(52116002)(38100700002)(8936002)(26005)(66556008)(316002)(6486002)(86362001)(38350700002)(6512007)(4326008)(5660300002)(2906002)(83380400001)(66946007)(186003)(478600001)(6666004)(956004)(66476007)(6916009)(36756003)(8676002)(2616005)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /CpdjBPILpZ4cY8ndiDe7DplgRucYUDHJoDUcDbj9AF31kV4K0qiKvOzUNwoTPyFahZEp9cyjSD3OQk8J2dpn/qgn7kCE+bplutRmYGz/HTe4va/z3cp7nwIonfbqobWV6yFvn/FqFf5GJQ7EjDGH2StL+4Ywb1jdVbfIW7Vw3kvrmcbD/lFaX1FOaZxBRL0XvMbVQk6uYHJLuQRiY5okh68HZSWVRS5fwuzG7Cn86Lna2irsu21YN0xbM/RWTZDy7tJzzuiRmJz15NDZ6NGkQqSafYTazvIHnRUytWXrBAtMTb34COvIJbD4nFqw6TiSH9OAjz0aycJ7vmnGN5zDlLlQhbng8YufdaxjcQ8Mzesj1CgPbibqkHqWlHzeslorSxj3/qynPYW34eTkxIdWLk/9lZn5nZ4B567JH2/wuVTBxmWKnSTsKkTNS/r7cprOjIUj8VGV6DRoKAzLdZLsqdiQ73bZcGxErHL8AbpmWNlZYcTlphtZpuXCIwJFK+NZ/ZiHIoWNvZ/nlaJqLCLPo3rbqxBq2xCoEgfNl3e+Bs3+KfYrSO870WkEeikhMP9mHKhDVU5RWw0j7Q+IVMYEvOocEIxw/R/6GG0P2LfLdj80kEqxxv8RTfq3DoHeE7aJboUcspdaFNdoLxu+DqFsHR+9iB0BvfnYqIKOXo46cCLr+ndwLNF/kIOOaZFSAkfiPB6IUdyEP0CSlGtSHPOiqLI9cOFdKJ1Mc50YwY7LYz+cyE+dUbD+F+7aHs6DDldN28svM1TBOMsv8INlpSJzbj+BRdRgkuNzuGayG+90DjaXuUC0L7k45PRDZFukNn3ISVOyYPe2JJU8FSyn8aa8ZAw33rl97FNTdX39cqcYgo0B7oQdX9i8hgjFMU128toJfId2K1TBrw0jax/B6Fo5dqzpezX4QXcUrGhyppZBZIKaVxt8pGMPUb8UyR9ww2ZkZILSg/5ifXGG8x8s/PJLPZ1tmmDlpX2ZSXxNCnzdJZk2/WshYDoBNOlEJRWfYxFQxAmA+1d2DnBlbMr7HWNzyZ0LjZKgWEzecTjktulVBKA3mOrixiX9tjDFGm8ZAUYjkRDgfllY+pfpze5s4ClbvjjTDDGSWIrNCqadL+FiYBH1gs8/5Gx8h6Xj/echEXwcbp3LyL9IQPfrnDhORXfJ+u3XvbpY+GhQD811/ozV+FG0DolKqpBo1/viQx8O4TtfwUQbTRusd402XeMUNcWYYkaon6OSSOtULRVfOCoPhmfVNA4hMdqYP8Sq0+EUkqCPHaNxhKMNFnydHyVyjfaV5fQeGwuRj4aMBTvC0XYYla45qTPOTbgnENApNWIT5Ay X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e7b1f3b-3944-46a9-89f1-08d969871929 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:41.4733 (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: T0GxrmAS+jKKvoz2237qjGxiwr5+R76xh9bafMbs08vA5+OlDWpwIWYJihsOsWRSXIbSeo5RzbUB08Hnc+F2ZWgt+bYfKb7Km7Ht8OIF2OI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6774 Received-SPF: pass client-ip=40.107.5.135; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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 | 67 +++++++++++++------ tests/qemu-iotests/tests/image-fleecing.out | 74 ++++++++++++++++++++- 2 files changed, 121 insertions(+), 20 deletions(-) diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing index f6318492c6..f18881fa71 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -48,12 +48,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_fleecing_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_fleecing_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, @@ -80,24 +85,39 @@ 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_fleecing_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: + if use_fleecing_filter: + log(vm.qmp('blockdev-add', { + 'driver': 'fleecing', + 'node-name': 'fl-fleecing', + 'file': tmp_node, + 'source': src_node, + })) + log(vm.qmp('blockdev-add', { 'driver': 'copy-before-write', 'node-name': 'fl-cbw', 'file': src_node, - 'target': tmp_node + 'target': 'fl-fleecing' if use_fleecing_filter else tmp_node })) log(vm.qmp('qom-set', path=qom_path, property='drive', value='fl-cbw')) @@ -108,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-fleecing' if use_fleecing_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 ---') @@ -150,16 +172,19 @@ 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: log(vm.qmp('qom-set', path=qom_path, property='drive', value=src_node)) log(vm.qmp('blockdev-del', node_name='fl-cbw')) + if use_fleecing_filter: + log(vm.qmp('blockdev-del', node_name='fl-fleecing')) else: log(vm.qmp('block-job-cancel', device='fleecing')) e = vm.event_wait('BLOCK_JOB_CANCELLED') 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() @@ -176,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_fleecing_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_fleecing_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 cbw-filter based fleecing ===\n') +test(True, False) -log('=== Test filter based fleecing ===\n') -test(True) +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 @@ -51,9 +51,79 @@ read -P0 0x3fe0000 64k --- Cleanup --- +{"return": {}} {"return": {}} {"data": {"device": "fleecing", "len": 67108864, "offset": 393216, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_CANCELLED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} {"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 cbw-filter based fleecing === + +--- Setting up images --- + +Done + +--- Launching VM --- + +Done + +--- Setting up Fleecing Graph --- + +{"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": {}} --- Confirming writes --- @@ -67,7 +137,7 @@ read -P0xdc 32M 32k read -P0xcd 0x3ff0000 64k Done -=== Test filter based fleecing === +=== Test fleecing-format based fleecing === --- Setting up images --- @@ -82,6 +152,7 @@ Done {"return": {}} {"return": {}} {"return": {}} +{"return": {}} --- Setting up NBD Export --- @@ -125,6 +196,7 @@ read -P0 0x3fe0000 64k {"return": {}} {"return": {}} {"return": {}} +{"return": {}} --- Confirming writes --- From patchwork Fri Aug 27 18:18:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA82EC432BE for ; Fri, 27 Aug 2021 18:41:16 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 69DE760E78 for ; Fri, 27 Aug 2021 18:41:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 69DE760E78 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:35446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgmx-0006Yt-8x for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:41:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRK-0001E6-Vb; Fri, 27 Aug 2021 14:18:55 -0400 Received: from mail-eopbgr50119.outbound.protection.outlook.com ([40.107.5.119]:12128 helo=EUR03-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRI-0006i4-RT; Fri, 27 Aug 2021 14:18:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O+quDkeEiAADGnV+DS2DG99MsxJ0G/+aHjTcio42hrnPNH/+0Hu1gDPwz/3OI4XMIgizJfPJ2A2N1kmXDUwA5dHwVQXu7aTrEVB5zZfd9n8vIhdlIooCMJtNjZR4hlgApJJF10puQTN33O+1+NIl0OeBCkgFlRNQWtBxalcheY7rb//4IwTL9QKrOVkP1VdKMTmCibxImd5lQev6AfeUP5MrtVtRSXxMq0usybWoDzvcKWJGxpTVj0y+oqeqhFqhWR3Qif0EQ7NPzcSvL2hQKmGoH5G5D9SE8TZXbIXQrZoUhhVDc3awWKdGz4rjiuslyRKy2WSR2icwe4HyoT3reA== 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-SenderADCheck; bh=E9j3u3Y5yJA20jpt0Tg7DN9PUeiOPxctgrkd8K5IcS8=; b=jMgv0GmEMh80opQOygiIEf5n1B4LadR+B3Cc0/IBskGRkhgeqHWDydAWa3YnKjCb8QN5N40zg3+nfSJuJ3N+HVQBK99Y+u0zF9IemrC6SWKP5kqxt5h9Wf6O+iUn56akIfNhAK0tsJ4E85k+wmQEqNiFnUc/wX6840OQeO1Y/oGUz9TZHwwa5Vo/5RQI8KHoZhIYkW3S4F/2TnnkxzphSLZ/PacNiw03uiuyaRpAZt6DfETn1cMmGutl31/RVWsYtavp0L1mRYZuulobOVsUJ9mS4ksmfmgILiZrT7zjzWVEwGBAfj8GjxFfsNcVOMLvf5P3Bln2s2BPGqQIiwetbQ== 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=E9j3u3Y5yJA20jpt0Tg7DN9PUeiOPxctgrkd8K5IcS8=; b=MAzsfmzyEt0DCvS6q4txUrrQ+wJWS29zHb16i1+AFkT+uh7YZf0gnGeonXtbbEYrL16xAAvU4i1UORSUIq0GsQQMD0OkZmrbT3jZYxrnRdFekBYwjUNv2XpotXf72RLgdkpmz3Scr5RtWxNlJi4RNOxTo7B5gloS65DE0+6iVPg= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6774.eurprd08.prod.outlook.com (2603:10a6:20b:399::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Fri, 27 Aug 2021 18:18:42 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:42 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 15/19] iotests.py: add qemu_io_pipe_and_status() Date: Fri, 27 Aug 2021 21:18:04 +0300 Message-Id: <20210827181808.311670-16-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1eee204d-4a9a-48cb-b49c-08d9698719e4 X-MS-TrafficTypeDiagnostic: AS8PR08MB6774: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:337; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YV/1t5ZbjvjhIUdHaFTuBssiRDGE49TgeXUAStRyeAQ+KK/C1veOWTeFthbYLDvPph8au5YUvw22brOMkYyWeGLjXnO2vnMb+dGt1terhDfto5SEcYijntbog9a1eZQrF3sdOxYtTz+IM+kCsG9HLFCZyS+64wzc0VQ6/0oLsKwm+gqnJ/GlbIKCpKZqPxp/Oi0WQk6c4lSdTGnm2BEX533xevaWRiBNSih+YvXOKWEjjVxUwfnvSSodHS9uUllNKmVZCfH8rDTogDmbzvGl7onLdMblCUyyIMEECf/8V1IJSGWlv6PFps8jRyaS/vImO3vPDmY8qKOiKVe9eE6P3Cvdvl0Kjh0oLUQiFUVmK4xK51sksLbn9LT81xRxV6Tp+0MjYTumqZ53GV9PsHdUveu+r2FocYE+tFP5Hf9CVYA5QTZMJCBUWSxoJmV1z6zBlaPwGSlq0f9pPF+ICg2cdzOdPcDjtTWtom+4rkeh5BMePnJWU4g1lAQ1mfNGZuFVozBzavDX62oACrBKTwlNWBd5inDmJ/PqtLdZ7Sm0LipQulHLQ4VcbV7W6n5hpQjUifvbe60yBr8vbfcOQ9WvCmZtikjCcZPJYKa7uXf6h54i/zyuHLi97Gn9hauViy0kUM/Js6NnO7K3Jpjfg/EXSTyVb8m3bP4wEwbm8zAYoMPyNGHmax98uMSFGEvFCBNeQAYkHNRYSCITqtgxgTCDog== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(366004)(39840400004)(136003)(396003)(346002)(6506007)(52116002)(38100700002)(8936002)(26005)(66556008)(316002)(6486002)(86362001)(38350700002)(6512007)(4326008)(5660300002)(2906002)(66946007)(186003)(478600001)(6666004)(956004)(4744005)(66476007)(6916009)(36756003)(8676002)(2616005)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NygT8K/IJwCY1GB81is1ZjZwWuSUh0E7s/g6KRoZ5X2KmRA9w99Iwb16bC6Y6Pw5Bg1Mh21RZhPDhBNL3wB7pg1lpXZ7BU0K2CBzf+GHtJO39VfMqqqr6q9vMFhZtcedQPN5m2OWo0NRk4Clq/SjrwX0EXbprOXpVki5jmIPEHlaqN6LNVvtzQbTSN4U6W6bm1T67pb6wPoCv+HuIVP+Mn4s4S4d64ousXy/K5nUlPMqlMcSWAujVR+XJtsLNdk73cEgtMK7K7Bf2zC2nlm5sL1VQhaNXyHazh48PbhGTwLpJFRleGdAS/I7BOREB9IILHn886+WrrWgmg7s57MtkkfjFykLWj2I8hFK5W2lJGTfbhu89livwKP3BAYWHV5UmMGafoS2BIj44C+5vfcbD/Uz3lWGssuNaXthbglgjNCAB9WAda8HLa3Sv6Y7XWkwgk+KAb5LKU7o2nIJjBNw9zRgJnhm4enwV+22Z4Mdg7dz4LBADd0Lw5J36YhPmkt1peT5w13yx9Rru5lY+wt+032u2BJyNdWqnUWxVtMeJf+GbmfES6LUi6Az2oVdayFsV4ogvF3JzHBouSg8DPz56I0WJwPZHnNmdaEY6DQI2qc08hQ1nZOp7AC/FpLuu3I1anuJt0ln/1H/sdb11+m3m+LkbWpKtD0VafvVBk92B1xLhEQtoEOG+rUL5vZFzNuGifDlZj/zIovQndz4fJZvmHF/cJrXPHdOUYL6HvPihUfbqD5JnskeoA+LK2vMjKchWd02zaUZ0J+i2BvsuSV3k/erWkpmNnJYFX/kTzQFreIgI6GnYLWlszKOcaKzl8taxw4ws8dhFfIeKym2n2emyYx3A7Y5LO0XLPGtfhVlZQ3504awo5HRzD9MJo0XdgDO918g7SdE3Bz0ZFmK2xDJSZRbjsuT5Uu0VBMxXkoCfWDabyZdKQAF1Ceu3k+D+NGnBvaB1tPlQhi4yFCrr0/DGvcnM+FV3hlygsM9GHbnpa/TQ3++7hUMFd7g5weqJIwjnA0yBlMbWCAQ9IaOzpVIm6iGV6BrkAxA0e7RgJSyEGwc/+9x+hcitbVAP/fGUwk7Ay5ZeuI1N2iYhjDFyA18ozfysXG0h54JSI624CJlUtdPqgY90g7Io6n4tn9jJavukHZ2D0v3OjSvcIfTihpIpxZZl7lWiYg4HBYyWW4Hfh9bhpas6GetVv837a2SE9TCwFaPoZpWr5r/TYaqsR42w5D7V8ODDBMMCCHDD6O9nkpyqbYCU1xmFn2kpOpVv3FwQ+ekH03Ge8KBsZae89VlOQAdlbIDpIqYksJ0rk/Poqd/wY59Vz5BcSWt6T/QBdCA X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1eee204d-4a9a-48cb-b49c-08d9698719e4 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:42.6790 (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: kWJlF2IcgfsMV4h7jNyLNZMS0tbip8vczmySwmMwlkn6Duzc+ZOiCQ30WCumfdH/eJuSAICeN0RXrodJcszEfp3clnlHxHD7K77GZYZdIlQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6774 Received-SPF: pass client-ip=40.107.5.119; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add helper that returns both status and output, to be used in the following commit Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/iotests.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 77efcb0927..ff96d8ef16 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -206,6 +206,10 @@ def qemu_io(*args): args = qemu_io_args + list(args) return qemu_tool_pipe_and_status('qemu-io', args)[0] +def qemu_io_pipe_and_status(*args): + args = qemu_io_args + list(args) + return qemu_tool_pipe_and_status('qemu-io', args) + def qemu_io_log(*args): result = qemu_io(*args) log(result, filters=[filter_testfiles, filter_qemu_io]) From patchwork Fri Aug 27 18:18:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 033F6C432BE for ; Fri, 27 Aug 2021 18:28:56 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8EF6960F45 for ; Fri, 27 Aug 2021 18:28:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8EF6960F45 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:44572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgb0-0001Q6-6C for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:28:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRM-0001FW-Ms; Fri, 27 Aug 2021 14:18:56 -0400 Received: from mail-eopbgr20117.outbound.protection.outlook.com ([40.107.2.117]:18413 helo=EUR02-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRJ-0006di-Kw; Fri, 27 Aug 2021 14:18:55 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GIMkLJWa+jqjjlqlzYjZqvVtL5klKz1NpMTbvOYN0UGxq0CySUtxefi2kokP7vC7ByPNWf5Dpa8DDNItBv87dnqbXprwPB+agmJGp0ooGVIu7BdhiMWDx1WWqEIF//vtzq43BAUO+sYngCFbOlMqwuWY4tyfe5Ba9eL0jQmD4C/skiTsvpvLpKM9+FqBPL2pMjx4ZWa+OyJXweaycMSAFAvsi0bmvGzKWwxqagGcP3QFKpRKA2Gd+MoamdWj84BdCc67xd3ggpRoJxVkXLBJUuHdwxVkwAzFC+L9cvAZuydBxS8mDtHF1mvs161iCiaE/u8aTCriZnHwFtCz04hFUQ== 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-SenderADCheck; bh=feKgbUrUHyK4s4qRnScjO7ZxNAZELzOMmSsvrYpOSRU=; b=fm90t317arzX+SVtwJqNpM8fs36dgP0xFc8XV76qywIRfZ54S8snGVhZgpjr85DSZaxHvrf6IVWdkC1s/ZdaTTJEcu1HhowUXGYkp3kdDotfcMZDbitTP0MOljvBh/wHldlEaRUt85AcLWGUmIlNGd9m+sGZ7ugUCoQFBLCIlhjAJ/dOqSr5TbYUBNu3gyHTfI0kTmTTWKrYtOUdQzFj8Q36Ueucq/PGJCj7Q2zf3xi6bjxM7qfQolJBYFNz7YWJo8OrC87G2MvMY21nRXlhI3jqQtlOOf982BcMRN6zq4aFzaPkEHvq9blkPlY4yBUTgPfgi60FNulNVPA0U/2xaA== 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=feKgbUrUHyK4s4qRnScjO7ZxNAZELzOMmSsvrYpOSRU=; b=SIwuhh1rWVUPhniKYKYIkMWP1PXcIYg1K3Xd7bYgoQDFjfeQtmAD5ydnqriA6es3TFbcw3luhAOcvqt0oakXURlXBOaX/ibh2WzKGR/KR3/YCDEMngbENGgJIlKBraVT5085Hi2yGHnDyR4LaK1JcyjDlwYcX1Ej/FeqXr7arWA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21; Fri, 27 Aug 2021 18:18:44 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:43 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 16/19] iotests/image-fleecing: add test case with bitmap Date: Fri, 27 Aug 2021 21:18:05 +0300 Message-Id: <20210827181808.311670-17-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d10c8fde-10c9-4ef9-1cce-08d969871a9f X-MS-TrafficTypeDiagnostic: AM6PR08MB3765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:73; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ax804zK5ToGzXs+Rawel765dnUvmw0LgI6WZvn+kR1opvAbk8/xl3j+l8oMVWAjpphNaO5ytvxk2YoSriWOcjFLpA1SYLuYnusLIGqsfZLA2M/aJ3CVOPBc/jUbnbPIA8RPeBY6pOZNpB3Iy/o3Krz9YkeiE7B3Dnt8vkGtriRJcvPhu2BNLogq7WJ6JPHzOfv5dnFMm/cqU08FV6XMWxZZvk/mDSOAWXNpG/QA7mToOMEO/dQ0cYt3Id7bUMGuKKDAeb9yHOqSPd2IaynQScSQINUDWv/xAdfHmBYq8O/JcLLi6v5K9QQY5Fmg0/YsN9/Oc4kS5W0DdXCAcAtSjxeonLZ7L7A8jHBmfNLRiLt8X7F9BH+iCAseSMx5Z8ZkSZYxjlMrfNZgE8z82ieLvK7NdLrnpmS04gFSA4kLEAXEXGRw2sZwt8q6OKwaqhDXnLAq2ic65k1LWenn0TnV4yzHCdtZ8vmtcoTWekuSmBDwR3pJKrTTrnVYcVM03HvfRWDWtVZkvQg+I11qTuCLml4ykaa2Xp4zv1+2c1JhkewhVmwUytMJr8/jiWUN7nmBQfZV3XZ+l9mW0Hlp+wa4vWnT20lpXtd73/HiK/2ASNsB6BFR3z2gzxZsstXS+Jl4FW4VGeT2n8/ohSMMkqA0LHmVax9VEBeFdGkypLa2+Q/fK2k5LAepeCrmXSbna7NLwjmYvv/7PMTWHf4fa7DZJuw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(366004)(136003)(346002)(396003)(52116002)(6486002)(1076003)(26005)(66946007)(66476007)(8936002)(6506007)(2616005)(38350700002)(38100700002)(956004)(5660300002)(86362001)(8676002)(186003)(6666004)(83380400001)(66556008)(6916009)(4326008)(6512007)(36756003)(2906002)(478600001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zcdLHFyj8BZEkhGpYCdzZzFon/37uxeY6Rw7Ny1+pmgRhU23OzwGqspMl9c+h3Pf5h9qdhDrPOBt7bG22fQhtgBGh1hehaSM+JccvW3TQWhL7Bc4eTcXaPtKCA/l8TtGqE9LvexxgU+GUQO+6MbztNvkbA07/vFdqojCGz+pE4T/Bz6EGQ0JU9sEpO7R2tVZEuSNir1KOp7nd2+w42VpIOtgsA8SMBwjF/BOov021ULn6orbGyd5XfewPXMIR3YhOFZamKjWM4P97cKrSj8OXOsnUKWD7ic60N5DLIrN0fd6nsK/UrIFW6EONk9AKrUyjJGjnSh5bhXQ5Ld3ceIzlKaUxCU6KKlA1eIG2wTrxCmrupa1JqsPMNZHXqRKy7zi3drIUTaV1Bb4Sg49j4xiY74YvmMsLccAi+lXVafEWKKroelrxM6H6cGgsBriGC8vYKI9QH82dokcJ7IVkxUkDWSw+sa3MRcOGBdtgL5k863Pw6JFw2Lx9YZyWeUmMGAZX9D4rB7XUps7hUhS2r3CtMJRqVgam2AJyQEQ1/2KIqlplKuTMKURIFbSINm/kr27HMkIROeuS6OHrKs8oH9rysdxMlKiSFBUxRUL+cIDIt7ou0PbfAXrqVJTa000tYua/JZb7MnRLElE+9+Jy8qFAqXzNX83rRNf6+D7NdFBi+d5t9ZL9VFpm/cVJjzlwwQqtFfmvfump3otLaC60u6ritq2GfZABUZt/ITBUZFIKiSQu798dl0mD+qvpEcTrcLTM9ZJHt3ElZsXV8M6yRkAIp1NZJTc4dtl8LSb4m9ht2umTvE0lak4fxV/gp89CYltles8oxPTkFrJ6ZzsD7zzkMbg9kRugLx3gZDlO/9hlBl6AkabgvJNZhjlE90T00k/7g5meMKRzsRu5j1LeLFLSXwixxRtSrPpLCIMKYk1O8a++7uZ0rdby2WsUc2057sLI+ZColi/fDumPQxRRwiADN7JshMq36Un8qzDyBQBQlNC2HGu5vYbumad94O6jGVcP7z+1tlhaMFUW+0pcA3Kg1rtaMQV/R2tRKCx5YG5LQhQM4Z4fesAdVDV6l4bTaOFsWRgGHKPrrcgsjqU7p/xoyT+4yTSIVPSWEWfYsK3XnE1A3cv1Yh8ql9b7bQq3GP1zM/JBwrT/R4IJR4zvuoOSoZ+AXPA8tUZ5YiVrvHJvUJcnLskdGZPdEmGKp1CUmEsdynNXhzqITxDkcnJg0bJmkU5r4XxWPvPn05WtY0ydfRUP5emBgVcX1thk5kG6n1mhCp1Jz5O/m1VZ+Hv9Z0OPtTxQ59Nqve8mBGBa+uOogTpNp2bMYFV6ugJ7yzVI2mr X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d10c8fde-10c9-4ef9-1cce-08d969871a9f X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:43.9156 (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: jjmTuvJGcjzT5XYHR+sh0rAWg3kLZ9L8v0KlCJnQCPcLKh87qESOGmlr0khTRN9vUfZBcjPJ9IGKhKtrqqVyOwDa7GCbN5Ezs47JHe9n9u8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 Received-SPF: pass client-ip=40.107.2.117; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Note that reads zero areas (not dirty in the bitmap) fails, that's correct. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/tests/image-fleecing | 32 ++++++-- tests/qemu-iotests/tests/image-fleecing.out | 84 +++++++++++++++++++++ 2 files changed, 108 insertions(+), 8 deletions(-) diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing index f18881fa71..ab95e4960e 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -23,7 +23,7 @@ # Creator/Owner: John Snow import iotests -from iotests import log, qemu_img, qemu_io, qemu_io_silent +from iotests import log, qemu_img, qemu_io, qemu_io_silent, qemu_io_pipe_and_status iotests.script_initialize( supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk', 'vhdx', 'raw'], @@ -49,11 +49,15 @@ remainder = [('0xd5', '0x108000', '32k'), # Right-end of partial-left [1] ('0xcd', '0x3ff0000', '64k')] # patterns[3] def do_test(use_cbw, use_fleecing_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_fleecing_filter: assert use_cbw assert qemu_img('create', '-f', 'raw', fleece_img_path, '64M') == 0 @@ -113,12 +117,17 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, 'source': src_node, })) - log(vm.qmp('blockdev-add', { + fl_cbw = { 'driver': 'copy-before-write', 'node-name': 'fl-cbw', 'file': src_node, 'target': 'fl-fleecing' if use_fleecing_filter else 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')) else: @@ -148,7 +157,9 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, for p in patterns + zeroes: cmd = 'read -P%s %s %s' % p log(cmd) - assert qemu_io_silent('-r', '-f', 'raw', '-c', cmd, nbd_uri) == 0 + out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) + if ret != 0: + print(out) log('') log('--- Testing COW ---') @@ -166,7 +177,9 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, for p in patterns + zeroes: cmd = 'read -P%s %s %s' % p log(cmd) - assert qemu_io_silent('-r', '-f', 'raw', '-c', cmd, nbd_uri) == 0 + out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) + if ret != 0: + print(out) log('') log('--- Cleanup ---') @@ -201,14 +214,14 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, log('Done') -def test(use_cbw, use_fleecing_filter): +def test(use_cbw, use_fleecing_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_fleecing_filter, base_img_path, - fleece_img_path, nbd_sock_path, vm) + fleece_img_path, nbd_sock_path, vm, bitmap=bitmap) log('=== Test backup(sync=none) based fleecing ===\n') @@ -219,3 +232,6 @@ test(True, False) log('=== Test fleecing-format based fleecing ===\n') test(True, True) + +log('=== Test fleecing-format based fleecing with bitmap ===\n') +test(True, True, bitmap=True) diff --git a/tests/qemu-iotests/tests/image-fleecing.out b/tests/qemu-iotests/tests/image-fleecing.out index da0af93388..62e1c1fe42 100644 --- a/tests/qemu-iotests/tests/image-fleecing.out +++ b/tests/qemu-iotests/tests/image-fleecing.out @@ -190,6 +190,90 @@ read -P0 0x00f8000 32k read -P0 0x2010000 32k read -P0 0x3fe0000 64k +--- Cleanup --- + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} + +--- Confirming writes --- + +read -P0xab 0 64k +read -P0xad 0x00f8000 64k +read -P0x1d 0x2008000 64k +read -P0xea 0x3fe0000 64k +read -P0xd5 0x108000 32k +read -P0xdc 32M 32k +read -P0xcd 0x3ff0000 64k + +Done +=== Test fleecing-format based fleecing with bitmap === + +--- Setting up images --- + +Done + +--- Launching VM --- + +Done + +--- Setting up Fleecing Graph --- + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} + +--- Setting up NBD Export --- + +{"return": {}} +{"return": {}} + +--- Sanity Check --- + +read -P0x5d 0 64k +read -P0xd5 1M 64k +read -P0xdc 32M 64k +read -P0xcd 0x3ff0000 64k +read -P0 0x00f8000 32k +read failed: Invalid argument + +read -P0 0x2010000 32k +read failed: Invalid argument + +read -P0 0x3fe0000 64k +read failed: Invalid argument + + +--- Testing COW --- + +write -P0xab 0 64k +{"return": ""} +write -P0xad 0x00f8000 64k +{"return": ""} +write -P0x1d 0x2008000 64k +{"return": ""} +write -P0xea 0x3fe0000 64k +{"return": ""} + +--- Verifying Data --- + +read -P0x5d 0 64k +read -P0xd5 1M 64k +read -P0xdc 32M 64k +read -P0xcd 0x3ff0000 64k +read -P0 0x00f8000 32k +read failed: Invalid argument + +read -P0 0x2010000 32k +read failed: Invalid argument + +read -P0 0x3fe0000 64k +read failed: Invalid argument + + --- Cleanup --- {"return": {}} From patchwork Fri Aug 27 18:18:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462683 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4955DC432BE for ; Fri, 27 Aug 2021 18:44:16 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B61BA60EB5 for ; Fri, 27 Aug 2021 18:44:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B61BA60EB5 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:40248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgpq-0001WM-Vc for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:44:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRM-0001Fg-Oo; Fri, 27 Aug 2021 14:18:56 -0400 Received: from mail-eopbgr20112.outbound.protection.outlook.com ([40.107.2.112]:14422 helo=EUR02-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRL-0006cC-9Z; Fri, 27 Aug 2021 14:18:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TkoZr5qeL/HNLUECZPUr7tMhROWb237mZYyYSETqVlJMOgyfDPPVgZ6d9/lyPMw73I94nATW7nQ721QAyef1u+JAmicZ82N7yNSLjpo9grwbvD4dHYr8lMqX/oS7xu+LXxXikOM4PjOMkj8xMMyd0vT47vQIqC5qPXI+x444sevbgDdSLAHy3HAqB06q63PMbfPkA6Y2CPL+cWTK2ZrMQrgKqifYfCprVjvRQX5CTNmBlY4Ybfbg0mPsuB98td1WHoC4BMk1GZlP7ok7UGuVYYJO5sondi20B+7AUl00pJJfDUGV90gC9r23yqSLrk94+Czj0U/4RQg9zQuNsaa6ZQ== 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-SenderADCheck; bh=id6Ws+1vmuiK1ZDxksT5x56XfzH86Fg5GkxheV5RRo8=; b=AixkWqeg9Wckc9FJsCIQCflykJyEhGIVRzi/p9+OvBCLUUI+Bm9tl99/9KNee/vm65/xcM4Euvds/58BLPE4JGd7K3tb28J8OXVy5KJcULZdABaFFFVZUcXuU9JmoI8t7S5Q9pajSZUgvwB924x5n65Cf7nvVsn+PJ0yj1/z6z8i6MR3wPUK55kgcYrFmLdPC3qqnXsvkjPoCaJy5nxABP2v4U59RRxDpzFr02vM7OQc6c8mmvNDkZwsFT0vmYHzv4QIVBeykk0HMp6mI5tO/ZIBFrh0an1EQJCvNVYiRG6JMvH/aq3w32V3RD2lWN5Y0CGi8V0qfHAY51oarE6LIQ== 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=id6Ws+1vmuiK1ZDxksT5x56XfzH86Fg5GkxheV5RRo8=; b=s8F9AAdl5xjQxYk/xqqpWIrA78VYCPbiN6dR/8WPfiT3rBZSYExOJdDEczzrVbrgAUT0fDndS+r9CWXNRDbJqkFgDFfca4tE1hSNwZqEbHPpqbNQ+RgYuL9GBy9NmDWOLWUwj/cWys9Nnch0lGoZngf0HgpJpL5GHgQ0LvA83eI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21; Fri, 27 Aug 2021 18:18:45 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:45 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 17/19] block: blk_root(): return non-const pointer Date: Fri, 27 Aug 2021 21:18:06 +0300 Message-Id: <20210827181808.311670-18-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d6fb75f5-87cf-49eb-3738-08d969871b59 X-MS-TrafficTypeDiagnostic: AM6PR08MB3765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7bRB9YN8Bv9k9I5cTZn0n5e6dOFAv1rj8tWio3INZGEZATpXhwVHnjowZrGhtC06GgrK2P16L2lFU0m1MjQHiOMYvBfB7ER4scVOe4ik60tmhcYDImfmM/VJYwIfBLvh7Ec7UfhhLWb18JnSpkJ0Tn7xFkSzyKPjc73MNjewIZn8VnhIW/oHOiDat8Km53wAQOwJBpkjoQYaQmBvB7GCWaie4EqthH5XIk2WxAz6jP7N6qBXU9hB/ndX6yOFQJzg5DEC9A8Wel+/cJcdx1Qe6GDSzDtb/fSG/ztA3LBqgT+l7Hn3b+70bckQZUZOdBACJKS7dN7KrneqR2KzFED9jXwDwOZZSwiGwL2GmwUGFWvvT4swP4VFupql4q82usf1Bw7V1IDBfeoHUOC4wuqkCG9flMnAlWSpigSiNjdEcywzdywwOGiR0JcynARCX+XW6do/STOHcwfRi47QwEHnDqZtmp/lDIvrvnONL12N5GnnXLdoeuHguSljXEasKKABNcZOfMfCxOw4Zcsn4CsnGkz4OYa/+7vEwDN0w28gP/HuRWuIhPDtQyvbVnIybYxdVQxNhmueGc9OdV/3bxSE9Y+EYKhgeU2JE77mJBu2T88AdF2BkvIBPP9aIlEdWPtQ5SFlueMA0NhAr7unPPgeJcaJqVQOH1VS7ZQPhQGz8G946jMOcmJ2zROp64m1AbrDmri+eigNA2bqjihZUr/LCw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(366004)(136003)(346002)(396003)(52116002)(6486002)(1076003)(26005)(66946007)(66476007)(8936002)(6506007)(2616005)(38350700002)(38100700002)(956004)(5660300002)(86362001)(8676002)(186003)(6666004)(83380400001)(66556008)(6916009)(4326008)(6512007)(36756003)(2906002)(478600001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: s2kI8X20elvHFtTafuJN8n4j6fpgboD7tu9xkA2BOv5LmJmIkYAoEkLHFtJAXWc8lz94CD8Vg2wSyqzlIuUJGte0a+hSIBpLtiiAQhZboz4P1it8XAbyKsvK4F39mum9aCesCCImg2/DquOwbEw+tv5FDsM5PDSTuLg+nuVVmpVO1LMkWN0s9L8DoHnUBhHfD262OWKBEVfTlK6yWQCUw+Vqz8qidWJI7c6he3ZpCR6iuEt3TG0qySDdiDK80ndUDHOI71o0fQ+6WDmnk8eI6GNElvAazD6Sqdg4429+MDE8Iv3KesuL7G/0FYdQT+ilh4lJhlvp0CszrL3IohBil12Zl1oMO56ae9ccByrRztE8hEaHXmKBbf8DKRTpl3TKs1yShErkXXwsCEHFdvo4dT3dXHihouzClv3TNhXU6ZKWFbXz0fmugBfqFmfpO05rsnJwqIe7GjphLIIifBwnnlOeLy1rAK/5xTYKONauuevd/L9WIIv48Ir6fQU/AnQ+Mp+DJknUFN+SHRXOckGoAtuKXJdN0PpEpLODieVFoJ0Xi0clrppNCG3d/ySfe21fJvOn8Sxa0euY4b/npxelQ7724GbpAnHD5q07+58sUMo0mbo2KNgPQiQKx7eXtp14JWKYhWiXf3a7eI3aaBafzXdt32fXpxjckFqH/pLn1b6hEowYO8iw53IK4Ds8wJTZBmpF9piGWa1bshuhGrFOm19aPP8LQqeNwbNcKvdens6kovEDCdX0SbiXVF91X9ic2ntXbUOnzbJVTN35BqWRD/24fMk/e0/Pfqqcut6Xg+oI4PEhur9wBM8ps9fl2fj8VTriLJNK+3OkIM/iZqzAt1oIpjLKLbelG/GLC4A2+AvnwmR/PI2eQrq6gnFy+av4JjwYAzxRXm6DxflQvs3rBjeE6W2/W4xEhPGXude+DNnF+qRuBexA6926aTbt7IgB/1c3kguamN6biq23D/ABZlMSSVlkKZopv5Zbg+GSbGFK4/VJbrIfPpcqpB6kxmf1IguDHRrCfFfBlnI83jALmoYSAErOnfP4Ps2mnF45NqCHfiTP0oO63rHNINHXkWUBj2hObxpMy+/Xf8yK90ISSoo6BjlrE8NtI3tdlDfCKFsQWM6bgk+F2RdVvt/cA/cc7344ha/YI22zCMTe7oVm6ANq6Umt0z3MVWFDTBaS6s74JQgm3ZNAMSzugGZfJTUny2ePedeAUOu7wmc/MyWM4BHN/EZoqAGqNJkEYm9wKwigu/q9etYlKusEthtQsN5byvlsnckkxcGGuT4Ik6edshQbok8k6On07cKSnFXD1gyFJotxnjHE0i9tUkFarQmK X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6fb75f5-87cf-49eb-3738-08d969871b59 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:45.1502 (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: lK4H9dV8YLYM8Ol9r0xr6A5cJNGLLA/VR9Rzi1Gz+o2H0c0pYjE5G83z1tnIjSQKLpTZNcoPegSLs/0vkOb8Kp901Ozed2Ufx6bs/jtLUdc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 Received-SPF: pass client-ip=40.107.2.112; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" In the following patch we'll want to pass blk children to block-copy. Const pointers are not enough. So, return non const pointer from blk_root(). Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/sysemu/block-backend.h | 2 +- block/block-backend.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 29d4fdbf63..5d4dd877b7 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -271,7 +271,7 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, int bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags); -const BdrvChild *blk_root(BlockBackend *blk); +BdrvChild *blk_root(BlockBackend *blk); int blk_make_empty(BlockBackend *blk, Error **errp); diff --git a/block/block-backend.c b/block/block-backend.c index 6140d133e2..b167c630d2 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2463,7 +2463,7 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, bytes, read_flags, write_flags); } -const BdrvChild *blk_root(BlockBackend *blk) +BdrvChild *blk_root(BlockBackend *blk) { return blk->root; } From patchwork Fri Aug 27 18:18:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7A5FC432BE for ; Fri, 27 Aug 2021 18:47:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 259A360560 for ; Fri, 27 Aug 2021 18:47:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 259A360560 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:45574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJgso-0005Fk-A9 for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:47:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRP-0001KH-Ue; Fri, 27 Aug 2021 14:18:59 -0400 Received: from mail-eopbgr20117.outbound.protection.outlook.com ([40.107.2.117]:18413 helo=EUR02-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRN-0006di-G3; Fri, 27 Aug 2021 14:18:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MPnxXBZ3Fo4kDwYOYqjKo4GiHlXXV/9ivpBWVcXKiIhFYFhxNP1pF/ExSJQxg1wyz6Hq9LBsjQKfwrwiudfNezqJQvGkXnLqNJFRYg55W+ivGUclxvnmqH9pObv2xbaUvNgdylHudw7Vug9rVOFwoqHtCR2KDUDcKnRM8TqHyW0POGNf9YbMUZ+iQagGNzInI3LhTC3N/0DjCho8cYwOzTvoGpB7AJbO/FpbYJdw1kGbTwG4MbM9MVXgN4nRPI+PjuvC/NVy8PVVeTcju27D1C7JS1a8cpIMnVAwsKUUhbZo+rr3ZGyXFxCDzlCAJa8uCFaKooD3b3EaOHpzWXJ9FA== 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-SenderADCheck; bh=e+H+qqSA4DXUqrnk6nIUOc1i9yni28xAe8/2mDTGYbs=; b=lIEAEUPZsYre8V2iyfxSojV+JiMTxI/lla7I71ptsG3cg9vDGDMPKbjvMePVlg2CFWP8f/bOt3s2V4jTWWANA6xnnHvRX+KJXs5JVUbX/m2JWK/VdTuf5WPsOMMcnDIl0QYR/vgozzmkwRHaZ5zFKcMUeOKvKcccthzIydVzHjxs3HBa9XtzdtuLYKvzyB5tAFN5POLXuJYuPaAqI803PwnFd2/J/VunCXhgBAJPYOJwBANvFPBT8IpQLRE4qXxAwdrNJZpa2/FUBupj51AvEq3pX3A9abkSTJcdKVHjppyTy99YQt0JTGlC577xYiCd0y8zhuxaxFXCUOidncpIsA== 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=e+H+qqSA4DXUqrnk6nIUOc1i9yni28xAe8/2mDTGYbs=; b=QhtAOKtluLeyl8IvzVdOI3WL0oib5pH5nnzVajF/JKymANY8/dOpWp4WWxMYLecnck8HirJmT15ShgtfSqdsSyCdvoQezfrUnX9ZAyT2Q+7NgGD3hyJT7JiAJ8xJPsLR785BQ5vh72qOKGkHf1uWmpnG4aSszUhumPT8HNNdR2c= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21; Fri, 27 Aug 2021 18:18:46 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:46 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 18/19] qapi: backup: add immutable-source parameter Date: Fri, 27 Aug 2021 21:18:07 +0300 Message-Id: <20210827181808.311670-19-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 95345882-f4a8-4128-4b46-08d969871c15 X-MS-TrafficTypeDiagnostic: AM6PR08MB3765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E/Wy1UMNY+zmNuOUZyKnHtlw5yeSlfbpalum1mRwv1yFQcyujHs5r7cH7eUF8/PWbXf1yeSEWQ+GSjr/o2d65vQgZjX4beqoBjHmRlvRqgOu+fiq08SxJHpdHRdyUMhk9kXT9k2whD1dY89QvkI+3WfdWH6/RrgQCZcgTDd12QKBiLeqkKdsSpzFeS3IBWp3qUj+R35XQ/sPGZEbhityK6l1bUvFRux2CHYqOejTuVO8RkfwGZqS2UO9cKNHR4goduOep/5yduEcp6nHgFxSIXDGQWKmvXlvPlpOZK06jgcMJTLk5M+tTp4Nc4oLQHy0VbmzLU4Tl5VlVvliXV/kLRxPGDtVFawfEJxh7mdSZQqV+93L4mY+LWjORUwHVtJ/kCmDzr9cwgYqA5y1QH2dmskI/4n9GKOO2d1iy04H2wepdiGDKNyVSsfYHCQl6H+UlAla2zRxEM/o1UgmEnAu9wrV7Zsqj+2Uvt+lYaY4HQeR/m5ZH88fHR700KTqmpccRGWM2RkgJM6zE7MED4NbG2j3mVFBiupgS3TXAQ/ZTfF05RxRCqstyX166KZLOwzTYMXE33PIVmQrdiSFj3YjanEJ7aHj/VNGFfTeXx2tlpGmev6EH+Ww6zp7ujmLWGPFQyxWoYZJuhkpvBF4eQ8/RTc1E7UfwlMqwIgVABqJ0piswuX93wyjf3xSwsQsmViuE3/fyzroBBCHHTUfZ9iuGg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(366004)(136003)(346002)(396003)(52116002)(6486002)(1076003)(26005)(66946007)(66476007)(8936002)(6506007)(2616005)(38350700002)(38100700002)(956004)(5660300002)(86362001)(8676002)(186003)(6666004)(83380400001)(66556008)(6916009)(4326008)(6512007)(36756003)(2906002)(478600001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: htVWXLpv7TyBVK2AfycBPfmb3pGUXBaGcOyitgL1UPWKDLapFwBW/gkWWYX871uWkXOUl8wGMFY6i4zp+HqBtWNA/H8ruf/tNiTgzd90ntfS5CKYXeyRXdLHVo8wIFyMAz5joMlUz5wQa9L5ZO7ItNUdJDoK/euYXu2rWW1sjF8RI9p43FhY3xuFNFrDyiPIdG0aAbz/sRdX17UQ9cP63xhAIJHa2+Zn/TLcwsQs5yigO0ntO97NGv92lOLW34HGV6Nk4nw49wIlGZyG37llhk2b/KEOB8E+GEc8y8deIoOcrgCIpv5zQFiuSfizrA4o4R8X+Ny42cHer2QFCKRs23wVmlv/rxSBt9EYhZUIusfwXx5xTVY+UHD9i5Y7sjluLTqat1t45v4ot9AS85pFnm/+9s/mZPApuVsa8J4fgdNGeHsXduVs2ymwjYtBY+WXcxwLgIqExshFNSqywQIg5IU6duWGEaoBLLE2PQoJd3N8qIaoQ9bdnfkS+r2w208xQzsw7K3DKqjNu0UF5cH6HDmSEcJikXGwaXUDk9Ey664WN8+y46/zNXYb0D2b0SbHynpm+dHdAkXFTll22Mq1aVLhhE7r0mDbJG7WHvfCyiv7xTGJ4StikM8vbDtlXiMEHttFnunt+rXywz3rHKm6P/bPgXldqKBhCFR1vy5h8eM4qWngu7IUpuX/honv6q2UmMqQ81t8ff0DQu6e0Jhgyq+3fx1hoihAZZ6LEWwCITJUOm+iHpfyAROS4ErNgXQ/2u1472+aTZkRHMKCZtpUk8SiEUbZUahFTMVsJmUXW4ZC2qjukoFi/k2QwfBvc/9v+StF0Y1aM9FghW8ylvY6W1MmWD2YPf2nsDf3VILsxP4Wx/NePjWugb85Nl9vedId4+Fjs+bZLYRxHbI53snUCpo3L0GeAgFYVTyYi3utbgzmP+tnbyKo2zw4ZwWwNqxPShkCPOVFH0SaGVHEK9FBoAW2cv1wP/GVgNE8ZwL+1OEZBttw0xQrCOm4MPSEV55FnFI2RX+h7loLIm981aEB3YuK58nWlQKHyhAiSFCnA16ydlOhnO41jP0EdH24oJGmzB4NO658dQ5bzcgza4vXagJ4KO6hnzUMZoZIoyYcO2TLeaU/1aZXNr9We9ya30BLGhTmli2B8qJW3laexd9E8UfeMqvxS6kWGKkuC88bVrdNngWVIjpys0OSJ2EKwjaKKQEX0E+nQAhTimaLLDwrnqfocWEFV7wcbsbxvE2jT4oxJVeo8e7tX6CP7UOGwAQzH9wAG3fL7G5wQNJeUB7u9pQkHxiJOM1Sdr3kLdJZYDV2Te32849UZ9eHBLqIS4pp X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95345882-f4a8-4128-4b46-08d969871c15 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:46.3509 (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: wICWSEzunN7C2JETW6To4sm+Z2C7x2WIaaUAYjpEUGvJohRvLYm0lCU9B7ZG/hbdyeS5FHgQiVBPTMy73yVauNKzQdu13L6foySMzDHxqM8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 Received-SPF: pass client-ip=40.107.2.117; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are on the way to implement internal-backup with fleecing scheme, which includes backup job copying from fleecing block driver node (which is target of copy-before-write filter) to final target of backup. This job doesn't need own filter, as fleecing block driver node is a kind of snapshot, it's immutable from reader point of view. Let's add a parameter for backup to not insert filter but instead unshare writes on source. This way backup job becomes a simple copying process. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 12 +++++++- include/block/block_int.h | 1 + block/backup.c | 61 +++++++++++++++++++++++++++++++++++---- block/replication.c | 2 +- blockdev.c | 1 + 5 files changed, 70 insertions(+), 7 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 8a333136f5..995ca16a5e 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1391,6 +1391,15 @@ # above node specified by @drive. If this option is not given, # a node name is autogenerated. (Since: 4.2) # +# @immutable-source: If true, assume source is immutable and don't insert filter +# as no copy-before-write operations are needed. It will +# fail if there are existing writers on source node, as well, +# any attempt to add writer to source node during backup will +# fail. @filter-node-name must not be set. +# If false, insert copy-before-write filter above source node +# (see also @filter-node-name parameter). +# Default is false. (Since 6.2) +# # @x-perf: Performance options. (Since 6.0) # # Note: @on-source-error and @on-target-error only affect background @@ -1407,7 +1416,8 @@ '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*auto-finalize': 'bool', '*auto-dismiss': 'bool', - '*filter-node-name': 'str', '*x-perf': 'BackupPerf' } } + '*filter-node-name': 'str', '*immutable-source': 'bool', + '*x-perf': 'BackupPerf' } } ## # @DriveBackup: diff --git a/include/block/block_int.h b/include/block/block_int.h index f1a54db0f8..6571dad061 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1284,6 +1284,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, BitmapSyncMode bitmap_mode, bool compress, const char *filter_node_name, + bool immutable_source, BackupPerf *perf, BlockdevOnError on_source_error, BlockdevOnError on_target_error, diff --git a/block/backup.c b/block/backup.c index 687d2882bc..a7f4d0d663 100644 --- a/block/backup.c +++ b/block/backup.c @@ -34,6 +34,14 @@ typedef struct BackupBlockJob { BlockDriverState *cbw; BlockDriverState *source_bs; BlockDriverState *target_bs; + BlockBackend *source_blk; + BlockBackend *target_blk; + /* + * Note that if backup runs with filter (immutable-source parameter is + * false), @cbw is set but @source_blk and @target_blk are NULL. + * Otherwise if backup runs without filter (immutable-source paramter is + * true), @cbw is NULL but @source_blk and @target_blk are set. + */ BdrvDirtyBitmap *sync_bitmap; @@ -102,7 +110,17 @@ static void backup_clean(Job *job) { BackupBlockJob *s = container_of(job, BackupBlockJob, common.job); block_job_remove_all_bdrv(&s->common); - bdrv_cbw_drop(s->cbw); + if (s->cbw) { + assert(!s->source_blk && !s->target_blk); + bdrv_cbw_drop(s->cbw); + } else { + block_copy_state_free(s->bcs); + s->bcs = NULL; + blk_unref(s->source_blk); + s->source_blk = NULL; + blk_unref(s->target_blk); + s->target_blk = NULL; + } } void backup_do_checkpoint(BlockJob *job, Error **errp) @@ -356,6 +374,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, BitmapSyncMode bitmap_mode, bool compress, const char *filter_node_name, + bool immutable_source, BackupPerf *perf, BlockdevOnError on_source_error, BlockdevOnError on_target_error, @@ -368,6 +387,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, int64_t cluster_size; BlockDriverState *cbw = NULL; BlockCopyState *bcs = NULL; + BlockBackend *source_blk = NULL, *target_blk = NULL; assert(bs); assert(target); @@ -376,6 +396,12 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, assert(sync_mode != MIRROR_SYNC_MODE_INCREMENTAL); assert(sync_bitmap || sync_mode != MIRROR_SYNC_MODE_BITMAP); + if (immutable_source && filter_node_name) { + error_setg(errp, "immutable-source and filter-node-name should not " + "be set simultaneously"); + return NULL; + } + if (bs == target) { error_setg(errp, "Source and target cannot be the same"); return NULL; @@ -450,9 +476,30 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, goto error; } - cbw = bdrv_cbw_append(bs, target, filter_node_name, &bcs, errp); - if (!cbw) { - goto error; + if (immutable_source) { + source_blk = blk_new_with_bs(bs, BLK_PERM_CONSISTENT_READ, + BLK_PERM_WRITE_UNCHANGED | + BLK_PERM_CONSISTENT_READ, errp); + if (!source_blk) { + goto error; + } + + target_blk = blk_new_with_bs(target, BLK_PERM_WRITE, + BLK_PERM_CONSISTENT_READ, errp); + if (!target_blk) { + goto error; + } + + bcs = block_copy_state_new(blk_root(source_blk), blk_root(target_blk), + NULL, false, errp); + if (!bcs) { + goto error; + } + } else { + cbw = bdrv_cbw_append(bs, target, filter_node_name, &bcs, errp); + if (!cbw) { + goto error; + } } cluster_size = block_copy_cluster_size(bcs); @@ -464,7 +511,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, } /* job->len is fixed, so we can't allow resize */ - job = block_job_create(job_id, &backup_job_driver, txn, cbw, + job = block_job_create(job_id, &backup_job_driver, txn, cbw ?: bs, 0, BLK_PERM_ALL, speed, creation_flags, cb, opaque, errp); if (!job) { @@ -474,6 +521,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, job->cbw = cbw; job->source_bs = bs; job->target_bs = target; + job->source_blk = source_blk; + job->target_blk = target_blk; job->on_source_error = on_source_error; job->on_target_error = on_target_error; job->sync_mode = sync_mode; @@ -501,6 +550,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, if (cbw) { bdrv_cbw_drop(cbw); } + blk_unref(source_blk); + blk_unref(target_blk); return NULL; } diff --git a/block/replication.c b/block/replication.c index 32444b9a8f..5dba4907b8 100644 --- a/block/replication.c +++ b/block/replication.c @@ -590,7 +590,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, s->backup_job = backup_job_create( NULL, s->secondary_disk->bs, s->hidden_disk->bs, 0, MIRROR_SYNC_MODE_NONE, NULL, 0, false, NULL, - &perf, + false, &perf, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL, backup_job_completed, bs, NULL, &local_err); diff --git a/blockdev.c b/blockdev.c index 3d8ac368a1..3a8ff7c5ce 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2911,6 +2911,7 @@ static BlockJob *do_backup_common(BackupCommon *backup, backup->sync, bmap, backup->bitmap_mode, backup->compress, backup->filter_node_name, + backup->immutable_source, &perf, backup->on_source_error, backup->on_target_error, From patchwork Fri Aug 27 18:18:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12462661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B281EC432BE for ; Fri, 27 Aug 2021 18:35:50 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1E249601FF for ; Fri, 27 Aug 2021 18:35:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1E249601FF Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:53790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJghh-0007uS-2z for qemu-devel@archiver.kernel.org; Fri, 27 Aug 2021 14:35:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRQ-0001Nn-Ox; Fri, 27 Aug 2021 14:19:00 -0400 Received: from mail-eopbgr20112.outbound.protection.outlook.com ([40.107.2.112]:14422 helo=EUR02-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJgRN-0006cC-Gs; Fri, 27 Aug 2021 14:19:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XVX6dQxRD8yS6AUxLm16Pl6Myyk1H8M+A7WhqB5sHCmpIRUPMxxDvIAikl5RsTPQR9jxfeTaU6E1FnTKULZHnKpkGOwtqoxjeY1ePw3YbYeP+483Vbo2/xzUfW+eMG8zOTUEpIxlWFWxwpBGLwdPi9w+CpnBnyHj8CJABgYRqD3UMCSg9b6+/ubMj+NqKW03d6ZlrtmhokbDIgMo81WuYkISphHLhVHHRWgBAekIylnAigz91H/cXxUHRAlWquZxrMsW2MSnmI/hB6j9/UAIrxO9hX1E3uEc87FOTumiTYNkcHOKEr+HRzDbzxhJx+qBjup5k7u+Zxl9kQ+iDiERBA== 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-SenderADCheck; bh=iIAV9rPRuG54n1EJskJ1OsHwMYQA+RAvEpN5U56jkic=; b=cmSknsQBzn5Sm+Aizl07O+6FBGHRsS3CmodnOSsiG7oI7s3Huyr6ZIpEDI6I84lR8O7pSXkaAPKlWNkJjDmw+EaqJ35DFyZYPAunDsvT7fEhHTIIMujfN4AyJQ5t06ri3sSrSY2vawiyp4CjrjxEkitIj/t8mxkIkeZVvSo5HFmAo9yNKWySSonCncaZVYYFXuUv4nAqVcZGBzUon3LWTLA583pXUmaSRq0QO+dmPt/n1A7dR+WXzje258IhJMWOaT59YcitE2Yhb6qWB4dU7zjbxbV0FkWc63Y01rK2L5iQAcVf7s6Mmtb8G3fSmQ5J6OOC0h2+sRF1+xeJDZBQyg== 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=iIAV9rPRuG54n1EJskJ1OsHwMYQA+RAvEpN5U56jkic=; b=IWSa8m9NO0VRNw+aPQ0evSvi9J0phe5JpJ/d7u+bGddGHp1tCLzUJAaiCIy9lEWQM6Wf28IC6VLKfVshG3Dm9X2aav+PSKwLk2nSgul/OPc6Hx84uRCBNw+SGmFtoSCy7PRzV/xZMSk0Nx5+Of1YOgT9ETA2DvBSi2VX2puiFfc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21; Fri, 27 Aug 2021 18:18:47 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%7]) with mapi id 15.20.4457.023; Fri, 27 Aug 2021 18:18:47 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH v2 19/19] iotests/image-fleecing: test push backup with fleecing Date: Fri, 27 Aug 2021 21:18:08 +0300 Message-Id: <20210827181808.311670-20-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827181808.311670-1-vsementsov@virtuozzo.com> References: <20210827181808.311670-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.220) by HE1PR0402CA0012.eurprd04.prod.outlook.com (2603:10a6:3:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Fri, 27 Aug 2021 18:18:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0f8b6643-ff59-4b6d-9966-08d969871ccb X-MS-TrafficTypeDiagnostic: AM6PR08MB3765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:580; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WfMiNZ9lVuO5r0U08TrMQGEHl2gpQJNW2VEGkV5zanMBkHBAF8Y+fbgobnVCEmnGFOIzs9aZMEcm2L4b0t6u7TrOaQsushAjBObEJGt7Rk8MsUSnVCW9PJLW4PbUPmjj7Ao8dHdGH9HtDHNKi92yK4cJqGYmxvR5pY5f8XGIv0tTLNNLTfiTN9JVwXLZAYRk3bGRsWMYrwBMUkZx34VOkHrzfA5zzSc9kCpgP1ewk7zMGv6PJQD+xLPu+7mQ25Ux8/JzLVwYSzp8WIAqkPKHIwdKicR04eSOHpeeW3MSTUw1q/1+2JgQMFrpWmfiG1K74DMcG3jh8FMi1gDgQOtoSKorBF9ehVD2c/FQfwHhOU+6rsVwhbHuE0mjIxHgECXXTyubUSZazrw81r/BfgcztZd5kiBlg9qzk0oogmlLpX7Jp6aW+xvEe3+q6SBIA8b71zOqgguNqKOLobQDk1Zd0p9LKGD4ahTfLy7TdHpUFUgGzXTksYstge1Dpoi6nnJwIybKMZd5+3PgdoaulHdL6SSAQcKswmcJuKM5cVivrfrgXChs2sLNxzGr537WXMODKVBQzsMcRqs7UUlUpaWnn4ACqWJ0OuuYczSoY/EhuHL57OqCERXS7v+DxAmIG5vN9kXXGCvmj+wwfewvZ9OQ2Zq/I3cAlRFNJVXR0nLnpX9r/UEUB6uWGBbRGoWSvF5zDKPpzGagoC02VkUECTG3sQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(366004)(136003)(346002)(396003)(52116002)(6486002)(1076003)(26005)(66946007)(66476007)(8936002)(6506007)(2616005)(38350700002)(38100700002)(956004)(5660300002)(86362001)(8676002)(186003)(6666004)(83380400001)(66556008)(6916009)(4326008)(6512007)(36756003)(2906002)(478600001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gQcQRLO4Mte77q14PH0WgotGUAdep9s2gQaoGKL2krGZ7DythDzxT1PaqmcEeVYF81LXGaQdDgc67q4sVbf1aymDuZMDijYksTrX6bOKKxWe2YUCVpxV9jPdUvo2xH0LDVuY4EpUCNcREJYYJwORBJPUCQAUF/TzsVBJAEF9qbof6js9KM5ejoCPfe9mK95sNc19romuAU93Wxiozq7oF7ChWCriYtyFJ2fBn0oWU0kFUGmj1MG0wOGkX4bDYul+NCcEm2I0M6SzV2EKYR+XGkxU4jsK0rXEn/SEensnqfy9ar2FHPeu17LG0fbCrFPkdVIJIR6Fb7noYJEXebs6o4ypm4m2JwX2huEEK/BonrYVphNf+Qok58BVOsePzHFcflVHoEKM7H/h4CF0TOMUncR3Gw+nHO81wJYrnU0tiGQInhPkWFTJelSWMtB++j17m8ooxYlAey49HBCL1aX9QBgifOZKJS164GmV8Xe7Afp0J5I6YFSprosV827TlNVf1tM6VG/zQ+1WfXIh5ax8XVdDknzrXZ9PJTNqZHGd8qQxWIMpK6616evAmMPrLkW+sfz4VCRNvFnHRWeQUaGBWwQbYkg+zhZi0tmaguPZtdUbliqQTvZbkJQeuU7vudXP+/aCwXgzfWedBuM+b2SL9VxGiuAq7h6so62Wrg+E208uZk4CEGjE3B9ZePGd4OBiHdNE1ZrduUK0YfAz7Y3hnI2Gdj70yI+QqlqeUwNZSmLXJNIVbtan8d3lL2wDyCRUS8R43hbtXS36Jgn67VM0pXlWPm+OeeFC8KofJRI2qeAC9eoaeP0zV8a5XqO66YiEKew23SC61VAgbBkyH0uS/EdXHY1syrI0g9SxU5wvkup65w+xNL7XM+Hvq0lhz/lJ6v/+eItqH0PnNM8oWoe7fl+BP3Yy5EfpyJ1tGDedAzb4sFxbBIPbiIQyCM2pyhIitPGhBjB0oMdjuWcfyqE+QcDLV0zusmpoQ5sjR+V/RougwBvMP8F/pj2qY9knvvZFnc+UQzPccw7EuakCOV8+kgwwWdER5ApVcpPDqCfrigbuvNNqnjstmw6HU5OoklZJMzI8bB339lix6vDMV+YobhTgybqPKIjpflL9rOS0iVq0+cifUJUKZuP5TMetDYjSuL878WGkUlaG6xL7UaU1FdbbEZWJN1xl05KXM6eBuNHandXZoZSfV0X2/yDOSB0/5wyqBPDHaY2348L3E8hYL7Nb3PpdWxGL3Iz2ffuXIpd9S416RAK0e/JxwZTR7mHZqNGAg3VilbgXNlIbev42FORulvn6yPu2NoS7gnkXMh4N2FaVog2s5WQpaBmSHt8j X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f8b6643-ff59-4b6d-9966-08d969871ccb X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2021 18:18:47.5616 (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: vmaFGsuNJX+7rwgQl865M/VTybfpLXIfGFliXHaJ2tkzkT6Ytl6DmefpwVVhLzLSYqtRCYllbBiXed3aG1+Jv6TVyCOBy/cAZSsMP3cQt2o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 Received-SPF: pass client-ip=40.107.2.112; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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 test for push backup with fleecing: - start fleecing with copy-before-write filter - start a backup job from temporary fleecing node to actual backup target Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/tests/image-fleecing | 121 ++++++++++++++------ tests/qemu-iotests/tests/image-fleecing.out | 63 ++++++++++ 2 files changed, 152 insertions(+), 32 deletions(-) diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing index ab95e4960e..ed57358e5d 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -48,9 +48,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_fleecing_filter, base_img_path, - fleece_img_path, nbd_sock_path, vm, +def do_test(vm, use_cbw, use_fleecing_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('') @@ -64,6 +70,9 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, else: assert qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') == 0 + if push_backup: + assert qemu_img('create', '-f', 'qcow2', target_img_path, '64M') == 0 + for p in patterns: qemu_io('-f', iotests.imgfmt, '-c', 'write -P%s %s %s' % p, base_img_path) @@ -139,27 +148,45 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, export_node = 'fl-fleecing' if use_fleecing_filter else tmp_node - log('') - log('--- Setting up NBD Export ---') - log('') + if push_backup: + log('') + log('--- Starting actual backup ---') + log('') - nbd_uri = 'nbd+unix:///%s?socket=%s' % (export_node, nbd_sock_path) - log(vm.qmp('nbd-server-start', - {'addr': { 'type': 'unix', - 'data': { 'path': nbd_sock_path } } })) + log(vm.qmp('blockdev-add', **{ + 'driver': iotests.imgfmt, + 'node-name': 'target', + 'file': { + 'driver': 'file', + 'filename': target_img_path + } + })) + log(vm.qmp('blockdev-backup', device=export_node, + sync='full', target='target', + immutable_source=True, + job_id='push-backup', speed=1)) + else: + log('') + log('--- Setting up NBD Export ---') + log('') - log(vm.qmp('nbd-server-add', device=export_node)) + nbd_uri = 'nbd+unix:///%s?socket=%s' % (export_node, nbd_sock_path) + log(vm.qmp('nbd-server-start', + {'addr': { 'type': 'unix', + 'data': { 'path': nbd_sock_path } } })) - log('') - log('--- Sanity Check ---') - log('') + log(vm.qmp('nbd-server-add', device=export_node)) - for p in patterns + zeroes: - cmd = 'read -P%s %s %s' % p - log(cmd) - out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) - if ret != 0: - print(out) + log('') + log('--- Sanity Check ---') + log('') + + for p in patterns + zeroes: + cmd = 'read -P%s %s %s' % p + log(cmd) + out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) + if ret != 0: + print(out) log('') log('--- Testing COW ---') @@ -170,6 +197,20 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, log(cmd) log(vm.hmp_qemu_io(qom_path, cmd, qdev=True)) + if push_backup: + # Check that previous operations were done during backup, not after + result = vm.qmp('query-block-jobs') + if len(result['return']) != 1: + log('Backup finished too fast, COW is not tested') + + result = vm.qmp('block-job-set-speed', device='push-backup', speed=0) + assert result == {'return': {}} + + log(vm.event_wait(name='BLOCK_JOB_COMPLETED', + match={'data': {'device': 'push-backup'}}), + filters=[iotests.filter_qmp_event]) + log(vm.qmp('blockdev-del', node_name='target')) + log('') log('--- Verifying Data ---') log('') @@ -177,15 +218,19 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, for p in patterns + zeroes: cmd = 'read -P%s %s %s' % p log(cmd) - out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) - if ret != 0: - print(out) + if push_backup: + assert qemu_io_silent('-r', '-c', cmd, target_img_path) == 0 + else: + out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) + if ret != 0: + print(out) log('') log('--- Cleanup ---') log('') - log(vm.qmp('nbd-server-stop')) + if not push_backup: + log(vm.qmp('nbd-server-stop')) if use_cbw: log(vm.qmp('qom-set', path=qom_path, property='drive', value=src_node)) @@ -214,24 +259,36 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, log('Done') -def test(use_cbw, use_fleecing_filter, bitmap=False): +def test(use_cbw, use_fleecing_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_fleecing_filter, base_img_path, - fleece_img_path, nbd_sock_path, vm, bitmap=bitmap) + do_test(vm, use_cbw, use_fleecing_filter, base_img_path, + fleece_img_path, nbd_sock_path, target_img_path, + bitmap=bitmap) + +def test_pull(use_cbw, use_fleecing_filter, bitmap=False): + with iotests.FilePath('nbd.sock', + base_dir=iotests.sock_dir) as nbd_sock_path: + test(use_cbw, use_fleecing_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