From: Stefan Hajnoczi <stefanha@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Alexander Bulekov <alxndr@bu.edu>, John Snow <jsnow@redhat.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [RFC PATCH-for-5.1] hw/ide: Do not block for AIO while resetting a drive
Date: Mon, 20 Jul 2020 11:02:46 +0100 [thread overview]
Message-ID: <20200720100246.GA24159@stefanha-x1.localdomain> (raw)
In-Reply-To: <20200717171938.1249-1-f4bug@amsat.org>
[-- Attachment #1: Type: text/plain, Size: 1807 bytes --]
On Fri, Jul 17, 2020 at 07:19:38PM +0200, Philippe Mathieu-Daudé wrote:
> Last minute chat:
> 19:01 <stefanha> f4bug: use bdrv_aio_cancel_async() if possible because it won't block the current thread.
> 19:02 <stefanha> f4bug: For example, in device emulation code where the guest has requested to cancel an I/O request it's often possible to use the async version.
> 19:02 <stefanha> f4bug: But in synchronous code like device reset it may be necessary to use the synchronous (blocking) bdrv_aio_cancel() API instead. :(
> 19:14 <stefanha> f4bug: The way to decide is: will the current function return to the event loop and is there someone who will handle the request completion callback when cancel finishes?
> 19:14 <stefanha> f4bug: If the next line of code requires the request to finished then async cancel cannot be used.
> 19:15 <stefanha> f4bug: On the other hand, if the function can return and it's okay for the request to cancel at some future time then you can use async.
>
> So I'll revisit this patch :)
> ---
> hw/ide/core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ide/core.c b/hw/ide/core.c
> index d997a78e47..e3a9ce7d25 100644
> --- a/hw/ide/core.c
> +++ b/hw/ide/core.c
> @@ -1315,7 +1315,8 @@ static void ide_reset(IDEState *s)
> trace_ide_reset(s);
>
> if (s->pio_aiocb) {
> - blk_aio_cancel(s->pio_aiocb);
> + /* If there is a pending AIO callback, invoke it now. */
> + blk_aio_cancel_async(s->pio_aiocb);
This is a place where an async call is not allowed. The completion
function must be called right away (synchronously) before we can
continue resetting the device.
I sent a patch that allows bdrv_aio_cancel() to find the AioContext so
it can call aio_poll().
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-07-20 10:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-17 17:19 [RFC PATCH-for-5.1] hw/ide: Do not block for AIO while resetting a drive Philippe Mathieu-Daudé
2020-07-17 17:27 ` no-reply
2020-07-20 10:02 ` Stefan Hajnoczi [this message]
2020-07-21 16:37 ` John Snow
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=20200720100246.GA24159@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=alxndr@bu.edu \
--cc=f4bug@amsat.org \
--cc=jsnow@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).