ubi: fastmap: Get wl PEB even ec beyonds the 'max' if free PEBs are run out
authorZhihao Cheng <chengzhihao1@huawei.com>
Mon, 28 Aug 2023 06:38:42 +0000 (14:38 +0800)
committerRichard Weinberger <richard@nod.at>
Sat, 28 Oct 2023 21:07:54 +0000 (23:07 +0200)
commit761893bd490b039258fda893c2a15fa59334c820
tree098ecc0109750de81cbb973bde7af72ff1c170b2
parenteada823e6a6fb856548f6e0c7a343cd5c41bb9d3
ubi: fastmap: Get wl PEB even ec beyonds the 'max' if free PEBs are run out

This is the part 2 to fix cyclically reusing single fastmap data PEBs.

Consider one situation, if there are four free PEBs for fm_anchor, pool,
wl_pool and fastmap data PEB with erase counter 100, 100, 100, 5096
(ubi->beb_rsvd_pebs is 0). PEB with erase counter 5096 is always picked
for fastmap data according to the realization of find_wl_entry(), since
fastmap data PEB is not scheduled for wl, finally there are two PEBs
(fm data) with great erase counter than other PEBS.
Get wl PEB even its erase counter exceeds the 'max' in find_wl_entry()
when free PEBs are run out after filling pools and fm data. Then the PEB
with biggest erase conter is taken as wl PEB, it can be scheduled for wl.

Fixes: dbb7d2a88d2a ("UBI: Add fastmap core")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217787
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/fastmap-wl.c
drivers/mtd/ubi/wl.c