We should check valid_map_mir and block count to ensure
the flushed raw_sit is correct.

Signed-off-by: Zhikang Zhang <zhangzhika...@huawei.com>
Signed-off-by: Yunlei He <heyun...@huawei.com>
---
 fs/f2fs/segment.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 5854cc4..c2dc7da 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -3380,6 +3380,11 @@ void flush_sit_entries(struct f2fs_sb_info *sbi, struct 
cp_control *cpc)
                        int offset, sit_offset;
 
                        se = get_seg_entry(sbi, segno);
+#ifdef CONFIG_F2FS_CHECK_FS
+                       if (memcmp(se->cur_valid_map, se->cur_valid_map_mir,
+                                               SIT_VBLOCK_MAP_SIZE))
+                               f2fs_bug_on(sbi, 1);
+#endif
 
                        /* add discard candidates */
                        if (!(cpc->reason & CP_DISCARD)) {
@@ -3395,10 +3400,14 @@ void flush_sit_entries(struct f2fs_sb_info *sbi, struct 
cp_control *cpc)
                                                        cpu_to_le32(segno);
                                seg_info_to_raw_sit(se,
                                        &sit_in_journal(journal, offset));
+                               check_block_count(sbi, segno,
+                                       &sit_in_journal(journal, offset));
                        } else {
                                sit_offset = SIT_ENTRY_OFFSET(sit_i, segno);
                                seg_info_to_raw_sit(se,
                                                &raw_sit->entries[sit_offset]);
+                               check_block_count(sbi, segno,
+                                               &raw_sit->entries[sit_offset]);
                        }
 
                        __clear_bit(segno, bitmap);
-- 
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
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to