summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2016-08-23 12:51:57 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-08-24 14:51:05 -0700
commit6dc4580696d837aa9a6a2569d0f0ce0e37883d9c (patch)
tree949d2e24898ca1e09bdfafc4a052a0e6afbc5b0f /xlators/features
parentb0a7016a7928a14a373dfda933ef17b70eb406b8 (diff)
arbiter: Fix memleak in arbiter_inode ctx
Backport of http://review.gluster.org/#/c/15289/ Problem: The iattbuf ptr stored in arbiter's inode context was not freed during inode forget. Fix: Change it to a statically allocated value so that we don't have to deal with allocating/freeing it. Change-Id: Id1b73b8aee1fb5c4174d0734bd20e168432b1abd BUG: 1369748 Reported-by: Benjamin Edgar <benedgar8@gmail.com> Signed-off-by: Ravishankar N <ravishankar@redhat.com> (cherry picked from commit 4aa52061a51b97c4f865b402f977b3b43f5471a7) Change-Id: I1c2d5c8d0f4222ec6ef16b1740e6daf956212d6f Reviewed-on: http://review.gluster.org/15306 Tested-by: Ravishankar N <ravishankar@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/arbiter/src/arbiter-mem-types.h1
-rw-r--r--xlators/features/arbiter/src/arbiter.c36
-rw-r--r--xlators/features/arbiter/src/arbiter.h2
3 files changed, 12 insertions, 27 deletions
diff --git a/xlators/features/arbiter/src/arbiter-mem-types.h b/xlators/features/arbiter/src/arbiter-mem-types.h
index 200b59de695..ccf864cdef0 100644
--- a/xlators/features/arbiter/src/arbiter-mem-types.h
+++ b/xlators/features/arbiter/src/arbiter-mem-types.h
@@ -13,7 +13,6 @@
typedef enum gf_arbiter_mem_types_ {
gf_arbiter_mt_inode_ctx_t = gf_common_mt_end + 1,
- gf_arbiter_mt_iatt,
gf_arbiter_mt_end
} gf_arbiter_mem_types_t;
#endif
diff --git a/xlators/features/arbiter/src/arbiter.c b/xlators/features/arbiter/src/arbiter.c
index 786f60b7bc9..0e555c84274 100644
--- a/xlators/features/arbiter/src/arbiter.c
+++ b/xlators/features/arbiter/src/arbiter.c
@@ -14,15 +14,6 @@
#include "xlator.h"
#include "logging.h"
-void
-arbiter_inode_ctx_destroy (arbiter_inode_ctx_t *ctx)
-{
- if (!ctx)
- return;
- GF_FREE (ctx->iattbuf);
- GF_FREE (ctx);
-}
-
static arbiter_inode_ctx_t *
__arbiter_inode_ctx_get (inode_t *inode, xlator_t *this)
{
@@ -39,23 +30,18 @@ __arbiter_inode_ctx_get (inode_t *inode, xlator_t *this)
ctx = GF_CALLOC (1, sizeof (*ctx), gf_arbiter_mt_inode_ctx_t);
if (!ctx)
- goto fail;
- ctx->iattbuf = GF_CALLOC (1, sizeof (*ctx->iattbuf),
- gf_arbiter_mt_iatt);
- if (!ctx->iattbuf)
- goto fail;
+ goto out;
+
ret = __inode_ctx_put (inode, this, (uint64_t)ctx);
if (ret) {
+ GF_FREE (ctx);
+ ctx = NULL;
gf_log_callingfn (this->name, GF_LOG_ERROR, "failed to "
"set the inode ctx (%s)",
uuid_utoa (inode->gfid));
- goto fail;
}
out:
return ctx;
-fail:
- arbiter_inode_ctx_destroy (ctx);
- return NULL;
}
static arbiter_inode_ctx_t *
@@ -86,7 +72,7 @@ arbiter_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
op_errno = ENOMEM;
goto unwind;
}
- memcpy (ctx->iattbuf, buf, sizeof (*ctx->iattbuf));
+ memcpy (&ctx->iattbuf, buf, sizeof (ctx->iattbuf));
unwind:
STACK_UNWIND_STRICT (lookup, frame, op_ret, op_errno, inode, buf,
@@ -126,7 +112,7 @@ arbiter_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
op_errno = ENOMEM;
goto unwind;
}
- buf = ctx->iattbuf;
+ buf = &ctx->iattbuf;
unwind:
STACK_UNWIND_STRICT (truncate, frame, op_ret, op_errno, buf, buf, NULL);
return 0;
@@ -148,7 +134,7 @@ arbiter_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
op_errno = ENOMEM;
goto unwind;
}
- buf = ctx->iattbuf;
+ buf = &ctx->iattbuf;
unwind:
STACK_UNWIND_STRICT (ftruncate, frame, op_ret, op_errno, buf, buf,
NULL);
@@ -210,7 +196,7 @@ arbiter_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
op_errno = ENOMEM;
goto unwind;
}
- buf = ctx->iattbuf;
+ buf = &ctx->iattbuf;
op_ret = iov_length (vector, count);
rsp_xdata = arbiter_fill_writev_xdata (fd, xdata, this);
unwind:
@@ -236,7 +222,7 @@ arbiter_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd,
op_errno = ENOMEM;
goto unwind;
}
- buf = ctx->iattbuf;
+ buf = &ctx->iattbuf;
unwind:
STACK_UNWIND_STRICT(fallocate, frame, op_ret, op_errno, buf, buf, NULL);
return 0;
@@ -257,7 +243,7 @@ arbiter_discard (call_frame_t *frame, xlator_t *this, fd_t *fd,
op_errno = ENOMEM;
goto unwind;
}
- buf = ctx->iattbuf;
+ buf = &ctx->iattbuf;
unwind:
STACK_UNWIND_STRICT(discard, frame, op_ret, op_errno, buf, buf, NULL);
return 0;
@@ -278,7 +264,7 @@ arbiter_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd,
op_errno = ENOMEM;
goto unwind;
}
- buf = ctx->iattbuf;
+ buf = &ctx->iattbuf;
unwind:
STACK_UNWIND_STRICT(zerofill, frame, op_ret, op_errno, buf, buf, NULL);
return 0;
diff --git a/xlators/features/arbiter/src/arbiter.h b/xlators/features/arbiter/src/arbiter.h
index 6ccc3add3b3..f52b45fad20 100644
--- a/xlators/features/arbiter/src/arbiter.h
+++ b/xlators/features/arbiter/src/arbiter.h
@@ -15,7 +15,7 @@
#include "common-utils.h"
typedef struct arbiter_inode_ctx_ {
- struct iatt *iattbuf;
+ struct iatt iattbuf;
} arbiter_inode_ctx_t;
#endif /* _ARBITER_H */