ext4_find_near(9)
β¨ ext4_find_near(9) β¨
okay bestie so this is a page from the Kernel API Manual β yes, the kernel has a manual, we're literally living in the future π
β and it's about ext4_find_near, a lil ext4 helper that goes "where should this new block live tho?"
π NAME π
ext4_find_near β find a place for allocation with sufficient locality
like, vibes-based real estate for disk blocks π‘β¨
π¦ SYNOPSIS π¦
ext4_fsblk_t ext4_find_near (struct inode *inode , Indirect *ind );
πΈ ARGUMENTS πΈ
inodeβ the owner. the main character of this whole situation πindβ descriptor of indirect block. (yes that's the whole description, it's giving minimalism π«Ά)
π DESCRIPTION π
so this function returns the preferred place for block allocation. it's used when the heuristic for sequential allocation fails β i.e. when the cute "just put the next one right after the last one" plan doesn't work out π.
the rules are, and we stan a rules-based queen:
- if there is a block to the left of our position β allocate near it.
- if the pointer will live in an indirect block β allocate near that block.
- if the pointer will live in the inode β allocate in the same cylinder group.
in that last case, we colour the starting block by the caller's 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. like, we keep the friend group together on the dancefloor πΊπ no cap.
β οΈ caller must make sure that ind is valid and will stay that way. literally your job bestie, not ours π
π₯ SEE ALSO π₯
- Kernel file
./fs/ext4/indirect.c ext4_block_to_path(9)ext4_get_branch(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 indirect.c friend group, honestly. go read them all, iykyk π
okay that's the page!! source/version is ./fs/ext4, dated October 2026, and the title/header thing was ext4_find_near(9) from the Kernel API Manual β mwah, go allocate responsibly, slay ππ§ββοΈβ
π¦ 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