fs/xfs/scrub/rtrefcount_repair.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/rtrefcount_repair.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/rtrefcount_repair.c- Extension
.c- Size
- 19811 bytes
- Lines
- 753
- 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_ialloc.hxfs_rmap.hxfs_rmap_btree.hxfs_rtrmap_btree.hxfs_refcount.hxfs_rtrefcount_btree.hxfs_error.hxfs_health.hxfs_inode.hxfs_quota.hxfs_rtalloc.hxfs_ag.hxfs_rtgroup.hxfs_rtbitmap.hscrub/xfs_scrub.hscrub/scrub.hscrub/common.hscrub/btree.h
Detected Declarations
struct xrep_rtrefcfunction xrep_setup_rtrefcountbtfunction xrep_rtrefc_check_extfunction xrep_rtrefc_stashfunction xrep_rtrefc_stash_cowfunction xrep_rtrefc_rmap_shareablefunction xrep_rtrefc_walk_rmapsfunction xrep_rtrefc_encode_startblockfunction xrep_rtrefc_extent_cmpfunction xrep_rtrefc_sort_recordsfunction foreach_xfarray_idxfunction xrep_rtrefc_walk_rmapfunction xrep_rtrefc_push_rmaps_atfunction xrep_rtrefc_scan_agfunction xrep_rtrefc_find_refcountsfunction xrep_rtrefc_get_recordsfunction xrep_rtrefc_claim_blockfunction xrep_rtrefc_iroot_sizefunction xrep_rtrefc_build_new_treefunction xrep_rtrefcountbt
Annotated Snippet
struct xrep_rtrefc {
/* refcount extents */
struct xfarray *refcount_records;
/* new refcountbt information */
struct xrep_newbt new_btree;
/* old refcountbt blocks */
struct xfsb_bitmap old_rtrefcountbt_blocks;
struct xfs_scrub *sc;
/* get_records()'s position in the rt refcount record array. */
xfarray_idx_t array_cur;
/* # of refcountbt blocks */
xfs_filblks_t btblocks;
};
/* Set us up to repair refcount btrees. */
int
xrep_setup_rtrefcountbt(
struct xfs_scrub *sc)
{
return xrep_setup_xfbtree(sc, "realtime rmap record bag");
}
/* Check for any obvious conflicts with this shared/CoW staging extent. */
STATIC int
xrep_rtrefc_check_ext(
struct xfs_scrub *sc,
const struct xfs_refcount_irec *rec)
{
xfs_rgblock_t last;
if (xfs_rtrefcount_check_irec(sc->sr.rtg, rec) != NULL)
return -EFSCORRUPTED;
if (xfs_rgbno_to_rtxoff(sc->mp, rec->rc_startblock) != 0)
return -EFSCORRUPTED;
last = rec->rc_startblock + rec->rc_blockcount - 1;
if (xfs_rgbno_to_rtxoff(sc->mp, last) != sc->mp->m_sb.sb_rextsize - 1)
return -EFSCORRUPTED;
/* Make sure this isn't free space or misaligned. */
return xrep_require_rtext_inuse(sc, rec->rc_startblock,
rec->rc_blockcount);
}
/* Record a reference count extent. */
STATIC int
xrep_rtrefc_stash(
struct xrep_rtrefc *rr,
enum xfs_refc_domain domain,
xfs_rgblock_t bno,
xfs_extlen_t len,
uint64_t refcount)
{
struct xfs_refcount_irec irec = {
.rc_startblock = bno,
.rc_blockcount = len,
.rc_refcount = refcount,
.rc_domain = domain,
};
int error = 0;
if (xchk_should_terminate(rr->sc, &error))
return error;
irec.rc_refcount = min_t(uint64_t, XFS_REFC_REFCOUNT_MAX, refcount);
error = xrep_rtrefc_check_ext(rr->sc, &irec);
if (error)
return error;
trace_xrep_refc_found(rtg_group(rr->sc->sr.rtg), &irec);
return xfarray_append(rr->refcount_records, &irec);
}
/* Record a CoW staging extent. */
STATIC int
xrep_rtrefc_stash_cow(
struct xrep_rtrefc *rr,
xfs_rgblock_t bno,
xfs_extlen_t len)
{
return xrep_rtrefc_stash(rr, XFS_REFC_DOMAIN_COW, bno, len, 1);
}
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_rtrefc`, `function xrep_setup_rtrefcountbt`, `function xrep_rtrefc_check_ext`, `function xrep_rtrefc_stash`, `function xrep_rtrefc_stash_cow`, `function xrep_rtrefc_rmap_shareable`, `function xrep_rtrefc_walk_rmaps`, `function xrep_rtrefc_encode_startblock`, `function xrep_rtrefc_extent_cmp`, `function xrep_rtrefc_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.