io_uring_prep_writev_fixed(3)

πŸ“¦
version 2.15 Β· 2 versions
, in arch rolling, ubuntu stonking

✨ 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 of iovec's with a size_t number of bytes each, this function can transfer at most INT_MAX bytes per call (that's the max for the underlying syscall interface). so don't go feral with the buffer sizes, bestie πŸ’€

🌈 SEE ALSO 🌈


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