linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: Xiaojun Wang <wangxiaojun11@huawei.com>, <jaegeuk@kernel.org>,
	<linux-f2fs-devel@lists.sourceforge.net>
Subject: Re: [f2fs-dev] [PATCH] f2fs: fix wrong total_sections check
Date: Wed, 16 Sep 2020 10:56:58 +0800	[thread overview]
Message-ID: <3041cb44-8666-1db2-7474-367cf19f46c7@huawei.com> (raw)
In-Reply-To: <20200916015410.4135737-1-wangxiaojun11@huawei.com>

On 2020/9/16 9:54, Xiaojun Wang wrote:
> Meta area is not included in section_count computation.
> The code in mkfs/f2fs_format.c is:
> 	total_zones = get_sb(segment_count) / (c.segs_per_zone) -
> 					total_meta_zones;
> 	set_sb(section_count, total_zones * c.secs_per_zone);
> 
> So the minimum total_sections is 1.
> 
> Signed-off-by: Xiaojun Wang <wangxiaojun11@huawei.com>
> ---
>   fs/f2fs/super.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index dfa072fa8081..a450c8589841 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -2799,8 +2799,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
>   		return -EFSCORRUPTED;
>   	}
>   
> -	if (total_sections > segment_count ||
> -			total_sections < F2FS_MIN_SEGMENTS ||
> +	if (total_sections > segment_count || total_sections < 1 ||
>   			segs_per_sec > segment_count || !segs_per_sec) {

Here, we try to check sanity on segs_per_sec config directly and indirectly:
- directly: check raw_super->segs_per_sec field
- indirectly: check whether segment_count / total_sections is less than 1

So I guess that first condition is wrong as well, should change it like?

if (total_sections > segment_count - 'total_meta_segment_count' ||

Thoughts?

Thanks,

>   		f2fs_info(sbi, "Invalid segment/section count (%u, %u x %u)",
>   			  segment_count, total_sections, segs_per_sec);
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2020-09-16  2:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-16  1:54 [f2fs-dev] [PATCH] f2fs: fix wrong total_sections check Xiaojun Wang
2020-09-16  2:56 ` Chao Yu [this message]
2020-09-16  6:56   ` wangxiaojun (N)
2020-09-16  9:49     ` Chao Yu
2020-09-17  3:54       ` wangxiaojun (N)

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=3041cb44-8666-1db2-7474-367cf19f46c7@huawei.com \
    --to=yuchao0@huawei.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=wangxiaojun11@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).