fs/smb/client/misc.c
Source file repositories/reference/linux-study-clean/fs/smb/client/misc.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/client/misc.c- Extension
.c- Size
- 28474 bytes
- Lines
- 1070
- 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/slab.hlinux/ctype.hlinux/mempool.hlinux/vmalloc.hcifsglob.hcifsproto.hcifs_debug.hsmberr.hnterr.hcifs_unicode.hsmb2pdu.hsmb2proto.hsmb1proto.hcifsfs.hdns_resolve.hdfs_cache.hdfs.hfs_context.hcached_dir.h
Detected Declarations
struct tcon_liststruct super_cb_datafunction counterfunction _free_xidfunction sesInfoAllocfunction sesInfoFreefunction tcon_info_allocfunction tconInfoFreefunction cifs_buf_getfunction cifs_buf_releasefunction cifs_small_buf_getfunction cifs_small_buf_releasefunction free_rsp_buffunction dump_smbfunction cifs_autodisable_serverinofunction cifs_set_oplock_levelfunction cifs_get_writerfunction cifs_put_writerfunction cifs_queue_oplock_breakfunction cifs_done_oplock_breakfunction backup_credfunction cifs_del_pending_openfunction cifs_add_pending_open_lockedfunction cifs_add_pending_openfunction cifs_is_deferred_closefunction list_for_each_entryfunction cifs_add_deferred_closefunction cifs_del_deferred_closefunction cifs_close_deferred_filefunction list_for_each_entry_safefunction cifs_close_all_deferred_filesfunction list_for_each_entry_safefunction cifs_close_all_deferred_files_sbfunction list_for_each_entry_safefunction cifs_close_deferred_file_under_dentryfunction list_for_each_entry_safefunction cifs_mark_open_handles_for_deleted_filefunction list_for_each_entryfunction parse_dfs_referralsfunction extract_unc_hostnamefunction writtenfunction tcon_super_cbfunction __cifs_put_superfunction cifs_put_tcp_superfunction match_target_ipfunction cifs_update_super_prepathfunction cifs_inval_name_dfs_link_errorfunction cifs_wait_for_server_reconnect
Annotated Snippet
struct tcon_list {
struct list_head entry;
struct cifs_tcon *tcon;
};
/* The xid serves as a useful identifier for each incoming vfs request,
in a similar way to the mid which is useful to track each sent smb,
and CurrentXid can also provide a running counter (although it
will eventually wrap past zero) of the total vfs operations handled
since the cifs fs was mounted */
unsigned int
_get_xid(void)
{
unsigned int xid;
spin_lock(&GlobalMid_Lock);
GlobalTotalActiveXid++;
/* keep high water mark for number of simultaneous ops in filesystem */
if (GlobalTotalActiveXid > GlobalMaxActiveXid)
GlobalMaxActiveXid = GlobalTotalActiveXid;
if (GlobalTotalActiveXid > 65000)
cifs_dbg(FYI, "warning: more than 65000 requests active\n");
xid = GlobalCurrentXid++;
spin_unlock(&GlobalMid_Lock);
return xid;
}
void
_free_xid(unsigned int xid)
{
spin_lock(&GlobalMid_Lock);
/* if (GlobalTotalActiveXid == 0)
BUG(); */
GlobalTotalActiveXid--;
spin_unlock(&GlobalMid_Lock);
}
struct cifs_ses *
sesInfoAlloc(void)
{
struct cifs_ses *ret_buf;
ret_buf = kzalloc_obj(struct cifs_ses);
if (ret_buf) {
atomic_inc(&sesInfoAllocCount);
spin_lock_init(&ret_buf->ses_lock);
ret_buf->ses_status = SES_NEW;
++ret_buf->ses_count;
INIT_LIST_HEAD(&ret_buf->smb_ses_list);
INIT_LIST_HEAD(&ret_buf->tcon_list);
mutex_init(&ret_buf->session_mutex);
spin_lock_init(&ret_buf->iface_lock);
INIT_LIST_HEAD(&ret_buf->iface_list);
spin_lock_init(&ret_buf->chan_lock);
}
return ret_buf;
}
void
sesInfoFree(struct cifs_ses *buf_to_free)
{
struct cifs_server_iface *iface = NULL, *niface = NULL;
if (buf_to_free == NULL) {
cifs_dbg(FYI, "Null buffer passed to sesInfoFree\n");
return;
}
unload_nls(buf_to_free->local_nls);
atomic_dec(&sesInfoAllocCount);
kfree(buf_to_free->serverOS);
kfree(buf_to_free->serverDomain);
kfree(buf_to_free->serverNOS);
kfree_sensitive(buf_to_free->password);
kfree_sensitive(buf_to_free->password2);
kfree(buf_to_free->user_name);
kfree(buf_to_free->domainName);
kfree(buf_to_free->dns_dom);
kfree_sensitive(buf_to_free->auth_key.response);
spin_lock(&buf_to_free->iface_lock);
list_for_each_entry_safe(iface, niface, &buf_to_free->iface_list,
iface_head)
kref_put(&iface->refcount, release_iface);
spin_unlock(&buf_to_free->iface_lock);
kfree_sensitive(buf_to_free);
}
struct cifs_tcon *
Annotation
- Immediate include surface: `linux/slab.h`, `linux/ctype.h`, `linux/mempool.h`, `linux/vmalloc.h`, `cifsglob.h`, `cifsproto.h`, `cifs_debug.h`, `smberr.h`.
- Detected declarations: `struct tcon_list`, `struct super_cb_data`, `function counter`, `function _free_xid`, `function sesInfoAlloc`, `function sesInfoFree`, `function tcon_info_alloc`, `function tconInfoFree`, `function cifs_buf_get`, `function cifs_buf_release`.
- 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.