fs/xfs/scrub/common.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/common.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/common.c- Extension
.c- Size
- 44658 bytes
- Lines
- 1757
- 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_inode.hxfs_icache.hxfs_alloc.hxfs_alloc_btree.hxfs_ialloc.hxfs_ialloc_btree.hxfs_refcount_btree.hxfs_rmap.hxfs_rmap_btree.hxfs_log.hxfs_trans_priv.hxfs_da_format.hxfs_da_btree.hxfs_dir2_priv.hxfs_dir2.hxfs_attr.hxfs_reflink.hxfs_ag.hxfs_error.hxfs_quota.hxfs_exchmaps.hxfs_rtbitmap.hxfs_rtgroup.h
Detected Declarations
struct xchk_rmap_ownedby_infofunction Copyrightfunction xchk_process_errorfunction xchk_process_rt_errorfunction xchk_xref_process_errorfunction __xchk_fblock_process_errorfunction xchk_fblock_process_errorfunction xchk_fblock_xref_process_errorfunction incorrectfunction xchk_ino_set_preenfunction xchk_fblock_set_preenfunction xchk_set_corruptfunction xchk_block_set_corruptfunction xchk_qcheck_set_corruptfunction xchk_block_xref_set_corruptfunction xchk_ino_set_corruptfunction xchk_ip_xref_set_corruptfunction xchk_fblock_set_corruptfunction xchk_fblock_xref_set_corruptfunction xchk_ino_set_warningfunction xchk_fblock_set_warningfunction xchk_set_incompletefunction xchk_count_rmap_ownedby_irecfunction xchk_count_rmap_ownedby_agfunction want_ag_read_header_failurefunction xchk_perag_read_headersfunction xchk_perag_drain_and_lockfunction xchk_ag_read_headersfunction xchk_ag_btcur_freefunction xchk_ag_btcur_initfunction xchk_ag_freefunction infunction xchk_rtgroup_initfunction xchk_rtgroup_lockfunction xchk_rtgroup_btcur_freefunction xchk_rtgroup_unlockfunction xchk_rtgroup_freefunction xchk_trans_cancelfunction xchk_trans_alloc_emptyfunction xchk_trans_allocfunction xchk_setup_fsfunction xchk_setup_rtfunction xchk_setup_ag_btreefunction xchk_checkpoint_logfunction xchk_igetfunction xchk_iget_agifunction xchk_ino_dqattachfunction xchk_install_handle_inode
Annotated Snippet
struct xchk_rmap_ownedby_info {
const struct xfs_owner_info *oinfo;
xfs_filblks_t *blocks;
};
STATIC int
xchk_count_rmap_ownedby_irec(
struct xfs_btree_cur *cur,
const struct xfs_rmap_irec *rec,
void *priv)
{
struct xchk_rmap_ownedby_info *sroi = priv;
bool irec_attr;
bool oinfo_attr;
irec_attr = rec->rm_flags & XFS_RMAP_ATTR_FORK;
oinfo_attr = sroi->oinfo->oi_flags & XFS_OWNER_INFO_ATTR_FORK;
if (rec->rm_owner != sroi->oinfo->oi_owner)
return 0;
if (XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) || irec_attr == oinfo_attr)
(*sroi->blocks) += rec->rm_blockcount;
return 0;
}
/*
* Calculate the number of blocks the rmap thinks are owned by something.
* The caller should pass us an rmapbt cursor.
*/
int
xchk_count_rmap_ownedby_ag(
struct xfs_scrub *sc,
struct xfs_btree_cur *cur,
const struct xfs_owner_info *oinfo,
xfs_filblks_t *blocks)
{
struct xchk_rmap_ownedby_info sroi = {
.oinfo = oinfo,
.blocks = blocks,
};
*blocks = 0;
return xfs_rmap_query_all(cur, xchk_count_rmap_ownedby_irec,
&sroi);
}
/*
* AG scrubbing
*
* These helpers facilitate locking an allocation group's header
* buffers, setting up cursors for all btrees that are present, and
* cleaning everything up once we're through.
*/
/* Decide if we want to return an AG header read failure. */
static inline bool
want_ag_read_header_failure(
struct xfs_scrub *sc,
unsigned int type)
{
/* Return all AG header read failures when scanning btrees. */
if (sc->sm->sm_type != XFS_SCRUB_TYPE_AGF &&
sc->sm->sm_type != XFS_SCRUB_TYPE_AGFL &&
sc->sm->sm_type != XFS_SCRUB_TYPE_AGI)
return true;
/*
* If we're scanning a given type of AG header, we only want to
* see read failures from that specific header. We'd like the
* other headers to cross-check them, but this isn't required.
*/
if (sc->sm->sm_type == type)
return true;
return false;
}
/*
* Grab the AG header buffers for the attached perag structure.
*
* The headers should be released by xchk_ag_free, but as a fail safe we attach
* all the buffers we grab to the scrub transaction so they'll all be freed
* when we cancel it.
*/
static inline int
xchk_perag_read_headers(
struct xfs_scrub *sc,
struct xchk_ag *sa)
{
int error;
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 xchk_rmap_ownedby_info`, `function Copyright`, `function xchk_process_error`, `function xchk_process_rt_error`, `function xchk_xref_process_error`, `function __xchk_fblock_process_error`, `function xchk_fblock_process_error`, `function xchk_fblock_xref_process_error`, `function incorrect`, `function xchk_ino_set_preen`.
- 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.