+static int fio_libaio_old_queue_init(struct libaio_data *ld, unsigned int depth,
+ bool hipri, bool useriocb, bool fixedbufs)
+{
+ if (hipri) {
+ log_err("fio: polled aio not available on your platform\n");
+ return 1;
+ }
+ if (useriocb) {
+ log_err("fio: user mapped iocbs not available on your platform\n");
+ return 1;
+ }
+ if (fixedbufs) {
+ log_err("fio: fixed buffers not available on your platform\n");
+ return 1;
+ }
+
+ 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, bool fixedbufs)
+{
+#ifdef __NR_sys_io_setup2
+ int ret, flags = 0;
+
+ if (hipri)
+ flags |= IOCTX_FLAG_IOPOLL;
+ if (useriocb)
+ flags |= IOCTX_FLAG_USERIOCB;
+ if (fixedbufs) {
+ struct rlimit rlim = {
+ .rlim_cur = RLIM_INFINITY,
+ .rlim_max = RLIM_INFINITY,
+ };
+
+ setrlimit(RLIMIT_MEMLOCK, &rlim);
+ flags |= IOCTX_FLAG_FIXEDBUFS;
+ }
+
+ ret = syscall(__NR_sys_io_setup2, depth, flags, ld->user_iocbs,
+ NULL, NULL, &ld->aio_ctx);
+ if (!ret)
+ return 0;
+ /* fall through to old syscall */
+#endif
+ return fio_libaio_old_queue_init(ld, depth, hipri, useriocb, fixedbufs);
+}
+
+static int fio_libaio_post_init(struct thread_data *td)