md/raid1: Mark device want_replacement when we see a write error.

Now that WantReplacement drives are replaced cleanly, mark a drive
as want_replacement when we see a write error.  It might get failed soon so
the WantReplacement flag is irrelevant, but if the write error is recorded
in the bad block log, we still want to activate any spare that might
be available.

Signed-off-by:  NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2011-12-23 10:17:57 +11:00
Родитель 7ef449d1ec
Коммит 19d671695e
1 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -391,6 +391,11 @@ static void raid1_end_write_request(struct bio *bio, int error)
if (!uptodate) { if (!uptodate) {
set_bit(WriteErrorSeen, set_bit(WriteErrorSeen,
&conf->mirrors[mirror].rdev->flags); &conf->mirrors[mirror].rdev->flags);
if (!test_and_set_bit(WantReplacement,
&conf->mirrors[mirror].rdev->flags))
set_bit(MD_RECOVERY_NEEDED, &
conf->mddev->recovery);
set_bit(R1BIO_WriteError, &r1_bio->state); set_bit(R1BIO_WriteError, &r1_bio->state);
} else { } else {
/* /*
@ -1461,6 +1466,10 @@ static void end_sync_write(struct bio *bio, int error)
} while (sectors_to_go > 0); } while (sectors_to_go > 0);
set_bit(WriteErrorSeen, set_bit(WriteErrorSeen,
&conf->mirrors[mirror].rdev->flags); &conf->mirrors[mirror].rdev->flags);
if (!test_and_set_bit(WantReplacement,
&conf->mirrors[mirror].rdev->flags))
set_bit(MD_RECOVERY_NEEDED, &
mddev->recovery);
set_bit(R1BIO_WriteError, &r1_bio->state); set_bit(R1BIO_WriteError, &r1_bio->state);
} else if (is_badblock(conf->mirrors[mirror].rdev, } else if (is_badblock(conf->mirrors[mirror].rdev,
r1_bio->sector, r1_bio->sector,
@ -1491,8 +1500,13 @@ static int r1_sync_page_io(struct md_rdev *rdev, sector_t sector,
if (sync_page_io(rdev, sector, sectors << 9, page, rw, false)) if (sync_page_io(rdev, sector, sectors << 9, page, rw, false))
/* success */ /* success */
return 1; return 1;
if (rw == WRITE) if (rw == WRITE) {
set_bit(WriteErrorSeen, &rdev->flags); set_bit(WriteErrorSeen, &rdev->flags);
if (!test_and_set_bit(WantReplacement,
&rdev->flags))
set_bit(MD_RECOVERY_NEEDED, &
rdev->mddev->recovery);
}
/* need to record an error - either for the block or the device */ /* need to record an error - either for the block or the device */
if (!rdev_set_badblocks(rdev, sector, sectors, 0)) if (!rdev_set_badblocks(rdev, sector, sectors, 0))
md_error(rdev->mddev, rdev); md_error(rdev->mddev, rdev);