All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] ext2load: increase read speed
@ 2012-03-28 14:37 Jason Cooper
  2012-04-26  1:17 ` Eric Nelson
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Jason Cooper @ 2012-03-28 14:37 UTC (permalink / raw)
  To: u-boot

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 <u-boot@lakedaemon.net>
---
 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);
 }
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2012-07-24  4:59 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-28 14:37 [U-Boot] [PATCH] ext2load: increase read speed Jason Cooper
2012-04-26  1:17 ` Eric Nelson
2012-05-08 15:43   ` Jason Cooper
2012-05-08 15:53     ` Eric Nelson
2012-04-26 12:54 ` Thierry Reding
2012-05-08 15:48   ` Jason Cooper
2012-05-08 16:13 ` [U-Boot] [GIT PULL] ext2load speedup Jason Cooper
2012-05-21  1:35   ` [U-Boot] [GIT PULL RESEND] " Jason Cooper
2012-05-21  5:19     ` Wolfgang Denk
2012-06-01 15:41     ` Jason Cooper
2012-06-01 15:54 ` [U-Boot] [PATCH v2] ext2load: increase read speed Jason Cooper
2012-06-21 20:49   ` Wolfgang Denk
2012-07-03 16:05     ` [U-Boot] [PATCH] ext2fs: fix warning: 'blocknxt' may be used uninitialized Kim Phillips
2012-07-03 22:12       ` Andreas Bießmann
2012-07-03 22:41         ` [U-Boot] [PATCH v2] " Kim Phillips
2012-07-04  6:09           ` Thierry Reding
2012-07-06 13:31           ` Jason Cooper
2012-07-08 20:55           ` Wolfgang Denk
2012-07-23 18:56             ` Tom Rini
2012-07-24  4:59               ` Thierry Reding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.