fs/f2fs/extent_cache.c
Source file repositories/reference/linux-study-clean/fs/f2fs/extent_cache.c
File Facts
- System
- Linux kernel
- Corpus path
fs/f2fs/extent_cache.c- Extension
.c- Size
- 32399 bytes
- Lines
- 1259
- 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.
- 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/f2fs_fs.hf2fs.hnode.htrace/events/f2fs.h
Detected Declarations
function Copyrightfunction __set_extent_infofunction __init_may_extent_treefunction __may_extent_treefunction __try_update_largest_extentfunction __is_extent_mergeablefunction __is_back_mergeablefunction __is_front_mergeablefunction __detach_extent_nodefunction __release_extent_nodefunction __free_extent_treefunction __drop_largest_extentfunction f2fs_init_read_extent_treefunction f2fs_init_age_extent_treefunction f2fs_init_extent_treefunction __lookup_extent_treefunction __destroy_extent_nodefunction __update_extent_tree_rangefunction f2fs_update_read_extent_tree_range_compressedfunction __calculate_block_agefunction __get_new_block_agefunction __update_extent_cachefunction __shrink_extent_treefunction f2fs_lookup_read_extent_cachefunction f2fs_lookup_read_extent_cache_blockfunction f2fs_update_read_extent_cachefunction f2fs_update_read_extent_cache_rangefunction f2fs_shrink_read_extent_treefunction f2fs_lookup_age_extent_cachefunction f2fs_update_age_extent_cachefunction f2fs_update_age_extent_cache_rangefunction f2fs_shrink_age_extent_treefunction f2fs_destroy_extent_nodefunction __drop_extent_treefunction f2fs_drop_extent_treefunction __destroy_extent_treefunction f2fs_destroy_extent_treefunction __init_extent_tree_infofunction f2fs_init_extent_cache_infofunction f2fs_create_extent_cachefunction f2fs_destroy_extent_cache
Annotated Snippet
if (devi == 0) {
f2fs_warn(sbi,
"%s: inode (ino=%llx) is an alias of meta device",
__func__, inode->i_ino);
return false;
}
if (bdev_is_zoned(FDEV(devi).bdev)) {
f2fs_warn(sbi,
"%s: device alias inode (ino=%llx)'s extent info "
"[%u, %u, %u] maps to zoned block device",
__func__, inode->i_ino, ei.blk, ei.fofs, ei.len);
return false;
}
return true;
}
f2fs_warn(sbi, "%s: device alias inode (ino=%llx)'s extent info "
"[%u, %u, %u] is inconsistent w/ any devices",
__func__, inode->i_ino, ei.blk, ei.fofs, ei.len);
return false;
}
static void __set_extent_info(struct extent_info *ei,
unsigned int fofs, unsigned int len,
block_t blk, bool keep_clen,
unsigned long age, unsigned long last_blocks,
enum extent_type type)
{
ei->fofs = fofs;
ei->len = len;
if (type == EX_READ) {
ei->blk = blk;
if (keep_clen)
return;
#ifdef CONFIG_F2FS_FS_COMPRESSION
ei->c_len = 0;
#endif
} else if (type == EX_BLOCK_AGE) {
ei->age = age;
ei->last_blocks = last_blocks;
}
}
static bool __init_may_extent_tree(struct inode *inode, enum extent_type type)
{
if (type == EX_READ)
return test_opt(F2FS_I_SB(inode), READ_EXTENT_CACHE) &&
S_ISREG(inode->i_mode);
if (type == EX_BLOCK_AGE)
return test_opt(F2FS_I_SB(inode), AGE_EXTENT_CACHE) &&
(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode));
return false;
}
static bool __may_extent_tree(struct inode *inode, enum extent_type type)
{
if (IS_DEVICE_ALIASING(inode) && type == EX_READ)
return true;
/*
* for recovered files during mount do not create extents
* if shrinker is not registered.
*/
if (list_empty(&F2FS_I_SB(inode)->s_list))
return false;
if (!__init_may_extent_tree(inode, type))
return false;
if (is_inode_flag_set(inode, FI_NO_EXTENT))
return false;
if (type == EX_READ) {
if (is_inode_flag_set(inode, FI_COMPRESSED_FILE) &&
!f2fs_sb_has_readonly(F2FS_I_SB(inode)))
return false;
} else if (type == EX_BLOCK_AGE) {
if (is_inode_flag_set(inode, FI_COMPRESSED_FILE))
return false;
if (file_is_cold(inode))
return false;
}
return true;
}
static void __try_update_largest_extent(struct extent_tree *et,
struct extent_node *en)
{
Annotation
- Immediate include surface: `linux/fs.h`, `linux/f2fs_fs.h`, `f2fs.h`, `node.h`, `trace/events/f2fs.h`.
- Detected declarations: `function Copyright`, `function __set_extent_info`, `function __init_may_extent_tree`, `function __may_extent_tree`, `function __try_update_largest_extent`, `function __is_extent_mergeable`, `function __is_back_mergeable`, `function __is_front_mergeable`, `function __detach_extent_node`, `function __release_extent_node`.
- 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.