[PATCH] mtd/ubi: recognize empty flash with errors as empty
Sebastian Andrzej Siewior
sebastian at breakpoint.cc
Mon Apr 26 04:28:55 EDT 2010
* Artem Bityutskiy | 2010-04-26 07:59:50 [+0300]:
>On Sun, 2010-04-25 at 23:09 +0200, Sebastian Andrzej Siewior wrote:
>> * Artem Bityutskiy | 2010-04-24 14:24:01 [+0300]:
>>
>> >Thanks, pushed to ubi-2.6.git / master with the following minor tweak,
>> >please check:
>> >
>> >diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
>> >index 7529d46..48e570c 100644
>> >--- a/drivers/mtd/ubi/scan.c
>> >+++ b/drivers/mtd/ubi/scan.c
>> >@@ -756,12 +756,12 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
>> > bitflips = 1;
>> > }
>> >
>> >- if (err != UBI_IO_BAD_EC_HDR)
>> >- si->is_empty = 0;
>> >-
>> > if (!ec_corr) {
>> > int image_seq;
>> >
>> >+ /* There is an EC header, so the flash is not empty */
>> >+ si->is_empty = 0;
>> >+
>> > /* Make sure UBI version is OK */
>> > if (ech->version != UBI_VERSION) {
>> > ubi_err("this UBI version is %d, image version is %d",
>> >
>>
>> I guess that's okay. What are the chances that you can't read the EC
>> header but you can somehow read the VID header.
>
>When the VID header sits in the next NAND page, there are some changes,
>but I never observed such a situation in practice.
>
>> AND if there is a valid
>> VID header then there is more, and si->is_empty will be set later on,
>> right?
>
>Yes, AFAICS.
Oh. UBI_IO_BAD_EC_HDR / UBI_IO_BAD_VID_HDR is returned when
- the page page can not be read
- the page contains non-ubi information
So I think the latter case is now broken. In fact I just copied some
random things into my mtd partition and after attach & mkvol they were
gone with no error.
So in case we want to support something other than UBI then we should
probably add another error code in order to distinguish between read
error and not a vald EC / VID header.
Sebastian
More information about the linux-mtd
mailing list