fs/dcache.c
Source file repositories/reference/linux-study-clean/fs/dcache.c
File Facts
- System
- Linux kernel
- Corpus path
fs/dcache.c- Extension
.c- Size
- 97801 bytes
- Lines
- 3521
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/ratelimit.hlinux/string.hlinux/mm.hlinux/fs.hlinux/fscrypt.hlinux/fsnotify.hlinux/slab.hlinux/init.hlinux/hash.hlinux/cache.hlinux/export.hlinux/security.hlinux/seqlock.hlinux/memblock.hlinux/bit_spinlock.hlinux/rculist_bl.hlinux/list_lru.hinternal.hmount.hasm/runtime-const.hasm/word-at-a-time.h
Detected Declarations
struct dentry_stat_tstruct external_namestruct completion_liststruct check_mountstruct select_dataenum d_walk_retfunction vfs_pressure_ratiofunction get_nr_dentryfunction get_nr_dentry_unusedfunction get_nr_dentry_negativefunction proc_nr_dentryfunction init_fs_dcache_sysctlsfunction load_unaligned_zeropadfunction dentry_string_cmpfunction dentry_cmpfunction __d_freefunction __d_free_externalfunction dname_externalfunction take_dentry_name_snapshotfunction release_dentry_name_snapshotfunction __d_set_inode_and_typefunction __d_clear_type_and_inodefunction dentry_freefunction d_iputfunction listfunction d_lru_delfunction d_shrink_delfunction d_shrink_addfunction d_lru_isolatefunction d_lru_shrink_movefunction ___d_dropfunction __d_dropfunction d_dropfunction shrink_dcache_treefunction d_complete_waitersfunction unlink_secondary_rootfunction dentry_unlistfunction d_walkfunction dentry_freefunction treefunction retain_dentryfunction d_mark_dontcachefunction dputfunction lockref_put_returnfunction finish_dputfunction deletionfunction d_make_discardablefunction dentry_free
Annotated Snippet
struct dentry_stat_t {
long nr_dentry;
long nr_unused;
long age_limit; /* age in seconds */
long want_pages; /* pages requested by system */
long nr_negative; /* # of unused negative dentries */
long dummy; /* Reserved for future use */
};
static DEFINE_PER_CPU(long, nr_dentry);
static DEFINE_PER_CPU(long, nr_dentry_unused);
static DEFINE_PER_CPU(long, nr_dentry_negative);
static int dentry_negative_policy;
#if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
/* Statistics gathering. */
static struct dentry_stat_t dentry_stat = {
.age_limit = 45,
};
/*
* Here we resort to our own counters instead of using generic per-cpu counters
* for consistency with what the vfs inode code does. We are expected to harvest
* better code and performance by having our own specialized counters.
*
* Please note that the loop is done over all possible CPUs, not over all online
* CPUs. The reason for this is that we don't want to play games with CPUs going
* on and off. If one of them goes off, we will just keep their counters.
*
* glommer: See cffbc8a for details, and if you ever intend to change this,
* please update all vfs counters to match.
*/
static long get_nr_dentry(void)
{
int i;
long sum = 0;
for_each_possible_cpu(i)
sum += per_cpu(nr_dentry, i);
return sum < 0 ? 0 : sum;
}
static long get_nr_dentry_unused(void)
{
int i;
long sum = 0;
for_each_possible_cpu(i)
sum += per_cpu(nr_dentry_unused, i);
return sum < 0 ? 0 : sum;
}
static long get_nr_dentry_negative(void)
{
int i;
long sum = 0;
for_each_possible_cpu(i)
sum += per_cpu(nr_dentry_negative, i);
return sum < 0 ? 0 : sum;
}
static int proc_nr_dentry(const struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos)
{
dentry_stat.nr_dentry = get_nr_dentry();
dentry_stat.nr_unused = get_nr_dentry_unused();
dentry_stat.nr_negative = get_nr_dentry_negative();
return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
}
static const struct ctl_table fs_dcache_sysctls[] = {
{
.procname = "dentry-state",
.data = &dentry_stat,
.maxlen = 6*sizeof(long),
.mode = 0444,
.proc_handler = proc_nr_dentry,
},
{
.procname = "dentry-negative",
.data = &dentry_negative_policy,
.maxlen = sizeof(dentry_negative_policy),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
};
static const struct ctl_table vm_dcache_sysctls[] = {
{
Annotation
- Immediate include surface: `linux/ratelimit.h`, `linux/string.h`, `linux/mm.h`, `linux/fs.h`, `linux/fscrypt.h`, `linux/fsnotify.h`, `linux/slab.h`, `linux/init.h`.
- Detected declarations: `struct dentry_stat_t`, `struct external_name`, `struct completion_list`, `struct check_mount`, `struct select_data`, `enum d_walk_ret`, `function vfs_pressure_ratio`, `function get_nr_dentry`, `function get_nr_dentry_unused`, `function get_nr_dentry_negative`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration 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.