truncate_pagecache_range(9)
π¦ truncate_pagecache_range(9) β a Kernel API Manual moment π
okay so bestie, welcome to the Kernel API Manual page for truncate_pagecache_range(9) β yes the title is a mouthful, we love her anyway π
β¨ NAME β¨
truncate_pagecache_range β unmaps and removes pagecache that's been hole-punched π³οΈβ¨
β¨ SYNOPSIS β¨
void truncate_pagecache_range (struct inode *inode , loff_t lstart ,
loff_t lend );
β¨ ARGUMENTS β¨
inodeβ the inode. that's it. that's the whole description lmao, she's lowkey mysterious πlstartβ offset of the beginning of the hole π³οΈlendβ offset of the last byte of the hole (yes, last byte, not "one past the end", don't come for me) π«Ά
β¨ DESCRIPTION β¨
so the vibe here: you should typically call this function before the filesystem releases the resources associated with the freed range (eg. deallocates blocks). timing is everything β°π
why? because this way, pagecache will always stay logically coherent with the on-disk format. no cap. and the filesystem would not have to deal with messy situations such as writepage being called for a page that has already had its underlying blocks deallocated ππ like imagine. that's the nightmare scenario. we're avoiding it.
think of it as: clear the pagecache first, free the blocks second, and everything stays iconic πβ¨
β¨ SEE ALSO β¨
folio_invalidate(9)mapping_evict_folio(9)truncate_inode_pages_range(9)truncate_inode_pages(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)
and the kernel file itself lives at ./mm/truncate.c π¦
aaaand that's the page bestie, mwah π the source is ./mm and she's dated October 2026 β so like, future girlie energy fr fr πΈβ¨ bye ily π«Άπ
π¦ 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