Skip to content

Commit ca294b3

Browse files
Li Nanliu-song-6
authored andcommitted
md/raid1: support read error check
After commit 1e50915 ("raid: improve MD/raid10 handling of correctable read errors."), rdev will be set to faulty if it reads data error to many times in raid10. Add this mechanism to raid1 now. Signed-off-by: Li Nan <linan122@huawei.com> Signed-off-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/r/20231215023852.3478228-3-linan666@huaweicloud.com
1 parent 1979dbb commit ca294b3

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

drivers/md/raid1.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,16 +2256,24 @@ static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio)
22562256
* 3. Performs writes following reads for array synchronising.
22572257
*/
22582258

2259-
static void fix_read_error(struct r1conf *conf, int read_disk,
2260-
sector_t sect, int sectors)
2259+
static void fix_read_error(struct r1conf *conf, struct r1bio *r1_bio)
22612260
{
2261+
sector_t sect = r1_bio->sector;
2262+
int sectors = r1_bio->sectors;
2263+
int read_disk = r1_bio->read_disk;
22622264
struct mddev *mddev = conf->mddev;
2265+
struct md_rdev *rdev = rcu_dereference(conf->mirrors[read_disk].rdev);
2266+
2267+
if (exceed_read_errors(mddev, rdev)) {
2268+
r1_bio->bios[r1_bio->read_disk] = IO_BLOCKED;
2269+
return;
2270+
}
2271+
22632272
while(sectors) {
22642273
int s = sectors;
22652274
int d = read_disk;
22662275
int success = 0;
22672276
int start;
2268-
struct md_rdev *rdev;
22692277

22702278
if (s > (PAGE_SIZE>>9))
22712279
s = PAGE_SIZE >> 9;
@@ -2506,8 +2514,7 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
25062514
if (mddev->ro == 0
25072515
&& !test_bit(FailFast, &rdev->flags)) {
25082516
freeze_array(conf, 1);
2509-
fix_read_error(conf, r1_bio->read_disk,
2510-
r1_bio->sector, r1_bio->sectors);
2517+
fix_read_error(conf, r1_bio);
25112518
unfreeze_array(conf);
25122519
} else if (mddev->ro == 0 && test_bit(FailFast, &rdev->flags)) {
25132520
md_error(mddev, rdev);

0 commit comments

Comments
 (0)