sload.f2fs: update sit entries of cursegs
PATCH 1/2 sload.f2fs: update sit entries of cursegs
move_curseg_info->reset_curseg changes cursegs, however, new segment entries are not set as dirty. As a result, flush_sit_entries will not update entries in SIT, especially when an empty segment is selected as the new curseg, its seg_entry->type is lost.
--- fsck/mount.c | 1 + 1 file changed, 1 insertion(+)
fsck/mount.c +1 -0
@@ -1149,6 +1149,7 @@ void reset_curseg(struct f2fs_sb_info *sbi, int type)SET_SUM_TYPE (sum_footer,SUM_TYPE_NODE ); se =get_seg_entry (sbi, curseg->segno); se->type = type; + se->dirty =1 ; }static void read_compacted_summaries (struct f2fs_sb_info *sbi)
Signature · 6 lines
2.17.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
RFC PATCH 2/2 fsck.f2fs: introduce fsck_chk_curseg_info
If curseg is an empty segment, it will not be checked. This patch introduces fsck_chk_curseg_info() to check SIT/SSA type of cursegs to avoid curseg corruption.
--- fsck/fsck.c | 34 ++++++++++++++++++++++++++++++++++ fsck/fsck.h | 1 + fsck/main.c | 2 ++ 3 files changed, 37 insertions(+)
fsck/fsck.c +34 -0
@@ -2422,6 +2422,40 @@ out:return cnt; } +int fsck_chk_curseg_info (struct f2fs_sb_info *sbi) +{ +struct curseg_info *curseg; +struct seg_entry *se; +struct f2fs_summary_block *sum_blk; +int i, ret =0 ; + +for (i =0 ; i <NO_CHECK_TYPE ; i++) { + curseg =CURSEG_I (sbi, i); + se =get_seg_entry (sbi, curseg->segno); + sum_blk = curseg->sum_blk; + +if (se->type != i) { +ASSERT_MSG ("Incorrect curseg [%d]: segno [0x%x] " +"type(SIT) [%d]" , i, curseg->segno, + se->type); + se->type = i; + ret =-1 ; + } +if (i <=CURSEG_COLD_DATA &&IS_SUM_DATA_SEG (sum_blk->footer)) { +continue ; + }else if (i >CURSEG_COLD_DATA &&IS_SUM_NODE_SEG (sum_blk->footer)) { +continue ; + }else { +ASSERT_MSG ("Incorrect curseg [%d]: segno [0x%x] " +"type(SSA) [%d]" , i, curseg->segno, + sum_blk->footer.entry_type); + ret =-1 ; + } + } + +return ret; +} +int fsck_verify (struct f2fs_sb_info *sbi) {unsigned int i =0 ;
fsck/fsck.h +1 -0
@@ -144,6 +144,7 @@ extern int fsck_chk_dentry_blk(struct f2fs_sb_info *, u32, struct child_info *,int fsck_chk_inline_dentries (struct f2fs_sb_info *,struct f2fs_node *,struct child_info *);int fsck_chk_meta (struct f2fs_sb_info *sbi); +int fsck_chk_curseg_info (struct f2fs_sb_info *);int convert_encrypted_name (unsigned char *,int ,unsigned char *,int );extern void update_free_segments (struct f2fs_sb_info *);
fsck/main.c +2 -0
@@ -578,6 +578,8 @@ static void do_fsck(struct f2fs_sb_info *sbi)print_cp_state (flag); +fsck_chk_curseg_info (sbi); +if (!c.fix_on && !c.bug_on) {switch (c.preen_mode) {case PREEN_MODE_1 :
Signature · 6 lines
2.17.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
PATCH 1/1 f2fs-tools: do not count free_segs in flush_sit_entries
flush_sit_entries() is always called before write_checkpoint(). Since free_segs is counted in write_checkpoint, there is no need to do that in flush_sit_entries. Besides, the value of free_segs may be not correct if we skip uptodate seg_entries.
--- fsck/mount.c | 7 ------- 1 file changed, 7 deletions(-)
fsck/mount.c +0 -7
@@ -1867,11 +1867,9 @@ void flush_journal_entries(struct f2fs_sb_info *sbi)void flush_sit_entries (struct f2fs_sb_info *sbi) { -struct f2fs_checkpoint *cp =F2FS_CKPT (sbi);struct sit_info *sit_i =SIT_I (sbi);struct f2fs_sit_block *sit_blk;unsigned int segno =0 ; -u32 free_segs =0 ; sit_blk =calloc (BLOCK_SZ ,1 );ASSERT (sit_blk);
@@ -1891,14 +1889,9 @@ void flush_sit_entries(struct f2fs_sb_info *sbi) sit->vblocks =cpu_to_le16 ((se->type <<SIT_VBLOCKS_SHIFT ) | se->valid_blocks);rewrite_current_sit_page (sbi, segno, sit_blk); - -if (se->valid_blocks ==0x0 && - !IS_CUR_SEGNO (sbi, segno,NO_CHECK_TYPE )) - free_segs++; }free (sit_blk); -set_cp (free_segment_count, free_segs); }int find_next_free_block (struct f2fs_sb_info *sbi,u64 *to,int left,int type)
Signature · 6 lines
2.17.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Re: [PATCH] f2fs-tools: do not count free_segs in flush_sit_entries
Quoted 6 lines · Sheng Yong
flush_sit_entries()is always called beforewrite_checkpoint(). Sincefree_segsis counted inwrite_checkpoint, there is no need to do that inflush_sit_entries. Besides, the value offree_segsmay be not correct if we skip uptodateseg_entries.Signed-off-by Sheng Yong <[email protected]>
Thanks,
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Re: [RFC PATCH 2/2] fsck.f2fs: introduce fsck_chk_curseg_info
In reply to Sheng YongQuoted 26 lines · Sheng Yong
If curseg is an empty segment, it will not be checked. This patch introduces
fsck_chk_curseg_info()to check SIT/SSA type of cursegs to avoid curseg corruption.Signed-off-by Sheng Yong <[email protected]>--- fsck/fsck.c | 34 ++++++++++++++++++++++++++++++++++ fsck/fsck.h | 1 + fsck/main.c | 2 ++ 3 files changed, 37 insertions(+)fsck/fsck.c +7
-0@@ -2422,6 +2422,40 @@ out:return cnt; } +int fsck_chk_curseg_info (struct f2fs_sb_info *sbi) +{ +struct curseg_info *curseg; +struct seg_entry *se; +struct f2fs_summary_block *sum_blk; +int i, ret =0 ; +
fsck/fsck.c out: · line 2441
Quoted 10 lines
fsck/fsck.c +10
-0+for (i =0 ; i <NO_CHECK_TYPE ; i++) { + curseg =CURSEG_I (sbi, i); + se =get_seg_entry (sbi, curseg->segno); + sum_blk = curseg->sum_blk; + +if (se->type != i) { +ASSERT_MSG ("Incorrect curseg [%d]: segno [0x%x] " +"type(SIT) [%d]" , i, curseg->segno, + se->type); + se->type = i;
Need to check c.fix_on to decide fix se->type here?
fsck/fsck.c out: · line 2451
Quoted 10 lines
fsck/fsck.c +10
-0+ ret =-1 ; + } +if (i <=CURSEG_COLD_DATA &&IS_SUM_DATA_SEG (sum_blk->footer)) { +continue ; + }else if (i >CURSEG_COLD_DATA &&IS_SUM_NODE_SEG (sum_blk->footer)) { +continue ; + }else { +ASSERT_MSG ("Incorrect curseg [%d]: segno [0x%x] " +"type(SSA) [%d]" , i, curseg->segno, + sum_blk->footer.entry_type);
Ditto.
Thanks,
Quoted 28 lines
fsck/fsck.c +7
-0+ ret =-1 ; + } + } + +return ret; +} +int fsck_verify (struct f2fs_sb_info *sbi) {unsigned int i =0 ;fsck/fsck.h +1
-0@@ -144,6 +144,7 @@ extern int fsck_chk_dentry_blk(struct f2fs_sb_info *, u32, struct child_info *,int fsck_chk_inline_dentries (struct f2fs_sb_info *,struct f2fs_node *,struct child_info *);int fsck_chk_meta (struct f2fs_sb_info *sbi); +int fsck_chk_curseg_info (struct f2fs_sb_info *);int convert_encrypted_name (unsigned char *,int ,unsigned char *,int );extern void update_free_segments (struct f2fs_sb_info *);fsck/main.c +0
-0
fsck/main.c static void do_fsck(struct f2fs_sb_info *sbi) · line 585
Quoted 8 lines
fsck/main.c +2
-0@@ -578,6 +578,8 @@ static void do_fsck(struct f2fs_sb_info *sbi)print_cp_state (flag); +fsck_chk_curseg_info (sbi); +if (!c.fix_on && !c.bug_on) {switch (c.preen_mode) {case PREEN_MODE_1 :
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
PATCH v2 1/1 fsck.f2fs: introduce fsck_chk_curseg_info
If curseg is an empty segment, it will not be checked. This patch introduces fsck_chk_curseg_info() to check SIT/SSA type of cursegs to avoid curseg corruption.
---
v2: check c.fix_on and c.preen_mode before updating se->type
fsck/fsck.c | 39 +++++++++++++++++++++++++++++++++++++++ fsck/fsck.h | 1 + fsck/main.c | 2 ++ 3 files changed, 42 insertions(+)
fsck/fsck.c +39 -0
@@ -2422,6 +2422,45 @@ out:return cnt; } +int fsck_chk_curseg_info (struct f2fs_sb_info *sbi) +{ +struct curseg_info *curseg; +struct seg_entry *se; +struct f2fs_summary_block *sum_blk; +int i, ret =0 ; + +for (i =0 ; i <NO_CHECK_TYPE ; i++) { + curseg =CURSEG_I (sbi, i); + se =get_seg_entry (sbi, curseg->segno); + sum_blk = curseg->sum_blk; + +if (se->type != i) { +ASSERT_MSG ("Incorrect curseg [%d]: segno [0x%x] " +"type(SIT) [%d]" , i, curseg->segno, + se->type); +if (c.fix_on || c.preen_mode) + se->type = i; + ret =-1 ; + } +if (i <=CURSEG_COLD_DATA &&IS_SUM_DATA_SEG (sum_blk->footer)) { +continue ; + }else if (i >CURSEG_COLD_DATA &&IS_SUM_NODE_SEG (sum_blk->footer)) { +continue ; + }else { +ASSERT_MSG ("Incorrect curseg [%d]: segno [0x%x] " +"type(SSA) [%d]" , i, curseg->segno, + sum_blk->footer.entry_type); +if (c.fix_on || c.preen_mode) + sum_blk->footer.entry_type = + i <=CURSEG_COLD_DATA ? +SUM_TYPE_DATA :SUM_TYPE_NODE ; + ret =-1 ; + } + } + +return ret; +} +int fsck_verify (struct f2fs_sb_info *sbi) {unsigned int i =0 ;
fsck/fsck.h +1 -0
@@ -144,6 +144,7 @@ extern int fsck_chk_dentry_blk(struct f2fs_sb_info *, u32, struct child_info *,int fsck_chk_inline_dentries (struct f2fs_sb_info *,struct f2fs_node *,struct child_info *);int fsck_chk_meta (struct f2fs_sb_info *sbi); +int fsck_chk_curseg_info (struct f2fs_sb_info *);int convert_encrypted_name (unsigned char *,int ,unsigned char *,int );extern void update_free_segments (struct f2fs_sb_info *);
fsck/main.c +2 -0
@@ -578,6 +578,8 @@ static void do_fsck(struct f2fs_sb_info *sbi)print_cp_state (flag); +fsck_chk_curseg_info (sbi); +if (!c.fix_on && !c.bug_on) {switch (c.preen_mode) {case PREEN_MODE_1 :
Signature · 6 lines
2.17.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Re: [PATCH v2] fsck.f2fs: introduce fsck_chk_curseg_info
Quoted 5 lines · Sheng Yong
If curseg is an empty segment, it will not be checked. This patch introduces
fsck_chk_curseg_info()to check SIT/SSA type of cursegs to avoid curseg corruption.Signed-off-by Sheng Yong <[email protected]>
Thanks,
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 6 lines · Sheng Yong
move_curseg_info->reset_cursegchanges cursegs, however, new segment entries are not set as dirty. As a result,flush_sit_entrieswill not update entries in SIT, especially when an empty segment is selected as the new curseg, itsseg_entry->typeis lost.Signed-off-by Sheng Yong <[email protected]>
Thanks,
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot