*/
//yaffs_guts.c
-const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.22 2003-03-11 05:16:53 charles Exp $";
+const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.23 2003-04-03 17:32:11 charles Exp $";
#include "yportenv.h"
cache->nBytes,1);
cache->dirty = 0;
+ cache->object = NULL;
}
} while(cache && chunkWritten > 0);
if(!dev->srCache[i].object)
{
//T(("Grabbing empty %d\n",i));
+
+ printf("Grabbing empty %d\n",i);
return &dev->srCache[i];
}
}
+
+ return NULL;
theOne = -1;
usage = 0; // just to stop the compiler grizzling
}
//T(("Grabbing non-empty %d\n",theOne));
+
+ if(theOne >= 0) printf("Grabbed non-empty cache %d\n",theOne);
+
return theOne >= 0 ? &dev->srCache[theOne] : NULL;
}
else
yaffs_Object *theObj;
int usage;
int i;
+ int pushout;
if(dev->nShortOpCaches > 0)
{
theObj = dev->srCache[0].object;
usage = dev->srCache[0].lastUse;
+ cache = &dev->srCache[0];
+ pushout = 0;
for(i = 1; i < dev->nShortOpCaches; i++)
{
{
usage = dev->srCache[i].lastUse;
theObj = dev->srCache[i].object;
+ cache = &dev->srCache[i];
+ pushout = i;
}
}
- yaffs_FlushFilesChunkCache(theObj);
+ if(!cache || cache->dirty)
+ {
+
+ printf("Dirty ");
+ yaffs_FlushFilesChunkCache(theObj);
- // Try again
- cache = yaffs_GrabChunkCacheWorker(dev);
+ // Try again
+ cache = yaffs_GrabChunkCacheWorker(dev);
+ }
+ else
+ {
+ printf(" pushout %d\n",pushout);
+ }
+
}
-
+
return cache;
}
else
int nToCopy;
int n = nBytes;
int nDone = 0;
+ yaffs_ChunkCache *cache;
yaffs_Device *dev;
nToCopy = YAFFS_BYTES_PER_CHUNK - start;
}
- if(nToCopy != YAFFS_BYTES_PER_CHUNK)
+ cache = yaffs_FindChunkCache(in,chunk);
+
+ // If the chunk is already in the cache or it is less than a whole chunk
+ // then use the cache (if there is caching)
+ // else bypass the cache.
+ if( cache || nToCopy != YAFFS_BYTES_PER_CHUNK)
{
- // An incomplete start or end chunk (or maybe both start and end chunk)
if(dev->nShortOpCaches > 0)
{
- yaffs_ChunkCache *cache;
+
// If we can't find the data in the cache, then load it up.
- cache = yaffs_FindChunkCache(in,chunk);
+
if(!cache)
{
cache = yaffs_GrabChunkCache(in->myDev);