net/sunrpc/debugfs.c
Source file repositories/reference/linux-study-clean/net/sunrpc/debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
net/sunrpc/debugfs.c- Extension
.c- Size
- 7044 bytes
- Lines
- 310
- 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.
- 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/debugfs.hlinux/sunrpc/sched.hlinux/sunrpc/clnt.hnetns.hfail.h
Detected Declarations
function tasks_showfunction tasks_startfunction tasks_nextfunction tasks_stopfunction tasks_openfunction tasks_releasefunction do_xprt_debugfsfunction rpc_clnt_debugfs_registerfunction rpc_clnt_debugfs_unregisterfunction xprt_info_showfunction xprt_info_openfunction xprt_info_releasefunction rpc_xprt_debugfs_registerfunction rpc_xprt_debugfs_unregisterfunction fail_sunrpc_initfunction fail_sunrpc_initfunction sunrpc_debugfs_initexport fail_sunrpc
Annotated Snippet
static const struct file_operations tasks_fops = {
.owner = THIS_MODULE,
.open = tasks_open,
.read = seq_read,
.llseek = seq_lseek,
.release = tasks_release,
};
static int do_xprt_debugfs(struct rpc_clnt *clnt, struct rpc_xprt *xprt, void *numv)
{
int len;
char name[24]; /* enough for "../../rpc_xprt/ + 8 hex digits + NULL */
char link[9]; /* enough for 8 hex digits + NULL */
int *nump = numv;
if (IS_ERR_OR_NULL(xprt->debugfs))
return 0;
len = snprintf(name, sizeof(name), "../../rpc_xprt/%s",
xprt->debugfs->d_name.name);
if (len >= sizeof(name))
return -1;
if (*nump == 0)
strcpy(link, "xprt");
else {
len = snprintf(link, sizeof(link), "xprt%d", *nump);
if (len >= sizeof(link))
return -1;
}
debugfs_create_symlink(link, clnt->cl_debugfs, name);
(*nump)++;
return 0;
}
void
rpc_clnt_debugfs_register(struct rpc_clnt *clnt)
{
int len;
char name[9]; /* enough for 8 hex digits + NULL */
int xprtnum = 0;
len = snprintf(name, sizeof(name), "%x", clnt->cl_clid);
if (len >= sizeof(name))
return;
/* make the per-client dir */
clnt->cl_debugfs = debugfs_create_dir(name, rpc_clnt_dir);
/* make tasks file */
debugfs_create_file("tasks", S_IFREG | 0400, clnt->cl_debugfs, clnt,
&tasks_fops);
rpc_clnt_iterate_for_each_xprt(clnt, do_xprt_debugfs, &xprtnum);
}
void
rpc_clnt_debugfs_unregister(struct rpc_clnt *clnt)
{
debugfs_remove_recursive(clnt->cl_debugfs);
clnt->cl_debugfs = NULL;
}
static int
xprt_info_show(struct seq_file *f, void *v)
{
struct rpc_xprt *xprt = f->private;
seq_printf(f, "netid: %s\n", xprt->address_strings[RPC_DISPLAY_NETID]);
seq_printf(f, "addr: %s\n", xprt->address_strings[RPC_DISPLAY_ADDR]);
seq_printf(f, "port: %s\n", xprt->address_strings[RPC_DISPLAY_PORT]);
seq_printf(f, "state: 0x%lx\n", xprt->state);
seq_printf(f, "netns: %u\n", xprt->xprt_net->ns.inum);
if (xprt->ops->get_srcaddr) {
int ret, buflen;
char buf[INET6_ADDRSTRLEN];
buflen = ARRAY_SIZE(buf);
ret = xprt->ops->get_srcaddr(xprt, buf, buflen);
if (ret < 0)
ret = sprintf(buf, "<closed>");
seq_printf(f, "saddr: %.*s\n", ret, buf);
}
return 0;
}
static int
xprt_info_open(struct inode *inode, struct file *filp)
{
int ret;
struct rpc_xprt *xprt = inode->i_private;
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/sunrpc/sched.h`, `linux/sunrpc/clnt.h`, `netns.h`, `fail.h`.
- Detected declarations: `function tasks_show`, `function tasks_start`, `function tasks_next`, `function tasks_stop`, `function tasks_open`, `function tasks_release`, `function do_xprt_debugfs`, `function rpc_clnt_debugfs_register`, `function rpc_clnt_debugfs_unregister`, `function xprt_info_show`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.