Skip to contentSkip to conversation

f2fs-tools: add the max chunk size limit in sparse image

PATCH In review Gao Ming 3 participants 3 messages Oct 15, 2018 – Oct 30, 2018 Library code

lore
Share & tools
lore

Gao Ming

author
#0 lore raw

PATCH 1/1 f2fs-tools: add the max chunk size limit in sparse image

Malloc Failure occurs in 32bit Windows, when using fastboot.exe flash the
f2fs sparse image filling with up to 2G chunk size.

---
 lib/libf2fs_io.c | 7 +++++++
 1 file changed, 7 insertions(+)
lib/libf2fs_io.c +7 -0
index 76d283d..47917ab 100644
@@ -311,6 +311,7 @@ int f2fs_init_sparse_file(void)
 #endif
 }
 
+#define MAX_CHUNK_SIZE (1 * 1024 * 1024 * 1024ULL)
 int f2fs_finalize_device(void)
 {
 	int i;
@@ -337,6 +338,12 @@ int f2fs_finalize_device(void)
 				chunk_start = -1;
 			} else if (blocks[j] && chunk_start == -1) {
 				chunk_start = j;
+			} else if (blocks[j] && (chunk_start != -1) &&
+				 (j + 1 - chunk_start >=
+					(MAX_CHUNK_SIZE / F2FS_BLKSIZE))) {
+				ret = sparse_merge_blocks(chunk_start,
+							  j + 1 - chunk_start);
+				chunk_start = -1;
 			}
 			ASSERT(!ret);
 		}
Signature · 1 line
2.8.1
#2 lore raw
In reply to Gao Ming

Hi, Jaegeuk, Chao, Ming

Quoted 13 lines · Gao Ming

Malloc Failure occurs in 32bit Windows, when using fastboot.exe flash the
f2fs sparse image filling with up to 2G chunk size.

---
 lib/libf2fs_io.c | 7 +++++++
 1 file changed, 7 insertions(+)
lib/libf2fs_io.c +0 -0
index 76d283d..47917ab 100644

lib/libf2fs_io.c int f2fs_init_sparse_file(void) · line 314

Quoted 4 lines
lib/libf2fs_io.c +1 -0
@@ -311,6 +311,7 @@ int f2fs_init_sparse_file(void)
 #endif
 }
 
+#define MAX_CHUNK_SIZE (1 * 1024 * 1024 * 1024ULL)

Should we introduce an option for fsck.f2fs to get the MAX_CHUNK_SIZE ?

Thanks

Quoted 17 lines
lib/libf2fs_io.c +6 -0
 int f2fs_finalize_device(void)
 {
 	int i;
@@ -337,6 +338,12 @@ int f2fs_finalize_device(void)
 				chunk_start = -1;
 			} else if (blocks[j] && chunk_start == -1) {
 				chunk_start = j;
+			} else if (blocks[j] && (chunk_start != -1) &&
+				 (j + 1 - chunk_start >=
+					(MAX_CHUNK_SIZE / F2FS_BLKSIZE))) {
+				ret = sparse_merge_blocks(chunk_start,
+							  j + 1 - chunk_start);
+				chunk_start = -1;
 			}
 			ASSERT(!ret);
 		}