projects
/
yaffs2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add more checkpoint tracing
[yaffs2.git]
/
yaffs_checkptrw.c
diff --git
a/yaffs_checkptrw.c
b/yaffs_checkptrw.c
index 6ed976db80f795e3b34b2341d2e77784093e947c..2b14006b71517fe2c5dc144fabb7af6e112aab5a 100644
(file)
--- a/
yaffs_checkptrw.c
+++ b/
yaffs_checkptrw.c
@@
-13,7
+13,7
@@
*/
const char *yaffs_checkptrw_c_version =
*/
const char *yaffs_checkptrw_c_version =
- "$Id: yaffs_checkptrw.c,v 1.
4 2006-05-23 19:08:41
charles Exp $";
+ "$Id: yaffs_checkptrw.c,v 1.
9 2006-11-09 23:57:07
charles Exp $";
#include "yaffs_checkptrw.h"
#include "yaffs_checkptrw.h"
@@
-43,10
+43,10
@@
static int yaffs_CheckpointErase(yaffs_Device *dev)
if(!dev->eraseBlockInNAND)
return 0;
T(YAFFS_TRACE_CHECKPOINT,(TSTR("checking blocks %d to %d"TENDSTR),
if(!dev->eraseBlockInNAND)
return 0;
T(YAFFS_TRACE_CHECKPOINT,(TSTR("checking blocks %d to %d"TENDSTR),
- dev->
startBlock,dev->e
ndBlock));
+ dev->
internalStartBlock,dev->internalE
ndBlock));
- for(i = dev->
startBlock; i <= dev->e
ndBlock; i++) {
- yaffs_BlockInfo *bi =
&dev->blockInfo[i]
;
+ for(i = dev->
internalStartBlock; i <= dev->internalE
ndBlock; i++) {
+ yaffs_BlockInfo *bi =
yaffs_GetBlockInfo(dev,i)
;
if(bi->blockState == YAFFS_BLOCK_STATE_CHECKPOINT){
T(YAFFS_TRACE_CHECKPOINT,(TSTR("erasing checkpt block %d"TENDSTR),i));
if(dev->eraseBlockInNAND(dev,i)){
if(bi->blockState == YAFFS_BLOCK_STATE_CHECKPOINT){
T(YAFFS_TRACE_CHECKPOINT,(TSTR("erasing checkpt block %d"TENDSTR),i));
if(dev->eraseBlockInNAND(dev,i)){
@@
-71,13
+71,16
@@
static void yaffs_CheckpointFindNextErasedBlock(yaffs_Device *dev)
{
int i;
int blocksAvailable = dev->nErasedBlocks - dev->nReservedBlocks;
{
int i;
int blocksAvailable = dev->nErasedBlocks - dev->nReservedBlocks;
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("allocating checkpt block: erased %d reserved %d avail %d next %d "TENDSTR),
+ dev->nErasedBlocks,dev->nReservedBlocks,blocksAvailable,dev->checkpointNextBlock));
if(dev->checkpointNextBlock >= 0 &&
if(dev->checkpointNextBlock >= 0 &&
- dev->checkpointNextBlock <= dev->
e
ndBlock &&
+ dev->checkpointNextBlock <= dev->
internalE
ndBlock &&
blocksAvailable > 0){
blocksAvailable > 0){
- for(i = dev->checkpointNextBlock; i <= dev->
e
ndBlock; i++){
- yaffs_BlockInfo *bi =
&dev->blockInfo[i]
;
+ for(i = dev->checkpointNextBlock; i <= dev->
internalE
ndBlock; i++){
+ yaffs_BlockInfo *bi =
yaffs_GetBlockInfo(dev,i)
;
if(bi->blockState == YAFFS_BLOCK_STATE_EMPTY){
dev->checkpointNextBlock = i + 1;
dev->checkpointCurrentBlock = i;
if(bi->blockState == YAFFS_BLOCK_STATE_EMPTY){
dev->checkpointNextBlock = i + 1;
dev->checkpointCurrentBlock = i;
@@
-98,7
+101,7
@@
static void yaffs_CheckpointFindNextCheckpointBlock(yaffs_Device *dev)
yaffs_ExtendedTags tags;
if(dev->blocksInCheckpoint < dev->checkpointMaxBlocks)
yaffs_ExtendedTags tags;
if(dev->blocksInCheckpoint < dev->checkpointMaxBlocks)
- for(i = dev->checkpointNextBlock; i <= dev->
e
ndBlock; i++){
+ for(i = dev->checkpointNextBlock; i <= dev->
internalE
ndBlock; i++){
int chunk = i * dev->nChunksPerBlock;
dev->readChunkWithTagsFromNAND(dev,chunk,NULL,&tags);
int chunk = i * dev->nChunksPerBlock;
dev->readChunkWithTagsFromNAND(dev,chunk,NULL,&tags);
@@
-135,7
+138,7
@@
int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
return 0;
if(!dev->checkpointBuffer)
return 0;
if(!dev->checkpointBuffer)
- dev->checkpointBuffer = YMALLOC_DMA(dev->nBytesPerChunk);
+ dev->checkpointBuffer = YMALLOC_DMA(dev->n
Data
BytesPerChunk);
if(!dev->checkpointBuffer)
return 0;
if(!dev->checkpointBuffer)
return 0;
@@
-147,11
+150,11
@@
int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
dev->checkpointByteCount = 0;
dev->checkpointCurrentBlock = -1;
dev->checkpointCurrentChunk = -1;
dev->checkpointByteCount = 0;
dev->checkpointCurrentBlock = -1;
dev->checkpointCurrentChunk = -1;
- dev->checkpointNextBlock = dev->
s
tartBlock;
+ dev->checkpointNextBlock = dev->
internalS
tartBlock;
/* Erase all the blocks in the checkpoint area */
if(forWriting){
/* Erase all the blocks in the checkpoint area */
if(forWriting){
- memset(dev->checkpointBuffer,0,dev->nBytesPerChunk);
+ memset(dev->checkpointBuffer,0,dev->n
Data
BytesPerChunk);
dev->checkpointByteOffset = 0;
return yaffs_CheckpointErase(dev);
dev->checkpointByteOffset = 0;
return yaffs_CheckpointErase(dev);
@@
-159,11
+162,11
@@
int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
} else {
int i;
/* Set to a value that will kick off a read */
} else {
int i;
/* Set to a value that will kick off a read */
- dev->checkpointByteOffset = dev->nBytesPerChunk;
+ dev->checkpointByteOffset = dev->n
Data
BytesPerChunk;
/* A checkpoint block list of 1 checkpoint block per 16 block is (hopefully)
* going to be way more than we need */
dev->blocksInCheckpoint = 0;
/* A checkpoint block list of 1 checkpoint block per 16 block is (hopefully)
* going to be way more than we need */
dev->blocksInCheckpoint = 0;
- dev->checkpointMaxBlocks = (dev->
endBlock - dev->s
tartBlock)/16 + 2;
+ dev->checkpointMaxBlocks = (dev->
internalEndBlock - dev->internalS
tartBlock)/16 + 2;
dev->checkpointBlockList = YMALLOC(sizeof(int) * dev->checkpointMaxBlocks);
for(i = 0; i < dev->checkpointMaxBlocks; i++)
dev->checkpointBlockList[i] = -1;
dev->checkpointBlockList = YMALLOC(sizeof(int) * dev->checkpointMaxBlocks);
for(i = 0; i < dev->checkpointMaxBlocks; i++)
dev->checkpointBlockList[i] = -1;
@@
-191,17
+194,20
@@
static int yaffs_CheckpointFlushBuffer(yaffs_Device *dev)
tags.objectId = dev->checkpointNextBlock; /* Hint to next place to look */
tags.chunkId = dev->checkpointPageSequence + 1;
tags.sequenceNumber = YAFFS_SEQUENCE_CHECKPOINT_DATA;
tags.objectId = dev->checkpointNextBlock; /* Hint to next place to look */
tags.chunkId = dev->checkpointPageSequence + 1;
tags.sequenceNumber = YAFFS_SEQUENCE_CHECKPOINT_DATA;
- tags.byteCount = dev->nBytesPerChunk;
+ tags.byteCount = dev->n
Data
BytesPerChunk;
if(dev->checkpointCurrentChunk == 0){
/* First chunk we write for the block? Set block state to
checkpoint */
if(dev->checkpointCurrentChunk == 0){
/* First chunk we write for the block? Set block state to
checkpoint */
- yaffs_BlockInfo *bi =
&dev->blockInfo[dev->checkpointCurrentBlock]
;
+ yaffs_BlockInfo *bi =
yaffs_GetBlockInfo(dev,dev->checkpointCurrentBlock)
;
bi->blockState = YAFFS_BLOCK_STATE_CHECKPOINT;
dev->blocksInCheckpoint++;
}
chunk = dev->checkpointCurrentBlock * dev->nChunksPerBlock + dev->checkpointCurrentChunk;
bi->blockState = YAFFS_BLOCK_STATE_CHECKPOINT;
dev->blocksInCheckpoint++;
}
chunk = dev->checkpointCurrentBlock * dev->nChunksPerBlock + dev->checkpointCurrentChunk;
-
+
+ T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpoint wite buffer nand %d(%d:%d) objid %d chId %d" TENDSTR),
+ chunk, dev->checkpointCurrentBlock, dev->checkpointCurrentChunk,tags.objectId,tags.chunkId));
+
dev->writeChunkWithTagsToNAND(dev,chunk,dev->checkpointBuffer,&tags);
dev->checkpointByteOffset = 0;
dev->checkpointPageSequence++;
dev->writeChunkWithTagsToNAND(dev,chunk,dev->checkpointBuffer,&tags);
dev->checkpointByteOffset = 0;
dev->checkpointPageSequence++;
@@
-210,7
+216,7
@@
static int yaffs_CheckpointFlushBuffer(yaffs_Device *dev)
dev->checkpointCurrentChunk = 0;
dev->checkpointCurrentBlock = -1;
}
dev->checkpointCurrentChunk = 0;
dev->checkpointCurrentBlock = -1;
}
- memset(dev->checkpointBuffer,0,dev->nBytesPerChunk);
+ memset(dev->checkpointBuffer,0,dev->n
Data
BytesPerChunk);
return 1;
}
return 1;
}
@@
-241,7
+247,7
@@
int yaffs_CheckpointWrite(yaffs_Device *dev,const void *data, int nBytes)
if(dev->checkpointByteOffset < 0 ||
if(dev->checkpointByteOffset < 0 ||
- dev->checkpointByteOffset >= dev->nBytesPerChunk)
+ dev->checkpointByteOffset >= dev->n
Data
BytesPerChunk)
ok = yaffs_CheckpointFlushBuffer(dev);
}
ok = yaffs_CheckpointFlushBuffer(dev);
}
@@
-267,7
+273,7
@@
int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes)
if(dev->checkpointByteOffset < 0 ||
if(dev->checkpointByteOffset < 0 ||
- dev->checkpointByteOffset >= dev->nBytesPerChunk) {
+ dev->checkpointByteOffset >= dev->n
Data
BytesPerChunk) {
if(dev->checkpointCurrentBlock < 0){
yaffs_CheckpointFindNextCheckpointBlock(dev);
if(dev->checkpointCurrentBlock < 0){
yaffs_CheckpointFindNextCheckpointBlock(dev);
@@
-321,7
+327,7
@@
int yaffs_CheckpointClose(yaffs_Device *dev)
} else {
int i;
for(i = 0; i < dev->blocksInCheckpoint && dev->checkpointBlockList[i] >= 0; i++){
} else {
int i;
for(i = 0; i < dev->blocksInCheckpoint && dev->checkpointBlockList[i] >= 0; i++){
- yaffs_BlockInfo *bi =
&dev->blockInfo[dev->checkpointBlockList[i]]
;
+ yaffs_BlockInfo *bi =
yaffs_GetBlockInfo(dev,dev->checkpointBlockList[i])
;
if(bi->blockState == YAFFS_BLOCK_STATE_EMPTY)
bi->blockState = YAFFS_BLOCK_STATE_CHECKPOINT;
else {
if(bi->blockState == YAFFS_BLOCK_STATE_EMPTY)
bi->blockState = YAFFS_BLOCK_STATE_CHECKPOINT;
else {