bio_truncate(9)
β¨ bio_truncate β the Kernel API Manual (section 9) β¨
okay bestie, welcome to bio_truncate(9) β yes, section 9, the kernel-functions chapter, we love a niche queen π
. This is the one that truncates a bio to a small size. Let's get into it, no cap.
π SYNOPSIS π
void bio_truncate (struct bio *bio , unsigned new_size );
literal function signature, copied exactly, do not come for me π
π¦ ARGUMENTS π¦
bioβ the bio that's getting truncated. it's the main character here, we're literally shrinking it πnew_sizeβ the new size you want the bio truncated to. yes it's just callednew_size, she's straightforward and we respect that π«Ά
πΈ DESCRIPTION πΈ
so the vibe is: truncate the bio down to a new size of new_size. that's the whole job. slay π
but wait β there's a plot twist β¨ if bio_op(bio) is REQ_OP_READ, then you zero out the truncated part. like, the bits you chopped off get filled with zeros. don't skip that step bestie, it's giving "important" π¨
β οΈ fr fr: this function should only be used for handling corner cases, such as bio eod. it is not your everyday go-to. corner cases only, iykyk π
π SEE ALSO π
the whole friend group, all of them, in Kernel file ./block/bio.c:
bio_reset(9)bio_reuse(9)bio_chain(9)bio_chain_and_submit(9)bio_alloc_bioset(9)bio_kmalloc(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_get_pages(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 whole page, bestie!! ππβ¨
this lil beauty lives in ./block and the version/date stamp on it is October 2026 β so mark your calendar, she's from the future and she's iconic for it π₯π. bye bestie, go truncate responsibly π¦π
π¦ 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