ext4_alloc_branch(9)
π ext4_alloc_branch(9) π
okay bestie, quick vibe check β this is a page from the Kernel API Manual, and we're talking about ext4_alloc_branch, which is literally the glow-up artist for block chains β¨
πΈ NAME πΈ
ext4_alloc_branch β allocate and set up a chain of blocks π
β¨ SYNOPSIS β¨
int ext4_alloc_branch (handle_t *handle , struct ext4_allocation_request
*ar , int indirect_blks , ext4_lblk_t *offsets , Indirect *branch );
like, yes, that signature is a whole meal π
π¦ ARGUMENTS π¦
handleβ the handle for this transaction, iykyk π«Άarβ the structure describing the allocation requestindirect_blksβ the number of allocated indirect blocksoffsetsβ the offsets (in the blocks) where we stash the pointers to next. lowkey crucial.branchβ the place to store the chain in π
π DESCRIPTION π
okay so here's the lore π§ this function allocates blocks, zeroes out all but the last one, links them into a chain, and β if we are synchronous β writes them to disk. no cap. in other words, it prepares a branch that can be spliced onto the inode, main character energy fr fr π₯
it stores the information about that chain in the branch[], in the same format as ext4_get_branch would do. we are calling it after we had read the existing part of the chain and partial points to the last triple of that (the one with zero ->key). upon exit we have the same picture as after the successful ext4_get_block, except that in one place the chain is disconnected β *branch->p is still zero (we did not set the last link), but branch->key contains the number that should be placed into *branch->p to fill that gap. it's giving "almost done, one tiny thing left" π
if allocation fails we free all the blocks we've allocated (and forget theirbuffer_heads) and return the error value from the failedext4_alloc_block(normally-ENOSPC). otherwise we set the chain as described above and return0. periodt. π
π SEE ALSO π
kernel file ./fs/ext4/indirect.c β plus the whole squad:
ext4_block_to_path(9)ext4_get_branch(9)ext4_find_near(9)ext4_find_goal(9)ext4_blks_to_allocate(9)ext4_splice_branch(9)ext4_find_shared(9)ext4_free_data(9)ext4_free_branches(9)ext4_ind_remove_space(9)
that's the whole page bestie, go slay some indirect blocks π
signed off with love from ./fs/ext4 β dated October 2026 β and yeah, this was ext4_alloc_branch(9) the whole time π
π¦ 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