Keir Fraser writes:
> However in this case I guess the IDE/SCSI device model could allow
> asynchronous reporting of flush completion to the guest, and this new aspect
> of the device model would obviously tie into your patch, being done on
> aio_fsync_cb().
Here is a revised patch. Is this a good fix?
I'm not an expert on the SCSI. So please excuse
the SCSI side is not implemented yet.
(I tried but it doesn't work well)
Thanks,
Kouya
Signed-off-by: Kouya Shimura <kouya@xxxxxxxxxxxxxx>
diff -r 76c9cf11ce23 tools/ioemu/block-raw.c
--- a/tools/ioemu/block-raw.c Fri Mar 21 09:45:34 2008 +0000
+++ b/tools/ioemu/block-raw.c Tue Mar 25 19:40:42 2008 +0900
@@ -606,6 +606,18 @@ static void raw_flush(BlockDriverState *
fsync(s->fd);
}
+void bdrv_aio_flush(BlockDriverState *bs,
+ BlockDriverCompletionFunc *cb, void *opaque)
+{
+ RawAIOCB *acb;
+
+ acb = raw_aio_setup(bs, 0, NULL, 0, cb, opaque);
+ if (!acb)
+ return;
+ if (aio_fsync(O_SYNC, &acb->aiocb) < 0)
+ qemu_aio_release(acb);
+}
+
BlockDriver bdrv_raw = {
"raw",
sizeof(BDRVRawState),
diff -r 76c9cf11ce23 tools/ioemu/hw/ide.c
--- a/tools/ioemu/hw/ide.c Fri Mar 21 09:45:34 2008 +0000
+++ b/tools/ioemu/hw/ide.c Tue Mar 25 19:40:42 2008 +0900
@@ -1738,6 +1738,13 @@ static void ide_clear_hob(IDEState *ide_
ide_if[1].select &= ~(1 << 7);
}
+static void ide_flush_cb(void *opaque, int ret)
+{
+ IDEState *s = (IDEState *)opaque;
+ s->status = READY_STAT;
+ ide_set_irq(s);
+}
+
static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
{
IDEState *ide_if = opaque;
@@ -1976,10 +1983,13 @@ static void ide_ioport_write(void *opaqu
break;
case WIN_FLUSH_CACHE:
case WIN_FLUSH_CACHE_EXT:
- if (s->bs)
- bdrv_flush(s->bs);
- s->status = READY_STAT;
- ide_set_irq(s);
+ if (s->bs) {
+ bdrv_aio_flush(s->bs, ide_flush_cb, s);
+ s->status = BUSY_STAT;
+ } else {
+ s->status = READY_STAT;
+ ide_set_irq(s);
+ }
break;
case WIN_IDLEIMMEDIATE:
case WIN_STANDBY:
diff -r 76c9cf11ce23 tools/ioemu/vl.h
--- a/tools/ioemu/vl.h Fri Mar 21 09:45:34 2008 +0000
+++ b/tools/ioemu/vl.h Tue Mar 25 19:40:42 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);
+void 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
|