[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH-for-5.1] hw/ide: Do not block for AIO while resetting a d

From: John Snow
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
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

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)
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().


OK, dropping Phil's patch here.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]