From: John Snow <jsnow@redhat.com>
To: "Stefan Hajnoczi" <stefanha@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Alexander Bulekov <alxndr@bu.edu>,
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: Tue, 21 Jul 2020 12:37:24 -0400 [thread overview]
Message-ID: <e853fb33-8b6a-1e36-e028-1efc51b01616@redhat.com> (raw)
In-Reply-To: <20200720100246.GA24159@stefanha-x1.localdomain>
On 7/20/20 6:02 AM, Stefan Hajnoczi wrote:
> 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
>
OK, dropping Phil's patch here.
--js
prev parent reply other threads:[~2020-07-21 16:38 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
2020-07-21 16:37 ` John Snow [this message]
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=e853fb33-8b6a-1e36-e028-1efc51b01616@redhat.com \
--to=jsnow@redhat.com \
--cc=alxndr@bu.edu \
--cc=f4bug@amsat.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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;
as well as URLs for NNTP newsgroup(s).