Commit 5f32366a authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: count discard command entry

Adds to count discard command entry and show the number in debugfs,
also fix to add cost of discard command cache into total comsumed
memory footprint.
Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 8b8dd65f
...@@ -67,6 +67,8 @@ static void update_general_status(struct f2fs_sb_info *sbi) ...@@ -67,6 +67,8 @@ static void update_general_status(struct f2fs_sb_info *sbi)
atomic_read(&SM_I(sbi)->dcc_info->issued_discard); atomic_read(&SM_I(sbi)->dcc_info->issued_discard);
si->nr_discarding = si->nr_discarding =
atomic_read(&SM_I(sbi)->dcc_info->issing_discard); atomic_read(&SM_I(sbi)->dcc_info->issing_discard);
si->nr_discard_cmd =
atomic_read(&SM_I(sbi)->dcc_info->discard_cmd_cnt);
} }
si->total_count = (int)sbi->user_block_count / sbi->blocks_per_seg; si->total_count = (int)sbi->user_block_count / sbi->blocks_per_seg;
si->rsvd_segs = reserved_segments(sbi); si->rsvd_segs = reserved_segments(sbi);
...@@ -220,8 +222,11 @@ static void update_mem_info(struct f2fs_sb_info *sbi) ...@@ -220,8 +222,11 @@ static void update_mem_info(struct f2fs_sb_info *sbi)
/* build merge flush thread */ /* build merge flush thread */
if (SM_I(sbi)->fcc_info) if (SM_I(sbi)->fcc_info)
si->cache_mem += sizeof(struct flush_cmd_control); si->cache_mem += sizeof(struct flush_cmd_control);
if (SM_I(sbi)->dcc_info) if (SM_I(sbi)->dcc_info) {
si->cache_mem += sizeof(struct discard_cmd_control); si->cache_mem += sizeof(struct discard_cmd_control);
si->cache_mem += sizeof(struct discard_cmd) *
atomic_read(&SM_I(sbi)->dcc_info->discard_cmd_cnt);
}
/* free nids */ /* free nids */
si->cache_mem += (NM_I(sbi)->nid_cnt[FREE_NID_LIST] + si->cache_mem += (NM_I(sbi)->nid_cnt[FREE_NID_LIST] +
...@@ -343,10 +348,11 @@ static int stat_show(struct seq_file *s, void *v) ...@@ -343,10 +348,11 @@ static int stat_show(struct seq_file *s, void *v)
si->ext_tree, si->zombie_tree, si->ext_node); si->ext_tree, si->zombie_tree, si->ext_node);
seq_puts(s, "\nBalancing F2FS Async:\n"); seq_puts(s, "\nBalancing F2FS Async:\n");
seq_printf(s, " - IO (CP: %4d, Data: %4d, Flush: (%4d %4d), " seq_printf(s, " - IO (CP: %4d, Data: %4d, Flush: (%4d %4d), "
"Discard: (%4d %4d))\n", "Discard: (%4d %4d)) cmd: %4d\n",
si->nr_wb_cp_data, si->nr_wb_data, si->nr_wb_cp_data, si->nr_wb_data,
si->nr_flushing, si->nr_flushed, si->nr_flushing, si->nr_flushed,
si->nr_discarding, si->nr_discarded); si->nr_discarding, si->nr_discarded,
si->nr_discard_cmd);
seq_printf(s, " - inmem: %4d, atomic IO: %4d (Max. %4d), " seq_printf(s, " - inmem: %4d, atomic IO: %4d (Max. %4d), "
"volatile IO: %4d (Max. %4d)\n", "volatile IO: %4d (Max. %4d)\n",
si->inmem_pages, si->aw_cnt, si->max_aw_cnt, si->inmem_pages, si->aw_cnt, si->max_aw_cnt,
......
...@@ -216,6 +216,7 @@ struct discard_cmd_control { ...@@ -216,6 +216,7 @@ struct discard_cmd_control {
int max_discards; /* max. discards to be issued */ int max_discards; /* max. discards to be issued */
atomic_t issued_discard; /* # of issued discard */ atomic_t issued_discard; /* # of issued discard */
atomic_t issing_discard; /* # of issing discard */ atomic_t issing_discard; /* # of issing discard */
atomic_t discard_cmd_cnt; /* # of cached cmd count */
}; };
/* for the list of fsync inodes, used only during recovery */ /* for the list of fsync inodes, used only during recovery */
...@@ -2333,6 +2334,7 @@ struct f2fs_stat_info { ...@@ -2333,6 +2334,7 @@ struct f2fs_stat_info {
int total_count, utilization; int total_count, utilization;
int bg_gc, nr_wb_cp_data, nr_wb_data; int bg_gc, nr_wb_cp_data, nr_wb_data;
int nr_flushing, nr_flushed, nr_discarding, nr_discarded; int nr_flushing, nr_flushed, nr_discarding, nr_discarded;
int nr_discard_cmd;
int inline_xattr, inline_inode, inline_dir, append, update, orphans; int inline_xattr, inline_inode, inline_dir, append, update, orphans;
int aw_cnt, max_aw_cnt, vw_cnt, max_vw_cnt; int aw_cnt, max_aw_cnt, vw_cnt, max_vw_cnt;
unsigned int valid_count, valid_node_count, valid_inode_count, discard_blks; unsigned int valid_count, valid_node_count, valid_inode_count, discard_blks;
......
...@@ -693,6 +693,8 @@ static void __add_discard_cmd(struct f2fs_sb_info *sbi, ...@@ -693,6 +693,8 @@ static void __add_discard_cmd(struct f2fs_sb_info *sbi,
mutex_lock(&dcc->cmd_lock); mutex_lock(&dcc->cmd_lock);
list_add_tail(&dc->list, cmd_list); list_add_tail(&dc->list, cmd_list);
mutex_unlock(&dcc->cmd_lock); mutex_unlock(&dcc->cmd_lock);
atomic_inc(&dcc->discard_cmd_cnt);
} }
static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *dc) static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *dc)
...@@ -708,6 +710,7 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *d ...@@ -708,6 +710,7 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *d
"Issue discard failed, ret: %d", dc->error); "Issue discard failed, ret: %d", dc->error);
list_del(&dc->list); list_del(&dc->list);
kmem_cache_free(discard_cmd_slab, dc); kmem_cache_free(discard_cmd_slab, dc);
atomic_dec(&SM_I(sbi)->dcc_info->discard_cmd_cnt);
} }
static void f2fs_submit_discard_endio(struct bio *bio) static void f2fs_submit_discard_endio(struct bio *bio)
...@@ -1145,6 +1148,7 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi) ...@@ -1145,6 +1148,7 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
mutex_init(&dcc->cmd_lock); mutex_init(&dcc->cmd_lock);
atomic_set(&dcc->issued_discard, 0); atomic_set(&dcc->issued_discard, 0);
atomic_set(&dcc->issing_discard, 0); atomic_set(&dcc->issing_discard, 0);
atomic_set(&dcc->discard_cmd_cnt, 0);
dcc->nr_discards = 0; dcc->nr_discards = 0;
dcc->max_discards = 0; dcc->max_discards = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment