bio_iov_iter_get_pages(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– bio_iov_iter_get_pages(9) πŸ’–

okay so bestie, welcome to the Kernel API Manual, and today's main character is bio_iov_iter_get_pages(9) β€” she's the one who feeds pages into a bio. let's get into it ✨


🌸 NAME 🌸

bio_iov_iter_get_pages β€” add user or kernel pages to a bio. that's it, that's the vibe πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

int bio_iov_iter_get_pages (struct bio *bio , struct iov_iter *iter ,
unsigned mem_align_mask , unsigned len_align_mask );

πŸ’… ARGUMENTS πŸ’…

  • bio β€” the bio you're adding pages to. the vessel. the moment. 🫢
  • iter β€” the iov iterator that describes the region we're adding. it's literally the map of where the pages live πŸ—ΊοΈ
  • mem_align_mask β€” the mask that the source address and length must be aligned to. pass 0 if you have no requirement at all, no pressure πŸ’β€β™€οΈ
  • len_align_mask β€” the mask to align the total size to. 0 means any length is fine, we're not picky 🌈

πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea β˜•: this function takes an iterator β€” either one pointing at user memory, or one pointing at kernel pages (that's a BVEC iterator, iykyk).

If we're adding user pages, she pins them and maps them into the kernel. that's the whole gig. and on IO completion, the caller should put those pages β€” don't forget, bestie, that's your job not hers 😭

For bvec based iterators, bio_iov_iter_get_pages uses the provided bvecs rather than copying them. which is a slay, but it comes with strings attached: anyone issuing kiocb based IO needs to ensure the bvecs and pages stay referenced until the submitted I/O is completed by a call to ->ki_complete, or until it returns with an error other than -EIOCBQUEUED. that's the fine print and it is not optional πŸ’€

The caller also needs to check if the bio is flagged BIO_NO_PAGE_REF on IO completion. if it isn't, then pages should be released. literally just check it, it takes two seconds πŸ™ˆ

⚠️ ngl, the function tries β€” but does not guarantee β€” to pin as many pages as fit into the bio, or are requested in iter, whatever is smaller. that's the smaller of the two, okay? If MM encounters an error while pinning the requested pages, it stops. and an error is returned only if 0 pages could be pinned. like, zero. none. zip. ✨

🌟 SEE ALSO 🌟

Kernel file ./block/bio.c β€” and her whole friend group ofc πŸ’œ:


and that's the page!! πŸŽ€ she lives in ./block, dated October 2026, and she's filed under bio_iov_iter_get_pages(9). mwah, go pin some pages responsibly bestie πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from