io_uring_prep_readv_fixed(3)
β¨ io_uring_prep_readv_fixed β¨
okay bestie, gather round, because today we're prepping a vectored read using fixed buffers and honestly? it's giving efficiency π
πΈ SYNOPSIS πΈ
#include <liburing.h>
void io_uring_prep_readv_fixed(struct io_uring_sqe *sqe,
int fd,
const struct iovec *iovecs,
unsigned nr_vecs,
__u64 offset,
int flags,
int buf_index);
π DESCRIPTION π
so like. the io_uring_prep_readv_fixed(3) function gets a vectored read request all dressed and ready, and it does it using fixed (registered) buffers π. your submission queue entry, sqe, gets set up to use the file descriptor fd and start reading nr_vecs iovecs starting from the file position offset. no cap.
the iovecs argument points at an array of iovec structures that describe the read buffers π¦. and here's the thing β all those buffers have to be part of the registered buffer set at index buf_index, the one you already registered earlier with io_uring_register_buffers(3). like, they gotta be in the club already, yk? π₯
the flags argument can hold any per-request flags, stuff like RWF_NOWAIT or any other flags that preadv2(2) supports β¨.
and the whole point of using fixed buffers? it skips the overhead of mapping your buffers for every single I/O operation, so apps that keep reusing the same buffers get a nice performance glow-up π. iconic behavior, honestly.
π«Ά RETURN VALUE π«Ά
None. that's it, that's the whole section. it returns nothing. π
π ERRORS π
the CQE res field is where the actual result lives, bestie. on success it holds the number of bytes read β. on error, you get a negative errno value back. so always check it, fr fr.
π§ NOTES π§
ok so lowkey important detail here π: this function accepts an array of iovec's where each one has a size_t number of bytes, BUT the io_uring_cqe's result code is an __s32 value. so in theory, a short read with a big enough iov_len value could produce an ambiguous return π.
but plot twist β the number of bytes actually transferred has the same limit as read(2), so this cannot happen in practice π. crisis averted, breathe.
π SEE ALSO π
io_uring_get_sqe(3)io_uring_submit(3)io_uring_prep_readv(3)io_uring_prep_readv2(3)io_uring_prep_read_fixed(3)io_uring_prep_writev_fixed(3)io_uring_register_buffers(3)
and that's the whole page, bestie!! this one's from the liburing-2.10 era, dated January 18, 2025 β go forth and register those buffers, you absolute main character πβ¨
π¦ where this page comes from
- arch rolling: liburing 2.15-1 Β· GPL-2.0-only WITH Linux-syscall-note OR MIT AND LGPL-2.0-or-later AND MIT
- ubuntu stonking: liburing-dev 2.15-1
- π the page's license: LGPL-2.0-or-later
- Copyright (C) 2025 Jens Axboe <axboe@kernel.dk>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms