From nobody Thu Nov 14 18:10:55 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=1629795105; cv=pass; d=zohomail.com; s=zohoarc; b=j8/gnUqOMBwtJVJ9qICjUUiCvo3+SpA4NT3JCwmw1t5L5TnZcr1uEUXk5I2xInVJIpEtainjw3WlHK2D3DN0Hq6u3Z6zs4fyJnP1zAQ4H9HKuzeh65vDURlsXdz/jPgQdXVziPxbI6yn3DqMCFV/Yx1wUZaHqq589+u0NAThSBc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629795105; 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=4UWqmIf4AvtJh12xDaKMPwgVVNXOvucUFiqwK3tqziM=; b=RUc4YMGBbH+L/N3Nx7niIi3aaSTsosx0BE4Fv681ifgdpYxGl/0VuoUwh0QrrZCAEhm9CoUi0qYN9JYgk51ZBqhr415OujsKJ/RqRo/ff94lvMAW/bOWLruegv2tbSCplnHOGOFhX8hDl7bzk9ivTu1gtTFPDXsFA//aO79U5so= 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 16297951057121022.9626186118688; Tue, 24 Aug 2021 01:51:45 -0700 (PDT) Received: from localhost ([::1]:60988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIS9o-0004VW-G1 for importer@patchew.org; Tue, 24 Aug 2021 04:51:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIRyC-0002Y1-J3; Tue, 24 Aug 2021 04:39:44 -0400 Received: from mail-eopbgr130120.outbound.protection.outlook.com ([40.107.13.120]:56386 helo=EUR01-HE1-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 1mIRy8-0007HX-4p; Tue, 24 Aug 2021 04:39:42 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6533.eurprd08.prod.outlook.com (2603:10a6:20b:33e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Tue, 24 Aug 2021 08:39:24 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::3c5e:7829:362d:1423]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::3c5e:7829:362d:1423%2]) with mapi id 15.20.4436.025; Tue, 24 Aug 2021 08:39:24 +0000 Received: from localhost.localdomain (185.215.60.249) by HE1PR05CA0178.eurprd05.prod.outlook.com (2603:10a6:3:f8::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Tue, 24 Aug 2021 08:39:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=REVJOfBj4SrfGIVUtj0u8w84Y4CJhj9TQj21lkb4K+3TDjhx6o6OFvBmMRYf9UyugsdCX4sDMv6/+YIAXUn2tWcnj/KtpoF0wVVCXOoqv79pcCIfuNPyW0Mmy32R7jrRkWy+03Fy+Z8NbPbjTUKpRJ8SALV9lmP7U52bgZFCa/fGwJ0q0p0RcnF3d15NWseVN4mBVeG7X5M2ELXWkJyUfnVsP61cZ+emJE/oFkK+xCsif9KJcNixbtKrs3B/l8eSA5+6kKGheIXxRoo/HV8zSZIZaUvUJB69PE2n2fhdATht5IeP427kB6ew8rRxUQLpijsVSndCz0cNyRNedfZY9Q== 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=4UWqmIf4AvtJh12xDaKMPwgVVNXOvucUFiqwK3tqziM=; b=NdAx6klMscX92UAwcrYbVKuRppFNeuDWuH6eG1M1UN3oKE97WVC7QE+3RPNlNU7R8OvcaCwa8zDzOBXGdqhVVVjh2KRbWy3PwX9WY1rlDO7+mqVFZZ8oQfsX8RpwvEt00DwN+RXpn7tiYg5tos9mC1tXNUM6AdbpW6kPeOVjYXdw4ZMO1U4idqymMOi3DpyufTdGVuiNZNSM/ILFfWV6y9toSnxsckQkrxUzO5+AoHnbSeBSQfnMmUsCAEdCrphzVaPDsb4Bz7M2txOGr92FGVyO6tjCjpBjsnRvgdCKTaBg4rgad/Ud3AYIaYullfBzjxOrF2mwqg/QRErO46Qu3w== 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=4UWqmIf4AvtJh12xDaKMPwgVVNXOvucUFiqwK3tqziM=; b=obvsJBnsuIwH6eWxWfCj9pyNpirkj+t6bUuKpsuuM4gDST/QbTvGjTrqPtBD792K4UDN7MohgbOLpUVYBv/9XMuFyvnZ8Wy8+KIotoYsFw3NkqEtNvZskbQTymg3DznnCC8LDLRv/EXmnUVQKcy/6gxQMCKOW/6fL5XHWKz7EW4= 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, crosa@redhat.com, ehabkost@redhat.com, berrange@redhat.com, pbonzini@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, hreitz@redhat.com, kwolf@redhat.com, Max Reitz Subject: [PATCH v8 05/34] block: rename backup-top to copy-before-write Date: Tue, 24 Aug 2021 11:38:27 +0300 Message-Id: <20210824083856.17408-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210824083856.17408-1-vsementsov@virtuozzo.com> References: <20210824083856.17408-1-vsementsov@virtuozzo.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HE1PR05CA0178.eurprd05.prod.outlook.com (2603:10a6:3:f8::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: 043e2fb3-ccc6-4a70-6b9e-08d966daad12 X-MS-TrafficTypeDiagnostic: AS8PR08MB6533: 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: et0an93fjc93VNELMEZTCFGhfaCyEBPT3m0I5Aq+zTnBjQ8NX+S4WgkYLCCbmIjyL7n5zKMcyg+GdcKWA3/lcIezIH3Ow6MdXk8Ktx84r3s3Gj1zfUrOR7qgiEGvZW9It+6FDWwTSCK0nwWaDJ36JDwOsXESHDAvr1uqNOo39eaSkue+gn8KT3QctD+VQTIB4RLtdgefdB9KMnGh+Mi8PlvUAPUf18HLZU4snRCcF/Y7oTwglyqUfAlkrdh8rGV5jStaXnEY2Gg9LBhjCEAm90p6Bz68dMxBWTZUxVitiizPxhKWwIsgrg4R6fq3fB9/7gVeyde/i7r/VbMvIQisTQavAMZOi4zcuAGltyybOaPNbIsCBPVQ/CGvbiE/G/UUPdWfmffd6XFi3LDlEnO3RgBHdTavOUtjdRaJSpAjxRbuCed25P2loU/TKZnA00vrdqgI76EgSnUzENJIA2xxw1KE1k+rMQiTdzPlqJsyTZ+MHqEZcaevfmzhSfu3I8gDVZGcBr+x7lHjeTGIm7uQOv0xsbwyCE591JWcFDKK4dJ+FlyBHQrdKQsLOPaD0CsVSQ4/PcUhIgmNwMmoh/xx/j+f2GxN9JgA9xdRsyS5ONvTnRalI5WprA6kSx9Avvw5BsmQ2xprRhzpKxrgteptSqFq4HwbHybzk1k45/ImvlFbLiKZZ2K8utVl4bHJMp20A29fx7qwbFfjk0imdDYCo3w0ImvN3Py91JjlOsPNzvNT6SbIc15QTXSiNVuAuozJ0XPu0bw3HARCXdz61fegPw== 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)(396003)(366004)(376002)(136003)(39830400003)(346002)(316002)(83380400001)(86362001)(36756003)(4326008)(6512007)(186003)(6486002)(478600001)(1076003)(6506007)(26005)(38100700002)(30864003)(38350700002)(7416002)(52116002)(6916009)(2616005)(8676002)(66476007)(2906002)(5660300002)(66556008)(956004)(8936002)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-Chunk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?utf-8?Q?RuXlxane9HEi8FX9PssMuPIr0zyK4T8FdSLS0/8?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 043e2fb3-ccc6-4a70-6b9e-08d966daad12 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2021 08:39:24.4455 (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: /sGFsXjzaHqs/J7IMjxShqVNkgXQ967ubD5GW92FJbN1xgzqiQWl5vR/tLpY3A1pdu/gnlPawDNvUCT0VlHYM1viLC20FL6Yem/HBPVz3RU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6533 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.13.120; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-HE1-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: 1629795106308100002 We are going to convert backup_top to full featured public filter, which can be used in separate of backup job. Start from renaming from "how it used" to "what it does". While updating comments in 283 iotest, drop and rephrase also things about ".active", as this field is now dropped, and filter doesn't have "inactive" mode. Note that this change may be considered as incompatible interface change, as backup-top filter format name was visible through query-block and query-named-block-nodes. Still, consider the following reasoning: 1. backup-top was never documented, so if someone depends on format name (for driver that can't be used other than it is automatically inserted on backup job start), it's a kind of "undocumented feature use". So I think we are free to change it. 2. There is a hope, that there is no such users: it's a lot more native to give a good node-name to backup-top filter if need to operate with it somehow, and don't touch format name. 3. Another "incompatible" change in further commit would be moving copy-before-write filter from using backing child to file child. And this is even more reasonable than renaming: for now all public filters are file-child based. So, it's a risky change, but risk seems small and good interface worth it. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- block/{backup-top.h =3D> copy-before-write.h} | 28 +++--- block/backup.c | 22 ++--- block/{backup-top.c =3D> copy-before-write.c} | 100 ++++++++++---------- MAINTAINERS | 4 +- block/meson.build | 2 +- tests/qemu-iotests/283 | 35 +++---- tests/qemu-iotests/283.out | 4 +- 7 files changed, 95 insertions(+), 100 deletions(-) rename block/{backup-top.h =3D> copy-before-write.h} (56%) rename block/{backup-top.c =3D> copy-before-write.c} (62%) diff --git a/block/backup-top.h b/block/copy-before-write.h similarity index 56% rename from block/backup-top.h rename to block/copy-before-write.h index b28b0031c4..5977b7aa31 100644 --- a/block/backup-top.h +++ b/block/copy-before-write.h @@ -1,10 +1,10 @@ /* - * backup-top filter driver + * copy-before-write filter driver * * The driver performs Copy-Before-Write (CBW) operation: it is injected a= bove * some node, and before each write it copies _old_ data to the target nod= e. * - * Copyright (c) 2018-2019 Virtuozzo International GmbH. + * Copyright (c) 2018-2021 Virtuozzo International GmbH. * * Author: * Sementsov-Ogievskiy Vladimir @@ -23,20 +23,20 @@ * along with this program. If not, see . */ =20 -#ifndef BACKUP_TOP_H -#define BACKUP_TOP_H +#ifndef COPY_BEFORE_WRITE_H +#define COPY_BEFORE_WRITE_H =20 #include "block/block_int.h" #include "block/block-copy.h" =20 -BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, - BlockDriverState *target, - const char *filter_node_name, - uint64_t cluster_size, - BackupPerf *perf, - BdrvRequestFlags write_flags, - BlockCopyState **bcs, - Error **errp); -void bdrv_backup_top_drop(BlockDriverState *bs); +BlockDriverState *bdrv_cbw_append(BlockDriverState *source, + BlockDriverState *target, + const char *filter_node_name, + uint64_t cluster_size, + BackupPerf *perf, + BdrvRequestFlags write_flags, + BlockCopyState **bcs, + Error **errp); +void bdrv_cbw_drop(BlockDriverState *bs); =20 -#endif /* BACKUP_TOP_H */ +#endif /* COPY_BEFORE_WRITE_H */ diff --git a/block/backup.c b/block/backup.c index bd3614ce70..ac91821b08 100644 --- a/block/backup.c +++ b/block/backup.c @@ -27,13 +27,13 @@ #include "qemu/bitmap.h" #include "qemu/error-report.h" =20 -#include "block/backup-top.h" +#include "block/copy-before-write.h" =20 #define BACKUP_CLUSTER_SIZE_DEFAULT (1 << 16) =20 typedef struct BackupBlockJob { BlockJob common; - BlockDriverState *backup_top; + BlockDriverState *cbw; BlockDriverState *source_bs; BlockDriverState *target_bs; =20 @@ -104,7 +104,7 @@ static void backup_clean(Job *job) { BackupBlockJob *s =3D container_of(job, BackupBlockJob, common.job); block_job_remove_all_bdrv(&s->common); - bdrv_backup_top_drop(s->backup_top); + bdrv_cbw_drop(s->cbw); } =20 void backup_do_checkpoint(BlockJob *job, Error **errp) @@ -408,7 +408,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDr= iverState *bs, BackupBlockJob *job =3D NULL; int64_t cluster_size; BdrvRequestFlags write_flags; - BlockDriverState *backup_top =3D NULL; + BlockDriverState *cbw =3D NULL; BlockCopyState *bcs =3D NULL; =20 assert(bs); @@ -521,22 +521,22 @@ BlockJob *backup_job_create(const char *job_id, Block= DriverState *bs, write_flags =3D (bdrv_chain_contains(target, bs) ? BDRV_REQ_SERIALISIN= G : 0) | (compress ? BDRV_REQ_WRITE_COMPRESSED : 0), =20 - backup_top =3D bdrv_backup_top_append(bs, target, filter_node_name, + cbw =3D bdrv_cbw_append(bs, target, filter_node_name, cluster_size, perf, write_flags, &bcs, errp); - if (!backup_top) { + if (!cbw) { goto error; } =20 /* job->len is fixed, so we can't allow resize */ - job =3D block_job_create(job_id, &backup_job_driver, txn, backup_top, + job =3D block_job_create(job_id, &backup_job_driver, txn, cbw, 0, BLK_PERM_ALL, speed, creation_flags, cb, opaque, errp); if (!job) { goto error; } =20 - job->backup_top =3D backup_top; + job->cbw =3D cbw; job->source_bs =3D bs; job->target_bs =3D target; job->on_source_error =3D on_source_error; @@ -552,7 +552,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDr= iverState *bs, block_copy_set_progress_meter(bcs, &job->common.job.progress); block_copy_set_speed(bcs, speed); =20 - /* Required permissions are already taken by backup-top target */ + /* Required permissions are taken by copy-before-write filter target */ block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL, &error_abort); =20 @@ -562,8 +562,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDr= iverState *bs, if (sync_bitmap) { bdrv_reclaim_dirty_bitmap(sync_bitmap, NULL); } - if (backup_top) { - bdrv_backup_top_drop(backup_top); + if (cbw) { + bdrv_cbw_drop(cbw); } =20 return NULL; diff --git a/block/backup-top.c b/block/copy-before-write.c similarity index 62% rename from block/backup-top.c rename to block/copy-before-write.c index 425e3778be..0dc5a107cf 100644 --- a/block/backup-top.c +++ b/block/copy-before-write.c @@ -1,10 +1,10 @@ /* - * backup-top filter driver + * copy-before-write filter driver * * The driver performs Copy-Before-Write (CBW) operation: it is injected a= bove * some node, and before each write it copies _old_ data to the target nod= e. * - * Copyright (c) 2018-2019 Virtuozzo International GmbH. + * Copyright (c) 2018-2021 Virtuozzo International GmbH. * * Author: * Sementsov-Ogievskiy Vladimir @@ -32,25 +32,25 @@ #include "block/qdict.h" #include "block/block-copy.h" =20 -#include "block/backup-top.h" +#include "block/copy-before-write.h" =20 -typedef struct BDRVBackupTopState { +typedef struct BDRVCopyBeforeWriteState { BlockCopyState *bcs; BdrvChild *target; int64_t cluster_size; -} BDRVBackupTopState; +} BDRVCopyBeforeWriteState; =20 -static coroutine_fn int backup_top_co_preadv( +static coroutine_fn int cbw_co_preadv( BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { return bdrv_co_preadv(bs->backing, offset, bytes, qiov, flags); } =20 -static coroutine_fn int backup_top_cbw(BlockDriverState *bs, uint64_t offs= et, - uint64_t bytes, BdrvRequestFlags fl= ags) +static coroutine_fn int cbw_do_copy_before_write(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, BdrvRequestFlags flags) { - BDRVBackupTopState *s =3D bs->opaque; + BDRVCopyBeforeWriteState *s =3D bs->opaque; uint64_t off, end; =20 if (flags & BDRV_REQ_WRITE_UNCHANGED) { @@ -63,10 +63,10 @@ static coroutine_fn int backup_top_cbw(BlockDriverState= *bs, uint64_t offset, return block_copy(s->bcs, off, end - off, true); } =20 -static int coroutine_fn backup_top_co_pdiscard(BlockDriverState *bs, - int64_t offset, int bytes) +static int coroutine_fn cbw_co_pdiscard(BlockDriverState *bs, + int64_t offset, int bytes) { - int ret =3D backup_top_cbw(bs, offset, bytes, 0); + int ret =3D cbw_do_copy_before_write(bs, offset, bytes, 0); if (ret < 0) { return ret; } @@ -74,10 +74,10 @@ static int coroutine_fn backup_top_co_pdiscard(BlockDri= verState *bs, return bdrv_co_pdiscard(bs->backing, offset, bytes); } =20 -static int coroutine_fn backup_top_co_pwrite_zeroes(BlockDriverState *bs, +static int coroutine_fn cbw_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bytes, BdrvRequestFlags flags) { - int ret =3D backup_top_cbw(bs, offset, bytes, flags); + int ret =3D cbw_do_copy_before_write(bs, offset, bytes, flags); if (ret < 0) { return ret; } @@ -85,12 +85,12 @@ static int coroutine_fn backup_top_co_pwrite_zeroes(Blo= ckDriverState *bs, return bdrv_co_pwrite_zeroes(bs->backing, offset, bytes, flags); } =20 -static coroutine_fn int backup_top_co_pwritev(BlockDriverState *bs, - uint64_t offset, - uint64_t bytes, - QEMUIOVector *qiov, int flag= s) +static coroutine_fn int cbw_co_pwritev(BlockDriverState *bs, + uint64_t offset, + uint64_t bytes, + QEMUIOVector *qiov, int flags) { - int ret =3D backup_top_cbw(bs, offset, bytes, flags); + int ret =3D cbw_do_copy_before_write(bs, offset, bytes, flags); if (ret < 0) { return ret; } @@ -98,7 +98,7 @@ static coroutine_fn int backup_top_co_pwritev(BlockDriver= State *bs, return bdrv_co_pwritev(bs->backing, offset, bytes, qiov, flags); } =20 -static int coroutine_fn backup_top_co_flush(BlockDriverState *bs) +static int coroutine_fn cbw_co_flush(BlockDriverState *bs) { if (!bs->backing) { return 0; @@ -107,7 +107,7 @@ static int coroutine_fn backup_top_co_flush(BlockDriver= State *bs) return bdrv_co_flush(bs->backing->bs); } =20 -static void backup_top_refresh_filename(BlockDriverState *bs) +static void cbw_refresh_filename(BlockDriverState *bs) { if (bs->backing =3D=3D NULL) { /* @@ -120,11 +120,11 @@ static void backup_top_refresh_filename(BlockDriverSt= ate *bs) bs->backing->bs->filename); } =20 -static void backup_top_child_perm(BlockDriverState *bs, BdrvChild *c, - BdrvChildRole role, - BlockReopenQueue *reopen_queue, - uint64_t perm, uint64_t shared, - uint64_t *nperm, uint64_t *nshared) +static void cbw_child_perm(BlockDriverState *bs, BdrvChild *c, + BdrvChildRole role, + BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nshared) { if (!(role & BDRV_CHILD_FILTERED)) { /* @@ -149,41 +149,41 @@ static void backup_top_child_perm(BlockDriverState *b= s, BdrvChild *c, } } =20 -BlockDriver bdrv_backup_top_filter =3D { - .format_name =3D "backup-top", - .instance_size =3D sizeof(BDRVBackupTopState), +BlockDriver bdrv_cbw_filter =3D { + .format_name =3D "copy-before-write", + .instance_size =3D sizeof(BDRVCopyBeforeWriteState), =20 - .bdrv_co_preadv =3D backup_top_co_preadv, - .bdrv_co_pwritev =3D backup_top_co_pwritev, - .bdrv_co_pwrite_zeroes =3D backup_top_co_pwrite_zeroes, - .bdrv_co_pdiscard =3D backup_top_co_pdiscard, - .bdrv_co_flush =3D backup_top_co_flush, + .bdrv_co_preadv =3D cbw_co_preadv, + .bdrv_co_pwritev =3D cbw_co_pwritev, + .bdrv_co_pwrite_zeroes =3D cbw_co_pwrite_zeroes, + .bdrv_co_pdiscard =3D cbw_co_pdiscard, + .bdrv_co_flush =3D cbw_co_flush, =20 - .bdrv_refresh_filename =3D backup_top_refresh_filename, + .bdrv_refresh_filename =3D cbw_refresh_filename, =20 - .bdrv_child_perm =3D backup_top_child_perm, + .bdrv_child_perm =3D cbw_child_perm, =20 .is_filter =3D true, }; =20 -BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, - BlockDriverState *target, - const char *filter_node_name, - uint64_t cluster_size, - BackupPerf *perf, - BdrvRequestFlags write_flags, - BlockCopyState **bcs, - Error **errp) +BlockDriverState *bdrv_cbw_append(BlockDriverState *source, + BlockDriverState *target, + const char *filter_node_name, + uint64_t cluster_size, + BackupPerf *perf, + BdrvRequestFlags write_flags, + BlockCopyState **bcs, + Error **errp) { ERRP_GUARD(); int ret; - BDRVBackupTopState *state; + BDRVCopyBeforeWriteState *state; BlockDriverState *top; bool appended =3D false; =20 assert(source->total_sectors =3D=3D target->total_sectors); =20 - top =3D bdrv_new_open_driver(&bdrv_backup_top_filter, filter_node_name, + top =3D bdrv_new_open_driver(&bdrv_cbw_filter, filter_node_name, BDRV_O_RDWR, errp); if (!top) { return NULL; @@ -210,7 +210,7 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverSta= te *source, =20 ret =3D bdrv_append(top, source, errp); if (ret < 0) { - error_prepend(errp, "Cannot append backup-top filter: "); + error_prepend(errp, "Cannot append copy-before-write filter: "); goto fail; } appended =3D true; @@ -231,7 +231,7 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverSta= te *source, =20 fail: if (appended) { - bdrv_backup_top_drop(top); + bdrv_cbw_drop(top); } else { bdrv_unref(top); } @@ -241,9 +241,9 @@ fail: return NULL; } =20 -void bdrv_backup_top_drop(BlockDriverState *bs) +void bdrv_cbw_drop(BlockDriverState *bs) { - BDRVBackupTopState *s =3D bs->opaque; + BDRVCopyBeforeWriteState *s =3D bs->opaque; =20 bdrv_drop_filter(bs, &error_abort); =20 diff --git a/MAINTAINERS b/MAINTAINERS index 6b3697962c..ece044bd25 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2337,8 +2337,8 @@ F: block/mirror.c F: qapi/job.json F: block/block-copy.c F: include/block/block-copy.c -F: block/backup-top.h -F: block/backup-top.c +F: block/copy-before-write.h +F: block/copy-before-write.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 0450914c7a..66ee11e62c 100644 --- a/block/meson.build +++ b/block/meson.build @@ -4,7 +4,7 @@ block_ss.add(files( 'aio_task.c', 'amend.c', 'backup.c', - 'backup-top.c', + 'copy-before-write.c', 'blkdebug.c', 'blklogwrites.c', 'blkverify.c', diff --git a/tests/qemu-iotests/283 b/tests/qemu-iotests/283 index 010c22f0a2..a09e0183ae 100755 --- a/tests/qemu-iotests/283 +++ b/tests/qemu-iotests/283 @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # group: auto quick # -# Test for backup-top filter permission activation failure +# Test for copy-before-write filter permission conflict # # Copyright (c) 2019 Virtuozzo International GmbH. # @@ -31,13 +31,13 @@ size =3D 1024 * 1024 """ Test description =20 When performing a backup, all writes on the source subtree must go through= the -backup-top filter so it can copy all data to the target before it is chang= ed. -backup-top filter is appended above source node, to achieve this thing, so= all -parents of source node are handled. A configuration with side parents of s= ource -sub-tree with write permission is unsupported (we'd have append several -backup-top filter like nodes to handle such parents). The test create an -example of such configuration and checks that a backup is then not allowed -(blockdev-backup command should fail). +copy-before-write filter so it can copy all data to the target before it is +changed. copy-before-write filter is appended above source node, to achie= ve +this thing, so all parents of source node are handled. A configuration with +side parents of source sub-tree with write permission is unsupported (we'd= have +append several copy-before-write filter like nodes to handle such parents)= . The +test create an example of such configuration and checks that a backup is t= hen +not allowed (blockdev-backup command should fail). =20 The configuration: =20 @@ -57,11 +57,10 @@ The configuration: =E2=94=82 base =E2=94=82 =E2=97=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80 =E2=94=82 other =E2=94=82 =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=98 =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=98 =20 -On activation (see .active field of backup-top state in block/backup-top.c= ), -backup-top is going to unshare write permission on its source child. Write -unsharing will be propagated to the "source->base" link and will conflict = with -other node write permission. So permission update will fail and backup job= will -not be started. +copy-before-write filter wants to unshare write permission on its source c= hild. +Write unsharing will be propagated to the "source->base" link and will con= flict +with other node write permission. So permission update will fail and backu= p job +will not be started. =20 Note, that the only thing which prevents backup of running on such configuration is default permission propagation scheme. It may be altered = by @@ -99,13 +98,9 @@ vm.qmp_log('blockdev-backup', sync=3D'full', device=3D's= ource', target=3D'target') vm.shutdown() =20 =20 -print('\n=3D=3D=3D backup-top should be gone after job-finalize =3D=3D=3D\= n') +print('\n=3D=3D=3D copy-before-write filter should be gone after job-final= ize =3D=3D=3D\n') =20 -# Check that the backup-top node is gone after job-finalize. -# -# During finalization, the node becomes inactive and can no longer -# function. If it is still present, new parents might be attached, and -# there would be no meaningful way to handle their I/O requests. +# Check that the copy-before-write node is gone after job-finalize. =20 vm =3D iotests.VM() vm.launch() @@ -131,7 +126,7 @@ vm.qmp_log('blockdev-backup', =20 vm.event_wait('BLOCK_JOB_PENDING', 5.0) =20 -# The backup-top filter should still be present prior to finalization +# The copy-before-write filter should still be present prior to finalizati= on assert vm.node_info('backup-filter') is not None =20 vm.qmp_log('job-finalize', id=3D'backup') diff --git a/tests/qemu-iotests/283.out b/tests/qemu-iotests/283.out index c6e12b15c5..f2b7219632 100644 --- a/tests/qemu-iotests/283.out +++ b/tests/qemu-iotests/283.out @@ -5,9 +5,9 @@ {"execute": "blockdev-add", "arguments": {"driver": "blkdebug", "image": "= base", "node-name": "other", "take-child-perms": ["write"]}} {"return": {}} {"execute": "blockdev-backup", "arguments": {"device": "source", "sync": "= full", "target": "target"}} -{"error": {"class": "GenericError", "desc": "Cannot append backup-top filt= er: Permission conflict on node 'base': permissions 'write' are both requir= ed by node 'other' (uses node 'base' as 'image' child) and unshared by node= 'source' (uses node 'base' as 'image' child)."}} +{"error": {"class": "GenericError", "desc": "Cannot append copy-before-wri= te filter: Permission conflict on node 'base': permissions 'write' are both= required by node 'other' (uses node 'base' as 'image' child) and unshared = by node 'source' (uses node 'base' as 'image' child)."}} =20 -=3D=3D=3D backup-top should be gone after job-finalize =3D=3D=3D +=3D=3D=3D copy-before-write filter should be gone after job-finalize =3D= =3D=3D =20 {"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name"= : "source"}} {"return": {}} --=20 2.29.2