X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=yaffs_guts.c;h=b90313e5fe408fea035902c9aebcf3a4a60b2041;hp=a5e8f670a03fd48b30bb40ac37587aedf5d3efd5;hb=c0d545a4291efbb95831518929a87f07aa3c1eb9;hpb=1049ca7d7f24a91577b738e26825fb9be2f169f3 diff --git a/yaffs_guts.c b/yaffs_guts.c index a5e8f67..b90313e 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -13,7 +13,7 @@ */ const char *yaffs_guts_c_version = - "$Id: yaffs_guts.c,v 1.42 2006-11-08 00:33:29 charles Exp $"; + "$Id: yaffs_guts.c,v 1.44 2006-11-11 23:27:44 charles Exp $"; #include "yportenv.h" @@ -484,13 +484,15 @@ static int yaffs_WriteNewChunkWithTagsToNAND(struct yaffs_DeviceStruct *dev, 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++; } @@ -2054,15 +2056,15 @@ static int yaffs_FindBlockForGarbageCollection(yaffs_Device * dev, 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 */ + } } } @@ -2154,6 +2156,11 @@ static void yaffs_BlockBecameDirty(yaffs_Device * dev, int blockNo) /* 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) {