Skip to content

Commit

Permalink
f2fs-tools: reduce overprov_segment_count set times
Browse files Browse the repository at this point in the history
If overprov_segment_count < rsvd_segment_count will
set_cp(overprov_segment_count) twice, reduce it.

Signed-off-by: zhangxirui <[email protected]>
Reviewed-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
zhangxirui authored and Jaegeuk Kim committed Aug 13, 2024
1 parent 3aefe2d commit dc5fc5d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions mkfs/f2fs_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,6 @@ static int f2fs_write_check_point_pack(void)
get_cp(rsvd_segment_count)) *
c.overprovision / 100);

if (!(c.conf_reserved_sections) &&
get_cp(overprov_segment_count) < get_cp(rsvd_segment_count))
set_cp(overprov_segment_count, get_cp(rsvd_segment_count));

/*
* If conf_reserved_sections has a non zero value, overprov_segment_count
* is set to overprov_segment_count + rsvd_segment_count.
Expand All @@ -788,8 +784,11 @@ static int f2fs_write_check_point_pack(void)
set_cp(overprov_segment_count, get_cp(overprov_segment_count) +
get_cp(rsvd_segment_count));
} else {
set_cp(overprov_segment_count, get_cp(overprov_segment_count) +
overprovision_segment_buffer(sb));
/*
* overprov_segment_count must bigger than rsvd_segment_count.
*/
set_cp(overprov_segment_count, max(get_cp(rsvd_segment_count),
get_cp(overprov_segment_count)) + overprovision_segment_buffer(sb));
}

if (f2fs_get_usable_segments(sb) <= get_cp(overprov_segment_count)) {
Expand Down

0 comments on commit dc5fc5d

Please sign in to comment.