summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/cluster')
-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
36 files changed, 970 insertions, 436 deletions
diff --git a/xlators/cluster/afr/src/afr-dir-read.c b/xlators/cluster/afr/src/afr-dir-read.c
index 501cc3e8c..0f9bdf59e 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 9d7e74e78..439e8d8c7 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 9ce103675..b1bbac10b 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 e28fe5f89..37909181e 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 000000000..27117c184
--- /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 f840c1bbe..ef9d4026e 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 5115a7306..30e1708cc 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 2d74ed1e9..e29c1deff 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 4336c7a61..dcb8d0d71 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 57408cfa6..4501595b7 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 4e2661131..507286944 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 a6ca1c2be..0f7d8bbae 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 1ee723d9c..a8a159205 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 e6e1e8181..b51f308ec 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 f2e1a182a..767be38b4 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 86d3c4410..41b689674 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 000000000..4a7a8bd81
--- /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 8a4d3a6f5..8380535f6 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 d7f187457..ca5601510 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 edb900f76..0d8241f41 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 680ce8d6f..f6fb6b652 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 c23c5676c..fb6593101 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 000000000..bdbfcb52b
--- /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 3317ae783..10e64e562 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 e5c9541db..5e06b7e02 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 b4c8ad525..ad01b2102 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 000000000..f41ab420a
--- /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 09d22b5d6..1383d83c1 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 b423642cc..eb549eb06 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 000000000..06667107d
--- /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 eb5a154d5..52473c03b 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 23ee4546d..8afc6aa9a 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 000000000..3b4abc8e9
--- /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 86f9e88fa..88145af9a 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 2eadfe31c..3f0910df4 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 cf3560d5b..8dcf16598 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); \