fs/xfs/scrub/repair.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/repair.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/repair.c- Extension
.c- Size
- 38111 bytes
- Lines
- 1411
- 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.
- 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_log_format.hxfs_trans.hxfs_sb.hxfs_inode.hxfs_alloc.hxfs_alloc_btree.hxfs_ialloc.hxfs_ialloc_btree.hxfs_rmap.hxfs_rmap_btree.hxfs_refcount_btree.hxfs_rtbitmap.hxfs_extent_busy.hxfs_ag.hxfs_ag_resv.hxfs_quota.hxfs_qm.hxfs_defer.hxfs_errortag.hxfs_error.hxfs_reflink.hxfs_health.hxfs_buf_mem.hxfs_da_format.hxfs_da_btree.h
Detected Declarations
struct xrep_findrootfunction Copyrightfunction xrep_failurefunction xrep_probefunction xrep_roll_ag_transfunction blifunction xrep_roll_transfunction xrep_defer_finishfunction blifunction xrep_ag_has_spacefunction xrep_calc_ag_resblksfunction xrep_calc_rtgroup_resblksfunction removedfunction xrep_findroot_agfl_walkfunction xrep_findroot_blockfunction xrep_findroot_rmapfunction xrep_find_ag_btree_rootsfunction xrep_update_qflagsfunction xrep_force_quotacheckfunction xrep_ino_dqattachfunction xrep_ino_ensure_extent_countfunction xrep_ag_btcur_initfunction xrep_reinit_pagffunction xrep_reinit_pagifunction xrep_ag_initfunction xrep_rtgroup_btcur_initfunction xrep_rtgroup_initfunction xrep_require_rtext_inusefunction xrep_reset_perag_resvfunction xrep_will_attemptfunction xrep_metadata_inode_subtypefunction xrep_metadata_inode_forksfunction xrep_setup_xfbtreefunction xrep_buf_verify_structfunction xrep_check_ino_btree_mappingfunction xrep_inode_set_nblocksfunction xrep_reset_metafile_resv
Annotated Snippet
struct xrep_findroot {
struct xfs_scrub *sc;
struct xfs_buf *agfl_bp;
struct xfs_agf *agf;
struct xrep_find_ag_btree *btree_info;
};
/* See if our block is in the AGFL. */
STATIC int
xrep_findroot_agfl_walk(
struct xfs_mount *mp,
xfs_agblock_t bno,
void *priv)
{
xfs_agblock_t *agbno = priv;
return (*agbno == bno) ? -ECANCELED : 0;
}
/* Does this block match the btree information passed in? */
STATIC int
xrep_findroot_block(
struct xrep_findroot *ri,
struct xrep_find_ag_btree *fab,
uint64_t owner,
xfs_agblock_t agbno,
bool *done_with_block)
{
struct xfs_mount *mp = ri->sc->mp;
struct xfs_buf *bp;
struct xfs_btree_block *btblock;
xfs_daddr_t daddr;
int block_level;
int error = 0;
daddr = xfs_agbno_to_daddr(ri->sc->sa.pag, agbno);
/*
* Blocks in the AGFL have stale contents that might just happen to
* have a matching magic and uuid. We don't want to pull these blocks
* in as part of a tree root, so we have to filter out the AGFL stuff
* here. If the AGFL looks insane we'll just refuse to repair.
*/
if (owner == XFS_RMAP_OWN_AG) {
error = xfs_agfl_walk(mp, ri->agf, ri->agfl_bp,
xrep_findroot_agfl_walk, &agbno);
if (error == -ECANCELED)
return 0;
if (error)
return error;
}
/*
* Read the buffer into memory so that we can see if it's a match for
* our btree type. We have no clue if it is beforehand, and we want to
* avoid xfs_trans_read_buf's behavior of dumping the DONE state (which
* will cause needless disk reads in subsequent calls to this function)
* and logging metadata verifier failures.
*
* Therefore, pass in NULL buffer ops. If the buffer was already in
* memory from some other caller it will already have b_ops assigned.
* If it was in memory from a previous unsuccessful findroot_block
* call, the buffer won't have b_ops but it should be clean and ready
* for us to try to verify if the read call succeeds. The same applies
* if the buffer wasn't in memory at all.
*
* Note: If we never match a btree type with this buffer, it will be
* left in memory with NULL b_ops. This shouldn't be a problem unless
* the buffer gets written.
*/
error = xfs_trans_read_buf(mp, ri->sc->tp, mp->m_ddev_targp, daddr,
mp->m_bsize, 0, &bp, NULL);
if (error)
return error;
/* Ensure the block magic matches the btree type we're looking for. */
btblock = XFS_BUF_TO_BLOCK(bp);
ASSERT(fab->buf_ops->magic[1] != 0);
if (btblock->bb_magic != fab->buf_ops->magic[1])
goto out;
/*
* If the buffer already has ops applied and they're not the ones for
* this btree type, we know this block doesn't match the btree and we
* can bail out.
*
* If the buffer ops match ours, someone else has already validated
* the block for us, so we can move on to checking if this is a root
* block candidate.
*
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_log_format.h`.
- Detected declarations: `struct xrep_findroot`, `function Copyright`, `function xrep_failure`, `function xrep_probe`, `function xrep_roll_ag_trans`, `function bli`, `function xrep_roll_trans`, `function xrep_defer_finish`, `function bli`, `function xrep_ag_has_space`.
- 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.