Commit af8ff65b authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: introduce release_discard_addr() for cleanup

Introduce release_discard_addr() to include common codes for cleanup.
Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
[Fengguang Wu: declare static function, reported by kbuild test robot]
Signed-off-by: default avatarFengguang Wu <fengguang.wu@intel.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent a9af3fdc
...@@ -1581,16 +1581,20 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc, ...@@ -1581,16 +1581,20 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc,
return false; return false;
} }
static void release_discard_addr(struct discard_entry *entry)
{
list_del(&entry->list);
kmem_cache_free(discard_entry_slab, entry);
}
void release_discard_addrs(struct f2fs_sb_info *sbi) void release_discard_addrs(struct f2fs_sb_info *sbi)
{ {
struct list_head *head = &(SM_I(sbi)->dcc_info->entry_list); struct list_head *head = &(SM_I(sbi)->dcc_info->entry_list);
struct discard_entry *entry, *this; struct discard_entry *entry, *this;
/* drop caches */ /* drop caches */
list_for_each_entry_safe(entry, this, head, list) { list_for_each_entry_safe(entry, this, head, list)
list_del(&entry->list); release_discard_addr(entry);
kmem_cache_free(discard_entry_slab, entry);
}
} }
/* /*
...@@ -1690,9 +1694,8 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -1690,9 +1694,8 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
if (cur_pos < sbi->blocks_per_seg) if (cur_pos < sbi->blocks_per_seg)
goto find_next; goto find_next;
list_del(&entry->list); release_discard_addr(entry);
dcc->nr_discards -= total_len; dcc->nr_discards -= total_len;
kmem_cache_free(discard_entry_slab, entry);
} }
wake_up_discard_thread(sbi, false); wake_up_discard_thread(sbi, false);
......
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