summaryrefslogtreecommitdiffstats
path: root/xlators/storage/bd
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2014-03-12 19:56:08 +0530
committerAnand Avati <avati@redhat.com>2014-03-08 17:02:27 -0800
commit40b0bf5fc01a17e9a1628cd9ff537b7e15353958 (patch)
tree99a476c2d1b5dc1e6d6a98691bf9ebb655d9ee74 /xlators/storage/bd
parent0ddd69a60e49f1335ed29a8225e31d24c836083a (diff)
storage/bd: Fix allocations/deallocations
Change-Id: I39c9eb083fc1c144fe6f011dd983b877fbbff0f7 BUG: 1075717 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/7230 Reviewed-by: Anand Avati <avati@redhat.com> Tested-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/storage/bd')
-rw-r--r--xlators/storage/bd/src/Makefile.am2
-rw-r--r--xlators/storage/bd/src/bd-aio.c5
-rw-r--r--xlators/storage/bd/src/bd-helper.c9
-rw-r--r--xlators/storage/bd/src/bd-mem-types.h27
-rw-r--r--xlators/storage/bd/src/bd.c18
-rw-r--r--xlators/storage/bd/src/bd.h7
6 files changed, 46 insertions, 22 deletions
diff --git a/xlators/storage/bd/src/Makefile.am b/xlators/storage/bd/src/Makefile.am
index 3d93f744295..60ceff31b20 100644
--- a/xlators/storage/bd/src/Makefile.am
+++ b/xlators/storage/bd/src/Makefile.am
@@ -7,7 +7,7 @@ LIBBD = -llvm2app -lrt
bd_la_SOURCES = bd.c bd-helper.c bd-aio.c
bd_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la $(LIBBD) $(LIBAIO)
-noinst_HEADERS = bd.h bd-aio.h
+noinst_HEADERS = bd.h bd-aio.h bd-mem-types.h
AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \
-I$(top_srcdir)/rpc/xdr/src \
diff --git a/xlators/storage/bd/src/bd-aio.c b/xlators/storage/bd/src/bd-aio.c
index 62d4590f728..9dc13b3ec60 100644
--- a/xlators/storage/bd/src/bd-aio.c
+++ b/xlators/storage/bd/src/bd-aio.c
@@ -29,6 +29,7 @@
#ifdef HAVE_LIBAIO
#include <libaio.h>
+#include "bd-mem-types.h"
struct bd_aio_cb {
struct iocb iocb;
@@ -187,7 +188,7 @@ bd_aio_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
goto err;
}
- paiocb = CALLOC (1, sizeof (*paiocb));
+ paiocb = GF_CALLOC (1, sizeof (*paiocb), gf_bd_aio_cb);
if (!paiocb) {
op_errno = ENOMEM;
goto err;
@@ -314,7 +315,7 @@ bd_aio_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
_fd = bd_fd->fd;
- paiocb = CALLOC (1, sizeof (*paiocb));
+ paiocb = GF_CALLOC (1, sizeof (*paiocb), gf_bd_aio_cb);
if (!paiocb) {
op_errno = ENOMEM;
goto err;
diff --git a/xlators/storage/bd/src/bd-helper.c b/xlators/storage/bd/src/bd-helper.c
index 63e26d8a3a6..4bd1d6111d5 100644
--- a/xlators/storage/bd/src/bd-helper.c
+++ b/xlators/storage/bd/src/bd-helper.c
@@ -9,6 +9,7 @@
#include <linux/fs.h>
#include <sys/ioctl.h>
#include "bd.h"
+#include "bd-mem-types.h"
#include "run.h"
int
@@ -242,7 +243,7 @@ __bd_fd_ctx_get (xlator_t *this, fd_t *fd, bd_fd_t **bdfd_p)
}
uuid_utoa_r (fd->inode->gfid, gfid);
- asprintf (&devpath, "/dev/%s/%s", priv->vg, gfid);
+ gf_asprintf (&devpath, "/dev/%s/%s", priv->vg, gfid);
if (!devpath)
goto out;
@@ -268,7 +269,7 @@ __bd_fd_ctx_get (xlator_t *this, fd_t *fd, bd_fd_t **bdfd_p)
ret = 0;
out:
- FREE (devpath);
+ GF_FREE (devpath);
if (ret) {
close (_fd);
GF_FREE (bdfd);
@@ -701,8 +702,8 @@ out:
if (fd2 != -1)
close (fd2);
- FREE (spath);
- FREE (dpath);
+ GF_FREE (spath);
+ GF_FREE (dpath);
return ret;
}
diff --git a/xlators/storage/bd/src/bd-mem-types.h b/xlators/storage/bd/src/bd-mem-types.h
new file mode 100644
index 00000000000..58b44834247
--- /dev/null
+++ b/xlators/storage/bd/src/bd-mem-types.h
@@ -0,0 +1,27 @@
+/*
+ Copyright (c) 2008-2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+
+#ifndef __BD_MEM_TYPES_H__
+#define __BD_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_bd_mem_types_ {
+ gf_bd_private = gf_common_mt_end + 1,
+ gf_bd_attr,
+ gf_bd_fd,
+ gf_bd_loc_t,
+ gf_bd_int32_t,
+ gf_bd_aio_cb,
+ gf_bd_mt_end
+};
+
+#endif
diff --git a/xlators/storage/bd/src/bd.c b/xlators/storage/bd/src/bd.c
index 4c3a7e14e65..0954b553da5 100644
--- a/xlators/storage/bd/src/bd.c
+++ b/xlators/storage/bd/src/bd.c
@@ -32,6 +32,7 @@
#include "bd.h"
#include "bd-aio.h"
+#include "bd-mem-types.h"
#include "defaults.h"
#include "glusterfs3-xdr.h"
#include "run.h"
@@ -213,7 +214,7 @@ bd_forget (xlator_t *this, inode_t *inode)
ret = bd_inode_ctx_get (inode, this, &bdatt);
if (!ret) {
inode_ctx_del (inode, this, &ctx);
- FREE (bdatt);
+ GF_FREE (bdatt);
}
return 0;
}
@@ -236,7 +237,7 @@ bd_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
entry->d_stat.ia_gfid, &type, &size)) {
entry->d_stat.ia_size = size;
entry->d_stat.ia_blocks = size / 512;
- FREE (type);
+ GF_FREE (type);
}
}
@@ -653,7 +654,7 @@ bd_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
goto posix;
uuid_utoa_r (fd->inode->gfid, gfid);
- asprintf (&devpath, "/dev/%s/%s", priv->vg, gfid);
+ gf_asprintf (&devpath, "/dev/%s/%s", priv->vg, gfid);
BD_VALIDATE_MEM_ALLOC (devpath, ret, out);
_fd = open (devpath, flags | O_LARGEFILE, 0);
@@ -688,7 +689,7 @@ posix:
out:
BD_STACK_UNWIND (open, frame, -1, ret, fd, NULL);
- FREE (devpath);
+ GF_FREE (devpath);
if (ret) {
close (_fd);
GF_FREE (bd_fd);
@@ -1213,7 +1214,7 @@ bd_offload_dest_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
- local->bdatt = CALLOC (1, sizeof (bd_attr_t));
+ local->bdatt = GF_CALLOC (1, sizeof (bd_attr_t), gf_bd_attr);
BD_VALIDATE_MEM_ALLOC (local->bdatt, op_errno, out);
STACK_WIND (frame, bd_offload_getx_cbk, FIRST_CHILD(this),
@@ -1303,7 +1304,7 @@ bd_offload (call_frame_t *frame, xlator_t *this, loc_t *loc,
local->dict = dict_new ();
BD_VALIDATE_MEM_ALLOC (local->dict, op_errno, out);
- local->dloc = CALLOC (1, sizeof (loc_t));
+ local->dloc = GF_CALLOC (1, sizeof (loc_t), gf_bd_loc_t);
BD_VALIDATE_MEM_ALLOC (local->dloc, op_errno, out);
strncpy (param, local->data->data, local->data->len);
@@ -1923,7 +1924,7 @@ bd_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
memcpy (postbuf, &bdatt->iatt, sizeof (struct iatt));
out:
- FREE (valid);
+ GF_FREE (valid);
BD_STACK_UNWIND (setattr, frame, op_ret, op_errno, prebuf,
postbuf, xdata);
return 0;
@@ -1948,7 +1949,7 @@ bd_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *stbuf,
local = bd_local_init (frame, this);
BD_VALIDATE_MEM_ALLOC (local, op_errno, out);
- ck_valid = CALLOC (1, sizeof (valid));
+ ck_valid = GF_CALLOC (1, sizeof (valid), gf_bd_int32_t);
BD_VALIDATE_MEM_ALLOC (ck_valid, op_errno, out);
local->inode = inode_ref (loc->inode);
@@ -2268,6 +2269,7 @@ mem_acct_init (xlator_t *this)
if (ret != 0)
gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
"failed");
+
return ret;
}
diff --git a/xlators/storage/bd/src/bd.h b/xlators/storage/bd/src/bd.h
index f59bc6a09ed..5307ca40736 100644
--- a/xlators/storage/bd/src/bd.h
+++ b/xlators/storage/bd/src/bd.h
@@ -92,13 +92,6 @@
typedef char bd_gfid_t[GF_UUID_BUF_SIZE];
-enum gf_bd_mem_types_ {
- gf_bd_private = gf_common_mt_end + 1,
- gf_bd_attr,
- gf_bd_fd,
- gf_bd_mt_end
-};
-
/**
* bd_fd - internal structure
*/