mkfs.f2fs: fix wrong ovp space calculation on large section

If a section consists of multiple segments, we should change the equation
to apply it on reserved space.

On 128GB,

option                 overprovision area         reserved area
-o5 -s128              9094                       6144
-o5 -s64               6179                       3072
-o5 -s1                3309                       48
-o1 -s128              27009                      26624
-o1 -s64               13831                      13312
-o1 -s1                858                        208

-s1                    858                        208
-s64   *               13831                      13312
-s128  *               27009                      26624
: * should be wrong.

After patch,

-s1    (ovp:1%)        858                        208
-s64   (ovp:4%)        6172                       3712
-s128  (ovp:6%)        8721                       5120

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Jaegeuk Kim 2015-09-23 14:59:30 -07:00
parent 6f9c275125
commit 6e2b58dcaf

View File

@ -171,7 +171,8 @@ static u_int32_t get_best_overprovision(void)
}
for (; candidate <= end; candidate += diff) {
reserved = 2 * (100 / candidate + 1) + 6;
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) {