summaryrefslogtreecommitdiffstats
path: root/xlators/debug
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-04-22 13:33:09 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-04-23 06:32:52 -0700
commit582de0677da4be19fc6f873625c58c45d069ab1c (patch)
treef10cb3e26e1f92f6ea91034e6f7bb925790dd9bc /xlators/debug
parent72baa17282f5cf749fa743fd601c7b728ece4fa2 (diff)
Memory accounting changes
Memory accounting Changes. Thanks to Vinayak Hegde and Csaba Henk for their contributions. Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 329 (Replacing memory allocation functions with mem-type functions) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=329
Diffstat (limited to 'xlators/debug')
-rw-r--r--xlators/debug/io-stats/src/io-stats-mem-types.h33
-rw-r--r--xlators/debug/io-stats/src/io-stats.c41
-rw-r--r--xlators/debug/trace/src/trace.c70
3 files changed, 98 insertions, 46 deletions
diff --git a/xlators/debug/io-stats/src/io-stats-mem-types.h b/xlators/debug/io-stats/src/io-stats-mem-types.h
new file mode 100644
index 000000000..d9b434d57
--- /dev/null
+++ b/xlators/debug/io-stats/src/io-stats-mem-types.h
@@ -0,0 +1,33 @@
+
+/*
+ Copyright (c) 2008-2009 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef __IO_STATS_MEM_TYPES_H__
+#define __IO_STATS_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_io_stats_mem_types_ {
+ gf_io_stats_mt_ios_conf = gf_common_mt_end + 1,
+ gf_io_stats_mt_ios_fd,
+ gf_io_stats_mt_end
+};
+#endif
+
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
index e5ccf10bc..09ee86751 100644
--- a/xlators/debug/io-stats/src/io-stats.c
+++ b/xlators/debug/io-stats/src/io-stats.c
@@ -41,6 +41,7 @@
#include <errno.h>
#include "glusterfs.h"
#include "xlator.h"
+#include "io-stats-mem-types.h"
struct ios_global_stats {
@@ -360,13 +361,13 @@ io_stats_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto unwind;
if (op_ret < 0) {
- FREE (path);
+ GF_FREE (path);
goto unwind;
}
- iosfd = CALLOC (1, sizeof (*iosfd));
+ iosfd = GF_CALLOC (1, sizeof (*iosfd), gf_io_stats_mt_ios_fd);
if (!iosfd) {
- FREE (path);
+ GF_FREE (path);
goto unwind;
}
@@ -396,13 +397,13 @@ io_stats_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto unwind;
if (op_ret < 0) {
- FREE (path);
+ GF_FREE (path);
goto unwind;
}
- iosfd = CALLOC (1, sizeof (*iosfd));
+ iosfd = GF_CALLOC (1, sizeof (*iosfd), gf_io_stats_mt_ios_fd);
if (!iosfd) {
- FREE (path);
+ GF_FREE (path);
goto unwind;
}
@@ -1024,7 +1025,7 @@ io_stats_open (call_frame_t *frame, xlator_t *this,
{
BUMP_FOP (OPEN);
- frame->local = strdup (loc->path);
+ frame->local = gf_strdup (loc->path);
STACK_WIND (frame, io_stats_open_cbk,
FIRST_CHILD(this),
@@ -1040,7 +1041,7 @@ io_stats_create (call_frame_t *frame, xlator_t *this,
{
BUMP_FOP (CREATE);
- frame->local = strdup (loc->path);
+ frame->local = gf_strdup (loc->path);
STACK_WIND (frame, io_stats_create_cbk,
FIRST_CHILD(this),
@@ -1382,8 +1383,8 @@ io_stats_release (xlator_t *this, fd_t *fd)
io_stats_dump_fd (this, iosfd);
if (iosfd->filename)
- FREE (iosfd->filename);
- FREE (iosfd);
+ GF_FREE (iosfd->filename);
+ GF_FREE (iosfd);
}
return 0;
@@ -1407,6 +1408,24 @@ io_stats_forget (xlator_t *this, fd_t *fd)
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_io_stats_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ " failed");
+ return ret;
+ }
+
+ return ret;
+}
int
init (xlator_t *this)
@@ -1432,7 +1451,7 @@ init (xlator_t *this)
options = this->options;
- conf = CALLOC (1, sizeof(*conf));
+ conf = GF_CALLOC (1, sizeof(*conf), gf_io_stats_mt_ios_conf);
LOCK_INIT (&conf->lock);
diff --git a/xlators/debug/trace/src/trace.c b/xlators/debug/trace/src/trace.c
index 5d1d342db..7d619aadb 100644
--- a/xlators/debug/trace/src/trace.c
+++ b/xlators/debug/trace/src/trace.c
@@ -75,7 +75,7 @@ trace_stat_to_str (struct iatt *stbuf)
strftime (ctime_buf, 256, "[%b %d %H:%M:%S]",
localtime ((time_t *)&stbuf->ia_ctime));
- asprint_ret_value = asprintf (&statstr,
+ asprint_ret_value = gf_asprintf (&statstr,
"ia_ino=%"PRIu64", ia_gen=%"PRIu64
", st_mode=%o, ia_nlink=%"GF_PRI_NLINK", "
"ia_uid=%d, ia_gid=%d, ia_size=%"PRId64", ia_blocks=%"PRId64
@@ -118,11 +118,11 @@ trace_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
statstr, preparentstr, postparentstr);
if (statstr)
- FREE (statstr);
+ GF_FREE (statstr);
if (preparentstr)
- FREE (preparentstr);
+ GF_FREE (preparentstr);
if (postparentstr)
- FREE (postparentstr);
+ GF_FREE (postparentstr);
} else {
gf_log (this->name, GF_LOG_NORMAL,
"%"PRId64": (op_ret=%d, op_errno=%d)",
@@ -255,10 +255,10 @@ trace_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
preopstr, postopstr);
if (preopstr)
- FREE (preopstr);
+ GF_FREE (preopstr);
if (postopstr)
- FREE (postopstr);
+ GF_FREE (postopstr);
} else {
gf_log (this->name, GF_LOG_NORMAL,
"%"PRId64": (op_ret=%d, op_errno=%d)",
@@ -324,10 +324,10 @@ trace_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
preopstr, postopstr);
if (preopstr)
- FREE (preopstr);
+ GF_FREE (preopstr);
if (postopstr)
- FREE (postopstr);
+ GF_FREE (postopstr);
} else {
gf_log (this->name, GF_LOG_NORMAL,
"%"PRId64": (op_ret=%d, op_errno=%d)",
@@ -472,10 +472,10 @@ trace_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
postparentstr);
if (preparentstr)
- FREE (preparentstr);
+ GF_FREE (preparentstr);
if (postparentstr)
- FREE (postparentstr);
+ GF_FREE (postparentstr);
} else {
gf_log (this->name, GF_LOG_NORMAL,
"%"PRId64": (op_ret=%d, op_errno=%d)",
@@ -519,16 +519,16 @@ trace_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
prenewparentstr, postnewparentstr);
if (preoldparentstr)
- FREE (preoldparentstr);
+ GF_FREE (preoldparentstr);
if (postoldparentstr)
- FREE (postoldparentstr);
+ GF_FREE (postoldparentstr);
if (prenewparentstr)
- FREE (prenewparentstr);
+ GF_FREE (prenewparentstr);
if (postnewparentstr)
- FREE (postnewparentstr);
+ GF_FREE (postnewparentstr);
} else {
gf_log (this->name, GF_LOG_NORMAL,
"%"PRId64": (op_ret=%d, op_errno=%d)",
@@ -569,7 +569,7 @@ trace_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
frame->root->unique, op_ret, op_errno);
if (statstr)
- FREE (statstr);
+ GF_FREE (statstr);
}
STACK_UNWIND_STRICT (readlink, frame, op_ret, op_errno, buf, stbuf);
@@ -598,9 +598,9 @@ trace_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
statstr, postparentstr);
if (statstr)
- FREE (statstr);
+ GF_FREE (statstr);
if (postparentstr)
- FREE (postparentstr);
+ GF_FREE (postparentstr);
} else {
gf_log (this->name, GF_LOG_NORMAL,
"%"PRId64": (op_ret=%d, op_errno=%d)",
@@ -638,13 +638,13 @@ trace_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
statstr, preparentstr, postparentstr);
if (statstr)
- FREE (statstr);
+ GF_FREE (statstr);
if (preparentstr)
- FREE (preparentstr);
+ GF_FREE (preparentstr);
if (postparentstr)
- FREE (postparentstr);
+ GF_FREE (postparentstr);
} else {
gf_log (this->name, GF_LOG_NORMAL,
@@ -683,13 +683,13 @@ trace_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
statstr, preparentstr, postparentstr);
if (statstr)
- FREE (statstr);
+ GF_FREE (statstr);
if (preparentstr)
- FREE (preparentstr);
+ GF_FREE (preparentstr);
if (postparentstr)
- FREE (postparentstr);
+ GF_FREE (postparentstr);
} else {
gf_log (this->name, GF_LOG_NORMAL,
"%"PRId64": (op_ret=%d, op_errno=%d)",
@@ -727,13 +727,13 @@ trace_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
statstr, preparentstr, postparentstr);
if (statstr)
- FREE (statstr);
+ GF_FREE (statstr);
if (preparentstr)
- FREE (preparentstr);
+ GF_FREE (preparentstr);
if (postparentstr)
- FREE (postparentstr);
+ GF_FREE (postparentstr);
} else {
gf_log (this->name, GF_LOG_NORMAL,
"%"PRId64": (op_ret=%d, op_errno=%d)",
@@ -771,13 +771,13 @@ trace_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
statstr, preparentstr, postparentstr);
if (statstr)
- FREE (statstr);
+ GF_FREE (statstr);
if (preparentstr)
- FREE (preparentstr);
+ GF_FREE (preparentstr);
if (postparentstr)
- FREE (postparentstr);
+ GF_FREE (postparentstr);
} else {
gf_log (this->name, GF_LOG_NORMAL,
"%"PRId64": (op_ret=%d, op_errno=%d)",
@@ -841,10 +841,10 @@ trace_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
postparentstr);
if (preparentstr)
- FREE (preparentstr);
+ GF_FREE (preparentstr);
if (postparentstr)
- FREE (postparentstr);
+ GF_FREE (postparentstr);
} else {
gf_log (this->name, GF_LOG_NORMAL,
"%"PRId64": (op_ret=%d, op_errno=%d)",
@@ -878,10 +878,10 @@ trace_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
postopstr);
if (preopstr)
- FREE (preopstr);
+ GF_FREE (preopstr);
if (postopstr)
- FREE (postopstr);
+ GF_FREE (postopstr);
} else {
gf_log (this->name, GF_LOG_NORMAL,
"%"PRId64": (op_ret=%d, op_errno=%d)",
@@ -1017,10 +1017,10 @@ trace_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
prebufstr, postbufstr);
if (prebufstr)
- FREE (prebufstr);
+ GF_FREE (prebufstr);
if (postbufstr)
- FREE (postbufstr);
+ GF_FREE (postbufstr);
} else {
gf_log (this->name, GF_LOG_NORMAL,