fs/smb/client/smb2misc.c
Source file repositories/reference/linux-study-clean/fs/smb/client/smb2misc.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/client/smb2misc.c- Extension
.c- Size
- 27175 bytes
- Lines
- 922
- 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
crypto/sha2.hlinux/ctype.hcifsglob.hcifsproto.hsmb2proto.hcifs_debug.hcifs_unicode.h../common/smb2status.hsmb2glob.hnterr.hcached_dir.h
Detected Declarations
struct smb2_lease_break_workfunction Copyrightfunction get_neg_ctxt_lenfunction smb2_check_messagefunction list_for_each_entryfunction itfunction smb2_calc_sizefunction cifs_convert_path_to_utf16function smb2_get_lease_statefunction cifs_ses_oplock_breakfunction smb2_queue_pending_open_breakfunction smb2_tcon_has_leasefunction list_for_each_entryfunction smb2_tcon_find_pending_open_leasefunction list_for_each_entryfunction smb2_is_valid_lease_breakfunction list_for_each_entryfunction smb2_is_valid_oplock_breakfunction list_for_each_entryfunction list_for_each_entryfunction smb2_cancelled_close_fidfunction __smb2_handle_cancelled_cmdfunction smb2_handle_cancelled_closefunction smb2_handle_cancelled_midfunction smb311_update_preauth_hash
Annotated Snippet
struct smb2_lease_break_work {
struct work_struct lease_break;
struct tcon_link *tlink;
__u8 lease_key[16];
__le32 lease_state;
};
static void
cifs_ses_oplock_break(struct work_struct *work)
{
struct smb2_lease_break_work *lw = container_of(work,
struct smb2_lease_break_work, lease_break);
int rc = 0;
rc = SMB2_lease_break(0, tlink_tcon(lw->tlink), lw->lease_key,
lw->lease_state);
cifs_dbg(FYI, "Lease release rc %d\n", rc);
cifs_put_tlink(lw->tlink);
kfree(lw);
}
static void
smb2_queue_pending_open_break(struct tcon_link *tlink, __u8 *lease_key,
__le32 new_lease_state)
{
struct smb2_lease_break_work *lw;
lw = kmalloc_obj(struct smb2_lease_break_work);
if (!lw) {
cifs_put_tlink(tlink);
return;
}
INIT_WORK(&lw->lease_break, cifs_ses_oplock_break);
lw->tlink = tlink;
lw->lease_state = new_lease_state;
memcpy(lw->lease_key, lease_key, SMB2_LEASE_KEY_SIZE);
queue_work(cifsiod_wq, &lw->lease_break);
}
static bool
smb2_tcon_has_lease(struct cifs_tcon *tcon, struct smb2_lease_break *rsp)
{
__u8 lease_state;
struct cifsFileInfo *cfile;
struct cifsInodeInfo *cinode;
int ack_req = le32_to_cpu(rsp->Flags &
SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED);
lease_state = le32_to_cpu(rsp->NewLeaseState);
list_for_each_entry(cfile, &tcon->openFileList, tlist) {
cinode = CIFS_I(d_inode(cfile->dentry));
if (memcmp(cinode->lease_key, rsp->LeaseKey,
SMB2_LEASE_KEY_SIZE))
continue;
cifs_dbg(FYI, "found in the open list\n");
cifs_dbg(FYI, "lease key match, lease break 0x%x\n",
lease_state);
if (ack_req)
cfile->oplock_break_cancelled = false;
else
cfile->oplock_break_cancelled = true;
set_bit(CIFS_INODE_PENDING_OPLOCK_BREAK, &cinode->flags);
cfile->oplock_epoch = le16_to_cpu(rsp->Epoch);
cfile->oplock_level = lease_state;
cifs_queue_oplock_break(cfile);
return true;
}
return false;
}
static struct cifs_pending_open *
smb2_tcon_find_pending_open_lease(struct cifs_tcon *tcon,
struct smb2_lease_break *rsp)
{
__u8 lease_state = le32_to_cpu(rsp->NewLeaseState);
int ack_req = le32_to_cpu(rsp->Flags &
SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED);
struct cifs_pending_open *open;
struct cifs_pending_open *found = NULL;
Annotation
- Immediate include surface: `crypto/sha2.h`, `linux/ctype.h`, `cifsglob.h`, `cifsproto.h`, `smb2proto.h`, `cifs_debug.h`, `cifs_unicode.h`, `../common/smb2status.h`.
- Detected declarations: `struct smb2_lease_break_work`, `function Copyright`, `function get_neg_ctxt_len`, `function smb2_check_message`, `function list_for_each_entry`, `function it`, `function smb2_calc_size`, `function cifs_convert_path_to_utf16`, `function smb2_get_lease_state`, `function cifs_ses_oplock_break`.
- 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.