changeset 27:ae8aefd82ff7

Prevent recursive gc
author charles
date Tue, 26 Jul 2005 04:05:28 +0100
parents 368da1ba99da
children 16d3de8dca1f
files yaffs_guts.c yaffs_guts.h
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/yaffs_guts.c
+++ b/yaffs_guts.c
@@ -2417,6 +2417,7 @@ int  yaffs_GarbageCollectBlock(yaffs_Dev
 	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_Dev
 	}
 	
 	
+	dev->isDoingGC = 0;
+	
 	//yaffs_VerifyFreeChunks(dev);
 			
 	return YAFFS_OK;
@@ -2634,9 +2637,13 @@ int yaffs_CheckGarbageCollection(yaffs_D
 	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 *d
 	dev->tagsEccUnfixed=0;
 	dev->nErasureFailures = 0;
 	dev->nErasedBlocks = 0;
+	dev->isDoingGC = 0;
 	
 	//dev->localBuffer = YMALLOC(dev->nBytesPerChunk);
 	// Initialise temporary buffers
--- a/yaffs_guts.h
+++ b/yaffs_guts.h
@@ -583,6 +583,7 @@ struct yaffs_DeviceStruct
 	int  nFreeTnodes;
 	yaffs_TnodeList *allocatedTnodeList;
 
+	int   isDoingGC;
 
 	int   nObjectsCreated;
 	yaffs_Object *freeObjects;