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.

Dependency Surface

Detected Declarations

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

Implementation Notes