From dc5fc5d733453caf28b1e429b89d997a6a41a3a5 Mon Sep 17 00:00:00 2001 From: zhangxirui Date: Thu, 1 Aug 2024 03:18:22 -0600 Subject: [PATCH] f2fs-tools: reduce overprov_segment_count set times If overprov_segment_count < rsvd_segment_count will set_cp(overprov_segment_count) twice, reduce it. Signed-off-by: zhangxirui Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim --- mkfs/f2fs_format.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index b8316f99..247a8367 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -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. @@ -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)) {