aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiao Ni <xni@redhat.com>2018-10-19 20:09:25 -0400
committerShaohua Li <shli@fb.com>2018-10-22 12:15:26 -0400
commitaf9b926de9c5986ab009e64917de87c9758bab10 (patch)
tree87258d69330822fc21a9ac467b2f856764f07cda
parent6aaa58c994277647f8b05ffef3b9b225a2d08f36 (diff)
MD: Memory leak when flush bio size is zero
flush_pool is leaked when flush bio size is zero Fixes: 5a409b4f56d5 ("MD: fix lock contention for flush bios") Signed-off-by: David Jeffery <djeffery@redhat.com> Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Shaohua Li <shli@fb.com>
-rw-r--r--drivers/md/md.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 1fa7f1b1d98a..fc488cb30a94 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -452,10 +452,11 @@ static void md_end_flush(struct bio *fbio)
452 rdev_dec_pending(rdev, mddev); 452 rdev_dec_pending(rdev, mddev);
453 453
454 if (atomic_dec_and_test(&fi->flush_pending)) { 454 if (atomic_dec_and_test(&fi->flush_pending)) {
455 if (bio->bi_iter.bi_size == 0) 455 if (bio->bi_iter.bi_size == 0) {
456 /* an empty barrier - all done */ 456 /* an empty barrier - all done */
457 bio_endio(bio); 457 bio_endio(bio);
458 else { 458 mempool_free(fi, mddev->flush_pool);
459 } else {
459 INIT_WORK(&fi->flush_work, submit_flushes); 460 INIT_WORK(&fi->flush_work, submit_flushes);
460 queue_work(md_wq, &fi->flush_work); 461 queue_work(md_wq, &fi->flush_work);
461 } 462 }
@@ -509,10 +510,11 @@ void md_flush_request(struct mddev *mddev, struct bio *bio)
509 rcu_read_unlock(); 510 rcu_read_unlock();
510 511
511 if (atomic_dec_and_test(&fi->flush_pending)) { 512 if (atomic_dec_and_test(&fi->flush_pending)) {
512 if (bio->bi_iter.bi_size == 0) 513 if (bio->bi_iter.bi_size == 0) {
513 /* an empty barrier - all done */ 514 /* an empty barrier - all done */
514 bio_endio(bio); 515 bio_endio(bio);
515 else { 516 mempool_free(fi, mddev->flush_pool);
517 } else {
516 INIT_WORK(&fi->flush_work, submit_flushes); 518 INIT_WORK(&fi->flush_work, submit_flushes);
517 queue_work(md_wq, &fi->flush_work); 519 queue_work(md_wq, &fi->flush_work);
518 } 520 }