net/sunrpc/cache.c
Source file repositories/reference/linux-study-clean/net/sunrpc/cache.c
File Facts
- System
- Linux kernel
- Corpus path
net/sunrpc/cache.c- Extension
.c- Size
- 48934 bytes
- Lines
- 2010
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/fs.hlinux/file.hlinux/hex.hlinux/slab.hlinux/signal.hlinux/sched.hlinux/kmod.hlinux/list.hlinux/module.hlinux/ctype.hlinux/string_helpers.hlinux/uaccess.hlinux/poll.hlinux/seq_file.hlinux/proc_fs.hlinux/net.hlinux/workqueue.hlinux/mutex.hlinux/pagemap.hasm/ioctls.hlinux/sunrpc/types.hlinux/sunrpc/cache.hlinux/sunrpc/stats.hlinux/sunrpc/rpc_pipe_fs.hnet/genetlink.htrace/events/sunrpc.hnetns.hnetlink.hfail.h
Detected Declarations
struct thread_deferred_reqstruct cache_requeststruct cache_readerfunction cache_initfunction sunrpc_begin_cache_remove_entryfunction sunrpc_end_cache_remove_entryfunction lockdep_is_heldfunction cache_fresh_lockedfunction cache_fresh_unlockedfunction cache_make_negativefunction cache_entry_updatefunction cache_is_validfunction try_to_negate_entryfunction cache_check_rcufunction willfunction sunrpc_init_cache_detailfunction sunrpc_destroy_cache_detailfunction cache_cleanfunction hlist_for_each_entry_safefunction do_cache_cleanfunction cache_flushfunction cache_purgefunction __unhash_deferred_reqfunction __hash_deferred_reqfunction setup_deferralfunction cache_restart_threadfunction cache_wait_reqfunction cache_limit_defersfunction cache_defer_immediatelyfunction cache_defer_immediatelyfunction cache_defer_reqfunction cache_revisit_requestfunction hlist_for_each_entry_safefunction cache_clean_deferredfunction list_for_each_entry_safefunction cache_requestfunction cache_next_requestfunction cache_readfunction cache_do_downcallfunction cache_downcallfunction cache_writefunction cache_pollfunction cache_ioctlfunction cache_openfunction cache_releasefunction cache_dequeuefunction qword_addfunction qword_addhex
Annotated Snippet
const struct file_operations cache_file_operations_pipefs = {
.owner = THIS_MODULE,
.read = cache_read_pipefs,
.write = cache_write_pipefs,
.poll = cache_poll_pipefs,
.unlocked_ioctl = cache_ioctl_pipefs, /* for FIONREAD */
.open = cache_open_pipefs,
.release = cache_release_pipefs,
};
static int content_open_pipefs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = RPC_I(inode)->private;
return content_open(inode, filp, cd);
}
static int content_release_pipefs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = RPC_I(inode)->private;
return content_release(inode, filp, cd);
}
const struct file_operations content_file_operations_pipefs = {
.open = content_open_pipefs,
.read = seq_read,
.llseek = seq_lseek,
.release = content_release_pipefs,
};
static int open_flush_pipefs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = RPC_I(inode)->private;
return open_flush(inode, filp, cd);
}
static int release_flush_pipefs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = RPC_I(inode)->private;
return release_flush(inode, filp, cd);
}
static ssize_t read_flush_pipefs(struct file *filp, char __user *buf,
size_t count, loff_t *ppos)
{
struct cache_detail *cd = RPC_I(file_inode(filp))->private;
return read_flush(filp, buf, count, ppos, cd);
}
static ssize_t write_flush_pipefs(struct file *filp,
const char __user *buf,
size_t count, loff_t *ppos)
{
struct cache_detail *cd = RPC_I(file_inode(filp))->private;
return write_flush(filp, buf, count, ppos, cd);
}
const struct file_operations cache_flush_operations_pipefs = {
.open = open_flush_pipefs,
.read = read_flush_pipefs,
.write = write_flush_pipefs,
.release = release_flush_pipefs,
};
int sunrpc_cache_register_pipefs(struct dentry *parent,
const char *name, umode_t umode,
struct cache_detail *cd)
{
struct dentry *dir = rpc_create_cache_dir(parent, name, umode, cd);
if (IS_ERR(dir))
return PTR_ERR(dir);
cd->pipefs = dir;
return 0;
}
EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs);
void sunrpc_cache_unregister_pipefs(struct cache_detail *cd)
{
if (cd->pipefs) {
rpc_remove_cache_dir(cd->pipefs);
cd->pipefs = NULL;
}
}
EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs);
Annotation
- Immediate include surface: `linux/types.h`, `linux/fs.h`, `linux/file.h`, `linux/hex.h`, `linux/slab.h`, `linux/signal.h`, `linux/sched.h`, `linux/kmod.h`.
- Detected declarations: `struct thread_deferred_req`, `struct cache_request`, `struct cache_reader`, `function cache_init`, `function sunrpc_begin_cache_remove_entry`, `function sunrpc_end_cache_remove_entry`, `function lockdep_is_held`, `function cache_fresh_locked`, `function cache_fresh_unlocked`, `function cache_make_negative`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.