From 8c7e1cfdebc6591bbedbe2e1b98b7b3279e6519c Mon Sep 17 00:00:00 2001 From: Alexander Bersenev Date: Wed, 16 May 2012 13:02:06 +0600 Subject: Fixed a memory leak in stripe translator. When iobuf is created it has reference count = 1. After iobref_add (local->iobref, iobuf); reference count becomes 2. After iobref_unref(local->iobref); it becomes 1 and never becomes 0. So iobuf never deletes and this causes a memory leak. I emulated it, creating files on brick manually. After 5 mins of: while true; do dd if=file of=/dev/zero bs=16384; done top showed me this: 4618 root 20 0 1721m 1.5g 1868 S 0.0 16.2 5:41.77 glusterfs 1.5 gb of memory has leaked. For what this if for? Can it be true in the normal conditions? if ((local->replies[i].op_ret < local->replies[i].requested_size) && (local->stbuf_size > (local->offset + op_ret))) { May be delete it entirely? Change-Id: I17c115ab566e5bba662dd809e0c747db3c0310c8 BUG: 822378 Signed-off-by: Alexander Bersenev Reviewed-on: http://review.gluster.com/3340 Tested-by: Gluster Build System Reviewed-by: Brian Foster Reviewed-by: Anand Avati --- xlators/cluster/stripe/src/stripe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'xlators/cluster/stripe/src/stripe.c') diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c index c64e8bfcb..a98e14e95 100644 --- a/xlators/cluster/stripe/src/stripe.c +++ b/xlators/cluster/stripe/src/stripe.c @@ -3097,9 +3097,11 @@ stripe_readv_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto done; } memset (iobuf->ptr, 0, vec[count].iov_len); - iobref_add (local->iobref, iobuf); vec[count].iov_base = iobuf->ptr; + iobref_add (local->iobref, iobuf); + iobuf_unref(iobuf); + op_ret += vec[count].iov_len; count++; } -- cgit