ext2_find_near(9)
β¨ ext2_find_near(9) β¨
okay so bestie, this is a page straight out of the Kernel API Manual β it's ext2_find_near(9) and it's literally the matchmaker of ext2 block allocation π
πΈ NAME πΈ
ext2_find_near β find a place for allocation with sufficient locality
(yes girl, it's out here finding blocks a good neighbourhood π‘)
π¦ SYNOPSIS π¦
ext2_fsblk_t ext2_find_near (struct inode *inode , Indirect *ind );
π ARGUMENTS π
inodeβ the owner. like, the inode that's gonna own this whole situation πindβ descriptor of indirect block.
β¨ DESCRIPTION β¨
So this function returns the preferred place for block allocation. Iconic behaviour, no cap. It gets called when the heuristic for sequential allocation fails β like, the usual plan didn't work out, so we gotta improvise π
The rules are, and I'm gonna say them exactly how they are:
- if there is a block to the left of our position β allocate near it.
- if pointer will live in indirect block β allocate near that block.
- if pointer will live in inode β allocate in the same cylinder group.
In the latter case (the inode one, keep up π«Ά) we colour the starting block by the callers PID to prevent it from clashing with concurrent allocations for a different inode in the same block group. The PID is used here so that functionally related files will be close-by on-disk. it's giving "keep your friends close" energy fr fr π₯Ί
β οΈ Caller must make sure thatindis valid and will stay that way. Like, genuinely. That's on you. Don't be out here passing a staleindand then acting surprised π
π SEE ALSO π
Kernel file ./fs/ext2/inode.c β and the whole squad:
ext2_block_to_path(9)ext2_get_branch(9)ext2_find_goal(9)ext2_blks_to_allocate(9)ext2_alloc_blocks(9)ext2_alloc_branch(9)ext2_splice_branch(9)ext2_find_shared(9)ext2_free_data(9)ext2_free_branches(9)
and that's the whole page bestie, we ate and left no crumbs π β¨
sign-off time π this one lives in ./fs/ext2, dated October 2026 β go read it, ily, bye π
π¦ 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