do_shrink(9)
π do_shrink β make a file smaller (yes, literally that) π
okay so this is a page from the Kernel API Manual, and it's about do_shrink(9). bestie, the name is not mysterious: it makes a file smaller. that's the whole gig. let's go β¨
πΈ SYNOPSIS πΈ
int do_shrink (struct inode *inode , u64 newsize );
that's it, that's the signature. two args, one int coming back at you π«Ά
π¦ ARGUMENTS π¦
inodeβ the inode. yeah. the inode. the one we're shrinking. πnewsizeβ the size to make the file. that's the target size, the goal, the destination, the moment π«
π DESCRIPTION π
so here's the vibe check: this function is called with an exclusive lock on inode. exclusive. no sharing, no plus-ones, nobody else touching this inode while we're working. π
and the rule, the one non-negotiable rule: the size must be equal to or smaller than the current inode size. equal is fine. smaller is fine. bigger? absolutely not, that's not shrinking, that's a whole different function (do_grow(9) is right there in SEE ALSO, iykyk π).
no cap, if you're coming in here trying to make a file bigger, you have misunderstood the assignment π
β RETURN β
errno β that's the return value. periodt.
π SEE ALSO π
it's giving extended universe, honestly. the whole bmap.c friend group shows up:
- the kernel file
./fs/gfs2/bmap.c 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)sweep_bh_for_rgrps(9)find_nonnull_ptr(9)punch_hole(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)
like, the entire roster. main character energy from every single one of them π
and that's the page!! mwah π this one came out of ./fs/gfs2, dated October 2026, and it's filed under do_shrink(9). go shrink something (smaller than it is now, PLEASE, we went over this π) π
π¦ 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