| /*********************************************************** |
| ** Copyright (C), 2008-2019, OPPO Mobile Comm Corp., Ltd. |
| ** VENDOR_EDIT |
| ** File: - of2fs_bigdata.h |
| ** Description: f2fs bigdata statistics code |
| ** |
| ** Version: 1.0 |
| ** Date : 2019/08/14 |
| ** Author: yanw@TECH.Storage.FS.oF2FS, add code for f2fs bigdata statistics |
| ** |
| ** ------------------ Revision History:------------------------ |
| ** <author> <data> <version > <desc> |
| ** yanwu 2019/08/14 1.0 add code for f2fs bigdata statistics |
| ****************************************************************/ |
| |
| #ifndef _OF2FS_BIGDATA_H |
| #define _OF2FS_BIGDATA_H |
| /* unit for time: ns */ |
| enum { |
| HC_UNSET, |
| HC_HOT_DATA, |
| HC_WARM_DATA, |
| HC_COLD_DATA, |
| HC_HOT_NODE, |
| HC_WARM_NODE, |
| HC_COLD_NODE, |
| NR_CURSEG, |
| HC_META = NR_CURSEG, |
| HC_META_SB, |
| HC_META_CP, |
| HC_META_SIT, |
| HC_META_NAT, |
| HC_META_SSA, |
| HC_DIRECT_IO, |
| HC_GC_COLD_DATA, |
| HC_REWRITE_HOT_DATA, |
| HC_REWRITE_WARM_DATA, |
| NR_HOTCOLD_TYPE, |
| }; |
| |
| struct f2fs_bigdata_info { |
| /* CP info |
| * avg_cp_time = cp_time / cp_count |
| */ |
| unsigned int cp_count, cp_success_count; |
| u64 cp_time, max_cp_time, max_cp_submit_time, |
| max_cp_flush_meta_time, max_cp_discard_time; |
| |
| |
| /* Discard info |
| * avg_discard_time = discard_time / discard_count |
| */ |
| unsigned int discard_count, discard_blocks, |
| undiscard_count, undiscard_blocks; |
| u64 discard_time, max_discard_time; |
| |
| /* GC info: BG_GC = 0, FG_GC = 1 |
| * avg_[bg|fg]gc_data_segments = [bg|fg]gc_data_segments / [bg|fg]gc_data_count |
| * avg_[bg|fg]gc_data_blocks = [bg|fg]gc_data_blocks / [bg|fg]gc_data_count |
| * avg_fggc_time = fggc_time / fggc_count |
| * |
| */ |
| unsigned int gc_count[2], gc_fail_count[2], |
| gc_data_count[2], gc_node_count[2]; |
| unsigned int gc_data_segments[2], gc_data_blocks[2], |
| gc_node_segments[2], gc_node_blocks[2]; |
| u64 fggc_time; |
| |
| |
| /* Node alloc info: LFS = 0, SSR = 1 */ |
| unsigned int node_alloc_count[2], data_alloc_count[2], data_ipu_count; |
| |
| unsigned long last_node_alloc_count, last_data_alloc_count; |
| unsigned long curr_node_alloc_count, curr_data_alloc_count; |
| unsigned long ssr_last_jiffies; |
| |
| /* Fsync info */ |
| unsigned int fsync_reg_file_count, fsync_dir_count; |
| u64 fsync_time, max_fsync_time, fsync_cp_time, max_fsync_cp_time, |
| fsync_wr_file_time, max_fsync_wr_file_time, fsync_sync_node_time, |
| max_fsync_sync_node_time, fsync_flush_time, max_fsync_flush_time; |
| |
| /* Hot cold info */ |
| unsigned long hotcold_count[NR_HOTCOLD_TYPE]; |
| unsigned long hotcold_gc_segments[NR_CURSEG]; |
| unsigned long hotcold_gc_blocks[NR_CURSEG]; |
| }; |
| |
| static inline struct f2fs_bigdata_info *F2FS_BD_STAT(struct f2fs_sb_info *sbi) |
| { |
| return (struct f2fs_bigdata_info *)sbi->bd_info; |
| } |
| |
| #define bd_inc_val(sbi, member, val) do { \ |
| struct f2fs_bigdata_info *bd = F2FS_BD_STAT(sbi); \ |
| if (bd) \ |
| bd->member += (val); \ |
| } while (0) |
| #define bd_inc_array_val(sbi, member, idx, val) do { \ |
| struct f2fs_bigdata_info *bd = F2FS_BD_STAT(sbi); \ |
| if (bd) \ |
| bd->member[(idx)] += (val); \ |
| } while (0) |
| |
| #define bd_set_val(sbi, member, val) do { \ |
| struct f2fs_bigdata_info *bd = F2FS_BD_STAT(sbi); \ |
| if (bd) \ |
| bd->member = (val); \ |
| } while (0) |
| #define bd_set_array_val(sbi, member, idx, val) do { \ |
| struct f2fs_bigdata_info *bd = F2FS_BD_STAT(sbi); \ |
| if (bd) \ |
| bd->member[(idx)] = (val); \ |
| } while (0) |
| |
| #define bd_max_val(sbi, member, val) do { \ |
| struct f2fs_bigdata_info *bd = F2FS_BD_STAT(sbi); \ |
| if (bd) { \ |
| if (bd->member < (val)) \ |
| bd->member = (val); \ |
| } \ |
| } while (0) |
| |
| #define bd_lock_init(sbi) spin_lock_init(&(sbi)->bd_lock) |
| #define bd_lock(sbi) spin_lock(&(sbi)->bd_lock) |
| #define bd_unlock(sbi) spin_unlock(&(sbi)->bd_lock) |
| #endif |