netfs_buffered_read_iter(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 sec
  • iter β€” 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 0 if IOCB_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