fs/xfs/libxfs/xfs_ialloc_btree.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_ialloc_btree.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_ialloc_btree.c- Extension
.c- Size
- 20821 bytes
- Lines
- 839
- 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_bit.hxfs_mount.hxfs_btree.hxfs_btree_staging.hxfs_ialloc.hxfs_ialloc_btree.hxfs_alloc.hxfs_error.hxfs_health.hxfs_trace.hxfs_trans.hxfs_rmap.hxfs_ag.h
Detected Declarations
function xfs_inobt_get_minrecsfunction xfs_inobt_dup_cursorfunction xfs_finobt_dup_cursorfunction xfs_inobt_mod_blockcountfunction __xfs_inobt_alloc_blockfunction xfs_inobt_alloc_blockfunction xfs_finobt_alloc_blockfunction __xfs_inobt_free_blockfunction xfs_inobt_free_blockfunction xfs_finobt_free_blockfunction xfs_inobt_get_maxrecsfunction xfs_inobt_init_key_from_recfunction xfs_inobt_init_high_key_from_recfunction xfs_inobt_init_rec_from_curfunction xfs_inobt_init_ptr_from_curfunction xfs_finobt_init_ptr_from_curfunction xfs_inobt_cmp_key_with_curfunction xfs_inobt_cmp_two_keysfunction xfs_inobt_verifyfunction landminefunction xfs_inobt_read_verifyfunction xfs_inobt_write_verifyfunction xfs_inobt_keys_inorderfunction xfs_inobt_recs_inorderfunction xfs_inobt_keys_contiguousfunction xfs_inobt_init_cursorfunction xfs_finobt_init_cursorfunction xfs_inobt_commit_staged_btreefunction xfs_inobt_block_maxrecsfunction xfs_inobt_maxrecsfunction xfs_inobt_maxlevels_ondiskfunction xfs_finobt_maxlevels_ondiskfunction xfs_iallocbt_maxlevels_ondiskfunction diskfunction xfs_inobt_rec_check_countfunction xfs_inobt_max_sizefunction xfs_finobt_count_blocksfunction xfs_finobt_read_blocksfunction xfs_finobt_calc_reservesfunction xfs_iallocbt_calc_sizefunction xfs_inobt_init_cur_cachefunction xfs_inobt_destroy_cur_cache
Annotated Snippet
if (xfs_has_inobtcounts(cur->bc_mp)) {
agi->agi_iblocks = cpu_to_be32(afake->af_blocks);
fields |= XFS_AGI_IBLOCKS;
}
xfs_ialloc_log_agi(tp, agbp, fields);
xfs_btree_commit_afakeroot(cur, tp, agbp);
} else {
fields = XFS_AGI_FREE_ROOT | XFS_AGI_FREE_LEVEL;
agi->agi_free_root = cpu_to_be32(afake->af_root);
agi->agi_free_level = cpu_to_be32(afake->af_levels);
if (xfs_has_inobtcounts(cur->bc_mp)) {
agi->agi_fblocks = cpu_to_be32(afake->af_blocks);
fields |= XFS_AGI_IBLOCKS;
}
xfs_ialloc_log_agi(tp, agbp, fields);
xfs_btree_commit_afakeroot(cur, tp, agbp);
}
}
/* Calculate number of records in an inode btree block. */
static inline unsigned int
xfs_inobt_block_maxrecs(
unsigned int blocklen,
bool leaf)
{
if (leaf)
return blocklen / sizeof(xfs_inobt_rec_t);
return blocklen / (sizeof(xfs_inobt_key_t) + sizeof(xfs_inobt_ptr_t));
}
/*
* Calculate number of records in an inobt btree block.
*/
unsigned int
xfs_inobt_maxrecs(
struct xfs_mount *mp,
unsigned int blocklen,
bool leaf)
{
blocklen -= XFS_INOBT_BLOCK_LEN(mp);
return xfs_inobt_block_maxrecs(blocklen, leaf);
}
/*
* Maximum number of inode btree records per AG. Pretend that we can fill an
* entire AG completely full of inodes except for the AG headers.
*/
#define XFS_MAX_INODE_RECORDS \
((XFS_MAX_AG_BYTES - (4 * BBSIZE)) / XFS_DINODE_MIN_SIZE) / \
XFS_INODES_PER_CHUNK
/* Compute the max possible height for the inode btree. */
static inline unsigned int
xfs_inobt_maxlevels_ondisk(void)
{
unsigned int minrecs[2];
unsigned int blocklen;
blocklen = min(XFS_MIN_BLOCKSIZE - XFS_BTREE_SBLOCK_LEN,
XFS_MIN_CRC_BLOCKSIZE - XFS_BTREE_SBLOCK_CRC_LEN);
minrecs[0] = xfs_inobt_block_maxrecs(blocklen, true) / 2;
minrecs[1] = xfs_inobt_block_maxrecs(blocklen, false) / 2;
return xfs_btree_compute_maxlevels(minrecs, XFS_MAX_INODE_RECORDS);
}
/* Compute the max possible height for the free inode btree. */
static inline unsigned int
xfs_finobt_maxlevels_ondisk(void)
{
unsigned int minrecs[2];
unsigned int blocklen;
blocklen = XFS_MIN_CRC_BLOCKSIZE - XFS_BTREE_SBLOCK_CRC_LEN;
minrecs[0] = xfs_inobt_block_maxrecs(blocklen, true) / 2;
minrecs[1] = xfs_inobt_block_maxrecs(blocklen, false) / 2;
return xfs_btree_compute_maxlevels(minrecs, XFS_MAX_INODE_RECORDS);
}
/* Compute the max possible height for either inode btree. */
unsigned int
xfs_iallocbt_maxlevels_ondisk(void)
{
return max(xfs_inobt_maxlevels_ondisk(),
xfs_finobt_maxlevels_ondisk());
}
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_inobt_get_minrecs`, `function xfs_inobt_dup_cursor`, `function xfs_finobt_dup_cursor`, `function xfs_inobt_mod_blockcount`, `function __xfs_inobt_alloc_block`, `function xfs_inobt_alloc_block`, `function xfs_finobt_alloc_block`, `function __xfs_inobt_free_block`, `function xfs_inobt_free_block`, `function xfs_finobt_free_block`.
- 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.