fs/xfs/xfs_icache.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_icache.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_icache.c- Extension
.c- Size
- 60455 bytes
- Lines
- 2357
- 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
xfs_platform.hxfs_fs.hxfs_shared.hxfs_format.hxfs_log_format.hxfs_trans_resv.hxfs_mount.hxfs_inode.hxfs_trans.hxfs_trans_priv.hxfs_inode_item.hxfs_quota.hxfs_trace.hxfs_icache.hxfs_bmap_util.hxfs_dquot_item.hxfs_dquot.hxfs_reflink.hxfs_ialloc.hxfs_ag.hxfs_log_priv.hxfs_health.hxfs_da_format.hxfs_dir2.hxfs_metafile.hlinux/iversion.h
Detected Declarations
enum xfs_icwalk_goalfunction ici_tag_to_markfunction xfs_inode_allocfunction xfs_inode_free_callbackfunction __xfs_inode_freefunction xfs_inode_freefunction xfs_reclaim_work_queuefunction xfs_blockgc_queuefunction xfs_perag_set_inode_tagfunction xfs_perag_clear_inode_tagfunction xfs_perag_grab_next_tagfunction xfs_reinit_inodefunction xfs_iget_recyclefunction xfs_iget_check_free_statefunction xfs_inodegc_queue_allfunction for_each_cpufunction xfs_inodegc_wait_allfunction xfs_iget_cache_hitfunction xfs_iget_cache_missfunction xfs_igetfunction xfs_trans_metafile_igetfunction xfs_metafile_igetfunction xfs_igetfunction __xfs_iflags_testfunction xfs_reclaim_inodefunction xfs_want_reclaim_sickfunction xfs_reclaim_inodesfunction xfs_reclaim_inodes_nrfunction xfs_reclaim_inodes_countfunction xfs_icwalk_match_idfunction xfs_icwalk_match_id_unionfunction xfs_icwalk_matchfunction xfs_reclaim_workerfunction xfs_inode_free_eofblocksfunction xfs_blockgc_set_iflagfunction xfs_inode_set_eofblocks_tagfunction xfs_blockgc_clear_iflagfunction xfs_inode_clear_eofblocks_tagfunction xfs_prep_free_cowblocksfunction xfs_inode_free_cowblocksfunction xfs_inode_set_cowblocks_tagfunction xfs_inode_clear_cowblocks_tagfunction xfs_blockgc_stopfunction xfs_blockgc_startfunction xfs_blockgc_igrabfunction xfs_blockgc_scan_inodefunction xfs_blockgc_workerfunction xfs_blockgc_free_space
Annotated Snippet
if (VFS_I(ip)->i_mode != 0) {
xfs_warn(ip->i_mount,
"Corruption detected! Free inode 0x%llx not marked free! (mode 0x%x)",
I_INO(ip), VFS_I(ip)->i_mode);
xfs_agno_mark_sick(ip->i_mount, XFS_INODE_TO_AGNO(ip),
XFS_SICK_AG_INOBT);
return -EFSCORRUPTED;
}
if (ip->i_nblocks != 0) {
xfs_warn(ip->i_mount,
"Corruption detected! Free inode 0x%llx has blocks allocated!",
I_INO(ip));
xfs_agno_mark_sick(ip->i_mount, XFS_INODE_TO_AGNO(ip),
XFS_SICK_AG_INOBT);
return -EFSCORRUPTED;
}
return 0;
}
/* should be an allocated inode */
if (VFS_I(ip)->i_mode == 0)
return -ENOENT;
return 0;
}
/* Make all pending inactivation work start immediately. */
static bool
xfs_inodegc_queue_all(
struct xfs_mount *mp)
{
struct xfs_inodegc *gc;
int cpu;
bool ret = false;
for_each_cpu(cpu, &mp->m_inodegc_cpumask) {
gc = per_cpu_ptr(mp->m_inodegc, cpu);
if (!llist_empty(&gc->list)) {
mod_delayed_work_on(cpu, mp->m_inodegc_wq, &gc->work, 0);
ret = true;
}
}
return ret;
}
/* Wait for all queued work and collect errors */
static int
xfs_inodegc_wait_all(
struct xfs_mount *mp)
{
int cpu;
int error = 0;
flush_workqueue(mp->m_inodegc_wq);
for_each_cpu(cpu, &mp->m_inodegc_cpumask) {
struct xfs_inodegc *gc;
gc = per_cpu_ptr(mp->m_inodegc, cpu);
if (gc->error && !error)
error = gc->error;
gc->error = 0;
}
return error;
}
/*
* Check the validity of the inode we just found it the cache
*/
static int
xfs_iget_cache_hit(
struct xfs_perag *pag,
struct xfs_inode *ip,
xfs_ino_t ino,
int flags,
int lock_flags) __releases(RCU)
{
struct inode *inode = VFS_I(ip);
struct xfs_mount *mp = ip->i_mount;
int error;
/*
* check for re-use of an inode within an RCU grace period due to the
* radix tree nodes not being updated yet. We monitor for this by
* setting the inode number to zero before freeing the inode structure.
* If the inode has been reallocated and set up, then the inode number
* will not match, so check for that, too.
*/
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_inode.h`.
- Detected declarations: `enum xfs_icwalk_goal`, `function ici_tag_to_mark`, `function xfs_inode_alloc`, `function xfs_inode_free_callback`, `function __xfs_inode_free`, `function xfs_inode_free`, `function xfs_reclaim_work_queue`, `function xfs_blockgc_queue`, `function xfs_perag_set_inode_tag`, `function xfs_perag_clear_inode_tag`.
- 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.