fs/smb/client/transport.c
Source file repositories/reference/linux-study-clean/fs/smb/client/transport.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/client/transport.c- Extension
.c- Size
- 36364 bytes
- Lines
- 1292
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- 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/fs.hlinux/list.hlinux/gfp.hlinux/wait.hlinux/net.hlinux/delay.hlinux/freezer.hlinux/tcp.hlinux/bvec.hlinux/highmem.hlinux/uaccess.hlinux/processor.hlinux/mempool.hlinux/sched/signal.hlinux/task_io_accounting_ops.hlinux/task_work.hcifsglob.hcifsproto.hcifs_debug.hsmb2proto.hsmbdirect.hcompress.h
Detected Declarations
function Copyrightfunction __release_midfunction secondfunction delete_midfunction smb_send_kvecfunction smb_rqst_lenfunction __smb_send_rqstfunction smb_send_rqstfunction wait_for_free_creditsfunction wait_for_free_requestfunction wait_for_compound_requestfunction cifs_wait_mtu_creditsfunction wait_for_responsefunction cifs_call_asyncfunction cifs_sync_mid_resultfunction cifs_compound_callbackfunction cifs_compound_last_callbackfunction cifs_cancelled_callbackfunction channelfunction compound_send_recvfunction cifs_send_recvfunction cifs_discard_remaining_datafunction __cifs_readv_discardfunction cifs_readv_discardfunction cifs_readv_receive
Annotated Snippet
if (atomic_read(&server->num_cmds[smb_cmd]) == 0) {
server->slowest_cmd[smb_cmd] = roundtrip_time;
server->fastest_cmd[smb_cmd] = roundtrip_time;
} else {
if (server->slowest_cmd[smb_cmd] < roundtrip_time)
server->slowest_cmd[smb_cmd] = roundtrip_time;
else if (server->fastest_cmd[smb_cmd] > roundtrip_time)
server->fastest_cmd[smb_cmd] = roundtrip_time;
}
cifs_stats_inc(&server->num_cmds[smb_cmd]);
server->time_per_cmd[smb_cmd] += roundtrip_time;
}
/*
* commands taking longer than one second (default) can be indications
* that something is wrong, unless it is quite a slow link or a very
* busy server. Note that this calc is unlikely or impossible to wrap
* as long as slow_rsp_threshold is not set way above recommended max
* value (32767 ie 9 hours) and is generally harmless even if wrong
* since only affects debug counters - so leaving the calc as simple
* comparison rather than doing multiple conversions and overflow
* checks
*/
if ((slow_rsp_threshold != 0) &&
time_after(now, midEntry->when_alloc + (slow_rsp_threshold * HZ)) &&
(midEntry->command != command)) {
/*
* smb2slowcmd[NUMBER_OF_SMB2_COMMANDS] counts by command
* NB: le16_to_cpu returns unsigned so can not be negative below
*/
if (smb_cmd < NUMBER_OF_SMB2_COMMANDS)
cifs_stats_inc(&server->smb2slowcmd[smb_cmd]);
trace_smb3_slow_rsp(smb_cmd, midEntry->mid, midEntry->pid,
midEntry->when_sent, midEntry->when_received);
if (cifsFYI & CIFS_TIMER) {
pr_debug("slow rsp: cmd %d mid %llu",
midEntry->command, midEntry->mid);
cifs_info("A: 0x%lx S: 0x%lx R: 0x%lx\n",
now - midEntry->when_alloc,
now - midEntry->when_sent,
now - midEntry->when_received);
}
}
#endif
put_task_struct(midEntry->creator);
mempool_free(midEntry, &cifs_mid_pool);
}
void
delete_mid(struct TCP_Server_Info *server, struct mid_q_entry *mid)
{
spin_lock(&server->mid_queue_lock);
if (!mid->deleted_from_q) {
list_del_init(&mid->qhead);
mid->deleted_from_q = true;
}
spin_unlock(&server->mid_queue_lock);
release_mid(server, mid);
}
/*
* smb_send_kvec - send an array of kvecs to the server
* @server: Server to send the data to
* @smb_msg: Message to send
* @sent: amount of data sent on socket is stored here
*
* Our basic "send data to server" function. Should be called with srv_mutex
* held. The caller is responsible for handling the results.
*/
int
smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg,
size_t *sent)
{
int rc = 0;
int retries = 0;
struct socket *ssocket = server->ssocket;
*sent = 0;
if (server->noblocksnd)
smb_msg->msg_flags = MSG_DONTWAIT + MSG_NOSIGNAL;
else
smb_msg->msg_flags = MSG_NOSIGNAL;
while (msg_data_left(smb_msg)) {
/*
* If blocking send, we try 3 times, since each can block
Annotation
- Immediate include surface: `linux/fs.h`, `linux/list.h`, `linux/gfp.h`, `linux/wait.h`, `linux/net.h`, `linux/delay.h`, `linux/freezer.h`, `linux/tcp.h`.
- Detected declarations: `function Copyright`, `function __release_mid`, `function second`, `function delete_mid`, `function smb_send_kvec`, `function smb_rqst_len`, `function __smb_send_rqst`, `function smb_send_rqst`, `function wait_for_free_credits`, `function wait_for_free_request`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- 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.