fs/xfs/libxfs/xfs_dir2_leaf.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_dir2_leaf.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_dir2_leaf.c- Extension
.c- Size
- 52393 bytes
- Lines
- 1882
- 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_log_format.hxfs_trans_resv.hxfs_mount.hxfs_inode.hxfs_bmap.hxfs_dir2.hxfs_dir2_priv.hxfs_error.hxfs_trace.hxfs_trans.hxfs_buf_item.hxfs_health.h
Detected Declarations
function xfs_dir2_leaf_hdr_from_diskfunction xfs_dir2_leaf_hdr_to_diskfunction xfs_dir3_leaf1_checkfunction xfs_dir3_leaf_checkfunction xfs_dir3_leaf_check_intfunction xfs_dir3_leaf_verifyfunction xfs_dir3_leaf_header_checkfunction xfs_dir3_leaf_read_verifyfunction xfs_dir3_leaf_write_verifyfunction xfs_dir3_leaf_readfunction xfs_dir3_leafn_readfunction xfs_dir3_leaf_initfunction xfs_dir3_leaf_get_buffunction xfs_dir3_leaf_find_stalefunction xfs_dir3_leaf_find_entryfunction xfs_dir3_leaf_log_entsfunction xfs_dir3_leaf_log_headerfunction xfs_dir3_leaf_log_tailfunction xfs_dir3_leaf_size
Annotated Snippet
if (i + 1 < hdr->count) {
if (be32_to_cpu(hdr->ents[i].hashval) >
be32_to_cpu(hdr->ents[i + 1].hashval))
return __this_address;
}
if (hdr->ents[i].address == cpu_to_be32(XFS_DIR2_NULL_DATAPTR))
stale++;
if (isleaf1 && xfs_dir2_dataptr_to_db(geo,
be32_to_cpu(hdr->ents[i].address)) >=
be32_to_cpu(ltp->bestcount))
return __this_address;
}
if (hdr->stale != stale)
return __this_address;
return NULL;
}
/*
* We verify the magic numbers before decoding the leaf header so that on debug
* kernels we don't get assertion failures in xfs_dir3_leaf_hdr_from_disk() due
* to incorrect magic numbers.
*/
static xfs_failaddr_t
xfs_dir3_leaf_verify(
struct xfs_buf *bp)
{
struct xfs_mount *mp = bp->b_mount;
struct xfs_dir3_icleaf_hdr leafhdr;
xfs_failaddr_t fa;
fa = xfs_da3_blkinfo_verify(bp, bp->b_addr);
if (fa)
return fa;
xfs_dir2_leaf_hdr_from_disk(mp, &leafhdr, bp->b_addr);
return xfs_dir3_leaf_check_int(mp, &leafhdr, bp->b_addr, true);
}
xfs_failaddr_t
xfs_dir3_leaf_header_check(
struct xfs_buf *bp,
xfs_ino_t owner)
{
struct xfs_mount *mp = bp->b_mount;
if (xfs_has_crc(mp)) {
struct xfs_dir3_leaf *hdr3 = bp->b_addr;
if (hdr3->hdr.info.hdr.magic !=
cpu_to_be16(XFS_DIR3_LEAF1_MAGIC) &&
hdr3->hdr.info.hdr.magic !=
cpu_to_be16(XFS_DIR3_LEAFN_MAGIC))
return __this_address;
if (be64_to_cpu(hdr3->hdr.info.owner) != owner)
return __this_address;
}
return NULL;
}
static void
xfs_dir3_leaf_read_verify(
struct xfs_buf *bp)
{
struct xfs_mount *mp = bp->b_mount;
xfs_failaddr_t fa;
if (xfs_has_crc(mp) &&
!xfs_buf_verify_cksum(bp, XFS_DIR3_LEAF_CRC_OFF))
xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else {
fa = xfs_dir3_leaf_verify(bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
}
static void
xfs_dir3_leaf_write_verify(
struct xfs_buf *bp)
{
struct xfs_mount *mp = bp->b_mount;
struct xfs_buf_log_item *bip = bp->b_log_item;
struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr;
xfs_failaddr_t fa;
fa = xfs_dir3_leaf_verify(bp);
if (fa) {
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_inode.h`.
- Detected declarations: `function xfs_dir2_leaf_hdr_from_disk`, `function xfs_dir2_leaf_hdr_to_disk`, `function xfs_dir3_leaf1_check`, `function xfs_dir3_leaf_check`, `function xfs_dir3_leaf_check_int`, `function xfs_dir3_leaf_verify`, `function xfs_dir3_leaf_header_check`, `function xfs_dir3_leaf_read_verify`, `function xfs_dir3_leaf_write_verify`, `function xfs_dir3_leaf_read`.
- 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.