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

[Xen-devel] [PATCH] minios: add a blkfront synchronous interface



minios: add a blkfront synchronous interface

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>

diff -r 5603534c62f9 extras/mini-os/blkfront.c
--- a/extras/mini-os/blkfront.c Tue Jun 03 09:41:19 2008 +0100
+++ b/extras/mini-os/blkfront.c Thu Jun 05 11:53:58 2008 +0100
@@ -323,14 +323,33 @@
     if(notify) notify_remote_via_evtchn(dev->evtchn);
 }
 
-void blkfront_aio_write(struct blkfront_aiocb *aiocbp)
+static void blkfront_aio_cb(struct blkfront_aiocb *aiocbp, int ret)
 {
-    blkfront_aio(aiocbp, 1);
+    aiocbp->data = (void*) 1;
 }
 
-void blkfront_aio_read(struct blkfront_aiocb *aiocbp)
+void blkfront_io(struct blkfront_aiocb *aiocbp, int write)
 {
-    blkfront_aio(aiocbp, 0);
+    unsigned long flags;
+    ASSERT(!aiocbp->aio_cb);
+    aiocbp->aio_cb = blkfront_aio_cb;
+    blkfront_aio(aiocbp, write);
+    aiocbp->data = NULL;
+
+    local_irq_save(flags);
+    DEFINE_WAIT(w);
+    while (1) {
+       blkfront_aio_poll(aiocbp->aio_dev);
+       if (aiocbp->data)
+           break;
+
+       add_waiter(w, blkfront_queue);
+       local_irq_restore(flags);
+       schedule();
+       local_irq_save(flags);
+    }
+    remove_waiter(w);
+    local_irq_restore(flags);
 }
 
 static void blkfront_push_operation(struct blkfront_dev *dev, uint8_t op, 
uint64_t id)
--- a/extras/mini-os/include/blkfront.h Tue Jun 03 09:41:19 2008 +0100
+++ b/extras/mini-os/include/blkfront.h Thu Jun 05 11:53:58 2008 +0100
@@ -29,8 +29,11 @@
 int blkfront_open(struct blkfront_dev *dev);
 #endif
 void blkfront_aio(struct blkfront_aiocb *aiocbp, int write);
-void blkfront_aio_read(struct blkfront_aiocb *aiocbp);
-void blkfront_aio_write(struct blkfront_aiocb *aiocbp);
+#define blkfront_aio_read(aiocbp) blkfront_aio(aiocbp, 0)
+#define blkfront_aio_write(aiocbp) blkfront_aio(aiocbp, 1)
+void blkfront_io(struct blkfront_aiocb *aiocbp, int write);
+#define blkfront_read(aiocbp) blkfront_io(aiocbp, 0)
+#define blkfront_write(aiocbp) blkfront_io(aiocbp, 1)
 void blkfront_aio_push_operation(struct blkfront_aiocb *aiocbp, uint8_t op);
 int blkfront_aio_poll(struct blkfront_dev *dev);
 void blkfront_sync(struct blkfront_dev *dev);

_______________________________________________
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®.