提交 d7bc2484 编写于 作者: J Jaegeuk Kim

f2fs: fix small discards not to issue redundantly

The ckpt_valid_map and cur_valid_map are synced by seg_info_to_raw_sit.

In the case of small discards, the candidates are selected before sync,
while fitrim selects candidates after sync.

So, for small discards, we need to add candidates only just being obsoleted.
Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
上级 1e84371f
...@@ -525,7 +525,8 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -525,7 +525,8 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc)
bool force = (cpc->reason == CP_DISCARD); bool force = (cpc->reason == CP_DISCARD);
int i; int i;
if (!force && !test_opt(sbi, DISCARD)) if (!force && (!test_opt(sbi, DISCARD) ||
SM_I(sbi)->nr_discards >= SM_I(sbi)->max_discards))
return; return;
if (force && !se->valid_blocks) { if (force && !se->valid_blocks) {
...@@ -553,7 +554,8 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -553,7 +554,8 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc)
/* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */ /* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */
for (i = 0; i < entries; i++) for (i = 0; i < entries; i++)
dmap[i] = ~(cur_map[i] | ckpt_map[i]); dmap[i] = force ? ~ckpt_map[i] :
(cur_map[i] ^ ckpt_map[i]) & ckpt_map[i];
while (force || SM_I(sbi)->nr_discards <= SM_I(sbi)->max_discards) { while (force || SM_I(sbi)->nr_discards <= SM_I(sbi)->max_discards) {
start = __find_rev_next_bit(dmap, max_blocks, end + 1); start = __find_rev_next_bit(dmap, max_blocks, end + 1);
...@@ -1759,7 +1761,7 @@ void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -1759,7 +1761,7 @@ void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
se = get_seg_entry(sbi, segno); se = get_seg_entry(sbi, segno);
/* add discard candidates */ /* add discard candidates */
if (SM_I(sbi)->nr_discards < SM_I(sbi)->max_discards) { if (cpc->reason != CP_DISCARD) {
cpc->trim_start = segno; cpc->trim_start = segno;
add_discard_addrs(sbi, cpc); add_discard_addrs(sbi, cpc);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册