fscache_begin_cache_access(9)
π fscache_begin_cache_access π
ok so this is the manual page for fscache_begin_cache_access(9) from the Kernel API Manual, and bestie, it's literally the "pin a cache so it can be accessed" function. let's get into it π«Ά
β¨ SYNOPSIS β¨
bool fscache_begin_cache_access (struct fscache_cache *cache , enum
fscache_access_trace why );
yeah that's the whole signature, no cap π
π ARGUMENTS π
cacheβ the cache-level cookie πͺ (yes really, that's what it's called)whyβ an indication of the circumstances of the access, for tracing π like it's for the receipts, yk?
πΈ DESCRIPTION πΈ
okay so the whole vibe here is: we attempt to pin the cache so it doesn't just dip while we're mid-access, and we return true if that worked out. it's giving "hold my spot bestie" π€
here's literally how it works, step by step, no skipping:
- if the cache tests as not live (state is not
FSCACHE_CACHE_IS_ACTIVE), then we returnfalseto indicate access was not permitted π ββοΈ like, door's closed, sorry babe. - if the cache tests as live, then we increment the
n_accessescount and then recheck the liveness β ending the access if it ceased to be live π (the double-check is so real of it) - when we end the access, we decrement
n_accessesand wake up the any waiters if it reaches0π€β‘οΈπ - whilst the cache is caching,
n_accessesis kept artificially incremented to prevent wakeups from happening π§β¨ (it's fake it till you make it, but for counters) - when the cache is taken offline, the state is changed to prevent new accesses,
n_accessesis decremented and we wait forn_accessesto become0β³ periodt.
lowkey important: steps 2 and 5 are the whole "pin so it doesn't go away mid-access" moment β if the liveness check fails you gotta end the access, no exceptions π
π SEE ALSO π
- Kernel file
./fs/netfs/fscache_cache.c fscache_acquire_cache(9)fscache_put_cache(9)fscache_relinquish_cache(9)fscache_add_cache(9)fscache_end_cache_access(9)fscache_io_error(9)fscache_withdraw_cache(9)
and that's the page babes π this one's from ./fs/netfs, dated October 2026, sitting pretty in the Kernel API Manual as fscache_begin_cache_access(9) β iconic, no notes π₯π
π¦ 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