@@ -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,