mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 10:57:46 +00:00
[PATCH] md: raid10 read-error handling - resync and read-only
Add in correct read-error handling for resync and read-only situations. When read-only, we don't over-write, so we need to mark the failed drive in the r10_bio so we don't re-try it. During resync, we always read all blocks, so if there is a read error, we simply over-write it with the good block that we found (assuming we found one). Note that the recovery case still isn't handled in an interesting way. There is nothing useful to do for the 2-copies case. If there are 3 or more copies, then we could try reading from one of the non-missing copies, but this is a bit complicated and very rarely would be used, so I'm leaving it for now. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
4443ae10ca
commit
0eb3ff12aa
2 changed files with 42 additions and 21 deletions
|
@ -172,7 +172,7 @@ static void put_all_bios(conf_t *conf, r10bio_t *r10_bio)
|
||||||
|
|
||||||
for (i = 0; i < conf->copies; i++) {
|
for (i = 0; i < conf->copies; i++) {
|
||||||
struct bio **bio = & r10_bio->devs[i].bio;
|
struct bio **bio = & r10_bio->devs[i].bio;
|
||||||
if (*bio)
|
if (*bio && *bio != IO_BLOCKED)
|
||||||
bio_put(*bio);
|
bio_put(*bio);
|
||||||
*bio = NULL;
|
*bio = NULL;
|
||||||
}
|
}
|
||||||
|
@ -500,6 +500,7 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
|
||||||
disk = r10_bio->devs[slot].devnum;
|
disk = r10_bio->devs[slot].devnum;
|
||||||
|
|
||||||
while ((rdev = rcu_dereference(conf->mirrors[disk].rdev)) == NULL ||
|
while ((rdev = rcu_dereference(conf->mirrors[disk].rdev)) == NULL ||
|
||||||
|
r10_bio->devs[slot].bio == IO_BLOCKED ||
|
||||||
!test_bit(In_sync, &rdev->flags)) {
|
!test_bit(In_sync, &rdev->flags)) {
|
||||||
slot++;
|
slot++;
|
||||||
if (slot == conf->copies) {
|
if (slot == conf->copies) {
|
||||||
|
@ -517,6 +518,7 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
|
||||||
slot = 0;
|
slot = 0;
|
||||||
disk = r10_bio->devs[slot].devnum;
|
disk = r10_bio->devs[slot].devnum;
|
||||||
while ((rdev=rcu_dereference(conf->mirrors[disk].rdev)) == NULL ||
|
while ((rdev=rcu_dereference(conf->mirrors[disk].rdev)) == NULL ||
|
||||||
|
r10_bio->devs[slot].bio == IO_BLOCKED ||
|
||||||
!test_bit(In_sync, &rdev->flags)) {
|
!test_bit(In_sync, &rdev->flags)) {
|
||||||
slot ++;
|
slot ++;
|
||||||
if (slot == conf->copies) {
|
if (slot == conf->copies) {
|
||||||
|
@ -537,6 +539,7 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
|
||||||
|
|
||||||
|
|
||||||
if ((rdev=rcu_dereference(conf->mirrors[ndisk].rdev)) == NULL ||
|
if ((rdev=rcu_dereference(conf->mirrors[ndisk].rdev)) == NULL ||
|
||||||
|
r10_bio->devs[nslot].bio == IO_BLOCKED ||
|
||||||
!test_bit(In_sync, &rdev->flags))
|
!test_bit(In_sync, &rdev->flags))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1104,7 +1107,6 @@ static int raid10_remove_disk(mddev_t *mddev, int number)
|
||||||
|
|
||||||
static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error)
|
static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error)
|
||||||
{
|
{
|
||||||
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
|
|
||||||
r10bio_t * r10_bio = (r10bio_t *)(bio->bi_private);
|
r10bio_t * r10_bio = (r10bio_t *)(bio->bi_private);
|
||||||
conf_t *conf = mddev_to_conf(r10_bio->mddev);
|
conf_t *conf = mddev_to_conf(r10_bio->mddev);
|
||||||
int i,d;
|
int i,d;
|
||||||
|
@ -1119,7 +1121,10 @@ static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error)
|
||||||
BUG();
|
BUG();
|
||||||
update_head_pos(i, r10_bio);
|
update_head_pos(i, r10_bio);
|
||||||
d = r10_bio->devs[i].devnum;
|
d = r10_bio->devs[i].devnum;
|
||||||
if (!uptodate)
|
|
||||||
|
if (test_bit(BIO_UPTODATE, &bio->bi_flags))
|
||||||
|
set_bit(R10BIO_Uptodate, &r10_bio->state);
|
||||||
|
else if (!test_bit(MD_RECOVERY_SYNC, &conf->mddev->recovery))
|
||||||
md_error(r10_bio->mddev,
|
md_error(r10_bio->mddev,
|
||||||
conf->mirrors[d].rdev);
|
conf->mirrors[d].rdev);
|
||||||
|
|
||||||
|
@ -1209,17 +1214,21 @@ static void sync_request_write(mddev_t *mddev, r10bio_t *r10_bio)
|
||||||
fbio = r10_bio->devs[i].bio;
|
fbio = r10_bio->devs[i].bio;
|
||||||
|
|
||||||
/* now find blocks with errors */
|
/* now find blocks with errors */
|
||||||
for (i=first+1 ; i < conf->copies ; i++) {
|
for (i=0 ; i < conf->copies ; i++) {
|
||||||
int vcnt, j, d;
|
int j, d;
|
||||||
|
int vcnt = r10_bio->sectors >> (PAGE_SHIFT-9);
|
||||||
|
|
||||||
if (!test_bit(BIO_UPTODATE, &r10_bio->devs[i].bio->bi_flags))
|
tbio = r10_bio->devs[i].bio;
|
||||||
|
|
||||||
|
if (tbio->bi_end_io != end_sync_read)
|
||||||
continue;
|
continue;
|
||||||
|
if (i == first)
|
||||||
|
continue;
|
||||||
|
if (test_bit(BIO_UPTODATE, &r10_bio->devs[i].bio->bi_flags)) {
|
||||||
/* We know that the bi_io_vec layout is the same for
|
/* We know that the bi_io_vec layout is the same for
|
||||||
* both 'first' and 'i', so we just compare them.
|
* both 'first' and 'i', so we just compare them.
|
||||||
* All vec entries are PAGE_SIZE;
|
* All vec entries are PAGE_SIZE;
|
||||||
*/
|
*/
|
||||||
tbio = r10_bio->devs[i].bio;
|
|
||||||
vcnt = r10_bio->sectors >> (PAGE_SHIFT-9);
|
|
||||||
for (j = 0; j < vcnt; j++)
|
for (j = 0; j < vcnt; j++)
|
||||||
if (memcmp(page_address(fbio->bi_io_vec[j].bv_page),
|
if (memcmp(page_address(fbio->bi_io_vec[j].bv_page),
|
||||||
page_address(tbio->bi_io_vec[j].bv_page),
|
page_address(tbio->bi_io_vec[j].bv_page),
|
||||||
|
@ -1228,6 +1237,7 @@ static void sync_request_write(mddev_t *mddev, r10bio_t *r10_bio)
|
||||||
if (j == vcnt)
|
if (j == vcnt)
|
||||||
continue;
|
continue;
|
||||||
mddev->resync_mismatches += r10_bio->sectors;
|
mddev->resync_mismatches += r10_bio->sectors;
|
||||||
|
}
|
||||||
if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery))
|
if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery))
|
||||||
/* Don't fix anything. */
|
/* Don't fix anything. */
|
||||||
continue;
|
continue;
|
||||||
|
@ -1308,7 +1318,10 @@ static void recovery_request_write(mddev_t *mddev, r10bio_t *r10_bio)
|
||||||
|
|
||||||
atomic_inc(&conf->mirrors[d].rdev->nr_pending);
|
atomic_inc(&conf->mirrors[d].rdev->nr_pending);
|
||||||
md_sync_acct(conf->mirrors[d].rdev->bdev, wbio->bi_size >> 9);
|
md_sync_acct(conf->mirrors[d].rdev->bdev, wbio->bi_size >> 9);
|
||||||
|
if (test_bit(R10BIO_Uptodate, &r10_bio->state))
|
||||||
generic_make_request(wbio);
|
generic_make_request(wbio);
|
||||||
|
else
|
||||||
|
bio_endio(wbio, wbio->bi_size, -EIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1445,7 +1458,8 @@ static void raid10d(mddev_t *mddev)
|
||||||
unfreeze_array(conf);
|
unfreeze_array(conf);
|
||||||
|
|
||||||
bio = r10_bio->devs[r10_bio->read_slot].bio;
|
bio = r10_bio->devs[r10_bio->read_slot].bio;
|
||||||
r10_bio->devs[r10_bio->read_slot].bio = NULL;
|
r10_bio->devs[r10_bio->read_slot].bio =
|
||||||
|
mddev->ro ? IO_BLOCKED : NULL;
|
||||||
bio_put(bio);
|
bio_put(bio);
|
||||||
mirror = read_balance(conf, r10_bio);
|
mirror = read_balance(conf, r10_bio);
|
||||||
if (mirror == -1) {
|
if (mirror == -1) {
|
||||||
|
|
|
@ -104,6 +104,13 @@ struct r10bio_s {
|
||||||
} devs[0];
|
} devs[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* when we get a read error on a read-only array, we redirect to another
|
||||||
|
* device without failing the first device, or trying to over-write to
|
||||||
|
* correct the read error. To keep track of bad blocks on a per-bio
|
||||||
|
* level, we store IO_BLOCKED in the appropriate 'bios' pointer
|
||||||
|
*/
|
||||||
|
#define IO_BLOCKED ((struct bio*)1)
|
||||||
|
|
||||||
/* bits for r10bio.state */
|
/* bits for r10bio.state */
|
||||||
#define R10BIO_Uptodate 0
|
#define R10BIO_Uptodate 0
|
||||||
#define R10BIO_IsSync 1
|
#define R10BIO_IsSync 1
|
||||||
|
|
Loading…
Reference in a new issue