sweep_bh_for_rgrps(9)
π sweep_bh_for_rgrps(9) β a Kernel API Manual moment
okay so bestie, this is from the Kernel API Manual, and honestly? it's giving "cleanup era" and i'm obsessed π
β¨ NAME β¨
sweep_bh_for_rgrps β find an rgrp in a meta buffer and free blocks therein π§Ή
πΈ SYNOPSIS πΈ
int sweep_bh_for_rgrps (struct gfs2_inode *ip , struct gfs2_holder
*rd_gh , struct buffer_head *bh , __be64 *start , __be64 *end , bool
meta , u32 *btotal );
π ARGUMENTS π
ipβ the inode, bestie. that's the whole vibe.rd_ghβ holder of resource group glock πbhβ buffer head to sweep (yes, we're sweeping it, periodt)startβ starting point inbhendβ end point inbhmetaβtrueifbhpoints to metadata (rather than data) π«Άbtotalβ place to keep count of total blocks freed π₯
π¦ DESCRIPTION π¦
so here's the tea β β we sweep a metadata buffer (the one provided by the metapath) for blocks we need to free, and we free them all. no cap.
but!! we do it one rgrp at a time. the way that works: if this block has references to multiple rgrps, we break it into individual transactions. this lets other processes use the rgrps while we're focused on a single one β better concurrency / performance, iykyk π
and at every transaction boundary, we rewrite the inode into the journal βοΈ. that way the bitmaps are kept consistent with the inode and we can recover if we're interrupted by power-outages πβ‘ (yes, genuinely β that's the whole safety net, don't skip it).
π RETURN π
0, or return code if an error occurred. and *btotal has the total number of blocks freed π
π SEE ALSO π
Kernel file ./fs/gfs2/bmap.c β and 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_iomap_alloc(9)gfs2_alloc_size(9)__gfs2_iomap_get(9)gfs2_block_map(9)gfs2_journaled_truncate(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)
π that's the whole page, bestie β thanks for reading, mwah π
sign-off time: this one lives at ./fs/gfs2, and the date on it is October 2026 β go forth and sweep responsibly, fr fr π§
π¦ 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