18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * f2fs debugging statistics 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2012 Samsung Electronics Co., Ltd. 68c2ecf20Sopenharmony_ci * http://www.samsung.com/ 78c2ecf20Sopenharmony_ci * Copyright (c) 2012 Linux Foundation 88c2ecf20Sopenharmony_ci * Copyright (c) 2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org> 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/fs.h> 128c2ecf20Sopenharmony_ci#include <linux/backing-dev.h> 138c2ecf20Sopenharmony_ci#include <linux/f2fs_fs.h> 148c2ecf20Sopenharmony_ci#include <linux/blkdev.h> 158c2ecf20Sopenharmony_ci#include <linux/debugfs.h> 168c2ecf20Sopenharmony_ci#include <linux/seq_file.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include "f2fs.h" 198c2ecf20Sopenharmony_ci#include "node.h" 208c2ecf20Sopenharmony_ci#include "segment.h" 218c2ecf20Sopenharmony_ci#include "gc.h" 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistatic LIST_HEAD(f2fs_stat_list); 248c2ecf20Sopenharmony_cistatic DEFINE_MUTEX(f2fs_stat_mutex); 258c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 268c2ecf20Sopenharmony_cistatic struct dentry *f2fs_debugfs_root; 278c2ecf20Sopenharmony_ci#endif 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* 308c2ecf20Sopenharmony_ci * This function calculates BDF of every segments 318c2ecf20Sopenharmony_ci */ 328c2ecf20Sopenharmony_civoid f2fs_update_sit_info(struct f2fs_sb_info *sbi) 338c2ecf20Sopenharmony_ci{ 348c2ecf20Sopenharmony_ci struct f2fs_stat_info *si = F2FS_STAT(sbi); 358c2ecf20Sopenharmony_ci unsigned long long blks_per_sec, hblks_per_sec, total_vblocks; 368c2ecf20Sopenharmony_ci unsigned long long bimodal, dist; 378c2ecf20Sopenharmony_ci unsigned int segno, vblocks; 388c2ecf20Sopenharmony_ci int ndirty = 0; 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci bimodal = 0; 418c2ecf20Sopenharmony_ci total_vblocks = 0; 428c2ecf20Sopenharmony_ci blks_per_sec = BLKS_PER_SEC(sbi); 438c2ecf20Sopenharmony_ci hblks_per_sec = blks_per_sec / 2; 448c2ecf20Sopenharmony_ci for (segno = 0; segno < MAIN_SEGS(sbi); segno += sbi->segs_per_sec) { 458c2ecf20Sopenharmony_ci vblocks = get_valid_blocks(sbi, segno, true); 468c2ecf20Sopenharmony_ci dist = abs(vblocks - hblks_per_sec); 478c2ecf20Sopenharmony_ci bimodal += dist * dist; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci if (vblocks > 0 && vblocks < blks_per_sec) { 508c2ecf20Sopenharmony_ci total_vblocks += vblocks; 518c2ecf20Sopenharmony_ci ndirty++; 528c2ecf20Sopenharmony_ci } 538c2ecf20Sopenharmony_ci } 548c2ecf20Sopenharmony_ci dist = div_u64(MAIN_SECS(sbi) * hblks_per_sec * hblks_per_sec, 100); 558c2ecf20Sopenharmony_ci si->bimodal = div64_u64(bimodal, dist); 568c2ecf20Sopenharmony_ci if (si->dirty_count) 578c2ecf20Sopenharmony_ci si->avg_vblocks = div_u64(total_vblocks, ndirty); 588c2ecf20Sopenharmony_ci else 598c2ecf20Sopenharmony_ci si->avg_vblocks = 0; 608c2ecf20Sopenharmony_ci} 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 638c2ecf20Sopenharmony_cistatic void update_general_status(struct f2fs_sb_info *sbi) 648c2ecf20Sopenharmony_ci{ 658c2ecf20Sopenharmony_ci struct f2fs_stat_info *si = F2FS_STAT(sbi); 668c2ecf20Sopenharmony_ci struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); 678c2ecf20Sopenharmony_ci int i; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci /* these will be changed if online resize is done */ 708c2ecf20Sopenharmony_ci si->main_area_segs = le32_to_cpu(raw_super->segment_count_main); 718c2ecf20Sopenharmony_ci si->main_area_sections = le32_to_cpu(raw_super->section_count); 728c2ecf20Sopenharmony_ci si->main_area_zones = si->main_area_sections / 738c2ecf20Sopenharmony_ci le32_to_cpu(raw_super->secs_per_zone); 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci /* validation check of the segment numbers */ 768c2ecf20Sopenharmony_ci si->hit_largest = atomic64_read(&sbi->read_hit_largest); 778c2ecf20Sopenharmony_ci si->hit_cached = atomic64_read(&sbi->read_hit_cached); 788c2ecf20Sopenharmony_ci si->hit_rbtree = atomic64_read(&sbi->read_hit_rbtree); 798c2ecf20Sopenharmony_ci si->hit_total = si->hit_largest + si->hit_cached + si->hit_rbtree; 808c2ecf20Sopenharmony_ci si->total_ext = atomic64_read(&sbi->total_hit_ext); 818c2ecf20Sopenharmony_ci si->ext_tree = atomic_read(&sbi->total_ext_tree); 828c2ecf20Sopenharmony_ci si->zombie_tree = atomic_read(&sbi->total_zombie_tree); 838c2ecf20Sopenharmony_ci si->ext_node = atomic_read(&sbi->total_ext_node); 848c2ecf20Sopenharmony_ci si->ndirty_node = get_pages(sbi, F2FS_DIRTY_NODES); 858c2ecf20Sopenharmony_ci si->ndirty_dent = get_pages(sbi, F2FS_DIRTY_DENTS); 868c2ecf20Sopenharmony_ci si->ndirty_meta = get_pages(sbi, F2FS_DIRTY_META); 878c2ecf20Sopenharmony_ci si->ndirty_data = get_pages(sbi, F2FS_DIRTY_DATA); 888c2ecf20Sopenharmony_ci si->ndirty_qdata = get_pages(sbi, F2FS_DIRTY_QDATA); 898c2ecf20Sopenharmony_ci si->ndirty_imeta = get_pages(sbi, F2FS_DIRTY_IMETA); 908c2ecf20Sopenharmony_ci si->ndirty_dirs = sbi->ndirty_inode[DIR_INODE]; 918c2ecf20Sopenharmony_ci si->ndirty_files = sbi->ndirty_inode[FILE_INODE]; 928c2ecf20Sopenharmony_ci si->nquota_files = sbi->nquota_files; 938c2ecf20Sopenharmony_ci si->ndirty_all = sbi->ndirty_inode[DIRTY_META]; 948c2ecf20Sopenharmony_ci si->inmem_pages = get_pages(sbi, F2FS_INMEM_PAGES); 958c2ecf20Sopenharmony_ci si->aw_cnt = sbi->atomic_files; 968c2ecf20Sopenharmony_ci si->vw_cnt = atomic_read(&sbi->vw_cnt); 978c2ecf20Sopenharmony_ci si->max_aw_cnt = atomic_read(&sbi->max_aw_cnt); 988c2ecf20Sopenharmony_ci si->max_vw_cnt = atomic_read(&sbi->max_vw_cnt); 998c2ecf20Sopenharmony_ci si->nr_dio_read = get_pages(sbi, F2FS_DIO_READ); 1008c2ecf20Sopenharmony_ci si->nr_dio_write = get_pages(sbi, F2FS_DIO_WRITE); 1018c2ecf20Sopenharmony_ci si->nr_wb_cp_data = get_pages(sbi, F2FS_WB_CP_DATA); 1028c2ecf20Sopenharmony_ci si->nr_wb_data = get_pages(sbi, F2FS_WB_DATA); 1038c2ecf20Sopenharmony_ci si->nr_rd_data = get_pages(sbi, F2FS_RD_DATA); 1048c2ecf20Sopenharmony_ci si->nr_rd_node = get_pages(sbi, F2FS_RD_NODE); 1058c2ecf20Sopenharmony_ci si->nr_rd_meta = get_pages(sbi, F2FS_RD_META); 1068c2ecf20Sopenharmony_ci if (SM_I(sbi)->fcc_info) { 1078c2ecf20Sopenharmony_ci si->nr_flushed = 1088c2ecf20Sopenharmony_ci atomic_read(&SM_I(sbi)->fcc_info->issued_flush); 1098c2ecf20Sopenharmony_ci si->nr_flushing = 1108c2ecf20Sopenharmony_ci atomic_read(&SM_I(sbi)->fcc_info->queued_flush); 1118c2ecf20Sopenharmony_ci si->flush_list_empty = 1128c2ecf20Sopenharmony_ci llist_empty(&SM_I(sbi)->fcc_info->issue_list); 1138c2ecf20Sopenharmony_ci } 1148c2ecf20Sopenharmony_ci if (SM_I(sbi)->dcc_info) { 1158c2ecf20Sopenharmony_ci si->nr_discarded = 1168c2ecf20Sopenharmony_ci atomic_read(&SM_I(sbi)->dcc_info->issued_discard); 1178c2ecf20Sopenharmony_ci si->nr_discarding = 1188c2ecf20Sopenharmony_ci atomic_read(&SM_I(sbi)->dcc_info->queued_discard); 1198c2ecf20Sopenharmony_ci si->nr_discard_cmd = 1208c2ecf20Sopenharmony_ci atomic_read(&SM_I(sbi)->dcc_info->discard_cmd_cnt); 1218c2ecf20Sopenharmony_ci si->undiscard_blks = SM_I(sbi)->dcc_info->undiscard_blks; 1228c2ecf20Sopenharmony_ci } 1238c2ecf20Sopenharmony_ci si->total_count = (int)sbi->user_block_count / sbi->blocks_per_seg; 1248c2ecf20Sopenharmony_ci si->rsvd_segs = reserved_segments(sbi); 1258c2ecf20Sopenharmony_ci si->overp_segs = overprovision_segments(sbi); 1268c2ecf20Sopenharmony_ci si->valid_count = valid_user_blocks(sbi); 1278c2ecf20Sopenharmony_ci si->discard_blks = discard_blocks(sbi); 1288c2ecf20Sopenharmony_ci si->valid_node_count = valid_node_count(sbi); 1298c2ecf20Sopenharmony_ci si->valid_inode_count = valid_inode_count(sbi); 1308c2ecf20Sopenharmony_ci si->inline_xattr = atomic_read(&sbi->inline_xattr); 1318c2ecf20Sopenharmony_ci si->inline_inode = atomic_read(&sbi->inline_inode); 1328c2ecf20Sopenharmony_ci si->inline_dir = atomic_read(&sbi->inline_dir); 1338c2ecf20Sopenharmony_ci si->compr_inode = atomic_read(&sbi->compr_inode); 1348c2ecf20Sopenharmony_ci si->compr_blocks = atomic64_read(&sbi->compr_blocks); 1358c2ecf20Sopenharmony_ci si->append = sbi->im[APPEND_INO].ino_num; 1368c2ecf20Sopenharmony_ci si->update = sbi->im[UPDATE_INO].ino_num; 1378c2ecf20Sopenharmony_ci si->orphans = sbi->im[ORPHAN_INO].ino_num; 1388c2ecf20Sopenharmony_ci si->utilization = utilization(sbi); 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci si->free_segs = free_segments(sbi); 1418c2ecf20Sopenharmony_ci si->free_secs = free_sections(sbi); 1428c2ecf20Sopenharmony_ci si->prefree_count = prefree_segments(sbi); 1438c2ecf20Sopenharmony_ci si->dirty_count = dirty_segments(sbi); 1448c2ecf20Sopenharmony_ci if (sbi->node_inode) 1458c2ecf20Sopenharmony_ci si->node_pages = NODE_MAPPING(sbi)->nrpages; 1468c2ecf20Sopenharmony_ci if (sbi->meta_inode) 1478c2ecf20Sopenharmony_ci si->meta_pages = META_MAPPING(sbi)->nrpages; 1488c2ecf20Sopenharmony_ci si->nats = NM_I(sbi)->nat_cnt[TOTAL_NAT]; 1498c2ecf20Sopenharmony_ci si->dirty_nats = NM_I(sbi)->nat_cnt[DIRTY_NAT]; 1508c2ecf20Sopenharmony_ci si->sits = MAIN_SEGS(sbi); 1518c2ecf20Sopenharmony_ci si->dirty_sits = SIT_I(sbi)->dirty_sentries; 1528c2ecf20Sopenharmony_ci si->free_nids = NM_I(sbi)->nid_cnt[FREE_NID]; 1538c2ecf20Sopenharmony_ci si->avail_nids = NM_I(sbi)->available_nids; 1548c2ecf20Sopenharmony_ci si->alloc_nids = NM_I(sbi)->nid_cnt[PREALLOC_NID]; 1558c2ecf20Sopenharmony_ci si->io_skip_bggc = sbi->io_skip_bggc; 1568c2ecf20Sopenharmony_ci si->other_skip_bggc = sbi->other_skip_bggc; 1578c2ecf20Sopenharmony_ci si->skipped_atomic_files[BG_GC] = sbi->skipped_atomic_files[BG_GC]; 1588c2ecf20Sopenharmony_ci si->skipped_atomic_files[FG_GC] = sbi->skipped_atomic_files[FG_GC]; 1598c2ecf20Sopenharmony_ci si->util_free = (int)(free_user_blocks(sbi) >> sbi->log_blocks_per_seg) 1608c2ecf20Sopenharmony_ci * 100 / (int)(sbi->user_block_count >> sbi->log_blocks_per_seg) 1618c2ecf20Sopenharmony_ci / 2; 1628c2ecf20Sopenharmony_ci si->util_valid = (int)(written_block_count(sbi) >> 1638c2ecf20Sopenharmony_ci sbi->log_blocks_per_seg) 1648c2ecf20Sopenharmony_ci * 100 / (int)(sbi->user_block_count >> sbi->log_blocks_per_seg) 1658c2ecf20Sopenharmony_ci / 2; 1668c2ecf20Sopenharmony_ci si->util_invalid = 50 - si->util_free - si->util_valid; 1678c2ecf20Sopenharmony_ci for (i = CURSEG_HOT_DATA; i < NO_CHECK_TYPE; i++) { 1688c2ecf20Sopenharmony_ci struct curseg_info *curseg = CURSEG_I(sbi, i); 1698c2ecf20Sopenharmony_ci si->curseg[i] = curseg->segno; 1708c2ecf20Sopenharmony_ci si->cursec[i] = GET_SEC_FROM_SEG(sbi, curseg->segno); 1718c2ecf20Sopenharmony_ci si->curzone[i] = GET_ZONE_FROM_SEC(sbi, si->cursec[i]); 1728c2ecf20Sopenharmony_ci } 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci for (i = META_CP; i < META_MAX; i++) 1758c2ecf20Sopenharmony_ci si->meta_count[i] = atomic_read(&sbi->meta_count[i]); 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci for (i = 0; i < NO_CHECK_TYPE; i++) { 1788c2ecf20Sopenharmony_ci si->dirty_seg[i] = 0; 1798c2ecf20Sopenharmony_ci si->full_seg[i] = 0; 1808c2ecf20Sopenharmony_ci si->valid_blks[i] = 0; 1818c2ecf20Sopenharmony_ci } 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci for (i = 0; i < MAIN_SEGS(sbi); i++) { 1848c2ecf20Sopenharmony_ci int blks = get_seg_entry(sbi, i)->valid_blocks; 1858c2ecf20Sopenharmony_ci int type = get_seg_entry(sbi, i)->type; 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci if (!blks) 1888c2ecf20Sopenharmony_ci continue; 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci if (blks == sbi->blocks_per_seg) 1918c2ecf20Sopenharmony_ci si->full_seg[type]++; 1928c2ecf20Sopenharmony_ci else 1938c2ecf20Sopenharmony_ci si->dirty_seg[type]++; 1948c2ecf20Sopenharmony_ci si->valid_blks[type] += blks; 1958c2ecf20Sopenharmony_ci } 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci for (i = 0; i < 2; i++) { 1988c2ecf20Sopenharmony_ci si->segment_count[i] = sbi->segment_count[i]; 1998c2ecf20Sopenharmony_ci si->block_count[i] = sbi->block_count[i]; 2008c2ecf20Sopenharmony_ci } 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci si->inplace_count = atomic_read(&sbi->inplace_count); 2038c2ecf20Sopenharmony_ci} 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci/* 2068c2ecf20Sopenharmony_ci * This function calculates memory footprint. 2078c2ecf20Sopenharmony_ci */ 2088c2ecf20Sopenharmony_cistatic void update_mem_info(struct f2fs_sb_info *sbi) 2098c2ecf20Sopenharmony_ci{ 2108c2ecf20Sopenharmony_ci struct f2fs_stat_info *si = F2FS_STAT(sbi); 2118c2ecf20Sopenharmony_ci int i; 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci if (si->base_mem) 2148c2ecf20Sopenharmony_ci goto get_cache; 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci /* build stat */ 2178c2ecf20Sopenharmony_ci si->base_mem = sizeof(struct f2fs_stat_info); 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci /* build superblock */ 2208c2ecf20Sopenharmony_ci si->base_mem += sizeof(struct f2fs_sb_info) + sbi->sb->s_blocksize; 2218c2ecf20Sopenharmony_ci si->base_mem += 2 * sizeof(struct f2fs_inode_info); 2228c2ecf20Sopenharmony_ci si->base_mem += sizeof(*sbi->ckpt); 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci /* build sm */ 2258c2ecf20Sopenharmony_ci si->base_mem += sizeof(struct f2fs_sm_info); 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci /* build sit */ 2288c2ecf20Sopenharmony_ci si->base_mem += sizeof(struct sit_info); 2298c2ecf20Sopenharmony_ci si->base_mem += MAIN_SEGS(sbi) * sizeof(struct seg_entry); 2308c2ecf20Sopenharmony_ci si->base_mem += f2fs_bitmap_size(MAIN_SEGS(sbi)); 2318c2ecf20Sopenharmony_ci si->base_mem += 2 * SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi); 2328c2ecf20Sopenharmony_ci si->base_mem += SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi); 2338c2ecf20Sopenharmony_ci si->base_mem += SIT_VBLOCK_MAP_SIZE; 2348c2ecf20Sopenharmony_ci if (__is_large_section(sbi)) 2358c2ecf20Sopenharmony_ci si->base_mem += MAIN_SECS(sbi) * sizeof(struct sec_entry); 2368c2ecf20Sopenharmony_ci si->base_mem += __bitmap_size(sbi, SIT_BITMAP); 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci /* build free segmap */ 2398c2ecf20Sopenharmony_ci si->base_mem += sizeof(struct free_segmap_info); 2408c2ecf20Sopenharmony_ci si->base_mem += f2fs_bitmap_size(MAIN_SEGS(sbi)); 2418c2ecf20Sopenharmony_ci si->base_mem += f2fs_bitmap_size(MAIN_SECS(sbi)); 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci /* build curseg */ 2448c2ecf20Sopenharmony_ci si->base_mem += sizeof(struct curseg_info) * NR_CURSEG_TYPE; 2458c2ecf20Sopenharmony_ci si->base_mem += PAGE_SIZE * NR_CURSEG_TYPE; 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci /* build dirty segmap */ 2488c2ecf20Sopenharmony_ci si->base_mem += sizeof(struct dirty_seglist_info); 2498c2ecf20Sopenharmony_ci si->base_mem += NR_DIRTY_TYPE * f2fs_bitmap_size(MAIN_SEGS(sbi)); 2508c2ecf20Sopenharmony_ci si->base_mem += f2fs_bitmap_size(MAIN_SECS(sbi)); 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci /* build nm */ 2538c2ecf20Sopenharmony_ci si->base_mem += sizeof(struct f2fs_nm_info); 2548c2ecf20Sopenharmony_ci si->base_mem += __bitmap_size(sbi, NAT_BITMAP); 2558c2ecf20Sopenharmony_ci si->base_mem += (NM_I(sbi)->nat_bits_blocks << F2FS_BLKSIZE_BITS); 2568c2ecf20Sopenharmony_ci si->base_mem += NM_I(sbi)->nat_blocks * 2578c2ecf20Sopenharmony_ci f2fs_bitmap_size(NAT_ENTRY_PER_BLOCK); 2588c2ecf20Sopenharmony_ci si->base_mem += NM_I(sbi)->nat_blocks / 8; 2598c2ecf20Sopenharmony_ci si->base_mem += NM_I(sbi)->nat_blocks * sizeof(unsigned short); 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ciget_cache: 2628c2ecf20Sopenharmony_ci si->cache_mem = 0; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci /* build gc */ 2658c2ecf20Sopenharmony_ci if (sbi->gc_thread) 2668c2ecf20Sopenharmony_ci si->cache_mem += sizeof(struct f2fs_gc_kthread); 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci /* build merge flush thread */ 2698c2ecf20Sopenharmony_ci if (SM_I(sbi)->fcc_info) 2708c2ecf20Sopenharmony_ci si->cache_mem += sizeof(struct flush_cmd_control); 2718c2ecf20Sopenharmony_ci if (SM_I(sbi)->dcc_info) { 2728c2ecf20Sopenharmony_ci si->cache_mem += sizeof(struct discard_cmd_control); 2738c2ecf20Sopenharmony_ci si->cache_mem += sizeof(struct discard_cmd) * 2748c2ecf20Sopenharmony_ci atomic_read(&SM_I(sbi)->dcc_info->discard_cmd_cnt); 2758c2ecf20Sopenharmony_ci } 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci /* free nids */ 2788c2ecf20Sopenharmony_ci si->cache_mem += (NM_I(sbi)->nid_cnt[FREE_NID] + 2798c2ecf20Sopenharmony_ci NM_I(sbi)->nid_cnt[PREALLOC_NID]) * 2808c2ecf20Sopenharmony_ci sizeof(struct free_nid); 2818c2ecf20Sopenharmony_ci si->cache_mem += NM_I(sbi)->nat_cnt[TOTAL_NAT] * 2828c2ecf20Sopenharmony_ci sizeof(struct nat_entry); 2838c2ecf20Sopenharmony_ci si->cache_mem += NM_I(sbi)->nat_cnt[DIRTY_NAT] * 2848c2ecf20Sopenharmony_ci sizeof(struct nat_entry_set); 2858c2ecf20Sopenharmony_ci si->cache_mem += si->inmem_pages * sizeof(struct inmem_pages); 2868c2ecf20Sopenharmony_ci for (i = 0; i < MAX_INO_ENTRY; i++) 2878c2ecf20Sopenharmony_ci si->cache_mem += sbi->im[i].ino_num * sizeof(struct ino_entry); 2888c2ecf20Sopenharmony_ci si->cache_mem += atomic_read(&sbi->total_ext_tree) * 2898c2ecf20Sopenharmony_ci sizeof(struct extent_tree); 2908c2ecf20Sopenharmony_ci si->cache_mem += atomic_read(&sbi->total_ext_node) * 2918c2ecf20Sopenharmony_ci sizeof(struct extent_node); 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci si->page_mem = 0; 2948c2ecf20Sopenharmony_ci if (sbi->node_inode) { 2958c2ecf20Sopenharmony_ci unsigned npages = NODE_MAPPING(sbi)->nrpages; 2968c2ecf20Sopenharmony_ci si->page_mem += (unsigned long long)npages << PAGE_SHIFT; 2978c2ecf20Sopenharmony_ci } 2988c2ecf20Sopenharmony_ci if (sbi->meta_inode) { 2998c2ecf20Sopenharmony_ci unsigned npages = META_MAPPING(sbi)->nrpages; 3008c2ecf20Sopenharmony_ci si->page_mem += (unsigned long long)npages << PAGE_SHIFT; 3018c2ecf20Sopenharmony_ci } 3028c2ecf20Sopenharmony_ci} 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_cistatic int stat_show(struct seq_file *s, void *v) 3058c2ecf20Sopenharmony_ci{ 3068c2ecf20Sopenharmony_ci struct f2fs_stat_info *si; 3078c2ecf20Sopenharmony_ci int i = 0; 3088c2ecf20Sopenharmony_ci int j; 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci mutex_lock(&f2fs_stat_mutex); 3118c2ecf20Sopenharmony_ci list_for_each_entry(si, &f2fs_stat_list, stat_list) { 3128c2ecf20Sopenharmony_ci update_general_status(si->sbi); 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci seq_printf(s, "\n=====[ partition info(%pg). #%d, %s, CP: %s]=====\n", 3158c2ecf20Sopenharmony_ci si->sbi->sb->s_bdev, i++, 3168c2ecf20Sopenharmony_ci f2fs_readonly(si->sbi->sb) ? "RO": "RW", 3178c2ecf20Sopenharmony_ci is_set_ckpt_flags(si->sbi, CP_DISABLED_FLAG) ? 3188c2ecf20Sopenharmony_ci "Disabled": (f2fs_cp_error(si->sbi) ? "Error": "Good")); 3198c2ecf20Sopenharmony_ci seq_printf(s, "[SB: 1] [CP: 2] [SIT: %d] [NAT: %d] ", 3208c2ecf20Sopenharmony_ci si->sit_area_segs, si->nat_area_segs); 3218c2ecf20Sopenharmony_ci seq_printf(s, "[SSA: %d] [MAIN: %d", 3228c2ecf20Sopenharmony_ci si->ssa_area_segs, si->main_area_segs); 3238c2ecf20Sopenharmony_ci seq_printf(s, "(OverProv:%d Resv:%d)]\n\n", 3248c2ecf20Sopenharmony_ci si->overp_segs, si->rsvd_segs); 3258c2ecf20Sopenharmony_ci seq_printf(s, "Current Time Sec: %llu / Mounted Time Sec: %llu\n\n", 3268c2ecf20Sopenharmony_ci ktime_get_boottime_seconds(), 3278c2ecf20Sopenharmony_ci SIT_I(si->sbi)->mounted_time); 3288c2ecf20Sopenharmony_ci if (test_opt(si->sbi, DISCARD)) 3298c2ecf20Sopenharmony_ci seq_printf(s, "Utilization: %u%% (%u valid blocks, %u discard blocks)\n", 3308c2ecf20Sopenharmony_ci si->utilization, si->valid_count, si->discard_blks); 3318c2ecf20Sopenharmony_ci else 3328c2ecf20Sopenharmony_ci seq_printf(s, "Utilization: %u%% (%u valid blocks)\n", 3338c2ecf20Sopenharmony_ci si->utilization, si->valid_count); 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci seq_printf(s, " - Node: %u (Inode: %u, ", 3368c2ecf20Sopenharmony_ci si->valid_node_count, si->valid_inode_count); 3378c2ecf20Sopenharmony_ci seq_printf(s, "Other: %u)\n - Data: %u\n", 3388c2ecf20Sopenharmony_ci si->valid_node_count - si->valid_inode_count, 3398c2ecf20Sopenharmony_ci si->valid_count - si->valid_node_count); 3408c2ecf20Sopenharmony_ci seq_printf(s, " - Inline_xattr Inode: %u\n", 3418c2ecf20Sopenharmony_ci si->inline_xattr); 3428c2ecf20Sopenharmony_ci seq_printf(s, " - Inline_data Inode: %u\n", 3438c2ecf20Sopenharmony_ci si->inline_inode); 3448c2ecf20Sopenharmony_ci seq_printf(s, " - Inline_dentry Inode: %u\n", 3458c2ecf20Sopenharmony_ci si->inline_dir); 3468c2ecf20Sopenharmony_ci seq_printf(s, " - Compressed Inode: %u, Blocks: %llu\n", 3478c2ecf20Sopenharmony_ci si->compr_inode, si->compr_blocks); 3488c2ecf20Sopenharmony_ci seq_printf(s, " - Orphan/Append/Update Inode: %u, %u, %u\n", 3498c2ecf20Sopenharmony_ci si->orphans, si->append, si->update); 3508c2ecf20Sopenharmony_ci seq_printf(s, "\nMain area: %d segs, %d secs %d zones\n", 3518c2ecf20Sopenharmony_ci si->main_area_segs, si->main_area_sections, 3528c2ecf20Sopenharmony_ci si->main_area_zones); 3538c2ecf20Sopenharmony_ci seq_printf(s, " TYPE %8s %8s %8s %10s %10s %10s\n", 3548c2ecf20Sopenharmony_ci "segno", "secno", "zoneno", "dirty_seg", "full_seg", "valid_blk"); 3558c2ecf20Sopenharmony_ci seq_printf(s, " - COLD data: %8d %8d %8d %10u %10u %10u\n", 3568c2ecf20Sopenharmony_ci si->curseg[CURSEG_COLD_DATA], 3578c2ecf20Sopenharmony_ci si->cursec[CURSEG_COLD_DATA], 3588c2ecf20Sopenharmony_ci si->curzone[CURSEG_COLD_DATA], 3598c2ecf20Sopenharmony_ci si->dirty_seg[CURSEG_COLD_DATA], 3608c2ecf20Sopenharmony_ci si->full_seg[CURSEG_COLD_DATA], 3618c2ecf20Sopenharmony_ci si->valid_blks[CURSEG_COLD_DATA]); 3628c2ecf20Sopenharmony_ci seq_printf(s, " - WARM data: %8d %8d %8d %10u %10u %10u\n", 3638c2ecf20Sopenharmony_ci si->curseg[CURSEG_WARM_DATA], 3648c2ecf20Sopenharmony_ci si->cursec[CURSEG_WARM_DATA], 3658c2ecf20Sopenharmony_ci si->curzone[CURSEG_WARM_DATA], 3668c2ecf20Sopenharmony_ci si->dirty_seg[CURSEG_WARM_DATA], 3678c2ecf20Sopenharmony_ci si->full_seg[CURSEG_WARM_DATA], 3688c2ecf20Sopenharmony_ci si->valid_blks[CURSEG_WARM_DATA]); 3698c2ecf20Sopenharmony_ci seq_printf(s, " - HOT data: %8d %8d %8d %10u %10u %10u\n", 3708c2ecf20Sopenharmony_ci si->curseg[CURSEG_HOT_DATA], 3718c2ecf20Sopenharmony_ci si->cursec[CURSEG_HOT_DATA], 3728c2ecf20Sopenharmony_ci si->curzone[CURSEG_HOT_DATA], 3738c2ecf20Sopenharmony_ci si->dirty_seg[CURSEG_HOT_DATA], 3748c2ecf20Sopenharmony_ci si->full_seg[CURSEG_HOT_DATA], 3758c2ecf20Sopenharmony_ci si->valid_blks[CURSEG_HOT_DATA]); 3768c2ecf20Sopenharmony_ci seq_printf(s, " - Dir dnode: %8d %8d %8d %10u %10u %10u\n", 3778c2ecf20Sopenharmony_ci si->curseg[CURSEG_HOT_NODE], 3788c2ecf20Sopenharmony_ci si->cursec[CURSEG_HOT_NODE], 3798c2ecf20Sopenharmony_ci si->curzone[CURSEG_HOT_NODE], 3808c2ecf20Sopenharmony_ci si->dirty_seg[CURSEG_HOT_NODE], 3818c2ecf20Sopenharmony_ci si->full_seg[CURSEG_HOT_NODE], 3828c2ecf20Sopenharmony_ci si->valid_blks[CURSEG_HOT_NODE]); 3838c2ecf20Sopenharmony_ci seq_printf(s, " - File dnode: %8d %8d %8d %10u %10u %10u\n", 3848c2ecf20Sopenharmony_ci si->curseg[CURSEG_WARM_NODE], 3858c2ecf20Sopenharmony_ci si->cursec[CURSEG_WARM_NODE], 3868c2ecf20Sopenharmony_ci si->curzone[CURSEG_WARM_NODE], 3878c2ecf20Sopenharmony_ci si->dirty_seg[CURSEG_WARM_NODE], 3888c2ecf20Sopenharmony_ci si->full_seg[CURSEG_WARM_NODE], 3898c2ecf20Sopenharmony_ci si->valid_blks[CURSEG_WARM_NODE]); 3908c2ecf20Sopenharmony_ci seq_printf(s, " - Indir nodes: %8d %8d %8d %10u %10u %10u\n", 3918c2ecf20Sopenharmony_ci si->curseg[CURSEG_COLD_NODE], 3928c2ecf20Sopenharmony_ci si->cursec[CURSEG_COLD_NODE], 3938c2ecf20Sopenharmony_ci si->curzone[CURSEG_COLD_NODE], 3948c2ecf20Sopenharmony_ci si->dirty_seg[CURSEG_COLD_NODE], 3958c2ecf20Sopenharmony_ci si->full_seg[CURSEG_COLD_NODE], 3968c2ecf20Sopenharmony_ci si->valid_blks[CURSEG_COLD_NODE]); 3978c2ecf20Sopenharmony_ci seq_printf(s, " - Pinned file: %8d %8d %8d\n", 3988c2ecf20Sopenharmony_ci si->curseg[CURSEG_COLD_DATA_PINNED], 3998c2ecf20Sopenharmony_ci si->cursec[CURSEG_COLD_DATA_PINNED], 4008c2ecf20Sopenharmony_ci si->curzone[CURSEG_COLD_DATA_PINNED]); 4018c2ecf20Sopenharmony_ci seq_printf(s, " - ATGC data: %8d %8d %8d\n", 4028c2ecf20Sopenharmony_ci si->curseg[CURSEG_ALL_DATA_ATGC], 4038c2ecf20Sopenharmony_ci si->cursec[CURSEG_ALL_DATA_ATGC], 4048c2ecf20Sopenharmony_ci si->curzone[CURSEG_ALL_DATA_ATGC]); 4058c2ecf20Sopenharmony_ci seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", 4068c2ecf20Sopenharmony_ci si->main_area_segs - si->dirty_count - 4078c2ecf20Sopenharmony_ci si->prefree_count - si->free_segs, 4088c2ecf20Sopenharmony_ci si->dirty_count); 4098c2ecf20Sopenharmony_ci seq_printf(s, " - Prefree: %d\n - Free: %d (%d)\n\n", 4108c2ecf20Sopenharmony_ci si->prefree_count, si->free_segs, si->free_secs); 4118c2ecf20Sopenharmony_ci seq_printf(s, "CP calls: %d (BG: %d)\n", 4128c2ecf20Sopenharmony_ci si->cp_count, si->bg_cp_count); 4138c2ecf20Sopenharmony_ci seq_printf(s, " - cp blocks : %u\n", si->meta_count[META_CP]); 4148c2ecf20Sopenharmony_ci seq_printf(s, " - sit blocks : %u\n", 4158c2ecf20Sopenharmony_ci si->meta_count[META_SIT]); 4168c2ecf20Sopenharmony_ci seq_printf(s, " - nat blocks : %u\n", 4178c2ecf20Sopenharmony_ci si->meta_count[META_NAT]); 4188c2ecf20Sopenharmony_ci seq_printf(s, " - ssa blocks : %u\n", 4198c2ecf20Sopenharmony_ci si->meta_count[META_SSA]); 4208c2ecf20Sopenharmony_ci seq_printf(s, "GC calls: %d (BG: %d)\n", 4218c2ecf20Sopenharmony_ci si->call_count, si->bg_gc); 4228c2ecf20Sopenharmony_ci seq_printf(s, " - data segments : %d (%d)\n", 4238c2ecf20Sopenharmony_ci si->data_segs, si->bg_data_segs); 4248c2ecf20Sopenharmony_ci seq_printf(s, " - node segments : %d (%d)\n", 4258c2ecf20Sopenharmony_ci si->node_segs, si->bg_node_segs); 4268c2ecf20Sopenharmony_ci seq_printf(s, "Try to move %d blocks (BG: %d)\n", si->tot_blks, 4278c2ecf20Sopenharmony_ci si->bg_data_blks + si->bg_node_blks); 4288c2ecf20Sopenharmony_ci seq_printf(s, " - data blocks : %d (%d)\n", si->data_blks, 4298c2ecf20Sopenharmony_ci si->bg_data_blks); 4308c2ecf20Sopenharmony_ci seq_printf(s, " - node blocks : %d (%d)\n", si->node_blks, 4318c2ecf20Sopenharmony_ci si->bg_node_blks); 4328c2ecf20Sopenharmony_ci seq_printf(s, "Skipped : atomic write %llu (%llu)\n", 4338c2ecf20Sopenharmony_ci si->skipped_atomic_files[BG_GC] + 4348c2ecf20Sopenharmony_ci si->skipped_atomic_files[FG_GC], 4358c2ecf20Sopenharmony_ci si->skipped_atomic_files[BG_GC]); 4368c2ecf20Sopenharmony_ci seq_printf(s, "BG skip : IO: %u, Other: %u\n", 4378c2ecf20Sopenharmony_ci si->io_skip_bggc, si->other_skip_bggc); 4388c2ecf20Sopenharmony_ci seq_puts(s, "\nExtent Cache:\n"); 4398c2ecf20Sopenharmony_ci seq_printf(s, " - Hit Count: L1-1:%llu L1-2:%llu L2:%llu\n", 4408c2ecf20Sopenharmony_ci si->hit_largest, si->hit_cached, 4418c2ecf20Sopenharmony_ci si->hit_rbtree); 4428c2ecf20Sopenharmony_ci seq_printf(s, " - Hit Ratio: %llu%% (%llu / %llu)\n", 4438c2ecf20Sopenharmony_ci !si->total_ext ? 0 : 4448c2ecf20Sopenharmony_ci div64_u64(si->hit_total * 100, si->total_ext), 4458c2ecf20Sopenharmony_ci si->hit_total, si->total_ext); 4468c2ecf20Sopenharmony_ci seq_printf(s, " - Inner Struct Count: tree: %d(%d), node: %d\n", 4478c2ecf20Sopenharmony_ci si->ext_tree, si->zombie_tree, si->ext_node); 4488c2ecf20Sopenharmony_ci seq_puts(s, "\nBalancing F2FS Async:\n"); 4498c2ecf20Sopenharmony_ci seq_printf(s, " - DIO (R: %4d, W: %4d)\n", 4508c2ecf20Sopenharmony_ci si->nr_dio_read, si->nr_dio_write); 4518c2ecf20Sopenharmony_ci seq_printf(s, " - IO_R (Data: %4d, Node: %4d, Meta: %4d\n", 4528c2ecf20Sopenharmony_ci si->nr_rd_data, si->nr_rd_node, si->nr_rd_meta); 4538c2ecf20Sopenharmony_ci seq_printf(s, " - IO_W (CP: %4d, Data: %4d, Flush: (%4d %4d %4d), " 4548c2ecf20Sopenharmony_ci "Discard: (%4d %4d)) cmd: %4d undiscard:%4u\n", 4558c2ecf20Sopenharmony_ci si->nr_wb_cp_data, si->nr_wb_data, 4568c2ecf20Sopenharmony_ci si->nr_flushing, si->nr_flushed, 4578c2ecf20Sopenharmony_ci si->flush_list_empty, 4588c2ecf20Sopenharmony_ci si->nr_discarding, si->nr_discarded, 4598c2ecf20Sopenharmony_ci si->nr_discard_cmd, si->undiscard_blks); 4608c2ecf20Sopenharmony_ci seq_printf(s, " - inmem: %4d, atomic IO: %4d (Max. %4d), " 4618c2ecf20Sopenharmony_ci "volatile IO: %4d (Max. %4d)\n", 4628c2ecf20Sopenharmony_ci si->inmem_pages, si->aw_cnt, si->max_aw_cnt, 4638c2ecf20Sopenharmony_ci si->vw_cnt, si->max_vw_cnt); 4648c2ecf20Sopenharmony_ci seq_printf(s, " - nodes: %4d in %4d\n", 4658c2ecf20Sopenharmony_ci si->ndirty_node, si->node_pages); 4668c2ecf20Sopenharmony_ci seq_printf(s, " - dents: %4d in dirs:%4d (%4d)\n", 4678c2ecf20Sopenharmony_ci si->ndirty_dent, si->ndirty_dirs, si->ndirty_all); 4688c2ecf20Sopenharmony_ci seq_printf(s, " - datas: %4d in files:%4d\n", 4698c2ecf20Sopenharmony_ci si->ndirty_data, si->ndirty_files); 4708c2ecf20Sopenharmony_ci seq_printf(s, " - quota datas: %4d in quota files:%4d\n", 4718c2ecf20Sopenharmony_ci si->ndirty_qdata, si->nquota_files); 4728c2ecf20Sopenharmony_ci seq_printf(s, " - meta: %4d in %4d\n", 4738c2ecf20Sopenharmony_ci si->ndirty_meta, si->meta_pages); 4748c2ecf20Sopenharmony_ci seq_printf(s, " - imeta: %4d\n", 4758c2ecf20Sopenharmony_ci si->ndirty_imeta); 4768c2ecf20Sopenharmony_ci seq_printf(s, " - NATs: %9d/%9d\n - SITs: %9d/%9d\n", 4778c2ecf20Sopenharmony_ci si->dirty_nats, si->nats, si->dirty_sits, si->sits); 4788c2ecf20Sopenharmony_ci seq_printf(s, " - free_nids: %9d/%9d\n - alloc_nids: %9d\n", 4798c2ecf20Sopenharmony_ci si->free_nids, si->avail_nids, si->alloc_nids); 4808c2ecf20Sopenharmony_ci seq_puts(s, "\nDistribution of User Blocks:"); 4818c2ecf20Sopenharmony_ci seq_puts(s, " [ valid | invalid | free ]\n"); 4828c2ecf20Sopenharmony_ci seq_puts(s, " ["); 4838c2ecf20Sopenharmony_ci 4848c2ecf20Sopenharmony_ci for (j = 0; j < si->util_valid; j++) 4858c2ecf20Sopenharmony_ci seq_putc(s, '-'); 4868c2ecf20Sopenharmony_ci seq_putc(s, '|'); 4878c2ecf20Sopenharmony_ci 4888c2ecf20Sopenharmony_ci for (j = 0; j < si->util_invalid; j++) 4898c2ecf20Sopenharmony_ci seq_putc(s, '-'); 4908c2ecf20Sopenharmony_ci seq_putc(s, '|'); 4918c2ecf20Sopenharmony_ci 4928c2ecf20Sopenharmony_ci for (j = 0; j < si->util_free; j++) 4938c2ecf20Sopenharmony_ci seq_putc(s, '-'); 4948c2ecf20Sopenharmony_ci seq_puts(s, "]\n\n"); 4958c2ecf20Sopenharmony_ci seq_printf(s, "IPU: %u blocks\n", si->inplace_count); 4968c2ecf20Sopenharmony_ci seq_printf(s, "SSR: %u blocks in %u segments\n", 4978c2ecf20Sopenharmony_ci si->block_count[SSR], si->segment_count[SSR]); 4988c2ecf20Sopenharmony_ci seq_printf(s, "LFS: %u blocks in %u segments\n", 4998c2ecf20Sopenharmony_ci si->block_count[LFS], si->segment_count[LFS]); 5008c2ecf20Sopenharmony_ci 5018c2ecf20Sopenharmony_ci /* segment usage info */ 5028c2ecf20Sopenharmony_ci f2fs_update_sit_info(si->sbi); 5038c2ecf20Sopenharmony_ci seq_printf(s, "\nBDF: %u, avg. vblocks: %u\n", 5048c2ecf20Sopenharmony_ci si->bimodal, si->avg_vblocks); 5058c2ecf20Sopenharmony_ci 5068c2ecf20Sopenharmony_ci /* memory footprint */ 5078c2ecf20Sopenharmony_ci update_mem_info(si->sbi); 5088c2ecf20Sopenharmony_ci seq_printf(s, "\nMemory: %llu KB\n", 5098c2ecf20Sopenharmony_ci (si->base_mem + si->cache_mem + si->page_mem) >> 10); 5108c2ecf20Sopenharmony_ci seq_printf(s, " - static: %llu KB\n", 5118c2ecf20Sopenharmony_ci si->base_mem >> 10); 5128c2ecf20Sopenharmony_ci seq_printf(s, " - cached: %llu KB\n", 5138c2ecf20Sopenharmony_ci si->cache_mem >> 10); 5148c2ecf20Sopenharmony_ci seq_printf(s, " - paged : %llu KB\n", 5158c2ecf20Sopenharmony_ci si->page_mem >> 10); 5168c2ecf20Sopenharmony_ci } 5178c2ecf20Sopenharmony_ci mutex_unlock(&f2fs_stat_mutex); 5188c2ecf20Sopenharmony_ci return 0; 5198c2ecf20Sopenharmony_ci} 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_ciDEFINE_SHOW_ATTRIBUTE(stat); 5228c2ecf20Sopenharmony_ci#endif 5238c2ecf20Sopenharmony_ci 5248c2ecf20Sopenharmony_ciint f2fs_build_stats(struct f2fs_sb_info *sbi) 5258c2ecf20Sopenharmony_ci{ 5268c2ecf20Sopenharmony_ci struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); 5278c2ecf20Sopenharmony_ci struct f2fs_stat_info *si; 5288c2ecf20Sopenharmony_ci int i; 5298c2ecf20Sopenharmony_ci 5308c2ecf20Sopenharmony_ci si = f2fs_kzalloc(sbi, sizeof(struct f2fs_stat_info), GFP_KERNEL); 5318c2ecf20Sopenharmony_ci if (!si) 5328c2ecf20Sopenharmony_ci return -ENOMEM; 5338c2ecf20Sopenharmony_ci 5348c2ecf20Sopenharmony_ci si->all_area_segs = le32_to_cpu(raw_super->segment_count); 5358c2ecf20Sopenharmony_ci si->sit_area_segs = le32_to_cpu(raw_super->segment_count_sit); 5368c2ecf20Sopenharmony_ci si->nat_area_segs = le32_to_cpu(raw_super->segment_count_nat); 5378c2ecf20Sopenharmony_ci si->ssa_area_segs = le32_to_cpu(raw_super->segment_count_ssa); 5388c2ecf20Sopenharmony_ci si->main_area_segs = le32_to_cpu(raw_super->segment_count_main); 5398c2ecf20Sopenharmony_ci si->main_area_sections = le32_to_cpu(raw_super->section_count); 5408c2ecf20Sopenharmony_ci si->main_area_zones = si->main_area_sections / 5418c2ecf20Sopenharmony_ci le32_to_cpu(raw_super->secs_per_zone); 5428c2ecf20Sopenharmony_ci si->sbi = sbi; 5438c2ecf20Sopenharmony_ci sbi->stat_info = si; 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_ci atomic64_set(&sbi->total_hit_ext, 0); 5468c2ecf20Sopenharmony_ci atomic64_set(&sbi->read_hit_rbtree, 0); 5478c2ecf20Sopenharmony_ci atomic64_set(&sbi->read_hit_largest, 0); 5488c2ecf20Sopenharmony_ci atomic64_set(&sbi->read_hit_cached, 0); 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_ci atomic_set(&sbi->inline_xattr, 0); 5518c2ecf20Sopenharmony_ci atomic_set(&sbi->inline_inode, 0); 5528c2ecf20Sopenharmony_ci atomic_set(&sbi->inline_dir, 0); 5538c2ecf20Sopenharmony_ci atomic_set(&sbi->compr_inode, 0); 5548c2ecf20Sopenharmony_ci atomic64_set(&sbi->compr_blocks, 0); 5558c2ecf20Sopenharmony_ci atomic_set(&sbi->inplace_count, 0); 5568c2ecf20Sopenharmony_ci for (i = META_CP; i < META_MAX; i++) 5578c2ecf20Sopenharmony_ci atomic_set(&sbi->meta_count[i], 0); 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_ci atomic_set(&sbi->vw_cnt, 0); 5608c2ecf20Sopenharmony_ci atomic_set(&sbi->max_aw_cnt, 0); 5618c2ecf20Sopenharmony_ci atomic_set(&sbi->max_vw_cnt, 0); 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_ci mutex_lock(&f2fs_stat_mutex); 5648c2ecf20Sopenharmony_ci list_add_tail(&si->stat_list, &f2fs_stat_list); 5658c2ecf20Sopenharmony_ci mutex_unlock(&f2fs_stat_mutex); 5668c2ecf20Sopenharmony_ci 5678c2ecf20Sopenharmony_ci return 0; 5688c2ecf20Sopenharmony_ci} 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_civoid f2fs_destroy_stats(struct f2fs_sb_info *sbi) 5718c2ecf20Sopenharmony_ci{ 5728c2ecf20Sopenharmony_ci struct f2fs_stat_info *si = F2FS_STAT(sbi); 5738c2ecf20Sopenharmony_ci 5748c2ecf20Sopenharmony_ci mutex_lock(&f2fs_stat_mutex); 5758c2ecf20Sopenharmony_ci list_del(&si->stat_list); 5768c2ecf20Sopenharmony_ci mutex_unlock(&f2fs_stat_mutex); 5778c2ecf20Sopenharmony_ci 5788c2ecf20Sopenharmony_ci kfree(si); 5798c2ecf20Sopenharmony_ci} 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_civoid __init f2fs_create_root_stats(void) 5828c2ecf20Sopenharmony_ci{ 5838c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 5848c2ecf20Sopenharmony_ci f2fs_debugfs_root = debugfs_create_dir("f2fs", NULL); 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_ci debugfs_create_file("status", S_IRUGO, f2fs_debugfs_root, NULL, 5878c2ecf20Sopenharmony_ci &stat_fops); 5888c2ecf20Sopenharmony_ci#endif 5898c2ecf20Sopenharmony_ci} 5908c2ecf20Sopenharmony_ci 5918c2ecf20Sopenharmony_civoid f2fs_destroy_root_stats(void) 5928c2ecf20Sopenharmony_ci{ 5938c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 5948c2ecf20Sopenharmony_ci debugfs_remove_recursive(f2fs_debugfs_root); 5958c2ecf20Sopenharmony_ci f2fs_debugfs_root = NULL; 5968c2ecf20Sopenharmony_ci#endif 5978c2ecf20Sopenharmony_ci} 598