forked from len0rd/rockbox
Bug fix: Do only flush the sector buffer after writing head bytes if it really needs to be. The old code did flush always, causing the huge slowdown of fprintf() and other places writing byte-wise
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5413 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
0b959cf8be
commit
f78524bf93
1 changed files with 5 additions and 8 deletions
|
@ -457,18 +457,15 @@ static int readwrite(int fd, void* buf, int count, bool write)
|
|||
nread = headbytes;
|
||||
count -= headbytes;
|
||||
}
|
||||
|
||||
/* if buffer has been modified, write it back to disk */
|
||||
if (nread && file->dirty) {
|
||||
rc = flush_cache(fd);
|
||||
if (rc < 0)
|
||||
return rc * 10 - 3;
|
||||
}
|
||||
|
||||
/* If the buffer has been modified, either it has been flushed already
|
||||
* (if (offs+headbytes == SECTOR_SIZE)...) or does not need to be (no
|
||||
* more data to follow in this call). Do NOT flush here. */
|
||||
|
||||
/* read/write whole sectors right into/from the supplied buffer */
|
||||
sectors = count / SECTOR_SIZE;
|
||||
if ( sectors ) {
|
||||
int rc = fat_readwrite(&(file->fatfile), sectors,
|
||||
int rc = fat_readwrite(&(file->fatfile), sectors,
|
||||
(unsigned char*)buf+nread, write );
|
||||
if ( rc < 0 ) {
|
||||
DEBUGF("Failed read/writing %d sectors\n",sectors);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue