net/sunrpc/xprtmultipath.c
Source file repositories/reference/linux-study-clean/net/sunrpc/xprtmultipath.c
File Facts
- System
- Linux kernel
- Corpus path
net/sunrpc/xprtmultipath.c- Extension
.c- Size
- 17076 bytes
- Lines
- 673
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source 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.
- 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/atomic.hlinux/types.hlinux/kref.hlinux/list.hlinux/rcupdate.hlinux/rculist.hlinux/slab.hlinux/spinlock.hlinux/sunrpc/xprt.hlinux/sunrpc/addr.hlinux/sunrpc/xprtmultipath.hsysfs.h
Detected Declarations
function xprt_switch_add_xprt_lockedfunction rpc_xprt_switch_add_xprtfunction xprt_switch_remove_xprt_lockedfunction rpc_xprt_switch_remove_xprtfunction xprt_multipath_cleanup_idsfunction xprt_switch_alloc_idfunction xprt_switch_free_idfunction xprt_switch_free_entriesfunction xprt_switch_freefunction xprt_switch_putfunction rpc_xprt_switch_set_roundrobinfunction xprt_iter_no_rewindfunction xprt_is_activefunction list_for_each_entry_rcufunction list_for_each_entry_rcufunction list_for_each_entry_rcufunction _xprt_iter_current_entryfunction __rpc_xprt_switch_has_addrfunction rpc_xprt_switch_has_addrfunction list_for_each_entry_rcufunction xprt_iter_rewindfunction __xprt_iter_initfunction xprt_iter_initfunction xprt_iter_init_listallfunction xprt_iter_init_listofflinefunction xprt_iter_destroyfunction rcu_read_lock
Annotated Snippet
if (rpc_cmp_addr_port(sap, (struct sockaddr *)&pos->addr)) {
pr_info("RPC: addr %s already in xprt switch\n",
pos->address_strings[RPC_DISPLAY_ADDR]);
return true;
}
}
return false;
}
bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps,
const struct sockaddr *sap)
{
bool res;
rcu_read_lock();
res = __rpc_xprt_switch_has_addr(xps, sap);
rcu_read_unlock();
return res;
}
static
struct rpc_xprt *xprt_switch_find_next_entry(struct list_head *head,
const struct rpc_xprt *cur, bool check_active)
{
struct rpc_xprt *pos, *prev = NULL;
bool found = false;
list_for_each_entry_rcu(pos, head, xprt_switch) {
if (cur == prev)
found = true;
/* for request to return active transports return only
* active, for request to return offline transports
* return only offline
*/
if (found && ((check_active && xprt_is_active(pos)) ||
(!check_active && !xprt_is_active(pos))))
return pos;
prev = pos;
}
return NULL;
}
static
struct rpc_xprt *xprt_switch_set_next_cursor(struct rpc_xprt_switch *xps,
struct rpc_xprt **cursor,
xprt_switch_find_xprt_t find_next)
{
struct rpc_xprt *pos, *old;
old = smp_load_acquire(cursor);
pos = find_next(xps, old);
smp_store_release(cursor, pos);
return pos;
}
static
struct rpc_xprt *xprt_iter_next_entry_multiple(struct rpc_xprt_iter *xpi,
xprt_switch_find_xprt_t find_next)
{
struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch);
if (xps == NULL)
return NULL;
return xprt_switch_set_next_cursor(xps, &xpi->xpi_cursor, find_next);
}
static
struct rpc_xprt *__xprt_switch_find_next_entry_roundrobin(struct list_head *head,
const struct rpc_xprt *cur)
{
struct rpc_xprt *ret;
ret = xprt_switch_find_next_entry(head, cur, true);
if (ret != NULL)
return ret;
return xprt_switch_find_first_entry(head);
}
static
struct rpc_xprt *xprt_switch_find_next_entry_roundrobin(struct rpc_xprt_switch *xps,
const struct rpc_xprt *cur)
{
struct list_head *head = &xps->xps_xprt_list;
struct rpc_xprt *xprt;
unsigned int nactive;
for (;;) {
unsigned long xprt_queuelen, xps_queuelen;
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/types.h`, `linux/kref.h`, `linux/list.h`, `linux/rcupdate.h`, `linux/rculist.h`, `linux/slab.h`, `linux/spinlock.h`.
- Detected declarations: `function xprt_switch_add_xprt_locked`, `function rpc_xprt_switch_add_xprt`, `function xprt_switch_remove_xprt_locked`, `function rpc_xprt_switch_remove_xprt`, `function xprt_multipath_cleanup_ids`, `function xprt_switch_alloc_id`, `function xprt_switch_free_id`, `function xprt_switch_free_entries`, `function xprt_switch_free`, `function xprt_switch_put`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.