summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-04-22 13:33:09 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-04-23 06:32:52 -0700
commit582de0677da4be19fc6f873625c58c45d069ab1c (patch)
treef10cb3e26e1f92f6ea91034e6f7bb925790dd9bc /xlators/cluster/dht/src/dht.c
parent72baa17282f5cf749fa743fd601c7b728ece4fa2 (diff)
Memory accounting changes
Memory accounting Changes. Thanks to Vinayak Hegde and Csaba Henk for their contributions. Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 329 (Replacing memory allocation functions with mem-type functions) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=329
Diffstat (limited to 'xlators/cluster/dht/src/dht.c')
-rw-r--r--xlators/cluster/dht/src/dht.c51
1 files changed, 36 insertions, 15 deletions
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;