[U-Boot] [PATCH 5/7] JFFS2: Change DEFAULT_EMPTY_SCAN_SIZE to 256 Bytes

Baidu Liu liucai.lfn at gmail.com
Sun Apr 24 05:39:29 CEST 2011


 1/ Syncs up with jffs2 in the linux kernel:
 If the first 256 Bytes is 0xff,we get the conclusion
 that the sector is empty.

Signed-off-by: Baidu Liu <liucai.lfn at gmail.com>
---
 fs/jffs2/jffs2_1pass.c      |   11 ++++++-----
 fs/jffs2/jffs2_nand_1pass.c |   13 ++++++-------
 include/jffs2/jffs2.h       |    2 ++
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
index b3d94af..62ba250 100644
--- a/fs/jffs2/jffs2_1pass.c
+++ b/fs/jffs2/jffs2_1pass.c
@@ -801,7 +801,7 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char *dest)
 #endif
 				default:
 					/* unknown */
-					putLabeledWord("UNKOWN COMPRESSION METHOD = ", jNode->compr);
+					putLabeledWord("UNKNOWN COMPRESSION METHOD = ", jNode->compr);
 					put_fl_mem(jNode, pL->readbuf);
 					return -1;
 					break;
@@ -1442,8 +1442,6 @@ dump_dirents(struct b_lists *pL)
 }
 #endif
 
-#define DEFAULT_EMPTY_SCAN_SIZE	4096
-
 static inline uint32_t EMPTY_SCAN_SIZE(uint32_t sector_size)
 {
 	if (sector_size < DEFAULT_EMPTY_SCAN_SIZE)
@@ -1560,14 +1558,17 @@ jffs2_1pass_build_lists(struct part_info * part)
 		/* We temporarily use 'ofs' as a pointer into the buffer/jeb */
 		ofs = 0;
 
-		/* Scan only 4KiB of 0xFF before declaring it's empty */
+		/* Scan only DEFAULT_EMPTY_SCAN_SIZE of 0xFF before declaring it's empty */
 		while (ofs < EMPTY_SCAN_SIZE(part->sector_size) &&
 				*(uint32_t *)(&buf[ofs]) == 0xFFFFFFFF)
 			ofs += 4;
 
-		if (ofs == EMPTY_SCAN_SIZE(part->sector_size))
+		if (ofs == EMPTY_SCAN_SIZE(part->sector_size)) {
+			printf("Block at 0x%08x is empty (erased)\n", sector_ofs);
 			continue;
+		}
 
+		/* Now ofs is a complete physical flash offset as it always was... */
 		ofs += sector_ofs;
 		prevofs = ofs - 1;
 
diff --git a/fs/jffs2/jffs2_nand_1pass.c b/fs/jffs2/jffs2_nand_1pass.c
index 885fa3c..5afe779 100644
--- a/fs/jffs2/jffs2_nand_1pass.c
+++ b/fs/jffs2/jffs2_nand_1pass.c
@@ -351,7 +351,7 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 ino, char *dest,
 #endif
 			default:
 				/* unknown */
-				putLabeledWord("UNKOWN COMPRESSION METHOD = ", inode->compr);
+				putLabeledWord("UNKNOWN COMPRESSION METHOD = ", inode->compr);
 				return -1;
 			}
 		}
@@ -789,7 +789,6 @@ jffs2_fill_scan_buf(nand_info_t *nand, unsigned char *buf,
 	return 0;
 }
 
-#define	EMPTY_SCAN_SIZE	1024
 static u32
 jffs2_1pass_build_lists(struct part_info * part)
 {
@@ -828,17 +827,17 @@ jffs2_1pass_build_lists(struct part_info * part)
 		if (nand_block_isbad(nand, offset))
 			continue;
 
-		if (jffs2_fill_scan_buf(nand, buf, offset, EMPTY_SCAN_SIZE))
+		if (jffs2_fill_scan_buf(nand, buf, offset, DEFAULT_EMPTY_SCAN_SIZE))
 			return 0;
 
 		ofs = 0;
-		/* Scan only 4KiB of 0xFF before declaring it's empty */
-		while (ofs < EMPTY_SCAN_SIZE && *(uint32_t *)(&buf[ofs]) == 0xFFFFFFFF)
+		/* Scan only DEFAULT_EMPTY_SCAN_SIZE of 0xFF before declaring it's empty */
+		while (ofs < DEFAULT_EMPTY_SCAN_SIZE && *(uint32_t *)(&buf[ofs]) == 0xFFFFFFFF)
 			ofs += 4;
-		if (ofs == EMPTY_SCAN_SIZE)
+		if (ofs == DEFAULT_EMPTY_SCAN_SIZE)
 			continue;
 
-		if (jffs2_fill_scan_buf(nand, buf + EMPTY_SCAN_SIZE, offset + EMPTY_SCAN_SIZE, sectorsize - EMPTY_SCAN_SIZE))
+		if (jffs2_fill_scan_buf(nand, buf + DEFAULT_EMPTY_SCAN_SIZE, offset + DEFAULT_EMPTY_SCAN_SIZE, sectorsize - DEFAULT_EMPTY_SCAN_SIZE))
 			return 0;
 		offset += ofs;
 
diff --git a/include/jffs2/jffs2.h b/include/jffs2/jffs2.h
index 5b006c0..9fb89b3 100644
--- a/include/jffs2/jffs2.h
+++ b/include/jffs2/jffs2.h
@@ -51,6 +51,8 @@ CONFIG_JFFS2_SUMMARY is enabled.
 #endif
 #endif
 
+#define DEFAULT_EMPTY_SCAN_SIZE	256
+
 #define JFFS2_SUPER_MAGIC 0x72b6
 
 /* Values we may expect to find in the 'magic' field */
-- 
1.7.3.1.msysgit.0



More information about the U-Boot mailing list