engines/libaio: fallback to old io_setup() system call
authorJens Axboe <axboe@kernel.dk>
Wed, 21 Nov 2018 12:53:38 +0000 (05:53 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 21 Nov 2018 12:53:38 +0000 (05:53 -0700)
We can't rely on the new one being there, if we fail calling
io_setup2(), fallback to io_setup() like before.

Fixes: a1b006fe1cd3 ("engines/libaio: fix new aio poll API")
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
engines/libaio.c

index bae141cabdd1bf57e974c1348fb5ab114e1da76d..991d588d2c8afda0de24c1f5ef475c67a57c68d3 100644 (file)
@@ -393,19 +393,9 @@ static void fio_libaio_cleanup(struct thread_data *td)
        }
 }
 
-static int fio_libaio_queue_init(struct libaio_data *ld, unsigned int depth,
-                                bool hipri, bool useriocb)
+static int fio_libaio_old_queue_init(struct libaio_data *ld, unsigned int depth,
+                                    bool hipri, bool useriocb)
 {
-#ifdef __NR_sys_io_setup2
-       int flags = 0;
-
-       if (hipri)
-               flags |= IOCTX_FLAG_IOPOLL;
-       if (useriocb)
-               flags |= IOCTX_FLAG_USERIOCB;
-
-       return syscall(__NR_sys_io_setup2, depth, flags, ld->user_iocbs, &ld->aio_ctx);
-#else
        if (hipri) {
                log_err("fio: polled aio not available on your platform\n");
                return 1;
@@ -416,6 +406,27 @@ static int fio_libaio_queue_init(struct libaio_data *ld, unsigned int depth,
        }
 
        return io_queue_init(depth, &ld->aio_ctx);
+}
+
+static int fio_libaio_queue_init(struct libaio_data *ld, unsigned int depth,
+                                bool hipri, bool useriocb)
+{
+#ifdef __NR_sys_io_setup2
+       int ret, flags = 0;
+
+       if (hipri)
+               flags |= IOCTX_FLAG_IOPOLL;
+       if (useriocb)
+               flags |= IOCTX_FLAG_USERIOCB;
+
+       ret = syscall(__NR_sys_io_setup2, depth, flags, ld->user_iocbs,
+                       &ld->aio_ctx);
+       if (!ret)
+               return 0;
+
+       return fio_libaio_old_queue_init(ld, depth, hipri, useriocb);
+#else
+       return fio_libaio_old_queue_init(ld, depth, hipri, useriocb);
 #endif
 }