mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
f2fs: free radix_tree_nodes used by nat_set entries
In the normal case, the radix_tree_nodes are freed successfully. But, when cp_error was detected, we should destroy them forcefully. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
df1991391f
commit
7aed0d4537
@ -1894,7 +1894,7 @@ void flush_nat_entries(struct f2fs_sb_info *sbi)
|
||||
struct f2fs_nm_info *nm_i = NM_I(sbi);
|
||||
struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
|
||||
struct f2fs_summary_block *sum = curseg->sum_blk;
|
||||
struct nat_entry_set *setvec[NATVEC_SIZE];
|
||||
struct nat_entry_set *setvec[SETVEC_SIZE];
|
||||
struct nat_entry_set *set, *tmp;
|
||||
unsigned int found;
|
||||
nid_t set_idx = 0;
|
||||
@ -1911,7 +1911,7 @@ void flush_nat_entries(struct f2fs_sb_info *sbi)
|
||||
remove_nats_in_journal(sbi);
|
||||
|
||||
while ((found = __gang_lookup_nat_set(nm_i,
|
||||
set_idx, NATVEC_SIZE, setvec))) {
|
||||
set_idx, SETVEC_SIZE, setvec))) {
|
||||
unsigned idx;
|
||||
set_idx = setvec[found - 1]->set + 1;
|
||||
for (idx = 0; idx < found; idx++)
|
||||
@ -1991,6 +1991,7 @@ void destroy_node_manager(struct f2fs_sb_info *sbi)
|
||||
struct f2fs_nm_info *nm_i = NM_I(sbi);
|
||||
struct free_nid *i, *next_i;
|
||||
struct nat_entry *natvec[NATVEC_SIZE];
|
||||
struct nat_entry_set *setvec[SETVEC_SIZE];
|
||||
nid_t nid = 0;
|
||||
unsigned int found;
|
||||
|
||||
@ -2015,11 +2016,27 @@ void destroy_node_manager(struct f2fs_sb_info *sbi)
|
||||
while ((found = __gang_lookup_nat_cache(nm_i,
|
||||
nid, NATVEC_SIZE, natvec))) {
|
||||
unsigned idx;
|
||||
|
||||
nid = nat_get_nid(natvec[found - 1]) + 1;
|
||||
for (idx = 0; idx < found; idx++)
|
||||
__del_from_nat_cache(nm_i, natvec[idx]);
|
||||
}
|
||||
f2fs_bug_on(sbi, nm_i->nat_cnt);
|
||||
|
||||
/* destroy nat set cache */
|
||||
nid = 0;
|
||||
while ((found = __gang_lookup_nat_set(nm_i,
|
||||
nid, SETVEC_SIZE, setvec))) {
|
||||
unsigned idx;
|
||||
|
||||
nid = setvec[found - 1]->set + 1;
|
||||
for (idx = 0; idx < found; idx++) {
|
||||
/* entry_cnt is not zero, when cp_error was occurred */
|
||||
f2fs_bug_on(sbi, !list_empty(&setvec[idx]->entry_list));
|
||||
radix_tree_delete(&nm_i->nat_set_root, setvec[idx]->set);
|
||||
kmem_cache_free(nat_entry_set_slab, setvec[idx]);
|
||||
}
|
||||
}
|
||||
up_write(&nm_i->nat_tree_lock);
|
||||
|
||||
kfree(nm_i->nat_bitmap);
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
/* vector size for gang look-up from nat cache that consists of radix tree */
|
||||
#define NATVEC_SIZE 64
|
||||
#define SETVEC_SIZE 32
|
||||
|
||||
/* return value for read_node_page */
|
||||
#define LOCKED_PAGE 1
|
||||
|
Loading…
Reference in New Issue
Block a user