linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 1/2] resize.f2fs: add option to manually specify new overprovision
@ 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-19  0:01 ` [f2fs-dev] [PATCH 1/2] resize.f2fs: add option to manually specify new overprovision Chao Yu
  0 siblings, 2 replies; 10+ messages in thread
From: qixiaoyu1 @ 2022-06-14 11:49 UTC (permalink / raw)
  To: jaegeuk; +Cc: liuchao12, linux-kernel, linux-f2fs-devel

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");
+	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 ||
+		(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);
-- 
2.36.1



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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-06-22 18:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).