From 820914103ca55c0eb7ecf6f458f18cb7989f439e Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Fri, 23 Mar 2012 11:39:51 +0000 Subject: [PATCH 1/2] xen_disk: open disk with BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_NATIVE_AIO Signed-off-by: Stefano Stabellini --- hw/xen_disk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/xen_disk.c b/hw/xen_disk.c index 68fa36a1cf..0f265a4baa 100644 --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -584,10 +584,10 @@ static int blk_init(struct XenDevice *xendev) } /* read-only ? */ + qflags = BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_NATIVE_AIO; if (strcmp(blkdev->mode, "w") == 0) { - qflags = BDRV_O_RDWR; + qflags |= BDRV_O_RDWR; } else { - qflags = 0; info |= VDISK_READONLY; } From d56de074698662b102a1901e3bae425f8e4945bf Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Fri, 23 Mar 2012 11:37:25 +0000 Subject: [PATCH 2/2] xen_disk: when using AIO flush after the operation is completed If ioreq->postsync call bdrv_flush when the AIO operation is actually completed. Signed-off-by: Stefano Stabellini --- hw/xen_disk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/xen_disk.c b/hw/xen_disk.c index 0f265a4baa..9cb0253719 100644 --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -330,6 +330,9 @@ static void qemu_aio_complete(void *opaque, int ret) if (ioreq->aio_inflight > 0) { return; } + if (ioreq->postsync) { + bdrv_flush(ioreq->blkdev->bs); + } ioreq->status = ioreq->aio_errors ? BLKIF_RSP_ERROR : BLKIF_RSP_OKAY; ioreq_unmap(ioreq); @@ -376,9 +379,6 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq) goto err; } - if (ioreq->postsync) { - bdrv_flush(blkdev->bs); /* FIXME: aio_flush() ??? */ - } qemu_aio_complete(ioreq, 0); return 0;