fs/ext4/extents_status.c
Source file repositories/reference/linux-study-clean/fs/ext4/extents_status.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ext4/extents_status.c- Extension
.c- Size
- 68570 bytes
- Lines
- 2393
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/list_sort.hlinux/proc_fs.hlinux/seq_file.hext4.htrace/events/ext4.hkunit/static_stub.hext4_extents.h
Detected Declarations
struct rsvd_countfunction ext4_init_esfunction ext4_exit_esfunction ext4_es_init_treefunction ext4_es_print_treefunction ext4_es_endfunction ext4_es_inc_seqfunction __es_check_extent_statusfunction __es_find_extent_rangefunction __es_find_extent_rangefunction __es_scan_rangefunction __es_scan_rangefunction __es_scan_clufunction __es_scan_clufunction ext4_es_list_addfunction ext4_es_list_delfunction __free_pendingfunction ext4_es_must_keepfunction ext4_es_init_extentfunction __es_free_extentfunction ext4_es_free_extentfunction ext4_es_can_be_mergedfunction ext4_es_try_to_merge_leftfunction ext4_es_try_to_merge_rightfunction ext4_es_insert_extent_ext_checkfunction ext4_es_insert_extent_ind_checkfunction ext4_es_insert_extent_checkfunction ext4_es_insert_extent_checkfunction ext4_es_insert_extentfunction ext4_es_cache_extentfunction ext4_es_lookup_extentfunction init_rsvdfunction count_rsvdfunction get_rsvdfunction __es_remove_extentfunction ext4_es_remove_extentfunction __es_shrinkfunction ext4_es_countfunction ext4_es_scanfunction ext4_seq_es_shrinker_info_showfunction ext4_es_register_shrinkerfunction ext4_es_unregister_shrinkerfunction es_do_reclaim_extentsfunction es_reclaim_extentsfunction ext4_clear_inode_esfunction ext4_print_pending_treefunction ext4_init_pendingfunction ext4_exit_pending
Annotated Snippet
struct rsvd_count {
int ndelayed;
bool first_do_lblk_found;
ext4_lblk_t first_do_lblk;
ext4_lblk_t last_do_lblk;
struct extent_status *left_es;
bool partial;
ext4_lblk_t lclu;
};
/*
* init_rsvd - initialize reserved count data before removing block range
* in file from extent status tree
*
* @inode - file containing range
* @lblk - first block in range
* @es - pointer to first extent in range
* @rc - pointer to reserved count data
*
* Assumes es is not NULL
*/
static void init_rsvd(struct inode *inode, ext4_lblk_t lblk,
struct extent_status *es, struct rsvd_count *rc)
{
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
struct rb_node *node;
rc->ndelayed = 0;
/*
* for bigalloc, note the first delayed block in the range has not
* been found, record the extent containing the block to the left of
* the region to be removed, if any, and note that there's no partial
* cluster to track
*/
if (sbi->s_cluster_ratio > 1) {
rc->first_do_lblk_found = false;
if (lblk > es->es_lblk) {
rc->left_es = es;
} else {
node = rb_prev(&es->rb_node);
rc->left_es = node ? rb_entry(node,
struct extent_status,
rb_node) : NULL;
}
rc->partial = false;
}
}
/*
* count_rsvd - count the clusters containing delayed blocks in a range
* within an extent and add to the running tally in rsvd_count
*
* @inode - file containing extent
* @lblk - first block in range
* @len - length of range in blocks
* @es - pointer to extent containing clusters to be counted
* @rc - pointer to reserved count data
*
* Tracks partial clusters found at the beginning and end of extents so
* they aren't overcounted when they span adjacent extents
*/
static void count_rsvd(struct inode *inode, ext4_lblk_t lblk, long len,
struct extent_status *es, struct rsvd_count *rc)
{
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
ext4_lblk_t i, end, nclu;
if (!ext4_es_is_delayed(es))
return;
WARN_ON(len <= 0);
if (sbi->s_cluster_ratio == 1) {
rc->ndelayed += (int) len;
return;
}
/* bigalloc */
i = (lblk < es->es_lblk) ? es->es_lblk : lblk;
end = lblk + (ext4_lblk_t) len - 1;
end = (end > ext4_es_end(es)) ? ext4_es_end(es) : end;
/* record the first block of the first delayed extent seen */
if (!rc->first_do_lblk_found) {
rc->first_do_lblk = i;
rc->first_do_lblk_found = true;
}
Annotation
- Immediate include surface: `linux/list_sort.h`, `linux/proc_fs.h`, `linux/seq_file.h`, `ext4.h`, `trace/events/ext4.h`, `kunit/static_stub.h`, `ext4_extents.h`.
- Detected declarations: `struct rsvd_count`, `function ext4_init_es`, `function ext4_exit_es`, `function ext4_es_init_tree`, `function ext4_es_print_tree`, `function ext4_es_end`, `function ext4_es_inc_seq`, `function __es_check_extent_status`, `function __es_find_extent_range`, `function __es_find_extent_range`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.