@@ -285,8 +285,10 @@ int io_uring_register(unsigned int fd, unsigned int opcode, const void *arg,
unsigned int nr_args);
/*
- * Mapped/registered wait regions
+ * Mapped/registered regions
*/
+int io_uring_register_region(struct io_uring *ring,
+ struct io_uring_mem_region_reg *reg);
struct io_uring_reg_wait *io_uring_setup_reg_wait(struct io_uring *ring,
unsigned nentries, int *err);
void io_uring_free_reg_wait(struct io_uring_reg_wait *reg, unsigned nentries);
@@ -224,4 +224,5 @@ LIBURING_2.9 {
io_uring_free_reg_wait;
io_uring_setup_reg_wait;
io_uring_clone_buffers_offset;
+ io_uring_register_region;
} LIBURING_2.8;
@@ -111,4 +111,5 @@ LIBURING_2.9 {
io_uring_free_reg_wait;
io_uring_setup_reg_wait;
io_uring_clone_buffers_offset;
+ io_uring_register_region;
} LIBURING_2.8;
@@ -324,6 +324,8 @@ int io_uring_submit_and_wait_reg(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr,
unsigned wait_nr, int reg_index)
{
+ unsigned long offset = reg_index * sizeof(struct io_uring_reg_wait);
+
struct get_data data = {
.submit = __io_uring_flush_sq(ring),
.wait_nr = wait_nr,
@@ -331,7 +333,7 @@ int io_uring_submit_and_wait_reg(struct io_uring *ring,
IORING_ENTER_EXT_ARG_REG,
.sz = sizeof(struct io_uring_reg_wait),
.has_ts = true,
- .arg = (void *) (uintptr_t) reg_index,
+ .arg = (void *) (uintptr_t) offset,
};
if (!(ring->features & IORING_FEAT_EXT_ARG))
@@ -470,3 +470,9 @@ int io_uring_register_wait_reg(struct io_uring *ring,
{
return -EINVAL;
}
+
+int io_uring_register_region(struct io_uring *ring,
+ struct io_uring_mem_region_reg *reg)
+{
+ return do_register(ring, IORING_REGISTER_MEM_REGION, reg, 1);
+}
Now the kernel expects a byte offset instead of a struct io_uring_reg_wait index. Also add a helper for registering a region of memory. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> --- src/include/liburing.h | 4 +++- src/liburing-ffi.map | 1 + src/liburing.map | 1 + src/queue.c | 4 +++- src/register.c | 6 ++++++ 5 files changed, 14 insertions(+), 2 deletions(-)