ext2_try_to_allocate(9)
π ext2_try_to_allocate(9) β from the Kernel API Manual, bestie π
okay so bestie, we're in the Kernel API Manual today and this one is a deep cut β it's ext2_try_to_allocate, straight out of the ext2 block allocator. yes the one with the reservation windows. no I will not be normal about it. let's go β¨
πΈ NAME πΈ
ext2_try_to_allocate β
and that's literally it. the name section is just the symbol, a dash, and silence. main character energy tbh, she said "my reputation precedes me" π
β¨ SYNOPSIS β¨
int ext2_try_to_allocate (struct super_block *sb , int group ,
struct buffer_head *bitmap_bh , ext2_grpblk_t grp_goal ,
unsigned long *count , struct ext2_reserve_window *my_rsv );
six arguments, one int coming back at you. she's a whole commitment, but we love her for it π«Ά
π¦ ARGUMENTS π¦
sbβ the superblock π your whole filesystem's vibe in one structgroupβ the given allocation block group, aka which block group we're shopping inbitmap_bhβ the bufferhead that holds the block bitmap β this is the actual map we're reading free bits out of πΊοΈgrp_goalβ the given target block within the group, our lil starting wishcountβ the target number of blocks to allocate (pointer, so it can be updated, iykyk)my_rsvβ the reservation window π
π DESCRIPTION π
so what does she actually do? she attempts to allocate blocks within a given range. that's the whole quest.
the plan is a three-step slay, in this exact order:
- set the range of allocation first π
- then find the first free bit(s) from the bitmap β and yes, only within that range
- and at last, allocate the blocks by claiming the found free bit as allocated β found it, so it's mine now, periodt π
now, how do we set that range? two paths, bestie, and it depends entirely on whether there's a reservation window:
- if there is a reservation window β we only try to allocate block(s) from the file's own reservation window. no window-hopping, no wandering eyes, she stays loyal π
- otherwise β the allocation range starts from the given goal block and ends at the block group's last block. that's the whole stretch of the group, go girl π
β οΈ and here's the messy part: if we failed to allocate the desired block, then we may end up crossing to a new bitmap. not a bug, just chaos β the search can spill right over into someone else's bitmap π
π₯ SEE ALSO π₯
the kernel file she lives in: ./fs/ext2/balloc.c β that's home base, go read her neighbors π«Ά
the whole friend group:
__rsv_window_dump(9)goal_in_my_reservation(9)search_reserve_window(9)rsv_window_remove(9)ext2_init_block_alloc_info(9)ext2_discard_reservation(9)ext2_free_blocks(9)bitmap_search_next_usable_block(9)find_next_usable_block(9)find_next_reservable_window(9)alloc_new_reservation(9)try_to_extend_reservation(9)ext2_try_to_allocate_with_rsv(9)ext2_has_free_blocks(9)ext2_bg_has_super(9)ext2_bg_num_gdb(9)
that's sixteen siblings and one source file. a family. no cap πΈ
π okay that's the whole page, bestie! this one's brought to you by ./fs/ext2 and dated October 2026, filed under ext2_try_to_allocate(9) β go forth and allocate responsibly, mwah πβ¨
π¦ 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