*/
const char *yaffs_guts_c_version =
- "$Id: yaffs_guts.c,v 1.41 2006-11-07 23:26:52 charles Exp $";
+ "$Id: yaffs_guts.c,v 1.44 2006-11-11 23:27:44 charles Exp $";
#include "yportenv.h"
static void yaffs_RetireBlock(yaffs_Device * dev, int blockInNAND)
{
+ yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, blockInNAND);
yaffs_InvalidateCheckpoint(dev);
yaffs_MarkBlockBad(dev, blockInNAND);
- yaffs_GetBlockInfo(dev, blockInNAND)->blockState =
- YAFFS_BLOCK_STATE_DEAD;
+ bi->blockState = YAFFS_BLOCK_STATE_DEAD;
+ bi->gcPrioritise = 0;
+ bi->needsRetiring = 0;
dev->nRetiredBlocks++;
}
static void yaffs_ReportOddballBlocks(yaffs_Device *dev)
{
int i;
- for(i = dev->startBlock; i <= dev->endBlock; i++){
+
+ for(i = dev->internalStartBlock; i <= dev->internalEndBlock && (yaffs_traceMask & YAFFS_TRACE_BAD_BLOCKS); i++){
yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,i);
if(bi->needsRetiring || bi->gcPrioritise)
T(YAFFS_TRACE_BAD_BLOCKS,(TSTR("yaffs block %d%s%s" TENDSTR),
dev->blockInfoAlt = 0;
/* Set up dynamic blockinfo stuff. */
- dev->chunkBitmapStride = (dev->nChunksPerBlock + 7) / 8; // round up bytes
+ dev->chunkBitmapStride = (dev->nChunksPerBlock + 7) / 8; /* round up bytes */
dev->chunkBits = YMALLOC(dev->chunkBitmapStride * nBlocks);
if(!dev->chunkBits){
dev->chunkBits = YMALLOC_ALT(dev->chunkBitmapStride * nBlocks);
for(i = dev->internalStartBlock; i < dev->internalEndBlock && !prioritised; i++){
bi = yaffs_GetBlockInfo(dev, i);
- if(bi->gcPrioritise)
+ if(bi->gcPrioritise) {
pendingPrioritisedExist = 1;
- if(bi->blockState == YAFFS_BLOCK_STATE_FULL &&
- bi->gcPrioritise &&
- yaffs_BlockNotDisqualifiedFromGC(dev, bi)){
- pagesInUse = (bi->pagesInUse - bi->softDeletions);
- dirtiest = i;
- prioritised = 1;
- aggressive = 1; /* Fool the non-aggressive skip logiv below */
+ if(bi->blockState == YAFFS_BLOCK_STATE_FULL &&
+ yaffs_BlockNotDisqualifiedFromGC(dev, bi)){
+ pagesInUse = (bi->pagesInUse - bi->softDeletions);
+ dirtiest = i;
+ prioritised = 1;
+ aggressive = 1; /* Fool the non-aggressive skip logiv below */
+ }
}
}
/* If the block is still healthy erase it and mark as clean.
* If the block has had a data failure, then retire it.
*/
+
+ T(YAFFS_TRACE_GC | YAFFS_TRACE_ERASE,
+ (TSTR("yaffs_BlockBecameDirty block %d state %d %s"TENDSTR),
+ blockNo, bi->blockState, (bi->needsRetiring) ? "needs retiring" : ""));
+
bi->blockState = YAFFS_BLOCK_STATE_DIRTY;
if (!bi->needsRetiring) {