fs/xfs/scrub/agheader.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/agheader.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/agheader.c- Extension
.c- Size
- 28587 bytes
- Lines
- 1062
- 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.
- 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_trans_resv.hxfs_mount.hxfs_btree.hxfs_sb.hxfs_alloc.hxfs_ialloc.hxfs_rmap.hxfs_ag.hxfs_inode.hscrub/scrub.hscrub/common.h
Detected Declarations
struct xchk_agfl_infofunction Copyrightfunction xchk_superblock_xreffunction filesystemfunction xchk_superblockfunction xchk_agf_record_bno_lengthsfunction xchk_agf_xref_freeblksfunction xchk_agf_xref_cntbtfunction xchk_agf_xref_btreeblksfunction xchk_agf_xref_refcblksfunction xchk_agf_xreffunction xchk_agffunction xchk_agfl_block_xreffunction xchk_agfl_blockfunction xchk_agblock_cmpfunction xchk_agfl_xreffunction xchk_agflfunction xchk_agi_xref_icountsfunction xchk_agi_xref_fiblocksfunction xchk_agi_xreffunction xchk_iunlinkfunction xchk_agi
Annotated Snippet
struct xchk_agfl_info {
/* Number of AGFL entries that the AGF claims are in use. */
unsigned int agflcount;
/* Number of AGFL entries that we found. */
unsigned int nr_entries;
/* Buffer to hold AGFL entries for extent checking. */
xfs_agblock_t *entries;
struct xfs_buf *agfl_bp;
struct xfs_scrub *sc;
};
/* Cross-reference with the other btrees. */
STATIC void
xchk_agfl_block_xref(
struct xfs_scrub *sc,
xfs_agblock_t agbno)
{
if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
return;
xchk_xref_is_used_space(sc, agbno, 1);
xchk_xref_is_not_inode_chunk(sc, agbno, 1);
xchk_xref_is_only_owned_by(sc, agbno, 1, &XFS_RMAP_OINFO_AG);
xchk_xref_is_not_shared(sc, agbno, 1);
xchk_xref_is_not_cow_staging(sc, agbno, 1);
}
/* Scrub an AGFL block. */
STATIC int
xchk_agfl_block(
struct xfs_mount *mp,
xfs_agblock_t agbno,
void *priv)
{
struct xchk_agfl_info *sai = priv;
struct xfs_scrub *sc = sai->sc;
if (xfs_verify_agbno(sc->sa.pag, agbno) &&
sai->nr_entries < sai->agflcount)
sai->entries[sai->nr_entries++] = agbno;
else
xchk_block_set_corrupt(sc, sai->agfl_bp);
xchk_agfl_block_xref(sc, agbno);
if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
return -ECANCELED;
return 0;
}
static int
xchk_agblock_cmp(
const void *pa,
const void *pb)
{
const xfs_agblock_t *a = pa;
const xfs_agblock_t *b = pb;
return (int)*a - (int)*b;
}
/* Cross-reference with the other btrees. */
STATIC void
xchk_agfl_xref(
struct xfs_scrub *sc)
{
struct xfs_mount *mp = sc->mp;
xfs_agblock_t agbno;
if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
return;
agbno = XFS_AGFL_BLOCK(mp);
xchk_ag_btcur_init(sc, &sc->sa);
xchk_xref_is_used_space(sc, agbno, 1);
xchk_xref_is_not_inode_chunk(sc, agbno, 1);
xchk_xref_is_only_owned_by(sc, agbno, 1, &XFS_RMAP_OINFO_FS);
xchk_xref_is_not_shared(sc, agbno, 1);
xchk_xref_is_not_cow_staging(sc, agbno, 1);
/*
* Scrub teardown will take care of sc->sa for us. Leave sc->sa
* active so that the agfl block xref can use it too.
*/
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_btree.h`, `xfs_sb.h`.
- Detected declarations: `struct xchk_agfl_info`, `function Copyright`, `function xchk_superblock_xref`, `function filesystem`, `function xchk_superblock`, `function xchk_agf_record_bno_lengths`, `function xchk_agf_xref_freeblks`, `function xchk_agf_xref_cntbt`, `function xchk_agf_xref_btreeblks`, `function xchk_agf_xref_refcblks`.
- 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.