From patchwork Wed Mar 28 14:37:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: u-boot@lakedaemon.net X-Patchwork-Id: 149244 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 2B91DB6FD1 for ; Thu, 29 Mar 2012 01:37:44 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 61B0328317; Wed, 28 Mar 2012 16:37:39 +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 sxNIgugaNkK0; Wed, 28 Mar 2012 16:37:39 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D92722830D; Wed, 28 Mar 2012 16:37:37 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 974762830D for ; Wed, 28 Mar 2012 16:37:34 +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 i-jEorzKK1kb for ; Wed, 28 Mar 2012 16:37:33 +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 mho-02-ewr.mailhop.org (mho-02-ewr.mailhop.org [204.13.248.72]) by theia.denx.de (Postfix) with ESMTPS id 32EF328308 for ; Wed, 28 Mar 2012 16:37:31 +0200 (CEST) Received: from pool-108-39-66-94.nrflva.fios.verizon.net ([108.39.66.94] helo=titan) by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1SCu05-000EAJ-Ee; Wed, 28 Mar 2012 14:37:25 +0000 Received: from triton.lakedaemon.net (triton.lakedaemon.net [10.16.5.29]) by titan (Postfix) with ESMTP id 9881732164E; Wed, 28 Mar 2012 10:37:22 -0400 (EDT) X-Mail-Handler: MailHop Outbound by DynDNS X-Originating-IP: 108.39.66.94 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/mailhop/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX18TS4v0qgoaNwhuF8rKj9D2j6WBGNpA6N8= From: Jason Cooper To: wd@denx.de, reinhard.arlt@esd-electronics.com Date: Wed, 28 Mar 2012 14:37:11 +0000 Message-Id: <1332945431-12441-1-git-send-email-u-boot@lakedaemon.net> X-Mailer: git-send-email 1.7.3.4 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH] ext2load: increase read speed X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This patch dramatically drops the amount of time u-boot needs to read a file from an ext2 partition. On a typical 2 to 5 MB file (kernels and initrds) it goes from tens of seconds to a couple seconds. All we are doing here is grouping contiguous blocks into one read. Boot tested on Globalscale Technologies Dreamplug (Kirkwood ARM SoC) with three different files. sha1sums were calculated in Linux userspace, and then confirmed after ext2load. Signed-off-by: Jason Cooper Tested-by: Eric Nelson Tested-by: Thierry Reding --- fs/ext2/ext2fs.c | 26 ++++++++++++++++++++++++-- 1 files changed, 24 insertions(+), 2 deletions(-) diff --git a/fs/ext2/ext2fs.c b/fs/ext2/ext2fs.c index e119e13..8531db5 100644 --- a/fs/ext2/ext2fs.c +++ b/fs/ext2/ext2fs.c @@ -414,7 +414,6 @@ int ext2fs_read_file if (blknr < 0) { return (-1); } - blknr = blknr << log2blocksize; /* Last block. */ if (i == blockcnt - 1) { @@ -432,6 +431,29 @@ int ext2fs_read_file blockend -= skipfirst; } + /* grab middle blocks in one go */ + if (i != pos / blocksize && i != blockcnt - 1 && blockcnt > 3) { + int oldblk = blknr; + int blocknxt; + while (i < blockcnt - 1) { + blocknxt = ext2fs_read_block(node, i + 1); + if (blocknxt == (oldblk + 1)) { + oldblk = blocknxt; + i++; + } else { + blocknxt = ext2fs_read_block(node, i); + break; + } + } + + if (oldblk == blknr) + blockend = blocksize; + else + blockend = (1 + blocknxt - blknr) * blocksize; + } + + blknr = blknr << log2blocksize; + /* If the block number is 0 this block is not stored on disk but is zero filled instead. */ if (blknr) { @@ -444,7 +466,7 @@ int ext2fs_read_file } else { memset (buf, 0, blocksize - skipfirst); } - buf += blocksize - skipfirst; + buf += blockend - skipfirst; } return (len); }