All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: qixiaoyu1 <qxy65535@gmail.com>, jaegeuk@kernel.org
Cc: liuchao12 <liuchao12@xiaomi.com>,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 1/2] resize.f2fs: add option to manually specify new overprovision
Date: Sun, 19 Jun 2022 08:01:38 +0800	[thread overview]
Message-ID: <5627a654-d605-6840-a133-e583c804aadd@kernel.org> (raw)
In-Reply-To: <20220614114929.6897-1-qixiaoyu1@xiaomi.com>

On 2022/6/14 19:49, qixiaoyu1 wrote:
> From: liuchao12 <liuchao12@xiaomi.com>
> 
> Make.f2fs supports manually specifying overprovision, and we expect
> resize.f2fs to support it as well.
> 
> This change add a new '-o' option to manually specify overprovision.
> 
> Signed-off-by: liuchao12 <liuchao12@xiaomi.com>
> ---
>   fsck/main.c   |  8 ++++++--
>   fsck/resize.c | 12 ++++++++++--
>   2 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/fsck/main.c b/fsck/main.c
> index aef797e..3b4da0f 100644
> --- a/fsck/main.c
> +++ b/fsck/main.c
> @@ -121,7 +121,8 @@ void resize_usage()
>   	MSG(0, "[options]:\n");
>   	MSG(0, "  -d debug level [default:0]\n");
>   	MSG(0, "  -i extended node bitmap, node ratio is 20%% by default\n");
> -	MSG(0, "  -s safe resize (Does not resize metadata)");
> +	MSG(0, "  -o overprovision percentage [default:auto]\n");

Should update manual as well?

