From: Eric Blake <eblake@redhat.com>
To: Guillaume Vincke <guillaume.vincke@ovhcloud.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com,
stefanha@redhat.com, fam@euphon.net
Subject: Re: [PATCH 2/5] block: Refresh the connection before block_resize
Date: Thu, 19 Nov 2026 16:32:17 -0600 [thread overview]
Message-ID: <av91249yWhnS7Gri@redhat.com> (raw)
In-Reply-To: <20261119144632.232457-3-guillaume.vincke@ovhcloud.com>
On Thu, Nov 19, 2026 at 03:46:29PM +0100, Guillaume Vincke wrote:
> When a network based device is not connected, there is no way for the
> backend to notify a change. For instance, the NBD client relies on lazy
> reconnection. Therefore, if an NBD backend changes size, there is
> currently no way to update the device size until at least one I/O
> operation is sent.
>
> This patch adds the bdrv_co_refresh_connection callback to the
> BlockDriver structure so a reconnection can be forced. Considering
> nbd_co_truncate() does not perform any I/O, it also modifies the QMP
> block_resize implementation to execute the callback, if defined, before
> truncating.
>
> No functional change.
At least not until later patches start implementing the new
callback. But overall the explanation of why this callback is useful
makes sense to me.
>
> Signed-off-by: Guillaume Vincke <guillaume.vincke@ovhcloud.com>
> ---
> block/block-backend.c | 12 ++++++++++++
> block/io.c | 24 ++++++++++++++++++++++++
> blockdev.c | 9 +++++++++
> include/block/block-io.h | 8 ++++++++
> include/block/block_int-common.h | 3 +++
> include/system/block-backend-io.h | 2 ++
> 6 files changed, 58 insertions(+)
>
> diff --git a/block/block-backend.c b/block/block-backend.c
> index 656c0aed67..b133bb8292 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -2600,6 +2600,18 @@ int coroutine_fn blk_co_truncate(BlockBackend *blk, int64_t offset, bool exact,
> return bdrv_co_truncate(blk->root, offset, exact, prealloc, flags, errp);
> }
>
> +int coroutine_fn blk_co_refresh_connection(BlockBackend *blk, Error **errp)
> +{
Check out scripts/git.orderfile for a way to list the .h changes (with
the documentation) ahead of the .c changes (with the implementation).
> +++ b/blockdev.c
> @@ -2314,6 +2314,7 @@ void coroutine_fn qmp_block_resize(const char *device, const char *node_name,
> BlockBackend *blk;
> BlockDriverState *bs;
> AioContext *old_ctx;
> + int ret;
>
> bs = bdrv_lookup_bs(device, node_name, &local_err);
> if (local_err) {
> @@ -2338,6 +2339,14 @@ void coroutine_fn qmp_block_resize(const char *device, const char *node_name,
> return;
> }
>
> + old_ctx = bdrv_co_enter(bs);
> + ret = blk_co_refresh_connection(blk, errp);
> + bdrv_co_leave(bs, old_ctx);
> + if (ret < 0) {
> + blk_co_unref(blk);
> + return;
> + }
> +
> bdrv_drained_begin(bs);
>
> old_ctx = bdrv_co_enter(bs);
Am I missing a reason for why you add a separate bdrv_co_enter/leave
critical section prior the bdrv_drained_begin, rather than reusing the
critical section already present during the drained region? Is it
because you want to ensure the (re-)connection is in place before the
drain can trigger IO traffic?
> diff --git a/include/block/block-io.h b/include/block/block-io.h
> index f671476f08..5a7328fed5 100644
> --- a/include/block/block-io.h
> +++ b/include/block/block-io.h
> @@ -114,6 +114,14 @@ int coroutine_fn GRAPH_RDLOCK bdrv_co_flush(BlockDriverState *bs);
> int coroutine_fn GRAPH_RDLOCK bdrv_co_pdiscard(BdrvChild *child, int64_t offset,
> int64_t bytes);
>
> +/*
> + * Ensure the connection is ready to process requests by re-establishing it if
> + * closed.
> + * Returns 0 when the driver does not declare the callback.
> + */
> +int coroutine_fn GRAPH_RDLOCK bdrv_co_refresh_connection(BdrvChild *child,
> + Error **errp);
Maybe word it as "Returns 0 when ready or if driver does not declare
the callback, and -errno on failure to reconnect."
--
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization: qemu.org | libguestfs.org
next prev parent reply other threads:[~2026-11-19 22:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 14:46 [PATCH 0/5] block/nbd: Fix block resize on idle device Guillaume Vincke
2026-11-19 14:46 ` [PATCH 1/5] block/nbd: Extract request slot access and reconnection Guillaume Vincke
2026-11-19 22:16 ` Eric Blake
2026-11-19 14:46 ` [PATCH 2/5] block: Refresh the connection before block_resize Guillaume Vincke
2026-11-19 22:32 ` Eric Blake [this message]
2026-11-20 10:40 ` guillaume vincke
2026-11-19 14:46 ` [PATCH 3/5] block/nbd: Refresh the connection on block_resize Guillaume Vincke
2026-11-19 16:25 ` Eric Blake
2026-11-20 10:12 ` guillaume vincke
2026-11-19 14:46 ` [PATCH 4/5] iotests: Add coverage for NBD resize Guillaume Vincke
2026-11-19 22:51 ` Eric Blake
2026-11-20 10:17 ` guillaume vincke
2026-11-19 14:46 ` [PATCH 5/5] block: Add refresh connection support to raw and luks Guillaume Vincke
2026-11-19 16:20 ` [PATCH 0/5] block/nbd: Fix block resize on idle device Eric Blake
2026-11-20 10:04 ` guillaume vincke
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=av91249yWhnS7Gri@redhat.com \
--to=eblake@redhat.com \
--cc=fam@euphon.net \
--cc=guillaume.vincke@ovhcloud.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@yandex-team.ru \
/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.