fs/smb/client/file.c
Source file repositories/reference/linux-study-clean/fs/smb/client/file.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/client/file.c- Extension
.c- Size
- 95997 bytes
- Lines
- 3457
- 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_struct.hlinux/filelock.hlinux/backing-dev.hlinux/stat.hlinux/fcntl.hlinux/pagemap.hlinux/writeback.hlinux/task_io_accounting_ops.hlinux/delay.hlinux/mount.hlinux/slab.hlinux/swap.hlinux/mm.hasm/div64.hcifsfs.hcifsglob.hcifsproto.hsmb2proto.hcifs_unicode.hcifs_debug.hcifs_fs_sb.hfscache.hsmbdirect.hfs_context.hcifs_ioctl.hcached_dir.htrace/events/netfs.h
Detected Declarations
struct lock_to_pushfunction cifs_prepare_writefunction cifs_issue_writefunction cifs_netfs_invalidate_cachefunction cifs_prepare_readfunction cifs_issue_readfunction cifs_begin_writebackfunction cifs_init_requestfunction cifs_rreq_donefunction cifs_free_requestfunction cifs_free_subrequestfunction cifs_mark_open_files_invalidfunction evict_inodesfunction cifs_posix_convert_flagsfunction cifs_get_dispositionfunction cifs_posix_openfunction cifs_nt_openfunction cifs_has_mand_locksfunction cifs_down_writefunction cifsFileInfo_getfunction cifsFileInfo_put_finalfunction cifsFileInfo_put_workfunction serverclose_workfunction cifsFileInfo_putfunction _cifsFileInfo_putfunction cifs_file_flushfunction cifs_do_truncatefunction cifs_openfunction cap_unixfunction cifs_relock_filefunction cifs_reopen_filefunction le64_to_cpufunction smb2_deferred_work_closefunction smb2_can_defer_closefunction cifs_closefunction cifs_reopen_persistent_handlesfunction list_for_each_entry_safefunction cifs_closedirfunction cifs_lock_initfunction cifs_del_lock_waitersfunction cifs_find_fid_lock_conflictfunction list_for_each_entryfunction cifs_find_lock_conflictfunction list_for_each_entryfunction lockfunction cifs_lock_addfunction cifs_lock_add_iffunction lock
Annotated Snippet
struct lock_to_push {
struct list_head llist;
__u64 offset;
__u64 length;
__u32 pid;
__u16 netfid;
__u8 type;
};
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
static int
cifs_push_posix_locks(struct cifsFileInfo *cfile)
{
struct inode *inode = d_inode(cfile->dentry);
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
struct file_lock *flock;
struct file_lock_context *flctx = locks_inode_context(inode);
unsigned int count = 0, i;
int rc = 0, xid, type;
struct list_head locks_to_send, *el;
struct lock_to_push *lck, *tmp;
__u64 length;
xid = get_xid();
if (!flctx)
goto out;
spin_lock(&flctx->flc_lock);
list_for_each(el, &flctx->flc_posix) {
count++;
}
spin_unlock(&flctx->flc_lock);
INIT_LIST_HEAD(&locks_to_send);
/*
* Allocating count locks is enough because no FL_POSIX locks can be
* added to the list while we are holding cinode->lock_sem that
* protects locking operations of this inode.
*/
for (i = 0; i < count; i++) {
lck = kmalloc_obj(struct lock_to_push);
if (!lck) {
rc = -ENOMEM;
goto err_out;
}
list_add_tail(&lck->llist, &locks_to_send);
}
el = locks_to_send.next;
spin_lock(&flctx->flc_lock);
for_each_file_lock(flock, &flctx->flc_posix) {
unsigned char ftype = flock->c.flc_type;
if (el == &locks_to_send) {
/*
* The list ended. We don't have enough allocated
* structures - something is really wrong.
*/
cifs_dbg(VFS, "Can't push all brlocks!\n");
break;
}
length = cifs_flock_len(flock);
if (ftype == F_RDLCK || ftype == F_SHLCK)
type = CIFS_RDLCK;
else
type = CIFS_WRLCK;
lck = list_entry(el, struct lock_to_push, llist);
lck->pid = hash_lockowner(flock->c.flc_owner);
lck->netfid = cfile->fid.netfid;
lck->length = length;
lck->type = type;
lck->offset = flock->fl_start;
}
spin_unlock(&flctx->flc_lock);
list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) {
int stored_rc;
stored_rc = CIFSSMBPosixLock(xid, tcon, lck->netfid, lck->pid,
lck->offset, lck->length, NULL,
lck->type, 0);
if (stored_rc)
rc = stored_rc;
list_del(&lck->llist);
kfree(lck);
}
out:
Annotation
- Immediate include surface: `linux/fs.h`, `linux/fs_struct.h`, `linux/filelock.h`, `linux/backing-dev.h`, `linux/stat.h`, `linux/fcntl.h`, `linux/pagemap.h`, `linux/writeback.h`.
- Detected declarations: `struct lock_to_push`, `function cifs_prepare_write`, `function cifs_issue_write`, `function cifs_netfs_invalidate_cache`, `function cifs_prepare_read`, `function cifs_issue_read`, `function cifs_begin_writeback`, `function cifs_init_request`, `function cifs_rreq_done`, `function cifs_free_request`.
- 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.