> +	MSG(0, "  -s safe resize (Does not resize metadata)\n");
>   	MSG(0, "  -t target sectors [default: device size]\n");
>   	MSG(0, "  -V print the version number and exit\n");
>   	exit(1);
> @@ -527,7 +528,7 @@ void f2fs_parse_options(int argc, char *argv[])
>   #endif
>   	} else if (!strcmp("resize.f2fs", prog)) {
>   #ifdef WITH_RESIZE
> -		const char *option_string = "d:fst:iV";
> +		const char *option_string = "d:fst:io:V";
>   
>   		c.func = RESIZE;
>   		while ((option = getopt(argc, argv, option_string)) != EOF) {
> @@ -561,6 +562,9 @@ void f2fs_parse_options(int argc, char *argv[])
>   			case 'i':
>   				c.large_nat_bitmap = 1;
>   				break;
> +			case 'o':
> +				c.new_overprovision = atof(optarg);
> +				break;
>   			case 'V':
>   				show_version(prog);
>   				exit(0);
> diff --git a/fsck/resize.c b/fsck/resize.c
> index f1b7701..d19c6fa 100644
> --- a/fsck/resize.c
> +++ b/fsck/resize.c
> @@ -146,12 +146,15 @@ safe_resize:
>   						get_sb(segs_per_sec));
>   
>   	/* Let's determine the best reserved and overprovisioned space */
> -	c.new_overprovision = get_best_overprovision(sb);
> +	if (c.new_overprovision == 0)
> +		c.new_overprovision = get_best_overprovision(sb);
> +
>   	c.new_reserved_segments =
>   		(2 * (100 / c.new_overprovision + 1) + 6) *
>   						get_sb(segs_per_sec);
>   
> -	if ((get_sb(segment_count_main) - 2) < c.new_reserved_segments ||
> +	if (c.new_overprovision == 0 ||

Should never be zero here? Otherwise above "100 / c.new_overprovision"
calculation will cause arithmetic exception.

Thanks,

> +		(get_sb(segment_count_main) - 2) < c.new_reserved_segments ||
>   		get_sb(segment_count_main) * blks_per_seg >
>   						get_sb(block_count)) {
>   		MSG(0, "\tError: Device size is not sufficient for F2FS volume, "
> @@ -476,6 +479,11 @@ static void rebuild_checkpoint(struct f2fs_sb_info *sbi,
>   	set_cp(overprov_segment_count, get_cp(overprov_segment_count) +
>   						get_cp(rsvd_segment_count));
>   
> +	DBG(0, "Info: Overprovision ratio = %.3lf%%\n", c.new_overprovision);
> +	DBG(0, "Info: Overprovision segments = %u (GC reserved = %u)\n",
> +					get_cp(overprov_segment_count),
> +					c.new_reserved_segments);
> +
>   	free_segment_count = get_free_segments(sbi);
>   	new_segment_count = get_newsb(segment_count_main) -
>   					get_sb(segment_count_main);


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

WARNING: multiple messages have this Message-ID (diff)
From: Chao Yu <chao@kernel.org>
To: qixiaoyu1 <qxy65535@gmail.com>, jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, liuchao12 <liuchao12@xiaomi.com>
Subject: Re: [PATCH 1/2] resize.f2fs: add option to manually specify new overprovision
Date: Sun, 19 Jun 2022 08:01:38 +0800	[thread overview]
Message-ID: <5627a654-d605-6840-a133-e583c804aadd@kernel.org> (raw)
In-Reply-To: <20220614114929.6897-1-qixiaoyu1@xiaomi.com>

On 2022/6/14 19:49, qixiaoyu1 wrote:
> From: liuchao12 <liuchao12@xiaomi.com>
> 
> Make.f2fs supports manually specifying overprovision, and we expect
> resize.f2fs to support it as well.
> 
> This change add a new '-o' option to manually specify overprovision.
> 
> Signed-off-by: liuchao12 <liuchao12@xiaomi.com>
> ---
>   fsck/main.c   |  8 ++++++--
>   fsck/resize.c | 12 ++++++++++--
>   2 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/fsck/main.c b/fsck/main.c
> index aef797e..3b4da0f 100644
> --- a/fsck/main.c
> +++ b/fsck/main.c
> @@ -121,7 +121,8 @@ void resize_usage()
>   	MSG(0, "[options]:\n");
>   	MSG(0, "  -d debug level [default:0]\n");
>   	MSG(0, "  -i extended node bitmap, node ratio is 20%% by default\n");
> -	MSG(0, "  -s safe resize (Does not resize metadata)");
> +	MSG(0, "  -o overprovision percentage [default:auto]\n");

Should update manual as well?

> +	MSG(0, "  -s safe resize (Does not resize metadata)\n");
>   	MSG(0, "  -t target sectors [default: device size]\n");
>   	MSG(0, "  -V print the version number and exit\n");
>   	exit(1);
> @@ -527,7 +528,7 @@ void f2fs_parse_options(int argc, char *argv[])
>   #endif
>   	} else if (!strcmp("resize.f2fs", prog)) {
>   #ifdef WITH_RESIZE
> -		const char *option_string = "d:fst:iV";
> +		const char *option_string = "d:fst:io:V";
>   
>   		c.func = RESIZE;
>   		while ((option = getopt(argc, argv, option_string)) != EOF) {
> @@ -561,6 +562,9 @@ void f2fs_parse_options(int argc, char *argv[])
>   			case 'i':
>   				c.large_nat_bitmap = 1;
>   				break;
> +			case 'o':
> +				c.new_overprovision = atof(optarg);
> +				break;
>   			case 'V':
>   				show_version(prog);
>   				exit(0);
> diff --git a/fsck/resize.c b/fsck/resize.c
> index f1b7701..d19c6fa 100644
> --- a/fsck/resize.c
> +++ b/fsck/resize.c
> @@ -146,12 +146,15 @@ safe_resize:
>   						get_sb(segs_per_sec));
>   
>   	/* Let's determine the best reserved and overprovisioned space */
> -	c.new_overprovision = get_best_overprovision(sb);
> +	if (c.new_overprovision == 0)
> +		c.new_overprovision = get_best_overprovision(sb);
> +
>   	c.new_reserved_segments =
>   		(2 * (100 / c.new_overprovision + 1) + 6) *
>   						get_sb(segs_per_sec);
>   
> -	if ((get_sb(segment_count_main) - 2) < c.new_reserved_segments ||
> +	if (c.new_overprovision == 0 ||

Should never be zero here? Otherwise above "100 / c.new_overprovision"
calculation will cause arithmetic exception.

Thanks,

> +		(get_sb(segment_count_main) - 2) < c.new_reserved_segments ||
>   		get_sb(segment_count_main) * blks_per_seg >
>   						get_sb(block_count)) {
>   		MSG(0, "\tError: Device size is not sufficient for F2FS volume, "
> @@ -476,6 +479,11 @@ static void rebuild_checkpoint(struct f2fs_sb_info *sbi,
>   	set_cp(overprov_segment_count, get_cp(overprov_segment_count) +
>   						get_cp(rsvd_segment_count));
>   
> +	DBG(0, "Info: Overprovision ratio = %.3lf%%\n", c.new_overprovision);
> +	DBG(0, "Info: Overprovision segments = %u (GC reserved = %u)\n",
> +					get_cp(overprov_segment_count),
> +					c.new_reserved_segments);
> +
>   	free_segment_count = get_free_segments(sbi);
>   	new_segment_count = get_newsb(segment_count_main) -
>   					get_sb(segment_count_main);

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

Thread overview: 20+ 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 ` qixiaoyu1
2022-06-14 11:49 ` [f2fs-dev] [PATCH 2/2] f2fs-tools: fix to check free space before grow qixiaoyu1
2022-06-14 11:49   ` qixiaoyu1
2022-06-19  0:10   ` [f2fs-dev] " Chao Yu
2022-06-19  0:10     ` Chao Yu
2022-06-19  0:01 ` Chao Yu [this message]
2022-06-19  0:01   ` [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-20  8:48     ` qixiaoyu1
2022-06-22 13:19     ` [f2fs-dev] " Chao Yu
2022-06-22 13:19       ` Chao Yu
2022-06-20 11:56   ` [f2fs-dev] [PATCH v3 1/2] " qixiaoyu1
2022-06-20 11:56     ` 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-20 11:56       ` qixiaoyu1
2022-06-22 13:21       ` [f2fs-dev] " Chao Yu
2022-06-22 13:21         ` Chao Yu
2022-06-22 18:31         ` [f2fs-dev] " Jaegeuk Kim
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=5627a654-d605-6840-a133-e583c804aadd@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuchao12@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.