rbd: add queuing delay
diff mbox

Message ID 20100620204426.GA7139@chb-desktop
State New, archived
Headers show

Commit Message

Christian Brunner June 20, 2010, 8:44 p.m. UTC
None

Patch
diff mbox

diff --git a/block/rbd.c b/block/rbd.c
index 74589cb..241b0c6 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -47,6 +47,14 @@ 
 
 #define OBJ_MAX_SIZE (1UL << OBJ_DEFAULT_OBJ_ORDER)
 
+/*
+ * For best performance MAX_RADOS_REQS should be at least as large as the 
+ * number of osds. It may be larger, but if to high you may experience lagging
+ *
+ * XXX: automatically set to 2*max_osd ???
+ */
+#define MAX_RADOS_REQS 16
+
 typedef struct RBDAIOCB {
     BlockDriverAIOCB common;
     QEMUBH *bh;
@@ -507,6 +515,11 @@  static BlockDriverAIOCB *rbd_aio_rw_vector(BlockDriverState *bs,
         rcb->segsize = segsize;
         rcb->buf = buf;
 
+        /* delay rados aio requests when the queue is getting to large */
+        while ((segnr - last_segnr + acb->aiocnt) > MAX_RADOS_REQS) {
+		usleep(100);
+	}
+
         if (write) {
             rados_aio_create_completion(rcb, NULL,
                                         (rados_callback_t) rbd_finish_aiocb,