fscache_write_to_cache(9)
πΎ fscache_write_to_cache β the kernel API manual page, bestie edition
okay so this is fscache_write_to_cache(9), straight out of the Kernel API Manual, and it's genuinely one of those functions that sounds scary but is lowkey just "pls put my dirty data in the cache, thanks π«Ά". Buckle up, we're going in β¨
β¨ NAME β¨
fscache_write_to_cache β save a write to the cache and clear PG_fscache π
π SYNOPSIS π
void fscache_write_to_cache (struct fscache_cookie *cookie , struct
address_space *mapping , loff_t start , size_t len , loff_t i_size ,
netfs_io_terminated_t term_func , void *term_func_priv , bool
using_pgpriv2 , bool caching );
it's giving "lots of arguments, but every single one is doing her job π" β eight of them, no cap, and every one matters.
π¦ ARGUMENTS π¦
cookieβ the cookie that represents the cache object πͺ (yes, it's literally called a cookie, slay)mappingβ the netfs inode you're using as the sourcestartβ where inmappingthis whole thing kicks offlenβ the amount of data to write backi_sizeβ the new size of the inodeterm_funcβ the function that gets called once it's all doneterm_func_privβ the private data forterm_funcπusing_pgpriv2β whether we're usingPG_private_2to mark an in-progress writecachingβ whether we actually want to do the caching (yes, that's the whole vibe check right there β)
πΈ DESCRIPTION πΈ
So this is a helper function for a netfs β it takes dirty data from an inode and writes it into the cache object that's backing it. literally its whole purpose π
start and len describe the range of the data. and listen, this does not need to be page-aligned β but to satisfy DIO requirements, the cache may expand it up to the page boundaries on either end. so it can grow a lil bit on each side, ngl π₯
All the pages covering the range must be marked with PG_fscache. non-negotiable, bestie π
If it's given, term_func will be called upon completion and supplied with term_func_priv. and heads up π¨ β if using_pgpriv2 is set, the PG_private_2 flags will have been cleared by this point, so the netfs must retain its own pin on the mapping. don't sleep on that one, fr fr π
π§ SEE ALSO π§
Kernel file ./include/linux/fscache.h β and the whole friend group π:
fscache_acquire_volume(9)fscache_relinquish_volume(9)fscache_acquire_cookie(9)fscache_use_cookie(9)fscache_unuse_cookie(9)fscache_relinquish_cookie(9)fscache_update_cookie(9)fscache_resize_cookie(9)fscache_invalidate(9)fscache_operation_valid(9)fscache_begin_read_operation(9)fscache_end_operation(9)fscache_read(9)fscache_begin_write_operation(9)fscache_write(9)fscache_clear_page_bits(9)fscache_note_page_release(9)
like, the whole fscache cinematic universe π go read them, iykyk π
and that's the page!! mwah π source/version lives over in ./include/linux, dated October 2026, and this whole glittery thing is filed under fscache_write_to_cache(9) β go forth and cache responsibly, bestie πΈβ¨π
π¦ 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