From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589295901; cv=none; d=zohomail.com; s=zohoarc; b=eW73PV0eYN/+KCTP//msn/wxTjvd9M7BdsxX2vuK3at3CNmC1cbF4HQEiW1MahsmwVPnSRkmpjDi7nQDtpqM6qJOaQyZffqXI0Ein8oRDGZ4J51+Pc2GrHae3KorrWjK2pejYHsCKBtOduQK4XD0Oc2AqlIqgOhZE80pu0/MeGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589295901; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ajHbr2zGjHQlukFyIaYtCRBrQE1iBgcDuW1y5sK7aKo=; b=AnsPZO9xxtvRMm+7eOJVl588D481CYmR/XyuCoYxR7zC81GHPMkTXvfAqjvHB8kUIqXcjY8V+cNIV5ECA3Ur1+Ax9dSe+WiPyKrY+wc3FuJbRn+m4484Xvj16SIpsUdXwimgv/OL9RAdkrC1RvmmZLEExiS8kk19tmAihuncG3I= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589295901403982.946505847927; Tue, 12 May 2020 08:05:01 -0700 (PDT) Received: from localhost ([::1]:35368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWSq-0001NF-53 for importer@patchew.org; Tue, 12 May 2020 11:05:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWI2-0005gM-M5; Tue, 12 May 2020 10:53:50 -0400 Received: from relay.sw.ru ([185.231.240.75]:45862) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWI0-0005ov-Kz; Tue, 12 May 2020 10:53:50 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHY-0003c8-Ec; Tue, 12 May 2020 17:53:20 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 01/15] block: Mark commit and mirror as filter drivers Date: Tue, 12 May 2020 17:53:02 +0300 Message-Id: <1589295196-773454-2-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz The commit and mirror block nodes are filters, so they should be marked as such. (Strictly speaking, BDS.is_filter's documentation states that a filter's child must be bs->file. The following patch will relax this restriction, however.) Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Andrey Shinkevich --- block/commit.c | 2 ++ block/mirror.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/block/commit.c b/block/commit.c index 87f6096..445a280 100644 --- a/block/commit.c +++ b/block/commit.c @@ -240,6 +240,8 @@ static BlockDriver bdrv_commit_top =3D { .bdrv_co_block_status =3D bdrv_co_block_status_from_backing, .bdrv_refresh_filename =3D bdrv_commit_top_refresh_filename, .bdrv_child_perm =3D bdrv_commit_top_child_perm, + + .is_filter =3D true, }; =20 void commit_start(const char *job_id, BlockDriverState *bs, diff --git a/block/mirror.c b/block/mirror.c index aca95c9..b6de24b 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1527,6 +1527,8 @@ static BlockDriver bdrv_mirror_top =3D { .bdrv_co_block_status =3D bdrv_co_block_status_from_backing, .bdrv_refresh_filename =3D bdrv_mirror_top_refresh_filename, .bdrv_child_perm =3D bdrv_mirror_top_child_perm, + + .is_filter =3D true, }; =20 static BlockJob *mirror_start_job( --=20 1.8.3.1 From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589295325; cv=none; d=zohomail.com; s=zohoarc; b=fe/AvV//fywjmyn4kpmmcBplgkU5Je1WYcaH7nxfnIMI4CUvUhJhIZxwSdXZCq1GeJJnevkcCczmoiW2CwTH+doHfsEEVKlodgpiuwXWUbb/JdSxOQBLEQFj53QEDayYquwJBYr0DLM7BjQeqdoQ8e7xb7BK1J1EQ4+sj0fAsXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589295325; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=fTpPedRuCFg6qv6M8SYR3huGnurtPASgFMADOKsqFsU=; b=jNaMEpd3kRFc7Oe+8hXkInq0j/hifUHPe9tvOnpLwL2Tpzpe/sKzh8Frli0j+HWXS44QhpXzgL2TsIes0W/G0pzHBGOMtJIxR/b6XE0q3oAyyiihnIF6FVj6FOWUWunxvn9JghvdIaq8FFQIIxlQVjcclh2ivoCVFmrygqZUeZ4= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589295325979980.7398976341092; Tue, 12 May 2020 07:55:25 -0700 (PDT) Received: from localhost ([::1]:55436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWJY-0008Io-L9 for importer@patchew.org; Tue, 12 May 2020 10:55:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHj-0004rX-N2; Tue, 12 May 2020 10:53:31 -0400 Received: from relay.sw.ru ([185.231.240.75]:45878) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHh-0005ow-8Z; Tue, 12 May 2020 10:53:31 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHY-0003c8-Kk; Tue, 12 May 2020 17:53:20 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 02/15] copy-on-read: Support compressed writes Date: Tue, 12 May 2020 17:53:03 +0300 Message-Id: <1589295196-773454-3-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/copy-on-read.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 242d3ff..c4fa468 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -106,6 +106,16 @@ static int coroutine_fn cor_co_pdiscard(BlockDriverSta= te *bs, } =20 =20 +static int coroutine_fn cor_co_pwritev_compressed(BlockDriverState *bs, + uint64_t offset, + uint64_t bytes, + QEMUIOVector *qiov) +{ + return bdrv_co_pwritev(bs->file, offset, bytes, qiov, + BDRV_REQ_WRITE_COMPRESSED); +} + + static void cor_eject(BlockDriverState *bs, bool eject_flag) { bdrv_eject(bs->file->bs, eject_flag); @@ -130,6 +140,7 @@ static BlockDriver bdrv_copy_on_read =3D { .bdrv_co_pwritev =3D cor_co_pwritev, .bdrv_co_pwrite_zeroes =3D cor_co_pwrite_zeroes, .bdrv_co_pdiscard =3D cor_co_pdiscard, + .bdrv_co_pwritev_compressed =3D cor_co_pwritev_compressed, =20 .bdrv_eject =3D cor_eject, .bdrv_lock_medium =3D cor_lock_medium, --=20 1.8.3.1 From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589295534; cv=none; d=zohomail.com; s=zohoarc; b=KLptol/xU0uLKOO3wuHqg59e1JWDMKinXp/lHh9GuPPdhu4ZMKeVPOx0VrcsEsmmzgr5mmRSddsWB13bYh4XebhjoNyLb0pooe2hDCcTP7uqXQtu1aSN51mdzWTyG/aqW6Ic1Ft/xMUYALhgjM64yu0036BFpVrSfFKoIGjRFFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589295534; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=yhLr/o8q/t10fJe6NbjhJZEtWPWIl1+2098ZONPr8M4=; b=disLrJhs6OYdmhiWvzSJ/H8QY4FQFoPb1mnF/2l9gyeWPa3L9GDnhrFAP14XBhBw0fpJX6KP/AQ9Akb/N4m1ZuYGBRvG/TqzK0bNK1lNhzxeYysCvEmhXMcktmMdxH7NBNLmEygFFxALAzgOSrOSZYkSqCZxJoXavyvwUHBIlo8= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589295534572680.387919600916; Tue, 12 May 2020 07:58:54 -0700 (PDT) Received: from localhost ([::1]:42720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWMv-0006nO-8M for importer@patchew.org; Tue, 12 May 2020 10:58:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWI3-0005hh-4c; Tue, 12 May 2020 10:53:51 -0400 Received: from relay.sw.ru ([185.231.240.75]:45874) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWI0-0005p4-PF; Tue, 12 May 2020 10:53:50 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHY-0003c8-SE; Tue, 12 May 2020 17:53:20 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 03/15] block: Add child access functions Date: Tue, 12 May 2020 17:53:04 +0300 Message-Id: <1589295196-773454-4-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz There are BDS children that the general block layer code can access, namely bs->file and bs->backing. Since the introduction of filters and external data files, their meaning is not quite clear. bs->backing can be a COW source, or it can be an R/W-filtered child; bs->file can be an R/W-filtered child, it can be data and metadata storage, or it can be just metadata storage. This overloading really is not helpful. This patch adds function that retrieve the correct child for each exact purpose. Later patches in this series will make use of them. Doing so will allow us to handle filter nodes and external data files in a meaningful way. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Andrey Shinkevich --- block.c | 99 +++++++++++++++++++++++++++++++++++++++++++= ++++ include/block/block_int.h | 57 +++++++++++++++++++++++++-- 2 files changed, 153 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 0653ccb..b2aae2e 100644 --- a/block.c +++ b/block.c @@ -6764,3 +6764,102 @@ void bdrv_del_child(BlockDriverState *parent_bs, Bd= rvChild *child, Error **errp) =20 parent_bs->drv->bdrv_del_child(parent_bs, child, errp); } + +/* + * Return the child that @bs acts as an overlay for, and from which data m= ay be + * copied in COW or COR operations. Usually this is the backing file. + */ +BdrvChild *bdrv_filtered_cow_child(BlockDriverState *bs) +{ + if (!bs || !bs->drv) { + return NULL; + } + + if (bs->drv->is_filter) { + return NULL; + } + + return bs->backing; +} + +/* + * If @bs acts as a pass-through filter for one of its children, + * return that child. "Pass-through" means that write operations to + * @bs are forwarded to that child instead of triggering COW. + */ +BdrvChild *bdrv_filtered_rw_child(BlockDriverState *bs) +{ + if (!bs || !bs->drv) { + return NULL; + } + + if (!bs->drv->is_filter) { + return NULL; + } + + /* Only one of @backing or @file may be used */ + assert(!(bs->backing && bs->file)); + + return bs->backing ?: bs->file; +} + +/* + * Return any filtered child, independently of how it reacts to write + * accesses and whether data is copied onto this BDS through COR. + */ +BdrvChild *bdrv_filtered_child(BlockDriverState *bs) +{ + BdrvChild *cow_child =3D bdrv_filtered_cow_child(bs); + BdrvChild *rw_child =3D bdrv_filtered_rw_child(bs); + + /* There can only be one filtered child at a time */ + assert(!(cow_child && rw_child)); + + return cow_child ?: rw_child; +} + +/* + * Return the child that stores the metadata for this node. + */ +BdrvChild *bdrv_metadata_child(BlockDriverState *bs) +{ + if (!bs || !bs->drv) { + return NULL; + } + + /* Filters do not have metadata */ + if (bs->drv->is_filter) { + return NULL; + } + + return bs->file; +} + +/* + * Return the child that stores the data that is allocated on this + * node. This may or may not include metadata. + */ +BdrvChild *bdrv_storage_child(BlockDriverState *bs) +{ + if (!bs || !bs->drv) { + return NULL; + } + + if (bs->drv->bdrv_storage_child) { + return bs->drv->bdrv_storage_child(bs); + } + + return bdrv_filtered_rw_child(bs) ?: bs->file; +} + +/* + * Return the primary child of this node: For filters, that is the + * filtered child. For other nodes, that is usually the child storing + * metadata. + * (A generally more helpful description is that this is (usually) the + * child that has the same filename as @bs.) + */ +BdrvChild *bdrv_primary_child(BlockDriverState *bs) +{ + return bdrv_filtered_rw_child(bs) ?: bs->file; +} diff --git a/include/block/block_int.h b/include/block/block_int.h index df6d027..dca59e9 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -89,9 +89,11 @@ struct BlockDriver { int instance_size; =20 /* set to true if the BlockDriver is a block filter. Block filters pass - * certain callbacks that refer to data (see block.c) to their bs->fil= e if - * the driver doesn't implement them. Drivers that do not wish to forw= ard - * must implement them and return -ENOTSUP. + * certain callbacks that refer to data (see block.c) to their bs->file + * or bs->backing (whichever one exists) if the driver doesn't impleme= nt + * them. Drivers that do not wish to forward must implement them and r= eturn + * -ENOTSUP. + * Note that filters are not allowed to modify data. */ bool is_filter; /* @@ -585,6 +587,13 @@ struct BlockDriver { * If this pointer is NULL, the array is considered empty. * "filename" and "driver" are always considered strong. */ const char *const *strong_runtime_opts; + + /** + * Return the data storage child, if there is exactly one. If + * this function is not implemented, the block layer will assume + * bs->file to be this child. + */ + BdrvChild *(*bdrv_storage_child)(BlockDriverState *bs); }; =20 static inline bool block_driver_can_compress(BlockDriver *drv) @@ -1332,6 +1341,48 @@ int refresh_total_sectors(BlockDriverState *bs, int6= 4_t hint); void bdrv_set_monitor_owned(BlockDriverState *bs); BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp); =20 +BdrvChild *bdrv_filtered_cow_child(BlockDriverState *bs); +BdrvChild *bdrv_filtered_rw_child(BlockDriverState *bs); +BdrvChild *bdrv_filtered_child(BlockDriverState *bs); +BdrvChild *bdrv_metadata_child(BlockDriverState *bs); +BdrvChild *bdrv_storage_child(BlockDriverState *bs); +BdrvChild *bdrv_primary_child(BlockDriverState *bs); + +static inline BlockDriverState *child_bs(BdrvChild *child) +{ + return child ? child->bs : NULL; +} + +static inline BlockDriverState *bdrv_filtered_cow_bs(BlockDriverState *bs) +{ + return child_bs(bdrv_filtered_cow_child(bs)); +} + +static inline BlockDriverState *bdrv_filtered_rw_bs(BlockDriverState *bs) +{ + return child_bs(bdrv_filtered_rw_child(bs)); +} + +static inline BlockDriverState *bdrv_filtered_bs(BlockDriverState *bs) +{ + return child_bs(bdrv_filtered_child(bs)); +} + +static inline BlockDriverState *bdrv_metadata_bs(BlockDriverState *bs) +{ + return child_bs(bdrv_metadata_child(bs)); +} + +static inline BlockDriverState *bdrv_storage_bs(BlockDriverState *bs) +{ + return child_bs(bdrv_storage_child(bs)); +} + +static inline BlockDriverState *bdrv_primary_bs(BlockDriverState *bs) +{ + return child_bs(bdrv_primary_child(bs)); +} + /** * Simple implementation of bdrv_co_create_opts for protocol drivers * which only support creation via opening a file --=20 1.8.3.1 From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589295448; cv=none; d=zohomail.com; s=zohoarc; b=mLd1JOjL6y4Rtl4QJ4NvR5O+gQ/k7WX41CkhAoGAZGPXndTQ9dih9tZfpveNrRPjwkNA081SBgr1orDCbXz+Yp4ajY45Z9q6LU/3J9frLjMf9azjplMNUq5XdQbu6MGmuCsMrgJhs09gQ//bVCqx+kiZ6FfXARDAzkwEBwJjgJw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589295448; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=zASR04zPoNFvDoH8WvVllsOZchmgdGZHYshCZ5g6KbQ=; b=GEiN8qg9f2kLe3njLEQFaASfyyNV6mQtp5YJSllHyxNyIBbOluda8wlihBSq41H2y23Y97BX21bMMyIeuuH5p+J0DkxKtYwHp8oCyF+5ApHtpMBmXIEVJhtMdaIZbMqM57peDUe15na0vgUJgqXfC3Gg+p+ZypUTd2Alw+lZ70c= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589295448136636.6173098551268; Tue, 12 May 2020 07:57:28 -0700 (PDT) Received: from localhost ([::1]:37012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWLW-0004GE-Rm for importer@patchew.org; Tue, 12 May 2020 10:57:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHl-0004vj-Av; Tue, 12 May 2020 10:53:33 -0400 Received: from relay.sw.ru ([185.231.240.75]:45888) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHi-0005p2-A9; Tue, 12 May 2020 10:53:32 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHZ-0003c8-1h; Tue, 12 May 2020 17:53:21 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 04/15] block: Add chain helper functions Date: Tue, 12 May 2020 17:53:05 +0300 Message-Id: <1589295196-773454-5-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz Add some helper functions for skipping filters in a chain of block nodes. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block.c | 55 +++++++++++++++++++++++++++++++++++++++++++= ++++ include/block/block_int.h | 3 +++ 2 files changed, 58 insertions(+) diff --git a/block.c b/block.c index b2aae2e..5b4ebfe 100644 --- a/block.c +++ b/block.c @@ -6863,3 +6863,58 @@ BdrvChild *bdrv_primary_child(BlockDriverState *bs) { return bdrv_filtered_rw_child(bs) ?: bs->file; } + +static BlockDriverState *bdrv_skip_filters(BlockDriverState *bs, + bool stop_on_explicit_filter) +{ + BdrvChild *filtered; + + if (!bs) { + return NULL; + } + + while (!(stop_on_explicit_filter && !bs->implicit)) { + filtered =3D bdrv_filtered_rw_child(bs); + if (!filtered) { + break; + } + bs =3D filtered->bs; + } + /* + * Note that this treats nodes with bs->drv =3D=3D NULL as not being + * R/W filters (bs->drv =3D=3D NULL should be replaced by something + * else anyway). + * The advantage of this behavior is that this function will thus + * always return a non-NULL value (given a non-NULL @bs). + */ + + return bs; +} + +/* + * Return the first BDS that has not been added implicitly or that + * does not have an RW-filtered child down the chain starting from @bs + * (including @bs itself). + */ +BlockDriverState *bdrv_skip_implicit_filters(BlockDriverState *bs) +{ + return bdrv_skip_filters(bs, true); +} + +/* + * Return the first BDS that does not have an RW-filtered child down + * the chain starting from @bs (including @bs itself). + */ +BlockDriverState *bdrv_skip_rw_filters(BlockDriverState *bs) +{ + return bdrv_skip_filters(bs, false); +} + +/* + * For a backing chain, return the first non-filter backing image of + * the first non-filter image. + */ +BlockDriverState *bdrv_backing_chain_next(BlockDriverState *bs) +{ + return bdrv_skip_rw_filters(bdrv_filtered_cow_bs(bdrv_skip_rw_filters(= bs))); +} diff --git a/include/block/block_int.h b/include/block/block_int.h index dca59e9..86f7666 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1347,6 +1347,9 @@ BdrvChild *bdrv_filtered_child(BlockDriverState *bs); BdrvChild *bdrv_metadata_child(BlockDriverState *bs); BdrvChild *bdrv_storage_child(BlockDriverState *bs); BdrvChild *bdrv_primary_child(BlockDriverState *bs); +BlockDriverState *bdrv_skip_implicit_filters(BlockDriverState *bs); +BlockDriverState *bdrv_skip_rw_filters(BlockDriverState *bs); +BlockDriverState *bdrv_backing_chain_next(BlockDriverState *bs); =20 static inline BlockDriverState *child_bs(BdrvChild *child) { --=20 1.8.3.1 From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589295305; cv=none; d=zohomail.com; s=zohoarc; b=V7+U6Xb4KDdHzq5ZV/TMXneBGRKZVDBVoOOEiKrYU7yU62rypG9U+AwgE91i/yxgl16oaS2qZRZQ3lfNQg5VEm7OnXlTyO/SZTLRFIIuvmZl+8oyQUM7a51lZgSkeAfkcv285JMikEr6NsczqrWDT23gQZa5qIfvTSUWyXV46R8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589295305; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=z3Gk0nxqRH/yItNtHuDdp5J5NCDdZoGKicmwGjw7Rpw=; b=ZTuIMZhh7JepNK4zrOGl2+pTcogSgw9NKtHEy4s5kMXII5Bq+hO0g1N5slfzhj/wCZuCGUOfDXhG0tfPAmz6VvGzKUnHFfYr8OgcZ1MIjklQW8a6yifWWrpzNqSc5sGfwmVPx4sn3c0NENvzu+f+XMAtUrrRvBQDnSw6YL52vgk= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589295304932648.4392986332263; Tue, 12 May 2020 07:55:04 -0700 (PDT) Received: from localhost ([::1]:54342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWJD-0007rH-I2 for importer@patchew.org; Tue, 12 May 2020 10:55:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHl-0004wf-Ng; Tue, 12 May 2020 10:53:33 -0400 Received: from relay.sw.ru ([185.231.240.75]:45858) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHh-0005ox-Hk; Tue, 12 May 2020 10:53:33 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHZ-0003c8-86; Tue, 12 May 2020 17:53:21 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 05/15] block: Include filters when freezing backing chain Date: Tue, 12 May 2020 17:53:06 +0300 Message-Id: <1589295196-773454-6-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz In order to make filters work in backing chains, the associated functions must be able to deal with them and freeze all filter links, be they COW or R/W filter links. In the process, rename these functions to reflect that they now act on generalized chains of filter nodes instead of backing chains alone. While at it, add some comments that note which functions require their caller to ensure that a given child link is not frozen, and how the callers do so. Signed-off-by: Max Reitz Signed-off-by: Andrey Shinkevich --- block.c | 81 ++++++++++++++++++++++++++++++-----------------= ---- block/commit.c | 8 ++--- block/mirror.c | 4 +-- block/stream.c | 8 ++--- include/block/block.h | 6 ++-- 5 files changed, 60 insertions(+), 47 deletions(-) diff --git a/block.c b/block.c index 5b4ebfe..459412e 100644 --- a/block.c +++ b/block.c @@ -2513,12 +2513,15 @@ static void bdrv_replace_child_noperm(BdrvChild *ch= ild, * If @new_bs is not NULL, bdrv_check_perm() must be called beforehand, as= this * function uses bdrv_set_perm() to update the permissions according to th= e new * reference that @new_bs gets. + * + * Callers must ensure that child->frozen is false. */ static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs) { BlockDriverState *old_bs =3D child->bs; uint64_t perm, shared_perm; =20 + /* Asserts that child->frozen =3D=3D false */ bdrv_replace_child_noperm(child, new_bs); =20 /* @@ -2676,6 +2679,7 @@ static void bdrv_detach_child(BdrvChild *child) g_free(child); } =20 +/* Callers must ensure that child->frozen is false. */ void bdrv_root_unref_child(BdrvChild *child) { BlockDriverState *child_bs; @@ -2685,10 +2689,6 @@ void bdrv_root_unref_child(BdrvChild *child) bdrv_unref(child_bs); } =20 -/** - * Clear all inherits_from pointers from children and grandchildren of - * @root that point to @root, where necessary. - */ static void bdrv_unset_inherits_from(BlockDriverState *root, BdrvChild *ch= ild) { BdrvChild *c; @@ -2713,6 +2713,7 @@ static void bdrv_unset_inherits_from(BlockDriverState= *root, BdrvChild *child) } } =20 +/* Callers must ensure that child->frozen is false. */ void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child) { if (child =3D=3D NULL) { @@ -2756,7 +2757,7 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockD= riverState *backing_hd, bool update_inherits_from =3D bdrv_chain_contains(bs, backing_hd) && bdrv_inherits_from_recursive(backing_hd, bs); =20 - if (bdrv_is_backing_chain_frozen(bs, backing_bs(bs), errp)) { + if (bdrv_is_chain_frozen(bs, child_bs(bs->backing), errp)) { return; } =20 @@ -2765,6 +2766,7 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockD= riverState *backing_hd, } =20 if (bs->backing) { + /* Cannot be frozen, we checked that above */ bdrv_unref_child(bs, bs->backing); bs->backing =3D NULL; } @@ -3912,8 +3914,7 @@ static int bdrv_reopen_parse_backing(BDRVReopenState = *reopen_state, return -EPERM; } /* Check if the backing link that we want to replace is frozen */ - if (bdrv_is_backing_chain_frozen(overlay_bs, backing_bs(overlay_bs= ), - errp)) { + if (bdrv_is_chain_frozen(overlay_bs, backing_bs(overlay_bs), errp)= ) { return -EPERM; } reopen_state->replace_backing_bs =3D true; @@ -4248,6 +4249,7 @@ static void bdrv_close(BlockDriverState *bs) =20 if (bs->drv) { if (bs->drv->bdrv_close) { + /* Must unfreeze all children, so bdrv_unref_child() works */ bs->drv->bdrv_close(bs); } bs->drv =3D NULL; @@ -4617,20 +4619,22 @@ BlockDriverState *bdrv_find_base(BlockDriverState *= bs) } =20 /* - * Return true if at least one of the backing links between @bs and - * @base is frozen. @errp is set if that's the case. + * Return true if at least one of the (COW and R/W) filter links + * between @bs and @base is frozen. @errp is set if that's the case. * @base must be reachable from @bs, or NULL. */ -bool bdrv_is_backing_chain_frozen(BlockDriverState *bs, BlockDriverState *= base, - Error **errp) +bool bdrv_is_chain_frozen(BlockDriverState *bs, BlockDriverState *base, + Error **errp) { BlockDriverState *i; + BdrvChild *child; + + for (i =3D bs; i !=3D base; i =3D child_bs(child)) { + child =3D bdrv_filtered_child(i); =20 - for (i =3D bs; i !=3D base; i =3D backing_bs(i)) { - if (i->backing && i->backing->frozen) { + if (child && child->frozen) { error_setg(errp, "Cannot change '%s' link from '%s' to '%s'", - i->backing->name, i->node_name, - backing_bs(i)->node_name); + child->name, i->node_name, child->bs->node_name); return true; } } @@ -4639,32 +4643,35 @@ bool bdrv_is_backing_chain_frozen(BlockDriverState = *bs, BlockDriverState *base, } =20 /* - * Freeze all backing links between @bs and @base. + * Freeze all (COW and R/W) filter links between @bs and @base. * If any of the links is already frozen the operation is aborted and * none of the links are modified. * @base must be reachable from @bs, or NULL. * Returns 0 on success. On failure returns < 0 and sets @errp. */ -int bdrv_freeze_backing_chain(BlockDriverState *bs, BlockDriverState *base, - Error **errp) +int bdrv_freeze_chain(BlockDriverState *bs, BlockDriverState *base, + Error **errp) { BlockDriverState *i; + BdrvChild *child; =20 - if (bdrv_is_backing_chain_frozen(bs, base, errp)) { + if (bdrv_is_chain_frozen(bs, base, errp)) { return -EPERM; } =20 - for (i =3D bs; i !=3D base; i =3D backing_bs(i)) { - if (i->backing && backing_bs(i)->never_freeze) { + for (i =3D bs; i !=3D base; i =3D child_bs(child)) { + child =3D bdrv_filtered_child(i); + if (child && child->bs->never_freeze) { error_setg(errp, "Cannot freeze '%s' link to '%s'", - i->backing->name, backing_bs(i)->node_name); + child->name, child->bs->node_name); return -EPERM; } } =20 - for (i =3D bs; i !=3D base; i =3D backing_bs(i)) { - if (i->backing) { - i->backing->frozen =3D true; + for (i =3D bs; i !=3D base; i =3D child_bs(child)) { + child =3D bdrv_filtered_child(i); + if (child) { + child->frozen =3D true; } } =20 @@ -4672,18 +4679,21 @@ int bdrv_freeze_backing_chain(BlockDriverState *bs,= BlockDriverState *base, } =20 /* - * Unfreeze all backing links between @bs and @base. The caller must - * ensure that all links are frozen before using this function. + * Unfreeze all (COW and R/W) filter links between @bs and @base. The + * caller must ensure that all links are frozen before using this + * function. * @base must be reachable from @bs, or NULL. */ -void bdrv_unfreeze_backing_chain(BlockDriverState *bs, BlockDriverState *b= ase) +void bdrv_unfreeze_chain(BlockDriverState *bs, BlockDriverState *base) { BlockDriverState *i; + BdrvChild *child; =20 - for (i =3D bs; i !=3D base; i =3D backing_bs(i)) { - if (i->backing) { - assert(i->backing->frozen); - i->backing->frozen =3D false; + for (i =3D bs; i !=3D base; i =3D child_bs(child)) { + child =3D bdrv_filtered_child(i); + if (child) { + assert(child->frozen); + child->frozen =3D false; } } } @@ -4786,8 +4796,11 @@ int bdrv_drop_intermediate(BlockDriverState *top, Bl= ockDriverState *base, } } =20 - /* Do the actual switch in the in-memory graph. - * Completes bdrv_check_update_perm() transaction internally. */ + /* + * Do the actual switch in the in-memory graph. + * Completes bdrv_check_update_perm() transaction internally. + * c->frozen is false, we have checked that above. + */ bdrv_ref(base); bdrv_replace_child(c, base); bdrv_unref(top); diff --git a/block/commit.c b/block/commit.c index 445a280..e1f45a4 100644 --- a/block/commit.c +++ b/block/commit.c @@ -47,7 +47,7 @@ static int commit_prepare(Job *job) { CommitBlockJob *s =3D container_of(job, CommitBlockJob, common.job); =20 - bdrv_unfreeze_backing_chain(s->commit_top_bs, s->base_bs); + bdrv_unfreeze_chain(s->commit_top_bs, s->base_bs); s->chain_frozen =3D false; =20 /* Remove base node parent that still uses BLK_PERM_WRITE/RESIZE before @@ -67,7 +67,7 @@ static void commit_abort(Job *job) BlockDriverState *top_bs =3D blk_bs(s->top); =20 if (s->chain_frozen) { - bdrv_unfreeze_backing_chain(s->commit_top_bs, s->base_bs); + bdrv_unfreeze_chain(s->commit_top_bs, s->base_bs); } =20 /* Make sure commit_top_bs and top stay around until bdrv_replace_node= () */ @@ -317,7 +317,7 @@ void commit_start(const char *job_id, BlockDriverState = *bs, } } =20 - if (bdrv_freeze_backing_chain(commit_top_bs, base, errp) < 0) { + if (bdrv_freeze_chain(commit_top_bs, base, errp) < 0) { goto fail; } s->chain_frozen =3D true; @@ -358,7 +358,7 @@ void commit_start(const char *job_id, BlockDriverState = *bs, =20 fail: if (s->chain_frozen) { - bdrv_unfreeze_backing_chain(commit_top_bs, base); + bdrv_unfreeze_chain(commit_top_bs, base); } if (s->base) { blk_unref(s->base); diff --git a/block/mirror.c b/block/mirror.c index b6de24b..4b187e6 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -648,7 +648,7 @@ static int mirror_exit_common(Job *job) target_bs =3D blk_bs(s->target); =20 if (bdrv_chain_contains(src, target_bs)) { - bdrv_unfreeze_backing_chain(mirror_top_bs, target_bs); + bdrv_unfreeze_chain(mirror_top_bs, target_bs); } =20 bdrv_release_dirty_bitmap(s->dirty_bitmap); @@ -1713,7 +1713,7 @@ static BlockJob *mirror_start_job( } } =20 - if (bdrv_freeze_backing_chain(mirror_top_bs, target, errp) < 0) { + if (bdrv_freeze_chain(mirror_top_bs, target, errp) < 0) { goto fail; } } diff --git a/block/stream.c b/block/stream.c index aa2e7af..3cca1f9 100644 --- a/block/stream.c +++ b/block/stream.c @@ -53,7 +53,7 @@ static void stream_abort(Job *job) =20 if (s->chain_frozen) { BlockJob *bjob =3D &s->common; - bdrv_unfreeze_backing_chain(blk_bs(bjob->blk), s->bottom); + bdrv_unfreeze_chain(blk_bs(bjob->blk), s->bottom); } } =20 @@ -66,7 +66,7 @@ static int stream_prepare(Job *job) Error *local_err =3D NULL; int ret =3D 0; =20 - bdrv_unfreeze_backing_chain(bs, s->bottom); + bdrv_unfreeze_chain(bs, s->bottom); s->chain_frozen =3D false; =20 if (bs->backing) { @@ -225,7 +225,7 @@ void stream_start(const char *job_id, BlockDriverState = *bs, int basic_flags =3D BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGE= D; BlockDriverState *bottom =3D bdrv_find_overlay(bs, base); =20 - if (bdrv_freeze_backing_chain(bs, bottom, errp) < 0) { + if (bdrv_freeze_chain(bs, bottom, errp) < 0) { return; } =20 @@ -276,5 +276,5 @@ fail: if (bs_read_only) { bdrv_reopen_set_read_only(bs, true, NULL); } - bdrv_unfreeze_backing_chain(bs, bottom); + bdrv_unfreeze_chain(bs, bottom); } diff --git a/include/block/block.h b/include/block/block.h index 4de8d8f..e55143d 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -360,11 +360,11 @@ int bdrv_drop_intermediate(BlockDriverState *top, Blo= ckDriverState *base, BlockDriverState *bdrv_find_overlay(BlockDriverState *active, BlockDriverState *bs); BlockDriverState *bdrv_find_base(BlockDriverState *bs); -bool bdrv_is_backing_chain_frozen(BlockDriverState *bs, BlockDriverState *= base, +bool bdrv_is_chain_frozen(BlockDriverState *bs, BlockDriverState *base, Error **errp); -int bdrv_freeze_backing_chain(BlockDriverState *bs, BlockDriverState *base, +int bdrv_freeze_chain(BlockDriverState *bs, BlockDriverState *base, Error **errp); -void bdrv_unfreeze_backing_chain(BlockDriverState *bs, BlockDriverState *b= ase); +void bdrv_unfreeze_chain(BlockDriverState *bs, BlockDriverState *base); int coroutine_fn bdrv_co_delete_file(BlockDriverState *bs, Error **errp); =20 =20 --=20 1.8.3.1 From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589296014; cv=none; d=zohomail.com; s=zohoarc; b=UuZ7I53RySdgjNWn+Mxj2AaXbVMT/vAqZ9+wr909z6f/Vny8bzk0Hi0w8jKfKqSzhyRsMiOtukaS0shcjhAe98mpIyil7RAcieDEwoJgFElq3slut7MwRmjUVIQKrY9+XQ79UNdJ0D1ckFe6wuFSpLo9fv0/YIzVF2MjnqEgBRQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589296014; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=xvEECRLFXYeR7RH2ACnh/tNKhssRQajXlAe7zXUtmLI=; b=GhKBrMeG9HqqJm4ggK49Q9ZRmlQ4Sr/k/FnzVyJkCrpi2+kbP7QlHWjBoAyhl56XIa1hHdMcd/EPPwHwd3JBwzSWUsVB1hA1T8t8Pd8I2bOOqcqZSL7TtfKoDtLQGU3Rn/9iIQrJ2SwebjwPuAeBK/2mZ39SQPCpi1gDKxh/Wuk= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589296014312784.9674651264984; Tue, 12 May 2020 08:06:54 -0700 (PDT) Received: from localhost ([::1]:41804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWUf-0004Lu-9B for importer@patchew.org; Tue, 12 May 2020 11:06:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWI3-0005jr-Tv; Tue, 12 May 2020 10:53:51 -0400 Received: from relay.sw.ru ([185.231.240.75]:45842) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWI0-0005ou-L8; Tue, 12 May 2020 10:53:51 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHZ-0003c8-DZ; Tue, 12 May 2020 17:53:21 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 06/15] block: Use CAFs in block status functions Date: Tue, 12 May 2020 17:53:07 +0300 Message-Id: <1589295196-773454-7-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz Use the child access functions in the block status inquiry functions as appropriate. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/io.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/block/io.c b/block/io.c index 7d30e61..47d8096 100644 --- a/block/io.c +++ b/block/io.c @@ -2387,11 +2387,12 @@ static int coroutine_fn bdrv_co_block_status(BlockD= riverState *bs, if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) { ret |=3D BDRV_BLOCK_ALLOCATED; } else if (want_zero) { + BlockDriverState *cow_bs =3D bdrv_filtered_cow_bs(bs); + if (bdrv_unallocated_blocks_are_zero(bs)) { ret |=3D BDRV_BLOCK_ZERO; - } else if (bs->backing) { - BlockDriverState *bs2 =3D bs->backing->bs; - int64_t size2 =3D bdrv_getlength(bs2); + } else if (cow_bs) { + int64_t size2 =3D bdrv_getlength(cow_bs); =20 if (size2 >=3D 0 && offset >=3D size2) { ret |=3D BDRV_BLOCK_ZERO; @@ -2457,7 +2458,7 @@ static int coroutine_fn bdrv_co_block_status_above(Bl= ockDriverState *bs, bool first =3D true; =20 assert(bs !=3D base); - for (p =3D bs; p !=3D base; p =3D backing_bs(p)) { + for (p =3D bs; p !=3D base; p =3D bdrv_filtered_bs(p)) { ret =3D bdrv_co_block_status(p, want_zero, offset, bytes, pnum, ma= p, file); if (ret < 0) { @@ -2543,7 +2544,7 @@ int bdrv_block_status_above(BlockDriverState *bs, Blo= ckDriverState *base, int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes, int64_t *pnum, int64_t *map, BlockDriverState **file) { - return bdrv_block_status_above(bs, backing_bs(bs), + return bdrv_block_status_above(bs, bdrv_filtered_bs(bs), offset, bytes, pnum, map, file); } =20 @@ -2553,9 +2554,9 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *= bs, int64_t offset, int ret; int64_t dummy; =20 - ret =3D bdrv_common_block_status_above(bs, backing_bs(bs), false, offs= et, - bytes, pnum ? pnum : &dummy, NULL, - NULL); + ret =3D bdrv_common_block_status_above(bs, bdrv_filtered_bs(bs), false, + offset, bytes, pnum ? pnum : &dum= my, + NULL, NULL); if (ret < 0) { return ret; } @@ -2618,7 +2619,7 @@ int bdrv_is_allocated_above(BlockDriverState *top, break; } =20 - intermediate =3D backing_bs(intermediate); + intermediate =3D bdrv_filtered_bs(intermediate); } =20 *pnum =3D n; --=20 1.8.3.1 From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589295583; cv=none; d=zohomail.com; s=zohoarc; b=T6xZKRke6epyEL3OSbKDbQYLGDVS/At37o5tIga5hNCofvzCwLE5DXTWEjQGTMfSHmq+TWwOtAdhshsFsJ0wJY76Y4m2h8l3uwpBNyfNNwap0deNJ+0ZlJ5uDV49+iwZw/92DBP1gy0F/wBue4Rot4mq7jItXlkWp9A16/RP7FU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589295583; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Cz7enbsa2nWcLDvJSYLqiuD1TA9o0ydVsr7jppDtfZw=; b=Pa3w35FTRmhyX9bcduwoeV753CRRiMzp49TxF0dO1FLDsX4+il0u5/bO2HPqAYRi5R9D3+BtpPaXdnEyrkpuf+M6/DgtDs1HsW1Da1zh+WmUog3rW53az2uQizPsSRjCNxYO90+q5Y9VkjpwSGJ+EsA9w3dOClJDqqnmR7LVbZ8= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589295583942310.7431826077201; Tue, 12 May 2020 07:59:43 -0700 (PDT) Received: from localhost ([::1]:46202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWNi-0000CB-IG for importer@patchew.org; Tue, 12 May 2020 10:59:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHk-0004uI-OY; Tue, 12 May 2020 10:53:32 -0400 Received: from relay.sw.ru ([185.231.240.75]:45830) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHh-0005oo-8J; Tue, 12 May 2020 10:53:32 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHZ-0003c8-J5; Tue, 12 May 2020 17:53:21 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 07/15] commit: Deal with filters when blocking intermediate nodes Date: Tue, 12 May 2020 17:53:08 +0300 Message-Id: <1589295196-773454-8-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz This includes some permission limiting (for example, we only need to take the RESIZE permission if the base is smaller than the top). Signed-off-by: Max Reitz Signed-off-by: Andrey Shinkevich --- block/commit.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++--------= ---- 1 file changed, 60 insertions(+), 15 deletions(-) diff --git a/block/commit.c b/block/commit.c index e1f45a4..4df145d 100644 --- a/block/commit.c +++ b/block/commit.c @@ -37,6 +37,7 @@ typedef struct CommitBlockJob { BlockBackend *top; BlockBackend *base; BlockDriverState *base_bs; + BlockDriverState *above_base; BlockdevOnError on_error; bool base_read_only; bool chain_frozen; @@ -153,7 +154,7 @@ static int coroutine_fn commit_run(Job *job, Error **er= rp) break; } /* Copy if allocated above the base */ - ret =3D bdrv_is_allocated_above(blk_bs(s->top), blk_bs(s->base), f= alse, + ret =3D bdrv_is_allocated_above(blk_bs(s->top), s->above_base, tru= e, offset, COMMIT_BUFFER_SIZE, &n); copy =3D (ret =3D=3D 1); trace_commit_one_iteration(s, offset, n, ret); @@ -253,15 +254,35 @@ void commit_start(const char *job_id, BlockDriverStat= e *bs, CommitBlockJob *s; BlockDriverState *iter; BlockDriverState *commit_top_bs =3D NULL; + BlockDriverState *filtered_base; Error *local_err =3D NULL; + int64_t base_size, top_size; + uint64_t perms, iter_shared_perms; int ret; =20 assert(top !=3D bs); - if (top =3D=3D base) { + if (bdrv_skip_rw_filters(top) =3D=3D bdrv_skip_rw_filters(base)) { error_setg(errp, "Invalid files for merge: top and base are the sa= me"); return; } =20 + base_size =3D bdrv_getlength(base); + if (base_size < 0) { + error_setg_errno(errp, -base_size, "Could not inquire base image s= ize"); + return; + } + + top_size =3D bdrv_getlength(top); + if (top_size < 0) { + error_setg_errno(errp, -top_size, "Could not inquire top image siz= e"); + return; + } + + perms =3D BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE; + if (base_size < top_size) { + perms |=3D BLK_PERM_RESIZE; + } + s =3D block_job_create(job_id, &commit_job_driver, NULL, bs, 0, BLK_PE= RM_ALL, speed, creation_flags, NULL, NULL, errp); if (!s) { @@ -301,17 +322,43 @@ void commit_start(const char *job_id, BlockDriverStat= e *bs, =20 s->commit_top_bs =3D commit_top_bs; =20 - /* Block all nodes between top and base, because they will - * disappear from the chain after this operation. */ - assert(bdrv_chain_contains(top, base)); - for (iter =3D top; iter !=3D base; iter =3D backing_bs(iter)) { - /* XXX BLK_PERM_WRITE needs to be allowed so we don't block oursel= ves - * at s->base (if writes are blocked for a node, they are also blo= cked - * for its backing file). The other options would be a second filt= er - * driver above s->base. */ + /* + * Block all nodes between top and base, because they will + * disappear from the chain after this operation. + * Note that this assumes that the user is fine with removing all + * nodes (including R/W filters) between top and base. Assuring + * this is the responsibility of the interface (i.e. whoever calls + * commit_start()). + */ + s->above_base =3D bdrv_find_overlay(top, base); + assert(s->above_base); + + /* + * The topmost node with + * bdrv_skip_rw_filters(filtered_base) =3D=3D bdrv_skip_rw_filters(bas= e) + */ + filtered_base =3D bdrv_filtered_cow_bs(s->above_base); + assert(bdrv_skip_rw_filters(filtered_base) =3D=3D bdrv_skip_rw_filters= (base)); + + /* + * XXX BLK_PERM_WRITE needs to be allowed so we don't block ourselves + * at s->base (if writes are blocked for a node, they are also blocked + * for its backing file). The other options would be a second filter + * driver above s->base. + */ + iter_shared_perms =3D BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE; + + for (iter =3D top; iter !=3D base; iter =3D bdrv_filtered_bs(iter)) { + if (iter =3D=3D filtered_base) { + /* + * From here on, all nodes are filters on the base. This + * allows us to share BLK_PERM_CONSISTENT_READ. + */ + iter_shared_perms |=3D BLK_PERM_CONSISTENT_READ; + } + ret =3D block_job_add_bdrv(&s->common, "intermediate node", iter, = 0, - BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE, - errp); + iter_shared_perms, errp); if (ret < 0) { goto fail; } @@ -328,9 +375,7 @@ void commit_start(const char *job_id, BlockDriverState = *bs, } =20 s->base =3D blk_new(s->common.job.aio_context, - BLK_PERM_CONSISTENT_READ - | BLK_PERM_WRITE - | BLK_PERM_RESIZE, + perms, BLK_PERM_CONSISTENT_READ | BLK_PERM_GRAPH_MOD | BLK_PERM_WRITE_UNCHANGED); --=20 1.8.3.1 From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589295446; cv=none; d=zohomail.com; s=zohoarc; b=Q7E3d8xMJ2/ZMQ4s7rbUnKtv8JQbfUFw3+XPuKRut9ouao2MjuEhHh80mDyXGcm1Jk1odXaK3KTfVZxrEmIhNC10q5WFpZ9KaFkSUsungQBSBFn/FNHOt0sJWA5sUa6ZZNZDz1D7d2IlJ47utzNV3UWPibu2tWIK8rnQSzRM/rc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589295446; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=QVVluTPj59WiaPfDlFXaLCGa49/OObMX6lPcLkmJdI0=; b=HLD6s+mQAcmwS89H9t6I01TcYEgUpAXZWpBqWVm6fROi0cPDajS9bha9M0Tt51e1J/50o16xZK6l7zrxSW+zS9Jj6q7iok6/WyDC/qKI/hSeG1RiGYfr80UZZ5BuuUqHnHayKJS+aV3FUQNsTiNp4Jelxee17gFk0glhpdJmcag= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589295446471613.3409990917548; Tue, 12 May 2020 07:57:26 -0700 (PDT) Received: from localhost ([::1]:36658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWLV-00046d-5F for importer@patchew.org; Tue, 12 May 2020 10:57:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHm-0004zw-TG; Tue, 12 May 2020 10:53:34 -0400 Received: from relay.sw.ru ([185.231.240.75]:45870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHh-0005p3-Fe; Tue, 12 May 2020 10:53:34 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHZ-0003c8-OX; Tue, 12 May 2020 17:53:21 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 08/15] block: Use CAFs when working with backing chains Date: Tue, 12 May 2020 17:53:09 +0300 Message-Id: <1589295196-773454-9-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz Use child access functions when iterating through backing chains so filters do not break the chain. Signed-off-by: Max Reitz --- block.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/block.c b/block.c index 459412e..69e9152 100644 --- a/block.c +++ b/block.c @@ -4593,7 +4593,8 @@ int bdrv_change_backing_file(BlockDriverState *bs, } =20 /* - * Finds the image layer in the chain that has 'bs' as its backing file. + * Finds the image layer in the chain that has 'bs' (or a filter on + * top of it) as its backing file. * * active is the current topmost image. * @@ -4605,11 +4606,18 @@ int bdrv_change_backing_file(BlockDriverState *bs, BlockDriverState *bdrv_find_overlay(BlockDriverState *active, BlockDriverState *bs) { - while (active && bs !=3D backing_bs(active)) { - active =3D backing_bs(active); + bs =3D bdrv_skip_rw_filters(bs); + active =3D bdrv_skip_rw_filters(active); + + while (active) { + BlockDriverState *next =3D bdrv_backing_chain_next(active); + if (bs =3D=3D next) { + return active; + } + active =3D next; } =20 - return active; + return NULL; } =20 /* Given a BDS, searches for the base layer. */ @@ -4761,9 +4769,7 @@ int bdrv_drop_intermediate(BlockDriverState *top, Blo= ckDriverState *base, * other intermediate nodes have been dropped. * If 'top' is an implicit node (e.g. "commit_top") we should skip * it because no one inherits from it. We use explicit_top for that. */ - while (explicit_top && explicit_top->implicit) { - explicit_top =3D backing_bs(explicit_top); - } + explicit_top =3D bdrv_skip_implicit_filters(explicit_top); update_inherits_from =3D bdrv_inherits_from_recursive(base, explicit_t= op); =20 /* success - we can delete the intermediate states, and link top->base= */ @@ -5205,7 +5211,7 @@ BlockDriverState *bdrv_lookup_bs(const char *device, bool bdrv_chain_contains(BlockDriverState *top, BlockDriverState *base) { while (top && top !=3D base) { - top =3D backing_bs(top); + top =3D bdrv_filtered_bs(top); } =20 return top !=3D NULL; @@ -5466,7 +5472,17 @@ BlockDriverState *bdrv_find_backing_image(BlockDrive= rState *bs, =20 is_protocol =3D path_has_protocol(backing_file); =20 - for (curr_bs =3D bs; curr_bs->backing; curr_bs =3D curr_bs->backing->b= s) { + /* + * Being largely a legacy function, skip any filters here + * (because filters do not have normal filenames, so they cannot + * match anyway; and allowing json:{} filenames is a bit out of + * scope). + */ + for (curr_bs =3D bdrv_skip_rw_filters(bs); + bdrv_filtered_cow_child(curr_bs) !=3D NULL; + curr_bs =3D bdrv_backing_chain_next(curr_bs)) + { + BlockDriverState *bs_below =3D bdrv_backing_chain_next(curr_bs); =20 /* If either of the filename paths is actually a protocol, then * compare unmodified paths; otherwise make paths relative */ @@ -5474,7 +5490,7 @@ BlockDriverState *bdrv_find_backing_image(BlockDriver= State *bs, char *backing_file_full_ret; =20 if (strcmp(backing_file, curr_bs->backing_file) =3D=3D 0) { - retval =3D curr_bs->backing->bs; + retval =3D bs_below; break; } /* Also check against the full backing filename for the image = */ @@ -5484,7 +5500,7 @@ BlockDriverState *bdrv_find_backing_image(BlockDriver= State *bs, bool equal =3D strcmp(backing_file, backing_file_full_ret)= =3D=3D 0; g_free(backing_file_full_ret); if (equal) { - retval =3D curr_bs->backing->bs; + retval =3D bs_below; break; } } @@ -5510,7 +5526,7 @@ BlockDriverState *bdrv_find_backing_image(BlockDriver= State *bs, g_free(filename_tmp); =20 if (strcmp(backing_file_full, filename_full) =3D=3D 0) { - retval =3D curr_bs->backing->bs; + retval =3D bs_below; break; } } --=20 1.8.3.1 From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589295744; cv=none; d=zohomail.com; s=zohoarc; b=T11ZhRUENnRzqRm1z5FdcPlRMedeCllTkf3yjdu66BxQv2P1ygP9s1W7JmgJolDGqM8NOZwo0uhRVtTCh/A98uhG2I5U2nWnEVrpITsMXk9WJJRXgD39oW1WsIQb7k/Pg34dJsIAoi/WfnJd9YNHo3i9kUjXzTLlAhwjkEvvTjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589295744; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=3iktd/mlnrZKHPf28Yb6eNDRaD3hlfAzmTtM+Q9VlCU=; b=EAoX3a0vrpSohbdCzEYw96Wn57MxR+OV26bWGauDbSbsQ5q0oLvlqbZMDao2i3yALEkA2LpKHp6LUsOI5wr4GAPPl4bql5Ic6qM203qzW9ovps/9Re0cPM2i55Ony5OurDQC4eqty/ZLUbG1ZY6wcOjK5CJbIPBD3xscIT7bNfg= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589295744168702.9827142755064; Tue, 12 May 2020 08:02:24 -0700 (PDT) Received: from localhost ([::1]:53174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWQI-0004Rv-BR for importer@patchew.org; Tue, 12 May 2020 11:02:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHm-0004xe-2V; Tue, 12 May 2020 10:53:34 -0400 Received: from relay.sw.ru ([185.231.240.75]:45872) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHh-0005p5-EV; Tue, 12 May 2020 10:53:33 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHZ-0003c8-Uf; Tue, 12 May 2020 17:53:22 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 09/15] block: prepare block-stream for using COR-filter Date: Tue, 12 May 2020 17:53:10 +0300 Message-Id: <1589295196-773454-10-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch is the first one in the series where the COR-filter node will be hard-coded for using in the block-stream job. The block jobs may be run in parallel. Exclude conflicts with filter nodes used for a concurrent job while checking for the blocked operations. It incurs changes in the iotests 030::test_overlapping_4 that now passes with no conflict because the stream job does not have a real dependency on its base and on a filter above it. Signed-off-by: Andrey Shinkevich --- blockdev.c | 11 +++++++++-- tests/qemu-iotests/030 | 9 ++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/blockdev.c b/blockdev.c index b3c840e..97c2ba2 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2763,6 +2763,7 @@ void qmp_block_stream(bool has_job_id, const char *jo= b_id, const char *device, Error *local_err =3D NULL; const char *base_name =3D NULL; int job_flags =3D JOB_DEFAULT; + BlockDriverState *bottom_cow_node; =20 if (!has_on_error) { on_error =3D BLOCKDEV_ON_ERROR_REPORT; @@ -2807,8 +2808,14 @@ void qmp_block_stream(bool has_job_id, const char *j= ob_id, const char *device, base_name =3D base_bs->filename; } =20 - /* Check for op blockers in the whole chain between bs and base */ - for (iter =3D bs; iter && iter !=3D base_bs; iter =3D backing_bs(iter)= ) { + bottom_cow_node =3D bdrv_find_overlay(bs, base_bs); + if (!bottom_cow_node) { + error_setg(errp, "bottom node is not found, nothing to stream"); + goto out; + } + /* Check for op blockers in the whole chain between bs and bottom */ + for (iter =3D bs; iter && iter !=3D bdrv_filtered_bs(bottom_cow_node); + iter =3D bdrv_filtered_bs(iter)) { if (bdrv_op_is_blocked(iter, BLOCK_OP_TYPE_STREAM, errp)) { goto out; } diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index 104e3ce..d7638cd 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -368,8 +368,7 @@ class TestParallelOps(iotests.QMPTestCase): self.wait_until_completed(drive=3D'commit-drive0') =20 # In this case the base node of the stream job is the same as the - # top node of commit job. Since this results in the commit filter - # node being part of the stream chain, this is not allowed. + # top node of commit job. def test_overlapping_4(self): self.assert_no_active_block_jobs() =20 @@ -381,13 +380,13 @@ class TestParallelOps(iotests.QMPTestCase): =20 # Stream from node2 into node4 result =3D self.vm.qmp('block-stream', device=3D'node4', base_node= =3D'node2', job_id=3D'node4') - self.assert_qmp(result, 'error/desc', - "Cannot freeze 'backing' link to 'commit-filter'") + self.assert_qmp(result, 'return', {}) =20 result =3D self.vm.qmp('block-job-set-speed', device=3D'drive0', s= peed=3D0) self.assert_qmp(result, 'return', {}) =20 - self.wait_until_completed() + self.vm.run_job(job=3D'drive0', auto_dismiss=3DTrue) + self.vm.run_job(job=3D'node4', auto_dismiss=3DTrue) self.assert_no_active_block_jobs() =20 # In this case the base node of the stream job is the commit job's --=20 1.8.3.1 From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589295778; cv=none; d=zohomail.com; s=zohoarc; b=jEdMrjDB04djVjWW8kNMlqhUHRtQflmiGrDUsZBQ6vEDFoCBwIE1WoMqGoGzL5XEKk0AEcC9FNc1H7A21fWRYBhpWdDl/kU23r8sqQ4IwD+eXjTJZXXXf2k67bHZWudmKwPB3R98aXi2TtHehZQIbmfGl+kMuMWap0rUr5e4VUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589295778; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=0cx8uO79+EWIEka8n7t85aqOrEHz3/5CRiBzdBRx8Aw=; b=kyVQ637idyzqyB/6XmVf90v7tEvBr6jEK7CxHf6bW3Y2cmfo6iit/HNjJ4sTZN9LRYr7YJ2MFVV8+JEKIZvIyJ9RdDcdKdlFAb7irSrViJ0Ll5Yivy68oAaTY4ex4yFwfxHOUKHLgbvjze3XWq31qXardBXK8GqSpd7qHNYZbPs= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589295778486686.5627092672187; Tue, 12 May 2020 08:02:58 -0700 (PDT) Received: from localhost ([::1]:55168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWQr-0005lu-Lf for importer@patchew.org; Tue, 12 May 2020 11:02:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWI1-0005eS-VP; Tue, 12 May 2020 10:53:50 -0400 Received: from relay.sw.ru ([185.231.240.75]:45860) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWI0-0005p0-L6; Tue, 12 May 2020 10:53:49 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHa-0003c8-5m; Tue, 12 May 2020 17:53:22 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 10/15] copy-on-read: Support change filename functions Date: Tue, 12 May 2020 17:53:11 +0300 Message-Id: <1589295196-773454-11-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The COR-filter driver should support a redirecting function to refresh filenames. Otherwise, a file name of the filter will be copied instead of the one of a data node. It is also true for the function bdrv_change_backing_file(). Signed-off-by: Andrey Shinkevich --- block/copy-on-read.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/block/copy-on-read.c b/block/copy-on-read.c index c4fa468..74e01ee 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -21,6 +21,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "block/block_int.h" #include "qemu/module.h" =20 @@ -128,6 +129,21 @@ static void cor_lock_medium(BlockDriverState *bs, bool= locked) } =20 =20 +static void cor_refresh_filename(BlockDriverState *bs) +{ + pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), + bs->file->bs->filename); +} + + +static int cor_change_backing_file(BlockDriverState *bs, + const char *backing_file, + const char *backing_fmt) +{ + return bdrv_change_backing_file(bs->file->bs, backing_file, backing_fm= t); +} + + static BlockDriver bdrv_copy_on_read =3D { .format_name =3D "copy-on-read", =20 @@ -146,6 +162,8 @@ static BlockDriver bdrv_copy_on_read =3D { .bdrv_lock_medium =3D cor_lock_medium, =20 .bdrv_co_block_status =3D bdrv_co_block_status_from_file, + .bdrv_refresh_filename =3D cor_refresh_filename, + .bdrv_change_backing_file =3D cor_change_backing_file, =20 .has_variable_length =3D true, .is_filter =3D true, --=20 1.8.3.1 From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589295303; cv=none; d=zohomail.com; s=zohoarc; b=VwnH5B4FsDewyFZ0LXQbA2snsU1eozsUzOjm/fFGCKelPNL947gfFIsWRT5i1GGSXXhQo5m0yZbc+2mfNWPrshvxMeOAHc2ARvXtOUQnsIhyqZG0A/WBnLWAj9K+jIQ09Q5i6M+yaAY6NBlF7CK2rvu8nOFMbI6riAzjlXeiQzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589295303; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=SioYj/k5UHGBORYI7+5QzkFL60dOdXG5APgbxWt39a8=; b=KKAtlRS7u/H4/1BwKR6a9nY3wTLh2Ogvn3f6AHnreAk98Ccd/tKW8Ov9XrqWccJg5XZZGwn88CUYWyQYXcP3pFtst6jc4TlPhmNhQFLMyCIONgJ6IiDNz5PP9EHFtUEqRhuFfy8AmMUz0Q8rWNkMP5CPiBvMFaaLBf+4folz8K4= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589295303586968.1844561009341; Tue, 12 May 2020 07:55:03 -0700 (PDT) Received: from localhost ([::1]:54188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWJC-0007nS-5e for importer@patchew.org; Tue, 12 May 2020 10:55:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHj-0004rv-Qb; Tue, 12 May 2020 10:53:31 -0400 Received: from relay.sw.ru ([185.231.240.75]:45852) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHh-0005ot-D1; Tue, 12 May 2020 10:53:31 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHa-0003c8-EA; Tue, 12 May 2020 17:53:22 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 11/15] copy-on-read: Support preadv/pwritev_part functions Date: Tue, 12 May 2020 17:53:12 +0300 Message-Id: <1589295196-773454-12-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add support for the recently introduced functions bdrv_co_preadv_part() and bdrv_co_pwritev_part() to the COR-filter driver. Signed-off-by: Andrey Shinkevich --- block/copy-on-read.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 74e01ee..4030d56 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -74,21 +74,25 @@ static int64_t cor_getlength(BlockDriverState *bs) } =20 =20 -static int coroutine_fn cor_co_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +static int coroutine_fn cor_co_preadv_part(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, + size_t qiov_offset, + int flags) { - return bdrv_co_preadv(bs->file, offset, bytes, qiov, - flags | BDRV_REQ_COPY_ON_READ); + return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset, + flags | BDRV_REQ_COPY_ON_READ); } =20 =20 -static int coroutine_fn cor_co_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, - QEMUIOVector *qiov, int flags) +static int coroutine_fn cor_co_pwritev_part(BlockDriverState *bs, + uint64_t offset, + uint64_t bytes, + QEMUIOVector *qiov, + size_t qiov_offset, int flags) { - - return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags); + return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset, + flags); } =20 =20 @@ -152,8 +156,8 @@ static BlockDriver bdrv_copy_on_read =3D { =20 .bdrv_getlength =3D cor_getlength, =20 - .bdrv_co_preadv =3D cor_co_preadv, - .bdrv_co_pwritev =3D cor_co_pwritev, + .bdrv_co_preadv_part =3D cor_co_preadv_part, + .bdrv_co_pwritev_part =3D cor_co_pwritev_part, .bdrv_co_pwrite_zeroes =3D cor_co_pwrite_zeroes, .bdrv_co_pdiscard =3D cor_co_pdiscard, .bdrv_co_pwritev_compressed =3D cor_co_pwritev_compressed, --=20 1.8.3.1 From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589295442; cv=none; d=zohomail.com; s=zohoarc; b=ffUIOGvUxrszem4N/b6d72iPgiL395NDAEpBgbbFynP3YJMAoHTIweoB80HRFzp7iEgkKhnYYSUpvG0YI3kxvAI21Mw6KNqxQD38OWol1Q7HXp45Wd0Lod6Hrm4uBZSEboIlU3ClJkkD9unonAIWPpCVVAtWPg6n00Myg7+S8DY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589295442; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=YLVJmGoFk02HSBU8fQlrWqxr1N2DDIrXh6p+XuT2yWw=; b=bOuPkG7TsTmus+jw1JQklvfqFcpVOXdSgZDHK6xGwJ2V3K7R2Ap2vjwfeMoWQ60ifz2uSbz6d282AVQ5kHyOkCaj2GmLYtu8REfPgrEdZOZaicsGEvgY0A5UdAUlNSKFkU+KlKt4RsOD1rbusmlW+c3B4FucWRx1Tk3E9MZ4XLg= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589295442027592.5968526368957; Tue, 12 May 2020 07:57:22 -0700 (PDT) Received: from localhost ([::1]:36302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWLQ-0003vn-L6 for importer@patchew.org; Tue, 12 May 2020 10:57:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHj-0004py-PD; Tue, 12 May 2020 10:53:31 -0400 Received: from relay.sw.ru ([185.231.240.75]:45838) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHh-0005os-4Z; Tue, 12 May 2020 10:53:30 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHa-0003c8-Kp; Tue, 12 May 2020 17:53:22 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 12/15] copy-on-read: add filter append/drop functions Date: Tue, 12 May 2020 17:53:13 +0300 Message-Id: <1589295196-773454-13-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Provide API for the COR-filter insertion/removal. Also, drop the filter child permissions for an inactive state when the filter node is being removed. Signed-off-by: Andrey Shinkevich --- block/copy-on-read.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 98 insertions(+) diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 4030d56..31e1619 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -24,8 +24,15 @@ #include "qemu/cutils.h" #include "block/block_int.h" #include "qemu/module.h" +#include "qapi/error.h" +#include "qapi/qmp/qdict.h" +#include "block/copy-on-read.h" =20 =20 +typedef struct BDRVStateCOR { + bool active; +} BDRVStateCOR; + static int cor_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { @@ -57,6 +64,17 @@ static void cor_child_perm(BlockDriverState *bs, BdrvChi= ld *c, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { + BDRVStateCOR *s =3D bs->opaque; + + if (!s->active) { + /* + * While the filter is being removed + */ + *nperm =3D 0; + *nshared =3D BLK_PERM_ALL; + return; + } + *nperm =3D perm & PERM_PASSTHROUGH; *nshared =3D (shared & PERM_PASSTHROUGH) | PERM_UNCHANGED; =20 @@ -150,6 +168,7 @@ static int cor_change_backing_file(BlockDriverState *bs, =20 static BlockDriver bdrv_copy_on_read =3D { .format_name =3D "copy-on-read", + .instance_size =3D sizeof(BDRVStateCOR), =20 .bdrv_open =3D cor_open, .bdrv_child_perm =3D cor_child_perm, @@ -178,4 +197,83 @@ static void bdrv_copy_on_read_init(void) bdrv_register(&bdrv_copy_on_read); } =20 + +static BlockDriverState *create_filter_node(BlockDriverState *bs, + const char *filter_node_name, + Error **errp) +{ + QDict *opts =3D qdict_new(); + + qdict_put_str(opts, "driver", "copy-on-read"); + qdict_put_str(opts, "file", bdrv_get_node_name(bs)); + if (filter_node_name) { + qdict_put_str(opts, "node-name", filter_node_name); + } + + return bdrv_open(NULL, NULL, opts, BDRV_O_RDWR, errp); +} + + +BlockDriverState *bdrv_cor_filter_append(BlockDriverState *bs, + const char *filter_node_name, + Error **errp) +{ + BlockDriverState *cor_filter_bs; + BDRVStateCOR *state; + Error *local_err =3D NULL; + + cor_filter_bs =3D create_filter_node(bs, filter_node_name, errp); + if (cor_filter_bs =3D=3D NULL) { + error_prepend(errp, "Could not create filter node: "); + return NULL; + } + + if (!filter_node_name) { + cor_filter_bs->implicit =3D true; + } + + bdrv_drained_begin(bs); + bdrv_replace_node(bs, cor_filter_bs, &local_err); + bdrv_drained_end(bs); + + if (local_err) { + bdrv_unref(cor_filter_bs); + error_propagate(errp, local_err); + return NULL; + } + + state =3D cor_filter_bs->opaque; + state->active =3D true; + + return cor_filter_bs; +} + + +void bdrv_cor_filter_drop(BlockDriverState *cor_filter_bs) +{ + BdrvChild *child; + BlockDriverState *bs; + BDRVStateCOR *s =3D cor_filter_bs->opaque; + + child =3D bdrv_filtered_rw_child(cor_filter_bs); + if (!child) { + return; + } + bs =3D child->bs; + + /* Retain the BDS until we complete the graph change. */ + bdrv_ref(bs); + /* Hold a guest back from writing while permissions are being reset. */ + bdrv_drained_begin(bs); + /* Drop permissions before the graph change. */ + s->active =3D false; + bdrv_child_refresh_perms(cor_filter_bs, child, &error_abort); + bdrv_replace_node(cor_filter_bs, bs, &error_abort); + + bdrv_drained_end(bs); + bdrv_unref(bs); + bdrv_unref(cor_filter_bs); +} + + block_init(bdrv_copy_on_read_init); --=20 1.8.3.1 From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589295690; cv=none; d=zohomail.com; s=zohoarc; b=evHrH/+41BMW/6fB33cqzmbsqWTh+Ptacx41gVAdTq/CmdD7afd8Wm769n0J/E3iKxhAz5hLdiTAGh+Dyynlx1qH0WE7vVB3qq8rNg//SoQYzOYOaAFeqwK4Rp6l+OJ6G81Qh7Lt6GxIrXfkARZND/U1hPQkmoFD2XjTwQQOYZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589295690; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=d1d/xk8OS66ODYtOkmz76/slj/XikFJIHvzgl3QV4f0=; b=b6w61eLGzrfDWuf25u2ZjLhR/BlosXdBY1YiuXmNkFlkEgDUnHsjz+h2hOneeAFcFel/B302LhO0kKLrCTrttHdrur6gRnRn6jqTwD2lfHZYG1vJMku+WDe/ogpGgBcW1aUPjAyQWvYuLjQFhSLQQXbSF1K+WzsQvGgGZ4LHBIY= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589295690545269.9229776054244; Tue, 12 May 2020 08:01:30 -0700 (PDT) Received: from localhost ([::1]:50388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWPR-0002kr-2w for importer@patchew.org; Tue, 12 May 2020 11:01:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWI3-0005jA-Ml; Tue, 12 May 2020 10:53:51 -0400 Received: from relay.sw.ru ([185.231.240.75]:45844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWI0-0005oq-MH; Tue, 12 May 2020 10:53:51 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHa-0003c8-QT; Tue, 12 May 2020 17:53:22 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 13/15] qapi: add filter-node-name to block-stream Date: Tue, 12 May 2020 17:53:14 +0300 Message-Id: <1589295196-773454-14-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Provide the possibility to pass the 'filter-node-name' parameter to the block-stream job as it is done for the commit block job. That will be needed for further iotests implementations. Signed-off-by: Andrey Shinkevich --- block/monitor/block-hmp-cmds.c | 4 ++-- block/stream.c | 4 +++- blockdev.c | 8 +++++++- include/block/block_int.h | 7 ++++++- qapi/block-core.json | 6 ++++++ 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index 4c8c375..6f6636b 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -507,8 +507,8 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict) =20 qmp_block_stream(true, device, device, base !=3D NULL, base, false, NU= LL, false, NULL, qdict_haskey(qdict, "speed"), speed, tru= e, - BLOCKDEV_ON_ERROR_REPORT, false, false, false, false, - &error); + BLOCKDEV_ON_ERROR_REPORT, false, NULL, false, false, = false, + false, &error); =20 hmp_handle_error(mon, error); } diff --git a/block/stream.c b/block/stream.c index 3cca1f9..e0b35f8 100644 --- a/block/stream.c +++ b/block/stream.c @@ -217,7 +217,9 @@ static const BlockJobDriver stream_job_driver =3D { void stream_start(const char *job_id, BlockDriverState *bs, BlockDriverState *base, const char *backing_file_str, int creation_flags, int64_t speed, - BlockdevOnError on_error, Error **errp) + BlockdevOnError on_error, + const char *filter_node_name, + Error **errp) { StreamBlockJob *s; BlockDriverState *iter; diff --git a/blockdev.c b/blockdev.c index 97c2ba2..67918fc 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2753,6 +2753,7 @@ void qmp_block_stream(bool has_job_id, const char *jo= b_id, const char *device, bool has_backing_file, const char *backing_file, bool has_speed, int64_t speed, bool has_on_error, BlockdevOnError on_error, + bool has_filter_node_name, const char *filter_node_n= ame, bool has_auto_finalize, bool auto_finalize, bool has_auto_dismiss, bool auto_dismiss, Error **errp) @@ -2769,6 +2770,10 @@ void qmp_block_stream(bool has_job_id, const char *j= ob_id, const char *device, on_error =3D BLOCKDEV_ON_ERROR_REPORT; } =20 + if (!has_filter_node_name) { + filter_node_name =3D NULL; + } + bs =3D bdrv_lookup_bs(device, device, errp); if (!bs) { return; @@ -2840,7 +2845,8 @@ void qmp_block_stream(bool has_job_id, const char *jo= b_id, const char *device, } =20 stream_start(has_job_id ? job_id : NULL, bs, base_bs, base_name, - job_flags, has_speed ? speed : 0, on_error, &local_err); + job_flags, has_speed ? speed : 0, on_error, + filter_node_name, &local_err); if (local_err) { error_propagate(errp, local_err); goto out; diff --git a/include/block/block_int.h b/include/block/block_int.h index 86f7666..0fdfa9c 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1094,6 +1094,9 @@ int is_windows_drive(const char *filename); * See @BlockJobCreateFlags * @speed: The maximum speed, in bytes per second, or 0 for unlimited. * @on_error: The action to take upon error. + * @filter_node_name: The node name that should be assigned to the filter + * driver that the commit job inserts into the graph above @bs. NULL means + * that a node name should be autogenerated. * @errp: Error object. * * Start a streaming operation on @bs. Clusters that are unallocated @@ -1106,7 +1109,9 @@ int is_windows_drive(const char *filename); void stream_start(const char *job_id, BlockDriverState *bs, BlockDriverState *base, const char *backing_file_str, int creation_flags, int64_t speed, - BlockdevOnError on_error, Error **errp); + BlockdevOnError on_error, + const char *filter_node_name, + Error **errp); =20 /** * commit_start: diff --git a/qapi/block-core.json b/qapi/block-core.json index 943df19..df6981e 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2509,6 +2509,11 @@ # 'stop' and 'enospc' can only be used if the block device # supports io-status (see BlockInfo). Since 1.3. # +# @filter-node-name: the node name that should be assigned to the +# filter driver that the stream job inserts into the gr= aph +# above @device. If this option is not given, a node na= me is +# autogenerated. (Since: 5.1) +# # @auto-finalize: When false, this job will wait in a PENDING state after = it has # finished its work, waiting for @block-job-finalize before # making any block graph changes. @@ -2539,6 +2544,7 @@ 'data': { '*job-id': 'str', 'device': 'str', '*base': 'str', '*base-node': 'str', '*backing-file': 'str', '*speed': 'int', '*on-error': 'BlockdevOnError', + '*filter-node-name': 'str', '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } } =20 ## --=20 1.8.3.1 From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589295869; cv=none; d=zohomail.com; s=zohoarc; b=lPVNddbcBAVT7U5xevnH3tjI72H1AXHhMu9tKzWemyPGHuKZ9NV9be79Ir3CnKoUg3I3lRrlrCVVU/LrEccvUbqjLzdwxhpsSEZoYe1kukNFL8xgQfzxeHjcloxBEndq0/EbgWap4ByCb2NKK+w6b8uANOAaVO7Ti0zBs0Cc9BI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589295869; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=5WEKnR9XqKZXSninBxWVlOwCmSDsLlgaMaS6cfDniTA=; b=KV58LRXaszz/jH98m9z/8h+A9a5A43yKLnRAvAxwBnXCPC7g84VOpWiJDKEoLtGbFiSlYqGkjXXjaNR7eGLwxHJJd3Q0E2VMxjJeTZ5/XdgNbz21O61vEuRQ4jJGiP55kcD7NPxVn7zmQDOMuAqwT8z0Gd0HKVFlcknmJEzT3ao= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589295869616468.3840665689785; Tue, 12 May 2020 08:04:29 -0700 (PDT) Received: from localhost ([::1]:32962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWSK-0000D6-I8 for importer@patchew.org; Tue, 12 May 2020 11:04:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWI2-0005gd-Pj; Tue, 12 May 2020 10:53:50 -0400 Received: from relay.sw.ru ([185.231.240.75]:45848) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWI0-0005or-OT; Tue, 12 May 2020 10:53:50 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHb-0003c8-14; Tue, 12 May 2020 17:53:23 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 14/15] iotests: prepare 245 for using filter in block-stream Date: Tue, 12 May 2020 17:53:15 +0300 Message-Id: <1589295196-773454-15-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The preliminary patch modifies the test 245 to prepare the block-stream job for using COR-filter. The filter breaks the backing chain being connected to the underlying node by file child link. Signed-off-by: Andrey Shinkevich --- tests/qemu-iotests/245 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245 index 4f5f0bb..5bcddc4 100755 --- a/tests/qemu-iotests/245 +++ b/tests/qemu-iotests/245 @@ -896,15 +896,19 @@ class TestBlockdevReopen(iotests.QMPTestCase): # make hd1 read-only and block-stream requires it to be read-write # (Which error message appears depends on whether the stream job is # already done with copying at this point.) - self.reopen(opts, {}, + opts =3D hd_opts(1) + opts['backing'] =3D hd_opts(2) + opts['backing']['backing'] =3D None + self.reopen(opts, {'read-only': True}, ["Can't set node 'hd1' to r/o with copy-on-read enabled", "Cannot make block node read-only, there is a writer on it"]) =20 # We can't remove hd2 while the stream job is ongoing - opts['backing']['backing'] =3D None - self.reopen(opts, {'backing.read-only': False}, "Cannot change 'ba= cking' link from 'hd1' to 'hd2'") + opts['backing'] =3D None + self.reopen(opts, {'read-only': False}, "Cannot change 'backing' l= ink from 'hd1' to 'hd2'") =20 # We can detach hd1 from hd0 because it doesn't affect the stream = job + opts =3D hd_opts(0) opts['backing'] =3D None self.reopen(opts) =20 --=20 1.8.3.1 From nobody Thu Oct 31 22:57:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1589295559; cv=none; d=zohomail.com; s=zohoarc; b=J/+Fyx0a138YZSoyelvMp0g7NVFXF+SsQH/Ty4NmRo3inTkmv14Q1WOjwilfom6hqYNLoqnCyp+lZGc9zHhnNXuECsnuE2s+/e5eykjrY19oBznzpO2EFGjL5wZig/4hWmKogwcvV9Mn0D3mZaOjIRNZgRD6noGeiY31Xj16L2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589295559; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=i5h4YwmUs4N8f5c1LpiWiXBjXXJMJMScC3bxv6aBO8g=; b=cC23gWXf17Upa/S+rAyvD+8XwNhBWyMFgGr/bS3M8Pbhq0hK4Yq47li7JdAjtcdrIeeEs4EjkwmvmmQE68ZorQzTqJKifeWPTKzTasTAeQBJySZuF+CtGOBiOTo1nbafADT6sb5d6JGZ910Bg/hu0aSk9jIWgijCGwnyD4TbW9s= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589295559989209.57217137267253; Tue, 12 May 2020 07:59:19 -0700 (PDT) Received: from localhost ([::1]:45024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYWNK-0007sa-NU for importer@patchew.org; Tue, 12 May 2020 10:59:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHl-0004v9-3a; Tue, 12 May 2020 10:53:33 -0400 Received: from relay.sw.ru ([185.231.240.75]:45892) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYWHh-0005oy-H6; Tue, 12 May 2020 10:53:32 -0400 Received: from dhcp-172-16-25-136.sw.ru ([172.16.25.136] helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jYWHb-0003c8-4i; Tue, 12 May 2020 17:53:23 +0300 From: Andrey Shinkevich To: qemu-block@nongnu.org Subject: [PATCH v3 15/15] block: apply COR-filter to block-stream jobs Date: Tue, 12 May 2020 17:53:16 +0300 Message-Id: <1589295196-773454-16-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1589295196-773454-1-git-send-email-andrey.shinkevich@virtuozzo.com> 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=185.231.240.75; envelope-from=andrey.shinkevich@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 10:53:25 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The patch completes the series with the COR-filter insertion to any block-stream operation. It also makes changes to the iotests 030 and 141.out. Signed-off-by: Andrey Shinkevich --- block/stream.c | 83 ++++++++++++++++++++++++++++++++----------= ---- tests/qemu-iotests/030 | 8 +++-- tests/qemu-iotests/141.out | 2 +- 3 files changed, 64 insertions(+), 29 deletions(-) diff --git a/block/stream.c b/block/stream.c index e0b35f8..a74a07b 100644 --- a/block/stream.c +++ b/block/stream.c @@ -19,6 +19,7 @@ #include "qapi/qmp/qerror.h" #include "qemu/ratelimit.h" #include "sysemu/block-backend.h" +#include "block/copy-on-read.h" =20 enum { /* @@ -32,8 +33,11 @@ enum { typedef struct StreamBlockJob { BlockJob common; BlockDriverState *bottom; + BlockDriverState *cor_filter_bs; + BlockDriverState *target_bs; BlockdevOnError on_error; char *backing_file_str; + char *base_fmt; bool bs_read_only; bool chain_frozen; } StreamBlockJob; @@ -52,33 +56,25 @@ static void stream_abort(Job *job) StreamBlockJob *s =3D container_of(job, StreamBlockJob, common.job); =20 if (s->chain_frozen) { - BlockJob *bjob =3D &s->common; - bdrv_unfreeze_chain(blk_bs(bjob->blk), s->bottom); + bdrv_unfreeze_chain(s->cor_filter_bs, s->bottom); } } =20 static int stream_prepare(Job *job) { StreamBlockJob *s =3D container_of(job, StreamBlockJob, common.job); - BlockJob *bjob =3D &s->common; - BlockDriverState *bs =3D blk_bs(bjob->blk); + BlockDriverState *bs =3D s->target_bs; BlockDriverState *base =3D backing_bs(s->bottom); Error *local_err =3D NULL; int ret =3D 0; =20 - bdrv_unfreeze_chain(bs, s->bottom); + bdrv_unfreeze_chain(s->cor_filter_bs, s->bottom); s->chain_frozen =3D false; =20 if (bs->backing) { - const char *base_id =3D NULL, *base_fmt =3D NULL; - if (base) { - base_id =3D s->backing_file_str; - if (base->drv) { - base_fmt =3D base->drv->format_name; - } - } bdrv_set_backing_hd(bs, base, &local_err); - ret =3D bdrv_change_backing_file(bs, base_id, base_fmt); + ret =3D bdrv_change_backing_file(bs, s->backing_file_str, + s->base_fmt); if (local_err) { error_report_err(local_err); return -EPERM; @@ -92,7 +88,9 @@ static void stream_clean(Job *job) { StreamBlockJob *s =3D container_of(job, StreamBlockJob, common.job); BlockJob *bjob =3D &s->common; - BlockDriverState *bs =3D blk_bs(bjob->blk); + BlockDriverState *bs =3D s->target_bs; + + bdrv_cor_filter_drop(s->cor_filter_bs); =20 /* Reopen the image back in read-only mode if necessary */ if (s->bs_read_only) { @@ -102,13 +100,14 @@ static void stream_clean(Job *job) } =20 g_free(s->backing_file_str); + g_free(s->base_fmt); } =20 static int coroutine_fn stream_run(Job *job, Error **errp) { StreamBlockJob *s =3D container_of(job, StreamBlockJob, common.job); BlockBackend *blk =3D s->common.blk; - BlockDriverState *bs =3D blk_bs(blk); + BlockDriverState *bs =3D s->target_bs; bool enable_cor =3D !backing_bs(s->bottom); int64_t len; int64_t offset =3D 0; @@ -156,8 +155,8 @@ static int coroutine_fn stream_run(Job *job, Error **er= rp) } else if (ret >=3D 0) { /* Copy if allocated in the intermediate images. Limit to the * known-unallocated area [offset, offset+n*BDRV_SECTOR_SIZE).= */ - ret =3D bdrv_is_allocated_above(backing_bs(bs), s->bottom, tru= e, - offset, n, &n); + ret =3D bdrv_is_allocated_above(bdrv_filtered_cow_bs(bs), s->b= ottom, + true, offset, n, &n); /* Finish early if end of backing file has been reached */ if (ret =3D=3D 0 && n =3D=3D 0) { n =3D len - offset; @@ -225,7 +224,13 @@ void stream_start(const char *job_id, BlockDriverState= *bs, BlockDriverState *iter; bool bs_read_only; int basic_flags =3D BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGE= D; + BlockDriverState *cor_filter_bs =3D NULL; BlockDriverState *bottom =3D bdrv_find_overlay(bs, base); + char *base_fmt =3D NULL; + + if (base && base->drv) { + base_fmt =3D g_strdup(base->drv->format_name); + } =20 if (bdrv_freeze_chain(bs, bottom, errp) < 0) { return; @@ -240,17 +245,35 @@ void stream_start(const char *job_id, BlockDriverStat= e *bs, } } =20 - /* Prevent concurrent jobs trying to modify the graph structure here, = we - * already have our own plans. Also don't allow resize as the image si= ze is - * queried only at the job start and then cached. */ - s =3D block_job_create(job_id, &stream_job_driver, NULL, bs, - basic_flags | BLK_PERM_GRAPH_MOD, - basic_flags | BLK_PERM_WRITE, + cor_filter_bs =3D bdrv_cor_filter_append(bs, filter_node_name, errp); + if (cor_filter_bs =3D=3D NULL) { + goto fail; + } + + if (bdrv_freeze_chain(cor_filter_bs, bs, errp) < 0) { + bdrv_cor_filter_drop(cor_filter_bs); + cor_filter_bs =3D NULL; + goto fail; + } + + s =3D block_job_create(job_id, &stream_job_driver, NULL, cor_filter_bs, + BLK_PERM_CONSISTENT_READ, + basic_flags | BLK_PERM_WRITE | BLK_PERM_GRAPH_MOD, speed, creation_flags, NULL, NULL, errp); if (!s) { goto fail; } =20 + /* + * Prevent concurrent jobs trying to modify the graph structure here, = we + * already have our own plans. Also don't allow resize as the image si= ze is + * queried only at the job start and then cached. + */ + if (block_job_add_bdrv(&s->common, "active node", bs, + basic_flags | BLK_PERM_GRAPH_MOD, + basic_flags | BLK_PERM_WRITE, &error_abort)) { + goto fail; + } /* Block all intermediate nodes between bs and base, because they will * disappear from the chain after this operation. The streaming job re= ads * every block only once, assuming that it doesn't change, so forbid w= rites @@ -259,13 +282,17 @@ void stream_start(const char *job_id, BlockDriverStat= e *bs, * due to parallel block jobs running. */ base =3D backing_bs(bottom); - for (iter =3D backing_bs(bs); iter && iter !=3D base; iter =3D backing= _bs(iter)) { + for (iter =3D bdrv_filtered_bs(bs); iter && iter !=3D base; + iter =3D bdrv_filtered_bs(iter)) { block_job_add_bdrv(&s->common, "intermediate node", iter, 0, basic_flags, &error_abort); } =20 + s->cor_filter_bs =3D cor_filter_bs; + s->target_bs =3D bs; s->bottom =3D bottom; s->backing_file_str =3D g_strdup(backing_file_str); + s->base_fmt =3D base_fmt; s->bs_read_only =3D bs_read_only; s->chain_frozen =3D true; =20 @@ -278,5 +305,11 @@ fail: if (bs_read_only) { bdrv_reopen_set_read_only(bs, true, NULL); } - bdrv_unfreeze_chain(bs, bottom); + + if (cor_filter_bs) { + bdrv_unfreeze_chain(cor_filter_bs, bottom); + bdrv_cor_filter_drop(cor_filter_bs); + } else { + bdrv_unfreeze_chain(bs, bottom); + } } diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index d7638cd..9856a08 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -269,12 +269,14 @@ class TestParallelOps(iotests.QMPTestCase): self.assert_no_active_block_jobs() =20 # Set a speed limit to make sure that this job blocks the rest - result =3D self.vm.qmp('block-stream', device=3D'node4', job_id=3D= 'stream-node4', base=3Dself.imgs[1], speed=3D1024*1024) + result =3D self.vm.qmp('block-stream', device=3D'node4', + job_id=3D'stream-node4', base=3Dself.imgs[1], + filter_node_name=3D'stream-filter', speed=3D1024*1024) self.assert_qmp(result, 'return', {}) =20 result =3D self.vm.qmp('block-stream', device=3D'node5', job_id=3D= 'stream-node5', base=3Dself.imgs[2]) self.assert_qmp(result, 'error/desc', - "Node 'node4' is busy: block device is in use by block job: st= ream") + "Node 'stream-filter' is busy: block device is in use by block= job: stream") =20 result =3D self.vm.qmp('block-stream', device=3D'node3', job_id=3D= 'stream-node3', base=3Dself.imgs[2]) self.assert_qmp(result, 'error/desc', @@ -287,7 +289,7 @@ class TestParallelOps(iotests.QMPTestCase): # block-commit should also fail if it touches nodes used by the st= ream job result =3D self.vm.qmp('block-commit', device=3D'drive0', base=3Ds= elf.imgs[4], job_id=3D'commit-node4') self.assert_qmp(result, 'error/desc', - "Node 'node4' is busy: block device is in use by block job: st= ream") + "Node 'stream-filter' is busy: block device is in use by block= job: stream") =20 result =3D self.vm.qmp('block-commit', device=3D'drive0', base=3Ds= elf.imgs[1], top=3Dself.imgs[3], job_id=3D'commit-node1') self.assert_qmp(result, 'error/desc', diff --git a/tests/qemu-iotests/141.out b/tests/qemu-iotests/141.out index 263b680..cf18558 100644 --- a/tests/qemu-iotests/141.out +++ b/tests/qemu-iotests/141.out @@ -99,7 +99,7 @@ wrote 1048576/1048576 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}} {'execute': 'blockdev-del', 'arguments': {'node-name': 'drv0'}} -{"error": {"class": "GenericError", "desc": "Node drv0 is in use"}} +{"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: block de= vice is in use by block job: stream"}} {'execute': 'block-job-cancel', 'arguments': {'device': 'job0'}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "job0"}} --=20 1.8.3.1