libaio: use INT_MAX to signal that we don't want the ring buffer
[fio.git] / engines / libaio.c
index e4869aa9d6a8648a7dbe9413421019f7b7b83234..bc459da1fcbaf5a310305cc4e4d2b63136c873a8 100644 (file)
@@ -255,11 +255,20 @@ static void fio_libaio_cleanup(struct thread_data *td)
 static int fio_libaio_init(struct thread_data *td)
 {
        struct libaio_data *ld = malloc(sizeof(*ld));
-       int err;
+       struct libaio_options *o = td->eo;
+       int err = 0;
 
        memset(ld, 0, sizeof(*ld));
 
-       err = io_queue_init(td->o.iodepth, &ld->aio_ctx);
+       /*
+        * First try passing in 0 for queue depth, since we don't
+        * care about the user ring. If that fails, the kernel is too old
+        * and we need the right depth.
+        */
+       if (!o->userspace_reap)
+               err = io_queue_init(INT_MAX, &ld->aio_ctx);
+       if (o->userspace_reap || err == -EINVAL)
+               err = io_queue_init(td->o.iodepth, &ld->aio_ctx);
        if (err) {
                td_verror(td, -err, "io_queue_init");
                log_err("fio: check /proc/sys/fs/aio-max-nr\n");