Commit 436da3cd authored by u-boot@lakedaemon.net's avatar u-boot@lakedaemon.net Committed by Wolfgang Denk
Browse files

ext2load: increase read speed



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: default avatarJason Cooper <u-boot@lakedaemon.net>
Tested-by: default avatarEric Nelson <eric.nelson@boundarydevices.com>
Tested-by: default avatarThierry Reding <thierry.reding@avionic-design.de>
parent 669df7e4
...@@ -420,7 +420,6 @@ int ext2fs_read_file ...@@ -420,7 +420,6 @@ int ext2fs_read_file
if (blknr < 0) { if (blknr < 0) {
return (-1); return (-1);
} }
blknr = blknr << log2blocksize;
/* Last block. */ /* Last block. */
if (i == blockcnt - 1) { if (i == blockcnt - 1) {
...@@ -438,6 +437,29 @@ int ext2fs_read_file ...@@ -438,6 +437,29 @@ int ext2fs_read_file
blockend -= skipfirst; 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 /* If the block number is 0 this block is not stored on disk but
is zero filled instead. */ is zero filled instead. */
if (blknr) { if (blknr) {
...@@ -450,7 +472,7 @@ int ext2fs_read_file ...@@ -450,7 +472,7 @@ int ext2fs_read_file
} else { } else {
memset (buf, 0, blocksize - skipfirst); memset (buf, 0, blocksize - skipfirst);
} }
buf += blocksize - skipfirst; buf += blockend - skipfirst;
} }
return (len); return (len);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment