aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/bitmap.c9
-rw-r--r--drivers/md/raid1.c37
-rw-r--r--include/linux/raid/bitmap.h2
3 files changed, 25 insertions, 23 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;
diff --git a/include/linux/raid/bitmap.h b/include/linux/raid/bitmap.h
index e24b74b11150..6213e976eade 100644
--- a/include/linux/raid/bitmap.h
+++ b/include/linux/raid/bitmap.h
@@ -262,7 +262,7 @@ void bitmap_write_all(struct bitmap *bitmap);
262int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors); 262int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors);
263void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors, 263void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors,
264 int success); 264 int success);
265int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks); 265int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int degraded);
266void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted); 266void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted);
267void bitmap_close_sync(struct bitmap *bitmap); 267void bitmap_close_sync(struct bitmap *bitmap);
268 268