ext4_get_branch(9)
π ext4_get_branch β bestie's guide to the kernel API manual β¨
okay so like, this is ext4_get_branch(9) from the Kernel API Manual, and honestly? she's a baddie. let's get into it π
πΈ NAME πΈ
ext4_get_branch β read the chain of indirect blocks leading to data π¦
like, the whole vibe is: follow the chain of indirect blocks until you find the actual data. it's giving treasure map energy iykyk π
β¨ SYNOPSIS β¨
Indirect * ext4_get_branch (struct inode *inode , int depth ,
ext4_lblk_t *offsets , Indirect chain[4] , int *err );
no cap, that's the exact signature, don't come for me π
π«Ά ARGUMENTS π«Ά
inodeβ the inode in question, aka the main character πdepthβ depth of the chain (1 - direct pointer, etc.) β yes, that's literally how it's written,1 - direct pointer, etc.π§offsetsβ offsets of pointers in inode/indirect blockschainβ place to store the result (she's the one holding everything together fr fr)errβ here we store the error value π
π₯ DESCRIPTION π₯
so the function fills the array of triples <key, p, bh> and returns NULL if everything went OK, or the pointer to the last filled triple (the incomplete one) otherwise. periodt.
upon the return:
chain[i].keycontains the number of(i+1)-th block in the chain (as it is stored in memory, i.e. little-endian 32-bit) β don't ask me why little-endian, that's just the lore π¦chain[i].pcontains the address of that number (it points intostruct inodefori==0and into thebh->b_datafori>0)chain[i].bhpoints to thebuffer_headof i-th indirect block fori>0andNULLfori==0
in other words, it holds the block numbers of the chain, addresses they were taken from (and where we can verify that chain did not change) and buffer_heads hosting these numbers. literally the receipts for everything π
π when does she stop π
- when it stumbles upon zero pointer (absent block) β pointer to last triple returned,
*err == 0 - when it gets an IO error reading an indirect block β ditto,
*err == -EIOπ - when it reads all
depth-1indirect blocks successfully and finds the whole chain, all way to the data β returnsNULL,*err == 0slay β¨
β οΈ ok bestie listen: need to be called with down_read(EXT4_I(inode)->i_data_sem) β do NOT skip this, it's not optional, it's the vibe check π
π SEE ALSO π
Kernel file ./fs/ext4/indirect.c:
ext4_block_to_path(9), ext4_find_near(9), ext4_find_goal(9), ext4_blks_to_allocate(9), ext4_alloc_branch(9), ext4_splice_branch(9), ext4_find_shared(9), ext4_free_data(9), ext4_free_branches(9), ext4_ind_remove_space(9)
the whole friend group fr, go read them too π«Ά
and that's the page!! this icon came from ./fs/ext4, dated October 2026, and it's part of the ext4_get_branch(9) kernel API manual β mwah, love u, go read your indirect blocks responsibly ππ₯°π
π¦ 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