blk_start_plug(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 blk_start_plug(9) 🌸

okay so bestie, welcome to the Kernel API Manual ✨ this one's a little function with main character energy: blk_start_plug.


πŸ’– NAME πŸ’–

blk_start_plug β€” initializes blk_plug and tracks it inside the task_struct 🫢


✨ SYNOPSIS ✨

void blk_start_plug (struct blk_plug *plug );

πŸŽ€ ARGUMENTS πŸŽ€

  • plug β€” the struct blk_plug that needs to be initialized. that's it, that's the one, give it a little kiss on the forehead before you pass it in πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the vibe: blk_start_plug tells the block layer that the caller intends to submit multiple I/O requests in a batch. like, "hey girl, I'm about to drop a whole haul, not just one thing" πŸ›οΈ

The block layer may use this hint to defer submitting I/Os from the caller until blk_finish_plug is called. obsessed, so efficient.

But β€” and this is the important part, no cap β€” the block layer may choose to submit requests before a call to blk_finish_plug if:

  • the number of queued I/Os exceeds BLK_MAX_REQUEST_COUNT, or
  • the size of the I/O is larger than BLK_PLUG_FLUSH_SIZE.

The queued I/Os may also be submitted early if the task schedules (see below πŸ‘‡).

Tracking blk_plug inside the task_struct helps with auto-flushing the pending I/O should the task end up blocking between blk_start_plug and blk_finish_plug. This is important from a performance perspective, but also ensures that we don't deadlock. 🚨

For instance: if the task is blocking for a memory allocation, memory reclaim could end up wanting to free a page belonging to that request that is currently residing in our private plug. By flushing the pending I/O when the process goes to sleep, we avoid this kind of deadlock. literally the whole point, iykyk πŸ’€βœ¨

ngl the deadlock avoidance is the real icon here. don't skip the flush, bestie.

🌈 SEE ALSO 🌈

Kernel file ./block/blk-core.c plus these absolute legends:


aaaand that's the page! πŸŽ‰ brought to you by the ./block girlies, dated October 2026, filed under blk_start_plug(9). mwah, go flush responsibly πŸ’‹πŸ’œ

πŸ“¦ where this page comes from