All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] dm thin: fix memory leak of singleton bio-prison cell
@ 2012-04-12 22:34 Mike Snitzer
  2012-04-12 22:34 ` [PATCH 2/2] dm thin: use slab_pool for caches Mike Snitzer
  2012-04-23  7:24 ` [PATCH 1/2] dm thin: fix memory leak of singleton bio-prison cell Joe Thornber
  0 siblings, 2 replies; 6+ messages in thread
From: Mike Snitzer @ 2012-04-12 22:34 UTC (permalink / raw)
  To: dm-devel; +Cc: ejt

Add missing mempool_free() to __cell_release_singleton().

This is a pretty significant leak that will accumulate to over 2GB of
leaked memory just from running the full thinp-test-suite.  Leak was
known to exist but the kmalloc_pool which was used for prison cell
allocation caused all leaked memory to be attributed to the "size-128"
cache.  kmemleak proved useful in identifying the source of this
illusive leak.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
 drivers/md/dm-thin.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Index: linux-2.6/drivers/md/dm-thin.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-thin.c
+++ linux-2.6/drivers/md/dm-thin.c
@@ -279,8 +279,10 @@ static void __cell_release(struct cell *
 
 	hlist_del(&cell->list);
 
-	bio_list_add(inmates, cell->holder);
-	bio_list_merge(inmates, &cell->bios);
+	if (inmates) {
+		bio_list_add(inmates, cell->holder);
+		bio_list_merge(inmates, &cell->bios);
+	}
 
 	mempool_free(cell, prison->cell_pool);
 }
@@ -303,9 +305,10 @@ static void cell_release(struct cell *ce
  */
 static void __cell_release_singleton(struct cell *cell, struct bio *bio)
 {
-	hlist_del(&cell->list);
 	BUG_ON(cell->holder != bio);
 	BUG_ON(!bio_list_empty(&cell->bios));
+
+	__cell_release(cell, NULL);
 }
 
 static void cell_release_singleton(struct cell *cell, struct bio *bio)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-04-23 10:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-12 22:34 [PATCH 1/2] dm thin: fix memory leak of singleton bio-prison cell Mike Snitzer
2012-04-12 22:34 ` [PATCH 2/2] dm thin: use slab_pool for caches Mike Snitzer
2012-04-12 22:39   ` [PATCH 2/2 v2] dm thin: use slab mempools with local caches Mike Snitzer
2012-04-23  7:24 ` [PATCH 1/2] dm thin: fix memory leak of singleton bio-prison cell Joe Thornber
2012-04-23 10:02   ` Alasdair G Kergon
2012-04-23  9:26     ` Joe Thornber

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.