f2fs: add bug on back during flush nat entries
PATCH 1/1 f2fs: add bug on back during flush nat entries
This patch add two bug on check back during flush nat entries, nat_tree_lock will prevent race from node block allocation in write_begin.
--- fs/f2fs/node.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/f2fs/node.c +4 -5
@@ -2519,10 +2519,9 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi, }/* Allow dirty nats by node block allocation in write_begin */ -if (!set->entry_cnt) { -radix_tree_delete (&NM_I (sbi)->nat_set_root, set->set); -kmem_cache_free (nat_entry_set_slab, set); - } +f2fs_bug_on (sbi, set->entry_cnt); +radix_tree_delete (&NM_I (sbi)->nat_set_root, set->set); +kmem_cache_free (nat_entry_set_slab, set); }/*
@@ -2566,8 +2565,8 @@ void flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)list_for_each_entry_safe (set, tmp, &sets, set_list)__flush_nat_entry_set (sbi, set, cpc); +f2fs_bug_on (sbi, nm_i->dirty_nat_cnt);up_write (&nm_i->nat_tree_lock); -/* Allow dirty nats by node block allocation in write_begin */ }static int __get_nat_bitmaps (struct f2fs_sb_info *sbi)
Signature · 6 lines
1.9.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 14 lines · Yunlei He
This patch add two bug on check back during flush nat entries,
nat_tree_lockwill prevent race from node block allocation inwrite_begin.Signed-off-by Yunlei He <[email protected]>--- fs/f2fs/node.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)fs/f2fs/node.c +0
-0
fs/f2fs/node.c static void __flush_nat_entry_set(struct f2fs_sb_info *sbi, · line 2524
Quoted 6 lines
fs/f2fs/node.c +0
-3@@ -2519,10 +2519,9 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi, }/* Allow dirty nats by node block allocation in write_begin */ -if (!set->entry_cnt) { -radix_tree_delete (&NM_I (sbi)->nat_set_root, set->set); -kmem_cache_free (nat_entry_set_slab, set);
During checkpoint, We allow buffered write which needs nid allocation, if we rollback the codes here, we may encounter the BUG_ON?
Thanks,
Quoted 9 lines
fs/f2fs/node.c +3
-1- } +f2fs_bug_on (sbi, set->entry_cnt); +radix_tree_delete (&NM_I (sbi)->nat_set_root, set->set); +kmem_cache_free (nat_entry_set_slab, set); }/*
fs/f2fs/node.c void flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc) · line 2572
Quoted 9 lines
fs/f2fs/node.c +1
-1@@ -2566,8 +2565,8 @@ void flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)list_for_each_entry_safe (set, tmp, &sets, set_list)__flush_nat_entry_set (sbi, set, cpc); +f2fs_bug_on (sbi, nm_i->dirty_nat_cnt);up_write (&nm_i->nat_tree_lock); -/* Allow dirty nats by node block allocation in write_begin */ }static int __get_nat_bitmaps (struct f2fs_sb_info *sbi)
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot