truncate_pagecache_range(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ 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 ✨

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