bt_for_each(9)
π bt_for_each β like, the kernel manual page for it β¨
bestie, this is bt_for_each from the Kernel API Manual, and it is literally about iterating over the requests associated with a hardware queue πΈ it's giving "walk the tags, one rq at a time" energy and honestly? iconic.
β¨ NAME β¨
bt_for_each β iterate over the requests associated with a hardware queue π
π¦ SYNOPSIS π¦
void bt_for_each (struct blk_mq_hw_ctx *hctx , struct request_queue *q ,
struct sbitmap_queue *bt , busy_tag_iter_fn *fn , void *data , bool
reserved );
okay so it takes six things and returns void, no cap π
π ARGUMENTS π
hctxβ the hardware queue you want to examine. that's the one, bestie πqβ the request queue thathctxis associated with, akahctx->queue. yep, that exact member π«Άbtβ the sbitmap to examine. this is either thebreserved_tagsmember or thebitmap_tagsmember ofstruct blk_mq_tagsβ pick your fighter, but only those two πfnβ a pointer to the function that gets called for each request associated withhctxthat has been assigned a driver tag. it's called like this:
fn(rq, data)
where rq is a pointer to a request. return true to keep iterating tags; return false to stop π₯ like, that's the whole vibe check right there β false means you're done, periodt.
dataβ gets passed as the second argument tofn. it's your little payload, carrying whatever you need πreservedβ tells you whetherbtis thebreserved_tagsmember or thebitmap_tagsmember ofstruct blk_mq_tagsβ (yes it's the same either/or situation frombt, it's just being confirmed here, k?)
πΈ SEE ALSO πΈ
- Kernel file
./block/blk-mq-tag.cbt_tags_for_each(9) blk_mq_all_tag_iter(9)blk_mq_tagset_busy_iter(9)blk_mq_tagset_wait_completed_request(9)blk_mq_queue_tag_busy_iter(9)blk_mq_unique_tag(9)
go read those too, they're all in the same friend group fr fr π
mwah π this page lives in ./block, the date on it is October 2026, and it's the bt_for_each(9) page from the Kernel API Manual β that's the whole sign-off bestie, go iterate some tags π§ββοΈβ¨
π¦ 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