ext2 and fat32 can't handle bad block of nand flash?

Sphinx King alpharoot at gmail.com
Sat Sep 17 08:55:05 EDT 2005


Hi all,
It sounds like we can not use ext2 or fat32 file system on nand flash
if the nand flash has bad blocks.

My board has only one bad block which can be handled by mtd driver
because I saw message like "bad eraseblock ..." during linux booting
up. I've managed to use mke2fs to format the mtdblock as ext2
(although it has bad block). When I copy file to this partition, it
soulds like ext2 still attempts to write data to the bad block
although this bad block is already put into the mtd bad block table.
This finally results in I/O error and the write fails. I also tried
fat32 and got the same result.

After looking into the mtd code, I found the write request (which is
from the up layer) to the bad block is transfered to the function
do_cached_write() in mtdblock.c. In this function mtd might do a
cached_write after it receives data from up layer, ie., it attempts to
read out sector data and do buffering, which will be written back to
the block later. Here the problem comes out. Since the block is bad,
an ECC error occurs which results in the failure of the read. And the
do_cached_write() returns error to inform up layer. However it seems
the up layer will try to write to the bad block again and again
although the write fails. Finally the copy of file completes but the
file is corrupt.

Is my understanding correct? Why ext2 or fat32 trys to write to a bad
block? Can we use ext2 or fat on nand flash if the flash has bad
block?

By reading some doc I was told there is no such problem for jffs2
because jffs2 can handle bad block info. Is it true? Currently I
haven't try jffs2 yet. I will try it in some days.

Can anybody help me on this? Thanks in advance.

-- 
Sphinx




More information about the linux-mtd mailing list