bi->blockState = YAFFS_BLOCK_STATE_DIRTY;
+ /* If this is the block being garbage collected then stop gc'ing this block */
+ if(blockNo == dev->gcBlock)
+ dev->gcBlock = -1;
+
if (!bi->needsRetiring) {
yaffs_InvalidateCheckpoint(dev);
erasedOk = yaffs_EraseBlockInNAND(dev, blockNo);
bi->hasShrinkHeader = 0; /* clear the flag so that the block can erase */
- /* Take off the number of soft deleted entries because
- * they're going to get really deleted during GC.
- */
- if(dev->gcChunk == 0) /* first time through for this block */
- dev->nFreeChunks -= bi->softDeletions;
-
dev->isDoingGC = 1;
if (isCheckpointBlock ||
* No need to copy this, just forget about it and
* fix up the object.
*/
+
+ /* Free chunks already includes softdeleted chunks.
+ * How ever this chunk is going to soon be really deleted
+ * which will increment free chunks.
+ * We have to decrement free chunks so this works out properly.
+ */
+ dev->nFreeChunks--;
object->nDataChunks--;
- /* If the gc completed then clear the current gcBlock so that we find another. */
- if (bi->blockState != YAFFS_BLOCK_STATE_COLLECTING) {
+ if (bi->blockState == YAFFS_BLOCK_STATE_COLLECTING) {
+ /*
+ * The gc did not complete. Set block state back to FULL
+ * because checkpointing does not restore gc.
+ */
+ bi->blockState = YAFFS_BLOCK_STATE_FULL;
+ } else {
+ /* The gc completed. */
chunksAfter = yaffs_GetErasedChunks(dev);
if (chunksBefore >= chunksAfter) {
T(YAFFS_TRACE_GC,
int retVal;
int immediateDeletion = 0;
+ yaffs_Device *dev = in->myDev;
if (!in->myInode)
immediateDeletion = 1;
in->objectId));
in->deleted = 1;
in->myDev->nDeletedFiles++;
- if (1 || in->myDev->param.isYaffs2)
+ if (dev->param.disableSoftDelete || dev->param.isYaffs2)
yaffs_ResizeFile(in, 0);
yaffs_SoftDeleteFile(in);
} else {
{
int retVal = YAFFS_OK;
int deleted = in->deleted;
+ yaffs_Device *dev = in->myDev;
- yaffs_ResizeFile(in, 0);
+ if (dev->param.disableSoftDelete || dev->param.isYaffs2)
+ yaffs_ResizeFile(in, 0);
if (in->nDataChunks > 0) {
/* Use soft deletion if there is data in the file.