* [PATCH 0/3] block: fix the size change notification in bdrv_replace_child_bs()
@ 2026-11-05 20:37 Denis V. Lunev
2026-11-05 20:37 ` [PATCH 1/3] block: read the old child length after draining " Denis V. Lunev
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Denis V. Lunev @ 2026-11-05 20:37 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Denis V. Lunev, Kevin Wolf, Hanna Reitz, Eric Blake,
Philippe Mathieu-Daudé
These address Kevin's review of the series which went in through
Eric's block pull as 8b267376df87..28fafb3147f5:
https://lore.kernel.org/qemu-devel/auyju4uLIBaCGPKH@redhat.com/
Tested with a local qtest, not included: with a second scsi-hd sharing
the new node, master reports CAPACITY DATA HAS CHANGED to that device
after qom-set on the first one, and with patch 3 it does not.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Hanna Reitz <hreitz@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Denis V. Lunev (3):
block: read the old child length after draining in
bdrv_replace_child_bs()
block: add bdrv_child_notify_resize() to notify a single parent
block: notify only the replaced child in bdrv_replace_child_bs()
block.c | 7 ++++---
block/io.c | 14 +++++++++++---
include/block/block_int-io.h | 8 +++++++-
3 files changed, 22 insertions(+), 7 deletions(-)
base-commit: f71afb409a87c4ecd0f9d63a5963eb645dfab780
--
2.53.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] block: read the old child length after draining in bdrv_replace_child_bs()
2026-11-05 20:37 [PATCH 0/3] block: fix the size change notification in bdrv_replace_child_bs() Denis V. Lunev
@ 2026-11-05 20:37 ` Denis V. Lunev
2026-11-05 20:37 ` [PATCH 2/3] block: add bdrv_child_notify_resize() to notify a single parent Denis V. Lunev
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Denis V. Lunev @ 2026-11-05 20:37 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Denis V. Lunev, Kevin Wolf, Hanna Reitz, Eric Blake,
Philippe Mathieu-Daudé
From: Denis V. Lunev <den@openvz.org>
bdrv_drained_begin() runs nested event loops, and old_bs can be resized
from there by something other than the BlockBackend being switched: an
export truncating it, or a block job completing. old_len read before
the drain is then stale, and comparing it with new_len sends a
notification the parent does not need or skips one it does.
Read it once both nodes are drained, so that the read, the comparison
and the notification see the same sizes. A resize which completes in
the drain notifies the parents of old_bs, @child included, on its own.
Fixes: 8b267376df87 ("block: notify the parent when a replaced child has a different size")
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Hanna Reitz <hreitz@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
block.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/block.c b/block.c
index 006c341340..9df1a48c06 100644
--- a/block.c
+++ b/block.c
@@ -5566,11 +5566,12 @@ int bdrv_replace_child_bs(BdrvChild *child, BlockDriverState *new_bs,
GLOBAL_STATE_CODE();
- old_len = bdrv_getlength(old_bs);
-
bdrv_ref(old_bs);
bdrv_drained_begin(old_bs);
bdrv_drained_begin(new_bs);
+
+ old_len = bdrv_getlength(old_bs);
+
bdrv_graph_wrlock();
bdrv_replace_child_tran(child, new_bs, tran);
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] block: add bdrv_child_notify_resize() to notify a single parent
2026-11-05 20:37 [PATCH 0/3] block: fix the size change notification in bdrv_replace_child_bs() Denis V. Lunev
2026-11-05 20:37 ` [PATCH 1/3] block: read the old child length after draining " Denis V. Lunev
@ 2026-11-05 20:37 ` Denis V. Lunev
2026-11-05 20:37 ` [PATCH 3/3] block: notify only the replaced child in bdrv_replace_child_bs() Denis V. Lunev
2026-11-17 11:00 ` [PATCH 0/3] block: fix the size change notification " Kevin Wolf
3 siblings, 0 replies; 5+ messages in thread
From: Denis V. Lunev @ 2026-11-05 20:37 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Denis V. Lunev, Kevin Wolf, Hanna Reitz, Eric Blake,
Philippe Mathieu-Daudé
From: Denis V. Lunev <den@openvz.org>
bdrv_co_parent_cb_resize() calls the resize hook of every parent of a
node. bdrv_replace_child_bs() needs to call it for one BdrvChild, and
from outside a coroutine.
Move the call into bdrv_co_child_notify_resize(), make the loop use it,
and add a co_wrapper for callers outside a coroutine.
No functional change.
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Hanna Reitz <hreitz@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
block/io.c | 14 +++++++++++---
include/block/block_int-io.h | 9 +++++++++
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/block/io.c b/block/io.c
index 06b1fc13b9..ea77f34204 100644
--- a/block/io.c
+++ b/block/io.c
@@ -3634,6 +3634,16 @@ int coroutine_fn bdrv_co_copy_range(BdrvChild *src, int64_t src_offset,
bytes, read_flags, write_flags);
}
+void coroutine_fn bdrv_co_child_notify_resize(BdrvChild *c)
+{
+ IO_CODE();
+ assert_bdrv_graph_readable();
+
+ if (c->klass->resize) {
+ c->klass->resize(c);
+ }
+}
+
void coroutine_fn bdrv_co_parent_cb_resize(BlockDriverState *bs)
{
BdrvChild *c;
@@ -3642,9 +3652,7 @@ void coroutine_fn bdrv_co_parent_cb_resize(BlockDriverState *bs)
assert_bdrv_graph_readable();
QLIST_FOREACH(c, &bs->parents, next_parent) {
- if (c->klass->resize) {
- c->klass->resize(c);
- }
+ bdrv_co_child_notify_resize(c);
}
}
diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h
index 95d0dd7a05..3cb72fecd4 100644
--- a/include/block/block_int-io.h
+++ b/include/block/block_int-io.h
@@ -197,6 +197,15 @@ void bdrv_bsc_fill(BlockDriverState *bs, int64_t offset, int64_t bytes);
void coroutine_fn GRAPH_RDLOCK
bdrv_co_parent_cb_resize(BlockDriverState *bs);
+/*
+ * Notify the parent behind @c that the size of its child changed.
+ */
+void coroutine_fn GRAPH_RDLOCK
+bdrv_co_child_notify_resize(BdrvChild *c);
+
+void co_wrapper_bdrv_rdlock
+bdrv_child_notify_resize(BdrvChild *c);
+
void co_wrapper_bdrv_rdlock
bdrv_parent_cb_resize(BlockDriverState *bs);
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] block: notify only the replaced child in bdrv_replace_child_bs()
2026-11-05 20:37 [PATCH 0/3] block: fix the size change notification in bdrv_replace_child_bs() Denis V. Lunev
2026-11-05 20:37 ` [PATCH 1/3] block: read the old child length after draining " Denis V. Lunev
2026-11-05 20:37 ` [PATCH 2/3] block: add bdrv_child_notify_resize() to notify a single parent Denis V. Lunev
@ 2026-11-05 20:37 ` Denis V. Lunev
2026-11-17 11:00 ` [PATCH 0/3] block: fix the size change notification " Kevin Wolf
3 siblings, 0 replies; 5+ messages in thread
From: Denis V. Lunev @ 2026-11-05 20:37 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Denis V. Lunev, Kevin Wolf, Hanna Reitz, Eric Blake,
Philippe Mathieu-Daudé
From: Denis V. Lunev <den@openvz.org>
bdrv_replace_child_bs() compares the sizes of the old and the new node
to decide whether @child has to be told, and then notifies every parent
of new_bs. The other parents already had that node and its size, so
they get a resize event for nothing: a scsi-hd sharing the new node
reports CAPACITY DATA HAS CHANGED to its guest although the capacity is
the same.
Notify @child alone. bdrv_parent_cb_resize() has no user left, so drop
it.
Fixes: 8b267376df87 ("block: notify the parent when a replaced child has a different size")
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Hanna Reitz <hreitz@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
block.c | 2 +-
include/block/block_int-io.h | 3 ---
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/block.c b/block.c
index 9df1a48c06..c3e7059556 100644
--- a/block.c
+++ b/block.c
@@ -5590,7 +5590,7 @@ int bdrv_replace_child_bs(BdrvChild *child, BlockDriverState *new_bs,
int64_t new_len = bdrv_getlength(new_bs);
if (new_len >= 0 && new_len != old_len) {
- bdrv_parent_cb_resize(new_bs);
+ bdrv_child_notify_resize(child);
}
}
diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h
index 3cb72fecd4..6aa7b2184e 100644
--- a/include/block/block_int-io.h
+++ b/include/block/block_int-io.h
@@ -206,7 +206,4 @@ bdrv_co_child_notify_resize(BdrvChild *c);
void co_wrapper_bdrv_rdlock
bdrv_child_notify_resize(BdrvChild *c);
-void co_wrapper_bdrv_rdlock
-bdrv_parent_cb_resize(BlockDriverState *bs);
-
#endif /* BLOCK_INT_IO_H */
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] block: fix the size change notification in bdrv_replace_child_bs()
2026-11-05 20:37 [PATCH 0/3] block: fix the size change notification in bdrv_replace_child_bs() Denis V. Lunev
` (2 preceding siblings ...)
2026-11-05 20:37 ` [PATCH 3/3] block: notify only the replaced child in bdrv_replace_child_bs() Denis V. Lunev
@ 2026-11-17 11:00 ` Kevin Wolf
3 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2026-11-17 11:00 UTC (permalink / raw)
To: Denis V. Lunev
Cc: qemu-devel, qemu-block, Hanna Reitz, Eric Blake,
Philippe Mathieu-Daudé
Am 05.11.2026 um 21:37 hat Denis V. Lunev geschrieben:
> These address Kevin's review of the series which went in through
> Eric's block pull as 8b267376df87..28fafb3147f5:
> https://lore.kernel.org/qemu-devel/auyju4uLIBaCGPKH@redhat.com/
>
> Tested with a local qtest, not included: with a second scsi-hd sharing
> the new node, master reports CAPACITY DATA HAS CHANGED to that device
> after qom-set on the first one, and with patch 3 it does not.
>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Hanna Reitz <hreitz@redhat.com>
> Cc: Eric Blake <eblake@redhat.com>
> Cc: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-17 11:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-05 20:37 [PATCH 0/3] block: fix the size change notification in bdrv_replace_child_bs() Denis V. Lunev
2026-11-05 20:37 ` [PATCH 1/3] block: read the old child length after draining " Denis V. Lunev
2026-11-05 20:37 ` [PATCH 2/3] block: add bdrv_child_notify_resize() to notify a single parent Denis V. Lunev
2026-11-05 20:37 ` [PATCH 3/3] block: notify only the replaced child in bdrv_replace_child_bs() Denis V. Lunev
2026-11-17 11:00 ` [PATCH 0/3] block: fix the size change notification " Kevin Wolf
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.