[U-Boot] [PATCH 6/7] JFFS2: scanning performance improvement

Baidu Liu liucai.lfn at gmail.com
Sun Apr 24 05:40:04 CEST 2011


 1/ Sync with kernel.
 If the 256-(struct jffs2_unknown_node *) bytes are
 0xff after the cleanmarker. We get the conclusion that
 the sector is empty.

Signed-off-by: Baidu Liu <liucai.lfn at gmail.com>
---
 fs/jffs2/jffs2_1pass.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
index 62ba250..bbfab2c 100644
--- a/fs/jffs2/jffs2_1pass.c
+++ b/fs/jffs2/jffs2_1pass.c
@@ -1596,16 +1596,14 @@ jffs2_1pass_build_lists(struct part_info * part)
 
 			if (*(uint32_t *)(&buf[ofs-buf_ofs]) == 0xffffffff) {
 				uint32_t inbuf_ofs;
-				uint32_t empty_start, scan_end;
+				uint32_t empty_start;
 
 				empty_start = ofs;
 				ofs += 4;
-				scan_end = min_t(uint32_t, EMPTY_SCAN_SIZE(
-							part->sector_size)/8,
-							buf_len);
+
 			more_empty:
 				inbuf_ofs = ofs - buf_ofs;
-				while (inbuf_ofs < scan_end) {
+				while (inbuf_ofs < buf_len) {
 					if (*(uint32_t *)(&buf[inbuf_ofs]) !=
 							0xffffffff)
 						goto scan_more;
@@ -1615,6 +1613,15 @@ jffs2_1pass_build_lists(struct part_info * part)
 				}
 				/* Ran off end. */
 
+				/* If we're only checking the beginning of a block with a cleanmarker,
+				   bail now */
+				if((buf_ofs == sector_ofs) && 
+				    (empty_start == sector_ofs +sizeof(struct jffs2_unknown_node))) {  
+				    printf("%d bytes at start of block seems clean... assuming all clean\n",
+						EMPTY_SCAN_SIZE(part->sector_size));
+				    break;
+				}
+
 				/* See how much more there is to read in this
 				 * eraseblock...
 				 */
@@ -1629,12 +1636,12 @@ jffs2_1pass_build_lists(struct part_info * part)
 					 */
 					break;
 				}
-				scan_end = buf_len;
 				get_fl_mem((u32)part->offset + ofs, buf_len,
 					   buf);
 				buf_ofs = ofs;
 				goto more_empty;
 			}
+			
 			if (node->magic != JFFS2_MAGIC_BITMASK ||
 					!hdr_crc(node)) {
 				ofs += 4;
-- 
1.7.3.1.msysgit.0



More information about the U-Boot mailing list