fs/xfs/scrub/bmap.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/bmap.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/bmap.c- Extension
.c- Size
- 33089 bytes
- Lines
- 1188
- 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_bit.hxfs_log_format.hxfs_trans.hxfs_inode.hxfs_alloc.hxfs_bmap.hxfs_bmap_btree.hxfs_rmap.hxfs_rmap_btree.hxfs_rtgroup.hxfs_health.hxfs_rtalloc.hxfs_rtrmap_btree.hscrub/scrub.hscrub/common.hscrub/btree.hscrub/health.hxfs_ag.h
Detected Declarations
struct xchk_bmap_infostruct xchk_bmap_check_rmap_infofunction Copyrightfunction xchk_bmap_get_rmapfunction extentfunction xchk_bmap_xref_rmapfunction xchk_bmap_xref_rmap_cowfunction xchk_bmap_rt_iextent_xreffunction xchk_bmap_iextent_xreffunction xchk_bmap_dirattr_extentfunction xchk_bmap_iextentfunction xchk_bmapbt_recfunction xchk_bmap_btreefunction xchk_bmap_check_rmapfunction xchk_bmap_check_ag_rmapsfunction xchk_bmap_check_rt_rmapsfunction xchk_bmap_check_empty_attrforkfunction xchk_bmap_check_empty_dataforkfunction xchk_bmap_want_check_rmapsfunction xchk_bmap_check_rmapsfunction xchk_bmap_iextent_delallocfunction xchk_bmap_iext_mappingfunction xchk_are_bmaps_contiguousfunction xchk_bmap_iext_iterfunction xchk_bmapfunction xchk_bmap_datafunction xchk_bmap_attrfunction xchk_bmap_cow
Annotated Snippet
struct xchk_bmap_info {
struct xfs_scrub *sc;
/* Incore extent tree cursor */
struct xfs_iext_cursor icur;
/* Previous fork mapping that we examined */
struct xfs_bmbt_irec prev_rec;
/* Is this a realtime fork? */
bool is_rt;
/* May mappings point to shared space? */
bool is_shared;
/* Was the incore extent tree loaded? */
bool was_loaded;
/* Which inode fork are we checking? */
int whichfork;
};
/* Look for a corresponding rmap for this irec. */
static inline bool
xchk_bmap_get_rmap(
struct xchk_bmap_info *info,
struct xfs_bmbt_irec *irec,
xfs_agblock_t bno,
uint64_t owner,
struct xfs_rmap_irec *rmap)
{
struct xfs_btree_cur **curp = &info->sc->sa.rmap_cur;
xfs_fileoff_t offset;
unsigned int rflags = 0;
int has_rmap;
int error;
if (xfs_ifork_is_realtime(info->sc->ip, info->whichfork))
curp = &info->sc->sr.rmap_cur;
if (*curp == NULL)
return false;
if (info->whichfork == XFS_ATTR_FORK)
rflags |= XFS_RMAP_ATTR_FORK;
if (irec->br_state == XFS_EXT_UNWRITTEN)
rflags |= XFS_RMAP_UNWRITTEN;
/*
* CoW staging extents are owned (on disk) by the refcountbt, so
* their rmaps do not have offsets.
*/
if (info->whichfork == XFS_COW_FORK)
offset = 0;
else
offset = irec->br_startoff;
/*
* If the caller thinks this could be a shared bmbt extent (IOWs,
* any data fork extent of a reflink inode) then we have to use the
* range rmap lookup to make sure we get the correct owner/offset.
*/
if (info->is_shared) {
error = xfs_rmap_lookup_le_range(*curp, bno, owner, offset,
rflags, rmap, &has_rmap);
} else {
error = xfs_rmap_lookup_le(*curp, bno, owner, offset,
rflags, rmap, &has_rmap);
}
if (!xchk_should_check_xref(info->sc, &error, curp))
return false;
if (!has_rmap)
xchk_fblock_xref_set_corrupt(info->sc, info->whichfork,
irec->br_startoff);
return has_rmap;
}
/* Make sure that we have rmapbt records for this data/attr fork extent. */
STATIC void
xchk_bmap_xref_rmap(
struct xchk_bmap_info *info,
struct xfs_bmbt_irec *irec,
xfs_agblock_t bno)
{
struct xfs_rmap_irec rmap;
unsigned long long rmap_end;
uint64_t owner = I_INO(info->sc->ip);
if (xchk_skip_xref(info->sc->sm))
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_bit.h`.
- Detected declarations: `struct xchk_bmap_info`, `struct xchk_bmap_check_rmap_info`, `function Copyright`, `function xchk_bmap_get_rmap`, `function extent`, `function xchk_bmap_xref_rmap`, `function xchk_bmap_xref_rmap_cow`, `function xchk_bmap_rt_iextent_xref`, `function xchk_bmap_iextent_xref`, `function xchk_bmap_dirattr_extent`.
- 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.