[BUG] JFFS2 power loss recovery issues on NAND

Alexey Korolev akorolev at infradead.org
Tue Jun 10 09:57:07 EDT 2008


David,

As I prommised we investigated the JFFS2 power loss issues and found
what exactly caused data corruption issues. The issue occurs not
only on the recent kernels (>2.6.25) but on old as well  - so I createed new thread.

The problem occurs when we face power loss during writing ECC bytes to
NAND. 
As we know one page of NAND device has 8 SW ECC regions. Assume 
we have written NAND main area correctly but got a power loss during
write of first 3 ECC bytes. For the first ECC region algorithm detects
that checksum is not the same but it detects one bit error (it is a
common situation for ECC algorithm to improperly detect 1bit error when
actual numer of error bits is large). Since ECC detects one bit error it
"corrects" one bit in NAND main area (in first 256 bytes). For other
regions ECC algorithm returned 2 bit errors and did not perform any
correction. 
JFFS2 ignores read errors from NAND since it has own CRC. On attempt to
read fragment from first 256 bytes JFFS2 detects CRC error as this
region has been improperly corrected and considers
node as invalid. Rest data on page is considered as good. 

So if we write new file during power loss and we have several nodes in
page, we may face bad case with hole in the middle of the file after
power loss. It is a bug. 

The attached picture may explain the issue better. 


So for now it is clear how JFFS2 fails. It is not obvious how to fix it. 
Do you have any suggestions or ideas how it could be fixed?
Would it be a good idea do hack JFFS2 in order to read data one more
time but without ECC correction in case of failed read?


Thanks,
Alexey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jffs2_power_loss.gif
Type: image/gif
Size: 54535 bytes
Desc: explanation of power loss issue
Url : http://lists.infradead.org/pipermail/linux-mtd/attachments/20080610/5a87ad02/attachment-0001.gif 


More information about the linux-mtd mailing list