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

Re: [Xen-devel] Windows Bug Check 0x101 issue



Samuel Thibault writes:
> Ian Jackson, le Tue 25 Mar 2008 11:28:32 +0000, a écrit :
> > The other is that the IDE flush necessarily blocks.
> 
> What do you mean by that?  In a real machine, the processor doesn't
> block while the flush is being done, and the OS just expects to see an
> irq some time after.  In that regard his patch should work fine.
> 
> That said it can't be applied as is because of the other points you
> raised, of course.

Anyway, I remade the patch as you point out. Is it enough?

To be honest, I'm skeptical about the necessity of the flush
for a *emulated* IDE disk but shared SCSI disk.

Signed-off-by: Kouya Shimura <kouya@xxxxxxxxxxxxxx>

diff -r e768be7bf561 tools/ioemu/block-qcow.c
--- a/tools/ioemu/block-qcow.c  Thu Mar 20 14:29:09 2008 -0600
+++ b/tools/ioemu/block-qcow.c  Wed Mar 26 14:53:46 2008 +0900
@@ -725,6 +725,13 @@ static void qcow_aio_cancel(BlockDriverA
     qemu_aio_release(acb);
 }
 
+static BlockDriverAIOCB *qcow_aio_flush(BlockDriverState *bs,
+        BlockDriverCompletionFunc *cb, void *opaque)
+{
+    BDRVQcowState *s = bs->opaque;
+    return bdrv_aio_flush(s->hd, cb, opaque);
+}
+
 static void qcow_close(BlockDriverState *bs)
 {
     BDRVQcowState *s = bs->opaque;
@@ -899,6 +906,7 @@ BlockDriver bdrv_qcow = {
     .bdrv_aio_read = qcow_aio_read,
     .bdrv_aio_write = qcow_aio_write,
     .bdrv_aio_cancel = qcow_aio_cancel,
+    .bdrv_aio_flush = qcow_aio_flush,
     .aiocb_size = sizeof(QCowAIOCB),
     .bdrv_write_compressed = qcow_write_compressed,
     .bdrv_get_info = qcow_get_info,
diff -r e768be7bf561 tools/ioemu/block-qcow2.c
--- a/tools/ioemu/block-qcow2.c Thu Mar 20 14:29:09 2008 -0600
+++ b/tools/ioemu/block-qcow2.c Wed Mar 26 14:52:15 2008 +0900
@@ -1005,6 +1005,13 @@ static void qcow_aio_cancel(BlockDriverA
     if (acb->hd_aiocb)
         bdrv_aio_cancel(acb->hd_aiocb);
     qemu_aio_release(acb);
+}
+
+static BlockDriverAIOCB *qcow_aio_flush(BlockDriverState *bs,
+        BlockDriverCompletionFunc *cb, void *opaque)
+{
+    BDRVQcowState *s = bs->opaque;
+    return bdrv_aio_flush(s->hd, cb, opaque);
 }
 
 static void qcow_close(BlockDriverState *bs)
@@ -2235,6 +2242,7 @@ BlockDriver bdrv_qcow2 = {
     .bdrv_aio_read = qcow_aio_read,
     .bdrv_aio_write = qcow_aio_write,
     .bdrv_aio_cancel = qcow_aio_cancel,
+    .bdrv_aio_flush = qcow_aio_flush,
     .aiocb_size = sizeof(QCowAIOCB),
     .bdrv_write_compressed = qcow_write_compressed,
 
diff -r e768be7bf561 tools/ioemu/block-raw.c
--- a/tools/ioemu/block-raw.c   Thu Mar 20 14:29:09 2008 -0600
+++ b/tools/ioemu/block-raw.c   Wed Mar 26 13:53:01 2008 +0900
@@ -496,6 +496,21 @@ static void raw_aio_cancel(BlockDriverAI
         pacb = &acb->next;
     }
 }
+
+static BlockDriverAIOCB *raw_aio_flush(BlockDriverState *bs,
+        BlockDriverCompletionFunc *cb, void *opaque)
+{
+    RawAIOCB *acb;
+
+    acb = raw_aio_setup(bs, 0, NULL, 0, cb, opaque);
+    if (!acb)
+        return NULL;
+    if (aio_fsync(O_SYNC, &acb->aiocb) < 0) {
+        qemu_aio_release(acb);
+        return NULL;
+    }
+    return &acb->common;
+}
 #endif
 
 static void raw_close(BlockDriverState *bs)
@@ -621,6 +636,7 @@ BlockDriver bdrv_raw = {
     .bdrv_aio_read = raw_aio_read,
     .bdrv_aio_write = raw_aio_write,
     .bdrv_aio_cancel = raw_aio_cancel,
+    .bdrv_aio_flush = raw_aio_flush,
     .aiocb_size = sizeof(RawAIOCB),
 #endif
     .protocol_name = "file",
@@ -959,6 +975,7 @@ BlockDriver bdrv_host_device = {
     .bdrv_aio_read = raw_aio_read,
     .bdrv_aio_write = raw_aio_write,
     .bdrv_aio_cancel = raw_aio_cancel,
+    .bdrv_aio_flush = raw_aio_flush,
     .aiocb_size = sizeof(RawAIOCB),
 #endif
     .bdrv_pread = raw_pread,
diff -r e768be7bf561 tools/ioemu/block.c
--- a/tools/ioemu/block.c       Thu Mar 20 14:29:09 2008 -0600
+++ b/tools/ioemu/block.c       Wed Mar 26 14:39:15 2008 +0900
@@ -1138,6 +1138,19 @@ void bdrv_aio_cancel(BlockDriverAIOCB *a
     drv->bdrv_aio_cancel(acb);
 }
 
+BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs, 
+                                 BlockDriverCompletionFunc *cb, void *opaque)
+{
+    BlockDriver *drv = bs->drv;
+
+    if (!drv)
+        return NULL;
+    if (!drv->bdrv_aio_flush)
+        return NULL;
+
+    return drv->bdrv_aio_flush(bs, cb, opaque);
+}
+
 
 /**************************************************************/
 /* async block device emulation */
diff -r e768be7bf561 tools/ioemu/block_int.h
--- a/tools/ioemu/block_int.h   Thu Mar 20 14:29:09 2008 -0600
+++ b/tools/ioemu/block_int.h   Wed Mar 26 13:53:01 2008 +0900
@@ -49,6 +49,8 @@ struct BlockDriver {
         int64_t sector_num, const uint8_t *buf, int nb_sectors,
         BlockDriverCompletionFunc *cb, void *opaque);
     void (*bdrv_aio_cancel)(BlockDriverAIOCB *acb);
+    BlockDriverAIOCB *(*bdrv_aio_flush)(BlockDriverState *bs,
+        BlockDriverCompletionFunc *cb, void *opaque);
     int aiocb_size;
 
     const char *protocol_name;
diff -r e768be7bf561 tools/ioemu/hw/ide.c
--- a/tools/ioemu/hw/ide.c      Thu Mar 20 14:29:09 2008 -0600
+++ b/tools/ioemu/hw/ide.c      Wed Mar 26 14:36:24 2008 +0900
@@ -1070,6 +1070,14 @@ static void ide_sector_write_dma(IDEStat
     s->io_buffer_index = 0;
     s->io_buffer_size = 0;
     ide_dma_start(s, ide_write_dma_cb);
+}
+
+static void ide_flush_cb(void *opaque, int ret)
+{
+    IDEState *s = opaque;
+
+    s->status = READY_STAT;
+    ide_set_irq(s);
 }
 
 static void ide_atapi_cmd_ok(IDEState *s)
@@ -1976,9 +1984,14 @@ static void ide_ioport_write(void *opaqu
             break;
         case WIN_FLUSH_CACHE:
         case WIN_FLUSH_CACHE_EXT:
-            if (s->bs)
+            if (s->bs) {
+                if (bdrv_aio_flush(s->bs, ide_flush_cb, s) != NULL) {
+                    s->status = BUSY_STAT;
+                    break;
+                }
                 bdrv_flush(s->bs);
-           s->status = READY_STAT;
+            }
+            s->status = READY_STAT;
             ide_set_irq(s);
             break;
         case WIN_IDLEIMMEDIATE:
diff -r e768be7bf561 tools/ioemu/vl.h
--- a/tools/ioemu/vl.h  Thu Mar 20 14:29:09 2008 -0600
+++ b/tools/ioemu/vl.h  Wed Mar 26 13:53:01 2008 +0900
@@ -653,6 +653,8 @@ BlockDriverAIOCB *bdrv_aio_write(BlockDr
                                  const uint8_t *buf, int nb_sectors,
                                  BlockDriverCompletionFunc *cb, void *opaque);
 void bdrv_aio_cancel(BlockDriverAIOCB *acb);
+BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs, 
+                                 BlockDriverCompletionFunc *cb, void *opaque);
 
 void qemu_aio_init(void);
 void qemu_aio_poll(void);
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.