net/9p/client.c
Source file repositories/reference/linux-study-clean/net/9p/client.c
File Facts
- System
- Linux kernel
- Corpus path
net/9p/client.c- Extension
.c- Size
- 53560 bytes
- Lines
- 2213
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/errno.hlinux/fs.hlinux/poll.hlinux/idr.hlinux/mutex.hlinux/slab.hlinux/sched/signal.hlinux/uaccess.hlinux/uio.hlinux/netfs.hnet/9p/9p.hlinux/seq_file.hlinux/fs_context.hnet/9p/client.hnet/9p/transport.hprotocol.htrace/events/9p.h
Detected Declarations
function Copyrightfunction p9_is_proto_dotufunction p9_show_client_optionsfunction safe_errnofunction apply_client_optionsfunction p9_fcall_initfunction p9_fcall_finifunction p9_tag_allocfunction p9_tag_removefunction p9_req_putfunction p9_tag_cleanupfunction p9_client_cbfunction p9_parse_headerfunction p9_check_errorsfunction p9_client_flushfunction structurefunction structurefunction p9_fid_destroyfunction do_trace_9p_fid_getfunction do_trace_9p_fid_putfunction p9_client_versionfunction p9_client_destroyfunction idr_for_each_entryfunction p9_client_disconnectfunction p9_client_begin_disconnectfunction p9_client_openfunction p9_client_create_dotlfunction p9_client_fcreatefunction p9_client_symlinkfunction p9_client_linkfunction p9_client_fsyncfunction p9_client_clunkfunction p9_client_removefunction p9_client_unlinkatfunction p9_client_readfunction p9_client_read_oncefunction p9_client_writefunction p9_client_write_subreqfunction p9_client_statsizefunction p9_client_wstatfunction p9_client_setattrfunction p9_client_statfsfunction p9_client_renamefunction p9_client_renameatfunction p9_client_xattrcreatefunction p9_client_readdirfunction p9_client_mknod_dotlfunction p9_client_mkdir_dotl
Annotated Snippet
if (!fc->sdata && c->trans_mod->supports_vmalloc) {
fc->sdata = kvmalloc(alloc_msize, GFP_NOFS);
fc->cache = NULL;
}
} else {
if (c->trans_mod->supports_vmalloc)
fc->sdata = kvmalloc(alloc_msize, GFP_NOFS);
else
fc->sdata = kmalloc(alloc_msize, GFP_NOFS);
fc->cache = NULL;
}
if (!fc->sdata)
return -ENOMEM;
fc->capacity = alloc_msize;
fc->id = 0;
fc->tag = P9_NOTAG;
return 0;
}
void p9_fcall_fini(struct p9_fcall *fc)
{
/* sdata can be NULL for interrupted requests in trans_rdma,
* and kmem_cache_free does not do NULL-check for us
*/
if (unlikely(!fc->sdata))
return;
if (fc->cache)
kmem_cache_free(fc->cache, fc->sdata);
else
kvfree(fc->sdata);
}
EXPORT_SYMBOL(p9_fcall_fini);
static struct kmem_cache *p9_req_cache;
/**
* p9_tag_alloc - Allocate a new request.
* @c: Client session.
* @type: Transaction type.
* @t_size: Buffer size for holding this request
* (automatic calculation by format template if 0).
* @r_size: Buffer size for holding server's reply on this request
* (automatic calculation by format template if 0).
* @fmt: Format template for assembling 9p request message
* (see p9pdu_vwritef).
* @ap: Variable arguments to be fed to passed format template
* (see p9pdu_vwritef).
*
* Context: Process context.
* Return: Pointer to new request.
*/
static struct p9_req_t *
p9_tag_alloc(struct p9_client *c, int8_t type, uint t_size, uint r_size,
const char *fmt, va_list ap)
{
struct p9_req_t *req = kmem_cache_alloc(p9_req_cache, GFP_NOFS);
int alloc_tsize;
int alloc_rsize;
int tag;
va_list apc;
va_copy(apc, ap);
alloc_tsize = min_t(size_t, c->msize,
t_size ?: p9_msg_buf_size(c, type, fmt, apc));
va_end(apc);
alloc_rsize = min_t(size_t, c->msize,
r_size ?: p9_msg_buf_size(c, type + 1, fmt, ap));
if (!req)
return ERR_PTR(-ENOMEM);
if (p9_fcall_init(c, &req->tc, alloc_tsize))
goto free_req;
if (p9_fcall_init(c, &req->rc, alloc_rsize))
goto free;
p9pdu_reset(&req->tc);
p9pdu_reset(&req->rc);
req->t_err = 0;
req->status = REQ_STATUS_ALLOC;
/* refcount needs to be set to 0 before inserting into the idr
* so p9_tag_lookup does not accept a request that is not fully
* initialized. refcount_set to 2 below will mark request ready.
*/
refcount_set(&req->refcount, 0);
init_waitqueue_head(&req->wq);
INIT_LIST_HEAD(&req->req_list);
Annotation
- Immediate include surface: `linux/module.h`, `linux/errno.h`, `linux/fs.h`, `linux/poll.h`, `linux/idr.h`, `linux/mutex.h`, `linux/slab.h`, `linux/sched/signal.h`.
- Detected declarations: `function Copyright`, `function p9_is_proto_dotu`, `function p9_show_client_options`, `function safe_errno`, `function apply_client_options`, `function p9_fcall_init`, `function p9_fcall_fini`, `function p9_tag_alloc`, `function p9_tag_remove`, `function p9_req_put`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.