io_uring_prep_fadvise(3)

πŸ“¦
version 2.15 Β· 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ io_uring_prep_fadvise ✨

okay bestie, sit down, hydrate, because we're about to prep an fadvise request and it's lowkey the easiest thing in the whole liburing manual. this page lives in the liburing manual, section 3, and it's giving "short and sweet but don't skip a single line" energy πŸ’…


🌸 NAME 🌸

io_uring_prep_fadvise β€” prepare a fadvise request


πŸŽ€ SYNOPSIS πŸŽ€

#include <fcntl.h>
#include <liburing.h>

void io_uring_prep_fadvise(struct io_uring_sqe *sqe,
                           int fd,
                           __u64 offset,
                           __u32 len,
                           int advice);

void io_uring_prep_fadvise64(struct io_uring_sqe *sqe,
                             int fd,
                             __u64 offset,
                             off_t len,
                             int advice);

πŸ¦‹ DESCRIPTION πŸ¦‹

so io_uring_prep_fadvise(3) prepares an fadvise request. that's it, that's the vibe. it sets up the submission queue entry sqe so it'll use the file descriptor that fd points to, kick off an fadvise operation starting at offset and running len bytes long, and hand it the advice sitting in advice. like passing a lil note to the kernel πŸ“

and io_uring_prep_fadvise64(3)? literally the same girl, just with more range β€” she works exactly like io_uring_prep_fadvise(3) except she takes a 64-bit length instead of just a 32-bit one. slay.

⚠️ but bestie, listen: older kernels may not support the 64-bit length variant. if you try to use it on a kernel that doesn't do 64-bit lengths, the request will get errored with -EINVAL in the results field of the CQE. no cap, that's on you 😭

this function prepares an async posix_fadvise(2) request β€” so if you want the actual details, go read that man page, she's the source of truth πŸ’–


πŸ’œ RETURN VALUE πŸ’œ

None. literally nothing. she doesn't return a thing and that's iconic of her 🫢


πŸ”₯ ERRORS πŸ”₯

the CQE res field will contain the result of the operation. see the related man page for details on possible values ✨

and here's the thing to remember β€” where synchronous system calls will return -1 on failure and set errno to the actual error value, io_uring never uses errno. instead it returns the negated errno directly in the CQE res field. periodt. πŸ’…


🌈 SEE ALSO 🌈


and that's the whole page, bestie, we ate and left no crumbs πŸ“ this was liburing-2.2, dated March 13, 2022 β€” go prep some requests, you've got main character energy and the kernel is ready for you πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from