diff mbox series

[f2fs-dev] f2fs-tools: reduce overprov_segment_count set times

Message ID 20240801091822.3853678-1-xirui.zhang@vivo.com (mailing list archive)
State New
Headers show
Series [f2fs-dev] f2fs-tools: reduce overprov_segment_count set times | expand

Commit Message

zhangxirui Aug. 1, 2024, 9:18 a.m. UTC
If overprov_segment_count < rsvd_segment_count will
set_cp(overprov_segment_count) twice, reduce it.

Signed-off-by: zhangxirui <xirui.zhang@vivo.com>
---
 mkfs/f2fs_format.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Chao Yu Aug. 13, 2024, 3:55 a.m. UTC | #1
On 2024/8/1 17:18, zhangxirui wrote:
> If overprov_segment_count < rsvd_segment_count will
> set_cp(overprov_segment_count) twice, reduce it.
> 
> Signed-off-by: zhangxirui <xirui.zhang@vivo.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,
diff mbox series

Patch

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index e26a513..794ced5 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -764,10 +764,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.
@@ -787,8 +783,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)) {