bio_alloc_clone(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… bio_alloc_clone β€” Kernel API Manual, section 9

okay so bestie, welcome to bio_alloc_clone(9) from the Kernel API Manual (yes, section 9, we're in kernel-dev territory now πŸŽ€). This is the one where you make a brand-new bio that's a total clone of another one and they share the same biovec situation. It's giving "twins but they share a closet" energy. Let's get into it ✨


✨ SYNOPSIS ✨

struct bio * bio_alloc_clone (struct block_device *bdev , struct bio
*bio_src , gfp_t gfp , struct bio_set *bs );

literally one function call, four arguments, and a struct bio * coming back at you 🫢


🌸 ARGUMENTS 🌸

  • bdev β€” the block_device you're cloning onto. this is the destination vibe πŸ¦‹
  • bio_src β€” the bio you're cloning from. your source material, your blueprint, your blueprint-bio πŸ’œ
  • gfp β€” the allocation priority. like, how hard should we be trying to get memory rn 😀
  • bs β€” the bio_set you're allocating out of. that's the pool, bestie πŸŠβ€β™€οΈ

πŸ‘‘ DESCRIPTION πŸ‘‘

So what actually happens? You allocate a new bio, and it's a clone of bio_src. βœ…

Here's the part that matters (highkey important, ngl): this reuses the bio_vecs that bio_src->bi_io_vec points to β€” it does not copy them, it shares them. It also clones the iterator that's pointing at the current position inside them 🎯

And now the ownership bit, listen up because this is the whole thing fr fr:

The caller owns the returned bio, but not the bio_vecs. And you must make sure the bio is freed before the memory pointed to by bio_Src->bi_io_vecs. Like, that's the rule. Break it and things get real bad real fast πŸ’€

so: you own the bio 🫡, you do not own the vecs πŸ™…β€β™€οΈ, and free order is not optional, it's the law periodt ✨


πŸ¦‹ SEE ALSO πŸ¦‹

Kernel file ./block/bio.c, plus this whole iconic little squad of friends πŸ‘―β€β™€οΈ:


anyway that's the whole page, ily, go free your bios in the right order πŸ’–

sign-off szn: this one lives in ./block, and it's dated October 2026 β€” so yeah, future-dated manpage, main character energy only 🌈⭐🫢

πŸ“¦ where this page comes from