fs/ext4/extents.c
Source file repositories/reference/linux-study-clean/fs/ext4/extents.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ext4/extents.c- Extension
.c- Size
- 176696 bytes
- Lines
- 6309
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
linux/fs.hlinux/time.hlinux/jbd2.hlinux/highuid.hlinux/pagemap.hlinux/quotaops.hlinux/string.hlinux/slab.hlinux/uaccess.hlinux/fiemap.hlinux/iomap.hlinux/sched/mm.hext4_jbd2.hext4_extents.hxattr.hkunit/static_stub.htrace/events/ext4.h
Detected Declarations
function ext4_extent_block_csumfunction ext4_extent_block_csum_verifyfunction ext4_extent_block_csum_setfunction ext4_ext_trunc_restart_fnfunction ext4_ext_path_brelsefunction ext4_ext_drop_refsfunction ext4_free_ext_pathfunction ext4_datasem_ensure_creditsfunction ext4_ext_get_accessfunction __ext4_ext_dirtyfunction __ext4_ext_dirtyfunction ext4_ext_new_meta_blockfunction ext4_ext_space_blockfunction ext4_ext_space_block_idxfunction ext4_ext_space_rootfunction ext4_ext_space_root_idxfunction ext4_force_split_extent_atfunction ext4_ext_max_entriesfunction ext4_valid_extentfunction ext4_valid_extent_idxfunction ext4_valid_extent_entriesfunction __ext4_ext_checkfunction ext4_ext_check_inodefunction ext4_cache_extentsfunction __read_extent_tree_blockfunction ext4_ext_precachefunction ext4_ext_show_pathfunction ext4_ext_show_leaffunction ext4_ext_show_movefunction ext4_ext_binsearch_idxfunction ext4_ext_binsearchfunction ext4_ext_tree_initfunction ext4_find_extentfunction ext4_ext_insert_indexfunction ext4_ext_splitfunction ext4_ext_grow_indepthfunction ext4_ext_create_new_leaffunction ext4_ext_search_leftfunction afunction ext4_ext_next_allocated_blockfunction ext4_ext_next_leaf_blockfunction ext4_ext_correct_indexesfunction ext4_can_extents_be_mergedfunction extentsfunction ext4_ext_try_to_merge_upfunction ext4_ext_try_to_mergefunction ext4_ext_check_overlapfunction block
Annotated Snippet
if (ex) {
ext4_fsblk_t ext_pblk = ext4_ext_pblock(ex);
ext4_lblk_t ext_block = le32_to_cpu(ex->ee_block);
if (block > ext_block)
return ext_pblk + (block - ext_block);
else
return ext_pblk - (ext_block - block);
}
/* it looks like index is empty;
* try to find starting block from index itself */
if (path[depth].p_bh)
return path[depth].p_bh->b_blocknr;
}
/* OK. use inode's group */
return ext4_inode_to_goal_block(inode);
}
/*
* Allocation for a meta data block
*/
static ext4_fsblk_t
ext4_ext_new_meta_block(handle_t *handle, struct inode *inode,
struct ext4_ext_path *path,
struct ext4_extent *ex, int *err, unsigned int flags)
{
ext4_fsblk_t goal, newblock;
goal = ext4_ext_find_goal(inode, path, le32_to_cpu(ex->ee_block));
newblock = ext4_new_meta_blocks(handle, inode, goal, flags,
NULL, err);
return newblock;
}
static inline int ext4_ext_space_block(struct inode *inode, int check)
{
int size;
size = (inode->i_sb->s_blocksize - sizeof(struct ext4_extent_header))
/ sizeof(struct ext4_extent);
#ifdef AGGRESSIVE_TEST
if (!check && size > 6)
size = 6;
#endif
return size;
}
static inline int ext4_ext_space_block_idx(struct inode *inode, int check)
{
int size;
size = (inode->i_sb->s_blocksize - sizeof(struct ext4_extent_header))
/ sizeof(struct ext4_extent_idx);
#ifdef AGGRESSIVE_TEST
if (!check && size > 5)
size = 5;
#endif
return size;
}
static inline int ext4_ext_space_root(struct inode *inode, int check)
{
int size;
size = sizeof(EXT4_I(inode)->i_data);
size -= sizeof(struct ext4_extent_header);
size /= sizeof(struct ext4_extent);
#ifdef AGGRESSIVE_TEST
if (!check && size > 3)
size = 3;
#endif
return size;
}
static inline int ext4_ext_space_root_idx(struct inode *inode, int check)
{
int size;
size = sizeof(EXT4_I(inode)->i_data);
size -= sizeof(struct ext4_extent_header);
size /= sizeof(struct ext4_extent_idx);
#ifdef AGGRESSIVE_TEST
if (!check && size > 4)
size = 4;
#endif
return size;
}
Annotation
- Immediate include surface: `linux/fs.h`, `linux/time.h`, `linux/jbd2.h`, `linux/highuid.h`, `linux/pagemap.h`, `linux/quotaops.h`, `linux/string.h`, `linux/slab.h`.
- Detected declarations: `function ext4_extent_block_csum`, `function ext4_extent_block_csum_verify`, `function ext4_extent_block_csum_set`, `function ext4_ext_trunc_restart_fn`, `function ext4_ext_path_brelse`, `function ext4_ext_drop_refs`, `function ext4_free_ext_path`, `function ext4_datasem_ensure_credits`, `function ext4_ext_get_access`, `function __ext4_ext_dirty`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.