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

Artem Bityutskiy dedekind1 at gmail.com
Fri Sep 24 04:47:06 EDT 2010


On Thu, 2010-09-23 at 15:55 -0400, Mike Frysinger wrote:
> 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 ?

No, unfortunately, it'd require some work with ancient code - not very
easy task, IMO.

> >> +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.

I think this is not fast-path and it does not hurt to have extra fields
just in case someone else needs them in future.

Also, make sure size of this structure is multiple of 8, not 4.

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

I think no, you should ignore them.  But you should write a comment that
userspace has to zero them, this is kind of part of API. Then when new
flags are added, old kernels will not fail, but ignore them.

But yes, this will work only if userspace follows the API.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)




More information about the linux-mtd mailing list