2008-09-25 01:20:56 +02:00
|
|
|
Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c
|
2008-07-19 01:04:37 +02:00
|
|
|
===================================================================
|
2008-09-25 01:20:56 +02:00
|
|
|
--- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/xen_blktap.c
|
|
|
|
+++ xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c
|
2008-08-18 00:24:29 +02:00
|
|
|
@@ -357,6 +357,15 @@ static void qemu_send_responses(void* op
|
2008-07-19 01:04:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
+ * Callback function for AIO flush
|
|
|
|
+ */
|
|
|
|
+static void qemu_flush_response(void* opaque, int ret) {
|
|
|
|
+ if (ret != 0) {
|
|
|
|
+ DPRINTF("aio_flush: ret = %d (%s)\n", ret, strerror(-ret));
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
* Callback function for the IO message pipe. Reads requests from the ring
|
|
|
|
* and processes them (call qemu read/write functions).
|
|
|
|
*
|
2008-08-18 00:24:29 +02:00
|
|
|
@@ -375,6 +384,7 @@ static void handle_blktap_iomsg(void* pr
|
2008-07-19 01:04:37 +02:00
|
|
|
blkif_t *blkif = s->blkif;
|
|
|
|
tapdev_info_t *info = s->ring_info;
|
|
|
|
int page_size = getpagesize();
|
|
|
|
+ int sync;
|
|
|
|
|
|
|
|
struct aiocb_info *aiocb_info;
|
|
|
|
|
2008-08-18 00:24:29 +02:00
|
|
|
@@ -407,7 +417,7 @@ static void handle_blktap_iomsg(void* pr
|
2008-07-19 01:04:37 +02:00
|
|
|
|
|
|
|
/* Don't allow writes on readonly devices */
|
|
|
|
if ((s->flags & TD_RDONLY) &&
|
|
|
|
- (req->operation == BLKIF_OP_WRITE)) {
|
|
|
|
+ (req->operation != BLKIF_OP_READ)) {
|
|
|
|
blkif->pending_list[idx].status = BLKIF_RSP_ERROR;
|
|
|
|
goto send_response;
|
|
|
|
}
|
2008-08-18 00:24:29 +02:00
|
|
|
@@ -428,7 +438,7 @@ static void handle_blktap_iomsg(void* pr
|
2008-07-19 01:04:37 +02:00
|
|
|
DPRINTF("Sector request failed:\n");
|
|
|
|
DPRINTF("%s request, idx [%d,%d] size [%llu], "
|
|
|
|
"sector [%llu,%llu]\n",
|
|
|
|
- (req->operation == BLKIF_OP_WRITE ?
|
|
|
|
+ (req->operation != BLKIF_OP_READ ?
|
|
|
|
"WRITE" : "READ"),
|
|
|
|
idx,i,
|
|
|
|
(long long unsigned)
|
2008-08-18 00:24:29 +02:00
|
|
|
@@ -441,8 +451,14 @@ static void handle_blktap_iomsg(void* pr
|
2008-07-19 01:04:37 +02:00
|
|
|
|
|
|
|
blkif->pending_list[idx].secs_pending += nsects;
|
|
|
|
|
|
|
|
- switch (req->operation)
|
|
|
|
+ sync = 0;
|
|
|
|
+ switch (req->operation)
|
|
|
|
{
|
|
|
|
+ case BLKIF_OP_WRITE_BARRIER:
|
|
|
|
+ sync = 1;
|
|
|
|
+ bdrv_aio_flush(s->bs, qemu_flush_response, NULL);
|
|
|
|
+ /* fall through */
|
|
|
|
+
|
|
|
|
case BLKIF_OP_WRITE:
|
|
|
|
aiocb_info = malloc(sizeof(*aiocb_info));
|
|
|
|
|
2008-08-18 00:24:29 +02:00
|
|
|
@@ -462,6 +478,10 @@ static void handle_blktap_iomsg(void* pr
|
2008-07-19 01:04:37 +02:00
|
|
|
DPRINTF("ERROR: bdrv_write() == NULL\n");
|
|
|
|
goto send_response;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ if (sync)
|
|
|
|
+ bdrv_aio_flush(s->bs, qemu_flush_response, NULL);
|
|
|
|
+
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLKIF_OP_READ:
|