dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Rockbox mail archive

Subject: Re: disk write testing
From: Björn Stenberg (
Date: 2002-11-04

Greg Haerr wrote:
> Attached is a patch that fixes an off-by-one error in the
> simulator disk writing code, firmware/test/fat/main.c. The
> tests now run with a 4-sector clustersize but fail with 1-sector
> cluster size. (I thought that easier to debug when set for
> a 1-to-1 sectorsize to clustersize mapping.) The problem
> is exacerbated when the script deletes files inbetween
> the 50x70k file creation. In any case, this should allow you
> to continue debugging the filesystem code.

Thank you.

> I personally think a redesign where _all_ buffers are kept at a layer
> just above the ata_{read,write}_sector layer and allowing the file
> open/read/write code to access them would make things alot simpler, and
> tunably smaller.

I disagree. There is good reason for each of the three separate buffers:

1) Buffering one sector per open file means we can always provide byte-for-byte file access within the last accessed sector without accessing the disk. This is the same model buffered i/o works in most operating systems.

2) Buffering the two last read directory sectors is vital for long filename parsing, since a single long filename can span three (!) directory sectors.

3) Caching the most recently used FAT sectors means we obtain very fast access to cluster chain information, which in turn speeds up disk reads and writes substantially.

Combining these three buffers into a regular i/o buffer would slow overall performance down, because the regular very big mp3 file reads will fill the buffer every time.

> Also, the code is not set up properly to update access times on
> reading, nor record file size in bytes for writing.

Read access time is not implemented yet. If we want it, it is very easy to add since fat_open() knows the location of the directory entry.

File size is handled in fat_closewrite().


Page was last modified "Jan 10 2012" The Rockbox Crew