blk_rq_prep_clone(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… blk_rq_prep_clone(9) β€” Kernel API Manual, bestie edition ✨

okay so this is a page from the Kernel API Manual and it's literally about one tiny helper that does a huge job. sit down, grab a strawberry drink πŸ“, and let's get into it.


✨ NAME ✨

blk_rq_prep_clone β€” the helper function that sets up a clone request 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

int blk_rq_prep_clone (struct request *rq , struct request *rq_src ,
       struct bio_set *bs , gfp_t gfp_mask , int (*bio_ctr)(struct bio *,
       struct bio *, void *) , void *data );

that's the whole vibe. six things go in, an int comes out. no cap. πŸ’œ


πŸŽ€ ARGUMENTS πŸŽ€

  • rq β€” the request that's getting set up. this is the main character ✨
  • rq_src β€” the original request. the one being cloned. the blueprint, the source material, the blueprint-iest blueprint πŸ“‹
  • bs β€” the bio_set that the clone's bios get allocated from. it's giving supply closet 🧚
  • gfp_mask β€” the memory allocation mask for the bio. yes it's a mask, no it's not for a party πŸ™ˆ
  • bio_ctr β€” the setup function that gets called for each clone bio. it returns 0 for success and non-0 for failure. so like, zero means slay, not-zero means 😭
  • data β€” private data that gets passed along to bio_ctr. it's the little note you tuck in the bag for later πŸ’Œ

πŸ”₯ DESCRIPTION πŸ”₯

so what it actually does: it clones the bios in rq_src over to rq, and copies the attributes of rq_src onto rq. very demure, very mindful, very clone-y. πŸ‘‘

but β€” and this is the part where you need to pay attention, bestie β€” the pages that the original bios are pointing to are not copied. the cloned bios just point to the same pages. same pages, no duplicate, no extra memory, iconic efficiency honestly. 🌈

⚠️ which means: cloned bios must be completed before the original bios. so the caller has to complete rq before rq_src. like, that's the rule. do not flip it. flipping it is not it. πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

the kernel file ./block/blk-mq.c and honestly the whole friend group:


that's the page!! sourced from ./block, dated October 2026, and that's the whole manual entry for blk_rq_prep_clone(9). go clone something responsibly, bestie πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from