ext2_find_shared(9)
πΈ ext2_find_shared(9) β Kernel API Manual, but make it bestie-core πΈ
π NAME π
ext2_find_shared β find the indirect blocks for partial truncation. That's the whole assignment, bestie: find the indirect blocks for partial truncation. Periodt. π
β¨ SYNOPSIS β¨
Indirect * ext2_find_shared (struct inode *inode , int depth , int
offsets[4] , Indirect chain[4] , __le32 *top );
π«Ά ARGUMENTS π«Ά
inodeβ the inode in question, aka the main character of this whole little situation.depthβ depth of the affected branch. Yes, we're going down, down, down.offsetsβ offsets of pointers in that branch (seeext2_block_to_path). It's giving map coordinates.chainβ place to store the pointers to partial indirect blocks.topβ place to the (detached) top of branch. Detached, like your vibe after reading kernel code at 2am.
π§ DESCRIPTION π§
This is a helper function used by ext2_truncate.
When we do truncate we may have to clean the ends of several indirect blocks but leave the blocks themselves alive. Block is partially truncated if some data below the new i_size is referred from it (and it is on the path to the first completely truncated data block, indeed). We have to free the top of that path along with everything to the right of the path. Since no allocation past the truncation point is possible until ext2_truncate finishes, we may safely do the latter, but top of branch may require special attention - pageout below the truncation point might try to populate it.
We atomically detach the top of branch from the tree, store the block number of its root in *top, pointers to buffer_heads of partially truncated blocks - in chain[].bh and pointers to their last elements that should not be removed - in chain[].p. Return value is the pointer to last filled element of chain.
The work left to caller to do the actual freeing of subtrees: a) free the subtree starting from *top b) free the subtrees whose roots are stored in (chain[i].p+1 .. end of chain[i].bh->b_data) c) free the subtrees growing from the inode past the chain[0].p (no partially truncated stuff there).
π SEE ALSO π
- Kernel file
./fs/ext2/inode.c ext2_block_to_path(9)ext2_get_branch(9)ext2_find_near(9)ext2_find_goal(9)ext2_blks_to_allocate(9)ext2_alloc_blocks(9)ext2_alloc_branch(9)ext2_splice_branch(9)ext2_free_data(9)ext2_free_branches(9)
mwah π β this lil page lives under ./fs/ext2, dated October 2026, and it's literally ext2_find_shared(9), bye bestie! π«Ά
π¦ 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