(This is a resend of a message I sent last week, but I wasn't subscribed to the list at the time so it ended up in list moderator approval land. Apologies in advance if the original message does eventually show up as a duplicate, but I suspect they are buried in a bucket of endless spam and will never be heard from again...) The yaffs2 MTD interface code does not properly translate EUCLEAN into YAFFS_ECC_RESULT_FIXED, which means error corrected blocks will never be scrubbed by the garbage collector, thus missing the chance to correct blocks before they fail in an uncorrectable manner. Also, this patch adds eccUnfixed/eccFixed/tagsEccUnfixed/tagsEccFixed accounting to the yaffs2 MTD interface code. Perhaps also YAFFS_OK should be returned in the case of EUCLEAN, but I couldn't find much that actually used that return value anyway, so I didn't bother with that. --- yaffs2-20081017/yaffs_mtdif2.c 2008-07-22 23:35:12.000000000 -0400 +++ yaffs2/yaffs_mtdif2.c 2008-10-29 14:35:38.000000000 -0400 @@ -176,8 +176,23 @@ if(localData) yaffs_ReleaseTempBuffer(dev,data,__LINE__); - if(tags && retval == -EBADMSG && tags->eccResult == YAFFS_ECC_RESULT_NO_ERROR) - tags->eccResult = YAFFS_ECC_RESULT_UNFIXED; + if (tags) { + + if (tags->eccResult == YAFFS_ECC_RESULT_UNFIXED) + dev->tagsEccUnfixed++; + else if (tags->eccResult == YAFFS_ECC_RESULT_FIXED) + dev->tagsEccFixed++; + + if (retval == -EBADMSG && tags->eccResult < YAFFS_ECC_RESULT_UNFIXED) { + dev->eccUnfixed++; + tags->eccResult = YAFFS_ECC_RESULT_UNFIXED; + } + else if (retval == -EUCLEAN && tags->eccResult < YAFFS_ECC_RESULT_FIXED) { + dev->eccFixed++; + tags->eccResult = YAFFS_ECC_RESULT_FIXED; + } + } + if (retval == 0) return YAFFS_OK; else