]> xenbits.xensource.com Git - qemu-xen-4.3-testing.git/commitdiff
ide write_cache disablement implemented using bdrv_aio_flush
authorIan Jackson <iwj@mariner.uk.xensource.com>
Wed, 2 Apr 2008 16:23:13 +0000 (17:23 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 12 May 2008 11:16:24 +0000 (12:16 +0100)
Previously our implementation of the cache flush for ide disks with
write_cache disabled was synchronous.  This is less than ideal.

hw/ide.c

index 1f60abd0186488d2fc0202c7797ef29c2232a2ab..6062c7448e24911d96181e7781308f47dba911e0 100644 (file)
--- a/hw/ide.c
+++ b/hw/ide.c
@@ -892,6 +892,14 @@ static int dma_buf_rw(BMDMAState *bm, int is_write)
     return 1;
 }
 
+static void ide_dma_eot(BMDMAState *bm) {
+    bm->status &= ~BM_STATUS_DMAING;
+    bm->status |= BM_STATUS_INT;
+    bm->dma_cb = NULL;
+    bm->ide_if = NULL;
+    bm->aiocb = NULL;
+}
+
 static void ide_read_dma_cb(void *opaque, int ret)
 {
     BMDMAState *bm = opaque;
@@ -921,11 +929,7 @@ static void ide_read_dma_cb(void *opaque, int ret)
         s->status = READY_STAT | SEEK_STAT;
         ide_set_irq(s);
     eot:
-        bm->status &= ~BM_STATUS_DMAING;
-        bm->status |= BM_STATUS_INT;
-        bm->dma_cb = NULL;
-        bm->ide_if = NULL;
-        bm->aiocb = NULL;
+       ide_dma_eot(bm);
         return;
     }
 
@@ -1007,6 +1011,20 @@ static void ide_sector_write(IDEState *s)
     }
 }
 
+static void ide_write_flush_cb(void *opaque, int ret) {
+    BMDMAState *bm = opaque;
+    IDEState *s = bm->ide_if;
+
+    if (ret != 0) {
+       ide_dma_error(s);
+       return;
+    }
+    s->status = READY_STAT | SEEK_STAT;
+    ide_set_irq(s);
+    ide_dma_eot(bm);
+    return;
+}
+
 static void ide_write_dma_cb(void *opaque, int ret)
 {
     BMDMAState *bm = opaque;
@@ -1032,20 +1050,13 @@ static void ide_write_dma_cb(void *opaque, int ret)
     /* end of transfer ? */
     if (s->nsector == 0) {
        if (!s->write_cache) {
-           ret = bdrv_flush(s->bs);
-           if (ret != 0) {
-               ide_dma_error(s);
-               return;
-           }
+           bdrv_aio_flush(s->bs, ide_write_flush_cb, bm);
+           return;
        }
         s->status = READY_STAT | SEEK_STAT;
         ide_set_irq(s);
     eot:
-        bm->status &= ~BM_STATUS_DMAING;
-        bm->status |= BM_STATUS_INT;
-        bm->dma_cb = NULL;
-        bm->ide_if = NULL;
-        bm->aiocb = NULL;
+       ide_dma_eot(bm);
         return;
     }
 
@@ -1366,11 +1377,7 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret)
         s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
         ide_set_irq(s);
     eot:
-        bm->status &= ~BM_STATUS_DMAING;
-        bm->status |= BM_STATUS_INT;
-        bm->dma_cb = NULL;
-        bm->ide_if = NULL;
-        bm->aiocb = NULL;
+       ide_dma_eot(bm);
         return;
     }