Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

md/raid1,raid10: don't fail devices for invalid IO errors

BLK_STS_INVAL indicates the IO request itself was invalid, not that the
device has failed. When raid1 treats this as a device error, it retries
on alternate mirrors which fail the same way, eventually exceeding the
read error threshold and removing the device from the array.

This happens when stacking configurations bypass bio_split_to_limits()
in the IO path: dm-raid calls md_handle_request() directly without going
through md_submit_bio(), skipping the alignment validation that would
otherwise reject invalid bios early. The invalid bio reaches the
lower block layers, which fail the bio with BLK_STS_INVAL, and raid1
wrongly interprets this as a device failure.

Add BLK_STS_INVAL to raid1_should_handle_error() so that invalid IO
errors are propagated back to the caller rather than triggering device
removal. This is consistent with the previous kernel behavior when
alignment checks were done earlier in the direct-io path.

Fixes: 5ff3f74e145adc7 ("block: simplify direct io validity check")

Reported-by: Tomáš Trnka <trnka@scm.com>
Closes: https://lore.kernel.org/linux-block/2982107.4sosBPzcNG@electra/
Signed-off-by: Keith Busch <kbusch@kernel.org>
Tested-by: Tomáš Trnka <trnka@scm.com>
Link: https://lore.kernel.org/r/20260416140345.3872265-1-kbusch@meta.com
Signed-off-by: Yu Kuai <yukuai@fnnas.com>

authored by

Keith Busch and committed by
Yu Kuai
f7b24c7b 45f96d75

+6 -1
+6 -1
drivers/md/raid1-10.c
··· 293 293 * bio with REQ_RAHEAD or REQ_NOWAIT can fail at anytime, before such IO is 294 294 * submitted to the underlying disks, hence don't record badblocks or retry 295 295 * in this case. 296 + * 297 + * BLK_STS_INVAL means the bio was not valid for the underlying device. This 298 + * is a user error, not a device failure, so retrying or recording bad blocks 299 + * would be wrong. 296 300 */ 297 301 static inline bool raid1_should_handle_error(struct bio *bio) 298 302 { 299 - return !(bio->bi_opf & (REQ_RAHEAD | REQ_NOWAIT)); 303 + return !(bio->bi_opf & (REQ_RAHEAD | REQ_NOWAIT)) && 304 + bio->bi_status != BLK_STS_INVAL; 300 305 }