fs/f2fs/segment.h
Source file repositories/reference/linux-study-clean/fs/f2fs/segment.h
File Facts
- System
- Linux kernel
- Corpus path
fs/f2fs/segment.h- Extension
.h- Size
- 32432 bytes
- Lines
- 1053
- 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/blkdev.hlinux/backing-dev.h
Detected Declarations
struct victim_sel_policystruct seg_entrystruct sec_entrystruct revoke_entrystruct sit_infostruct free_segmap_infostruct dirty_seglist_infostruct curseg_infostruct sit_entry_setenum dirty_typefunction Copyrightfunction is_cursegfunction is_cursecfunction get_valid_blocksfunction get_ckpt_valid_blocksfunction set_ckpt_valid_blocksfunction sanity_check_valid_blocksfunction sanity_check_valid_blocksfunction __seg_info_to_raw_sitfunction seg_info_to_sit_foliofunction seg_info_to_raw_sitfunction find_next_inusefunction __set_freefunction __set_inusefunction __set_test_and_freefunction __set_test_and_inusefunction get_sit_bitmapfunction written_block_countfunction free_segmentsfunction reserved_segmentsfunction free_sectionsfunction prefree_segmentsfunction dirty_segmentsfunction overprovision_segmentsfunction reserved_sectionsfunction get_left_section_blocksfunction get_additional_blocks_requiredfunction __get_secs_requiredfunction has_not_enough_free_secsfunction has_enough_free_secsfunction has_enough_free_blksfunction f2fs_is_checkpoint_readyfunction excess_prefree_segsfunction utilizationfunction IS_F2FS_IPU_DISABLEfunction curseg_segnofunction curseg_alloc_typefunction valid_main_segno
Annotated Snippet
struct victim_sel_policy {
int alloc_mode; /* LFS or SSR */
int gc_mode; /* GC_CB or GC_GREEDY */
unsigned long *dirty_bitmap; /* dirty segment/section bitmap */
unsigned int max_search; /*
* maximum # of segments/sections
* to search
*/
unsigned int offset; /* last scanned bitmap offset */
unsigned int ofs_unit; /* bitmap search unit */
unsigned int min_cost; /* minimum cost */
unsigned long long oldest_age; /* oldest age of segments having the same min cost */
unsigned int min_segno; /* segment # having min. cost */
unsigned long long age; /* mtime of GCed section*/
unsigned long long age_threshold;/* age threshold */
bool one_time_gc; /* one time GC */
};
struct seg_entry {
unsigned int type:6; /* segment type like CURSEG_XXX_TYPE */
unsigned int valid_blocks:10; /* # of valid blocks */
unsigned int ckpt_valid_blocks:10; /* # of valid blocks last cp */
unsigned int padding:6; /* padding */
unsigned char *cur_valid_map; /* validity bitmap of blocks */
#ifdef CONFIG_F2FS_CHECK_FS
unsigned char *cur_valid_map_mir; /* mirror of current valid bitmap */
#endif
/*
* # of valid blocks and the validity bitmap stored in the last
* checkpoint pack. This information is used by the SSR mode.
*/
unsigned char *ckpt_valid_map; /* validity bitmap of blocks last cp */
unsigned char *discard_map;
unsigned long long mtime; /* modification time of the segment */
};
struct sec_entry {
unsigned int valid_blocks; /* # of valid blocks in a section */
unsigned int ckpt_valid_blocks; /* # of valid blocks last cp in a section */
};
#define MAX_SKIP_GC_COUNT 16
struct revoke_entry {
struct list_head list;
block_t old_addr; /* for revoking when fail to commit */
pgoff_t index;
};
struct sit_info {
block_t sit_base_addr; /* start block address of SIT area */
block_t sit_blocks; /* # of blocks used by SIT area */
block_t written_valid_blocks; /* # of valid blocks in main area */
char *bitmap; /* all bitmaps pointer */
char *sit_bitmap; /* SIT bitmap pointer */
#ifdef CONFIG_F2FS_CHECK_FS
char *sit_bitmap_mir; /* SIT bitmap mirror */
/* bitmap of segments to be ignored by GC in case of errors */
unsigned long *invalid_segmap;
#endif
unsigned int bitmap_size; /* SIT bitmap size */
unsigned long *tmp_map; /* bitmap for temporal use */
unsigned long *dirty_sentries_bitmap; /* bitmap for dirty sentries */
unsigned int dirty_sentries; /* # of dirty sentries */
unsigned int sents_per_block; /* # of SIT entries per block */
struct rw_semaphore sentry_lock; /* to protect SIT cache */
struct seg_entry *sentries; /* SIT segment-level cache */
struct sec_entry *sec_entries; /* SIT section-level cache */
/* for cost-benefit algorithm in cleaning procedure */
unsigned long long elapsed_time; /* elapsed time after mount */
unsigned long long mounted_time; /* mount time */
unsigned long long min_mtime; /* min. modification time */
unsigned long long max_mtime; /* max. modification time */
unsigned long long dirty_min_mtime; /* rerange candidates in GC_AT */
unsigned long long dirty_max_mtime; /* rerange candidates in GC_AT */
unsigned int last_victim[MAX_GC_POLICY]; /* last victim segment # */
};
struct free_segmap_info {
unsigned int start_segno; /* start segment number logically */
unsigned int free_segments; /* # of free segments */
unsigned int free_sections; /* # of free sections */
spinlock_t segmap_lock; /* free segmap lock */
unsigned long *free_segmap; /* free segment bitmap */
unsigned long *free_secmap; /* free section bitmap */
};
Annotation
- Immediate include surface: `linux/blkdev.h`, `linux/backing-dev.h`.
- Detected declarations: `struct victim_sel_policy`, `struct seg_entry`, `struct sec_entry`, `struct revoke_entry`, `struct sit_info`, `struct free_segmap_info`, `struct dirty_seglist_info`, `struct curseg_info`, `struct sit_entry_set`, `enum dirty_type`.
- 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.