Skip to contentSkip to conversation

mkfs.f2fs: check the c.overprovision with zero before using it

PATCH New Kinglong Mee 1 participant 1 message Feb 6, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mkfs.f2fs: check the c.overprovision with zero before using it

The using of c.overprovision when it equal zero as,

c.reserved_segments =
(2 * (100 / c.overprovision + 1) + 6)
* c.segs_per_sec;

may cause problem, although it doesn't happen.

---
 mkfs/f2fs_format.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
mkfs/f2fs_format.c +4 -4
index 3c13026..2e0a4e5 100644
@@ -337,10 +337,6 @@ 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) + 6)
-			* 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) ||
@@ -349,6 +345,10 @@ static int f2fs_prepare_super_block(void)
 		return -1;
 	}
 
+	c.reserved_segments =
+			(2 * (100 / c.overprovision + 1) + 6)
+			* c.segs_per_sec;
+
 	uuid_generate(sb->uuid);
 
 	utf8_to_utf16(sb->volume_name, (const char *)c.vol_label,
Signature · 6 lines
2.9.3


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