linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v2] mkfs.f2fs: recalculate sit_segments by max_sit_bitmap_size
@ 2016-02-23  3:46 Junling Zheng
  2016-02-23  5:28 ` Chao Yu
  0 siblings, 1 reply; 5+ messages in thread
From: Junling Zheng @ 2016-02-23  3:46 UTC (permalink / raw)
  To: linux-f2fs-devel, jaegeuk

In most cases, sit_bitmap_size is smaller than MAX_SIT_BITMAP_SIZE.

However, in some extreme scenarios, such as 16TB, sit_bitmap_size
could be larger than MAX_SIT_BITMAP_SIZE.

In this case, we should recalculate the sit_segments through
max_sit_bitmap_size to prevent sit_ver_bitmap_bytesize got from
segment_count_sit in f2fs_write_check_point_pack() being over
MAX_SIT_BITMAP_SIZE.

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
---
 mkfs/f2fs_format.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 645c2aa..3a050e0 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -191,6 +191,22 @@ static int f2fs_prepare_super_block(void)
 
 	sit_segments = SEG_ALIGN(blocks_for_sit);
 
+	/*
+	 * In most cases, sit_bitmap_size is smaller than MAX_SIT_BITMAP_SIZE.
+	 * However, in an extreme scenario(16TB), sit_bitmap_size could be larger
+	 * than MAX_SIT_BITMAP_SIZE. Thus, we should recalculate the sit_segments
+	 * to prevent sit_ver_bitmap_bytesize got from segment_count_sit in
+	 * f2fs_write_check_point_pack() being over MAX_SIT_BITMAP_SIZE.
+	 */
+	sit_bitmap_size = (sit_segments << log_blks_per_seg) / 8;
+
+	if (sit_bitmap_size > MAX_SIT_BITMAP_SIZE) {
+		max_sit_bitmap_size = MAX_SIT_BITMAP_SIZE;
+		sit_segments = max_sit_bitmap_size * 8 >> log_blks_per_seg;
+		blocks_for_sit = sit_segments << log_blks_per_seg;
+	} else
+		max_sit_bitmap_size = sit_bitmap_size;
+
 	set_sb(segment_count_sit, sit_segments * 2);
 
 	set_sb(nat_blkaddr, get_sb(sit_blkaddr) + get_sb(segment_count_sit) *
@@ -208,13 +224,6 @@ static int f2fs_prepare_super_block(void)
 	 * This number resizes NAT bitmap area in a CP page.
 	 * So the threshold is determined not to overflow one CP page
 	 */
-	sit_bitmap_size = ((get_sb(segment_count_sit) / 2) <<
-				log_blks_per_seg) / 8;
-
-	if (sit_bitmap_size > MAX_SIT_BITMAP_SIZE)
-		max_sit_bitmap_size = MAX_SIT_BITMAP_SIZE;
-	else
-		max_sit_bitmap_size = sit_bitmap_size;
 
 	/*
 	 * It should be reserved minimum 1 segment for nat.
-- 
1.9.1


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-02-23 12:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-23  3:46 [RFC PATCH v2] mkfs.f2fs: recalculate sit_segments by max_sit_bitmap_size Junling Zheng
2016-02-23  5:28 ` Chao Yu
2016-02-23  7:19   ` Junling Zheng
2016-02-23  9:46     ` Chao Yu
2016-02-23 12:04       ` Junling Zheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).