f2fs: add a help func F2FS_STAT() to get the f2fs_stat_info
Add a help func F2FS_STAT() to get the f2fs_stat_info. Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
This commit is contained in:
parent
5e176d54a6
commit
963d4f7d7b
2 changed files with 16 additions and 11 deletions
|
@ -29,7 +29,7 @@ static DEFINE_MUTEX(f2fs_stat_mutex);
|
|||
|
||||
static void update_general_status(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
struct f2fs_stat_info *si = sbi->stat_info;
|
||||
struct f2fs_stat_info *si = F2FS_STAT(sbi);
|
||||
int i;
|
||||
|
||||
/* valid check of the segment numbers */
|
||||
|
@ -83,7 +83,7 @@ static void update_general_status(struct f2fs_sb_info *sbi)
|
|||
*/
|
||||
static void update_sit_info(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
struct f2fs_stat_info *si = sbi->stat_info;
|
||||
struct f2fs_stat_info *si = F2FS_STAT(sbi);
|
||||
unsigned int blks_per_sec, hblks_per_sec, total_vblocks, bimodal, dist;
|
||||
struct sit_info *sit_i = SIT_I(sbi);
|
||||
unsigned int segno, vblocks;
|
||||
|
@ -118,7 +118,7 @@ static void update_sit_info(struct f2fs_sb_info *sbi)
|
|||
*/
|
||||
static void update_mem_info(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
struct f2fs_stat_info *si = sbi->stat_info;
|
||||
struct f2fs_stat_info *si = F2FS_STAT(sbi);
|
||||
unsigned npages;
|
||||
|
||||
if (si->base_mem)
|
||||
|
@ -305,11 +305,10 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)
|
|||
struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
|
||||
struct f2fs_stat_info *si;
|
||||
|
||||
sbi->stat_info = kzalloc(sizeof(struct f2fs_stat_info), GFP_KERNEL);
|
||||
if (!sbi->stat_info)
|
||||
si = kzalloc(sizeof(struct f2fs_stat_info), GFP_KERNEL);
|
||||
if (!si)
|
||||
return -ENOMEM;
|
||||
|
||||
si = sbi->stat_info;
|
||||
si->all_area_segs = le32_to_cpu(raw_super->segment_count);
|
||||
si->sit_area_segs = le32_to_cpu(raw_super->segment_count_sit);
|
||||
si->nat_area_segs = le32_to_cpu(raw_super->segment_count_nat);
|
||||
|
@ -319,6 +318,7 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)
|
|||
si->main_area_zones = si->main_area_sections /
|
||||
le32_to_cpu(raw_super->secs_per_zone);
|
||||
si->sbi = sbi;
|
||||
sbi->stat_info = si;
|
||||
|
||||
mutex_lock(&f2fs_stat_mutex);
|
||||
list_add_tail(&si->stat_list, &f2fs_stat_list);
|
||||
|
@ -329,13 +329,13 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)
|
|||
|
||||
void f2fs_destroy_stats(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
struct f2fs_stat_info *si = sbi->stat_info;
|
||||
struct f2fs_stat_info *si = F2FS_STAT(sbi);
|
||||
|
||||
mutex_lock(&f2fs_stat_mutex);
|
||||
list_del(&si->stat_list);
|
||||
mutex_unlock(&f2fs_stat_mutex);
|
||||
|
||||
kfree(sbi->stat_info);
|
||||
kfree(si);
|
||||
}
|
||||
|
||||
void __init f2fs_create_root_stats(void)
|
||||
|
|
|
@ -1113,11 +1113,16 @@ struct f2fs_stat_info {
|
|||
unsigned base_mem, cache_mem;
|
||||
};
|
||||
|
||||
static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
return (struct f2fs_stat_info*)sbi->stat_info;
|
||||
}
|
||||
|
||||
#define stat_inc_call_count(si) ((si)->call_count++)
|
||||
|
||||
#define stat_inc_seg_count(sbi, type) \
|
||||
do { \
|
||||
struct f2fs_stat_info *si = sbi->stat_info; \
|
||||
struct f2fs_stat_info *si = F2FS_STAT(sbi); \
|
||||
(si)->tot_segs++; \
|
||||
if (type == SUM_TYPE_DATA) \
|
||||
si->data_segs++; \
|
||||
|
@ -1130,14 +1135,14 @@ struct f2fs_stat_info {
|
|||
|
||||
#define stat_inc_data_blk_count(sbi, blks) \
|
||||
do { \
|
||||
struct f2fs_stat_info *si = sbi->stat_info; \
|
||||
struct f2fs_stat_info *si = F2FS_STAT(sbi); \
|
||||
stat_inc_tot_blk_count(si, blks); \
|
||||
si->data_blks += (blks); \
|
||||
} while (0)
|
||||
|
||||
#define stat_inc_node_blk_count(sbi, blks) \
|
||||
do { \
|
||||
struct f2fs_stat_info *si = sbi->stat_info; \
|
||||
struct f2fs_stat_info *si = F2FS_STAT(sbi); \
|
||||
stat_inc_tot_blk_count(si, blks); \
|
||||
si->node_blks += (blks); \
|
||||
} while (0)
|
||||
|
|
Loading…
Reference in a new issue