include/linux/sunrpc/cache.h
Source file repositories/reference/linux-study-clean/include/linux/sunrpc/cache.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/sunrpc/cache.h- Extension
.h- Size
- 9781 bytes
- Lines
- 340
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kref.hlinux/slab.hlinux/atomic.hlinux/kstrtox.hlinux/proc_fs.hlinux/wait.h
Detected Declarations
struct cache_headstruct cache_detailstruct cache_reqstruct cache_deferred_reqfunction ktime_get_boottime_secondsfunction convert_to_wallclockfunction cache_putfunction cache_is_expiredfunction get_intfunction get_uintfunction get_timefunction get_expiry
Annotated Snippet
extern const struct file_operations cache_file_operations_pipefs;
extern const struct file_operations content_file_operations_pipefs;
extern const struct file_operations cache_flush_operations_pipefs;
extern struct cache_head *
sunrpc_cache_lookup_rcu(struct cache_detail *detail,
struct cache_head *key, int hash);
extern struct cache_head *
sunrpc_cache_update(struct cache_detail *detail,
struct cache_head *new, struct cache_head *old, int hash);
extern int
sunrpc_cache_upcall(struct cache_detail *detail, struct cache_head *h);
extern int
sunrpc_cache_upcall_warn(struct cache_detail *detail,
struct cache_head *h);
extern void cache_clean_deferred(void *owner);
static inline struct cache_head *cache_get(struct cache_head *h)
{
kref_get(&h->ref);
return h;
}
static inline struct cache_head *cache_get_rcu(struct cache_head *h)
{
if (kref_get_unless_zero(&h->ref))
return h;
return NULL;
}
static inline void cache_put(struct cache_head *h, struct cache_detail *cd)
{
if (kref_read(&h->ref) <= 2 &&
h->expiry_time < cd->nextcheck)
cd->nextcheck = h->expiry_time;
kref_put(&h->ref, cd->cache_put);
}
static inline bool cache_is_expired(struct cache_detail *detail, struct cache_head *h)
{
if (h->expiry_time < seconds_since_boot())
return true;
if (!test_bit(CACHE_VALID, &h->flags))
return false;
return detail->flush_time >= h->last_refresh;
}
extern int cache_check_rcu(struct cache_detail *detail,
struct cache_head *h, struct cache_req *rqstp);
extern int cache_check(struct cache_detail *detail,
struct cache_head *h, struct cache_req *rqstp);
extern void cache_flush(void);
extern void cache_purge(struct cache_detail *detail);
#define NEVER (0x7FFFFFFF)
extern void __init cache_initialize(void);
extern int cache_register_net(struct cache_detail *cd, struct net *net);
extern void cache_unregister_net(struct cache_detail *cd, struct net *net);
extern struct cache_detail *cache_create_net(const struct cache_detail *tmpl, struct net *net);
extern void cache_destroy_net(struct cache_detail *cd, struct net *net);
extern void sunrpc_init_cache_detail(struct cache_detail *cd);
extern void sunrpc_destroy_cache_detail(struct cache_detail *cd);
extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *,
umode_t, struct cache_detail *);
extern void sunrpc_cache_unregister_pipefs(struct cache_detail *);
extern void sunrpc_cache_unhash(struct cache_detail *, struct cache_head *);
int sunrpc_cache_requests_count(struct cache_detail *cd);
int sunrpc_cache_requests_snapshot(struct cache_detail *cd,
struct cache_head **items,
u64 *seqnos, int max,
u64 min_seqno);
int sunrpc_cache_notify(struct cache_detail *cd, struct cache_head *h,
u32 cache_type);
/* Must store cache_detail in seq_file->private if using next three functions */
extern void *cache_seq_start_rcu(struct seq_file *file, loff_t *pos);
extern void *cache_seq_next_rcu(struct seq_file *file, void *p, loff_t *pos);
extern void cache_seq_stop_rcu(struct seq_file *file, void *p);
extern void qword_add(char **bpp, int *lp, char *str);
extern void qword_addhex(char **bpp, int *lp, char *buf, int blen);
extern int qword_get(char **bpp, char *dest, int bufsize);
static inline int get_int(char **bpp, int *anint)
{
Annotation
- Immediate include surface: `linux/kref.h`, `linux/slab.h`, `linux/atomic.h`, `linux/kstrtox.h`, `linux/proc_fs.h`, `linux/wait.h`.
- Detected declarations: `struct cache_head`, `struct cache_detail`, `struct cache_req`, `struct cache_deferred_req`, `function ktime_get_boottime_seconds`, `function convert_to_wallclock`, `function cache_put`, `function cache_is_expired`, `function get_int`, `function get_uint`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.