aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorNeilBrown <neilb@cse.unsw.edu.au>2005-07-15 06:56:35 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-15 12:54:51 -0400
commit6a806c510de490318846b53bbfec463d02ca274b (patch)
tree7018abfd9db7856708bc2c578f48c30eab8855b1 /drivers/md
parenta1287ba1ba810aae1f8b81e32560d5d3bf3ff9f0 (diff)
[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: Neil Brown <neilb@cse.unsw.edu.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/bitmap.c9
-rw-r--r--drivers/md/raid1.c37
2 files changed, 24 insertions, 22 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 95980ad6b27b..0c2ed99a3832 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1345,7 +1345,8 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
1345 } 1345 }
1346} 1346}
1347 1347
1348int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks) 1348int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks,
1349 int degraded)
1349{ 1350{
1350 bitmap_counter_t *bmc; 1351 bitmap_counter_t *bmc;
1351 int rv; 1352 int rv;
@@ -1362,8 +1363,10 @@ int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks)
1362 rv = 1; 1363 rv = 1;
1363 else if (NEEDED(*bmc)) { 1364 else if (NEEDED(*bmc)) {
1364 rv = 1; 1365 rv = 1;
1365 *bmc |= RESYNC_MASK; 1366 if (!degraded) { /* don't set/clear bits if degraded */
1366 *bmc &= ~NEEDED_MASK; 1367 *bmc |= RESYNC_MASK;
1368 *bmc &= ~NEEDED_MASK;
1369 }
1367 } 1370 }
1368 } 1371 }
1369 spin_unlock_irq(&bitmap->lock); 1372 spin_unlock_irq(&bitmap->lock);
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index ff1dbec864af..5f253ee536bb 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1126,21 +1126,19 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1126 * only be one in raid1 resync. 1126 * only be one in raid1 resync.
1127 * We can find the current addess in mddev->curr_resync 1127 * We can find the current addess in mddev->curr_resync
1128 */ 1128 */
1129 if (!conf->fullsync) { 1129 if (mddev->curr_resync < max_sector) /* aborted */
1130 if (mddev->curr_resync < max_sector) 1130 bitmap_end_sync(mddev->bitmap, mddev->curr_resync,
1131 bitmap_end_sync(mddev->bitmap,
1132 mddev->curr_resync,
1133 &sync_blocks, 1); 1131 &sync_blocks, 1);
1134 bitmap_close_sync(mddev->bitmap); 1132 else /* completed sync */
1135 }
1136 if (mddev->curr_resync >= max_sector)
1137 conf->fullsync = 0; 1133 conf->fullsync = 0;
1134
1135 bitmap_close_sync(mddev->bitmap);
1138 close_sync(conf); 1136 close_sync(conf);
1139 return 0; 1137 return 0;
1140 } 1138 }
1141 1139
1142 if (!conf->fullsync && 1140 if (!bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, mddev->degraded) &&
1143 !bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks)) { 1141 !conf->fullsync) {
1144 /* We can skip this block, and probably several more */ 1142 /* We can skip this block, and probably several more */
1145 *skipped = 1; 1143 *skipped = 1;
1146 return sync_blocks; 1144 return sync_blocks;
@@ -1243,15 +1241,15 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1243 len = (max_sector - sector_nr) << 9; 1241 len = (max_sector - sector_nr) << 9;
1244 if (len == 0) 1242 if (len == 0)
1245 break; 1243 break;
1246 if (!conf->fullsync) { 1244 if (sync_blocks == 0) {
1247 if (sync_blocks == 0) { 1245 if (!bitmap_start_sync(mddev->bitmap, sector_nr,
1248 if (!bitmap_start_sync(mddev->bitmap, 1246 &sync_blocks, mddev->degraded) &&
1249 sector_nr, &sync_blocks)) 1247 !conf->fullsync)
1250 break; 1248 break;
1251 if (sync_blocks < (PAGE_SIZE>>9)) 1249 if (sync_blocks < (PAGE_SIZE>>9))
1252 BUG(); 1250 BUG();
1253 if (len > (sync_blocks<<9)) len = sync_blocks<<9; 1251 if (len > (sync_blocks<<9))
1254 } 1252 len = sync_blocks<<9;
1255 } 1253 }
1256 1254
1257 for (i=0 ; i < conf->raid_disks; i++) { 1255 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 while (i > 0) { 1262 while (i > 0) {
1265 i--; 1263 i--;
1266 bio = r1_bio->bios[i]; 1264 bio = r1_bio->bios[i];
1267 if (bio->bi_end_io==NULL) continue; 1265 if (bio->bi_end_io==NULL)
1266 continue;
1268 /* remove last page from this bio */ 1267 /* remove last page from this bio */
1269 bio->bi_vcnt--; 1268 bio->bi_vcnt--;
1270 bio->bi_size -= len; 1269 bio->bi_size -= len;