All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Hanna Czenczek <hreitz@redhat.com>
Cc: Fiona Ebner <f.ebner@proxmox.com>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org,
	stefanha@redhat.com, fam@euphon.net
Subject: Re: [PATCH 3/4] block: implement 'resize' callback for child_of_bds class
Date: Tue, 1 Jul 2025 19:32:16 +0200	[thread overview]
Message-ID: <aGQboEwTVS5sYxa_@redhat.com> (raw)
In-Reply-To: <18f6275a-dee0-4df4-85e3-efaf81a7724d@redhat.com>

Am 01.07.2025 um 16:46 hat Hanna Czenczek geschrieben:
> On 30.06.25 13:27, Fiona Ebner wrote:
> > 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 <f.ebner@proxmox.com>
> > ---
> >   block.c                          | 12 ++++++++++++
> >   include/block/block_int-common.h |  2 +-
> >   2 files changed, 13 insertions(+), 1 deletion(-)
> 
> What does this do for block job filter nodes, like mirror?  If they changed
> their length, we might have to consider whether the job also needs to be
> amended somehow.

mirror doesn't share BLK_PERM_RESIZE in its block_job_create() call, so
can this even happen? (If yes, that sounds bad.)

> However, I assume it’s a safe (conservative) change for them because such
> drivers don’t implement bdrv_co_getlength(), so
> bdrv_co_refresh_total_sectors() will not change anything.  Is that right and
> intended?
> 
> Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
> 
> (Babbling below.)
> 
> > 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(BdrvChild *child)
> >       }
> >   }
> > +static void coroutine_fn GRAPH_RDLOCK bdrv_child_cb_resize(BdrvChild *child)
> > +{
> > +    BlockDriverState *bs = child->opaque;
> > +
> > +    if (bs->drv && bs->drv->is_filter) {
> 
> Checking the role for BDRV_CHILD_FILTERED would be more generic; but it
> would cause 'raw' nodes to be updated, too.  But I don’t know whether we
> want that or not, and excluding raw (i.e. not changing behavior there) is
> certainly the safe option.

If the size is not explicitly overridden in the node configuration, I
would certainly expect that a raw node reflects the size of its file
node.

Seems this is exactly the condition that makes it use
BDRV_CHILD_FILTERED, so it would probably be a good change?

> > +        /* Best effort, ignore errors. */
> > +        bdrv_co_refresh_total_sectors(bs, bs->total_sectors);
> > +        bdrv_co_parent_cb_resize(bs);
> 
> This makes me wonder whether bdrv_co_refresh_total_sectors() should itself
> call bdrv_co_parent_cb_resize().  Still not quite sure; if the underlying
> image file is resized by an external party (and we notice this by accident,
> more or less), maybe the guest device should be informed.
> 
> (One thing to consider, maybe, are nodes that unshare the resize permission
> for a child.  It’s probably not clever to call the resize CB if that
> permission is unshared, so maybe just from that perspective, we should keep
> that CB strictly inside of that explicit truncate path that checks that
> permission (at least when growing images...).)
> 
> Anyway, again, this is the safe option.

The traditional solution for nodes that unshare resize, but get resized
in the background anyway would be bs->drv = NULL, and we probably still
aren't certain what happens after that. :-)

Kevin



  reply	other threads:[~2025-07-01 17:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-30 11:27 [PATCH 0/4] refresh filter parents when child was resized Fiona Ebner
2025-06-30 11:27 ` [PATCH 1/4] include/block/block_int-common: document when resize callback is used Fiona Ebner
2025-07-01 14:47   ` Hanna Czenczek
2025-06-30 11:27 ` [PATCH 2/4] block: make bdrv_co_parent_cb_resize() a proper IO API function Fiona Ebner
2025-07-01 14:47   ` Hanna Czenczek
2025-06-30 11:27 ` [PATCH 3/4] block: implement 'resize' callback for child_of_bds class Fiona Ebner
2025-07-01 14:46   ` Hanna Czenczek
2025-07-01 17:32     ` Kevin Wolf [this message]
2025-09-17 11:31       ` Fiona Ebner
2025-06-30 11:27 ` [PATCH 4/4] iotests: add test for resizing a node below filters Fiona Ebner
2025-07-01 14:53   ` Hanna Czenczek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aGQboEwTVS5sYxa_@redhat.com \
    --to=kwolf@redhat.com \
    --cc=f.ebner@proxmox.com \
    --cc=fam@euphon.net \
    --cc=hreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.