]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/meta-ti-glsdk.git/blob - recipes-bsp/u-boot/u-boot/2011.09git/0006-ext2load-increase-read-speed.patch
recipes-kernel: Add GLSDK specific kernel tree for omap-a15
[glsdk/meta-ti-glsdk.git] / recipes-bsp / u-boot / u-boot / 2011.09git / 0006-ext2load-increase-read-speed.patch
1 From f6894e8bc193d225267e4d58a633354e9937c93d Mon Sep 17 00:00:00 2001
2 From: "u-boot@lakedaemon.net" <u-boot@lakedaemon.net>
3 Date: Wed, 28 Mar 2012 04:37:11 +0000
4 Subject: [PATCH 06/10] ext2load: increase read speed
6 This patch dramatically drops the amount of time u-boot needs to read a
7 file from an ext2 partition.  On a typical 2 to 5 MB file (kernels and
8 initrds) it goes from tens of seconds to a couple seconds.
10 All we are doing here is grouping contiguous blocks into one read.
12 Boot tested on Globalscale Technologies Dreamplug (Kirkwood ARM SoC)
13 with three different files.  sha1sums were calculated in Linux
14 userspace, and then confirmed after ext2load.
16 Signed-off-by: Jason Cooper <u-boot@lakedaemon.net>
17 ---
18  fs/ext2/ext2fs.c |   26 ++++++++++++++++++++++++--
19  1 file changed, 24 insertions(+), 2 deletions(-)
21 diff --git a/fs/ext2/ext2fs.c b/fs/ext2/ext2fs.c
22 index e119e13..8531db5 100644
23 --- a/fs/ext2/ext2fs.c
24 +++ b/fs/ext2/ext2fs.c
25 @@ -414,7 +414,6 @@ int ext2fs_read_file
26                 if (blknr < 0) {
27                         return (-1);
28                 }
29 -               blknr = blknr << log2blocksize;
30  
31                 /* Last block.  */
32                 if (i == blockcnt - 1) {
33 @@ -432,6 +431,29 @@ int ext2fs_read_file
34                         blockend -= skipfirst;
35                 }
36  
37 +               /* grab middle blocks in one go */
38 +               if (i != pos / blocksize && i != blockcnt - 1 && blockcnt > 3) {
39 +                       int oldblk = blknr;
40 +                       int blocknxt;
41 +                       while (i < blockcnt - 1) {
42 +                               blocknxt = ext2fs_read_block(node, i + 1);
43 +                               if (blocknxt == (oldblk + 1)) {
44 +                                       oldblk = blocknxt;
45 +                                       i++;
46 +                               } else {
47 +                                       blocknxt = ext2fs_read_block(node, i);
48 +                                       break;
49 +                               }
50 +                       }
51 +
52 +                       if (oldblk == blknr)
53 +                               blockend = blocksize;
54 +                       else
55 +                               blockend = (1 + blocknxt - blknr) * blocksize;
56 +               }
57 +
58 +               blknr = blknr << log2blocksize;
59 +
60                 /* If the block number is 0 this block is not stored on disk but
61                    is zero filled instead.  */
62                 if (blknr) {
63 @@ -444,7 +466,7 @@ int ext2fs_read_file
64                 } else {
65                         memset (buf, 0, blocksize - skipfirst);
66                 }
67 -               buf += blocksize - skipfirst;
68 +               buf += blockend - skipfirst;
69         }
70         return (len);
71  }
72 -- 
73 1.7.10