diff options
author | Wang Zhaolong <wangzhaolong@huaweicloud.com> | 2025-09-02 17:27:32 +0800 |
---|---|---|
committer | Miquel Raynal <miquel.raynal@bootlin.com> | 2025-09-11 17:34:15 +0200 |
commit | 9781c381c159523c6792b1d08d4be6055e0dbd8b (patch) | |
tree | 0533f6349aec04f04ef7e73543bfd46c0fd87100 /rust/helpers/helpers.c | |
parent | 81eb13a19a8eb259b3d9b1fdf5cbf154f71fc1d0 (diff) |
mtd: core: skip badblocks increment for blocks already known bad
Repeatedly marking the same eraseblock bad inflates
mtd->ecc_stats.badblocks because mtd_block_markbad() unconditionally
increments the counter on success, while some implementations (e.g.
NAND) return 0 both when the block was already bad and when it has just
been marked[1].
Fix by checking if the block is already bad before calling
->_block_markbad() when _block_isbad is available. Only skip the counter
increment when we can confirm the block was already bad. In all other
cases continue incrementing the counter.
This keeps the logic centralized in mtdcore without requiring driver
changes.
Link: https://lore.kernel.org/all/ef573188-9815-4a6b-bad1-3d8ff7c9b16f@huaweicloud.com/ [1]
Signed-off-by: Wang Zhaolong <wangzhaolong@huaweicloud.com>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Diffstat (limited to 'rust/helpers/helpers.c')
0 files changed, 0 insertions, 0 deletions