md/raid1,raid10: don't fail devices for invalid IO errors
PATCH 1/1 md/raid1,raid10: don't fail devices for invalid IO errors
From: Keith Busch <[email protected]>
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.
--- drivers/md/raid1-10.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/md/raid1-10.c +6 -1
@@ -293,8 +293,13 @@ static inline bool raid1_should_read_first(struct mddev *mddev,* bio with REQ_RAHEAD or REQ_NOWAIT can fail at anytime, before such IO is * submitted to the underlying disks, hence don't record badblocks or retry * in this case. +* +* BLK_STS_INVAL means the bio was not valid for the underlying device. This +* is a user error, not a device failure, so retrying or recording bad blocks +* would be wrong. */ static inline bool raid1_should_handle_error (struct bio *bio) { -return !(bio->bi_opf & (REQ_RAHEAD |REQ_NOWAIT )); +return !(bio->bi_opf & (REQ_RAHEAD |REQ_NOWAIT )) && + bio->bi_status !=BLK_STS_INVAL ; }
Signature · 1 line
2.52.0
Quoted 19 lines · CEST Keith Busch
From: Keith Busch <[email protected]>
BLK_STS_INVALindicates 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 callsmd_handle_request()directly without going throughmd_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 withBLK_STS_INVAL, and raid1 wrongly interprets this as a device failure.Add
BLK_STS_INVALtoraid1_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.
Quoted 4 lines
Fixes 5ff3f74e145adc7 ("block: simplify direct io validity check")Reported-by Tomáš Trnka <[email protected]>Signed-off-by Keith Busch <[email protected]>
Quoted 23 lines
--- drivers/md/raid1-10.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/md/raid1-10.c +0
-0@@ -293,8 +293,13 @@ static inline bool raid1_should_read_first(struct mddev *mddev, * bio with REQ_RAHEAD or REQ_NOWAIT can fail at anytime, beforesuch IO is * submitted to the underlying disks, hence don't record badblocks or retry * in this case.
+ *
+ *BLK_STS_INVALmeans the bio was not valid for the underlying device. This + * is a user error, not a device failure, so retrying or recording bad blocks + * would be wrong.
*/
static inline boolraid1_should_handle_error(struct bio *bio){drivers/md/raid1-10.c +2
-1-return !(bio->bi_opf & (REQ_RAHEAD |REQ_NOWAIT )); +return !(bio->bi_opf & (REQ_RAHEAD |REQ_NOWAIT )) && + bio->bi_status !=BLK_STS_INVAL ; }
Yu Kuai
AppliedQuoted 19 lines · Keith Busch
From: Keith Busch<[email protected]>
BLK_STS_INVALindicates 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 callsmd_handle_request()directly without going throughmd_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 withBLK_STS_INVAL, and raid1 wrongly interprets this as a device failure.Add
BLK_STS_INVALtoraid1_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.
Quoted 7 lines
Fixes 5ff3f74e145adc7 ("block: simplify direct io validity check")Reported-by Tomáš Trnka<[email protected]>Signed-off-by Keith Busch<[email protected]>--- drivers/md/raid1-10.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Applied
Signature · 2 lines
Thansk, Kuai