Skip to content

Commit 7449f69

Browse files
Tomasz Majchrzakshligit
authored andcommitted
raid1: handle read error also in readonly mode
If write is the first operation on a disk and it happens not to be aligned to page size, block layer sends read request first. If read operation fails, the disk is set as failed as no attempt to fix the error is made because array is in auto-readonly mode. Similarily, the disk is set as failed for read-only array. Take the same approach as in raid10. Don't fail the disk if array is in readonly or auto-readonly mode. Try to redirect the request first and if unsuccessful, return a read error. Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Shaohua Li <shli@fb.com>
1 parent 9a8b27f commit 7449f69

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/md/raid1.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,17 +2297,23 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
22972297
* This is all done synchronously while the array is
22982298
* frozen
22992299
*/
2300+
2301+
bio = r1_bio->bios[r1_bio->read_disk];
2302+
bdevname(bio->bi_bdev, b);
2303+
bio_put(bio);
2304+
r1_bio->bios[r1_bio->read_disk] = NULL;
2305+
23002306
if (mddev->ro == 0) {
23012307
freeze_array(conf, 1);
23022308
fix_read_error(conf, r1_bio->read_disk,
23032309
r1_bio->sector, r1_bio->sectors);
23042310
unfreeze_array(conf);
2305-
} else
2306-
md_error(mddev, conf->mirrors[r1_bio->read_disk].rdev);
2311+
} else {
2312+
r1_bio->bios[r1_bio->read_disk] = IO_BLOCKED;
2313+
}
2314+
23072315
rdev_dec_pending(conf->mirrors[r1_bio->read_disk].rdev, conf->mddev);
23082316

2309-
bio = r1_bio->bios[r1_bio->read_disk];
2310-
bdevname(bio->bi_bdev, b);
23112317
read_more:
23122318
disk = read_balance(conf, r1_bio, &max_sectors);
23132319
if (disk == -1) {
@@ -2318,11 +2324,6 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
23182324
} else {
23192325
const unsigned long do_sync
23202326
= r1_bio->master_bio->bi_opf & REQ_SYNC;
2321-
if (bio) {
2322-
r1_bio->bios[r1_bio->read_disk] =
2323-
mddev->ro ? IO_BLOCKED : NULL;
2324-
bio_put(bio);
2325-
}
23262327
r1_bio->read_disk = disk;
23272328
bio = bio_clone_mddev(r1_bio->master_bio, GFP_NOIO, mddev);
23282329
bio_trim(bio, r1_bio->sector - bio->bi_iter.bi_sector,

0 commit comments

Comments
 (0)