]> Pileus Git - ~andy/linux/blobdiff - drivers/md/raid1.c
Merge tag 'pm-for-3.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[~andy/linux] / drivers / md / raid1.c
index 05c557e8f862e412636cd90ddaae8cfd56ebe947..636bae0405e8167edcec328e5759b3f949dd0876 100644 (file)
@@ -333,9 +333,10 @@ static void raid1_end_read_request(struct bio *bio, int error)
                spin_unlock_irqrestore(&conf->device_lock, flags);
        }
 
-       if (uptodate)
+       if (uptodate) {
                raid_end_bio_io(r1_bio);
-       else {
+               rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev);
+       } else {
                /*
                 * oops, read error:
                 */
@@ -349,9 +350,8 @@ static void raid1_end_read_request(struct bio *bio, int error)
                        (unsigned long long)r1_bio->sector);
                set_bit(R1BIO_ReadError, &r1_bio->state);
                reschedule_retry(r1_bio);
+               /* don't drop the reference on read_disk yet */
        }
-
-       rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev);
 }
 
 static void close_write(struct r1bio *r1_bio)
@@ -1876,7 +1876,7 @@ static int process_checks(struct r1bio *r1_bio)
                } else
                        j = 0;
                if (j >= 0)
-                       mddev->resync_mismatches += r1_bio->sectors;
+                       atomic64_add(r1_bio->sectors, &mddev->resync_mismatches);
                if (j < 0 || (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)
                              && test_bit(BIO_UPTODATE, &sbio->bi_flags))) {
                        /* No need to write to this device. */
@@ -2229,6 +2229,7 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
                unfreeze_array(conf);
        } else
                md_error(mddev, conf->mirrors[r1_bio->read_disk].rdev);
+       rdev_dec_pending(conf->mirrors[r1_bio->read_disk].rdev, conf->mddev);
 
        bio = r1_bio->bios[r1_bio->read_disk];
        bdevname(bio->bi_bdev, b);
@@ -2294,8 +2295,9 @@ read_more:
        }
 }
 
-static void raid1d(struct mddev *mddev)
+static void raid1d(struct md_thread *thread)
 {
+       struct mddev *mddev = thread->mddev;
        struct r1bio *r1_bio;
        unsigned long flags;
        struct r1conf *conf = mddev->private;
@@ -2708,7 +2710,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
                    || disk_idx < 0)
                        continue;
                if (test_bit(Replacement, &rdev->flags))
-                       disk = conf->mirrors + conf->raid_disks + disk_idx;
+                       disk = conf->mirrors + mddev->raid_disks + disk_idx;
                else
                        disk = conf->mirrors + disk_idx;