fs/xfs/libxfs/xfs_iext_tree.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_iext_tree.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_iext_tree.c- Extension
.c- Size
- 23886 bytes
- Lines
- 1068
- 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_shared.hxfs_format.hxfs_bit.hxfs_log_format.hxfs_trans_resv.hxfs_mount.hxfs_inode.hxfs_trace.h
Detected Declarations
struct xfs_iext_recstruct xfs_iext_nodestruct xfs_iext_leaffunction xfs_iext_rec_is_emptyfunction xfs_iext_rec_clearfunction xfs_iext_setfunction xfs_iext_getfunction xfs_iext_countfunction xfs_iext_max_recsfunction xfs_iext_validfunction xfs_iext_find_first_leaffunction xfs_iext_find_last_leaffunction xfs_iext_firstfunction xfs_iext_lastfunction xfs_iext_nextfunction xfs_iext_prevfunction xfs_iext_key_cmpfunction xfs_iext_rec_cmpfunction xfs_iext_find_levelfunction xfs_iext_node_posfunction xfs_iext_node_insert_posfunction xfs_iext_node_nr_entriesfunction xfs_iext_leaf_nr_entriesfunction xfs_iext_leaf_keyfunction xfs_iext_alloc_nodefunction xfs_iext_growfunction xfs_iext_update_nodefunction xfs_iext_split_nodefunction xfs_iext_insert_nodefunction xfs_iext_split_leaffunction xfs_iext_alloc_rootfunction xfs_iext_realloc_rootfunction xfs_iext_inc_seqfunction xfs_iext_insert_rawfunction xfs_iext_insertfunction xfs_iext_rebalance_nodefunction xfs_iext_remove_nodefunction xfs_iext_rebalance_leaffunction xfs_iext_free_last_leaffunction xfs_iext_removefunction xfs_iext_lookup_extentfunction xfs_iext_lookup_extent_beforefunction xfs_iext_update_extentfunction xfs_iext_get_extentfunction xfs_iext_destroy_nodefunction xfs_iext_destroy
Annotated Snippet
struct xfs_iext_rec {
uint64_t lo;
uint64_t hi;
};
/*
* Given that the length can't be a zero, only an empty hi value indicates an
* unused record.
*/
static bool xfs_iext_rec_is_empty(struct xfs_iext_rec *rec)
{
return rec->hi == 0;
}
static inline void xfs_iext_rec_clear(struct xfs_iext_rec *rec)
{
rec->lo = 0;
rec->hi = 0;
}
static void
xfs_iext_set(
struct xfs_iext_rec *rec,
struct xfs_bmbt_irec *irec)
{
ASSERT((irec->br_startoff & ~XFS_IEXT_STARTOFF_MASK) == 0);
ASSERT((irec->br_blockcount & ~XFS_IEXT_LENGTH_MASK) == 0);
ASSERT((irec->br_startblock & ~XFS_IEXT_STARTBLOCK_MASK) == 0);
rec->lo = irec->br_startoff & XFS_IEXT_STARTOFF_MASK;
rec->hi = irec->br_blockcount & XFS_IEXT_LENGTH_MASK;
rec->lo |= (irec->br_startblock << 54);
rec->hi |= ((irec->br_startblock & ~xfs_mask64lo(10)) << (22 - 10));
if (irec->br_state == XFS_EXT_UNWRITTEN)
rec->hi |= (1 << 21);
}
static void
xfs_iext_get(
struct xfs_bmbt_irec *irec,
struct xfs_iext_rec *rec)
{
irec->br_startoff = rec->lo & XFS_IEXT_STARTOFF_MASK;
irec->br_blockcount = rec->hi & XFS_IEXT_LENGTH_MASK;
irec->br_startblock = rec->lo >> 54;
irec->br_startblock |= (rec->hi & xfs_mask64hi(42)) >> (22 - 10);
if (rec->hi & (1 << 21))
irec->br_state = XFS_EXT_UNWRITTEN;
else
irec->br_state = XFS_EXT_NORM;
}
enum {
NODE_SIZE = 256,
KEYS_PER_NODE = NODE_SIZE / (sizeof(uint64_t) + sizeof(void *)),
RECS_PER_LEAF = (NODE_SIZE - (2 * sizeof(struct xfs_iext_leaf *))) /
sizeof(struct xfs_iext_rec),
};
/*
* In-core extent btree block layout:
*
* There are two types of blocks in the btree: leaf and inner (non-leaf) blocks.
*
* The leaf blocks are made up by %KEYS_PER_NODE extent records, which each
* contain the startoffset, blockcount, startblock and unwritten extent flag.
* See above for the exact format, followed by pointers to the previous and next
* leaf blocks (if there are any).
*
* The inner (non-leaf) blocks first contain KEYS_PER_NODE lookup keys, followed
* by an equal number of pointers to the btree blocks at the next lower level.
*
* +-------+-------+-------+-------+-------+----------+----------+
* Leaf: | rec 1 | rec 2 | rec 3 | rec 4 | rec N | prev-ptr | next-ptr |
* +-------+-------+-------+-------+-------+----------+----------+
*
* +-------+-------+-------+-------+-------+-------+------+-------+
* Inner: | key 1 | key 2 | key 3 | key N | ptr 1 | ptr 2 | ptr3 | ptr N |
* +-------+-------+-------+-------+-------+-------+------+-------+
*/
struct xfs_iext_node {
uint64_t keys[KEYS_PER_NODE];
#define XFS_IEXT_KEY_INVALID (1ULL << 63)
void *ptrs[KEYS_PER_NODE];
};
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_bit.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_inode.h`.
- Detected declarations: `struct xfs_iext_rec`, `struct xfs_iext_node`, `struct xfs_iext_leaf`, `function xfs_iext_rec_is_empty`, `function xfs_iext_rec_clear`, `function xfs_iext_set`, `function xfs_iext_get`, `function xfs_iext_count`, `function xfs_iext_max_recs`, `function xfs_iext_valid`.
- 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.