- if (test_bit(R1BIO_IsSync, &r1_bio->state))
- sync_request_write(mddev, r1_bio);
- else if (test_bit(R1BIO_ReadError, &r1_bio->state)) {
+ if (test_bit(R1BIO_IsSync, &r1_bio->state)) {
+ if (test_bit(R1BIO_MadeGood, &r1_bio->state)) {
+ int m;
+ int s = r1_bio->sectors;
+ for (m = 0; m < conf->raid_disks ; m++) {
+ struct bio *bio = r1_bio->bios[m];
+ if (bio->bi_end_io != NULL &&
+ test_bit(BIO_UPTODATE,
+ &bio->bi_flags)) {
+ rdev = conf->mirrors[m].rdev;
+ rdev_clear_badblocks(
+ rdev,
+ r1_bio->sector,
+ r1_bio->sectors);
+ }
+ }
+ put_buf(r1_bio);
+ md_done_sync(mddev, s, 1);
+ } else
+ sync_request_write(mddev, r1_bio);
+ } else if (test_bit(R1BIO_MadeGood, &r1_bio->state)) {
+ int m;
+ for (m = 0; m < conf->raid_disks ; m++)
+ if (r1_bio->bios[m] == IO_MADE_GOOD) {
+ rdev = conf->mirrors[m].rdev;
+ rdev_clear_badblocks(
+ rdev,
+ r1_bio->sector,
+ r1_bio->sectors);
+ rdev_dec_pending(rdev, mddev);
+ }
+ raid_end_bio_io(r1_bio);
+ } else if (test_bit(R1BIO_ReadError, &r1_bio->state)) {