linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: Sheng Yong <shengyong1@huawei.com>, jaegeuk@kernel.org
Cc: miaoxie@huawei.com, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [RFC PATCH 2/2] fsck.f2fs: introduce fsck_chk_curseg_info
Date: Tue, 19 Jun 2018 20:11:32 +0800	[thread overview]
Message-ID: <4b799e3b-a5fd-15e4-c50e-3771eb37fb4d@huawei.com> (raw)
In-Reply-To: <20180613015150.197854-2-shengyong1@huawei.com>

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

  parent reply	other threads:[~2018-06-19 12:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Chao Yu [this message]
2018-06-20 11:12     ` [PATCH v2] fsck.f2fs: introduce fsck_chk_curseg_info 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4b799e3b-a5fd-15e4-c50e-3771eb37fb4d@huawei.com \
    --to=yuchao0@huawei.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=miaoxie@huawei.com \
    --cc=shengyong1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).