]> git.hungrycats.org Git - linux/commitdiff
[PATCH] md: abort the resync of raid1 there is only one device.
authorNeil Brown <neilb@cse.unsw.edu.au>
Sat, 5 Jun 2004 03:56:27 +0000 (20:56 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 5 Jun 2004 03:56:27 +0000 (20:56 -0700)
If raid1 decides it needs to resync it will do so even if there is only one
working device.  This is pointless.

With this patch we abort resync if there is nowhere to write to.

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/md/md.c
drivers/md/raid1.c

index 5ce315a719a442581b3755ca02bd12b5f851b2a6..3901266c8b897691ae307be3884da3704dad5cc9 100644 (file)
@@ -3284,7 +3284,7 @@ static void md_do_sync(mddev_t *mddev)
                j += sectors;
                if (j>1) mddev->curr_resync = j;
 
-               if (last_check + window > j)
+               if (last_check + window > j || j == max_sectors)
                        continue;
 
                last_check = j;
index 891fb6593df87b3ac78310d46fae995519d04afa..a0489c59c64f785db5dd779468345b3d56f2a170 100644 (file)
@@ -979,6 +979,7 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
        sector_t max_sector, nr_sectors;
        int disk;
        int i;
+       int write_targets = 0;
 
        if (!conf->r1buf_pool)
                if (init_resync(conf))
@@ -1055,12 +1056,24 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
                            sector_nr + RESYNC_SECTORS > mddev->recovery_cp)) {
                        bio->bi_rw = WRITE;
                        bio->bi_end_io = end_sync_write;
+                       write_targets ++;
                } else
                        continue;
                bio->bi_sector = sector_nr + conf->mirrors[i].rdev->data_offset;
                bio->bi_bdev = conf->mirrors[i].rdev->bdev;
                bio->bi_private = r1_bio;
        }
+       if (write_targets == 0) {
+               /* There is nowhere to write, so all non-sync
+                * drives must be failed - so we are finished
+                */
+               int rv = max_sector - sector_nr;
+               md_done_sync(mddev, rv, 1);
+               put_buf(r1_bio);
+               atomic_dec(&conf->mirrors[disk].rdev->nr_pending);
+               return rv;
+       }
+
        nr_sectors = 0;
        do {
                struct page *page;