fs/xfs/scrub/attr.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/attr.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/attr.c- Extension
.c- Size
- 17361 bytes
- Lines
- 687
- 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_log_format.hxfs_trans.hxfs_inode.hxfs_da_format.hxfs_da_btree.hxfs_attr.hxfs_attr_leaf.hxfs_attr_sf.hxfs_parent.hscrub/scrub.hscrub/common.hscrub/dabtree.hscrub/attr.hscrub/listxattr.hscrub/repair.h
Detected Declarations
function Copyrightfunction xchk_xattr_want_freemapfunction xchk_setup_xattr_buffunction xchk_setup_xattrfunction xchk_xattr_actorfunction xchk_xattr_set_mapfunction xchk_xattr_entryfunction xchk_xattr_blockfunction xchk_xattr_recfunction xchk_xattr_check_sffunction xchk_xattr
Annotated Snippet
sizeof(xfs_attr_leaf_entry_t))) {
xchk_da_set_corrupt(ds, level);
goto out;
}
/* Check the entry and nameval. */
xchk_xattr_entry(ds, level, buf_end, leaf, &leafhdr,
ent, i, &usedbytes, &last_hashval);
if (ds->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
goto out;
}
/* Construct bitmap of freemap contents. */
for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; i++) {
if (!xchk_xattr_set_map(ds->sc, ab->freemap,
leafhdr.freemap[i].base,
leafhdr.freemap[i].size))
xchk_da_set_corrupt(ds, level);
/*
* freemap entries with zero length and nonzero base can cause
* problems with older kernels, so we mark these for preening
* even though there's no inconsistency.
*/
if (leafhdr.freemap[i].size == 0 &&
leafhdr.freemap[i].base > 0)
xchk_da_set_preen(ds, level);
if (ds->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
goto out;
}
/* Look for bits that are set in freemap and are marked in use. */
if (bitmap_intersects(ab->freemap, ab->usedmap,
mp->m_attr_geo->blksize))
xchk_da_set_corrupt(ds, level);
if (leafhdr.usedbytes != usedbytes)
xchk_da_set_corrupt(ds, level);
out:
return 0;
}
/* Scrub a attribute btree record. */
STATIC int
xchk_xattr_rec(
struct xchk_da_btree *ds,
int level)
{
struct xfs_mount *mp = ds->state->mp;
struct xfs_da_state_blk *blk = &ds->state->path.blk[level];
struct xfs_attr_leaf_name_local *lentry;
struct xfs_attr_leaf_name_remote *rentry;
struct xfs_buf *bp;
struct xfs_attr_leaf_entry *ent;
xfs_dahash_t calc_hash;
xfs_dahash_t hash;
int nameidx;
int hdrsize;
int error;
ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
ent = xfs_attr3_leaf_entryp(blk->bp->b_addr) + blk->index;
/* Check the whole block, if necessary. */
error = xchk_xattr_block(ds, level);
if (error)
goto out;
if (ds->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
goto out;
/* Check the hash of the entry. */
error = xchk_da_btree_hash(ds, level, &ent->hashval);
if (error)
goto out;
/* Find the attr entry's location. */
bp = blk->bp;
hdrsize = xfs_attr3_leaf_hdr_size(bp->b_addr);
nameidx = be16_to_cpu(ent->nameidx);
if (nameidx < hdrsize || nameidx >= mp->m_attr_geo->blksize) {
xchk_da_set_corrupt(ds, level);
goto out;
}
/* Retrieve the entry and check it. */
hash = be32_to_cpu(ent->hashval);
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_log_format.h`, `xfs_trans.h`.
- Detected declarations: `function Copyright`, `function xchk_xattr_want_freemap`, `function xchk_setup_xattr_buf`, `function xchk_setup_xattr`, `function xchk_xattr_actor`, `function xchk_xattr_set_map`, `function xchk_xattr_entry`, `function xchk_xattr_block`, `function xchk_xattr_rec`, `function xchk_xattr_check_sf`.
- 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.