fs/xfs/scrub/ialloc.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/ialloc.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/ialloc.c- Extension
.c- Size
- 22042 bytes
- Lines
- 797
- 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_log_format.hxfs_trans.hxfs_inode.hxfs_ialloc.hxfs_ialloc_btree.hxfs_icache.hxfs_rmap.hscrub/scrub.hscrub/common.hscrub/btree.hscrub/trace.hxfs_ag.h
Detected Declarations
struct xchk_iallocbtfunction Copyrightfunction xchk_inobt_xref_finobtfunction xchk_inobt_chunk_xref_finobtfunction xchk_finobt_xref_inobtfunction xchk_finobt_chunk_xref_inobtfunction xchk_iallocbt_chunkfunction xchk_iallocbt_check_cluster_ifreefunction xchk_iallocbt_check_clusterfunction xchk_iallocbt_check_clustersfunction xchk_iallocbt_rec_alignmentfunction xchk_iallocbt_recfunction xchk_iallocbt_xref_rmap_btreeblksfunction xchk_iallocbt_xref_rmap_inodesfunction xchk_iallocbtfunction xchk_xref_inode_checkfunction xchk_xref_is_not_inode_chunkfunction xchk_xref_is_inode_chunk
Annotated Snippet
struct xchk_iallocbt {
/* Number of inodes we see while scanning inobt. */
unsigned long long inodes;
/* Expected next startino, for big block filesystems. */
xfs_agino_t next_startino;
/* Expected end of the current inode cluster. */
xfs_agino_t next_cluster_ino;
};
/*
* Does the finobt have a record for this inode with the same hole/free state?
* This is a bit complicated because of the following:
*
* - The finobt need not have a record if all inodes in the inobt record are
* allocated.
* - The finobt need not have a record if all inodes in the inobt record are
* free.
* - The finobt need not have a record if the inobt record says this is a hole.
* This likely doesn't happen in practice.
*/
STATIC int
xchk_inobt_xref_finobt(
struct xfs_scrub *sc,
struct xfs_inobt_rec_incore *irec,
xfs_agino_t agino,
bool free,
bool hole)
{
struct xfs_inobt_rec_incore frec;
struct xfs_btree_cur *cur = sc->sa.fino_cur;
bool ffree, fhole;
unsigned int frec_idx, fhole_idx;
int has_record;
int error;
ASSERT(xfs_btree_is_fino(cur->bc_ops));
error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE, &has_record);
if (error)
return error;
if (!has_record)
goto no_record;
error = xfs_inobt_get_rec(cur, &frec, &has_record);
if (!has_record)
return -EFSCORRUPTED;
if (frec.ir_startino + XFS_INODES_PER_CHUNK <= agino)
goto no_record;
/* There's a finobt record; free and hole status must match. */
frec_idx = agino - frec.ir_startino;
ffree = frec.ir_free & (1ULL << frec_idx);
fhole_idx = frec_idx / XFS_INODES_PER_HOLEMASK_BIT;
fhole = frec.ir_holemask & (1U << fhole_idx);
if (ffree != free)
xchk_btree_xref_set_corrupt(sc, cur, 0);
if (fhole != hole)
xchk_btree_xref_set_corrupt(sc, cur, 0);
return 0;
no_record:
/* inobt record is fully allocated */
if (irec->ir_free == 0)
return 0;
/* inobt record is totally unallocated */
if (irec->ir_free == XFS_INOBT_ALL_FREE)
return 0;
/* inobt record says this is a hole */
if (hole)
return 0;
/* finobt doesn't care about allocated inodes */
if (!free)
return 0;
xchk_btree_xref_set_corrupt(sc, cur, 0);
return 0;
}
/*
* Make sure that each inode of this part of an inobt record has the same
* sparse and free status as the finobt.
*/
STATIC void
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_iallocbt`, `function Copyright`, `function xchk_inobt_xref_finobt`, `function xchk_inobt_chunk_xref_finobt`, `function xchk_finobt_xref_inobt`, `function xchk_finobt_chunk_xref_inobt`, `function xchk_iallocbt_chunk`, `function xchk_iallocbt_check_cluster_ifree`, `function xchk_iallocbt_check_cluster`, `function xchk_iallocbt_check_clusters`.
- 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.