fs/xfs/scrub/alloc_repair.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/alloc_repair.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/alloc_repair.c- Extension
.c- Size
- 25976 bytes
- Lines
- 947
- 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_trans_resv.hxfs_mount.hxfs_defer.hxfs_btree.hxfs_btree_staging.hxfs_bit.hxfs_log_format.hxfs_trans.hxfs_sb.hxfs_alloc.hxfs_alloc_btree.hxfs_rmap.hxfs_rmap_btree.hxfs_inode.hxfs_refcount.hxfs_extent_busy.hxfs_health.hxfs_bmap.hxfs_ialloc.hxfs_ag.hscrub/xfs_scrub.hscrub/scrub.hscrub/common.hscrub/btree.hscrub/trace.hscrub/repair.hscrub/bitmap.hscrub/agb_bitmap.h
Detected Declarations
struct xrep_abtfunction xrep_setup_ag_allocbtfunction xrep_abt_check_free_extfunction xrep_abt_stashfunction xrep_abt_walk_rmapfunction xrep_abt_walk_agflfunction xrep_bnobt_extent_cmpfunction xrep_bnobt_sort_recordsfunction xrep_cntbt_extent_cmpfunction xrep_cntbt_sort_recordsfunction findfunction xrep_abt_reserve_spacefunction xrep_abt_dispose_onefunction afunction list_for_each_entry_safefunction xrep_abt_get_recordsfunction xrep_abt_claim_blockfunction xrep_abt_reset_countersfunction xrep_abt_build_new_treesfunction xrep_abt_remove_old_treesfunction xrep_allocbtfunction xrep_revalidate_allocbt
Annotated Snippet
struct xrep_abt {
/* Blocks owned by the rmapbt or the agfl. */
struct xagb_bitmap not_allocbt_blocks;
/* All OWN_AG blocks. */
struct xagb_bitmap old_allocbt_blocks;
/*
* New bnobt information. All btree block reservations are added to
* the reservation list in new_bnobt.
*/
struct xrep_newbt new_bnobt;
/* new cntbt information */
struct xrep_newbt new_cntbt;
/* Free space extents. */
struct xfarray *free_records;
struct xfs_scrub *sc;
/* Number of non-null records in @free_records. */
uint64_t nr_real_records;
/* get_records()'s position in the free space record array. */
xfarray_idx_t array_cur;
/*
* Next block we anticipate seeing in the rmap records. If the next
* rmap record is greater than next_agbno, we have found unused space.
*/
xfs_agblock_t next_agbno;
/* Number of free blocks in this AG. */
xfs_agblock_t nr_blocks;
/* Longest free extent we found in the AG. */
xfs_agblock_t longest;
};
/* Set up to repair AG free space btrees. */
int
xrep_setup_ag_allocbt(
struct xfs_scrub *sc)
{
struct xfs_group *xg = pag_group(sc->sa.pag);
unsigned int busy_gen;
/*
* Make sure the busy extent list is clear because we can't put extents
* on there twice.
*/
if (xfs_extent_busy_list_empty(xg, &busy_gen))
return 0;
return xfs_extent_busy_flush(sc->tp, xg, busy_gen, 0);
}
/* Check for any obvious conflicts in the free extent. */
STATIC int
xrep_abt_check_free_ext(
struct xfs_scrub *sc,
const struct xfs_alloc_rec_incore *rec)
{
enum xbtree_recpacking outcome;
int error;
if (xfs_alloc_check_irec(sc->sa.pag, rec) != NULL)
return -EFSCORRUPTED;
/* Must not be an inode chunk. */
error = xfs_ialloc_has_inodes_at_extent(sc->sa.ino_cur,
rec->ar_startblock, rec->ar_blockcount, &outcome);
if (error)
return error;
if (outcome != XBTREE_RECPACKING_EMPTY)
return -EFSCORRUPTED;
/* Must not be shared or CoW staging. */
if (sc->sa.refc_cur) {
error = xfs_refcount_has_records(sc->sa.refc_cur,
XFS_REFC_DOMAIN_SHARED, rec->ar_startblock,
rec->ar_blockcount, &outcome);
if (error)
return error;
if (outcome != XBTREE_RECPACKING_EMPTY)
return -EFSCORRUPTED;
error = xfs_refcount_has_records(sc->sa.refc_cur,
XFS_REFC_DOMAIN_COW, rec->ar_startblock,
rec->ar_blockcount, &outcome);
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_defer.h`, `xfs_btree.h`.
- Detected declarations: `struct xrep_abt`, `function xrep_setup_ag_allocbt`, `function xrep_abt_check_free_ext`, `function xrep_abt_stash`, `function xrep_abt_walk_rmap`, `function xrep_abt_walk_agfl`, `function xrep_bnobt_extent_cmp`, `function xrep_bnobt_sort_records`, `function xrep_cntbt_extent_cmp`, `function xrep_cntbt_sort_records`.
- 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.