Prevent recursive gc
authorcharles <charles>
Tue, 26 Jul 2005 03:05:28 +0000 (03:05 +0000)
committercharles <charles>
Tue, 26 Jul 2005 03:05:28 +0000 (03:05 +0000)
yaffs_guts.c
yaffs_guts.h

index c776e7817799206353748219a6e5b71b4f71879f..02723f71a8e2b691bccb75c7b2f5e1d7dacc41d0 100644 (file)
@@ -14,7 +14,7 @@
  */
  //yaffs_guts.c
 
-const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.9 2005-07-18 23:16:04 charles Exp $";
+const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.10 2005-07-26 03:05:28 charles Exp $";
 
 #include "yportenv.h"
 
@@ -2417,6 +2417,7 @@ int  yaffs_GarbageCollectBlock(yaffs_Device *dev,int block)
        dev->nFreeChunks -= bi->softDeletions;  // Take off the number of soft deleted entries because
                                                // they're going to get really deleted during GC.
 
+       dev->isDoingGC = 1;
 
        if(!yaffs_StillSomeChunkBits(dev,block))
        {
@@ -2549,6 +2550,8 @@ int  yaffs_GarbageCollectBlock(yaffs_Device *dev,int block)
        }
        
        
+       dev->isDoingGC = 0;
+       
        //yaffs_VerifyFreeChunks(dev);
                        
        return YAFFS_OK;
@@ -2634,9 +2637,13 @@ int yaffs_CheckGarbageCollection(yaffs_Device *dev)
        int gcOk = YAFFS_OK;
        int maxTries = 0;
        
-       //yaffs_DoUnlinkedFileDeletion(dev);
-       
        //yaffs_VerifyFreeChunks(dev);
+       
+       if(dev->isDoingGC)
+       {
+               // Bail out so we don't get recursive gc
+               return YAFFS_OK;
+       }
 
        // This loop should pass the first time.
        // We'll only see looping here if the erase of the collected block fails.
@@ -6017,6 +6024,7 @@ int yaffs_GutsInitialise(yaffs_Device *dev)
        dev->tagsEccUnfixed=0;
        dev->nErasureFailures = 0;
        dev->nErasedBlocks = 0;
+       dev->isDoingGC = 0;
        
        //dev->localBuffer = YMALLOC(dev->nBytesPerChunk);
        // Initialise temporary buffers
index cf8f5f76bafcceb921fb5a41fa290097713f7473..1fb8b870d2746258ec0134fcdfc18297063885b1 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.8 2005-07-18 23:16:04 charles Exp $
+ * $Id: yaffs_guts.h,v 1.9 2005-07-26 03:05:28 charles Exp $
  */
 
 #ifndef __YAFFS_GUTS_H__
@@ -583,6 +583,7 @@ struct yaffs_DeviceStruct
        int  nFreeTnodes;
        yaffs_TnodeList *allocatedTnodeList;
 
+       int   isDoingGC;
 
        int   nObjectsCreated;
        yaffs_Object *freeObjects;