* [PATCH 1/2] sload.f2fs: update sit entries of cursegs @ 2018-06-13 1:51 Sheng Yong 2018-06-13 1:51 ` [RFC PATCH 2/2] fsck.f2fs: introduce fsck_chk_curseg_info Sheng Yong 2018-06-19 12:07 ` [PATCH 1/2] sload.f2fs: update sit entries of cursegs Chao Yu 0 siblings, 2 replies; 8+ messages in thread From: Sheng Yong @ 2018-06-13 1:51 UTC (permalink / raw) To: jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel 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. Signed-off-by: Sheng Yong <shengyong1@huawei.com> --- fsck/mount.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fsck/mount.c b/fsck/mount.c index 0a30adb..68278c5 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -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) -- 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RFC PATCH 2/2] fsck.f2fs: introduce fsck_chk_curseg_info 2018-06-13 1:51 [PATCH 1/2] sload.f2fs: update sit entries of cursegs Sheng Yong @ 2018-06-13 1:51 ` Sheng Yong 2018-06-13 10:13 ` [PATCH] f2fs-tools: do not count free_segs in flush_sit_entries Sheng Yong 2018-06-19 12:11 ` [RFC PATCH 2/2] fsck.f2fs: introduce fsck_chk_curseg_info Chao Yu 2018-06-19 12:07 ` [PATCH 1/2] sload.f2fs: update sit entries of cursegs Chao Yu 1 sibling, 2 replies; 8+ messages in thread From: Sheng Yong @ 2018-06-13 1:51 UTC (permalink / raw) To: jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel 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 <shengyong1@huawei.com> --- fsck/fsck.c | 34 ++++++++++++++++++++++++++++++++++ fsck/fsck.h | 1 + fsck/main.c | 2 ++ 3 files changed, 37 insertions(+) diff --git a/fsck/fsck.c b/fsck/fsck.c index 5b6dbc8..cfd939f 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -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; diff --git a/fsck/fsck.h b/fsck/fsck.h index cbe7fc4..5530aff 100644 --- a/fsck/fsck.h +++ b/fsck/fsck.h @@ -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 *); diff --git a/fsck/main.c b/fsck/main.c index 09026c9..f6d12b0 100644 --- a/fsck/main.c +++ b/fsck/main.c @@ -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: -- 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] f2fs-tools: do not count free_segs in flush_sit_entries 2018-06-13 1:51 ` [RFC PATCH 2/2] fsck.f2fs: introduce fsck_chk_curseg_info Sheng Yong @ 2018-06-13 10:13 ` Sheng Yong 2018-06-19 12:12 ` Chao Yu 2018-06-19 12:11 ` [RFC PATCH 2/2] fsck.f2fs: introduce fsck_chk_curseg_info Chao Yu 1 sibling, 1 reply; 8+ messages in thread From: Sheng Yong @ 2018-06-13 10:13 UTC (permalink / raw) To: jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel 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. Signed-off-by: Sheng Yong <shengyong1@huawei.com> --- fsck/mount.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/fsck/mount.c b/fsck/mount.c index 68278c5..80a4849 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -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) -- 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] f2fs-tools: do not count free_segs in flush_sit_entries 2018-06-13 10:13 ` [PATCH] f2fs-tools: do not count free_segs in flush_sit_entries Sheng Yong @ 2018-06-19 12:12 ` Chao Yu 0 siblings, 0 replies; 8+ messages in thread From: Chao Yu @ 2018-06-19 12:12 UTC (permalink / raw) To: Sheng Yong, jaegeuk; +Cc: miaoxie, linux-f2fs-devel On 2018/6/13 18:13, Sheng Yong wrote: > 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. > > Signed-off-by: Sheng Yong <shengyong1@huawei.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Thanks, ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH 2/2] fsck.f2fs: introduce fsck_chk_curseg_info 2018-06-13 1:51 ` [RFC PATCH 2/2] fsck.f2fs: introduce fsck_chk_curseg_info Sheng Yong 2018-06-13 10:13 ` [PATCH] f2fs-tools: do not count free_segs in flush_sit_entries Sheng Yong @ 2018-06-19 12:11 ` Chao Yu 2018-06-20 11:12 ` [PATCH v2] " Sheng Yong 1 sibling, 1 reply; 8+ messages in thread From: Chao Yu @ 2018-06-19 12:11 UTC (permalink / raw) To: Sheng Yong, jaegeuk; +Cc: miaoxie, linux-f2fs-devel On 2018/6/13 9:51, Sheng Yong wrote: > 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 <shengyong1@huawei.com> > --- > fsck/fsck.c | 34 ++++++++++++++++++++++++++++++++++ > fsck/fsck.h | 1 + > fsck/main.c | 2 ++ > 3 files changed, 37 insertions(+) > > diff --git a/fsck/fsck.c b/fsck/fsck.c > index 5b6dbc8..cfd939f 100644 > --- a/fsck/fsck.c > +++ b/fsck/fsck.c > @@ -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; Need to check c.fix_on to decide fix se->type here? > + 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, > + ret = -1; > + } > + } > + > + return ret; > +} > + > int fsck_verify(struct f2fs_sb_info *sbi) > { > unsigned int i = 0; > diff --git a/fsck/fsck.h b/fsck/fsck.h > index cbe7fc4..5530aff 100644 > --- a/fsck/fsck.h > +++ b/fsck/fsck.h > @@ -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 *); > diff --git a/fsck/main.c b/fsck/main.c > index 09026c9..f6d12b0 100644 > --- a/fsck/main.c > +++ b/fsck/main.c > @@ -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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] fsck.f2fs: introduce fsck_chk_curseg_info 2018-06-19 12:11 ` [RFC PATCH 2/2] fsck.f2fs: introduce fsck_chk_curseg_info Chao Yu @ 2018-06-20 11:12 ` Sheng Yong 2018-06-21 6:12 ` Chao Yu 0 siblings, 1 reply; 8+ messages in thread From: Sheng Yong @ 2018-06-20 11:12 UTC (permalink / raw) To: jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel 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 <shengyong1@huawei.com> --- 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(+) diff --git a/fsck/fsck.c b/fsck/fsck.c index 5b6dbc8..36b0b1d 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -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; diff --git a/fsck/fsck.h b/fsck/fsck.h index cbe7fc4..5530aff 100644 --- a/fsck/fsck.h +++ b/fsck/fsck.h @@ -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 *); diff --git a/fsck/main.c b/fsck/main.c index 09026c9..f6d12b0 100644 --- a/fsck/main.c +++ b/fsck/main.c @@ -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: -- 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] fsck.f2fs: introduce fsck_chk_curseg_info 2018-06-20 11:12 ` [PATCH v2] " Sheng Yong @ 2018-06-21 6:12 ` Chao Yu 0 siblings, 0 replies; 8+ messages in thread From: Chao Yu @ 2018-06-21 6:12 UTC (permalink / raw) To: Sheng Yong, jaegeuk; +Cc: miaoxie, linux-f2fs-devel On 2018/6/20 19:12, Sheng Yong wrote: > 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 <shengyong1@huawei.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Thanks, ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] sload.f2fs: update sit entries of cursegs 2018-06-13 1:51 [PATCH 1/2] sload.f2fs: update sit entries of cursegs Sheng Yong 2018-06-13 1:51 ` [RFC PATCH 2/2] fsck.f2fs: introduce fsck_chk_curseg_info Sheng Yong @ 2018-06-19 12:07 ` Chao Yu 1 sibling, 0 replies; 8+ messages in thread From: Chao Yu @ 2018-06-19 12:07 UTC (permalink / raw) To: Sheng Yong, jaegeuk; +Cc: miaoxie, linux-f2fs-devel On 2018/6/13 9:51, Sheng Yong wrote: > 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. > > Signed-off-by: Sheng Yong <shengyong1@huawei.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Thanks, ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-06-21 6:12 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-06-13 1:51 [PATCH 1/2] sload.f2fs: update sit entries of cursegs Sheng Yong 2018-06-13 1:51 ` [RFC PATCH 2/2] fsck.f2fs: introduce fsck_chk_curseg_info Sheng Yong 2018-06-13 10:13 ` [PATCH] f2fs-tools: do not count free_segs in flush_sit_entries Sheng Yong 2018-06-19 12:12 ` Chao Yu 2018-06-19 12:11 ` [RFC PATCH 2/2] fsck.f2fs: introduce fsck_chk_curseg_info Chao Yu 2018-06-20 11:12 ` [PATCH v2] " Sheng Yong 2018-06-21 6:12 ` Chao Yu 2018-06-19 12:07 ` [PATCH 1/2] sload.f2fs: update sit entries of cursegs Chao Yu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).