From fd7e3b6052881319d4671771aae44933bbf858d4 Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Sat, 9 Apr 2011 01:54:19 +0000 Subject: enable memory accounting for error-gen xlator Signed-off-by: Raghavendra Bhat Signed-off-by: Anand Avati BUG: 329 (Replacing memory allocation functions with mem-type functions) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=329 --- xlators/debug/error-gen/src/error-gen-mem-types.h | 30 +++++++++++++++++++++++ xlators/debug/error-gen/src/error-gen.c | 22 +++++++++++++++-- xlators/debug/error-gen/src/error-gen.h | 2 ++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 xlators/debug/error-gen/src/error-gen-mem-types.h (limited to 'xlators/debug') diff --git a/xlators/debug/error-gen/src/error-gen-mem-types.h b/xlators/debug/error-gen/src/error-gen-mem-types.h new file mode 100644 index 00000000000..0fae10944d8 --- /dev/null +++ b/xlators/debug/error-gen/src/error-gen-mem-types.h @@ -0,0 +1,30 @@ +/* + Copyright (c) 2008-2010 Gluster, Inc. + This file is part of GlusterFS. + + GlusterFS is free software; you can redistribute it and/or modify + it under the terms of the GNU Affero 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 + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see + . +*/ + + +#ifndef __ERROR_GEN_MEM_TYPES_H__ +#define __ERROR_GEN_MEM_TYPES_H__ + +#include "mem-types.h" + +enum gf_error_gen_mem_types_ { + gf_error_gen_mt_eg_t = gf_common_mt_end + 1, + gf_error_gen_mt_end +}; +#endif diff --git a/xlators/debug/error-gen/src/error-gen.c b/xlators/debug/error-gen/src/error-gen.c index 84a42072770..458db300354 100644 --- a/xlators/debug/error-gen/src/error-gen.c +++ b/xlators/debug/error-gen/src/error-gen.c @@ -1845,6 +1845,24 @@ error_gen_close (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_error_gen_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) @@ -1876,7 +1894,7 @@ init (xlator_t *this) failure_percent = dict_get (this->options, "failure"); enable = dict_get (this->options, "enable"); - pvt = CALLOC (1, sizeof (eg_t)); + pvt = GF_CALLOC (1, sizeof (eg_t), gf_error_gen_mt_eg_t); if (!pvt) { gf_log (this->name, GF_LOG_ERROR, @@ -1955,7 +1973,7 @@ fini (xlator_t *this) if (pvt) { LOCK_DESTROY (&pvt->lock); - FREE (pvt); + GF_FREE (pvt); gf_log (this->name, GF_LOG_DEBUG, "fini called"); } return; diff --git a/xlators/debug/error-gen/src/error-gen.h b/xlators/debug/error-gen/src/error-gen.h index 1c902cf4f21..28bcdc2abc6 100644 --- a/xlators/debug/error-gen/src/error-gen.h +++ b/xlators/debug/error-gen/src/error-gen.h @@ -25,6 +25,8 @@ #include "config.h" #endif +#include "error-gen-mem-types.h" + #define GF_FAILURE_DEFAULT 10 typedef struct { -- cgit