mkfs.f2fs: export get_best_overprovision

This patch exports get_best_overprovision() function.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Jaegeuk Kim 2015-12-08 17:30:38 -08:00
parent c605c5eb4c
commit c8ce2bf7b1
2 changed files with 29 additions and 29 deletions

View File

@ -886,4 +886,32 @@ extern struct f2fs_configuration config;
#define ZONE_ALIGN(blks) ALIGN(blks, config.blks_per_seg * \ #define ZONE_ALIGN(blks) ALIGN(blks, config.blks_per_seg * \
config.segs_per_zone) config.segs_per_zone)
static inline double get_best_overprovision(struct f2fs_super_block *sb)
{
double reserved, ovp, candidate, end, diff, space;
double max_ovp = 0, max_space = 0;
if (get_sb(segment_count_main) < 256) {
candidate = 10;
end = 95;
diff = 5;
} else {
candidate = 0.01;
end = 10;
diff = 0.01;
}
for (; candidate <= end; candidate += diff) {
reserved = (2 * (100 / candidate + 1) + 6) *
get_sb(segs_per_sec);
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;
}
#endif /*__F2FS_FS_H */ #endif /*__F2FS_FS_H */

View File

@ -117,34 +117,6 @@ next:
free(config.extension_list); free(config.extension_list);
} }
static double get_best_overprovision(void)
{
double reserved, ovp, candidate, end, diff, space;
double max_ovp = 0, max_space = 0;
if (get_sb(segment_count_main) < 256) {
candidate = 10;
end = 95;
diff = 5;
} else {
candidate = 0.01;
end = 10;
diff = 0.01;
}
for (; candidate <= end; candidate += diff) {
reserved = (2 * (100 / candidate + 1) + 6) *
get_sb(segs_per_sec);
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) static int f2fs_prepare_super_block(void)
{ {
u_int32_t blk_size_bytes; u_int32_t blk_size_bytes;
@ -302,7 +274,7 @@ static int f2fs_prepare_super_block(void)
/* Let's determine the best reserved and overprovisioned space */ /* Let's determine the best reserved and overprovisioned space */
if (config.overprovision == 0) if (config.overprovision == 0)
config.overprovision = get_best_overprovision(); config.overprovision = get_best_overprovision(sb);
config.reserved_segments = config.reserved_segments =
(2 * (100 / config.overprovision + 1) + 6) (2 * (100 / config.overprovision + 1) + 6)