Hello,
I would like to submit back to Yaffs community same changes I have done to
yaffs2.
miscfix.patch:
1) bugfix in case if Chunk Erase Check is not done (failed write will make a
lot of bad blocks);
2) lower limit of nReservedBlocks and nCheckpointReservedBlocks in case of
small partition (otherwise on 4MB partition only 2MB is usable in case of
large block nand);
rwcounters.patch:
fixed nPageReads and nPageWrites to work on large block nand devices as well;
badblocks.patch:
added /proc/yaffs to show number of bad blocks;
ccwarn.patch:
fixed few compilation warnings;
Best regards,
Artis
diff -u yaffs2/yaffs_nand.c yaffs2-mine/yaffs_nand.c
--- yaffs2/yaffs_nand.c 2006-05-08 13:13:34.000000000 +0300
+++ yaffs2-mine/yaffs_nand.c 2006-06-12 11:55:41.000000000 +0300
@@ -26,6 +26,8 @@
{
chunkInNAND -= dev->chunkOffset;
+ dev->nPageReads++;
+
if (dev->readChunkWithTagsFromNAND)
return dev->readChunkWithTagsFromNAND(dev, chunkInNAND, buffer,
tags);
@@ -60,6 +62,8 @@
YBUG();
}
+ dev->nPageWrites++;
+
if (dev->writeChunkWithTagsToNAND)
return dev->writeChunkWithTagsToNAND(dev, chunkInNAND, buffer,
tags);
diff -u yaffs2/yaffs_tagscompat.c yaffs2-mine/yaffs_tagscompat.c
--- yaffs2/yaffs_tagscompat.c 2005-11-29 22:54:32.000000000 +0200
+++ yaffs2-mine/yaffs_tagscompat.c 2006-06-12 11:55:35.000000000 +0300
@@ -173,7 +173,6 @@
return YAFFS_FAIL;
}
- dev->nPageWrites++;
return dev->writeChunkToNAND(dev, chunkInNAND, data, spare);
}
@@ -187,8 +186,6 @@
int retVal;
yaffs_Spare localSpare;
- dev->nPageReads++;
-
if (!spare && data) {
/* If we don't have a real spare, then we use a local one. */
/* Need this for the calculation of the ecc */
diff -u yaffs2/yaffs_fs.c yaffs2-mine/yaffs_fs.c
--- yaffs2/yaffs_fs.c 2006-06-05 07:12:44.000000000 +0300
+++ yaffs2-mine/yaffs_fs.c 2006-06-12 12:15:08.000000000 +0300
@@ -1565,6 +1565,11 @@
nBlocks = mtd->size / mtd->erasesize;
dev->nCheckpointReservedBlocks = 10;
+ if (nBlocks < (dev->nReservedBlocks + 1 +
+ dev->nCheckpointReservedBlocks) * 10) {
+ dev->nCheckpointReservedBlocks = 0;
+ dev->nReservedBlocks = max(nBlocks / 10, 1);
+ }
dev->startBlock = 0;
dev->endBlock = nBlocks - 1;
} else {
diff -u yaffs2/yaffs_guts.c yaffs2-mine/yaffs_guts.c
--- yaffs2/yaffs_guts.c 2006-06-05 07:10:49.000000000 +0300
+++ yaffs2-mine/yaffs_guts.c 2006-06-12 12:15:08.000000000 +0300
@@ -331,6 +331,8 @@
/* First check this chunk is erased... */
#ifndef CONFIG_YAFFS_DISABLE_CHUNK_ERASED_CHECK
writeOk = yaffs_CheckChunkErased(dev, chunk);
+#else
+ writeOk = 1;
#endif
if (!writeOk) {
T(YAFFS_TRACE_ERROR,
diff -u yaffs2/yaffs_fs.c yaffs2-mine/yaffs_fs.c
--- yaffs2/yaffs_fs.c 2006-06-05 07:12:44.000000000 +0300
+++ yaffs2-mine/yaffs_fs.c 2006-06-12 12:00:22.000000000 +0300
@@ -1732,6 +1732,7 @@
dev->passiveGarbageCollections);
buf += sprintf(buf, "nRetriedWrites..... %d\n", dev->nRetriedWrites);
buf += sprintf(buf, "nRetireBlocks...... %d\n", dev->nRetiredBlocks);
+ buf += sprintf(buf, "nBadBlocks......... %d\n", dev->nBadBlocks);
buf += sprintf(buf, "eccFixed........... %d\n", dev->eccFixed);
buf += sprintf(buf, "eccUnfixed......... %d\n", dev->eccUnfixed);
buf += sprintf(buf, "tagsEccFixed....... %d\n", dev->tagsEccFixed);
diff -u yaffs2/yaffs_guts.c yaffs2-mine/yaffs_guts.c
--- yaffs2/yaffs_guts.c 2006-06-05 07:10:49.000000000 +0300
+++ yaffs2-mine/yaffs_guts.c 2006-06-12 12:00:44.000000000 +0300
@@ -384,6 +384,7 @@
YAFFS_BLOCK_STATE_DEAD;
dev->nRetiredBlocks++;
+ dev->nBadBlocks++;
}
/*
@@ -4517,6 +4518,7 @@
if (state == YAFFS_BLOCK_STATE_DEAD) {
T(YAFFS_TRACE_BAD_BLOCKS,
(TSTR("block %d is bad" TENDSTR), blk));
+ dev->nBadBlocks++;
} else if (state == YAFFS_BLOCK_STATE_EMPTY) {
T(YAFFS_TRACE_SCAN_DEBUG,
(TSTR("Block empty " TENDSTR)));
@@ -6183,6 +6185,7 @@
dev->tagsEccUnfixed = 0;
dev->nErasureFailures = 0;
dev->nErasedBlocks = 0;
+ dev->nBadBlocks = 0;
dev->isDoingGC = 0;
/* Initialise temporary buffers and caches. */
diff -u yaffs2/yaffs_guts.h yaffs2-mine/yaffs_guts.h
--- yaffs2/yaffs_guts.h 2006-05-17 12:31:06.000000000 +0300
+++ yaffs2-mine/yaffs_guts.h 2006-06-12 12:00:48.000000000 +0300
@@ -683,6 +683,7 @@
int passiveGarbageCollections;
int nRetriedWrites;
int nRetiredBlocks;
+ int nBadBlocks;
int eccFixed;
int eccUnfixed;
int tagsEccFixed;
diff -u yaffs2/yaffs_guts.c yaffs2-mine/yaffs_guts.c
--- yaffs2/yaffs_guts.c 2006-06-05 07:10:49.000000000 +0300
+++ yaffs2-mine/yaffs_guts.c 2006-06-12 12:22:43.000000000 +0300
@@ -4466,7 +4466,6 @@
int deleted;
yaffs_BlockState state;
yaffs_Object *hardList = NULL;
- yaffs_Object *hl;
yaffs_BlockInfo *bi;
int sequenceNumber;
yaffs_ObjectHeader *oh;
diff -u yaffs2/yaffs_qsort.c yaffs2-mine/yaffs_qsort.c
--- yaffs2/yaffs_qsort.c 2006-05-21 12:34:12.000000000 +0300
+++ yaffs2-mine/yaffs_qsort.c 2006-06-12 12:22:43.000000000 +0300
@@ -74,6 +74,7 @@
:(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));
}
+#undef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
void
qsort(void *aa, size_t n, size_t es, int (*cmp)(const void *, const void *))