fs/smb/client/connect.c
Source file repositories/reference/linux-study-clean/fs/smb/client/connect.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/client/connect.c- Extension
.c- Size
- 124896 bytes
- Lines
- 4542
- 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.
- 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/fs.hlinux/fs_context.hlinux/net.hlinux/string.hlinux/sched/mm.hlinux/sched/signal.hlinux/list.hlinux/wait.hlinux/slab.hlinux/pagemap.hlinux/ctype.hlinux/utsname.hlinux/mempool.hlinux/delay.hlinux/completion.hlinux/kthread.hlinux/freezer.hlinux/namei.hlinux/uuid.hlinux/uaccess.hasm/processor.hlinux/inet.hlinux/module.hkeys/user-type.hnet/ipv6.hlinux/parser.hlinux/bvec.hcifsglob.hcifsproto.hcifs_unicode.hcifs_debug.hcifs_fs_sb.h
Detected Declarations
function reconn_set_ipaddr_from_hostnamefunction smb2_query_server_interfacesfunction cifs_signal_cifsd_for_reconnectfunction list_for_each_entryfunction list_for_each_entry_safefunction cifs_mark_tcp_ses_conns_for_reconnectfunction list_for_each_entryfunction cifs_abort_connectionfunction cifs_tcp_ses_needs_reconnectfunction sessionfunction __reconnect_target_lockedfunction reconnect_target_lockedfunction reconnect_dfs_serverfunction _cifs_reconnectfunction _cifs_reconnectfunction cifs_reconnectfunction cifs_reconnect_oncefunction cifs_echo_requestfunction allocate_buffersfunction server_unresponsivefunction time_afterfunction time_afterfunction zero_creditsfunction cifs_readv_from_socketfunction cifs_read_from_socketfunction cifs_discard_from_socketfunction cifs_read_iter_from_socketfunction is_smb_responsefunction sessionfunction list_for_each_entry_safefunction reconnectfunction dequeue_midfunction smb2_get_credits_from_hdrfunction handle_midfunction cifs_enable_signingfunction clean_demultiplex_infofunction list_for_each_safefunction list_for_each_safefunction standard_receive3function cifs_handle_standardfunction smb2_add_credits_from_hdrfunction cifs_demultiplex_threadfunction cifs_ipaddr_cmpfunction cifs_match_ipaddrfunction match_portfunction match_server_addressfunction match_securityfunction match_server
Annotated Snippet
list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
spin_lock(&ses->ses_lock);
if (ses->ses_status == SES_EXITING) {
spin_unlock(&ses->ses_lock);
continue;
}
spin_lock(&ses->chan_lock);
for (i = 1; i < ses->chan_count; i++) {
nserver = ses->chans[i].server;
if (!nserver)
continue;
nserver->srv_count++;
list_add(&nserver->rlist, &reco);
}
spin_unlock(&ses->chan_lock);
spin_unlock(&ses->ses_lock);
}
}
list_for_each_entry_safe(server, nserver, &reco, rlist) {
list_del_init(&server->rlist);
set_need_reco(server);
cifs_put_tcp_session(server, 0);
}
}
/*
* Mark all sessions and tcons for reconnect.
* IMPORTANT: make sure that this gets called only from
* cifsd thread. For any other thread, use
* cifs_signal_cifsd_for_reconnect
*
* @server: the tcp ses for which reconnect is needed
* @server needs to be previously set to CifsNeedReconnect.
* @mark_smb_session: whether even sessions need to be marked
*/
void
cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
bool mark_smb_session)
{
struct TCP_Server_Info *pserver;
struct cifs_ses *ses, *nses;
struct cifs_tcon *tcon;
/*
* before reconnecting the tcp session, mark the smb session (uid) and the tid bad so they
* are not used until reconnected.
*/
cifs_dbg(FYI, "%s: marking necessary sessions and tcons for reconnect\n", __func__);
/* If server is a channel, select the primary channel */
pserver = SERVER_IS_CHAN(server) ? server->primary_server : server;
/*
* if the server has been marked for termination, there is a
* chance that the remaining channels all need reconnect. To be
* on the safer side, mark the session and trees for reconnect
* for this scenario. This might cause a few redundant session
* setup and tree connect requests, but it is better than not doing
* a tree connect when needed, and all following requests failing
*/
if (server->terminate) {
mark_smb_session = true;
server = pserver;
}
spin_lock(&cifs_tcp_ses_lock);
list_for_each_entry_safe(ses, nses, &pserver->smb_ses_list, smb_ses_list) {
spin_lock(&ses->ses_lock);
if (ses->ses_status == SES_EXITING) {
spin_unlock(&ses->ses_lock);
continue;
}
spin_unlock(&ses->ses_lock);
spin_lock(&ses->chan_lock);
if (cifs_ses_get_chan_index(ses, server) ==
CIFS_INVAL_CHAN_INDEX) {
spin_unlock(&ses->chan_lock);
continue;
}
if (!cifs_chan_is_iface_active(ses, server)) {
spin_unlock(&ses->chan_lock);
cifs_chan_update_iface(ses, server);
spin_lock(&ses->chan_lock);
}
if (!mark_smb_session && cifs_chan_needs_reconnect(ses, server)) {
spin_unlock(&ses->chan_lock);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/fs_context.h`, `linux/net.h`, `linux/string.h`, `linux/sched/mm.h`, `linux/sched/signal.h`, `linux/list.h`, `linux/wait.h`.
- Detected declarations: `function reconn_set_ipaddr_from_hostname`, `function smb2_query_server_interfaces`, `function cifs_signal_cifsd_for_reconnect`, `function list_for_each_entry`, `function list_for_each_entry_safe`, `function cifs_mark_tcp_ses_conns_for_reconnect`, `function list_for_each_entry`, `function cifs_abort_connection`, `function cifs_tcp_ses_needs_reconnect`, `function session`.
- 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.