netfs_buffered_read_iter(9)
β¨ netfs_buffered_read_iter β¨
okay so bestie, welcome to the Kernel API Manual π you're about to meet the read function that literally every page-cache-using filesystem relies on, no cap.
π NAME π
netfs_buffered_read_iter β the filesystem buffered I/O read routine. that's it, that's the whole vibe check β¨
πΈ SYNOPSIS πΈ
ssize_t netfs_buffered_read_iter (struct kiocb *iocb , struct iov_iter *iter );
π¦ ARGUMENTS π¦
iocbβ the kernel I/O control block π it's giving "main character", it carries the flags we're gonna be obsessed with in a seciterβ the destination for the data read π₯ that's where the bytes go, periodt
π DESCRIPTION π
so this right here is the ->read_iter routine for all filesystems that can use the page cache directly. like, every single one. iconic behavior fr fr π
now, the flags, because this is where it gets juicy π
The IOCB_NOWAIT flag in iocb->ki_flags means -EAGAIN shall be returned when no data can be read without waiting for I/O requests to complete. but β and this is the important part, don't skip it β it doesn't prevent readahead. she still readaheads. she's multitasking π
The IOCB_NOIO flag in iocb->ki_flags means no new I/O requests shall be made for the read or for readahead. none. zero. π« When no data can be read, -EAGAIN shall be returned. And when readahead would be triggered? you get a partial, possibly empty read back. like, that's just how it is bestie π«Ά
β both of these flags live in iocb->ki_flags, so check there before you start drama π
π₯ RETURN π₯
- number of bytes copied, even for partial reads π (yes, partial counts, she did her best)
- negative error code (or
0ifIOCB_NOIO) if nothing was read π
π SEE ALSO π
Kernel file ./fs/netfs/buffered_read.c, plus these baddies:
π that's the whole page bestie, ily, go read some bytes π
this lil masterpiece lives in ./fs/netfs, is dated October 2026, and answers to the name netfs_buffered_read_iter(9) β mwah, signing off π§β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms