shmem_recalc_inode(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

โœจ NAME โœจ

Okay bestie, this is shmem_recalc_inode(9) from the Kernel API Manual, and it does exactly what the name says: recalculate the block usage of an inode. Periodt. ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

bool shmem_recalc_inode (struct inode *inode , long alloced , long
       swapped );

๐ŸŽ€ ARGUMENTS ๐ŸŽ€

  • inode โ€” the inode weโ€™re recalculating, no cap.
  • alloced โ€” the change in number of pages allocated to inode.
  • swapped โ€” the change in number of pages swapped from inode.

๐Ÿ’… DESCRIPTION ๐Ÿ’…

So hereโ€™s the tea: we have to calculate the free blocks since the mm can drop undirtied hole pages behind our back. ๐Ÿ˜ญ

But normally, itโ€™s giving this exact equation:

info->alloced == inode->i_mapping->nrpages + info->swapped

So the mm freed amount is literally:

info->alloced - (inode->i_mapping->nrpages + info->swapped)

Thatโ€™s the whole math vibe, iykyk. ๐Ÿงฎโœจ


๐Ÿซถ RETURN ๐Ÿซถ

It returns true if swapped was incremented from 0 โ€” specifically for shmem_writeout. Slay. โœ…


๐Ÿ”ฅ SEE ALSO ๐Ÿ”ฅ

The kernel file lore lives in ./mm/shmem.c, and the squad to check out is:


k bye bestie โ€” source/version info is ./mm, dated October 2026, mwah ๐Ÿ’‹โœจ

๐Ÿ“ฆ where this page comes from