From patchwork Mon Apr 11 13:35:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baidu Boy X-Patchwork-Id: 90596 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 71511B6F17 for ; Mon, 11 Apr 2011 23:37:06 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0BCA5280AA; Mon, 11 Apr 2011 15:37:05 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4RM06GFNdFb8; Mon, 11 Apr 2011 15:37:04 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A430F280AE; Mon, 11 Apr 2011 15:37:03 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AE9C0280AE for ; Mon, 11 Apr 2011 15:37:01 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TeWtLIoKXLXT for ; Mon, 11 Apr 2011 15:37:01 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-vw0-f44.google.com (mail-vw0-f44.google.com [209.85.212.44]) by theia.denx.de (Postfix) with ESMTPS id AAAE7280AA for ; Mon, 11 Apr 2011 15:37:00 +0200 (CEST) Received: by vws12 with SMTP id 12so4069626vws.3 for ; Mon, 11 Apr 2011 06:36:59 -0700 (PDT) Received: by 10.52.92.131 with SMTP id cm3mr6816060vdb.112.1302529019202; Mon, 11 Apr 2011 06:36:59 -0700 (PDT) Received: from LENOVOE5CA6843 ([114.221.3.248]) by mx.google.com with ESMTPS id i12sm1153941vcs.15.2011.04.11.06.36.41 (version=SSLv3 cipher=OTHER); Mon, 11 Apr 2011 06:36:56 -0700 (PDT) From: "Leo Liu" To: Date: Mon, 11 Apr 2011 21:35:54 +0800 Message-ID: <003001cbf84d$88c6c7d0$6401a8c0@LENOVOE5CA6843> MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 11 Thread-Index: Acv4TWGmCWNwoBkOS46nmz5HpBVjSw== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3664 Cc: liu.cai1@zte.com.cn Subject: [U-Boot] [PATCH] JFFS2: accelerate scanning. X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This patch make the JFFS2 scanning faster in U-Boot. 1). if we find 1KB 0xFF data from the beginning of the erase block,skip it. 2). if the 1KB data is 0xFF after the cleanmarker, ship this erase block. For the 16MB nor flash, the scanning time is changed from about 9s to 1s. Signed-off-by: Leo Liu --- fs/jffs2/jffs2_1pass.c | 31 +++++++++++++++++++++---------- fs/jffs2/jffs2_nand_1pass.c | 2 +- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c index dfb1745..f38f755 100644 --- a/fs/jffs2/jffs2_1pass.c +++ b/fs/jffs2/jffs2_1pass.c @@ -1441,7 +1441,7 @@ dump_dirents(struct b_lists *pL) } #endif -#define DEFAULT_EMPTY_SCAN_SIZE 4096 +#define DEFAULT_EMPTY_SCAN_SIZE 1024 static inline uint32_t EMPTY_SCAN_SIZE(uint32_t sector_size) { @@ -1461,7 +1461,7 @@ jffs2_1pass_build_lists(struct part_info * part) u32 counter4 = 0; u32 counterF = 0; u32 counterN = 0; - u32 buf_size = DEFAULT_EMPTY_SCAN_SIZE; + u32 buf_size = 128*1024;; char *buf; /* turn off the lcd. Refreshing the lcd adds 50% overhead to the */ @@ -1559,14 +1559,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 1KiB 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; @@ -1594,16 +1597,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; @@ -1613,6 +1614,12 @@ 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) && + (node ==(struct jffs2_unknown_node *)&buf[ofs-buf_ofs])) + break; + /* See how much more there is to read in this * eraseblock... */ @@ -1627,12 +1634,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; @@ -1650,6 +1657,8 @@ jffs2_1pass_build_lists(struct part_info * part) case JFFS2_NODETYPE_INODE: if (buf_ofs + buf_len < ofs + sizeof(struct jffs2_raw_inode)) { + buf_len = min_t(uint32_t, buf_size, sector_ofs + + part->sector_size - ofs); get_fl_mem((u32)part->offset + ofs, buf_len, buf); buf_ofs = ofs; @@ -1671,6 +1680,8 @@ jffs2_1pass_build_lists(struct part_info * part) ((struct jffs2_raw_dirent *) node)->nsize) { + buf_len = min_t(uint32_t, buf_size, sector_ofs + + part->sector_size - ofs); get_fl_mem((u32)part->offset + ofs, buf_len, buf); buf_ofs = ofs; diff --git a/fs/jffs2/jffs2_nand_1pass.c b/fs/jffs2/jffs2_nand_1pass.c index e3bc536..16bb2e9 100644 --- a/fs/jffs2/jffs2_nand_1pass.c +++ b/fs/jffs2/jffs2_nand_1pass.c @@ -833,7 +833,7 @@ jffs2_1pass_build_lists(struct part_info * part) return 0; ofs = 0; - /* Scan only 4KiB of 0xFF before declaring it's empty */ + /* Scan only 1KiB of 0xFF before declaring it's empty */ while (ofs < EMPTY_SCAN_SIZE && *(uint32_t *)(&buf[ofs]) == 0xFFFFFFFF) ofs += 4; if (ofs == EMPTY_SCAN_SIZE)