Add non-partitioned checkpointing
authorcharles <charles>
Wed, 17 May 2006 09:27:23 +0000 (09:27 +0000)
committercharles <charles>
Wed, 17 May 2006 09:27:23 +0000 (09:27 +0000)
direct/yaffscfg2k.c
yaffs_checkptrw.c
yaffs_fs.c
yaffs_guts.h

index c2cd1c9..38384bb 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <errno.h>
 
-unsigned yaffs_traceMask = YAFFS_TRACE_SCAN |  YAFFS_TRACE_GC | YAFFS_TRACE_GC_DETAIL | YAFFS_TRACE_WRITE | YAFFS_TRACE_ERASE | YAFFS_TRACE_TRACING | YAFFS_TRACE_ALLOCATE;
+unsigned yaffs_traceMask = YAFFS_TRACE_SCAN |  YAFFS_TRACE_GC | YAFFS_TRACE_GC_DETAIL | YAFFS_TRACE_WRITE | YAFFS_TRACE_ERASE | YAFFS_TRACE_TRACING | YAFFS_TRACE_ALLOCATE | YAFFS_TRACE_CHECKPOINT;
 
 
 void yaffsfs_SetError(int err)
@@ -125,9 +125,9 @@ int yaffs_StartUp(void)
        flashDev.nBytesPerChunk = 2048;
        flashDev.nChunksPerBlock = 64;
        flashDev.nReservedBlocks = 5;
-       flashDev.checkpointStartBlock = 1;
-       flashDev.checkpointEndBlock = 20;
-       flashDev.startBlock = 21
+       //flashDev.checkpointStartBlock = 1;
+       //flashDev.checkpointEndBlock = 20;
+       flashDev.startBlock = 20
        //flashDev.endBlock = 127; // Last block in 16MB
        flashDev.endBlock = yflash_GetNumberOfBlocks()-1;
        flashDev.isYaffs2 = 1;
index 12d3cea..686a47b 100644 (file)
  */
 
 const char *yaffs_checkptrw_c_version =
-    "$Id: yaffs_checkptrw.c,v 1.1 2006-05-08 10:13:34 charles Exp $";
+    "$Id: yaffs_checkptrw.c,v 1.2 2006-05-17 09:31:07 charles Exp $";
 
 
 #include "yaffs_checkptrw.h"
 
 
-int yaffs_CheckpointSpaceOk(yaffs_Device *dev)
+static int yaffs_CheckpointSpaceOk(yaffs_Device *dev)
 {
 
-       T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpt blocks %d %d %d %d" TENDSTR),
-               dev->checkpointStartBlock, dev->checkpointEndBlock,
-               dev->startBlock,dev->endBlock));
+       int blocksAvailable = dev->nErasedBlocks - dev->nReservedBlocks;
+       
+       if(blocksAvailable < 0)
+               blocksAvailable = 0;
                
-       if(dev->checkpointStartBlock >= dev->checkpointEndBlock)
-               return 0;
+       T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpt blocks available" TENDSTR)));
                
-       if(dev->checkpointStartBlock >= dev->startBlock && 
-          dev->checkpointStartBlock <= dev->endBlock)
-               return 0;
-
-       if(dev->checkpointEndBlock >= dev->startBlock && 
-          dev->checkpointEndBlock <= dev->endBlock)
-               return 0;
+       
+       if(blocksAvailable <= 0)
+               return 0;
                
        return 1;
 }
 
-int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
+
+
+static int yaffs_CheckpointErase(yaffs_Device *dev)
 {
+       
        int i;
        
+
+       if(!dev->eraseBlockInNAND)      
+               return 0;
+       T(YAFFS_TRACE_CHECKPOINT,(TSTR("checking blocks %d to %d"TENDSTR),
+               dev->startBlock,dev->endBlock));
+               
+       for(i = dev->startBlock; i <= dev->endBlock; i++) {
+               yaffs_BlockInfo *bi = &dev->blockInfo[i];
+               if(bi->blockState == YAFFS_BLOCK_STATE_CHECKPOINT){
+                       T(YAFFS_TRACE_CHECKPOINT,(TSTR("erasing checkpt block %d"TENDSTR),i));
+                       if(dev->eraseBlockInNAND(dev,i)){
+                               bi->blockState = YAFFS_BLOCK_STATE_EMPTY;
+                               dev->nErasedBlocks++;
+                               dev->nFreeChunks += dev->nChunksPerBlock;
+                       }
+                       else {
+                               dev->markNANDBlockBad(dev,i);
+                               bi->blockState = YAFFS_BLOCK_STATE_DEAD;
+                       }
+               }
+       }
+       
+       dev->blocksInCheckpoint = 0;
+       
+       return 1;
+}
+
+
+static void yaffs_CheckpointFindNextErasedBlock(yaffs_Device *dev)
+{
+       int  i;
+       int blocksAvailable = dev->nErasedBlocks - dev->nReservedBlocks;
+               
+       if(dev->checkpointNextBlock >= 0 &&
+          dev->checkpointNextBlock <= dev->endBlock &&
+          blocksAvailable > 0){
+       
+               for(i = dev->checkpointNextBlock; i <= dev->endBlock; i++){
+                       yaffs_BlockInfo *bi = &dev->blockInfo[i];
+                       if(bi->blockState == YAFFS_BLOCK_STATE_EMPTY){
+                               dev->checkpointNextBlock = i + 1;
+                               dev->nErasedBlocks--;
+                               dev->checkpointCurrentBlock = i;
+                               T(YAFFS_TRACE_CHECKPOINT,(TSTR("allocating checkpt block %d"TENDSTR),i));
+                               return;
+                       }
+               }
+       }
+       T(YAFFS_TRACE_CHECKPOINT,(TSTR("out of checkpt blocks"TENDSTR)));
+       
+       dev->checkpointNextBlock = -1;
+       dev->checkpointCurrentBlock = -1;
+}
+
+static void yaffs_CheckpointFindNextCheckpointBlock(yaffs_Device *dev)
+{
+       int  i;
+       yaffs_ExtendedTags tags;
+       
+       if(dev->blocksInCheckpoint < dev->checkpointMaxBlocks) 
+               for(i = dev->checkpointNextBlock; i <= dev->endBlock; i++){
+                       int chunk = i * dev->nChunksPerBlock;
+
+                       dev->readChunkWithTagsFromNAND(dev,chunk,NULL,&tags);
+                                                     
+                       if(tags.sequenceNumber == YAFFS_SEQUENCE_CHECKPOINT_DATA){
+                               /* Right kind of block */
+                               dev->checkpointNextBlock = tags.objectId;
+                               dev->checkpointCurrentBlock = i;
+                               dev->checkpointBlockList[dev->blocksInCheckpoint] = i;
+                               dev->blocksInCheckpoint++;
+                               T(YAFFS_TRACE_CHECKPOINT,(TSTR("found checkpt block %d"TENDSTR),i));
+                               return;
+                       }
+               }
+
+       T(YAFFS_TRACE_CHECKPOINT,(TSTR("found no more checkpt blocks"TENDSTR)));
+
+       dev->checkpointNextBlock = -1;
+       dev->checkpointCurrentBlock = -1;
+}
+
+
+int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
+{
+       
        /* Got the functions we need? */
        if (!dev->writeChunkWithTagsToNAND ||
            !dev->readChunkWithTagsFromNAND ||
-           !dev->eraseBlockInNAND)
+           !dev->eraseBlockInNAND ||
+           !dev->markNANDBlockBad)
                return 0;
-       
-       /* Got a valid checkpoint data region? */
-       if(!yaffs_CheckpointSpaceOk(dev))
+
+       if(forWriting && !yaffs_CheckpointSpaceOk(dev))
                return 0;
                        
        if(!dev->checkpointBuffer)
                dev->checkpointBuffer = YMALLOC(dev->nBytesPerChunk);
        if(!dev->checkpointBuffer)
                return 0;
+
        
-       dev->checkpointPage = dev->checkpointStartBlock * dev->nChunksPerBlock;
+       dev->checkpointPageSequence = 0;
        
        dev->checkpointOpenForWrite = forWriting;
        
        dev->checkpointByteCount = 0;
+       dev->checkpointCurrentBlock = -1;
+       dev->checkpointCurrentChunk = -1;
+       dev->checkpointNextBlock = dev->startBlock;
        
        /* Erase all the blocks in the checkpoint area */
        if(forWriting){
-               T(YAFFS_TRACE_CHECKPOINT,(TSTR("erasing checkpt data"TENDSTR)));
-               for( i = dev->checkpointStartBlock; i <= dev->checkpointEndBlock; i++)
-                       dev->eraseBlockInNAND(dev,i);
-               
+               memset(dev->checkpointBuffer,0,dev->nBytesPerChunk);
                dev->checkpointByteOffset = 0;
+               return yaffs_CheckpointErase(dev);
                
-               memset(dev->checkpointBuffer,0,dev->nBytesPerChunk);
                
        } else {
+               int i;
                /* Set to a value that will kick off a read */
                dev->checkpointByteOffset = dev->nBytesPerChunk;
+               /* A checkpoint block list of 1 checkpoint block per 16 block is (hopefully)
+                * going to be way more than we need */
+               dev->checkpointMaxBlocks = (dev->endBlock - dev->startBlock)/16 + 2;
+               dev->checkpointBlockList = YMALLOC(sizeof(int) * dev->checkpointMaxBlocks);
+               for(i = 0; i < dev->checkpointMaxBlocks; i++)
+                       dev->checkpointBlockList[i] = -1;
        }
        
        return 1;
@@ -86,47 +179,40 @@ int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
 static int yaffs_CheckpointFlushBuffer(yaffs_Device *dev)
 {
 
-       int blockNo;
-       int goodBlockFound;
-       yaffs_BlockState state;
-       __u32 seqenceNumber;
+       int chunk;
 
        yaffs_ExtendedTags tags;
+       
+       if(dev->checkpointCurrentBlock < 0){
+               yaffs_CheckpointFindNextErasedBlock(dev);
+               dev->checkpointCurrentChunk = 0;
+       }
+       
+       if(dev->checkpointCurrentBlock < 0)
+               return 0;
+       
        tags.chunkDeleted = 0;
-       tags.objectId = YAFFS_OBJECTID_CHECKPOINT_DATA;
-       tags.chunkId = dev->checkpointPage + 1;
-       tags.sequenceNumber = 1;
+       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;
        
-       /* printf("write checkpoint page %d\n",dev->checkpointPage); */
-       
-       if(dev->checkpointPage%dev->nChunksPerBlock == 0){
-               /* Start of a new block, do a block validity check */
-               blockNo = dev->checkpointPage/dev->nChunksPerBlock;
-               goodBlockFound = 0;
-               while(blockNo <= dev->checkpointEndBlock && !goodBlockFound){
-                       dev->queryNANDBlock(dev,blockNo,&state,&tags);
-                       if(state != YAFFS_BLOCK_STATE_DEAD)
-                               goodBlockFound = 1;
-                       else {
-                               blockNo++;
-                               dev->checkpointPage += dev->nChunksPerBlock;
-                       }
-               }
+       chunk = dev->checkpointCurrentBlock * dev->nChunksPerBlock + dev->checkpointCurrentChunk;
                
-               if(!goodBlockFound)
-                       return 0;
-       }
-       
-       dev->writeChunkWithTagsToNAND(dev, dev->checkpointPage, 
-                                     dev->checkpointBuffer,&tags);
+       dev->writeChunkWithTagsToNAND(dev,chunk,dev->checkpointBuffer,&tags);
        dev->checkpointByteOffset = 0;
-       dev->checkpointPage++;     
+       dev->checkpointPageSequence++;     
+       dev->checkpointCurrentChunk++;
+       if(dev->checkpointCurrentChunk >= dev->nChunksPerBlock){
+               dev->checkpointCurrentChunk = 0;
+               dev->checkpointCurrentBlock = -1;
+       }
        memset(dev->checkpointBuffer,0,dev->nBytesPerChunk);
        
        return 1;
 }
 
+
 int yaffs_CheckpointWrite(yaffs_Device *dev,const void *data, int nBytes)
 {
        int i=0;
@@ -165,9 +251,9 @@ int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes)
        int i=0;
        int ok = 1;
        yaffs_ExtendedTags tags;
-       yaffs_BlockState state;
-       int blockNo;
-       int goodBlockFound;
+
+       
+       int chunk;
 
        __u8 *dataBytes = (__u8 *)data;
                
@@ -175,39 +261,40 @@ int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes)
                return 0;
 
        while(i < nBytes && ok) {
+       
+       
                if(dev->checkpointByteOffset < 0 ||
                   dev->checkpointByteOffset >= dev->nBytesPerChunk) {
-                       if(dev->checkpointPage%dev->nChunksPerBlock == 0){
-                               /* Start of a new block, do a block validity check */
-                               blockNo = dev->checkpointPage/dev->nChunksPerBlock;
-                               goodBlockFound = 0;
-                               while(blockNo <= dev->checkpointEndBlock && !goodBlockFound){
-                                       dev->queryNANDBlock(dev,blockNo,&state,&tags);
-                                       if(state != YAFFS_BLOCK_STATE_DEAD)
-                                               goodBlockFound = 1;
-                                       else {
-                                               blockNo++;
-                                               dev->checkpointPage += dev->nChunksPerBlock;
-                                       }
-                               }
-               
-                               if(!goodBlockFound)
-                                       return 0;
+                  
+                       if(dev->checkpointCurrentBlock < 0){
+                               yaffs_CheckpointFindNextCheckpointBlock(dev);
+                               dev->checkpointCurrentChunk = 0;
                        }
-
-
-                       /* read in the next chunk */
-                       /* printf("read checkpoint page %d\n",dev->checkpointPage); */
-                       dev->readChunkWithTagsFromNAND(dev, dev->checkpointPage, 
-                                                      dev->checkpointBuffer,
-                                                     &tags);
+                       
+                       if(dev->checkpointCurrentBlock < 0)
+                               ok = 0;
+                       else {
+                       
+                               chunk = dev->checkpointCurrentBlock * dev->nChunksPerBlock + 
+                                         dev->checkpointCurrentChunk;
+
+                               /* read in the next chunk */
+                               /* printf("read checkpoint page %d\n",dev->checkpointPage); */
+                               dev->readChunkWithTagsFromNAND(dev, chunk, 
+                                                              dev->checkpointBuffer,
+                                                             &tags);
                                                      
-                       if(tags.objectId != YAFFS_OBJECTID_CHECKPOINT_DATA ||
-                          tags.chunkId != (dev->checkpointPage + 1))
-                          ok = 0;
+                               if(tags.chunkId != (dev->checkpointPageSequence + 1) ||
+                                  tags.sequenceNumber != YAFFS_SEQUENCE_CHECKPOINT_DATA)
+                                  ok = 0;
 
-                       dev->checkpointByteOffset = 0;
-                       dev->checkpointPage++;
+                               dev->checkpointByteOffset = 0;
+                               dev->checkpointPageSequence++;
+                               dev->checkpointCurrentChunk++;
+                       
+                               if(dev->checkpointCurrentChunk >= dev->nChunksPerBlock)
+                                       dev->checkpointCurrentBlock = -1;
+                       }
                }
                
                if(ok){
@@ -228,13 +315,29 @@ int yaffs_CheckpointClose(yaffs_Device *dev)
        if(dev->checkpointOpenForWrite){        
                if(dev->checkpointByteOffset != 0)
                        yaffs_CheckpointFlushBuffer(dev);
+       } else {
+               int i;
+               for(i = 0; i < dev->blocksInCheckpoint && dev->checkpointBlockList[i] >= 0; i++){
+                       yaffs_BlockInfo *bi = &dev->blockInfo[dev->checkpointBlockList[i]];
+                       if(bi->blockState == YAFFS_BLOCK_STATE_EMPTY)
+                               bi->blockState = YAFFS_BLOCK_STATE_CHECKPOINT;
+                       else {
+                               // Todo this looks odd...
+                       }
+               }
+               YFREE(dev->checkpointBlockList);
+               dev->checkpointBlockList = NULL;
        }
 
+       dev->nFreeChunks -= dev->blocksInCheckpoint * dev->nChunksPerBlock;
+       dev->nErasedBlocks -= dev->blocksInCheckpoint;
+
+               
        T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpoint byte count %d" TENDSTR),
                        dev->checkpointByteCount));
                        
        if(dev->checkpointBuffer){
-               /* flush the buffer */  
+               /* free the buffer */   
                YFREE(dev->checkpointBuffer);
                dev->checkpointBuffer = NULL;
                return 1;
@@ -253,13 +356,7 @@ int yaffs_CheckpointInvalidateStream(yaffs_Device *dev)
        if(!yaffs_CheckpointSpaceOk(dev))
                return 0;
 
-       if(dev->eraseBlockInNAND){
-               T(YAFFS_TRACE_CHECKPOINT,(TSTR("erasing checkpt data"TENDSTR)));
-
-               return dev->eraseBlockInNAND(dev, dev->checkpointStartBlock);
-       }
-       else
-               return 0;
+       return yaffs_CheckpointErase(dev);
 }
 
 
index 0959111..bcc148b 100644 (file)
@@ -31,7 +31,7 @@
  */
 
 const char *yaffs_fs_c_version =
-    "$Id: yaffs_fs.c,v 1.46 2006-05-08 10:13:34 charles Exp $";
+    "$Id: yaffs_fs.c,v 1.47 2006-05-17 09:36:06 charles Exp $";
 extern const char *yaffs_guts_c_version;
 
 #include <linux/config.h>
@@ -132,6 +132,9 @@ static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
                        struct inode *new_dir, struct dentry *new_dentry);
 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr);
 
+static int yaffs_sync_fs(struct super_block *sb);
+static int yaffs_write_super(struct super_block *sb);
+
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf);
 #else
@@ -217,6 +220,8 @@ static struct super_operations yaffs_super_ops = {
        .put_super = yaffs_put_super,
        .delete_inode = yaffs_delete_inode,
        .clear_inode = yaffs_clear_inode,
+       .sync_fs = yaffs_sync_fs,
+       .write_super = yaffs_write_super,
 };
 
 static void yaffs_GrossLock(yaffs_Device * dev)
@@ -1252,6 +1257,47 @@ static int yaffs_statfs(struct super_block *sb, struct statfs *buf)
        return 0;
 }
 
+
+
+static int yaffs_do_sync_fs(struct super_block *sb)
+{
+
+       yaffs_Device *dev = yaffs_SuperToDevice(sb);
+       T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_do_sync_fs\n"));
+
+       if(sb->s_dirt) {
+               yaffs_GrossLock(dev);
+
+               if(dev)
+                       yaffs_CheckpointSave(dev);
+               
+               yaffs_GrossUnlock(dev);
+
+               sb->s_dirt = 0;
+       }
+       return 0;
+}
+
+
+static int yaffs_write_super(struct super_block *sb)
+{
+
+       T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_write_super\n"));
+       return 0; /* yaffs_do_sync_fs(sb);*/
+       
+}
+
+
+static int yaffs_sync_fs(struct super_block *sb)
+{
+
+       T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_sync_fs\n"));
+       
+       return 0; /* yaffs_do_sync_fs(sb);*/
+       
+}
+
+
 static void yaffs_read_inode(struct inode *inode)
 {
        /* NB This is called as a side effect of other functions, but
@@ -1280,6 +1326,8 @@ static void yaffs_put_super(struct super_block *sb)
 {
        yaffs_Device *dev = yaffs_SuperToDevice(sb);
 
+       T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_put_super\n"));
+
        yaffs_GrossLock(dev);
        
        yaffs_FlushEntireDeviceCache(dev);
@@ -1318,6 +1366,15 @@ static void yaffs_MTDPutSuper(struct super_block *sb)
 }
 
 
+static void yaffs_MarkSuperBlockDirty(void *vsb)
+{
+       struct super_block *sb = (struct super_block *)vsb;
+       
+       T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_MarkSuperBlockDirty() sb = %p\n",sb));
+//     if(sb)
+//             sb->s_dirt = 1;
+}
+
 static struct super_block *yaffs_internal_read_super(int yaffsVersion,
                                                     struct super_block *sb,
                                                     void *data, int silent)
@@ -1490,9 +1547,7 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
                dev->nBytesPerChunk = mtd->oobblock;
                dev->nChunksPerBlock = mtd->erasesize / mtd->oobblock;
                nBlocks = mtd->size / mtd->erasesize;
-               dev->checkpointStartBlock = 0;
-               dev->checkpointEndBlock = 20;
-               dev->startBlock = dev->checkpointEndBlock + 1;
+               dev->startBlock = 0;
                dev->endBlock = nBlocks - 1;
        } else {
                dev->writeChunkToNAND = nandmtd_WriteChunkToNAND;
@@ -1504,6 +1559,10 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
        dev->initialiseNAND = nandmtd_InitialiseNAND;
 
        dev->putSuperFunc = yaffs_MTDPutSuper;
+       
+       dev->superBlock = (void *)sb;
+       dev->markSuperBlockDirty = yaffs_MarkSuperBlockDirty;
+       
 
 #ifndef CONFIG_YAFFS_DOES_ECC
        dev->useNANDECC = 1;
index 2da7449..de0627e 100644 (file)
@@ -14,7 +14,7 @@
  *
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  *
- * $Id: yaffs_guts.h,v 1.21 2006-05-08 10:13:34 charles Exp $
+ * $Id: yaffs_guts.h,v 1.22 2006-05-17 09:31:06 charles Exp $
  */
 
 #ifndef __YAFFS_GUTS_H__
@@ -88,6 +88,7 @@
 /* Sseudo object ids for checkpointing */
 #define YAFFS_OBJECTID_SB_HEADER       0x10
 #define YAFFS_OBJECTID_CHECKPOINT_DATA 0x20
+#define YAFFS_SEQUENCE_CHECKPOINT_DATA  0x21
 
 /* */
 
@@ -240,13 +241,13 @@ typedef enum {
 
        YAFFS_BLOCK_STATE_ALLOCATING,
        /* This block is partially allocated. 
+        * At least one page holds valid data.
         * This is the one currently being used for page
         * allocation. Should never be more than one of these
         */
 
        YAFFS_BLOCK_STATE_FULL, 
        /* All the pages in this block have been allocated.
-        * At least one page holds valid data.
         */
 
        YAFFS_BLOCK_STATE_DIRTY,
@@ -254,6 +255,10 @@ typedef enum {
         * Erase me, reuse me.
         */
 
+       YAFFS_BLOCK_STATE_CHECKPOINT,   
+       /* This block is assigned to holding checkpoint data.
+        */
+
        YAFFS_BLOCK_STATE_COLLECTING,   
        /* This block is being garbage collected */
 
@@ -522,10 +527,15 @@ struct yaffs_DeviceStruct {
        int endBlock;           /* End block we're allowed to use */
        int nReservedBlocks;    /* We want this tuneable so that we can reduce */
                                /* reserved blocks on NOR and RAM. */
-       /* Stuff used by checkpointing */
-       int headerBlock;
+       
+       /* Stuff used by the partitioned checkpointing mechanism */
        int checkpointStartBlock;
        int checkpointEndBlock;
+       
+       /* Stuff used by the shared space checkpointing mechanism */
+       /* If this value is zero, then this mechanism is disabled */
+       
+       int nCheckpointReservedBlocks; /* Blocks to reserve for checkpoint data */
 
        
 
@@ -541,6 +551,8 @@ struct yaffs_DeviceStruct {
        void *genericDevice;    /* Pointer to device context
                                 * On an mtd this holds the mtd pointer.
                                 */
+        void *superBlock;
+        
        /* NAND access functions (Must be set before calling YAFFS)*/
 
        int (*writeChunkToNAND) (struct yaffs_DeviceStruct * dev,
@@ -573,6 +585,9 @@ struct yaffs_DeviceStruct {
         */
        void (*removeObjectCallback)(struct yaffs_ObjectStruct *obj);
        
+       /* Callback to mark the superblock dirsty */
+       void (*markSuperBlockDirty)(void * superblock);
+       
        int wideTnodesDisabled; /* Set to disable wide tnodes */
        
 
@@ -610,12 +625,17 @@ struct yaffs_DeviceStruct {
        
 
        /* Runtime checkpointing stuff */
-       int checkpointBlock;
-       int checkpointPage;
+       int checkpointPageSequence;   /* running sequence number of checkpoint pages */
        int checkpointByteCount;
        int checkpointByteOffset;
        __u8 *checkpointBuffer;
        int checkpointOpenForWrite;
+       int blocksInCheckpoint;
+       int checkpointCurrentChunk;
+       int checkpointCurrentBlock;
+       int checkpointNextBlock;
+       int *checkpointBlockList;
+       int checkpointMaxBlocks;
        
        /* Block Info */
        yaffs_BlockInfo *blockInfo;