fs/autofs/expire.c
Source file repositories/reference/linux-study-clean/fs/autofs/expire.c
File Facts
- System
- Linux kernel
- Corpus path
fs/autofs/expire.c- Extension
.c- Size
- 14746 bytes
- Lines
- 621
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
autofs_i.h
Detected Declarations
function autofs_can_expirefunction autofs_mount_busyfunction hlist_for_each_entry_fromfunction autofs_direct_busyfunction autofs_tree_busyfunction dgetfunction offsetfunction autofs_expire_waitfunction autofs_expire_runfunction autofs_do_expire_multifunction autofs_expire_multi
Annotated Snippet
if (simple_positive(child)) {
dget_dlock(child);
spin_unlock(&child->d_lock);
return child;
}
spin_unlock(&child->d_lock);
}
return NULL;
}
/*
* Calculate and dget next entry in the subdirs list under root.
*/
static struct dentry *get_next_positive_subdir(struct dentry *prev,
struct dentry *root)
{
struct autofs_sb_info *sbi = autofs_sbi(root->d_sb);
struct dentry *q;
spin_lock(&sbi->lookup_lock);
spin_lock(&root->d_lock);
q = positive_after(root, prev);
spin_unlock(&root->d_lock);
spin_unlock(&sbi->lookup_lock);
dput(prev);
return q;
}
/*
* Calculate and dget next entry in top down tree traversal.
*/
static struct dentry *get_next_positive_dentry(struct dentry *prev,
struct dentry *root)
{
struct autofs_sb_info *sbi = autofs_sbi(root->d_sb);
struct dentry *p = prev, *ret = NULL, *d = NULL;
if (prev == NULL)
return dget(root);
spin_lock(&sbi->lookup_lock);
spin_lock(&p->d_lock);
while (1) {
struct dentry *parent;
ret = positive_after(p, d);
if (ret || p == root)
break;
parent = p->d_parent;
spin_unlock(&p->d_lock);
spin_lock(&parent->d_lock);
d = p;
p = parent;
}
spin_unlock(&p->d_lock);
spin_unlock(&sbi->lookup_lock);
dput(prev);
return ret;
}
/*
* Check a direct mount point for busyness.
* Direct mounts have similar expiry semantics to tree mounts.
* The tree is not busy iff no mountpoints are busy and there are no
* autofs submounts.
*/
static int autofs_direct_busy(struct vfsmount *mnt,
struct dentry *top,
unsigned long timeout,
unsigned int how)
{
pr_debug("top %p %pd\n", top, top);
/* Forced expire, user space handles busy mounts */
if (how & AUTOFS_EXP_FORCED)
return 0;
/* If it's busy update the expiry counters */
if (!may_umount_tree(mnt)) {
struct autofs_info *ino;
ino = autofs_dentry_ino(top);
if (ino)
ino->last_used = jiffies;
return 1;
}
/* Timeout of a direct mount is determined by its top dentry */
if (!autofs_can_expire(top, timeout, how))
Annotation
- Immediate include surface: `autofs_i.h`.
- Detected declarations: `function autofs_can_expire`, `function autofs_mount_busy`, `function hlist_for_each_entry_from`, `function autofs_direct_busy`, `function autofs_tree_busy`, `function dget`, `function offset`, `function autofs_expire_wait`, `function autofs_expire_run`, `function autofs_do_expire_multi`.
- 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.