fs/smb/client/smb2ops.c
Source file repositories/reference/linux-study-clean/fs/smb/client/smb2ops.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/client/smb2ops.c- Extension
.c- Size
- 172396 bytes
- Lines
- 5983
- 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.
- 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/pagemap.hlinux/vfs.hlinux/falloc.hlinux/scatterlist.hlinux/uuid.hlinux/sort.hcrypto/aead.hlinux/fiemap.hlinux/folio_queue.huapi/linux/magic.hcifsfs.hcifsglob.hcifsproto.hsmb2proto.hsmb2pdu.hcifs_debug.hcifs_unicode.h../common/smb2status.hsmb2glob.hcifs_ioctl.hsmbdirect.hfscache.hfs_context.hcached_dir.hreparse.h
Detected Declarations
struct smb2_decrypt_workfunction Copyrightfunction smb2_add_creditsfunction smb2_set_creditsfunction smb2_get_credits_fieldfunction smb2_get_creditsfunction smb2_wait_mtu_creditsfunction smb2_adjust_creditsfunction smb2_get_next_midfunction smb2_revert_current_midfunction __smb2_find_midfunction smb2_find_midfunction smb2_find_dequeue_midfunction smb2_dump_detailfunction smb2_need_negfunction smb2_negotiatefunction prevent_zero_iosizefunction smb2_negotiate_wsizefunction smb3_negotiate_wsizefunction smb2_negotiate_rsizefunction smb3_negotiate_rsizefunction iface_cmpfunction parse_server_interfacesfunction list_for_each_entry_safefunction SMB3_request_interfacesfunction time_beforefunction smb3_qfs_tconfunction smb2_qfs_tconfunction smb2_is_path_accessiblefunction smb2_get_srv_inumfunction smb2_query_file_infofunction move_smb2_ea_to_cifsfunction smb2_query_easfunction smb2_set_eafunction smb2_can_echofunction smb2_clear_statsfunction smb2_dump_share_capsfunction smb2_print_statsfunction smb2_set_fidfunction smb2_close_filefunction smb2_close_getattrfunction SMB2_request_res_keyfunction smb2_ioctl_query_infofunction calc_chunk_countfunction smb2_copychunk_rangefunction smb2_flush_filefunction smb2_read_data_offsetfunction smb2_read_data_length
Annotated Snippet
struct smb2_decrypt_work {
struct work_struct decrypt;
struct TCP_Server_Info *server;
struct folio_queue *buffer;
char *buf;
unsigned int len;
};
static void smb2_decrypt_offload(struct work_struct *work)
{
struct smb2_decrypt_work *dw = container_of(work,
struct smb2_decrypt_work, decrypt);
int rc;
struct mid_q_entry *mid;
struct iov_iter iter;
iov_iter_folio_queue(&iter, ITER_DEST, dw->buffer, 0, 0, dw->len);
rc = decrypt_raw_data(dw->server, dw->buf, dw->server->vals->read_rsp_size,
&iter, true);
if (rc) {
cifs_dbg(VFS, "error decrypting rc=%d\n", rc);
goto free_pages;
}
dw->server->lstrp = jiffies;
mid = smb2_find_dequeue_mid(dw->server, dw->buf);
if (mid == NULL)
cifs_dbg(FYI, "mid not found\n");
else {
mid->decrypted = true;
rc = handle_read_data(dw->server, mid, dw->buf,
dw->server->vals->read_rsp_size,
dw->buffer, dw->len,
true);
if (rc >= 0) {
#ifdef CONFIG_CIFS_STATS2
mid->when_received = jiffies;
#endif
if (dw->server->ops->is_network_name_deleted)
dw->server->ops->is_network_name_deleted(dw->buf,
dw->server);
mid_execute_callback(dw->server, mid);
} else {
spin_lock(&dw->server->srv_lock);
if (dw->server->tcpStatus == CifsNeedReconnect) {
spin_lock(&dw->server->mid_queue_lock);
mid->mid_state = MID_RETRY_NEEDED;
spin_unlock(&dw->server->mid_queue_lock);
spin_unlock(&dw->server->srv_lock);
mid_execute_callback(dw->server, mid);
} else {
spin_lock(&dw->server->mid_queue_lock);
mid->mid_state = MID_REQUEST_SUBMITTED;
mid->deleted_from_q = false;
list_add_tail(&mid->qhead,
&dw->server->pending_mid_q);
spin_unlock(&dw->server->mid_queue_lock);
spin_unlock(&dw->server->srv_lock);
}
}
release_mid(dw->server, mid);
}
free_pages:
netfs_free_folioq_buffer(dw->buffer);
cifs_small_buf_release(dw->buf);
kfree(dw);
}
static int
receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid,
int *num_mids)
{
char *buf = server->smallbuf;
struct smb2_transform_hdr *tr_hdr = (struct smb2_transform_hdr *)buf;
struct iov_iter iter;
unsigned int len;
unsigned int buflen = server->pdu_size;
int rc;
struct smb2_decrypt_work *dw;
dw = kzalloc_obj(struct smb2_decrypt_work);
if (!dw)
return -ENOMEM;
INIT_WORK(&dw->decrypt, smb2_decrypt_offload);
dw->server = server;
Annotation
- Immediate include surface: `linux/pagemap.h`, `linux/vfs.h`, `linux/falloc.h`, `linux/scatterlist.h`, `linux/uuid.h`, `linux/sort.h`, `crypto/aead.h`, `linux/fiemap.h`.
- Detected declarations: `struct smb2_decrypt_work`, `function Copyright`, `function smb2_add_credits`, `function smb2_set_credits`, `function smb2_get_credits_field`, `function smb2_get_credits`, `function smb2_wait_mtu_credits`, `function smb2_adjust_credits`, `function smb2_get_next_mid`, `function smb2_revert_current_mid`.
- 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.