summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--glusterfsd/src/glusterfsd-mem-types.h36
-rw-r--r--glusterfsd/src/glusterfsd.c96
-rw-r--r--libglusterfs/src/authenticate.c12
-rw-r--r--libglusterfs/src/call-stub.c65
-rw-r--r--libglusterfs/src/common-utils.c38
-rw-r--r--libglusterfs/src/common-utils.h6
-rw-r--r--libglusterfs/src/defaults.c10
-rw-r--r--libglusterfs/src/defaults.h2
-rw-r--r--libglusterfs/src/dict.c69
-rw-r--r--libglusterfs/src/event.c62
-rw-r--r--libglusterfs/src/fd.c27
-rw-r--r--libglusterfs/src/gf-dirent.c7
-rw-r--r--libglusterfs/src/globals.c4
-rw-r--r--libglusterfs/src/inode.c55
-rw-r--r--libglusterfs/src/iobuf.c18
-rw-r--r--libglusterfs/src/logging.c44
-rw-r--r--libglusterfs/src/mem-pool.c287
-rw-r--r--libglusterfs/src/mem-pool.h65
-rw-r--r--libglusterfs/src/mem-types.h82
-rw-r--r--libglusterfs/src/protocol.h3
-rw-r--r--libglusterfs/src/rbthash.c20
-rw-r--r--libglusterfs/src/scheduler.c6
-rw-r--r--libglusterfs/src/scheduler.h1
-rw-r--r--libglusterfs/src/stack.h19
-rw-r--r--libglusterfs/src/statedump.c45
-rw-r--r--libglusterfs/src/timer.c19
-rw-r--r--libglusterfs/src/timer.h4
-rw-r--r--libglusterfs/src/transport.c37
-rw-r--r--libglusterfs/src/xlator.c74
-rw-r--r--libglusterfs/src/xlator.h3
-rw-r--r--scheduler/alu/src/alu-mem-types.h35
-rw-r--r--scheduler/alu/src/alu.c64
-rw-r--r--scheduler/nufa/src/nufa-mem-types.h33
-rw-r--r--scheduler/nufa/src/nufa.c54
-rw-r--r--scheduler/random/src/random-mem-types.h32
-rw-r--r--scheduler/random/src/random.c34
-rw-r--r--scheduler/rr/src/rr-mem-types.h32
-rw-r--r--scheduler/rr/src/rr-options.c4
-rw-r--r--scheduler/rr/src/rr.c20
-rw-r--r--scheduler/switch/src/switch-mem-types.h33
-rw-r--r--scheduler/switch/src/switch.c68
-rw-r--r--transport/ib-verbs/src/ib-verbs-mem-types.h39
-rw-r--r--transport/ib-verbs/src/ib-verbs.c78
-rw-r--r--transport/ib-verbs/src/ib-verbs.h1
-rw-r--r--transport/socket/src/socket-mem-types.h36
-rw-r--r--transport/socket/src/socket.c38
-rw-r--r--transport/socket/src/socket.h1
-rw-r--r--xlators/cluster/afr/src/afr-dir-read.c19
-rw-r--r--xlators/cluster/afr/src/afr-dir-write.c8
-rw-r--r--xlators/cluster/afr/src/afr-inode-read.c6
-rw-r--r--xlators/cluster/afr/src/afr-inode-write.c2
-rw-r--r--xlators/cluster/afr/src/afr-mem-types.h46
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-algorithm.c35
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c67
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c16
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-entry.c22
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-metadata.c5
-rw-r--r--xlators/cluster/afr/src/afr.c137
-rw-r--r--xlators/cluster/afr/src/afr.h52
-rw-r--r--xlators/cluster/dht/src/dht-common.c9
-rw-r--r--xlators/cluster/dht/src/dht-common.h2
-rw-r--r--xlators/cluster/dht/src/dht-helper.c9
-rw-r--r--xlators/cluster/dht/src/dht-layout.c13
-rw-r--r--xlators/cluster/dht/src/dht-mem-types.h42
-rw-r--r--xlators/cluster/dht/src/dht-selfheal.c2
-rw-r--r--xlators/cluster/dht/src/dht.c51
-rw-r--r--xlators/cluster/dht/src/nufa.c32
-rw-r--r--xlators/cluster/dht/src/switch.c78
-rw-r--r--xlators/cluster/ha/src/ha-helpers.c11
-rw-r--r--xlators/cluster/ha/src/ha-mem-types.h37
-rw-r--r--xlators/cluster/ha/src/ha.c167
-rw-r--r--xlators/cluster/ha/src/ha.h2
-rw-r--r--xlators/cluster/map/src/map-helper.c5
-rw-r--r--xlators/cluster/map/src/map-mem-types.h35
-rw-r--r--xlators/cluster/map/src/map.c48
-rw-r--r--xlators/cluster/map/src/map.h1
-rw-r--r--xlators/cluster/stripe/src/stripe-mem-types.h40
-rw-r--r--xlators/cluster/stripe/src/stripe.c178
-rw-r--r--xlators/cluster/stripe/src/stripe.h1
-rw-r--r--xlators/cluster/unify/src/unify-mem-types.h41
-rw-r--r--xlators/cluster/unify/src/unify-self-heal.c90
-rw-r--r--xlators/cluster/unify/src/unify.c94
-rw-r--r--xlators/cluster/unify/src/unify.h3
-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
-rw-r--r--xlators/features/filter/src/filter-mem-types.h30
-rw-r--r--xlators/features/filter/src/filter.c48
-rw-r--r--xlators/features/locks/src/common.c49
-rw-r--r--xlators/features/locks/src/entrylk.c29
-rw-r--r--xlators/features/locks/src/inodelk.c9
-rw-r--r--xlators/features/locks/src/locks-mem-types.h39
-rw-r--r--xlators/features/locks/src/locks.h1
-rw-r--r--xlators/features/locks/src/posix.c60
-rw-r--r--xlators/features/path-convertor/src/path-mem-types.h32
-rw-r--r--xlators/features/path-convertor/src/path.c88
-rw-r--r--xlators/features/quota/src/quota-mem-types.h31
-rw-r--r--xlators/features/quota/src/quota.c40
-rw-r--r--xlators/features/trash/src/trash-mem-types.h33
-rw-r--r--xlators/features/trash/src/trash.c83
-rw-r--r--xlators/meta/src/meta-mem-types.h35
-rw-r--r--xlators/meta/src/meta.c61
-rw-r--r--xlators/meta/src/tree.c23
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c81
-rw-r--r--xlators/mount/fuse/src/fuse-mem-types.h35
-rw-r--r--xlators/nfs/lib/src/rpcsvc-auth.c12
-rw-r--r--xlators/nfs/lib/src/rpcsvc.c32
-rw-r--r--xlators/nfs/lib/src/xdr-nfs3.c18
-rw-r--r--xlators/nfs/server/src/mount3.c31
-rw-r--r--xlators/nfs/server/src/nfs-common.c11
-rw-r--r--xlators/nfs/server/src/nfs-mem-types.h46
-rw-r--r--xlators/nfs/server/src/nfs.c26
-rw-r--r--xlators/nfs/server/src/nfs3-helpers.c35
-rw-r--r--xlators/nfs/server/src/nfs3.c21
-rw-r--r--xlators/performance/io-cache/src/io-cache.c77
-rw-r--r--xlators/performance/io-cache/src/ioc-inode.c10
-rw-r--r--xlators/performance/io-cache/src/ioc-mem-types.h40
-rw-r--r--xlators/performance/io-cache/src/page.c39
-rw-r--r--xlators/performance/io-threads/src/io-threads.c25
-rw-r--r--xlators/performance/io-threads/src/io-threads.h1
-rw-r--r--xlators/performance/io-threads/src/iot-mem-types.h31
-rw-r--r--xlators/performance/quick-read/src/quick-read-mem-types.h35
-rw-r--r--xlators/performance/quick-read/src/quick-read.c72
-rw-r--r--xlators/performance/quick-read/src/quick-read.h1
-rw-r--r--xlators/performance/read-ahead/src/page.c40
-rw-r--r--xlators/performance/read-ahead/src/read-ahead-mem-types.h37
-rw-r--r--xlators/performance/read-ahead/src/read-ahead.c33
-rw-r--r--xlators/performance/read-ahead/src/read-ahead.h1
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch-mem-types.h36
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.c84
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.h1
-rw-r--r--xlators/performance/write-behind/src/write-behind-mem-types.h35
-rw-r--r--xlators/performance/write-behind/src/write-behind.c81
-rw-r--r--xlators/protocol/client/src/client-mem-types.h43
-rw-r--r--xlators/protocol/client/src/client-protocol.c178
-rw-r--r--xlators/protocol/client/src/saved-frames.c13
-rw-r--r--xlators/protocol/server/src/server-helpers.c97
-rw-r--r--xlators/protocol/server/src/server-mem-types.h39
-rw-r--r--xlators/protocol/server/src/server-protocol.c164
-rw-r--r--xlators/protocol/server/src/server-protocol.h1
-rw-r--r--xlators/protocol/server/src/server-resolve.c11
-rw-r--r--xlators/storage/bdb/src/bctx.c14
-rw-r--r--xlators/storage/bdb/src/bdb-ll.c48
-rw-r--r--xlators/storage/bdb/src/bdb-mem-types.h42
-rw-r--r--xlators/storage/bdb/src/bdb.c95
-rw-r--r--xlators/storage/posix/src/posix-mem-types.h36
-rw-r--r--xlators/storage/posix/src/posix.c140
-rw-r--r--xlators/storage/posix/src/posix.h2
148 files changed, 4368 insertions, 1641 deletions
diff --git a/glusterfsd/src/glusterfsd-mem-types.h b/glusterfsd/src/glusterfsd-mem-types.h
new file mode 100644
index 00000000000..1cca177889b
--- /dev/null
+++ b/glusterfsd/src/glusterfsd-mem-types.h
@@ -0,0 +1,36 @@
+/*
+ Copyright (c) 2006-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 __GLUSTERFSD_MEM_TYPES_H__
+#define __GLUSTERFSD_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+#define GF_MEM_TYPE_START (gf_common_mt_end + 1)
+
+enum gfd_mem_types_ {
+ gfd_mt_xlator_list_t = GF_MEM_TYPE_START,
+ gfd_mt_xlator_t,
+ gfd_mt_xlator_cmdline_option_t,
+ gfd_mt_char,
+ gfd_mt_call_pool_t,
+ gfd_mt_end
+
+};
+#endif
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index 867cdf78e12..570e7c19559 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -2,7 +2,7 @@
Copyright (c) 2006-2009 Gluster, Inc. <http://www.gluster.com>
This file is part of GlusterFS.
- GlusterFS is free software; you can redistribute it and/or modify
+ GlusterFS is GF_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.
@@ -70,6 +70,7 @@
#include "globals.h"
#include "statedump.h"
#include "latency.h"
+#include "glusterfsd-mem-types.h"
#include <fnmatch.h>
@@ -298,12 +299,14 @@ _add_fuse_mount (xlator_t *graph)
ctx = graph->ctx;
cmd_args = &ctx->cmd_args;
- xlchild = CALLOC (sizeof (*xlchild), 1);
+ xlchild = GF_CALLOC (sizeof (*xlchild), 1,
+ gfd_mt_xlator_list_t);
ERR_ABORT (xlchild);
xlchild->xlator = graph;
- top = CALLOC (1, sizeof (*top));
- top->name = strdup ("fuse");
+ top = GF_CALLOC (1, sizeof (*top),
+ gfd_mt_xlator_t);
+ top->name = gf_strdup ("fuse");
if (xlator_set_type (top, ZR_XLATOR_FUSE) == -1) {
fprintf (stderr,
"MOUNT-POINT %s initialization failed",
@@ -368,7 +371,8 @@ _add_fuse_mount (xlator_t *graph)
#endif /* GF_DARWIN_HOST_OS */
- graph->parents = CALLOC (1, sizeof (xlator_list_t));
+ graph->parents = GF_CALLOC (1, sizeof (xlator_list_t),
+ gfd_mt_xlator_list_t);
graph->parents->xlator = top;
return top;
@@ -696,6 +700,10 @@ glusterfs_graph_init (xlator_t *graph, int fuse)
"validating translator failed");
return -1;
}
+
+ if (graph->mem_acct_init (graph) != 0)
+ return -1;
+
if (xlator_init (graph) != 0)
return -1;
@@ -730,27 +738,30 @@ gf_remember_xlator_option (struct list_head *options, char *arg)
ctx = get_global_ctx_ptr ();
cmd_args = &ctx->cmd_args;
- option = CALLOC (1, sizeof (xlator_cmdline_option_t));
+ option = GF_CALLOC (1, sizeof (xlator_cmdline_option_t),
+ gfd_mt_xlator_cmdline_option_t);
INIT_LIST_HEAD (&option->cmd_args);
dot = strchr (arg, '.');
if (!dot)
goto out;
- option->volume = CALLOC ((dot - arg), sizeof (char));
+ option->volume = GF_CALLOC ((dot - arg), sizeof (char),
+ gfd_mt_char);
strncpy (option->volume, arg, (dot - arg));
equals = strchr (arg, '=');
if (!equals)
goto out;
- option->key = CALLOC ((equals - dot), sizeof (char));
+ option->key = GF_CALLOC ((equals - dot), sizeof (char),
+ gfd_mt_char);
strncpy (option->key, dot + 1, (equals - dot - 1));
if (!*(equals + 1))
goto out;
- option->value = strdup (equals + 1);
+ option->value = gf_strdup (equals + 1);
list_add (&option->cmd_args, &cmd_args->xlator_options);
@@ -759,13 +770,13 @@ out:
if (ret == -1) {
if (option) {
if (option->volume)
- FREE (option->volume);
+ GF_FREE (option->volume);
if (option->key)
- FREE (option->key);
+ GF_FREE (option->key);
if (option->value)
- FREE (option->value);
+ GF_FREE (option->value);
- FREE (option);
+ GF_FREE (option);
}
}
@@ -819,7 +830,7 @@ parse_opts (int key, char *arg, struct argp_state *state)
switch (key) {
case ARGP_VOLFILE_SERVER_KEY:
- cmd_args->volfile_server = strdup (arg);
+ cmd_args->volfile_server = gf_strdup (arg);
break;
case ARGP_VOLFILE_MAX_FETCH_ATTEMPTS:
@@ -839,11 +850,11 @@ parse_opts (int key, char *arg, struct argp_state *state)
break;
case ARGP_VOLUME_FILE_KEY:
- cmd_args->volume_file = strdup (arg);
+ cmd_args->volume_file = gf_strdup (arg);
break;
case ARGP_LOG_SERVER_KEY:
- cmd_args->log_server = strdup (arg);
+ cmd_args->log_server = gf_strdup (arg);
break;
case ARGP_LOG_LEVEL_KEY:
@@ -880,7 +891,7 @@ parse_opts (int key, char *arg, struct argp_state *state)
break;
case ARGP_LOG_FILE_KEY:
- cmd_args->log_file = strdup (arg);
+ cmd_args->log_file = gf_strdup (arg);
break;
case ARGP_VOLFILE_SERVER_PORT_KEY:
@@ -908,15 +919,15 @@ parse_opts (int key, char *arg, struct argp_state *state)
break;
case ARGP_VOLFILE_SERVER_TRANSPORT_KEY:
- cmd_args->volfile_server_transport = strdup (arg);
+ cmd_args->volfile_server_transport = gf_strdup (arg);
break;
case ARGP_VOLFILE_ID_KEY:
- cmd_args->volfile_id = strdup (arg);
+ cmd_args->volfile_id = gf_strdup (arg);
break;
case ARGP_PID_FILE_KEY:
- cmd_args->pid_file = strdup (arg);
+ cmd_args->pid_file = gf_strdup (arg);
break;
case ARGP_NO_DAEMON_KEY:
@@ -924,7 +935,7 @@ parse_opts (int key, char *arg, struct argp_state *state)
break;
case ARGP_RUN_ID_KEY:
- cmd_args->run_id = strdup (arg);
+ cmd_args->run_id = gf_strdup (arg);
break;
case ARGP_DEBUG_KEY:
@@ -969,7 +980,7 @@ parse_opts (int key, char *arg, struct argp_state *state)
break;
case ARGP_VOLUME_NAME_KEY:
- cmd_args->volume_name = strdup (arg);
+ cmd_args->volume_name = gf_strdup (arg);
break;
case ARGP_XLATOR_OPTION_KEY:
@@ -990,7 +1001,7 @@ parse_opts (int key, char *arg, struct argp_state *state)
if (state->arg_num >= 1)
argp_usage (state);
- cmd_args->mount_point = strdup (arg);
+ cmd_args->mount_point = gf_strdup (arg);
break;
}
@@ -1064,7 +1075,7 @@ zr_build_process_uuid ()
snprintf (tmp_str, 1024, "%s-%d-%s:%ld",
hostname, getpid(), now_str, tv.tv_usec);
- return strdup (tmp_str);
+ return gf_strdup (tmp_str);
}
#define GF_SERVER_PROCESS 0
@@ -1076,7 +1087,7 @@ gf_get_process_mode (char *exec_name)
char *dup_execname = NULL, *base = NULL;
uint8_t ret = 0;
- dup_execname = strdup (exec_name);
+ dup_execname = gf_strdup (exec_name);
base = basename (dup_execname);
if (!strncmp (base, "glusterfsd", 10)) {
@@ -1085,7 +1096,7 @@ gf_get_process_mode (char *exec_name)
ret = GF_CLIENT_PROCESS;
}
- free (dup_execname);
+ GF_FREE (dup_execname);
return ret;
}
@@ -1110,9 +1121,9 @@ set_log_file_path (cmd_args_t *cmd_args)
if (cmd_args->mount_point[i] == '/')
tmp_str[j] = '-';
}
- ret = asprintf (&cmd_args->log_file,
- DEFAULT_LOG_FILE_DIRECTORY "/%s.log",
- tmp_str);
+ ret = gf_asprintf (&cmd_args->log_file,
+ DEFAULT_LOG_FILE_DIRECTORY "/%s.log",
+ tmp_str);
if (-1 == ret) {
gf_log ("glusterfsd", GF_LOG_ERROR,
"asprintf failed while setting up log-file");
@@ -1130,7 +1141,7 @@ set_log_file_path (cmd_args_t *cmd_args)
if (cmd_args->volume_file[i] == '/')
tmp_str[j] = '-';
}
- ret = asprintf (&cmd_args->log_file,
+ ret = gf_asprintf (&cmd_args->log_file,
DEFAULT_LOG_FILE_DIRECTORY "/%s.log",
tmp_str);
if (-1 == ret) {
@@ -1149,9 +1160,9 @@ set_log_file_path (cmd_args_t *cmd_args)
if (cmd_args->volfile_id)
tmp_ptr = cmd_args->volfile_id;
- ret = asprintf (&cmd_args->log_file,
- DEFAULT_LOG_FILE_DIRECTORY "/%s-%s-%d.log",
- cmd_args->volfile_server, tmp_ptr, port);
+ ret = gf_asprintf (&cmd_args->log_file,
+ DEFAULT_LOG_FILE_DIRECTORY "/%s-%s-%d.log",
+ cmd_args->volfile_server, tmp_ptr, port);
if (-1 == ret) {
gf_log ("glusterfsd", GF_LOG_ERROR,
"asprintf failed while setting up log-file");
@@ -1190,6 +1201,10 @@ main (int argc, char *argv[])
if (ret)
return ret;
+ ret = xlator_mem_acct_init (THIS, gfd_mt_end);
+ if (ret)
+ return ret;
+
utime = time (NULL);
ctx = glusterfs_ctx_get ();
process_mode = gf_get_process_mode (argv[0]);
@@ -1215,9 +1230,9 @@ main (int argc, char *argv[])
if ((cmd_args->volfile_server == NULL)
&& (cmd_args->volume_file == NULL)) {
if (process_mode == GF_SERVER_PROCESS)
- cmd_args->volume_file = strdup (DEFAULT_SERVER_VOLUME_FILE);
+ cmd_args->volume_file = gf_strdup (DEFAULT_SERVER_VOLUME_FILE);
else
- cmd_args->volume_file = strdup (DEFAULT_CLIENT_VOLUME_FILE);
+ cmd_args->volume_file = gf_strdup (DEFAULT_CLIENT_VOLUME_FILE);
}
if (cmd_args->log_file == NULL) {
@@ -1233,7 +1248,8 @@ main (int argc, char *argv[])
ctx->iobuf_pool = iobuf_pool_new (8 * GF_UNIT_MB, ctx->page_size);
ctx->event_pool = event_pool_new (DEFAULT_EVENT_POOL_SIZE);
pthread_mutex_init (&(ctx->lock), NULL);
- pool = ctx->pool = CALLOC (1, sizeof (call_pool_t));
+ pool = ctx->pool = GF_CALLOC (1, sizeof (call_pool_t),
+ gfd_mt_call_pool_t);
ERR_ABORT (ctx->pool);
LOCK_INIT (&pool->lock);
INIT_LIST_HEAD (&pool->all_frames);
@@ -1256,17 +1272,17 @@ main (int argc, char *argv[])
/* Create symlink to actual log file */
unlink (cmd_args->log_file);
- tmp_logfile_dyn = strdup (tmp_logfile);
+ tmp_logfile_dyn = gf_strdup (tmp_logfile);
tmp_logfilebase = basename (tmp_logfile_dyn);
ret = symlink (tmp_logfilebase, cmd_args->log_file);
if (-1 == ret) {
fprintf (stderr, "symlink of logfile failed");
} else {
- FREE (cmd_args->log_file);
- cmd_args->log_file = strdup (tmp_logfile);
+ GF_FREE (cmd_args->log_file);
+ cmd_args->log_file = gf_strdup (tmp_logfile);
}
- FREE (tmp_logfile_dyn);
+ GF_FREE (tmp_logfile_dyn);
}
}
diff --git a/libglusterfs/src/authenticate.c b/libglusterfs/src/authenticate.c
index 6a6fd03ac79..eb0e2464cf6 100644
--- a/libglusterfs/src/authenticate.c
+++ b/libglusterfs/src/authenticate.c
@@ -58,7 +58,7 @@ init (dict_t *this,
key = "addr";
}
- ret = asprintf (&auth_file, "%s/%s.so", LIBDIR, key);
+ ret = gf_asprintf (&auth_file, "%s/%s.so", LIBDIR, key);
if (-1 == ret) {
gf_log ("authenticate", GF_LOG_ERROR, "asprintf failed");
dict_set (this, key, data_from_dynptr (NULL, 0));
@@ -71,11 +71,11 @@ init (dict_t *this,
gf_log ("authenticate", GF_LOG_ERROR, "dlopen(%s): %s\n",
auth_file, dlerror ());
dict_set (this, key, data_from_dynptr (NULL, 0));
- FREE (auth_file);
+ GF_FREE (auth_file);
*error = -1;
return;
}
- FREE (auth_file);
+ GF_FREE (auth_file);
authenticate = dlsym (handle, "gf_auth");
if (!authenticate) {
@@ -86,14 +86,16 @@ init (dict_t *this,
return;
}
- auth_handle = CALLOC (1, sizeof (*auth_handle));
+ auth_handle = GF_CALLOC (1, sizeof (*auth_handle),
+ gf_common_mt_auth_handle_t);
if (!auth_handle) {
gf_log ("authenticate", GF_LOG_ERROR, "Out of memory");
dict_set (this, key, data_from_dynptr (NULL, 0));
*error = -1;
return;
}
- auth_handle->vol_opt = CALLOC (1, sizeof (volume_opt_list_t));
+ auth_handle->vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t),
+ gf_common_mt_volume_opt_list_t);
auth_handle->vol_opt->given_opt = dlsym (handle, "options");
if (auth_handle->vol_opt->given_opt == NULL) {
gf_log ("authenticate", GF_LOG_DEBUG,
diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c
index 5f73d9d6e5c..f0d04eb95d7 100644
--- a/libglusterfs/src/call-stub.c
+++ b/libglusterfs/src/call-stub.c
@@ -26,6 +26,7 @@
#include "md5.h"
#include "call-stub.h"
+#include "mem-types.h"
static call_stub_t *
@@ -37,7 +38,7 @@ stub_new (call_frame_t *frame,
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
- new = CALLOC (1, sizeof (*new));
+ new = GF_CALLOC (1, sizeof (*new), gf_common_mt_call_stub_t);
GF_VALIDATE_OR_GOTO ("call-stub", new, out);
new->frame = frame;
@@ -383,7 +384,7 @@ fop_readlink_cbk_stub (call_frame_t *frame,
stub->args.readlink_cbk.op_ret = op_ret;
stub->args.readlink_cbk.op_errno = op_errno;
if (path)
- stub->args.readlink_cbk.buf = strdup (path);
+ stub->args.readlink_cbk.buf = gf_strdup (path);
if (sbuf)
stub->args.readlink_cbk.sbuf = *sbuf;
out:
@@ -614,7 +615,7 @@ fop_symlink_stub (call_frame_t *frame,
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.symlink.fn = fn;
- stub->args.symlink.linkname = strdup (linkname);
+ stub->args.symlink.linkname = gf_strdup (linkname);
loc_copy (&stub->args.symlink.loc, loc);
out:
return stub;
@@ -1291,7 +1292,7 @@ fop_getxattr_stub (call_frame_t *frame,
loc_copy (&stub->args.getxattr.loc, loc);
if (name)
- stub->args.getxattr.name = strdup (name);
+ stub->args.getxattr.name = gf_strdup (name);
out:
return stub;
}
@@ -1388,7 +1389,7 @@ fop_fgetxattr_stub (call_frame_t *frame,
stub->args.fgetxattr.fd = fd_ref (fd);
if (name)
- stub->args.fgetxattr.name = strdup (name);
+ stub->args.fgetxattr.name = gf_strdup (name);
out:
return stub;
}
@@ -1437,7 +1438,7 @@ fop_removexattr_stub (call_frame_t *frame,
stub->args.removexattr.fn = fn;
loc_copy (&stub->args.removexattr.loc, loc);
- stub->args.removexattr.name = strdup (name);
+ stub->args.removexattr.name = gf_strdup (name);
out:
return stub;
}
@@ -1529,7 +1530,7 @@ fop_inodelk_stub (call_frame_t *frame, fop_inodelk_t fn,
stub->args.inodelk.fn = fn;
if (volume)
- stub->args.inodelk.volume = strdup (volume);
+ stub->args.inodelk.volume = gf_strdup (volume);
loc_copy (&stub->args.inodelk.loc, loc);
stub->args.inodelk.cmd = cmd;
@@ -1578,7 +1579,7 @@ fop_finodelk_stub (call_frame_t *frame, fop_finodelk_t fn,
stub->args.finodelk.fd = fd_ref (fd);
if (volume)
- stub->args.finodelk.volume = strdup (volume);
+ stub->args.finodelk.volume = gf_strdup (volume);
stub->args.finodelk.cmd = cmd;
stub->args.finodelk.lock = *lock;
@@ -1625,14 +1626,14 @@ fop_entrylk_stub (call_frame_t *frame, fop_entrylk_t fn,
stub->args.entrylk.fn = fn;
if (volume)
- stub->args.entrylk.volume = strdup (volume);
+ stub->args.entrylk.volume = gf_strdup (volume);
loc_copy (&stub->args.entrylk.loc, loc);
stub->args.entrylk.cmd = cmd;
stub->args.entrylk.type = type;
if (name)
- stub->args.entrylk.name = strdup (name);
+ stub->args.entrylk.name = gf_strdup (name);
return stub;
}
@@ -1675,14 +1676,14 @@ fop_fentrylk_stub (call_frame_t *frame, fop_fentrylk_t fn,
stub->args.fentrylk.fn = fn;
if (volume)
- stub->args.fentrylk.volume = strdup (volume);
+ stub->args.fentrylk.volume = gf_strdup (volume);
if (fd)
stub->args.fentrylk.fd = fd_ref (fd);
stub->args.fentrylk.cmd = cmd;
stub->args.fentrylk.type = type;
if (name)
- stub->args.fentrylk.name = strdup (name);
+ stub->args.fentrylk.name = gf_strdup (name);
return stub;
}
@@ -3222,8 +3223,8 @@ call_resume_unwind (call_stub_t *stub)
stub->args.checksum_cbk.dir_checksum);
if (stub->args.checksum_cbk.op_ret >= 0)
{
- FREE (stub->args.checksum_cbk.file_checksum);
- FREE (stub->args.checksum_cbk.dir_checksum);
+ GF_FREE (stub->args.checksum_cbk.file_checksum);
+ GF_FREE (stub->args.checksum_cbk.dir_checksum);
}
break;
@@ -3247,7 +3248,7 @@ call_resume_unwind (call_stub_t *stub)
stub->args.rchecksum_cbk.strong_checksum);
if (stub->args.rchecksum_cbk.op_ret >= 0)
{
- FREE (stub->args.rchecksum_cbk.strong_checksum);
+ GF_FREE (stub->args.rchecksum_cbk.strong_checksum);
}
break;
@@ -3438,7 +3439,7 @@ call_stub_destroy_wind (call_stub_t *stub)
case GF_FOP_SYMLINK:
{
- FREE (stub->args.symlink.linkname);
+ GF_FREE ((char *)stub->args.symlink.linkname);
loc_wipe (&stub->args.symlink.loc);
}
break;
@@ -3475,7 +3476,7 @@ call_stub_destroy_wind (call_stub_t *stub)
struct iobref *iobref = stub->args.writev.iobref;
if (stub->args.writev.fd)
fd_unref (stub->args.writev.fd);
- FREE (stub->args.writev.vector);
+ GF_FREE (stub->args.writev.vector);
if (iobref)
iobref_unref (iobref);
break;
@@ -3511,7 +3512,7 @@ call_stub_destroy_wind (call_stub_t *stub)
case GF_FOP_GETXATTR:
{
if (stub->args.getxattr.name)
- FREE (stub->args.getxattr.name);
+ GF_FREE ((char *)stub->args.getxattr.name);
loc_wipe (&stub->args.getxattr.loc);
break;
}
@@ -3527,7 +3528,7 @@ call_stub_destroy_wind (call_stub_t *stub)
case GF_FOP_FGETXATTR:
{
if (stub->args.fgetxattr.name)
- FREE (stub->args.fgetxattr.name);
+ GF_FREE ((char *)stub->args.fgetxattr.name);
fd_unref (stub->args.fgetxattr.fd);
break;
}
@@ -3535,7 +3536,7 @@ call_stub_destroy_wind (call_stub_t *stub)
case GF_FOP_REMOVEXATTR:
{
loc_wipe (&stub->args.removexattr.loc);
- FREE (stub->args.removexattr.name);
+ GF_FREE ((char *)stub->args.removexattr.name);
break;
}
@@ -3584,7 +3585,7 @@ call_stub_destroy_wind (call_stub_t *stub)
case GF_FOP_INODELK:
{
if (stub->args.inodelk.volume)
- FREE (stub->args.inodelk.volume);
+ GF_FREE ((char *)stub->args.inodelk.volume);
loc_wipe (&stub->args.inodelk.loc);
break;
@@ -3592,7 +3593,7 @@ call_stub_destroy_wind (call_stub_t *stub)
case GF_FOP_FINODELK:
{
if (stub->args.finodelk.volume)
- FREE (stub->args.finodelk.volume);
+ GF_FREE ((char *)stub->args.finodelk.volume);
if (stub->args.finodelk.fd)
fd_unref (stub->args.finodelk.fd);
@@ -3601,20 +3602,20 @@ call_stub_destroy_wind (call_stub_t *stub)
case GF_FOP_ENTRYLK:
{
if (stub->args.entrylk.volume)
- FREE (stub->args.entrylk.volume);
+ GF_FREE ((char *)stub->args.entrylk.volume);
if (stub->args.entrylk.name)
- FREE (stub->args.entrylk.name);
+ GF_FREE ((char *)stub->args.entrylk.name);
loc_wipe (&stub->args.entrylk.loc);
break;
}
case GF_FOP_FENTRYLK:
{
if (stub->args.fentrylk.volume)
- FREE (stub->args.fentrylk.volume);
+ GF_FREE ((char *)stub->args.fentrylk.volume);
if (stub->args.fentrylk.name)
- FREE (stub->args.fentrylk.name);
+ GF_FREE ((char *)stub->args.fentrylk.name);
if (stub->args.fentrylk.fd)
fd_unref (stub->args.fentrylk.fd);
@@ -3717,7 +3718,7 @@ call_stub_destroy_unwind (call_stub_t *stub)
case GF_FOP_READLINK:
{
if (stub->args.readlink_cbk.buf)
- FREE (stub->args.readlink_cbk.buf);
+ GF_FREE ((char *)stub->args.readlink_cbk.buf);
}
break;
@@ -3765,7 +3766,7 @@ call_stub_destroy_unwind (call_stub_t *stub)
{
if (stub->args.readv_cbk.op_ret >= 0) {
struct iobref *iobref = stub->args.readv_cbk.iobref;
- FREE (stub->args.readv_cbk.vector);
+ GF_FREE (stub->args.readv_cbk.vector);
if (iobref) {
iobref_unref (iobref);
@@ -3856,8 +3857,8 @@ call_stub_destroy_unwind (call_stub_t *stub)
case GF_FOP_CHECKSUM:
{
if (stub->args.checksum_cbk.op_ret >= 0) {
- FREE (stub->args.checksum_cbk.file_checksum);
- FREE (stub->args.checksum_cbk.dir_checksum);
+ GF_FREE (stub->args.checksum_cbk.file_checksum);
+ GF_FREE (stub->args.checksum_cbk.dir_checksum);
}
}
break;
@@ -3865,7 +3866,7 @@ call_stub_destroy_unwind (call_stub_t *stub)
case GF_FOP_RCHECKSUM:
{
if (stub->args.rchecksum_cbk.op_ret >= 0) {
- FREE (stub->args.rchecksum_cbk.strong_checksum);
+ GF_FREE (stub->args.rchecksum_cbk.strong_checksum);
}
}
break;
@@ -3931,7 +3932,7 @@ call_stub_destroy (call_stub_t *stub)
call_stub_destroy_unwind (stub);
}
- FREE (stub);
+ GF_FREE (stub);
out:
return;
}
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 984ad0794a3..7851ad2f815 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -89,7 +89,8 @@ gf_resolve_ip6 (const char *hostname,
}
if (!*dnscache) {
- *dnscache = CALLOC (1, sizeof (struct dnscache6));
+ *dnscache = GF_CALLOC (1, sizeof (struct dnscache6),
+ gf_common_mt_dnscache6);
}
cache = *dnscache;
@@ -111,7 +112,7 @@ gf_resolve_ip6 (const char *hostname,
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_ADDRCONFIG;
- ret = asprintf (&port_str, "%d", port);
+ ret = gf_asprintf (&port_str, "%d", port);
if (-1 == ret) {
gf_log ("resolver", GF_LOG_ERROR, "asprintf failed");
return -1;
@@ -120,12 +121,12 @@ gf_resolve_ip6 (const char *hostname,
gf_log ("resolver", GF_LOG_ERROR,
"getaddrinfo failed (%s)", gai_strerror (ret));
- free (*dnscache);
+ GF_FREE (*dnscache);
*dnscache = NULL;
- free (port_str);
+ GF_FREE (port_str);
return -1;
}
- free (port_str);
+ GF_FREE (port_str);
cache->next = cache->first;
}
@@ -173,7 +174,7 @@ gf_resolve_ip6 (const char *hostname,
err:
freeaddrinfo (cache->first);
cache->first = cache->next = NULL;
- free (cache);
+ GF_FREE (cache);
*dnscache = NULL;
return -1;
}
@@ -509,7 +510,8 @@ gf_strsplit (const char *str, const char *delim,
return -1;
}
- if ((_running = strdup (str)) == NULL)
+ _running = gf_strdup (str);
+ if (_running == NULL)
{
return -1;
}
@@ -520,17 +522,19 @@ gf_strsplit (const char *str, const char *delim,
if (token[0] != '\0')
count++;
}
- free (_running);
+ GF_FREE (_running);
- if ((_running = strdup (str)) == NULL)
+ _running = gf_strdup (str);
+ if (_running == NULL)
{
return -1;
}
running = _running;
- if ((token_list = CALLOC (count, sizeof (char *))) == NULL)
+ if ((token_list = GF_CALLOC (count, sizeof (char *),
+ gf_common_mt_char)) == NULL)
{
- free (_running);
+ GF_FREE (_running);
return -1;
}
@@ -539,23 +543,25 @@ gf_strsplit (const char *str, const char *delim,
if (token[0] == '\0')
continue;
- if ((token_list[i++] = strdup (token)) == NULL)
+ token_list[i] = gf_strdup (token);
+ if (token_list[i] == NULL)
goto free_exit;
+ i++;
}
- free (_running);
+ GF_FREE (_running);
*tokens = token_list;
*token_count = count;
return 0;
free_exit:
- free (_running);
+ GF_FREE (_running);
for (j = 0; j < i; j++)
{
- free (token_list[j]);
+ GF_FREE (token_list[j]);
}
- free (token_list);
+ GF_FREE (token_list);
return -1;
}
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index 9c1c93ebffb..3bf4ba9b180 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -147,7 +147,7 @@ iov_free (struct iovec *vector, int count)
for (i = 0; i < count; i++)
FREE (vector[i].iov_base);
- FREE (vector);
+ GF_FREE (vector);
}
@@ -172,7 +172,7 @@ iov_dup (struct iovec *vector, int count)
struct iovec *newvec = NULL;
bytecount = (count * sizeof (struct iovec));
- newvec = MALLOC (bytecount);
+ newvec = GF_MALLOC (bytecount, gf_common_mt_iovec);
if (!newvec)
return NULL;
@@ -282,7 +282,7 @@ memdup (const void *ptr, size_t size)
{
void *newptr = NULL;
- newptr = MALLOC (size);
+ newptr = GF_MALLOC (size, gf_common_mt_memdup);
if (!newptr)
return NULL;
diff --git a/libglusterfs/src/defaults.c b/libglusterfs/src/defaults.c
index 7ae60130e62..7ec877551bf 100644
--- a/libglusterfs/src/defaults.c
+++ b/libglusterfs/src/defaults.c
@@ -1383,3 +1383,13 @@ default_fsetattr (call_frame_t *frame,
fd, stbuf, valid);
return 0;
}
+
+int32_t
+default_mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ ret = xlator_mem_acct_init (this, gf_common_mt_end);
+
+ return ret;
+}
diff --git a/libglusterfs/src/defaults.h b/libglusterfs/src/defaults.h
index 58ef90d423d..30e0f9e371a 100644
--- a/libglusterfs/src/defaults.h
+++ b/libglusterfs/src/defaults.h
@@ -432,4 +432,6 @@ default_writev_cbk (call_frame_t *frame,
struct iatt *prebuf,
struct iatt *postbuf);
+int32_t
+default_mem_acct_init (xlator_t *this);
#endif /* _DEFAULTS_H */
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index 9e97bf1d422..7d560bdac71 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -41,7 +41,8 @@ get_new_data_pair ()
{
data_pair_t *data_pair_ptr = NULL;
- data_pair_ptr = (data_pair_t *) CALLOC (1, sizeof (data_pair_t));
+ data_pair_ptr = (data_pair_t *) GF_CALLOC (1, sizeof (data_pair_t),
+ gf_common_mt_data_pair_t);
ERR_ABORT (data_pair_ptr);
return data_pair_ptr;
@@ -52,7 +53,7 @@ get_new_data ()
{
data_t *data = NULL;
- data = (data_t *) CALLOC (1, sizeof (data_t));
+ data = (data_t *) GF_CALLOC (1, sizeof (data_t), gf_common_mt_data_t);
if (!data) {
gf_log ("dict", GF_LOG_CRITICAL,
"calloc () returned NULL");
@@ -66,7 +67,7 @@ get_new_data ()
dict_t *
get_new_dict_full (int size_hint)
{
- dict_t *dict = CALLOC (1, sizeof (dict_t));
+ dict_t *dict = GF_CALLOC (1, sizeof (dict_t), gf_common_mt_dict_t);
if (!dict) {
gf_log ("dict", GF_LOG_CRITICAL,
@@ -75,7 +76,8 @@ get_new_dict_full (int size_hint)
}
dict->hash_size = size_hint;
- dict->members = CALLOC (size_hint, sizeof (data_pair_t *));
+ dict->members = GF_CALLOC (size_hint, sizeof (data_pair_t *),
+ gf_common_mt_data_pair_t);
if (!dict->members) {
gf_log ("dict", GF_LOG_CRITICAL,
@@ -138,14 +140,14 @@ data_destroy (data_t *data)
if (!data->is_static) {
if (data->data)
- FREE (data->data);
+ GF_FREE (data->data);
if (data->vec)
- FREE (data->vec);
+ GF_FREE (data->vec);
}
data->len = 0xbabababa;
if (!data->is_const)
- FREE (data);
+ GF_FREE (data);
}
}
@@ -158,7 +160,8 @@ data_copy (data_t *old)
return NULL;
}
- data_t *newdata = (data_t *) CALLOC (1, sizeof (*newdata));
+ data_t *newdata = (data_t *) GF_CALLOC (1, sizeof (*newdata),
+ gf_common_mt_data_t);
if (!newdata) {
gf_log ("dict", GF_LOG_CRITICAL,
@@ -229,7 +232,7 @@ _dict_set (dict_t *this,
int ret = 0;
if (!key) {
- ret = asprintf (&key, "ref:%p", value);
+ ret = gf_asprintf (&key, "ref:%p", value);
if (-1 == ret) {
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
return -1;
@@ -246,18 +249,20 @@ _dict_set (dict_t *this,
pair->value = data_ref (value);
data_unref (unref_data);
if (key_free)
- FREE (key);
+ GF_FREE (key);
/* Indicates duplicate key */
return 0;
}
- pair = (data_pair_t *) CALLOC (1, sizeof (*pair));
+ pair = (data_pair_t *) GF_CALLOC (1, sizeof (*pair),
+ gf_common_mt_data_pair_t);
if (!pair) {
gf_log ("dict", GF_LOG_CRITICAL,
"@pair - NULL returned by CALLOC");
return -1;
}
- pair->key = (char *) CALLOC (1, strlen (key) + 1);
+ pair->key = (char *) GF_CALLOC (1, strlen (key) + 1,
+ gf_common_mt_char);
if (!pair->key) {
gf_log ("dict", GF_LOG_CRITICAL,
"@pair->key - NULL returned by CALLOC");
@@ -280,7 +285,7 @@ _dict_set (dict_t *this,
this->count++;
if (key_free)
- FREE (key);
+ GF_FREE (key);
return 0;
}
@@ -364,8 +369,8 @@ dict_del (dict_t *this,
if (pair->next)
pair->next->prev = pair->prev;
- FREE (pair->key);
- FREE (pair);
+ GF_FREE (pair->key);
+ GF_FREE (pair);
this->count--;
break;
}
@@ -396,18 +401,18 @@ dict_destroy (dict_t *this)
while (prev) {
pair = pair->next;
data_unref (prev->value);
- FREE (prev->key);
- FREE (prev);
+ GF_FREE (prev->key);
+ GF_FREE (prev);
prev = pair;
}
- FREE (this->members);
+ GF_FREE (this->members);
if (this->extra_free)
- FREE (this->extra_free);
+ GF_FREE (this->extra_free);
if (!this->is_static)
- FREE (this);
+ GF_FREE (this);
return;
}
@@ -630,7 +635,7 @@ dict_unserialize_old (char *buf, int32_t size, dict_t **fill)
goto ret;
err:
- FREE (*fill);
+ GF_FREE (*fill);
*fill = NULL;
ret:
@@ -744,7 +749,7 @@ int_to_data (int64_t value)
return NULL;
}
- ret = asprintf (&data->data, "%"PRId64, value);
+ ret = gf_asprintf (&data->data, "%"PRId64, value);
if (-1 == ret) {
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
return NULL;
@@ -765,7 +770,7 @@ data_from_int64 (int64_t value)
"@data - NULL returned by CALLOC");
return NULL;
}
- ret = asprintf (&data->data, "%"PRId64, value);
+ ret = gf_asprintf (&data->data, "%"PRId64, value);
if (-1 == ret) {
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
return NULL;
@@ -786,7 +791,7 @@ data_from_int32 (int32_t value)
"@data - NULL returned by CALLOC");
return NULL;
}
- ret = asprintf (&data->data, "%"PRId32, value);
+ ret = gf_asprintf (&data->data, "%"PRId32, value);
if (-1 == ret) {
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
return NULL;
@@ -808,7 +813,7 @@ data_from_int16 (int16_t value)
"@data - NULL returned by CALLOC");
return NULL;
}
- ret = asprintf (&data->data, "%"PRId16, value);
+ ret = gf_asprintf (&data->data, "%"PRId16, value);
if (-1 == ret) {
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
return NULL;
@@ -830,7 +835,7 @@ data_from_int8 (int8_t value)
"@data - NULL returned by CALLOC");
return NULL;
}
- ret = asprintf (&data->data, "%d", value);
+ ret = gf_asprintf (&data->data, "%d", value);
if (-1 == ret) {
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
return NULL;
@@ -852,7 +857,7 @@ data_from_uint64 (uint64_t value)
"@data - NULL returned by CALLOC");
return NULL;
}
- ret = asprintf (&data->data, "%"PRIu64, value);
+ ret = gf_asprintf (&data->data, "%"PRIu64, value);
if (-1 == ret) {
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
return NULL;
@@ -877,7 +882,7 @@ data_from_double (double value)
return NULL;
}
- ret = asprintf (&data->data, "%f", value);
+ ret = gf_asprintf (&data->data, "%f", value);
if (ret == -1) {
gf_log ("dict", GF_LOG_CRITICAL,
"@data - allocation failed by ASPRINTF");
@@ -900,7 +905,7 @@ data_from_uint32 (uint32_t value)
"@data - NULL returned by CALLOC");
return NULL;
}
- ret = asprintf (&data->data, "%"PRIu32, value);
+ ret = gf_asprintf (&data->data, "%"PRIu32, value);
if (-1 == ret) {
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
return NULL;
@@ -923,7 +928,7 @@ data_from_uint16 (uint16_t value)
"@data - NULL returned by CALLOC");
return NULL;
}
- ret = asprintf (&data->data, "%"PRIu16, value);
+ ret = gf_asprintf (&data->data, "%"PRIu16, value);
if (-1 == ret) {
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
return NULL;
@@ -2513,7 +2518,7 @@ dict_allocate_and_serialize (dict_t *this, char **buf, size_t *length)
goto unlock;
}
- *buf = CALLOC (1, len);
+ *buf = GF_CALLOC (1, len, gf_common_mt_char);
if (*buf == NULL) {
ret = -ENOMEM;
gf_log ("dict", GF_LOG_ERROR, "out of memory");
@@ -2522,7 +2527,7 @@ dict_allocate_and_serialize (dict_t *this, char **buf, size_t *length)
ret = _dict_serialize (this, *buf);
if (ret < 0) {
- FREE (*buf);
+ GF_FREE (*buf);
*buf = NULL;
goto unlock;
}
diff --git a/libglusterfs/src/event.c b/libglusterfs/src/event.c
index 7bef3c5bda5..819357d437a 100644
--- a/libglusterfs/src/event.c
+++ b/libglusterfs/src/event.c
@@ -97,19 +97,21 @@ event_pool_new_poll (int count)
struct event_pool *event_pool = NULL;
int ret = -1;
- event_pool = CALLOC (1, sizeof (*event_pool));
+ event_pool = GF_CALLOC (1, sizeof (*event_pool),
+ gf_common_mt_event_pool);
if (!event_pool)
return NULL;
event_pool->count = count;
- event_pool->reg = CALLOC (event_pool->count,
- sizeof (*event_pool->reg));
+ event_pool->reg = GF_CALLOC (event_pool->count,
+ sizeof (*event_pool->reg),
+ gf_common_mt_reg);
if (!event_pool->reg) {
gf_log ("poll", GF_LOG_CRITICAL,
"failed to allocate event registry");
- free (event_pool);
+ GF_FREE (event_pool);
return NULL;
}
@@ -120,8 +122,8 @@ event_pool_new_poll (int count)
if (ret == -1) {
gf_log ("poll", GF_LOG_ERROR,
"pipe creation failed (%s)", strerror (errno));
- free (event_pool->reg);
- free (event_pool);
+ GF_FREE (event_pool->reg);
+ GF_FREE (event_pool);
return NULL;
}
@@ -134,8 +136,8 @@ event_pool_new_poll (int count)
close (event_pool->breaker[1]);
event_pool->breaker[0] = event_pool->breaker[1] = -1;
- free (event_pool->reg);
- free (event_pool);
+ GF_FREE (event_pool->reg);
+ GF_FREE (event_pool);
return NULL;
}
@@ -149,8 +151,8 @@ event_pool_new_poll (int count)
close (event_pool->breaker[1]);
event_pool->breaker[0] = event_pool->breaker[1] = -1;
- free (event_pool->reg);
- free (event_pool);
+ GF_FREE (event_pool->reg);
+ GF_FREE (event_pool);
return NULL;
}
@@ -163,8 +165,8 @@ event_pool_new_poll (int count)
close (event_pool->breaker[1]);
event_pool->breaker[0] = event_pool->breaker[1] = -1;
- free (event_pool->reg);
- free (event_pool);
+ GF_FREE (event_pool->reg);
+ GF_FREE (event_pool);
return NULL;
}
@@ -190,9 +192,9 @@ event_register_poll (struct event_pool *event_pool, int fd,
{
event_pool->count += 256;
- event_pool->reg = realloc (event_pool->reg,
- event_pool->count *
- sizeof (*event_pool->reg));
+ event_pool->reg = GF_REALLOC (event_pool->reg,
+ event_pool->count *
+ sizeof (*event_pool->reg));
}
idx = event_pool->used++;
@@ -392,14 +394,15 @@ event_dispatch_poll_resize (struct event_pool *event_pool,
if (event_pool->used > event_pool->evcache_size) {
if (event_pool->evcache)
- free (event_pool->evcache);
+ GF_FREE (event_pool->evcache);
event_pool->evcache = ufds = NULL;
event_pool->evcache_size = event_pool->used;
- ufds = CALLOC (sizeof (struct pollfd),
- event_pool->evcache_size);
+ ufds = GF_CALLOC (sizeof (struct pollfd),
+ event_pool->evcache_size,
+ gf_common_mt_pollfd);
event_pool->evcache = ufds;
}
@@ -478,19 +481,21 @@ event_pool_new_epoll (int count)
struct event_pool *event_pool = NULL;
int epfd = -1;
- event_pool = CALLOC (1, sizeof (*event_pool));
+ event_pool = GF_CALLOC (1, sizeof (*event_pool),
+ gf_common_mt_event_pool);
if (!event_pool)
return NULL;
event_pool->count = count;
- event_pool->reg = CALLOC (event_pool->count,
- sizeof (*event_pool->reg));
+ event_pool->reg = GF_CALLOC (event_pool->count,
+ sizeof (*event_pool->reg),
+ gf_common_mt_reg);
if (!event_pool->reg) {
gf_log ("epoll", GF_LOG_CRITICAL,
"event registry allocation failed");
- free (event_pool);
+ GF_FREE (event_pool);
return NULL;
}
@@ -499,8 +504,8 @@ event_pool_new_epoll (int count)
if (epfd == -1) {
gf_log ("epoll", GF_LOG_ERROR, "epoll fd creation failed (%s)",
strerror (errno));
- free (event_pool->reg);
- free (event_pool);
+ GF_FREE (event_pool->reg);
+ GF_FREE (event_pool);
return NULL;
}
@@ -536,7 +541,7 @@ event_register_epoll (struct event_pool *event_pool, int fd,
if (event_pool->count == event_pool->used) {
event_pool->count *= 2;
- event_pool->reg = realloc (event_pool->reg,
+ event_pool->reg = GF_REALLOC (event_pool->reg,
event_pool->count *
sizeof (*event_pool->reg));
@@ -832,15 +837,16 @@ event_dispatch_epoll (struct event_pool *event_pool)
if (event_pool->used > event_pool->evcache_size) {
if (event_pool->evcache)
- free (event_pool->evcache);
+ GF_FREE (event_pool->evcache);
event_pool->evcache = events = NULL;
event_pool->evcache_size =
event_pool->used + 256;
- events = CALLOC (event_pool->evcache_size,
- sizeof (struct epoll_event));
+ events = GF_CALLOC (event_pool->evcache_size,
+ sizeof (struct epoll_event),
+ gf_common_mt_epoll_event);
event_pool->evcache = events;
}
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c
index ee529f35645..b01caf765ff 100644
--- a/libglusterfs/src/fd.c
+++ b/libglusterfs/src/fd.c
@@ -99,7 +99,8 @@ gf_fd_fdtable_expand (fdtable_t *fdtable, uint32_t nr)
oldfds = fdtable->fdentries;
oldmax_fds = fdtable->max_fds;
- fdtable->fdentries = CALLOC (nr, sizeof (fdentry_t));
+ fdtable->fdentries = GF_CALLOC (nr, sizeof (fdentry_t),
+ gf_common_mt_fdentry_t);
ERR_ABORT (fdtable->fdentries);
fdtable->max_fds = nr;
@@ -116,7 +117,7 @@ gf_fd_fdtable_expand (fdtable_t *fdtable, uint32_t nr)
* using the expanded table.
*/
fdtable->first_free = oldmax_fds;
- FREE (oldfds);
+ GF_FREE (oldfds);
return 0;
}
@@ -125,7 +126,7 @@ gf_fd_fdtable_alloc (void)
{
fdtable_t *fdtable = NULL;
- fdtable = CALLOC (1, sizeof (*fdtable));
+ fdtable = GF_CALLOC (1, sizeof (*fdtable), gf_common_mt_fdtable_t);
if (!fdtable)
return NULL;
@@ -150,7 +151,8 @@ __gf_fd_fdtable_get_all_fds (fdtable_t *fdtable, uint32_t *count)
}
fdentries = fdtable->fdentries;
- fdtable->fdentries = calloc (fdtable->max_fds, sizeof (fdentry_t));
+ fdtable->fdentries = GF_CALLOC (fdtable->max_fds, sizeof (fdentry_t),
+ gf_common_mt_fdentry_t);
gf_fd_chain_fd_entries (fdtable->fdentries, 0, fdtable->max_fds);
*count = fdtable->max_fds;
@@ -190,7 +192,7 @@ gf_fd_fdtable_destroy (fdtable_t *fdtable)
pthread_mutex_lock (&fdtable->lock);
{
fdentries = __gf_fd_fdtable_get_all_fds (fdtable, &fd_count);
- FREE (fdtable->fdentries);
+ GF_FREE (fdtable->fdentries);
}
pthread_mutex_unlock (&fdtable->lock);
@@ -202,9 +204,9 @@ gf_fd_fdtable_destroy (fdtable_t *fdtable)
}
}
- FREE (fdentries);
+ GF_FREE (fdentries);
pthread_mutex_destroy (&fdtable->lock);
- FREE (fdtable);
+ GF_FREE (fdtable);
}
}
@@ -425,10 +427,10 @@ fd_destroy (fd_t *fd)
LOCK_DESTROY (&fd->lock);
- FREE (fd->_ctx);
+ GF_FREE (fd->_ctx);
inode_unref (fd->inode);
fd->inode = (inode_t *)0xaaaaaaaa;
- FREE (fd);
+ GF_FREE (fd);
out:
return;
@@ -488,11 +490,12 @@ fd_create (inode_t *inode, pid_t pid)
return NULL;
}
- fd = CALLOC (1, sizeof (fd_t));
+ fd = GF_CALLOC (1, sizeof (fd_t), gf_common_mt_fd_t);
ERR_ABORT (fd);
- fd->_ctx = CALLOC (1, (sizeof (struct _fd_ctx) *
- inode->table->xl->ctx->xl_count));
+ fd->_ctx = GF_CALLOC (1, (sizeof (struct _fd_ctx) *
+ inode->table->xl->ctx->xl_count),
+ gf_common_mt_fd_ctx);
fd->inode = inode_ref (inode);
fd->pid = pid;
INIT_LIST_HEAD (&fd->inode_list);
diff --git a/libglusterfs/src/gf-dirent.c b/libglusterfs/src/gf-dirent.c
index 4a7220d9693..e3c1f1b9004 100644
--- a/libglusterfs/src/gf-dirent.c
+++ b/libglusterfs/src/gf-dirent.c
@@ -75,7 +75,8 @@ gf_dirent_for_name (const char *name)
gf_dirent_t *gf_dirent = NULL;
/* TODO: use mem-pool */
- gf_dirent = CALLOC (gf_dirent_size (name), 1);
+ gf_dirent = GF_CALLOC (gf_dirent_size (name), 1,
+ gf_common_mt_gf_dirent_t);
if (!gf_dirent)
return NULL;
@@ -105,7 +106,7 @@ gf_dirent_free (gf_dirent_t *entries)
list_for_each_entry_safe (entry, tmp, &entries->list, list) {
list_del (&entry->list);
- FREE (entry);
+ GF_FREE (entry);
}
}
@@ -165,7 +166,7 @@ gf_dirent_unserialize (gf_dirent_t *entries, const char *buf, size_t buf_size)
}
entry_len = sizeof (gf_dirent_t) + entry_strlen + 1;
- entry = CALLOC (1, entry_len);
+ entry = GF_CALLOC (1, entry_len, gf_common_mt_gf_dirent_t);
if (!entry) {
break;
}
diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c
index cdb561de199..9677a169ecb 100644
--- a/libglusterfs/src/globals.c
+++ b/libglusterfs/src/globals.c
@@ -27,6 +27,7 @@
#include "globals.h"
#include "glusterfs.h"
#include "xlator.h"
+#include "mem-pool.h"
/* CTX */
@@ -221,6 +222,9 @@ glusterfs_globals_init ()
ret = glusterfs_central_log_flag_init ();
if (ret)
goto out;
+
+ gf_mem_acct_enable_set ();
+
out:
return ret;
}
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
index 6e5d82fec7d..622857c1ab0 100644
--- a/libglusterfs/src/inode.c
+++ b/libglusterfs/src/inode.c
@@ -138,14 +138,14 @@ __dentry_unset (dentry_t *dentry)
list_del_init (&dentry->inode_list);
if (dentry->name)
- FREE (dentry->name);
+ GF_FREE (dentry->name);
if (dentry->parent) {
__inode_unref (dentry->parent);
dentry->parent = NULL;
}
- FREE (dentry);
+ GF_FREE (dentry);
}
@@ -292,11 +292,11 @@ __inode_destroy (inode_t *inode)
}
}
- FREE (inode->_ctx);
+ GF_FREE (inode->_ctx);
noctx:
LOCK_DESTROY (&inode->lock);
// memset (inode, 0xb, sizeof (*inode));
- FREE (inode);
+ GF_FREE (inode);
}
@@ -424,7 +424,8 @@ __dentry_create (inode_t *inode, inode_t *parent, const char *name)
{
dentry_t *newd = NULL;
- newd = (void *) CALLOC (1, sizeof (*newd));
+ newd = (void *) GF_CALLOC (1, sizeof (*newd),
+ gf_common_mt_dentry_t);
if (newd == NULL) {
gf_log ("inode", GF_LOG_ERROR, "out of memory");
goto out;
@@ -433,10 +434,10 @@ __dentry_create (inode_t *inode, inode_t *parent, const char *name)
INIT_LIST_HEAD (&newd->inode_list);
INIT_LIST_HEAD (&newd->hash);
- newd->name = strdup (name);
+ newd->name = gf_strdup (name);
if (newd->name == NULL) {
gf_log ("inode", GF_LOG_ERROR, "out of memory");
- FREE (newd);
+ GF_FREE (newd);
newd = NULL;
goto out;
}
@@ -457,7 +458,7 @@ __inode_create (inode_table_t *table)
{
inode_t *newi = NULL;
- newi = (void *) CALLOC (1, sizeof (*newi));
+ newi = (void *) GF_CALLOC (1, sizeof (*newi), gf_common_mt_inode_t);
if (!newi) {
gf_log ("inode", GF_LOG_ERROR, "out of memory");
goto out;
@@ -472,12 +473,13 @@ __inode_create (inode_table_t *table)
INIT_LIST_HEAD (&newi->hash);
INIT_LIST_HEAD (&newi->dentry_list);
- newi->_ctx = CALLOC (1, (sizeof (struct _inode_ctx) *
- table->xl->ctx->xl_count));
+ newi->_ctx = GF_CALLOC (1, (sizeof (struct _inode_ctx) *
+ table->xl->ctx->xl_count),
+ gf_common_mt_inode_ctx);
if (newi->_ctx == NULL) {
gf_log ("inode", GF_LOG_ERROR, "out of memory");
LOCK_DESTROY (&newi->lock);
- FREE (newi);
+ GF_FREE (newi);
newi = NULL;
goto out;
}
@@ -486,6 +488,7 @@ __inode_create (inode_table_t *table)
table->lru_size++;
out:
+
return newi;
}
@@ -936,7 +939,7 @@ inode_path (inode_t *inode, const char *name, char **bufp)
ret = i;
size = i + 1;
- buf = CALLOC (size, sizeof (char));
+ buf = GF_CALLOC (size, sizeof (char), gf_common_mt_char);
if (buf) {
buf[size - 1] = 0;
@@ -968,9 +971,9 @@ unlock:
if (inode->ino == 1 && !name) {
ret = 1;
if (buf) {
- FREE (buf);
+ GF_FREE (buf);
}
- buf = CALLOC (ret + 1, sizeof (char));
+ buf = GF_CALLOC (ret + 1, sizeof (char), gf_common_mt_char);
if (buf) {
strcpy (buf, "/");
*bufp = buf;
@@ -1049,7 +1052,7 @@ inode_table_new (size_t lru_limit, xlator_t *xl)
int ret = 0;
int i = 0;
- new = (void *)calloc (1, sizeof (*new));
+ new = (void *)GF_CALLOC(1, sizeof (*new), gf_common_mt_inode_table_t);
if (!new)
return NULL;
@@ -1059,18 +1062,20 @@ inode_table_new (size_t lru_limit, xlator_t *xl)
new->hashsize = 14057; /* TODO: Random Number?? */
- new->inode_hash = (void *)calloc (new->hashsize,
- sizeof (struct list_head));
+ new->inode_hash = (void *)GF_CALLOC (new->hashsize,
+ sizeof (struct list_head),
+ gf_common_mt_list_head);
if (!new->inode_hash) {
- FREE (new);
+ GF_FREE (new);
return NULL;
}
- new->name_hash = (void *)calloc (new->hashsize,
- sizeof (struct list_head));
+ new->name_hash = (void *)GF_CALLOC (new->hashsize,
+ sizeof (struct list_head),
+ gf_common_mt_list_head);
if (!new->name_hash) {
- FREE (new->inode_hash);
- FREE (new);
+ GF_FREE (new->inode_hash);
+ GF_FREE (new);
return NULL;
}
@@ -1088,7 +1093,7 @@ inode_table_new (size_t lru_limit, xlator_t *xl)
INIT_LIST_HEAD (&new->purge);
INIT_LIST_HEAD (&new->attic);
- ret = asprintf (&new->name, "%s/inode", xl->name);
+ ret = gf_asprintf (&new->name, "%s/inode", xl->name);
if (-1 == ret) {
/* TODO: This should be ok to continue, check with avati */
;
@@ -1114,7 +1119,7 @@ inode_from_path (inode_table_t *itable, const char *path)
char *strtokptr = NULL;
/* top-down approach */
- pathname = strdup (path);
+ pathname = gf_strdup (path);
if (pathname == NULL) {
gf_log ("inode", GF_LOG_ERROR, "out of memory");
goto out;
@@ -1153,7 +1158,7 @@ inode_from_path (inode_table_t *itable, const char *path)
inode_unref (parent);
if (pathname)
- free (pathname);
+ GF_FREE (pathname);
out:
return inode;
diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c
index 227b46fe88b..e39976945cc 100644
--- a/libglusterfs/src/iobuf.c
+++ b/libglusterfs/src/iobuf.c
@@ -41,7 +41,8 @@ __iobuf_arena_init_iobufs (struct iobuf_arena *iobuf_arena)
page_size = iobuf_arena->iobuf_pool->page_size;
iobuf_cnt = arena_size / page_size;
- iobuf_arena->iobufs = CALLOC (sizeof (*iobuf), iobuf_cnt);
+ iobuf_arena->iobufs = GF_CALLOC (sizeof (*iobuf), iobuf_cnt,
+ gf_common_mt_iobuf);
if (!iobuf_arena->iobufs)
return;
@@ -87,7 +88,7 @@ __iobuf_arena_destroy_iobufs (struct iobuf_arena *iobuf_arena)
iobuf++;
}
- FREE (iobuf_arena->iobufs);
+ GF_FREE (iobuf_arena->iobufs);
}
@@ -107,7 +108,7 @@ __iobuf_arena_destroy (struct iobuf_arena *iobuf_arena)
&& iobuf_arena->mem_base != MAP_FAILED)
munmap (iobuf_arena->mem_base, iobuf_pool->arena_size);
- FREE (iobuf_arena);
+ GF_FREE (iobuf_arena);
}
@@ -117,7 +118,8 @@ __iobuf_arena_alloc (struct iobuf_pool *iobuf_pool)
struct iobuf_arena *iobuf_arena = NULL;
size_t arena_size = 0;
- iobuf_arena = CALLOC (sizeof (*iobuf_arena), 1);
+ iobuf_arena = GF_CALLOC (sizeof (*iobuf_arena), 1,
+ gf_common_mt_iobuf_arena);
if (!iobuf_arena)
goto err;
@@ -224,7 +226,8 @@ iobuf_pool_new (size_t arena_size, size_t page_size)
if (arena_size < page_size)
return NULL;
- iobuf_pool = CALLOC (sizeof (*iobuf_pool), 1);
+ iobuf_pool = GF_CALLOC (sizeof (*iobuf_pool), 1,
+ gf_common_mt_iobuf_pool);
if (!iobuf_pool)
return NULL;
@@ -463,7 +466,8 @@ iobref_new ()
{
struct iobref *iobref = NULL;
- iobref = CALLOC (sizeof (*iobref), 1);
+ iobref = GF_CALLOC (sizeof (*iobref), 1,
+ gf_common_mt_iobref);
if (!iobref)
return NULL;
@@ -508,7 +512,7 @@ iobref_destroy (struct iobref *iobref)
iobuf_unref (iobuf);
}
- FREE (iobref);
+ GF_FREE (iobref);
}
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index a006184ccd7..a8a7d4dc933 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -84,7 +84,7 @@ gf_log_init (const char *file)
pthread_mutex_init (&logfile_mutex, NULL);
- filename = strdup (file);
+ filename = gf_strdup (file);
if (!filename) {
fprintf (stderr, "gf_log_init: strdup error\n");
return -1;
@@ -153,11 +153,11 @@ __get_dummy_xlator (glusterfs_ctx_t *ctx, const char *remote_host,
xlator_list_t * parent = NULL;
xlator_list_t * tmp = NULL;
- top = CALLOC (1, sizeof (*top));
+ top = GF_CALLOC (1, sizeof (*top), gf_common_mt_xlator_t);
if (!top)
goto out;
- trans = CALLOC (1, sizeof (*trans));
+ trans = GF_CALLOC (1, sizeof (*trans), gf_common_mt_xlator_t);
if (!trans)
goto out;
@@ -169,7 +169,8 @@ __get_dummy_xlator (glusterfs_ctx_t *ctx, const char *remote_host,
top->next = trans;
top->init = dummy_init;
top->notify = gf_log_notify;
- top->children = (void *) CALLOC (1, sizeof (*top->children));
+ top->children = (void *) GF_CALLOC (1, sizeof (*top->children),
+ gf_common_mt_xlator_list_t);
if (!top->children)
goto out;
@@ -183,7 +184,7 @@ __get_dummy_xlator (glusterfs_ctx_t *ctx, const char *remote_host,
trans->notify = default_notify;
trans->options = get_new_dict ();
- parent = CALLOC (1, sizeof(*parent));
+ parent = GF_CALLOC (1, sizeof(*parent), gf_common_mt_xlator_list_t);
if (!parent)
goto out;
@@ -219,7 +220,8 @@ __get_dummy_xlator (glusterfs_ctx_t *ctx, const char *remote_host,
ret = dict_set_static_ptr (trans->options, "non-blocking-io", "off");
if (transport) {
- char *transport_type = CALLOC (1, strlen (transport) + 10);
+ char *transport_type = GF_CALLOC (1, strlen (transport) + 10,
+ gf_common_mt_char);
ERR_ABORT (transport_type);
strcpy(transport_type, transport);
@@ -293,7 +295,7 @@ gf_log_central_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
msg = (struct _log_msg *) cookie;
- FREE (msg->msg);
+ GF_FREE ((char *)(msg->msg));
STACK_DESTROY (frame->root);
@@ -375,14 +377,14 @@ gf_log_central (const char *msg)
{
struct _log_msg *lm = NULL;
- lm = CALLOC (1, sizeof (*lm));
+ lm = GF_CALLOC (1, sizeof (*lm), gf_common_mt_log_msg);
if (!lm)
goto out;
INIT_LIST_HEAD (&lm->queue);
- lm->msg = strdup (msg);
+ lm->msg = gf_strdup (msg);
pthread_mutex_lock (&msg_queue_mutex);
{
@@ -491,10 +493,10 @@ log:
else
basename = file;
- ret = asprintf (&str1, "[%s] %s [%s:%d:%s] %s: ",
- timestr, level_strings[level],
- basename, line, function,
- domain);
+ ret = gf_asprintf (&str1, "[%s] %s [%s:%d:%s] %s: ",
+ timestr, level_strings[level],
+ basename, line, function,
+ domain);
if (-1 == ret) {
goto unlock;
}
@@ -507,7 +509,7 @@ log:
va_end (ap);
len = strlen (str1);
- msg = malloc (len + strlen (str2) + 1);
+ msg = GF_MALLOC (len + strlen (str2) + 1, gf_common_mt_char);
strcpy (msg, str1);
strcpy (msg + len, str2);
@@ -528,11 +530,11 @@ unlock:
}
glusterfs_central_log_flag_unset ();
}
- FREE (msg);
+ GF_FREE (msg);
}
if (str1)
- FREE (str1);
+ GF_FREE (str1);
if (str2)
FREE (str2);
@@ -559,12 +561,12 @@ client_log_init (struct _client_log *cl, char *identifier)
cl->identifier = identifier;
- ret = asprintf (&path, "%s.client-%s", filename, identifier);
+ ret = gf_asprintf (&path, "%s.client-%s", filename, identifier);
if (-1 == ret) {
return;
}
cl->file = fopen (path, "a");
- FREE (path);
+ GF_FREE (path);
INIT_LIST_HEAD (&cl->list);
}
@@ -576,7 +578,8 @@ __logfile_for_client (char *identifier)
struct _client_log *client = NULL;
if (!client_logs) {
- client = CALLOC (1, sizeof (*client));
+ client = GF_CALLOC (1, sizeof (*client),
+ gf_common_mt_client_log);
client_log_init (client, identifier);
client_logs = client;
@@ -588,7 +591,8 @@ __logfile_for_client (char *identifier)
}
if (!client) {
- client = CALLOC (1, sizeof (*client));
+ client = GF_CALLOC (1, sizeof (*client),
+ gf_common_mt_client_log);
client_log_init (client, identifier);
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index b0e8391f03a..f1a2c98de84 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -19,13 +19,278 @@
#include "mem-pool.h"
#include "logging.h"
+#include "xlator.h"
#include <stdlib.h>
+#include <stdarg.h>
#define GF_MEM_POOL_PAD_BOUNDARY (sizeof(struct list_head))
#define mem_pool_chunkhead2ptr(head) ((head) + GF_MEM_POOL_PAD_BOUNDARY)
#define mem_pool_ptr2chunkhead(ptr) ((ptr) - GF_MEM_POOL_PAD_BOUNDARY)
+#define GF_MEM_HEADER_SIZE (4 + sizeof (size_t) + sizeof (xlator_t *) + 4)
+#define GF_MEM_TRAILER_SIZE 4
+
+#define GF_MEM_HEADER_MAGIC 0xCAFEBABE
+#define GF_MEM_TRAILER_MAGIC 0xBAADF00D
+
+#define GLUSTERFS_ENV_MEM_ACCT_STR "GLUSTERFS_DISABLE_MEM_ACCT"
+
+static int gf_mem_acct_enable = 1;
+
+int
+gf_mem_acct_is_enabled ()
+{
+ return gf_mem_acct_enable;
+}
+
+void
+gf_mem_acct_enable_set ()
+{
+ char *opt = NULL;
+ long val = -1;
+
+ opt = getenv (GLUSTERFS_ENV_MEM_ACCT_STR);
+
+ if (!opt)
+ return;
+
+ val = strtol (opt, NULL, 0);
+
+ if (val)
+ gf_mem_acct_enable = 0;
+ else
+ gf_mem_acct_enable = 1;
+
+}
+
+void
+gf_mem_set_acct_info (xlator_t *xl, char **alloc_ptr,
+ size_t size, uint32_t type)
+{
+
+ char *ptr = NULL;
+
+ if (!alloc_ptr)
+ return;
+
+ ptr = (char *) (*alloc_ptr);
+
+ if (!xl) {
+ assert (0);
+ }
+
+ if (!(xl->mem_acct.rec)) {
+ assert (0);
+ }
+
+ if (type > xl->mem_acct.num_types) {
+ assert (0);
+ }
+
+ LOCK(&xl->mem_acct.rec[type].lock);
+ {
+ xl->mem_acct.rec[type].size += size;
+ xl->mem_acct.rec[type].num_allocs++;
+ xl->mem_acct.rec[type].max_size =
+ max (xl->mem_acct.rec[type].max_size,
+ xl->mem_acct.rec[type].size);
+ xl->mem_acct.rec[type].max_num_allocs =
+ max (xl->mem_acct.rec[type].max_num_allocs,
+ xl->mem_acct.rec[type].num_allocs);
+ }
+ UNLOCK(&xl->mem_acct.rec[type].lock);
+
+ *(uint32_t *)(ptr) = type;
+ ptr = ptr + 4;
+ memcpy (ptr, &size, sizeof(size_t));
+ ptr += sizeof (size_t);
+ memcpy (ptr, &xl, sizeof(xlator_t *));
+ ptr += sizeof (xlator_t *);
+ *(uint32_t *)(ptr) = GF_MEM_HEADER_MAGIC;
+ ptr = ptr + 4;
+ *(uint32_t *) (ptr + size) = GF_MEM_TRAILER_MAGIC;
+
+ *alloc_ptr = (void *)ptr;
+ return;
+}
+
+
+void *
+__gf_calloc (size_t nmemb, size_t size, uint32_t type)
+{
+ size_t tot_size = 0;
+ size_t req_size = 0;
+ char *ptr = NULL;
+ xlator_t *xl = NULL;
+
+ if (!gf_mem_acct_enable)
+ return CALLOC (nmemb, size);
+
+ xl = THIS;
+
+ req_size = nmemb * size;
+ tot_size = req_size + GF_MEM_HEADER_SIZE + GF_MEM_TRAILER_SIZE;
+
+ ptr = calloc (1, tot_size);
+
+ if (!ptr)
+ return NULL;
+
+ gf_mem_set_acct_info (xl, &ptr, req_size, type);
+
+ return (void *)ptr;
+}
+
+void *
+__gf_malloc (size_t size, uint32_t type)
+{
+ size_t tot_size = 0;
+ char *ptr = NULL;
+ xlator_t *xl = NULL;
+
+ if (!gf_mem_acct_enable)
+ return MALLOC (size);
+
+ xl = THIS;
+
+ tot_size = size + GF_MEM_HEADER_SIZE + GF_MEM_TRAILER_SIZE;
+
+ ptr = malloc (tot_size);
+ if (!ptr)
+ return NULL;
+
+ gf_mem_set_acct_info (xl, &ptr, size, type);
+
+ return (void *)ptr;
+}
+
+void *
+__gf_realloc (void *ptr, size_t size)
+{
+ size_t tot_size = 0;
+ char *orig_ptr = NULL;
+ xlator_t *xl = NULL;
+ uint32_t type = 0;
+
+
+ tot_size = size + GF_MEM_HEADER_SIZE + GF_MEM_TRAILER_SIZE;
+
+ orig_ptr = (char *)ptr - 4;
+
+ assert (*(uint32_t *)orig_ptr == GF_MEM_HEADER_MAGIC);
+
+ orig_ptr = orig_ptr - sizeof(xlator_t *);
+ xl = *((xlator_t **)orig_ptr);
+
+ orig_ptr = (char *)ptr - GF_MEM_HEADER_SIZE;
+ type = *(uint32_t *)orig_ptr;
+
+ ptr = realloc (orig_ptr, tot_size);
+ if (!ptr)
+ return NULL;
+
+ gf_mem_set_acct_info (xl, (char **)&ptr, size, type);
+
+ return (void *)ptr;
+}
+
+int
+gf_asprintf (char **string_ptr, const char *format, ...)
+{
+ va_list arg;
+ char *str = NULL;
+ int size = 0;
+ int rv = 0;
+
+ if (!string_ptr || !format)
+ return -1;
+
+ va_start (arg, format);
+ size = vsnprintf (NULL, 0, format, arg);
+ size++;
+ va_start (arg, format);
+ str = GF_MALLOC (size, gf_common_mt_asprintf);
+ if (str == NULL) {
+ va_end (arg);
+ /*
+ * Strictly speaking, GNU asprintf doesn't do this,
+ * but the caller isn't checking the return value.
+ */
+ gf_log ("libglusterfs", GF_LOG_CRITICAL,
+ "failed to allocate memory");
+ return -1;
+ }
+ rv = vsnprintf( str, size, format, arg);
+ va_end (arg);
+
+ *string_ptr = str;
+ return (rv);
+}
+
+void
+__gf_free (void *free_ptr)
+{
+ size_t req_size = 0;
+ char *ptr = NULL;
+ uint32_t type = 0;
+ xlator_t *xl = NULL;
+
+ if (!gf_mem_acct_enable) {
+ FREE (free_ptr);
+ return;
+ }
+
+ if (!free_ptr)
+ return;
+
+
+ ptr = (char *)free_ptr - 4;
+
+ if (GF_MEM_HEADER_MAGIC != *(uint32_t *)ptr) {
+ //Possible corruption, assert here
+ assert (0);
+ }
+
+ *(uint32_t *)ptr = 0;
+
+ ptr = ptr - sizeof(xlator_t *);
+ memcpy (&xl, ptr, sizeof(xlator_t *));
+
+ if (!xl) {
+ //gf_free expects xl to be available
+ assert (0);
+ }
+
+ if (!xl->mem_acct.rec) {
+ ptr = (char *)free_ptr - GF_MEM_HEADER_SIZE;
+ goto free;
+ }
+
+
+ ptr = ptr - sizeof(size_t);
+ memcpy (&req_size, ptr, sizeof (size_t));
+ ptr = ptr - 4;
+ type = *(uint32_t *)ptr;
+
+ if (GF_MEM_TRAILER_MAGIC != *(uint32_t *)
+ ((char *)free_ptr + req_size)) {
+ // This points to a memory overrun
+ assert (0);
+ }
+ *(uint32_t *) ((char *)free_ptr + req_size) = 0;
+
+ LOCK (&xl->mem_acct.rec[type].lock);
+ {
+ xl->mem_acct.rec[type].size -= req_size;
+ xl->mem_acct.rec[type].num_allocs--;
+ }
+ UNLOCK (&xl->mem_acct.rec[type].lock);
+free:
+ FREE (ptr);
+}
+
+
struct mem_pool *
mem_pool_new_fn (unsigned long sizeof_type,
@@ -36,14 +301,14 @@ mem_pool_new_fn (unsigned long sizeof_type,
void *pool = NULL;
int i = 0;
struct list_head *list = NULL;
-
+
if (!sizeof_type || !count) {
gf_log ("mem-pool", GF_LOG_ERROR, "invalid argument");
return NULL;
}
padded_sizeof_type = sizeof_type + GF_MEM_POOL_PAD_BOUNDARY;
-
- mem_pool = CALLOC (sizeof (*mem_pool), 1);
+
+ mem_pool = GF_CALLOC (sizeof (*mem_pool), 1, gf_common_mt_mem_pool);
if (!mem_pool)
return NULL;
@@ -54,9 +319,9 @@ mem_pool_new_fn (unsigned long sizeof_type,
mem_pool->cold_count = count;
mem_pool->real_sizeof_type = sizeof_type;
- pool = CALLOC (count, padded_sizeof_type);
+ pool = GF_CALLOC (count, padded_sizeof_type, gf_common_mt_long);
if (!pool) {
- FREE (mem_pool);
+ GF_FREE (mem_pool);
return NULL;
}
@@ -78,7 +343,7 @@ mem_get (struct mem_pool *mem_pool)
{
struct list_head *list = NULL;
void *ptr = NULL;
-
+
if (!mem_pool) {
gf_log ("mem-pool", GF_LOG_ERROR, "invalid argument");
return NULL;
@@ -141,7 +406,7 @@ __is_member (struct mem_pool *pool, void *ptr)
gf_log ("mem-pool", GF_LOG_ERROR, "invalid argument");
return -1;
}
-
+
if (ptr < pool->pool || ptr >= pool->pool_end)
return 0;
@@ -157,12 +422,12 @@ void
mem_put (struct mem_pool *pool, void *ptr)
{
struct list_head *list = NULL;
-
+
if (!pool || !ptr) {
gf_log ("mem-pool", GF_LOG_ERROR, "invalid argument");
return;
}
-
+
LOCK (&pool->lock);
{
@@ -210,8 +475,8 @@ mem_pool_destroy (struct mem_pool *pool)
return;
LOCK_DESTROY (&pool->lock);
- FREE (pool->pool);
- FREE (pool);
+ GF_FREE (pool->pool);
+ GF_FREE (pool);
return;
}
diff --git a/libglusterfs/src/mem-pool.h b/libglusterfs/src/mem-pool.h
index 9b8efbb9573..2a064643c7a 100644
--- a/libglusterfs/src/mem-pool.h
+++ b/libglusterfs/src/mem-pool.h
@@ -22,7 +22,10 @@
#include "list.h"
#include "locking.h"
+#include "mem-types.h"
#include <stdlib.h>
+#include <inttypes.h>
+#include <string.h>
#define MALLOC(size) malloc(size)
@@ -34,6 +37,65 @@
ptr = (void *)0xeeeeeeee; \
}
+struct mem_acct {
+ uint32_t num_types;
+ struct mem_acct_rec *rec;
+};
+
+struct mem_acct_rec {
+ size_t size;
+ size_t max_size;
+ uint32_t num_allocs;
+ uint32_t max_num_allocs;
+ gf_lock_t lock;
+};
+
+
+void *
+__gf_calloc (size_t cnt, size_t size, uint32_t type);
+
+void *
+__gf_malloc (size_t size, uint32_t type);
+
+void *
+__gf_realloc (void *ptr, size_t size);
+
+int
+gf_asprintf (char **string_ptr, const char *format, ...);
+
+#define GF_CALLOC(nmemb, size, type) __gf_calloc (nmemb, size, type)
+
+#define GF_MALLOC(size, type) __gf_malloc (size, type)
+
+#define GF_REALLOC(ptr, size) __gf_realloc (ptr, size)
+
+void
+__gf_free (void *ptr);
+
+
+#define GF_FREE(free_ptr) __gf_free (free_ptr);
+
+static inline
+char * gf_strdup (const char *src)
+{
+
+ char *dup_str = NULL;
+ size_t len = 0;
+
+ len = strlen (src) + 1;
+
+ dup_str = GF_CALLOC(1, len, gf_common_mt_strdup);
+
+ if (!dup_str)
+ return NULL;
+
+ memcpy (dup_str, src, len);
+
+ return dup_str;
+}
+
+
+
struct mem_pool {
struct list_head list;
int hot_count;
@@ -55,4 +117,7 @@ void *mem_get (struct mem_pool *pool);
void mem_pool_destroy (struct mem_pool *pool);
+int gf_mem_acct_is_enabled ();
+void gf_mem_acct_enable_set ();
+
#endif /* _MEM_POOL_H */
diff --git a/libglusterfs/src/mem-types.h b/libglusterfs/src/mem-types.h
new file mode 100644
index 00000000000..daf680eb2a7
--- /dev/null
+++ b/libglusterfs/src/mem-types.h
@@ -0,0 +1,82 @@
+/*
+ Copyright (c) 2006-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 __MEM_TYPES_H__
+#define __MEM_TYPES_H__
+
+
+enum gf_common_mem_types_ {
+ gf_common_mt_call_stub_t = 0,
+ gf_common_mt_dnscache6,
+ gf_common_mt_data_pair_t,
+ gf_common_mt_data_t,
+ gf_common_mt_dict_t,
+ gf_common_mt_event_pool,
+ gf_common_mt_reg,
+ gf_common_mt_pollfd,
+ gf_common_mt_epoll_event,
+ gf_common_mt_fdentry_t,
+ gf_common_mt_fdtable_t,
+ gf_common_mt_fd_t,
+ gf_common_mt_fd_ctx,
+ gf_common_mt_gf_dirent_t,
+ gf_common_mt_glusterfs_ctx_t,
+ gf_common_mt_dentry_t,
+ gf_common_mt_inode_t,
+ gf_common_mt_inode_ctx,
+ gf_common_mt_list_head,
+ gf_common_mt_inode_table_t,
+ gf_common_mt_xlator_t,
+ gf_common_mt_xlator_list_t,
+ gf_common_mt_log_msg,
+ gf_common_mt_client_log,
+ gf_common_mt_volume_opt_list_t,
+ gf_common_mt_gf_hdr_common_t,
+ gf_common_mt_call_frame_t,
+ gf_common_mt_call_stack_t,
+ gf_common_mt_gf_timer_t,
+ gf_common_mt_gf_timer_registry_t,
+ gf_common_mt_transport,
+ gf_common_mt_transport_msg,
+ gf_common_mt_auth_handle_t,
+ gf_common_mt_iobuf,
+ gf_common_mt_iobuf_arena,
+ gf_common_mt_iobref,
+ gf_common_mt_iobuf_pool,
+ gf_common_mt_iovec,
+ gf_common_mt_memdup,
+ gf_common_mt_asprintf,
+ gf_common_mt_strdup,
+ gf_common_mt_socket_private_t,
+ gf_common_mt_ioq,
+ gf_common_mt_transport_t,
+ gf_common_mt_socket_local_t,
+ gf_common_mt_char,
+ gf_common_mt_rbthash_table_t,
+ gf_common_mt_rbthash_bucket,
+ gf_common_mt_mem_pool,
+ gf_common_mt_long,
+ gf_common_mt_rpcsvc_auth_list,
+ gf_common_mt_rpcsvc_t,
+ gf_common_mt_rpcsvc_conn_t,
+ gf_common_mt_rpcsvc_program_t,
+ gf_common_mt_rpcsvc_stage_t,
+ gf_common_mt_end
+};
+#endif
diff --git a/libglusterfs/src/protocol.h b/libglusterfs/src/protocol.h
index 592d0a4f440..6e8a130674f 100644
--- a/libglusterfs/src/protocol.h
+++ b/libglusterfs/src/protocol.h
@@ -999,7 +999,8 @@ __gf_hdr_new (int size)
gf_hdr_common_t *hdr = NULL;
/* TODO: use mem-pool */
- hdr = CALLOC (sizeof (gf_hdr_common_t) + size, 1);
+ hdr = GF_CALLOC (sizeof (gf_hdr_common_t) + size, 1,
+ gf_common_mt_gf_hdr_common_t);
if (!hdr) {
return NULL;
diff --git a/libglusterfs/src/rbthash.c b/libglusterfs/src/rbthash.c
index 33e80224a87..b5e684def18 100644
--- a/libglusterfs/src/rbthash.c
+++ b/libglusterfs/src/rbthash.c
@@ -116,11 +116,13 @@ rbthash_table_init (int buckets, rbt_hasher_t hfunc,
}
- newtab = CALLOC (1, sizeof (*newtab));
+ newtab = GF_CALLOC (1, sizeof (*newtab),
+ gf_common_mt_rbthash_table_t);
if (!newtab)
return NULL;
- newtab->buckets = CALLOC (buckets, sizeof (struct rbthash_bucket));
+ newtab->buckets = GF_CALLOC (buckets, sizeof (struct rbthash_bucket),
+ gf_common_mt_rbthash_bucket);
if (!newtab->buckets) {
gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to allocate memory");
goto free_newtab;
@@ -157,11 +159,11 @@ rbthash_table_init (int buckets, rbt_hasher_t hfunc,
free_buckets:
if (ret == -1)
- FREE (newtab->buckets);
+ GF_FREE (newtab->buckets);
free_newtab:
if (ret == -1) {
- FREE (newtab);
+ GF_FREE (newtab);
newtab = NULL;
}
@@ -185,7 +187,7 @@ rbthash_init_entry (rbthash_table_t *tbl, void *data, void *key, int keylen)
}
entry->data = data;
- entry->key = CALLOC (keylen, sizeof (char));
+ entry->key = GF_CALLOC (keylen, sizeof (char), gf_common_mt_char);
if (!entry->key) {
gf_log (GF_RBTHASH, GF_LOG_ERROR, "Memory allocation failed");
goto free_entry;
@@ -216,7 +218,7 @@ rbthash_deinit_entry (rbthash_table_t *tbl, rbthash_entry_t *entry)
return;
if (entry->key)
- FREE (entry->key);
+ GF_FREE (entry->key);
if (tbl) {
if ((entry->data) && (tbl->dfunc))
@@ -374,7 +376,7 @@ rbthash_remove (rbthash_table_t *tbl, void *key, int keylen)
if (!entry)
return NULL;
- FREE (entry->key);
+ GF_FREE (entry->key);
dataref = entry->data;
mem_put (tbl->entrypool, entry);
@@ -418,7 +420,7 @@ rbthash_table_destroy (rbthash_table_t *tbl)
if (tbl->pool_alloced)
mem_pool_destroy (tbl->entrypool);
- FREE (tbl->buckets);
- FREE (tbl);
+ GF_FREE (tbl->buckets);
+ GF_FREE (tbl);
}
diff --git a/libglusterfs/src/scheduler.c b/libglusterfs/src/scheduler.c
index 459c7d86872..94131676e17 100644
--- a/libglusterfs/src/scheduler.c
+++ b/libglusterfs/src/scheduler.c
@@ -43,7 +43,7 @@ get_scheduler (xlator_t *xl, const char *name)
return NULL;
}
- ret = asprintf (&sched_file, "%s/%s.so", SCHEDULERDIR, name);
+ ret = gf_asprintf (&sched_file, "%s/%s.so", SCHEDULERDIR, name);
if (-1 == ret) {
gf_log ("scheduler", GF_LOG_ERROR, "asprintf failed");
return NULL;
@@ -66,7 +66,8 @@ get_scheduler (xlator_t *xl, const char *name)
return NULL;
}
- vol_opt = CALLOC (1, sizeof (volume_opt_list_t));
+ vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t),
+ gf_common_mt_volume_opt_list_t);
vol_opt->given_opt = dlsym (handle, "options");
if (vol_opt->given_opt == NULL) {
gf_log ("scheduler", GF_LOG_DEBUG,
@@ -80,6 +81,7 @@ get_scheduler (xlator_t *xl, const char *name)
return NULL;
}
}
+ GF_FREE(sched_file);
return tmp_sched;
}
diff --git a/libglusterfs/src/scheduler.h b/libglusterfs/src/scheduler.h
index 814df909016..3e4acaaddcc 100644
--- a/libglusterfs/src/scheduler.h
+++ b/libglusterfs/src/scheduler.h
@@ -33,6 +33,7 @@ struct sched_ops {
void (*update) (xlator_t *this);
xlator_t *(*schedule) (xlator_t *this, const void *path);
void (*notify) (xlator_t *xl, int32_t event, void *data);
+ int32_t (*mem_acct_init) (xlator_t *this);
};
extern struct sched_ops *get_scheduler (xlator_t *xl, const char *name);
diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h
index 25925f7a699..645f633f5d0 100644
--- a/libglusterfs/src/stack.h
+++ b/libglusterfs/src/stack.h
@@ -137,9 +137,9 @@ FRAME_DESTROY (call_frame_t *frame)
if (frame->prev)
frame->prev->next = frame->next;
if (frame->local)
- FREE (frame->local);
+ GF_FREE (frame->local);
LOCK_DESTROY (&frame->lock);
- FREE (frame);
+ GF_FREE (frame);
}
@@ -161,7 +161,7 @@ STACK_DESTROY (call_stack_t *stack)
UNLOCK (&stack->pool->lock);
if (stack->frames.local)
- FREE (stack->frames.local);
+ GF_FREE (stack->frames.local);
LOCK_DESTROY (&stack->frames.lock);
@@ -172,7 +172,7 @@ STACK_DESTROY (call_stack_t *stack)
FRAME_DESTROY (stack->frames.next);
}
- FREE (stack);
+ GF_FREE (stack);
}
@@ -185,7 +185,8 @@ STACK_DESTROY (call_stack_t *stack)
call_frame_t *_new = NULL; \
xlator_t *old_THIS = NULL; \
\
- _new = CALLOC (1, sizeof (call_frame_t)); \
+ _new = GF_CALLOC (1, sizeof (call_frame_t), \
+ gf_common_mt_call_frame_t); \
ERR_ABORT (_new); \
typeof(fn##_cbk) tmp_cbk = rfn; \
_new->root = frame->root; \
@@ -219,7 +220,8 @@ STACK_DESTROY (call_stack_t *stack)
call_frame_t *_new = NULL; \
xlator_t *old_THIS = NULL; \
\
- _new = CALLOC (1, sizeof (call_frame_t)); \
+ _new = GF_CALLOC (1, sizeof (call_frame_t), \
+ gf_common_mt_call_frame_t); \
ERR_ABORT (_new); \
typeof(fn##_cbk) tmp_cbk = rfn; \
_new->root = frame->root; \
@@ -304,7 +306,8 @@ copy_frame (call_frame_t *frame)
return NULL;
}
- newstack = (void *) CALLOC (1, sizeof (*newstack));
+ newstack = (void *) GF_CALLOC (1, sizeof (*newstack),
+ gf_common_mt_call_stack_t);
if (newstack == NULL) {
return NULL;
}
@@ -347,7 +350,7 @@ create_frame (xlator_t *xl, call_pool_t *pool)
return NULL;
}
- stack = CALLOC (1, sizeof (*stack));
+ stack = GF_CALLOC (1, sizeof (*stack),gf_common_mt_call_stack_t);
if (!stack)
return NULL;
diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c
index 4e42280068f..678ed6c8ecd 100644
--- a/libglusterfs/src/statedump.c
+++ b/libglusterfs/src/statedump.c
@@ -28,6 +28,8 @@
#include <malloc.h>
#endif /* MALLOC_H */
+extern xlator_t global_xlator;
+
static pthread_mutex_t gf_proc_dump_mutex;
static int gf_dump_fd = -1;
@@ -115,6 +117,46 @@ gf_proc_dump_write (char *key, char *value,...)
ret = write(gf_dump_fd, buf, strlen(buf));
}
+static void
+gf_proc_dump_xlator_mem_info (xlator_t *xl)
+{
+ char key[GF_DUMP_MAX_BUF_LEN];
+ char prefix[GF_DUMP_MAX_BUF_LEN];
+ int i = 0;
+ struct mem_acct rec = {0,};
+
+ if (!xl)
+ return;
+
+ if (!xl->mem_acct.rec)
+ return;
+
+ gf_proc_dump_add_section("%s.%s - Memory usage", xl->type,xl->name);
+ gf_proc_dump_write("num_types", "%d", xl->mem_acct.num_types);
+
+ for (i = 0; i < xl->mem_acct.num_types; i++) {
+ if (!(memcmp (&xl->mem_acct.rec[i], &rec,
+ sizeof(struct mem_acct))))
+ continue;
+
+ gf_proc_dump_add_section("%s.%s - usage-type %d", xl->type,
+ xl->name,i);
+ gf_proc_dump_build_key(prefix, "memusage", "%s.%s.type.%d",
+ xl->type, xl->name, i);
+ gf_proc_dump_build_key(key, prefix, "size");
+ gf_proc_dump_write(key, "%u", xl->mem_acct.rec[i].size);
+ gf_proc_dump_build_key(key, prefix, "num_allocs");
+ gf_proc_dump_write(key, "%u", xl->mem_acct.rec[i].num_allocs);
+ gf_proc_dump_build_key(key, prefix, "max_size");
+ gf_proc_dump_write(key, "%u", xl->mem_acct.rec[i].max_size);
+ gf_proc_dump_build_key(key, prefix, "max_num_allocs");
+ gf_proc_dump_write(key, "%u", xl->mem_acct.rec[i].max_num_allocs);
+ }
+
+ return;
+}
+
+
/* Currently this dumps only mallinfo. More can be built on here */
void
@@ -138,6 +180,7 @@ gf_proc_dump_mem_info ()
gf_proc_dump_write("mallinfo_fordblks", "%d", info.fordblks);
gf_proc_dump_write("mallinfo_keepcost", "%d", info.keepcost);
#endif
+ gf_proc_dump_xlator_mem_info(&global_xlator);
}
@@ -151,7 +194,9 @@ gf_proc_dump_xlator_info (xlator_t *this_xl)
return;
while (this_xl) {
+
gf_proc_dump_latency_info (this_xl);
+ gf_proc_dump_xlator_mem_info(this_xl);
if (!this_xl->dumpops) {
this_xl = this_xl->next;
diff --git a/libglusterfs/src/timer.c b/libglusterfs/src/timer.c
index 6188ccacbac..7ff18f94e35 100644
--- a/libglusterfs/src/timer.c
+++ b/libglusterfs/src/timer.c
@@ -25,13 +25,14 @@
#include "timer.h"
#include "logging.h"
#include "common-utils.h"
+#include "globals.h"
#define TS(tv) ((((unsigned long long) tv.tv_sec) * 1000000) + (tv.tv_usec))
gf_timer_t *
gf_timer_call_after (glusterfs_ctx_t *ctx,
struct timeval delta,
- gf_timer_cbk_t cbk,
+ gf_timer_cbk_t callbk,
void *data)
{
gf_timer_registry_t *reg = NULL;
@@ -52,7 +53,7 @@ gf_timer_call_after (glusterfs_ctx_t *ctx,
return NULL;
}
- event = CALLOC (1, sizeof (*event));
+ event = GF_CALLOC (1, sizeof (*event), gf_common_mt_gf_timer_t);
if (!event) {
gf_log ("timer", GF_LOG_CRITICAL, "Not enough memory");
return NULL;
@@ -62,8 +63,9 @@ gf_timer_call_after (glusterfs_ctx_t *ctx,
event->at.tv_sec += ((event->at.tv_usec + delta.tv_usec) / 1000000);
event->at.tv_sec += delta.tv_sec;
at = TS (event->at);
- event->cbk = cbk;
+ event->callbk = callbk;
event->data = data;
+ event->xl = THIS;
pthread_mutex_lock (&reg->lock);
{
trav = reg->active.prev;
@@ -126,7 +128,7 @@ gf_timer_call_cancel (glusterfs_ctx_t *ctx,
}
pthread_mutex_unlock (&reg->lock);
- FREE (event);
+ GF_FREE (event);
return 0;
}
@@ -168,8 +170,10 @@ gf_timer_proc (void *ctx)
}
}
pthread_mutex_unlock (&reg->lock);
+ if (event->xl)
+ THIS = event->xl;
if (need_cbk)
- event->cbk (event->data);
+ event->callbk (event->data);
else
break;
@@ -189,7 +193,7 @@ gf_timer_proc (void *ctx)
}
pthread_mutex_unlock (&reg->lock);
pthread_mutex_destroy (&reg->lock);
- FREE (((glusterfs_ctx_t *)ctx)->timer);
+ GF_FREE (((glusterfs_ctx_t *)ctx)->timer);
return NULL;
}
@@ -206,7 +210,8 @@ gf_timer_registry_init (glusterfs_ctx_t *ctx)
if (!ctx->timer) {
gf_timer_registry_t *reg = NULL;
- ctx->timer = reg = CALLOC (1, sizeof (*reg));
+ ctx->timer = reg = GF_CALLOC (1, sizeof (*reg),
+ gf_common_mt_gf_timer_registry_t);
ERR_ABORT (reg);
pthread_mutex_init (&reg->lock, NULL);
reg->active.next = &reg->active;
diff --git a/libglusterfs/src/timer.h b/libglusterfs/src/timer.h
index 98440dc61f3..e5fa5e2c679 100644
--- a/libglusterfs/src/timer.h
+++ b/libglusterfs/src/timer.h
@@ -26,6 +26,7 @@
#endif
#include "glusterfs.h"
+#include "xlator.h"
#include <sys/time.h>
#include <pthread.h>
@@ -34,8 +35,9 @@ typedef void (*gf_timer_cbk_t) (void *);
struct _gf_timer {
struct _gf_timer *next, *prev;
struct timeval at;
- gf_timer_cbk_t cbk;
+ gf_timer_cbk_t callbk;
void *data;
+ xlator_t *xl;
};
struct _gf_timer_registry {
diff --git a/libglusterfs/src/transport.c b/libglusterfs/src/transport.c
index aee809117b6..d460d02096e 100644
--- a/libglusterfs/src/transport.c
+++ b/libglusterfs/src/transport.c
@@ -52,7 +52,8 @@ transport_load (dict_t *options,
GF_VALIDATE_OR_GOTO("transport", options, fail);
GF_VALIDATE_OR_GOTO("transport", xl, fail);
- trans = CALLOC (1, sizeof (struct transport));
+ trans = GF_CALLOC (1, sizeof (struct transport),
+ gf_common_mt_transport);
GF_VALIDATE_OR_GOTO("transport", trans, fail);
trans->xl = xl;
@@ -107,14 +108,14 @@ transport_load (dict_t *options,
ret = dict_get_str (options, "transport-type", &type);
if (ret < 0) {
- FREE (trans);
+ GF_FREE (trans);
gf_log ("transport", GF_LOG_ERROR,
"'option transport-type <xx>' missing in volume '%s'",
xl->name);
goto fail;
}
- ret = asprintf (&name, "%s/%s.so", TRANSPORTDIR, type);
+ ret = gf_asprintf (&name, "%s/%s.so", TRANSPORTDIR, type);
if (-1 == ret) {
gf_log ("transport", GF_LOG_ERROR, "asprintf failed");
goto fail;
@@ -129,17 +130,17 @@ transport_load (dict_t *options,
"volume '%s': transport-type '%s' is not valid or "
"not found on this machine",
xl->name, type);
- FREE (name);
- FREE (trans);
+ GF_FREE (name);
+ GF_FREE (trans);
goto fail;
}
- FREE (name);
+ GF_FREE (name);
trans->ops = dlsym (handle, "tops");
if (trans->ops == NULL) {
gf_log ("transport", GF_LOG_ERROR,
"dlsym (transport_ops) on %s", dlerror ());
- FREE (trans);
+ GF_FREE (trans);
goto fail;
}
@@ -147,7 +148,7 @@ transport_load (dict_t *options,
if (trans->init == NULL) {
gf_log ("transport", GF_LOG_ERROR,
"dlsym (gf_transport_init) on %s", dlerror ());
- FREE (trans);
+ GF_FREE (trans);
goto fail;
}
@@ -155,11 +156,12 @@ transport_load (dict_t *options,
if (trans->fini == NULL) {
gf_log ("transport", GF_LOG_ERROR,
"dlsym (gf_transport_fini) on %s", dlerror ());
- FREE (trans);
+ GF_FREE (trans);
goto fail;
}
- vol_opt = CALLOC (1, sizeof (volume_opt_list_t));
+ vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t),
+ gf_common_mt_volume_opt_list_t);
vol_opt->given_opt = dlsym (handle, "options");
if (vol_opt->given_opt == NULL) {
gf_log ("transport", GF_LOG_DEBUG,
@@ -171,7 +173,7 @@ transport_load (dict_t *options,
vol_opt->given_opt)) {
gf_log ("transport", GF_LOG_ERROR,
"volume option validation failed");
- FREE (trans);
+ GF_FREE (trans);
goto fail;
}
}
@@ -180,7 +182,7 @@ transport_load (dict_t *options,
if (ret != 0) {
gf_log ("transport", GF_LOG_ERROR,
"'%s' initialization failed", type);
- FREE (trans);
+ GF_FREE (trans);
goto fail;
}
@@ -204,7 +206,8 @@ transport_submit (transport_t *this, char *buf, int32_t len,
if (this->peer_trans) {
peer_trans = this->peer_trans;
- msg = CALLOC (1, sizeof (*msg));
+ msg = GF_CALLOC (1, sizeof (*msg),
+ gf_common_mt_transport_msg);
if (!msg) {
return -ENOMEM;
}
@@ -215,8 +218,8 @@ transport_submit (transport_t *this, char *buf, int32_t len,
if (vector) {
iobuf = iobuf_get (this->xl->ctx->iobuf_pool);
if (!iobuf) {
- FREE (msg->hdr);
- FREE (msg);
+ GF_FREE (msg->hdr);
+ GF_FREE (msg);
return -ENOMEM;
}
@@ -293,7 +296,7 @@ transport_destroy (transport_t *this)
this->fini (this);
pthread_mutex_destroy (&this->lock);
- FREE (this);
+ GF_FREE (this);
fail:
return ret;
}
@@ -391,7 +394,7 @@ transport_peerproc (void *trans_data)
xlator_notify (trans->xl, GF_EVENT_POLLIN, trans);
- FREE (msg);
+ GF_FREE (msg);
}
}
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index ffa1d94e431..6d27a01405d 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -106,6 +106,9 @@ fill_defaults (xlator_t *xl)
if (!xl->notify)
xl->notify = default_notify;
+ if (!xl->mem_acct_init)
+ xl->mem_acct_init = default_mem_acct_init;
+
return;
}
@@ -146,7 +149,8 @@ valid_ipv4_address (char *address, int length)
char *tmp = NULL, *ptr = NULL, *prev = NULL, *endptr = NULL;
char ret = 1;
- prev = tmp = strdup (address);
+ tmp = gf_strdup (address);
+ prev = tmp;
prev = strtok_r (tmp, ".", &ptr);
while (prev != NULL)
@@ -166,7 +170,7 @@ valid_ipv4_address (char *address, int length)
}
out:
- FREE (tmp);
+ GF_FREE (tmp);
return ret;
}
@@ -178,7 +182,7 @@ valid_ipv6_address (char *address, int length)
char *tmp = NULL, *ptr = NULL, *prev = NULL, *endptr = NULL;
char ret = 1;
- tmp = strdup (address);
+ tmp = gf_strdup (address);
prev = strtok_r (tmp, ":", &ptr);
while (prev != NULL)
@@ -199,7 +203,7 @@ valid_ipv6_address (char *address, int length)
}
out:
- FREE (tmp);
+ GF_FREE (tmp);
return ret;
}
@@ -650,7 +654,7 @@ validate_xlator_volume_options (xlator_t *xl, volume_option_t *opt)
" with correction",
trav->key[i], trav->key[0]);
/* TODO: some bytes lost */
- pairs->key = strdup (trav->key[0]);
+ pairs->key = gf_strdup (trav->key[0]);
}
break;
}
@@ -684,9 +688,9 @@ xlator_set_type (xlator_t *xl,
return -1;
}
- xl->type = strdup (type);
+ xl->type = gf_strdup (type);
- ret = asprintf (&name, "%s/%s.so", XLATORDIR, type);
+ ret = gf_asprintf (&name, "%s/%s.so", XLATORDIR, type);
if (-1 == ret) {
gf_log ("xlator", GF_LOG_ERROR, "asprintf failed");
return -1;
@@ -740,9 +744,16 @@ xlator_set_type (xlator_t *xl,
"dlsym(dumpops) on %s -- neglecting", dlerror ());
}
+ if (!(xl->mem_acct_init = dlsym (handle, "mem_acct_init"))) {
+ gf_log (xl->name, GF_LOG_DEBUG,
+ "dlsym(mem_acct_init) on %s -- neglecting",
+ dlerror ());
+ }
+
INIT_LIST_HEAD (&xl->volume_options);
- vol_opt = CALLOC (1, sizeof (volume_opt_list_t));
+ vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t),
+ gf_common_mt_volume_opt_list_t);
if (!(vol_opt->given_opt = dlsym (handle, "options"))) {
dlerror ();
@@ -753,7 +764,7 @@ xlator_set_type (xlator_t *xl,
fill_defaults (xl);
- FREE (name);
+ GF_FREE (name);
return 0;
}
@@ -825,6 +836,8 @@ xlator_init_rec (xlator_t *xl)
while (trav) {
ret = -1;
+ if (trav->mem_acct_init)
+ trav->mem_acct_init (trav);
if (trav->init && !trav->ready) {
ret = xlator_init (trav);
if (ret) {
@@ -940,6 +953,39 @@ xlator_init (xlator_t *xl)
return ret;
}
+int
+xlator_mem_acct_init (xlator_t *xl, int num_types)
+{
+ int i = 0;
+ int ret = 0;
+
+ if (!gf_mem_acct_is_enabled())
+ return 0;
+
+ if (!xl)
+ return -1;
+
+ xl->mem_acct.num_types = num_types;
+
+ xl->mem_acct.rec = calloc(num_types, sizeof(struct mem_acct_rec));
+
+ if (!xl->mem_acct.rec) {
+ gf_log("xlator", GF_LOG_ERROR, "Out of Memory");
+ return -1;
+ }
+
+ gf_log(xl->name, GF_LOG_DEBUG, "Allocated mem_acct_rec for %d types",
+ num_types);
+
+ for (i = 0; i < num_types; i++) {
+ ret = LOCK_INIT(&(xl->mem_acct.rec[i].lock));
+ if (ret) {
+ fprintf(stderr, "Unable to lock..errno : %d",errno);
+ }
+ }
+
+ return 0;
+}
void
xlator_tree_fini (xlator_t *xl)
@@ -969,9 +1015,9 @@ xlator_tree_free (xlator_t *tree)
while (prev) {
trav = prev->next;
dict_destroy (prev->options);
- FREE (prev->name);
- FREE (prev->type);
- FREE (prev);
+ GF_FREE (prev->name);
+ GF_FREE (prev->type);
+ GF_FREE (prev);
prev = trav;
}
@@ -987,7 +1033,7 @@ loc_wipe (loc_t *loc)
loc->inode = NULL;
}
if (loc->path) {
- FREE (loc->path);
+ GF_FREE ((char *)loc->path);
loc->path = NULL;
}
@@ -1011,7 +1057,7 @@ loc_copy (loc_t *dst, loc_t *src)
if (src->parent)
dst->parent = inode_ref (src->parent);
- dst->path = strdup (src->path);
+ dst->path = gf_strdup (src->path);
if (!dst->path)
goto out;
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h
index 993679b2500..3bee959f890 100644
--- a/libglusterfs/src/xlator.h
+++ b/libglusterfs/src/xlator.h
@@ -846,6 +846,7 @@ struct _xlator {
void (*fini) (xlator_t *this);
int32_t (*init) (xlator_t *this);
+ int32_t (*mem_acct_init) (xlator_t *this);
event_notify_fn_t notify;
/* for latency measurement */
@@ -857,6 +858,7 @@ struct _xlator {
char ready;
char init_succeeded;
void *private;
+ struct mem_acct mem_acct;
};
#define xlator_has_parent(xl) (xl->parents != NULL)
@@ -888,6 +890,7 @@ void inode_destroy_notify (inode_t *inode, const char *xlname);
int loc_copy (loc_t *dst, loc_t *src);
#define loc_dup(src, dst) loc_copy(dst, src)
void loc_wipe (loc_t *loc);
+int xlator_mem_acct_init (xlator_t *xl, int num_types);
#define GF_STAT_PRINT_FMT_STR "%"PRIx64",%"PRIx64",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx64",%"PRIx64",%"PRIx32",%"PRIx64",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32"\n"
diff --git a/scheduler/alu/src/alu-mem-types.h b/scheduler/alu/src/alu-mem-types.h
new file mode 100644
index 00000000000..39da342ec6c
--- /dev/null
+++ b/scheduler/alu/src/alu-mem-types.h
@@ -0,0 +1,35 @@
+/*
+ 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 __ALU_MEM_TYPES_H__
+#define __ALU_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_alu_mem_types_ {
+ gf_alu_mt_alu_threshold = gf_common_mt_end + 1,
+ gf_alu_mt_alu_sched,
+ gf_alu_mt_alu_limits,
+ gf_alu_mt_alu_sched_struct,
+ gf_alu_mt_alu_sched_node,
+ gf_alu_mt_end
+};
+#endif
+
diff --git a/scheduler/alu/src/alu.c b/scheduler/alu/src/alu.c
index 8a328dea0b9..f2a0a08f481 100644
--- a/scheduler/alu/src/alu.c
+++ b/scheduler/alu/src/alu.c
@@ -32,6 +32,7 @@
#include <stdint.h>
#include "stack.h"
#include "alu.h"
+#include "alu-mem-types.h"
#define ALU_DISK_USAGE_ENTRY_THRESHOLD_DEFAULT (1 * GF_UNIT_GB)
#define ALU_DISK_USAGE_EXIT_THRESHOLD_DEFAULT (512 * GF_UNIT_MB)
@@ -146,7 +147,9 @@ alu_parse_options (xlator_t *xl, struct alu_sched *alu_sched)
if (strcmp (order_str, "disk-usage") == 0) {
/* Disk usage */
_threshold_fn =
- CALLOC (1, sizeof (struct alu_threshold));
+ GF_CALLOC (1,
+ sizeof (struct alu_threshold),
+ gf_alu_mt_alu_threshold);
ERR_ABORT (_threshold_fn);
_threshold_fn->diff_value = get_max_diff_disk_usage;
_threshold_fn->sched_value = get_stats_disk_usage;
@@ -199,7 +202,7 @@ alu_parse_options (xlator_t *xl, struct alu_sched *alu_sched)
} else if (strcmp (order_str, "write-usage") == 0) {
/* Handle "write-usage" */
- _threshold_fn = CALLOC (1, sizeof (struct alu_threshold));
+ _threshold_fn = GF_CALLOC (1, sizeof (struct alu_threshold), gf_alu_mt_alu_threshold);
ERR_ABORT (_threshold_fn);
_threshold_fn->diff_value = get_max_diff_write_usage;
_threshold_fn->sched_value = get_stats_write_usage;
@@ -252,7 +255,7 @@ alu_parse_options (xlator_t *xl, struct alu_sched *alu_sched)
} else if (strcmp (order_str, "read-usage") == 0) {
/* Read usage */
- _threshold_fn = CALLOC (1, sizeof (struct alu_threshold));
+ _threshold_fn = GF_CALLOC (1, sizeof (struct alu_threshold), gf_alu_mt_alu_threshold);
ERR_ABORT (_threshold_fn);
_threshold_fn->diff_value = get_max_diff_read_usage;
_threshold_fn->sched_value = get_stats_read_usage;
@@ -311,7 +314,7 @@ alu_parse_options (xlator_t *xl, struct alu_sched *alu_sched)
} else if (strcmp (order_str, "open-files-usage") == 0) {
/* Open files counter */
- _threshold_fn = CALLOC (1, sizeof (struct alu_threshold));
+ _threshold_fn = GF_CALLOC (1, sizeof (struct alu_threshold), gf_alu_mt_alu_threshold);
ERR_ABORT (_threshold_fn);
_threshold_fn->diff_value = get_max_diff_file_usage;
_threshold_fn->sched_value = get_stats_file_usage;
@@ -372,7 +375,7 @@ alu_parse_options (xlator_t *xl, struct alu_sched *alu_sched)
} else if (strcmp (order_str, "disk-speed-usage") == 0) {
/* Disk speed */
- _threshold_fn = CALLOC (1, sizeof (struct alu_threshold));
+ _threshold_fn = GF_CALLOC (1, sizeof (struct alu_threshold), gf_alu_mt_alu_threshold);
ERR_ABORT (_threshold_fn);
_threshold_fn->diff_value = get_max_diff_disk_speed;
_threshold_fn->sched_value = get_stats_disk_speed;
@@ -423,7 +426,8 @@ alu_init (xlator_t *xl)
uint32_t min_free_disk = 0;
data_t *limits = NULL;
- alu_sched = CALLOC (1, sizeof (struct alu_sched));
+ alu_sched = GF_CALLOC (1, sizeof (struct alu_sched),
+ gf_alu_mt_alu_sched);
ERR_ABORT (alu_sched);
{
@@ -435,7 +439,8 @@ alu_init (xlator_t *xl)
limits = dict_get (xl->options,
"scheduler.limits.min-free-disk");
if (limits) {
- _limit_fn = CALLOC (1, sizeof (struct alu_limits));
+ _limit_fn = GF_CALLOC (1, sizeof (struct alu_limits),
+ gf_alu_mt_alu_limits);
ERR_ABORT (_limit_fn);
_limit_fn->min_value = get_stats_free_disk;
_limit_fn->cur_value = get_stats_free_disk;
@@ -470,7 +475,8 @@ alu_init (xlator_t *xl)
"scheduler.limits.max-open-files");
if (limits) {
// Update alu_sched->priority properly
- _limit_fn = CALLOC (1, sizeof (struct alu_limits));
+ _limit_fn = GF_CALLOC (1, sizeof (struct alu_limits),
+ gf_alu_mt_alu_limits);
ERR_ABORT (_limit_fn);
_limit_fn->max_value = get_stats_file_usage;
_limit_fn->cur_value = get_stats_file_usage;
@@ -539,7 +545,7 @@ alu_init (xlator_t *xl)
trav_xl = trav_xl->next;
}
alu_sched->child_count = index;
- sched_array = CALLOC (index, sizeof (struct alu_sched_struct));
+ sched_array = GF_CALLOC (index, sizeof (struct alu_sched_struct), gf_alu_mt_alu_sched_struct);
ERR_ABORT (sched_array);
trav_xl = xl->children;
index = 0;
@@ -556,7 +562,7 @@ alu_init (xlator_t *xl)
if (data) {
char *child = NULL;
char *tmp = NULL;
- char *childs_data = strdup (data->data);
+ char *childs_data = gf_strdup (data->data);
child = strtok_r (childs_data, ",", &tmp);
while (child) {
@@ -604,18 +610,18 @@ alu_fini (xlator_t *xl)
struct alu_threshold *threshold = alu_sched->threshold_fn;
void *tmp = NULL;
pthread_mutex_destroy (&alu_sched->alu_mutex);
- free (alu_sched->array);
+ GF_FREE (alu_sched->array);
while (limit) {
tmp = limit;
limit = limit->next;
- free (tmp);
+ GF_FREE (tmp);
}
while (threshold) {
tmp = threshold;
threshold = threshold->next;
- free (tmp);
+ GF_FREE (tmp);
}
- free (alu_sched);
+ GF_FREE (alu_sched);
}
static int32_t
@@ -785,7 +791,7 @@ alu_scheduler (xlator_t *xl, const void *path)
continue;
}
}
- tmp_sched_node = CALLOC (1, sizeof (struct alu_sched_node));
+ tmp_sched_node = GF_CALLOC (1, sizeof (struct alu_sched_node), gf_alu_mt_alu_sched_node);
ERR_ABORT (tmp_sched_node);
tmp_sched_node->index = idx;
if (!alu_sched->sched_node) {
@@ -808,7 +814,7 @@ alu_scheduler (xlator_t *xl, const void *path)
if (alu_sched->array[sched_index].eligible)
break;
alu_sched->sched_node = trav_sched_node->next;
- free (trav_sched_node);
+ GF_FREE (trav_sched_node);
alu_sched->sched_nodes_pending--;
}
if (alu_sched->sched_nodes_pending) {
@@ -823,7 +829,7 @@ alu_scheduler (xlator_t *xl, const void *path)
/* Free the allocated info for the node :) */
pthread_mutex_lock (&alu_sched->alu_mutex);
alu_sched->sched_node = trav_sched_node->next;
- free (trav_sched_node);
+ GF_FREE (trav_sched_node);
trav_sched_node = alu_sched->sched_node;
alu_sched->sched_nodes_pending--;
pthread_mutex_unlock (&alu_sched->alu_mutex);
@@ -832,7 +838,7 @@ alu_scheduler (xlator_t *xl, const void *path)
/* if there is no exit value, then exit after scheduling once */
pthread_mutex_lock (&alu_sched->alu_mutex);
alu_sched->sched_node = trav_sched_node->next;
- free (trav_sched_node);
+ GF_FREE (trav_sched_node);
trav_sched_node = alu_sched->sched_node;
alu_sched->sched_nodes_pending--;
pthread_mutex_unlock (&alu_sched->alu_mutex);
@@ -928,12 +934,32 @@ alu_notify (xlator_t *xl, int32_t event, void *data)
}
+int32_t
+alu_mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_alu_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
struct sched_ops sched = {
.init = alu_init,
.fini = alu_fini,
.update = alu_update,
.schedule = alu_scheduler,
- .notify = alu_notify
+ .notify = alu_notify,
+ .mem_acct_init = alu_mem_acct_init,
};
struct volume_options options[] = {
diff --git a/scheduler/nufa/src/nufa-mem-types.h b/scheduler/nufa/src/nufa-mem-types.h
new file mode 100644
index 00000000000..d8ce993daf9
--- /dev/null
+++ b/scheduler/nufa/src/nufa-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 __NUFA_MEM_TYPES_H__
+#define __NUFA_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_locks_mem_types_ {
+ gf_nufa_mt_nufa_struct = gf_common_mt_end + 1,
+ gf_nufa_mt_nufa_sched_struct,
+ gf_nufa_mt_int32_t,
+ gf_nufa_mt_end
+};
+#endif
+
diff --git a/scheduler/nufa/src/nufa.c b/scheduler/nufa/src/nufa.c
index 92b70ca7580..f089782cd8c 100644
--- a/scheduler/nufa/src/nufa.c
+++ b/scheduler/nufa/src/nufa.c
@@ -26,6 +26,7 @@
#include "scheduler.h"
#include "common-utils.h"
+#include "nufa-mem-types.h"
struct nufa_sched_struct {
xlator_t *xl;
@@ -63,7 +64,8 @@ nufa_init (xlator_t *xl)
xlator_list_t *trav_xl = xl->children;
struct nufa_struct *nufa_buf = NULL;
- nufa_buf = CALLOC (1, sizeof (struct nufa_struct));
+ nufa_buf = GF_CALLOC (1, sizeof (struct nufa_struct),
+ gf_nufa_mt_nufa_struct);
ERR_ABORT (nufa_buf);
data = dict_get (xl->options, "scheduler.limits.min-free-disk");
@@ -112,9 +114,11 @@ nufa_init (xlator_t *xl)
}
nufa_buf->child_count = index;
nufa_buf->sched_index = 0;
- nufa_buf->array = CALLOC (index, sizeof (struct nufa_sched_struct));
+ nufa_buf->array = GF_CALLOC (index, sizeof (struct nufa_sched_struct),
+ gf_nufa_mt_nufa_sched_struct);
ERR_ABORT (nufa_buf->array);
- nufa_buf->local_array = CALLOC (index, sizeof (int32_t));
+ nufa_buf->local_array = GF_CALLOC (index, sizeof (int32_t),
+ gf_nufa_mt_int32_t);
ERR_ABORT (nufa_buf->array);
trav_xl = xl->children;
@@ -123,9 +127,9 @@ nufa_init (xlator_t *xl)
/* Error */
gf_log ("nufa", GF_LOG_ERROR,
"No 'local-volume-name' option given in volume file");
- FREE (nufa_buf->array);
- FREE (nufa_buf->local_array);
- FREE (nufa_buf);
+ GF_FREE (nufa_buf->array);
+ GF_FREE (nufa_buf->local_array);
+ GF_FREE (nufa_buf);
return -1;
}
@@ -147,7 +151,7 @@ nufa_init (xlator_t *xl)
int32_t array_index = 0;
char *child = NULL;
char *tmp = NULL;
- char *childs_data = strdup (local_name->data);
+ char *childs_data = gf_strdup (local_name->data);
child = strtok_r (childs_data, ",", &tmp);
while (child) {
@@ -168,9 +172,9 @@ nufa_init (xlator_t *xl)
gf_log ("nufa", GF_LOG_ERROR,
"option 'scheduler.local-volume-name' "
"%s is wrong", child);
- FREE (nufa_buf->array);
- FREE (nufa_buf->local_array);
- FREE (nufa_buf);
+ GF_FREE (nufa_buf->array);
+ GF_FREE (nufa_buf->local_array);
+ GF_FREE (nufa_buf);
return -1;
} else {
nufa_buf->local_array[array_index++] = index;
@@ -178,7 +182,7 @@ nufa_init (xlator_t *xl)
}
child = strtok_r (NULL, ",", &tmp);
}
- free (childs_data);
+ GF_FREE (childs_data);
}
LOCK_INIT (&nufa_buf->nufa_lock);
@@ -193,9 +197,9 @@ nufa_fini (xlator_t *xl)
(struct nufa_struct *)*((long *)xl->private);
LOCK_DESTROY (&nufa_buf->nufa_lock);
- FREE (nufa_buf->local_array);
- FREE (nufa_buf->array);
- FREE (nufa_buf);
+ GF_FREE (nufa_buf->local_array);
+ GF_FREE (nufa_buf->array);
+ GF_FREE (nufa_buf);
}
static int32_t
@@ -379,12 +383,32 @@ nufa_notify (xlator_t *xl, int32_t event, void *data)
}
+int32_t
+nufa_mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_nufa_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
struct sched_ops sched = {
.init = nufa_init,
.fini = nufa_fini,
.update = nufa_update,
.schedule = nufa_schedule,
- .notify = nufa_notify
+ .notify = nufa_notify,
+ .mem_acct_init = nufa_mem_acct_init,
};
struct volume_options options[] = {
diff --git a/scheduler/random/src/random-mem-types.h b/scheduler/random/src/random-mem-types.h
new file mode 100644
index 00000000000..612e53dbdb6
--- /dev/null
+++ b/scheduler/random/src/random-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 __RANDOM_MEM_TYPES_H__
+#define __RANDOM_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_random_mem_types_ {
+ gf_random_mt_random_struct = gf_common_mt_end + 1,
+ gf_random_mt_random_sched_struct,
+ gf_random_mt_end
+};
+#endif
+
diff --git a/scheduler/random/src/random.c b/scheduler/random/src/random.c
index 07ed45e7318..e6bd34c3d7e 100644
--- a/scheduler/random/src/random.c
+++ b/scheduler/random/src/random.c
@@ -26,6 +26,7 @@
#endif
#include "random.h"
+#include "random-mem-types.h"
#define RANDOM_LIMITS_MIN_FREE_DISK_DEFAULT 15
#define RANDOM_REFRESH_INTERVAL_DEFAULT 10
@@ -39,7 +40,8 @@ random_init (xlator_t *xl)
data_t *limit = NULL;
int32_t index = 0;
- random_buf = CALLOC (1, sizeof (struct random_struct));
+ random_buf = GF_CALLOC (1, sizeof (struct random_struct),
+ gf_random_mt_random_struct);
ERR_ABORT (random_buf);
/* Set the seed for the 'random' function */
@@ -89,8 +91,9 @@ random_init (xlator_t *xl)
trav_xl = trav_xl->next;
}
random_buf->child_count = index;
- random_buf->array = CALLOC (index,
- sizeof (struct random_sched_struct));
+ random_buf->array = GF_CALLOC (index,
+ sizeof (struct random_sched_struct),
+ gf_random_mt_random_sched_struct);
ERR_ABORT (random_buf->array);
trav_xl = xl->children;
index = 0;
@@ -115,8 +118,8 @@ random_fini (xlator_t *xl)
random_buf = (struct random_struct *)*((long *)xl->private);
pthread_mutex_destroy (&random_buf->random_mutex);
- free (random_buf->array);
- free (random_buf);
+ GF_FREE (random_buf->array);
+ GF_FREE (random_buf);
}
@@ -222,6 +225,24 @@ random_schedule (xlator_t *xl, const void *path)
return random_buf->array[rand].xl;
}
+int32_t
+random_mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_random_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ " failed");
+ return ret;
+ }
+
+ return ret;
+}
/**
* notify
@@ -267,7 +288,8 @@ struct sched_ops sched = {
.fini = random_fini,
.update = random_update,
.schedule = random_schedule,
- .notify = random_notify
+ .notify = random_notify,
+ .mem_acct_init = random_mem_acct_init,
};
struct volume_options options[] = {
diff --git a/scheduler/rr/src/rr-mem-types.h b/scheduler/rr/src/rr-mem-types.h
new file mode 100644
index 00000000000..4b283ca841d
--- /dev/null
+++ b/scheduler/rr/src/rr-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 __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 b76c9fcccfc..b454ccd7c22 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 d47f87278bc..83a0f267fd2 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;
diff --git a/scheduler/switch/src/switch-mem-types.h b/scheduler/switch/src/switch-mem-types.h
new file mode 100644
index 00000000000..07773da4e2f
--- /dev/null
+++ b/scheduler/switch/src/switch-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 __SWITCH_MEM_TYPES_H__
+#define __SWITCH_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_switch_mem_types_ {
+ gf_switch_mt_switch_struct = gf_common_mt_end + 1,
+ gf_switch_mt_switch_sched_struct,
+ gf_switch_mt_switch_sched_array,
+ gf_switch_mt_end
+};
+#endif
+
diff --git a/scheduler/switch/src/switch.c b/scheduler/switch/src/switch.c
index 8089f9376fa..5a5d20f8d50 100644
--- a/scheduler/switch/src/switch.c
+++ b/scheduler/switch/src/switch.c
@@ -28,6 +28,7 @@
#include "xlator.h"
#include "scheduler.h"
+#include "switch-mem-types.h"
struct switch_sched_array {
xlator_t *xl;
@@ -58,20 +59,20 @@ static xlator_t *
switch_get_matching_xl (const char *path, struct switch_sched_struct *cond)
{
struct switch_sched_struct *trav = cond;
- char *pathname = strdup (path);
+ char *pathname = gf_strdup (path);
int index = 0;
while (trav) {
if (fnmatch (trav->path_pattern,
pathname, FNM_NOESCAPE) == 0) {
- free (pathname);
+ GF_FREE (pathname);
trav->node_index %= trav->num_child;
index = (trav->node_index++) % trav->num_child;
return trav->array[index].xl;
}
trav = trav->next;
}
- free (pathname);
+ GF_FREE (pathname);
return NULL;
}
@@ -107,7 +108,8 @@ switch_init (xlator_t *xl)
xlator_list_t *trav_xl = xl->children;
struct switch_struct *switch_buf = NULL;
- switch_buf = CALLOC (1, sizeof (struct switch_struct));
+ switch_buf = GF_CALLOC (1, sizeof (struct switch_struct),
+ gf_switch_mt_switch_struct);
ERR_ABORT (switch_buf);
while (trav_xl) {
@@ -115,8 +117,9 @@ switch_init (xlator_t *xl)
trav_xl = trav_xl->next;
}
switch_buf->child_count = index;
- switch_buf->array = CALLOC (index + 1,
- sizeof (struct switch_sched_struct));
+ switch_buf->array = GF_CALLOC (index + 1,
+ sizeof (struct switch_sched_struct),
+ gf_switch_mt_switch_sched_struct);
ERR_ABORT (switch_buf->array);
trav_xl = xl->children;
index = 0;
@@ -130,7 +133,7 @@ switch_init (xlator_t *xl)
data = dict_get (xl->options, "scheduler.read-only-subvolumes");
if (data) {
- childs_data = strdup (data->data);
+ childs_data = gf_strdup (data->data);
child = strtok_r (childs_data, ",", &tmp);
while (child) {
for (index = 1;
@@ -148,7 +151,7 @@ switch_init (xlator_t *xl)
}
child = strtok_r (NULL, ",", &tmp);
}
- free (childs_data);
+ GF_FREE (childs_data);
}
data = dict_get (xl->options, "scheduler.local-volume-name");
@@ -176,10 +179,9 @@ switch_init (xlator_t *xl)
"option block-size *avi:10MB" etc */
switch_str = strtok_r (data->data, ";", &tmp_str);
while (switch_str) {
- dup_str = strdup (switch_str);
+ dup_str = gf_strdup (switch_str);
switch_opt =
- CALLOC (1,
- sizeof (struct switch_sched_struct));
+ GF_CALLOC (1, sizeof (struct switch_sched_struct), gf_switch_mt_switch_sched_struct);
ERR_ABORT (switch_opt);
/* Link it to the main structure */
@@ -201,7 +203,7 @@ switch_init (xlator_t *xl)
"for all the unconfigured child nodes,"
" hence neglecting current option");
switch_str = strtok_r (NULL, ";", &tmp_str);
- free (dup_str);
+ GF_FREE (dup_str);
continue;
}
memcpy (switch_opt->path_pattern,
@@ -212,7 +214,7 @@ switch_init (xlator_t *xl)
char *dup_childs = NULL;
/* TODO: get the list of child nodes for
the given pattern */
- dup_childs = strdup (childs);
+ dup_childs = gf_strdup (childs);
child = strtok_r (dup_childs, ",", &tmp);
while (child) {
if (gf_unify_valid_child (child, xl)) {
@@ -229,11 +231,11 @@ switch_init (xlator_t *xl)
return -1;
}
}
- free (dup_childs);
+ GF_FREE (dup_childs);
child = strtok_r (childs, ",", &tmp1);
switch_opt->num_child = idx;
switch_opt->array =
- CALLOC (1, idx * sizeof (struct switch_sched_array));
+ GF_CALLOC (1, idx * sizeof (struct switch_sched_array), gf_switch_mt_switch_sched_array);
ERR_ABORT (switch_opt->array);
idx = 0;
child = strtok_r (childs, ",", &tmp);
@@ -267,11 +269,11 @@ switch_init (xlator_t *xl)
gf_log ("switch", GF_LOG_ERROR,
"Check \"scheduler.switch.case\" "
"option in unify volume. Exiting");
- free (switch_buf->array);
- free (switch_buf);
+ GF_FREE (switch_buf->array);
+ GF_FREE (switch_buf);
return -1;
}
- free (dup_str);
+ GF_FREE (dup_str);
switch_str = strtok_r (NULL, ";", &tmp_str);
}
}
@@ -293,7 +295,7 @@ switch_init (xlator_t *xl)
"No nodes left for pattern '*'. Exiting.");
return -1;
}
- switch_opt = CALLOC (1, sizeof (struct switch_sched_struct));
+ switch_opt = GF_CALLOC (1, sizeof (struct switch_sched_struct), gf_switch_mt_switch_sched_struct);
ERR_ABORT (switch_opt);
if (switch_buf->cond) {
/* there are already few entries */
@@ -309,7 +311,7 @@ switch_init (xlator_t *xl)
memcpy (switch_opt->path_pattern, "*", 2);
switch_opt->num_child = flag;
switch_opt->array =
- CALLOC (1, flag * sizeof (struct switch_sched_array));
+ GF_CALLOC (1, flag * sizeof (struct switch_sched_array), gf_switch_mt_switch_sched_array);
ERR_ABORT (switch_opt->array);
flag = 0;
for (index=0; index < switch_buf->child_count; index++) {
@@ -343,8 +345,8 @@ switch_fini (xlator_t *xl)
switch_buf = (struct switch_struct *)*((long *)xl->private);
pthread_mutex_destroy (&switch_buf->switch_mutex);
- free (switch_buf->array);
- free (switch_buf);
+ GF_FREE (switch_buf->array);
+ GF_FREE (switch_buf);
}
static xlator_t *
@@ -403,13 +405,33 @@ switch_update (xlator_t *xl)
{
return;
}
+
+int32_t
+switch_mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_switch_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ " failed");
+ return ret;
+ }
+
+ return ret;
+}
struct sched_ops sched = {
.init = switch_init,
.fini = switch_fini,
.update = switch_update,
.schedule = switch_schedule,
- .notify = switch_notify
+ .notify = switch_notify,
+ .mem_acct_init = switch_mem_acct_init,
};
struct volume_options options[] = {
diff --git a/transport/ib-verbs/src/ib-verbs-mem-types.h b/transport/ib-verbs/src/ib-verbs-mem-types.h
new file mode 100644
index 00000000000..bac559646fc
--- /dev/null
+++ b/transport/ib-verbs/src/ib-verbs-mem-types.h
@@ -0,0 +1,39 @@
+
+/*
+ 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 __IB_VERBS_MEM_TYPES_H__
+#define __IB_VERBS_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_ib_verbs_mem_types_ {
+ gf_ibv_mt_ib_verbs_private_t = gf_common_mt_end + 1,
+ gf_ibv_mt_ib_verbs_ioq_t,
+ gf_ibv_mt_transport_t,
+ gf_ibv_mt_ib_verbs_local_t,
+ gf_ibv_mt_ib_verbs_post_t,
+ gf_ibv_mt_char,
+ gf_ibv_mt_qpent,
+ gf_ibv_mt_ib_verbs_device_t,
+ gf_ibv_mt_end
+};
+#endif
+
diff --git a/transport/ib-verbs/src/ib-verbs.c b/transport/ib-verbs/src/ib-verbs.c
index b02e0bd6340..a252a13d884 100644
--- a/transport/ib-verbs/src/ib-verbs.c
+++ b/transport/ib-verbs/src/ib-verbs.c
@@ -156,7 +156,8 @@ ib_verbs_new_post (ib_verbs_device_t *device, int32_t len)
{
ib_verbs_post_t *post;
- post = (ib_verbs_post_t *) CALLOC (1, sizeof (*post));
+ post = (ib_verbs_post_t *) GF_CALLOC (1, sizeof (*post),
+ gf_ibv_mt_ib_verbs_post_t);
if (!post)
return NULL;
@@ -164,7 +165,7 @@ ib_verbs_new_post (ib_verbs_device_t *device, int32_t len)
post->buf = valloc (len);
if (!post->buf) {
- free (post);
+ GF_FREE (post);
return NULL;
}
@@ -174,7 +175,7 @@ ib_verbs_new_post (ib_verbs_device_t *device, int32_t len)
IBV_ACCESS_LOCAL_WRITE);
if (!post->mr) {
free (post->buf);
- free (post);
+ GF_FREE (post);
return NULL;
}
@@ -216,7 +217,7 @@ ib_verbs_destroy_post (ib_verbs_post_t *post)
{
ibv_dereg_mr (post->mr);
free (post->buf);
- free (post);
+ GF_FREE (post);
}
@@ -258,10 +259,10 @@ __ib_verbs_ioq_entry_free (ib_verbs_ioq_t *entry)
iobref_unref (entry->iobref);
/* TODO: use mem-pool */
- free (entry->buf);
+ GF_FREE (entry->buf);
/* TODO: use mem-pool */
- free (entry);
+ GF_FREE (entry);
}
@@ -497,7 +498,7 @@ ib_verbs_ioq_new (char *buf, int len, struct iovec *vector,
ib_verbs_ioq_t *entry = NULL;
/* TODO: use mem-pool */
- entry = CALLOC (1, sizeof (*entry));
+ entry = GF_CALLOC (1, sizeof (*entry), gf_ibv_mt_ib_verbs_ioq_t);
assert (count <= (MAX_IOVEC-2));
@@ -602,7 +603,7 @@ ib_verbs_receive (transport_t *this, char **hdr_p, size_t *hdrlen_p,
copy_from += sizeof (*header);
if (size1) {
- hdr = CALLOC (1, size1);
+ hdr = GF_CALLOC (1, size1, gf_ibv_mt_char);
if (!hdr) {
gf_log (this->xl->name, GF_LOG_ERROR,
"unable to allocate header for peer %s",
@@ -729,7 +730,7 @@ ib_verbs_register_peer (ib_verbs_device_t *device,
pthread_mutex_unlock (&qpreg->lock);
return;
}
- ent = (struct _qpent *) CALLOC (1, sizeof (*ent));
+ ent = (struct _qpent *) GF_CALLOC (1, sizeof (*ent), gf_ibv_mt_qpent);
ERR_ABORT (ent);
/* TODO: ref reg->peer */
ent->peer = peer;
@@ -762,7 +763,7 @@ ib_verbs_unregister_peer (ib_verbs_device_t *device,
ent->prev->next = ent->next;
ent->next->prev = ent->prev;
/* TODO: unref reg->peer */
- free (ent);
+ GF_FREE (ent);
qpreg->count--;
pthread_mutex_unlock (&qpreg->lock);
}
@@ -1476,7 +1477,7 @@ ib_verbs_options_init (transport_t *this)
temp = dict_get (this->xl->options,
"transport.ib-verbs.device-name");
if (temp)
- options->device_name = strdup (temp->data);
+ options->device_name = gf_strdup (temp->data);
return;
}
@@ -1519,7 +1520,8 @@ ib_verbs_get_device (transport_t *this,
if (!trav) {
- trav = CALLOC (1, sizeof (*trav));
+ trav = GF_CALLOC (1, sizeof (*trav),
+ gf_ibv_mt_ib_verbs_device_t);
ERR_ABORT (trav);
priv->device = trav;
@@ -1555,7 +1557,7 @@ ib_verbs_get_device (transport_t *this,
"port: %u", port);
}
- trav->device_name = strdup (device_name);
+ trav->device_name = gf_strdup (device_name);
trav->port = port;
trav->next = ctx->ib;
@@ -1684,7 +1686,7 @@ ib_verbs_init (transport_t *this)
if (!options->device_name) {
if (*dev_list) {
options->device_name =
- strdup (ibv_get_device_name (*dev_list));
+ gf_strdup (ibv_get_device_name (*dev_list));
} else {
gf_log ("transport/ib-verbs", GF_LOG_CRITICAL,
"IB device list is empty. Check for "
@@ -1828,7 +1830,7 @@ ib_verbs_handshake_pollin (transport_t *this)
switch (priv->handshake.incoming.state)
{
case IB_VERBS_HANDSHAKE_START:
- buf = priv->handshake.incoming.buf = CALLOC (1, 256);
+ buf = priv->handshake.incoming.buf = GF_CALLOC (1, 256, gf_ibv_mt_char);
ib_verbs_fill_handshake_data (buf, &priv->handshake.incoming, priv);
buf[0] = 0;
priv->handshake.incoming.state = IB_VERBS_HANDSHAKE_RECEIVING_DATA;
@@ -1941,7 +1943,7 @@ ib_verbs_handshake_pollin (transport_t *this)
(struct sockaddr *) &this->peerinfo.sockaddr,
&sock_len);
- FREE (priv->handshake.incoming.buf);
+ GF_FREE (priv->handshake.incoming.buf);
priv->handshake.incoming.buf = NULL;
priv->handshake.incoming.state = IB_VERBS_HANDSHAKE_COMPLETE;
}
@@ -1981,7 +1983,7 @@ ib_verbs_handshake_pollout (transport_t *this)
switch (priv->handshake.outgoing.state)
{
case IB_VERBS_HANDSHAKE_START:
- buf = priv->handshake.outgoing.buf = CALLOC (1, 256);
+ buf = priv->handshake.outgoing.buf = GF_CALLOC (1, 256, gf_ibv_mt_char);
ib_verbs_fill_handshake_data (buf, &priv->handshake.outgoing, priv);
priv->handshake.outgoing.state = IB_VERBS_HANDSHAKE_SENDING_DATA;
break;
@@ -2031,7 +2033,7 @@ ib_verbs_handshake_pollout (transport_t *this)
}
if (!ret) {
- FREE (priv->handshake.outgoing.buf);
+ GF_FREE (priv->handshake.outgoing.buf);
priv->handshake.outgoing.buf = NULL;
priv->handshake.outgoing.state = IB_VERBS_HANDSHAKE_COMPLETE;
}
@@ -2082,14 +2084,14 @@ ib_verbs_handshake_pollerr (transport_t *this)
}
if (priv->handshake.incoming.buf) {
- FREE (priv->handshake.incoming.buf);
+ GF_FREE (priv->handshake.incoming.buf);
priv->handshake.incoming.buf = NULL;
}
priv->handshake.incoming.state = IB_VERBS_HANDSHAKE_START;
if (priv->handshake.outgoing.buf) {
- FREE (priv->handshake.outgoing.buf);
+ GF_FREE (priv->handshake.outgoing.buf);
priv->handshake.outgoing.buf = NULL;
}
@@ -2352,9 +2354,11 @@ ib_verbs_server_event_handler (int fd, int idx, void *data,
if (!poll_in)
return 0;
- this = CALLOC (1, sizeof (transport_t));
+ this = GF_CALLOC (1, sizeof (transport_t),
+ gf_ibv_mt_transport_t);
ERR_ABORT (this);
- priv = CALLOC (1, sizeof (ib_verbs_private_t));
+ priv = GF_CALLOC (1, sizeof (ib_verbs_private_t),
+ gf_ibv_mt_ib_verbs_private_t);
ERR_ABORT (priv);
this->private = priv;
/* Copy all the ib_verbs related values in priv, from trans_priv
@@ -2381,8 +2385,8 @@ ib_verbs_server_event_handler (int fd, int idx, void *data,
gf_log ("ib-verbs/server", GF_LOG_ERROR,
"accept() failed: %s",
strerror (errno));
- free (this->private);
- free (this);
+ GF_FREE (this->private);
+ GF_FREE (this);
return -1;
}
@@ -2445,7 +2449,7 @@ ib_verbs_listen (transport_t *this)
gf_log ("ib-verbs/server", GF_LOG_CRITICAL,
"init: failed to create socket, error: %s",
strerror (errno));
- free (this->private);
+ GF_FREE (this->private);
ret = -1;
goto err;
}
@@ -2504,7 +2508,8 @@ struct transport_ops tops = {
int32_t
init (transport_t *this)
{
- ib_verbs_private_t *priv = CALLOC (1, sizeof (*priv));
+ ib_verbs_private_t *priv = GF_CALLOC (1, sizeof (*priv),
+ gf_ibv_mt_ib_verbs_private_t);
this->private = priv;
priv->sock = -1;
@@ -2532,10 +2537,29 @@ fini (struct transport *this)
gf_log (this->xl->name, GF_LOG_TRACE,
"called fini on transport: %p",
this);
- free (priv);
+ GF_FREE (priv);
return;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_common_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
/* TODO: expand each option */
struct volume_options options[] = {
{ .key = {"transport.ib-verbs.port",
diff --git a/transport/ib-verbs/src/ib-verbs.h b/transport/ib-verbs/src/ib-verbs.h
index ea016c34d99..c385b62e5cb 100644
--- a/transport/ib-verbs/src/ib-verbs.h
+++ b/transport/ib-verbs/src/ib-verbs.h
@@ -32,6 +32,7 @@
#include "xlator.h"
#include "event.h"
+#include "ib-verbs-mem-types.h"
#include <stdio.h>
#include <list.h>
diff --git a/transport/socket/src/socket-mem-types.h b/transport/socket/src/socket-mem-types.h
new file mode 100644
index 00000000000..f50f4a75de8
--- /dev/null
+++ b/transport/socket/src/socket-mem-types.h
@@ -0,0 +1,36 @@
+
+/*
+ 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 __SOCKET_MEM_TYPES_H__
+#define __SOCKET_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_socket_mem_types_ {
+ gf_socket_mt_socket_private_t = gf_common_mt_end + 1,
+ gf_socket_mt_ioq,
+ gf_socket_mt_transport_t,
+ gf_socket_mt_socket_local_t,
+ gf_socket_mt_char,
+ gf_socket_mt_end
+};
+#endif
+
diff --git a/transport/socket/src/socket.c b/transport/socket/src/socket.c
index 28b828f29a2..7f7f8093a7d 100644
--- a/transport/socket/src/socket.c
+++ b/transport/socket/src/socket.c
@@ -273,7 +273,7 @@ __socket_reset (transport_t *this)
/* TODO: use mem-pool on incoming data */
if (priv->incoming.hdr_p)
- free (priv->incoming.hdr_p);
+ GF_FREE (priv->incoming.hdr_p);
if (priv->incoming.iobuf)
iobuf_unref (priv->incoming.iobuf);
@@ -298,7 +298,8 @@ __socket_ioq_new (transport_t *this, char *buf, int len,
priv = this->private;
/* TODO: use mem-pool */
- entry = CALLOC (1, sizeof (*entry));
+ entry = GF_CALLOC (1, sizeof (*entry),
+ gf_common_mt_ioq);
if (!entry)
return NULL;
@@ -346,10 +347,10 @@ __socket_ioq_entry_free (struct ioq *entry)
iobref_unref (entry->iobref);
/* TODO: use mem-pool */
- free (entry->buf);
+ GF_FREE (entry->buf);
/* TODO: use mem-pool */
- free (entry);
+ GF_FREE (entry);
}
@@ -607,7 +608,8 @@ __socket_proto_state_machine (transport_t *this)
priv->incoming.buflen = size2;
/* TODO: use mem-pool */
- priv->incoming.hdr_p = MALLOC (size1);
+ priv->incoming.hdr_p = GF_MALLOC (size1,
+ gf_common_mt_char);
if (size2) {
/* TODO: sanity check size2 < page size
*/
@@ -891,7 +893,8 @@ socket_server_event_handler (int fd, int idx, void *data,
}
}
- new_trans = CALLOC (1, sizeof (*new_trans));
+ new_trans = GF_CALLOC (1, sizeof (*new_trans),
+ gf_common_mt_transport_t);
new_trans->xl = this->xl;
new_trans->fini = this->fini;
@@ -1376,7 +1379,8 @@ socket_init (transport_t *this)
return -1;
}
- priv = CALLOC (1, sizeof (*priv));
+ priv = GF_CALLOC (1, sizeof (*priv),
+ gf_common_mt_socket_private_t);
if (!priv) {
gf_log (this->xl->name, GF_LOG_ERROR,
"calloc (1, %"GF_PRI_SIZET") returned NULL",
@@ -1465,9 +1469,27 @@ fini (transport_t *this)
"transport %p destroyed", this);
pthread_mutex_destroy (&priv->lock);
- FREE (priv);
+ GF_FREE (priv);
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_common_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
int32_t
init (transport_t *this)
diff --git a/transport/socket/src/socket.h b/transport/socket/src/socket.h
index 44715697db1..bc6d3b27c3a 100644
--- a/transport/socket/src/socket.h
+++ b/transport/socket/src/socket.h
@@ -31,6 +31,7 @@
#include "logging.h"
#include "dict.h"
#include "mem-pool.h"
+#include "socket-mem-types.h"
#ifndef MAX_IOVEC
#define MAX_IOVEC 16
diff --git a/xlators/cluster/afr/src/afr-dir-read.c b/xlators/cluster/afr/src/afr-dir-read.c
index 501cc3e8c58..0f9bdf59eae 100644
--- a/xlators/cluster/afr/src/afr-dir-read.c
+++ b/xlators/cluster/afr/src/afr-dir-read.c
@@ -188,8 +188,9 @@ afr_examine_dir (call_frame_t *frame, xlator_t *this)
local = frame->local;
priv = this->private;
- local->cont.opendir.checksum = CALLOC (priv->child_count,
- sizeof (*local->cont.opendir.checksum));
+ local->cont.opendir.checksum = GF_CALLOC (priv->child_count,
+ sizeof (*local->cont.opendir.checksum),
+ gf_afr_mt_int32_t);
call_count = afr_up_children_count (priv->child_count, local->child_up);
@@ -387,8 +388,8 @@ afr_remember_entries (gf_dirent_t *entries, fd_t *fd)
fd_ctx = (afr_fd_ctx_t *)(long) ctx;
list_for_each_entry (entry, &entries->list, list) {
- n = CALLOC (1, sizeof (*n));
- n->name = strdup (entry->d_name);
+ n = GF_CALLOC (1, sizeof (*n), gf_afr_mt_entry_name);
+ n->name = gf_strdup (entry->d_name);
INIT_LIST_HEAD (&n->list);
list_add (&n->list, &fd_ctx->entries);
@@ -421,7 +422,7 @@ afr_filter_entries (gf_dirent_t *entries, fd_t *fd)
if (remembered_name (entry->d_name, &fd_ctx->entries)) {
list_del (&entry->list);
- FREE (entry);
+ GF_FREE (entry);
}
}
@@ -448,9 +449,9 @@ afr_forget_entries (fd_t *fd)
fd_ctx = (afr_fd_ctx_t *)(long) ctx;
list_for_each_entry_safe (entry, tmp, &fd_ctx->entries, list) {
- FREE (entry->name);
+ GF_FREE (entry->name);
list_del (&entry->list);
- FREE (entry);
+ GF_FREE (entry);
}
}
@@ -485,7 +486,7 @@ afr_readdir_cbk (call_frame_t *frame, void *cookie,
if ((local->fd->inode == local->fd->inode->table->root)
&& !strcmp (entry->d_name, GF_REPLICATE_TRASH_DIR)) {
list_del_init (&entry->list);
- FREE (entry);
+ GF_FREE (entry);
}
}
}
@@ -571,7 +572,7 @@ afr_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if ((local->fd->inode == local->fd->inode->table->root)
&& !strcmp (entry->d_name, GF_REPLICATE_TRASH_DIR)) {
list_del_init (&entry->list);
- FREE (entry);
+ GF_FREE (entry);
}
}
}
diff --git a/xlators/cluster/afr/src/afr-dir-write.c b/xlators/cluster/afr/src/afr-dir-write.c
index 9d7e74e7871..439e8d8c765 100644
--- a/xlators/cluster/afr/src/afr-dir-write.c
+++ b/xlators/cluster/afr/src/afr-dir-write.c
@@ -58,9 +58,9 @@ afr_build_parent_loc (loc_t *parent, loc_t *child)
return;
}
- tmp = strdup (child->path);
- parent->path = strdup (dirname (tmp));
- FREE (tmp);
+ tmp = gf_strdup (child->path);
+ parent->path = gf_strdup (dirname (tmp));
+ GF_FREE (tmp);
parent->name = strrchr (parent->path, '/');
if (parent->name)
@@ -1315,7 +1315,7 @@ afr_symlink (call_frame_t *frame, xlator_t *this,
}
UNLOCK (&priv->read_child_lock);
- local->cont.symlink.linkpath = strdup (linkpath);
+ local->cont.symlink.linkpath = gf_strdup (linkpath);
if (loc->parent)
local->cont.symlink.parent_ino = loc->parent->ino;
diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c
index 9ce1036755d..b1bbac10bc2 100644
--- a/xlators/cluster/afr/src/afr-inode-read.c
+++ b/xlators/cluster/afr/src/afr-inode-read.c
@@ -566,7 +566,7 @@ __gather_xattr_keys (dict_t *dict, char *key, data_t *value,
if (!strncmp (key, AFR_XATTR_PREFIX,
strlen (AFR_XATTR_PREFIX))) {
- xkey = CALLOC (1, sizeof (*xkey));
+ xkey = GF_CALLOC (1, sizeof (*xkey), gf_afr_mt_xattr_key);
if (!xkey)
return;
@@ -596,7 +596,7 @@ __filter_xattrs (dict_t *dict)
list_del_init (&key->list);
- FREE (key);
+ GF_FREE (key);
}
}
@@ -713,7 +713,7 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
loc_copy (&local->loc, loc);
if (name)
- local->cont.getxattr.name = strdup (name);
+ local->cont.getxattr.name = gf_strdup (name);
STACK_WIND_COOKIE (frame, afr_getxattr_cbk,
(void *) (long) call_child,
diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c
index e28fe5f89ac..37909181e21 100644
--- a/xlators/cluster/afr/src/afr-inode-write.c
+++ b/xlators/cluster/afr/src/afr-inode-write.c
@@ -1600,7 +1600,7 @@ afr_removexattr (call_frame_t *frame, xlator_t *this,
local->op_ret = -1;
- local->cont.removexattr.name = strdup (name);
+ local->cont.removexattr.name = gf_strdup (name);
local->transaction.fop = afr_removexattr_wind;
local->transaction.done = afr_removexattr_done;
diff --git a/xlators/cluster/afr/src/afr-mem-types.h b/xlators/cluster/afr/src/afr-mem-types.h
new file mode 100644
index 00000000000..27117c1848c
--- /dev/null
+++ b/xlators/cluster/afr/src/afr-mem-types.h
@@ -0,0 +1,46 @@
+/*
+ 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 __AFR_MEM_TYPES_H__
+#define __AFR_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_afr_mem_types_ {
+ gf_afr_mt_iovec = gf_common_mt_end + 1,
+ gf_afr_mt_afr_fd_ctx_t,
+ gf_afr_mt_afr_local_t,
+ gf_afr_mt_afr_private_t,
+ gf_afr_mt_int32_t,
+ gf_afr_mt_char,
+ gf_afr_mt_xattr_key,
+ gf_afr_mt_dict_t,
+ gf_afr_mt_xlator_t,
+ gf_afr_mt_stat,
+ gf_afr_mt_int,
+ gf_afr_mt_afr_node_character,
+ gf_afr_mt_sh_diff_loop_state,
+ gf_afr_mt_uint8_t,
+ gf_afr_mt_loc_t,
+ gf_afr_mt_entry_name,
+ gf_afr_mt_end
+};
+#endif
+
diff --git a/xlators/cluster/afr/src/afr-self-heal-algorithm.c b/xlators/cluster/afr/src/afr-self-heal-algorithm.c
index f840c1bbe25..ef9d4026e0d 100644
--- a/xlators/cluster/afr/src/afr-self-heal-algorithm.c
+++ b/xlators/cluster/afr/src/afr-self-heal-algorithm.c
@@ -66,7 +66,7 @@ sh_full_private_cleanup (call_frame_t *frame, xlator_t *this)
sh_priv = sh->private;
if (sh_priv)
- FREE (sh_priv);
+ GF_FREE (sh_priv);
}
@@ -384,7 +384,8 @@ afr_sh_algo_full (call_frame_t *frame, xlator_t *this)
local = frame->local;
sh = &local->self_heal;
- sh_priv = CALLOC (1, sizeof (*sh_priv));
+ sh_priv = GF_CALLOC (1, sizeof (*sh_priv),
+ gf_afr_mt_afr_private_t);
LOCK_INIT (&sh_priv->lock);
@@ -422,18 +423,18 @@ sh_diff_private_cleanup (call_frame_t *frame, xlator_t *this)
for (i = 0; i < priv->data_self_heal_window_size; i++) {
if (sh_priv->loops[i]) {
if (sh_priv->loops[i]->write_needed)
- FREE (sh_priv->loops[i]->write_needed);
+ GF_FREE (sh_priv->loops[i]->write_needed);
if (sh_priv->loops[i]->checksum)
- FREE (sh_priv->loops[i]->checksum);
+ GF_FREE (sh_priv->loops[i]->checksum);
}
}
if (sh_priv) {
if (sh_priv->loops)
- FREE (sh_priv->loops);
+ GF_FREE (sh_priv->loops);
- FREE (sh_priv);
+ GF_FREE (sh_priv);
}
@@ -1034,7 +1035,8 @@ afr_sh_algo_diff (call_frame_t *frame, xlator_t *this)
local = frame->local;
sh = &local->self_heal;
- sh_priv = CALLOC (1, sizeof (*sh_priv));
+ sh_priv = GF_CALLOC (1, sizeof (*sh_priv),
+ gf_afr_mt_afr_private_t);
sh_priv->block_size = this->ctx->page_size;
@@ -1044,16 +1046,19 @@ afr_sh_algo_diff (call_frame_t *frame, xlator_t *this)
local->call_count = 0;
- sh_priv->loops = CALLOC (priv->data_self_heal_window_size,
- sizeof (*sh_priv->loops));
+ sh_priv->loops = GF_CALLOC (priv->data_self_heal_window_size,
+ sizeof (*sh_priv->loops),
+ gf_afr_mt_sh_diff_loop_state);
for (i = 0; i < priv->data_self_heal_window_size; i++) {
- sh_priv->loops[i] = CALLOC (1, sizeof (*sh_priv->loops[i]));
-
- sh_priv->loops[i]->checksum = CALLOC (priv->child_count,
- MD5_DIGEST_LEN);
- sh_priv->loops[i]->write_needed = CALLOC (priv->child_count,
- sizeof (*sh_priv->loops[i]->write_needed));
+ sh_priv->loops[i] = GF_CALLOC (1, sizeof (*sh_priv->loops[i]),
+ gf_afr_mt_sh_diff_loop_state);
+
+ sh_priv->loops[i]->checksum = GF_CALLOC (priv->child_count,
+ MD5_DIGEST_LEN, gf_afr_mt_uint8_t);
+ sh_priv->loops[i]->write_needed = GF_CALLOC (priv->child_count,
+ sizeof (*sh_priv->loops[i]->write_needed),
+ gf_afr_mt_char);
}
sh_diff_loop_driver (frame, this);
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index 5115a7306ee..30e1708cc1f 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -98,7 +98,7 @@ afr_sh_print_pending_matrix (int32_t *pending_matrix[], xlator_t *this)
int i, j;
/* 10 digits per entry + 1 space + '[' and ']' */
- buf = MALLOC (priv->child_count * 11 + 8);
+ buf = GF_MALLOC (priv->child_count * 11 + 8, gf_afr_mt_char);
for (i = 0; i < priv->child_count; i++) {
ptr = buf;
@@ -111,7 +111,7 @@ afr_sh_print_pending_matrix (int32_t *pending_matrix[], xlator_t *this)
"pending_matrix: %s", buf);
}
- FREE (buf);
+ GF_FREE (buf);
}
@@ -129,7 +129,8 @@ afr_sh_build_pending_matrix (afr_private_t *priv,
unsigned char *ignorant_subvols = NULL;
- ignorant_subvols = CALLOC (sizeof (*ignorant_subvols), child_count);
+ ignorant_subvols = GF_CALLOC (sizeof (*ignorant_subvols), child_count,
+ gf_afr_mt_char);
/* start clean */
for (i = 0; i < child_count; i++) {
@@ -177,7 +178,7 @@ afr_sh_build_pending_matrix (afr_private_t *priv,
}
}
- FREE (ignorant_subvols);
+ GF_FREE (ignorant_subvols);
}
@@ -479,8 +480,9 @@ afr_sh_mark_sources (afr_self_heal_t *sh, int child_count,
/* stores the 'characters' (innocent, fool, wise) of the nodes */
afr_node_character *
- characters = CALLOC (sizeof (afr_node_character),
- child_count);
+ characters = GF_CALLOC (sizeof (afr_node_character),
+ child_count,
+ gf_afr_mt_afr_node_character) ;
/* start clean */
for (i = 0; i < child_count; i++) {
@@ -543,7 +545,7 @@ afr_sh_mark_sources (afr_self_heal_t *sh, int child_count,
}
out:
- FREE (characters);
+ GF_FREE (characters);
return nsources;
}
@@ -612,7 +614,8 @@ afr_sh_delta_to_xattr (afr_private_t *priv,
continue;
for (j = 0; j < child_count; j++) {
- pending = CALLOC (sizeof (int32_t), 3);
+ pending = GF_CALLOC (sizeof (int32_t), 3,
+ gf_afr_mt_int32_t);
/* 3 = data+metadata+entry */
k = afr_index_for_transaction_type (type);
@@ -882,7 +885,7 @@ sh_destroy_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (parent_loc) {
loc_wipe (parent_loc);
- FREE (parent_loc);
+ GF_FREE (parent_loc);
}
call_count = afr_frame_return (frame);
@@ -935,7 +938,8 @@ sh_missing_entries_newentry_cbk (call_frame_t *frame, void *cookie,
if (op_ret == 0) {
setattr_frame = copy_frame (frame);
- setattr_frame->local = CALLOC (1, sizeof (afr_local_t));
+ setattr_frame->local = GF_CALLOC (1, sizeof (afr_local_t),
+ gf_afr_mt_afr_local_t);
((afr_local_t *)setattr_frame->local)->call_count = 2;
@@ -950,7 +954,8 @@ sh_missing_entries_newentry_cbk (call_frame_t *frame, void *cookie,
&local->loc, &stbuf, valid);
valid = GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME;
- parent_loc = CALLOC (1, sizeof (*parent_loc));
+ parent_loc = GF_CALLOC (1, sizeof (*parent_loc),
+ gf_afr_mt_loc_t);
afr_build_parent_loc (parent_loc, &local->loc);
STACK_WIND_COOKIE (setattr_frame, sh_destroy_cbk,
@@ -1452,7 +1457,9 @@ afr_local_t *afr_local_copy (afr_local_t *l, xlator_t *this)
sh = &l->self_heal;
- lc = CALLOC (1, sizeof (afr_local_t));
+ lc = GF_CALLOC (1, sizeof (afr_local_t),
+ gf_afr_mt_afr_local_t);
+
shc = &lc->self_heal;
shc->unwind = sh->unwind;
@@ -1567,23 +1574,35 @@ afr_self_heal (call_frame_t *frame, xlator_t *this)
sh->completion_cbk = afr_self_heal_completion_cbk;
- sh->buf = CALLOC (priv->child_count, sizeof (struct stat));
- sh->child_errno = CALLOC (priv->child_count, sizeof (int));
- sh->success = CALLOC (priv->child_count, sizeof (int));
- sh->xattr = CALLOC (priv->child_count, sizeof (dict_t *));
- sh->sources = CALLOC (priv->child_count, sizeof (*sh->sources));
- sh->locked_nodes = CALLOC (priv->child_count, sizeof (*sh->locked_nodes));
+ sh->buf = GF_CALLOC (priv->child_count, sizeof (struct stat),
+ gf_afr_mt_stat);
+ sh->child_errno = GF_CALLOC (priv->child_count, sizeof (int),
+ gf_afr_mt_int);
+ sh->success = GF_CALLOC (priv->child_count, sizeof (int),
+ gf_afr_mt_int);
+ sh->xattr = GF_CALLOC (priv->child_count, sizeof (dict_t *),
+ gf_afr_mt_dict_t);
+ sh->sources = GF_CALLOC (sizeof (*sh->sources), priv->child_count,
+ gf_afr_mt_int);
+ sh->locked_nodes = GF_CALLOC (sizeof (*sh->locked_nodes),
+ priv->child_count,
+ gf_afr_mt_int);
+
+ sh->pending_matrix = GF_CALLOC (sizeof (int32_t *), priv->child_count,
+ gf_afr_mt_int32_t);
- sh->pending_matrix = CALLOC (sizeof (int32_t *), priv->child_count);
for (i = 0; i < priv->child_count; i++) {
- sh->pending_matrix[i] = CALLOC (sizeof (int32_t),
- priv->child_count);
+ sh->pending_matrix[i] = GF_CALLOC (sizeof (int32_t),
+ priv->child_count,
+ gf_afr_mt_int32_t);
}
- sh->delta_matrix = CALLOC (sizeof (int32_t *), priv->child_count);
+ sh->delta_matrix = GF_CALLOC (sizeof (int32_t *), priv->child_count,
+ gf_afr_mt_int32_t);
for (i = 0; i < priv->child_count; i++) {
- sh->delta_matrix[i] = CALLOC (sizeof (int32_t),
- priv->child_count);
+ sh->delta_matrix[i] = GF_CALLOC (sizeof (int32_t),
+ priv->child_count,
+ gf_afr_mt_int32_t);
}
if (local->success_count && local->enoent_count) {
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
index 2d74ed1e98d..e29c1deff4b 100644
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
@@ -387,7 +387,8 @@ afr_sh_data_erase_pending (call_frame_t *frame, xlator_t *this)
afr_sh_pending_to_delta (priv, sh->xattr, sh->delta_matrix, sh->success,
priv->child_count, AFR_DATA_TRANSACTION);
- erase_xattr = CALLOC (sizeof (*erase_xattr), priv->child_count);
+ erase_xattr = GF_CALLOC (sizeof (*erase_xattr), priv->child_count,
+ gf_afr_mt_dict_t);
for (i = 0; i < priv->child_count; i++) {
if (sh->xattr[i]) {
@@ -425,7 +426,7 @@ afr_sh_data_erase_pending (call_frame_t *frame, xlator_t *this)
dict_unref (erase_xattr[i]);
}
}
- FREE (erase_xattr);
+ GF_FREE (erase_xattr);
return 0;
}
@@ -766,13 +767,16 @@ afr_self_heal_get_source (xlator_t *this, afr_local_t *local, dict_t **xattr)
sh = &local->self_heal;
priv = this->private;
- sh->pending_matrix = CALLOC (sizeof (int32_t *), priv->child_count);
+ sh->pending_matrix = GF_CALLOC (sizeof (int32_t *), priv->child_count,
+ gf_afr_mt_int32_t);
for (i = 0; i < priv->child_count; i++) {
- sh->pending_matrix[i] = CALLOC (sizeof (int32_t),
- priv->child_count);
+ sh->pending_matrix[i] = GF_CALLOC (sizeof (int32_t),
+ priv->child_count,
+ gf_afr_mt_int32_t);
}
- sh->sources = CALLOC (priv->child_count, sizeof (*sh->sources));
+ sh->sources = GF_CALLOC (priv->child_count, sizeof (*sh->sources),
+ gf_afr_mt_int32_t);
afr_sh_build_pending_matrix (priv, sh->pending_matrix, xattr,
priv->child_count, AFR_DATA_TRANSACTION);
diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c
index 4336c7a61f8..dcb8d0d71df 100644
--- a/xlators/cluster/afr/src/afr-self-heal-entry.c
+++ b/xlators/cluster/afr/src/afr-self-heal-entry.c
@@ -236,7 +236,8 @@ afr_sh_entry_erase_pending (call_frame_t *frame, xlator_t *this)
afr_sh_pending_to_delta (priv, sh->xattr, sh->delta_matrix, sh->success,
priv->child_count, AFR_ENTRY_TRANSACTION);
- erase_xattr = CALLOC (sizeof (*erase_xattr), priv->child_count);
+ erase_xattr = GF_CALLOC (sizeof (*erase_xattr), priv->child_count,
+ gf_afr_mt_dict_t);
for (i = 0; i < priv->child_count; i++) {
if (sh->xattr[i]) {
@@ -277,7 +278,7 @@ afr_sh_entry_erase_pending (call_frame_t *frame, xlator_t *this)
dict_unref (erase_xattr[i]);
}
}
- FREE (erase_xattr);
+ GF_FREE (erase_xattr);
if (need_unwind)
afr_sh_entry_finish (frame, this);
@@ -373,10 +374,10 @@ build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name)
}
if (strcmp (parent->path, "/") == 0)
- ret = asprintf ((char **)&child->path, "/%s", name);
+ ret = gf_asprintf ((char **)&child->path, "/%s", name);
else
- ret = asprintf ((char **)&child->path, "%s/%s", parent->path,
- name);
+ ret = gf_asprintf ((char **)&child->path, "%s/%s",
+ parent->path, name);
if (-1 == ret) {
gf_log (this->name, GF_LOG_ERROR,
@@ -532,7 +533,7 @@ afr_sh_entry_expunge_rename_cbk (call_frame_t *expunge_frame, void *cookie,
static void
init_trash_loc (loc_t *trash_loc, inode_table_t *table)
{
- trash_loc->path = strdup ("/" GF_REPLICATE_TRASH_DIR);
+ trash_loc->path = gf_strdup ("/" GF_REPLICATE_TRASH_DIR);
trash_loc->name = GF_REPLICATE_TRASH_DIR;
trash_loc->parent = table->root;
trash_loc->inode = inode_new (table);
@@ -545,7 +546,8 @@ make_trash_path (const char *path)
char *c = NULL;
char *tp = NULL;
- tp = CALLOC (strlen ("/" GF_REPLICATE_TRASH_DIR) + strlen (path) + 1, sizeof (char));
+ tp = GF_CALLOC (strlen ("/" GF_REPLICATE_TRASH_DIR) + strlen (path) + 1,
+ sizeof (char), gf_afr_mt_char);
strcpy (tp, GF_REPLICATE_TRASH_DIR);
strcat (tp, path);
@@ -1263,7 +1265,7 @@ afr_sh_entry_impunge_parent_setattr_cbk (call_frame_t *setattr_frame,
loc_wipe (parent_loc);
- FREE (parent_loc);
+ GF_FREE (parent_loc);
AFR_STACK_DESTROY (setattr_frame);
return 0;
@@ -1336,7 +1338,7 @@ afr_sh_entry_impunge_newfile_cbk (call_frame_t *impunge_frame, void *cookie,
parentbuf = impunge_sh->parentbuf;
setattr_frame = copy_frame (impunge_frame);
- parent_loc = CALLOC (1, sizeof (*parent_loc));
+ parent_loc = GF_CALLOC (1, sizeof (*parent_loc), gf_afr_mt_loc_t);
afr_build_parent_loc (parent_loc, &impunge_local->loc);
STACK_WIND_COOKIE (impunge_frame, afr_sh_entry_impunge_xattrop_cbk,
@@ -1668,7 +1670,7 @@ afr_sh_entry_impunge_readlink_cbk (call_frame_t *impunge_frame, void *cookie,
goto out;
}
- impunge_sh->linkname = strdup (linkname);
+ impunge_sh->linkname = gf_strdup (linkname);
afr_sh_entry_impunge_readlink_sink (impunge_frame, this, child_index);
diff --git a/xlators/cluster/afr/src/afr-self-heal-metadata.c b/xlators/cluster/afr/src/afr-self-heal-metadata.c
index 57408cfa68c..4501595b7a4 100644
--- a/xlators/cluster/afr/src/afr-self-heal-metadata.c
+++ b/xlators/cluster/afr/src/afr-self-heal-metadata.c
@@ -225,7 +225,8 @@ afr_sh_metadata_erase_pending (call_frame_t *frame, xlator_t *this)
sh->success, priv->child_count,
AFR_METADATA_TRANSACTION);
- erase_xattr = CALLOC (sizeof (*erase_xattr), priv->child_count);
+ erase_xattr = GF_CALLOC (sizeof (*erase_xattr), priv->child_count,
+ gf_afr_mt_dict_t);
for (i = 0; i < priv->child_count; i++) {
if (sh->xattr[i]) {
@@ -272,7 +273,7 @@ afr_sh_metadata_erase_pending (call_frame_t *frame, xlator_t *this)
dict_unref (erase_xattr[i]);
}
}
- FREE (erase_xattr);
+ GF_FREE (erase_xattr);
return 0;
}
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index 4e266113119..5072869448e 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -239,7 +239,7 @@ afr_local_sh_cleanup (afr_local_t *local, xlator_t *this)
priv = this->private;
if (sh->buf)
- FREE (sh->buf);
+ GF_FREE (sh->buf);
if (sh->xattr) {
for (i = 0; i < priv->child_count; i++) {
@@ -248,34 +248,34 @@ afr_local_sh_cleanup (afr_local_t *local, xlator_t *this)
sh->xattr[i] = NULL;
}
}
- FREE (sh->xattr);
+ GF_FREE (sh->xattr);
}
if (sh->child_errno)
- FREE (sh->child_errno);
+ GF_FREE (sh->child_errno);
if (sh->pending_matrix) {
for (i = 0; i < priv->child_count; i++) {
- FREE (sh->pending_matrix[i]);
+ GF_FREE (sh->pending_matrix[i]);
}
- FREE (sh->pending_matrix);
+ GF_FREE (sh->pending_matrix);
}
if (sh->delta_matrix) {
for (i = 0; i < priv->child_count; i++) {
- FREE (sh->delta_matrix[i]);
+ GF_FREE (sh->delta_matrix[i]);
}
- FREE (sh->delta_matrix);
+ GF_FREE (sh->delta_matrix);
}
if (sh->sources)
- FREE (sh->sources);
+ GF_FREE (sh->sources);
if (sh->success)
- FREE (sh->success);
+ GF_FREE (sh->success);
if (sh->locked_nodes)
- FREE (sh->locked_nodes);
+ GF_FREE (sh->locked_nodes);
if (sh->healing_fd && !sh->healing_fd_opened) {
fd_unref (sh->healing_fd);
@@ -283,7 +283,7 @@ afr_local_sh_cleanup (afr_local_t *local, xlator_t *this)
}
if (sh->linkname)
- FREE (sh->linkname);
+ GF_FREE ((char *)sh->linkname);
loc_wipe (&sh->parent_loc);
}
@@ -299,17 +299,17 @@ afr_local_transaction_cleanup (afr_local_t *local, xlator_t *this)
for (i = 0; i < priv->child_count; i++) {
if (local->pending && local->pending[i])
- FREE (local->pending[i]);
+ GF_FREE (local->pending[i]);
}
- FREE (local->pending);
+ GF_FREE (local->pending);
- FREE (local->transaction.locked_nodes);
- FREE (local->transaction.child_errno);
- FREE (local->child_errno);
+ GF_FREE (local->transaction.locked_nodes);
+ GF_FREE (local->transaction.child_errno);
+ GF_FREE (local->child_errno);
- FREE (local->transaction.basename);
- FREE (local->transaction.new_basename);
+ GF_FREE (local->transaction.basename);
+ GF_FREE (local->transaction.new_basename);
loc_wipe (&local->transaction.parent_loc);
loc_wipe (&local->transaction.new_parent_loc);
@@ -340,7 +340,7 @@ afr_local_cleanup (afr_local_t *local, xlator_t *this)
if (local->xattr_req)
dict_unref (local->xattr_req);
- FREE (local->child_up);
+ GF_FREE (local->child_up);
{ /* lookup */
if (local->cont.lookup.xattrs) {
@@ -350,7 +350,7 @@ afr_local_cleanup (afr_local_t *local, xlator_t *this)
local->cont.lookup.xattrs[i] = NULL;
}
}
- FREE (local->cont.lookup.xattrs);
+ GF_FREE (local->cont.lookup.xattrs);
local->cont.lookup.xattrs = NULL;
}
@@ -365,19 +365,19 @@ afr_local_cleanup (afr_local_t *local, xlator_t *this)
{ /* getxattr */
if (local->cont.getxattr.name)
- FREE (local->cont.getxattr.name);
+ GF_FREE (local->cont.getxattr.name);
}
{ /* lk */
if (local->cont.lk.locked_nodes)
- FREE (local->cont.lk.locked_nodes);
+ GF_FREE (local->cont.lk.locked_nodes);
}
{ /* checksum */
if (local->cont.checksum.file_checksum)
- FREE (local->cont.checksum.file_checksum);
+ GF_FREE (local->cont.checksum.file_checksum);
if (local->cont.checksum.dir_checksum)
- FREE (local->cont.checksum.dir_checksum);
+ GF_FREE (local->cont.checksum.dir_checksum);
}
{ /* create */
@@ -386,7 +386,7 @@ afr_local_cleanup (afr_local_t *local, xlator_t *this)
}
{ /* writev */
- FREE (local->cont.writev.vector);
+ GF_FREE (local->cont.writev.vector);
}
{ /* setxattr */
@@ -395,16 +395,16 @@ afr_local_cleanup (afr_local_t *local, xlator_t *this)
}
{ /* removexattr */
- FREE (local->cont.removexattr.name);
+ GF_FREE (local->cont.removexattr.name);
}
{ /* symlink */
- FREE (local->cont.symlink.linkpath);
+ GF_FREE (local->cont.symlink.linkpath);
}
{ /* opendir */
if (local->cont.opendir.checksum)
- FREE (local->cont.opendir.checksum);
+ GF_FREE (local->cont.opendir.checksum);
}
}
@@ -1005,8 +1005,9 @@ afr_lookup (call_frame_t *frame, xlator_t *this,
local->child_up = memdup (priv->child_up, priv->child_count);
- local->cont.lookup.xattrs = CALLOC (priv->child_count,
- sizeof (*local->cont.lookup.xattr));
+ local->cont.lookup.xattrs = GF_CALLOC (priv->child_count,
+ sizeof (*local->cont.lookup.xattr),
+ gf_afr_mt_dict_t);
local->call_count = afr_up_children_count (priv->child_count,
local->child_up);
@@ -1083,7 +1084,8 @@ afr_fd_ctx_set (xlator_t *this, fd_t *fd)
if (ret == 0)
goto unlock;
- fd_ctx = CALLOC (1, sizeof (afr_fd_ctx_t));
+ fd_ctx = GF_CALLOC (1, sizeof (afr_fd_ctx_t),
+ gf_afr_mt_afr_fd_ctx_t);
if (!fd_ctx) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -1092,8 +1094,9 @@ afr_fd_ctx_set (xlator_t *this, fd_t *fd)
goto unlock;
}
- fd_ctx->pre_op_done = CALLOC (sizeof (*fd_ctx->pre_op_done),
- priv->child_count);
+ fd_ctx->pre_op_done = GF_CALLOC (sizeof (*fd_ctx->pre_op_done),
+ priv->child_count,
+ gf_afr_mt_char);
if (!fd_ctx->pre_op_done) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -1101,8 +1104,9 @@ afr_fd_ctx_set (xlator_t *this, fd_t *fd)
goto unlock;
}
- fd_ctx->opened_on = CALLOC (sizeof (*fd_ctx->opened_on),
- priv->child_count);
+ fd_ctx->opened_on = GF_CALLOC (sizeof (*fd_ctx->opened_on),
+ priv->child_count,
+ gf_afr_mt_char);
if (!fd_ctx->opened_on) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -1110,8 +1114,10 @@ afr_fd_ctx_set (xlator_t *this, fd_t *fd)
goto unlock;
}
- fd_ctx->child_failed = CALLOC (sizeof (*fd_ctx->child_failed),
- priv->child_count);
+ fd_ctx->child_failed = GF_CALLOC (
+ sizeof (*fd_ctx->child_failed),
+ priv->child_count,
+ gf_afr_mt_char);
if (!fd_ctx->child_failed) {
gf_log (this->name, GF_LOG_ERROR,
@@ -1436,15 +1442,15 @@ afr_cleanup_fd_ctx (xlator_t *this, fd_t *fd)
if (fd_ctx) {
if (fd_ctx->child_failed)
- FREE (fd_ctx->child_failed);
+ GF_FREE (fd_ctx->child_failed);
if (fd_ctx->pre_op_done)
- FREE (fd_ctx->pre_op_done);
+ GF_FREE (fd_ctx->pre_op_done);
if (fd_ctx->opened_on)
- FREE (fd_ctx->opened_on);
+ GF_FREE (fd_ctx->opened_on);
- FREE (fd_ctx);
+ GF_FREE (fd_ctx);
}
out:
@@ -2176,11 +2182,13 @@ afr_checksum_cbk (call_frame_t *frame, void *cookie,
if (op_ret == 0 && (local->op_ret != 0)) {
local->op_ret = 0;
- local->cont.checksum.file_checksum = MALLOC (NAME_MAX);
+ local->cont.checksum.file_checksum =
+ GF_MALLOC (NAME_MAX, gf_afr_mt_char);
memcpy (local->cont.checksum.file_checksum, file_checksum,
NAME_MAX);
- local->cont.checksum.dir_checksum = MALLOC (NAME_MAX);
+ local->cont.checksum.dir_checksum =
+ GF_MALLOC (NAME_MAX, gf_afr_mt_char);
memcpy (local->cont.checksum.dir_checksum, dir_checksum,
NAME_MAX);
@@ -2486,8 +2494,9 @@ afr_lk (call_frame_t *frame, xlator_t *this,
frame->local = local;
- local->cont.lk.locked_nodes = CALLOC (priv->child_count,
- sizeof (*local->cont.lk.locked_nodes));
+ local->cont.lk.locked_nodes = GF_CALLOC (priv->child_count,
+ sizeof (*local->cont.lk.locked_nodes),
+ gf_afr_mt_char);
if (!local->cont.lk.locked_nodes) {
gf_log (this->name, GF_LOG_ERROR, "Out of memory");
@@ -2676,6 +2685,25 @@ notify (xlator_t *this, int32_t event,
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_afr_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log(this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
static const char *favorite_child_warning_str = "You have specified subvolume '%s' "
"as the 'favorite child'. This means that if a discrepancy in the content "
@@ -2718,6 +2746,7 @@ init (xlator_t *this)
int read_ret = -1;
int dict_ret = -1;
+
if (!this->children) {
gf_log (this->name, GF_LOG_ERROR,
"replicate translator needs more than one "
@@ -2730,6 +2759,7 @@ init (xlator_t *this)
"Volume is dangling.");
}
+
ALLOC_OR_GOTO (this->private, afr_private_t, out);
priv = this->private;
@@ -2775,7 +2805,7 @@ init (xlator_t *this)
dict_ret = dict_get_str (this->options, "data-self-heal-algorithm",
&algo);
if (dict_ret == 0) {
- priv->data_self_heal_algorithm = strdup (algo);
+ priv->data_self_heal_algorithm = gf_strdup (algo);
}
@@ -2946,7 +2976,8 @@ init (xlator_t *this)
LOCK_INIT (&priv->lock);
LOCK_INIT (&priv->read_child_lock);
- priv->child_up = CALLOC (sizeof (unsigned char), child_count);
+ priv->child_up = GF_CALLOC (sizeof (unsigned char), child_count,
+ gf_afr_mt_char);
if (!priv->child_up) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory.");
@@ -2954,7 +2985,8 @@ init (xlator_t *this)
goto out;
}
- priv->children = CALLOC (sizeof (xlator_t *), child_count);
+ priv->children = GF_CALLOC (sizeof (xlator_t *), child_count,
+ gf_afr_mt_xlator_t);
if (!priv->children) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory.");
@@ -2962,7 +2994,9 @@ init (xlator_t *this)
goto out;
}
- priv->pending_key = CALLOC (sizeof (*priv->pending_key), child_count);
+ priv->pending_key = GF_CALLOC (sizeof (*priv->pending_key),
+ child_count,
+ gf_afr_mt_char);
if (!priv->pending_key) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory.");
@@ -2975,8 +3009,9 @@ init (xlator_t *this)
while (i < child_count) {
priv->children[i] = trav->xlator;
- ret = asprintf (&priv->pending_key[i], "%s.%s", AFR_XATTR_PREFIX,
- trav->xlator->name);
+ ret = gf_asprintf (&priv->pending_key[i], "%s.%s",
+ AFR_XATTR_PREFIX,
+ trav->xlator->name);
if (-1 == ret) {
gf_log (this->name, GF_LOG_ERROR,
"asprintf failed to set pending key");
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index a6ca1c2be9d..0f7d8bbae13 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -29,6 +29,7 @@
#include "scheduler.h"
#include "call-stub.h"
#include "compat-errno.h"
+#include "afr-mem-types.h"
#define AFR_XATTR_PREFIX "trusted.afr"
@@ -302,7 +303,7 @@ typedef struct _afr_local {
} readlink;
struct {
- const char *name;
+ char *name;
int last_tried;
} getxattr;
@@ -401,7 +402,7 @@ typedef struct _afr_local {
} setxattr;
struct {
- const char *name;
+ char *name;
} removexattr;
/* dir write */
@@ -509,8 +510,8 @@ typedef struct _afr_local {
unsigned char *locked_nodes;
int lock_count;
- const char *basename;
- const char *new_basename;
+ char *basename;
+ char *new_basename;
loc_t parent_loc;
loc_t new_parent_loc;
@@ -559,7 +560,8 @@ typedef struct {
/* try alloc and if it fails, goto label */
#define ALLOC_OR_GOTO(var, type, label) do { \
- var = CALLOC (sizeof (type), 1); \
+ var = GF_CALLOC (sizeof (type), 1, \
+ gf_afr_mt_##type); \
if (!var) { \
gf_log (this->name, GF_LOG_ERROR, \
"out of memory :("); \
@@ -643,7 +645,7 @@ afr_cleanup_fd_ctx (xlator_t *this, fd_t *fd);
frame->local = NULL; \
STACK_UNWIND_STRICT (fop, frame, params); \
afr_local_cleanup (__local, __this); \
- free (__local); \
+ GF_FREE (__local); \
} while (0);
#define AFR_STACK_DESTROY(frame) \
@@ -655,7 +657,7 @@ afr_cleanup_fd_ctx (xlator_t *this, fd_t *fd);
frame->local = NULL; \
STACK_DESTROY (frame->root); \
afr_local_cleanup (__local, __this); \
- free (__local); \
+ GF_FREE (__local); \
} while (0);
/* allocate and return a string that is the basename of argument */
@@ -664,9 +666,9 @@ AFR_BASENAME (const char *str)
{
char *__tmp_str = NULL;
char *__basename_str = NULL;
- __tmp_str = strdup (str);
- __basename_str = strdup (basename (__tmp_str));
- FREE (__tmp_str);
+ __tmp_str = gf_strdup (str);
+ __basename_str = gf_strdup (basename (__tmp_str));
+ GF_FREE (__tmp_str);
return __basename_str;
}
@@ -674,8 +676,9 @@ AFR_BASENAME (const char *str)
static inline int
AFR_LOCAL_INIT (afr_local_t *local, afr_private_t *priv)
{
- local->child_up = CALLOC (sizeof (*local->child_up),
- priv->child_count);
+ local->child_up = GF_CALLOC (sizeof (*local->child_up),
+ priv->child_count,
+ gf_afr_mt_char);
if (!local->child_up) {
return -ENOMEM;
}
@@ -731,31 +734,36 @@ afr_transaction_local_init (afr_local_t *local, afr_private_t *priv)
local->first_up_child = afr_first_up_child (priv);
- local->child_errno = CALLOC (sizeof (*local->child_errno),
- priv->child_count);
+ local->child_errno = GF_CALLOC (sizeof (*local->child_errno),
+ priv->child_count,
+ gf_afr_mt_int32_t);
if (!local->child_errno) {
return -ENOMEM;
}
- local->pending = CALLOC (sizeof (*local->pending),
- priv->child_count);
+ local->pending = GF_CALLOC (sizeof (*local->pending),
+ priv->child_count,
+ gf_afr_mt_int32_t);
if (!local->pending) {
return -ENOMEM;
}
for (i = 0; i < priv->child_count; i++) {
- local->pending[i] = CALLOC (sizeof (*local->pending[i]),
- 3); /* data + metadata + entry */
+ local->pending[i] = GF_CALLOC (sizeof (*local->pending[i]),
+ 3, /* data + metadata + entry */
+ gf_afr_mt_int32_t);
if (!local->pending[i])
return -ENOMEM;
}
- local->transaction.locked_nodes = CALLOC (sizeof (*local->transaction.locked_nodes),
- priv->child_count);
+ local->transaction.locked_nodes = GF_CALLOC (sizeof (*local->transaction.locked_nodes),
+ priv->child_count,
+ gf_afr_mt_char);
- local->transaction.child_errno = CALLOC (sizeof (*local->transaction.child_errno),
- priv->child_count);
+ local->transaction.child_errno = GF_CALLOC (sizeof (*local->transaction.child_errno),
+ priv->child_count,
+ gf_afr_mt_int32_t);
return 0;
}
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 1ee723d9cfb..a8a15920518 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -3557,7 +3557,8 @@ dht_rmdir_is_subvol_empty (call_frame_t *frame, xlator_t *this,
goto err;
}
- lookup_local = CALLOC (sizeof (*local), 1);
+ lookup_local = GF_CALLOC (sizeof (*local), 1,
+ gf_dht_mt_dht_local_t);
if (!lookup_local) {
gf_log (this->name, GF_LOG_ERROR,
"Out of Memory");
@@ -4235,7 +4236,8 @@ dht_init_subvolumes (xlator_t *this, dht_conf_t *conf)
for (subvols = this->children; subvols; subvols = subvols->next)
cnt++;
- conf->subvolumes = CALLOC (cnt, sizeof (xlator_t *));
+ conf->subvolumes = GF_CALLOC (cnt, sizeof (xlator_t *),
+ gf_dht_mt_xlator_t);
if (!conf->subvolumes) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -4247,7 +4249,8 @@ dht_init_subvolumes (xlator_t *this, dht_conf_t *conf)
for (subvols = this->children; subvols; subvols = subvols->next)
conf->subvolumes[cnt++] = subvols->xlator;
- conf->subvolume_status = CALLOC (cnt, sizeof (char));
+ conf->subvolume_status = GF_CALLOC (cnt, sizeof (char),
+ gf_dht_mt_char);
if (!conf->subvolume_status) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index e6e1e8181c6..b51f308ec9c 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -22,6 +22,8 @@
#include "config.h"
#endif
+#include "dht-mem-types.h"
+
#ifndef _DHT_H
#define _DHT_H
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
index f2e1a182a72..767be38b41c 100644
--- a/xlators/cluster/dht/src/dht-helper.c
+++ b/xlators/cluster/dht/src/dht-helper.c
@@ -148,7 +148,7 @@ dht_local_wipe (xlator_t *this, dht_local_t *local)
local->selfheal.layout = NULL;
}
- FREE (local);
+ GF_FREE (local);
}
@@ -158,7 +158,8 @@ dht_local_init (call_frame_t *frame)
dht_local_t *local = NULL;
/* TODO: use mem-pool */
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_dht_mt_dht_local_t);
if (!local)
return NULL;
@@ -408,9 +409,9 @@ dht_build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name)
}
if (strcmp (parent->path, "/") == 0)
- asprintf ((char **)&child->path, "/%s", name);
+ gf_asprintf ((char **)&child->path, "/%s", name);
else
- asprintf ((char **)&child->path, "%s/%s", parent->path, name);
+ gf_asprintf ((char **)&child->path, "%s/%s", parent->path, name);
if (!child->path) {
gf_log (this->name, GF_LOG_ERROR,
diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c
index 86d3c4410fc..41b6896743f 100644
--- a/xlators/cluster/dht/src/dht-layout.c
+++ b/xlators/cluster/dht/src/dht-layout.c
@@ -44,7 +44,8 @@ dht_layout_new (xlator_t *this, int cnt)
conf = this->private;
- layout = CALLOC (1, layout_size (cnt));
+ layout = GF_CALLOC (1, layout_size (cnt),
+ gf_dht_mt_dht_layout_t);
if (!layout) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -131,7 +132,7 @@ dht_layout_unref (xlator_t *this, dht_layout_t *layout)
UNLOCK (&conf->layout_lock);
if (!ref)
- FREE (layout);
+ GF_FREE (layout);
}
@@ -218,8 +219,9 @@ dht_layouts_init (xlator_t *this, dht_conf_t *conf)
int ret = -1;
- conf->file_layouts = CALLOC (conf->subvolume_cnt,
- sizeof (dht_layout_t *));
+ conf->file_layouts = GF_CALLOC (conf->subvolume_cnt,
+ sizeof (dht_layout_t *),
+ gf_dht_mt_dht_layout_t);
if (!conf->file_layouts) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -253,7 +255,8 @@ dht_disk_layout_extract (xlator_t *this, dht_layout_t *layout,
int ret = -1;
int32_t *disk_layout = NULL;
- disk_layout = CALLOC (5, sizeof (int));
+ disk_layout = GF_CALLOC (5, sizeof (int),
+ gf_dht_mt_int32_t);
if (!disk_layout) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
diff --git a/xlators/cluster/dht/src/dht-mem-types.h b/xlators/cluster/dht/src/dht-mem-types.h
new file mode 100644
index 00000000000..4a7a8bd811a
--- /dev/null
+++ b/xlators/cluster/dht/src/dht-mem-types.h
@@ -0,0 +1,42 @@
+
+/*
+ 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 __DHT_MEM_TYPES_H__
+#define __DHT_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_dht_mem_types_ {
+ gf_dht_mt_dht_du_t = gf_common_mt_end + 1,
+ gf_dht_mt_dht_conf_t,
+ gf_dht_mt_char,
+ gf_dht_mt_int32_t,
+ gf_dht_mt_dht_local_t,
+ gf_dht_mt_xlator_t,
+ gf_dht_mt_dht_layout_t,
+ gf_switch_mt_dht_conf_t,
+ gf_switch_mt_dht_du_t,
+ gf_switch_mt_switch_sched_array,
+ gf_switch_mt_switch_struct,
+ gf_dht_mt_end
+};
+#endif
+
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
index 8a4d3a6f58c..8380535f69b 100644
--- a/xlators/cluster/dht/src/dht-selfheal.c
+++ b/xlators/cluster/dht/src/dht-selfheal.c
@@ -138,7 +138,7 @@ err:
dict_destroy (xattr);
if (disk_layout)
- FREE (disk_layout);
+ GF_FREE (disk_layout);
dht_selfheal_dir_xattr_cbk (frame, subvol, frame->this,
-1, ENOMEM);
diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c
index d7f187457fc..ca5601510bf 100644
--- a/xlators/cluster/dht/src/dht.c
+++ b/xlators/cluster/dht/src/dht.c
@@ -212,26 +212,45 @@ fini (xlator_t *this)
if (conf) {
if (conf->file_layouts) {
for (i = 0; i < conf->subvolume_cnt; i++) {
- FREE (conf->file_layouts[i]);
+ GF_FREE (conf->file_layouts[i]);
}
- FREE (conf->file_layouts);
+ GF_FREE (conf->file_layouts);
}
if (conf->default_dir_layout)
- FREE (conf->default_dir_layout);
+ GF_FREE (conf->default_dir_layout);
if (conf->subvolumes)
- FREE (conf->subvolumes);
+ GF_FREE (conf->subvolumes);
if (conf->subvolume_status)
- FREE (conf->subvolume_status);
+ GF_FREE (conf->subvolume_status);
- FREE (conf);
+ GF_FREE (conf);
}
return;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_dht_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)
{
@@ -241,6 +260,7 @@ init (xlator_t *this)
int i = 0;
uint32_t temp_free_disk = 0;
+
if (!this->children) {
gf_log (this->name, GF_LOG_CRITICAL,
"Distribute needs more than one subvolume");
@@ -252,7 +272,7 @@ init (xlator_t *this)
"dangling volume. check volfile");
}
- conf = CALLOC (1, sizeof (*conf));
+ conf = GF_CALLOC (1, sizeof (*conf), gf_dht_mt_dht_conf_t);
if (!conf) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -302,7 +322,8 @@ init (xlator_t *this)
goto err;
}
- conf->du_stats = CALLOC (conf->subvolume_cnt, sizeof (dht_du_t));
+ conf->du_stats = GF_CALLOC (conf->subvolume_cnt, sizeof (dht_du_t),
+ gf_dht_mt_dht_du_t);
if (!conf->du_stats) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -322,24 +343,24 @@ err:
if (conf) {
if (conf->file_layouts) {
for (i = 0; i < conf->subvolume_cnt; i++) {
- FREE (conf->file_layouts[i]);
+ GF_FREE (conf->file_layouts[i]);
}
- FREE (conf->file_layouts);
+ GF_FREE (conf->file_layouts);
}
if (conf->default_dir_layout)
- FREE (conf->default_dir_layout);
+ GF_FREE (conf->default_dir_layout);
if (conf->subvolumes)
- FREE (conf->subvolumes);
+ GF_FREE (conf->subvolumes);
if (conf->subvolume_status)
- FREE (conf->subvolume_status);
+ GF_FREE (conf->subvolume_status);
if (conf->du_stats)
- FREE (conf->du_stats);
+ GF_FREE (conf->du_stats);
- FREE (conf);
+ GF_FREE (conf);
}
return -1;
diff --git a/xlators/cluster/dht/src/nufa.c b/xlators/cluster/dht/src/nufa.c
index edb900f763a..0d8241f41a5 100644
--- a/xlators/cluster/dht/src/nufa.c
+++ b/xlators/cluster/dht/src/nufa.c
@@ -513,21 +513,21 @@ fini (xlator_t *this)
if (conf) {
if (conf->file_layouts) {
for (i = 0; i < conf->subvolume_cnt; i++) {
- FREE (conf->file_layouts[i]);
+ GF_FREE (conf->file_layouts[i]);
}
- FREE (conf->file_layouts);
+ GF_FREE (conf->file_layouts);
}
if (conf->default_dir_layout)
- FREE (conf->default_dir_layout);
+ GF_FREE (conf->default_dir_layout);
if (conf->subvolumes)
- FREE (conf->subvolumes);
+ GF_FREE (conf->subvolumes);
if (conf->subvolume_status)
- FREE (conf->subvolume_status);
+ GF_FREE (conf->subvolume_status);
- FREE (conf);
+ GF_FREE (conf);
}
return;
@@ -557,7 +557,8 @@ init (xlator_t *this)
"dangling volume. check volfile");
}
- conf = CALLOC (1, sizeof (*conf));
+ conf = GF_CALLOC (1, sizeof (*conf),
+ gf_dht_mt_dht_conf_t);
if (!conf) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -642,7 +643,8 @@ init (xlator_t *this)
}
}
- conf->du_stats = CALLOC (conf->subvolume_cnt, sizeof (dht_du_t));
+ conf->du_stats = GF_CALLOC (conf->subvolume_cnt, sizeof (dht_du_t),
+ gf_dht_mt_dht_du_t);
if (!conf->du_stats) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -657,24 +659,24 @@ err:
if (conf) {
if (conf->file_layouts) {
for (i = 0; i < conf->subvolume_cnt; i++) {
- FREE (conf->file_layouts[i]);
+ GF_FREE (conf->file_layouts[i]);
}
- FREE (conf->file_layouts);
+ GF_FREE (conf->file_layouts);
}
if (conf->default_dir_layout)
- FREE (conf->default_dir_layout);
+ GF_FREE (conf->default_dir_layout);
if (conf->subvolumes)
- FREE (conf->subvolumes);
+ GF_FREE (conf->subvolumes);
if (conf->subvolume_status)
- FREE (conf->subvolume_status);
+ GF_FREE (conf->subvolume_status);
if (conf->du_stats)
- FREE (conf->du_stats);
+ GF_FREE (conf->du_stats);
- FREE (conf);
+ GF_FREE (conf);
}
return -1;
diff --git a/xlators/cluster/dht/src/switch.c b/xlators/cluster/dht/src/switch.c
index 680ce8d6f06..f6fb6b652b3 100644
--- a/xlators/cluster/dht/src/switch.c
+++ b/xlators/cluster/dht/src/switch.c
@@ -24,6 +24,7 @@
#endif
#include "dht-common.c"
+#include "dht-mem-types.h"
#include <sys/time.h>
#include <stdlib.h>
@@ -82,7 +83,7 @@ get_switch_matching_subvol (const char *path, dht_conf_t *conf,
return hashed_subvol;
trav = cond;
- pathname = strdup (path);
+ pathname = gf_strdup (path);
while (trav) {
if (fnmatch (trav->path_pattern,
pathname, FNM_NOESCAPE) == 0) {
@@ -96,7 +97,7 @@ get_switch_matching_subvol (const char *path, dht_conf_t *conf,
}
trav = trav->next;
}
- free (pathname);
+ GF_FREE (pathname);
return hashed_subvol;
}
@@ -620,29 +621,29 @@ fini (xlator_t *this)
conf->private = NULL;
while (trav) {
if (trav->array)
- FREE (trav->array);
+ GF_FREE (trav->array);
prev = trav;
trav = trav->next;
- FREE (prev);
+ GF_FREE (prev);
}
if (conf->file_layouts) {
for (i = 0; i < conf->subvolume_cnt; i++) {
- FREE (conf->file_layouts[i]);
+ GF_FREE (conf->file_layouts[i]);
}
- FREE (conf->file_layouts);
+ GF_FREE (conf->file_layouts);
}
if (conf->default_dir_layout)
- FREE (conf->default_dir_layout);
+ GF_FREE (conf->default_dir_layout);
if (conf->subvolumes)
- FREE (conf->subvolumes);
+ GF_FREE (conf->subvolumes);
if (conf->subvolume_status)
- FREE (conf->subvolume_status);
+ GF_FREE (conf->subvolume_status);
- FREE (conf);
+ GF_FREE (conf);
}
return;
@@ -679,8 +680,9 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
trav_xl = trav_xl->next;
}
child_count = index;
- switch_buf_array = CALLOC ((index + 1),
- sizeof (struct switch_sched_array));
+ switch_buf_array = GF_CALLOC ((index + 1),
+ sizeof (struct switch_sched_array),
+ gf_switch_mt_switch_sched_array);
if (!switch_buf_array)
goto err;
@@ -698,11 +700,12 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
/* Get the pattern for considering switch case.
"option block-size *avi:10MB" etc */
- option_string = strdup (pattern_str);
+ option_string = gf_strdup (pattern_str);
switch_str = strtok_r (option_string, ";", &tmp_str);
while (switch_str) {
- dup_str = strdup (switch_str);
- switch_opt = CALLOC (1, sizeof (struct switch_struct));
+ dup_str = gf_strdup (switch_str);
+ switch_opt = GF_CALLOC (1, sizeof (struct switch_struct),
+ gf_switch_mt_switch_struct);
if (!switch_opt)
goto err;
@@ -714,12 +717,12 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
"for all the unconfigured child nodes,"
" hence neglecting current option");
switch_str = strtok_r (NULL, ";", &tmp_str);
- free (dup_str);
+ GF_FREE (dup_str);
continue;
}
memcpy (switch_opt->path_pattern, pattern, strlen (pattern));
if (childs) {
- dup_childs = strdup (childs);
+ dup_childs = gf_strdup (childs);
child = strtok_r (dup_childs, ",", &tmp);
while (child) {
if (gf_switch_valid_child (this, child)) {
@@ -734,11 +737,12 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
goto err;
}
}
- free (dup_childs);
+ GF_FREE (dup_childs);
child = strtok_r (childs, ",", &tmp1);
switch_opt->num_child = idx;
- switch_opt->array = CALLOC (1, (idx *
- sizeof (struct switch_sched_array)));
+ switch_opt->array = GF_CALLOC (1, (idx *
+ sizeof (struct switch_sched_array)),
+ gf_switch_mt_switch_sched_array);
if (!switch_opt->array)
goto err;
idx = 0;
@@ -772,7 +776,7 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
"option in unify volume. Exiting");
goto err;
}
- free (dup_str);
+ GF_FREE (dup_str);
/* Link it to the main structure */
if (switch_buf) {
@@ -803,7 +807,8 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
"No nodes left for pattern '*'. Exiting");
goto err;
}
- switch_opt = CALLOC (1, sizeof (struct switch_struct));
+ switch_opt = GF_CALLOC (1, sizeof (struct switch_struct),
+ gf_switch_mt_switch_struct);
if (!switch_opt)
goto err;
@@ -811,7 +816,9 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
memcpy (switch_opt->path_pattern, "*", 2);
switch_opt->num_child = flag;
switch_opt->array =
- CALLOC (1, flag * sizeof (struct switch_sched_array));
+ GF_CALLOC (1,
+ flag * sizeof (struct switch_sched_array),
+ gf_switch_mt_switch_sched_array);
if (!switch_opt->array)
goto err;
flag = 0;
@@ -846,14 +853,14 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
err:
if (switch_buf) {
if (switch_buf_array)
- FREE (switch_buf_array);
+ GF_FREE (switch_buf_array);
trav = switch_buf;
while (trav) {
if (trav->array)
- FREE (trav->array);
+ GF_FREE (trav->array);
switch_opt = trav;
trav = trav->next;
- FREE (switch_opt);
+ GF_FREE (switch_opt);
}
}
return -1;
@@ -881,7 +888,7 @@ init (xlator_t *this)
"dangling volume. check volfile");
}
- conf = CALLOC (1, sizeof (*conf));
+ conf = GF_CALLOC (1, sizeof (*conf), gf_switch_mt_dht_conf_t);
if (!conf) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -947,7 +954,8 @@ init (xlator_t *this)
conf->gen = 1;
- conf->du_stats = CALLOC (conf->subvolume_cnt, sizeof (dht_du_t));
+ conf->du_stats = GF_CALLOC (conf->subvolume_cnt, sizeof (dht_du_t),
+ gf_switch_mt_dht_du_t);
if (!conf->du_stats) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -962,24 +970,24 @@ err:
if (conf) {
if (conf->file_layouts) {
for (i = 0; i < conf->subvolume_cnt; i++) {
- FREE (conf->file_layouts[i]);
+ GF_FREE (conf->file_layouts[i]);
}
- FREE (conf->file_layouts);
+ GF_FREE (conf->file_layouts);
}
if (conf->default_dir_layout)
- FREE (conf->default_dir_layout);
+ GF_FREE (conf->default_dir_layout);
if (conf->subvolumes)
- FREE (conf->subvolumes);
+ GF_FREE (conf->subvolumes);
if (conf->subvolume_status)
- FREE (conf->subvolume_status);
+ GF_FREE (conf->subvolume_status);
if (conf->du_stats)
- FREE (conf->du_stats);
+ GF_FREE (conf->du_stats);
- FREE (conf);
+ GF_FREE (conf);
}
return -1;
diff --git a/xlators/cluster/ha/src/ha-helpers.c b/xlators/cluster/ha/src/ha-helpers.c
index c23c5676ce0..fb6593101a4 100644
--- a/xlators/cluster/ha/src/ha-helpers.c
+++ b/xlators/cluster/ha/src/ha-helpers.c
@@ -49,12 +49,14 @@ int ha_alloc_init_fd (call_frame_t *frame, fd_t *fd)
goto out;
}
hafdp = (hafd_t *)(long)tmp_hafdp;
- local = frame->local = CALLOC (1, sizeof (*local));
+ local = frame->local = GF_CALLOC (1, sizeof (*local),
+ gf_ha_mt_ha_local_t);
if (local == NULL) {
ret = -ENOMEM;
goto out;
}
- local->state = CALLOC (1, child_count);
+ local->state = GF_CALLOC (1, child_count,
+ gf_ha_mt_child_count);
if (local->state == NULL) {
ret = -ENOMEM;
goto out;
@@ -147,7 +149,7 @@ int ha_handle_cbk (call_frame_t *frame, void *cookie, int op_ret, int op_errno)
}
if (local->fd) {
- FREE (local->state);
+ GF_FREE (local->state);
local->state = NULL;
fd_unref (local->fd);
@@ -170,7 +172,8 @@ int ha_alloc_init_inode (call_frame_t *frame, inode_t *inode)
local = frame->local;
if (local == NULL) {
- local = frame->local = CALLOC (1, sizeof (*local));
+ local = frame->local = GF_CALLOC (1, sizeof (*local),
+ gf_ha_mt_ha_local_t);
if (local == NULL) {
ret = -ENOMEM;
goto out;
diff --git a/xlators/cluster/ha/src/ha-mem-types.h b/xlators/cluster/ha/src/ha-mem-types.h
new file mode 100644
index 00000000000..bdbfcb52b54
--- /dev/null
+++ b/xlators/cluster/ha/src/ha-mem-types.h
@@ -0,0 +1,37 @@
+
+/*
+ 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 __HA_MEM_TYPES_H__
+#define __HA_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_ha_mem_types_ {
+ gf_ha_mt_ha_local_t = gf_common_mt_end + 1,
+ gf_ha_mt_hafd_t,
+ gf_ha_mt_char,
+ gf_ha_mt_child_count,
+ gf_ha_mt_xlator_t,
+ gf_ha_mt_ha_private_t,
+ gf_ha_mt_end
+};
+#endif
+
diff --git a/xlators/cluster/ha/src/ha.c b/xlators/cluster/ha/src/ha.c
index 3317ae7832e..10e64e56252 100644
--- a/xlators/cluster/ha/src/ha.c
+++ b/xlators/cluster/ha/src/ha.c
@@ -50,7 +50,7 @@ ha_local_wipe (ha_local_t *local)
}
if (local->state) {
- FREE (local->state);
+ GF_FREE (local->state);
local->state = NULL;
}
@@ -71,7 +71,7 @@ ha_local_wipe (ha_local_t *local)
local->inode = NULL;
}
- FREE (local);
+ GF_FREE (local);
return;
}
@@ -84,7 +84,7 @@ ha_forget (xlator_t *this,
char *state = NULL;
if (!inode_ctx_del (inode, this, &stateino)) {
state = ((char *)(long)stateino);
- FREE (state);
+ GF_FREE (state);
}
return 0;
@@ -193,7 +193,8 @@ ha_lookup (call_frame_t *frame,
child_count = pvt->child_count;
children = pvt->children;
- frame->local = local = CALLOC (1, sizeof (*local));
+ frame->local = local = GF_CALLOC (1, sizeof (*local),
+ gf_ha_mt_ha_local_t);
if (!local) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
op_errno = ENOMEM;
@@ -205,7 +206,7 @@ ha_lookup (call_frame_t *frame,
ret = inode_ctx_get (loc->inode, this, NULL);
if (ret) {
- state = CALLOC (1, child_count);
+ state = GF_CALLOC (1, child_count, gf_ha_mt_child_count);
if (state == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
op_errno = ENOMEM;
@@ -645,7 +646,7 @@ ha_mknod_lookup_cbk (call_frame_t *frame,
if (cnt == 0) {
call_stub_t *stub = local->stub;
- FREE (local->state);
+ GF_FREE (local->state);
STACK_UNWIND (frame,
local->op_ret,
local->op_errno,
@@ -715,7 +716,7 @@ ha_mknod_cbk (call_frame_t *frame,
if (cnt == 0 || i == child_count) {
call_stub_t *stub = local->stub;
- FREE (local->state);
+ GF_FREE (local->state);
stub = local->stub;
STACK_UNWIND (frame, local->op_ret, local->op_errno,
local->stub->args.mknod.loc.inode, &local->buf,
@@ -770,7 +771,8 @@ ha_mknod (call_frame_t *frame,
pvt = this->private;
child_count = pvt->child_count;
- frame->local = local = CALLOC (1, sizeof (*local));
+ frame->local = local = GF_CALLOC (1, sizeof (*local),
+ gf_ha_mt_ha_local_t);
if (!local) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
op_errno = ENOMEM;
@@ -786,7 +788,7 @@ ha_mknod (call_frame_t *frame,
local->op_ret = -1;
local->op_errno = ENOTCONN;
- local->state = CALLOC (1, child_count);
+ local->state = GF_CALLOC (1, child_count, gf_ha_mt_char);
if (!local->state) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
op_errno = ENOMEM;
@@ -796,7 +798,7 @@ ha_mknod (call_frame_t *frame,
memcpy (local->state, pvt->state, child_count);
local->active = -1;
- stateino = CALLOC (1, child_count);
+ stateino = GF_CALLOC (1, child_count, gf_ha_mt_char);
if (!stateino) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
op_errno = ENOMEM;
@@ -875,7 +877,7 @@ ha_mkdir_lookup_cbk (call_frame_t *frame,
if (cnt == 0) {
call_stub_t *stub = local->stub;
- FREE (local->state);
+ GF_FREE (local->state);
STACK_UNWIND (frame,
local->op_ret,
local->op_errno,
@@ -940,7 +942,7 @@ ha_mkdir_cbk (call_frame_t *frame,
if (cnt == 0 || i == child_count) {
call_stub_t *stub = local->stub;
- FREE (local->state);
+ GF_FREE (local->state);
stub = local->stub;
STACK_UNWIND (frame, local->op_ret, local->op_errno,
local->stub->args.mkdir.loc.inode, &local->buf,
@@ -993,7 +995,8 @@ ha_mkdir (call_frame_t *frame,
pvt = this->private;
child_count = pvt->child_count;
- frame->local = local = CALLOC (1, sizeof (*local));
+ frame->local = local = GF_CALLOC (1, sizeof (*local),
+ gf_ha_mt_ha_local_t);
if (!frame->local) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
op_errno = ENOMEM;
@@ -1009,7 +1012,7 @@ ha_mkdir (call_frame_t *frame,
local->op_ret = -1;
local->op_errno = ENOTCONN;
- local->state = CALLOC (1, child_count);
+ local->state = GF_CALLOC (1, child_count, gf_ha_mt_char);
if (!local->state) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
op_errno = ENOMEM;
@@ -1019,7 +1022,7 @@ ha_mkdir (call_frame_t *frame,
memcpy (local->state, pvt->state, child_count);
local->active = -1;
- stateino = CALLOC (1, child_count);
+ stateino = GF_CALLOC (1, child_count, gf_ha_mt_char);
if (!stateino) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
op_errno = ENOMEM;
@@ -1204,7 +1207,7 @@ ha_symlink_lookup_cbk (call_frame_t *frame,
if (cnt == 0) {
call_stub_t *stub = local->stub;
- FREE (local->state);
+ GF_FREE (local->state);
STACK_UNWIND (frame,
local->op_ret,
local->op_errno,
@@ -1268,7 +1271,7 @@ ha_symlink_cbk (call_frame_t *frame,
if (cnt == 0 || i == child_count) {
call_stub_t *stub = local->stub;
- FREE (local->state);
+ GF_FREE (local->state);
stub = local->stub;
STACK_UNWIND (frame, local->op_ret, local->op_errno,
local->stub->args.symlink.loc.inode, &local->buf,
@@ -1321,7 +1324,8 @@ ha_symlink (call_frame_t *frame,
pvt = this->private;
child_count = pvt->child_count;
- frame->local = local = CALLOC (1, sizeof (*local));
+ frame->local = local = GF_CALLOC (1, sizeof (*local),
+ gf_ha_mt_ha_local_t);
if (!local) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -1337,7 +1341,7 @@ ha_symlink (call_frame_t *frame,
local->op_ret = -1;
local->op_errno = ENOTCONN;
- local->state = CALLOC (1, child_count);
+ local->state = GF_CALLOC (1, child_count, gf_ha_mt_char);
if (!local->state) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -1347,7 +1351,7 @@ ha_symlink (call_frame_t *frame,
memcpy (local->state, pvt->state, child_count);
local->active = -1;
- stateino = CALLOC (1, child_count);
+ stateino = GF_CALLOC (1, child_count, gf_ha_mt_char);
if (!stateino) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -1481,7 +1485,7 @@ ha_link_lookup_cbk (call_frame_t *frame,
if (cnt == 0) {
call_stub_t *stub = local->stub;
- FREE (local->state);
+ GF_FREE (local->state);
STACK_UNWIND (frame,
local->op_ret,
local->op_errno,
@@ -1545,7 +1549,7 @@ ha_link_cbk (call_frame_t *frame,
if (cnt == 0 || i == child_count) {
call_stub_t *stub = local->stub;
- FREE (local->state);
+ GF_FREE (local->state);
stub = local->stub;
STACK_UNWIND (frame, local->op_ret, local->op_errno,
local->stub->args.link.oldloc.inode, &local->buf,
@@ -1613,7 +1617,8 @@ ha_link (call_frame_t *frame,
pvt = this->private;
child_count = pvt->child_count;
- frame->local = local = CALLOC (1, sizeof (*local));
+ frame->local = local = GF_CALLOC (1, sizeof (*local),
+ gf_ha_mt_ha_local_t);
if (!frame->local) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
op_errno = ENOMEM;
@@ -1629,7 +1634,7 @@ ha_link (call_frame_t *frame,
local->op_ret = -1;
local->op_errno = ENOTCONN;
- local->state = CALLOC (1, child_count);
+ local->state = GF_CALLOC (1, child_count, gf_ha_mt_char);
if (!local->state) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
op_errno = ENOMEM;
@@ -1741,7 +1746,7 @@ ha_create_cbk (call_frame_t *frame,
stub->args.create.fd,
stub->args.create.loc.inode, &local->buf,
&local->preparent, &local->postparent);
- FREE (state);
+ GF_FREE (state);
call_stub_destroy (stub);
return 0;
}
@@ -1785,7 +1790,8 @@ ha_create (call_frame_t *frame,
children = pvt->children;
if (local == NULL) {
- local = frame->local = CALLOC (1, sizeof (*local));
+ frame->local = local = GF_CALLOC (1, sizeof (*local),
+ gf_ha_mt_ha_local_t);
if (!local) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -1799,7 +1805,7 @@ ha_create (call_frame_t *frame,
goto err;
}
- local->state = CALLOC (1, child_count);
+ local->state = GF_CALLOC (1, child_count, gf_ha_mt_char);
if (!local->state) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -1819,28 +1825,28 @@ ha_create (call_frame_t *frame,
}
}
/* FIXME handle active -1 */
- stateino = CALLOC (1, child_count);
+ stateino = GF_CALLOC (1, child_count, gf_ha_mt_char);
if (!stateino) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
goto err;
}
- hafdp = CALLOC (1, sizeof (*hafdp));
+ hafdp = GF_CALLOC (1, sizeof (*hafdp), gf_ha_mt_hafd_t);
if (!hafdp) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
goto err;
}
- hafdp->fdstate = CALLOC (1, child_count);
+ hafdp->fdstate = GF_CALLOC (1, child_count, gf_ha_mt_char);
if (!hafdp->fdstate) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
goto err;
}
- hafdp->path = strdup(loc->path);
+ hafdp->path = gf_strdup(loc->path);
if (!hafdp->path) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -1865,20 +1871,20 @@ err:
ha_local_wipe (local);
if (stateino) {
- FREE (stateino);
+ GF_FREE (stateino);
stateino = NULL;
}
if (hafdp) {
if (hafdp->fdstate) {
- FREE (hafdp->fdstate);
+ GF_FREE (hafdp->fdstate);
}
if (hafdp->path) {
- FREE (hafdp->path);
+ GF_FREE (hafdp->path);
}
- FREE (hafdp);
+ GF_FREE (hafdp);
}
return 0;
@@ -1955,7 +1961,8 @@ ha_open (call_frame_t *frame,
child_count = pvt->child_count;
- local = frame->local = CALLOC (1, sizeof (*local));
+ frame->local = local = GF_CALLOC (1, sizeof (*local),
+ gf_ha_mt_ha_local_t);
if (!local) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -1966,21 +1973,21 @@ ha_open (call_frame_t *frame,
local->op_errno = ENOTCONN;
local->fd = fd;
- hafdp = CALLOC (1, sizeof (*hafdp));
+ hafdp = GF_CALLOC (1, sizeof (*hafdp), gf_ha_mt_hafd_t);
if (!hafdp) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
goto err;
}
- hafdp->fdstate = CALLOC (1, child_count);
+ hafdp->fdstate = GF_CALLOC (1, child_count, gf_ha_mt_char);
if (!hafdp->fdstate) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
goto err;
}
- hafdp->path = strdup (loc->path);
+ hafdp->path = gf_strdup (loc->path);
if (!hafdp->path) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -2020,16 +2027,16 @@ err:
STACK_UNWIND (frame, -1, op_errno, fd);
if (hafdp) {
if (hafdp->fdstate) {
- FREE (hafdp->fdstate);
+ GF_FREE (hafdp->fdstate);
hafdp->fdstate = NULL;
}
if (hafdp->path) {
- FREE (hafdp->path);
+ GF_FREE (hafdp->path);
hafdp->path = NULL;
}
- FREE (hafdp);
+ GF_FREE (hafdp);
}
ha_local_wipe (local);
@@ -2420,7 +2427,8 @@ ha_opendir (call_frame_t *frame,
children = pvt->children;
child_count = pvt->child_count;
- local = frame->local = CALLOC (1, sizeof (*local));
+ frame->local = local = GF_CALLOC (1, sizeof (*local),
+ gf_ha_mt_ha_local_t);
if (!local) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -2431,21 +2439,21 @@ ha_opendir (call_frame_t *frame,
local->op_errno = ENOTCONN;
local->fd = fd;
- hafdp = CALLOC (1, sizeof (*hafdp));
+ hafdp = GF_CALLOC (1, sizeof (*hafdp), gf_ha_mt_hafd_t);
if (!hafdp) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
goto err;
}
- hafdp->fdstate = CALLOC (1, child_count);
+ hafdp->fdstate = GF_CALLOC (1, child_count, gf_ha_mt_char);
if (!hafdp->fdstate) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
goto err;
}
- hafdp->path = strdup (loc->path);
+ hafdp->path = gf_strdup (loc->path);
if (!hafdp->path) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -2484,16 +2492,16 @@ err:
ha_local_wipe (local);
if (hafdp) {
if (hafdp->fdstate) {
- FREE (hafdp->fdstate);
+ GF_FREE (hafdp->fdstate);
hafdp->fdstate = NULL;
}
if (hafdp->path) {
- FREE (hafdp->path);
+ GF_FREE (hafdp->path);
hafdp->path = NULL;
}
- FREE (hafdp);
+ GF_FREE (hafdp);
}
return 0;
}
@@ -2733,7 +2741,8 @@ ha_statfs (call_frame_t *frame,
/* The normal way of handling failover doesn't work here
* as loc->inode may be null in this case.
*/
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_ha_mt_ha_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -3073,7 +3082,7 @@ ha_lk_setlk_unlck_cbk (call_frame_t *frame,
if (cnt == 0) {
stub = local->stub;
- FREE (local->state);
+ GF_FREE (local->state);
if (stub->args.lk.lock.l_type == F_UNLCK) {
STACK_UNWIND (frame, local->op_ret, local->op_errno, &stub->args.lk.lock);
} else {
@@ -3122,7 +3131,7 @@ ha_lk_setlk_cbk (call_frame_t *frame,
}
if (i == child_count) {
call_stub_t *stub = local->stub;
- FREE (local->state);
+ GF_FREE (local->state);
STACK_UNWIND (frame, 0, op_errno, &stub->args.lk.lock);
call_stub_destroy (stub);
return 0;
@@ -3163,7 +3172,7 @@ ha_lk_setlk_cbk (call_frame_t *frame,
}
return 0;
} else {
- FREE (local->state);
+ GF_FREE (local->state);
call_stub_destroy (local->stub);
STACK_UNWIND (frame,
op_ret,
@@ -3197,7 +3206,7 @@ ha_lk_getlk_cbk (call_frame_t *frame,
prev_frame = cookie;
if (op_ret == 0) {
- FREE (local->state);
+ GF_FREE (local->state);
call_stub_destroy (local->stub);
STACK_UNWIND (frame, 0, 0, lock);
return 0;
@@ -3214,7 +3223,7 @@ ha_lk_getlk_cbk (call_frame_t *frame,
}
if (i == child_count) {
- FREE (local->state);
+ GF_FREE (local->state);
call_stub_destroy (local->stub);
STACK_UNWIND (frame, op_ret, op_errno, lock);
return 0;
@@ -3255,7 +3264,8 @@ ha_lk (call_frame_t *frame,
gf_log (this->name, GF_LOG_ERROR, "fd_ctx_get failed");
if (local == NULL) {
- local = frame->local = CALLOC (1, sizeof (*local));
+ local = frame->local = GF_CALLOC (1, sizeof (*local),
+ gf_ha_mt_ha_local_t);
if (!local) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -3280,7 +3290,7 @@ ha_lk (call_frame_t *frame,
goto err;
}
- local->state = CALLOC (1, child_count);
+ local->state = GF_CALLOC (1, child_count, gf_ha_mt_char);
if (!local->state) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -3636,7 +3646,8 @@ ha_stats (call_frame_t *frame,
int i = 0;
int32_t op_errno = EINVAL;
- local = frame->local = CALLOC (1, sizeof (*local));
+ local = frame->local = GF_CALLOC (1, sizeof (*local),
+ gf_ha_mt_ha_local_t);
if (!local) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -3737,7 +3748,8 @@ ha_getspec (call_frame_t *frame,
int i = 0;
int32_t op_errno = EINVAL;
- local = frame->local = CALLOC (1, sizeof (*local));
+ local = frame->local = GF_CALLOC (1, sizeof (*local),
+ gf_ha_mt_ha_local_t);
if (!local) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -3791,8 +3803,8 @@ ha_closedir (xlator_t *this,
}
hafdp = (hafd_t *)(long)tmp_hafdp;
- FREE (hafdp->fdstate);
- FREE (hafdp->path);
+ GF_FREE (hafdp->fdstate);
+ GF_FREE (hafdp->path);
LOCK_DESTROY (&hafdp->lock);
return 0;
}
@@ -3812,8 +3824,8 @@ ha_close (xlator_t *this,
}
hafdp = (hafd_t *)(long)tmp_hafdp;
- FREE (hafdp->fdstate);
- FREE (hafdp->path);
+ GF_FREE (hafdp->fdstate);
+ GF_FREE (hafdp->path);
LOCK_DESTROY (&hafdp->lock);
return 0;
}
@@ -3884,6 +3896,25 @@ notify (xlator_t *this,
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_ha_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)
{
@@ -3891,6 +3922,7 @@ init (xlator_t *this)
xlator_list_t *trav = NULL;
int count = 0, ret = 0;
+
if (!this->children) {
gf_log (this->name,GF_LOG_ERROR,
"FATAL: ha should have one or more child defined");
@@ -3903,7 +3935,7 @@ init (xlator_t *this)
}
trav = this->children;
- pvt = CALLOC (1, sizeof (ha_private_t));
+ pvt = GF_CALLOC (1, sizeof (ha_private_t), gf_ha_mt_ha_private_t);
ret = dict_get_int32 (this->options, "preferred-subvolume",
&pvt->pref_subvol);
@@ -3918,7 +3950,8 @@ init (xlator_t *this)
}
pvt->child_count = count;
- pvt->children = CALLOC (count, sizeof (xlator_t*));
+ pvt->children = GF_CALLOC (count, sizeof (xlator_t*),
+ gf_ha_mt_xlator_t);
trav = this->children;
count = 0;
@@ -3928,7 +3961,7 @@ init (xlator_t *this)
trav = trav->next;
}
- pvt->state = CALLOC (1, count);
+ pvt->state = GF_CALLOC (1, count, gf_ha_mt_char);
this->private = pvt;
return 0;
}
@@ -3938,7 +3971,7 @@ fini (xlator_t *this)
{
ha_private_t *priv = NULL;
priv = this->private;
- FREE (priv);
+ GF_FREE (priv);
return;
}
diff --git a/xlators/cluster/ha/src/ha.h b/xlators/cluster/ha/src/ha.h
index e5c9541dbe3..5e06b7e0201 100644
--- a/xlators/cluster/ha/src/ha.h
+++ b/xlators/cluster/ha/src/ha.h
@@ -20,6 +20,8 @@
#ifndef __HA_H_
#define __HA_H_
+#include "ha-mem-types.h"
+
typedef struct {
call_stub_t *stub;
int32_t op_ret, op_errno;
diff --git a/xlators/cluster/map/src/map-helper.c b/xlators/cluster/map/src/map-helper.c
index b4c8ad52590..ad01b2102dc 100644
--- a/xlators/cluster/map/src/map-helper.c
+++ b/xlators/cluster/map/src/map-helper.c
@@ -256,14 +256,15 @@ verify_dir_and_assign_subvol (xlator_t *this,
goto out;
}
- tmp_map = CALLOC (1, sizeof (struct map_pattern));
+ tmp_map = GF_CALLOC (1, sizeof (struct map_pattern),
+ gf_map_mt_map_pattern);
tmp_map->xl = trav->xlator;
tmp_map->dir_len = strlen (directory);
/* make sure that the top level directory starts
* with '/' and ends without '/'
*/
- tmp_map->directory = strdup (directory);
+ tmp_map->directory = gf_strdup (directory);
if (directory[tmp_map->dir_len - 1] == '/') {
tmp_map->dir_len--;
}
diff --git a/xlators/cluster/map/src/map-mem-types.h b/xlators/cluster/map/src/map-mem-types.h
new file mode 100644
index 00000000000..f41ab420ace
--- /dev/null
+++ b/xlators/cluster/map/src/map-mem-types.h
@@ -0,0 +1,35 @@
+
+/*
+ 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 __MAP_MEM_TYPES_H__
+#define __MAP_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_map_mem_types_ {
+ gf_map_mt_map_private_t = gf_common_mt_end + 1,
+ gf_map_mt_map_local_t,
+ gf_map_mt_map_xlator_array,
+ gf_map_mt_map_pattern,
+ gf_map_mt_end
+};
+#endif
+
diff --git a/xlators/cluster/map/src/map.c b/xlators/cluster/map/src/map.c
index 09d22b5d690..1383d83c1c9 100644
--- a/xlators/cluster/map/src/map.c
+++ b/xlators/cluster/map/src/map.c
@@ -2147,7 +2147,8 @@ map_lookup (call_frame_t *frame,
return 0;
root_inode:
- local = CALLOC (1, sizeof (map_local_t));
+ local = GF_CALLOC (1, sizeof (map_local_t),
+ gf_map_mt_map_local_t);
frame->local = local;
local->call_count = priv->child_count;
@@ -2199,7 +2200,8 @@ map_statfs (call_frame_t *frame,
return 0;
root_inode:
- local = CALLOC (1, sizeof (map_local_t));
+ local = GF_CALLOC (1, sizeof (map_local_t),
+ gf_map_mt_map_local_t);
priv = this->private;
frame->local = local;
@@ -2251,7 +2253,8 @@ map_opendir (call_frame_t *frame,
return 0;
root_inode:
- local = CALLOC (1, sizeof (map_local_t));
+ local = GF_CALLOC (1, sizeof (map_local_t),
+ gf_map_mt_map_local_t);
priv = this->private;
frame->local = local;
@@ -2310,7 +2313,8 @@ map_do_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
root_inode:
/* readdir on '/' */
- local = CALLOC (1, sizeof (map_local_t));
+ local = GF_CALLOC (1, sizeof (map_local_t),
+ gf_map_mt_map_local_t);
if (!local) {
gf_log (this->name, GF_LOG_ERROR,
"memory allocation failed :(");
@@ -2372,21 +2376,40 @@ fini (xlator_t *this)
if (priv) {
if (priv->xlarray)
- FREE (priv->xlarray);
+ GF_FREE (priv->xlarray);
trav_map = priv->map;
while (trav_map) {
tmp_map = trav_map;
trav_map = trav_map->next;
- FREE (tmp_map);
+ GF_FREE (tmp_map);
}
- FREE(priv);
+ GF_FREE(priv);
}
return;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_map_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)
{
@@ -2403,6 +2426,7 @@ init (xlator_t *this)
char *subvol_str = NULL;
char *map_xl = NULL;
+
if (!this->children) {
gf_log (this->name,GF_LOG_ERROR,
"FATAL: map should have one or more child defined");
@@ -2414,7 +2438,8 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- priv = CALLOC (1, sizeof (map_private_t));
+ priv = GF_CALLOC (1, sizeof (map_private_t),
+ gf_map_mt_map_private_t);
this->private = priv;
/* allocate xlator array */
@@ -2423,7 +2448,8 @@ init (xlator_t *this)
count++;
trav = trav->next;
}
- priv->xlarray = CALLOC (1, sizeof (struct map_xlator_array) * count);
+ priv->xlarray = GF_CALLOC (1, sizeof (struct map_xlator_array) * count,
+ gf_map_mt_map_xlator_array);
priv->child_count = count;
/* build xlator array */
@@ -2443,7 +2469,7 @@ init (xlator_t *this)
}
map_pair_str = strtok_r (pattern_string, ";", &tmp_str);
while (map_pair_str) {
- dup_map_pair = strdup (map_pair_str);
+ dup_map_pair = gf_strdup (map_pair_str);
dir_str = strtok_r (dup_map_pair, ":", &tmp_str1);
if (!dir_str) {
gf_log (this->name, GF_LOG_ERROR,
@@ -2465,7 +2491,7 @@ init (xlator_t *this)
goto err;
}
- FREE (dup_map_pair);
+ GF_FREE (dup_map_pair);
map_pair_str = strtok_r (NULL, ";", &tmp_str);
}
diff --git a/xlators/cluster/map/src/map.h b/xlators/cluster/map/src/map.h
index b423642cc32..eb549eb06e7 100644
--- a/xlators/cluster/map/src/map.h
+++ b/xlators/cluster/map/src/map.h
@@ -21,6 +21,7 @@
#define __MAP_H__
#include "xlator.h"
+#include "map-mem-types.h"
struct map_pattern {
struct map_pattern *next;
diff --git a/xlators/cluster/stripe/src/stripe-mem-types.h b/xlators/cluster/stripe/src/stripe-mem-types.h
new file mode 100644
index 00000000000..06667107d65
--- /dev/null
+++ b/xlators/cluster/stripe/src/stripe-mem-types.h
@@ -0,0 +1,40 @@
+
+/*
+ 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 __STRIPE_MEM_TYPES_H__
+#define __STRIPE_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_stripe_mem_types_ {
+ gf_stripe_mt_stripe_local_t = gf_common_mt_end + 1,
+ gf_stripe_mt_iovec,
+ gf_stripe_mt_readv_replies,
+ gf_stripe_mt_stripe_fd_ctx_t,
+ gf_stripe_mt_char,
+ gf_stripe_mt_int8_t,
+ gf_stripe_mt_xlator_t,
+ gf_stripe_mt_stripe_private_t,
+ gf_stripe_mt_stripe_options,
+ gf_stripe_mt_end
+};
+#endif
+
diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c
index eb5a154d5ee..52473c03b5c 100644
--- a/xlators/cluster/stripe/src/stripe.c
+++ b/xlators/cluster/stripe/src/stripe.c
@@ -53,7 +53,7 @@ stripe_get_matching_bs (const char *path, struct stripe_options *opts,
uint64_t block_size = 0;
block_size = default_bs;
- pathname = strdup (path);
+ pathname = gf_strdup (path);
trav = opts;
while (trav) {
@@ -63,7 +63,8 @@ stripe_get_matching_bs (const char *path, struct stripe_options *opts,
}
trav = trav->next;
}
- free (pathname);
+
+ GF_FREE (pathname);
return block_size;
}
@@ -572,7 +573,8 @@ stripe_entry_self_heal (call_frame_t *frame, xlator_t *this,
if (!rframe) {
goto out;
}
- rlocal = CALLOC (1, sizeof (stripe_local_t));
+ rlocal = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!rlocal) {
goto out;
}
@@ -709,7 +711,8 @@ stripe_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
trav = this->children;
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -760,7 +763,8 @@ stripe_stat (call_frame_t *frame, xlator_t *this, loc_t *loc)
}
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -844,7 +848,8 @@ stripe_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc)
priv = this->private;
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -893,7 +898,8 @@ stripe_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset)
}
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1008,7 +1014,8 @@ stripe_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
}
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1049,7 +1056,8 @@ stripe_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
trav = this->children;
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1215,7 +1223,8 @@ stripe_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
}
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1270,7 +1279,8 @@ stripe_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc)
}
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1356,7 +1366,8 @@ stripe_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc)
}
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1617,7 +1628,8 @@ stripe_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
}
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1684,7 +1696,8 @@ stripe_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode)
}
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1735,7 +1748,8 @@ stripe_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc)
}
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -1936,7 +1950,8 @@ stripe_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* */
if (local->op_ret >= 0) {
- fctx = CALLOC (1, sizeof (stripe_fd_ctx_t));
+ fctx = GF_CALLOC (1, sizeof (stripe_fd_ctx_t),
+ gf_stripe_mt_stripe_fd_ctx_t);
if (fctx) {
fctx->stripe_size = local->stripe_size;
fctx->stripe_count = priv->child_count;
@@ -2035,7 +2050,8 @@ stripe_create (call_frame_t *frame, xlator_t *this, loc_t *loc,
}
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -2107,8 +2123,8 @@ stripe_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (local->op_ret == -1) {
if (local->fctx) {
if (!local->fctx->static_array)
- FREE (local->fctx->xl_array);
- FREE (local->fctx);
+ GF_FREE (local->fctx->xl_array);
+ GF_FREE (local->fctx);
}
} else {
fd_ctx_set (local->fd, this,
@@ -2167,7 +2183,8 @@ stripe_open_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
if (!local->fctx) {
- local->fctx = CALLOC (1, sizeof (stripe_fd_ctx_t));
+ local->fctx = GF_CALLOC (1, sizeof (stripe_fd_ctx_t),
+ gf_stripe_mt_stripe_fd_ctx_t);
if (!local->fctx) {
local->op_errno = ENOMEM;
local->op_ret = -1;
@@ -2209,9 +2226,11 @@ stripe_open_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local->op_errno = EIO;
goto unlock;
}
- local->fctx->xl_array =
- CALLOC (local->fctx->stripe_count,
- sizeof (xlator_t *));
+
+ local->fctx->xl_array =
+ GF_CALLOC (local->fctx->stripe_count,
+ sizeof (xlator_t *),
+ gf_stripe_mt_xlator_t);
}
if (local->fctx->stripe_count != data_to_int32 (data)) {
gf_log (this->name, GF_LOG_ERROR,
@@ -2326,7 +2345,8 @@ stripe_open (call_frame_t *frame, xlator_t *this, loc_t *loc,
}
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -2354,7 +2374,8 @@ stripe_open (call_frame_t *frame, xlator_t *this, loc_t *loc,
trav = trav->next;
}
} else {
- local->fctx = CALLOC (1, sizeof (stripe_fd_ctx_t));
+ local->fctx = GF_CALLOC (1, sizeof (stripe_fd_ctx_t),
+ gf_stripe_mt_stripe_fd_ctx_t);
if (!local->fctx) {
op_errno = ENOMEM;
goto err;
@@ -2448,7 +2469,8 @@ stripe_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd)
}
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -2537,7 +2559,8 @@ stripe_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
priv = this->private;
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -2582,7 +2605,8 @@ stripe_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
goto err;
}
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -2624,7 +2648,8 @@ stripe_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags)
trav = this->children;
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -2668,7 +2693,8 @@ stripe_fstat (call_frame_t *frame,
trav = this->children;
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -2710,7 +2736,8 @@ stripe_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
trav = this->children;
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -2752,7 +2779,8 @@ stripe_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags)
trav = this->children;
/* Initialization */
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -2802,7 +2830,8 @@ stripe_readv_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
op_ret = 0;
/* Keep extra space for filling in '\0's */
- vec = CALLOC ((local->count * 2), sizeof (struct iovec));
+ vec = GF_CALLOC ((local->count * 2), sizeof (struct iovec),
+ gf_stripe_mt_iovec);
if (!vec) {
op_ret = -1;
goto done;
@@ -2932,7 +2961,8 @@ stripe_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (need_to_check_proper_size)
goto check_size;
- final_vec = CALLOC (mlocal->count, sizeof (struct iovec));
+ final_vec = GF_CALLOC (mlocal->count, sizeof (struct iovec),
+ gf_stripe_mt_iovec);
if (!final_vec) {
op_ret = -1;
@@ -2964,7 +2994,8 @@ stripe_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
iobref_unref (tmp_iobref);
if (final_vec)
- FREE (final_vec);
+ GF_FREE (final_vec);
+ }
goto out;
@@ -2977,7 +3008,7 @@ stripe_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
(fctx->xl_array[index])->fops->fstat,
mlocal->fd);
}
- }
+
out:
STACK_DESTROY (frame->root);
return 0;
@@ -3027,8 +3058,9 @@ stripe_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
rounded_start = floor (offset, stripe_size);
rounded_end = roof (offset+size, stripe_size);
num_stripe = rounded_end/stripe_size - rounded_start/stripe_size;
-
- local = CALLOC (1, sizeof (stripe_local_t));
+
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -3036,7 +3068,8 @@ stripe_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
frame->local = local;
/* This is where all the vectors should be copied. */
- local->replies = CALLOC (num_stripe, sizeof (struct readv_replies));
+ local->replies = GF_CALLOC (num_stripe, sizeof (struct readv_replies),
+ gf_stripe_mt_readv_replies);
if (!local->replies) {
op_errno = ENOMEM;
goto err;
@@ -3051,7 +3084,8 @@ stripe_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
for (index = off_index; index < (num_stripe + off_index); index++) {
rframe = copy_frame (frame);
- rlocal = CALLOC (1, sizeof (stripe_local_t));
+ rlocal = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!rlocal) {
op_errno = ENOMEM;
goto err;
@@ -3173,7 +3207,8 @@ stripe_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
}
remaining_size = total_size;
- local = CALLOC (1, sizeof (stripe_local_t));
+ local = GF_CALLOC (1, sizeof (stripe_local_t),
+ gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
@@ -3198,7 +3233,8 @@ stripe_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
tmp_count = iov_subset (vector, count, offset_offset,
offset_offset + fill_size, NULL);
- tmp_vec = CALLOC (tmp_count, sizeof (struct iovec));
+ tmp_vec = GF_CALLOC (tmp_count, sizeof (struct iovec),
+ gf_stripe_mt_iovec);
if (!tmp_vec) {
op_errno = ENOMEM;
goto err;
@@ -3213,7 +3249,7 @@ stripe_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
STACK_WIND(frame, stripe_writev_cbk, fctx->xl_array[idx],
fctx->xl_array[idx]->fops->writev, fd, tmp_vec,
tmp_count, offset + offset_offset, iobref);
- FREE (tmp_vec);
+ GF_FREE (tmp_vec);
offset_offset += fill_size;
if (remaining_size == 0)
break;
@@ -3243,10 +3279,10 @@ stripe_release (xlator_t *this, fd_t *fd)
fctx = (stripe_fd_ctx_t *)(long)tmp_fctx;
if (!fctx->static_array)
- FREE (fctx->xl_array);
-
- FREE (fctx);
-
+ GF_FREE (fctx->xl_array);
+
+ GF_FREE (fctx);
+
out:
return 0;
}
@@ -3345,10 +3381,11 @@ set_stripe_block_size (xlator_t *this, stripe_private_t *priv, char *data)
"option block-size *avi:10MB" etc */
stripe_str = strtok_r (data, ",", &tmp_str);
while (stripe_str) {
- dup_str = strdup (stripe_str);
- stripe_opt = CALLOC (1, sizeof (struct stripe_options));
+ dup_str = gf_strdup (stripe_str);
+ stripe_opt = GF_CALLOC (1, sizeof (struct stripe_options),
+ gf_stripe_mt_stripe_options);
if (!stripe_opt) {
- FREE (dup_str);
+ GF_FREE (dup_str);
goto out;
}
@@ -3378,6 +3415,7 @@ set_stripe_block_size (xlator_t *this, stripe_private_t *priv, char *data)
temp_stripeopt->next = stripe_opt;
}
stripe_str = strtok_r (NULL, ",", &tmp_str);
+ GF_FREE (dup_str);
}
ret = 0;
@@ -3385,6 +3423,25 @@ set_stripe_block_size (xlator_t *this, stripe_private_t *priv, char *data)
return ret;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_stripe_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
/**
* init - This function is called when xlator-graph gets initialized.
* The option given in volfiles are parsed here.
@@ -3423,14 +3480,19 @@ init (xlator_t *this)
" please check the volume. exiting");
goto out;
}
- priv = CALLOC (1, sizeof (stripe_private_t));
+
+ priv = GF_CALLOC (1, sizeof (stripe_private_t),
+ gf_stripe_mt_stripe_private_t);
+
if (!priv)
goto out;
- priv->xl_array = CALLOC (count, sizeof (xlator_t *));
+ priv->xl_array = GF_CALLOC (count, sizeof (xlator_t *),
+ gf_stripe_mt_xlator_t);
if (!priv->xl_array)
goto out;
- priv->state = CALLOC (count, sizeof (int8_t));
+ priv->state = GF_CALLOC (count, sizeof (int8_t),
+ gf_stripe_mt_int8_t);
if (!priv->state)
goto out;
@@ -3485,8 +3547,8 @@ init (xlator_t *this)
if (ret) {
if (priv) {
if (priv->xl_array)
- FREE (priv->xl_array);
- FREE (priv);
+ GF_FREE (priv->xl_array);
+ GF_FREE (priv);
}
}
return ret;
@@ -3506,16 +3568,16 @@ fini (xlator_t *this)
priv = this->private;
if (priv) {
if (priv->xl_array)
- FREE (priv->xl_array);
+ GF_FREE (priv->xl_array);
trav = priv->pattern;
while (trav) {
prev = trav;
trav = trav->next;
- FREE (prev);
+ GF_FREE (prev);
}
LOCK_DESTROY (&priv->lock);
- FREE (priv);
+ GF_FREE (priv);
}
return;
diff --git a/xlators/cluster/stripe/src/stripe.h b/xlators/cluster/stripe/src/stripe.h
index 23ee4546d60..8afc6aa9a58 100644
--- a/xlators/cluster/stripe/src/stripe.h
+++ b/xlators/cluster/stripe/src/stripe.h
@@ -32,6 +32,7 @@
#include "common-utils.h"
#include "compat.h"
#include "compat-errno.h"
+#include "stripe-mem-types.h"
#include <fnmatch.h>
#include <signal.h>
diff --git a/xlators/cluster/unify/src/unify-mem-types.h b/xlators/cluster/unify/src/unify-mem-types.h
new file mode 100644
index 00000000000..3b4abc8e9b8
--- /dev/null
+++ b/xlators/cluster/unify/src/unify-mem-types.h
@@ -0,0 +1,41 @@
+
+/*
+ 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 __UNIFY_MEM_TYPES_H__
+#define __UNIFY_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_unify_mem_types_ {
+ gf_unify_mt_char = gf_common_mt_end + 1,
+ gf_unify_mt_int16_t,
+ gf_unify_mt_xlator_t,
+ gf_unify_mt_unify_private_t,
+ gf_unify_mt_xlator_list_t,
+ gf_unify_mt_dir_entry_t,
+ gf_unify_mt_off_t,
+ gf_unify_mt_int,
+ gf_unify_mt_unify_self_heal_struct,
+ gf_unify_mt_unify_local_t,
+ gf_unify_mt_end
+};
+#endif
+
diff --git a/xlators/cluster/unify/src/unify-self-heal.c b/xlators/cluster/unify/src/unify-self-heal.c
index 86f9e88fa5c..88145af9a77 100644
--- a/xlators/cluster/unify/src/unify-self-heal.c
+++ b/xlators/cluster/unify/src/unify-self-heal.c
@@ -93,20 +93,20 @@ unify_local_wipe (unify_local_t *local)
{
/* Free the strdup'd variables in the local structure */
if (local->name) {
- FREE (local->name);
+ GF_FREE (local->name);
}
if (local->sh_struct) {
if (local->sh_struct->offset_list)
- FREE (local->sh_struct->offset_list);
+ GF_FREE (local->sh_struct->offset_list);
if (local->sh_struct->entry_list)
- FREE (local->sh_struct->entry_list);
+ GF_FREE (local->sh_struct->entry_list);
if (local->sh_struct->count_list)
- FREE (local->sh_struct->count_list);
+ GF_FREE (local->sh_struct->count_list);
- FREE (local->sh_struct);
+ GF_FREE (local->sh_struct);
}
loc_wipe (&local->loc1);
@@ -144,13 +144,13 @@ unify_sh_setdents_cbk (call_frame_t *frame,
trav = entry->next;
while (trav) {
prev->next = trav->next;
- FREE (trav->name);
+ GF_FREE (trav->name);
if (IA_ISLNK (trav->buf.ia_type))
- FREE (trav->link);
- FREE (trav);
+ GF_FREE (trav->link);
+ GF_FREE (trav);
trav = prev->next;
}
- FREE (entry);
+ GF_FREE (entry);
}
if (!local->flags) {
@@ -202,7 +202,8 @@ unify_sh_ns_getdents_cbk (call_frame_t *frame,
unify_private_t *priv = this->private;
long index = 0;
unsigned long final = 0;
- dir_entry_t *tmp = CALLOC (1, sizeof (dir_entry_t));
+ dir_entry_t *tmp = GF_CALLOC (1, sizeof (dir_entry_t),
+ gf_unify_mt_dir_entry_t);
local->sh_struct->entry_list[0] = tmp;
local->sh_struct->count_list[0] = count;
@@ -259,13 +260,13 @@ unify_sh_ns_setdents_cbk (call_frame_t *frame,
trav = entry->next;
while (trav) {
prev->next = trav->next;
- FREE (trav->name);
+ GF_FREE (trav->name);
if (IA_ISLNK (trav->buf.ia_type))
- FREE (trav->link);
- FREE (trav);
+ GF_FREE (trav->link);
+ GF_FREE (trav);
trav = prev->next;
}
- FREE (entry);
+ GF_FREE (entry);
}
}
UNLOCK (&frame->lock);
@@ -341,7 +342,8 @@ unify_sh_getdents_cbk (call_frame_t *frame,
if (op_ret >= 0 && count > 0) {
/* There is some dentry found, just send the dentry to NS */
- tmp = CALLOC (1, sizeof (dir_entry_t));
+ tmp = GF_CALLOC (1, sizeof (dir_entry_t),
+ gf_unify_mt_dir_entry_t);
local->sh_struct->entry_list[index] = tmp;
local->sh_struct->count_list[index] = count;
if (entry) {
@@ -458,18 +460,21 @@ unify_sh_opendir_cbk (call_frame_t *frame,
* STACK_WIND.
*/
local->sh_struct->offset_list =
- calloc (priv->child_count,
- sizeof (off_t));
+ GF_CALLOC (priv->child_count,
+ sizeof (off_t),
+ gf_unify_mt_off_t);
ERR_ABORT (local->sh_struct->offset_list);
local->sh_struct->entry_list =
- calloc (priv->child_count,
- sizeof (dir_entry_t *));
+ GF_CALLOC (priv->child_count,
+ sizeof (dir_entry_t *),
+ gf_unify_mt_dir_entry_t);
ERR_ABORT (local->sh_struct->entry_list);
local->sh_struct->count_list =
- calloc (priv->child_count,
- sizeof (int));
+ GF_CALLOC (priv->child_count,
+ sizeof (int),
+ gf_unify_mt_int);
ERR_ABORT (local->sh_struct->count_list);
/* Send getdents on all the fds */
@@ -668,13 +673,13 @@ unify_bgsh_setdents_cbk (call_frame_t *frame,
trav = entry->next;
while (trav) {
prev->next = trav->next;
- FREE (trav->name);
+ GF_FREE (trav->name);
if (IA_ISLNK (trav->buf.ia_type))
- FREE (trav->link);
- FREE (trav);
+ GF_FREE (trav->link);
+ GF_FREE (trav);
trav = prev->next;
}
- FREE (entry);
+ GF_FREE (entry);
}
if (!local->flags) {
@@ -718,7 +723,8 @@ unify_bgsh_ns_getdents_cbk (call_frame_t *frame,
unify_private_t *priv = this->private;
long index = 0;
unsigned long final = 0;
- dir_entry_t *tmp = CALLOC (1, sizeof (dir_entry_t));
+ dir_entry_t *tmp = GF_CALLOC (1, sizeof (dir_entry_t),
+ gf_unify_mt_dir_entry_t);
local->sh_struct->entry_list[0] = tmp;
local->sh_struct->count_list[0] = count;
@@ -775,13 +781,13 @@ unify_bgsh_ns_setdents_cbk (call_frame_t *frame,
trav = entry->next;
while (trav) {
prev->next = trav->next;
- FREE (trav->name);
+ GF_FREE (trav->name);
if (IA_ISLNK (trav->buf.ia_type))
- FREE (trav->link);
- FREE (trav);
+ GF_FREE (trav->link);
+ GF_FREE (trav);
trav = prev->next;
}
- FREE (entry);
+ GF_FREE (entry);
}
if (local->sh_struct->count_list[index] <
@@ -855,7 +861,8 @@ unify_bgsh_getdents_cbk (call_frame_t *frame,
if (op_ret >= 0 && count > 0) {
/* There is some dentry found, just send the dentry to NS */
- tmp = CALLOC (1, sizeof (dir_entry_t));
+ tmp = GF_CALLOC (1, sizeof (dir_entry_t),
+ gf_unify_mt_dir_entry_t);
local->sh_struct->entry_list[index] = tmp;
local->sh_struct->count_list[index] = count;
if (entry) {
@@ -969,18 +976,21 @@ unify_bgsh_opendir_cbk (call_frame_t *frame,
track of offset sent to each node during
STACK_WIND. */
local->sh_struct->offset_list =
- calloc (priv->child_count,
- sizeof (off_t));
+ GF_CALLOC (priv->child_count,
+ sizeof (off_t),
+ gf_unify_mt_off_t);
ERR_ABORT (local->sh_struct->offset_list);
local->sh_struct->entry_list =
- calloc (priv->child_count,
- sizeof (dir_entry_t *));
+ GF_CALLOC (priv->child_count,
+ sizeof (dir_entry_t *),
+ gf_unify_mt_dir_entry_t);
ERR_ABORT (local->sh_struct->entry_list);
local->sh_struct->count_list =
- calloc (priv->child_count,
- sizeof (int));
+ GF_CALLOC (priv->child_count,
+ sizeof (int),
+ gf_unify_mt_int);
ERR_ABORT (local->sh_struct->count_list);
/* Send getdents on all the fds */
@@ -1161,7 +1171,8 @@ zr_unify_self_heal (call_frame_t *frame,
local->failed = 0;
local->call_count = priv->child_count + 1;
local->sh_struct =
- calloc (1, sizeof (struct unify_self_heal_struct));
+ GF_CALLOC (1, sizeof (struct unify_self_heal_struct),
+ gf_unify_mt_unify_self_heal_struct);
/* +1 is for NS */
for (index = 0;
@@ -1188,7 +1199,8 @@ zr_unify_self_heal (call_frame_t *frame,
bg_local->failed = 0;
bg_local->call_count = priv->child_count + 1;
bg_local->sh_struct =
- calloc (1, sizeof (struct unify_self_heal_struct));
+ GF_CALLOC (1, sizeof (struct unify_self_heal_struct),
+ gf_unify_mt_unify_self_heal_struct);
/* +1 is for NS */
for (index = 0; index < (priv->child_count + 1); index++) {
diff --git a/xlators/cluster/unify/src/unify.c b/xlators/cluster/unify/src/unify.c
index 2eadfe31cd7..3f0910df4fa 100644
--- a/xlators/cluster/unify/src/unify.c
+++ b/xlators/cluster/unify/src/unify.c
@@ -82,7 +82,7 @@ unify_local_wipe (unify_local_t *local)
{
/* Free the strdup'd variables in the local structure */
if (local->name) {
- FREE (local->name);
+ GF_FREE (local->name);
}
loc_wipe (&local->loc1);
loc_wipe (&local->loc2);
@@ -421,7 +421,8 @@ unify_lookup_cbk (call_frame_t *frame,
if (!local->list) {
/* list is not allocated, allocate
the max possible range */
- local->list = CALLOC (1, 2 * (priv->child_count + 2));
+ local->list = GF_CALLOC (1, 2 * (priv->child_count + 2),
+ gf_unify_mt_int16_t);
if (!local->list) {
gf_log (this->name,
GF_LOG_CRITICAL,
@@ -494,11 +495,12 @@ unify_lookup_cbk (call_frame_t *frame,
/* If its a file, big array is useless,
allocate the smaller one */
int16_t *list = NULL;
- list = CALLOC (1, 2 * (local->index + 1));
+ list = GF_CALLOC (1, 2 * (local->index + 1),
+ gf_unify_mt_int16_t);
ERR_ABORT (list);
memcpy (list, local->list, 2 * local->index);
/* Make the end of the list as -1 */
- FREE (local->list);
+ GF_FREE (local->list);
local->list = list;
local->list [local->index] = -1;
/* Update the inode's ctx with proper array */
@@ -524,7 +526,7 @@ unify_lookup_cbk (call_frame_t *frame,
}
if (local->op_ret == -1) {
if (!local->revalidate && local->list)
- FREE (local->list);
+ GF_FREE (local->list);
}
if ((local->op_ret >= 0) && local->failed &&
@@ -1219,19 +1221,20 @@ unify_open_readlink_cbk (call_frame_t *frame,
}
if (path[0] == '/') {
- local->name = strdup (path);
+ local->name = gf_strdup (path);
ERR_ABORT (local->name);
} else {
- char *tmp_str = strdup (local->loc1.path);
+ char *tmp_str = gf_strdup (local->loc1.path);
char *tmp_base = dirname (tmp_str);
- local->name = CALLOC (1, ZR_PATH_MAX);
+ local->name = GF_CALLOC (1, ZR_PATH_MAX, gf_unify_mt_char);
strcpy (local->name, tmp_base);
strncat (local->name, "/", 1);
strcat (local->name, path);
- FREE (tmp_str);
+ GF_FREE (tmp_str);
}
- local->list = CALLOC (1, sizeof (int16_t) * 3);
+ local->list = GF_CALLOC (1, sizeof (int16_t) * 3,
+ gf_unify_mt_int16_t);
ERR_ABORT (local->list);
local->call_count = priv->child_count + 1;
local->op_ret = -1;
@@ -1663,7 +1666,8 @@ unify_ns_create_cbk (call_frame_t *frame,
local->op_ret = -1;
/* Start the mapping list */
- list = CALLOC (1, sizeof (int16_t) * 3);
+ list = GF_CALLOC (1, sizeof (int16_t) * 3,
+ gf_unify_mt_int16_t);
ERR_ABORT (list);
inode_ctx_put (inode, this, (uint64_t)(long)list);
list[0] = priv->child_count;
@@ -1709,7 +1713,8 @@ unify_ns_create_cbk (call_frame_t *frame,
"File(%s) already exists on namespace, sending "
"open instead", local->loc1.path);
- local->list = CALLOC (1, sizeof (int16_t) * 3);
+ local->list = GF_CALLOC (1, sizeof (int16_t) * 3,
+ gf_unify_mt_int16_t);
ERR_ABORT (local->list);
local->call_count = priv->child_count + 1;
local->op_ret = -1;
@@ -2827,7 +2832,7 @@ unify_setxattr (call_frame_t *frame,
content only if file exists */
local->flags = flags;
local->dict = dict;
- local->name = strdup (trav->key);
+ local->name = gf_strdup (trav->key);
flags |= XATTR_REPLACE;
}
@@ -3207,7 +3212,7 @@ unify_ns_mknod_cbk (call_frame_t *frame,
local->oldpreparent = *preparent;
local->oldpostparent = *postparent;
- list = CALLOC (1, sizeof (int16_t) * 3);
+ list = GF_CALLOC (1, sizeof (int16_t) * 3, gf_unify_mt_int16_t);
ERR_ABORT (list);
list[0] = priv->child_count;
list[2] = -1;
@@ -3383,7 +3388,7 @@ unify_ns_symlink_cbk (call_frame_t *frame,
/* Start the mapping list */
- list = CALLOC (1, sizeof (int16_t) * 3);
+ list = GF_CALLOC (1, sizeof (int16_t) * 3, gf_unify_mt_int16_t);
ERR_ABORT (list);
list[0] = priv->child_count; //namespace's index
list[2] = -1;
@@ -3439,7 +3444,7 @@ unify_symlink (call_frame_t *frame,
/* Initialization */
INIT_LOCAL (frame, local);
loc_copy (&local->loc1, loc);
- local->name = strdup (linkpath);
+ local->name = gf_strdup (linkpath);
if ((local->name == NULL) ||
(local->loc1.path == NULL)) {
@@ -3620,7 +3625,8 @@ unify_rename_cbk (call_frame_t *frame,
if (list) {
for (index = 0; list[index] != -1; index++);
- tmp_list = CALLOC (1, index * 2);
+ tmp_list = GF_CALLOC (1, index * 2,
+ gf_unify_mt_int16_t);
memcpy (tmp_list, list, index * 2);
for (index = 0; list[index] != -1; index++) {
@@ -3668,11 +3674,11 @@ unify_rename_cbk (call_frame_t *frame,
}
}
- FREE (tmp_list);
+ GF_FREE (tmp_list);
return 0;
}
if (tmp_list)
- FREE (tmp_list);
+ GF_FREE (tmp_list);
}
}
@@ -4183,7 +4189,7 @@ unify_forget (xlator_t *this,
inode_ctx_get (inode, this, &tmp_list);
if (tmp_list) {
list = (int16_t *)(long)tmp_list;
- FREE (list);
+ GF_FREE (list);
}
}
@@ -4271,6 +4277,25 @@ notify (xlator_t *this,
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_unify_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
/**
* init - This function is called first in the xlator, while initializing.
* All the config file options are checked and appropriate flags are set.
@@ -4290,6 +4315,7 @@ init (xlator_t *this)
xlator_list_t *parent = NULL;
unify_private_t *_private = NULL;
+
/* Check for number of child nodes, if there is no child nodes, exit */
if (!this->children) {
gf_log (this->name, GF_LOG_ERROR,
@@ -4347,20 +4373,21 @@ init (xlator_t *this)
gf_log (this->name, GF_LOG_DEBUG,
"namespace node specified as %s", data->data);
- _private = CALLOC (1, sizeof (*_private));
+ _private = GF_CALLOC (1, sizeof (*_private),
+ gf_unify_mt_unify_private_t);
ERR_ABORT (_private);
_private->sched_ops = get_scheduler (this, scheduler->data);
if (!_private->sched_ops) {
gf_log (this->name, GF_LOG_CRITICAL,
"Error while loading scheduler. Exiting");
- FREE (_private);
+ GF_FREE (_private);
return -1;
}
if (ns_xl->parents) {
gf_log (this->name, GF_LOG_CRITICAL,
"Namespace node should not be a child of any other node. Exiting");
- FREE (_private);
+ GF_FREE (_private);
return -1;
}
@@ -4390,8 +4417,9 @@ init (xlator_t *this)
" you may hit some performance penalty");
}
- _private->xl_array = CALLOC (1,
- sizeof (xlator_t) * (count + 1));
+ _private->xl_array = GF_CALLOC (1,
+ sizeof (xlator_t) * (count + 1),
+ gf_unify_mt_xlator_t);
ERR_ABORT (_private->xl_array);
count = 0;
@@ -4435,21 +4463,29 @@ init (xlator_t *this)
/* Now that everything is fine. */
this->private = (void *)_private;
{
+ ret = _private->sched_ops->mem_acct_init (this);
+
+ if (ret == -1) {
+ return -1;
+ }
+
/* Initialize scheduler, if everything else is successful */
ret = _private->sched_ops->init (this);
if (ret == -1) {
gf_log (this->name, GF_LOG_CRITICAL,
"Initializing scheduler failed, Exiting");
- FREE (_private);
+ GF_FREE (_private);
return -1;
}
+
ret = 0;
/* This section is required because some fops may look
* for 'xl->parent' variable
*/
- xlparent = CALLOC (1, sizeof (*xlparent));
+ xlparent = GF_CALLOC (1, sizeof (*xlparent),
+ gf_unify_mt_xlator_list_t);
xlparent->xlator = this;
if (!ns_xl->parents) {
ns_xl->parents = xlparent;
@@ -4477,8 +4513,8 @@ fini (xlator_t *this)
priv->sched_ops->fini (this);
this->private = NULL;
LOCK_DESTROY (&priv->lock);
- FREE (priv->xl_array);
- FREE (priv);
+ GF_FREE (priv->xl_array);
+ GF_FREE (priv);
return;
}
diff --git a/xlators/cluster/unify/src/unify.h b/xlators/cluster/unify/src/unify.h
index cf3560d5b05..8dcf1659821 100644
--- a/xlators/cluster/unify/src/unify.h
+++ b/xlators/cluster/unify/src/unify.h
@@ -27,6 +27,7 @@
#include "scheduler.h"
#include "list.h"
+#include "unify-mem-types.h"
#define MAX_DIR_ENTRY_STRING (32 * 1024)
@@ -42,7 +43,7 @@
/* This is used to allocate memory for local structure */
#define INIT_LOCAL(fr, loc) \
do { \
- loc = CALLOC (1, sizeof (unify_local_t)); \
+ loc = GF_CALLOC (1, sizeof (unify_local_t), gf_unify_mt_unify_local_t); \
ERR_ABORT (loc); \
if (!loc) { \
STACK_UNWIND (fr, -1, ENOMEM); \
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 00000000000..d9b434d579f
--- /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 e5ccf10bcb8..09ee86751f2 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 5d1d342db88..7d619aadbc4 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,
diff --git a/xlators/features/filter/src/filter-mem-types.h b/xlators/features/filter/src/filter-mem-types.h
new file mode 100644
index 00000000000..cca354438b5
--- /dev/null
+++ b/xlators/features/filter/src/filter-mem-types.h
@@ -0,0 +1,30 @@
+/*
+ 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 __FILTER_MEM_TYPES_H__
+#define __FILTER_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_filter_mem_types_ {
+ gf_filter_mt_gf_filter = gf_common_mt_end + 1,
+ gf_filter_mt_end
+};
+#endif
+
diff --git a/xlators/features/filter/src/filter.c b/xlators/features/filter/src/filter.c
index 0f5e67fb0fd..a0469bf6ecc 100644
--- a/xlators/features/filter/src/filter.c
+++ b/xlators/features/filter/src/filter.c
@@ -30,6 +30,7 @@
#include "logging.h"
#include "dict.h"
#include "xlator.h"
+#include "filter-mem-types.h"
#define GF_FILTER_NOBODY_UID 65534
#define GF_FILTER_NOBODY_GID 65534
@@ -1355,6 +1356,25 @@ filter_removexattr (call_frame_t *frame,
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_filter_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)
{
@@ -1384,7 +1404,7 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- filter = CALLOC (sizeof (*filter), 1);
+ filter = GF_CALLOC (sizeof (*filter), 1, gf_filter_mt_gf_filter);
ERR_ABORT (filter);
if (dict_get (this->options, "read-only")) {
@@ -1419,11 +1439,11 @@ init (xlator_t *this)
option_data = dict_get (this->options, "translate-uid");
value = strtok_r (option_data->data, ",", &tmp_str);
while (value) {
- dup_str = strdup (value);
+ dup_str = gf_strdup (value);
input_value_str1 = strtok_r (dup_str, "=", &tmp_str1);
if (input_value_str1) {
/* Check for n-m */
- char *temp_string = strdup (input_value_str1);
+ char *temp_string = gf_strdup (input_value_str1);
input_value_str2 = strtok_r (temp_string, "-", &tmp_str2);
if (gf_string2int (input_value_str2, &input_value) != 0) {
gf_log (this->name, GF_LOG_ERROR,
@@ -1442,7 +1462,7 @@ init (xlator_t *this)
}
}
filter->translate_input_uid[filter->translate_num_uid_entries][1] = input_value;
- FREE (temp_string);
+ GF_FREE (temp_string);
output_value_str = strtok_r (NULL, "=", &tmp_str1);
if (output_value_str) {
if (gf_string2int (output_value_str, &output_value) != 0) {
@@ -1471,7 +1491,7 @@ init (xlator_t *this)
if (filter->translate_num_uid_entries == GF_MAXIMUM_FILTERING_ALLOWED)
break;
value = strtok_r (NULL, ",", &tmp_str);
- FREE (dup_str);
+ GF_FREE (dup_str);
}
}
@@ -1483,11 +1503,11 @@ init (xlator_t *this)
option_data = dict_get (this->options, "translate-gid");
value = strtok_r (option_data->data, ",", &tmp_str);
while (value) {
- dup_str = strdup (value);
+ dup_str = gf_strdup (value);
input_value_str1 = strtok_r (dup_str, "=", &tmp_str1);
if (input_value_str1) {
/* Check for n-m */
- char *temp_string = strdup (input_value_str1);
+ char *temp_string = gf_strdup (input_value_str1);
input_value_str2 = strtok_r (temp_string, "-", &tmp_str2);
if (gf_string2int (input_value_str2, &input_value) != 0) {
gf_log (this->name, GF_LOG_ERROR,
@@ -1506,7 +1526,7 @@ init (xlator_t *this)
}
}
filter->translate_input_gid[filter->translate_num_gid_entries][1] = input_value;
- FREE (temp_string);
+ GF_FREE (temp_string);
output_value_str = strtok_r (NULL, "=", &tmp_str1);
if (output_value_str) {
if (gf_string2int (output_value_str, &output_value) != 0) {
@@ -1536,7 +1556,7 @@ init (xlator_t *this)
if (filter->translate_num_gid_entries == GF_MAXIMUM_FILTERING_ALLOWED)
break;
value = strtok_r (NULL, ",", &tmp_str);
- FREE (dup_str);
+ GF_FREE (dup_str);
}
}
@@ -1547,7 +1567,7 @@ init (xlator_t *this)
option_data = dict_get (this->options, "filter-uid");
value = strtok_r (option_data->data, ",", &tmp_str);
while (value) {
- dup_str = strdup (value);
+ dup_str = gf_strdup (value);
/* Check for n-m */
input_value_str1 = strtok_r (dup_str, "-", &tmp_str1);
if (gf_string2int (input_value_str1, &input_value) != 0) {
@@ -1577,7 +1597,7 @@ init (xlator_t *this)
if (filter->filter_num_uid_entries == GF_MAXIMUM_FILTERING_ALLOWED)
break;
value = strtok_r (NULL, ",", &tmp_str);
- FREE (dup_str);
+ GF_FREE (dup_str);
}
filter->partial_filter = 1;
}
@@ -1589,7 +1609,7 @@ init (xlator_t *this)
option_data = dict_get (this->options, "filter-gid");
value = strtok_r (option_data->data, ",", &tmp_str);
while (value) {
- dup_str = strdup (value);
+ dup_str = gf_strdup (value);
/* Check for n-m */
input_value_str1 = strtok_r (dup_str, "-", &tmp_str1);
if (gf_string2int (input_value_str1, &input_value) != 0) {
@@ -1619,7 +1639,7 @@ init (xlator_t *this)
if (filter->filter_num_gid_entries == GF_MAXIMUM_FILTERING_ALLOWED)
break;
value = strtok_r (NULL, ",", &tmp_str);
- FREE (dup_str);
+ GF_FREE (dup_str);
}
gf_log (this->name, GF_LOG_ERROR, "this option is not supported currently.. exiting");
return -1;
@@ -1660,7 +1680,7 @@ fini (xlator_t *this)
{
struct gf_filter *filter = this->private;
- FREE (filter);
+ GF_FREE (filter);
return;
}
diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c
index 83800ff5aeb..9568c2a5e9c 100644
--- a/xlators/features/locks/src/common.c
+++ b/xlators/features/locks/src/common.c
@@ -48,12 +48,13 @@ allocate_domain (const char *volume)
{
pl_dom_list_t *dom = NULL;
- dom = CALLOC (1, sizeof (*dom));
+ dom = GF_CALLOC (1, sizeof (*dom),
+ gf_locks_mt_pl_dom_list_t);
if (!dom)
return NULL;
- dom->domain = strdup(volume);
+ dom->domain = gf_strdup(volume);
if (!dom->domain) {
gf_log ("posix-locks", GF_LOG_TRACE,
"Out of Memory");
@@ -151,7 +152,7 @@ pl_print_lockee (char *str, int size, fd_t *fd, loc_t *loc)
}
if (loc && loc->path) {
- ipath = strdup (loc->path);
+ ipath = gf_strdup (loc->path);
} else {
ret = inode_path (inode, NULL, &ipath);
if (ret <= 0)
@@ -163,7 +164,7 @@ pl_print_lockee (char *str, int size, fd_t *fd, loc_t *loc)
ipath ? ipath : "<nul>");
if (ipath)
- FREE (ipath);
+ GF_FREE (ipath);
}
@@ -418,7 +419,8 @@ pl_inode_get (xlator_t *this, inode_t *inode)
pl_inode = (pl_inode_t *)(long)tmp_pl_inode;
goto out;
}
- pl_inode = CALLOC (1, sizeof (*pl_inode));
+ pl_inode = GF_CALLOC (1, sizeof (*pl_inode),
+ gf_locks_mt_pl_inode_t);
if (!pl_inode) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory.");
@@ -454,7 +456,8 @@ new_posix_lock (struct flock *flock, transport_t *transport, pid_t client_pid,
{
posix_lock_t *lock = NULL;
- lock = CALLOC (1, sizeof (posix_lock_t));
+ lock = GF_CALLOC (1, sizeof (posix_lock_t),
+ gf_locks_mt_posix_lock_t);
if (!lock) {
return NULL;
}
@@ -490,7 +493,7 @@ __delete_lock (pl_inode_t *pl_inode, posix_lock_t *lock)
void
__destroy_lock (posix_lock_t *lock)
{
- free (lock);
+ GF_FREE (lock);
}
@@ -567,7 +570,8 @@ add_locks (posix_lock_t *l1, posix_lock_t *l2)
{
posix_lock_t *sum = NULL;
- sum = CALLOC (1, sizeof (posix_lock_t));
+ sum = GF_CALLOC (1, sizeof (posix_lock_t),
+ gf_locks_mt_posix_lock_t);
if (!sum)
return NULL;
@@ -591,7 +595,8 @@ subtract_locks (posix_lock_t *big, posix_lock_t *small)
if ((big->fl_start == small->fl_start) &&
(big->fl_end == small->fl_end)) {
/* both edges coincide with big */
- v.locks[0] = CALLOC (1, sizeof (posix_lock_t));
+ v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
+ gf_locks_mt_posix_lock_t);
ERR_ABORT (v.locks[0]);
memcpy (v.locks[0], big, sizeof (posix_lock_t));
v.locks[0]->fl_type = small->fl_type;
@@ -599,11 +604,14 @@ subtract_locks (posix_lock_t *big, posix_lock_t *small)
else if ((small->fl_start > big->fl_start) &&
(small->fl_end < big->fl_end)) {
/* both edges lie inside big */
- v.locks[0] = CALLOC (1, sizeof (posix_lock_t));
+ v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
+ gf_locks_mt_posix_lock_t);
ERR_ABORT (v.locks[0]);
- v.locks[1] = CALLOC (1, sizeof (posix_lock_t));
+ v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t),
+ gf_locks_mt_posix_lock_t);
ERR_ABORT (v.locks[1]);
- v.locks[2] = CALLOC (1, sizeof (posix_lock_t));
+ v.locks[2] = GF_CALLOC (1, sizeof (posix_lock_t),
+ gf_locks_mt_posix_lock_t);
ERR_ABORT (v.locks[2]);
memcpy (v.locks[0], big, sizeof (posix_lock_t));
@@ -615,9 +623,11 @@ subtract_locks (posix_lock_t *big, posix_lock_t *small)
}
/* one edge coincides with big */
else if (small->fl_start == big->fl_start) {
- v.locks[0] = CALLOC (1, sizeof (posix_lock_t));
+ v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
+ gf_locks_mt_posix_lock_t);
ERR_ABORT (v.locks[0]);
- v.locks[1] = CALLOC (1, sizeof (posix_lock_t));
+ v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t),
+ gf_locks_mt_posix_lock_t);
ERR_ABORT (v.locks[1]);
memcpy (v.locks[0], big, sizeof (posix_lock_t));
@@ -626,9 +636,11 @@ subtract_locks (posix_lock_t *big, posix_lock_t *small)
memcpy (v.locks[1], small, sizeof (posix_lock_t));
}
else if (small->fl_end == big->fl_end) {
- v.locks[0] = CALLOC (1, sizeof (posix_lock_t));
+ v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
+ gf_locks_mt_posix_lock_t);
ERR_ABORT (v.locks[0]);
- v.locks[1] = CALLOC (1, sizeof (posix_lock_t));
+ v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t),
+ gf_locks_mt_posix_lock_t);
ERR_ABORT (v.locks[1]);
memcpy (v.locks[0], big, sizeof (posix_lock_t));
@@ -800,7 +812,8 @@ __grant_blocked_locks (xlator_t *this, pl_inode_t *pl_inode, struct list_head *g
list_del_init (&l->list);
if (__is_lock_grantable (pl_inode, l)) {
- conf = CALLOC (1, sizeof (*conf));
+ conf = GF_CALLOC (1, sizeof (*conf),
+ gf_locks_mt_posix_lock_t);
if (!conf) {
l->blocked = 1;
@@ -855,7 +868,7 @@ grant_blocked_locks (xlator_t *this, pl_inode_t *pl_inode)
STACK_UNWIND (lock->frame, 0, 0, &lock->user_flock);
- FREE (lock);
+ GF_FREE (lock);
}
return;
diff --git a/xlators/features/locks/src/entrylk.c b/xlators/features/locks/src/entrylk.c
index b83044b7f28..e4b9bb5687e 100644
--- a/xlators/features/locks/src/entrylk.c
+++ b/xlators/features/locks/src/entrylk.c
@@ -40,12 +40,13 @@ new_entrylk_lock (pl_inode_t *pinode, const char *basename, entrylk_type type,
{
pl_entry_lock_t *newlock = NULL;
- newlock = CALLOC (1, sizeof (pl_entry_lock_t));
+ newlock = GF_CALLOC (1, sizeof (pl_entry_lock_t),
+ gf_locks_mt_pl_entry_lock_t);
if (!newlock) {
goto out;
}
- newlock->basename = basename ? strdup (basename) : NULL;
+ newlock->basename = basename ? gf_strdup (basename) : NULL;
newlock->type = type;
newlock->trans = trans;
newlock->volume = volume;
@@ -457,8 +458,8 @@ __grant_blocked_entry_locks (xlator_t *this, pl_inode_t *pl_inode,
list_add (&bl->blocked_locks, granted);
} else {
if (bl->basename)
- FREE (bl->basename);
- FREE (bl);
+ GF_FREE ((char *)bl->basename);
+ GF_FREE (bl);
}
}
return;
@@ -490,12 +491,12 @@ grant_blocked_entry_locks (xlator_t *this, pl_inode_t *pl_inode,
STACK_UNWIND_STRICT (entrylk, lock->frame, 0, 0);
- FREE (lock->basename);
- FREE (lock);
+ GF_FREE ((char *)lock->basename);
+ GF_FREE (lock);
}
- FREE (unlocked->basename);
- FREE (unlocked);
+ GF_FREE ((char *)unlocked->basename);
+ GF_FREE (unlocked);
return;
}
@@ -545,8 +546,8 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode,
"releasing lock on held by "
"{transport=%p}",trans);
- FREE (lock->basename);
- FREE (lock);
+ GF_FREE ((char *)lock->basename);
+ GF_FREE (lock);
}
__grant_blocked_entry_locks (this, pinode, dom, &granted);
@@ -561,8 +562,8 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode,
STACK_UNWIND_STRICT (entrylk, lock->frame, -1, EAGAIN);
if (lock->basename)
- FREE (lock->basename);
- FREE (lock);
+ GF_FREE ((char *)lock->basename);
+ GF_FREE (lock);
}
@@ -572,8 +573,8 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode,
STACK_UNWIND_STRICT (entrylk, lock->frame, 0, 0);
if (lock->basename)
- FREE (lock->basename);
- FREE (lock);
+ GF_FREE ((char *)lock->basename);
+ GF_FREE (lock);
}
return 0;
diff --git a/xlators/features/locks/src/inodelk.c b/xlators/features/locks/src/inodelk.c
index 50a5996d74a..64028d079c3 100644
--- a/xlators/features/locks/src/inodelk.c
+++ b/xlators/features/locks/src/inodelk.c
@@ -42,7 +42,7 @@ __delete_inode_lock (pl_inode_lock_t *lock)
void
__destroy_inode_lock (pl_inode_lock_t *lock)
{
- FREE (lock);
+ GF_FREE (lock);
}
/* Check if 2 inodelks are conflicting on type. Only 2 shared locks don't conflict */
@@ -439,7 +439,7 @@ release_inode_locks_of_transport (xlator_t *this, pl_dom_list_t *dom,
}
unlock:
if (path)
- FREE (path);
+ GF_FREE (path);
pthread_mutex_unlock (&pinode->mutex);
@@ -447,7 +447,7 @@ unlock:
list_del_init (&l->blocked_locks);
STACK_UNWIND_STRICT (inodelk, l->frame, -1, EAGAIN);
- FREE (l);
+ GF_FREE (l);
}
grant_blocked_inode_locks (this, pinode, dom);
@@ -515,7 +515,8 @@ new_inode_lock (struct flock *flock, transport_t *transport, pid_t client_pid,
{
pl_inode_lock_t *lock = NULL;
- lock = CALLOC (1, sizeof (*lock));
+ lock = GF_CALLOC (1, sizeof (*lock),
+ gf_locks_mt_pl_inode_lock_t);
if (!lock) {
return NULL;
}
diff --git a/xlators/features/locks/src/locks-mem-types.h b/xlators/features/locks/src/locks-mem-types.h
new file mode 100644
index 00000000000..cf50240863b
--- /dev/null
+++ b/xlators/features/locks/src/locks-mem-types.h
@@ -0,0 +1,39 @@
+/*
+ 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 __LOCKS_MEM_TYPES_H__
+#define __LOCKS_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_locks_mem_types_ {
+ gf_locks_mt_pl_dom_list_t = gf_common_mt_end + 1,
+ gf_locks_mt_pl_inode_t,
+ gf_locks_mt_posix_lock_t,
+ gf_locks_mt_pl_entry_lock_t,
+ gf_locks_mt_pl_inode_lock_t,
+ gf_locks_mt_truncate_ops,
+ gf_locks_mt_pl_rw_req_t,
+ gf_locks_mt_posix_locks_private_t,
+ gf_locks_mt_pl_local_t,
+ gf_locks_mt_end
+};
+#endif
+
diff --git a/xlators/features/locks/src/locks.h b/xlators/features/locks/src/locks.h
index e89092811a6..01764484a0c 100644
--- a/xlators/features/locks/src/locks.h
+++ b/xlators/features/locks/src/locks.h
@@ -29,6 +29,7 @@
#include "transport.h"
#include "stack.h"
#include "call-stub.h"
+#include "locks-mem-types.h"
struct __pl_fd;
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index 2e6afd9fca6..83b3eb34039 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -180,7 +180,8 @@ pl_truncate (call_frame_t *frame, xlator_t *this,
{
struct _truncate_ops *local = NULL;
- local = CALLOC (1, sizeof (struct _truncate_ops));
+ local = GF_CALLOC (1, sizeof (struct _truncate_ops),
+ gf_locks_mt_truncate_ops);
if (!local) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory.");
@@ -211,7 +212,8 @@ pl_ftruncate (call_frame_t *frame, xlator_t *this,
{
struct _truncate_ops *local = NULL;
- local = CALLOC (1, sizeof (struct _truncate_ops));
+ local = GF_CALLOC (1, sizeof (struct _truncate_ops),
+ gf_locks_mt_truncate_ops);
if (!local) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory.");
@@ -522,7 +524,7 @@ do_blocked_rw (pl_inode_t *pl_inode)
list_for_each_entry_safe (rw, tmp, &wind_list, list) {
list_del_init (&rw->list);
call_resume (rw->stub);
- free (rw);
+ GF_FREE (rw);
}
return;
@@ -601,7 +603,8 @@ pl_readv (call_frame_t *frame, xlator_t *this,
goto unlock;
}
- rw = CALLOC (1, sizeof (*rw));
+ rw = GF_CALLOC (1, sizeof (*rw),
+ gf_locks_mt_pl_rw_req_t);
if (!rw) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory.");
@@ -617,7 +620,7 @@ pl_readv (call_frame_t *frame, xlator_t *this,
"Out of memory.");
op_errno = ENOMEM;
op_ret = -1;
- free (rw);
+ GF_FREE (rw);
goto unlock;
}
@@ -698,7 +701,8 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
goto unlock;
}
- rw = CALLOC (1, sizeof (*rw));
+ rw = GF_CALLOC (1, sizeof (*rw),
+ gf_locks_mt_pl_rw_req_t);
if (!rw) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory.");
@@ -715,7 +719,7 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
"Out of memory.");
op_errno = ENOMEM;
op_ret = -1;
- free (rw);
+ GF_FREE (rw);
goto unlock;
}
@@ -876,7 +880,7 @@ pl_forget (xlator_t *this,
list) {
list_del (&rw_req->list);
- FREE (rw_req);
+ GF_FREE (rw_req);
}
}
@@ -920,8 +924,8 @@ pl_forget (xlator_t *this,
list_del_init (&entry_l->domain_list);
if (entry_l->basename)
- FREE (entry_l->basename);
- FREE (entry_l);
+ GF_FREE ((char *)entry_l->basename);
+ GF_FREE (entry_l);
}
list_splice_init (&dom->blocked_entrylks, &entrylks_released);
@@ -930,8 +934,8 @@ pl_forget (xlator_t *this,
list_del (&dom->inode_list);
gf_log ("posix-locks", GF_LOG_TRACE,
" Cleaning up domain: %s", dom->domain);
- FREE (dom->domain);
- FREE (dom);
+ GF_FREE ((char *)(dom->domain));
+ GF_FREE (dom);
}
}
@@ -953,12 +957,12 @@ pl_forget (xlator_t *this,
STACK_UNWIND_STRICT (entrylk, entry_l->frame, -1, 0);
if (entry_l->basename)
- FREE (entry_l->basename);
- FREE (entry_l);
+ GF_FREE ((char *)entry_l->basename);
+ GF_FREE (entry_l);
}
- FREE (pl_inode);
+ GF_FREE (pl_inode);
return 0;
}
@@ -1117,7 +1121,7 @@ pl_lookup_cbk (call_frame_t *frame,
frame->local = NULL;
if (local != NULL)
- FREE (local);
+ GF_FREE (local);
out:
STACK_UNWIND (frame,
@@ -1143,7 +1147,7 @@ pl_lookup (call_frame_t *frame,
VALIDATE_OR_GOTO (this, out);
VALIDATE_OR_GOTO (loc, out);
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_locks_mt_pl_local_t);
if (!local) {
ret = -1;
gf_log (this->name, GF_LOG_ERROR,
@@ -1437,7 +1441,24 @@ pl_dump_inode (xlator_t *this)
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_locks_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)
@@ -1469,7 +1490,8 @@ init (xlator_t *this)
return -1;
}
- priv = CALLOC (1, sizeof (*priv));
+ priv = GF_CALLOC (1, sizeof (*priv),
+ gf_locks_mt_posix_locks_private_t);
mandatory = dict_get (this->options, "mandatory-locks");
if (mandatory)
@@ -1497,7 +1519,7 @@ fini (xlator_t *this)
posix_locks_private_t *priv = NULL;
priv = this->private;
- free (priv);
+ GF_FREE (priv);
return 0;
}
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")) {
diff --git a/xlators/features/quota/src/quota-mem-types.h b/xlators/features/quota/src/quota-mem-types.h
new file mode 100644
index 00000000000..b71314ed8e6
--- /dev/null
+++ b/xlators/features/quota/src/quota-mem-types.h
@@ -0,0 +1,31 @@
+/*
+ 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 __QUOTA_MEM_TYPES_H__
+#define __QUOTA_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_quota_mem_types_ {
+ gf_quota_mt_quota_local = gf_common_mt_end + 1,
+ gf_quota_mt_quota_priv,
+ gf_quota_mt_end
+};
+#endif
+
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index 822c29bd375..3b4690bf0ae 100644
--- a/xlators/features/quota/src/quota.c
+++ b/xlators/features/quota/src/quota.c
@@ -27,6 +27,7 @@
#include "xlator.h"
#include "defaults.h"
#include "common-utils.h"
+#include "quota-mem-types.h"
#ifndef MAX_IOVEC
#define MAX_IOVEC 16
@@ -204,7 +205,8 @@ quota_truncate (call_frame_t *frame, xlator_t *this,
priv = this->private;
if (priv->disk_usage_limit) {
- local = CALLOC (1, sizeof (struct quota_local));
+ local = GF_CALLOC (1, sizeof (struct quota_local),
+ gf_quota_mt_quota_local);
frame->local = local;
loc_copy (&local->loc, loc);
@@ -279,7 +281,8 @@ quota_ftruncate (call_frame_t *frame, xlator_t *this,
priv = this->private;
if (priv->disk_usage_limit) {
- local = CALLOC (1, sizeof (struct quota_local));
+ local = GF_CALLOC (1, sizeof (struct quota_local),
+ gf_quota_mt_quota_local);
frame->local = local;
local->fd = fd_ref (fd);
@@ -462,7 +465,8 @@ quota_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc)
priv = this->private;
if (priv->disk_usage_limit) {
- local = CALLOC (1, sizeof (struct quota_local));
+ local = GF_CALLOC (1, sizeof (struct quota_local),
+ gf_quota_mt_quota_local);
frame->local = local;
loc_copy (&local->loc, loc);
@@ -534,7 +538,8 @@ quota_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc)
priv = this->private;
if (priv->disk_usage_limit) {
- local = CALLOC (1, sizeof (struct quota_local));
+ local = GF_CALLOC (1, sizeof (struct quota_local),
+ gf_quota_mt_quota_local);
frame->local = local;
loc_copy (&local->loc, loc);
@@ -772,7 +777,8 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
}
if (priv->disk_usage_limit) {
- local = CALLOC (1, sizeof (struct quota_local));
+ local = GF_CALLOC (1, sizeof (struct quota_local),
+ gf_quota_mt_quota_local);
local->fd = fd_ref (fd);
local->iobref = iobref_ref (iobref);
for (i = 0; i < count; i++) {
@@ -1018,7 +1024,26 @@ quota_lookup (call_frame_t *frame,
loc,
xattr_req);
return 0;
- }
+}
+
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_quota_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)
@@ -1038,7 +1063,8 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- _private = CALLOC (1, sizeof (struct quota_priv));
+ _private = GF_CALLOC (1, sizeof (struct quota_priv),
+ gf_quota_mt_quota_priv);
_private->disk_usage_limit = 0;
data = dict_get (this->options, "disk-usage-limit");
if (data) {
diff --git a/xlators/features/trash/src/trash-mem-types.h b/xlators/features/trash/src/trash-mem-types.h
new file mode 100644
index 00000000000..48613d1e80b
--- /dev/null
+++ b/xlators/features/trash/src/trash-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 __TRASH_MEM_TYPES_H__
+#define __TRASH_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_trash_mem_types_ {
+ gf_trash_mt_trash_local_t = gf_common_mt_end + 1,
+ gf_trash_mt_trash_private_t,
+ gf_trash_mt_char,
+ gf_trash_mt_trash_elim_pattern_t,
+ gf_trash_mt_end
+};
+#endif
+
diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c
index 5ee3da2c8c7..ff060cc5c0d 100644
--- a/xlators/features/trash/src/trash.c
+++ b/xlators/features/trash/src/trash.c
@@ -23,7 +23,7 @@
#endif
#include "trash.h"
-
+#include "trash-mem-types.h"
int32_t
trash_ftruncate_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
@@ -63,7 +63,7 @@ trash_local_wipe (trash_local_t *local)
if (local->newfd)
fd_unref (local->newfd);
- FREE (local);
+ GF_FREE (local);
out:
return;
}
@@ -94,7 +94,7 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
loc_t tmp_loc = {0,};
local = frame->local;
- tmp_str = strdup (local->newpath);
+ tmp_str = gf_strdup (local->newpath);
if (!tmp_str) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
}
@@ -166,8 +166,8 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
&tmp_loc, 0755);
out:
- free (cookie);
- free (tmp_str);
+ GF_FREE (cookie);
+ GF_FREE (tmp_str);
return 0;
}
@@ -195,7 +195,7 @@ trash_unlink_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local = frame->local;
if ((op_ret == -1) && (op_errno == ENOENT)) {
- tmp_str = strdup (local->newpath);
+ tmp_str = gf_strdup (local->newpath);
if (!tmp_str) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
}
@@ -203,7 +203,7 @@ trash_unlink_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
tmp_loc.path = dir_name;
- tmp_cookie = strdup (dir_name);
+ tmp_cookie = gf_strdup (dir_name);
if (!tmp_cookie) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
}
@@ -213,7 +213,7 @@ trash_unlink_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
FIRST_CHILD(this)->fops->mkdir,
&tmp_loc, 0755);
- free (tmp_str);
+ GF_FREE (tmp_str);
return 0;
}
@@ -337,7 +337,7 @@ trash_rename_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local = frame->local;
if ((op_ret == -1) && (op_errno == ENOENT)) {
- tmp_str = strdup (local->newpath);
+ tmp_str = gf_strdup (local->newpath);
if (!tmp_str) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
}
@@ -346,7 +346,7 @@ trash_rename_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* check for the errno, if its ENOENT create directory and call
* rename later
*/
- tmp_path = strdup (dir_name);
+ tmp_path = gf_strdup (dir_name);
if (!tmp_path) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
}
@@ -358,7 +358,7 @@ trash_rename_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
this->children->xlator->fops->mkdir,
&tmp_loc, 0755);
- free (tmp_str);
+ GF_FREE (tmp_str);
return 0;
}
@@ -396,7 +396,7 @@ trash_rename_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
loc_t tmp_loc = {0,};
local = frame->local;
- tmp_str = strdup (local->newpath);
+ tmp_str = gf_strdup (local->newpath);
if (!tmp_str) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
}
@@ -438,8 +438,8 @@ trash_rename_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
out:
- free (cookie); /* strdup (dir_name) was sent here :) */
- free (tmp_str);
+ GF_FREE (cookie); /* strdup (dir_name) was sent here :) */
+ GF_FREE (tmp_str);
return 0;
}
@@ -529,7 +529,8 @@ trash_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
return 0;
}
- local = CALLOC (1, sizeof (trash_local_t));
+ local = GF_CALLOC (1, sizeof (trash_local_t),
+ gf_trash_mt_trash_local_t);
if (!local) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
TRASH_STACK_UNWIND (frame, -1, ENOMEM,
@@ -605,7 +606,8 @@ trash_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc)
return 0;
}
- local = CALLOC (1, sizeof (trash_local_t));
+ local = GF_CALLOC (1, sizeof (trash_local_t),
+ gf_trash_mt_trash_local_t);
if (!local) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
TRASH_STACK_UNWIND (frame, -1, ENOMEM, NULL, NULL);
@@ -781,13 +783,13 @@ trash_truncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if ((op_ret == -1) && (op_errno == ENOENT)) {
//Creating the directory structure here.
- tmp_str = strdup (local->newpath);
+ tmp_str = gf_strdup (local->newpath);
if (!tmp_str) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
}
dir_name = dirname (tmp_str);
- tmp_path = strdup (dir_name);
+ tmp_path = gf_strdup (dir_name);
if (!tmp_path) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
}
@@ -798,7 +800,7 @@ trash_truncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
tmp_path, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->mkdir,
&tmp_loc, 0755);
- free (tmp_str);
+ GF_FREE (tmp_str);
goto out;
}
@@ -850,7 +852,7 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
loop_count = local->loop_count;
- tmp_str = strdup (local->newpath);
+ tmp_str = gf_strdup (local->newpath);
if (!tmp_str) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
}
@@ -923,8 +925,8 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
&tmp_loc, 0755);
out:
- free (cookie); /* strdup (dir_name) was sent here :) */
- free (tmp_str);
+ GF_FREE (cookie); /* strdup (dir_name) was sent here :) */
+ GF_FREE (tmp_str);
return 0;
}
@@ -979,8 +981,8 @@ trash_truncate_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
strcpy (loc_newname,local->loc.name);
strcat (loc_newname,timestr);
- local->newloc.name = strdup (loc_newname);
- local->newloc.path = strdup (local->newpath);
+ local->newloc.name = gf_strdup (loc_newname);
+ local->newloc.path = gf_strdup (local->newpath);
local->newloc.inode = inode_new (local->loc.inode->table);
local->newloc.ino = local->newloc.inode->ino;
local->newfd = fd_create (local->newloc.inode, frame->root->pid);
@@ -1036,7 +1038,8 @@ trash_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc,
LOCK_INIT (&frame->lock);
- local = CALLOC (1, sizeof (trash_local_t));
+ local = GF_CALLOC (1, sizeof (trash_local_t),
+ gf_trash_mt_trash_local_t);
if (!local) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
TRASH_STACK_UNWIND (frame, -1, ENOMEM, NULL);
@@ -1154,13 +1157,13 @@ trash_ftruncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local = frame->local;
if ((op_ret == -1) && (op_errno == ENOENT)) {
- tmp_str = strdup (local->newpath);
+ tmp_str = gf_strdup (local->newpath);
if (!tmp_str) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
}
dir_name = dirname (tmp_str);
- tmp_path = strdup (dir_name);
+ tmp_path = gf_strdup (dir_name);
if (!tmp_path) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
}
@@ -1171,7 +1174,7 @@ trash_ftruncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
tmp_path, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->mkdir,
&tmp_loc, 0755);
- free (tmp_str);
+ GF_FREE (tmp_str);
return 0;
}
@@ -1214,7 +1217,7 @@ trash_ftruncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
loop_count = local->loop_count;
- tmp_str = strdup (local->newpath);
+ tmp_str = gf_strdup (local->newpath);
if (!tmp_str) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
}
@@ -1288,8 +1291,8 @@ trash_ftruncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
&tmp_loc, 0755);
out:
- free (cookie); /* strdup (dir_name) was sent here :) */
- free (tmp_str);
+ GF_FREE (cookie); /* strdup (dir_name) was sent here :) */
+ GF_FREE (tmp_str);
return 0;
}
@@ -1374,7 +1377,8 @@ trash_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
return 0;
}
- local = CALLOC (1, sizeof (trash_local_t));
+ local = GF_CALLOC (1, sizeof (trash_local_t),
+ gf_trash_mt_trash_local_t);
if (!local) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
TRASH_STACK_UNWIND (frame, -1, ENOMEM, NULL, NULL);
@@ -1438,7 +1442,7 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- _priv = CALLOC (1, sizeof (*_priv));
+ _priv = GF_CALLOC (1, sizeof (*_priv), gf_trash_mt_trash_private_t);
if (!_priv) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
return -1;
@@ -1449,17 +1453,17 @@ init (xlator_t *this)
gf_log (this->name, GF_LOG_NORMAL,
"no option specified for 'trash-dir', "
"using \"/.trashcan/\"");
- _priv->trash_dir = strdup ("/.trashcan");
+ _priv->trash_dir = gf_strdup ("/.trashcan");
} else {
/* Need a path with '/' as the first char, if not
given, append it */
if (data->data[0] == '/') {
- _priv->trash_dir = strdup (data->data);
+ _priv->trash_dir = gf_strdup (data->data);
} else {
/* TODO: Make sure there is no ".." in the path */
strcpy (trash_dir, "/");
strcat (trash_dir, data->data);
- _priv->trash_dir = strdup (trash_dir);
+ _priv->trash_dir = gf_strdup (trash_dir);
}
}
@@ -1468,7 +1472,7 @@ init (xlator_t *this)
gf_log (this->name, GF_LOG_TRACE,
"no option specified for 'eliminate', using NULL");
} else {
- tmp_str = strdup (data->data);
+ tmp_str = gf_strdup (data->data);
if (!tmp_str) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
}
@@ -1476,7 +1480,8 @@ init (xlator_t *this)
/* Match Filename to option specified in eliminate. */
component = strtok_r (tmp_str, "|", &strtokptr);
while (component) {
- trav = CALLOC (1, sizeof (*trav));
+ trav = GF_CALLOC (1, sizeof (*trav),
+ gf_trash_mt_trash_elim_pattern_t);
if (!trav) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
}
@@ -1521,7 +1526,7 @@ fini (xlator_t *this)
priv = this->private;
if (priv)
- FREE (priv);
+ GF_FREE (priv);
return;
}
diff --git a/xlators/meta/src/meta-mem-types.h b/xlators/meta/src/meta-mem-types.h
new file mode 100644
index 00000000000..a9ec9435a4a
--- /dev/null
+++ b/xlators/meta/src/meta-mem-types.h
@@ -0,0 +1,35 @@
+/*
+ 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 __META_MEM_TYPES_H__
+#define __META_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_meta_mem_types_ {
+ gf_meta_mt__open_local = gf_common_mt_end + 1,
+ gf_meta_mt_dir_entry_t,
+ gf_meta_mt_meta_dirent_t,
+ gf_meta_mt_meta_private_t,
+ gf_meta_mt_stat,
+ gf_meta_mt_end
+};
+#endif
+
diff --git a/xlators/meta/src/meta.c b/xlators/meta/src/meta.c
index 7843e816939..2babe32f911 100644
--- a/xlators/meta/src/meta.c
+++ b/xlators/meta/src/meta.c
@@ -32,6 +32,7 @@
#include "meta.h"
#include "view.h"
+#include "meta-mem-types.h"
int32_t
meta_getattr_cbk (call_frame_t *frame,
@@ -516,9 +517,9 @@ meta_open (call_frame_t *frame, xlator_t *this,
if (file) {
if (file->fops && file->fops->open) {
- struct _open_local *local = CALLOC (1, sizeof (struct _open_local));
+ struct _open_local *local = GF_CALLOC (1, sizeof (struct _open_local), gf_meta_mt__open_local);
ERR_ABORT (local);
- local->path = strdup (path);
+ local->path = gf_strdup (path);
frame->local = local;
STACK_WIND (frame, meta_open_cbk,
this, file->fops->open,
@@ -528,7 +529,7 @@ meta_open (call_frame_t *frame, xlator_t *this,
else {
dict_t *ctx = get_new_dict ();
dict_ref (ctx);
- dict_set (ctx, this->name, str_to_data (strdup (path)));
+ dict_set (ctx, this->name, str_to_data (gf_strdup (path)));
STACK_UNWIND (frame, 0, 0, ctx, file->stbuf);
return 0;
}
@@ -551,9 +552,9 @@ meta_create (call_frame_t *frame, xlator_t *this,
if (file) {
if (file->fops && file->fops->create) {
- struct _open_local *local = CALLOC (1, sizeof (struct _open_local));
+ struct _open_local *local = GF_CALLOC (1, sizeof (struct _open_local), gf_meta_mt__open_local);
ERR_ABORT (local);
- local->path = strdup (path);
+ local->path = gf_strdup (path);
frame->local = local;
STACK_WIND (frame, meta_open_cbk,
this, file->fops->create,
@@ -826,7 +827,7 @@ meta_opendir (call_frame_t *frame,
if (dir) {
dict_t *ctx = get_new_dict ();
- dict_set (ctx, this->name, str_to_data (strdup (path)));
+ dict_set (ctx, this->name, str_to_data (gf_strdup (path)));
STACK_UNWIND (frame, 0, 0, ctx);
return 0;
}
@@ -850,10 +851,11 @@ meta_readdir_cbk (call_frame_t *frame,
meta_private_t *priv = (meta_private_t *)this->private;
if ((int) cookie == 1) {
- dir_entry_t *dir = CALLOC (1, sizeof (dir_entry_t));
+ dir_entry_t *dir = GF_CALLOC (1, sizeof (dir_entry_t),
+ gf_meta_mt_dir_entry_t);
ERR_ABORT (dir);
- dir->name = strdup (".meta");
+ dir->name = gf_strdup (".meta");
memcpy (&dir->buf, priv->tree->stbuf, sizeof (struct stat));
dir->next = entries->next;
entries->next = dir;
@@ -887,7 +889,8 @@ meta_readdir (call_frame_t *frame,
dir_entry_t *entries = NULL;
while (dir) {
- dir_entry_t *d = CALLOC (1, sizeof (dir_entry_t));
+ dir_entry_t *d = GF_CALLOC (1, sizeof (dir_entry_t),
+ gf_meta_mt_dir_entry_t);
ERR_ABORT (d);
d->name = dir->name;
d->buf = *dir->stbuf;
@@ -897,7 +900,8 @@ meta_readdir (call_frame_t *frame,
dir = dir->next;
}
- dir_entry_t *header = CALLOC (1, sizeof (dir_entry_t));
+ dir_entry_t *header = GF_CALLOC (1, sizeof (dir_entry_t),
+ gf_meta_mt_dir_entry_t);
ERR_ABORT (header);
header->next = entries;
STACK_UNWIND (frame, 0, 0, header, count);
@@ -1163,16 +1167,16 @@ add_xlator_to_tree (meta_dirent_t *tree, xlator_t *this,
const char *prefix)
{
char *dir;
- asprintf (&dir, "%s/%s", prefix, this->name);
+ gf_asprintf (&dir, "%s/%s", prefix, this->name);
char *children;
- asprintf (&children, "%s/%s", dir, "subvolumes");
+ gf_asprintf (&children, "%s/%s", dir, "subvolumes");
char *type;
- asprintf (&type, "%s/%s", dir, "type");
+ gf_asprintf (&type, "%s/%s", dir, "type");
char *view;
- asprintf (&view, "%s/%s", dir, "view");
+ gf_asprintf (&view, "%s/%s", dir, "view");
insert_meta_entry (tree, dir, S_IFDIR, NULL, NULL);
insert_meta_entry (tree, children, S_IFDIR, NULL, NULL);
@@ -1194,9 +1198,10 @@ static void
build_meta_tree (xlator_t *this)
{
meta_private_t *priv = (meta_private_t *) this->private;
- priv->tree = CALLOC (1, sizeof (meta_dirent_t));
+ priv->tree = GF_CALLOC (1, sizeof (meta_dirent_t),
+ gf_meta_mt_meta_dirent_t);
ERR_ABORT (priv->tree);
- priv->tree->name = strdup (".meta");
+ priv->tree->name = gf_strdup (".meta");
priv->tree->stbuf = new_stbuf ();
priv->tree->stbuf->st_mode = S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH |
S_IXUSR | S_IXGRP | S_IXOTH;
@@ -1215,6 +1220,25 @@ build_meta_tree (xlator_t *this)
}
int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_meta_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)
{
if (this->parent != NULL) {
@@ -1222,12 +1246,13 @@ init (xlator_t *this)
return -1;
}
- meta_private_t *priv = CALLOC (1, sizeof (meta_private_t));
+ meta_private_t *priv = GF_CALLOC (1, sizeof (meta_private_t),
+ gf_meta_mt_meta_private_t);
ERR_ABORT (priv);
data_t *directory = dict_get (this->options, "directory");
if (directory) {
- priv->directory = strdup (data_to_str (directory));
+ priv->directory = gf_strdup (data_to_str (directory));
}
else {
priv->directory = ".meta";
diff --git a/xlators/meta/src/tree.c b/xlators/meta/src/tree.c
index a5ba08a3f3c..787f27da4f0 100644
--- a/xlators/meta/src/tree.c
+++ b/xlators/meta/src/tree.c
@@ -31,6 +31,7 @@
#include "xlator.h"
#include "meta.h"
+#include "meta-mem-types.h"
static int
is_meta_path (const char *path)
@@ -46,7 +47,7 @@ struct stat *
new_stbuf (void)
{
static int next_inode = 0;
- struct stat *stbuf = CALLOC (1, sizeof (struct stat));
+ struct stat *stbuf = GF_CALLOC (1, sizeof (struct stat), gf_meta_mt_stat);
ERR_ABORT (stbuf);
@@ -99,7 +100,7 @@ meta_dirent_t *
lookup_meta_entry (meta_dirent_t *root, const char *path,
char **remain)
{
- char *_path = strdup (path);
+ char *_path = gf_strdup (path);
if (!is_meta_path (path))
return NULL;
@@ -119,10 +120,10 @@ lookup_meta_entry (meta_dirent_t *root, const char *path,
while (piece) {
char *tmp = *remain;
if (*remain)
- asprintf (remain, "/%s/%s", *remain, piece);
+ gf_asprintf (remain, "/%s/%s", *remain, piece);
else
- asprintf (remain, "/%s", piece);
- if (tmp) free (tmp);
+ gf_asprintf (remain, "/%s", piece);
+ if (tmp) GF_FREE (tmp);
piece = strtok (NULL, "/");
}
}
@@ -132,7 +133,7 @@ lookup_meta_entry (meta_dirent_t *root, const char *path,
trav = ntrav;
}
- free (_path);
+ GF_FREE (_path);
return trav;
}
@@ -148,9 +149,10 @@ insert_meta_entry (meta_dirent_t *root, const char *path,
if (!dir)
return NULL;
- meta_dirent_t *new = CALLOC (1, sizeof (meta_dirent_t));
+ meta_dirent_t *new = GF_CALLOC (1, sizeof (meta_dirent_t),
+ gf_meta_mt_meta_dirent_t);
ERR_ABORT (new);
- new->name = strdup (slashpos+1);
+ new->name = gf_strdup (slashpos+1);
new->type = type;
new->parent = parent;
new->next = parent->children;
@@ -167,9 +169,10 @@ insert_meta_entry (meta_dirent_t *root, const char *path,
int main (void)
{
- meta_dirent_t *root = CALLOC (1, sizeof (meta_dirent_t));
+ meta_dirent_t *root = GF_CALLOC (1, sizeof (meta_dirent_t),
+ gf_meta_mt_meta_dirent_t);
ERR_ABORT (root);
- root->name = strdup (".meta");
+ root->name = gf_strdup (".meta");
insert_meta_entry (root, "/.meta/version", S_IFREG, NULL, NULL);
return 0;
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index b57dc0cfeb2..a6ff46a2659 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -48,6 +48,7 @@
#include "fuse_kernel.h"
#include "fuse-misc.h"
#include "fuse-mount.h"
+#include "fuse-mem-types.h"
#include "list.h"
#include "dict.h"
@@ -146,7 +147,7 @@ typedef struct fuse_private fuse_private_t;
finh->unique, finh->opcode); \
\
send_fuse_err (this, finh, ENOMEM); \
- FREE (finh); \
+ GF_FREE (finh); \
\
return; \
} \
@@ -186,7 +187,7 @@ free_state (fuse_state_t *state)
state->dict = (void *)0xaaaaeeee;
}
if (state->name) {
- FREE (state->name);
+ GF_FREE (state->name);
state->name = NULL;
}
if (state->fd) {
@@ -194,13 +195,13 @@ free_state (fuse_state_t *state)
state->fd = (void *)0xfdfdfdfd;
}
if (state->finh) {
- FREE (state->finh);
+ GF_FREE (state->finh);
state->finh = NULL;
}
#ifdef DEBUG
memset (state, 0x90, sizeof (*state));
#endif
- FREE (state);
+ GF_FREE (state);
state = NULL;
}
@@ -210,7 +211,8 @@ get_state (xlator_t *this, fuse_in_header_t *finh)
{
fuse_state_t *state = NULL;
- state = (void *)calloc (1, sizeof (*state));
+ state = (void *)GF_CALLOC (1, sizeof (*state),
+ gf_fuse_mt_fuse_state_t);
if (!state)
return NULL;
state->pool = this->ctx->pool;
@@ -619,7 +621,7 @@ fuse_forget (xlator_t *this, fuse_in_header_t *finh, void *msg)
inode_t *fuse_inode;
if (finh->nodeid == 1) {
- FREE (finh);
+ GF_FREE (finh);
return;
}
@@ -628,7 +630,7 @@ fuse_forget (xlator_t *this, fuse_in_header_t *finh, void *msg)
inode_forget (fuse_inode, ffi->nlookup);
inode_unref (fuse_inode);
- FREE (finh);
+ GF_FREE (finh);
}
@@ -1832,13 +1834,14 @@ fuse_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
frame->root->unique,
op_ret, state->size, state->off, stbuf->ia_size);
- iov_out = CALLOC (count + 1, sizeof (*iov_out));
+ iov_out = GF_CALLOC (count + 1, sizeof (*iov_out),
+ gf_fuse_mt_iovec);
if (iov_out) {
fouh.error = 0;
iov_out[0].iov_base = &fouh;
memcpy (iov_out + 1, vector, count * sizeof (*iov_out));
send_fuse_iov (this, finh, iov_out, count + 1);
- FREE (iov_out);
+ GF_FREE (iov_out);
} else
send_fuse_err (this, finh, ENOMEM);
} else {
@@ -2197,7 +2200,7 @@ fuse_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
strlen (entry->d_name));
}
- buf = CALLOC (1, size);
+ buf = GF_CALLOC (1, size, gf_fuse_mt_char);
if (!buf) {
gf_log ("glusterfs-fuse", GF_LOG_DEBUG,
"%"PRIu64": READDIR => -1 (%s)", frame->root->unique,
@@ -2223,7 +2226,7 @@ out:
free_state (state);
STACK_DESTROY (frame->root);
if (buf)
- FREE (buf);
+ GF_FREE (buf);
return 0;
}
@@ -2402,7 +2405,7 @@ fuse_setxattr (xlator_t *this, fuse_in_header_t *finh, void *msg)
#ifdef DISABLE_POSIX_ACL
if (!strncmp (name, "system.", 7)) {
send_fuse_err (this, finh, EOPNOTSUPP);
- FREE (finh);
+ GF_FREE (finh);
return;
}
#endif
@@ -2546,7 +2549,8 @@ fuse_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
priv->volfile_size = st.st_size;
- file = priv->volfile = CALLOC (1, priv->volfile_size);
+ file = priv->volfile = GF_CALLOC (1, priv->volfile_size,
+ gf_fuse_mt_char);
ret = lseek (fd, 0, SEEK_SET);
while ((ret = read (fd, file, GF_UNIT_KB)) > 0) {
file += ret;
@@ -2637,14 +2641,14 @@ fuse_getxattr (xlator_t *this, fuse_in_header_t *finh, void *msg)
#ifdef DISABLE_POSIX_ACL
if (!strncmp (name, "system.", 7)) {
send_fuse_err (this, finh, ENODATA);
- FREE (finh);
+ GF_FREE (finh);
return;
}
#endif
GET_STATE (this, finh, state);
state->size = fgxi->size;
- state->name = strdup (name);
+ state->name = gf_strdup (name);
ret = fuse_loc_fill (&state->loc, state, finh->nodeid, 0, NULL);
if ((state->loc.inode == NULL) ||
@@ -2950,7 +2954,7 @@ fuse_init (xlator_t *this, fuse_in_header_t *finh, void *msg)
}
out:
- FREE (finh);
+ GF_FREE (finh);
}
@@ -2959,7 +2963,7 @@ fuse_enosys (xlator_t *this, fuse_in_header_t *finh, void *msg)
{
send_fuse_err (this, finh, ENOSYS);
- FREE (finh);
+ GF_FREE (finh);
}
@@ -2968,7 +2972,7 @@ fuse_destroy (xlator_t *this, fuse_in_header_t *finh, void *msg)
{
send_fuse_err (this, finh, 0);
- FREE (finh);
+ GF_FREE (finh);
}
static fuse_handler_t *fuse_ops[FUSE_713_OP_HIGH];
@@ -3101,14 +3105,15 @@ fuse_thread_proc (void *data)
* but it's good enough in most cases (and we can handle
* rest via realloc).
*/
- iov_in[0].iov_base = CALLOC (1, msg0_size);
+ iov_in[0].iov_base = GF_CALLOC (1, msg0_size,
+ gf_fuse_mt_iov_base);
if (!iobuf || !iov_in[0].iov_base) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
if (iobuf)
iobuf_unref (iobuf);
- FREE (iov_in[0].iov_base);
+ GF_FREE (iov_in[0].iov_base);
sleep (10);
continue;
}
@@ -3160,7 +3165,7 @@ fuse_thread_proc (void *data)
else {
if (res > msg0_size) {
iov_in[0].iov_base =
- realloc (iov_in[0].iov_base, res);
+ GF_REALLOC (iov_in[0].iov_base, res);
if (iov_in[0].iov_base)
finh = (fuse_in_header_t *)
iov_in[0].iov_base;
@@ -3187,11 +3192,11 @@ fuse_thread_proc (void *data)
cont_err:
iobuf_unref (iobuf);
- FREE (iov_in[0].iov_base);
+ GF_FREE (iov_in[0].iov_base);
}
iobuf_unref (iobuf);
- FREE (iov_in[0].iov_base);
+ GF_FREE (iov_in[0].iov_base);
if (dict_get (this->options, ZR_MOUNTPOINT_OPT))
mount_point = data_to_str (dict_get (this->options,
@@ -3328,6 +3333,24 @@ notify (xlator_t *this, int32_t event, void *data, ...)
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_fuse_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_xl)
@@ -3350,7 +3373,7 @@ init (xlator_t *this_xl)
options = this_xl->options;
if (this_xl->name == NULL) {
- this_xl->name = strdup ("fuse");
+ this_xl->name = gf_strdup ("fuse");
if (!this_xl->name) {
gf_log ("glusterfs-fuse", GF_LOG_ERROR,
"Out of memory");
@@ -3360,7 +3383,7 @@ init (xlator_t *this_xl)
xl_name_allocated = 1;
}
- priv = CALLOC (1, sizeof (*priv));
+ priv = GF_CALLOC (1, sizeof (*priv), gf_fuse_mt_fuse_private_t);
if (!priv) {
gf_log ("glusterfs-fuse", GF_LOG_ERROR,
"Out of memory");
@@ -3404,7 +3427,7 @@ init (xlator_t *this_xl)
ZR_MOUNTPOINT_OPT, value_string);
goto cleanup_exit;
}
- priv->mount_point = strdup (value_string);
+ priv->mount_point = gf_strdup (value_string);
if (!priv->mount_point) {
gf_log ("glusterfs-fuse", GF_LOG_ERROR,
"Out of memory");
@@ -3503,12 +3526,12 @@ init (xlator_t *this_xl)
cleanup_exit:
if (xl_name_allocated)
- FREE (this_xl->name);
+ GF_FREE (this_xl->name);
if (priv) {
- FREE (priv->mount_point);
+ GF_FREE (priv->mount_point);
close (priv->fd);
}
- FREE (priv);
+ GF_FREE (priv);
return -1;
}
diff --git a/xlators/mount/fuse/src/fuse-mem-types.h b/xlators/mount/fuse/src/fuse-mem-types.h
new file mode 100644
index 00000000000..b0eb816cd14
--- /dev/null
+++ b/xlators/mount/fuse/src/fuse-mem-types.h
@@ -0,0 +1,35 @@
+/*
+ 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 __FUSE_MEM_TYPES_H__
+#define __FUSE_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_fuse_mem_types_ {
+ gf_fuse_mt_iovec = gf_common_mt_end + 1,
+ gf_fuse_mt_fuse_private_t,
+ gf_fuse_mt_char,
+ gf_fuse_mt_iov_base,
+ gf_fuse_mt_fuse_state_t,
+ gf_fuse_mt_end
+};
+#endif
+
diff --git a/xlators/nfs/lib/src/rpcsvc-auth.c b/xlators/nfs/lib/src/rpcsvc-auth.c
index 38697965bbd..f61fe91d0b2 100644
--- a/xlators/nfs/lib/src/rpcsvc-auth.c
+++ b/xlators/nfs/lib/src/rpcsvc-auth.c
@@ -36,7 +36,7 @@ rpcsvc_auth_add_initer (struct list_head *list, char *idfier,
if ((!list) || (!init) || (!idfier))
return -1;
- new = CALLOC (1, sizeof (*new));
+ new = GF_CALLOC (1, sizeof (*new), gf_common_mt_rpcsvc_auth_list);
if (!new) {
gf_log (GF_RPCSVC, GF_LOG_ERROR, "Memory allocation failed");
return -1;
@@ -312,7 +312,7 @@ rpcsvc_auth_array (rpcsvc_t *svc, char *volname, int *autharr, int arrlen)
if (count >= arrlen)
break;
- gen = asprintf (&srchstr, "rpc-auth.%s", auth->name);
+ gen = gf_asprintf (&srchstr, "rpc-auth.%s", auth->name);
if (gen == -1) {
count = -1;
goto err;
@@ -334,9 +334,9 @@ rpcsvc_auth_array (rpcsvc_t *svc, char *volname, int *autharr, int arrlen)
"d to read auth val");
}
- FREE (srchstr);
- spec = asprintf (&srchstr, "rpc-auth.%s.%s", auth->name,
- volname);
+ GF_FREE (srchstr);
+ spec = gf_asprintf (&srchstr, "rpc-auth.%s.%s", auth->name,
+ volname);
if (spec == -1) {
count = -1;
goto err;
@@ -360,7 +360,7 @@ rpcsvc_auth_array (rpcsvc_t *svc, char *volname, int *autharr, int arrlen)
"d to read auth val");
}
- FREE (srchstr);
+ GF_FREE (srchstr);
final = rpcsvc_combine_gen_spec_volume_checks (gen, spec);
if (final == RPCSVC_AUTH_ACCEPT) {
autharr[count] = auth->auth->authnum;
diff --git a/xlators/nfs/lib/src/rpcsvc.c b/xlators/nfs/lib/src/rpcsvc.c
index 47510ad8a35..bcb8af65241 100644
--- a/xlators/nfs/lib/src/rpcsvc.c
+++ b/xlators/nfs/lib/src/rpcsvc.c
@@ -78,7 +78,7 @@ rpcsvc_stage_init (rpcsvc_t *svc)
if (!svc)
return NULL;
- stg = CALLOC (1, sizeof(*stg));
+ stg = GF_CALLOC (1, sizeof(*stg), gf_common_mt_rpcsvc_stage_t);
if (!stg)
return NULL;
@@ -106,7 +106,7 @@ rpcsvc_stage_init (rpcsvc_t *svc)
ret = 0;
free_stg:
if (ret == -1) {
- FREE (stg);
+ GF_FREE (stg);
stg = NULL;
}
@@ -135,7 +135,7 @@ rpcsvc_init (glusterfs_ctx_t *ctx, dict_t *options)
if ((!ctx) || (!options))
return NULL;
- svc = CALLOC (1, sizeof (*svc));
+ svc = GF_CALLOC (1, sizeof (*svc), gf_common_mt_rpcsvc_t);
if (!svc)
return NULL;
@@ -169,7 +169,7 @@ rpcsvc_init (glusterfs_ctx_t *ctx, dict_t *options)
ret = 0;
free_svc:
if (ret == -1) {
- FREE (svc);
+ GF_FREE (svc);
svc = NULL;
}
@@ -248,7 +248,7 @@ rpcsvc_conn_peer_check_allow (dict_t *options, char *volname, char *clstr)
* subvolumes.
*/
if (volname) {
- ret = asprintf (&srchstr, "rpc-auth.addr.%s.allow", volname);
+ ret = gf_asprintf (&srchstr, "rpc-auth.addr.%s.allow", volname);
if (ret == -1) {
gf_log (GF_RPCSVC, GF_LOG_ERROR, "asprintf failed");
ret = RPCSVC_AUTH_DONTCARE;
@@ -259,7 +259,7 @@ rpcsvc_conn_peer_check_allow (dict_t *options, char *volname, char *clstr)
ret = rpcsvc_conn_peer_check_search (options, srchstr, clstr);
if (volname)
- FREE (srchstr);
+ GF_FREE (srchstr);
if (ret == 0)
ret = RPCSVC_AUTH_ACCEPT;
@@ -280,7 +280,7 @@ rpcsvc_conn_peer_check_reject (dict_t *options, char *volname, char *clstr)
return ret;
if (volname) {
- ret = asprintf (&srchstr, "rpc-auth.addr.%s.reject", volname);
+ ret = gf_asprintf (&srchstr, "rpc-auth.addr.%s.reject", volname);
if (ret == -1) {
gf_log (GF_RPCSVC, GF_LOG_ERROR, "asprintf failed");
ret = RPCSVC_AUTH_REJECT;
@@ -291,7 +291,7 @@ rpcsvc_conn_peer_check_reject (dict_t *options, char *volname, char *clstr)
ret = rpcsvc_conn_peer_check_search (options, srchstr, clstr);
if (volname)
- FREE (srchstr);
+ GF_FREE (srchstr);
if (ret == 0)
ret = RPCSVC_AUTH_REJECT;
@@ -591,14 +591,14 @@ rpcsvc_volume_allowed (dict_t *options, char *volname)
if ((!options) || (!volname))
return NULL;
- ret = asprintf (&srchstr, "rpc-auth.addr.%s.allow", volname);
+ ret = gf_asprintf (&srchstr, "rpc-auth.addr.%s.allow", volname);
if (ret == -1) {
gf_log (GF_RPCSVC, GF_LOG_ERROR, "asprintf failed");
goto out;
}
if (!dict_get (options, srchstr)) {
- FREE (srchstr);
+ GF_FREE (srchstr);
srchstr = globalrule;
ret = dict_get_str (options, srchstr, &addrstr);
} else
@@ -617,7 +617,7 @@ rpcsvc_conn_init (rpcsvc_t *svc, rpcsvc_program_t *prog, int sockfd)
int ret = -1;
unsigned int poolcount = 0;
- conn = CALLOC (1, sizeof(*conn));
+ conn = GF_CALLOC (1, sizeof(*conn), gf_common_mt_rpcsvc_conn_t);
if (!conn) {
gf_log (GF_RPCSVC, GF_LOG_ERROR, "memory allocation failed");
return NULL;
@@ -659,7 +659,7 @@ free_txp:
free_conn:
if (ret == -1) {
- FREE (conn);
+ GF_FREE (conn);
conn = NULL;
}
@@ -677,7 +677,7 @@ rpcsvc_conn_destroy (rpcsvc_conn_t *conn)
conn->program->conn_destroy (conn->program->private, conn);
/* Need to destory record state, txlists etc. */
- FREE (conn);
+ GF_FREE (conn);
gf_log (GF_RPCSVC, GF_LOG_DEBUG, "Connection destroyed");
}
@@ -917,7 +917,7 @@ rpcsvc_conn_privport_check (rpcsvc_t *svc, char *volname, rpcsvc_conn_t *conn)
}
/* Disabled by default */
- ret = asprintf (&srchstr, "rpc-auth.ports.%s.insecure", volname);
+ ret = gf_asprintf (&srchstr, "rpc-auth.ports.%s.insecure", volname);
if (ret == -1) {
gf_log (GF_RPCSVC, GF_LOG_ERROR, "asprintf failed");
ret = RPCSVC_AUTH_REJECT;
@@ -2632,7 +2632,7 @@ rpcsvc_program_register (rpcsvc_t *svc, rpcsvc_program_t program)
if (!svc)
return -1;
- newprog = CALLOC (1, sizeof(*newprog));
+ newprog = GF_CALLOC (1, sizeof(*newprog), gf_common_mt_rpcsvc_program_t);
if (!newprog)
return -1;
@@ -2666,7 +2666,7 @@ free_prog:
gf_log (GF_RPCSVC, GF_LOG_ERROR, "Program registration failed:"
" %s, Num: %d, Ver: %d, Port: %d", newprog->progname,
newprog->prognum, newprog->progver, newprog->progport);
- FREE (newprog);
+ GF_FREE (newprog);
}
return ret;
diff --git a/xlators/nfs/lib/src/xdr-nfs3.c b/xlators/nfs/lib/src/xdr-nfs3.c
index 7d8075a56ca..d7984be56a4 100644
--- a/xlators/nfs/lib/src/xdr-nfs3.c
+++ b/xlators/nfs/lib/src/xdr-nfs3.c
@@ -1841,15 +1841,15 @@ xdr_free_exports_list (struct exportnode *first)
while (first) {
elist = first->ex_next;
if (first->ex_dir)
- FREE (first->ex_dir);
+ GF_FREE (first->ex_dir);
if (first->ex_groups) {
if (first->ex_groups->gr_name)
- FREE (first->ex_groups->gr_name);
- FREE (first->ex_groups);
+ GF_FREE (first->ex_groups->gr_name);
+ GF_FREE (first->ex_groups);
}
- FREE (first);
+ GF_FREE (first);
first = elist;
}
@@ -1865,10 +1865,10 @@ xdr_free_mountlist (mountlist ml)
return;
while (ml) {
- FREE (ml->ml_hostname);
- FREE (ml->ml_directory);
+ GF_FREE (ml->ml_hostname);
+ GF_FREE (ml->ml_directory);
next = ml->ml_next;
- FREE (ml);
+ GF_FREE (ml);
ml = next;
}
@@ -1885,8 +1885,8 @@ xdr_free_write3args_nocopy (write3args *wa)
if (!wa)
return;
- FREE (wa->file.data.data_val);
- FREE (wa);
+ GF_FREE (wa->file.data.data_val);
+ GF_FREE (wa);
}
diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c
index db4a88e3d69..c3792b314bd 100644
--- a/xlators/nfs/server/src/mount3.c
+++ b/xlators/nfs/server/src/mount3.c
@@ -36,6 +36,7 @@
#include "nfs-generics.h"
#include "locking.h"
#include "iatt.h"
+#include "nfs-mem-types.h"
#include <errno.h>
@@ -182,7 +183,7 @@ mnt3svc_update_mountlist (struct mount3_state *ms, rpcsvc_request_t *req,
if ((!ms) || (!req) || (!exportxl))
return -1;
- me = (struct mountentry *)CALLOC (1, sizeof (*me));
+ me = (struct mountentry *)GF_CALLOC (1, sizeof (*me), gf_nfs_mt_mountentry);
if (!me)
return -1;
@@ -203,7 +204,7 @@ mnt3svc_update_mountlist (struct mount3_state *ms, rpcsvc_request_t *req,
free_err:
if (ret == -1)
- FREE (me);
+ GF_FREE (me);
return ret;
}
@@ -387,14 +388,15 @@ __build_mountlist (struct mount3_state *ms, int *count)
gf_log (GF_MNT, GF_LOG_DEBUG, "Building mount list:");
list_for_each_entry (me, &ms->mountlist, mlist) {
namelen = strlen (me->exname);
- mlist = CALLOC (1, sizeof (*mlist));
+ mlist = GF_CALLOC (1, sizeof (*mlist), gf_nfs_mt_mountbody);
if (!mlist) {
gf_log (GF_MNT, GF_LOG_ERROR, "Memory allocation"
" failed");
goto free_list;
}
- mlist->ml_directory = CALLOC (namelen + 2, sizeof (char));
+ mlist->ml_directory = GF_CALLOC (namelen + 2, sizeof (char),
+ gf_nfs_mt_char);
if (!mlist->ml_directory) {
gf_log (GF_MNT, GF_LOG_ERROR, "Memory allocation"
" failed");
@@ -405,7 +407,8 @@ __build_mountlist (struct mount3_state *ms, int *count)
strcat (mlist->ml_directory, me->exname);
namelen = strlen (me->hostname);
- mlist->ml_hostname = CALLOC (namelen + 2, sizeof (char));
+ mlist->ml_hostname = GF_CALLOC (namelen + 2, sizeof (char),
+ gf_nfs_mt_char);
if (!mlist->ml_hostname) {
gf_log (GF_MNT, GF_LOG_ERROR, "Memory allocation"
" failed");
@@ -526,7 +529,7 @@ __mnt3svc_umount (struct mount3_state *ms, char *dirpath, char *hostname)
gf_log (GF_MNT, GF_LOG_DEBUG, "Unmounting: dir %s, host: %s",
me->exname, me->hostname);
list_del (&me->mlist);
- FREE (me);
+ GF_FREE (me);
ret = 0;
ret:
return ret;
@@ -635,7 +638,7 @@ __mnt3svc_umountall (struct mount3_state *ms)
list_for_each_entry (me, &ms->mountlist, mlist) {
list_del (&me->mlist);
- FREE (me);
+ GF_FREE (me);
}
return 0;
@@ -701,14 +704,15 @@ mnt3_xlchildren_to_exports (rpcsvc_t *svc, xlator_list_t *cl)
while (cl) {
namelen = strlen (cl->xlator->name);
- elist = CALLOC (1, sizeof (*elist));
+ elist = GF_CALLOC (1, sizeof (*elist), gf_nfs_mt_exportnode);
if (!elist) {
gf_log (GF_MNT, GF_LOG_ERROR, "Memory allocation"
" failed");
goto free_list;
}
- elist->ex_dir = CALLOC (namelen + 2, sizeof (char));
+ elist->ex_dir = GF_CALLOC (namelen + 2, sizeof (char),
+ gf_nfs_mt_char);
if (!elist->ex_dir) {
gf_log (GF_MNT, GF_LOG_ERROR, "Memory allocation"
" failed");
@@ -720,11 +724,12 @@ mnt3_xlchildren_to_exports (rpcsvc_t *svc, xlator_list_t *cl)
addrstr = rpcsvc_volume_allowed (svc->options,cl->xlator->name);
if (addrstr)
- addrstr = strdup (addrstr);
+ addrstr = gf_strdup (addrstr);
else
- addrstr = strdup ("No Access");
+ addrstr = gf_strdup ("No Access");
- elist->ex_groups = CALLOC (1, sizeof (struct groupnode));
+ elist->ex_groups = GF_CALLOC (1, sizeof (struct groupnode),
+ gf_nfs_mt_groupnode);
if (!elist->ex_groups) {
gf_log (GF_MNT, GF_LOG_ERROR, "Memory allocation"
" failed");
@@ -801,7 +806,7 @@ mnt3_init_state (xlator_t *nfsx)
if (!nfsx)
return NULL;
- ms = CALLOC (1, sizeof (*ms));
+ ms = GF_CALLOC (1, sizeof (*ms), gf_nfs_mt_mount3_state);
if (!ms) {
gf_log (GF_MNT, GF_LOG_ERROR, "Memory allocation failed");
return NULL;
diff --git a/xlators/nfs/server/src/nfs-common.c b/xlators/nfs/server/src/nfs-common.c
index 3623f041c14..69bf46702eb 100644
--- a/xlators/nfs/server/src/nfs-common.c
+++ b/xlators/nfs/server/src/nfs-common.c
@@ -30,6 +30,7 @@
#include "iobuf.h"
#include "nfs-common.h"
#include "nfs-fops.h"
+#include "nfs-mem-types.h"
#include "rpcsvc.h"
#include "iatt.h"
@@ -144,7 +145,7 @@ nfs_loc_wipe (loc_t *loc)
return;
if (loc->path) {
- FREE (loc->path);
+ GF_FREE ((char *)loc->path);
loc->path = NULL;
}
@@ -175,7 +176,7 @@ nfs_loc_copy (loc_t *dst, loc_t *src)
if (src->parent)
dst->parent = inode_ref (src->parent);
- dst->path = strdup (src->path);
+ dst->path = gf_strdup (src->path);
if (!dst->path)
goto out;
@@ -206,7 +207,7 @@ nfs_loc_fill (loc_t *loc, inode_t *inode, inode_t *parent, char *path)
if (parent)
loc->parent = inode_ref (parent);
- loc->path = strdup (path);
+ loc->path = gf_strdup (path);
if (!loc->path) {
gf_log (GF_NFS, GF_LOG_ERROR, "strdup failed");
goto loc_wipe;
@@ -258,7 +259,7 @@ err:
inode_unref (parent);
if (resolvedpath)
- FREE (resolvedpath);
+ GF_FREE (resolvedpath);
return ret;
}
@@ -370,7 +371,7 @@ err:
inode_unref (entryinode);
if (resolvedpath)
- FREE (resolvedpath);
+ GF_FREE (resolvedpath);
return ret;
}
diff --git a/xlators/nfs/server/src/nfs-mem-types.h b/xlators/nfs/server/src/nfs-mem-types.h
new file mode 100644
index 00000000000..118ee2d23b0
--- /dev/null
+++ b/xlators/nfs/server/src/nfs-mem-types.h
@@ -0,0 +1,46 @@
+/*
+ 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 __NFS_MEM_TYPES_H__
+#define __NFS_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_nfs_mem_types_ {
+ gf_nfs_mt_mountentry = gf_common_mt_end + 1,
+ gf_nfs_mt_mountbody,
+ gf_nfs_mt_nfs_state,
+ gf_nfs_mt_char,
+ gf_nfs_mt_exportnode,
+ gf_nfs_mt_groupnode,
+ gf_nfs_mt_mount3_state,
+ gf_nfs_mt_write3args,
+ gf_nfs_mt_nfs3_export,
+ gf_nfs_mt_nfs3_state,
+ gf_nfs_mt_entry3,
+ gf_nfs_mt_entryp3,
+ gf_nfs_mt_nfs3_fd_entry,
+ gf_nfs_mt_nfs_initer_list,
+ gf_nfs_mt_xlator_t,
+ gf_nfs_mt_list_head,
+ gf_nfs_mt_end
+};
+#endif
+
diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c
index b598b0c69da..fa7edc9ff6a 100644
--- a/xlators/nfs/server/src/nfs.c
+++ b/xlators/nfs/server/src/nfs.c
@@ -38,6 +38,7 @@
#include "inode.h"
#include "mount3.h"
#include "nfs3.h"
+#include "nfs-mem-types.h"
/* Every NFS version must call this function with the init function
* for its particular version.
@@ -49,7 +50,7 @@ nfs_add_initer (struct list_head *list, nfs_version_initer_t init)
if ((!list) || (!init))
return -1;
- new = CALLOC (1, sizeof (*new));
+ new = GF_CALLOC (1, sizeof (*new), gf_nfs_mt_nfs_initer_list);
if (!new) {
gf_log (GF_NFS, GF_LOG_ERROR, "Memory allocation failed");
return -1;
@@ -356,7 +357,8 @@ nfs_init_subvolumes (struct nfs_state *nfs, xlator_list_t *cl)
}
LOCK_INIT (&nfs->svinitlock);
- nfs->initedxl = CALLOC (svcount, sizeof (xlator_t *));
+ nfs->initedxl = GF_CALLOC (svcount, sizeof (xlator_t *),
+ gf_nfs_mt_xlator_t );
if (!nfs->initedxl) {
gf_log (GF_NFS, GF_LOG_ERROR, "Failed to allocated inited xls");
ret = -1;
@@ -435,6 +437,24 @@ nfs_request_user_init (nfs_user_t *nfu, rpcsvc_request_t *req)
return;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_nfs_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) {
@@ -452,7 +472,7 @@ init (xlator_t *this) {
return -1;
}
- nfs = CALLOC (1, sizeof (*nfs));
+ nfs = GF_CALLOC (1, sizeof (*nfs), gf_nfs_mt_nfs_state);
if (!nfs) {
gf_log (GF_NFS, GF_LOG_ERROR, "memory allocation failed");
return -1;
diff --git a/xlators/nfs/server/src/nfs3-helpers.c b/xlators/nfs/server/src/nfs3-helpers.c
index 72861dfd0e8..52bb7169a72 100644
--- a/xlators/nfs/server/src/nfs3-helpers.c
+++ b/xlators/nfs/server/src/nfs3-helpers.c
@@ -33,6 +33,7 @@
#include "nfs-inodes.h"
#include "nfs-generics.h"
#include "nfs3-helpers.h"
+#include "nfs-mem-types.h"
#include "iatt.h"
#include <string.h>
@@ -708,16 +709,17 @@ nfs3_fill_entry3 (gf_dirent_t *entry)
if (!entry)
return NULL;
- ent = CALLOC (1, sizeof (*ent));
+ ent = GF_CALLOC (1, sizeof (*ent), gf_nfs_mt_entry3);
if (!ent)
return NULL;
gf_log (GF_NFS3, GF_LOG_TRACE, "Entry: %s", entry->d_name);
ent->fileid = entry->d_ino;
ent->cookie = entry->d_off;
- ent->name = CALLOC ((strlen (entry->d_name) + 1), sizeof (char));
+ ent->name = GF_CALLOC ((strlen (entry->d_name) + 1), sizeof (char),
+ gf_nfs_mt_char);
if (!ent->name) {
- FREE (ent);
+ GF_FREE (ent);
ent = NULL;
goto err;
}
@@ -754,7 +756,7 @@ nfs3_fh_to_post_op_fh3 (struct nfs3_fh *fh)
pfh.handle_follows = 1;
- fhp = CALLOC (1, sizeof (*fh));
+ fhp = GF_CALLOC (1, sizeof (*fh), gf_nfs_mt_char);
if (!fhp)
return pfh;
@@ -775,15 +777,16 @@ nfs3_fill_entryp3 (gf_dirent_t *entry, struct nfs3_fh *dirfh)
gf_log (GF_NFS3, GF_LOG_TRACE, "Entry: %s, ino: %"PRIu64,
entry->d_name, entry->d_ino);
- ent = CALLOC (1, sizeof (*ent));
+ ent = GF_CALLOC (1, sizeof (*ent), gf_nfs_mt_entryp3);
if (!ent)
return NULL;
ent->fileid = entry->d_ino;
ent->cookie = entry->d_off;
- ent->name = CALLOC ((strlen (entry->d_name) + 1), sizeof (char));
+ ent->name = GF_CALLOC ((strlen (entry->d_name) + 1), sizeof (char),
+ gf_nfs_mt_char);
if (!ent->name) {
- FREE (ent);
+ GF_FREE (ent);
ent = NULL;
goto err;
}
@@ -937,9 +940,9 @@ nfs3_free_readdirp3res (readdirp3res *res)
while (ent) {
next = ent->nextentry;
- FREE (ent->name);
- FREE (ent->name_handle.post_op_fh3_u.handle.data.data_val);
- FREE (ent);
+ GF_FREE (ent->name);
+ GF_FREE (ent->name_handle.post_op_fh3_u.handle.data.data_val);
+ GF_FREE (ent);
ent = next;
}
@@ -960,8 +963,8 @@ nfs3_free_readdir3res (readdir3res *res)
while (ent) {
next = ent->nextentry;
- FREE (ent->name);
- FREE (ent);
+ GF_FREE (ent->name);
+ GF_FREE (ent);
ent = next;
}
@@ -1810,7 +1813,7 @@ __nfs3_fdcache_remove_entry (struct nfs3_state *nfs3, struct nfs3_fd_entry *fde)
list_del (&fde->list);
fd_ctx_del (fde->cachedfd, nfs3->nfsx, NULL);
fd_unref (fde->cachedfd);
- FREE (fde);
+ GF_FREE (fde);
--nfs3->fdcount;
return 0;
@@ -1869,7 +1872,7 @@ nfs3_fdcache_add (struct nfs3_state *nfs3, fd_t *fd)
if ((!nfs3) || (!fd))
return -1;
- fde = CALLOC (1, sizeof (*fd));
+ fde = GF_CALLOC (1, sizeof (*fd), gf_nfs_mt_nfs3_fd_entry);
if (!fde) {
gf_log (GF_NFS3, GF_LOG_ERROR, "fd entry allocation failed");
goto out;
@@ -1939,7 +1942,7 @@ __nfs3_queue_call_state (nfs3_call_state_t *cs)
goto attach_cs;
}
- inode_q = CALLOC (1, sizeof (*inode_q));
+ inode_q = GF_CALLOC (1, sizeof (*inode_q), gf_nfs_mt_list_head);
if (!inode_q)
goto err;
@@ -2844,7 +2847,7 @@ nfs3_fh_resolve_and_resume (nfs3_call_state_t *cs, struct nfs3_fh *fh,
if (!entry)
ret = nfs3_fh_resolve_inode (cs);
else {
- cs->resolventry = strdup (entry);
+ cs->resolventry = gf_strdup (entry);
if (!cs->resolventry)
goto err;
diff --git a/xlators/nfs/server/src/nfs3.c b/xlators/nfs/server/src/nfs3.c
index 57d9f576eb1..a4ef1c6fc2c 100644
--- a/xlators/nfs/server/src/nfs3.c
+++ b/xlators/nfs/server/src/nfs3.c
@@ -36,6 +36,7 @@
#include "nfs-inodes.h"
#include "nfs-generics.h"
#include "nfs3-helpers.h"
+#include "nfs-mem-types.h"
#include <sys/socket.h>
@@ -203,10 +204,10 @@ nfs3_call_state_wipe (nfs3_call_state_t *cs)
fd_unref (cs->resolve_dir_fd);
if (cs->resolventry)
- FREE (cs->resolventry);
+ GF_FREE (cs->resolventry);
if (cs->pathname)
- FREE (cs->pathname);
+ GF_FREE (cs->pathname);
if (!list_empty (&cs->entries.list))
gf_dirent_free (&cs->entries);
@@ -1810,7 +1811,7 @@ nfs3svc_write_vecsizer (rpcsvc_request_t *req, ssize_t *readsize, int *newbuf)
rpcsvc_request_set_private (req, NFS3_VECWRITE_READREST);
ret = 0;
} else if (state == NFS3_VECWRITE_READREST) {
- args = CALLOC (1, sizeof (*args));
+ args = GF_CALLOC (1, sizeof (*args), gf_nfs_mt_write3args);
if (!args)
goto rpcerr;
@@ -2490,7 +2491,7 @@ nfs3_symlink (rpcsvc_request_t *req, struct nfs3_fh *dirfh, char *name,
nfs3_handle_call_state_init (nfs3, cs, req, vol, stat, nfs3err);
cs->parent = *dirfh;
- cs->pathname = strdup (target);
+ cs->pathname = gf_strdup (target);
if (!cs->pathname) {
ret = -1;
stat = NFS3ERR_SERVERFAULT;
@@ -3284,7 +3285,7 @@ nfs3_rename (rpcsvc_request_t *req, struct nfs3_fh *olddirfh, char *oldname,
* of the dest (fh,name) pair.
*/
cs->fh = *newdirfh;
- cs->pathname = strdup (newname);
+ cs->pathname = gf_strdup (newname);
if (!cs->pathname) {
stat = NFS3ERR_SERVERFAULT;
ret = -1;
@@ -3470,7 +3471,7 @@ nfs3_link (rpcsvc_request_t *req, struct nfs3_fh *targetfh,
nfs3_handle_call_state_init (nfs3, cs, req, vol, stat, nfs3err);
cs->fh = *dirfh;
- cs->pathname = strdup (newname);
+ cs->pathname = gf_strdup (newname);
if (!cs->pathname) {
stat = NFS3ERR_SERVERFAULT;
ret = -1;
@@ -4735,7 +4736,8 @@ nfs3_init_subvolumes (struct nfs3_state *nfs3, xlator_t *nfsx)
xl_list = xl_list->next;
}
- nfs3->exports = CALLOC (xl_count, sizeof (struct nfs3_export));
+ nfs3->exports = GF_CALLOC (xl_count, sizeof (struct nfs3_export),
+ gf_nfs_mt_nfs3_export);
if (!nfs3->exports) {
gf_log (GF_NFS3, GF_LOG_ERROR, "Memory allocation failed");
goto err;
@@ -4772,7 +4774,8 @@ nfs3_init_state (xlator_t *nfsx)
if (!nfsx)
return NULL;
- nfs3 = (struct nfs3_state *)CALLOC (1, sizeof (*nfs3));
+ nfs3 = (struct nfs3_state *)GF_CALLOC (1, sizeof (*nfs3),
+ gf_nfs_mt_nfs3_state);
if (!nfs3) {
gf_log (GF_NFS3, GF_LOG_ERROR, "Memory allocation failed");
return NULL;
@@ -4817,7 +4820,7 @@ free_localpool:
ret:
if (ret == -1) {
- FREE (nfs3);
+ GF_FREE (nfs3);
nfs3 = NULL;
}
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
index 9bf20be5bb5..9f402f1dace 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -27,6 +27,7 @@
#include "dict.h"
#include "xlator.h"
#include "io-cache.h"
+#include "ioc-mem-types.h"
#include <assert.h>
#include <sys/time.h>
@@ -259,7 +260,8 @@ ioc_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
ioc_local_t *local = NULL;
int32_t op_errno = -1, ret = -1;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_ioc_mt_ioc_local_t);
if (local == NULL) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -401,7 +403,8 @@ ioc_wait_on_inode (ioc_inode_t *ioc_inode, ioc_page_t *page)
}
if (!page_found) {
- waiter = CALLOC (1, sizeof (ioc_waitq_t));
+ waiter = GF_CALLOC (1, sizeof (ioc_waitq_t),
+ gf_ioc_mt_ioc_waitq_t);
if (waiter == NULL) {
gf_log (ioc_inode->table->xl->name, GF_LOG_ERROR,
"out of memory");
@@ -436,7 +439,8 @@ ioc_cache_validate (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,
int32_t ret = 0;
local = frame->local;
- validate_local = CALLOC (1, sizeof (ioc_local_t));
+ validate_local = GF_CALLOC (1, sizeof (ioc_local_t),
+ gf_ioc_mt_ioc_local_t);
if (validate_local == NULL) {
ret = -1;
local->op_ret = -1;
@@ -451,7 +455,7 @@ ioc_cache_validate (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,
ret = -1;
local->op_ret = -1;
local->op_errno = ENOMEM;
- FREE (validate_local);
+ GF_FREE (validate_local);
gf_log (ioc_inode->table->xl->name, GF_LOG_ERROR,
"out of memory");
goto out;
@@ -563,7 +567,7 @@ ioc_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
}
}
- FREE (local);
+ GF_FREE (local);
frame->local = NULL;
STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd);
@@ -641,7 +645,7 @@ ioc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
frame->local = NULL;
- FREE (local);
+ GF_FREE (local);
STACK_UNWIND_STRICT (create, frame, op_ret, op_errno, fd, inode, buf,
preparent, postparent);
@@ -664,7 +668,7 @@ ioc_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
ioc_local_t *local = NULL;
- local = CALLOC (1, sizeof (ioc_local_t));
+ local = GF_CALLOC (1, sizeof (ioc_local_t), gf_ioc_mt_ioc_local_t);
if (local == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
STACK_UNWIND_STRICT (open, frame, -1, ENOMEM, NULL);
@@ -698,8 +702,8 @@ ioc_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
mode_t mode, fd_t *fd)
{
ioc_local_t *local = NULL;
-
- local = CALLOC (1, sizeof (ioc_local_t));
+
+ local = GF_CALLOC (1, sizeof (ioc_local_t), gf_ioc_mt_ioc_local_t);
if (local == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
STACK_UNWIND_STRICT (create, frame, -1, ENOMEM, NULL, NULL,
@@ -1021,7 +1025,8 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
return 0;
}
- local = (ioc_local_t *) CALLOC (1, sizeof (ioc_local_t));
+ local = (ioc_local_t *) GF_CALLOC (1, sizeof (ioc_local_t),
+ gf_ioc_mt_ioc_local_t);
if (local == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
op_errno = ENOMEM;
@@ -1105,7 +1110,7 @@ ioc_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
ioc_local_t *local = NULL;
uint64_t ioc_inode = 0;
- local = CALLOC (1, sizeof (ioc_local_t));
+ local = GF_CALLOC (1, sizeof (ioc_local_t), gf_ioc_mt_ioc_local_t);
if (local == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -1270,7 +1275,7 @@ ioc_get_priority_list (const char *opt_str, struct list_head *first)
char *string = NULL;
struct ioc_priority *curr = NULL, *tmp = NULL;
- string = strdup (opt_str);
+ string = gf_strdup (opt_str);
if (string == NULL) {
max_pri = -1;
goto out;
@@ -1284,7 +1289,8 @@ ioc_get_priority_list (const char *opt_str, struct list_head *first)
*/
stripe_str = strtok_r (string, ",", &tmp_str);
while (stripe_str) {
- curr = CALLOC (1, sizeof (struct ioc_priority));
+ curr = GF_CALLOC (1, sizeof (struct ioc_priority),
+ gf_ioc_mt_ioc_priority);
if (curr == NULL) {
max_pri = -1;
goto out;
@@ -1292,7 +1298,7 @@ ioc_get_priority_list (const char *opt_str, struct list_head *first)
list_add_tail (&curr->list, first);
- dup_str = strdup (stripe_str);
+ dup_str = gf_strdup (stripe_str);
if (dup_str == NULL) {
max_pri = -1;
goto out;
@@ -1315,7 +1321,7 @@ ioc_get_priority_list (const char *opt_str, struct list_head *first)
pattern,
priority);
- curr->pattern = strdup (pattern);
+ curr->pattern = gf_strdup (pattern);
if (curr->pattern == NULL) {
max_pri = -1;
goto out;
@@ -1329,31 +1335,50 @@ ioc_get_priority_list (const char *opt_str, struct list_head *first)
max_pri = max (max_pri, curr->priority);
}
- free (dup_str);
+ GF_FREE (dup_str);
dup_str = NULL;
stripe_str = strtok_r (NULL, ",", &tmp_str);
}
out:
if (string != NULL) {
- free (string);
+ GF_FREE (string);
}
if (dup_str != NULL) {
- free (dup_str);
+ GF_FREE (dup_str);
}
if (max_pri == -1) {
list_for_each_entry_safe (curr, tmp, first, list) {
list_del_init (&curr->list);
- free (curr->pattern);
- free (curr);
+ GF_FREE (curr->pattern);
+ GF_FREE (curr);
}
}
return max_pri;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_ioc_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
/*
* init -
* @this:
@@ -1381,7 +1406,7 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- table = (void *) CALLOC (1, sizeof (*table));
+ table = (void *) GF_CALLOC (1, sizeof (*table), gf_ioc_mt_ioc_table_t);
if (table == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
goto out;
@@ -1477,7 +1502,9 @@ init (xlator_t *this)
goto out;
}
- table->inode_lru = CALLOC (table->max_pri, sizeof (struct list_head));
+ table->inode_lru = GF_CALLOC (table->max_pri,
+ sizeof (struct list_head),
+ gf_ioc_mt_list_head);
if (table->inode_lru == NULL) {
goto out;
}
@@ -1495,8 +1522,8 @@ init (xlator_t *this)
out:
if (ret == -1) {
if (table != NULL) {
- free (table->inode_lru);
- free (table);
+ GF_FREE (table->inode_lru);
+ GF_FREE (table);
}
}
@@ -1518,7 +1545,7 @@ fini (xlator_t *this)
return;
pthread_mutex_destroy (&table->table_lock);
- FREE (table);
+ GF_FREE (table);
this->private = NULL;
return;
diff --git a/xlators/performance/io-cache/src/ioc-inode.c b/xlators/performance/io-cache/src/ioc-inode.c
index 763f329db14..5619134814c 100644
--- a/xlators/performance/io-cache/src/ioc-inode.c
+++ b/xlators/performance/io-cache/src/ioc-inode.c
@@ -23,6 +23,7 @@
#endif
#include "io-cache.h"
+#include "ioc-mem-types.h"
extern int ioc_log2_page_size;
@@ -51,7 +52,7 @@ ptr_to_str (void *ptr)
{
int ret = 0;
char *str = NULL;
- ret = asprintf (&str, "%p", ptr);
+ ret = gf_asprintf (&str, "%p", ptr);
if (-1 == ret) {
gf_log ("ioc", GF_LOG_ERROR,
"asprintf failed while converting ptr to str");
@@ -137,7 +138,7 @@ ioc_inode_wakeup (call_frame_t *frame, ioc_inode_t *ioc_inode,
waiter = waiter->next;
waited->data = NULL;
- free (waited);
+ GF_FREE (waited);
}
}
@@ -157,7 +158,8 @@ ioc_inode_update (ioc_table_t *table, inode_t *inode, uint32_t weight)
ioc_inode_t *ioc_inode = NULL;
unsigned long no_of_pages = 0;
- ioc_inode = CALLOC (1, sizeof (ioc_inode_t));
+ ioc_inode = GF_CALLOC (1, sizeof (ioc_inode_t),
+ gf_ioc_mt_ioc_inode_t);
if (ioc_inode == NULL) {
goto out;
}
@@ -213,5 +215,5 @@ ioc_inode_destroy (ioc_inode_t *ioc_inode)
rbthash_table_destroy (ioc_inode->cache.page_table);
pthread_mutex_destroy (&ioc_inode->inode_lock);
- free (ioc_inode);
+ GF_FREE (ioc_inode);
}
diff --git a/xlators/performance/io-cache/src/ioc-mem-types.h b/xlators/performance/io-cache/src/ioc-mem-types.h
new file mode 100644
index 00000000000..d1da65ca1c7
--- /dev/null
+++ b/xlators/performance/io-cache/src/ioc-mem-types.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (c) 2007-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 __IOC_MT_H__
+#define __IOC_MT_H__
+
+#include "mem-types.h"
+
+enum gf_ioc_mem_types_ {
+ gf_ioc_mt_iovec = gf_common_mt_end + 1,
+ gf_ioc_mt_ioc_table_t,
+ gf_ioc_mt_char,
+ gf_ioc_mt_ioc_local_t,
+ gf_ioc_mt_ioc_waitq_t,
+ gf_ioc_mt_ioc_priority,
+ gf_ioc_mt_list_head,
+ gf_ioc_mt_call_pool_t,
+ gf_ioc_mt_ioc_inode_t,
+ gf_ioc_mt_ioc_fill_t,
+ gf_ioc_mt_ioc_newpage_t,
+ gf_ioc_mt_end
+};
+#endif
+
diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c
index 28be2b35883..7209abb08a3 100644
--- a/xlators/performance/io-cache/src/page.c
+++ b/xlators/performance/io-cache/src/page.c
@@ -27,6 +27,7 @@
#include "dict.h"
#include "xlator.h"
#include "io-cache.h"
+#include "ioc-mem-types.h"
#include <assert.h>
#include <sys/time.h>
@@ -86,7 +87,7 @@ ioc_page_destroy (ioc_page_t *page)
if (page->vector){
iobref_unref (page->iobref);
- free (page->vector);
+ GF_FREE (page->vector);
page->vector = NULL;
}
@@ -95,7 +96,7 @@ ioc_page_destroy (ioc_page_t *page)
if (page_size != -1) {
pthread_mutex_destroy (&page->page_lock);
- free (page);
+ GF_FREE (page);
}
return page_size;
@@ -194,7 +195,8 @@ ioc_page_create (ioc_inode_t *ioc_inode, off_t offset)
table = ioc_inode->table;
rounded_offset = floor (offset, table->page_size);
- newpage = CALLOC (1, sizeof (*newpage));
+ newpage = GF_CALLOC (1, sizeof (*newpage),
+ gf_ioc_mt_ioc_newpage_t);
if (newpage == NULL) {
goto out;
}
@@ -202,7 +204,7 @@ ioc_page_create (ioc_inode_t *ioc_inode, off_t offset)
if (ioc_inode) {
table = ioc_inode->table;
} else {
- free (newpage);
+ GF_FREE (newpage);
newpage = NULL;
goto out;
}
@@ -241,7 +243,7 @@ ioc_wait_on_page (ioc_page_t *page, call_frame_t *frame, off_t offset,
ioc_waitq_t *waitq = NULL;
ioc_local_t *local = frame->local;
- waitq = CALLOC (1, sizeof (*waitq));
+ waitq = GF_CALLOC (1, sizeof (*waitq), gf_ioc_mt_ioc_waitq_t);
if (waitq == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
@@ -322,7 +324,7 @@ ioc_waitq_return (ioc_waitq_t *waitq)
frame = trav->data;
ioc_frame_return (frame);
- free (trav);
+ GF_FREE (trav);
}
}
@@ -394,7 +396,7 @@ ioc_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
} else {
if (page->vector) {
iobref_unref (page->iobref);
- free (page->vector);
+ GF_FREE (page->vector);
page->vector = NULL;
}
@@ -507,7 +509,8 @@ ioc_page_fault (ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd,
goto err;
}
- fault_local = CALLOC (1, sizeof (ioc_local_t));
+ fault_local = GF_CALLOC (1, sizeof (ioc_local_t),
+ gf_ioc_mt_ioc_local_t);
if (fault_local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -603,7 +606,8 @@ ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset,
copy_size, src_offset, dst_offset);
{
- new = CALLOC (1, sizeof (*new));
+ new = GF_CALLOC (1, sizeof (*new),
+ gf_ioc_mt_ioc_fill_t);
if (new == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
@@ -622,14 +626,15 @@ ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset,
src_offset + copy_size,
NULL);
- new->vector = CALLOC (new->count,
- sizeof (struct iovec));
+ new->vector = GF_CALLOC (new->count,
+ sizeof (struct iovec),
+ gf_ioc_mt_iovec);
if (new->vector == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
iobref_unref (new->iobref);
- FREE (new);
+ GF_FREE (new);
ret = -1;
gf_log (page->inode->table->xl->name,
@@ -722,7 +727,7 @@ ioc_frame_unwind (call_frame_t *frame)
count += fill->count;
}
- vector = CALLOC (count, sizeof (*vector));
+ vector = GF_CALLOC (count, sizeof (*vector), gf_ioc_mt_iovec);
if (vector == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -743,8 +748,8 @@ ioc_frame_unwind (call_frame_t *frame)
list_del (&fill->list);
iobref_unref (fill->iobref);
- free (fill->vector);
- free (fill);
+ GF_FREE (fill->vector);
+ GF_FREE (fill);
}
if (op_ret != -1) {
@@ -764,12 +769,12 @@ ioc_frame_unwind (call_frame_t *frame)
}
if (vector != NULL) {
- free (vector);
+ GF_FREE (vector);
vector = NULL;
}
pthread_mutex_destroy (&local->local_lock);
- free (local);
+ GF_FREE (local);
return;
}
diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c
index 5ef7167336c..c2cca788855 100644
--- a/xlators/performance/io-threads/src/io-threads.c
+++ b/xlators/performance/io-threads/src/io-threads.c
@@ -2111,6 +2111,24 @@ set_stack_size (iot_conf_t *conf)
}
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_iot_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)
@@ -2132,7 +2150,8 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- conf = (void *) CALLOC (1, sizeof (*conf));
+ conf = (void *) GF_CALLOC (1, sizeof (*conf),
+ gf_iot_mt_iot_conf_t);
if (conf == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"out of memory");
@@ -2169,7 +2188,7 @@ init (xlator_t *this)
if (ret == -1) {
gf_log (this->name, GF_LOG_ERROR,
"cannot initialize worker threads, exiting init");
- FREE (conf);
+ GF_FREE (conf);
goto out;
}
@@ -2185,7 +2204,7 @@ fini (xlator_t *this)
{
iot_conf_t *conf = this->private;
- FREE (conf);
+ GF_FREE (conf);
this->private = NULL;
return;
diff --git a/xlators/performance/io-threads/src/io-threads.h b/xlators/performance/io-threads/src/io-threads.h
index 85836ff583d..137418034b1 100644
--- a/xlators/performance/io-threads/src/io-threads.h
+++ b/xlators/performance/io-threads/src/io-threads.h
@@ -35,6 +35,7 @@
#include "list.h"
#include <stdlib.h>
#include "locking.h"
+#include "iot-mem-types.h"
#include <semaphore.h>
diff --git a/xlators/performance/io-threads/src/iot-mem-types.h b/xlators/performance/io-threads/src/iot-mem-types.h
new file mode 100644
index 00000000000..c083f83b495
--- /dev/null
+++ b/xlators/performance/io-threads/src/iot-mem-types.h
@@ -0,0 +1,31 @@
+/*
+ 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 __IOT_MEM_TYPES_H__
+#define __IOT_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_iot_mem_types_ {
+ gf_iot_mt_iot_conf_t = gf_common_mt_end + 1,
+ gf_iot_mt_end
+};
+#endif
+
diff --git a/xlators/performance/quick-read/src/quick-read-mem-types.h b/xlators/performance/quick-read/src/quick-read-mem-types.h
new file mode 100644
index 00000000000..1e7a5d56d2c
--- /dev/null
+++ b/xlators/performance/quick-read/src/quick-read-mem-types.h
@@ -0,0 +1,35 @@
+/*
+ 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 __QR_MEM_TYPES_H__
+#define __QR_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_qr_mem_types_ {
+ gf_qr_mt_qr_file_t = gf_common_mt_end + 1,
+ gf_qr_mt_qr_fd_ctx_t,
+ gf_qr_mt_qr_local_t,
+ gf_qr_mt_iovec,
+ gf_qr_mt_qr_conf_t,
+ gf_qr_mt_end
+};
+#endif
+
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c
index 6cdb735a049..15d4b6378dd 100644
--- a/xlators/performance/quick-read/src/quick-read.c
+++ b/xlators/performance/quick-read/src/quick-read.c
@@ -33,7 +33,7 @@ qr_loc_wipe (loc_t *loc)
}
if (loc->path) {
- FREE (loc->path);
+ GF_FREE ((char *)loc->path);
loc->path = NULL;
}
@@ -65,10 +65,10 @@ qr_loc_fill (loc_t *loc, inode_t *inode, char *path)
}
loc->inode = inode_ref (inode);
- loc->path = strdup (path);
+ loc->path = gf_strdup (path);
loc->ino = inode->ino;
- parent = strdup (path);
+ parent = gf_strdup (path);
if (parent == NULL) {
ret = -1;
goto out;
@@ -92,7 +92,7 @@ out:
}
if (parent) {
- FREE (parent);
+ GF_FREE (parent);
}
return ret;
@@ -139,8 +139,8 @@ qr_fd_ctx_free (qr_fd_ctx_t *qr_fd_ctx)
assert (list_empty (&qr_fd_ctx->waiting_ops));
- FREE (qr_fd_ctx->path);
- FREE (qr_fd_ctx);
+ GF_FREE (qr_fd_ctx->path);
+ GF_FREE (qr_fd_ctx);
out:
return;
@@ -184,7 +184,8 @@ qr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
{
ret = __inode_ctx_get (inode, this, &value);
if (ret == -1) {
- qr_file = CALLOC (1, sizeof (*qr_file));
+ qr_file = GF_CALLOC (1, sizeof (*qr_file),
+ gf_qr_mt_qr_file_t);
if (qr_file == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -195,7 +196,7 @@ qr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = __inode_ctx_put (inode, this,
(uint64_t)(long)qr_file);
if (ret == -1) {
- FREE (qr_file);
+ GF_FREE (qr_file);
qr_file = NULL;
op_ret = -1;
op_errno = EINVAL;
@@ -430,7 +431,8 @@ qr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
conf = this->private;
- tmp_fd_ctx = qr_fd_ctx = CALLOC (1, sizeof (*qr_fd_ctx));
+ tmp_fd_ctx = qr_fd_ctx = GF_CALLOC (1, sizeof (*qr_fd_ctx),
+ gf_qr_mt_qr_fd_ctx_t);
if (qr_fd_ctx == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -441,7 +443,7 @@ qr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
LOCK_INIT (&qr_fd_ctx->lock);
INIT_LIST_HEAD (&qr_fd_ctx->waiting_ops);
- qr_fd_ctx->path = strdup (loc->path);
+ qr_fd_ctx->path = gf_strdup (loc->path);
qr_fd_ctx->flags = flags;
qr_fd_ctx->wbflags = wbflags;
@@ -453,7 +455,8 @@ qr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
}
tmp_fd_ctx = NULL;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_qr_mt_qr_local_t);
if (local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -515,7 +518,7 @@ unwind:
}
if (local != NULL) {
- FREE (local);
+ GF_FREE (local);
}
STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd);
@@ -599,8 +602,8 @@ qr_validate_cache_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
frame->local = NULL;
call_resume (local->stub);
-
- FREE (local);
+
+ GF_FREE (local);
return 0;
unwind:
@@ -657,7 +660,8 @@ qr_validate_cache (call_frame_t *frame, xlator_t *this, fd_t *fd,
call_stub_t *validate_stub = NULL;
char need_open = 0, can_wind = 0;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_qr_mt_qr_local_t);
if (local == NULL) {
goto out;
}
@@ -839,8 +843,9 @@ qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
goto unlock;
}
- vector = CALLOC (count,
- sizeof (*vector));
+ vector = GF_CALLOC (count,
+ sizeof (*vector),
+ gf_qr_mt_iovec);
if (vector == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -977,7 +982,7 @@ out:
}
if (vector) {
- FREE (vector);
+ GF_FREE (vector);
}
if (iobref) {
@@ -1942,8 +1947,9 @@ qr_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
if (ret == 0) {
qr_fd_ctx = (qr_fd_ctx_t *)(long)value;
}
-
- local = CALLOC (1, sizeof (*local));
+
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_qr_mt_qr_local_t);
if (local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -2152,7 +2158,7 @@ qr_forget (xlator_t *this, inode_t *inode)
UNLOCK (&qr_file->lock);
}
- FREE (qr_file);
+ GF_FREE (qr_file);
}
return 0;
@@ -2189,6 +2195,25 @@ qr_priv_dump (xlator_t *this)
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_qr_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)
{
@@ -2208,7 +2233,8 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- conf = CALLOC (1, sizeof (*conf));
+ conf = GF_CALLOC (1, sizeof (*conf),
+ gf_qr_mt_qr_conf_t);
if (conf == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"out of memory");
@@ -2249,7 +2275,7 @@ init (xlator_t *this)
this->private = conf;
out:
if ((ret == -1) && conf) {
- FREE (conf);
+ GF_FREE (conf);
}
return ret;
diff --git a/xlators/performance/quick-read/src/quick-read.h b/xlators/performance/quick-read/src/quick-read.h
index e6aebecc18d..7b832ff88ca 100644
--- a/xlators/performance/quick-read/src/quick-read.h
+++ b/xlators/performance/quick-read/src/quick-read.h
@@ -40,6 +40,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include "quick-read-mem-types.h"
#define GLUSTERFS_CONTENT_KEY "glusterfs.content"
diff --git a/xlators/performance/read-ahead/src/page.c b/xlators/performance/read-ahead/src/page.c
index 063258c8f37..0e271a9ac70 100644
--- a/xlators/performance/read-ahead/src/page.c
+++ b/xlators/performance/read-ahead/src/page.c
@@ -62,7 +62,8 @@ ra_page_create (ra_file_t *file, off_t offset)
page = page->next;
if (page == &file->pages || page->offset != rounded_offset) {
- newpage = CALLOC (1, sizeof (*newpage));
+ newpage = GF_CALLOC (1, sizeof (*newpage),
+ gf_ra_mt_ra_page_t);
if (!newpage)
return NULL;
@@ -87,7 +88,8 @@ ra_wait_on_page (ra_page_t *page, call_frame_t *frame)
ra_local_t *local = NULL;
local = frame->local;
- waitq = CALLOC (1, sizeof (*waitq));
+ waitq = GF_CALLOC (1, sizeof (*waitq),
+ gf_ra_mt_ra_waitq_t);
if (!waitq) {
gf_log (frame->this->name, GF_LOG_ERROR,
"out of memory");
@@ -123,7 +125,7 @@ ra_waitq_return (ra_waitq_t *waitq)
frame = trav->data;
ra_frame_return (frame);
- free (trav);
+ GF_FREE (trav);
}
}
@@ -176,7 +178,7 @@ ra_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (page->vector) {
iobref_unref (page->iobref);
- free (page->vector);
+ GF_FREE (page->vector);
}
page->vector = iov_dup (vector, count);
@@ -200,7 +202,7 @@ unlock:
fd_unref (local->fd);
- free (frame->local);
+ GF_FREE (frame->local);
frame->local = NULL;
STACK_DESTROY (frame->root);
@@ -225,7 +227,8 @@ ra_page_fault (ra_file_t *file, call_frame_t *frame, off_t offset)
goto err;
}
- fault_local = CALLOC (1, sizeof (ra_local_t));
+ fault_local = GF_CALLOC (1, sizeof (ra_local_t),
+ gf_ra_mt_ra_local_t);
if (fault_local == NULL) {
STACK_DESTROY (fault_frame->root);
op_ret = -1;
@@ -297,7 +300,8 @@ ra_frame_fill (ra_page_t *page, call_frame_t *frame)
fill = fill->next;
}
- new = CALLOC (1, sizeof (*new));
+ new = GF_CALLOC (1, sizeof (*new),
+ gf_ra_mt_ra_fill_t);
if (new == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
@@ -310,11 +314,12 @@ ra_frame_fill (ra_page_t *page, call_frame_t *frame)
new->count = iov_subset (page->vector, page->count,
src_offset, src_offset+copy_size,
NULL);
- new->vector = CALLOC (new->count, sizeof (struct iovec));
+ new->vector = GF_CALLOC (new->count, sizeof (struct iovec),
+ gf_ra_mt_iovec);
if (new->vector == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
- FREE (new);
+ GF_FREE (new);
goto out;
}
@@ -366,7 +371,8 @@ ra_frame_unwind (call_frame_t *frame)
fill = fill->next;
}
- vector = CALLOC (count, sizeof (*vector));
+ vector = GF_CALLOC (count, sizeof (*vector),
+ gf_ra_mt_iovec);
if (vector == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
@@ -391,8 +397,8 @@ ra_frame_unwind (call_frame_t *frame)
fill->prev->next = fill->prev;
iobref_unref (fill->iobref);
- free (fill->vector);
- free (fill);
+ GF_FREE (fill->vector);
+ GF_FREE (fill);
fill = next;
}
@@ -406,8 +412,8 @@ ra_frame_unwind (call_frame_t *frame)
iobref_unref (iobref);
pthread_mutex_destroy (&local->local_lock);
- free (local);
- free (vector);
+ GF_FREE (local);
+ GF_FREE (vector);
return;
}
@@ -475,8 +481,8 @@ ra_page_purge (ra_page_t *page)
if (page->iobref) {
iobref_unref (page->iobref);
}
- free (page->vector);
- free (page);
+ GF_FREE (page->vector);
+ GF_FREE (page);
}
/*
@@ -541,5 +547,5 @@ ra_file_destroy (ra_file_t *file)
}
pthread_mutex_destroy (&file->file_lock);
- free (file);
+ GF_FREE (file);
}
diff --git a/xlators/performance/read-ahead/src/read-ahead-mem-types.h b/xlators/performance/read-ahead/src/read-ahead-mem-types.h
new file mode 100644
index 00000000000..b21d0595a2d
--- /dev/null
+++ b/xlators/performance/read-ahead/src/read-ahead-mem-types.h
@@ -0,0 +1,37 @@
+/*
+ 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 __RA_MEM_TYPES_H__
+#define __RA_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_ra_mem_types_ {
+ gf_ra_mt_ra_file_t = gf_common_mt_end + 1,
+ gf_ra_mt_ra_local_t,
+ gf_ra_mt_ra_conf_t,
+ gf_ra_mt_ra_page_t,
+ gf_ra_mt_ra_waitq_t,
+ gf_ra_mt_ra_fill_t,
+ gf_ra_mt_iovec,
+ gf_ra_mt_end
+};
+#endif
+
diff --git a/xlators/performance/read-ahead/src/read-ahead.c b/xlators/performance/read-ahead/src/read-ahead.c
index c0a43258242..9f97c72e933 100644
--- a/xlators/performance/read-ahead/src/read-ahead.c
+++ b/xlators/performance/read-ahead/src/read-ahead.c
@@ -59,7 +59,7 @@ ra_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
wbflags = (long)frame->local;
- file = CALLOC (1, sizeof (*file));
+ file = GF_CALLOC (1, sizeof (*file), gf_ra_mt_ra_file_t);
if (!file) {
op_ret = -1;
op_errno = ENOMEM;
@@ -129,7 +129,7 @@ ra_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto unwind;
}
- file = CALLOC (1, sizeof (*file));
+ file = GF_CALLOC (1, sizeof (*file), gf_ra_mt_ra_file_t);
if (!file) {
op_ret = -1;
op_errno = ENOMEM;
@@ -480,7 +480,8 @@ ra_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
return 0;
}
- local = (void *) CALLOC (1, sizeof (*local));
+ local = (void *) GF_CALLOC (1, sizeof (*local),
+ gf_ra_mt_ra_local_t);
if (!local) {
gf_log (this->name, GF_LOG_ERROR,
"out of memory");
@@ -823,6 +824,25 @@ ra_priv_dump (xlator_t *this)
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_ra_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)
{
@@ -843,7 +863,8 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- conf = (void *) CALLOC (1, sizeof (*conf));
+ conf = (void *) GF_CALLOC (1, sizeof (*conf),
+ gf_ra_mt_ra_conf_t);
if (conf == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"FATAL: Out of memory");
@@ -897,7 +918,7 @@ init (xlator_t *this)
out:
if (ret == -1) {
if (conf != NULL) {
- FREE (conf);
+ GF_FREE (conf);
}
}
@@ -913,7 +934,7 @@ fini (xlator_t *this)
return;
pthread_mutex_destroy (&conf->conf_lock);
- FREE (conf);
+ GF_FREE (conf);
this->private = NULL;
return;
diff --git a/xlators/performance/read-ahead/src/read-ahead.h b/xlators/performance/read-ahead/src/read-ahead.h
index 0ad47fc756b..1f56e85d2ea 100644
--- a/xlators/performance/read-ahead/src/read-ahead.h
+++ b/xlators/performance/read-ahead/src/read-ahead.h
@@ -31,6 +31,7 @@
#include "dict.h"
#include "xlator.h"
#include "common-utils.h"
+#include "read-ahead-mem-types.h"
struct ra_conf;
struct ra_local;
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch-mem-types.h b/xlators/performance/stat-prefetch/src/stat-prefetch-mem-types.h
new file mode 100644
index 00000000000..f3d25a8af71
--- /dev/null
+++ b/xlators/performance/stat-prefetch/src/stat-prefetch-mem-types.h
@@ -0,0 +1,36 @@
+/*
+ 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 __SP_MEM_TYPES_H__
+#define __SP_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_sp_mem_types_ {
+ gf_sp_mt_sp_cache_t = gf_common_mt_end + 1,
+ gf_sp_mt_sp_fd_ctx_t,
+ gf_sp_mt_stat,
+ gf_sp_mt_sp_local_t,
+ gf_sp_mt_sp_inode_ctx_t,
+ gf_sp_mt_sp_private_t,
+ gf_sp_mt_end
+};
+#endif
+
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c
index c54042130e8..e7dd8958fb4 100644
--- a/xlators/performance/stat-prefetch/src/stat-prefetch.c
+++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c
@@ -59,7 +59,7 @@ sp_inode_ctx_free (xlator_t *this, sp_inode_ctx_t *ctx)
UNLOCK (&ctx->lock);
LOCK_DESTROY (&ctx->lock);
- FREE (ctx);
+ GF_FREE (ctx);
out:
return;
@@ -71,7 +71,8 @@ sp_inode_ctx_init ()
{
sp_inode_ctx_t *inode_ctx = NULL;
- inode_ctx = CALLOC (1, sizeof (*inode_ctx));
+ inode_ctx = GF_CALLOC (1, sizeof (*inode_ctx),
+ gf_sp_mt_sp_inode_ctx_t);
if (inode_ctx == NULL) {
goto out;
}
@@ -224,7 +225,7 @@ sp_cache_unref (sp_cache_t *cache)
if (refcount == 0) {
rbthash_table_destroy (cache->table);
- FREE (cache);
+ GF_FREE (cache);
}
out:
@@ -272,7 +273,8 @@ sp_process_inode_ctx (call_frame_t *frame, xlator_t *this, loc_t *loc,
{
if (!(inode_ctx->looked_up || inode_ctx->lookup_in_progress)) {
if (frame->local == NULL) {
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name,
local,
unlock,
@@ -340,14 +342,14 @@ sp_cache_init (xlator_t *this)
if (!priv->mem_pool)
goto out;
- cache = CALLOC (1, sizeof (*cache));
+ cache = GF_CALLOC (1, sizeof (*cache), gf_sp_mt_sp_cache_t);
if (cache) {
cache->table =
rbthash_table_init (GF_SP_CACHE_BUCKETS,
sp_hashfn, free,
0, priv->mem_pool);
if (cache->table == NULL) {
- FREE (cache);
+ GF_FREE (cache);
cache = NULL;
goto out;
}
@@ -366,7 +368,7 @@ sp_local_free (sp_local_t *local)
{
if (local) {
loc_wipe (&local->loc);
- FREE (local);
+ GF_FREE (local);
}
}
@@ -400,7 +402,7 @@ sp_cache_remove_entry (sp_cache_t *cache, char *name, char remove_all)
table = cache->table;
cache->table = rbthash_table_init (GF_SP_CACHE_BUCKETS,
sp_hashfn,
- free,
+ __gf_free,
0,
priv->mem_pool);
if (cache->table == NULL) {
@@ -412,7 +414,7 @@ sp_cache_remove_entry (sp_cache_t *cache, char *name, char remove_all)
} else {
data = rbthash_remove (cache->table, name,
strlen (name));
- FREE (data);
+ GF_FREE (data);
ret = 0;
}
}
@@ -526,7 +528,7 @@ sp_fd_ctx_free (sp_fd_ctx_t *fd_ctx)
}
if (fd_ctx->name) {
- FREE (fd_ctx->name);
+ GF_FREE (fd_ctx->name);
fd_ctx->name = NULL;
}
@@ -534,7 +536,7 @@ sp_fd_ctx_free (sp_fd_ctx_t *fd_ctx)
sp_cache_free (fd_ctx->cache);
}
- FREE (fd_ctx);
+ GF_FREE (fd_ctx);
out:
return;
}
@@ -545,7 +547,7 @@ sp_fd_ctx_init (void)
{
sp_fd_ctx_t *fd_ctx = NULL;
- fd_ctx = CALLOC (1, sizeof (*fd_ctx));
+ fd_ctx = GF_CALLOC (1, sizeof (*fd_ctx), gf_sp_mt_sp_fd_ctx_t);
return fd_ctx;
}
@@ -567,7 +569,7 @@ sp_fd_ctx_new (xlator_t *this, inode_t *parent, char *name, sp_cache_t *cache)
}
if (name) {
- fd_ctx->name = strdup (name);
+ fd_ctx->name = gf_strdup (name);
if (fd_ctx->name == NULL) {
sp_fd_ctx_free (fd_ctx);
fd_ctx = NULL;
@@ -713,7 +715,7 @@ sp_cache_add_entries (sp_cache_t *cache, gf_dirent_t *entries)
ret = rbthash_insert (cache->table, new, new->d_name,
strlen (new->d_name));
if (ret == -1) {
- FREE (new);
+ GF_FREE (new);
continue;
}
@@ -807,7 +809,7 @@ sp_get_ancestors (char *path, char **parent, char **grand_parent)
break;
}
- cpy = strdup (path);
+ cpy = gf_strdup (path);
if (cpy == NULL) {
goto out;
}
@@ -851,13 +853,13 @@ sp_cache_remove_parent_entry (call_frame_t *frame, xlator_t *this,
cache_gp = sp_get_cache_inode (this, inode_gp,
frame->root->pid);
if (cache_gp) {
- cpy = strdup (parent);
+ cpy = gf_strdup (parent);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name,
cpy, out, errno,
ENOMEM);
path = basename (cpy);
sp_cache_remove_entry (cache_gp, path, 0);
- FREE (cpy);
+ GF_FREE (cpy);
sp_cache_unref (cache_gp);
}
@@ -868,11 +870,11 @@ sp_cache_remove_parent_entry (call_frame_t *frame, xlator_t *this,
ret = 0;
out:
if (parent) {
- FREE (parent);
+ GF_FREE (parent);
}
if (grand_parent) {
- FREE (grand_parent);
+ GF_FREE (grand_parent);
}
return ret;
@@ -1015,7 +1017,7 @@ sp_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req)
entry_cached = 1;
}
- FREE (dirent);
+ GF_FREE (dirent);
}
} else if (IA_ISDIR (loc->inode->ia_type)) {
cache = sp_get_cache_inode (this, loc->inode, frame->root->pid);
@@ -1032,7 +1034,7 @@ sp_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req)
entry_cached = 1;
}
- FREE (dirent);
+ GF_FREE (dirent);
}
}
}
@@ -1054,7 +1056,7 @@ wind:
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, stub, unwind,
op_errno, ENOMEM);
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, unwind,
op_errno, ENOMEM);
@@ -1204,14 +1206,14 @@ sp_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
ret = sp_cache_remove_parent_entry (frame, this, fd->inode->table,
path);
- FREE (path);
+ GF_FREE (path);
if (ret < 0) {
errno = -ret;
goto unwind;
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
if (local) {
local->fd = fd;
frame->local = local;
@@ -1341,7 +1343,7 @@ sp_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, loc->inode, out,
op_errno, EINVAL);
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, out, op_errno,
ENOMEM);
@@ -1453,7 +1455,7 @@ sp_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
goto out;
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, out, op_errno,
ENOMEM);
@@ -1541,7 +1543,7 @@ sp_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd)
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, loc->inode, out,
op_errno, EINVAL);
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, out, op_errno,
ENOMEM);
@@ -1643,7 +1645,7 @@ sp_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode)
goto out;
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, out, op_errno,
ENOMEM);
@@ -1706,7 +1708,7 @@ sp_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
goto out;
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, out, op_errno,
ENOMEM);
@@ -1769,7 +1771,7 @@ sp_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath,
goto out;
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, out, op_errno,
ENOMEM);
@@ -3687,7 +3689,7 @@ sp_forget (xlator_t *this, inode_t *inode)
if (value) {
buf = (void *)(long)value;
- FREE (buf);
+ GF_FREE (buf);
}
return 0;
@@ -3717,7 +3719,24 @@ sp_release (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_sp_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)
@@ -3733,7 +3752,8 @@ init (xlator_t *this)
goto out;
}
- priv = CALLOC (1, sizeof(sp_private_t));
+ priv = GF_CALLOC (1, sizeof(sp_private_t),
+ gf_sp_mt_sp_private_t);
LOCK_INIT (&priv->lock);
this->private = priv;
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.h b/xlators/performance/stat-prefetch/src/stat-prefetch.h
index 9ff2899a9ac..16edf76aa71 100644
--- a/xlators/performance/stat-prefetch/src/stat-prefetch.h
+++ b/xlators/performance/stat-prefetch/src/stat-prefetch.h
@@ -33,6 +33,7 @@
#include "rbthash.h"
#include "hashfn.h"
#include "call-stub.h"
+#include "stat-prefetch-mem-types.h"
#include <libgen.h>
struct sp_cache {
diff --git a/xlators/performance/write-behind/src/write-behind-mem-types.h b/xlators/performance/write-behind/src/write-behind-mem-types.h
new file mode 100644
index 00000000000..6184615195b
--- /dev/null
+++ b/xlators/performance/write-behind/src/write-behind-mem-types.h
@@ -0,0 +1,35 @@
+/*
+ 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 __WB_MEM_TYPES_H__
+#define __WB_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_wb_mem_types_ {
+ gf_wb_mt_wb_file_t = gf_common_mt_end + 1,
+ gf_wb_mt_wb_local_t,
+ gf_wb_mt_wb_request_t,
+ gf_wb_mt_iovec,
+ gf_wb_mt_wb_conf_t,
+ gf_wb_mt_end
+};
+#endif
+
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index 3cbfc497591..bd046500657 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -35,6 +35,7 @@
#include "common-utils.h"
#include "call-stub.h"
#include "statedump.h"
+#include "write-behind-mem-types.h"
#define MAX_VECTOR_COUNT 8
#define WB_AGGREGATE_SIZE 131072 /* 128 KB */
@@ -141,7 +142,7 @@ __wb_request_unref (wb_request_t *this)
call_stub_destroy (this->stub);
}
- FREE (this);
+ GF_FREE (this);
}
}
@@ -209,7 +210,7 @@ wb_enqueue (wb_file_t *file, call_stub_t *stub)
struct iovec *vector = NULL;
int32_t count = 0;
- request = CALLOC (1, sizeof (*request));
+ request = GF_CALLOC (1, sizeof (*request), gf_wb_mt_wb_request_t);
if (request == NULL) {
goto out;
}
@@ -270,7 +271,7 @@ wb_file_create (xlator_t *this, fd_t *fd)
wb_file_t *file = NULL;
wb_conf_t *conf = this->private;
- file = CALLOC (1, sizeof (*file));
+ file = GF_CALLOC (1, sizeof (*file), gf_wb_mt_wb_file_t);
if (file == NULL) {
goto out;
}
@@ -307,7 +308,7 @@ wb_file_destroy (wb_file_t *file)
if (!refcount){
LOCK_DESTROY (&file->lock);
- FREE (file);
+ GF_FREE (file);
}
return;
@@ -407,7 +408,8 @@ wb_sync (call_frame_t *frame, wb_file_t *file, list_head_t *winds)
list_for_each_entry_safe (request, dummy, winds, winds) {
if (!vector) {
- vector = MALLOC (VECTORSIZE (MAX_VECTOR_COUNT));
+ vector = GF_MALLOC (VECTORSIZE (MAX_VECTOR_COUNT),
+ gf_wb_mt_iovec);
if (vector == NULL) {
bytes = -1;
goto out;
@@ -419,7 +421,8 @@ wb_sync (call_frame_t *frame, wb_file_t *file, list_head_t *winds)
goto out;
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
bytes = -1;
goto out;
@@ -488,7 +491,7 @@ wb_sync (call_frame_t *frame, wb_file_t *file, list_head_t *winds)
iobref);
iobref_unref (iobref);
- FREE (vector);
+ GF_FREE (vector);
first_request = NULL;
iobref = NULL;
vector = NULL;
@@ -505,7 +508,7 @@ out:
}
if (local != NULL) {
- FREE (local);
+ GF_FREE (local);
}
if (iobref != NULL) {
@@ -513,7 +516,7 @@ out:
}
if (vector != NULL) {
- FREE (vector);
+ GF_FREE (vector);
}
return bytes;
@@ -612,7 +615,8 @@ wb_stat (call_frame_t *frame, xlator_t *this, loc_t *loc)
}
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -726,7 +730,8 @@ wb_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd)
}
file = (wb_file_t *)(long)tmp_file;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
STACK_UNWIND_STRICT (fstat, frame, -1, ENOMEM, NULL);
return 0;
@@ -877,7 +882,8 @@ wb_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset)
}
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -994,7 +1000,8 @@ wb_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
file = (wb_file_t *)(long)tmp_file;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
STACK_UNWIND_STRICT (ftruncate, frame, -1, ENOMEM,
NULL, NULL);
@@ -1131,7 +1138,8 @@ wb_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
wb_request_t *request = NULL;
int32_t ret = -1, op_errno = EINVAL;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -1263,7 +1271,8 @@ wb_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
wb_local_t *local = NULL;
int32_t op_errno = EINVAL;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -1894,7 +1903,8 @@ wb_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
goto unwind;
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -2010,7 +2020,8 @@ wb_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
file = (wb_file_t *)(long)tmp_file;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
STACK_UNWIND_STRICT (readv, frame, -1, ENOMEM,
NULL, 0, NULL, NULL);
@@ -2165,7 +2176,8 @@ wb_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
file = (wb_file_t *)(long)tmp_file;
if (file != NULL) {
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
STACK_UNWIND (frame, -1, ENOMEM, NULL);
return 0;
@@ -2196,7 +2208,8 @@ wb_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
if (conf->flush_behind
&& (!disabled) && (disable_till == 0)) {
- tmp_local = CALLOC (1, sizeof (*local));
+ tmp_local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (tmp_local == NULL) {
STACK_UNWIND_STRICT (flush, frame, -1, ENOMEM);
@@ -2337,7 +2350,8 @@ wb_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync)
file = (wb_file_t *)(long)tmp_file;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
STACK_UNWIND_STRICT (fsync, frame, -1, ENOMEM, NULL, NULL);
return 0;
@@ -2444,6 +2458,25 @@ wb_priv_dump (xlator_t *this)
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_wb_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)
{
@@ -2468,7 +2501,7 @@ init (xlator_t *this)
options = this->options;
- conf = CALLOC (1, sizeof (*conf));
+ conf = GF_CALLOC (1, sizeof (*conf), gf_wb_mt_wb_conf_t);
if (conf == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"FATAL: Out of memory");
@@ -2521,7 +2554,7 @@ init (xlator_t *this)
"invalid number format \"%s\" of \"option "
"window-size\"",
str);
- FREE (conf);
+ GF_FREE (conf);
return -1;
}
}
@@ -2539,7 +2572,7 @@ init (xlator_t *this)
"aggregate-size(%"PRIu64") cannot be more than "
"window-size"
"(%"PRIu64")", conf->aggregate_size, conf->window_size);
- FREE (conf);
+ GF_FREE (conf);
return -1;
}
@@ -2586,7 +2619,7 @@ fini (xlator_t *this)
{
wb_conf_t *conf = this->private;
- FREE (conf);
+ GF_FREE (conf);
return;
}
diff --git a/xlators/protocol/client/src/client-mem-types.h b/xlators/protocol/client/src/client-mem-types.h
new file mode 100644
index 00000000000..1eee8d93159
--- /dev/null
+++ b/xlators/protocol/client/src/client-mem-types.h
@@ -0,0 +1,43 @@
+
+/*
+ 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 __CLIENT_MEM_TYPES_H__
+#define __CLIENT_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_client_mem_types_ {
+ gf_client_mt_dir_entry_t = gf_common_mt_end + 1,
+ gf_client_mt_volfile_ctx,
+ gf_client_mt_client_state_t,
+ gf_client_mt_client_conf_t,
+ gf_client_mt_locker,
+ gf_client_mt_lock_table,
+ gf_client_mt_char,
+ gf_client_mt_client_connection_t,
+ gf_client_mt_client_fd_ctx_t,
+ gf_client_mt_client_local_t,
+ gf_client_mt_saved_frames,
+ gf_client_mt_saved_frame,
+ gf_client_mt_end
+};
+#endif
+
diff --git a/xlators/protocol/client/src/client-protocol.c b/xlators/protocol/client/src/client-protocol.c
index 36a31c5c918..df890cc3ca6 100644
--- a/xlators/protocol/client/src/client-protocol.c
+++ b/xlators/protocol/client/src/client-protocol.c
@@ -37,6 +37,7 @@
#include "compat.h"
#include "compat-errno.h"
#include "statedump.h"
+#include "client-mem-types.h"
#include <sys/resource.h>
#include <inttypes.h>
@@ -169,7 +170,7 @@ client_local_wipe (client_local_t *local)
if (local->fd)
fd_unref (local->fd);
- free (local);
+ GF_FREE (local);
}
return 0;
@@ -234,7 +235,7 @@ call_bail (void *data)
/* Chaining to get call-always functionality from
call-once timer */
if (conn->timer) {
- timer_cbk = conn->timer->cbk;
+ timer_cbk = conn->timer->callbk;
timeout.tv_sec = 10;
timeout.tv_usec = 0;
@@ -320,7 +321,7 @@ call_bail (void *data)
gf_ops[trav->op] (frame, &hdr, sizeof (hdr), NULL);
list_del_init (&trav->list);
- FREE (trav);
+ GF_FREE (trav);
}
out:
return;
@@ -507,7 +508,7 @@ client_start_ping (void *data)
return;
err:
if (hdr)
- FREE (hdr);
+ GF_FREE (hdr);
if (dummy_frame)
STACK_DESTROY (dummy_frame->root);
@@ -661,7 +662,7 @@ protocol_client_xfer (call_frame_t *frame, xlator_t *this, transport_t *trans,
gf_cbks[op] (frame, &rsphdr, sizeof (rsphdr), NULL);
}
- FREE (hdr);
+ GF_FREE (hdr);
}
return ret;
@@ -695,7 +696,7 @@ client_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
client_local_t *local = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
local->fd = fd_ref (fd);
@@ -735,7 +736,7 @@ client_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, fd, NULL, NULL);
return 0;
@@ -765,7 +766,7 @@ client_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
uint64_t gen = 0;
client_local_t *local = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
local->fd = fd_ref (fd);
@@ -805,7 +806,7 @@ client_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, fd);
return 0;
@@ -860,7 +861,7 @@ client_stat (call_frame_t *frame, xlator_t *this, loc_t *loc)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -916,7 +917,7 @@ client_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -947,7 +948,7 @@ client_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
uint64_t gen = 0;
client_local_t *local = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
loc_copy (&local->loc, loc);
@@ -985,7 +986,7 @@ client_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, loc->inode, NULL);
return 0;
@@ -1014,7 +1015,7 @@ client_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode)
uint64_t gen = 0;
client_local_t *local = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
loc_copy (&local->loc, loc);
@@ -1051,7 +1052,7 @@ client_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, loc->inode, NULL);
return 0;
@@ -1107,7 +1108,7 @@ client_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -1163,7 +1164,7 @@ client_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -1195,7 +1196,7 @@ client_symlink (call_frame_t *frame, xlator_t *this, const char *linkname,
uint64_t gen = 0;
client_local_t *local = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
loc_copy (&local->loc, loc);
@@ -1232,7 +1233,7 @@ client_symlink (call_frame_t *frame, xlator_t *this, const char *linkname,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, loc->inode, NULL);
return 0;
@@ -1312,7 +1313,7 @@ client_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -1344,7 +1345,7 @@ client_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc)
uint64_t newgen = 0;
client_local_t *local = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
loc_copy (&local->loc, oldloc);
@@ -1395,7 +1396,7 @@ client_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, oldloc->inode, NULL);
return 0;
}
@@ -1450,7 +1451,7 @@ client_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -1523,7 +1524,7 @@ client_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
return 0;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL, 0, NULL);
return 0;
@@ -1596,7 +1597,7 @@ client_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -1653,7 +1654,7 @@ client_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -1721,7 +1722,7 @@ client_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
return 0;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -1790,7 +1791,7 @@ client_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -1844,7 +1845,7 @@ client_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc,
req->dict_len = hton32 (dict_len);
if (dict) {
memcpy (req->dict, buf, dict_len);
- FREE (buf);
+ GF_FREE (buf);
}
req->ino = hton64 (ino);
@@ -1858,7 +1859,7 @@ client_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -1942,7 +1943,7 @@ client_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EBADFD, NULL);
return 0;
@@ -2019,7 +2020,7 @@ client_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -2110,7 +2111,7 @@ client_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -2170,7 +2171,7 @@ client_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -2249,7 +2250,7 @@ client_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -2308,7 +2309,7 @@ client_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
}
@@ -2335,7 +2336,7 @@ client_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc,
size_t pathlen = 0;
client_local_t *local = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
loc_copy (&local->loc, loc);
@@ -2371,7 +2372,7 @@ client_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, fd);
return 0;
@@ -2437,7 +2438,7 @@ client_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
return 0;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EBADFD, NULL);
return 0;
@@ -2505,7 +2506,7 @@ client_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
return 0;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EBADFD, NULL);
return 0;
@@ -2624,7 +2625,7 @@ client_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -2693,7 +2694,7 @@ client_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -2759,7 +2760,7 @@ client_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -2857,7 +2858,7 @@ client_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -2949,7 +2950,7 @@ client_inodelk (call_frame_t *frame, xlator_t *this, const char *volume,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -3056,7 +3057,7 @@ client_finodelk (call_frame_t *frame, xlator_t *this, const char *volume,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -3118,7 +3119,7 @@ client_entrylk (call_frame_t *frame, xlator_t *this, const char *volume,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -3196,7 +3197,7 @@ client_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -3230,7 +3231,7 @@ client_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
client_local_t *local = NULL;
char *buf = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
loc_copy (&local->loc, loc);
@@ -3281,7 +3282,7 @@ client_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
if (dictlen > 0) {
memcpy (req->dict + pathlen + baselen, buf, dictlen);
- FREE (buf);
+ GF_FREE (buf);
}
req->dictlen = hton32 (dictlen);
@@ -3451,7 +3452,7 @@ client_fdctx_destroy (xlator_t *this, client_fd_ctx_t *fdctx)
out:
inode_unref (fdctx->inode);
- FREE (fdctx);
+ GF_FREE (fdctx);
return ret;
}
@@ -3598,7 +3599,7 @@ fail:
STACK_UNWIND (frame, op_ret, op_errno, dict);
if (dictbuf)
- free (dictbuf);
+ GF_FREE (dictbuf);
if (dict)
dict_unref (dict);
@@ -3657,7 +3658,7 @@ fail:
STACK_UNWIND (frame, op_ret, op_errno, dict);
if (dictbuf)
- free (dictbuf);
+ GF_FREE (dictbuf);
if (dict)
dict_unref (dict);
@@ -3724,7 +3725,8 @@ client_create_cbk (call_frame_t *frame, gf_hdr_common_t *hdr, size_t hdrlen,
local->loc.path);
}
- fdctx = CALLOC (1, sizeof (*fdctx));
+ fdctx = GF_CALLOC (1, sizeof (*fdctx),
+ gf_client_mt_client_fd_ctx_t);
if (!fdctx) {
op_ret = -1;
op_errno = ENOMEM;
@@ -3801,7 +3803,8 @@ client_open_cbk (call_frame_t *frame, gf_hdr_common_t *hdr, size_t hdrlen,
}
if (op_ret >= 0) {
- fdctx = CALLOC (1, sizeof (*fdctx));
+ fdctx = GF_CALLOC (1, sizeof (*fdctx),
+ gf_client_mt_client_fd_ctx_t);
if (!fdctx) {
op_ret = -1;
op_errno = ENOMEM;
@@ -4521,7 +4524,8 @@ client_opendir_cbk (call_frame_t *frame, gf_hdr_common_t *hdr, size_t hdrlen,
}
if (op_ret >= 0) {
- fdctx = CALLOC (1, sizeof (*fdctx));
+ fdctx = GF_CALLOC (1, sizeof (*fdctx),
+ gf_client_mt_client_fd_ctx_t);
if (!fdctx) {
op_ret = -1;
op_errno = ENOMEM;
@@ -4719,7 +4723,7 @@ fail:
client_local_wipe (local);
if (dictbuf)
- free (dictbuf);
+ GF_FREE (dictbuf);
if (xattr)
dict_unref (xattr);
@@ -4790,13 +4794,13 @@ gf_free_direntry (dir_entry_t *head)
trav = head->next;
while (trav) {
prev->next = trav->next;
- FREE (trav->name);
+ GF_FREE (trav->name);
if (IA_ISLNK (trav->buf.ia_type))
- FREE (trav->link);
- FREE (trav);
+ GF_FREE (trav->link);
+ GF_FREE (trav);
trav = prev->next;
}
- FREE (head);
+ GF_FREE (head);
fail:
return 0;
}
@@ -4945,7 +4949,7 @@ fail:
client_local_wipe (local);
if (dictbuf)
- free (dictbuf);
+ GF_FREE (dictbuf);
if (dict)
dict_unref (dict);
@@ -5133,7 +5137,7 @@ client_getspec (call_frame_t *frame, xlator_t *this, const char *key,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
}
@@ -5203,7 +5207,7 @@ client_log (call_frame_t *frame, xlator_t *this, const char *msg)
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -5477,7 +5481,7 @@ protocol_client_reopendir (xlator_t *this, client_fd_ctx_t *fdctx)
goto out;
}
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
if (!local) {
goto out;
}
@@ -5523,7 +5527,7 @@ out:
client_local_wipe (local);
if (path)
- FREE (path);
+ GF_FREE (path);
return 0;
}
@@ -5600,7 +5604,7 @@ protocol_client_reopen (xlator_t *this, client_fd_ctx_t *fdctx)
goto out;
}
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
if (!local) {
goto out;
}
@@ -5647,7 +5651,7 @@ out:
client_local_wipe (local);
if (path)
- FREE (path);
+ GF_FREE (path);
return 0;
@@ -6120,6 +6124,26 @@ protocol_client_interpret (xlator_t *this, transport_t *trans,
return ret;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_client_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
+
/*
* init - initiliazation function. called during loading of client protocol
* @this:
@@ -6179,7 +6203,8 @@ init (xlator_t *this)
ping_timeout = GF_UNIVERSAL_ANSWER;
}
- conf = CALLOC (1, sizeof (client_conf_t));
+ conf = GF_CALLOC (1, sizeof (client_conf_t),
+ gf_client_mt_client_conf_t);
pthread_mutex_init (&conf->mutex, NULL);
INIT_LIST_HEAD (&conf->saved_fds);
@@ -6189,7 +6214,7 @@ init (xlator_t *this)
for (i = 0; i < CHANNEL_MAX; i++) {
if (CHANNEL_LOWLAT == i) {
dict_set (this->options, "transport.socket.lowlat",
- data_from_dynstr (strdup ("true")));
+ data_from_dynstr (gf_strdup ("true")));
}
trans = transport_load (this->options, this);
if (trans == NULL) {
@@ -6199,7 +6224,8 @@ init (xlator_t *this)
goto out;
}
- conn = CALLOC (1, sizeof (*conn));
+ conn = GF_CALLOC (1, sizeof (*conn),
+ gf_client_mt_client_connection_t);
conn->saved_frames = saved_frames_new ();
@@ -6262,7 +6288,7 @@ fini (xlator_t *this)
this->private = NULL;
if (conf) {
- FREE (conf);
+ GF_FREE (conf);
}
return;
}
@@ -6288,8 +6314,8 @@ protocol_client_handshake (xlator_t *this, transport_t *trans)
GF_PROTOCOL_VERSION);
}
- ret = asprintf (&process_uuid_xl, "%s-%s", this->ctx->process_uuid,
- this->name);
+ ret = gf_asprintf (&process_uuid_xl, "%s-%s", this->ctx->process_uuid,
+ this->name);
if (-1 == ret) {
gf_log (this->name, GF_LOG_ERROR,
"asprintf failed while setting process_uuid");
@@ -6345,7 +6371,7 @@ protocol_client_handshake (xlator_t *this, transport_t *trans)
return ret;
fail:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
return ret;
}
@@ -6393,7 +6419,7 @@ protocol_client_pollin (xlator_t *this, transport_t *trans)
}
/* TODO: use mem-pool */
- FREE (hdr);
+ GF_FREE (hdr);
return ret;
}
diff --git a/xlators/protocol/client/src/saved-frames.c b/xlators/protocol/client/src/saved-frames.c
index cd5349e21fb..770de19ad72 100644
--- a/xlators/protocol/client/src/saved-frames.c
+++ b/xlators/protocol/client/src/saved-frames.c
@@ -22,6 +22,7 @@
#include "common-utils.h"
#include "protocol.h"
#include "xlator.h"
+#include "client-mem-types.h"
@@ -30,7 +31,8 @@ saved_frames_new (void)
{
struct saved_frames *saved_frames = NULL;
- saved_frames = CALLOC (sizeof (*saved_frames), 1);
+ saved_frames = GF_CALLOC (sizeof (*saved_frames), 1,
+ gf_client_mt_saved_frames);
if (!saved_frames) {
return NULL;
}
@@ -76,7 +78,8 @@ saved_frames_put (struct saved_frames *frames, call_frame_t *frame,
head_frame = get_head_frame_for_type (frames, type);
- saved_frame = CALLOC (sizeof (*saved_frame), 1);
+ saved_frame = GF_CALLOC (sizeof (*saved_frame), 1,
+ gf_client_mt_saved_frame);
if (!saved_frame) {
return -ENOMEM;
}
@@ -119,7 +122,7 @@ saved_frames_get (struct saved_frames *frames, int32_t op,
if (saved_frame)
frame = saved_frame->frame;
- FREE (saved_frame);
+ GF_FREE (saved_frame);
return frame;
}
@@ -174,7 +177,7 @@ saved_frames_unwind (xlator_t *this, struct saved_frames *saved_frames,
gf_ops[trav->op] (frame, &hdr, sizeof (hdr), NULL);
list_del_init (&trav->list);
- FREE (trav);
+ GF_FREE (trav);
}
}
@@ -187,5 +190,5 @@ saved_frames_destroy (xlator_t *this, struct saved_frames *frames,
saved_frames_unwind (this, frames, &frames->mops, gf_mops, gf_mop_list);
saved_frames_unwind (this, frames, &frames->cbks, gf_cbks, gf_cbk_list);
- FREE (frames);
+ GF_FREE (frames);
}
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c
index dc2620c9055..d07e841f287 100644
--- a/xlators/protocol/server/src/server-helpers.c
+++ b/xlators/protocol/server/src/server-helpers.c
@@ -101,7 +101,7 @@ server_loc_fill (loc_t *loc, server_state_t *state,
if (loc->name)
loc->name++;
} else {
- loc->path = strdup (path);
+ loc->path = gf_strdup (path);
loc->name = strrchr (loc->path, '/');
if (loc->name)
loc->name++;
@@ -142,7 +142,7 @@ stat_to_str (struct iatt *stbuf)
uint32_t ctime_nsec = stbuf->ia_ctime_nsec;
- ret = asprintf (&tmp_buf,
+ ret = gf_asprintf (&tmp_buf,
GF_STAT_PRINT_FMT_STR,
dev,
ino,
@@ -182,8 +182,8 @@ server_loc_wipe (loc_t *loc)
loc->inode = NULL;
}
- if (loc->path)
- FREE (loc->path);
+ if (loc->path)
+ GF_FREE ((char *)loc->path);
}
@@ -194,13 +194,13 @@ server_resolve_wipe (server_resolve_t *resolve)
int i = 0;
if (resolve->path)
- FREE (resolve->path);
+ GF_FREE (resolve->path);
if (resolve->bname)
- FREE (resolve->bname);
+ GF_FREE (resolve->bname);
if (resolve->resolved)
- FREE (resolve->resolved);
+ GF_FREE (resolve->resolved);
loc_wipe (&resolve->deep_loc);
@@ -210,7 +210,7 @@ server_resolve_wipe (server_resolve_t *resolve)
if (comp[i].inode)
inode_unref (comp[i].inode);
}
- FREE (resolve->components);
+ GF_FREE (resolve->components);
}
}
@@ -244,10 +244,10 @@ free_state (server_state_t *state)
}
if (state->volume)
- FREE (state->volume);
+ GF_FREE ((char *)state->volume);
if (state->name)
- FREE (state->name);
+ GF_FREE (state->name);
server_loc_wipe (&state->loc);
server_loc_wipe (&state->loc2);
@@ -255,7 +255,7 @@ free_state (server_state_t *state)
server_resolve_wipe (&state->resolve);
server_resolve_wipe (&state->resolve2);
- FREE (state);
+ GF_FREE (state);
}
@@ -269,7 +269,8 @@ server_copy_frame (call_frame_t *frame)
new_frame = copy_frame (frame);
- new_state = CALLOC (1, sizeof (server_state_t));
+ new_state = GF_CALLOC (1, sizeof (server_state_t),
+ gf_server_mt_server_state_t);
new_frame->root->op = frame->root->op;
new_frame->root->type = frame->root->type;
@@ -295,7 +296,8 @@ gf_add_locker (struct _lock_table *table, const char *volume,
struct _locker *new = NULL;
uint8_t dir = 0;
- new = CALLOC (1, sizeof (struct _locker));
+ new = GF_CALLOC (1, sizeof (struct _locker),
+ gf_server_mt_locker);
if (new == NULL) {
gf_log ("server", GF_LOG_ERROR,
"failed to allocate memory for \'struct _locker\'");
@@ -303,7 +305,7 @@ gf_add_locker (struct _lock_table *table, const char *volume,
}
INIT_LIST_HEAD (&new->lockers);
- new->volume = strdup (volume);
+ new->volume = gf_strdup (volume);
if (fd == NULL) {
loc_copy (&new->loc, loc);
@@ -381,9 +383,9 @@ gf_del_locker (struct _lock_table *table, const char *volume,
else
loc_wipe (&locker->loc);
- free (locker->volume);
- free (locker);
- }
+ GF_FREE (locker->volume);
+ GF_FREE (locker);
+ }
return ret;
}
@@ -419,7 +421,7 @@ gf_direntry_to_bin (dir_entry_t *head, char *buffer)
trav->name, tmp_buf,
trav->link);
- FREE (tmp_buf);
+ GF_FREE (tmp_buf);
trav = trav->next;
ptr += this_len;
}
@@ -435,7 +437,8 @@ gf_lock_table_new (void)
{
struct _lock_table *new = NULL;
- new = CALLOC (1, sizeof (struct _lock_table));
+ new = GF_CALLOC (1, sizeof (struct _lock_table),
+ gf_server_mt_lock_table);
if (new == NULL) {
gf_log ("server-protocol", GF_LOG_CRITICAL,
"failed to allocate memory for new lock table");
@@ -473,7 +476,7 @@ do_lock_table_cleanup (xlator_t *this, server_connection_t *conn,
}
UNLOCK (&ltable->lock);
- free (ltable);
+ GF_FREE (ltable);
flock.l_type = F_UNLCK;
flock.l_start = 0;
@@ -509,10 +512,10 @@ do_lock_table_cleanup (xlator_t *this, server_connection_t *conn,
loc_wipe (&locker->loc);
}
- free (locker->volume);
-
+ GF_FREE (locker->volume);
+
list_del_init (&locker->lockers);
- free (locker);
+ GF_FREE (locker);
}
tmp = NULL;
@@ -541,10 +544,10 @@ do_lock_table_cleanup (xlator_t *this, server_connection_t *conn,
loc_wipe (&locker->loc);
}
- free (locker->volume);
-
+ GF_FREE (locker->volume);
+
list_del_init (&locker->lockers);
- free (locker);
+ GF_FREE (locker);
}
ret = 0;
@@ -601,7 +604,7 @@ do_fd_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame,
}
}
- FREE (fdentries);
+ GF_FREE (fdentries);
ret = 0;
out:
@@ -631,7 +634,7 @@ do_connection_cleanup (xlator_t *this, server_connection_t *conn,
state = CALL_STATE (frame);
if (state)
- free (state);
+ GF_FREE (state);
STACK_DESTROY (frame->root);
@@ -733,7 +736,7 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn)
list_splice_init (&ltable->dir_lockers, &dir_lockers);
}
UNLOCK (&ltable->lock);
- free (ltable);
+ GF_FREE (ltable);
flock.l_type = F_UNLCK;
flock.l_start = 0;
@@ -764,11 +767,11 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn)
loc_wipe (&locker->loc);
}
- free (locker->volume);
+ GF_FREE (locker->volume);
- list_del_init (&locker->lockers);
- free (locker);
- }
+ list_del_init (&locker->lockers);
+ GF_FREE (locker);
+ }
tmp = NULL;
locker = NULL;
@@ -796,11 +799,12 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn)
loc_wipe (&locker->loc);
}
- free (locker->volume);
+ GF_FREE (locker->volume);
- list_del_init (&locker->lockers);
- free (locker);
- }
+
+ list_del_init (&locker->lockers);
+ GF_FREE (locker);
+ }
pthread_mutex_lock (&(conn->lock));
{
@@ -827,22 +831,22 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn)
fd);
}
}
- FREE (fdentries);
+ GF_FREE (fdentries);
}
}
if (frame) {
state = CALL_STATE (frame);
if (state)
- free (state);
+ GF_FREE (state);
STACK_DESTROY (frame->root);
}
gf_log (this->name, GF_LOG_INFO, "destroyed connection of %s",
conn->id);
- FREE (conn->id);
- FREE (conn);
+ GF_FREE (conn->id);
+ GF_FREE (conn);
out:
return ret;
@@ -867,12 +871,13 @@ server_connection_get (xlator_t *this, const char *id)
}
}
- if (!conn) {
- conn = (void *) CALLOC (1, sizeof (*conn));
+ if (!conn) {
+ conn = (void *) GF_CALLOC (1, sizeof (*conn),
+ gf_server_mt_server_connection_t);
- conn->id = strdup (id);
- conn->fdtable = gf_fd_fdtable_alloc ();
- conn->ltable = gf_lock_table_new ();
+ conn->id = gf_strdup (id);
+ conn->fdtable = gf_fd_fdtable_alloc ();
+ conn->ltable = gf_lock_table_new ();
pthread_mutex_init (&conn->lock, NULL);
diff --git a/xlators/protocol/server/src/server-mem-types.h b/xlators/protocol/server/src/server-mem-types.h
new file mode 100644
index 00000000000..86877d79dac
--- /dev/null
+++ b/xlators/protocol/server/src/server-mem-types.h
@@ -0,0 +1,39 @@
+/*
+ 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 __AFR_MEM_TYPES_H__
+#define __AFR_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_server_mem_types_ {
+ gf_server_mt_dir_entry_t = gf_common_mt_end + 1,
+ gf_server_mt_volfile_ctx,
+ gf_server_mt_server_state_t,
+ gf_server_mt_server_conf_t,
+ gf_server_mt_locker,
+ gf_server_mt_lock_table,
+ gf_server_mt_char,
+ gf_server_mt_server_connection_t,
+ gf_server_mt_resolve_comp,
+ gf_server_mt_end
+};
+#endif
+
diff --git a/xlators/protocol/server/src/server-protocol.c b/xlators/protocol/server/src/server-protocol.c
index 71c5a1fc38c..079b3f2e4c3 100644
--- a/xlators/protocol/server/src/server-protocol.c
+++ b/xlators/protocol/server/src/server-protocol.c
@@ -2,7 +2,7 @@
Copyright (c) 2006-2009 Gluster, Inc. <http://www.gluster.com>
This file is part of GlusterFS.
- GlusterFS is free software; you can redistribute it and/or modify
+ GlusterFS is GF_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.
@@ -2535,10 +2535,10 @@ server_lookup (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_DONTCARE;
state->resolve.par = ntoh64 (req->par);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
if (IS_NOT_ROOT (pathlen)) {
- state->resolve.bname = strdup (req->bname + pathlen);
+ state->resolve.bname = gf_strdup (req->bname + pathlen);
baselen = STRLEN_0 (state->resolve.bname);
}
@@ -2555,7 +2555,7 @@ server_lookup (call_frame_t *frame, xlator_t *bound_xl,
"unserialize req-buffer to dictionary",
frame->root->unique, state->resolve.path,
state->resolve.ino);
- FREE (req_dictbuf);
+ GF_FREE (req_dictbuf);
goto err;
}
@@ -2625,7 +2625,7 @@ server_stat (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_MUST;
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
}
resolve_and_resume (frame, server_stat_resume);
@@ -2670,7 +2670,7 @@ server_setattr (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_MUST;
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
gf_stat_to_iatt (&req->stbuf, &state->stbuf);
state->valid = ntoh32 (req->valid);
@@ -2762,7 +2762,7 @@ server_readlink (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_MUST;
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->size = ntoh32 (req->size);
@@ -2817,8 +2817,8 @@ server_create (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_NOT;
state->resolve.par = ntoh64 (req->par);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
- state->resolve.bname = strdup (req->bname + pathlen);
+ state->resolve.path = gf_strdup (req->path);
+ state->resolve.bname = gf_strdup (req->bname + pathlen);
state->mode = ntoh32 (req->mode);
state->flags = gf_flags_to_flags (ntoh32 (req->flags));
@@ -2867,7 +2867,7 @@ server_open (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_MUST;
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->flags = gf_flags_to_flags (ntoh32 (req->flags));
@@ -3208,7 +3208,7 @@ server_truncate (call_frame_t *frame, xlator_t *bound_xl,
state = CALL_STATE (frame);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
state->offset = ntoh64 (req->offset);
@@ -3257,8 +3257,8 @@ server_unlink (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_MUST;
state->resolve.par = ntoh64 (req->par);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
- state->resolve.bname = strdup (req->bname + pathlen);
+ state->resolve.path = gf_strdup (req->path);
+ state->resolve.bname = gf_strdup (req->bname + pathlen);
resolve_and_resume (frame, server_unlink_resume);
@@ -3306,7 +3306,7 @@ server_setxattr (call_frame_t *frame, xlator_t *bound_xl,
dict_len = ntoh32 (req->dict_len);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->path + dict_len);
+ state->resolve.path = gf_strdup (req->path + dict_len);
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
state->flags = ntoh32 (req->flags);
@@ -3323,7 +3323,7 @@ server_setxattr (call_frame_t *frame, xlator_t *bound_xl,
"unserialize request buffer to dictionary",
frame->root->unique, state->loc.path,
state->resolve.ino);
- FREE (req_dictbuf);
+ GF_FREE (req_dictbuf);
goto err;
}
@@ -3400,7 +3400,7 @@ server_fsetxattr (call_frame_t *frame, xlator_t *bound_xl,
"unserialize request buffer to dictionary",
frame->root->unique, state->loc.path,
state->resolve.ino);
- FREE (req_dictbuf);
+ GF_FREE (req_dictbuf);
goto err;
}
@@ -3478,7 +3478,7 @@ server_fxattrop (call_frame_t *frame, xlator_t *bound_xl,
"fd - %"PRId64" (%"PRId64"): failed to unserialize "
"request buffer to dictionary",
state->resolve.fd_no, state->fd->inode->ino);
- free (req_dictbuf);
+ GF_FREE (req_dictbuf);
goto fail;
}
dict->extra_free = req_dictbuf;
@@ -3538,7 +3538,7 @@ server_xattrop (call_frame_t *frame, xlator_t *bound_xl,
dict_len = ntoh32 (req->dict_len);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->path + dict_len);
+ state->resolve.path = gf_strdup (req->path + dict_len);
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
state->flags = ntoh32 (req->flags);
@@ -3555,7 +3555,7 @@ server_xattrop (call_frame_t *frame, xlator_t *bound_xl,
"fd - %"PRId64" (%"PRId64"): failed to unserialize "
"request buffer to dictionary",
state->resolve.fd_no, state->fd->inode->ino);
- free (req_dictbuf);
+ GF_FREE (req_dictbuf);
goto fail;
}
dict->extra_free = req_dictbuf;
@@ -3613,13 +3613,13 @@ server_getxattr (call_frame_t *frame, xlator_t *bound_xl,
pathlen = STRLEN_0 (req->path);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
namelen = ntoh32 (req->namelen);
if (namelen)
- state->name = strdup (req->name + pathlen);
+ state->name = gf_strdup (req->name + pathlen);
resolve_and_resume (frame, server_getxattr_resume);
@@ -3665,7 +3665,7 @@ server_fgetxattr (call_frame_t *frame, xlator_t *bound_xl,
namelen = ntoh32 (req->namelen);
if (namelen)
- state->name = strdup (req->name);
+ state->name = gf_strdup (req->name);
resolve_and_resume (frame, server_fgetxattr_resume);
@@ -3708,10 +3708,10 @@ server_removexattr (call_frame_t *frame, xlator_t *bound_xl,
pathlen = STRLEN_0 (req->path);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
- state->name = strdup (req->name + pathlen);
+ state->name = gf_strdup (req->name + pathlen);
resolve_and_resume (frame, server_removexattr_resume);
@@ -3758,7 +3758,7 @@ server_statfs (call_frame_t *frame, xlator_t *bound_xl,
if (!state->resolve.ino)
state->resolve.ino = 1;
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
resolve_and_resume (frame, server_statfs_resume);
@@ -3801,7 +3801,7 @@ server_opendir (call_frame_t *frame, xlator_t *bound_xl,
state = CALL_STATE (frame);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
@@ -4087,8 +4087,8 @@ server_mknod (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_NOT;
state->resolve.par = ntoh64 (req->par);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
- state->resolve.bname = strdup (req->bname + pathlen);
+ state->resolve.path = gf_strdup (req->path);
+ state->resolve.bname = gf_strdup (req->bname + pathlen);
state->mode = ntoh32 (req->mode);
state->dev = ntoh64 (req->dev);
@@ -4140,8 +4140,8 @@ server_mkdir (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_NOT;
state->resolve.par = ntoh64 (req->par);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
- state->resolve.bname = strdup (req->bname + pathlen);
+ state->resolve.path = gf_strdup (req->path);
+ state->resolve.bname = gf_strdup (req->bname + pathlen);
state->mode = ntoh32 (req->mode);
@@ -4186,8 +4186,8 @@ server_rmdir (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_MUST;
state->resolve.par = ntoh64 (req->par);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
- state->resolve.bname = strdup (req->bname + pathlen);
+ state->resolve.path = gf_strdup (req->path);
+ state->resolve.bname = gf_strdup (req->bname + pathlen);
resolve_and_resume (frame, server_rmdir_resume);
@@ -4235,7 +4235,7 @@ server_inodelk (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_EXACT;
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
cmd = ntoh32 (req->cmd);
switch (cmd) {
@@ -4251,7 +4251,7 @@ server_inodelk (call_frame_t *frame, xlator_t *bound_xl,
}
state->type = ntoh32 (req->type);
- state->volume = strdup (req->volume + pathlen);
+ state->volume = gf_strdup (req->volume + pathlen);
gf_flock_to_flock (&req->flock, &state->flock);
@@ -4310,7 +4310,7 @@ server_finodelk (call_frame_t *frame, xlator_t *bound_xl,
state = CALL_STATE(frame);
state->resolve.type = RESOLVE_EXACT;
- state->volume = strdup (req->volume);
+ state->volume = gf_strdup (req->volume);
state->resolve.fd_no = ntoh64 (req->fd);
state->cmd = ntoh32 (req->cmd);
@@ -4388,13 +4388,13 @@ server_entrylk (call_frame_t *frame, xlator_t *bound_xl,
vollen = STRLEN_0(req->volume + pathlen + namelen);
state->resolve.type = RESOLVE_EXACT;
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
if (namelen)
- state->name = strdup (req->name + pathlen);
- state->volume = strdup (req->volume + pathlen + namelen);
+ state->name = gf_strdup (req->name + pathlen);
+ state->volume = gf_strdup (req->volume + pathlen + namelen);
state->cmd = ntoh32 (req->cmd);
state->type = ntoh32 (req->type);
@@ -4451,7 +4451,7 @@ server_fentrylk (call_frame_t *frame, xlator_t *bound_xl,
namelen = ntoh64 (req->namelen);
if (namelen)
state->name = req->name;
- state->volume = strdup (req->volume + namelen);
+ state->volume = gf_strdup (req->volume + namelen);
resolve_and_resume (frame, server_finodelk_resume);
@@ -4495,7 +4495,7 @@ server_access (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_MUST;
state->resolve.ino = hton64 (req->ino);
state->resolve.gen = hton64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->mask = ntoh32 (req->mask);
@@ -4548,9 +4548,9 @@ server_symlink (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_NOT;
state->resolve.par = ntoh64 (req->par);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
- state->resolve.bname = strdup (req->bname + pathlen);
- state->name = strdup (req->linkname + pathlen + baselen);
+ state->resolve.path = gf_strdup (req->path);
+ state->resolve.bname = gf_strdup (req->bname + pathlen);
+ state->name = gf_strdup (req->linkname + pathlen + baselen);
resolve_and_resume (frame, server_symlink_resume);
@@ -4610,13 +4610,13 @@ server_link (call_frame_t *frame, xlator_t *this,
newbaselen = STRLEN_0 (req->newbname + oldpathlen + newpathlen);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->oldpath);
+ state->resolve.path = gf_strdup (req->oldpath);
state->resolve.ino = ntoh64 (req->oldino);
state->resolve.gen = ntoh64 (req->oldgen);
state->resolve2.type = RESOLVE_NOT;
- state->resolve2.path = strdup (req->newpath + oldpathlen);
- state->resolve2.bname = strdup (req->newbname + oldpathlen + newpathlen);
+ state->resolve2.path = gf_strdup (req->newpath + oldpathlen);
+ state->resolve2.bname = gf_strdup (req->newbname + oldpathlen + newpathlen);
state->resolve2.par = ntoh64 (req->newpar);
state->resolve2.gen = ntoh64 (req->newgen);
@@ -4680,14 +4680,14 @@ server_rename (call_frame_t *frame, xlator_t *bound_xl,
oldbaselen + newpathlen);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->oldpath);
- state->resolve.bname = strdup (req->oldbname + oldpathlen);
+ state->resolve.path = gf_strdup (req->oldpath);
+ state->resolve.bname = gf_strdup (req->oldbname + oldpathlen);
state->resolve.par = ntoh64 (req->oldpar);
state->resolve.gen = ntoh64 (req->oldgen);
state->resolve2.type = RESOLVE_MAY;
- state->resolve2.path = strdup (req->newpath + oldpathlen + oldbaselen);
- state->resolve2.bname = strdup (req->newbname + oldpathlen + oldbaselen +
+ state->resolve2.path = gf_strdup (req->newpath + oldpathlen + oldbaselen);
+ state->resolve2.bname = gf_strdup (req->newbname + oldpathlen + oldbaselen +
newpathlen);
state->resolve2.par = ntoh64 (req->newpar);
state->resolve2.gen = ntoh64 (req->newgen);
@@ -4809,10 +4809,11 @@ _volfile_update_checksum (xlator_t *this, char *key, uint32_t checksum)
}
if (!temp_volfile) {
- temp_volfile = CALLOC (1, sizeof (struct _volfile_ctx));
+ temp_volfile = GF_CALLOC (1, sizeof (struct _volfile_ctx),
+ gf_server_mt_volfile_ctx);
temp_volfile->next = conf->volfile;
- temp_volfile->key = (key)? strdup (key): NULL;
+ temp_volfile->key = (key)? gf_strdup (key): NULL;
temp_volfile->checksum = checksum;
conf->volfile = temp_volfile;
@@ -4900,12 +4901,12 @@ build_volfile_path (xlator_t *this, const char *key, char *path,
goto out;
}
- conf_dir = strdup (conf_dir_data->data);
+ conf_dir = gf_strdup (conf_dir_data->data);
free_conf_dir = 1;
}
- ret = asprintf (&filename, "%s/%s.vol",
- conf_dir, key);
+ ret = gf_asprintf (&filename, "%s/%s.vol",
+ conf_dir, key);
if (-1 == ret)
goto out;
@@ -4933,10 +4934,10 @@ build_volfile_path (xlator_t *this, const char *key, char *path,
out:
if (free_conf_dir)
- free (conf_dir);
+ GF_FREE (conf_dir);
if (free_filename)
- free (filename);
+ GF_FREE (filename);
return ret;
}
@@ -5161,7 +5162,7 @@ server_checksum (call_frame_t *frame, xlator_t *bound_xl,
state = CALL_STATE (frame);
state->resolve.type = RESOLVE_MAY;
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->resolve.gen = ntoh64 (req->gen);
state->resolve.ino = ntoh64 (req->ino);
state->flags = ntoh32 (req->flag);
@@ -5397,11 +5398,11 @@ mop_setvolume (call_frame_t *frame, xlator_t *bound_xl,
ret = strcmp (version, GF_PROTOCOL_VERSION);
if (ret != 0) {
- ret = asprintf (&msg, "protocol version mismatch: client(%s) "
+ ret = gf_asprintf (&msg, "protocol version mismatch: client(%s) "
"- server(%s)", version, GF_PROTOCOL_VERSION);
if (-1 == ret) {
gf_log (trans->xl->name, GF_LOG_ERROR,
- "asprintf failed while setting up error msg");
+ "gf_asprintf failed while setting up error msg");
goto fail;
}
ret = dict_set_dynstr (reply, "ERROR", msg);
@@ -5430,11 +5431,11 @@ mop_setvolume (call_frame_t *frame, xlator_t *bound_xl,
xl = get_xlator_by_name (frame->this, name);
if (xl == NULL) {
- ret = asprintf (&msg, "remote-subvolume \"%s\" is not found",
+ ret = gf_asprintf (&msg, "remote-subvolume \"%s\" is not found",
name);
if (-1 == ret) {
gf_log (trans->xl->name, GF_LOG_ERROR,
- "asprintf failed while setting error msg");
+ "gf_asprintf failed while setting error msg");
goto fail;
}
ret = dict_set_dynstr (reply, "ERROR", msg);
@@ -5806,7 +5807,8 @@ get_frame_for_transport (transport_t *trans)
frame = create_frame (trans->xl, pool);
GF_VALIDATE_OR_GOTO("server", frame, out);
- state = CALLOC (1, sizeof (*state));
+ state = GF_CALLOC (1, sizeof (*state),
+ gf_server_mt_server_state_t);
GF_VALIDATE_OR_GOTO("server", state, out);
conn = trans->xl_private;
@@ -6187,7 +6189,7 @@ get_auth_types (dict_t *this, char *key, data_t *value, void *data)
int32_t ret = -1;
auth_dict = data;
- key_cpy = strdup (key);
+ key_cpy = gf_strdup (key);
GF_VALIDATE_OR_GOTO("server", key_cpy, out);
tmp = strtok_r (key_cpy, ".", &saveptr);
@@ -6208,7 +6210,7 @@ get_auth_types (dict_t *this, char *key, data_t *value, void *data)
}
}
- FREE (key_cpy);
+ GF_FREE (key_cpy);
out:
return;
}
@@ -6229,7 +6231,7 @@ validate_auth_options (xlator_t *this, dict_t *dict)
while (trav) {
error = -1;
for (pair = dict->members_list; pair; pair = pair->next) {
- key_cpy = strdup (pair->key);
+ key_cpy = gf_strdup (pair->key);
tmp = strtok_r (key_cpy, ".", &saveptr);
ret = strcmp (tmp, "auth");
if (ret == 0) {
@@ -6241,10 +6243,10 @@ validate_auth_options (xlator_t *this, dict_t *dict)
if (strcmp (tmp, trav->xlator->name) == 0) {
error = 0;
- free (key_cpy);
+ GF_FREE (key_cpy);
break;
}
- free (key_cpy);
+ GF_FREE (key_cpy);
}
if (-1 == error) {
gf_log (this->name, GF_LOG_ERROR,
@@ -6259,6 +6261,25 @@ validate_auth_options (xlator_t *this, dict_t *dict)
return error;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_server_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ " failed");
+ return ret;
+ }
+
+ return ret;
+}
+
/*
* init - called during server protocol initialization
@@ -6295,7 +6316,8 @@ init (xlator_t *this)
goto out;
}
- conf = CALLOC (1, sizeof (server_conf_t));
+ conf = GF_CALLOC (1, sizeof (server_conf_t),
+ gf_server_mt_server_conf_t);
GF_VALIDATE_OR_GOTO(this->name, conf, out);
INIT_LIST_HEAD (&conf->conns);
@@ -6409,7 +6431,7 @@ protocol_server_pollin (xlator_t *this, transport_t *trans)
hdrlen, iobuf);
/* TODO: use mem-pool */
- FREE (hdr);
+ GF_FREE (hdr);
return ret;
}
@@ -6433,7 +6455,7 @@ fini (xlator_t *this)
dict_unref (conf->auth_modules);
}
- FREE (conf);
+ GF_FREE (conf);
this->private = NULL;
out:
return;
diff --git a/xlators/protocol/server/src/server-protocol.h b/xlators/protocol/server/src/server-protocol.h
index 61fcb877e42..3d432614c27 100644
--- a/xlators/protocol/server/src/server-protocol.h
+++ b/xlators/protocol/server/src/server-protocol.h
@@ -34,6 +34,7 @@
#include "authenticate.h"
#include "fd.h"
#include "byte-order.h"
+#include "server-mem-types.h"
#define DEFAULT_BLOCK_SIZE 4194304 /* 4MB */
#define DEFAULT_VOLUME_FILE_PATH CONFDIR "/glusterfs.vol"
diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c
index f4c9ebad7a2..00f1728c5eb 100644
--- a/xlators/protocol/server/src/server-resolve.c
+++ b/xlators/protocol/server/src/server-resolve.c
@@ -69,11 +69,12 @@ prepare_components (call_frame_t *frame)
this = frame->this;
resolve = state->resolve_now;
- resolved = strdup (resolve->path);
+ resolved = gf_strdup (resolve->path);
resolve->resolved = resolved;
count = component_count (resolve->path);
- components = CALLOC (sizeof (*components), count);
+ components = GF_CALLOC (sizeof (*components), count,
+ gf_server_mt_resolve_comp);
resolve->components = components;
components[0].basename = "";
@@ -116,7 +117,7 @@ resolve_loc_touchup (call_frame_t *frame)
}
if (!path)
- path = strdup (resolve->path);
+ path = gf_strdup (resolve->path);
loc->path = path;
}
@@ -205,7 +206,7 @@ resolve_deep_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* join the current component with the path resolved until now */
*(components[i].basename - 1) = '/';
- resolve->deep_loc.path = strdup (resolve->resolved);
+ resolve->deep_loc.path = gf_strdup (resolve->resolved);
resolve->deep_loc.parent = inode_ref (components[i-1].inode);
resolve->deep_loc.inode = inode_new (state->itable);
resolve->deep_loc.name = components[i].basename;
@@ -241,7 +242,7 @@ resolve_path_deep (call_frame_t *frame)
/* start from the root */
resolve->deep_loc.inode = state->itable->root;
- resolve->deep_loc.path = strdup ("/");
+ resolve->deep_loc.path = gf_strdup ("/");
resolve->deep_loc.name = "";
STACK_WIND_COOKIE (frame, resolve_deep_cbk, (void *) (long) i,
diff --git a/xlators/storage/bdb/src/bctx.c b/xlators/storage/bdb/src/bctx.c
index 361ce75fe9c..150d709a245 100644
--- a/xlators/storage/bdb/src/bctx.c
+++ b/xlators/storage/bdb/src/bctx.c
@@ -25,12 +25,12 @@ static void
__destroy_bctx (bctx_t *bctx)
{
if (bctx->directory)
- FREE (bctx->directory);
+ GF_FREE (bctx->directory);
if (bctx->db_path)
- FREE (bctx->db_path);
+ GF_FREE (bctx->db_path);
- FREE (bctx);
+ GF_FREE (bctx);
}
static void
@@ -236,16 +236,16 @@ __create_bctx (bctx_table_t *table,
bctx_t *bctx = NULL;
char *db_path = NULL;
- bctx = CALLOC (1, sizeof (*bctx));
+ bctx = GF_CALLOC (1, sizeof (*bctx), gf_bdb_mt_bctx_t);
GF_VALIDATE_OR_GOTO ("bctx", bctx, out);
bctx->table = table;
- bctx->directory = strdup (path);
+ bctx->directory = gf_strdup (path);
GF_VALIDATE_OR_GOTO ("bctx", bctx->directory, out);
MAKE_REAL_PATH_TO_STORAGE_DB (db_path, BDB_THIS (table), path);
- bctx->db_path = strdup (db_path);
+ bctx->db_path = gf_strdup (db_path);
GF_VALIDATE_OR_GOTO ("bctx", bctx->directory, out);
INIT_LIST_HEAD (&bctx->c_list);
@@ -327,7 +327,7 @@ bctx_parent (bctx_table_t *table,
GF_VALIDATE_OR_GOTO ("bctx", table, out);
GF_VALIDATE_OR_GOTO ("bctx", path, out);
- pathname = strdup (path);
+ pathname = gf_strdup (path);
GF_VALIDATE_OR_GOTO ("bctx", pathname, out);
directory = dirname (pathname);
diff --git a/xlators/storage/bdb/src/bdb-ll.c b/xlators/storage/bdb/src/bdb-ll.c
index 290b29710dd..dcf18c0a737 100644
--- a/xlators/storage/bdb/src/bdb-ll.c
+++ b/xlators/storage/bdb/src/bdb-ll.c
@@ -57,7 +57,7 @@ bdb_generate_secondary_hash (DB *secondary,
primary = pkey->data;
- hash = calloc (1, sizeof (uint32_t));
+ hash = GF_CALLOC (1, sizeof (uint32_t), gf_bdb_mt_uint32_t);
*hash = gf_dm_hashfn (primary, pkey->size);
@@ -316,9 +316,10 @@ bdb_cache_insert (bctx_t *bctx,
list_del_init (&bcache->c_list);
}
if (bcache->key) {
- free (bcache->key);
- bcache->key = calloc (key->size + 1,
- sizeof (char));
+ GF_FREE (bcache->key);
+ bcache->key = GF_CALLOC (key->size + 1,
+ sizeof (char),
+ gf_bdb_mt_char);
GF_VALIDATE_OR_GOTO ("bdb-ll",
bcache->key, unlock);
memcpy (bcache->key, (char *)key->data,
@@ -331,7 +332,7 @@ bdb_cache_insert (bctx_t *bctx,
bctx->directory, (char *)key->data);
} /* if(bcache->key)...else */
if (bcache->data) {
- free (bcache->data);
+ GF_FREE (bcache->data);
bcache->data = memdup (data->data, data->size);
GF_VALIDATE_OR_GOTO ("bdb-ll", bcache->data,
unlock);
@@ -347,10 +348,12 @@ bdb_cache_insert (bctx_t *bctx,
ret = 0;
} else {
/* we will be entering here very rarely */
- bcache = CALLOC (1, sizeof (*bcache));
+ bcache = GF_CALLOC (1, sizeof (*bcache),
+ gf_bdb_mt_bdb_cache_t);
GF_VALIDATE_OR_GOTO ("bdb-ll", bcache, unlock);
- bcache->key = calloc (key->size + 1, sizeof (char));
+ bcache->key = GF_CALLOC (key->size + 1, sizeof (char),
+ gf_bdb_mt_char);
GF_VALIDATE_OR_GOTO ("bdb-ll", bcache->key, unlock);
memcpy (bcache->key, key->data, key->size);
@@ -391,9 +394,9 @@ bdb_cache_delete (bctx_t *bctx,
if (bcache) {
list_del_init (&bcache->c_list);
- free (bcache->key);
- free (bcache->data);
- free (bcache);
+ GF_FREE (bcache->key);
+ GF_FREE (bcache->data);
+ GF_FREE (bcache);
}
}
UNLOCK (&bctx->lock);
@@ -578,7 +581,7 @@ bdb_db_get (bctx_t *bctx,
}
if (size == 0)
- free (value.data);
+ GF_FREE (value.data);
need_break = 1;
} else {
@@ -615,7 +618,7 @@ bdb_db_iread (struct bdb_ctx *bctx, const char *key, char **bufp)
size = ret;
if (bufp) {
- buf = calloc (size, sizeof (char));
+ buf = GF_CALLOC (size, sizeof (char), gf_bdb_mt_char);
*bufp = buf;
ret = bdb_db_get (bctx, NULL, key, buf, size, 0);
}
@@ -1309,7 +1312,7 @@ bdb_db_init (xlator_t *this,
private->dir_mode = private->dir_mode | S_IFDIR;
- table = CALLOC (1, sizeof (*table));
+ table = GF_CALLOC (1, sizeof (*table), gf_bdb_mt_bctx_table_t);
if (table == NULL) {
gf_log ("bdb-ll", GF_LOG_CRITICAL,
"memory allocation for 'storage/bdb' internal "
@@ -1376,8 +1379,9 @@ bdb_db_init (xlator_t *this,
}
table->hash_size = BDB_DEFAULT_HASH_SIZE;
- table->b_hash = CALLOC (BDB_DEFAULT_HASH_SIZE,
- sizeof (struct list_head));
+ table->b_hash = GF_CALLOC (BDB_DEFAULT_HASH_SIZE,
+ sizeof (struct list_head),
+ gf_bdb_mt_list_head);
for (idx = 0; idx < table->hash_size; idx++)
INIT_LIST_HEAD(&(table->b_hash[idx]));
@@ -1386,7 +1390,7 @@ bdb_db_init (xlator_t *this,
ret = dict_get_str (options, "errfile", &errfile);
if (ret == 0) {
- private->errfile = strdup (errfile);
+ private->errfile = gf_strdup (errfile);
gf_log (this->name, GF_LOG_DEBUG,
"using %s as error logging file for libdb (Berkeley DB "
"library) internal logging.", private->errfile);
@@ -1402,10 +1406,10 @@ bdb_db_init (xlator_t *this,
"using the database environment home "
"directory (%s) itself as transaction log "
"directory", directory);
- private->logdir = strdup (directory);
+ private->logdir = gf_strdup (directory);
} else {
- private->logdir = strdup (logdir);
+ private->logdir = gf_strdup (logdir);
op_ret = stat (private->logdir, &stbuf);
if ((op_ret != 0)
@@ -1445,15 +1449,15 @@ bdb_db_init (xlator_t *this,
return op_ret;
err:
if (table) {
- FREE (table->b_hash);
- FREE (table);
+ GF_FREE (table->b_hash);
+ GF_FREE (table);
}
if (private) {
if (private->errfile)
- FREE (private->errfile);
+ GF_FREE (private->errfile);
if (private->logdir)
- FREE (private->logdir);
+ GF_FREE (private->logdir);
}
return -1;
diff --git a/xlators/storage/bdb/src/bdb-mem-types.h b/xlators/storage/bdb/src/bdb-mem-types.h
new file mode 100644
index 00000000000..cfbc4a4e117
--- /dev/null
+++ b/xlators/storage/bdb/src/bdb-mem-types.h
@@ -0,0 +1,42 @@
+/*
+ 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 __POSIX_MEM_TYPES_H__
+#define __POSIX_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_bdb_mem_types_ {
+ gf_bdb_mt_bctx_t = gf_common_mt_end + 1,
+ gf_bdb_mt_bdb_fd,
+ gf_bdb_mt_dir_entry_t,
+ gf_bdb_mt_char,
+ gf_bdb_mt_dir_entry_t,
+ gf_bdb_mt_char,
+ gf_bdb_mt_bdb_private,
+ gf_bdb_mt_uint32_t,
+ gf_bdb_mt_char,
+ gf_bdb_mt_bdb_cache_t,
+ gf_bdb_mt_char,
+ gf_bdb_mt_bctx_table_t,
+ gf_bdb_mt_list_head,
+ gf_bdb_mt_end,
+};
+#endif
diff --git a/xlators/storage/bdb/src/bdb.c b/xlators/storage/bdb/src/bdb.c
index 68e5227a17b..fba34ee0450 100644
--- a/xlators/storage/bdb/src/bdb.c
+++ b/xlators/storage/bdb/src/bdb.c
@@ -320,7 +320,7 @@ bdb_create (call_frame_t *frame,
}
/* create successful */
- bfd = CALLOC (1, sizeof (*bfd));
+ bfd = GF_CALLOC (1, sizeof (*bfd), gf_bdb_mt_bdb_fd);
if (bfd == NULL) {
gf_log (this->name, GF_LOG_DEBUG,
"CREATE %"PRId64"/%s (%s): ENOMEM"
@@ -333,7 +333,7 @@ bdb_create (call_frame_t *frame,
/* NOTE: bdb_get_bctx_from () returns bctx with a ref */
bfd->ctx = bctx;
- bfd->key = strdup (key_string);
+ bfd->key = gf_strdup (key_string);
if (bfd->key == NULL) {
gf_log (this->name, GF_LOG_DEBUG,
"CREATE %"PRId64" (%s): ENOMEM"
@@ -399,7 +399,7 @@ bdb_open (call_frame_t *frame,
goto out;
}
- bfd = CALLOC (1, sizeof (*bfd));
+ bfd = GF_CALLOC (1, sizeof (*bfd), gf_bdb_mt_bdb_fd);
if (bfd == NULL) {
gf_log (this->name, GF_LOG_DEBUG,
"OPEN %"PRId64" (%s): ENOMEM"
@@ -414,7 +414,7 @@ bdb_open (call_frame_t *frame,
bfd->ctx = bctx;
MAKE_KEY_FROM_PATH (key_string, loc->path);
- bfd->key = strdup (key_string);
+ bfd->key = gf_strdup (key_string);
if (bfd->key == NULL) {
gf_log (this->name, GF_LOG_DEBUG,
"OPEN %"PRId64" (%s): ENOMEM"
@@ -686,8 +686,8 @@ bdb_release (xlator_t *this,
bfd->ctx = NULL;
if (bfd->key)
- FREE (bfd->key); /* we did strdup() in bdb_open() */
- FREE (bfd);
+ GF_FREE (bfd->key); /* we did strdup() in bdb_open() */
+ GF_FREE (bfd);
op_ret = 0;
op_errno = 0;
@@ -793,7 +793,7 @@ bdb_lookup (call_frame_t *frame,
MAKE_REAL_PATH (real_path, this, loc->path);
- pathname = strdup (loc->path);
+ pathname = gf_strdup (loc->path);
GF_VALIDATE_OR_GOTO (this->name, pathname, out);
directory = dirname (pathname);
@@ -932,11 +932,11 @@ bdb_lookup (call_frame_t *frame,
file_content, entry_size);
if (op_ret < 0) {
/* continue without giving file contents */
- FREE (file_content);
+ GF_FREE (file_content);
}
} else {
if (file_content)
- FREE (file_content);
+ GF_FREE (file_content);
}
if (loc->ino) {
@@ -966,7 +966,7 @@ out:
}
if (pathname)
- free (pathname);
+ GF_FREE (pathname);
if (xattr)
dict_ref (xattr);
@@ -1102,7 +1102,7 @@ bdb_opendir (call_frame_t *frame,
goto out;
}
- bfd = CALLOC (1, sizeof (*bfd));
+ bfd = GF_CALLOC (1, sizeof (*bfd), gf_bdb_mt_bdb_fd);
if (bfd == NULL) {
gf_log (this->name, GF_LOG_DEBUG,
"OPENDIR %"PRId64" (%s): ENOMEM"
@@ -1126,7 +1126,7 @@ bdb_opendir (call_frame_t *frame,
/* NOTE: bctx_lookup() return bctx with ref */
bfd->ctx = bctx;
- bfd->path = strdup (real_path);
+ bfd->path = gf_strdup (real_path);
if (bfd == NULL) {
gf_log (this->name, GF_LOG_DEBUG,
"OPENDIR %"PRId64" (%s): ENOMEM"
@@ -1149,7 +1149,7 @@ err:
if (bfd->dir)
closedir (bfd->dir);
- FREE (bfd);
+ GF_FREE (bfd);
}
return 0;
@@ -1264,7 +1264,8 @@ bdb_getdents (call_frame_t *frame,
continue;
}/* if(key.data)...else */
- this_entry = CALLOC (1, sizeof (*this_entry));
+ this_entry = GF_CALLOC (1, sizeof (*this_entry),
+ gf_bdb_mt_dir_entry_t);
if (this_entry == NULL) {
gf_log (this->name, GF_LOG_DEBUG,
"GETDENTS %"PRId64" - %"GF_PRI_SIZET",%"PRId64
@@ -1276,7 +1277,8 @@ bdb_getdents (call_frame_t *frame,
goto out;
}
- this_entry->name = CALLOC (pri.size + 1, sizeof (char));
+ this_entry->name = GF_CALLOC (pri.size + 1, sizeof (char),
+ gf_bdb_mt_char);
if (this_entry->name == NULL) {
gf_log (this->name, GF_LOG_DEBUG,
"GETDENTS %"PRId64" - %"GF_PRI_SIZET",%"PRId64
@@ -1308,10 +1310,10 @@ bdb_getdents (call_frame_t *frame,
/* if size is 0, count can never be = size,
* so entire dir is read */
if (sec.data)
- FREE (sec.data);
+ GF_FREE (sec.data);
if (pri.data)
- FREE (pri.data);
+ GF_FREE (pri.data);
if (count == size)
break;
@@ -1377,7 +1379,8 @@ dir_read:
continue;
}
- this_entry = CALLOC (1, sizeof (*this_entry));
+ this_entry = GF_CALLOC (1, sizeof (*this_entry),
+ gf_bdb_mt_dir_entry_t);
if (this_entry == NULL) {
gf_log (this->name, GF_LOG_DEBUG,
"GETDENTS %"PRId64" - %"GF_PRI_SIZET",%"PRId64
@@ -1389,7 +1392,7 @@ dir_read:
goto out;
}
- this_entry->name = strdup (dirent->d_name);
+ this_entry->name = gf_strdup (dirent->d_name);
if (this_entry->name == NULL) {
gf_log (this->name, GF_LOG_DEBUG,
"GETDENTS %"PRId64" - %"GF_PRI_SIZET",%"PRId64
@@ -1410,7 +1413,7 @@ dir_read:
ret = readlink (entry_path, linkpath, ZR_PATH_MAX);
if (ret != -1) {
linkpath[ret] = '\0';
- this_entry->link = strdup (linkpath);
+ this_entry->link = gf_strdup (linkpath);
}
} else {
this_entry->link = "";
@@ -1441,8 +1444,8 @@ out:
while (entries.next) {
this_entry = entries.next;
entries.next = entries.next->next;
- FREE (this_entry->name);
- FREE (this_entry);
+ GF_FREE (this_entry->name);
+ GF_FREE (this_entry);
}
return 0;
@@ -1468,7 +1471,7 @@ bdb_releasedir (xlator_t *this,
}
if (bfd->path) {
- free (bfd->path);
+ GF_FREE (bfd->path);
} else {
gf_log (this->name, GF_LOG_DEBUG,
"RELEASEDIR %"PRId64": (bfd->path is NULL)",
@@ -1491,7 +1494,7 @@ bdb_releasedir (xlator_t *this,
fd->inode->ino);
}
- free (bfd);
+ GF_FREE (bfd);
out:
return 0;
@@ -2395,7 +2398,7 @@ bdb_getxattr (call_frame_t *frame,
if (op_ret == -1)
break;
- value = CALLOC (op_ret + 1, sizeof(char));
+ value = GF_CALLOC (op_ret + 1, sizeof(char), gf_bdb_mt_char);
GF_VALIDATE_OR_GOTO (this->name, value, out);
op_ret = sys_lgetxattr (real_path, key, value,
@@ -2406,7 +2409,7 @@ bdb_getxattr (call_frame_t *frame,
op_ret = dict_set_dynptr (dict, key,
value, op_ret);
if (op_ret < 0) {
- FREE (value);
+ GF_FREE (value);
gf_log (this->name, GF_LOG_DEBUG,
"GETXATTR %"PRId64" (%s) - %s: "
"(skipping key %s)",
@@ -2619,7 +2622,7 @@ bdb_setdents (call_frame_t *frame,
real_path_len = strlen (bfd->path);
entry_path_len = real_path_len + 256;
- entry_path = CALLOC (1, entry_path_len);
+ entry_path = GF_CALLOC (1, entry_path_len, gf_bdb_mt_char);
GF_VALIDATE_OR_GOTO (this->name, entry_path, out);
strcpy (entry_path, bfd->path);
@@ -2710,7 +2713,7 @@ bdb_setdents (call_frame_t *frame,
out:
STACK_UNWIND (frame, op_ret, op_errno);
- FREE (entry_path);
+ GF_FREE (entry_path);
return 0;
}
@@ -2892,11 +2895,11 @@ bdb_readdir (call_frame_t *frame,
this_entry->d_len = pri.size + 1;
if (sec.data) {
- FREE (sec.data);
+ GF_FREE (sec.data);
}
if (pri.data)
- FREE (pri.data);
+ GF_FREE (pri.data);
list_add_tail (&this_entry->list, &entries.list);
@@ -3189,7 +3192,7 @@ bdb_checksum (call_frame_t *frame,
for (idx = 0; idx < length; idx++)
file_checksum[idx] ^= data[idx];
- FREE (key.data);
+ GF_FREE (key.data);
} else {
gf_log (this->name, GF_LOG_DEBUG,
"CHECKSUM %"PRId64" (%s)",
@@ -3240,6 +3243,24 @@ notify (xlator_t *this,
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_bdb_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log(this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
/**
* init -
@@ -3273,7 +3294,7 @@ init (xlator_t *this)
goto err;
}
- _private = CALLOC (1, sizeof (*_private));
+ _private = GF_CALLOC (1, sizeof (*_private), gf_bdb_mt_bdb_private);
if (_private == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"could not allocate memory for 'storage/bdb' "
@@ -3317,7 +3338,7 @@ init (xlator_t *this)
}
- _private->export_path = strdup (directory);
+ _private->export_path = gf_strdup (directory);
if (_private->export_path == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"could not allocate memory for 'storage/bdb' "
@@ -3367,9 +3388,9 @@ init (xlator_t *this)
err:
if (_private) {
if (_private->export_path)
- FREE (_private->export_path);
+ GF_FREE (_private->export_path);
- FREE (_private);
+ GF_FREE (_private);
}
out:
return ret;
@@ -3444,9 +3465,9 @@ fini (xlator_t *this)
/* impossible to reach here */
}
- FREE (B_TABLE(this));
+ GF_FREE (B_TABLE(this));
}
- FREE (private);
+ GF_FREE (private);
return;
}
diff --git a/xlators/storage/posix/src/posix-mem-types.h b/xlators/storage/posix/src/posix-mem-types.h
new file mode 100644
index 00000000000..6687560cfab
--- /dev/null
+++ b/xlators/storage/posix/src/posix-mem-types.h
@@ -0,0 +1,36 @@
+/*
+ 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 __POSIX_MEM_TYPES_H__
+#define __POSIX_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_posix_mem_types_ {
+ gf_posix_mt_dir_entry_t = gf_common_mt_end + 1,
+ gf_posix_mt_posix_fd,
+ gf_posix_mt_char,
+ gf_posix_mt_posix_private,
+ gf_posix_mt_int32_t,
+ gf_posix_mt_posix_dev_t,
+ gf_posix_mt_trash_path,
+ gf_posix_mt_end
+};
+#endif
+
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 832b437b5d5..5ed3e5dc631 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -126,7 +126,8 @@ _posix_xattr_get_set (dict_t *xattr_req,
goto err;
}
- databuf = calloc (1, filler->stbuf->ia_size);
+ databuf = GF_CALLOC (1, filler->stbuf->ia_size,
+ gf_posix_mt_char);
if (!databuf) {
gf_log (filler->this->name, GF_LOG_ERROR,
@@ -163,7 +164,7 @@ _posix_xattr_get_set (dict_t *xattr_req,
if (_fd != -1)
close (_fd);
if (databuf)
- FREE (databuf);
+ GF_FREE (databuf);
}
} else if (!strcmp (key, GLUSTERFS_OPEN_FD_COUNT)) {
loc = filler->loc;
@@ -176,7 +177,8 @@ _posix_xattr_get_set (dict_t *xattr_req,
xattr_size = sys_lgetxattr (filler->real_path, key, NULL, 0);
if (xattr_size > 0) {
- value = calloc (1, xattr_size + 1);
+ value = GF_CALLOC (1, xattr_size + 1,
+ gf_posix_mt_char);
sys_lgetxattr (filler->real_path, key, value,
xattr_size);
@@ -422,7 +424,7 @@ setgid_override (xlator_t *this, char *real_path, gid_t *gid)
int op_ret = 0;
- tmp_path = strdup (real_path);
+ tmp_path = gf_strdup (real_path);
if (!tmp_path) {
op_ret = -ENOMEM;
gf_log ("[storage/posix]", GF_LOG_ERROR,
@@ -453,7 +455,7 @@ setgid_override (xlator_t *this, char *real_path, gid_t *gid)
out:
if (tmp_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return op_ret;
}
@@ -504,7 +506,7 @@ posix_lookup (call_frame_t *frame, xlator_t *this,
parent:
if (loc->parent) {
- pathdup = strdup (real_path);
+ pathdup = gf_strdup (real_path);
GF_VALIDATE_OR_GOTO (this->name, pathdup, out);
parentpath = dirname (pathdup);
@@ -522,7 +524,7 @@ parent:
op_ret = entry_ret;
out:
if (pathdup)
- FREE (pathdup);
+ GF_FREE (pathdup);
if (xattr)
dict_ref (xattr);
@@ -915,7 +917,7 @@ posix_opendir (call_frame_t *frame, xlator_t *this,
goto out;
}
- pfd = CALLOC (1, sizeof (*fd));
+ pfd = GF_CALLOC (1, sizeof (*fd), gf_posix_mt_posix_fd);
if (!pfd) {
op_errno = errno;
gf_log (this->name, GF_LOG_ERROR,
@@ -925,7 +927,7 @@ posix_opendir (call_frame_t *frame, xlator_t *this,
pfd->dir = dir;
pfd->fd = dirfd (dir);
- pfd->path = strdup (real_path);
+ pfd->path = gf_strdup (real_path);
if (!pfd->path) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory.");
@@ -944,8 +946,8 @@ posix_opendir (call_frame_t *frame, xlator_t *this,
}
if (pfd) {
if (pfd->path)
- FREE (pfd->path);
- FREE (pfd);
+ GF_FREE (pfd->path);
+ GF_FREE (pfd);
pfd = NULL;
}
}
@@ -1101,7 +1103,7 @@ posix_mknod (call_frame_t *frame, xlator_t *this,
goto out;
SET_FS_ID (frame->root->uid, gid);
- pathdup = strdup (real_path);
+ pathdup = gf_strdup (real_path);
GF_VALIDATE_OR_GOTO (this->name, pathdup, out);
parentpath = dirname (pathdup);
@@ -1168,7 +1170,7 @@ posix_mknod (call_frame_t *frame, xlator_t *this,
out:
if (pathdup)
- FREE (pathdup);
+ GF_FREE (pathdup);
SET_TO_OLD_FS_ID ();
@@ -1289,9 +1291,9 @@ posix_janitor_thread_proc (void *data)
}
if (pfd->path)
- FREE (pfd->path);
+ GF_FREE (pfd->path);
- FREE (pfd);
+ GF_FREE (pfd);
}
}
@@ -1367,7 +1369,7 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
goto out;
SET_FS_ID (frame->root->uid, gid);
- pathdup = strdup (real_path);
+ pathdup = gf_strdup (real_path);
GF_VALIDATE_OR_GOTO (this->name, pathdup, out);
parentpath = dirname (pathdup);
@@ -1423,7 +1425,7 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
out:
if (pathdup)
- FREE (pathdup);
+ GF_FREE (pathdup);
SET_TO_OLD_FS_ID ();
@@ -1461,7 +1463,7 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
SET_FS_ID (frame->root->uid, frame->root->gid);
MAKE_REAL_PATH (real_path, this, loc->path);
- pathdup = strdup (real_path);
+ pathdup = gf_strdup (real_path);
GF_VALIDATE_OR_GOTO (this->name, pathdup, out);
parentpath = dirname (pathdup);
@@ -1512,7 +1514,7 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
out:
if (pathdup)
- FREE (pathdup);
+ GF_FREE (pathdup);
SET_TO_OLD_FS_ID ();
@@ -1547,7 +1549,7 @@ posix_rmdir (call_frame_t *frame, xlator_t *this,
SET_FS_ID (frame->root->uid, frame->root->gid);
MAKE_REAL_PATH (real_path, this, loc->path);
- pathdup = strdup (real_path);
+ pathdup = gf_strdup (real_path);
GF_VALIDATE_OR_GOTO (this->name, pathdup, out);
parentpath = dirname (pathdup);
@@ -1589,7 +1591,7 @@ posix_rmdir (call_frame_t *frame, xlator_t *this,
out:
if (pathdup)
- FREE (pathdup);
+ GF_FREE (pathdup);
SET_TO_OLD_FS_ID ();
@@ -1639,7 +1641,7 @@ posix_symlink (call_frame_t *frame, xlator_t *this,
goto out;
SET_FS_ID (frame->root->uid, gid);
- pathdup = strdup (real_path);
+ pathdup = gf_strdup (real_path);
GF_VALIDATE_OR_GOTO (this->name, pathdup, out);
parentpath = dirname (pathdup);
@@ -1695,7 +1697,7 @@ posix_symlink (call_frame_t *frame, xlator_t *this,
out:
if (pathdup)
- FREE (pathdup);
+ GF_FREE (pathdup);
SET_TO_OLD_FS_ID ();
@@ -1744,7 +1746,7 @@ posix_rename (call_frame_t *frame, xlator_t *this,
MAKE_REAL_PATH (real_oldpath, this, oldloc->path);
MAKE_REAL_PATH (real_newpath, this, newloc->path);
- oldpathdup = strdup (real_oldpath);
+ oldpathdup = gf_strdup (real_oldpath);
GF_VALIDATE_OR_GOTO (this->name, oldpathdup, out);
oldparentpath = dirname (oldpathdup);
@@ -1758,7 +1760,7 @@ posix_rename (call_frame_t *frame, xlator_t *this,
goto out;
}
- newpathdup = strdup (real_newpath);
+ newpathdup = gf_strdup (real_newpath);
GF_VALIDATE_OR_GOTO (this->name, newpathdup, out);
newparentpath = dirname (newpathdup);
@@ -1818,10 +1820,10 @@ posix_rename (call_frame_t *frame, xlator_t *this,
out:
if (oldpathdup)
- FREE (oldpathdup);
+ GF_FREE (oldpathdup);
if (newpathdup)
- FREE (newpathdup);
+ GF_FREE (newpathdup);
SET_TO_OLD_FS_ID ();
@@ -1873,7 +1875,7 @@ posix_link (call_frame_t *frame, xlator_t *this,
was_present = 0;
}
- newpathdup = strdup (real_newpath);
+ newpathdup = gf_strdup (real_newpath);
if (!newpathdup) {
gf_log (this->name, GF_LOG_ERROR, "strdup failed");
op_errno = ENOMEM;
@@ -1919,7 +1921,7 @@ posix_link (call_frame_t *frame, xlator_t *this,
out:
if (newpathdup)
- FREE (newpathdup);
+ GF_FREE (newpathdup);
SET_TO_OLD_FS_ID ();
STACK_UNWIND_STRICT (link, frame, op_ret, op_errno,
@@ -2039,7 +2041,7 @@ posix_create (call_frame_t *frame, xlator_t *this,
}
SET_FS_ID (frame->root->uid, gid);
- pathdup = strdup (real_path);
+ pathdup = gf_strdup (real_path);
GF_VALIDATE_OR_GOTO (this->name, pathdup, out);
parentpath = dirname (pathdup);
@@ -2106,7 +2108,7 @@ posix_create (call_frame_t *frame, xlator_t *this,
}
op_ret = -1;
- pfd = CALLOC (1, sizeof (*pfd));
+ pfd = GF_CALLOC (1, sizeof (*pfd), gf_posix_mt_posix_fd);
if (!pfd) {
op_errno = errno;
@@ -2130,7 +2132,7 @@ posix_create (call_frame_t *frame, xlator_t *this,
out:
if (pathdup)
- FREE (pathdup);
+ GF_FREE (pathdup);
SET_TO_OLD_FS_ID ();
if ((-1 == op_ret) && (_fd != -1)) {
@@ -2197,7 +2199,7 @@ posix_open (call_frame_t *frame, xlator_t *this,
goto out;
}
- pfd = CALLOC (1, sizeof (*pfd));
+ pfd = GF_CALLOC (1, sizeof (*pfd), gf_posix_mt_posix_fd);
if (!pfd) {
op_errno = errno;
@@ -2453,7 +2455,8 @@ posix_writev (call_frame_t *frame, xlator_t *this,
max_buf_size = vector[idx].iov_len;
}
- alloc_buf = MALLOC (1 * (max_buf_size + align));
+ alloc_buf = GF_MALLOC (1 * (max_buf_size + align),
+ gf_posix_mt_char);
if (!alloc_buf) {
op_errno = errno;
gf_log (this->name, GF_LOG_ERROR,
@@ -2530,7 +2533,7 @@ posix_writev (call_frame_t *frame, xlator_t *this,
out:
if (alloc_buf) {
- FREE (alloc_buf);
+ GF_FREE (alloc_buf);
}
STACK_UNWIND_STRICT (writev, frame, op_ret, op_errno, &preop, &postop);
@@ -2965,7 +2968,8 @@ get_file_contents (xlator_t *this, char *real_path,
goto out;
}
- *contents = CALLOC (stbuf.ia_size + 1, sizeof(char));
+ *contents = GF_CALLOC (stbuf.ia_size + 1, sizeof(char),
+ gf_posix_mt_char);
if (! *contents) {
op_ret = -errno;
@@ -2995,7 +2999,7 @@ get_file_contents (xlator_t *this, char *real_path,
out:
if (op_ret < 0) {
if (*contents)
- FREE (*contents);
+ GF_FREE (*contents);
if (file_fd != -1)
close (file_fd);
}
@@ -3114,7 +3118,8 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
if (op_ret == -1)
break;
- value = CALLOC (op_ret + 1, sizeof(char));
+ value = GF_CALLOC (op_ret + 1, sizeof(char),
+ gf_posix_mt_char);
if (!value) {
op_errno = errno;
gf_log (this->name, GF_LOG_ERROR, "Out of memory.");
@@ -3129,7 +3134,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
if (strcmp (key, gen_key) != 0)
dict_set (dict, key, data_from_dynptr (value, op_ret));
else
- FREE (value);
+ GF_FREE (value);
remaining_size -= strlen (key) + 1;
list_offset += strlen (key) + 1;
@@ -3239,7 +3244,8 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
if (op_ret == -1)
break;
- value = CALLOC (op_ret + 1, sizeof(char));
+ value = GF_CALLOC (op_ret + 1, sizeof(char),
+ gf_posix_mt_char);
if (!value) {
op_errno = errno;
gf_log (this->name, GF_LOG_ERROR, "Out of memory.");
@@ -3525,7 +3531,7 @@ do_xattrop (call_frame_t *frame, xlator_t *this,
MAKE_REAL_PATH (real_path, this, loc->path);
if (loc) {
- path = strdup (loc->path);
+ path = gf_strdup (loc->path);
inode = loc->inode;
} else {
inode = fd->inode;
@@ -3533,7 +3539,8 @@ do_xattrop (call_frame_t *frame, xlator_t *this,
while (trav) {
count = trav->value->len / sizeof (int32_t);
- array = CALLOC (count, sizeof (int32_t));
+ array = GF_CALLOC (count, sizeof (int32_t),
+ gf_posix_mt_int32_t);
LOCK (&inode->lock);
{
@@ -3645,10 +3652,10 @@ do_xattrop (call_frame_t *frame, xlator_t *this,
out:
if (array)
- FREE (array);
+ GF_FREE (array);
if (path)
- FREE (path);
+ GF_FREE (path);
STACK_UNWIND_STRICT (xattrop, frame, op_ret, op_errno, xattr);
return 0;
@@ -4222,8 +4229,8 @@ posix_rchecksum (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (fd, out);
memset (strong_checksum, 0, MD5_DIGEST_LEN);
+ buf = GF_CALLOC (1, len, gf_posix_mt_char);
- buf = CALLOC (1, len);
if (!buf) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR,
@@ -4255,7 +4262,7 @@ posix_rchecksum (call_frame_t *frame, xlator_t *this,
weak_checksum = gf_rsync_weak_checksum (buf, len);
gf_rsync_strong_checksum (buf, len, strong_checksum);
- FREE (buf);
+ GF_FREE (buf);
op_ret = 0;
out:
@@ -4289,6 +4296,25 @@ notify (xlator_t *this,
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_posix_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log(this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
/**
* init -
*/
@@ -4375,7 +4401,8 @@ init (xlator_t *this)
}
}
- _private = CALLOC (1, sizeof (*_private));
+ _private = GF_CALLOC (1, sizeof (*_private),
+ gf_posix_mt_posix_private);
if (!_private) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory.");
@@ -4383,13 +4410,14 @@ init (xlator_t *this)
goto out;
}
- _private->base_path = strdup (dir_data->data);
+ _private->base_path = gf_strdup (dir_data->data);
_private->base_path_length = strlen (_private->base_path);
- _private->trash_path = CALLOC (1, _private->base_path_length
- + strlen ("/")
- + strlen (GF_REPLICATE_TRASH_DIR)
- + 1);
+ _private->trash_path = GF_CALLOC (1, _private->base_path_length
+ + strlen ("/")
+ + strlen (GF_REPLICATE_TRASH_DIR)
+ + 1,
+ gf_posix_mt_trash_path);
if (!_private->trash_path) {
gf_log (this->name, GF_LOG_ERROR,
@@ -4477,9 +4505,11 @@ init (xlator_t *this)
if (_private->num_devices_to_span < 1)
_private->num_devices_to_span = 1;
}
- _private->st_device = CALLOC (1, (sizeof (dev_t) *
- _private->num_devices_to_span));
+ _private->st_device = GF_CALLOC (1, (sizeof (dev_t) *
+ _private->num_devices_to_span),
+ gf_posix_mt_posix_dev_t);
+
/* Start with the base */
_private->st_device[0] = buf.st_dev;
@@ -4542,7 +4572,7 @@ fini (xlator_t *this)
{
struct posix_private *priv = this->private;
sys_lremovexattr (priv->base_path, "trusted.glusterfs.test");
- FREE (priv);
+ GF_FREE (priv);
return;
}
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index 6146c37055f..0295a1f4804 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -50,6 +50,8 @@
#include "xlator.h"
#include "inode.h"
#include "compat.h"
+#include "timer.h"
+#include "posix-mem-types.h"
/**
* posix_fd - internal structure common to file and directory fd's