| 1 |
// SPDX-License-Identifier: GPL-2.0 |
| 2 |
/* |
| 3 |
* f2fs debugging statistics |
| 4 |
* |
| 5 |
* Copyright (c) 2012 Samsung Electronics Co., Ltd. |
| 6 |
* http://www.samsung.com/ |
| 7 |
* Copyright (c) 2012 Linux Foundation |
| 8 |
* Copyright (c) 2012 Greg Kroah-Hartman <[email protected]> |
| 9 |
*/ |
| 10 |
|
| 11 |
#include <linux/fs.h> |
| 12 |
#include <linux/backing-dev.h> |
| 13 |
#include <linux/f2fs_fs.h> |
| 14 |
#include <linux/blkdev.h> |
| 15 |
#include <linux/debugfs.h> |
| 16 |
#include <linux/seq_file.h> |
| 17 |
|
| 18 |
#include "f2fs.h" |
| 19 |
#include "node.h" |
| 20 |
#include "segment.h" |
| 21 |
#include "gc.h" |
| 22 |
|
| 23 |
static LIST_HEAD(f2fs_stat_list); |
| 24 |
static DEFINE_SPINLOCK(f2fs_stat_lock); |
| 25 |
#ifdef CONFIG_DEBUG_FS |
| 26 |
static struct dentry *f2fs_debugfs_root; |
| 27 |
#endif |
| 28 |
|
| 29 |
/* |
| 30 |
* This function calculates BDF of every segments |
| 31 |
*/ |
| 32 |
void f2fs_update_sit_info(struct f2fs_sb_info *sbi) |
| 33 |
{ |
| 34 |
struct f2fs_stat_info *si = F2FS_STAT(sbi); |
| 35 |
unsigned long long blks_per_sec, hblks_per_sec, total_vblocks; |
| 36 |
unsigned long long bimodal, dist; |
| 37 |
unsigned int segno, vblocks; |
| 38 |
int ndirty = 0; |
| 39 |
|
| 40 |
bimodal = 0; |
| 41 |
total_vblocks = 0; |
| 42 |
blks_per_sec = CAP_BLKS_PER_SEC(sbi); |
| 43 |
hblks_per_sec = blks_per_sec / 2; |
| 44 |
for (segno = 0; segno < MAIN_SEGS(sbi); segno += SEGS_PER_SEC(sbi)) { |
| 45 |
vblocks = get_valid_blocks(sbi, segno, true); |
| 46 |
dist = abs(vblocks - hblks_per_sec); |
| 47 |
bimodal += dist * dist; |
| 48 |
|
| 49 |
if (vblocks > 0 && vblocks < blks_per_sec) { |
| 50 |
total_vblocks += vblocks; |
| 51 |
ndirty++; |
| 52 |
} |
| 53 |
} |
| 54 |
dist = div_u64(MAIN_SECS(sbi) * hblks_per_sec * hblks_per_sec, 100); |
| 55 |
si->bimodal = div64_u64(bimodal, dist); |
| 56 |
if (si->dirty_count) |
| 57 |
si->avg_vblocks = div_u64(total_vblocks, ndirty); |
| 58 |
else |
| 59 |
si->avg_vblocks = 0; |
| 60 |
} |
| 61 |
|
| 62 |
#ifdef CONFIG_DEBUG_FS |
| 63 |
static void update_multidevice_stats(struct f2fs_sb_info *sbi) |
| 64 |
{ |
| 65 |
struct f2fs_stat_info *si = F2FS_STAT(sbi); |
| 66 |
struct f2fs_dev_stats *dev_stats = si->dev_stats; |
| 67 |
int i, j; |
| 68 |
|
| 69 |
if (!f2fs_is_multi_device(sbi)) |
| 70 |
return; |
| 71 |
|
| 72 |
memset(dev_stats, 0, sizeof(struct f2fs_dev_stats) * sbi->s_ndevs); |
| 73 |
for (i = 0; i < sbi->s_ndevs; i++) { |
| 74 |
unsigned int start_segno, end_segno; |
| 75 |
block_t start_blk, end_blk; |
| 76 |
|
| 77 |
if (i == 0) { |
| 78 |
start_blk = MAIN_BLKADDR(sbi); |
| 79 |
end_blk = FDEV(i).end_blk + 1 - SEG0_BLKADDR(sbi); |
| 80 |
} else { |
| 81 |
start_blk = FDEV(i).start_blk; |
| 82 |
end_blk = FDEV(i).end_blk + 1; |
| 83 |
} |
| 84 |
|
| 85 |
start_segno = GET_SEGNO(sbi, start_blk); |
| 86 |
end_segno = GET_SEGNO(sbi, end_blk); |
| 87 |
|
| 88 |
for (j = start_segno; j < end_segno; j++) { |
| 89 |
unsigned int seg_blks, sec_blks; |
| 90 |
|
| 91 |
seg_blks = get_seg_entry(sbi, j)->valid_blocks; |
| 92 |
|
| 93 |
/* update segment stats */ |
| 94 |
if (is_curseg(sbi, j)) |
| 95 |
dev_stats[i].devstats[0][DEVSTAT_INUSE]++; |
| 96 |
else if (seg_blks == BLKS_PER_SEG(sbi)) |
| 97 |
dev_stats[i].devstats[0][DEVSTAT_FULL]++; |
| 98 |
else if (seg_blks != 0) |
| 99 |
dev_stats[i].devstats[0][DEVSTAT_DIRTY]++; |
| 100 |
else if (!test_bit(j, FREE_I(sbi)->free_segmap)) |
| 101 |
dev_stats[i].devstats[0][DEVSTAT_FREE]++; |
| 102 |
else |
| 103 |
dev_stats[i].devstats[0][DEVSTAT_PREFREE]++; |
| 104 |
|
| 105 |
if (!__is_large_section(sbi) || |
| 106 |
(j % SEGS_PER_SEC(sbi)) != 0) |
| 107 |
continue; |
| 108 |
|
| 109 |
sec_blks = get_sec_entry(sbi, j)->valid_blocks; |
| 110 |
|
| 111 |
/* update section stats */ |
| 112 |
if (is_cursec(sbi, GET_SEC_FROM_SEG(sbi, j))) |
| 113 |
dev_stats[i].devstats[1][DEVSTAT_INUSE]++; |
| 114 |
else if (sec_blks == BLKS_PER_SEC(sbi)) |
| 115 |
dev_stats[i].devstats[1][DEVSTAT_FULL]++; |
| 116 |
else if (sec_blks != 0) |
| 117 |
dev_stats[i].devstats[1][DEVSTAT_DIRTY]++; |
| 118 |
else if (!test_bit(GET_SEC_FROM_SEG(sbi, j), |
| 119 |
FREE_I(sbi)->free_secmap)) |
| 120 |
dev_stats[i].devstats[1][DEVSTAT_FREE]++; |
| 121 |
else |
| 122 |
dev_stats[i].devstats[1][DEVSTAT_PREFREE]++; |
| 123 |
} |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
static void update_general_status(struct f2fs_sb_info *sbi) |
| 128 |
{ |
| 129 |
struct f2fs_stat_info *si = F2FS_STAT(sbi); |
| 130 |
struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); |
| 131 |
int i; |
| 132 |
|
| 133 |
/* these will be changed if online resize is done */ |
| 134 |
si->main_area_segs = le32_to_cpu(raw_super->segment_count_main); |
| 135 |
si->main_area_sections = le32_to_cpu(raw_super->section_count); |
| 136 |
si->main_area_zones = si->main_area_sections / |
| 137 |
le32_to_cpu(raw_super->secs_per_zone); |
| 138 |
|
| 139 |
/* general extent cache stats */ |
| 140 |
for (i = 0; i < NR_EXTENT_CACHES; i++) { |
| 141 |
struct extent_tree_info *eti = &sbi->extent_tree[i]; |
| 142 |
|
| 143 |
si->hit_cached[i] = atomic64_read(&sbi->read_hit_cached[i]); |
| 144 |
si->hit_rbtree[i] = atomic64_read(&sbi->read_hit_rbtree[i]); |
| 145 |
si->total_ext[i] = atomic64_read(&sbi->total_hit_ext[i]); |
| 146 |
si->hit_total[i] = si->hit_cached[i] + si->hit_rbtree[i]; |
| 147 |
si->ext_tree[i] = atomic_read(&eti->total_ext_tree); |
| 148 |
si->zombie_tree[i] = atomic_read(&eti->total_zombie_tree); |
| 149 |
si->ext_node[i] = atomic_read(&eti->total_ext_node); |
| 150 |
} |
| 151 |
/* read extent_cache only */ |
| 152 |
si->hit_largest = atomic64_read(&sbi->read_hit_largest); |
| 153 |
si->hit_total[EX_READ] += si->hit_largest; |
| 154 |
|
| 155 |
/* block age extent_cache only */ |
| 156 |
si->allocated_data_blocks = atomic64_read(&sbi->allocated_data_blocks); |
| 157 |
|
| 158 |
/* validation check of the segment numbers */ |
| 159 |
si->ndirty_node = get_pages(sbi, F2FS_DIRTY_NODES); |
| 160 |
si->ndirty_dent = get_pages(sbi, F2FS_DIRTY_DENTS); |
| 161 |
si->ndirty_meta = get_pages(sbi, F2FS_DIRTY_META); |
| 162 |
si->ndirty_data = get_pages(sbi, F2FS_DIRTY_DATA); |
| 163 |
si->ndirty_qdata = get_pages(sbi, F2FS_DIRTY_QDATA); |
| 164 |
si->ndirty_imeta = get_pages(sbi, F2FS_DIRTY_IMETA); |
| 165 |
si->ndirty_dirs = sbi->ndirty_inode[DIR_INODE]; |
| 166 |
si->ndirty_files = sbi->ndirty_inode[FILE_INODE]; |
| 167 |
si->ndonate_files = sbi->donate_files; |
| 168 |
si->nquota_files = sbi->nquota_files; |
| 169 |
si->ndirty_all = sbi->ndirty_inode[DIRTY_META]; |
| 170 |
si->aw_cnt = atomic_read(&sbi->atomic_files); |
| 171 |
si->max_aw_cnt = atomic_read(&sbi->max_aw_cnt); |
| 172 |
si->nr_dio_read = get_pages(sbi, F2FS_DIO_READ); |
| 173 |
si->nr_dio_write = get_pages(sbi, F2FS_DIO_WRITE); |
| 174 |
si->nr_wb_cp_data = get_pages(sbi, F2FS_WB_CP_DATA); |
| 175 |
si->nr_wb_data = get_pages(sbi, F2FS_WB_DATA); |
| 176 |
si->nr_rd_data = get_pages(sbi, F2FS_RD_DATA); |
| 177 |
si->nr_rd_node = get_pages(sbi, F2FS_RD_NODE); |
| 178 |
si->nr_rd_meta = get_pages(sbi, F2FS_RD_META); |
| 179 |
if (SM_I(sbi)->fcc_info) { |
| 180 |
si->nr_flushed = |
| 181 |
atomic_read(&SM_I(sbi)->fcc_info->issued_flush); |
| 182 |
si->nr_flushing = |
| 183 |
atomic_read(&SM_I(sbi)->fcc_info->queued_flush); |
| 184 |
si->flush_list_empty = |
| 185 |
llist_empty(&SM_I(sbi)->fcc_info->issue_list); |
| 186 |
} |
| 187 |
if (SM_I(sbi)->dcc_info) { |
| 188 |
si->nr_discarded = |
| 189 |
atomic_read(&SM_I(sbi)->dcc_info->issued_discard); |
| 190 |
si->nr_discarding = |
| 191 |
atomic_read(&SM_I(sbi)->dcc_info->queued_discard); |
| 192 |
si->nr_discard_cmd = |
| 193 |
atomic_read(&SM_I(sbi)->dcc_info->discard_cmd_cnt); |
| 194 |
si->undiscard_blks = SM_I(sbi)->dcc_info->undiscard_blks; |
| 195 |
} |
| 196 |
si->nr_issued_ckpt = atomic_read(&sbi->cprc_info.issued_ckpt); |
| 197 |
si->nr_total_ckpt = atomic_read(&sbi->cprc_info.total_ckpt); |
| 198 |
si->nr_queued_ckpt = atomic_read(&sbi->cprc_info.queued_ckpt); |
| 199 |
spin_lock(&sbi->cprc_info.stat_lock); |
| 200 |
si->cur_ckpt_time = sbi->cprc_info.cur_time; |
| 201 |
si->peak_ckpt_time = sbi->cprc_info.peak_time; |
| 202 |
spin_unlock(&sbi->cprc_info.stat_lock); |
| 203 |
si->total_count = BLKS_TO_SEGS(sbi, (int)sbi->user_block_count); |
| 204 |
si->rsvd_segs = reserved_segments(sbi); |
| 205 |
si->overp_segs = overprovision_segments(sbi); |
| 206 |
si->valid_count = valid_user_blocks(sbi); |
| 207 |
si->discard_blks = discard_blocks(sbi); |
| 208 |
si->valid_node_count = valid_node_count(sbi); |
| 209 |
si->valid_inode_count = valid_inode_count(sbi); |
| 210 |
si->inline_xattr = atomic_read(&sbi->inline_xattr); |
| 211 |
si->inline_inode = atomic_read(&sbi->inline_inode); |
| 212 |
si->inline_dir = atomic_read(&sbi->inline_dir); |
| 213 |
si->compr_inode = atomic_read(&sbi->compr_inode); |
| 214 |
si->swapfile_inode = atomic_read(&sbi->swapfile_inode); |
| 215 |
si->compr_blocks = atomic64_read(&sbi->compr_blocks); |
| 216 |
si->append = sbi->im[APPEND_INO].ino_num; |
| 217 |
si->update = sbi->im[UPDATE_INO].ino_num; |
| 218 |
si->orphans = sbi->im[ORPHAN_INO].ino_num; |
| 219 |
si->utilization = utilization(sbi); |
| 220 |
|
| 221 |
si->free_segs = free_segments(sbi); |
| 222 |
si->free_secs = free_sections(sbi); |
| 223 |
si->prefree_count = prefree_segments(sbi); |
| 224 |
si->dirty_count = dirty_segments(sbi); |
| 225 |
if (sbi->node_inode) |
| 226 |
si->node_pages = NODE_MAPPING(sbi)->nrpages; |
| 227 |
if (sbi->meta_inode) |
| 228 |
si->meta_pages = META_MAPPING(sbi)->nrpages; |
| 229 |
#ifdef CONFIG_F2FS_FS_COMPRESSION |
| 230 |
if (sbi->compress_inode) { |
| 231 |
si->compress_pages = COMPRESS_MAPPING(sbi)->nrpages; |
| 232 |
si->compress_page_hit = atomic_read(&sbi->compress_page_hit); |
| 233 |
} |
| 234 |
#endif |
| 235 |
si->nats = NM_I(sbi)->nat_cnt[TOTAL_NAT]; |
| 236 |
si->dirty_nats = NM_I(sbi)->nat_cnt[DIRTY_NAT]; |
| 237 |
si->sits = MAIN_SEGS(sbi); |
| 238 |
si->dirty_sits = SIT_I(sbi)->dirty_sentries; |
| 239 |
si->free_nids = NM_I(sbi)->nid_cnt[FREE_NID]; |
| 240 |
si->avail_nids = NM_I(sbi)->available_nids; |
| 241 |
si->alloc_nids = NM_I(sbi)->nid_cnt[PREALLOC_NID]; |
| 242 |
si->io_skip_bggc = sbi->io_skip_bggc; |
| 243 |
si->other_skip_bggc = sbi->other_skip_bggc; |
| 244 |
si->util_free = (int)(BLKS_TO_SEGS(sbi, free_user_blocks(sbi))) |
| 245 |
* 100 / (int)(sbi->user_block_count >> sbi->log_blocks_per_seg) |
| 246 |
/ 2; |
| 247 |
si->util_valid = (int)(BLKS_TO_SEGS(sbi, written_block_count(sbi))) |
| 248 |
* 100 / (int)(sbi->user_block_count >> sbi->log_blocks_per_seg) |
| 249 |
/ 2; |
| 250 |
si->util_invalid = 50 - si->util_free - si->util_valid; |
| 251 |
for (i = CURSEG_HOT_DATA; i < NO_CHECK_TYPE; i++) { |
| 252 |
struct curseg_info *curseg = CURSEG_I(sbi, i); |
| 253 |
|
| 254 |
si->blkoff[i] = curseg->next_blkoff; |
| 255 |
si->curseg[i] = curseg->segno; |
| 256 |
si->cursec[i] = GET_SEC_FROM_SEG(sbi, curseg->segno); |
| 257 |
si->curzone[i] = GET_ZONE_FROM_SEC(sbi, si->cursec[i]); |
| 258 |
} |
| 259 |
|
| 260 |
for (i = META_CP; i < META_MAX; i++) |
| 261 |
si->meta_count[i] = atomic_read(&sbi->meta_count[i]); |
| 262 |
|
| 263 |
for (i = 0; i < NO_CHECK_TYPE; i++) { |
| 264 |
si->dirty_seg[i] = 0; |
| 265 |
si->full_seg[i] = 0; |
| 266 |
si->valid_blks[i] = 0; |
| 267 |
} |
| 268 |
|
| 269 |
for (i = 0; i < MAIN_SEGS(sbi); i++) { |
| 270 |
int blks = get_seg_entry(sbi, i)->valid_blocks; |
| 271 |
int type = get_seg_entry(sbi, i)->type; |
| 272 |
|
| 273 |
if (!blks) |
| 274 |
continue; |
| 275 |
|
| 276 |
if (blks == BLKS_PER_SEG(sbi)) |
| 277 |
si->full_seg[type]++; |
| 278 |
else |
| 279 |
si->dirty_seg[type]++; |
| 280 |
si->valid_blks[type] += blks; |
| 281 |
} |
| 282 |
|
| 283 |
update_multidevice_stats(sbi); |
| 284 |
|
| 285 |
for (i = 0; i < MAX_CALL_TYPE; i++) |
| 286 |
si->cp_call_count[i] = atomic_read(&sbi->cp_call_count[i]); |
| 287 |
|
| 288 |
for (i = 0; i < 2; i++) { |
| 289 |
si->segment_count[i] = sbi->segment_count[i]; |
| 290 |
si->block_count[i] = sbi->block_count[i]; |
| 291 |
} |
| 292 |
|
| 293 |
si->inplace_count = atomic_read(&sbi->inplace_count); |
| 294 |
} |
| 295 |
|
| 296 |
/* |
| 297 |
* This function calculates memory footprint. |
| 298 |
*/ |
| 299 |
static void update_mem_info(struct f2fs_sb_info *sbi) |
| 300 |
{ |
| 301 |
struct f2fs_stat_info *si = F2FS_STAT(sbi); |
| 302 |
int i; |
| 303 |
|
| 304 |
if (si->base_mem) |
| 305 |
goto get_cache; |
| 306 |
|
| 307 |
/* build stat */ |
| 308 |
si->base_mem = sizeof(struct f2fs_stat_info); |
| 309 |
|
| 310 |
/* build superblock */ |
| 311 |
si->base_mem += sizeof(struct f2fs_sb_info) + sbi->sb->s_blocksize; |
| 312 |
si->base_mem += 2 * sizeof(struct f2fs_inode_info); |
| 313 |
si->base_mem += sizeof(*sbi->ckpt); |
| 314 |
|
| 315 |
/* build sm */ |
| 316 |
si->base_mem += sizeof(struct f2fs_sm_info); |
| 317 |
|
| 318 |
/* build sit */ |
| 319 |
si->base_mem += sizeof(struct sit_info); |
| 320 |
si->base_mem += MAIN_SEGS(sbi) * sizeof(struct seg_entry); |
| 321 |
si->base_mem += f2fs_bitmap_size(MAIN_SEGS(sbi)); |
| 322 |
si->base_mem += 2 * SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi); |
| 323 |
si->base_mem += SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi); |
| 324 |
si->base_mem += SIT_VBLOCK_MAP_SIZE; |
| 325 |
if (__is_large_section(sbi)) |
| 326 |
si->base_mem += MAIN_SECS(sbi) * sizeof(struct sec_entry); |
| 327 |
si->base_mem += __bitmap_size(sbi, SIT_BITMAP); |
| 328 |
|
| 329 |
/* build free segmap */ |
| 330 |
si->base_mem += sizeof(struct free_segmap_info); |
| 331 |
si->base_mem += f2fs_bitmap_size(MAIN_SEGS(sbi)); |
| 332 |
si->base_mem += f2fs_bitmap_size(MAIN_SECS(sbi)); |
| 333 |
|
| 334 |
/* build curseg */ |
| 335 |
si->base_mem += sizeof(struct curseg_info) * NR_CURSEG_TYPE; |
| 336 |
si->base_mem += PAGE_SIZE * NR_CURSEG_TYPE; |
| 337 |
|
| 338 |
/* build dirty segmap */ |
| 339 |
si->base_mem += sizeof(struct dirty_seglist_info); |
| 340 |
si->base_mem += NR_DIRTY_TYPE * f2fs_bitmap_size(MAIN_SEGS(sbi)); |
| 341 |
si->base_mem += f2fs_bitmap_size(MAIN_SECS(sbi)); |
| 342 |
|
| 343 |
/* build nm */ |
| 344 |
si->base_mem += sizeof(struct f2fs_nm_info); |
| 345 |
si->base_mem += __bitmap_size(sbi, NAT_BITMAP); |
| 346 |
si->base_mem += F2FS_BLK_TO_BYTES(NM_I(sbi)->nat_bits_blocks); |
| 347 |
si->base_mem += NM_I(sbi)->nat_blocks * |
| 348 |
f2fs_bitmap_size(NAT_ENTRY_PER_BLOCK); |
| 349 |
si->base_mem += NM_I(sbi)->nat_blocks / 8; |
| 350 |
si->base_mem += NM_I(sbi)->nat_blocks * sizeof(unsigned short); |
| 351 |
|
| 352 |
get_cache: |
| 353 |
si->cache_mem = 0; |
| 354 |
|
| 355 |
/* build gc */ |
| 356 |
if (sbi->gc_thread) |
| 357 |
si->cache_mem += sizeof(struct f2fs_gc_kthread); |
| 358 |
|
| 359 |
/* build merge flush thread */ |
| 360 |
if (SM_I(sbi)->fcc_info) |
| 361 |
si->cache_mem += sizeof(struct flush_cmd_control); |
| 362 |
if (SM_I(sbi)->dcc_info) { |
| 363 |
si->cache_mem += sizeof(struct discard_cmd_control); |
| 364 |
si->cache_mem += sizeof(struct discard_cmd) * |
| 365 |
atomic_read(&SM_I(sbi)->dcc_info->discard_cmd_cnt); |
| 366 |
} |
| 367 |
|
| 368 |
/* free nids */ |
| 369 |
si->cache_mem += (NM_I(sbi)->nid_cnt[FREE_NID] + |
| 370 |
NM_I(sbi)->nid_cnt[PREALLOC_NID]) * |
| 371 |
sizeof(struct free_nid); |
| 372 |
si->cache_mem += NM_I(sbi)->nat_cnt[TOTAL_NAT] * |
| 373 |
sizeof(struct nat_entry); |
| 374 |
si->cache_mem += NM_I(sbi)->nat_cnt[DIRTY_NAT] * |
| 375 |
sizeof(struct nat_entry_set); |
| 376 |
for (i = 0; i < MAX_INO_ENTRY; i++) |
| 377 |
si->cache_mem += sbi->im[i].ino_num * sizeof(struct ino_entry); |
| 378 |
|
| 379 |
for (i = 0; i < NR_EXTENT_CACHES; i++) { |
| 380 |
struct extent_tree_info *eti = &sbi->extent_tree[i]; |
| 381 |
|
| 382 |
si->ext_mem[i] = atomic_read(&eti->total_ext_tree) * |
| 383 |
sizeof(struct extent_tree); |
| 384 |
si->ext_mem[i] += atomic_read(&eti->total_ext_node) * |
| 385 |
sizeof(struct extent_node); |
| 386 |
si->cache_mem += si->ext_mem[i]; |
| 387 |
} |
| 388 |
|
| 389 |
si->page_mem = 0; |
| 390 |
if (sbi->node_inode) { |
| 391 |
unsigned long npages = NODE_MAPPING(sbi)->nrpages; |
| 392 |
|
| 393 |
si->page_mem += (unsigned long long)npages << PAGE_SHIFT; |
| 394 |
} |
| 395 |
if (sbi->meta_inode) { |
| 396 |
unsigned long npages = META_MAPPING(sbi)->nrpages; |
| 397 |
|
| 398 |
si->page_mem += (unsigned long long)npages << PAGE_SHIFT; |
| 399 |
} |
| 400 |
#ifdef CONFIG_F2FS_FS_COMPRESSION |
| 401 |
if (sbi->compress_inode) { |
| 402 |
unsigned long npages = COMPRESS_MAPPING(sbi)->nrpages; |
| 403 |
|
| 404 |
si->page_mem += (unsigned long long)npages << PAGE_SHIFT; |
| 405 |
} |
| 406 |
#endif |
| 407 |
} |
| 408 |
|
| 409 |
static const char *s_flag[MAX_SBI_FLAG] = { |
| 410 |
[SBI_IS_DIRTY] = "fs_dirty", |
| 411 |
[SBI_IS_CLOSE] = "closing", |
| 412 |
[SBI_NEED_FSCK] = "need_fsck", |
| 413 |
[SBI_POR_DOING] = "recovering", |
| 414 |
[SBI_NEED_SB_WRITE] = "sb_dirty", |
| 415 |
[SBI_NEED_CP] = "need_cp", |
| 416 |
[SBI_IS_SHUTDOWN] = "shutdown", |
| 417 |
[SBI_IS_RECOVERED] = "recovered", |
| 418 |
[SBI_CP_DISABLED] = "cp_disabled", |
| 419 |
[SBI_CP_DISABLED_QUICK] = "cp_disabled_quick", |
| 420 |
[SBI_QUOTA_NEED_FLUSH] = "quota_need_flush", |
| 421 |
[SBI_QUOTA_SKIP_FLUSH] = "quota_skip_flush", |
| 422 |
[SBI_QUOTA_NEED_REPAIR] = "quota_need_repair", |
| 423 |
[SBI_IS_RESIZEFS] = "resizefs", |
| 424 |
[SBI_IS_FREEZING] = "freezefs", |
| 425 |
[SBI_IS_WRITABLE] = "writable", |
| 426 |
[SBI_ENABLE_CHECKPOINT] = "enable_checkpoint", |
| 427 |
}; |
| 428 |
|
| 429 |
static const char *ipu_mode_names[F2FS_IPU_MAX] = { |
| 430 |
[F2FS_IPU_FORCE] = "FORCE", |
| 431 |
[F2FS_IPU_SSR] = "SSR", |
| 432 |
[F2FS_IPU_UTIL] = "UTIL", |
| 433 |
[F2FS_IPU_SSR_UTIL] = "SSR_UTIL", |
| 434 |
[F2FS_IPU_FSYNC] = "FSYNC", |
| 435 |
[F2FS_IPU_ASYNC] = "ASYNC", |
| 436 |
[F2FS_IPU_NOCACHE] = "NOCACHE", |
| 437 |
[F2FS_IPU_HONOR_OPU_WRITE] = "HONOR_OPU_WRITE", |
| 438 |
}; |
| 439 |
|
| 440 |
static int stat_show(struct seq_file *s, void *v) |
| 441 |
{ |
| 442 |
struct f2fs_stat_info *si; |
| 443 |
int i = 0, j = 0; |
| 444 |
|
| 445 |
spin_lock(&f2fs_stat_lock); |
| 446 |
list_for_each_entry(si, &f2fs_stat_list, stat_list) { |
| 447 |
struct f2fs_sb_info *sbi = si->sbi; |
| 448 |
|
| 449 |
update_general_status(sbi); |
| 450 |
|
| 451 |
seq_printf(s, "\n=====[ partition info(%pg). #%d, %s, CP: %s]=====\n", |
| 452 |
sbi->sb->s_bdev, i++, |
| 453 |
f2fs_readonly(sbi->sb) ? "RO" : "RW", |
| 454 |
is_set_ckpt_flags(sbi, CP_DISABLED_FLAG) ? |
| 455 |
"Disabled" : (f2fs_cp_error(sbi) ? "Error" : "Good")); |
| 456 |
if (sbi->s_flag) { |
| 457 |
seq_puts(s, "[SBI:"); |
| 458 |
for_each_set_bit(j, &sbi->s_flag, MAX_SBI_FLAG) |
| 459 |
seq_printf(s, " %s", s_flag[j]); |
| 460 |
seq_puts(s, "]\n"); |
| 461 |
} |
| 462 |
seq_printf(s, "[SB: 1] [CP: 2] [SIT: %d] [NAT: %d] ", |
| 463 |
si->sit_area_segs, si->nat_area_segs); |
| 464 |
seq_printf(s, "[SSA: %d] [MAIN: %d", |
| 465 |
si->ssa_area_segs, si->main_area_segs); |
| 466 |
seq_printf(s, "(OverProv:%d Resv:%d)]\n\n", |
| 467 |
si->overp_segs, si->rsvd_segs); |
| 468 |
seq_printf(s, "Current Time Sec: %llu / Mounted Time Sec: %llu\n\n", |
| 469 |
ktime_get_boottime_seconds(), |
| 470 |
SIT_I(sbi)->mounted_time); |
| 471 |
|
| 472 |
seq_puts(s, "Policy:\n"); |
| 473 |
seq_puts(s, " - IPU: ["); |
| 474 |
if (IS_F2FS_IPU_DISABLE(sbi)) { |
| 475 |
seq_puts(s, " DISABLE"); |
| 476 |
} else { |
| 477 |
unsigned long policy = SM_I(sbi)->ipu_policy; |
| 478 |
|
| 479 |
for_each_set_bit(j, &policy, F2FS_IPU_MAX) |
| 480 |
seq_printf(s, " %s", ipu_mode_names[j]); |
| 481 |
} |
| 482 |
seq_puts(s, " ]\n\n"); |
| 483 |
|
| 484 |
if (test_opt(sbi, DISCARD)) |
| 485 |
seq_printf(s, "Utilization: %u%% (%u valid blocks, %u discard blocks)\n", |
| 486 |
si->utilization, si->valid_count, si->discard_blks); |
| 487 |
else |
| 488 |
seq_printf(s, "Utilization: %u%% (%u valid blocks)\n", |
| 489 |
si->utilization, si->valid_count); |
| 490 |
|
| 491 |
seq_printf(s, " - Node: %u (Inode: %u, ", |
| 492 |
si->valid_node_count, si->valid_inode_count); |
| 493 |
seq_printf(s, "Other: %u)\n - Data: %u\n", |
| 494 |
si->valid_node_count - si->valid_inode_count, |
| 495 |
si->valid_count - si->valid_node_count); |
| 496 |
seq_printf(s, " - Inline_xattr Inode: %u\n", |
| 497 |
si->inline_xattr); |
| 498 |
seq_printf(s, " - Inline_data Inode: %u\n", |
| 499 |
si->inline_inode); |
| 500 |
seq_printf(s, " - Inline_dentry Inode: %u\n", |
| 501 |
si->inline_dir); |
| 502 |
seq_printf(s, " - Compressed Inode: %u, Blocks: %llu\n", |
| 503 |
si->compr_inode, si->compr_blocks); |
| 504 |
seq_printf(s, " - Swapfile Inode: %u\n", |
| 505 |
si->swapfile_inode); |
| 506 |
seq_printf(s, " - Donate Inode: %u\n", |
| 507 |
si->ndonate_files); |
| 508 |
seq_printf(s, " - Orphan/Append/Update Inode: %u, %u, %u\n", |
| 509 |
si->orphans, si->append, si->update); |
| 510 |
seq_printf(s, "\nMain area: %d segs, %d secs %d zones\n", |
| 511 |
si->main_area_segs, si->main_area_sections, |
| 512 |
si->main_area_zones); |
| 513 |
seq_printf(s, " TYPE %8s %8s %8s %8s %10s %10s %10s\n", |
| 514 |
"blkoff", "segno", "secno", "zoneno", "dirty_seg", "full_seg", "valid_blk"); |
| 515 |
seq_printf(s, " - COLD data: %8d %8d %8d %8d %10u %10u %10u\n", |
| 516 |
si->blkoff[CURSEG_COLD_DATA], |
| 517 |
si->curseg[CURSEG_COLD_DATA], |
| 518 |
si->cursec[CURSEG_COLD_DATA], |
| 519 |
si->curzone[CURSEG_COLD_DATA], |
| 520 |
si->dirty_seg[CURSEG_COLD_DATA], |
| 521 |
si->full_seg[CURSEG_COLD_DATA], |
| 522 |
si->valid_blks[CURSEG_COLD_DATA]); |
| 523 |
seq_printf(s, " - WARM data: %8d %8d %8d %8d %10u %10u %10u\n", |
| 524 |
si->blkoff[CURSEG_WARM_DATA], |
| 525 |
si->curseg[CURSEG_WARM_DATA], |
| 526 |
si->cursec[CURSEG_WARM_DATA], |
| 527 |
si->curzone[CURSEG_WARM_DATA], |
| 528 |
si->dirty_seg[CURSEG_WARM_DATA], |
| 529 |
si->full_seg[CURSEG_WARM_DATA], |
| 530 |
si->valid_blks[CURSEG_WARM_DATA]); |
| 531 |
seq_printf(s, " - HOT data: %8d %8d %8d %8d %10u %10u %10u\n", |
| 532 |
si->blkoff[CURSEG_HOT_DATA], |
| 533 |
si->curseg[CURSEG_HOT_DATA], |
| 534 |
si->cursec[CURSEG_HOT_DATA], |
| 535 |
si->curzone[CURSEG_HOT_DATA], |
| 536 |
si->dirty_seg[CURSEG_HOT_DATA], |
| 537 |
si->full_seg[CURSEG_HOT_DATA], |
| 538 |
si->valid_blks[CURSEG_HOT_DATA]); |
| 539 |
seq_printf(s, " - Dir dnode: %8d %8d %8d %8d %10u %10u %10u\n", |
| 540 |
si->blkoff[CURSEG_HOT_NODE], |
| 541 |
si->curseg[CURSEG_HOT_NODE], |
| 542 |
si->cursec[CURSEG_HOT_NODE], |
| 543 |
si->curzone[CURSEG_HOT_NODE], |
| 544 |
si->dirty_seg[CURSEG_HOT_NODE], |
| 545 |
si->full_seg[CURSEG_HOT_NODE], |
| 546 |
si->valid_blks[CURSEG_HOT_NODE]); |
| 547 |
seq_printf(s, " - File dnode: %8d %8d %8d %8d %10u %10u %10u\n", |
| 548 |
si->blkoff[CURSEG_WARM_NODE], |
| 549 |
si->curseg[CURSEG_WARM_NODE], |
| 550 |
si->cursec[CURSEG_WARM_NODE], |
| 551 |
si->curzone[CURSEG_WARM_NODE], |
| 552 |
si->dirty_seg[CURSEG_WARM_NODE], |
| 553 |
si->full_seg[CURSEG_WARM_NODE], |
| 554 |
si->valid_blks[CURSEG_WARM_NODE]); |
| 555 |
seq_printf(s, " - Indir nodes: %8d %8d %8d %8d %10u %10u %10u\n", |
| 556 |
si->blkoff[CURSEG_COLD_NODE], |
| 557 |
si->curseg[CURSEG_COLD_NODE], |
| 558 |
si->cursec[CURSEG_COLD_NODE], |
| 559 |
si->curzone[CURSEG_COLD_NODE], |
| 560 |
si->dirty_seg[CURSEG_COLD_NODE], |
| 561 |
si->full_seg[CURSEG_COLD_NODE], |
| 562 |
si->valid_blks[CURSEG_COLD_NODE]); |
| 563 |
seq_printf(s, " - Pinned file: %8d %8d %8d %8d\n", |
| 564 |
si->blkoff[CURSEG_COLD_DATA_PINNED], |
| 565 |
si->curseg[CURSEG_COLD_DATA_PINNED], |
| 566 |
si->cursec[CURSEG_COLD_DATA_PINNED], |
| 567 |
si->curzone[CURSEG_COLD_DATA_PINNED]); |
| 568 |
seq_printf(s, " - ATGC data: %8d %8d %8d %8d\n", |
| 569 |
si->blkoff[CURSEG_ALL_DATA_ATGC], |
| 570 |
si->curseg[CURSEG_ALL_DATA_ATGC], |
| 571 |
si->cursec[CURSEG_ALL_DATA_ATGC], |
| 572 |
si->curzone[CURSEG_ALL_DATA_ATGC]); |
| 573 |
seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", |
| 574 |
si->main_area_segs - si->dirty_count - |
| 575 |
si->prefree_count - si->free_segs, |
| 576 |
si->dirty_count); |
| 577 |
seq_printf(s, " - Prefree: %d\n - Free: %d (%d)\n\n", |
| 578 |
si->prefree_count, si->free_segs, si->free_secs); |
| 579 |
if (f2fs_is_multi_device(sbi)) { |
| 580 |
seq_puts(s, "Multidevice stats:\n"); |
| 581 |
seq_printf(s, " [seg: %8s %8s %8s %8s %8s]", |
| 582 |
"inuse", "dirty", "full", "free", "prefree"); |
| 583 |
if (__is_large_section(sbi)) |
| 584 |
seq_printf(s, " [sec: %8s %8s %8s %8s %8s]\n", |
| 585 |
"inuse", "dirty", "full", "free", "prefree"); |
| 586 |
else |
| 587 |
seq_puts(s, "\n"); |
| 588 |
|
| 589 |
for (i = 0; i < sbi->s_ndevs; i++) { |
| 590 |
seq_printf(s, " #%-2d %8u %8u %8u %8u %8u", i, |
| 591 |
si->dev_stats[i].devstats[0][DEVSTAT_INUSE], |
| 592 |
si->dev_stats[i].devstats[0][DEVSTAT_DIRTY], |
| 593 |
si->dev_stats[i].devstats[0][DEVSTAT_FULL], |
| 594 |
si->dev_stats[i].devstats[0][DEVSTAT_FREE], |
| 595 |
si->dev_stats[i].devstats[0][DEVSTAT_PREFREE]); |
| 596 |
if (!__is_large_section(sbi)) { |
| 597 |
seq_puts(s, "\n"); |
| 598 |
continue; |
| 599 |
} |
| 600 |
seq_printf(s, " %8u %8u %8u %8u %8u\n", |
| 601 |
si->dev_stats[i].devstats[1][DEVSTAT_INUSE], |
| 602 |
si->dev_stats[i].devstats[1][DEVSTAT_DIRTY], |
| 603 |
si->dev_stats[i].devstats[1][DEVSTAT_FULL], |
| 604 |
si->dev_stats[i].devstats[1][DEVSTAT_FREE], |
| 605 |
si->dev_stats[i].devstats[1][DEVSTAT_PREFREE]); |
| 606 |
} |
| 607 |
seq_puts(s, "\n"); |
| 608 |
} |
| 609 |
seq_printf(s, "CP calls: %d (BG: %d)\n", |
| 610 |
si->cp_call_count[TOTAL_CALL], |
| 611 |
si->cp_call_count[BACKGROUND]); |
| 612 |
seq_printf(s, "CP count: %d\n", si->cp_count); |
| 613 |
seq_printf(s, " - cp blocks : %u\n", si->meta_count[META_CP]); |
| 614 |
seq_printf(s, " - sit blocks : %u\n", |
| 615 |
si->meta_count[META_SIT]); |
| 616 |
seq_printf(s, " - nat blocks : %u\n", |
| 617 |
si->meta_count[META_NAT]); |
| 618 |
seq_printf(s, " - ssa blocks : %u\n", |
| 619 |
si->meta_count[META_SSA]); |
| 620 |
seq_puts(s, "CP merge:\n"); |
| 621 |
seq_printf(s, " - Queued : %4d\n", si->nr_queued_ckpt); |
| 622 |
seq_printf(s, " - Issued : %4d\n", si->nr_issued_ckpt); |
| 623 |
seq_printf(s, " - Total : %4d\n", si->nr_total_ckpt); |
| 624 |
seq_printf(s, " - Cur time : %4d(ms)\n", si->cur_ckpt_time); |
| 625 |
seq_printf(s, " - Peak time : %4d(ms)\n", si->peak_ckpt_time); |
| 626 |
seq_printf(s, "GC calls: %d (gc_thread: %d)\n", |
| 627 |
si->gc_call_count[BACKGROUND] + |
| 628 |
si->gc_call_count[FOREGROUND], |
| 629 |
si->gc_call_count[BACKGROUND]); |
| 630 |
if (__is_large_section(sbi)) { |
| 631 |
seq_printf(s, " - data sections : %d (BG: %d)\n", |
| 632 |
si->gc_secs[DATA][BG_GC] + si->gc_secs[DATA][FG_GC], |
| 633 |
si->gc_secs[DATA][BG_GC]); |
| 634 |
seq_printf(s, " - node sections : %d (BG: %d)\n", |
| 635 |
si->gc_secs[NODE][BG_GC] + si->gc_secs[NODE][FG_GC], |
| 636 |
si->gc_secs[NODE][BG_GC]); |
| 637 |
} |
| 638 |
seq_printf(s, " - data segments : %d (BG: %d)\n", |
| 639 |
si->gc_segs[DATA][BG_GC] + si->gc_segs[DATA][FG_GC], |
| 640 |
si->gc_segs[DATA][BG_GC]); |
| 641 |
seq_printf(s, " - node segments : %d (BG: %d)\n", |
| 642 |
si->gc_segs[NODE][BG_GC] + si->gc_segs[NODE][FG_GC], |
| 643 |
si->gc_segs[NODE][BG_GC]); |
| 644 |
seq_puts(s, " - Reclaimed segs :\n"); |
| 645 |
seq_printf(s, " - Normal : %d\n", sbi->gc_reclaimed_segs[GC_NORMAL]); |
| 646 |
seq_printf(s, " - Idle CB : %d\n", sbi->gc_reclaimed_segs[GC_IDLE_CB]); |
| 647 |
seq_printf(s, " - Idle Greedy : %d\n", |
| 648 |
sbi->gc_reclaimed_segs[GC_IDLE_GREEDY]); |
| 649 |
seq_printf(s, " - Idle AT : %d\n", sbi->gc_reclaimed_segs[GC_IDLE_AT]); |
| 650 |
seq_printf(s, " - Urgent High : %d\n", |
| 651 |
sbi->gc_reclaimed_segs[GC_URGENT_HIGH]); |
| 652 |
seq_printf(s, " - Urgent Mid : %d\n", sbi->gc_reclaimed_segs[GC_URGENT_MID]); |
| 653 |
seq_printf(s, " - Urgent Low : %d\n", sbi->gc_reclaimed_segs[GC_URGENT_LOW]); |
| 654 |
seq_printf(s, "Try to move %d blocks (BG: %d)\n", si->tot_blks, |
| 655 |
si->bg_data_blks + si->bg_node_blks); |
| 656 |
seq_printf(s, " - data blocks : %d (%d)\n", si->data_blks, |
| 657 |
si->bg_data_blks); |
| 658 |
seq_printf(s, " - node blocks : %d (%d)\n", si->node_blks, |
| 659 |
si->bg_node_blks); |
| 660 |
seq_printf(s, "BG skip : IO: %u, Other: %u\n", |
| 661 |
si->io_skip_bggc, si->other_skip_bggc); |
| 662 |
seq_puts(s, "\nExtent Cache (Read):\n"); |
| 663 |
seq_printf(s, " - Hit Count: L1-1:%llu L1-2:%llu L2:%llu\n", |
| 664 |
si->hit_largest, si->hit_cached[EX_READ], |
| 665 |
si->hit_rbtree[EX_READ]); |
| 666 |
seq_printf(s, " - Hit Ratio: %llu%% (%llu / %llu)\n", |
| 667 |
!si->total_ext[EX_READ] ? 0 : |
| 668 |
div64_u64(si->hit_total[EX_READ] * 100, |
| 669 |
si->total_ext[EX_READ]), |
| 670 |
si->hit_total[EX_READ], si->total_ext[EX_READ]); |
| 671 |
seq_printf(s, " - Inner Struct Count: tree: %d(%d), node: %d\n", |
| 672 |
si->ext_tree[EX_READ], si->zombie_tree[EX_READ], |
| 673 |
si->ext_node[EX_READ]); |
| 674 |
seq_puts(s, "\nExtent Cache (Block Age):\n"); |
| 675 |
seq_printf(s, " - Allocated Data Blocks: %llu\n", |
| 676 |
si->allocated_data_blocks); |
| 677 |
seq_printf(s, " - Hit Count: L1:%llu L2:%llu\n", |
| 678 |
si->hit_cached[EX_BLOCK_AGE], |
| 679 |
si->hit_rbtree[EX_BLOCK_AGE]); |
| 680 |
seq_printf(s, " - Hit Ratio: %llu%% (%llu / %llu)\n", |
| 681 |
!si->total_ext[EX_BLOCK_AGE] ? 0 : |
| 682 |
div64_u64(si->hit_total[EX_BLOCK_AGE] * 100, |
| 683 |
si->total_ext[EX_BLOCK_AGE]), |
| 684 |
si->hit_total[EX_BLOCK_AGE], |
| 685 |
si->total_ext[EX_BLOCK_AGE]); |
| 686 |
seq_printf(s, " - Inner Struct Count: tree: %d(%d), node: %d\n", |
| 687 |
si->ext_tree[EX_BLOCK_AGE], |
| 688 |
si->zombie_tree[EX_BLOCK_AGE], |
| 689 |
si->ext_node[EX_BLOCK_AGE]); |
| 690 |
seq_puts(s, "\nBalancing F2FS Async:\n"); |
| 691 |
seq_printf(s, " - DIO (R: %4d, W: %4d)\n", |
| 692 |
si->nr_dio_read, si->nr_dio_write); |
| 693 |
seq_printf(s, " - IO_R (Data: %4d, Node: %4d, Meta: %4d\n", |
| 694 |
si->nr_rd_data, si->nr_rd_node, si->nr_rd_meta); |
| 695 |
seq_printf(s, " - IO_W (CP: %4d, Data: %4d, Flush: (%4d %4d %4d), ", |
| 696 |
si->nr_wb_cp_data, si->nr_wb_data, |
| 697 |
si->nr_flushing, si->nr_flushed, |
| 698 |
si->flush_list_empty); |
| 699 |
seq_printf(s, "Discard: (%4d %4d)) cmd: %4d undiscard:%4u\n", |
| 700 |
si->nr_discarding, si->nr_discarded, |
| 701 |
si->nr_discard_cmd, si->undiscard_blks); |
| 702 |
seq_printf(s, " - atomic IO: %4d (Max. %4d)\n", |
| 703 |
si->aw_cnt, si->max_aw_cnt); |
| 704 |
seq_printf(s, " - compress: %4d, hit:%8d\n", si->compress_pages, si->compress_page_hit); |
| 705 |
seq_printf(s, " - nodes: %4d in %4d\n", |
| 706 |
si->ndirty_node, si->node_pages); |
| 707 |
seq_printf(s, " - dents: %4d in dirs:%4d (%4d)\n", |
| 708 |
si->ndirty_dent, si->ndirty_dirs, si->ndirty_all); |
| 709 |
seq_printf(s, " - data: %4d in files:%4d\n", |
| 710 |
si->ndirty_data, si->ndirty_files); |
| 711 |
seq_printf(s, " - quota data: %4d in quota files:%4d\n", |
| 712 |
si->ndirty_qdata, si->nquota_files); |
| 713 |
seq_printf(s, " - meta: %4d in %4d\n", |
| 714 |
si->ndirty_meta, si->meta_pages); |
| 715 |
seq_printf(s, " - imeta: %4d\n", |
| 716 |
si->ndirty_imeta); |
| 717 |
seq_printf(s, " - fsync mark: %4lld\n", |
| 718 |
percpu_counter_sum_positive( |
| 719 |
&sbi->rf_node_block_count)); |
| 720 |
seq_printf(s, " - NATs: %9d/%9d\n - SITs: %9d/%9d\n", |
| 721 |
si->dirty_nats, si->nats, si->dirty_sits, si->sits); |
| 722 |
seq_printf(s, " - free_nids: %9d/%9d\n - alloc_nids: %9d\n", |
| 723 |
si->free_nids, si->avail_nids, si->alloc_nids); |
| 724 |
seq_puts(s, "\nDistribution of User Blocks:"); |
| 725 |
seq_puts(s, " [ valid | invalid | free ]\n"); |
| 726 |
seq_puts(s, " ["); |
| 727 |
|
| 728 |
for (j = 0; j < si->util_valid; j++) |
| 729 |
seq_putc(s, '-'); |
| 730 |
seq_putc(s, '|'); |
| 731 |
|
| 732 |
for (j = 0; j < si->util_invalid; j++) |
| 733 |
seq_putc(s, '-'); |
| 734 |
seq_putc(s, '|'); |
| 735 |
|
| 736 |
for (j = 0; j < si->util_free; j++) |
| 737 |
seq_putc(s, '-'); |
| 738 |
seq_puts(s, "]\n\n"); |
| 739 |
seq_printf(s, "IPU: %u blocks\n", si->inplace_count); |
| 740 |
seq_printf(s, "SSR: %u blocks in %u segments\n", |
| 741 |
si->block_count[SSR], si->segment_count[SSR]); |
| 742 |
seq_printf(s, "LFS: %u blocks in %u segments\n", |
| 743 |
si->block_count[LFS], si->segment_count[LFS]); |
| 744 |
|
| 745 |
/* segment usage info */ |
| 746 |
f2fs_update_sit_info(sbi); |
| 747 |
seq_printf(s, "\nBDF: %u, avg. vblocks: %u\n", |
| 748 |
si->bimodal, si->avg_vblocks); |
| 749 |
|
| 750 |
/* memory footprint */ |
| 751 |
update_mem_info(sbi); |
| 752 |
seq_printf(s, "\nMemory: %llu KB\n", |
| 753 |
(si->base_mem + si->cache_mem + si->page_mem) >> 10); |
| 754 |
seq_printf(s, " - static: %llu KB\n", |
| 755 |
si->base_mem >> 10); |
| 756 |
seq_printf(s, " - cached all: %llu KB\n", |
| 757 |
si->cache_mem >> 10); |
| 758 |
seq_printf(s, " - read extent cache: %llu KB\n", |
| 759 |
si->ext_mem[EX_READ] >> 10); |
| 760 |
seq_printf(s, " - block age extent cache: %llu KB\n", |
| 761 |
si->ext_mem[EX_BLOCK_AGE] >> 10); |
| 762 |
seq_printf(s, " - paged : %llu KB\n", |
| 763 |
si->page_mem >> 10); |
| 764 |
} |
| 765 |
spin_unlock(&f2fs_stat_lock); |
| 766 |
return 0; |
| 767 |
} |
| 768 |
|
| 769 |
DEFINE_SHOW_ATTRIBUTE(stat); |
| 770 |
#endif |
| 771 |
|
| 772 |
int f2fs_build_stats(struct f2fs_sb_info *sbi) |
| 773 |
{ |
| 774 |
struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); |
| 775 |
struct f2fs_stat_info *si; |
| 776 |
struct f2fs_dev_stats *dev_stats; |
| 777 |
int i; |
| 778 |
|
| 779 |
si = f2fs_kzalloc(sbi, sizeof(struct f2fs_stat_info), GFP_KERNEL); |
| 780 |
if (!si) |
| 781 |
return -ENOMEM; |
| 782 |
|
| 783 |
dev_stats = f2fs_kzalloc(sbi, sizeof(struct f2fs_dev_stats) * |
| 784 |
sbi->s_ndevs, GFP_KERNEL); |
| 785 |
if (!dev_stats) { |
| 786 |
kfree(si); |
| 787 |
return -ENOMEM; |
| 788 |
} |
| 789 |
|
| 790 |
si->dev_stats = dev_stats; |
| 791 |
|
| 792 |
si->all_area_segs = le32_to_cpu(raw_super->segment_count); |
| 793 |
si->sit_area_segs = le32_to_cpu(raw_super->segment_count_sit); |
| 794 |
si->nat_area_segs = le32_to_cpu(raw_super->segment_count_nat); |
| 795 |
si->ssa_area_segs = le32_to_cpu(raw_super->segment_count_ssa); |
| 796 |
si->main_area_segs = le32_to_cpu(raw_super->segment_count_main); |
| 797 |
si->main_area_sections = le32_to_cpu(raw_super->section_count); |
| 798 |
si->main_area_zones = si->main_area_sections / |
| 799 |
le32_to_cpu(raw_super->secs_per_zone); |
| 800 |
si->sbi = sbi; |
| 801 |
sbi->stat_info = si; |
| 802 |
|
| 803 |
/* general extent cache stats */ |
| 804 |
for (i = 0; i < NR_EXTENT_CACHES; i++) { |
| 805 |
atomic64_set(&sbi->total_hit_ext[i], 0); |
| 806 |
atomic64_set(&sbi->read_hit_rbtree[i], 0); |
| 807 |
atomic64_set(&sbi->read_hit_cached[i], 0); |
| 808 |
} |
| 809 |
|
| 810 |
/* read extent_cache only */ |
| 811 |
atomic64_set(&sbi->read_hit_largest, 0); |
| 812 |
|
| 813 |
atomic_set(&sbi->inline_xattr, 0); |
| 814 |
atomic_set(&sbi->inline_inode, 0); |
| 815 |
atomic_set(&sbi->inline_dir, 0); |
| 816 |
atomic_set(&sbi->compr_inode, 0); |
| 817 |
atomic64_set(&sbi->compr_blocks, 0); |
| 818 |
atomic_set(&sbi->swapfile_inode, 0); |
| 819 |
atomic_set(&sbi->atomic_files, 0); |
| 820 |
atomic_set(&sbi->inplace_count, 0); |
| 821 |
for (i = META_CP; i < META_MAX; i++) |
| 822 |
atomic_set(&sbi->meta_count[i], 0); |
| 823 |
for (i = 0; i < MAX_CALL_TYPE; i++) |
| 824 |
atomic_set(&sbi->cp_call_count[i], 0); |
| 825 |
|
| 826 |
atomic_set(&sbi->max_aw_cnt, 0); |
| 827 |
|
| 828 |
spin_lock(&f2fs_stat_lock); |
| 829 |
list_add_tail(&si->stat_list, &f2fs_stat_list); |
| 830 |
spin_unlock(&f2fs_stat_lock); |
| 831 |
|
| 832 |
return 0; |
| 833 |
} |
| 834 |
|
| 835 |
void f2fs_destroy_stats(struct f2fs_sb_info *sbi) |
| 836 |
{ |
| 837 |
struct f2fs_stat_info *si = F2FS_STAT(sbi); |
| 838 |
|
| 839 |
spin_lock(&f2fs_stat_lock); |
| 840 |
list_del(&si->stat_list); |
| 841 |
spin_unlock(&f2fs_stat_lock); |
| 842 |
|
| 843 |
kfree(si->dev_stats); |
| 844 |
kfree(si); |
| 845 |
} |
| 846 |
|
| 847 |
void __init f2fs_create_root_stats(void) |
| 848 |
{ |
| 849 |
#ifdef CONFIG_DEBUG_FS |
| 850 |
f2fs_debugfs_root = debugfs_create_dir("f2fs", NULL); |
| 851 |
|
| 852 |
debugfs_create_file("status", 0444, f2fs_debugfs_root, NULL, |
| 853 |
&stat_fops); |
| 854 |
#endif |
| 855 |
} |
| 856 |
|
| 857 |
void f2fs_destroy_root_stats(void) |
| 858 |
{ |
| 859 |
#ifdef CONFIG_DEBUG_FS |
| 860 |
debugfs_remove_recursive(f2fs_debugfs_root); |
| 861 |
f2fs_debugfs_root = NULL; |
| 862 |
#endif |
| 863 |
} |