fs/f2fs/debug.c
Source file repositories/reference/linux-study-clean/fs/f2fs/debug.c
File Facts
- System
- Linux kernel
- Corpus path
fs/f2fs/debug.c- Extension
.c- Size
- 30089 bytes
- Lines
- 865
- 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/backing-dev.hlinux/f2fs_fs.hlinux/blkdev.hlinux/debugfs.hlinux/seq_file.hf2fs.hnode.hsegment.hgc.h
Detected Declarations
function f2fs_update_sit_infofunction update_multidevice_statsfunction update_general_statusfunction update_mem_infofunction stat_showfunction f2fs_build_statsfunction f2fs_destroy_statsfunction f2fs_create_root_statsfunction f2fs_destroy_root_stats
Annotated Snippet
if (vblocks > 0 && vblocks < blks_per_sec) {
total_vblocks += vblocks;
ndirty++;
}
}
dist = div_u64(MAIN_SECS(sbi) * hblks_per_sec * hblks_per_sec, 100);
si->bimodal = div64_u64(bimodal, dist);
if (si->dirty_count)
si->avg_vblocks = div_u64(total_vblocks, ndirty);
else
si->avg_vblocks = 0;
}
#ifdef CONFIG_DEBUG_FS
static void update_multidevice_stats(struct f2fs_sb_info *sbi)
{
struct f2fs_stat_info *si = F2FS_STAT(sbi);
struct f2fs_dev_stats *dev_stats = si->dev_stats;
int i, j;
if (!f2fs_is_multi_device(sbi))
return;
memset(dev_stats, 0, sizeof(struct f2fs_dev_stats) * sbi->s_ndevs);
for (i = 0; i < sbi->s_ndevs; i++) {
unsigned int start_segno, end_segno;
block_t start_blk, end_blk;
if (i == 0) {
start_blk = MAIN_BLKADDR(sbi);
end_blk = FDEV(i).end_blk + 1 - SEG0_BLKADDR(sbi);
} else {
start_blk = FDEV(i).start_blk;
end_blk = FDEV(i).end_blk + 1;
}
start_segno = GET_SEGNO(sbi, start_blk);
end_segno = GET_SEGNO(sbi, end_blk);
for (j = start_segno; j < end_segno; j++) {
unsigned int seg_blks, sec_blks;
seg_blks = get_seg_entry(sbi, j)->valid_blocks;
/* update segment stats */
if (is_curseg(sbi, j))
dev_stats[i].devstats[0][DEVSTAT_INUSE]++;
else if (seg_blks == BLKS_PER_SEG(sbi))
dev_stats[i].devstats[0][DEVSTAT_FULL]++;
else if (seg_blks != 0)
dev_stats[i].devstats[0][DEVSTAT_DIRTY]++;
else if (!test_bit(j, FREE_I(sbi)->free_segmap))
dev_stats[i].devstats[0][DEVSTAT_FREE]++;
else
dev_stats[i].devstats[0][DEVSTAT_PREFREE]++;
if (!__is_large_section(sbi) ||
(j % SEGS_PER_SEC(sbi)) != 0)
continue;
sec_blks = get_sec_entry(sbi, j)->valid_blocks;
/* update section stats */
if (is_cursec(sbi, GET_SEC_FROM_SEG(sbi, j)))
dev_stats[i].devstats[1][DEVSTAT_INUSE]++;
else if (sec_blks == BLKS_PER_SEC(sbi))
dev_stats[i].devstats[1][DEVSTAT_FULL]++;
else if (sec_blks != 0)
dev_stats[i].devstats[1][DEVSTAT_DIRTY]++;
else if (!test_bit(GET_SEC_FROM_SEG(sbi, j),
FREE_I(sbi)->free_secmap))
dev_stats[i].devstats[1][DEVSTAT_FREE]++;
else
dev_stats[i].devstats[1][DEVSTAT_PREFREE]++;
}
}
}
static void update_general_status(struct f2fs_sb_info *sbi)
{
struct f2fs_stat_info *si = F2FS_STAT(sbi);
struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
int i;
/* these will be changed if online resize is done */
si->main_area_segs = le32_to_cpu(raw_super->segment_count_main);
si->main_area_sections = le32_to_cpu(raw_super->section_count);
si->main_area_zones = si->main_area_sections /
le32_to_cpu(raw_super->secs_per_zone);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/backing-dev.h`, `linux/f2fs_fs.h`, `linux/blkdev.h`, `linux/debugfs.h`, `linux/seq_file.h`, `f2fs.h`, `node.h`.
- Detected declarations: `function f2fs_update_sit_info`, `function update_multidevice_stats`, `function update_general_status`, `function update_mem_info`, `function stat_show`, `function f2fs_build_stats`, `function f2fs_destroy_stats`, `function f2fs_create_root_stats`, `function f2fs_destroy_root_stats`.
- 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.