Patchwork [08/10] ide: Handle immediate bdrv_aio_flush failure

login
register
mail settings
Submitter Kevin Wolf
Date Nov. 4, 2010, 1:15 p.m.
Message ID <1288876539-8300-9-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/70135/
State New
Headers show

Comments

Kevin Wolf - Nov. 4, 2010, 1:15 p.m.
If bdrv_aio_flush returns NULL, this should be treated as an error.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 hw/ide/core.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

Patch

diff --git a/hw/ide/core.c b/hw/ide/core.c
index bc3e916..484e0ca 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -811,10 +811,16 @@  static void ide_flush_cb(void *opaque, int ret)
 
 static void ide_flush_cache(IDEState *s)
 {
-    if (s->bs) {
-        bdrv_aio_flush(s->bs, ide_flush_cb, s);
-    } else {
+    BlockDriverAIOCB *acb;
+
+    if (s->bs == NULL) {
         ide_flush_cb(s, 0);
+        return;
+    }
+
+    acb = bdrv_aio_flush(s->bs, ide_flush_cb, s);
+    if (acb == NULL) {
+        ide_flush_cb(s, -EIO);
     }
 }