Mercurial > yaffs-ecoscentric
changeset 330:421c019d1990
Fix checkpoint to handle out of space conditions better
| author | charles |
|---|---|
| date | Thu, 29 Oct 2009 03:05:55 +0000 |
| parents | d5dc2356f18e |
| children | 37f81449fcd7 |
| files | yaffs_checkptrw.c |
| diffstat | 1 files changed, 10 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/yaffs_checkptrw.c +++ b/yaffs_checkptrw.c @@ -130,6 +130,9 @@ static void yaffs_CheckpointFindNextChec int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting) { + + dev->checkpointOpenForWrite = forWriting; + /* Got the functions we need? */ if (!dev->writeChunkWithTagsToNAND || !dev->readChunkWithTagsFromNAND || @@ -147,9 +150,6 @@ int yaffs_CheckpointOpen(yaffs_Device *d dev->checkpointPageSequence = 0; - - dev->checkpointOpenForWrite = forWriting; - dev->checkpointByteCount = 0; dev->checkpointSum = 0; dev->checkpointXor = 0; @@ -358,11 +358,14 @@ int yaffs_CheckpointClose(yaffs_Device * if (dev->checkpointOpenForWrite) { if (dev->checkpointByteOffset != 0) yaffs_CheckpointFlushBuffer(dev); - } else { + } else if(dev->checkpointBlockList){ int i; for (i = 0; i < dev->blocksInCheckpoint && dev->checkpointBlockList[i] >= 0; i++) { - yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, dev->checkpointBlockList[i]); - if (bi->blockState == YAFFS_BLOCK_STATE_EMPTY) + int blk = dev->checkpointBlockList[i]; + yaffs_BlockInfo *bi = NULL; + if( dev->internalStartBlock <= blk && blk <= dev->internalEndBlock) + bi = yaffs_GetBlockInfo(dev, blk); + if (bi && bi->blockState == YAFFS_BLOCK_STATE_EMPTY) bi->blockState = YAFFS_BLOCK_STATE_CHECKPOINT; else { /* Todo this looks odd... */ @@ -390,13 +393,10 @@ int yaffs_CheckpointClose(yaffs_Device * int yaffs_CheckpointInvalidateStream(yaffs_Device *dev) { - /* Erase the first checksum block */ + /* Erase the checkpoint data */ T(YAFFS_TRACE_CHECKPOINT, (TSTR("checkpoint invalidate"TENDSTR))); - if (!yaffs_CheckpointSpaceOk(dev)) - return 0; - return yaffs_CheckpointErase(dev); }
