[PATCH v2] MTD: modify mtd api to return bitflip info on read operations

Ricard Wanderlof ricard.wanderlof at axis.com
Wed Dec 7 03:01:40 EST 2011


On Wed, 7 Dec 2011, Mike Dunn wrote:

> For UBI, the direction of the discussion was that the driver would 
> indicate the ecc strength of the device (via a new element in struct 
> mtd_info), and this would be the default UBI scrublevel.  A non-zero 
> sysfs parameter would override the default.


>
> BTW, it is currently possible (and easy) to do what Peter suggests; i.e., to
> avoid any UBI rework and make the decision to scrub in the driver.  All the
> driver has to do is not return -EUCLEAN unless it thinks the block should be
> scrubbed.  Of course this would be a lie if there were in fact corrected
> bitflips.  For drivers using the mtd nand interface, the lie would be in the ecc
> stats, since the nand infrastructure code returns -EUCLEAN (or 0) based on
> that.  This is what we willl have to do in the diskonchip drivers in order to
> get ubi/ubifs to work on them if we don't change the mtd api (and afterwards
> make the changes to ubi).

The idea of using -EUCLEAN to indicate that the lower levels think it's 
time for scrubbing appeals to me. One reason is that an upper layer such 
as UBI should not really be concerned with details such as ECC strength 
and number of flipped bits, it seems to me that such things should be left 
to a lower level. Also, one could imagine different variants of flash 
technology requiring different consideration to bit flips and other 
phenomena which again should not be something that for instance UBI needs 
to know about. It makes sense for mtd to have a sweeping knowledge of the 
general types of errors that can occur so that part of the decision can be 
made there.

That said, the level at which the lowest level reports -EUCLEAN could be 
something that is configurable from user space (sysfs), so that it's 
userspace that sets the actual policy and no one else.

So, something like this:
- The driver reports number of bit flips and current ECC strength etc to
   the mtd layer.
- Based on some userspace knob, the mtd framework reports -EUCLEAN if
   scrubbing is needed.
- Upper layers perform scrubbing if they want to (i.e. UBI) or not (i.e.
   JFFS2).

I don't really see this as lying, more of a redefinition of what -EUCLEAN 
really means. The current behavior was invented when single-bit errors 
could be correct and nothing else, and furthermore such bitflips were 
rare; now that multiple-bit errors are commonplace it's time to put more 
detail into what -EUCLEAN implies.  It's not really breaking anything old 
either, if sane defaults are used.

/Ricard
-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30



More information about the linux-mtd mailing list