fat: replace LINEAR_PREFETCH_SIZE with PREFETCH_BLOCKS
PATCH 2/2 fat: replace LINEAR_PREFETCH_SIZE with PREFETCH_BLOCKS
Currently in do_fat_read() when reading FAT sectors, we have to divide down LINEAR_PREFETCH_SIZE by the sector size, whereas it's defined as 2 sectors worth of bytes. In order to avoid redundant multiplication/division, introduce #define PREFETCH_BLOCKS instead of #define LINEAR_PREFETCH_SIZE.
---
Slight optimization atop of commit 3831530dcb7b71329c272ccd6181f8038b6a6dd0 (VFAT: fix processing of scattered long file name entries) and my recently submitted patch fixing crash with big sector size.
The patch was generated atop of the below patches posted earlier:
http://marc.info/?l=u-boot&m=131283284822789
http://marc.info/?l=u-boot&m=131283289722891
fs/fat/fat.c | 9 ++++----- include/fat.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-)
fs/fat/fat.c +4 -5
@@ -440,10 +440,9 @@ get_vfatname (fsdata *mydata, int curclu {dir_entry *realdent;dir_slot *slotptr = (dir_slot *)retdent; -__u8 *buflimit = cluster + ((curclust ==0 ) ? -LINEAR_PREFETCH_SIZE : - (mydata->clust_size * mydata->sect_size) - ); +__u8 *buflimit = cluster + mydata->sect_size * ((curclust ==0 ) ? +PREFETCH_BLOCKS : + mydata->clust_size);__u8 counter = (slotptr->id & ~LAST_LONG_ENTRY_MASK ) &0xff ;int idx =0 ;
@@ -880,7 +879,7 @@ do_fat_read (const char *filename, voidif (disk_read (cursect, (mydata->fatsize ==32 ) ? (mydata->clust_size) : -LINEAR_PREFETCH_SIZE / mydata->sect_size, +PREFETCH_BLOCKS , do_fat_read_block) <0 ) {debug ("Error: reading rootdir block\n" ); goto exit;
include/fat.h +1 -1
@@ -33,7 +33,7 @@/* Maximum Long File Name length supported here is 128 UTF-16 code units */ #define VFAT_MAXLEN_BYTES 256/* Maximum LFN buffer in bytes */ #define VFAT_MAXSEQ 9/* Up to 9 of 13 2-byte UTF-16 entries */ -#define LINEAR_PREFETCH_SIZE (mydata->sect_size*2)/* Prefetch buffer size */ +#define PREFETCH_BLOCKS 2#define MAX_CLUSTSIZE 65536#define DIRENTSPERBLOCK (mydata->sect_size / sizeof(dir_entry))
Wolfgang Denk
AppliedPATCH 2/2 fat: replace LINEAR_PREFETCH_SIZE with PREFETCH_BLOCKS
Dear Sergei Shtylyov,
Quoted 12 lines · In message <[email protected]> you wrote:
Currently in
do_fat_read()when reading FAT sectors, we have to divide downLINEAR_PREFETCH_SIZEby the sector size, whereas it's defined as 2 sectors worth of bytes. In order to avoid redundant multiplication/division, introduce #definePREFETCH_BLOCKSinstead of #defineLINEAR_PREFETCH_SIZE.Signed-off-by Sergei Shtylyov <[email protected]>---
Slight optimization atop of commit3831530dcb7b71329c272ccd6181f8038b6a6dd0(VFAT: fix processing of scattered long file name entries) and my recently submitted patch fixing crash with big sector size.
Quoted 7 lines
The patch was generated atop of the below patches posted earlier:
http://marc.info/?l=u-boot&m=131283284822789
http://marc.info/?l=u-boot&m=131283289722891fs/fat/fat.c | 9 ++++----- include/fat.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 9 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I've been programming for (35-9=) 24 years myself, and I find the
best way to learn a new language is to *read* every example snippet I
can find, with a reference book close by. Eventually, the *rhythm* of
the language starts pounding in my head... and my fluency is close at
hand. That's how I learned Perl, and now I'm one of the drummers. :-)
-- Randal L. Schwartz in <[email protected]>