truncate_inode_pages(9)
π truncate_inode_pages β the Kernel API Manual page, bestie β¨
okay so this is truncate_inode_pages(9) from the Kernel API Manual, and honestly? she's a baddie with a very specific job. let's get into it π
β¨ NAME β¨
truncate_inode_pages β truncate all the pages from an offset π«Ά
(like, emphasis on all, the manpage literally put asterisks around it, she's not being subtle)
πΈ SYNOPSIS πΈ
void truncate_inode_pages (struct address_space *mapping , loff_t lstart
);
void, no return value, no notes, no nothing β she does the thing and dips π
π¦ ARGUMENTS π¦
mappingβ the mapping you wanna truncate. that's the one, bestie π―lstartβ the offset you're truncating from. everything from here on out? gone βοΈ
π DESCRIPTION π
okay so the whole vibe here is: this gets called under β and is serialised by β inode->i_rwsem and mapping->invalidate_lock. so like, both locks, at the same time, no cap. ππ iykyk.
π NOTE π
β οΈ bestie listen, this is the important bit β οΈ
when this function returns, there can still be a page in the process of deletion (it's inside __filemap_remove_folio) hanging out in the specified range. so mapping->nrpages can be non-zero when this function returns β even after truncating the whole entire mapping π
like she said she's done but one page is still in the group chat leaving. fr fr. not a bug, just the vibe π
π₯ SEE ALSO π₯
Kernel file ./mm/truncate.c and her whole friend group:
folio_invalidate(9)mapping_evict_folio(9)truncate_inode_pages_range(9)truncate_inode_pages_final(9)mapping_try_invalidate(9)invalidate_mapping_pages(9)invalidate_inode_pages2_range(9)invalidate_inode_pages2(9)truncate_pagecache(9)truncate_setsize(9)pagecache_isize_extended(9)truncate_pagecache_range(9)
and that's the page, periodt π
signing off from the ./mm directory, October 2026 edition of this very iconic Kernel API Manual entry β mwah, ily, go read truncate_inode_pages_range(9) next π§ββοΈβ
π¦ 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