net/sunrpc/rpc_pipe.c
Source file repositories/reference/linux-study-clean/net/sunrpc/rpc_pipe.c
File Facts
- System
- Linux kernel
- Corpus path
net/sunrpc/rpc_pipe.c- Extension
.c- Size
- 30654 bytes
- Lines
- 1262
- 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/module.hlinux/slab.hlinux/string.hlinux/pagemap.hlinux/mount.hlinux/fs_context.hlinux/namei.hlinux/fsnotify.hlinux/kernel.hlinux/rcupdate.hlinux/utsname.hasm/ioctls.hlinux/poll.hlinux/wait.hlinux/seq_file.hlinux/sunrpc/clnt.hlinux/workqueue.hlinux/sunrpc/rpc_pipe_fs.hlinux/sunrpc/cache.hlinux/nsproxy.hlinux/notifier.hnetns.hsunrpc.h
Detected Declarations
struct rpc_filelistfunction rpc_pipefs_notifier_registerfunction rpc_pipefs_notifier_unregisterfunction rpc_purge_listfunction rpc_timeout_upcall_queuefunction rpc_pipe_generic_upcallfunction rpc_queue_upcallfunction rpc_inode_setownerfunction rpc_close_pipesfunction rpc_alloc_inodefunction rpc_free_inodefunction rpc_pipe_openfunction rpc_pipe_releasefunction rpc_pipe_readfunction rpc_pipe_writefunction rpc_pipe_pollfunction rpc_pipe_ioctlfunction rpc_show_infofunction rpc_info_openfunction rpc_info_releasefunction rpc_get_inodefunction init_pipefunction rpc_destroy_pipe_datafunction rpc_new_filefunction rpc_populatefunction rpc_queue_upcallfunction rpc_unlinkfunction rpc_init_pipe_dir_headfunction rpc_init_pipe_dir_objectfunction rpc_add_pipe_dir_object_lockedfunction rpc_remove_pipe_dir_object_lockedfunction rpc_add_pipe_dir_objectfunction rpc_remove_pipe_dir_objectfunction rpc_find_or_alloc_pipe_dir_objectfunction rpc_create_pipe_dir_objectsfunction rpc_destroy_pipe_dir_objectsfunction rpc_mkpipefunction rpc_remove_client_dirfunction rpc_remove_cache_dirfunction rpc_pipefs_init_netfunction rpc_pipefs_exit_netfunction rpc_put_sb_netfunction dummy_downcallfunction rpc_dummy_info_showfunction rpc_gssd_dummy_populatefunction rpc_fill_superfunction gssd_runningfunction rpc_fs_get_tree
Annotated Snippet
static const struct file_operations rpc_pipe_fops = {
.owner = THIS_MODULE,
.read = rpc_pipe_read,
.write = rpc_pipe_write,
.poll = rpc_pipe_poll,
.unlocked_ioctl = rpc_pipe_ioctl,
.open = rpc_pipe_open,
.release = rpc_pipe_release,
};
static int
rpc_show_info(struct seq_file *m, void *v)
{
struct rpc_clnt *clnt = m->private;
rcu_read_lock();
seq_printf(m, "RPC server: %s\n",
rcu_dereference(clnt->cl_xprt)->servername);
seq_printf(m, "service: %s (%d) version %d\n", clnt->cl_program->name,
clnt->cl_prog, clnt->cl_vers);
seq_printf(m, "address: %s\n", rpc_peeraddr2str(clnt, RPC_DISPLAY_ADDR));
seq_printf(m, "protocol: %s\n", rpc_peeraddr2str(clnt, RPC_DISPLAY_PROTO));
seq_printf(m, "port: %s\n", rpc_peeraddr2str(clnt, RPC_DISPLAY_PORT));
rcu_read_unlock();
return 0;
}
static int
rpc_info_open(struct inode *inode, struct file *file)
{
struct rpc_clnt *clnt = NULL;
int ret = single_open(file, rpc_show_info, NULL);
if (!ret) {
struct seq_file *m = file->private_data;
spin_lock(&file->f_path.dentry->d_lock);
if (!d_unhashed(file->f_path.dentry))
clnt = RPC_I(inode)->private;
if (clnt != NULL && refcount_inc_not_zero(&clnt->cl_count)) {
spin_unlock(&file->f_path.dentry->d_lock);
m->private = clnt;
} else {
spin_unlock(&file->f_path.dentry->d_lock);
single_release(inode, file);
ret = -EINVAL;
}
}
return ret;
}
static int
rpc_info_release(struct inode *inode, struct file *file)
{
struct seq_file *m = file->private_data;
struct rpc_clnt *clnt = (struct rpc_clnt *)m->private;
if (clnt)
rpc_release_client(clnt);
return single_release(inode, file);
}
static const struct file_operations rpc_info_operations = {
.owner = THIS_MODULE,
.open = rpc_info_open,
.read = seq_read,
.llseek = seq_lseek,
.release = rpc_info_release,
};
/*
* Description of fs contents.
*/
struct rpc_filelist {
const char *name;
const struct file_operations *i_fop;
umode_t mode;
};
static struct inode *
rpc_get_inode(struct super_block *sb, umode_t mode)
{
struct inode *inode = new_inode(sb);
if (!inode)
return NULL;
inode->i_ino = get_next_ino();
inode->i_mode = mode;
simple_inode_init_ts(inode);
switch (mode & S_IFMT) {
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/string.h`, `linux/pagemap.h`, `linux/mount.h`, `linux/fs_context.h`, `linux/namei.h`, `linux/fsnotify.h`.
- Detected declarations: `struct rpc_filelist`, `function rpc_pipefs_notifier_register`, `function rpc_pipefs_notifier_unregister`, `function rpc_purge_list`, `function rpc_timeout_upcall_queue`, `function rpc_pipe_generic_upcall`, `function rpc_queue_upcall`, `function rpc_inode_setowner`, `function rpc_close_pipes`, `function rpc_alloc_inode`.
- 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.