fs/xfs/xfs_iwalk.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_iwalk.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_iwalk.c- Extension
.c- Size
- 20560 bytes
- Lines
- 755
- 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.
- 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_btree.hxfs_ialloc.hxfs_ialloc_btree.hxfs_iwalk.hxfs_error.hxfs_trace.hxfs_icache.hxfs_health.hxfs_trans.hxfs_pwork.hxfs_ag.hxfs_bit.h
Detected Declarations
struct xfs_iwalk_agfunction xfs_iwalk_ichunk_rafunction xfs_iwalk_allocfunction xfs_iwalk_freefunction xfs_iwalk_ag_recsfunction xfs_iwalk_del_inobtfunction xfs_iwalk_ag_startfunction fullfunction xfs_iwalk_agfunction xfs_iwalk_prefetchfunction xfs_iwalk_argsfunction xfs_iwalkfunction xfs_iwalk_ag_workfunction xfs_iwalk_threadedfunction xfs_inobt_walk_prefetchfunction xfs_inobt_walk
Annotated Snippet
struct xfs_iwalk_ag {
/* parallel work control data; will be null if single threaded */
struct xfs_pwork pwork;
struct xfs_mount *mp;
struct xfs_trans *tp;
struct xfs_perag *pag;
/* Where do we start the traversal? */
xfs_ino_t startino;
/* What was the last inode number we saw when iterating the inobt? */
xfs_ino_t lastino;
/* Array of inobt records we cache. */
struct xfs_inobt_rec_incore *recs;
/* Number of entries allocated for the @recs array. */
unsigned int sz_recs;
/* Number of entries in the @recs array that are in use. */
unsigned int nr_recs;
/* Inode walk function and data pointer. */
xfs_iwalk_fn iwalk_fn;
xfs_inobt_walk_fn inobt_walk_fn;
void *data;
/*
* Make it look like the inodes up to startino are free so that
* bulkstat can start its inode iteration at the correct place without
* needing to special case everywhere.
*/
unsigned int trim_start:1;
/* Skip empty inobt records? */
unsigned int skip_empty:1;
/* Drop the (hopefully empty) transaction when calling iwalk_fn. */
unsigned int drop_trans:1;
};
/*
* Loop over all clusters in a chunk for a given incore inode allocation btree
* record. Do a readahead if there are any allocated inodes in that cluster.
*/
STATIC void
xfs_iwalk_ichunk_ra(
struct xfs_mount *mp,
struct xfs_perag *pag,
struct xfs_inobt_rec_incore *irec)
{
struct xfs_ino_geometry *igeo = M_IGEO(mp);
xfs_agblock_t agbno;
struct blk_plug plug;
int i; /* inode chunk index */
agbno = XFS_AGINO_TO_AGBNO(mp, irec->ir_startino);
blk_start_plug(&plug);
for (i = 0; i < XFS_INODES_PER_CHUNK; i += igeo->inodes_per_cluster) {
xfs_inofree_t imask;
imask = xfs_inobt_maskn(i, igeo->inodes_per_cluster);
if (imask & ~irec->ir_free) {
xfs_buf_readahead(mp->m_ddev_targp,
xfs_agbno_to_daddr(pag, agbno),
igeo->blocks_per_cluster * mp->m_bsize,
&xfs_inode_buf_ops);
}
agbno += igeo->blocks_per_cluster;
}
blk_finish_plug(&plug);
}
/*
* Set the bits in @irec's free mask that correspond to the inodes before
* @agino so that we skip them. This is how we restart an inode walk that was
* interrupted in the middle of an inode record.
*/
STATIC void
xfs_iwalk_adjust_start(
xfs_agino_t agino, /* starting inode of chunk */
struct xfs_inobt_rec_incore *irec) /* btree record */
{
int idx; /* index into inode chunk */
idx = agino - irec->ir_startino;
irec->ir_free |= xfs_inobt_maskn(0, idx);
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: `struct xfs_iwalk_ag`, `function xfs_iwalk_ichunk_ra`, `function xfs_iwalk_alloc`, `function xfs_iwalk_free`, `function xfs_iwalk_ag_recs`, `function xfs_iwalk_del_inobt`, `function xfs_iwalk_ag_start`, `function full`, `function xfs_iwalk_ag`, `function xfs_iwalk_prefetch`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
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.