Skip to content

Commit 71cc21e

Browse files
author
Ming Lei
committed
md/raid1: Add check for missing source disk in process_checks()
JIRA: https://issues.redhat.com/browse/RHEL-106845 commit b7c178d Author: Meir Elisha <meir.elisha@volumez.com> Date: Tue Apr 8 17:38:08 2025 +0300 md/raid1: Add check for missing source disk in process_checks() During recovery/check operations, the process_checks function loops through available disks to find a 'primary' source with successfully read data. If no suitable source disk is found after checking all possibilities, the 'primary' index will reach conf->raid_disks * 2. Add an explicit check for this condition after the loop. If no source disk was found, print an error message and return early to prevent further processing without a valid primary source. Link: https://lore.kernel.org/linux-raid/20250408143808.1026534-1-meir.elisha@volumez.com Signed-off-by: Meir Elisha <meir.elisha@volumez.com> Suggested-and-reviewed-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Ming Lei <ming.lei@redhat.com>
1 parent bb7c988 commit 71cc21e

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

drivers/md/raid1.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,14 +2202,9 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
22022202
if (!rdev_set_badblocks(rdev, sect, s, 0))
22032203
abort = 1;
22042204
}
2205-
if (abort) {
2206-
conf->recovery_disabled =
2207-
mddev->recovery_disabled;
2208-
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
2209-
md_done_sync(mddev, r1_bio->sectors, 0);
2210-
put_buf(r1_bio);
2205+
if (abort)
22112206
return 0;
2212-
}
2207+
22132208
/* Try next page */
22142209
sectors -= s;
22152210
sect += s;
@@ -2348,10 +2343,21 @@ static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio)
23482343
int disks = conf->raid_disks * 2;
23492344
struct bio *wbio;
23502345

2351-
if (!test_bit(R1BIO_Uptodate, &r1_bio->state))
2352-
/* ouch - failed to read all of that. */
2353-
if (!fix_sync_read_error(r1_bio))
2346+
if (!test_bit(R1BIO_Uptodate, &r1_bio->state)) {
2347+
/*
2348+
* ouch - failed to read all of that.
2349+
* No need to fix read error for check/repair
2350+
* because all member disks are read.
2351+
*/
2352+
if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery) ||
2353+
!fix_sync_read_error(r1_bio)) {
2354+
conf->recovery_disabled = mddev->recovery_disabled;
2355+
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
2356+
md_done_sync(mddev, r1_bio->sectors, 0);
2357+
put_buf(r1_bio);
23542358
return;
2359+
}
2360+
}
23552361

23562362
if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery))
23572363
process_checks(r1_bio);

0 commit comments

Comments
 (0)