* [PATCH 2/3] mkfs.f2fs: set overprovision size more precisely
2015-08-11 1:23 [PATCH 1/3] mkfs.f2fs: fix wrong documentation Jaegeuk Kim
@ 2015-08-11 1:23 ` Jaegeuk Kim
2015-08-11 1:23 ` [PATCH 3/3] mkfs.f2fs: don't need to limit MIN_VOLUME SIZE Jaegeuk Kim
1 sibling, 0 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2015-08-11 1:23 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim
This patch introduces to set the default overprovision space according to the
partition size in order to provide more space.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
lib/libf2fs.c | 4 ++--
mkfs/f2fs_format.c | 40 ++++++++++++++++++++++++++++++++++++++++
mkfs/f2fs_format_main.c | 5 -----
3 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 7fd2550..e8f4d47 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -353,8 +353,8 @@ void f2fs_init_configuration(struct f2fs_configuration *c)
c->blks_per_seg = DEFAULT_BLOCKS_PER_SEGMENT;
/* calculated by overprovision ratio */
- c->reserved_segments = 48;
- c->overprovision = 5;
+ c->reserved_segments = 0;
+ c->overprovision = 0;
c->segs_per_sec = 1;
c->secs_per_zone = 1;
c->segs_per_zone = 1;
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index f879bca..21e74fe 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -155,6 +155,33 @@ static void configure_extension_list(void)
free(config.extension_list);
}
+static u_int32_t get_best_overprovision(void)
+{
+ u_int32_t reserved, ovp, candidate, end, diff, space;
+ u_int32_t max_ovp = 0, max_space = 0;
+
+ if (get_sb(segment_count_main) < 256) {
+ candidate = 10;
+ end = 95;
+ diff = 5;
+ } else {
+ candidate = 1;
+ end = 10;
+ diff = 1;
+ }
+
+ for (; candidate <= end; candidate += diff) {
+ reserved = 2 * (100 / candidate + 1) + 6;
+ ovp = (get_sb(segment_count_main) - reserved) * candidate / 100;
+ space = get_sb(segment_count_main) - reserved - ovp;
+ if (max_space < space) {
+ max_space = space;
+ max_ovp = candidate;
+ }
+ }
+ return max_ovp;
+}
+
static int f2fs_prepare_super_block(void)
{
u_int32_t blk_size_bytes;
@@ -310,6 +337,14 @@ static int f2fs_prepare_super_block(void)
set_sb(segment_count_main, get_sb(section_count) * config.segs_per_sec);
+ /* Let's determine the best reserved and overprovisioned space */
+ if (config.overprovision == 0)
+ config.overprovision = get_best_overprovision();
+
+ config.reserved_segments =
+ (2 * (100 / config.overprovision + 1) + 6)
+ * config.segs_per_sec;
+
if ((get_sb(segment_count_main) - 2) <
config.reserved_segments) {
MSG(1, "\tError: Device size is not sufficient for F2FS volume,\
@@ -497,6 +532,11 @@ static int f2fs_write_check_point_pack(void)
set_cp(overprov_segment_count, get_cp(overprov_segment_count) +
get_cp(rsvd_segment_count));
+ MSG(0, "Info: Overprovision ratio = %u%%\n", config.overprovision);
+ MSG(0, "Info: Overprovision segments = %u (GC reserved = %u)\n",
+ get_cp(overprov_segment_count),
+ config.reserved_segments);
+
/* main segments - reserved segments - (node + data segments) */
set_cp(free_segment_count, get_sb(segment_count_main) - 6);
set_cp(user_block_count, ((get_cp(free_segment_count) + 6 -
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index 5a9e7e2..fc612d8 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -56,7 +56,6 @@ static void f2fs_show_info()
if (config.vol_label)
MSG(0, "Info: Label = %s\n", config.vol_label);
- MSG(0, "Info: Overprovision ratio = %u%%\n", config.overprovision);
MSG(0, "Info: Segments per section = %d\n", config.segs_per_sec);
MSG(0, "Info: Sections per zone = %d\n", config.secs_per_zone);
MSG(0, "Info: Trim is %s\n", config.trim ? "enabled": "disabled");
@@ -134,10 +133,6 @@ static void f2fs_parse_options(int argc, char *argv[])
config.total_sectors,
config.total_sectors * 512);
}
-
- config.reserved_segments =
- (2 * (100 / config.overprovision + 1) + 6)
- * config.segs_per_sec;
config.segs_per_zone = config.segs_per_sec * config.secs_per_zone;
}
--
2.1.1
------------------------------------------------------------------------------
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] mkfs.f2fs: don't need to limit MIN_VOLUME SIZE
2015-08-11 1:23 [PATCH 1/3] mkfs.f2fs: fix wrong documentation Jaegeuk Kim
2015-08-11 1:23 ` [PATCH 2/3] mkfs.f2fs: set overprovision size more precisely Jaegeuk Kim
@ 2015-08-11 1:23 ` Jaegeuk Kim
1 sibling, 0 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2015-08-11 1:23 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim
The minimum volume size is determined while preparing superblock.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
include/f2fs_fs.h | 1 -
lib/libf2fs.c | 7 -------
2 files changed, 8 deletions(-)
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 59cc0d1..38a774c 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -209,7 +209,6 @@ static inline uint64_t bswap_64(uint64_t val)
#define CHECKSUM_OFFSET 4092
/* for mkfs */
-#define F2FS_MIN_VOLUME_SIZE 104857600
#define F2FS_NUMBER_OF_CHECKPOINT_PACK 2
#define DEFAULT_SECTOR_SIZE 512
#define DEFAULT_SECTORS_PER_BLOCK 8
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index e8f4d47..83d1296 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -499,13 +499,6 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
MSG(0, "Info: sector size = %u\n", c->sector_size);
MSG(0, "Info: total sectors = %"PRIu64" (%"PRIu64" MB)\n",
c->total_sectors, c->total_sectors >> 11);
- if (c->total_sectors <
- (F2FS_MIN_VOLUME_SIZE / c->sector_size)) {
- MSG(0, "Error: Min volume size supported is %d\n",
- F2FS_MIN_VOLUME_SIZE);
- return -1;
- }
-
return 0;
}
--
2.1.1
------------------------------------------------------------------------------
^ permalink raw reply related [flat|nested] 3+ messages in thread