fscache_write_to_cache(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’Ύ 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 source
  • start β€” where in mapping this whole thing kicks off
  • len β€” the amount of data to write back
  • i_size β€” the new size of the inode
  • term_func β€” the function that gets called once it's all done
  • term_func_priv β€” the private data for term_func πŸ™ˆ
  • using_pgpriv2 β€” whether we're using PG_private_2 to mark an in-progress write
  • caching β€” 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 πŸ’œ:

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