aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-03-09 20:33:46 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-09 22:47:37 -0500
commit04b857f74cec5efc7730e9db47e291310f4708a4 (patch)
tree4609bd7553665604270a976f6887d46140decfcb /drivers
parent628de616ba760b7b1d5e3d95dbe40a988fbf8ca5 (diff)
[PATCH] md: Fix several raid1 bugs which cause a memory leak
- wrong test for 'is this a BARRIER bio' - not freeing on all possible paths. - using r1_bio after freeing it. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/raid1.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index d39f584cd8b3..5d88329e3c7a 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -306,6 +306,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
306 r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private); 306 r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private);
307 int mirror, behind = test_bit(R1BIO_BehindIO, &r1_bio->state); 307 int mirror, behind = test_bit(R1BIO_BehindIO, &r1_bio->state);
308 conf_t *conf = mddev_to_conf(r1_bio->mddev); 308 conf_t *conf = mddev_to_conf(r1_bio->mddev);
309 struct bio *to_put = NULL;
309 310
310 if (bio->bi_size) 311 if (bio->bi_size)
311 return 1; 312 return 1;
@@ -323,6 +324,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
323 * this branch is our 'one mirror IO has finished' event handler: 324 * this branch is our 'one mirror IO has finished' event handler:
324 */ 325 */
325 r1_bio->bios[mirror] = NULL; 326 r1_bio->bios[mirror] = NULL;
327 to_put = bio;
326 if (!uptodate) { 328 if (!uptodate) {
327 md_error(r1_bio->mddev, conf->mirrors[mirror].rdev); 329 md_error(r1_bio->mddev, conf->mirrors[mirror].rdev);
328 /* an I/O failed, we can't clear the bitmap */ 330 /* an I/O failed, we can't clear the bitmap */
@@ -375,7 +377,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
375 /* Don't dec_pending yet, we want to hold 377 /* Don't dec_pending yet, we want to hold
376 * the reference over the retry 378 * the reference over the retry
377 */ 379 */
378 return 0; 380 goto out;
379 } 381 }
380 if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { 382 if (test_bit(R1BIO_BehindIO, &r1_bio->state)) {
381 /* free extra copy of the data pages */ 383 /* free extra copy of the data pages */
@@ -392,10 +394,11 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
392 raid_end_bio_io(r1_bio); 394 raid_end_bio_io(r1_bio);
393 } 395 }
394 396
395 if (r1_bio->bios[mirror]==NULL)
396 bio_put(bio);
397
398 rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev); 397 rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev);
398 out:
399 if (to_put)
400 bio_put(to_put);
401
399 return 0; 402 return 0;
400} 403}
401 404
@@ -857,7 +860,7 @@ static int make_request(request_queue_t *q, struct bio * bio)
857 atomic_set(&r1_bio->remaining, 0); 860 atomic_set(&r1_bio->remaining, 0);
858 atomic_set(&r1_bio->behind_remaining, 0); 861 atomic_set(&r1_bio->behind_remaining, 0);
859 862
860 do_barriers = bio->bi_rw & BIO_RW_BARRIER; 863 do_barriers = bio_barrier(bio);
861 if (do_barriers) 864 if (do_barriers)
862 set_bit(R1BIO_Barrier, &r1_bio->state); 865 set_bit(R1BIO_Barrier, &r1_bio->state);
863 866