From: Kevin Wolf <kwolf@redhat.com>
To: Fabiano Rosas <farosas@suse.de>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
"Hanna Reitz" <hreitz@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"João Silva" <jsilva@suse.de>, "Lin Ma" <lma@suse.com>,
"Claudio Fontana" <cfontana@suse.de>,
"Dario Faggioli" <dfaggioli@suse.com>,
"Eric Blake" <eblake@redhat.com>
Subject: Re: [RFC PATCH 5/6] block: Allow bdrv_get_allocated_file_size to run in bdrv context
Date: Fri, 26 May 2023 11:28:25 +0200 [thread overview]
Message-ID: <ZHB7ufFMG90NUcM0@redhat.com> (raw)
In-Reply-To: <20230523213903.18418-6-farosas@suse.de>
Am 23.05.2023 um 23:39 hat Fabiano Rosas geschrieben:
> We're about to move calls to 'fstat' into the thread-pool to avoid
> blocking VCPU threads should the system call take too long.
>
> To achieve that we first need to make sure none of its callers is
> holding the aio_context lock, otherwise yielding before scheduling the
> aiocb handler would result in a deadlock when the qemu_global_mutex is
> released and another thread tries to acquire the aio_context.
>
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
> block/qapi.c | 22 +++++++++++++++++++++-
> 1 file changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/block/qapi.c b/block/qapi.c
> index ae6cd1c2ff..cd197abf1f 100644
> --- a/block/qapi.c
> +++ b/block/qapi.c
> @@ -222,6 +222,26 @@ int bdrv_query_snapshot_info_list(BlockDriverState *bs,
> return 0;
> }
>
> +static int64_t bdrv_get_actual_size(BlockDriverState *bs)
> +{
> + int64_t size;
> + AioContext *old_ctx = NULL;
> +
> + if (qemu_in_coroutine()) {
Hm. Why can't we make sure that it always runs in a coroutine?
Callers:
* bdrv_query_block_node_info(). This functions seems to be completely
unused, we can remove it.
* bdrv_query_image_info(). Called by bdrv_block_device_info() and itself.
bdrv_block_device_info() could become a co_wrapper after swapping the
first two parameters so that it runs in the AioContext of @bs.
* bdrv_query_block_graph_info(). Only called by qemu-img. Could become a
co_wrapper_bdrv_rdlock.
> + aio_context_release(bdrv_get_aio_context(bs));
> + old_ctx = bdrv_co_enter(bs);
I think this is the wrong function to do this. The caller should already
make sure that it's in the right AioContext.
> + }
> +
> + size = bdrv_get_allocated_file_size(bs);
> +
> + if (qemu_in_coroutine() && old_ctx) {
> + bdrv_co_leave(bs, old_ctx);
> + aio_context_acquire(bdrv_get_aio_context(bs));
> + }
> +
> + return size;
> +}
Kevin
next prev parent reply other threads:[~2023-05-26 9:29 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 21:38 [RFC PATCH 0/6] block: Make raw_co_get_allocated_file_size asynchronous Fabiano Rosas
2023-05-23 21:38 ` [RFC PATCH 1/6] block: Remove bdrv_query_block_node_info Fabiano Rosas
2023-05-24 8:31 ` Claudio Fontana
2023-05-23 21:38 ` [RFC PATCH 2/6] block: Mark bdrv_co_get_allocated_file_size() as mixed Fabiano Rosas
2023-05-25 14:17 ` Eric Blake
2023-05-26 9:12 ` Kevin Wolf
2023-05-23 21:39 ` [RFC PATCH 3/6] Convert query-block/info_block to coroutine Fabiano Rosas
2023-05-24 8:48 ` Claudio Fontana
2023-05-25 14:26 ` Eric Blake
2023-05-26 14:05 ` Fabiano Rosas
2023-05-23 21:39 ` [RFC PATCH 4/6] " Fabiano Rosas
2023-05-24 4:23 ` Lin Ma
2023-05-24 12:30 ` Fabiano Rosas
2023-05-24 8:49 ` Claudio Fontana
2023-05-24 9:24 ` Lin Ma
2023-05-24 15:57 ` Claudio Fontana
2023-05-23 21:39 ` [RFC PATCH 5/6] block: Allow bdrv_get_allocated_file_size to run in bdrv context Fabiano Rosas
2023-05-26 9:28 ` Kevin Wolf [this message]
2023-05-29 17:47 ` Fabiano Rosas
2023-05-23 21:39 ` [RFC PATCH 6/6] block: Add a thread-pool version of fstat Fabiano Rosas
2023-05-24 15:56 ` Claudio Fontana
2023-05-25 15:45 ` Eric Blake
2023-05-26 14:20 ` Fabiano Rosas
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=ZHB7ufFMG90NUcM0@redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=cfontana@suse.de \
--cc=dfaggioli@suse.com \
--cc=eblake@redhat.com \
--cc=farosas@suse.de \
--cc=hreitz@redhat.com \
--cc=jsilva@suse.de \
--cc=lma@suse.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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.