All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 1/2] libf2fs: limit the total size up to 16T
@ 2016-02-23 13:43 Junling Zheng
  2016-02-23 13:43 ` [RFC PATCH 2/2] f2fs-tools: redefine MAX_SIT_BITMAP_SIZE Junling Zheng
  0 siblings, 1 reply; 2+ messages in thread
From: Junling Zheng @ 2016-02-23 13:43 UTC (permalink / raw)
  To: linux-f2fs-devel, jaegeuk, chao2.yu

F2FS can support 16T bytes at most. Limit the config.total_sectors
so that most parameters calculated according to it in sb/cp can be
limited correctly too.

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
---
 lib/libf2fs.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 5eb5c33..a8ad324 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -640,6 +640,11 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
 		c->total_sectors = wanted_total_sectors;
 
 	}
+	if (c->total_sectors * c->sector_size >
+		(u_int64_t)F2FS_MAX_SEGMENT * 2 * 1024 * 1024) {
+		MSG(0, "\tError: F2FS can support 16TB at most!!!\n");
+		return -1;
+	}
 	MSG(0, "Info: sector size = %u\n", c->sector_size);
 	MSG(0, "Info: total sectors = %"PRIu64" (%"PRIu64" MB)\n",
 				c->total_sectors, (c->total_sectors *
-- 
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] 2+ messages in thread

* [RFC PATCH 2/2] f2fs-tools: redefine MAX_SIT_BITMAP_SIZE
  2016-02-23 13:43 [RFC PATCH 1/2] libf2fs: limit the total size up to 16T Junling Zheng
@ 2016-02-23 13:43 ` Junling Zheng
  0 siblings, 0 replies; 2+ messages in thread
From: Junling Zheng @ 2016-02-23 13:43 UTC (permalink / raw)
  To: linux-f2fs-devel, jaegeuk, chao2.yu

During mkfs, segment_count_sit is calculated using ALIGN and
SEG_ALIGN, which are both upward. Then, in some extreme scenarios,
such as 16TB, sit_ver_bitmap_bytesize got from segment_count_sit
will exceed MAX_SIT_BITMAP_SIZE, which is calculated in a downward
method.

Unify the two calculating methods and redefine MAX_SIT_BITMAP_SIZE
to prevent sit_ver_bitmap_bytesize overflowing.

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
---
 include/f2fs_fs.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index b58aa74..3a1d2d1 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -642,7 +642,9 @@ struct f2fs_nat_block {
  * disk is 16 TB and it equals to 16 * 1024 * 1024 / 2 segments.
  */
 #define F2FS_MAX_SEGMENT       ((16 * 1024 * 1024) / 2)
-#define MAX_SIT_BITMAP_SIZE    ((F2FS_MAX_SEGMENT / SIT_ENTRY_PER_BLOCK) / 8)
+#define MAX_SIT_BITMAP_SIZE    (SEG_ALIGN(ALIGN(F2FS_MAX_SEGMENT, \
+						SIT_ENTRY_PER_BLOCK)) * \
+						config.blks_per_seg / 8)
 
 /*
  * Note that f2fs_sit_entry->vblocks has the following bit-field information.
-- 
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] 2+ messages in thread

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-23 13:43 [RFC PATCH 1/2] libf2fs: limit the total size up to 16T Junling Zheng
2016-02-23 13:43 ` [RFC PATCH 2/2] f2fs-tools: redefine MAX_SIT_BITMAP_SIZE Junling Zheng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.