summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/cluster/dht')
-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
9 files changed, 160 insertions, 78 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 1ee723d9cfb..a8a15920518 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -3557,7 +3557,8 @@ dht_rmdir_is_subvol_empty (call_frame_t *frame, xlator_t *this,
goto err;
}
- lookup_local = CALLOC (sizeof (*local), 1);
+ lookup_local = GF_CALLOC (sizeof (*local), 1,
+ gf_dht_mt_dht_local_t);
if (!lookup_local) {
gf_log (this->name, GF_LOG_ERROR,
"Out of Memory");
@@ -4235,7 +4236,8 @@ dht_init_subvolumes (xlator_t *this, dht_conf_t *conf)
for (subvols = this->children; subvols; subvols = subvols->next)
cnt++;
- conf->subvolumes = CALLOC (cnt, sizeof (xlator_t *));
+ conf->subvolumes = GF_CALLOC (cnt, sizeof (xlator_t *),
+ gf_dht_mt_xlator_t);
if (!conf->subvolumes) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -4247,7 +4249,8 @@ dht_init_subvolumes (xlator_t *this, dht_conf_t *conf)
for (subvols = this->children; subvols; subvols = subvols->next)
conf->subvolumes[cnt++] = subvols->xlator;
- conf->subvolume_status = CALLOC (cnt, sizeof (char));
+ conf->subvolume_status = GF_CALLOC (cnt, sizeof (char),
+ gf_dht_mt_char);
if (!conf->subvolume_status) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index e6e1e8181c6..b51f308ec9c 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -22,6 +22,8 @@
#include "config.h"
#endif
+#include "dht-mem-types.h"
+
#ifndef _DHT_H
#define _DHT_H
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
index f2e1a182a72..767be38b41c 100644
--- a/xlators/cluster/dht/src/dht-helper.c
+++ b/xlators/cluster/dht/src/dht-helper.c
@@ -148,7 +148,7 @@ dht_local_wipe (xlator_t *this, dht_local_t *local)
local->selfheal.layout = NULL;
}
- FREE (local);
+ GF_FREE (local);
}
@@ -158,7 +158,8 @@ dht_local_init (call_frame_t *frame)
dht_local_t *local = NULL;
/* TODO: use mem-pool */
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_dht_mt_dht_local_t);
if (!local)
return NULL;
@@ -408,9 +409,9 @@ dht_build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name)
}
if (strcmp (parent->path, "/") == 0)
- asprintf ((char **)&child->path, "/%s", name);
+ gf_asprintf ((char **)&child->path, "/%s", name);
else
- asprintf ((char **)&child->path, "%s/%s", parent->path, name);
+ gf_asprintf ((char **)&child->path, "%s/%s", parent->path, name);
if (!child->path) {
gf_log (this->name, GF_LOG_ERROR,
diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c
index 86d3c4410fc..41b6896743f 100644
--- a/xlators/cluster/dht/src/dht-layout.c
+++ b/xlators/cluster/dht/src/dht-layout.c
@@ -44,7 +44,8 @@ dht_layout_new (xlator_t *this, int cnt)
conf = this->private;
- layout = CALLOC (1, layout_size (cnt));
+ layout = GF_CALLOC (1, layout_size (cnt),
+ gf_dht_mt_dht_layout_t);
if (!layout) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -131,7 +132,7 @@ dht_layout_unref (xlator_t *this, dht_layout_t *layout)
UNLOCK (&conf->layout_lock);
if (!ref)
- FREE (layout);
+ GF_FREE (layout);
}
@@ -218,8 +219,9 @@ dht_layouts_init (xlator_t *this, dht_conf_t *conf)
int ret = -1;
- conf->file_layouts = CALLOC (conf->subvolume_cnt,
- sizeof (dht_layout_t *));
+ conf->file_layouts = GF_CALLOC (conf->subvolume_cnt,
+ sizeof (dht_layout_t *),
+ gf_dht_mt_dht_layout_t);
if (!conf->file_layouts) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -253,7 +255,8 @@ dht_disk_layout_extract (xlator_t *this, dht_layout_t *layout,
int ret = -1;
int32_t *disk_layout = NULL;
- disk_layout = CALLOC (5, sizeof (int));
+ disk_layout = GF_CALLOC (5, sizeof (int),
+ gf_dht_mt_int32_t);
if (!disk_layout) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
diff --git a/xlators/cluster/dht/src/dht-mem-types.h b/xlators/cluster/dht/src/dht-mem-types.h
new file mode 100644
index 00000000000..4a7a8bd811a
--- /dev/null
+++ b/xlators/cluster/dht/src/dht-mem-types.h
@@ -0,0 +1,42 @@
+
+/*
+ Copyright (c) 2008-2009 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef __DHT_MEM_TYPES_H__
+#define __DHT_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_dht_mem_types_ {
+ gf_dht_mt_dht_du_t = gf_common_mt_end + 1,
+ gf_dht_mt_dht_conf_t,
+ gf_dht_mt_char,
+ gf_dht_mt_int32_t,
+ gf_dht_mt_dht_local_t,
+ gf_dht_mt_xlator_t,
+ gf_dht_mt_dht_layout_t,
+ gf_switch_mt_dht_conf_t,
+ gf_switch_mt_dht_du_t,
+ gf_switch_mt_switch_sched_array,
+ gf_switch_mt_switch_struct,
+ gf_dht_mt_end
+};
+#endif
+
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
index 8a4d3a6f58c..8380535f69b 100644
--- a/xlators/cluster/dht/src/dht-selfheal.c
+++ b/xlators/cluster/dht/src/dht-selfheal.c
@@ -138,7 +138,7 @@ err:
dict_destroy (xattr);
if (disk_layout)
- FREE (disk_layout);
+ GF_FREE (disk_layout);
dht_selfheal_dir_xattr_cbk (frame, subvol, frame->this,
-1, ENOMEM);
diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c
index d7f187457fc..ca5601510bf 100644
--- a/xlators/cluster/dht/src/dht.c
+++ b/xlators/cluster/dht/src/dht.c
@@ -212,26 +212,45 @@ fini (xlator_t *this)
if (conf) {
if (conf->file_layouts) {
for (i = 0; i < conf->subvolume_cnt; i++) {
- FREE (conf->file_layouts[i]);
+ GF_FREE (conf->file_layouts[i]);
}
- FREE (conf->file_layouts);
+ GF_FREE (conf->file_layouts);
}
if (conf->default_dir_layout)
- FREE (conf->default_dir_layout);
+ GF_FREE (conf->default_dir_layout);
if (conf->subvolumes)
- FREE (conf->subvolumes);
+ GF_FREE (conf->subvolumes);
if (conf->subvolume_status)
- FREE (conf->subvolume_status);
+ GF_FREE (conf->subvolume_status);
- FREE (conf);
+ GF_FREE (conf);
}
return;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_dht_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
int
init (xlator_t *this)
{
@@ -241,6 +260,7 @@ init (xlator_t *this)
int i = 0;
uint32_t temp_free_disk = 0;
+
if (!this->children) {
gf_log (this->name, GF_LOG_CRITICAL,
"Distribute needs more than one subvolume");
@@ -252,7 +272,7 @@ init (xlator_t *this)
"dangling volume. check volfile");
}
- conf = CALLOC (1, sizeof (*conf));
+ conf = GF_CALLOC (1, sizeof (*conf), gf_dht_mt_dht_conf_t);
if (!conf) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -302,7 +322,8 @@ init (xlator_t *this)
goto err;
}
- conf->du_stats = CALLOC (conf->subvolume_cnt, sizeof (dht_du_t));
+ conf->du_stats = GF_CALLOC (conf->subvolume_cnt, sizeof (dht_du_t),
+ gf_dht_mt_dht_du_t);
if (!conf->du_stats) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -322,24 +343,24 @@ err:
if (conf) {
if (conf->file_layouts) {
for (i = 0; i < conf->subvolume_cnt; i++) {
- FREE (conf->file_layouts[i]);
+ GF_FREE (conf->file_layouts[i]);
}
- FREE (conf->file_layouts);
+ GF_FREE (conf->file_layouts);
}
if (conf->default_dir_layout)
- FREE (conf->default_dir_layout);
+ GF_FREE (conf->default_dir_layout);
if (conf->subvolumes)
- FREE (conf->subvolumes);
+ GF_FREE (conf->subvolumes);
if (conf->subvolume_status)
- FREE (conf->subvolume_status);
+ GF_FREE (conf->subvolume_status);
if (conf->du_stats)
- FREE (conf->du_stats);
+ GF_FREE (conf->du_stats);
- FREE (conf);
+ GF_FREE (conf);
}
return -1;
diff --git a/xlators/cluster/dht/src/nufa.c b/xlators/cluster/dht/src/nufa.c
index edb900f763a..0d8241f41a5 100644
--- a/xlators/cluster/dht/src/nufa.c
+++ b/xlators/cluster/dht/src/nufa.c
@@ -513,21 +513,21 @@ fini (xlator_t *this)
if (conf) {
if (conf->file_layouts) {
for (i = 0; i < conf->subvolume_cnt; i++) {
- FREE (conf->file_layouts[i]);
+ GF_FREE (conf->file_layouts[i]);
}
- FREE (conf->file_layouts);
+ GF_FREE (conf->file_layouts);
}
if (conf->default_dir_layout)
- FREE (conf->default_dir_layout);
+ GF_FREE (conf->default_dir_layout);
if (conf->subvolumes)
- FREE (conf->subvolumes);
+ GF_FREE (conf->subvolumes);
if (conf->subvolume_status)
- FREE (conf->subvolume_status);
+ GF_FREE (conf->subvolume_status);
- FREE (conf);
+ GF_FREE (conf);
}
return;
@@ -557,7 +557,8 @@ init (xlator_t *this)
"dangling volume. check volfile");
}
- conf = CALLOC (1, sizeof (*conf));
+ conf = GF_CALLOC (1, sizeof (*conf),
+ gf_dht_mt_dht_conf_t);
if (!conf) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -642,7 +643,8 @@ init (xlator_t *this)
}
}
- conf->du_stats = CALLOC (conf->subvolume_cnt, sizeof (dht_du_t));
+ conf->du_stats = GF_CALLOC (conf->subvolume_cnt, sizeof (dht_du_t),
+ gf_dht_mt_dht_du_t);
if (!conf->du_stats) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -657,24 +659,24 @@ err:
if (conf) {
if (conf->file_layouts) {
for (i = 0; i < conf->subvolume_cnt; i++) {
- FREE (conf->file_layouts[i]);
+ GF_FREE (conf->file_layouts[i]);
}
- FREE (conf->file_layouts);
+ GF_FREE (conf->file_layouts);
}
if (conf->default_dir_layout)
- FREE (conf->default_dir_layout);
+ GF_FREE (conf->default_dir_layout);
if (conf->subvolumes)
- FREE (conf->subvolumes);
+ GF_FREE (conf->subvolumes);
if (conf->subvolume_status)
- FREE (conf->subvolume_status);
+ GF_FREE (conf->subvolume_status);
if (conf->du_stats)
- FREE (conf->du_stats);
+ GF_FREE (conf->du_stats);
- FREE (conf);
+ GF_FREE (conf);
}
return -1;
diff --git a/xlators/cluster/dht/src/switch.c b/xlators/cluster/dht/src/switch.c
index 680ce8d6f06..f6fb6b652b3 100644
--- a/xlators/cluster/dht/src/switch.c
+++ b/xlators/cluster/dht/src/switch.c
@@ -24,6 +24,7 @@
#endif
#include "dht-common.c"
+#include "dht-mem-types.h"
#include <sys/time.h>
#include <stdlib.h>
@@ -82,7 +83,7 @@ get_switch_matching_subvol (const char *path, dht_conf_t *conf,
return hashed_subvol;
trav = cond;
- pathname = strdup (path);
+ pathname = gf_strdup (path);
while (trav) {
if (fnmatch (trav->path_pattern,
pathname, FNM_NOESCAPE) == 0) {
@@ -96,7 +97,7 @@ get_switch_matching_subvol (const char *path, dht_conf_t *conf,
}
trav = trav->next;
}
- free (pathname);
+ GF_FREE (pathname);
return hashed_subvol;
}
@@ -620,29 +621,29 @@ fini (xlator_t *this)
conf->private = NULL;
while (trav) {
if (trav->array)
- FREE (trav->array);
+ GF_FREE (trav->array);
prev = trav;
trav = trav->next;
- FREE (prev);
+ GF_FREE (prev);
}
if (conf->file_layouts) {
for (i = 0; i < conf->subvolume_cnt; i++) {
- FREE (conf->file_layouts[i]);
+ GF_FREE (conf->file_layouts[i]);
}
- FREE (conf->file_layouts);
+ GF_FREE (conf->file_layouts);
}
if (conf->default_dir_layout)
- FREE (conf->default_dir_layout);
+ GF_FREE (conf->default_dir_layout);
if (conf->subvolumes)
- FREE (conf->subvolumes);
+ GF_FREE (conf->subvolumes);
if (conf->subvolume_status)
- FREE (conf->subvolume_status);
+ GF_FREE (conf->subvolume_status);
- FREE (conf);
+ GF_FREE (conf);
}
return;
@@ -679,8 +680,9 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
trav_xl = trav_xl->next;
}
child_count = index;
- switch_buf_array = CALLOC ((index + 1),
- sizeof (struct switch_sched_array));
+ switch_buf_array = GF_CALLOC ((index + 1),
+ sizeof (struct switch_sched_array),
+ gf_switch_mt_switch_sched_array);
if (!switch_buf_array)
goto err;
@@ -698,11 +700,12 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
/* Get the pattern for considering switch case.
"option block-size *avi:10MB" etc */
- option_string = strdup (pattern_str);
+ option_string = gf_strdup (pattern_str);
switch_str = strtok_r (option_string, ";", &tmp_str);
while (switch_str) {
- dup_str = strdup (switch_str);
- switch_opt = CALLOC (1, sizeof (struct switch_struct));
+ dup_str = gf_strdup (switch_str);
+ switch_opt = GF_CALLOC (1, sizeof (struct switch_struct),
+ gf_switch_mt_switch_struct);
if (!switch_opt)
goto err;
@@ -714,12 +717,12 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
"for all the unconfigured child nodes,"
" hence neglecting current option");
switch_str = strtok_r (NULL, ";", &tmp_str);
- free (dup_str);
+ GF_FREE (dup_str);
continue;
}
memcpy (switch_opt->path_pattern, pattern, strlen (pattern));
if (childs) {
- dup_childs = strdup (childs);
+ dup_childs = gf_strdup (childs);
child = strtok_r (dup_childs, ",", &tmp);
while (child) {
if (gf_switch_valid_child (this, child)) {
@@ -734,11 +737,12 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
goto err;
}
}
- free (dup_childs);
+ GF_FREE (dup_childs);
child = strtok_r (childs, ",", &tmp1);
switch_opt->num_child = idx;
- switch_opt->array = CALLOC (1, (idx *
- sizeof (struct switch_sched_array)));
+ switch_opt->array = GF_CALLOC (1, (idx *
+ sizeof (struct switch_sched_array)),
+ gf_switch_mt_switch_sched_array);
if (!switch_opt->array)
goto err;
idx = 0;
@@ -772,7 +776,7 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
"option in unify volume. Exiting");
goto err;
}
- free (dup_str);
+ GF_FREE (dup_str);
/* Link it to the main structure */
if (switch_buf) {
@@ -803,7 +807,8 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
"No nodes left for pattern '*'. Exiting");
goto err;
}
- switch_opt = CALLOC (1, sizeof (struct switch_struct));
+ switch_opt = GF_CALLOC (1, sizeof (struct switch_struct),
+ gf_switch_mt_switch_struct);
if (!switch_opt)
goto err;
@@ -811,7 +816,9 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
memcpy (switch_opt->path_pattern, "*", 2);
switch_opt->num_child = flag;
switch_opt->array =
- CALLOC (1, flag * sizeof (struct switch_sched_array));
+ GF_CALLOC (1,
+ flag * sizeof (struct switch_sched_array),
+ gf_switch_mt_switch_sched_array);
if (!switch_opt->array)
goto err;
flag = 0;
@@ -846,14 +853,14 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
err:
if (switch_buf) {
if (switch_buf_array)
- FREE (switch_buf_array);
+ GF_FREE (switch_buf_array);
trav = switch_buf;
while (trav) {
if (trav->array)
- FREE (trav->array);
+ GF_FREE (trav->array);
switch_opt = trav;
trav = trav->next;
- FREE (switch_opt);
+ GF_FREE (switch_opt);
}
}
return -1;
@@ -881,7 +888,7 @@ init (xlator_t *this)
"dangling volume. check volfile");
}
- conf = CALLOC (1, sizeof (*conf));
+ conf = GF_CALLOC (1, sizeof (*conf), gf_switch_mt_dht_conf_t);
if (!conf) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -947,7 +954,8 @@ init (xlator_t *this)
conf->gen = 1;
- conf->du_stats = CALLOC (conf->subvolume_cnt, sizeof (dht_du_t));
+ conf->du_stats = GF_CALLOC (conf->subvolume_cnt, sizeof (dht_du_t),
+ gf_switch_mt_dht_du_t);
if (!conf->du_stats) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
@@ -962,24 +970,24 @@ err:
if (conf) {
if (conf->file_layouts) {
for (i = 0; i < conf->subvolume_cnt; i++) {
- FREE (conf->file_layouts[i]);
+ GF_FREE (conf->file_layouts[i]);
}
- FREE (conf->file_layouts);
+ GF_FREE (conf->file_layouts);
}
if (conf->default_dir_layout)
- FREE (conf->default_dir_layout);
+ GF_FREE (conf->default_dir_layout);
if (conf->subvolumes)
- FREE (conf->subvolumes);
+ GF_FREE (conf->subvolumes);
if (conf->subvolume_status)
- FREE (conf->subvolume_status);
+ GF_FREE (conf->subvolume_status);
if (conf->du_stats)
- FREE (conf->du_stats);
+ GF_FREE (conf->du_stats);
- FREE (conf);
+ GF_FREE (conf);
}
return -1;