aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid10.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2011-10-19 08:30:42 -0400
committerJens Axboe <axboe@kernel.dk>2011-10-19 08:30:42 -0400
commit5c04b426f2e8b46cfc7969a35b2631063a3c646c (patch)
tree2d27d9f5d2fe5d5e8fbc01a467ec58bcb50235c1 /drivers/md/raid10.c
parent499337bb6511e665a236a6a947f819d98ea340c6 (diff)
parent899e3ee404961a90b828ad527573aaaac39f0ab1 (diff)
Merge branch 'v3.1-rc10' into for-3.2/core
Conflicts: block/blk-core.c include/linux/blkdev.h Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/md/raid10.c')
-rw-r--r--drivers/md/raid10.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 04b625e1cb60..ea5fc0b6a84c 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -337,6 +337,21 @@ static void close_write(r10bio_t *r10_bio)
337 md_write_end(r10_bio->mddev); 337 md_write_end(r10_bio->mddev);
338} 338}
339 339
340static void one_write_done(r10bio_t *r10_bio)
341{
342 if (atomic_dec_and_test(&r10_bio->remaining)) {
343 if (test_bit(R10BIO_WriteError, &r10_bio->state))
344 reschedule_retry(r10_bio);
345 else {
346 close_write(r10_bio);
347 if (test_bit(R10BIO_MadeGood, &r10_bio->state))
348 reschedule_retry(r10_bio);
349 else
350 raid_end_bio_io(r10_bio);
351 }
352 }
353}
354
340static void raid10_end_write_request(struct bio *bio, int error) 355static void raid10_end_write_request(struct bio *bio, int error)
341{ 356{
342 int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 357 int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
@@ -387,17 +402,7 @@ static void raid10_end_write_request(struct bio *bio, int error)
387 * Let's see if all mirrored write operations have finished 402 * Let's see if all mirrored write operations have finished
388 * already. 403 * already.
389 */ 404 */
390 if (atomic_dec_and_test(&r10_bio->remaining)) { 405 one_write_done(r10_bio);
391 if (test_bit(R10BIO_WriteError, &r10_bio->state))
392 reschedule_retry(r10_bio);
393 else {
394 close_write(r10_bio);
395 if (test_bit(R10BIO_MadeGood, &r10_bio->state))
396 reschedule_retry(r10_bio);
397 else
398 raid_end_bio_io(r10_bio);
399 }
400 }
401 if (dec_rdev) 406 if (dec_rdev)
402 rdev_dec_pending(conf->mirrors[dev].rdev, conf->mddev); 407 rdev_dec_pending(conf->mirrors[dev].rdev, conf->mddev);
403} 408}
@@ -1125,20 +1130,12 @@ retry_write:
1125 spin_unlock_irqrestore(&conf->device_lock, flags); 1130 spin_unlock_irqrestore(&conf->device_lock, flags);
1126 } 1131 }
1127 1132
1128 if (atomic_dec_and_test(&r10_bio->remaining)) { 1133 /* Don't remove the bias on 'remaining' (one_write_done) until
1129 /* This matches the end of raid10_end_write_request() */ 1134 * after checking if we need to go around again.
1130 bitmap_endwrite(r10_bio->mddev->bitmap, r10_bio->sector, 1135 */
1131 r10_bio->sectors,
1132 !test_bit(R10BIO_Degraded, &r10_bio->state),
1133 0);
1134 md_write_end(mddev);
1135 raid_end_bio_io(r10_bio);
1136 }
1137
1138 /* In case raid10d snuck in to freeze_array */
1139 wake_up(&conf->wait_barrier);
1140 1136
1141 if (sectors_handled < (bio->bi_size >> 9)) { 1137 if (sectors_handled < (bio->bi_size >> 9)) {
1138 one_write_done(r10_bio);
1142 /* We need another r10_bio. It has already been counted 1139 /* We need another r10_bio. It has already been counted
1143 * in bio->bi_phys_segments. 1140 * in bio->bi_phys_segments.
1144 */ 1141 */
@@ -1152,6 +1149,10 @@ retry_write:
1152 r10_bio->state = 0; 1149 r10_bio->state = 0;
1153 goto retry_write; 1150 goto retry_write;
1154 } 1151 }
1152 one_write_done(r10_bio);
1153
1154 /* In case raid10d snuck in to freeze_array */
1155 wake_up(&conf->wait_barrier);
1155 1156
1156 if (do_sync || !mddev->bitmap || !plugged) 1157 if (do_sync || !mddev->bitmap || !plugged)
1157 md_wakeup_thread(mddev->thread); 1158 md_wakeup_thread(mddev->thread);
@@ -2951,7 +2952,7 @@ static int run(mddev_t *mddev)
2951 return 0; 2952 return 0;
2952 2953
2953out_free_conf: 2954out_free_conf:
2954 md_unregister_thread(mddev->thread); 2955 md_unregister_thread(&mddev->thread);
2955 if (conf->r10bio_pool) 2956 if (conf->r10bio_pool)
2956 mempool_destroy(conf->r10bio_pool); 2957 mempool_destroy(conf->r10bio_pool);
2957 safe_put_page(conf->tmppage); 2958 safe_put_page(conf->tmppage);
@@ -2969,8 +2970,7 @@ static int stop(mddev_t *mddev)
2969 raise_barrier(conf, 0); 2970 raise_barrier(conf, 0);
2970 lower_barrier(conf); 2971 lower_barrier(conf);
2971 2972
2972 md_unregister_thread(mddev->thread); 2973 md_unregister_thread(&mddev->thread);
2973 mddev->thread = NULL;
2974 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ 2974 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
2975 if (conf->r10bio_pool) 2975 if (conf->r10bio_pool)
2976 mempool_destroy(conf->r10bio_pool); 2976 mempool_destroy(conf->r10bio_pool);