linux equivalent of u-boot's "nand scrub" (erasing blocks even when OOB says "bad")

Mike Frysinger vapier.adi at
Thu Sep 23 15:55:17 EDT 2010

On Thu, Sep 23, 2010 at 08:28, Artem Bityutskiy wrote:
> On Wed, 2010-09-22 at 03:43 -0400, Mike Frysinger wrote:
>> here's a POC that works for me.  with a simple tweak to `flash_eraseall`, i
>> can now recover my mtd devices with funky OOB layouts.
>> ive only extended MEMERASE64 as i believe the non-64 variants are EOL ?  or
>> should i also extend the 32bit interface as well ?
> We need something consistent. This patch will just erase the bad
> eraseblock. This will not mark it as good in the BBT (neither in-ram nor
> on-flash). If the erasure succeeds, the block will still be marked as
> bad in BBT, but after reboot, if the BBT is not on-flash, it will be
> treated as good eraseblock, because scanning will not find the bad block
> marker anymore. If the BBT is on-flash, it'll stay bad. This is
> inconsistent.

i dont think the current BBT API supports marking bad blocks as good ?
 if it does, could you highlight it for me ?

>> +struct erase_info_user64_flags {
>> +     __u64 start;
>> +     __u64 length;
>> +     __u32 flags;
>> +};
> I think it needs to have som more room for possible future extentions.
> Also, good tone for ioctls is to make them to be multiple of 64-bit -
> less pain in mixed 32/64 bit setups.
> Please, add some
> u8 padding[12]
> field and add a comment that this has to be zero, and may be used in
> future.
> Then in future we may extend ioctls and add more fields.

well, the idea i have with flags is that we carve one bit out to mean
"extend".  so if in the future we wanted to extend the struct, we set
that flag and the kernel knows that userspace wants the larger
version.  that gives you a way of extending things indefinitely at the
cost of 1 bit.

which also means i should probably carve that bit out now and have the
kernel return an error when it is set today.

>> +#define MEMERASE64_FLAGS     _IOW('M', 23, struct erase_info_user64_flags)
> I do not like the name. We may add something else, not just flags later.

i was going to use "MEMERASE2", but that didnt scale well with "MEMERASE264".



More information about the linux-mtd mailing list