Skip to contentSkip to conversation

mkfs.f2fs: not allow to format too small sized partition

PATCH In review Jaegeuk Kim 2 participants 2 messages May 24, 2018 – May 25, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mkfs.f2fs: not allow to format too small sized partition

For example, if we want to format 40MB image, it'll give 12 segments for main area. And, it assigns 6 for current segments, 11 for ovp segments, and 10 for reserved segments. So, we have 5 free segments, which we can't handle:

 # of free segments < # of reserved segments.
---
 mkfs/f2fs_format.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
mkfs/f2fs_format.c +6 -5
index 0a99a77..3ab5236 100644
@@ -408,18 +408,19 @@ static int f2fs_prepare_super_block(void)
 	if (c.overprovision == 0)
 		c.overprovision = get_best_overprovision(sb);
 
+	c.reserved_segments =
+			(2 * (100 / c.overprovision + 1) + NR_CURSEG_TYPE)
+			* c.segs_per_sec;
+
 	if (c.overprovision == 0 || c.total_segments < F2FS_MIN_SEGMENTS ||
 		(c.devices[0].total_sectors *
 			c.sector_size < zone_align_start_offset) ||
-		(get_sb(segment_count_main) - 2) < c.reserved_segments) {
+		(get_sb(segment_count_main) - NR_CURSEG_TYPE) <
+						c.reserved_segments) {
 		MSG(0, "\tError: Device size is not sufficient for F2FS volume\n");
 		return -1;
 	}
 
-	c.reserved_segments =
-			(2 * (100 / c.overprovision + 1) + 6)
-			* c.segs_per_sec;
-
 	uuid_generate(sb->uuid);
 
 	/* precompute checksum seed for metadata */
Signature · 6 lines
2.17.0.441.gb46fe60e1d-goog


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jaegeuk Kim

For example, if we want to format 40MB image, it'll give 12 segments for main area. And, it assigns 6 for current segments, 11 for ovp segments, and 10 for reserved segments. So, we have 5 free segments, which we can't handle:

 # of free segments < # of reserved segments.

Thanks,

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot