Commit 6a806c51 authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds

[PATCH] md/raid1: clear bitmap when fullsync completes

We need to be careful differentiating between a resync of a complete array,
in which we can clear the bitmap, and a resync of a degraded array, in
which we cannot.

This patch cleans all that up.

Cc: Paul Clements <paul.clements@steeleye.com>
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 a1287ba1
...@@ -1345,7 +1345,8 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto ...@@ -1345,7 +1345,8 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
} }
} }
int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks) int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks,
int degraded)
{ {
bitmap_counter_t *bmc; bitmap_counter_t *bmc;
int rv; int rv;
...@@ -1362,10 +1363,12 @@ int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks) ...@@ -1362,10 +1363,12 @@ int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks)
rv = 1; rv = 1;
else if (NEEDED(*bmc)) { else if (NEEDED(*bmc)) {
rv = 1; rv = 1;
if (!degraded) { /* don't set/clear bits if degraded */
*bmc |= RESYNC_MASK; *bmc |= RESYNC_MASK;
*bmc &= ~NEEDED_MASK; *bmc &= ~NEEDED_MASK;
} }
} }
}
spin_unlock_irq(&bitmap->lock); spin_unlock_irq(&bitmap->lock);
return rv; return rv;
} }
......
...@@ -1126,21 +1126,19 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i ...@@ -1126,21 +1126,19 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
* only be one in raid1 resync. * only be one in raid1 resync.
* We can find the current addess in mddev->curr_resync * We can find the current addess in mddev->curr_resync
*/ */
if (!conf->fullsync) { if (mddev->curr_resync < max_sector) /* aborted */
if (mddev->curr_resync < max_sector) bitmap_end_sync(mddev->bitmap, mddev->curr_resync,
bitmap_end_sync(mddev->bitmap,
mddev->curr_resync,
&sync_blocks, 1); &sync_blocks, 1);
bitmap_close_sync(mddev->bitmap); else /* completed sync */
}
if (mddev->curr_resync >= max_sector)
conf->fullsync = 0; conf->fullsync = 0;
bitmap_close_sync(mddev->bitmap);
close_sync(conf); close_sync(conf);
return 0; return 0;
} }
if (!conf->fullsync && if (!bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, mddev->degraded) &&
!bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks)) { !conf->fullsync) {
/* We can skip this block, and probably several more */ /* We can skip this block, and probably several more */
*skipped = 1; *skipped = 1;
return sync_blocks; return sync_blocks;
...@@ -1243,15 +1241,15 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i ...@@ -1243,15 +1241,15 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
len = (max_sector - sector_nr) << 9; len = (max_sector - sector_nr) << 9;
if (len == 0) if (len == 0)
break; break;
if (!conf->fullsync) {
if (sync_blocks == 0) { if (sync_blocks == 0) {
if (!bitmap_start_sync(mddev->bitmap, if (!bitmap_start_sync(mddev->bitmap, sector_nr,
sector_nr, &sync_blocks)) &sync_blocks, mddev->degraded) &&
!conf->fullsync)
break; break;
if (sync_blocks < (PAGE_SIZE>>9)) if (sync_blocks < (PAGE_SIZE>>9))
BUG(); BUG();
if (len > (sync_blocks<<9)) len = sync_blocks<<9; if (len > (sync_blocks<<9))
} len = sync_blocks<<9;
} }
for (i=0 ; i < conf->raid_disks; i++) { for (i=0 ; i < conf->raid_disks; i++) {
...@@ -1264,7 +1262,8 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i ...@@ -1264,7 +1262,8 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
while (i > 0) { while (i > 0) {
i--; i--;
bio = r1_bio->bios[i]; bio = r1_bio->bios[i];
if (bio->bi_end_io==NULL) continue; if (bio->bi_end_io==NULL)
continue;
/* remove last page from this bio */ /* remove last page from this bio */
bio->bi_vcnt--; bio->bi_vcnt--;
bio->bi_size -= len; bio->bi_size -= len;
......
...@@ -262,7 +262,7 @@ void bitmap_write_all(struct bitmap *bitmap); ...@@ -262,7 +262,7 @@ void bitmap_write_all(struct bitmap *bitmap);
int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors); int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors);
void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors, void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors,
int success); int success);
int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks); int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int degraded);
void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted); void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted);
void bitmap_close_sync(struct bitmap *bitmap); void bitmap_close_sync(struct bitmap *bitmap);
......
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