From nobody Sat May 18 23:14:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1626876436; cv=pass; d=zohomail.com; s=zohoarc; b=azMhAyvZmi6qQhddfJEk15ZjR+c0CBNYN0yL8dyIcFAkKSh+IWbV3TlF4BihxpbajZOeE5tCykCVAbH6iFpeQpZcL1V7ywPyVZ/PmCIqaPEzz98CWbYdEGtzuVqDrvGgaA27DU//7wzCFbhIx0xNChFQ7NRJaKKJopjVqRadsOc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626876436; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qKVGlcs7J41JcZcGNtCz5zh5Fph/2zhGg8FbNDDs8q4=; b=Ou4u5hRUSaLUNvtN2K0LpPXsY5m+MnZRICV9DmUm05xdxCgV008Z7qUJuzMYs/4emFu4lMxMf2RNy+xDFCC76N+blbGKLVtrMBi+HT0uVtY3tMWrM7+gema/oNpSivHror2sQn34JbLrgtdPvLtBCWxgDpQpVZjxwi18qUTIp8E= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626876436732732.816072585875; Wed, 21 Jul 2021 07:07:16 -0700 (PDT) Received: from localhost ([::1]:33300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m6CsV-0005D1-AS for importer@patchew.org; Wed, 21 Jul 2021 10:07:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6Cq8-00020s-6l; Wed, 21 Jul 2021 10:04:48 -0400 Received: from mail-eopbgr80105.outbound.protection.outlook.com ([40.107.8.105]:17431 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6Cq5-0007Ca-8X; Wed, 21 Jul 2021 10:04:47 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24; Wed, 21 Jul 2021 14:04:40 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%6]) with mapi id 15.20.4331.034; Wed, 21 Jul 2021 14:04:40 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 21 Jul 2021 14:04:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dPyonGcO6M/QUKKpiA/O3HJRYhYo4w85cmIQ58CWvrg5sBpAIfJijqLUCGfip4Zua0CcaJW2ixEE0rLcdyJJEKnselk6ieaLTx/MDD4WxlkXw6nExxOYcYRg99+L39MbakPS9itHAyqTmGiOCt5GTc9B/WuiJmkFUZySZ6skkR/STB9HZgGXKlGtmdgY/W46vnY+AR7M8Rk2pnPO6i8BItOTIptUNSyNW0JAUfparzdifjr9vDyqcm5sr1d9ZKVlYBy3pUoIQbUDsVNA9+1f8wvRMoLQOgt600b4YTbDWbJoxd+M+KcrmWIozW34HQ4cRScR4PLT2JjHwqc8aw81Kw== 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=qKVGlcs7J41JcZcGNtCz5zh5Fph/2zhGg8FbNDDs8q4=; b=XGCK4MTT6WNHVOPen/erIiW9NeIYKrSMi3GewxoJqo9TscGg3+xx42XoJ2saHXxyvFZDSgMxWSsCNwRVFPP4HwTLu9UcFH5iuftkfMEbCRc95WatHKk56s4MtGEdm0v2E7d3kZ533EmDTgOWmEFkdghzLw/J5q1WS1eGaYOZ/YS/aqebITT71ZYusR9XRPcvlcoSB5n+66WIJTeyxGKkH9jl3HaZS0EZ8XiEUGYdOHCpe2QEoTsHuyBoo03Rq9uxDfrgJ0UYfwMJHfpd3OXrJnk4PZyse9wnCajbL9S+l9ysLtqDpyaLLLkMJVXr3jyoexrzFbjCQYAC/XtChldMJA== 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=qKVGlcs7J41JcZcGNtCz5zh5Fph/2zhGg8FbNDDs8q4=; b=NGkUjo05v/mO2zCH/AmYR0bsWLihf5g6LQdrcDmKFkZ/nAxGTbX9lCBP7YCB0odTsXoYKJTaLS7ybz5apKMZ2QeWJlwzme1BI6r18N+SAPIQkYKhG68ejs0pGAgNYN19J7xHmZafMpFLpIMoWl/DBedZDoPUcPk/H6sj2i3OPwk= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, vsementsov@virtuozzo.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v2 1/6] block/block-copy: use write-unchanged for fleecing scheme Date: Wed, 21 Jul 2021 17:04:19 +0300 Message-Id: <20210721140424.163701-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210721140424.163701-1-vsementsov@virtuozzo.com> References: <20210721140424.163701-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HE1P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::26) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc920127-3491-4cd3-6b82-08d94c507ba8 X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1051; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P2p19WT5YeH/xJZW8yalm7IBMrUseliM46MqEstXRRGHVN06/L+aVi5Bzm/L40oJRy2XL8i1/zuBrLPzCM+38N/zZ1RTsENdzA3bEyDNU46sDetR1FRv39Jm/ZqsU4Pat7YfqR9fVWSgyz2UFu4QVizYEhXegHP4D+vy4U86xVBvxEOOfSIdwOcu6Q1S+/EQ2rBmySNLfUiWjq1r3XsDsBw1v9jFY/Y1PuZvz05avsmckLS29BCU2WkWm1nHdbVid+N5x+6KW7IE4bctfaDZELOVUH3zYN2lduaWM8v/2Y2kuGGGp5ViSgxKdGkTqLxWwgDMhgXLkXiRl2LmuR/aXGl4Wy4TAARGniPY4nJBn+DDyjaKdmaDnq6LuJ23GV+1JSIAH4sW/Hi/xytTSHaoTRS06+krWFbrgBPyKoAfLglwXvFIE9DjCPjDAdMN3wlKv5h/TbxYCjq86p+4UVsvk4LkwOj4RBaLT4HUgP9hykoAEp3FFTwa8PbkyWHlTAhKe9udwwHaH3YRcHm2pVnHj42j4Dz7NGrmBfvjGpygTYERI8bk2kTU2HysQtqHQpGlF+AehYyZKZ8WqbADlcOnOOmtCKzCB/N/oKydfHl46qYtalyxYFW7J2BPh0yJlIPNjBTNlZp3hB8EljxqGCb6+zsOjX19F6Z+j6Ewoe8USBUn+tppCV30W2rqq8L1s/D9LsvslBN/Vzu2RSgz3LdQrQ== 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)(366004)(346002)(136003)(396003)(39840400004)(376002)(38100700002)(5660300002)(52116002)(38350700002)(2906002)(83380400001)(956004)(1076003)(6506007)(6916009)(316002)(6666004)(66946007)(66476007)(66556008)(478600001)(186003)(4326008)(36756003)(6512007)(86362001)(26005)(8936002)(8676002)(6486002)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?/4oxgLbXogkvJm7bgz9DmhkgfVVxEjFsMHPZ0Nix/Y2ahMqSetf1MhIC3S9R?= =?us-ascii?Q?gAQoFRm2XRppE6WIu2/rEJQbE7nE2Td5+3flyKQVzKF7NrChb342sgFBJ5BT?= =?us-ascii?Q?z2DROxRWKWbSGjXJK9RKtZnuCOSMODK9AabhHXs3OXuYLeXLT1UDeCNqZUCg?= =?us-ascii?Q?98tvSwfUVeOAGemko7YBEjwlIiTODyWishgEBSO5bp2RhGiv7PFoEcEZ1KWy?= =?us-ascii?Q?TxeWvxrDZmJuxYYnxwX24T/w6r/FIJzvVqOg77NWp2DcxfAhmNkjV/R+a9lB?= =?us-ascii?Q?XU8Q/UwxKG0dtDSWSTT41pLmOGTB7z5cZXyEfxExpb07/JatUG6HFdf9VD0z?= =?us-ascii?Q?m/NpuhRFoCEAE6CKPLXGNwEpdNH1M7Ys36XOkCDRocw/EbEr+kVer6DGyuAw?= =?us-ascii?Q?RL8iilVFnBrFXpZnfwrijDjAkKfWcPDgBZaMStjieFvAxguoaVeY/TJ+8ndC?= =?us-ascii?Q?zXeMRn4WTH8MjTqmOgGIPVFclNlGDDgAbT8utBum6I9KJRncC/DRuXIugmO5?= =?us-ascii?Q?Btda81mNd47qPL9K4REv4WlChowZY2APFqCdTHXzHtyRnM7rJN9ihI38R66h?= =?us-ascii?Q?m/6l5K+yv0ZS/omai0yLCR5QG/JHe6ksTaBPAeCVj8dFHZUc21I1yC1iLo5T?= =?us-ascii?Q?20bvyc+X2GAO2XlkxPx6ocyQdJZMfW7DvDNYeXeoAz+59M1Xbpsk4NfHsVWM?= =?us-ascii?Q?VuoBRPcKo5BGb70teo2nBBEzLFpWalKtJWHGHKgQLaa720Ec19em9J0flShn?= =?us-ascii?Q?GIoc95jN6jU/0L3+qJvyD84UfGqcFNe3G9bEXwTAzE+dW5nC+K3Mlmk3aIgl?= =?us-ascii?Q?3mOUkfRAMnSoqlqhJ5yBhdniQ93obPGBXwn9Y+rD4YN/sW++LXuXuC+WRrNh?= =?us-ascii?Q?l8gEfQwaA9VtSh7TUZBsqZFKIM5Y1xfI/io44oYwViUGNKC4FlV0NwgrIL5E?= =?us-ascii?Q?xRCCaXsp1Gxoq5lcI0S8qFepxHygf+WVWRQB2MmxBPoBFNIs+84WR0LyIRxb?= =?us-ascii?Q?U/j5OJInU+q5YS6OTens0fTtkNSQ82tixGt3f4Yv+1m5Y3EtChFvC9mAaq6F?= =?us-ascii?Q?x0TJ+BhFRMmynnDIfbWJo2U6s2nZ5KbsqxEg6c+ArZCYrkqk2lwCE0e5O1nY?= =?us-ascii?Q?jDtMyalva8WhWpp/nt/aniuAIdtMTrQNJ5mOpGAoG43ZEnBOW3CInge9OU1I?= =?us-ascii?Q?HMBq4d+g+BUoAGLhKuMrR3UseVasUEJ0+zAR4Bow/Am7CTAuVrw0M7qqzwU8?= =?us-ascii?Q?V9RufdXJ6Upx8zCXyY8lh4THmILo5FkHpMGs5YBde+0Gipb3mC12Xf2/vh25?= =?us-ascii?Q?6P2hEY0XUKeCfQ6seVt9Hmyb?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc920127-3491-4cd3-6b82-08d94c507ba8 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2021 14:04:40.6809 (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: zr2zKRq3acDlwFi7XXshB/ge9qkNhcn6Dk5e+diIDBZKEIwErQ5NDAaholeNbHSuDYNsoInmxMAWkFGHS9oPsGHXrAYle3aKnPqlJTWt9RA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.8.105; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1626876439958100001 Content-Type: text/plain; charset="utf-8" We are going to use fleecing scheme for push-backup, so that copy-before-write filter does copy before write operations to temporary image and backup job copies data from (immutable from backup's point of view) temporary image to actual backup target. For this to work properly, backup job should unshare writes on immutable source node. copy-before-write filter should do write-unchanged operations for this (they are really unchanged, as source is a backing of temporary node). So, we want to teach block-copy to do WRITE_UNCHANGED operations in case of fleecing. We can detect fleecing on initialization but that's not safe enough: block graph may change. We can freeze the backing chain of target to avoid changes but that's not flexible. We can detect fleecing before each write but that's an overhead. Actually, we'll have to detect fleecing in copy-before-write filter anyway, to chose correct permissions on target node in further patch. So, we can just add a possibility to control adding BDRV_REQ_WRITE_UNCHANGED flag in block_copy, like block_copy_set_write_unchanged(). Block-copy doesn't own source and target child and relies on correct permission handling by block-copy user. Finally, let's go the simplest way: just do WRITE_UNCHANGED if s->target has only that permission currently. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/block-copy.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/block/block-copy.c b/block/block-copy.c index 020c8d7126..a850684ac6 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -114,7 +114,10 @@ typedef struct BlockCopyState { /* * BdrvChild objects are not owned or managed by block-copy. They are * provided by block-copy user and user is responsible for appropriate - * permissions on these children. + * permissions on these children. Note also that block-copy will + * automatically add BDRV_REQ_WRITE_UNCHANGED flag to write operations= if + * target child has BLK_PERM_WRITE_UNCHANGED permission but doesn't ha= ve + * BLK_PERM_WRITE permission. */ BdrvChild *source; BdrvChild *target; @@ -508,6 +511,7 @@ static int coroutine_fn block_copy_do_copy(BlockCopySta= te *s, int ret; int64_t nbytes =3D MIN(offset + bytes, s->len) - offset; void *bounce_buffer =3D NULL; + BdrvRequestFlags write_flags =3D s->write_flags; =20 assert(offset >=3D 0 && bytes > 0 && INT64_MAX - offset >=3D bytes); assert(QEMU_IS_ALIGNED(offset, s->cluster_size)); @@ -517,9 +521,15 @@ static int coroutine_fn block_copy_do_copy(BlockCopySt= ate *s, offset + bytes =3D=3D QEMU_ALIGN_UP(s->len, s->cluster_size)); assert(nbytes < INT_MAX); =20 + if ((s->target->perm & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) = =3D=3D + BLK_PERM_WRITE_UNCHANGED) + { + write_flags |=3D BDRV_REQ_WRITE_UNCHANGED; + } + switch (*method) { case COPY_WRITE_ZEROES: - ret =3D bdrv_co_pwrite_zeroes(s->target, offset, nbytes, s->write_= flags & + ret =3D bdrv_co_pwrite_zeroes(s->target, offset, nbytes, write_fla= gs & ~BDRV_REQ_WRITE_COMPRESSED); if (ret < 0) { trace_block_copy_write_zeroes_fail(s, offset, ret); @@ -530,7 +540,7 @@ static int coroutine_fn block_copy_do_copy(BlockCopySta= te *s, case COPY_RANGE_SMALL: case COPY_RANGE_FULL: ret =3D bdrv_co_copy_range(s->source, offset, s->target, offset, n= bytes, - 0, s->write_flags); + 0, write_flags); if (ret >=3D 0) { /* Successful copy-range, increase chunk size. */ *method =3D COPY_RANGE_FULL; @@ -563,7 +573,7 @@ static int coroutine_fn block_copy_do_copy(BlockCopySta= te *s, } =20 ret =3D bdrv_co_pwrite(s->target, offset, nbytes, bounce_buffer, - s->write_flags); + write_flags); if (ret < 0) { trace_block_copy_write_fail(s, offset, ret); *error_is_read =3D false; --=20 2.29.2 From nobody Sat May 18 23:14:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1626876432; cv=pass; d=zohomail.com; s=zohoarc; b=Q/5bNsiCVUMd6r8lXDoRA+J/vY2sVAssbmFxyqk6d8uKqHwAoVvBYuREyMGrItQxsLrba9fKMpzY70SRJ9il0/Yyn90NPCM/ksaKjt4u4ZfreIHyXKztDn38M7zIEgTZzKKStOVUllyjemEN0BydLzPNwxWaYPYOfFASyz2daLw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626876432; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/7NTIygQ1ANSTyO6aSkYdm0tyohisTgZcvOTuKGhE9M=; b=Irtj1N9itnGnandhlc6DGUrMc1IX+CclyEJOdQTmVOFfzmln7O4vjXD6gDPHJkU/TmR68mdwnXbr3SgX8KA5+47GkedDpi0kRoUy7YOLLQLfIbd1LAyGnQvPJ4l6KawSa9e4AIyYt0r0w6wAEl3ZkvlJQe7pWm71fbc7piOs3dw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626876432146485.6349483061871; Wed, 21 Jul 2021 07:07:12 -0700 (PDT) Received: from localhost ([::1]:32812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m6CsQ-0004tc-Sq for importer@patchew.org; Wed, 21 Jul 2021 10:07:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6CqA-000254-D1; Wed, 21 Jul 2021 10:04:50 -0400 Received: from mail-eopbgr80105.outbound.protection.outlook.com ([40.107.8.105]:17431 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6Cq8-0007Ca-Tq; Wed, 21 Jul 2021 10:04:50 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24; Wed, 21 Jul 2021 14:04:42 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%6]) with mapi id 15.20.4331.034; Wed, 21 Jul 2021 14:04:42 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 21 Jul 2021 14:04:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LuZeFNdkrTr6UhcvH0W1dPJ85sXS/kw2UjY31Cr/7Fw6/w3CUD+WsEbf6ov37cUa16w02B5XY5/niPTx4IfZLmb7uEKojxOWy2gh4wkWgRN63u8rdsRzLOThDAFYpzPFdzrzGaMOE/Bw9be9wGuQSejANjT46dHB0FdYmp6BKy+Dw7KrzDJb+xuyT1Io9hyn2/iMh2itzguN7r0dOGtWp3Lmw/tnPbQpORJMGHrSNsOMdYzeBwYlB6eztUtRA/EhhM5KdsRkHiCNoO9vrixYQjtlTOcHz8pCPykx+IJ0wm/g8yHbbmbZyU87IVUgELlptKoy6yix6gvqvp89p+8Q2Q== 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=/7NTIygQ1ANSTyO6aSkYdm0tyohisTgZcvOTuKGhE9M=; b=XLOJaKjzAVl6NFdRJklgdcFZFWjBKiieVYtVx8fdMrPTMVyiN1W/05kr8CdFJLM8ZhQhu9Bvqa009QgIrXRjHdxVBERZRJe77Jd+YxVihFXc7fWFfEdNPluuZ+10NqubNw2IOzVmlMGFeobHVZ1IQs0qTIz5WvDcjqkd2jfIEKyVUDZQjxQoDMdb5DlbFZ0FKq6sgRlKoAmWoawImeUQuc/MR8kvbhRt9QmDxJFusJolS3Jr1J9bI+skbwr7xoI4Unz7DQKF39lO4gUWn0S69pGWJ/pTakhw/J4dacMBdgoIsg9IHgtcOa4pdiAvyhWZMrJODq8zb87VH0p7ZwSLpA== 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=/7NTIygQ1ANSTyO6aSkYdm0tyohisTgZcvOTuKGhE9M=; b=iDNcTdQfSH1cieVedds8EBKcDEntDZxkRVNyyKzH5uyJqOenSZpcAY4TkdcCUvnNY9U5Chbxa3WBaZKrOftPO/tG1qGOV0C+fLLB+PlCGEl9TIo75MXKlWGLpix9NNhNFzW2RKjyy7VM3oqfeDAymX3rLsbJJsgE4uwlY4uYkoI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, vsementsov@virtuozzo.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v2 2/6] block/copy-before-write: require BLK_PERM_WRITE_UNCHANGED for fleecing Date: Wed, 21 Jul 2021 17:04:20 +0300 Message-Id: <20210721140424.163701-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210721140424.163701-1-vsementsov@virtuozzo.com> References: <20210721140424.163701-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HE1P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::26) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6bba2d1a-b0c8-4485-114d-08d94c507c62 X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:31; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bYVS0MHZGwVwONXxvJ7uMCoqZ7a+q2+Jl+eaOR8t5+GfiIM5zmPOjrFr5UfsCqxym3xBs+8M49i3aHOLD0D/3UmHB58bWcyjgzq5j8HNFqeUCQMXo92k9fz8+RbgXLO7BUSjgXeQVeJywLgkRvTFP21BpJYu5sDdH51umMRFO4TBCsgQuZon/qrc9CcgzTIXXtO2gHIuWap3mWbbg6xcJNIKrjkR64h7qT4X+IeQwS/kgfRxOxgKJJHYDXBmgxUlUozlRAnGxWd2eyDf1Ga2RXm6QnAz0qcMidzMcb7h40DhBrrqN7e5Y2LnCRLiyoaWQP4bjKVcAJwyeJYlFHI7y+8KPDq6d0BlGXFFY5qad4YUB9Ax4+nPJvukJ/hPO/00xRXPlHAyd58itC4eQ89qrtirtxaxTfulthf399GJNoBfroExKWxA2GOVr/mo1fYol2XeT3sE0pX4qh/FKyVvKchPqiSMRVKqiaoIAP1LtHuDkxNPXcuI1/ATeuC0FsHwWQBC56Ap6X8DkuzrWUSCJwOsutr+LfNN0S96M5xGiVpjL6W1UL1Z0FJOrNpXhU4AAgodmmN/u08SOwqezQ7hhdh1p7KDTfXhv15+XcfdYgwMRQ33gqZUK5n999wAqUfMOUIG44mr+jqpTLWq3iOWdrNCNi4xHLD+cfCkt3Yws6ZNMYTd5ArIa8EN8uE4JzYWNQ/wxUvF0WZBMT67QA1BUQ== 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)(366004)(346002)(136003)(396003)(39840400004)(376002)(38100700002)(5660300002)(52116002)(38350700002)(2906002)(83380400001)(956004)(1076003)(6506007)(6916009)(316002)(6666004)(66946007)(66476007)(66556008)(478600001)(186003)(4326008)(36756003)(6512007)(86362001)(26005)(8936002)(8676002)(6486002)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?mxzhJ9FPbHORfsX4foCr7iXAJnCigHD4rBIRMeCXmnfYra/Neoh6jpadlm9h?= =?us-ascii?Q?donnVKk2/wgYStFcJG+Uaaw8lFpDw1nXww7nMI7jYb8WA6pK+qW6oXzbwBUh?= =?us-ascii?Q?Q+7h+IoweOvKfNusXcgw4GJ4hPXKh8oPgHAaQDHiLFdtMXYv/46M19pLgs5b?= =?us-ascii?Q?bVsKPi8jU0w8DRLWKEGnU5b/Qs/nIHavyMmRYnyoQYMxwYL+DtzCylhGuXNO?= =?us-ascii?Q?wAKkzjyf5OY+bV7wktk91WjxrQyTaHu95vRIuosBdYNy1aZFdE/hnaCoewU5?= =?us-ascii?Q?nn/Z9PCzMuvXQlt9PxJYxAgIuW+ZkJoArqel5eAa6PxavJBDZLblC3zxXSZd?= =?us-ascii?Q?9LhhDd/vQmk/sdIXRi1ZIRVMtD9yD1wc0XjthgeDChveU3YM/jRkeFtkmwO9?= =?us-ascii?Q?ruCLLttuHv8Xr6ftRng0CrF96am80bwxEd0HtgjoRYlWImr8oNamW73oPWgs?= =?us-ascii?Q?lQC/KyGm1sM4z48I9mo79ynHpkHYVhCqrcaT0zuQX9eRmSFMGpZnCsjUpzTL?= =?us-ascii?Q?F87Xg3ChzCqAmDJFYyRH5DdOG1pufQD7E84jyg4FoyL5mNuy11BuI3l2DLCA?= =?us-ascii?Q?KWY6Hma16l6L/5oCcTK78dHx9PgY2XCdZo3CnSpmVAWaWy/YSASdJg2QjpqF?= =?us-ascii?Q?Ekd4TdWVpH7+Fckc8M9mEzV7uo/Ydg9aqNJI9/DOJ5AgduNTo4CbrXm8LOpF?= =?us-ascii?Q?f3LLHdf5b6V17xV+Ufa3D+er5uTYRBT51Ia74yKuMHfhgeNAuMk+XuLRRLY2?= =?us-ascii?Q?MaAXl/KZXOi/FAnnf2KayXMbapdrvQKKJ3Q5BcLSNn6GZ150ikUSIqVnd1Ml?= =?us-ascii?Q?uRHp9ygPPSyieTZlZ+94uH1HggMgDUnWZDzX6FLs6exONy41BK5diuy8pmYL?= =?us-ascii?Q?B6ZGwi7PPB9ug6yZvzcaotXEnSsi3uVtupE1IQI0EzVeut4LUFUQUTIv/AHO?= =?us-ascii?Q?VjZiypIQNAp2i6LP+kdqNFmfy4XiEzHJw/eqYeo0Pnp9fVuPMQ0DQKF9gdF9?= =?us-ascii?Q?PDvrN4dvy4tsVVhg2DC+uCly39VAcyzR6x+JyQ732FSsd/aLXX3z5LNDso0K?= =?us-ascii?Q?zL99wlDOu0ShFlthaEJhBfPaBrFPMdHMUpYIz49qu3Yd5VRuN3ijFuNeGU58?= =?us-ascii?Q?UTsXlavugvbSC6YQrCfl8hAadPIjD00ARRnZolDlpwryTEwZsJelxWFdZQPF?= =?us-ascii?Q?fgTpOyh5GdNTPtNKsPG/XqwOW5nVUX5PFCZQn+9Xoh4FjT+WClAOIie06ZX0?= =?us-ascii?Q?N9MQyzRR8W06Qz0gAmk2WoQ1WpWjxh/edSDBzFm12pCB2iSSJaIH5qg0/E37?= =?us-ascii?Q?yST73xqk/Bd3yisI5K6Cotkg?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6bba2d1a-b0c8-4485-114d-08d94c507c62 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2021 14:04:41.9095 (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: 1BBzBL1Y2k7jWuHk6nuh1Nu6LFLFYdW1LL7XEpsiH4hJv3wSK4gNBbHmMKlpvjB/ags+ePtjmMFKiyBERjKKpxw4gQBfDU+dPvGlKQ2zCNw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.8.105; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1626876437114100001 Content-Type: text/plain; charset="utf-8" Now block-copy detects fleecing scheme and do write-unchanged operations if detected. So, let's require appropriate permissions. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/copy-before-write.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 2cd68b480a..808e8707ed 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -113,6 +113,14 @@ static void cbw_refresh_filename(BlockDriverState *bs) bs->file->bs->filename); } =20 +static bool cbw_is_fleecing(BlockDriverState *bs) +{ + BDRVCopyBeforeWriteState *s =3D bs->opaque; + + return bs->file && s->target && + bdrv_skip_filters(bs) =3D=3D bdrv_backing_chain_next(s->target->bs= ); +} + static void cbw_child_perm(BlockDriverState *bs, BdrvChild *c, BdrvChildRole role, BlockReopenQueue *reopen_queue, @@ -129,7 +137,8 @@ static void cbw_child_perm(BlockDriverState *bs, BdrvCh= ild *c, * only upfront. */ *nshared =3D BLK_PERM_ALL & ~BLK_PERM_RESIZE; - *nperm =3D BLK_PERM_WRITE; + *nperm =3D + cbw_is_fleecing(bs) ? BLK_PERM_WRITE_UNCHANGED : BLK_PERM_WRIT= E; } else { /* Source child */ bdrv_default_perms(bs, c, role, reopen_queue, --=20 2.29.2 From nobody Sat May 18 23:14:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1626876729; cv=pass; d=zohomail.com; s=zohoarc; b=O6CmGaQuyfitCP/BsGh5heSasiwFjEFu8FYyc6CX7D7nqnBk+IgBv0/3Wr5GmO2CHlMLsWobTucHWdrv/QCkfjND6EdSHFhGdI50ZQTCoQuduXk4CbS4TK/PTROEwlccO7scPIiVPOMjQt/SWD3Yv8FnzBo/c/PTO6qexfECwnY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626876729; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UiSzgzOI9RSEXKEdm94TJEWQPysSiTrl7D3wUBiwC34=; b=ALdbtROiiYpHivxRZztH1oGCv1BWZPW8+V6xxNj9/Rc3xOE1PH6DUt5paTNB3UVfqww6nzYL5NQZ+ve67AtsNsoJOkeyM2n1tKtShdqhcJhFGFzghkiAXR5PMRC2xwRKDAopPwFiOsNyAYegKM4VElox53R3jBDA+F4dvxm43fE= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626876729852824.3635161531704; Wed, 21 Jul 2021 07:12:09 -0700 (PDT) Received: from localhost ([::1]:48696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m6CxE-0007Et-JQ for importer@patchew.org; Wed, 21 Jul 2021 10:12:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6CqI-0002Fa-H4; Wed, 21 Jul 2021 10:04:58 -0400 Received: from mail-eopbgr80105.outbound.protection.outlook.com ([40.107.8.105]:17431 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6CqB-0007Ca-7t; Wed, 21 Jul 2021 10:04:55 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24; Wed, 21 Jul 2021 14:04:43 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%6]) with mapi id 15.20.4331.034; Wed, 21 Jul 2021 14:04:43 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 21 Jul 2021 14:04:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OE6nTl3ehbJx03ZtaTVqXnalH+G7ksCIW1zQLe4V0XHFrWQQKL4+P5iMhcoQsbRSIMrXEK4AZv9LpS1aI9VlxzUt+HvQUh8lre7c10URM30z1M5fL6DDfaOvOYGW5GyXTUvMrMlPJcyYI9L/w5W3erqmsurO8rnKKsps6LsrUQPmxcRAHUkybxVsLUiUnzeTPxxoySUdiZhozBxfZfJ/FgM8DEkRclLfBNpRa5Ur317dA6/URYuD3PLdwyX2h25888IGhUFAZ/gdpqQdZG9KUEo11hdqeNaa3Te+vG0+9q6GnFOBtN97GKjDf9sq0ybO6uht+B453jLvvq4h4ZUHaw== 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=UiSzgzOI9RSEXKEdm94TJEWQPysSiTrl7D3wUBiwC34=; b=ZoOKo4gEBZmRG2tOeSYLb+JUaVYp9VlrYagHMAJ77mIT2i53lhgFq/znmxpJpPKFuZXDLL/yS/hNCwdKNX/LGz1EqZqzPHMTitedibdJcVp2rQaOhecYwAjRYSqlOAdu5wFNR9+6BMAp76lQ97MsRullrbO4kFIk4FwWWNCaQF5kD4wKdDs5ETcjteZc0Pq2u7R4/ozOznwVmn4OO6IMbc65YHynFIDY4Yse+PgCvQX/9C3n0OFixn8m2z30VSEHlvVmdB9Co+Lxx0fx223j4RsMU1VihEUyFJx5hM6qc1tWU99KczCiNhbA1CTr1ql82ou8yvrhadcPLuvXKwaMvw== 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=UiSzgzOI9RSEXKEdm94TJEWQPysSiTrl7D3wUBiwC34=; b=oBOyQy9mYGybb048Eupy3yOIz75AVebTm8qG9DaJeKEg/FbUg733WcYizQTDslE0DSN0FyHwk57QR21TfufBO5TsLFQgz7Al9O2MyCYb9e1nOr1F5H3/5tEZkXP3NybBuoz7rnITxZpVXf0mxFcpif4ip6678QV5tKCR9JO11MA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, vsementsov@virtuozzo.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v2 3/6] block: share writes on backing child of fleecing node Date: Wed, 21 Jul 2021 17:04:21 +0300 Message-Id: <20210721140424.163701-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210721140424.163701-1-vsementsov@virtuozzo.com> References: <20210721140424.163701-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HE1P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::26) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5db67ec9-26bd-486a-9712-08d94c507d25 X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:159; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4KpJMon2LnjTW4u0QILvy42VsxdVIzA4ETo14cxbDnctt6Mh7/wGwZSR0rC9+YZAuwmc7JmyDYoPW4QIW3Xus4WdwdrgF+i80bd9kWPwMw/ZG6UUA3VP+57HbY5ZkzAlMtQf39HEEWw4ASzbMGlzcxAhp59loBpNmG15B6lCwWHR73QKHS9Bunz0F+nXAuEjkGatoxsd00Xo1xaanERde1UXLN9CcQ7QarWZJuLYWM54RlDYyKJtFXPzE/QMnfi1l/Dq7V4EJk9HIRMGZQZ7FBJ7mqb2yVKzfc+l8jBq5T6f4gOMDajbXfhAzeS/LBUtRvF8nRCo4Sq7TUnkx5P5657+E0rC1OqI/G5FwgTJ7clNGUfAEScsByVNWAtREI8zBuGd+LN5r9xxXtAPEALAcXF/ryxoAkHtfRXgD5dt9FFRFfQRJBXpzrW54QVaXTZksy1oSh2mZp/bUEUU2O0DDdU25M3tlvoUyJBHeP3wkLjY7tqFZ48s4z2foZs9IbH/X+7Ja+rdnMgFjOSaHgyqY+CXLY+fbfYbSJaRD+W/SPMLm+3/vN1oZEWXQmSZ+loORpuQvUobiHZD145SzER/6HYmlSnzYrgA3A8zqHW3DpZlOUKuEMMT/kAsyDgKfpU2KWazf/SxwJUZkVo8U7ln2dsniU/UAEwdzvCuqv3C+PqjGiOrIu6AjyWjrG2SqczuMBMSUqc27RfptBL0gS/Jqg== 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)(366004)(346002)(136003)(396003)(39840400004)(376002)(38100700002)(5660300002)(52116002)(38350700002)(2906002)(83380400001)(956004)(1076003)(6506007)(6916009)(316002)(6666004)(66946007)(66476007)(66556008)(478600001)(186003)(4326008)(36756003)(6512007)(86362001)(26005)(8936002)(8676002)(6486002)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?YrSMMnY7KPDjQAGNbS4hwcR/Uv/cIR+vKkj/IsJb1U40kV2o6iaHmrAAqWEH?= =?us-ascii?Q?ls/w3cR/vi5nEMqkYntLUgpx0E9udC1cALdUCgjYTr9NG+Hf8BsEXmx62joM?= =?us-ascii?Q?U7NK2r6yzCUA3UMjP+ooouDVPKRFNnX3cqc92Rm2e9g7Re6nPFSNgYupcLKG?= =?us-ascii?Q?91ToVdnufxKyEO2G1/PugEBpWFO1CPb5Y2H4QEYayr7sHIsnWBFR8VS78evE?= =?us-ascii?Q?QS5+JGs1KhI55MYcbF6v6ZnvqdZbhM5YupEgQYQKdCmv2lv9knqD0qja5GWL?= =?us-ascii?Q?pcHHIXXkoiAlOgj4X0PQZUi/D3OYMuYE0dUamCP5Pxac/rJVZc/qKkXRt63/?= =?us-ascii?Q?kpsT6hMA3PGJOs+i6rnsApH91pg8KhvwkPaLnMwnPDwTjjt6XsyygrS+OW6b?= =?us-ascii?Q?i5T/hX3TnsDvG1L12ynUcPmV4PiOnzMPUZTYMNv1GPuPtenIUr/GHsntCwjA?= =?us-ascii?Q?jVM9e6vbWteOcGxpwIr7jeSpHHVS7VQL/ngsHF339oUf30hMwNdpA0K4Td6Q?= =?us-ascii?Q?atly2fXMKIuoOVTql4Hz3fhy60mn8Zv0svlboVJ1S0l0DDm+CYincZp8XeiM?= =?us-ascii?Q?5LOIxZa8KETKgyIURhdDDJB7qIiwLg65vVuU3fBw4g2AyZva0UXlPXUVtqBS?= =?us-ascii?Q?fWenlcNzAMnU5y6UvZKrG+N9r3g76VnyZE7CPByXBUY3qt2u5eAWwbHJq7gJ?= =?us-ascii?Q?Y3ZrW20yCJIJNiHfgQIl8f+2fRqKln0Ll4MurALdsqC9m9XZlYhSZTWDmNZY?= =?us-ascii?Q?UoKKg5yQduRCnZt2x52mr8B6Y8enG2gV0oeTIQ7cMC2M1WQwFsGX3rO+jG8n?= =?us-ascii?Q?3KAiRe2KOCnnjkNGE2dxBAFd+RT6sKwfHjPdDLHo+/ZGQMMEfJqDEBj7ZlDq?= =?us-ascii?Q?Swm7ftbGlkRSIEh6bITMxiRAKPG+habI8g5+Wj8iDHVqkhOMb2op/DS7hiuA?= =?us-ascii?Q?p6yVNrU8RtNbcvUB/qorE5VoSMOv9lg/wrU6HC007yNz3a9tkmSd5bZWjWFx?= =?us-ascii?Q?t/jxKc5cA6eOFkWP448aV3pHZuoPDLz+ZPbLZ9tqlysxWeuWcd6FMlekr33b?= =?us-ascii?Q?wJk4lW9cucuVvX3bkarv/PnNJbXAYyjc0ksAaw/wx/pVVzq9QmxehPZmNa6A?= =?us-ascii?Q?wByPh+kWgiKs04reoQOX+5MoPBvCGH5Fe2jR7l0vptv+R+4WBIhCiGYFha7j?= =?us-ascii?Q?nSt9fXGT+3FXc9GVsgEFHUPaZVZGa+Fv05QabYUAUb2J1nmoBZnxGquFTeI+?= =?us-ascii?Q?tRI3odfVlUQcok+kSlhACEhY9urFtbDTq/BKaqe4syaGlaKzBXgylEuS9+EW?= =?us-ascii?Q?aVkUTbJ+SW/LUF1Ui7xyGIb4?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5db67ec9-26bd-486a-9712-08d94c507d25 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2021 14:04:43.1819 (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: OVI2qzvY2/vuwOJgR7muS4SQxcSjeMGIQLvcL/zZssJKHel7UphWJNZJ5l350e9rB1tC8Yq84d0MOQpK/e53D5ibKuk+MdAhEg/9RbIgaEM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.8.105; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1626876731103100001 Content-Type: text/plain; charset="utf-8" By default, we share writes on backing child only if our parents share write permission on us. Still, with fleecing scheme we want to be able to unshare writes on fleecing node, which is a kind of immutable snapshot (copy-before-write operations are write-unchanged). So, let's detect fleecing node and share writes on its backing child. (we should share them, otherwise copy-before-write filter can't write to its file child). With fleecing scheme we are sure, that writes to backing child goes through copy-before-write filter, so we are safe to share them. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/copy-before-write.h | 1 + block.c | 3 ++- block/copy-before-write.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/block/copy-before-write.h b/block/copy-before-write.h index 51847e711a..a15ae9366d 100644 --- a/block/copy-before-write.h +++ b/block/copy-before-write.h @@ -35,5 +35,6 @@ BlockDriverState *bdrv_cbw_append(BlockDriverState *sourc= e, BlockCopyState **bcs, Error **errp); void bdrv_cbw_drop(BlockDriverState *bs); +bool bdrv_is_fleecing_node(BlockDriverState *bs); =20 #endif /* COPY_BEFORE_WRITE_H */ diff --git a/block.c b/block.c index 94a556e61d..d1046b7ff5 100644 --- a/block.c +++ b/block.c @@ -50,6 +50,7 @@ #include "qemu/cutils.h" #include "qemu/id.h" #include "block/coroutines.h" +#include "block/copy-before-write.h" =20 #ifdef CONFIG_BSD #include @@ -2507,7 +2508,7 @@ static void bdrv_default_perms_for_cow(BlockDriverSta= te *bs, BdrvChild *c, * writable and resizable backing file. * TODO Require !(perm & BLK_PERM_CONSISTENT_READ), too? */ - if (shared & BLK_PERM_WRITE) { + if (shared & BLK_PERM_WRITE || bdrv_is_fleecing_node(bs)) { shared =3D BLK_PERM_WRITE | BLK_PERM_RESIZE; } else { shared =3D 0; diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 808e8707ed..0a311e311a 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -257,6 +257,43 @@ void bdrv_cbw_drop(BlockDriverState *bs) bdrv_unref(bs); } =20 +/* + * Detect is bs a fleecing node in some fleecing sceheme like: + * + * copy-before-write -- target --> fleecing-node + * | | + * | file | backing + * active-node <--------------------- + * + * In this case, fleecing-node can (and should) safely share writes on its + * backing child. + */ +bool bdrv_is_fleecing_node(BlockDriverState *bs) +{ + BdrvChild *parent; + BlockDriverState *parent_bs; + BDRVCopyBeforeWriteState *s; + + QLIST_FOREACH(parent, &bs->parents, next_parent) { + if (parent->klass !=3D &child_of_bds) { + continue; + } + + parent_bs =3D parent->opaque; + if (parent_bs->drv !=3D &bdrv_cbw_filter) { + continue; + } + + s =3D parent_bs->opaque; + + if (s->target && s->target->bs =3D=3D bs && cbw_is_fleecing(parent= _bs)) { + return true; + } + } + + return false; +} + static void cbw_init(void) { bdrv_register(&bdrv_cbw_filter); --=20 2.29.2 From nobody Sat May 18 23:14:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1626876469; cv=pass; d=zohomail.com; s=zohoarc; b=Zn5CZbsFfFOUG9rKQzzOOhi2zgMUjlUiy2j86ugZOgMJF+kPZVWuMgYhkYUekTK86POW8/aKC4b+GtvOEAqdEHXEPdY4fsHjscdCZllA3k+NEXFS3v8yJHThg/ilA1GQzTBJNhU9ecdJex6cuh5pyWNbJ7Ap3IQB0vo4RJS2LcA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626876469; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=id6Ws+1vmuiK1ZDxksT5x56XfzH86Fg5GkxheV5RRo8=; b=V7uWnteJRzZ9RJpoAttijrv0rPbfqFZnPTkBjvRJxRCIY74BvQLn3ngXM8kM9w3cWocmqj144lIqtx8zmYop1By811EKYuZkTEjaZLJxBkevxh+QZLaSsmyoHKu2DTSdEFs+EVPFED2TsgKnCRw2zOSCQw/czMdLpqwxdhqJ1Mw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626876469260927.2207007468209; Wed, 21 Jul 2021 07:07:49 -0700 (PDT) Received: from localhost ([::1]:34474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m6Ct2-00064X-4P for importer@patchew.org; Wed, 21 Jul 2021 10:07:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42068) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6CqM-0002MN-43; Wed, 21 Jul 2021 10:05:02 -0400 Received: from mail-eopbgr80105.outbound.protection.outlook.com ([40.107.8.105]:17431 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6CqJ-0007Ca-IW; Wed, 21 Jul 2021 10:05:01 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24; Wed, 21 Jul 2021 14:04:44 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%6]) with mapi id 15.20.4331.034; Wed, 21 Jul 2021 14:04:44 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 21 Jul 2021 14:04:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CdioR2sZYXug/v5pz37j5NmnNMk4ow+gikXFTKKuA1gO6NuzRKBMCyElHylHnhIB9qJyjewmQQ6M8nqnv78qE/NsZgs6lEFPj8REUNcRMmdYEto5m2tsOeBwCDmeyamLWRGl6iSyKLcV3TtFQkRAiFA/qPfQznRxlHHJokgyuGXfbNY0GlBZYpsnK1Lvism36GMgDv9ahY6lz7Cg0/oq7a47If+yOtqFpWXDoBzvMS307uAw4OAUTPOfWkbMtsAR0hk2N1FQfRNf47GcohMRbiV3dNyjaLimxdUy08csydvfiPfr6dnbPKb1RzkGgX6jfTKC2CBxyL8QtLhFBVXPkw== 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=hBOSlaNkEHChfu1zgSjupCeu2Gf24ihyKwitYzUZllWTJ5zssPeRvbsJBZtE+QgnV9cXITmP3ih5/97l3m+QAfjFA4y7X9THkFBH9C/Rm9ZGoIEGs03AyAjhNPZQuTC8O7BUy38DZghSO69D4HIOHnM7qBbF8lwarZ+fzMnMGtO0xzo/B38niMo2PHVETIqSbjwky0/kQQD6UlXMagPDjVD5ZW7EnOl7cXldPfnr15mwjIiSV/0qiPIb+xd0BooJGEYnoHjNfPofRDMsjew2RSCHT59DM5cqeVI0Qj8qvfVRgXexV2pfYn966E7gBOPJKFym3d1JC+iSxCK6Qac6Rg== 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=usANF9acu0wkTVCnHm5K70e937M6B5ZJkA/sFM6NS4Yxm2hJK5yItxlGMyUJb/y6baV2oIftbYOJKDXBP16Jivjq1cYPEXiNxkkBTZmsI3p7PUVxkngwRpq9Q/EkekT5clroYQW3JhXF9V99Op3Oz+BhlxyO6hRhqUYImi/FsEs= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, vsementsov@virtuozzo.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v2 4/6] block: blk_root(): return non-const pointer Date: Wed, 21 Jul 2021 17:04:22 +0300 Message-Id: <20210721140424.163701-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210721140424.163701-1-vsementsov@virtuozzo.com> References: <20210721140424.163701-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HE1P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::26) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b9c58a65-6c62-4038-1974-08d94c507de4 X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: 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: kGzAnvj2RDdqgVYHden/SUi6hxSCpI11s6Ni398bam5e6P/jJitG1r8a9RHoaSCxrXXUYQVYEn1G+Arhi+hqkBhhw+R5wKtY1f3HRuQaNvbO7Lc3zt3dPZmJV6BOGhns8rXVWZ3btbgLIZM0FdDV63V/qhqZ7hnzw/ijiqYENqQnqMIu3H7TIPYdTKchAVBUAcwqelp0/wFSWBROG2eH72cTBApYqUptoN97BKmuqFZ9LtlG2XXjVmlz7XX1QQp1PLJGZcqUJh4UQXoS1zQzLPKrWyViunDee137EQ6Nfp6XGGwyu8QReUy5EnZbG4BAp2vbVcy/hj815s+V8WcOjx2vxfW6EkJuVMFXaJoPQl2FPLyVbpxdc5yEPFBFtFJkRAflMleCKUNos3NCy6dIyC9yJfV8/rLvyXBMgeqsWXyBApT+SRltPKy5P90a/+S1zOwMZfMqJyRIc+knXZOV4EraxRzfjWLM2oNRxMRW9u2l/Ut+DDu8KXEI7T+P0EDXNL/wd0ewCVVrvZEtOm/dFbf4Xt/31IU/xKnljDxVPK4eIOt7jNuxpqgqrBVAX+3r6qQ/cQ4qdO/Zroo6qVoM72tlMmk95KULviEU4YT1p6YXnELY54F9czSsusbKU+IZfIFA0W+fEucBV7cF7D1wfP3blIH6MiQv4m4oCsrUFrBCGqEqAqJAll/3SYxJylw7YqYfH+mRrAvhCotjgDaE8A== 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)(366004)(346002)(136003)(396003)(39840400004)(376002)(38100700002)(5660300002)(52116002)(38350700002)(2906002)(83380400001)(956004)(1076003)(6506007)(6916009)(316002)(6666004)(66946007)(66476007)(66556008)(478600001)(186003)(4326008)(36756003)(6512007)(86362001)(26005)(8936002)(8676002)(6486002)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ay/K7qw6y/pF3I9BXxO611GmiUKJuEm5PKph/nqOb3bSYNWx5YDV8WZziSZh?= =?us-ascii?Q?xmWpn1JydyldmyVkiyOn8uGF4hiN0md1yMl2Fy4Eo+aT2e/OfNXXHhb8cDxY?= =?us-ascii?Q?aCsOlX9SDbF/yadPq26Q2XYtN9Mw/qgsBtQstzvy3dvers7FMur8IB2nLE2Z?= =?us-ascii?Q?FJOSgTpuzfozRI06XZHLvUDTSr3Md6ZfPH+hBDgP+BO+uXgW0YdsYRNd2UMY?= =?us-ascii?Q?TZPUbRFSBqRhOAdr0U5H0z9RazvRTAh6chMkbnv20sgRyOWaW3Hkgbty7bN+?= =?us-ascii?Q?S8Wh6XcJ1ibqxO2xxGH1fuld1qdtgIVVPtKpm6M8gD8u8KfCBxBprG9s6xMY?= =?us-ascii?Q?iVe6pHkzhWicWxlVvahGcQHOAbuzes5zoAhjYGvSBHAZVK6RcI7IJ7VHQjEP?= =?us-ascii?Q?ILiXe4eQuboDL/d7tPynxSNHZFWl2TYLQVYxTGxLVSa9T+Rvg0EX4/5S4Qux?= =?us-ascii?Q?FXXWeeK8D8JK7QZhvUODYECuDKvDjnpLdYScUEz5X52hn82B8dBTRxzinkou?= =?us-ascii?Q?QqHRode+ORi7P/j63H1xV2cnwkyka00yEzTzw8h7l37VgrAI4xmM049/VR4Q?= =?us-ascii?Q?ZnJdJRpP0hti2/NiOW7JAwAXMffNtO3TM+AeDutCZhzOwnO4lv0QAqFlXUV0?= =?us-ascii?Q?CMgqhbzxyWjeP+1M00vXvosiXtbuYjC9Zl48QX2Pnxk79zaoay6St1LZqsGV?= =?us-ascii?Q?5gfdUz/WEjHqCozNgsKOqr3MZbc4J4erWhUlNhMh/1fZfAmYiiOJxjOpYAvx?= =?us-ascii?Q?5AkyI3KRGjfxmB36Bk0p0ETnqMhJ8kaES4QUQzBDPy3kkuRRSp46rZKNS/wb?= =?us-ascii?Q?T7t8m/hlyVV+m7NyufGy+ArQw3F2hnW0Vkx4l2eYfWMJM1uN+UqCvsG3cMat?= =?us-ascii?Q?+c8AS5VGLt+lhCFkUXnpMpAshxMgPwZm1tO5XRnQyLkbdM3LyVxZlJZO/K2r?= =?us-ascii?Q?oDtLVNprZ2x/QsAtqWjNEngVUvGHrM1PCHq7TZmEVhimpIwDX9hyTSNOpviH?= =?us-ascii?Q?bg/Yt2MeiHEH7aUIO8YXFx6NmV1OVkwoNNG7XQ3d9k/fatOo4RWK3OyT9g4v?= =?us-ascii?Q?Ub2KbU9RDUO5BCGztIIYpO7mY9wkwmoCJQ93e20XfEvNdUabXDP59p9btjk9?= =?us-ascii?Q?uYiUfaBfZQYVxpcHSGqhKLgkttsGmnlkIpYDMjpRASyk6cbvQzq1PlcZ86hM?= =?us-ascii?Q?fRQ180Z+u8xiW/EYSycqNesO0DJfROjOLIZc+LcWbQIYlc35PbasjsI1Xfdd?= =?us-ascii?Q?UofLWmzFM3nu2YCysw5I66rvDb7ntmSVHGi9VqdENgxFWQf2KC4QKG9bpcbu?= =?us-ascii?Q?nrSKHRityv+qMFDdAaxiyzSp?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b9c58a65-6c62-4038-1974-08d94c507de4 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2021 14:04:44.4493 (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: YXy+8zy5yZtswD4qlBihm+tngm88YOiABSVGmBlvJxlIP9Nf0XSeqhlj3wWNbty3YxLJ2oKGqfWWV6ph4jUGNgGMNi1SW45+A2Uqy/5hRaU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.8.105; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1626876470934100001 Content-Type: text/plain; charset="utf-8" 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); =20 -const BdrvChild *blk_root(BlockBackend *blk); +BdrvChild *blk_root(BlockBackend *blk); =20 int blk_make_empty(BlockBackend *blk, Error **errp); =20 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); } =20 -const BdrvChild *blk_root(BlockBackend *blk) +BdrvChild *blk_root(BlockBackend *blk) { return blk->root; } --=20 2.29.2 From nobody Sat May 18 23:14:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1626876616; cv=pass; d=zohomail.com; s=zohoarc; b=KWVAGgioDEb1iTf7WDP08hTmgrvC6hSujIAdfy9RUAx5UZObPTz5r0lw21X0Tbm70vXiY5+PIDwJl2XecGsOZIUm6sP5V2kHGH2LSqY60JiDmvBdT4ECdW+WLeDSkcxwKdhjxpezKFscnAc9kZtWoiDsuIh8e+smbOfKcvRSduA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626876616; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SLisOIkdcfkCPVNUw6rSKkNVPe8yX/qz3Ja1yfN5I9A=; b=K+ROaJbeKLFH43AJ8cgYMj+vxwXOwetrfl+V2wMKnm0/D1UZZxOS3sMVt2zH3twYkhDK4B7cXXKg9dXt710e+5qo9rtXQwEfjLzQK/8x5PvDeHHEAe2X1m5pIC9NcCqNQLdWG+Ca1E45nlhmFs+AW68LSnjjcLANVSnA54zNAZY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626876616444510.36097832919916; Wed, 21 Jul 2021 07:10:16 -0700 (PDT) Received: from localhost ([::1]:41838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m6CvP-0002aY-1c for importer@patchew.org; Wed, 21 Jul 2021 10:10:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6CqP-0002YN-Gz; Wed, 21 Jul 2021 10:05:05 -0400 Received: from mail-eopbgr80105.outbound.protection.outlook.com ([40.107.8.105]:17431 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6CqN-0007Ca-1a; Wed, 21 Jul 2021 10:05:05 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24; Wed, 21 Jul 2021 14:04:45 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%6]) with mapi id 15.20.4331.034; Wed, 21 Jul 2021 14:04:45 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 21 Jul 2021 14:04:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GUwW7HN0ZdMrULsS9nyYD7HBKgrJAATU2G9yJrggbowCzERK60k2N5gVWaJRffS2q3eymESYJr9moGXT4p2j3l1lSfCDcjjuy5w9v/Vwr406gUCzLLENWWYJmsFMAZwaF0t+ZEjOdBr7WMAVcWalcH4eMvnex8a8urgAks2vBPXeiOCCyEtYIyz64HRUc8/ZQNHwEyW1rhm7Zsdx/ey4ZuC9Q1mpXG6HMm1qjsO5hv4evgUPZzLG2ZZzYU3lXe66fTPCa5FhKxznEpTNVdks0KSD4FbQ6X+/6A5FVS7iFl1HXU6S3UVyJOz6CI8qE3Nj4JDYWkvHLfhgBQXuoFChiw== 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=SLisOIkdcfkCPVNUw6rSKkNVPe8yX/qz3Ja1yfN5I9A=; b=ZMd+PR2mKdYgkZgui7GCgJxlddS7wsDy5NN5sbxE32n3ihOvafcatY8H67S7FDfsTirk8mMNtYfdEw38brl/w9Gfey8/op7N1+Wkyio8bEKslyM64RNmKpK69GglJUGkODjIkoKFLm5IEAjPiqUWZYEqcVoOo/jeexGFjKf9YaHv2R5NRhKqPccHknGigKC0W98NqiVVCvOUYfOUEbn6NSbfOw5M5JPpPXMxpIGYf9y2+pObCyWFcezXQWSDlHh4KeradrmgLONYWKrPFqz41lfTlVmEFGBxc8ytCAjZuFo7/XbtzeZ4s/IozYTfco72RMee4K8YiqCgYD4yAVVeww== 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=SLisOIkdcfkCPVNUw6rSKkNVPe8yX/qz3Ja1yfN5I9A=; b=GPzhxf9Gcom8alobb9jsEU6rsD4miluepAGCEchTA07glqSkCz1SfWRgVveFwU27uoyv+p/d1fMtGKXRj/JyAPR51WX/sBa8+5FdemuDg9TYYiUIEN8GuTLWEU0TH8fC5qz4yEN7EZVrwwoOFXn01aNL2EjkRCpeq6G8EBvBpsM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, vsementsov@virtuozzo.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v2 5/6] qapi: backup: add immutable-source paramter Date: Wed, 21 Jul 2021 17:04:23 +0300 Message-Id: <20210721140424.163701-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210721140424.163701-1-vsementsov@virtuozzo.com> References: <20210721140424.163701-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HE1P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::26) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1d196d29-553b-4f82-412f-08d94c507ea6 X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 01MTSSsuM57ZLoTo69HO6qpymoCTZ1dw/efYceKnOj38lkfr9FHZBfKilhpvmBqDH5tXkGABaRR/WIIWpfqmBAZdwCAL6FakXQTimwEmXmqa2zBq1P/j4+y7Fzq2iYRwrbnRpnzDYd1+kNMiB/HEYqFyvY3ueKCIfJl+WJQNtsyNW32R5xpaWHu+NwB3BwLS2PnFUctw/GdGL9apdoSx5+eHstNhQcyM2sLgIbH35bvBH+KxAVHCYhNJMMdRCTRcmewBjSUIKShIn7nEvFmu1B6Pf2/ja6TuMV0b90XvB3BqVx1Fmk0XrNrrChxOazCD+JwxnAhbfJhx3ZStRjo3DNzKlVilW/PGn4cnP+UjNBOc1IWruiA3L2C9SIY4ZCE+HAFwMegzP/3N+oXOIzDxJpxj4r0Ak0lqqa26i1Ek7JZUDOvS33iozhuCBW2LV0F/PWTfdPE2rGo/Xw91bwGuYAxu6ej6tqj/8h6PgmglG9pKQrAaJLQrda+big1ablqyaGYjRhR1L7G1vSvcfM+F297gobqtOx3u+v5aia9SjkoHitkXT1QEtpJxxUhCa1AHm0DMlJ0+D1i2jPwNBBxHEXYRzSSS5ztZKZPvKQ6EfSeF6Tt2wWaQc35/tTJU934jY54u6H8N09TtMymCYun/ZJuUEivTb543rVHy/m+gfiyJzggmHpuHRtm6k2uxHpnoDmcUNExtpVQyeKkuxgymOA== 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)(366004)(346002)(136003)(396003)(39840400004)(376002)(38100700002)(5660300002)(52116002)(38350700002)(2906002)(83380400001)(956004)(1076003)(6506007)(6916009)(316002)(6666004)(66946007)(66476007)(66556008)(478600001)(186003)(4326008)(36756003)(6512007)(86362001)(26005)(8936002)(8676002)(6486002)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?KEVnwlgm/UKoA+6iD+pbenmm5X7nvW2CLY+faDqX4bhqkUdg1lVFsOY8nhzE?= =?us-ascii?Q?cB2Mzjz2QzQZsuWEBIy66u+wgMldbb4RB5adDCmEdZStAW7rh0M/PO/FtHgP?= =?us-ascii?Q?xp737xbCk3auf+rH6x7zujfuBjquzgDCe2ki74jJDwcTGwA5pmQuxRfdpDSm?= =?us-ascii?Q?UOg+OIZKLSnsbKUUjgU9ZpZaZvUWZrrnHFRqbLXoNv9H5gnR6/1hDt7iJztA?= =?us-ascii?Q?7XxWCqhyBBvR+c4gWNA7UHvSFxErHoureu+le1+U5P0Ovc27m+4dKk5Z3MPR?= =?us-ascii?Q?a4jfipZef74nBdNiRQPVbG/1SDWZxagef52lYHBaR3+rQmt3oUS/YFZACG02?= =?us-ascii?Q?a0ha+iruH0/gPCYoIGllD/nAke5rQTezo79kvyifqQo2mNOJEY7963PxDpTC?= =?us-ascii?Q?mFlMEyYHLF66dNjfTyE7Y2BkQEPgEkCAOoeNBeLeu/JbGztQu1UjfCmQT8Y5?= =?us-ascii?Q?6HsfeF15kSkyXi9CZ4ISJoYanteUL460LUAdclRax1s8gikCKFqg9DJ3eG0p?= =?us-ascii?Q?sewsTgZicniSsBruVu/0xzys9oJaUsTVBcWrkrhLgy0TJsJyv/azoPJSWYRO?= =?us-ascii?Q?wYyBMLpyRW1fYw45i72CrABow93BsNRAVdZkpTqyXZVBGMVu1OHcKcFzaq72?= =?us-ascii?Q?UxIW8IhPGd6x351J0xwJppqLzzJ4LdUgt1zwK/qDwJ2rqIUafzS9f1BMjKDP?= =?us-ascii?Q?NNbd4GMFtpN3hvAp8+waRvdoW7uxF/vap0nUr5sV9hKx22k/Stu7no3zfrPQ?= =?us-ascii?Q?LdEpSLXWkjDaYa1IfecnDlHASb6eYqA1BifCFX3dA4z1ierbPBsc2lFFL80A?= =?us-ascii?Q?SD57quONQqW4T2Be4baMMacd/10lHYOY/IYZwfKGeqw3UyPCbu+hwFBbyVgG?= =?us-ascii?Q?eRaL0CJpKxVkdsp5px7SG3F4otrV1FqlBt1D5ZzQrHGhQJbBoW/ydDDBRMi+?= =?us-ascii?Q?mKvYty5hbcYaqh7vhnA6z49XtRY4rsujnl+kARwMVsIowaFDcz83+RNtnc6C?= =?us-ascii?Q?WcSsxP1KkLr3B5XrvQcXltIerUNfEhnvfUzIOHRo5ZTaF3zuasOOIClhx3NY?= =?us-ascii?Q?fyKekM1FaVLPjgFlDZ8o2xHelBdFKedC6d6g/deecM13WGiFmFiJzIhQB/aW?= =?us-ascii?Q?k26X++LjHQWE/go7EiTeMAqpRjnPD5UfjvcbZuIidMkfVbToF41WyRfcUK4Z?= =?us-ascii?Q?hGu4F7EOxVc5UxzcNutlWekL5lmC/JwUtcqxO4ZA3+nF05AgzMa8kup7ARuN?= =?us-ascii?Q?0D/kj0frYDnvmFmQ542ApW66u/aBF4TMeGGI+ozv6jyY5z6Ahq3Deiyc11LO?= =?us-ascii?Q?VlOGPjrPUAF/86lPomzOBhoE?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d196d29-553b-4f82-412f-08d94c507ea6 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2021 14:04:45.7715 (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: GKbH8FYp0AIXjNVUJ2rVPeD+hVGy6j2qP29KI4l62f5n1kapaLu1yNKrsdYcpkoEk6aVnMkcrBbx+SiYfAJZuW4yKChviQL6iKuzh5YPxRA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.8.105; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1626876617784100001 Content-Type: text/plain; charset="utf-8" We are on the way to implement internal-backup with fleecing scheme, which includes backup job copying from temporary node (which is target of copy-before-write filter) to final target of backup. This job doesn't need own filter, as temporary node is a kind of snapshot, it's immutable. Let's add a parameter for backup to not insert filter and handle guest writes to source node but instead unshare writes on source. This way backup job become a simple copying process. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 12 ++++++- include/block/block_int.h | 1 + block/backup.c | 71 ++++++++++++++++++++++++++++++++++++--- block/replication.c | 2 +- blockdev.c | 1 + 5 files changed, 80 insertions(+), 7 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 59d3e5e42d..d266eceabb 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 backu= p will +# fail. @filter-node-name must not be set. +# If false, insert copy-before-write filter above sourc= e 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' } } =20 ## # @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, Block= DriverState *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..2bf0840bc2 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. + */ =20 BdrvDirtyBitmap *sync_bitmap; =20 @@ -102,7 +110,17 @@ static void backup_clean(Job *job) { BackupBlockJob *s =3D 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 =3D NULL; + blk_unref(s->source_blk); + s->source_blk =3D NULL; + blk_unref(s->target_blk); + s->target_blk =3D NULL; + } } =20 void backup_do_checkpoint(BlockJob *job, Error **errp) @@ -356,6 +374,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDr= iverState *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, BlockDr= iverState *bs, int64_t cluster_size; BlockDriverState *cbw =3D NULL; BlockCopyState *bcs =3D NULL; + BlockBackend *source_blk =3D NULL, *target_blk =3D NULL; =20 assert(bs); assert(target); @@ -376,6 +396,12 @@ BlockJob *backup_job_create(const char *job_id, BlockD= riverState *bs, assert(sync_mode !=3D MIRROR_SYNC_MODE_INCREMENTAL); assert(sync_bitmap || sync_mode !=3D MIRROR_SYNC_MODE_BITMAP); =20 + if (immutable_source && filter_node_name) { + error_setg(errp, "immutable-source and filter-node-name should not= " + "be set simultaneously"); + return NULL; + } + if (bs =3D=3D target) { error_setg(errp, "Source and target cannot be the same"); return NULL; @@ -450,9 +476,40 @@ BlockJob *backup_job_create(const char *job_id, BlockD= riverState *bs, goto error; } =20 - cbw =3D bdrv_cbw_append(bs, target, filter_node_name, &bcs, errp); - if (!cbw) { - goto error; + if (immutable_source) { + BdrvDirtyBitmap *copy_bitmap; + + source_blk =3D 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 =3D blk_new_with_bs(target, BLK_PERM_WRITE, + BLK_PERM_CONSISTENT_READ, errp); + if (!target_blk) { + goto error; + } + + /* + * initalize block-copy state and copy bitmap in a way copy-before= -write + * filter do it, to have same code path later. + */ + bcs =3D block_copy_state_new(blk_root(source_blk), blk_root(target= _blk), + false, false, errp); + if (!bcs) { + goto error; + } + + copy_bitmap =3D block_copy_dirty_bitmap(bcs); + bdrv_set_dirty_bitmap(copy_bitmap, 0, + bdrv_dirty_bitmap_size(copy_bitmap)); + } else { + cbw =3D bdrv_cbw_append(bs, target, filter_node_name, &bcs, errp); + if (!cbw) { + goto error; + } } =20 cluster_size =3D block_copy_cluster_size(bcs); @@ -464,7 +521,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDr= iverState *bs, } =20 /* job->len is fixed, so we can't allow resize */ - job =3D block_job_create(job_id, &backup_job_driver, txn, cbw, + job =3D 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 +531,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDr= iverState *bs, job->cbw =3D cbw; job->source_bs =3D bs; job->target_bs =3D target; + job->source_blk =3D source_blk; + job->target_blk =3D target_blk; job->on_source_error =3D on_source_error; job->on_target_error =3D on_target_error; job->sync_mode =3D sync_mode; @@ -501,6 +560,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDr= iverState *bs, if (cbw) { bdrv_cbw_drop(cbw); } + blk_unref(source_blk); + blk_unref(target_blk); =20 return NULL; } diff --git a/block/replication.c b/block/replication.c index 774e15df16..8839ababa4 100644 --- a/block/replication.c +++ b/block/replication.c @@ -566,7 +566,7 @@ static void replication_start(ReplicationState *rs, Rep= licationMode mode, s->backup_job =3D backup_job_create( NULL, s->secondary_disk->bs, s->hidden_dis= k->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 *backu= p, backup->sync, bmap, backup->bitmap_mode, backup->compress, backup->filter_node_name, + backup->immutable_source, &perf, backup->on_source_error, backup->on_target_error, --=20 2.29.2 From nobody Sat May 18 23:14:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1626876645; cv=pass; d=zohomail.com; s=zohoarc; b=VUbymzoU26zWvlyc9ap2OXajBlBUhD9h6h7FH5/lCBLAprZdnUVMu5hmbvXhwtg2ENyDoC8QnAQ6R9JWOJL+lHadFMndQA6HVJ6DUW+uyFvYmZedq6OlBejIJpvV0ymageQSk3O3VQmIuNrs7mt0c8efFvVbZdmTrvLUgXHeq7s= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626876645; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PGm2uqLSxHsP3FsPqqvzoklSv0TGI8UcplfD7f9xkBg=; b=QbMUddFLOtdDC3rF4FnwMoS2dPPs56TFXz4dtC6qbOMytIAW1hZzh1uFye8VwqTxYEbe8lexHxIZ9KIEYo6wpuei88qkCBfO8kMJ8plK7jmCNpb7ysiljGoo+sRmrGYblNXJ5yHanmzSawtmJy0GjQr+Q9uLGOKSuQcmQ3PaLi0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626876645326348.42406846728693; Wed, 21 Jul 2021 07:10:45 -0700 (PDT) Received: from localhost ([::1]:42860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m6Cvs-0003GC-5q for importer@patchew.org; Wed, 21 Jul 2021 10:10:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6CqS-0002e2-9V; Wed, 21 Jul 2021 10:05:12 -0400 Received: from mail-eopbgr80105.outbound.protection.outlook.com ([40.107.8.105]:17431 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6CqQ-0007Ca-8C; Wed, 21 Jul 2021 10:05:08 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24; Wed, 21 Jul 2021 14:04:47 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%6]) with mapi id 15.20.4331.034; Wed, 21 Jul 2021 14:04:47 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 21 Jul 2021 14:04:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QU1FJXyF+2tPzYlSGZESDceEUmF9UhQ0PCjnWCim1vn9jf70RV3mL2ocuMd/R3rtwy+wL1Sk6aanDazMumW1PCHGAyOHypuaOhQB86tSGUFn9mTO64YntbheEnru80C7yKoWAiaMPQXNQ36OFpOD7LS9iKePRpzWOMEG7/SxJS5D0vra/7wca+W/WD1riu93qBdkuo/A4QcBcA8DJhwwVorz6Mxiuf2pBx7rZzKA5JawiGmnjAAHfIJF2PvS2bycYOTYSFELKNxhbevm+rTKY9wMPbfAKESN9cK9cyAN5bB0zpCcCE+daKiqcXpr8gLqLCEb3Bb6q43Wg8dnPpIaRw== 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=PGm2uqLSxHsP3FsPqqvzoklSv0TGI8UcplfD7f9xkBg=; b=HJXE3AmQU1PceFXQjf6iKjIHPbidS2Knr5ELf1FOxZ7YpEh0jWDWzjEiHkaEl+/2RhiVQR/WpYMjOi39a5XjudtvEFZUeLPtiy1WQgEAFGO851AF/ibZd7T4Kfeq/c4ogdaZjtV3fWZ8aUqCQSZo+k4M6ulYDzB7tn0XvKw11R1J9dn5v5JvT5SdaTkufRo8MyVnzYvY5wNByZ7n6L7jsz+WmWSq7U7qoNkds4O6+7N3MIy9ONJPajr4Pk202P0WLamL894W39uCAnsTDqDZ7skjU5qCa6BGIWgvhVP1rQ+ISorlgCd8zj0EunJiRuHIP2VspEhcIvkWfsNW4V4dzQ== 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=PGm2uqLSxHsP3FsPqqvzoklSv0TGI8UcplfD7f9xkBg=; b=EC9m4TxgzakUJ4O3rYVxFXPyJ18FD3c1QxLp1O9AhyoUH5o4O+FCBj5/8SdY9dF8M6QckB6V7agwd6bxhA+E0smjqRbCPZAoD0UFvAtqINI5Et3FyOHK8R7QZiXkE+VsIh0qGHLlvy2zfewz9cyTrNxRsjYNv6Aj8Ow4HKfX7EQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, vsementsov@virtuozzo.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v2 6/6] iotests/image-fleecing: test push backup with fleecing Date: Wed, 21 Jul 2021 17:04:24 +0300 Message-Id: <20210721140424.163701-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210721140424.163701-1-vsementsov@virtuozzo.com> References: <20210721140424.163701-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HE1P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:3:fd::26) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6349621a-c8b3-46e1-65fb-08d94c507f6f X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: 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: XQ3fVzLWT8dNngRsu79EqZ1Ve6wrixllUwpv6qJ/6Jy0hrhk6Jydn/4dkN+EkuJYXmFy03BnFRJYDFWtS+htBQo/g+eypVmLRFLLwPXoTzcZbrKf+NE/b0Fr/ozfgXg6e8cs/7Vt31NoACKBNqIc5UUFVhiWg8ITi4vqAEHQgCZ26fyc8LAfZnL667H2SRBWYLgOgD1S0pUU1+XZHx/l/9kcdpku4l/DaOQ3cmLCfcUonWrro3Gizbi+Yl+90Mjx7bDYwVJiCjHCyeDsqefYr6JO7gk/YZVEzDs6Uq17E6TSiXAYZKk87QLLM47AcRSiDQQ39U075U6lV81YKfWJ1/waKtDlp1pcWevgqIFO0axXrgNWljlymp/CX6wpeZOrCCfdBXWRsdRyGfgKqFFRWse4CPw2SipcISI4bGaKg3bnkOf43iJdZ95aZVENdPCswVQT0inOpSVxLZdp4tenA8u4fdGpawYJB4TVWN8/AWauX9BrspLxMlKBQK1z6Zr0qTp8C27DlDMItaHT9x9hFXMV3ZI/dijKnqEwj3o5w26x/17/8aciXxnuZRcx0JZbKay8dDHwdfntis9s8xMhnzNjpMDspv5E7WWylzqCTYoPyyMZDYKLCPhKRgYW6kVxtxM1sNggW7mraOHeC1iOIQ2yexco+uXuNBBj/WlRxuw0E+0hg1+Aw9DHU8ZI8MobIFK/1oSrZaW474A0/Dnuxg== 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)(366004)(346002)(136003)(396003)(39840400004)(376002)(38100700002)(5660300002)(52116002)(38350700002)(2906002)(83380400001)(956004)(1076003)(6506007)(6916009)(316002)(6666004)(66946007)(66476007)(66556008)(478600001)(186003)(4326008)(36756003)(6512007)(86362001)(26005)(8936002)(8676002)(6486002)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?LOqedaxUBBsC3R2ZtOxwYphD4cc/Fu1wVMu/LIxgxNXs8VDySevp8BqsgW/n?= =?us-ascii?Q?7VlqAVQvlPO1GzzHAKIalI1n7TCCThI68WTwSL6bsck2ZudtQBr8HHzx+TK9?= =?us-ascii?Q?n+Pvx4TgfekMnEZ8jC2McSClM2/O88pj1XWE4LJ7ivqF+gThP4hoCT2a2aYH?= =?us-ascii?Q?DV9Tw0Lh4Oj+vSj54G8spvIBlVGH56DZ7j1M/JsYd9wVgVWGBvfq+SYyzvQU?= =?us-ascii?Q?ZaWVoOIcdIzDObFmmfhw+w4OgPD2vGrXJPR1VRa54wI6mpANnnvLHT3XQONf?= =?us-ascii?Q?BGXjDJhszbfMRNbxNybnS+gjctjk0unF7ORVbGfy/WbijogVtKOwN2x6KH+4?= =?us-ascii?Q?A7c6rMdKUfvs1DXSq9njbJolndfKlkanamVmm3C/KSHv5XZs6nkW4nBycFPV?= =?us-ascii?Q?9i0eKJgC5hFhDRGEVoOXIl8NwZueQslAetuo5hPmsL6yk+Bs5rpYvtxeLh2s?= =?us-ascii?Q?rC8zua29VxBrtt6CzGQ6MLKTK/Q+qjU0cBPbp5QOrcjgXA/1db6k9e8FqRa8?= =?us-ascii?Q?pem9oscC2ucFu2P20F1PJWAIElwQnZwaH71iXVd4gzBi3aiZEEW0QO6fbqGP?= =?us-ascii?Q?Fhv3HH2MU5qjHC/3ZeDkWFu450/FKIbstqJ+9uUQYVXSovm7j9D86N0x8tXU?= =?us-ascii?Q?inpd4yB0TSLDv9q2iiC5H5qft0wV6UA6esflUxyftHwsgADC4lNIvdAFvJdz?= =?us-ascii?Q?4j5A+KE0Y0luYzPp4xvyUu5ami6KV4+Sm11KrOsrc2BSAATVMckRy9rsHjeN?= =?us-ascii?Q?JASJAX2bYnprm/x7oE+RCC8U0OvnQE7ADX3cm5GgSQfY6DtTdGGv71ar6j+X?= =?us-ascii?Q?/hs+noI3Qx4gOfgK515WNFtNdY0tgtmls+Fcn+sH3s+Sj4HQXkt6VPwumhuy?= =?us-ascii?Q?PdkHWpe0XvwVz0+atkV+6t3iKylhpBgzK+Z1oCXWGWjDoBX/8/kLVpa/xhIF?= =?us-ascii?Q?nWf2SS6iGv1SfCbZwbXHhCf44lthRB9cqF+u/FjqEiG2c2VhVFNPZXn2RCj6?= =?us-ascii?Q?6W106VrrunQY7veWo4BIqCnBbR89qhc0TzPAGeFeem4U4UIFlwnbUYZ0TxI9?= =?us-ascii?Q?fNvI+JxsT71zkzjgG/QtMVlqn1jycvdgZXgW03qcV+nmiaq7/y5Go5srIYzs?= =?us-ascii?Q?lMwz91m8lf8gAi4lqQyrdLlCVFGeLadS+/WNjzHW2bD3FzHGAy43lUEKGf6I?= =?us-ascii?Q?snggn0Owj8pOX1a+5mcQTxy3zhD0DNcMMb/M5+FB7Fcnhrh6itcVv/VghCCK?= =?us-ascii?Q?UXKNxIcpZq0aSdcPh9j5ajSMy9dk93mkqI1tFV3gx6Mds9ONci+GzuqvM8sF?= =?us-ascii?Q?ALGsmswMjNxpxnWjeQqJbR1S?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6349621a-c8b3-46e1-65fb-08d94c507f6f X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2021 14:04:47.0280 (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: i32YuHWZ7UjN8RmAtZLpXSNxSMap3LPYNd9i6dz5EDP/oTN4YKKD5Ju81CvS6x16wvOW5nelnkOcjfv7yrMUhgEHtnA8Twaz0vIR1Xx4uis= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.8.105; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1626876646152100002 Content-Type: text/plain; charset="utf-8" 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 | 105 +++++++++++++++----- tests/qemu-iotests/tests/image-fleecing.out | 61 ++++++++++++ 2 files changed, 141 insertions(+), 25 deletions(-) diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/t= ests/image-fleecing index f6318492c6..083cfacc6f 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -48,12 +48,20 @@ remainder =3D [('0xd5', '0x108000', '32k'), # Right-en= d of partial-left [1] ('0xdc', '32M', '32k'), # Left-end of partial-right [2] ('0xcd', '0x3ff0000', '64k')] # patterns[3] =20 -def do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm): +def do_test(vm, use_cbw, base_img_path, fleece_img_path, nbd_sock_path=3DN= one, + target_img_path=3DNone): + push_backup =3D target_img_path is not None + assert (nbd_sock_path is not None) !=3D push_backup + if push_backup: + assert use_cbw + log('--- Setting up images ---') log('') =20 assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') = =3D=3D 0 assert qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') =3D= =3D 0 + if push_backup: + assert qemu_img('create', '-f', 'qcow2', target_img_path, '64M') = =3D=3D 0 =20 for p in patterns: qemu_io('-f', iotests.imgfmt, @@ -108,25 +116,43 @@ def do_test(use_cbw, base_img_path, fleece_img_path, = nbd_sock_path, vm): target=3Dtmp_node, sync=3D'none')) =20 - log('') - log('--- Setting up NBD Export ---') - log('') + if push_backup: + log('') + log('--- Starting actual backup ---') + log('') + + log(vm.qmp('blockdev-add', **{ + 'driver': iotests.imgfmt, + 'node-name': 'target', + 'file': { + 'driver': 'file', + 'filename': target_img_path + } + })) + log(vm.qmp('blockdev-backup', device=3Dtmp_node, + sync=3D'full', target=3D'target', + immutable_source=3DTrue, + job_id=3D'push-backup', speed=3D1)) + else: + log('') + log('--- Setting up NBD Export ---') + log('') =20 - nbd_uri =3D 'nbd+unix:///%s?socket=3D%s' % (tmp_node, nbd_sock_path) - log(vm.qmp('nbd-server-start', - {'addr': { 'type': 'unix', - 'data': { 'path': nbd_sock_path } } })) + nbd_uri =3D 'nbd+unix:///%s?socket=3D%s' % (tmp_node, nbd_sock_pat= h) + log(vm.qmp('nbd-server-start', + {'addr': { 'type': 'unix', + 'data': { 'path': nbd_sock_path } } })) =20 - log(vm.qmp('nbd-server-add', device=3Dtmp_node)) + log(vm.qmp('nbd-server-add', device=3Dtmp_node)) =20 - log('') - log('--- Sanity Check ---') - log('') + log('') + log('--- Sanity Check ---') + log('') =20 - for p in patterns + zeroes: - cmd =3D 'read -P%s %s %s' % p - log(cmd) - assert qemu_io_silent('-r', '-f', 'raw', '-c', cmd, nbd_uri) =3D= =3D 0 + for p in patterns + zeroes: + cmd =3D 'read -P%s %s %s' % p + log(cmd) + assert qemu_io_silent('-r', '-f', 'raw', '-c', cmd, nbd_uri) = =3D=3D 0 =20 log('') log('--- Testing COW ---') @@ -137,6 +163,20 @@ def do_test(use_cbw, base_img_path, fleece_img_path, n= bd_sock_path, vm): log(cmd) log(vm.hmp_qemu_io(qom_path, cmd, qdev=3DTrue)) =20 + if push_backup: + # Check that previous operations were done during backup, not after + result =3D vm.qmp('query-block-jobs') + if len(result['return']) !=3D 1: + log('Backup finished too fast, COW is not tested') + + result =3D vm.qmp('block-job-set-speed', device=3D'push-backup', s= peed=3D0) + assert result =3D=3D {'return': {}} + + log(vm.event_wait(name=3D'BLOCK_JOB_COMPLETED', + match=3D{'data': {'device': 'push-backup'}}), + filters=3D[iotests.filter_qmp_event]) + log(vm.qmp('blockdev-del', node_name=3D'target')) + log('') log('--- Verifying Data ---') log('') @@ -144,7 +184,10 @@ def do_test(use_cbw, base_img_path, fleece_img_path, n= bd_sock_path, vm): for p in patterns + zeroes: cmd =3D 'read -P%s %s %s' % p log(cmd) - assert qemu_io_silent('-r', '-f', 'raw', '-c', cmd, nbd_uri) =3D= =3D 0 + if push_backup: + assert qemu_io_silent('-r', '-c', cmd, target_img_path) =3D=3D= 0 + else: + assert qemu_io_silent('-r', '-f', 'raw', '-c', cmd, nbd_uri) = =3D=3D 0 =20 log('') log('--- Cleanup ---') @@ -159,7 +202,9 @@ def do_test(use_cbw, base_img_path, fleece_img_path, nb= d_sock_path, vm): assert e is not None log(e, filters=3D[iotests.filter_qmp_event]) =20 - log(vm.qmp('nbd-server-stop')) + if not push_backup: + log(vm.qmp('nbd-server-stop')) + log(vm.qmp('blockdev-del', node_name=3Dtmp_node)) vm.shutdown() =20 @@ -175,18 +220,28 @@ def do_test(use_cbw, base_img_path, fleece_img_path, = nbd_sock_path, vm): log('') log('Done') =20 - -def test(use_cbw): +def test(use_cbw, nbd_sock_path=3DNone, target_img_path=3DNone): with iotests.FilePath('base.img') as base_img_path, \ iotests.FilePath('fleece.img') as fleece_img_path, \ - iotests.FilePath('nbd.sock', - base_dir=3Diotests.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(vm, use_cbw, base_img_path, fleece_img_path, nbd_sock_path, + target_img_path) + +def test_pull(use_cbw): + with iotests.FilePath('nbd.sock', + base_dir=3Diotests.sock_dir) as nbd_sock_path: + test(use_cbw, nbd_sock_path, None) + +def test_push(): + with iotests.FilePath('target.img') as target_img_path: + test(True, None, target_img_path) =20 =20 log('=3D=3D=3D Test backup(sync=3Dnone) based fleecing =3D=3D=3D\n') -test(False) +test_pull(False) =20 log('=3D=3D=3D Test filter based fleecing =3D=3D=3D\n') -test(True) +test_pull(True) + +log('=3D=3D=3D Test push backup with fleecing =3D=3D=3D\n') +test_push() diff --git a/tests/qemu-iotests/tests/image-fleecing.out b/tests/qemu-iotes= ts/tests/image-fleecing.out index e96d122a8b..4d132c4633 100644 --- a/tests/qemu-iotests/tests/image-fleecing.out +++ b/tests/qemu-iotests/tests/image-fleecing.out @@ -137,3 +137,64 @@ read -P0xdc 32M 32k read -P0xcd 0x3ff0000 64k =20 Done +=3D=3D=3D Test push backup with fleecing =3D=3D=3D + +--- Setting up images --- + +Done + +--- Launching VM --- + +Done + +--- Setting up Fleecing Graph --- + +{"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, "s= peed": 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": {}} + +--- 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 --=20 2.29.2