fs/smb/server/vfs_cache.c
Source file repositories/reference/linux-study-clean/fs/smb/server/vfs_cache.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/server/vfs_cache.c- Extension
.c- Size
- 36176 bytes
- Lines
- 1504
- 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/filelock.hlinux/slab.hlinux/vmalloc.hlinux/kthread.hlinux/freezer.hglob.hvfs_cache.hoplock.hvfs.hconnection.hmisc.hmgmt/tree_connect.hmgmt/user_session.hmgmt/user_config.hsmb_common.hserver.hsmb2pdu.h
Detected Declarations
function proc_show_filesfunction create_proc_filesfunction create_proc_filesfunction ksmbd_set_fd_limitfunction fd_limit_depletedfunction fd_limit_closefunction inode_hashfunction hlist_for_each_entryfunction ksmbd_query_inode_statusfunction ksmbd_inode_pending_deletefunction ksmbd_set_inode_pending_deletefunction ksmbd_clear_inode_pending_deletefunction ksmbd_fd_set_delete_on_closefunction ksmbd_inode_hashfunction ksmbd_inode_unhashfunction ksmbd_inode_initfunction ksmbd_inode_freefunction ksmbd_inode_putfunction ksmbd_inode_hash_initfunction ksmbd_release_inode_hashfunction __ksmbd_inode_closefunction __ksmbd_remove_durable_fdfunction ksmbd_remove_durable_fdfunction __ksmbd_remove_fdfunction __ksmbd_close_fdfunction ksmbd_reopen_durable_fdfunction __put_fd_finalfunction set_close_state_blocked_worksfunction ksmbd_close_fdfunction ksmbd_fd_putfunction __sanity_checkfunction jiffies_to_msecsfunction ksmbd_put_durable_fdfunction __open_id_setfunction __open_idfunction ksmbd_open_durable_fdfunction ksmbd_update_fstatefunction ksmbd_mark_fp_closedfunction __close_file_table_idsfunction connectsfunction transientfunction is_reconnectablefunction tree_conn_fd_checkfunction ksmbd_durable_scavenger_alivefunction ksmbd_scavenger_dispose_dhfunction ksmbd_durable_scavengerfunction idr_for_each_entryfunction ksmbd_launch_ksmbd_durable_scavenger
Annotated Snippet
if (opinfo) {
const struct ksmbd_const_name *const_names;
int count;
unsigned int level;
if (opinfo->is_lease) {
const_names = ksmbd_lease_const_names;
count = ARRAY_SIZE(ksmbd_lease_const_names);
level = le32_to_cpu(opinfo->o_lease->state);
} else {
const_names = ksmbd_oplock_const_names;
count = ARRAY_SIZE(ksmbd_oplock_const_names);
level = opinfo->level;
}
rcu_read_unlock();
ksmbd_proc_show_const_name(m, " %-15s",
const_names, count, level);
} else {
rcu_read_unlock();
seq_printf(m, " %-15s", " ");
}
seq_printf(m, " %#010x %#010x %s\n",
le32_to_cpu(fp->daccess),
le32_to_cpu(fp->saccess),
fp->filp->f_path.dentry->d_name.name);
}
read_unlock(&global_ft.lock);
return 0;
}
static int create_proc_files(void)
{
ksmbd_proc_create("files", proc_show_files, NULL);
return 0;
}
#else
static int create_proc_files(void) { return 0; }
#endif
static bool durable_scavenger_running;
static DEFINE_MUTEX(durable_scavenger_lock);
static wait_queue_head_t dh_wq;
void ksmbd_set_fd_limit(unsigned long limit)
{
limit = min(limit, get_max_files());
atomic_long_set(&fd_limit, limit);
}
static bool fd_limit_depleted(void)
{
long v = atomic_long_dec_return(&fd_limit);
if (v >= 0)
return false;
atomic_long_inc(&fd_limit);
return true;
}
static void fd_limit_close(void)
{
atomic_long_inc(&fd_limit);
}
/*
* INODE hash
*/
static unsigned long inode_hash(struct super_block *sb, unsigned long hashval)
{
unsigned long tmp;
tmp = (hashval * (unsigned long)sb) ^ (GOLDEN_RATIO_PRIME + hashval) /
L1_CACHE_BYTES;
tmp = tmp ^ ((tmp ^ GOLDEN_RATIO_PRIME) >> inode_hash_shift);
return tmp & inode_hash_mask;
}
static struct ksmbd_inode *__ksmbd_inode_lookup(struct dentry *de)
{
struct hlist_head *head = inode_hashtable +
inode_hash(d_inode(de)->i_sb, (unsigned long)de);
struct ksmbd_inode *ci = NULL, *ret_ci = NULL;
hlist_for_each_entry(ci, head, m_hash) {
if (ci->m_de == de) {
if (atomic_inc_not_zero(&ci->m_count))
ret_ci = ci;
break;
Annotation
- Immediate include surface: `linux/fs.h`, `linux/filelock.h`, `linux/slab.h`, `linux/vmalloc.h`, `linux/kthread.h`, `linux/freezer.h`, `glob.h`, `vfs_cache.h`.
- Detected declarations: `function proc_show_files`, `function create_proc_files`, `function create_proc_files`, `function ksmbd_set_fd_limit`, `function fd_limit_depleted`, `function fd_limit_close`, `function inode_hash`, `function hlist_for_each_entry`, `function ksmbd_query_inode_status`, `function ksmbd_inode_pending_delete`.
- 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.