borrow_pbn_lock_from_pool(9)
π borrow_pbn_lock_from_pool(9)
okay so first things first, bestie, this whole thing lives in the Kernel API Manual (that's the manual name btw, now you know β¨). It's a kernel function page, it's giving driver-internals realness, and honestly? It's kinda iconic. Let's get into it π
β¨ NAME β¨
borrow_pbn_lock_from_pool β the function that literally borrows a PBN lock out of the pool and initializes it with whatever type you hand it π«Ά
πΈ SYNOPSIS πΈ
int borrow_pbn_lock_from_pool (struct pbn_lock_pool *pool , enum
pbn_lock_type type , struct pbn_lock **lock_ptr );
that's the whole signature, copied verbatim, no notes π
π¦ ARGUMENTS π¦
poolβ the pool you're borrowing from. this is your plug, your source, your supply πtypeβ the type you wanna initialize the lock with. you pick it, you own it.lock_ptrβ a pointer that receives the borrowed lock. it's the little basket where your lock lands π§Ί
β DESCRIPTION β
so like, here's the tea: pools do not grow on demand and they do not allocate memory. Periodt. π Which means if the pool is empty? This call fails. No dramatic rescue, no sneaky malloc behind your back, it just says no.
And here's the part people forget (iykyk): borrowed locks are still associated with this pool, so when you're done, you must return them to only this pool. Not some other pool. Not a vibe-adjacent pool. This one. π
π₯ RETURN π₯
VDO_SUCCESSβ you got your lock, slay πVDO_LOCK_ERRORβ the pool was empty, better luck next time π
π SEE ALSO π
bestie, buckle up, this list is long and every single one of these is required reading, no cap. The kernel file is ./drivers/md/dm-vdo/physical-zone.c and the crew is:
vdo_is_pbn_read_lock(9)vdo_downgrade_pbn_write_lock(9)vdo_claim_pbn_lock_increment(9)vdo_assign_pbn_lock_provisional_reference(9)vdo_unassign_pbn_lock_provisional_reference(9)release_pbn_lock_provisional_reference(9)union idle_pbn_lock(9)struct pbn_lock_pool(9)return_pbn_lock_to_pool(9)make_pbn_lock_pool(9)free_pbn_lock_pool(9)initialize_zone(9)vdo_make_physical_zones(9)vdo_free_physical_zones(9)vdo_get_physical_zone_pbn_lock(9)vdo_attempt_physical_zone_pbn_lock(9)allocate_and_lock_block(9)retry_allocation(9)continue_allocating(9)vdo_allocate_block_in_zone(9)vdo_release_physical_zone_pbn_lock(9)vdo_dump_physical_zone(9)
that's the whole friend group, go say hi π«Ά
quick vibe check before you go: empty pool = VDO_LOCK_ERROR, and every borrowed lock goes home to the same pool it came from. That's the rule. Don't break it. π
and that's the page, bestie!! π this one ships out of ./drivers/md/dm-vdo, dated October 2026 β go off, borrow responsibly, mwah ππ
π¦ 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