diff --git a/src/include/liburing.h b/src/include/liburing.h index cbba6ebcb..bd845cf84 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -201,7 +201,7 @@ int io_uring_submit_and_wait_reg(struct io_uring *ring, int arg_index); int io_uring_register_cqwait_reg(struct io_uring *ring, - struct io_uring_reg_wait *arg, int nr); + struct io_uring_reg_wait *reg, int nr); int io_uring_resize_rings(struct io_uring *ring, struct io_uring_params *p); int io_uring_clone_buffers(struct io_uring *dst, struct io_uring *src); int io_uring_register_buffers(struct io_uring *ring, const struct iovec *iovecs, diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h index b73deaf45..654567dfa 100644 --- a/src/include/liburing/io_uring.h +++ b/src/include/liburing/io_uring.h @@ -804,6 +804,26 @@ enum { IORING_REG_WAIT_TS = (1U << 0), }; +/* + * Argument for IORING_REGISTER_CQWAIT_REG, registering a region of + * struct io_uring_reg_wait that can be indexed when io_uring_enter(2) is + * called rather than pass in a wait argument structure separately. + */ +struct io_uring_cqwait_reg_arg { + __u32 flags; + __u32 struct_size; + __u32 nr_entries; + __u32 pad; + __u64 user_addr; + __u64 pad2[3]; +}; + +/* + * Argument for io_uring_enter(2) with + * IORING_GETEVENTS | IORING_ENTER_EXT_ARG_REG set, where the actual argument + * is an index into a previously registered fixed wait region described by + * the below structure. + */ struct io_uring_reg_wait { struct __kernel_timespec ts; __u32 min_wait_usec; @@ -814,6 +834,9 @@ struct io_uring_reg_wait { __u64 pad2[2]; }; +/* + * Argument for io_uring_enter(2) with IORING_GETEVENTS | IORING_ENTER_EXT_ARG + */ struct io_uring_getevents_arg { __u64 sigmask; __u32 sigmask_sz; diff --git a/src/register.c b/src/register.c index b24590371..6e9bc8857 100644 --- a/src/register.c +++ b/src/register.c @@ -454,7 +454,14 @@ int io_uring_resize_rings(struct io_uring *ring, struct io_uring_params *p) } int io_uring_register_cqwait_reg(struct io_uring *ring, - struct io_uring_reg_wait *arg, int nr) + struct io_uring_reg_wait *reg, int nr) { - return do_register(ring, IORING_REGISTER_CQWAIT_REG, arg, nr); + struct io_uring_cqwait_reg_arg arg = { + .flags = 0, + .struct_size = sizeof(*reg), + .nr_entries = nr, + .user_addr = (unsigned long) (uintptr_t) reg, + }; + + return do_register(ring, IORING_REGISTER_CQWAIT_REG, &arg, 1); }