Re: [PATCH v2] md/raid5: fix inverted condition in rdev_set_badblocks call
From: yu kuai
Date: Mon Nov 02 2026 - 21:02:50 EST
在 2026/10/17 16:37, zhanghao 写道:
> Commit fd4d44c14ff6 ("md: mark rdev Faulty when badblocks setting fails")
> attempted to unify badblock handling but introduced a logic inversion in
> raid5_end_read_request().
>
> The original check was:
>
> if (!(set_bad && In_sync && rdev_set_badblocks(...)))
> md_error(...);
>
> which records badblocks when `set_bad && In_sync`, and calls md_error()
> either when recording fails or when the rdev is not In_sync. The new
> condition `if (!(set_bad && In_sync))` skips rdev_set_badblocks() exactly
> during recovery/reshape (In_sync is set), so failed badblock updates no
> longer trigger md_error() and the rdev is not marked Faulty. This allows
> reconstruction to continue on a disk with a saturated badblock table,
> potentially propagating corrupted data to the replacement disk.
>
> Restore the intended behavior by recording badblocks when `set_bad &&
> In_sync`, and calling md_error() in the else branch so that non-In_sync
> rdevs, replacement devices, and the too-many-read-errors path are still
> marked Faulty.
>
> Fixes: fd4d44c14ff6 ("md: mark rdev Faulty when badblocks setting fails")
> Cc:stable@xxxxxxxxxxxxxxx
> Signed-off-by: zhanghao<zh_exit@xxxxxxx>
> ---
> v2:
> - Add the else branch calling md_error() for the !(set_bad && In_sync)
> cases, as pointed out by Sashiko: replacement device read errors,
> the too-many-read-errors path, and non-In_sync uncorrectable reads
> would otherwise no longer mark the rdev Faulty.
>
> drivers/md/raid5.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Applied
--
Thanks,
Kuai