fs/xfs/libxfs/xfs_alloc_btree.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_alloc_btree.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_alloc_btree.c- Extension
.c- Size
- 15573 bytes
- Lines
- 620
- 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_btree.hxfs_btree_staging.hxfs_alloc_btree.hxfs_alloc.hxfs_extent_busy.hxfs_error.hxfs_health.hxfs_trace.hxfs_trans.hxfs_ag.h
Detected Declarations
function xfs_bnobt_dup_cursorfunction xfs_cntbt_dup_cursorfunction xfs_allocbt_set_rootfunction xfs_allocbt_alloc_blockfunction xfs_allocbt_free_blockfunction xfs_allocbt_get_minrecsfunction xfs_allocbt_get_maxrecsfunction xfs_allocbt_init_key_from_recfunction xfs_bnobt_init_high_key_from_recfunction xfs_cntbt_init_high_key_from_recfunction xfs_allocbt_init_rec_from_curfunction xfs_allocbt_init_ptr_from_curfunction xfs_bnobt_cmp_key_with_curfunction xfs_cntbt_cmp_key_with_curfunction xfs_bnobt_cmp_two_keysfunction xfs_cntbt_cmp_two_keysfunction xfs_allocbt_verifyfunction xfs_allocbt_read_verifyfunction xfs_allocbt_write_verifyfunction xfs_bnobt_keys_inorderfunction xfs_bnobt_recs_inorderfunction xfs_cntbt_keys_inorderfunction xfs_cntbt_recs_inorderfunction xfs_allocbt_keys_contiguousfunction xfs_bnobt_init_cursorfunction xfs_cntbt_init_cursorfunction xfs_allocbt_commit_staged_btreefunction xfs_allocbt_block_maxrecsfunction xfs_allocbt_maxrecsfunction xfs_allocbt_maxlevels_ondiskfunction xfs_allocbt_calc_sizefunction xfs_allocbt_init_cur_cachefunction xfs_allocbt_destroy_cur_cache
Annotated Snippet
if (bp->b_ops->magic[0] == cpu_to_be32(XFS_ABTC_MAGIC)) {
maxlevel = pag->pagf_cnt_level;
#ifdef CONFIG_XFS_ONLINE_REPAIR
repair_maxlevel = pag->pagf_repair_cnt_level;
#endif
} else {
maxlevel = pag->pagf_bno_level;
#ifdef CONFIG_XFS_ONLINE_REPAIR
repair_maxlevel = pag->pagf_repair_bno_level;
#endif
}
if (level >= max(maxlevel, repair_maxlevel))
return __this_address;
} else if (level >= mp->m_alloc_maxlevels)
return __this_address;
return xfs_btree_agblock_verify(bp, mp->m_alloc_mxr[level != 0]);
}
static void
xfs_allocbt_read_verify(
struct xfs_buf *bp)
{
xfs_failaddr_t fa;
if (!xfs_btree_agblock_verify_crc(bp))
xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else {
fa = xfs_allocbt_verify(bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
if (bp->b_error)
trace_xfs_btree_corrupt(bp, _RET_IP_);
}
static void
xfs_allocbt_write_verify(
struct xfs_buf *bp)
{
xfs_failaddr_t fa;
fa = xfs_allocbt_verify(bp);
if (fa) {
trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return;
}
xfs_btree_agblock_calc_crc(bp);
}
const struct xfs_buf_ops xfs_bnobt_buf_ops = {
.name = "xfs_bnobt",
.magic = { cpu_to_be32(XFS_ABTB_MAGIC),
cpu_to_be32(XFS_ABTB_CRC_MAGIC) },
.verify_read = xfs_allocbt_read_verify,
.verify_write = xfs_allocbt_write_verify,
.verify_struct = xfs_allocbt_verify,
};
const struct xfs_buf_ops xfs_cntbt_buf_ops = {
.name = "xfs_cntbt",
.magic = { cpu_to_be32(XFS_ABTC_MAGIC),
cpu_to_be32(XFS_ABTC_CRC_MAGIC) },
.verify_read = xfs_allocbt_read_verify,
.verify_write = xfs_allocbt_write_verify,
.verify_struct = xfs_allocbt_verify,
};
STATIC int
xfs_bnobt_keys_inorder(
struct xfs_btree_cur *cur,
const union xfs_btree_key *k1,
const union xfs_btree_key *k2)
{
return be32_to_cpu(k1->alloc.ar_startblock) <
be32_to_cpu(k2->alloc.ar_startblock);
}
STATIC int
xfs_bnobt_recs_inorder(
struct xfs_btree_cur *cur,
const union xfs_btree_rec *r1,
const union xfs_btree_rec *r2)
{
return be32_to_cpu(r1->alloc.ar_startblock) +
be32_to_cpu(r1->alloc.ar_blockcount) <=
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_btree.h`.
- Detected declarations: `function xfs_bnobt_dup_cursor`, `function xfs_cntbt_dup_cursor`, `function xfs_allocbt_set_root`, `function xfs_allocbt_alloc_block`, `function xfs_allocbt_free_block`, `function xfs_allocbt_get_minrecs`, `function xfs_allocbt_get_maxrecs`, `function xfs_allocbt_init_key_from_rec`, `function xfs_bnobt_init_high_key_from_rec`, `function xfs_cntbt_init_high_key_from_rec`.
- 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.