VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / drivers / md / raid1.c
index 1b80c5b..04b2aef 100644 (file)
@@ -206,7 +206,7 @@ static int map(mddev_t *mddev, mdk_rdev_t **rdevp)
                        *rdevp = rdev;
                        atomic_inc(&rdev->nr_pending);
                        spin_unlock_irq(&conf->device_lock);
-                       return 0;
+                       return i;
                }
        }
        spin_unlock_irq(&conf->device_lock);
@@ -376,7 +376,8 @@ static int read_balance(conf_t *conf, struct bio *bio, r1bio_t *r1_bio)
         * device if no resync is going on, or below the resync window.
         * We take the first readable disk when above the resync window.
         */
-       if (!conf->mddev->in_sync && (this_sector + sectors >= conf->next_resync)) {
+       if (conf->mddev->recovery_cp < MaxSector &&
+           (this_sector + sectors >= conf->next_resync)) {
                /* make sure that disk is operational */
                new_disk = 0;
 
@@ -918,18 +919,22 @@ static void raid1d(mddev_t *mddev)
 
                mddev = r1_bio->mddev;
                conf = mddev_to_conf(mddev);
-               bio = r1_bio->master_bio;
                if (test_bit(R1BIO_IsSync, &r1_bio->state)) {
                        sync_request_write(mddev, r1_bio);
                        unplug = 1;
                } else {
-                       if (map(mddev, &rdev) == -1) {
+                       int disk;
+                       bio = r1_bio->bios[r1_bio->read_disk];
+                       if ((disk=map(mddev, &rdev)) == -1) {
                                printk(KERN_ALERT "raid1: %s: unrecoverable I/O"
                                       " read error for block %llu\n",
                                       bdevname(bio->bi_bdev,b),
                                       (unsigned long long)r1_bio->sector);
                                raid_end_bio_io(r1_bio);
                        } else {
+                               r1_bio->bios[r1_bio->read_disk] = NULL;
+                               r1_bio->read_disk = disk;
+                               r1_bio->bios[r1_bio->read_disk] = bio;
                                printk(KERN_ERR "raid1: %s: redirecting sector %llu to"
                                       " another mirror\n",
                                       bdevname(rdev->bdev,b),