engines/libaio: update to new io_setup2() system call
authorJens Axboe <axboe@kernel.dk>
Mon, 19 Nov 2018 23:11:56 +0000 (16:11 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 19 Nov 2018 23:11:56 +0000 (16:11 -0700)
We need that to enable polling.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
arch/arch-x86_64.h
engines/libaio.c

index 484ea0c5b8eb82ba892a1676b100131bf13a8635..6361d52f6482ac0e3e2d32f9e754f8ac6d61448d 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef ARCH_X86_64_H
 #define ARCH_X86_64_H
 
 #ifndef ARCH_X86_64_H
 #define ARCH_X86_64_H
 
+#ifndef __NR_sys_iosetup2
+#define __NR_sys_iosetup2      335
+#endif
+
 static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
                            unsigned int *ecx, unsigned int *edx)
 {
 static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
                            unsigned int *ecx, unsigned int *edx)
 {
index dc664627be73093e5357d13acb9df0a695d5bebc..da7f0c3ee7555bc4ef08bee90e405e0c4dd90acf 100644 (file)
@@ -16,6 +16,9 @@
 #ifndef IOCB_FLAG_HIPRI
 #define IOCB_FLAG_HIPRI        (1 << 2)
 #endif
 #ifndef IOCB_FLAG_HIPRI
 #define IOCB_FLAG_HIPRI        (1 << 2)
 #endif
+#ifndef IOCTX_FLAG_IOPOLL
+#define IOCTX_FLAG_IOPOLL      (1 << 0)
+#endif
 
 static int fio_libaio_commit(struct thread_data *td);
 
 
 static int fio_libaio_commit(struct thread_data *td);
 
@@ -354,6 +357,25 @@ static void fio_libaio_cleanup(struct thread_data *td)
        }
 }
 
        }
 }
 
+static int fio_libaio_queue_init(struct libaio_data *ld, unsigned int depth,
+                                bool hipri)
+{
+#ifdef __NR_sys_io_setup2
+       int err, flags = 0;
+
+       if (hipri)
+               flags = IOCTX_FLAG_IOPOLL;
+
+       return syscall(__NR_sys_io_setup2, depth, flags, &ld->aio_ctx);
+#else
+       if (hipri) {
+               log_err("fio: polled aio not available on your platform\n");
+               return 1;
+       }
+       return io_queue_init(depth, &ld->aio_ctx);
+#endif
+}
+
 static int fio_libaio_init(struct thread_data *td)
 {
        struct libaio_options *o = td->eo;
 static int fio_libaio_init(struct thread_data *td)
 {
        struct libaio_options *o = td->eo;
@@ -368,9 +390,9 @@ static int fio_libaio_init(struct thread_data *td)
         * and we need the right depth.
         */
        if (!o->userspace_reap)
         * and we need the right depth.
         */
        if (!o->userspace_reap)
-               err = io_queue_init(INT_MAX, &ld->aio_ctx);
+               err = fio_libaio_queue_init(ld, INT_MAX, o->hipri);
        if (o->userspace_reap || err == -EINVAL)
        if (o->userspace_reap || err == -EINVAL)
-               err = io_queue_init(td->o.iodepth, &ld->aio_ctx);
+               err = fio_libaio_queue_init(ld, td->o.iodepth, o->hipri);
        if (err) {
                td_verror(td, -err, "io_queue_init");
                log_err("fio: check /proc/sys/fs/aio-max-nr\n");
        if (err) {
                td_verror(td, -err, "io_queue_init");
                log_err("fio: check /proc/sys/fs/aio-max-nr\n");