fs/xfs/libxfs/xfs_da_btree.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_da_btree.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_da_btree.c- Extension
.c- Size
- 77251 bytes
- Lines
- 2914
- 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_log_format.hxfs_trans_resv.hxfs_bit.hxfs_mount.hxfs_inode.hxfs_dir2.hxfs_dir2_priv.hxfs_trans.hxfs_bmap.hxfs_attr_leaf.hxfs_error.hxfs_trace.hxfs_buf_item.hxfs_log.hxfs_errortag.hxfs_health.h
Detected Declarations
function xfs_da_state_allocfunction xfs_da_state_kill_altpathfunction xfs_da_state_freefunction xfs_da_state_resetfunction xfs_dabuf_nfsbfunction xfs_da3_node_hdr_from_diskfunction xfs_da3_node_hdr_to_diskfunction xfs_da3_blkinfo_verifyfunction xfs_da3_node_verifyfunction xfs_da3_node_header_checkfunction xfs_da3_header_checkfunction xfs_da3_node_write_verifyfunction xfs_da3_node_read_verifyfunction xfs_da3_node_verify_structfunction xfs_da3_node_set_typefunction xfs_da3_node_readfunction xfs_da3_node_read_mappedfunction xfs_da_buf_copyfunction xfs_da3_node_createfunction partsfunction xfs_da3_node_rebalancefunction be32_to_cpufunction xfs_da3_node_addfunction xfs_da3_joinfunction xfs_da_blkinfo_onlychild_validatefunction xfs_da3_root_joinfunction xfs_da3_node_toosmallfunction xfs_da3_node_lasthashfunction xfs_da3_fixhashpathfunction __xfs_da3_node_removefunction xfs_da3_node_removefunction xfs_attr3_node_entry_removefunction xfs_da3_node_unbalancefunction be32_to_cpufunction xfs_da3_node_orderfunction blocksfunction xfs_da_hashnamefunction xfs_da_compnamefunction xfs_da_grow_inode_intfunction xfs_da_grow_inodefunction xfs_da3_swap_lastblockfunction xfs_da_shrink_inodefunction xfs_dabuf_mapfunction xfs_da_get_buffunction xfs_da_read_buffunction xfs_da_reada_buf
Annotated Snippet
if (!xfs_buf_verify_cksum(bp, XFS_DA3_NODE_CRC_OFF)) {
xfs_verifier_error(bp, -EFSBADCRC,
__this_address);
break;
}
fallthrough;
case XFS_DA_NODE_MAGIC:
fa = xfs_da3_node_verify(bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return;
case XFS_ATTR_LEAF_MAGIC:
case XFS_ATTR3_LEAF_MAGIC:
bp->b_ops = &xfs_attr3_leaf_buf_ops;
bp->b_ops->verify_read(bp);
return;
case XFS_DIR2_LEAFN_MAGIC:
case XFS_DIR3_LEAFN_MAGIC:
bp->b_ops = &xfs_dir3_leafn_buf_ops;
bp->b_ops->verify_read(bp);
return;
default:
xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
break;
}
}
/* Verify the structure of a da3 block. */
static xfs_failaddr_t
xfs_da3_node_verify_struct(
struct xfs_buf *bp)
{
struct xfs_da_blkinfo *info = bp->b_addr;
switch (be16_to_cpu(info->magic)) {
case XFS_DA3_NODE_MAGIC:
case XFS_DA_NODE_MAGIC:
return xfs_da3_node_verify(bp);
case XFS_ATTR_LEAF_MAGIC:
case XFS_ATTR3_LEAF_MAGIC:
bp->b_ops = &xfs_attr3_leaf_buf_ops;
return bp->b_ops->verify_struct(bp);
case XFS_DIR2_LEAFN_MAGIC:
case XFS_DIR3_LEAFN_MAGIC:
bp->b_ops = &xfs_dir3_leafn_buf_ops;
return bp->b_ops->verify_struct(bp);
default:
return __this_address;
}
}
const struct xfs_buf_ops xfs_da3_node_buf_ops = {
.name = "xfs_da3_node",
.magic16 = { cpu_to_be16(XFS_DA_NODE_MAGIC),
cpu_to_be16(XFS_DA3_NODE_MAGIC) },
.verify_read = xfs_da3_node_read_verify,
.verify_write = xfs_da3_node_write_verify,
.verify_struct = xfs_da3_node_verify_struct,
};
static int
xfs_da3_node_set_type(
struct xfs_trans *tp,
struct xfs_inode *dp,
int whichfork,
struct xfs_buf *bp)
{
struct xfs_da_blkinfo *info = bp->b_addr;
switch (be16_to_cpu(info->magic)) {
case XFS_DA_NODE_MAGIC:
case XFS_DA3_NODE_MAGIC:
xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DA_NODE_BUF);
return 0;
case XFS_ATTR_LEAF_MAGIC:
case XFS_ATTR3_LEAF_MAGIC:
xfs_trans_buf_set_type(tp, bp, XFS_BLFT_ATTR_LEAF_BUF);
return 0;
case XFS_DIR2_LEAFN_MAGIC:
case XFS_DIR3_LEAFN_MAGIC:
xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DIR_LEAFN_BUF);
return 0;
default:
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, tp->t_mountp,
info, sizeof(*info));
xfs_trans_brelse(tp, bp);
xfs_dirattr_mark_sick(dp, whichfork);
return -EFSCORRUPTED;
}
}
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_bit.h`, `xfs_mount.h`.
- Detected declarations: `function xfs_da_state_alloc`, `function xfs_da_state_kill_altpath`, `function xfs_da_state_free`, `function xfs_da_state_reset`, `function xfs_dabuf_nfsb`, `function xfs_da3_node_hdr_from_disk`, `function xfs_da3_node_hdr_to_disk`, `function xfs_da3_blkinfo_verify`, `function xfs_da3_node_verify`, `function xfs_da3_node_header_check`.
- 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.