fs/smb/client/cifssmb.c
Source file repositories/reference/linux-study-clean/fs/smb/client/cifssmb.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/client/cifssmb.c- Extension
.c- Size
- 191647 bytes
- Lines
- 6442
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/filelock.hlinux/kernel.hlinux/vfs.hlinux/slab.hlinux/posix_acl_xattr.hlinux/pagemap.hlinux/swap.hlinux/task_io_accounting_ops.hlinux/uaccess.hlinux/netfs.htrace/events/netfs.hcifsglob.hcifsproto.hsmb1proto.h../common/smbfsctl.hcifsfs.hcifsacl.hcifs_unicode.hcifs_debug.hfscache.hsmbdirect.hdfs_cache.h
Detected Declarations
function cifs_reconnect_tconfunction small_smb_initfunction small_smb_init_no_tcfunction __smb_initfunction smb_initfunction smb_init_no_reconnectfunction validate_t2function decode_ext_sec_blobfunction should_set_ext_sec_flagfunction CIFSSMBNegotiatefunction CIFSTConfunction CIFSSMBTDisfunction cifs_echo_callbackfunction CIFSSMBEchofunction CIFSSMBLogofffunction CIFSPOSIXDelFilefunction CIFSSMBDelFilefunction CIFSSMBRmDirfunction CIFSSMBMkDirfunction CIFSPOSIXCreatefunction convert_dispositionfunction access_flags_to_smbopen_modefunction SMBLegacyOpenfunction CIFS_openfunction cifs_readv_callbackfunction cifs_async_readvfunction CIFSSMBReadfunction CIFSSMBWritefunction bufferfunction cifs_async_writevfunction CIFSSMBWrite2function cifs_lockvfunction CIFSSMBLockfunction CIFSSMBPosixLockfunction CIFSSMBClosefunction CIFSSMBFlushfunction CIFSSMBRenamefunction CIFSSMBRenameOpenFilefunction CIFSUnixCreateSymLinkfunction CIFSUnixCreateHardLinkfunction CIFSCreateHardLinkfunction CIFSSMBUnixQuerySymLinkfunction cifs_query_reparse_pointfunction CIFSSMB_set_compressionfunction cifs_init_posix_aclfunction cifs_to_posix_aclfunction FOREACH_ACL_ENTRYfunction cifs_init_ace
Annotated Snippet
if (smb_command != SMB_COM_TREE_DISCONNECT) {
spin_unlock(&tcon->tc_lock);
cifs_dbg(FYI, "can not send cmd %d while umounting\n",
smb_command);
return -ENODEV;
}
}
spin_unlock(&tcon->tc_lock);
again:
rc = cifs_wait_for_server_reconnect(server, tcon->retry);
if (rc)
return rc;
spin_lock(&ses->chan_lock);
if (!cifs_chan_needs_reconnect(ses, server) && !tcon->need_reconnect) {
spin_unlock(&ses->chan_lock);
return 0;
}
spin_unlock(&ses->chan_lock);
mutex_lock(&ses->session_mutex);
/*
* Handle the case where a concurrent thread failed to negotiate or
* killed a channel.
*/
spin_lock(&server->srv_lock);
switch (server->tcpStatus) {
case CifsExiting:
spin_unlock(&server->srv_lock);
mutex_unlock(&ses->session_mutex);
return -EHOSTDOWN;
case CifsNeedReconnect:
spin_unlock(&server->srv_lock);
mutex_unlock(&ses->session_mutex);
if (!tcon->retry)
return -EHOSTDOWN;
goto again;
default:
break;
}
spin_unlock(&server->srv_lock);
/*
* need to prevent multiple threads trying to simultaneously
* reconnect the same SMB session
*/
spin_lock(&ses->ses_lock);
spin_lock(&ses->chan_lock);
if (!cifs_chan_needs_reconnect(ses, server) &&
ses->ses_status == SES_GOOD) {
spin_unlock(&ses->chan_lock);
spin_unlock(&ses->ses_lock);
/* this means that we only need to tree connect */
if (tcon->need_reconnect)
goto skip_sess_setup;
mutex_unlock(&ses->session_mutex);
goto out;
}
spin_unlock(&ses->chan_lock);
spin_unlock(&ses->ses_lock);
rc = cifs_negotiate_protocol(0, ses, server);
if (rc) {
mutex_unlock(&ses->session_mutex);
if (!tcon->retry)
return -EHOSTDOWN;
goto again;
}
rc = cifs_setup_session(0, ses, server, ses->local_nls);
if ((rc == -EACCES) || (rc == -EHOSTDOWN) || (rc == -EKEYREVOKED)) {
/*
* Try alternate password for next reconnect if an alternate
* password is available.
*/
if (ses->password2)
swap(ses->password2, ses->password);
}
/* do we need to reconnect tcon? */
if (rc || !tcon->need_reconnect) {
mutex_unlock(&ses->session_mutex);
goto out;
}
skip_sess_setup:
cifs_mark_open_files_invalid(tcon);
rc = cifs_tree_connect(0, tcon);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/filelock.h`, `linux/kernel.h`, `linux/vfs.h`, `linux/slab.h`, `linux/posix_acl_xattr.h`, `linux/pagemap.h`, `linux/swap.h`.
- Detected declarations: `function cifs_reconnect_tcon`, `function small_smb_init`, `function small_smb_init_no_tc`, `function __smb_init`, `function smb_init`, `function smb_init_no_reconnect`, `function validate_t2`, `function decode_ext_sec_blob`, `function should_set_ext_sec_flag`, `function CIFSSMBNegotiate`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.