f2fs: validate before set/clear free nat bitmap
A message that is not in the archive (sent off-list or not yet received): CGME20171114072142epcas5p1e7543c4f118db48ff8ad417894f964d2@epcas5p1.samsung.com
PATCH RESEND v2 1/1 f2fs: validate before set/clear free nat bitmap
In flush_nat_entries, all dirty nats will be flushed and if their new address isn't NULL_ADDR, their bitmaps will be updated, the free_nid_count of the bitmaps will be increased regardless of whether the nats have already been occupied before. This could lead to wrong free_nid_count.
So this patch checks the status of the bits before actually set/clear them.
--- fs/f2fs/node.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
fs/f2fs/node.c +10 -7
@@ -1906,15 +1906,18 @@ static void update_free_nid_bitmap(struct f2fs_sb_info *sbi, nid_t nid,if (!test_bit_le (nat_ofs, nm_i->nat_block_bitmap))return ; -if (set) +if (set) { +if (test_bit_le (nid_ofs, nm_i->free_nid_bitmap[nat_ofs])) +return ;__set_bit_le (nid_ofs, nm_i->free_nid_bitmap[nat_ofs]); -else -__clear_bit_le (nid_ofs, nm_i->free_nid_bitmap[nat_ofs]); - -if (set) nm_i->free_nid_count[nat_ofs]++; -else if (!build) - nm_i->free_nid_count[nat_ofs]--; + }else { +if (!test_bit_le (nid_ofs, nm_i->free_nid_bitmap[nat_ofs])) +return ; +__clear_bit_le (nid_ofs, nm_i->free_nid_bitmap[nat_ofs]); +if (!build) + nm_i->free_nid_count[nat_ofs]--; + } } static void scan_nat_page(struct f2fs_sb_info *sbi,
--
2.7.4
Quoted 9 lines · LiFan
In
flush_nat_entries, all dirty nats will be flushed and if their new address isn'tNULL_ADDR, their bitmaps will be updated, thefree_nid_countof the bitmaps will be increased regardless of whether the nats have already been occupied before. This could lead to wrongfree_nid_count.
So this patch checks the status of the bits before actually set/clear them.Fixes 586d1492f301 ("f2fs: skip scanning free nid bitmap of full NAT blocks")Signed-off-by Fan li <[email protected]>
Thanks,
Quoted 34 lines
--- fs/f2fs/node.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)fs/f2fs/node.c +10
-8@@ -1906,15 +1906,18 @@ static void update_free_nid_bitmap(struct f2fs_sb_info *sbi, nid_t nid,if (!test_bit_le (nat_ofs, nm_i->nat_block_bitmap))return ; -if (set) +if (set) { +if (test_bit_le (nid_ofs, nm_i->free_nid_bitmap[nat_ofs])) +return ;__set_bit_le (nid_ofs, nm_i->free_nid_bitmap[nat_ofs]); -else -__clear_bit_le (nid_ofs, nm_i->free_nid_bitmap[nat_ofs]); - -if (set) nm_i->free_nid_count[nat_ofs]++; -else if (!build) - nm_i->free_nid_count[nat_ofs]--; + }else { +if (!test_bit_le (nid_ofs, nm_i->free_nid_bitmap[nat_ofs])) +return ; +__clear_bit_le (nid_ofs, nm_i->free_nid_bitmap[nat_ofs]); +if (!build) + nm_i->free_nid_count[nat_ofs]--; + } } static void scan_nat_page(struct f2fs_sb_info *sbi, --
Quoted 5 lines
2.7.4
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot