Commit c144ee55 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] md: abort the resync of raid1 there is only one device.

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: default avatarNeil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 65e01fa2
...@@ -3284,7 +3284,7 @@ static void md_do_sync(mddev_t *mddev) ...@@ -3284,7 +3284,7 @@ static void md_do_sync(mddev_t *mddev)
j += sectors; j += sectors;
if (j>1) mddev->curr_resync = j; if (j>1) mddev->curr_resync = j;
if (last_check + window > j) if (last_check + window > j || j == max_sectors)
continue; continue;
last_check = j; last_check = j;
......
...@@ -979,6 +979,7 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster) ...@@ -979,6 +979,7 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
sector_t max_sector, nr_sectors; sector_t max_sector, nr_sectors;
int disk; int disk;
int i; int i;
int write_targets = 0;
if (!conf->r1buf_pool) if (!conf->r1buf_pool)
if (init_resync(conf)) if (init_resync(conf))
...@@ -1055,12 +1056,24 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster) ...@@ -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)) { sector_nr + RESYNC_SECTORS > mddev->recovery_cp)) {
bio->bi_rw = WRITE; bio->bi_rw = WRITE;
bio->bi_end_io = end_sync_write; bio->bi_end_io = end_sync_write;
write_targets ++;
} else } else
continue; continue;
bio->bi_sector = sector_nr + conf->mirrors[i].rdev->data_offset; bio->bi_sector = sector_nr + conf->mirrors[i].rdev->data_offset;
bio->bi_bdev = conf->mirrors[i].rdev->bdev; bio->bi_bdev = conf->mirrors[i].rdev->bdev;
bio->bi_private = r1_bio; 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; nr_sectors = 0;
do { do {
struct page *page; struct page *page;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment