blk_rq_prep_clone(9)
π 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β thebio_setthat 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 returns0for success and non-0for failure. so like, zero means slay, not-zero means πdataβ private data that gets passed along tobio_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 completerqbeforerq_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:
blk_mq_wait_quiesce_done(9)blk_mq_quiesce_queue(9)blk_update_request(9)blk_mq_complete_request(9)blk_mq_start_request(9)blk_execute_rq_nowait(9)blk_execute_rq(9)blk_mq_delay_run_hw_queue(9)blk_mq_run_hw_queue(9)blk_mq_run_hw_queues(9)blk_mq_delay_run_hw_queues(9)blk_mq_request_bypass_insert(9)blk_mq_try_issue_directly(9)blk_mq_submit_bio(9)blk_insert_cloned_request(9)blk_rq_unprep_clone(9)blk_mq_destroy_queue(9)
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
- 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