From 582de0677da4be19fc6f873625c58c45d069ab1c Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Thu, 22 Apr 2010 13:33:09 +0000 Subject: Memory accounting changes Memory accounting Changes. Thanks to Vinayak Hegde and Csaba Henk for their contributions. Signed-off-by: Vijay Bellur Signed-off-by: Anand V. Avati BUG: 329 (Replacing memory allocation functions with mem-type functions) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=329 --- scheduler/rr/src/rr-mem-types.h | 32 ++++++++++++++++++++++++++++++++ scheduler/rr/src/rr-options.c | 4 ++-- scheduler/rr/src/rr.c | 20 +++++++++++--------- 3 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 scheduler/rr/src/rr-mem-types.h (limited to 'scheduler/rr') diff --git a/scheduler/rr/src/rr-mem-types.h b/scheduler/rr/src/rr-mem-types.h new file mode 100644 index 000000000..4b283ca84 --- /dev/null +++ b/scheduler/rr/src/rr-mem-types.h @@ -0,0 +1,32 @@ +/* + Copyright (c) 2008-2009 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 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 + . +*/ + + +#ifndef __RR_MEM_TYPES_H__ +#define __RR_MEM_TYPES_H__ + +#include "mem-types.h" + +enum gf_rr_mem_types_ { + gf_rr_mt_rr_t = gf_common_mt_end + 1, + gf_rr_mt_rr_subvolume_t, + gf_rr_mt_end +}; +#endif + diff --git a/scheduler/rr/src/rr-options.c b/scheduler/rr/src/rr-options.c index b76c9fccc..b454ccd7c 100644 --- a/scheduler/rr/src/rr-options.c +++ b/scheduler/rr/src/rr-options.c @@ -143,9 +143,9 @@ _rr_options_read_only_subvolumes_validate (const char *value_string, free_exit: for (i = 0; i < vcount; i++) { - free (vlist[i]); + GF_FREE (vlist[i]); } - free (vlist); + GF_FREE (vlist); return -1; } diff --git a/scheduler/rr/src/rr.c b/scheduler/rr/src/rr.c index d47f87278..83a0f267f 100644 --- a/scheduler/rr/src/rr.c +++ b/scheduler/rr/src/rr.c @@ -31,6 +31,7 @@ #include "rr-options.h" #include "rr.h" +#include "rr-mem-types.h" #define RR_MIN_FREE_DISK_NOT_REACHED 0 #define RR_MIN_FREE_DISK_REACHED 1 @@ -58,14 +59,14 @@ _cleanup_rr (rr_t *rr) { for (i = 0; i < rr->options.read_only_subvolume_count; i++) { - free (rr->options.read_only_subvolume_list[i]); + GF_FREE (rr->options.read_only_subvolume_list[i]); } - free (rr->options.read_only_subvolume_list); + GF_FREE (rr->options.read_only_subvolume_list); } - free (rr->subvolume_list); + GF_FREE (rr->subvolume_list); - free (rr); + GF_FREE (rr); return 0; } @@ -95,14 +96,14 @@ rr_init (xlator_t *this_xl) return -1; } - if ((rr = CALLOC (1, sizeof (rr_t))) == NULL) + if ((rr = GF_CALLOC (1, sizeof (rr_t), gf_rr_mt_rr_t)) == NULL) { return -1; } if (rr_options_validate (options, &rr->options) != 0) { - free (rr); + GF_FREE (rr); return -1; } @@ -147,8 +148,9 @@ rr_init (xlator_t *this_xl) return -1; } - if ((rr->subvolume_list = CALLOC (rr->subvolume_count, - sizeof (rr_subvolume_t))) == NULL) + if ((rr->subvolume_list = GF_CALLOC (rr->subvolume_count, + sizeof (rr_subvolume_t), + gf_rr_mt_rr_subvolume_t)) == NULL) { _cleanup_rr (rr); return -1; @@ -476,7 +478,7 @@ rr_notify (xlator_t *this_xl, int32_t event, void *data) if (xattr) dict_ref (xattr); - loc.path = strdup ("/"); + loc.path = gf_strdup ("/"); for (trav = this_xl->parents->xlator; trav; trav = trav->parents->xlator) { if (trav->itable) { loc.inode = trav->itable->root; -- cgit