diff mbox

[1/2] block/io: allow AIOCB without callback

Message ID 1440058448-27847-2-git-send-email-pl@kamp.de
State New
Headers show

Commit Message

Peter Lieven Aug. 20, 2015, 8:14 a.m. UTC
If the backend storage is unresponsive and we cancel a request due to
a timeout we cannot immediately destroy the AIOCB because the storage
might complete the original request laster if it is responsive again.
For this purpose allow to set the callback to NULL and ignore it in
this case.

Signed-off-by: Peter Lieven <pl@kamp.de>
---
 block/io.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Eric Blake Aug. 21, 2015, 6:12 a.m. UTC | #1
On 08/20/2015 01:14 AM, Peter Lieven wrote:
> If the backend storage is unresponsive and we cancel a request due to
> a timeout we cannot immediately destroy the AIOCB because the storage
> might complete the original request laster if it is responsive again.

s/laster/later/

> For this purpose allow to set the callback to NULL and ignore it in
> this case.
> 
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---

I'll leave the technical review to others, I'm just pointing out grammar.
Peter Lieven Aug. 31, 2015, 8:38 a.m. UTC | #2
Am 21.08.2015 um 08:12 schrieb Eric Blake:
> On 08/20/2015 01:14 AM, Peter Lieven wrote:
>> If the backend storage is unresponsive and we cancel a request due to
>> a timeout we cannot immediately destroy the AIOCB because the storage
>> might complete the original request laster if it is responsive again.
> s/laster/later/
>
>> For this purpose allow to set the callback to NULL and ignore it in
>> this case.
>>
>> Signed-off-by: Peter Lieven <pl@kamp.de>
>> ---
> I'll leave the technical review to others, I'm just pointing out grammar.
>


I am using this one for quite some time now. It seems a good step into solving the deadlock
problem. The issue is we still need to make the ATAPI calls async. The OS is only spending 2-3 Minutes
with DMA cancelling and then issues reads again so we still deadlock at the end.

Peter
diff mbox

Patch

diff --git a/block/io.c b/block/io.c
index d4bc83b..e628581 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2007,7 +2007,9 @@  static void bdrv_aio_bh_cb(void *opaque)
         qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size);
     }
     qemu_vfree(acb->bounce);
-    acb->common.cb(acb->common.opaque, acb->ret);
+    if (acb->common.cb) {
+        acb->common.cb(acb->common.opaque, acb->ret);
+    }
     qemu_bh_delete(acb->bh);
     acb->bh = NULL;
     qemu_aio_unref(acb);
@@ -2075,7 +2077,9 @@  static const AIOCBInfo bdrv_em_co_aiocb_info = {
 static void bdrv_co_complete(BlockAIOCBCoroutine *acb)
 {
     if (!acb->need_bh) {
-        acb->common.cb(acb->common.opaque, acb->req.error);
+        if (acb->common.cb) {
+            acb->common.cb(acb->common.opaque, acb->req.error);
+        }
         qemu_aio_unref(acb);
     }
 }