DOKK / manpages / debian 12 / liburing-dev / io_uring_register_buffers.3.en
io_uring_register_buffers(3) liburing Manual io_uring_register_buffers(3)

io_uring_register_buffers - register buffers for fixed buffer operations

#include <liburing.h>
int io_uring_register_buffers(struct io_uring *ring,
                              const struct iovec *iovecs,
                              unsigned nr_iovecs);
int io_uring_register_buffers_sparse(struct io_uring *ring,
                              unsigned nr_iovecs);

The io_uring_register_buffers(3) function registers nr_iovecs number of buffers defined by the array iovecs belonging to the ring.

The io_uring_register_buffers_sparse(3) function registers nr_iovecs empty buffers belonging to the ring. These buffers must be updated before use, using eg io_uring_register_buffers_update_tag(3).

After the caller has registered the buffers, they can be used with one of the fixed buffers functions.

Registered buffers is an optimization that is useful in conjunction with O_DIRECT reads and writes, where it maps the specified range into the kernel once when the buffer is registered rather than doing a map and unmap for each IO every time IO is performed to that region. Additionally, it also avoids manipulating the page reference counts for each IO.

On success io_uring_register_buffers(3) and io_uring_register_buffers_sparse(3) return 0. On failure they return -errno.

io_uring_get_sqe(3), io_uring_unregister_buffers(3), io_uring_register_buf_ring(3), io_uring_prep_read_fixed(3), io_uring_prep_write_fixed(3)

November 15, 2021 liburing-2.1