From e65ef9593436f0f62df366f506f7c4d318b5cd71 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 21 Nov 2018 05:53:38 -0700 Subject: [PATCH] engines/libaio: fallback to old io_setup() system call 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 Signed-off-by: Jens Axboe --- engines/libaio.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/engines/libaio.c b/engines/libaio.c index bae141ca..991d588d 100644 --- a/engines/libaio.c +++ b/engines/libaio.c @@ -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 } -- 2.25.1