• Arne Edholm's avatar
    ubi: Select fastmap anchor PEBs considering wear level rules · 4b68bf9a
    Arne Edholm authored
    There is a risk that the fastmap anchor PEB is alternating between
    just two PEBs, the current anchor and the previous anchor that was just
    deleted. As the fastmap pools gets the first take on free PEBs, the
    pools may leave no free PEBs to be selected as the new anchor,
    resulting in the two PEBs alternating behaviour. If the anchor PEBs gets
    a high erase count the PEBs will not be used by the pools but remain in
    ubi->free, even more increasing the likelihood they will be used as
    anchors.
    
    Getting stuck using only a couple of PEBs continuously will result in an
    uneven wear, eventually leading to failure.
    
    To fix this:
    
    - Choose the fastmap anchor when the most free PEBs are available. This is
      during rebuilding of the fastmap pools, after the unused pool PEBs are
      added to ubi->free but before the pools are populated again from the
      free PEBs. Also reserve an additional second best PEB as a candidate
      for the next time the fast map anchor is updated. If a better PEB is
      found the next time the fast map anchor is updated, the candidate is
      made available for building the pools.
    
    - Enable anchor move within the anchor area again as it is useful for
      distributing wear.
    
    - The anchor candidate for the next fastmap update is the most suited free
      PEB. Check this PEB's erase count during wear leveling. If the wear
      leveling limit is exceeded, the PEB is considered unsuitable for now. As
      all other non used anchor area PEBs should be even worse, free up the
      used anchor area PEB with the lowest erase count.
    Signed-off-by: default avatarArne Edholm <arne.edholm@axis.com>
    Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
    4b68bf9a
wl.c 55.1 KB