bio_iov_iter_get_pages(9)
π 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. pass0if you have no requirement at all, no pressure πββοΈlen_align_maskβ the mask to align the total size to.0means 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 initer, 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 if0pages could be pinned. like, zero. none. zip. β¨
π SEE ALSO π
Kernel file ./block/bio.c β and her whole friend group ofc π:
bio_reset(9)bio_reuse(9)bio_chain(9)bio_chain_and_submit(9)bio_alloc_bioset(9)bio_kmalloc(9)bio_truncate(9)guard_bio_eod(9)bio_put(9)bio_alloc_clone(9)bio_init_clone(9)bio_full(9)__bio_add_page(9)bio_add_virt_nofail(9)bio_add_page(9)bio_add_folio(9)bio_add_vmalloc_chunk(9)bio_add_vmalloc(9)bio_iov_iter_bounce(9)bio_iov_iter_unbounce(9)bio_await(9)submit_bio_wait(9)bdev_rw_virt(9)bio_copy_data(9)bio_endio(9)bio_split(9)bio_trim(9)bioset_init(9)
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
- 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