mkfs.f2fs: fix wrong documentation
PATCH 1/3 mkfs.f2fs: fix wrong documentation
The -s should be the number of segments per a section.
Reported-by Marc Lehmann <[email protected]>
Signed-off-by Jaegeuk Kim <[email protected]>
--- man/mkfs.f2fs.8 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
man/mkfs.f2fs.8 +4 -4
@@ -21,7 +21,7 @@ mkfs.f2fs \- create an F2FS file system ] [ .B \-s -.I log-based-#-of-segments-per-section +.I #-of-segments-per-section ] [ .B \-z
@@ -60,10 +60,10 @@ Specify the volume label to the partition mounted as F2FS. Specify the percentage over the volume size for overprovision area. This area is hidden to users, and utilized by F2FS cleaner. The default percentage is 5%. .TP -.BI \-s " log-based-#-of-segments-per-section" -Specify the log-based number of segments per section. A section consists of +.BI \-s " #-of-segments-per-section" +Specify the number of segments per section. A section consists of multiple consecutive segments, and is the unit of garbage collection. -The default number is 0, which means one segment is assigned to a section. +The default number is 1, which means one segment is assigned to a section. .TP .BI \-z " #-of-sections-per-zone" Specify the number of sections per zone. A zone consists of multiple sections.
Signature · 4 lines
2.1.1 ------------------------------------------------------------------------------
PATCH 2/3 mkfs.f2fs: set overprovision size more precisely
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 <[email protected]>
--- lib/libf2fs.c | 4 ++-- mkfs/f2fs_format.c | 40 ++++++++++++++++++++++++++++++++++++++++ mkfs/f2fs_format_main.c | 5 ----- 3 files changed, 42 insertions(+), 7 deletions(-)
lib/libf2fs.c +2 -2
@@ -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 ;
mkfs/f2fs_format.c +40 -0
@@ -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 -
mkfs/f2fs_format_main.c +0 -5
@@ -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; }
Signature · 4 lines
2.1.1 ------------------------------------------------------------------------------
PATCH 3/3 mkfs.f2fs: don't need to limit MIN_VOLUME SIZE
In reply to Jaegeuk KimThe minimum volume size is determined while preparing superblock.
Signed-off-by Jaegeuk Kim <[email protected]>
--- include/f2fs_fs.h | 1 - lib/libf2fs.c | 7 ------- 2 files changed, 8 deletions(-)
include/f2fs_fs.h +0 -1
@@ -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
lib/libf2fs.c +0 -7
@@ -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 ; }
Signature · 4 lines
2.1.1 ------------------------------------------------------------------------------