linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Yunlong Song <yunlong.song@huawei.com>
To: jaegeuk@kernel.org, cm224.lee@samsung.com, yuchao0@huawei.com,
	chao@kernel.org, sylinux@163.com, yunlong.song@huawei.com,
	miaoxie@huawei.com, zhouxiyu@huawei.com
Cc: bintian.wang@huawei.com, linux-fsdevel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] mkfs.f2fs: add option to set the value of reserved segments and overprovision segments
Date: Fri, 17 Feb 2017 20:53:06 +0800	[thread overview]
Message-ID: <1487335987-32601-2-git-send-email-yunlong.song@huawei.com> (raw)
In-Reply-To: <1487335987-32601-1-git-send-email-yunlong.song@huawei.com>

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
 include/f2fs_fs.h       |  3 +++
 lib/libf2fs.c           |  3 +++
 mkfs/f2fs_format.c      | 21 ++++++++++++++-------
 mkfs/f2fs_format_main.c | 10 +++++++++-
 4 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 97ee297..2a62660 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -304,6 +304,9 @@ struct f2fs_configuration {
 	/* sload parameters */
 	char *from_dir;
 	char *mount_point;
+
+	u_int32_t force_rsvd;
+	u_int32_t force_ovp;
 } __attribute__((packed));
 
 #ifdef CONFIG_64BIT
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 93d3da9..971fe99 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -573,6 +573,9 @@ void f2fs_init_configuration(void)
 	c.trim = 1;
 	c.ro = 0;
 	c.kd = -1;
+
+	c.force_rsvd = 0;
+	c.force_ovp = 0;
 }
 
 static int is_mounted(const char *mpt, const char *device)
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 3c13026..42a7bd5 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -337,9 +337,12 @@ static int f2fs_prepare_super_block(void)
 	if (c.overprovision == 0)
 		c.overprovision = get_best_overprovision(sb);
 
-	c.reserved_segments =
-			(2 * (100 / c.overprovision + 1) + 6)
-			* c.segs_per_sec;
+	if (c.force_rsvd)
+		c.reserved_segments = c.force_rsvd;
+	else
+		c.reserved_segments =
+				(2 * (100 / c.overprovision + 1) + 6)
+				* c.segs_per_sec;
 
 	if (c.overprovision == 0 || c.total_segments < F2FS_MIN_SEGMENTS ||
 		(c.devices[0].total_sectors *
@@ -522,13 +525,17 @@ static int f2fs_write_check_point_pack(void)
 	set_cp(cur_data_blkoff[0], 1);
 	set_cp(valid_block_count, 2);
 	set_cp(rsvd_segment_count, c.reserved_segments);
-	set_cp(overprov_segment_count, (get_sb(segment_count_main) -
-			get_cp(rsvd_segment_count)) *
-			c.overprovision / 100);
+	if (c.force_ovp)
+		set_cp(overprov_segment_count, c.force_ovp);
+	else
+		set_cp(overprov_segment_count, (get_sb(segment_count_main) -
+				get_cp(rsvd_segment_count)) *
+				c.overprovision / 100);
 	set_cp(overprov_segment_count, get_cp(overprov_segment_count) +
 			get_cp(rsvd_segment_count));
 
-	MSG(0, "Info: Overprovision ratio = %.3lf%%\n", c.overprovision);
+	if (c.force_rsvd == 0 || c.force_ovp == 0)
+		MSG(0, "Info: Overprovision ratio = %.3lf%%\n", c.overprovision);
 	MSG(0, "Info: Overprovision segments = %u (GC reserved = %u)\n",
 					get_cp(overprov_segment_count),
 					c.reserved_segments);
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index 5bb1faf..45c513b 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -39,6 +39,8 @@ static void mkfs_usage()
 	MSG(0, "  -z # of sections per zone [default:1]\n");
 	MSG(0, "  -t 0: nodiscard, 1: discard [default:1]\n");
 	MSG(0, "  -m support zoned block device [default:0]\n");
+	MSG(0, "  -r force set reserved segments\n");
+	MSG(0, "  -R force set overprovision segments\n");
 	MSG(0, "sectors: number of sectors. [default: determined by device size]\n");
 	exit(1);
 }
@@ -72,7 +74,7 @@ static void parse_feature(const char *features)
 
 static void f2fs_parse_options(int argc, char *argv[])
 {
-	static const char *option_string = "qa:c:d:e:l:mo:O:s:z:t:";
+	static const char *option_string = "qa:c:d:e:l:mo:O:s:z:t:r:R:";
 	int32_t option=0;
 
 	while ((option = getopt(argc,argv,option_string)) != EOF) {
@@ -128,6 +130,12 @@ static void f2fs_parse_options(int argc, char *argv[])
 		case 't':
 			c.trim = atoi(optarg);
 			break;
+		case 'r':
+			c.force_rsvd = atoi(optarg);
+			break;
+		case 'R':
+			c.force_ovp = atoi(optarg);
+			break;
 		default:
 			MSG(0, "\tError: Unknown option %c\n",option);
 			mkfs_usage();
-- 
1.8.5.2

  reply	other threads:[~2017-02-17 12:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17 12:53 [PATCH 0/2] Reduce the overprovision size a lot in f2fs Yunlong Song
2017-02-17 12:53 ` Yunlong Song [this message]
2017-02-17 12:53 ` [PATCH 2/2] f2fs: fix the case when there is no free segment to allocate for CURSEG_WARM_NODE Yunlong Song
2017-02-17 18:39   ` Jaegeuk Kim
2017-02-23 12:06     ` Chao Yu
2017-02-23 19:27       ` Jaegeuk Kim
2017-02-17 19:33 ` [PATCH 0/2] Reduce the overprovision size a lot in f2fs 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=1487335987-32601-2-git-send-email-yunlong.song@huawei.com \
    --to=yunlong.song@huawei.com \
    --cc=bintian.wang@huawei.com \
    --cc=chao@kernel.org \
    --cc=cm224.lee@samsung.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=sylinux@163.com \
    --cc=yuchao0@huawei.com \
    --cc=zhouxiyu@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).