Skip to contentSkip to conversation

xen_disk: use NATIVE_AIO and NOCACHE

PATCH New Stefano Stabellini 1 participant 3 messages Mar 23, 2012

lore
Share & tools
lore
#0 lore raw

cover xen_disk: use NATIVE_AIO and NOCACHE

Hi all,
this small patch series allows xen_disk to be used correctly with NATIVE_AIO and O_DIRECT.

This series should be backported to the stable branch too.

Stefano Stabellini (2):
xen_disk: open disk with BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_NATIVE_AIO
xen_disk: when using AIO flush after the operation is completed

 hw/xen_disk.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

git://xenbits.xen.org/people/sstabellini/qemu-dm.git disk_io

Cheers,

Stefano

#1 lore raw

PATCH 1/2 xen_disk: open disk with BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_NATIVE_AIO

---
 hw/xen_disk.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/xen_disk.c +2 -2
index 68fa36a..0f265a4 100644
@@ -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;
     }
 
Signature · 1 line
1.7.2.5
#2 lore raw

PATCH 2/2 xen_disk: when using AIO flush after the operation is completed

In reply to Stefano Stabellini

If ioreq->postsync call bdrv_flush when the AIO operation is actually completed.

---
 hw/xen_disk.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
hw/xen_disk.c +3 -3
index 0f265a4..9cb0253 100644
@@ -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;
Signature · 1 line
1.7.2.5