netfs_clear_stale_isize(9)
π netfs_clear_stale_isize π
okay so this is a page out of the Kernel API Manual, bestie β literally kernel-internal stuff, iykyk. buckle up π
β¨ NAME β¨
netfs_clear_stale_isize β bestie, it clears stale pagecache data that's chilling inside a hole you're about to create π§Ήπ
πΈ SYNOPSIS πΈ
int netfs_clear_stale_isize (struct inode *inode , uoff_t from , uoff_t
to , bool nowait , bool exclusive );
π¦ ARGUMENTS π¦
inodeβ the inode we're doing all this to. main character fr.fromβ the base of the hole that's gonna be made.toβ the top of the hole that's gonna be made.nowaitβ set it totrueand instead of blocking you get-EAGAINback. no waiting around, periodt.exclusiveβ set it totruewhen the caller is holdingi_rwsemexclusively for the resize. it's giving "i have the lock, trust me" energy π
π DESCRIPTION π
okay so the whole vibe: zero out any data left sitting in the pagecache inside the [from, to) hole β you do it by writing through an mmap β so that data doesn't get exposed as file content once the file gets extended. gross otherwise π
And here's the smart part: only the uptodate folio straddling from can even hold such data, because pages wholly beyond the EOF literally can't be faulted in. so the zeroing is limited to that one folio, slay. and the folio gets zeroed rather than dropped so that a concurrent extending write can't lose data. protecting the data, we love to see it π«Ά
Now, exclusive β this is the part where you gotta pay attention:
- if
exclusiveis false,fromgets re-read fromi_sizeand used to clamp the zeroed range. that's for callers that might be racing with another writer also extending the file (eg. multiple buffered writes extending the same file under a sharedi_rwsem). shared lock chaos, love that for them. - if
exclusiveis true, that's for callers holdingi_rwsemexclusively across the whole resize who have already updatedi_sizetoto. in that case staleness is decided from the folio's dirty state instead π΅οΈββοΈ because no genuine concurrent buffered writer can be racing, a lockless stat adopting a server-confirmed size mid-resize has no data behind it and never dirties the folio β so it literally can't fool this check into skipping the zeroing the way it could fool theexclusivefalse clamp. not today, bestie π
and real talk:pagecache_isize_extendedcan't be reused here. nope. it's keyed on a sub-page block size (which is a total no-op when the block size is>= PAGE_SIZE, like on network filesystems), it runs afteri_sizeis updated, it can't honournowait, and it doesn't wait for writeback. π so keep the two in sync if either one gets changed, fr fr.
π₯ RETURN π₯
0on success β we ate π-EAGAINifnowaitis set and the folio is mapped or under writeback and so can't be cleaned without blocking. can't clean it without blocking, so it says no thanks.
π SEE ALSO π
Kernel file ./fs/netfs/misc.c, plus the whole squad:
netfs_alloc_folioq_buffer(9)netfs_free_folioq_buffer(9)netfs_dirty_folio(9)netfs_unpin_writeback(9)netfs_clear_inode_writeback(9)netfs_invalidate_folio(9)netfs_release_folio(9)
β¨ anyway bestie that's the whole page π this little icon lives in ./fs/netfs, dated October 2026, and it's still waving at you as netfs_clear_stale_isize(9) π mwah, go clear some stale isize, 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