fs/xfs/scrub/rtrmap_repair.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/rtrmap_repair.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/rtrmap_repair.c- Extension
.c- Size
- 24841 bytes
- Lines
- 979
- 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_trans_resv.hxfs_mount.hxfs_defer.hxfs_btree.hxfs_btree_staging.hxfs_buf_mem.hxfs_btree_mem.hxfs_bit.hxfs_log_format.hxfs_trans.hxfs_sb.hxfs_alloc.hxfs_rmap.hxfs_rmap_btree.hxfs_rtrmap_btree.hxfs_inode.hxfs_icache.hxfs_bmap.hxfs_bmap_btree.hxfs_quota.hxfs_rtalloc.hxfs_ag.hxfs_rtgroup.hxfs_refcount.hscrub/xfs_scrub.hscrub/scrub.hscrub/common.hscrub/btree.h
Detected Declarations
struct xrep_rtrmapstruct xrep_rtrmap_iforkstruct xrep_rtrmap_stash_runfunction xrep_setup_rtrmapbtfunction xrep_rtrmap_check_mappingfunction xrep_rtrmap_stashfunction xrep_rtrmap_stash_accumulatedfunction xrep_rtrmap_visit_bmbtfunction xrep_rtrmap_scan_bmbtfunction xrep_rtrmap_scan_iextfunction for_each_xfs_iextfunction xrep_rtrmap_scan_dforkfunction xrep_rtrmap_scan_inodefunction xrep_rtrmap_walk_rmapfunction xrep_rtrmap_scan_agfunction xrep_rtrmap_stash_runfunction xrep_rtrmap_stash_bitmapfunction xrep_rtrmap_walk_cowblocksfunction xrep_rtrmap_find_refcount_rmapsfunction xrep_rtrmap_check_recordfunction xrep_rtrmap_find_rmapsfunction xrep_rtrmap_get_recordsfunction xrep_rtrmap_claim_blockfunction xrep_rtrmap_iroot_sizefunction xrep_rtrmap_build_new_treefunction xrep_rtrmapbt_want_live_updatefunction xrep_rtrmapbt_live_updatefunction xrep_rtrmap_setup_scanfunction xrep_rtrmap_teardownfunction xrep_rtrmapbt
Annotated Snippet
struct xrep_rtrmap {
/* new rtrmapbt information */
struct xrep_newbt new_btree;
/* lock for the xfbtree and xfile */
struct mutex lock;
/* rmap records generated from primary metadata */
struct xfbtree rtrmap_btree;
struct xfs_scrub *sc;
/* bitmap of old rtrmapbt blocks */
struct xfsb_bitmap old_rtrmapbt_blocks;
/* Hooks into rtrmap update code. */
struct xfs_rmap_hook rhook;
/* inode scan cursor */
struct xchk_iscan iscan;
/* in-memory btree cursor for the ->get_blocks walk */
struct xfs_btree_cur *mcur;
/* Number of records we're staging in the new btree. */
uint64_t nr_records;
};
/* Set us up to repair rt reverse mapping btrees. */
int
xrep_setup_rtrmapbt(
struct xfs_scrub *sc)
{
struct xrep_rtrmap *rr;
int error;
xchk_fsgates_enable(sc, XCHK_FSGATES_RMAP);
error = xrep_setup_xfbtree(sc, "realtime reverse mapping records");
if (error)
return error;
rr = kzalloc_obj(struct xrep_rtrmap, XCHK_GFP_FLAGS);
if (!rr)
return -ENOMEM;
rr->sc = sc;
sc->buf = rr;
return 0;
}
/* Make sure there's nothing funny about this mapping. */
STATIC int
xrep_rtrmap_check_mapping(
struct xfs_scrub *sc,
const struct xfs_rmap_irec *rec)
{
if (xfs_rtrmap_check_irec(sc->sr.rtg, rec) != NULL)
return -EFSCORRUPTED;
/* Make sure this isn't free space. */
return xrep_require_rtext_inuse(sc, rec->rm_startblock,
rec->rm_blockcount);
}
/* Store a reverse-mapping record. */
static inline int
xrep_rtrmap_stash(
struct xrep_rtrmap *rr,
xfs_rgblock_t startblock,
xfs_extlen_t blockcount,
uint64_t owner,
uint64_t offset,
unsigned int flags)
{
struct xfs_rmap_irec rmap = {
.rm_startblock = startblock,
.rm_blockcount = blockcount,
.rm_owner = owner,
.rm_offset = offset,
.rm_flags = flags,
};
struct xfs_scrub *sc = rr->sc;
struct xfs_btree_cur *mcur;
int error = 0;
if (xchk_should_terminate(sc, &error))
return error;
if (xchk_iscan_aborted(&rr->iscan))
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_rtrmap`, `struct xrep_rtrmap_ifork`, `struct xrep_rtrmap_stash_run`, `function xrep_setup_rtrmapbt`, `function xrep_rtrmap_check_mapping`, `function xrep_rtrmap_stash`, `function xrep_rtrmap_stash_accumulated`, `function xrep_rtrmap_visit_bmbt`, `function xrep_rtrmap_scan_bmbt`, `function xrep_rtrmap_scan_iext`.
- 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.