Lines Matching full:sbi

32 void f2fs_update_sit_info(struct f2fs_sb_info *sbi)  in f2fs_update_sit_info()  argument
34 struct f2fs_stat_info *si = F2FS_STAT(sbi); in f2fs_update_sit_info()
42 blks_per_sec = CAP_BLKS_PER_SEC(sbi); in f2fs_update_sit_info()
44 for (segno = 0; segno < MAIN_SEGS(sbi); segno += SEGS_PER_SEC(sbi)) { in f2fs_update_sit_info()
45 vblocks = get_valid_blocks(sbi, segno, true); in f2fs_update_sit_info()
54 dist = div_u64(MAIN_SECS(sbi) * hblks_per_sec * hblks_per_sec, 100); in f2fs_update_sit_info()
63 static void update_general_status(struct f2fs_sb_info *sbi) in update_general_status() argument
65 struct f2fs_stat_info *si = F2FS_STAT(sbi); in update_general_status()
66 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); in update_general_status()
77 struct extent_tree_info *eti = &sbi->extent_tree[i]; in update_general_status()
79 si->hit_cached[i] = atomic64_read(&sbi->read_hit_cached[i]); in update_general_status()
80 si->hit_rbtree[i] = atomic64_read(&sbi->read_hit_rbtree[i]); in update_general_status()
81 si->total_ext[i] = atomic64_read(&sbi->total_hit_ext[i]); in update_general_status()
88 si->hit_largest = atomic64_read(&sbi->read_hit_largest); in update_general_status()
92 si->allocated_data_blocks = atomic64_read(&sbi->allocated_data_blocks); in update_general_status()
95 si->ndirty_node = get_pages(sbi, F2FS_DIRTY_NODES); in update_general_status()
96 si->ndirty_dent = get_pages(sbi, F2FS_DIRTY_DENTS); in update_general_status()
97 si->ndirty_meta = get_pages(sbi, F2FS_DIRTY_META); in update_general_status()
98 si->ndirty_data = get_pages(sbi, F2FS_DIRTY_DATA); in update_general_status()
99 si->ndirty_qdata = get_pages(sbi, F2FS_DIRTY_QDATA); in update_general_status()
100 si->ndirty_imeta = get_pages(sbi, F2FS_DIRTY_IMETA); in update_general_status()
101 si->ndirty_dirs = sbi->ndirty_inode[DIR_INODE]; in update_general_status()
102 si->ndirty_files = sbi->ndirty_inode[FILE_INODE]; in update_general_status()
103 si->nquota_files = sbi->nquota_files; in update_general_status()
104 si->ndirty_all = sbi->ndirty_inode[DIRTY_META]; in update_general_status()
105 si->aw_cnt = atomic_read(&sbi->atomic_files); in update_general_status()
106 si->max_aw_cnt = atomic_read(&sbi->max_aw_cnt); in update_general_status()
107 si->nr_dio_read = get_pages(sbi, F2FS_DIO_READ); in update_general_status()
108 si->nr_dio_write = get_pages(sbi, F2FS_DIO_WRITE); in update_general_status()
109 si->nr_wb_cp_data = get_pages(sbi, F2FS_WB_CP_DATA); in update_general_status()
110 si->nr_wb_data = get_pages(sbi, F2FS_WB_DATA); in update_general_status()
111 si->nr_rd_data = get_pages(sbi, F2FS_RD_DATA); in update_general_status()
112 si->nr_rd_node = get_pages(sbi, F2FS_RD_NODE); in update_general_status()
113 si->nr_rd_meta = get_pages(sbi, F2FS_RD_META); in update_general_status()
114 if (SM_I(sbi)->fcc_info) { in update_general_status()
116 atomic_read(&SM_I(sbi)->fcc_info->issued_flush); in update_general_status()
118 atomic_read(&SM_I(sbi)->fcc_info->queued_flush); in update_general_status()
120 llist_empty(&SM_I(sbi)->fcc_info->issue_list); in update_general_status()
122 if (SM_I(sbi)->dcc_info) { in update_general_status()
124 atomic_read(&SM_I(sbi)->dcc_info->issued_discard); in update_general_status()
126 atomic_read(&SM_I(sbi)->dcc_info->queued_discard); in update_general_status()
128 atomic_read(&SM_I(sbi)->dcc_info->discard_cmd_cnt); in update_general_status()
129 si->undiscard_blks = SM_I(sbi)->dcc_info->undiscard_blks; in update_general_status()
131 si->nr_issued_ckpt = atomic_read(&sbi->cprc_info.issued_ckpt); in update_general_status()
132 si->nr_total_ckpt = atomic_read(&sbi->cprc_info.total_ckpt); in update_general_status()
133 si->nr_queued_ckpt = atomic_read(&sbi->cprc_info.queued_ckpt); in update_general_status()
134 spin_lock(&sbi->cprc_info.stat_lock); in update_general_status()
135 si->cur_ckpt_time = sbi->cprc_info.cur_time; in update_general_status()
136 si->peak_ckpt_time = sbi->cprc_info.peak_time; in update_general_status()
137 spin_unlock(&sbi->cprc_info.stat_lock); in update_general_status()
138 si->total_count = (int)sbi->user_block_count / BLKS_PER_SEG(sbi); in update_general_status()
139 si->rsvd_segs = reserved_segments(sbi); in update_general_status()
140 si->overp_segs = overprovision_segments(sbi); in update_general_status()
141 si->valid_count = valid_user_blocks(sbi); in update_general_status()
142 si->discard_blks = discard_blocks(sbi); in update_general_status()
143 si->valid_node_count = valid_node_count(sbi); in update_general_status()
144 si->valid_inode_count = valid_inode_count(sbi); in update_general_status()
145 si->inline_xattr = atomic_read(&sbi->inline_xattr); in update_general_status()
146 si->inline_inode = atomic_read(&sbi->inline_inode); in update_general_status()
147 si->inline_dir = atomic_read(&sbi->inline_dir); in update_general_status()
148 si->compr_inode = atomic_read(&sbi->compr_inode); in update_general_status()
149 si->swapfile_inode = atomic_read(&sbi->swapfile_inode); in update_general_status()
150 si->compr_blocks = atomic64_read(&sbi->compr_blocks); in update_general_status()
151 si->append = sbi->im[APPEND_INO].ino_num; in update_general_status()
152 si->update = sbi->im[UPDATE_INO].ino_num; in update_general_status()
153 si->orphans = sbi->im[ORPHAN_INO].ino_num; in update_general_status()
154 si->utilization = utilization(sbi); in update_general_status()
156 si->free_segs = free_segments(sbi); in update_general_status()
157 si->free_secs = free_sections(sbi); in update_general_status()
158 si->prefree_count = prefree_segments(sbi); in update_general_status()
159 si->dirty_count = dirty_segments(sbi); in update_general_status()
160 if (sbi->node_inode) in update_general_status()
161 si->node_pages = NODE_MAPPING(sbi)->nrpages; in update_general_status()
162 if (sbi->meta_inode) in update_general_status()
163 si->meta_pages = META_MAPPING(sbi)->nrpages; in update_general_status()
165 if (sbi->compress_inode) { in update_general_status()
166 si->compress_pages = COMPRESS_MAPPING(sbi)->nrpages; in update_general_status()
167 si->compress_page_hit = atomic_read(&sbi->compress_page_hit); in update_general_status()
170 si->nats = NM_I(sbi)->nat_cnt[TOTAL_NAT]; in update_general_status()
171 si->dirty_nats = NM_I(sbi)->nat_cnt[DIRTY_NAT]; in update_general_status()
172 si->sits = MAIN_SEGS(sbi); in update_general_status()
173 si->dirty_sits = SIT_I(sbi)->dirty_sentries; in update_general_status()
174 si->free_nids = NM_I(sbi)->nid_cnt[FREE_NID]; in update_general_status()
175 si->avail_nids = NM_I(sbi)->available_nids; in update_general_status()
176 si->alloc_nids = NM_I(sbi)->nid_cnt[PREALLOC_NID]; in update_general_status()
177 si->io_skip_bggc = sbi->io_skip_bggc; in update_general_status()
178 si->other_skip_bggc = sbi->other_skip_bggc; in update_general_status()
179 si->util_free = (int)(free_user_blocks(sbi) >> sbi->log_blocks_per_seg) in update_general_status()
180 * 100 / (int)(sbi->user_block_count >> sbi->log_blocks_per_seg) in update_general_status()
182 si->util_valid = (int)(written_block_count(sbi) >> in update_general_status()
183 sbi->log_blocks_per_seg) in update_general_status()
184 * 100 / (int)(sbi->user_block_count >> sbi->log_blocks_per_seg) in update_general_status()
188 struct curseg_info *curseg = CURSEG_I(sbi, i); in update_general_status()
191 si->cursec[i] = GET_SEC_FROM_SEG(sbi, curseg->segno); in update_general_status()
192 si->curzone[i] = GET_ZONE_FROM_SEC(sbi, si->cursec[i]); in update_general_status()
196 si->meta_count[i] = atomic_read(&sbi->meta_count[i]); in update_general_status()
204 for (i = 0; i < MAIN_SEGS(sbi); i++) { in update_general_status()
205 int blks = get_seg_entry(sbi, i)->valid_blocks; in update_general_status()
206 int type = get_seg_entry(sbi, i)->type; in update_general_status()
211 if (blks == BLKS_PER_SEG(sbi)) in update_general_status()
219 si->cp_call_count[i] = atomic_read(&sbi->cp_call_count[i]); in update_general_status()
222 si->segment_count[i] = sbi->segment_count[i]; in update_general_status()
223 si->block_count[i] = sbi->block_count[i]; in update_general_status()
226 si->inplace_count = atomic_read(&sbi->inplace_count); in update_general_status()
232 static void update_mem_info(struct f2fs_sb_info *sbi) in update_mem_info() argument
234 struct f2fs_stat_info *si = F2FS_STAT(sbi); in update_mem_info()
244 si->base_mem += sizeof(struct f2fs_sb_info) + sbi->sb->s_blocksize; in update_mem_info()
246 si->base_mem += sizeof(*sbi->ckpt); in update_mem_info()
253 si->base_mem += MAIN_SEGS(sbi) * sizeof(struct seg_entry); in update_mem_info()
254 si->base_mem += f2fs_bitmap_size(MAIN_SEGS(sbi)); in update_mem_info()
255 si->base_mem += 2 * SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi); in update_mem_info()
256 si->base_mem += SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi); in update_mem_info()
258 if (__is_large_section(sbi)) in update_mem_info()
259 si->base_mem += MAIN_SECS(sbi) * sizeof(struct sec_entry); in update_mem_info()
260 si->base_mem += __bitmap_size(sbi, SIT_BITMAP); in update_mem_info()
264 si->base_mem += f2fs_bitmap_size(MAIN_SEGS(sbi)); in update_mem_info()
265 si->base_mem += f2fs_bitmap_size(MAIN_SECS(sbi)); in update_mem_info()
273 si->base_mem += NR_DIRTY_TYPE * f2fs_bitmap_size(MAIN_SEGS(sbi)); in update_mem_info()
274 si->base_mem += f2fs_bitmap_size(MAIN_SECS(sbi)); in update_mem_info()
278 si->base_mem += __bitmap_size(sbi, NAT_BITMAP); in update_mem_info()
279 si->base_mem += (NM_I(sbi)->nat_bits_blocks << F2FS_BLKSIZE_BITS); in update_mem_info()
280 si->base_mem += NM_I(sbi)->nat_blocks * in update_mem_info()
282 si->base_mem += NM_I(sbi)->nat_blocks / 8; in update_mem_info()
283 si->base_mem += NM_I(sbi)->nat_blocks * sizeof(unsigned short); in update_mem_info()
289 if (sbi->gc_thread) in update_mem_info()
293 if (SM_I(sbi)->fcc_info) in update_mem_info()
295 if (SM_I(sbi)->dcc_info) { in update_mem_info()
298 atomic_read(&SM_I(sbi)->dcc_info->discard_cmd_cnt); in update_mem_info()
302 si->cache_mem += (NM_I(sbi)->nid_cnt[FREE_NID] + in update_mem_info()
303 NM_I(sbi)->nid_cnt[PREALLOC_NID]) * in update_mem_info()
305 si->cache_mem += NM_I(sbi)->nat_cnt[TOTAL_NAT] * in update_mem_info()
307 si->cache_mem += NM_I(sbi)->nat_cnt[DIRTY_NAT] * in update_mem_info()
310 si->cache_mem += sbi->im[i].ino_num * sizeof(struct ino_entry); in update_mem_info()
313 struct extent_tree_info *eti = &sbi->extent_tree[i]; in update_mem_info()
323 if (sbi->node_inode) { in update_mem_info()
324 unsigned long npages = NODE_MAPPING(sbi)->nrpages; in update_mem_info()
328 if (sbi->meta_inode) { in update_mem_info()
329 unsigned long npages = META_MAPPING(sbi)->nrpages; in update_mem_info()
334 if (sbi->compress_inode) { in update_mem_info()
335 unsigned long npages = COMPRESS_MAPPING(sbi)->nrpages; in update_mem_info()
380 struct f2fs_sb_info *sbi = si->sbi; in stat_show() local
382 update_general_status(sbi); in stat_show()
385 sbi->sb->s_bdev, i++, in stat_show()
386 f2fs_readonly(sbi->sb) ? "RO" : "RW", in stat_show()
387 is_set_ckpt_flags(sbi, CP_DISABLED_FLAG) ? in stat_show()
388 "Disabled" : (f2fs_cp_error(sbi) ? "Error" : "Good")); in stat_show()
389 if (sbi->s_flag) { in stat_show()
390 seq_puts(s, "[SBI:"); in stat_show()
391 for_each_set_bit(j, &sbi->s_flag, MAX_SBI_FLAG) in stat_show()
403 SIT_I(sbi)->mounted_time); in stat_show()
407 if (IS_F2FS_IPU_DISABLE(sbi)) { in stat_show()
410 unsigned long policy = SM_I(sbi)->ipu_policy; in stat_show()
417 if (test_opt(sbi, DISCARD)) in stat_show()
523 if (__is_large_section(sbi)) { in stat_show()
538 seq_printf(s, " - Normal : %d\n", sbi->gc_reclaimed_segs[GC_NORMAL]); in stat_show()
539 seq_printf(s, " - Idle CB : %d\n", sbi->gc_reclaimed_segs[GC_IDLE_CB]); in stat_show()
541 sbi->gc_reclaimed_segs[GC_IDLE_GREEDY]); in stat_show()
542 seq_printf(s, " - Idle AT : %d\n", sbi->gc_reclaimed_segs[GC_IDLE_AT]); in stat_show()
544 sbi->gc_reclaimed_segs[GC_URGENT_HIGH]); in stat_show()
545 seq_printf(s, " - Urgent Mid : %d\n", sbi->gc_reclaimed_segs[GC_URGENT_MID]); in stat_show()
546 seq_printf(s, " - Urgent Low : %d\n", sbi->gc_reclaimed_segs[GC_URGENT_LOW]); in stat_show()
612 &sbi->rf_node_block_count)); in stat_show()
639 f2fs_update_sit_info(sbi); in stat_show()
644 update_mem_info(sbi); in stat_show()
665 int f2fs_build_stats(struct f2fs_sb_info *sbi) in f2fs_build_stats() argument
667 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); in f2fs_build_stats()
672 si = f2fs_kzalloc(sbi, sizeof(struct f2fs_stat_info), GFP_KERNEL); in f2fs_build_stats()
684 si->sbi = sbi; in f2fs_build_stats()
685 sbi->stat_info = si; in f2fs_build_stats()
689 atomic64_set(&sbi->total_hit_ext[i], 0); in f2fs_build_stats()
690 atomic64_set(&sbi->read_hit_rbtree[i], 0); in f2fs_build_stats()
691 atomic64_set(&sbi->read_hit_cached[i], 0); in f2fs_build_stats()
695 atomic64_set(&sbi->read_hit_largest, 0); in f2fs_build_stats()
697 atomic_set(&sbi->inline_xattr, 0); in f2fs_build_stats()
698 atomic_set(&sbi->inline_inode, 0); in f2fs_build_stats()
699 atomic_set(&sbi->inline_dir, 0); in f2fs_build_stats()
700 atomic_set(&sbi->compr_inode, 0); in f2fs_build_stats()
701 atomic64_set(&sbi->compr_blocks, 0); in f2fs_build_stats()
702 atomic_set(&sbi->swapfile_inode, 0); in f2fs_build_stats()
703 atomic_set(&sbi->atomic_files, 0); in f2fs_build_stats()
704 atomic_set(&sbi->inplace_count, 0); in f2fs_build_stats()
706 atomic_set(&sbi->meta_count[i], 0); in f2fs_build_stats()
708 atomic_set(&sbi->cp_call_count[i], 0); in f2fs_build_stats()
710 atomic_set(&sbi->max_aw_cnt, 0); in f2fs_build_stats()
719 void f2fs_destroy_stats(struct f2fs_sb_info *sbi) in f2fs_destroy_stats() argument
721 struct f2fs_stat_info *si = F2FS_STAT(sbi); in f2fs_destroy_stats()