Skip to content

Commit

Permalink
ubi: Don't do anchor move within fastmap area
Browse files Browse the repository at this point in the history
To make sure that Fastmap can use a PEB within the first 64
PEBs, UBI moves blocks away from that area.
It uses regular wear-leveling for that job.

An anchor move can be triggered if no PEB is free in this area
or because of anticipation. In the latter case it can happen
that UBI decides to move a block but finds a free PEB
within the same area.
This case is in vain an increases only erase counters.

Catch this case and cancel wear-leveling if this happens.

Signed-off-by: Richard Weinberger <[email protected]>
  • Loading branch information
richardweinberger committed Sep 15, 2019
1 parent cbc898d commit 8596813
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/mtd/ubi/wl.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,12 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
if (!e2)
goto out_cancel;

/*
* Anchor move within the anchor area is useless.
*/
if (e2->pnum < UBI_FM_MAX_START)
goto out_cancel;

self_check_in_wl_tree(ubi, e1, &ubi->used);
rb_erase(&e1->u.rb, &ubi->used);
dbg_wl("anchor-move PEB %d to PEB %d", e1->pnum, e2->pnum);
Expand Down

0 comments on commit 8596813

Please sign in to comment.