Virtuozzo QEMU development (svt-core@virtuozzo.com)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: andrey.drobyshev@virtuozzo.com, "Denis V. Lunev" <den@openvz.org>
Cc: svt-core@virtuozzo.com, den@openvz.org
Subject: Re: [PATCH hci-dev 2/6] block: notify the parent when a replaced child has a different size #VSTOR-130961
Date: Wed, 4 Nov 2026 13:51:03 +0000	[thread overview]
Message-ID: <010701a1a6d3d79c-cbcec1c8-ebe1-40ca-a26c-0e18ee952075-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261104134539.1519657-3-den@openvz.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] block: bdrv_replace_resize_commit() notifies all parents of new_bs
--

commit 1388b90801798d7d441e56e99ea5745089939495
Author: Denis V. Lunev <den@openvz.org>

block: notify the parent when a replaced child has a different size #VSTOR-130961

This commit makes bdrv_replace_child_bs() register a transaction action. When the transaction commits, the action compares the lengths of the old and new nodes. If they differ, it calls bdrv_parent_cb_resize() on the new node, so parents that cache the child size learn about the change.

> diff --git a/block.c b/block.c
> --- a/block.c
> +++ b/block.c

[ ... ]

> +static void bdrv_replace_resize_commit(void *opaque)
> +{
> +    BdrvReplaceResizeState *s = opaque;
> +    int64_t old_len = bdrv_getlength(s->old_bs);
> +    int64_t new_len = bdrv_getlength(s->new_bs);
> +
> +    /* A parent caching the child size has to learn that it changed */
> +    if (old_len >= 0 && new_len >= 0 && new_len != old_len) {
> +        bdrv_parent_cb_resize(s->new_bs);
> +    }
> +}

[Severity: Low]
Is the notification broader than the commit message describes? The subject and body talk about notifying "the parent" of the replaced child. However, bdrv_replace_resize_commit() calls bdrv_parent_cb_resize(s->new_bs), which wraps bdrv_co_parent_cb_resize(). That function walks every entry in bs->parents:

block/io.c:bdrv_co_parent_cb_resize() {
    ...
    QLIST_FOREACH(c, &bs->parents, next_parent) {
        if (c->klass->resize) {
            c->klass->resize(c);
        }
    }
}

BdrvReplaceResizeState records only old_bs and new_bs, not the replaced BdrvChild. The old_len versus new_len check says nothing about the other parents of new_bs.

When the commit action runs, the replaced child is already a parent of new_bs. Any other BlockBackend, export or device model attached to new_bs also gets resize(). Their view of the size did not change.

Can this send redundant notifications to those parents? For example, virtio-blk would get an extra config-change interrupt. scsi-disk would report a spurious CAPACITY DATA HAS CHANGED unit attention.

Would it be better to notify only the parent that was replaced, or to describe the broader behavior in the commit message?

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261104134539.1519657-1-den@openvz.org?part=2

  reply	other threads:[~2026-11-04 13:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 13:45 [PATCH hci-dev 0/6] block, scsi-disk: honour a size change on child replacement #VSTOR-130961 Denis V. Lunev
2026-11-04 13:45 ` [PATCH hci-dev 1/6] block: make bdrv_co_parent_cb_resize() a proper IO API function #VSTOR-130961 Denis V. Lunev
2026-11-04 13:47   ` no-reply
2026-11-04 13:45 ` [PATCH hci-dev 2/6] block: notify the parent when a replaced child has a different size #VSTOR-130961 Denis V. Lunev
2026-11-04 13:51   ` no-reply [this message]
2026-11-04 13:45 ` [PATCH hci-dev 3/6] scsi-disk: refresh the cached capacity from the resize callback #VSTOR-130961 Denis V. Lunev
2026-11-04 13:50   ` no-reply
2026-11-04 13:45 ` [PATCH hci-dev 4/6] tests/qtest/virtio-scsi: cover a replacement that changes the size #VSTOR-130961 Denis V. Lunev
2026-11-04 13:54   ` no-reply
2026-11-04 13:45 ` [PATCH hci-dev 5/6] tests/qemu-iotests/qom-set-drive: replace with a differently sized node #VSTOR-130961 Denis V. Lunev
2026-11-04 13:51   ` no-reply
2026-11-04 13:45 ` [PATCH hci-dev 6/6] tests/qtest/virtio-scsi: cover vz-x-blockdev-replace changing the size #VSTOR-130961 Denis V. Lunev
2026-11-04 13:53   ` no-reply
2026-11-04 14:00 ` [PATCH hci-dev 0/6] block, scsi-disk: honour a size change on child replacement #VSTOR-130961 Andrey Drobyshev

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=010701a1a6d3d79c-cbcec1c8-ebe1-40ca-a26c-0e18ee952075-000000@eu-central-1.amazonses.com \
    --to=no-reply@sashiko.virtuozzo.com \
    --cc=andrey.drobyshev@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=svt-core@virtuozzo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox