Fix blocks per chunk in resize
[yaffs/.git] / yaffs_guts.h
index 0fe8f74557b7ca942ad0d1c9b5591102606cc0e8..5d6afde41f54b70e92b7dfee99132e8a57c85e93 100644 (file)
  *
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  *
- * $Id: yaffs_guts.h,v 1.14 2003-01-14 23:15:32 charles Exp $
+ * $Id: yaffs_guts.h,v 1.21 2005-10-11 23:43:27 charles Exp $
  */
 
 #ifndef __YAFFS_GUTS_H__
 #define __YAFFS_GUTS_H__
 
-#include "devextras.h"
-
+#include "yportenv.h"
 
 #define YAFFS_OK       1
 #define YAFFS_FAIL  0
@@ -62,8 +61,6 @@
 #define YAFFS_NOBJECT_BUCKETS          256
 
 
-#define YAFFS_RESERVED_BLOCKS          8
-
 #define YAFFS_OBJECT_SPACE                     0x40000
 #define YAFFS_MAX_NAME_LENGTH          255
 #define YAFFS_SHORT_NAME_LENGTH                15
@@ -165,8 +162,8 @@ typedef struct
 #ifndef CONFIG_YAFFS_NO_YAFFS2
        __u32 sequenceNumber;   // block sequence number for yaffs2
 #endif
-       int   softDeletions:8;  // number of soft deleted pages
-    int   pagesInUse:8;                // number of pages in use
+       int   softDeletions:12; // number of soft deleted pages
+    int   pagesInUse:12;       // number of pages in use
     __u32 blockState:4;        // One of the above block states
     __u32 needsRetiring:1;     // Data has failed on this block, need to get valid data off
                                                // and retire the block.
@@ -196,16 +193,16 @@ typedef struct
        char  name[YAFFS_MAX_NAME_LENGTH + 1];
 
        // Thes following apply to directories, files, symlinks - not hard links
-       __u32 st_mode;  // protection
+       __u32 yst_mode;  // protection
 
 #ifdef CONFIG_YAFFS_WINCE
        __u32 notForWinCE[5];
 #else
-       __u32 st_uid;   // user ID of owner
-       __u32 st_gid;    // group ID of owner 
-       __u32 st_atime; // time of last access
-       __u32 st_mtime; // time of last modification
-       __u32 st_ctime; // time of last change
+       __u32 yst_uid;   // user ID of owner
+       __u32 yst_gid;    // group ID of owner 
+       __u32 yst_atime; // time of last access
+       __u32 yst_mtime; // time of last modification
+       __u32 yst_ctime; // time of last change
 #endif
 
        // File size  applies to files only
@@ -217,7 +214,7 @@ typedef struct
        // Alias is for symlinks only.
        char alias[YAFFS_MAX_ALIAS_LENGTH + 1];
        
-       __u32 st_rdev;  // device stuff for block and char devices (maj/min)
+       __u32 yst_rdev;  // device stuff for block and char devices (maj/min)
        
 #ifdef CONFIG_YAFFS_WINCE
        __u32 win_ctime[2];
@@ -335,7 +332,7 @@ struct  yaffs_ObjectStruct
        __u32 objectId;         // the object id value
        
        
-       __u32 st_mode;          // protection
+       __u32 yst_mode;         // protection
 
 #ifdef CONFIG_YAFFS_SHORT_NAMES_IN_RAM
        char shortName[YAFFS_SHORT_NAME_LENGTH+1];
@@ -350,19 +347,21 @@ struct  yaffs_ObjectStruct
        __u32 win_mtime[2];
        __u32 win_atime[2];
 #else
-       __u32 st_uid;           // user ID of owner
-       __u32 st_gid;           // group ID of owner 
-       __u32 st_atime;         // time of last access
-       __u32 st_mtime;         // time of last modification
-       __u32 st_ctime;         // time of last change
+       __u32 yst_uid;          // user ID of owner
+       __u32 yst_gid;          // group ID of owner 
+       __u32 yst_atime;        // time of last access
+       __u32 yst_mtime;        // time of last modification
+       __u32 yst_ctime;        // time of last change
 #endif
 
-       __u32 st_rdev;      // device stuff for block and char devices
+       __u32 yst_rdev;             // device stuff for block and char devices
 
 
 
 #ifdef __KERNEL__
        struct inode *myInode;
+       __u8  deferedFree;   // YAFFS has removed the object from NAND, but it is being kept
+                            // Alive until the inode is cleared to prevent inode inconsistencies.
 #endif
 
 
@@ -399,9 +398,11 @@ struct yaffs_DeviceStruct
 {
        // Entry parameters set up way early. Yaffs sets up the rest.
        int   nBytesPerChunk;    // Should be a power of 2 >= 512
-       int       nChunksPerBlock;
-       int   startBlock;       // Start block we're allowed to use
-       int   endBlock;         // End block we're allowed to use
+       int   nChunksPerBlock;   // does not need to be a power of 2
+       int   startBlock;                // Start block we're allowed to use
+       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.
        
        int   useNANDECC;               // Flag to decide whether or not to use NANDECC
        int   nShortOpCaches;   // If <= 0, then short op caching is disabled, else
@@ -419,6 +420,11 @@ struct yaffs_DeviceStruct
        int (*initialiseNAND)(struct yaffs_DeviceStruct *dev);
 
        // Runtime parameters. Set up by YAFFS.
+       int   internalStartBlock;                // Internal version of startBlock
+       int   internalEndBlock;                  // End block we're allowed to use
+       int   blockOffset;
+       int   chunkOffset;
+       
        
        __u16 chunkGroupBits; // 0 for devices <= 32MB. else log2(nchunks) - 16
        __u16 chunkGroupSize; // == 2^^chunkGroupBits
@@ -466,7 +472,6 @@ struct yaffs_DeviceStruct
                
        int   currentDirtyChecker;      // Used to find current dirtiest block
        
-       int   garbageCollectionRequired;
        
        // Operations since mount
        int nPageWrites;
@@ -474,6 +479,7 @@ struct yaffs_DeviceStruct
        int nBlockErasures;
        int nGCCopies;
        int garbageCollections;
+       int passiveGarbageCollections;
        int nRetriedWrites;
        int nRetiredBlocks;
        int eccFixed;
@@ -491,8 +497,6 @@ struct yaffs_DeviceStruct
 //     yaffs_Spare bufferedSpare[YAFFS_CHUNKS_PER_BLOCK];
        int bufferedBlock;      // Which block is buffered here?
        int doingBufferedBlockRewrite;
-       
-       int blockSelectedForGC;
 
        yaffs_ChunkCache *srCache;
        int srLastUse;
@@ -578,6 +582,9 @@ yaffs_Object *yaffs_LostNFound(yaffs_Device *dev);
 void  yfsd_WinFileTimeNow(__u32 target[2]);
 #endif
 
+#ifdef __KERNEL__
+void yaffs_HandleDeferedFree(yaffs_Object *obj);
+#endif
 
 // Debug dump 
 int yaffs_DumpObject(yaffs_Object *obj);
@@ -588,3 +595,4 @@ void yaffs_GutsTest(yaffs_Device *dev);
 
 #endif
 
+