]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
ubi: fastmap: Fix missed fm_anchor PEB in wear-leveling after disabling fastmap
authorZhihao Cheng <chengzhihao1@huawei.com>
Tue, 9 Aug 2022 07:06:19 +0000 (15:06 +0800)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 14 Mar 2023 15:47:48 +0000 (16:47 +0100)
commit5772a1dbe6f6299c268451d8ec2e771eefe31325
tree06dea724964bacab01ca48d560870dfdd7ed99be
parent096e7c2a734caf3a2efc874716cda7eae2e98b17
ubi: fastmap: Fix missed fm_anchor PEB in wear-leveling after disabling fastmap

BugLink: https://bugs.launchpad.net/bugs/2011430
[ Upstream commit 76f9476ece445a07aeb72df9d896cd563fb5b50f ]

After disabling fastmap(ubi->fm_disabled = 1), fastmap won't be updated,
fm_anchor PEB is missed being scheduled for erasing. Besides, fm_anchor
PEB may have smallest erase count, it doesn't participate wear-leveling.
The difference of erase count between fm_anchor PEB and other PEBs will
be larger and larger later on.

In which situation fastmap can be disabled? Initially, we have an UBI
image with fastmap. Then the image will be atttached without module
parameter 'fm_autoconvert', ubi turns to full scanning mode in one
random attaching process(eg. bad fastmap caused by powercut), ubi
fastmap is disabled since then.

Fix it by not getting fm_anchor if fastmap is disabled in
ubi_refill_pools().

Fetch a reproducer in [Link].

Link: https://bugzilla.kernel.org/show_bug.cgi?id=216341
Fixes: 4b68bf9a69d22d ("ubi: Select fastmap anchor PEBs considering ...")
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mtd/ubi/fastmap-wl.c