fs/f2fs/gc.h
Source file repositories/reference/linux-study-clean/fs/f2fs/gc.h
File Facts
- System
- Linux kernel
- Corpus path
fs/f2fs/gc.h- Extension
.h- Size
- 6122 bytes
- Lines
- 203
- 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
- No C-style include directives detected by the generator.
Detected Declarations
struct f2fs_gc_kthreadstruct gc_inode_liststruct victim_entryfunction free_segs_blk_count_zonedfunction free_segs_blk_countfunction free_user_blocksfunction limit_invalid_user_blocksfunction limit_free_user_blocksfunction increase_sleep_timefunction decrease_sleep_timefunction has_enough_free_blocksfunction has_enough_invalid_blocksfunction need_to_boost_gc
Annotated Snippet
struct f2fs_gc_kthread {
struct task_struct *f2fs_gc_task;
wait_queue_head_t gc_wait_queue_head;
/* for gc sleep time */
unsigned int urgent_sleep_time;
unsigned int min_sleep_time;
unsigned int max_sleep_time;
unsigned int no_gc_sleep_time;
/* for changing gc mode */
bool gc_wake;
/* for GC_MERGE mount option */
wait_queue_head_t fggc_wq; /*
* caller of f2fs_balance_fs()
* will wait on this wait queue.
*/
/* for gc control for zoned devices */
unsigned int no_zoned_gc_percent;
unsigned int boost_zoned_gc_percent;
unsigned int valid_thresh_ratio;
unsigned int boost_gc_multiple;
unsigned int boost_gc_greedy;
};
struct gc_inode_list {
struct list_head ilist;
struct radix_tree_root iroot;
};
struct victim_entry {
struct rb_node rb_node; /* rb node located in rb-tree */
unsigned long long mtime; /* mtime of section */
unsigned int segno; /* segment No. */
struct list_head list;
};
/*
* inline functions
*/
/*
* On a Zoned device zone-capacity can be less than zone-size and if
* zone-capacity is not aligned to f2fs segment size(2MB), then the segment
* starting just before zone-capacity has some blocks spanning across the
* zone-capacity, these blocks are not usable.
* Such spanning segments can be in free list so calculate the sum of usable
* blocks in currently free segments including normal and spanning segments.
*/
static inline block_t free_segs_blk_count_zoned(struct f2fs_sb_info *sbi)
{
block_t free_seg_blks = 0;
struct free_segmap_info *free_i = FREE_I(sbi);
int j;
spin_lock(&free_i->segmap_lock);
for (j = 0; j < MAIN_SEGS(sbi); j++)
if (!test_bit(j, free_i->free_segmap))
free_seg_blks += f2fs_usable_blks_in_seg(sbi, j);
spin_unlock(&free_i->segmap_lock);
return free_seg_blks;
}
static inline block_t free_segs_blk_count(struct f2fs_sb_info *sbi)
{
if (f2fs_sb_has_blkzoned(sbi))
return free_segs_blk_count_zoned(sbi);
return SEGS_TO_BLKS(sbi, free_segments(sbi));
}
static inline block_t free_user_blocks(struct f2fs_sb_info *sbi)
{
block_t free_blks, ovp_blks;
free_blks = free_segs_blk_count(sbi);
ovp_blks = SEGS_TO_BLKS(sbi, overprovision_segments(sbi));
if (free_blks < ovp_blks)
return 0;
return free_blks - ovp_blks;
}
static inline block_t limit_invalid_user_blocks(block_t user_block_count)
{
return (long)(user_block_count * LIMIT_INVALID_BLOCK) / 100;
Annotation
- Detected declarations: `struct f2fs_gc_kthread`, `struct gc_inode_list`, `struct victim_entry`, `function free_segs_blk_count_zoned`, `function free_segs_blk_count`, `function free_user_blocks`, `function limit_invalid_user_blocks`, `function limit_free_user_blocks`, `function increase_sleep_time`, `function decrease_sleep_time`.
- 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.