Skip to content

Commit b7c178d

Browse files
Meir ElishaYuKuai-huawei
authored andcommitted
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>
1 parent 6ec1f02 commit b7c178d

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
@@ -2200,14 +2200,9 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
22002200
if (!rdev_set_badblocks(rdev, sect, s, 0))
22012201
abort = 1;
22022202
}
2203-
if (abort) {
2204-
conf->recovery_disabled =
2205-
mddev->recovery_disabled;
2206-
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
2207-
md_done_sync(mddev, r1_bio->sectors, 0);
2208-
put_buf(r1_bio);
2203+
if (abort)
22092204
return 0;
2210-
}
2205+
22112206
/* Try next page */
22122207
sectors -= s;
22132208
sect += s;
@@ -2346,10 +2341,21 @@ static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio)
23462341
int disks = conf->raid_disks * 2;
23472342
struct bio *wbio;
23482343

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

23542360
if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery))
23552361
process_checks(r1_bio);

0 commit comments

Comments
 (0)