fs/xfs/scrub/inode_repair.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/inode_repair.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/inode_repair.c- Extension
.c- Size
- 53258 bytes
- Lines
- 2094
- 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_bit.hxfs_log_format.hxfs_trans.hxfs_sb.hxfs_inode.hxfs_icache.hxfs_inode_buf.hxfs_inode_fork.hxfs_ialloc.hxfs_da_format.hxfs_reflink.hxfs_alloc.hxfs_rmap.hxfs_rmap_btree.hxfs_bmap.hxfs_bmap_btree.hxfs_bmap_util.hxfs_dir2.hxfs_dir2_priv.hxfs_quota_defs.hxfs_quota.hxfs_ag.hxfs_rtbitmap.hxfs_attr_leaf.h
Detected Declarations
struct xrep_inodefunction xrep_setup_inodefunction xrep_dinode_buf_corefunction xrep_dinode_buffunction xrep_dinode_headerfunction xrep_dinode_findmode_direntfunction xrep_dinode_ilock_nowaitfunction xrep_dinode_trylock_directoryfunction xrep_dinode_findmode_walk_directoryfunction xrep_dinode_find_modefunction xrep_dinode_modefunction xrep_dinode_nlinksfunction xrep_dinode_flagsfunction xrep_dinode_zap_symlinkfunction xrep_dinode_zap_dirfunction xrep_dinode_sizefunction xrep_dinode_extsize_hintsfunction xrep_dinode_walk_rmapfunction xrep_dinode_count_ag_rmapsfunction xrep_dinode_walk_rtrmapfunction xrep_dinode_count_rtgroup_rmapsfunction xrep_dinode_count_rmapsfunction xrep_dinode_bad_extents_forkfunction xrep_dinode_bad_bmbt_forkfunction xrep_dinode_bad_rtrmapbt_forkfunction xrep_dinode_bad_rtrefcountbt_forkfunction xrep_dinode_bad_metabt_forkfunction xrep_dinode_check_dforkfunction xrep_dinode_set_data_nextentsfunction xrep_dinode_set_attr_nextentsfunction xrep_dinode_zap_dforkfunction xrep_dinode_check_aforkfunction xrep_dinode_zap_aforkfunction xrep_dinode_ensure_forkofffunction xfs_dfork_data_extentsfunction xfs_dfork_attr_extentsfunction xrep_dinode_zap_forksfunction xrep_dinode_corefunction xrep_dinode_problemsfunction xrep_inode_blockcountsfunction xrep_inode_idsfunction xrep_clamp_timestampfunction xrep_inode_timestampsfunction xrep_inode_flagsfunction xrep_inode_blockdir_sizefunction xrep_inode_sfdir_sizefunction xrep_inode_dir_sizefunction xrep_inode_extsize
Annotated Snippet
struct xrep_inode {
/* Inode mapping that we saved from the initial lookup attempt. */
struct xfs_imap imap;
struct xfs_scrub *sc;
/* Blocks in use on the data device by data extents or bmbt blocks. */
xfs_rfsblock_t data_blocks;
/* Blocks in use on the rt device. */
xfs_rfsblock_t rt_blocks;
/* Blocks in use by the attr fork. */
xfs_rfsblock_t attr_blocks;
/* Number of data device extents for the data fork. */
xfs_extnum_t data_extents;
/*
* Number of realtime device extents for the data fork. If
* data_extents and rt_extents indicate that the data fork has extents
* on both devices, we'll just back away slowly.
*/
xfs_extnum_t rt_extents;
/* Number of (data device) extents for the attr fork. */
xfs_aextnum_t attr_extents;
/* Sick state to set after zapping parts of the inode. */
unsigned int ino_sick_mask;
/* Must we remove all access from this file? */
bool zap_acls;
/* Inode scanner to see if we can find the ftype from dirents */
struct xchk_iscan ftype_iscan;
uint8_t alleged_ftype;
};
/*
* Setup function for inode repair. @imap contains the ondisk inode mapping
* information so that we can correct the ondisk inode cluster buffer if
* necessary to make iget work.
*/
int
xrep_setup_inode(
struct xfs_scrub *sc,
const struct xfs_imap *imap)
{
struct xrep_inode *ri;
sc->buf = kzalloc_obj(struct xrep_inode, XCHK_GFP_FLAGS);
if (!sc->buf)
return -ENOMEM;
ri = sc->buf;
memcpy(&ri->imap, imap, sizeof(struct xfs_imap));
ri->sc = sc;
return 0;
}
/*
* Make sure this ondisk inode can pass the inode buffer verifier. This is
* not the same as the dinode verifier.
*/
STATIC void
xrep_dinode_buf_core(
struct xfs_scrub *sc,
struct xfs_buf *bp,
unsigned int ioffset)
{
struct xfs_dinode *dip = xfs_buf_offset(bp, ioffset);
struct xfs_trans *tp = sc->tp;
struct xfs_mount *mp = sc->mp;
xfs_agino_t agino;
bool crc_ok = false;
bool magic_ok = false;
bool unlinked_ok = false;
agino = be32_to_cpu(dip->di_next_unlinked);
if (xfs_verify_agino_or_null(bp->b_pag, agino))
unlinked_ok = true;
if (dip->di_magic == cpu_to_be16(XFS_DINODE_MAGIC) &&
xfs_dinode_good_version(mp, dip->di_version))
magic_ok = true;
if (xfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize,
XFS_DINODE_CRC_OFF))
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_inode`, `function xrep_setup_inode`, `function xrep_dinode_buf_core`, `function xrep_dinode_buf`, `function xrep_dinode_header`, `function xrep_dinode_findmode_dirent`, `function xrep_dinode_ilock_nowait`, `function xrep_dinode_trylock_directory`, `function xrep_dinode_findmode_walk_directory`, `function xrep_dinode_find_mode`.
- 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.