__gfs2_iomap_alloc(9)
πΈ __gfs2_iomap_alloc(9) β the Kernel API Manual, bestie edition πΈ
okay so this page lives in the Kernel API Manual and it's literally all about building a metadata tree of the requested height π like, you know when you need a tree and it needs to be a specific height? yeah. that. let's get into it π«Ά
β¨ NAME β¨
__gfs2_iomap_alloc β build a metadata tree of the requested height π lowkey the whole personality of this function ngl
π¦ SYNOPSIS π¦
int __gfs2_iomap_alloc (struct inode *inode , struct iomap *iomap ,
struct metapath *mp );
three args, one int back, no cap π
πΈ ARGUMENTS πΈ
inodeβ the GFS2 inode π like, the inode. the main character, fr.iomapβ theiomapstructure β¨ your classic iomap situation.mpβ the metapath π§ and bestie, it needs to already have the proper height information calculated. don't come in here with a half-baked metapath, it's giving unprepared π
π DESCRIPTION π
okay so in this routine we may have to alloc three whole vibes of thing, and yes you have to keep all three straight π:
- indirect blocks to grow the metadata tree height π±
- indirect blocks to fill in the lower part of the metadata tree π§±
- data blocks πΎ
this function is called after __gfs2_iomap_get, which is the one that actually works out the total number of blocks we need via gfs2_alloc_size π₯ so like, the math is already done by the time we show up. we're just here to execute.
then we do the actual allocation, asking for an extent at a time β and here's the slay part: if enough contiguous free blocks are available, there will only be one allocation request per call πβ¨ and then we use the state machine to initialise the blocks in order. state machine doing the heavy lifting, as always π
right now? this function will allocate at most one indirect block worth of data β with a default block size of 4K, that's slightly less than 2M π that's the cap, that's the limit, that's the vibe check result.
and if this limitation is ever removed to allow huge allocations, we would probably still want to limit the iomap size we return, to avoid stalling other tasks during huge writes π«Ά the next iomap iteration would then find the blocks already allocated. so like β even in the glowing future where we're huge? still limiting. periodt. π
π₯ RETURN π₯
errno on error π (that's it, that's the return section, we keep it real)
π SEE ALSO π
kernel file ./fs/gfs2/bmap.c plus the whole friend group π:
gfs2_unstuffer_folio(9)gfs2_unstuff_dinode(9)find_metapath(9)metaptr1(9)metapointer(9)lookup_metapath(9)fillup_metapath(9)gfs2_extent_length(9)gfs2_hole_size(9)gfs2_alloc_size(9)__gfs2_iomap_get(9)gfs2_block_map(9)gfs2_journaled_truncate(9)sweep_bh_for_rgrps(9)find_nonnull_ptr(9)punch_hole(9)do_shrink(9)do_grow(9)gfs2_setattr_size(9)gfs2_free_journal_extents(9)gfs2_add_jextent(9)gfs2_map_journal_extents(9)gfs2_write_alloc_required(9)
ok literally that's the whole page, go read bmap.c if you want the deep lore π
and that's a wrap bestie π this came from the source tree at ./fs/gfs2, dated October 2026, and the page itself is __gfs2_iomap_alloc(9) β mwah, go build some trees πβπ
π¦ 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