io_uring_prep_writev_fixed(3)
β¨ io_uring_prep_writev_fixed π
okay so bestie, this one lives in the liburing Manual, and it's giving "I write a bunch of little buffers to a file and I do it with PRE-REGISTERED buffer energy" π¦ no cap. Let's get into it.
πΈ NAME πΈ
io_uring_prep_writev_fixed β prepare a vectored write using fixed buffers π
π SYNOPSIS π
#include <liburing.h>
void io_uring_prep_writev_fixed(struct io_uring_sqe *sqe,
int fd,
const struct iovec *iovecs,
unsigned nr_vecs,
__u64 offset,
int flags,
int buf_index);
π DESCRIPTION π
so io_uring_prep_writev_fixed(3) sets up a vectored write request that uses fixed (registered) buffers. slay.
The submission queue entry sqe gets set up to use the file descriptor fd to start writing nr_vecs iovecs from the file position offset. literally that's the whole vibe.
The iovecs argument points to an array of iovec structures describing the write buffers. and here's the catch bestie β all of those buffers must be part of the registered buffer set at index buf_index, which you registered earlier with io_uring_register_buffers(3). no registering, no writing. periodt.
The flags argument can hold any per-request flags, like RWF_APPEND or whatever other flags pwritev2(2) supports. so cute, so flexible β¨
Why would you even do this? Because using fixed buffers avoids the overhead of mapping buffers for every single I/O operation, which is a big performance glow-up for apps that reuse the same buffers over and over. main character optimization energy fr fr π₯
π RETURN VALUE π
None. that's it. it just sets up the sqe and dips π«Ά
π ERRORS π
The CQE res field will contain the result of the operation β the number of bytes written on success. and on error? a negative errno value comes back. classic.
β NOTES β
despite accepting an array ofiovec's with asize_tnumber of bytes each, this function can transfer at mostINT_MAXbytes per call (that's the max for the underlying syscall interface). so don't go feral with the buffer sizes, bestie π
π SEE ALSO π
io_uring_get_sqe(3)io_uring_submit(3)io_uring_prep_writev(3)io_uring_prep_writev2(3)io_uring_prep_write_fixed(3)io_uring_prep_readv_fixed(3)io_uring_register_buffers(3)
and that's the whole thing, angel π§ this cutie is liburing-2.10, dated January 18, 2025, and it ate. go register those buffers and write something iconic πβ¨
π¦ 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