net/sunrpc/xprt.c
Source file repositories/reference/linux-study-clean/net/sunrpc/xprt.c
File Facts
- System
- Linux kernel
- Corpus path
net/sunrpc/xprt.c- Extension
.c- Size
- 57428 bytes
- Lines
- 2230
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/types.hlinux/interrupt.hlinux/workqueue.hlinux/net.hlinux/ktime.hlinux/sunrpc/clnt.hlinux/sunrpc/metrics.hlinux/sunrpc/bc_xprt.hlinux/rcupdate.hlinux/sched/mm.htrace/events/sunrpc.hsunrpc.hsysfs.hfail.h
Detected Declarations
enum xprt_xid_rb_cmpfunction xprt_request_timeoutfunction xprt_register_transportfunction xprt_unregister_transportfunction xprt_class_releasefunction xprt_class_find_by_ident_lockedfunction list_for_each_entryfunction xprt_class_find_by_identfunction xprt_class_find_by_netid_lockedfunction list_for_each_entryfunction xprt_class_find_by_netidfunction xprt_find_transport_identfunction xprt_clear_lockedfunction xprt_reserve_xprtfunction xprt_need_congestion_window_waitfunction xprt_set_congestion_window_waitfunction xprt_test_and_clear_congestion_window_waitfunction xprt_reserve_xprt_congfunction xprt_lock_writefunction __xprt_lock_write_funcfunction __xprt_lock_write_nextfunction __xprt_lock_write_next_congfunction xprt_release_xprtfunction xprt_release_xprt_congfunction xprt_release_writefunction __xprt_get_congfunction __xprt_put_congfunction xprt_request_get_congfunction xprt_release_rqst_congfunction xprt_clear_congestion_window_wait_lockedfunction xprt_clear_congestion_window_waitfunction xprt_adjust_cwndfunction xprt_wake_pending_tasksfunction RPC_IS_SOFTfunction xprt_clear_write_space_lockedfunction xprt_write_spacefunction xprt_abs_ktime_to_jiffiesfunction xprt_calc_majortimeofunction xprt_reset_majortimeofunction xprt_reset_minortimeofunction xprt_init_majortimeofunction xprt_adjust_timeoutfunction xprt_autoclosefunction xprt_disconnect_donefunction xprt_schedule_autoclose_lockedfunction xprt_force_disconnectfunction xprt_connect_cookiefunction xprt_request_retransmit_after_disconnect
Annotated Snippet
if (t == transport) {
printk(KERN_INFO
"RPC: Unregistered %s transport module.\n",
transport->name);
list_del_init(&transport->list);
goto out;
}
}
result = -ENOENT;
out:
spin_unlock(&xprt_list_lock);
return result;
}
EXPORT_SYMBOL_GPL(xprt_unregister_transport);
static void
xprt_class_release(const struct xprt_class *t)
{
module_put(t->owner);
}
static const struct xprt_class *
xprt_class_find_by_ident_locked(int ident)
{
const struct xprt_class *t;
list_for_each_entry(t, &xprt_list, list) {
if (t->ident != ident)
continue;
if (!try_module_get(t->owner))
continue;
return t;
}
return NULL;
}
static const struct xprt_class *
xprt_class_find_by_ident(int ident)
{
const struct xprt_class *t;
spin_lock(&xprt_list_lock);
t = xprt_class_find_by_ident_locked(ident);
spin_unlock(&xprt_list_lock);
return t;
}
static const struct xprt_class *
xprt_class_find_by_netid_locked(const char *netid)
{
const struct xprt_class *t;
unsigned int i;
list_for_each_entry(t, &xprt_list, list) {
for (i = 0; t->netid[i][0] != '\0'; i++) {
if (strcmp(t->netid[i], netid) != 0)
continue;
if (!try_module_get(t->owner))
continue;
return t;
}
}
return NULL;
}
static const struct xprt_class *
xprt_class_find_by_netid(const char *netid)
{
const struct xprt_class *t;
spin_lock(&xprt_list_lock);
t = xprt_class_find_by_netid_locked(netid);
if (!t) {
spin_unlock(&xprt_list_lock);
request_module("rpc%s", netid);
spin_lock(&xprt_list_lock);
t = xprt_class_find_by_netid_locked(netid);
}
spin_unlock(&xprt_list_lock);
return t;
}
/**
* xprt_find_transport_ident - convert a netid into a transport identifier
* @netid: transport to load
*
* Returns:
* > 0: transport identifier
* -ENOENT: transport module not available
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/interrupt.h`, `linux/workqueue.h`, `linux/net.h`, `linux/ktime.h`, `linux/sunrpc/clnt.h`, `linux/sunrpc/metrics.h`.
- Detected declarations: `enum xprt_xid_rb_cmp`, `function xprt_request_timeout`, `function xprt_register_transport`, `function xprt_unregister_transport`, `function xprt_class_release`, `function xprt_class_find_by_ident_locked`, `function list_for_each_entry`, `function xprt_class_find_by_ident`, `function xprt_class_find_by_netid_locked`, `function list_for_each_entry`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.