[PATCH] ubifs: Bound lpt_gc() retries when LPT GC makes no progress
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Tue Nov 24 12:48:17 PST 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ubifs: missing Fixes trailer for LPT GC infinite loop fix in
lpt_gc()
--
commit 55a4a4fac9e4853bd36c8438d3e0d2d5af7bf8dd
Author: Devin Armstrong <darmstrong at tantalus.com>
> ubifs: Bound lpt_gc() retries when LPT GC makes no progress
>
> ubifs_lpt_start_commit() and ubifs_lpt_post_commit() call lpt_gc() in a
> "while (need_write_all(c))" loop. If lpt_gc_lnum() cannot dirty every
> node of the LEB it was given, that LEB's free + dirty space never
> reaches leb_size, need_write_all() keeps returning 1, lpt_gc() keeps
> selecting the same LEB, and the loop never ends.
>
> One way to get there is the LPT scanning problem reported in the link
> below: the 0xff padding at the end of an LPT commit followed by the
> first bytes of the next commit's lsave node can form a valid-looking
> node (the 16-bit CRC matches by chance). When this happens, a read-write
> mount or remount spins in the kernel at 100% CPU and can't be killed.
> Read-only mounts never commit, so they are not affected.
>
> Track the LEB and its dirty space selected by lpt_gc() in the caller's
> loop. If the same LEB is selected UBIFS_LPT_GC_MAX_RETRIES times in a
> row with unchanged dirty space, return -EUCLEAN. Any pass that makes
> progress changes the dirty space and restarts the count, so the normal
> GC retry cycle is unaffected.
>
> The error makes the commit fail, which puts UBIFS in read-only mode, so
> the mount or remount fails with an error instead of hanging. This does
> not repair the LPT, it only turns an endless loop into a failure.
>
> Link: https://lore.kernel.org/linux-mtd/97ca7fe4-4ad4-edd1-e97a-1d540aeabe2d@huawei.com/
>
> Signed-off-by: Devin Armstrong <darmstrong at tantalus.com>
[Severity: Low]
This fixes an infinite loop in the LPT GC commit path. Should it include:
Fixes: 1e51764a3c2a ("UBIFS: add new flash file system")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124-lpt-gc-send-v1-1-eb975487c6d5@tantalus.com?part=1
More information about the linux-mtd
mailing list