linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: qixiaoyu1 <qxy65535@gmail.com>, jaegeuk@kernel.org
Cc: qixiaoyu1 <qixiaoyu1@xiaomi.com>,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 2/2] f2fs-tools: fix to check free space before grow
Date: Sun, 19 Jun 2022 08:10:52 +0800	[thread overview]
Message-ID: <f3fd41e1-ea76-a7d7-4890-ff66ea87b7ab@kernel.org> (raw)
In-Reply-To: <20220614114929.6897-2-qixiaoyu1@xiaomi.com>

On 2022/6/14 19:49, qixiaoyu1 wrote:
> Otherwise, after grow, kernel may report below error message
> when we mount the image if -o parameter is specified during resize:
> 
> F2FS-fs (loop0): invalid crc_offset: 0
> F2FS-fs (loop0): Wrong valid_user_blocks: 16404, user_block_count: 13312
> F2FS-fs (loop0): Failed to get valid F2FS checkpoint
> mount(2) system call failed: Structure needs cleaning.
> 
> Signed-off-by: qixiaoyu1 <qixiaoyu1@xiaomi.com>

It looks this patch should be merged into previous one, otherwise
-o option support is broken for resize.f2fs.

Thanks,

> ---
>   fsck/resize.c | 36 ++++++++++++++++++++++++------------
>   1 file changed, 24 insertions(+), 12 deletions(-)
> 
> diff --git a/fsck/resize.c b/fsck/resize.c
> index d19c6fa..e135b66 100644
> --- a/fsck/resize.c
> +++ b/fsck/resize.c
> @@ -599,6 +599,26 @@ static void rebuild_checkpoint(struct f2fs_sb_info *sbi,
>   	DBG(0, "Info: Done to rebuild checkpoint blocks\n");
>   }
>   
> +static int f2fs_resize_check(struct f2fs_sb_info *sbi, struct f2fs_super_block *new_sb)
> +{
> +	struct f2fs_checkpoint *cp = F2FS_CKPT(sbi);
> +	block_t user_block_count;
> +	unsigned int overprov_segment_count;
> +
> +	overprov_segment_count = (get_newsb(segment_count_main) -
> +			c.new_reserved_segments) *
> +			c.new_overprovision / 100;
> +	overprov_segment_count += c.new_reserved_segments;
> +
> +	user_block_count = (get_newsb(segment_count_main) -
> +			overprov_segment_count) * c.blks_per_seg;
> +
> +	if (get_cp(valid_block_count) > user_block_count)
> +		return -1;
> +
> +	return 0;
> +}
> +
>   static int f2fs_resize_grow(struct f2fs_sb_info *sbi)
>   {
>   	struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi);
> @@ -616,6 +636,9 @@ static int f2fs_resize_grow(struct f2fs_sb_info *sbi)
>   	if (get_new_sb(new_sb))
>   		return -1;
>   
> +	if (f2fs_resize_check(sbi, new_sb) < 0)
> +		return -1;
> +
>   	/* check nat availability */
>   	if (get_sb(segment_count_nat) > get_newsb(segment_count_nat)) {
>   		err = shrink_nats(sbi, new_sb);
> @@ -659,11 +682,8 @@ static int f2fs_resize_shrink(struct f2fs_sb_info *sbi)
>   	struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi);
>   	struct f2fs_super_block new_sb_raw;
>   	struct f2fs_super_block *new_sb = &new_sb_raw;
> -	struct f2fs_checkpoint *cp = F2FS_CKPT(sbi);
>   	block_t old_end_blkaddr, old_main_blkaddr;
>   	block_t new_end_blkaddr, new_main_blkaddr, tmp_end_blkaddr;
> -	block_t user_block_count;
> -	unsigned int overprov_segment_count;
>   	unsigned int offset;
>   	int err = -1;
>   
> @@ -674,15 +694,7 @@ static int f2fs_resize_shrink(struct f2fs_sb_info *sbi)
>   	if (get_new_sb(new_sb))
>   		return -1;
>   
> -	overprov_segment_count = (get_newsb(segment_count_main) -
> -			c.new_reserved_segments) *
> -			c.new_overprovision / 100;
> -	overprov_segment_count += c.new_reserved_segments;
> -
> -	user_block_count = (get_newsb(segment_count_main) -
> -			overprov_segment_count) * c.blks_per_seg;
> -
> -	if (get_cp(valid_block_count) > user_block_count)
> +	if (f2fs_resize_check(sbi, new_sb) < 0)
>   		return -1;
>   
>   	/* check nat availability */


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

  reply	other threads:[~2022-06-19  0:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-14 11:49 [f2fs-dev] [PATCH 1/2] resize.f2fs: add option to manually specify new overprovision qixiaoyu1
2022-06-14 11:49 ` [f2fs-dev] [PATCH 2/2] f2fs-tools: fix to check free space before grow qixiaoyu1
2022-06-19  0:10   ` Chao Yu [this message]
2022-06-19  0:01 ` [f2fs-dev] [PATCH 1/2] resize.f2fs: add option to manually specify new overprovision Chao Yu
2022-06-20  8:48   ` [f2fs-dev] [PATCH v2] " qixiaoyu1
2022-06-22 13:19     ` Chao Yu
2022-06-20 11:56   ` [f2fs-dev] [PATCH v3 1/2] " qixiaoyu1
2022-06-20 11:56     ` [f2fs-dev] [PATCH v3 2/2] resize.f2fs: update man page for options -i, -s and -V qixiaoyu1
2022-06-22 13:21       ` Chao Yu
2022-06-22 18:31         ` Jaegeuk Kim

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=f3fd41e1-ea76-a7d7-4890-ff66ea87b7ab@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qixiaoyu1@xiaomi.com \
    --cc=qxy65535@gmail.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).