UBIFS seeing corrupt blank pages when image flashed via u-boot

Gupta, Pekon pekon at ti.com
Wed Jan 15 16:29:07 EST 2014


Hi Artem,

>From: Artem Bityutskiy [mailto:artem.bityutskiy at linux.intel.com]
<snip>
>Conclusion: all UBIFS needs is a way to ask the driver - is this NAND
>page blank or not? UBIFS does not really has to compare to all 0xFFs.
>
Thanks for details. Yes, I understand the concept in general that you
want to recover last bit of user-data written on NAND (without corruption).

Now, as NAND driver itself does differentiation between and erased-page
v/s programmed-page. Can we use different error codes to pass this
information to upper layers like;

*For MTD layer*
0: data valid, length of data is determined by 'read_len'  (currently)
-EUCLEAN: correctable bit-flips found, data is valid
-EBADMSG: un-correctable bit-flips, data *may-be* invalid.
-ENODATA: detected erased-page. *Actual* data determined by read_len.
-ENOMSG:  detected erased-page with bit-flips. *Actual* data determined by read_len.

*For UBI layer*
We can convert the MTD error-codes into UBI specific error-codes at
ubi_io_read() interface. This way many checks in other parts of UBI
layer can be simplified, and even slightly speed-up scan_peb().

--------------------------
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index bf79def..9b011b9 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -168,18 +168,24 @@ retry:
        if (err) {
                const char *errstr = mtd_is_eccerr(err) ? " (ECC error)" : "";

-               if (mtd_is_bitflip(err)) {
-                       /*
-                        * -EUCLEAN is reported if there was a bit-flip which
-                        * was corrected, so this is harmless.
-                        *
-                        * We do not report about it here unless debugging is
-                        * enabled. A corresponding message will be printed
-                        * later, when it is has been scrubbed.
-                        */
+               switch (err) {
+               case -EUCLEAN:
                        ubi_msg("fixable bit-flip detected at PEB %d", pnum);
                        ubi_assert(len == read);
                        return UBI_IO_BITFLIPS;
+               case -ENODATA:
+                       if (read == 0)
+                               return UBI_IO_FF;
+                       else
+                               return 0;
+               case -ENOMSG:
+                       if (read == 0)
+                               return UBI_IO_FF_BITFLIPS;
+                       else
+                               return UBI_IO_BITFLIPS;
+               case -EBADMSG:
+               default:
+                       continue;
                }
--------------------------

Also, please consider, if this approach is even feasible for other types
of MTD devices (NOR and OneNAND) ?


with regards, pekon


More information about the linux-mtd mailing list