gfs2_block_map(9)
β¨ gfs2_block_map(9) β¨
okay so real talk, this page lives in the Kernel API Manual and it's all about one little function that maps blocks. bestie, let's get into it π«Ά
π SYNOPSIS
int gfs2_block_map (struct inode *inode , sector_t lblock ,
struct buffer_head *bh_map , int create );
like, that's the whole vibe. one function, four args, and it returns an int. slay β¨
π ARGUMENTS
inodeβ the inode, obviously πββοΈ the star of the show.lblockβ the logical block number. like, the block number in logical land, not disk land.bh_mapβ the bh that's getting mapped. this is the buffer head doing the actual work.createβ true if it's ok to alloc blocks to satisfy the request π so basically "can I go shopping for new blocks if I need to".
π¦ DESCRIPTION
okay so first thing first: the size of the requested mapping is defined in bh_map->b_size. that's where it lives. no cap.
When lblock is not mapped, this function clears buffer_mapped(bh_map) and leaves bh_map->b_size unchanged. so like, it just kind of... unmapped-vibes it. π«
But when lblock and successive blocks are mapped β up to the requested size β it sets buffer_mapped(bh_map) and sets bh_map->b_size to indicate the size of the mapping. so now the buffer knows what it's got. iconic behavior honestly π
It also sets buffer_boundary if a read of metadata will be required before the next block can be mapped. that's your little heads-up that you gotta go read some metadata first, no biggie.
And it sets buffer_new if new blocks were allocated. that's a "hey, these blocks are fresh out of the oven" signal π
π₯ RETURN
Returns errno. that's it. that's the value.
π SEE ALSO
Kernel file ./fs/gfs2/bmap.c β and the whole squad:
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_iomap_alloc(9)gfs2_alloc_size(9)__gfs2_iomap_get(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)
okay that's the whole page bestie, go map some blocks π
this lil masterpiece comes to you from ./fs/gfs2, dated October 2026, and it's filed under gfs2_block_map(9) β 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