diff options
author | Vijay Bellur <vijay@gluster.com> | 2010-04-22 13:33:09 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-04-23 06:32:52 -0700 |
commit | 582de0677da4be19fc6f873625c58c45d069ab1c (patch) | |
tree | f10cb3e26e1f92f6ea91034e6f7bb925790dd9bc /xlators/features/path-convertor | |
parent | 72baa17282f5cf749fa743fd601c7b728ece4fa2 (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/features/path-convertor')
-rw-r--r-- | xlators/features/path-convertor/src/path-mem-types.h | 32 | ||||
-rw-r--r-- | xlators/features/path-convertor/src/path.c | 88 |
2 files changed, 87 insertions, 33 deletions
diff --git a/xlators/features/path-convertor/src/path-mem-types.h b/xlators/features/path-convertor/src/path-mem-types.h new file mode 100644 index 00000000000..99f794679e7 --- /dev/null +++ b/xlators/features/path-convertor/src/path-mem-types.h @@ -0,0 +1,32 @@ +/* + 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 __PATH_MEM_TYPES_H__ +#define __PATH_MEM_TYPES_H__ + +#include "mem-types.h" + +enum gf_path_mem_types_ { + gf_path_mt_path_private_t = gf_common_mt_end + 1, + gf_path_mt_char, + gf_path_mt_regex_t, + gf_path_mt_end +}; +#endif + diff --git a/xlators/features/path-convertor/src/path.c b/xlators/features/path-convertor/src/path.c index 3589e1485c7..eda1633834e 100644 --- a/xlators/features/path-convertor/src/path.c +++ b/xlators/features/path-convertor/src/path.c @@ -35,6 +35,7 @@ #include <errno.h> #include "glusterfs.h" #include "xlator.h" +#include "path-mem-types.h" typedef struct path_private { @@ -63,7 +64,9 @@ name_this_to_that (xlator_t *xl, const char *path, const char *name) if (priv->end_off && (total_len > priv->end_off)) { j = priv->start_off; - tmp_name = CALLOC (1, (total_len + ZR_FILE_CONTENT_STRLEN)); + tmp_name = GF_CALLOC (1, (total_len + + ZR_FILE_CONTENT_STRLEN), + gf_path_mt_char); ERR_ABORT (tmp_name); /* Get the complete path for the file first */ @@ -104,7 +107,7 @@ path_this_to_that (xlator_t *xl, const char *path) int32_t i = 0, j = 0; if (priv->end_off && (path_len > priv->start_off)) { - priv_path = CALLOC (1, path_len); + priv_path = GF_CALLOC (1, path_len, gf_path_mt_char); ERR_ABORT (priv_path); if (priv->start_off && (path_len > priv->start_off)) @@ -378,7 +381,7 @@ path_lookup (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -405,7 +408,7 @@ path_stat (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -434,7 +437,7 @@ path_readlink (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -465,7 +468,7 @@ path_mknod (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -494,7 +497,7 @@ path_mkdir (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -521,7 +524,7 @@ path_unlink (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -548,7 +551,7 @@ path_rmdir (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -577,7 +580,7 @@ path_symlink (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -615,11 +618,11 @@ path_rename (call_frame_t *frame, oldloc->path = oldloc_path; if (tmp_oldloc_path != oldloc_path) - FREE (tmp_oldloc_path); + GF_FREE (tmp_oldloc_path); newloc->path = newloc_path; if (tmp_newloc_path != newloc_path) - FREE (tmp_newloc_path); + GF_FREE (tmp_newloc_path); return 0; } @@ -657,11 +660,11 @@ path_link (call_frame_t *frame, oldloc->path = oldloc_path; if (tmp_oldloc_path != oldloc_path) - FREE (tmp_oldloc_path); + GF_FREE (tmp_oldloc_path); newloc->path = newloc_path; if (tmp_newloc_path != newloc_path) - FREE (tmp_newloc_path); + GF_FREE (tmp_newloc_path); return 0; } @@ -704,7 +707,7 @@ path_setattr (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -734,7 +737,7 @@ path_truncate (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -768,7 +771,7 @@ path_open (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -801,7 +804,7 @@ path_create (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -843,10 +846,10 @@ path_setxattr (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); if (tmp_name) - FREE (tmp_name); + GF_FREE (tmp_name); return 0; } @@ -880,10 +883,10 @@ path_getxattr (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); if (tmp_name != name) - FREE (tmp_name); + GF_FREE (tmp_name); return 0; } @@ -917,10 +920,10 @@ path_removexattr (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); if (tmp_name != name) - FREE (tmp_name); + GF_FREE (tmp_name); return 0; } @@ -949,7 +952,7 @@ path_opendir (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -978,7 +981,7 @@ path_access (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -1020,7 +1023,7 @@ path_checksum (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -1047,7 +1050,7 @@ path_entrylk (call_frame_t *frame, xlator_t *this, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -1073,7 +1076,7 @@ path_inodelk (call_frame_t *frame, xlator_t *this, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -1105,11 +1108,29 @@ path_xattrop (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } +int32_t +mem_acct_init (xlator_t *this) +{ + int ret = -1; + + if (!this) + return ret; + + ret = xlator_mem_acct_init (this, gf_path_mt_end + 1); + + if (ret != 0) { + gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" + "failed"); + return ret; + } + + return ret; +} int32_t init (xlator_t *this) @@ -1128,7 +1149,7 @@ init (xlator_t *this) "dangling volume. check volfile "); } - priv = CALLOC (1, sizeof (*priv)); + priv = GF_CALLOC (1, sizeof (*priv), gf_path_mt_path_private_t); ERR_ABORT (priv); if (dict_get (options, "start-offset")) { priv->start_off = data_to_int32 (dict_get (options, @@ -1141,7 +1162,8 @@ init (xlator_t *this) if (dict_get (options, "regex")) { int32_t ret = 0; - priv->preg = CALLOC (1, sizeof (regex_t)); + priv->preg = GF_CALLOC (1, sizeof (regex_t), + gf_path_mt_regex_t); ERR_ABORT (priv->preg); ret = regcomp (priv->preg, data_to_str (dict_get (options, "regex")), @@ -1149,7 +1171,7 @@ init (xlator_t *this) if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to compile the 'option regex'"); - FREE (priv); + GF_FREE (priv); return -1; } if (dict_get (options, "replace-with")) { |