From nobody Sat Nov 15 15:29:52 2025 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175128312124994.79342435058504; Mon, 30 Jun 2025 04:32:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uWCjJ-00060f-7L; Mon, 30 Jun 2025 07:31:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uWCiw-0005tn-0W; Mon, 30 Jun 2025 07:30:58 -0400 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uWCio-0004kL-9n; Mon, 30 Jun 2025 07:30:57 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2D44E4423D; Mon, 30 Jun 2025 13:30:40 +0200 (CEST) From: Fiona Ebner To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, stefanha@redhat.com, fam@euphon.net Subject: [PATCH 3/4] block: implement 'resize' callback for child_of_bds class Date: Mon, 30 Jun 2025 13:27:32 +0200 Message-ID: <20250630113035.820557-4-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250630113035.820557-1-f.ebner@proxmox.com> References: <20250630113035.820557-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.237, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1751283122551116600 Content-Type: text/plain; charset="utf-8" If a node below a filter node is resized, the size of the filter node is now also refreshed (recursively for filter parents). Signed-off-by: Fiona Ebner Reviewed-by: Hanna Czenczek --- block.c | 12 ++++++++++++ include/block/block_int-common.h | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index bfd4340b24..449f814ebe 100644 --- a/block.c +++ b/block.c @@ -1497,6 +1497,17 @@ static void GRAPH_WRLOCK bdrv_child_cb_detach(BdrvCh= ild *child) } } =20 +static void coroutine_fn GRAPH_RDLOCK bdrv_child_cb_resize(BdrvChild *chil= d) +{ + BlockDriverState *bs =3D child->opaque; + + if (bs->drv && bs->drv->is_filter) { + /* Best effort, ignore errors. */ + bdrv_co_refresh_total_sectors(bs, bs->total_sectors); + bdrv_co_parent_cb_resize(bs); + } +} + static int bdrv_child_cb_update_filename(BdrvChild *c, BlockDriverState *b= ase, const char *filename, bool backing_mask_protocol, @@ -1529,6 +1540,7 @@ const BdrvChildClass child_of_bds =3D { .detach =3D bdrv_child_cb_detach, .inactivate =3D bdrv_child_cb_inactivate, .change_aio_ctx =3D bdrv_child_cb_change_aio_ctx, + .resize =3D bdrv_child_cb_resize, .update_filename =3D bdrv_child_cb_update_filename, .get_parent_aio_context =3D child_of_bds_get_parent_aio_context, }; diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 692a9696d1..6670db2f85 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -1023,7 +1023,7 @@ struct BdrvChildClass { /* * Notifies the parent that the child was resized. */ - void (*resize)(BdrvChild *child); + void GRAPH_RDLOCK_PTR (*resize)(BdrvChild *child); =20 /* * Returns a name that is supposedly more useful for human users than = the --=20 2.47.2