summaryrefslogtreecommitdiffstats
path: root/xlators/performance
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/performance
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/performance')
-rw-r--r--xlators/performance/io-cache/src/io-cache.c77
-rw-r--r--xlators/performance/io-cache/src/ioc-inode.c10
-rw-r--r--xlators/performance/io-cache/src/ioc-mem-types.h40
-rw-r--r--xlators/performance/io-cache/src/page.c39
-rw-r--r--xlators/performance/io-threads/src/io-threads.c25
-rw-r--r--xlators/performance/io-threads/src/io-threads.h1
-rw-r--r--xlators/performance/io-threads/src/iot-mem-types.h31
-rw-r--r--xlators/performance/quick-read/src/quick-read-mem-types.h35
-rw-r--r--xlators/performance/quick-read/src/quick-read.c72
-rw-r--r--xlators/performance/quick-read/src/quick-read.h1
-rw-r--r--xlators/performance/read-ahead/src/page.c40
-rw-r--r--xlators/performance/read-ahead/src/read-ahead-mem-types.h37
-rw-r--r--xlators/performance/read-ahead/src/read-ahead.c33
-rw-r--r--xlators/performance/read-ahead/src/read-ahead.h1
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch-mem-types.h36
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.c84
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.h1
-rw-r--r--xlators/performance/write-behind/src/write-behind-mem-types.h35
-rw-r--r--xlators/performance/write-behind/src/write-behind.c81
19 files changed, 528 insertions, 151 deletions
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
index 9bf20be5b..9f402f1da 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -27,6 +27,7 @@
#include "dict.h"
#include "xlator.h"
#include "io-cache.h"
+#include "ioc-mem-types.h"
#include <assert.h>
#include <sys/time.h>
@@ -259,7 +260,8 @@ ioc_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
ioc_local_t *local = NULL;
int32_t op_errno = -1, ret = -1;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_ioc_mt_ioc_local_t);
if (local == NULL) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -401,7 +403,8 @@ ioc_wait_on_inode (ioc_inode_t *ioc_inode, ioc_page_t *page)
}
if (!page_found) {
- waiter = CALLOC (1, sizeof (ioc_waitq_t));
+ waiter = GF_CALLOC (1, sizeof (ioc_waitq_t),
+ gf_ioc_mt_ioc_waitq_t);
if (waiter == NULL) {
gf_log (ioc_inode->table->xl->name, GF_LOG_ERROR,
"out of memory");
@@ -436,7 +439,8 @@ ioc_cache_validate (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,
int32_t ret = 0;
local = frame->local;
- validate_local = CALLOC (1, sizeof (ioc_local_t));
+ validate_local = GF_CALLOC (1, sizeof (ioc_local_t),
+ gf_ioc_mt_ioc_local_t);
if (validate_local == NULL) {
ret = -1;
local->op_ret = -1;
@@ -451,7 +455,7 @@ ioc_cache_validate (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,
ret = -1;
local->op_ret = -1;
local->op_errno = ENOMEM;
- FREE (validate_local);
+ GF_FREE (validate_local);
gf_log (ioc_inode->table->xl->name, GF_LOG_ERROR,
"out of memory");
goto out;
@@ -563,7 +567,7 @@ ioc_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
}
}
- FREE (local);
+ GF_FREE (local);
frame->local = NULL;
STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd);
@@ -641,7 +645,7 @@ ioc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
frame->local = NULL;
- FREE (local);
+ GF_FREE (local);
STACK_UNWIND_STRICT (create, frame, op_ret, op_errno, fd, inode, buf,
preparent, postparent);
@@ -664,7 +668,7 @@ ioc_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
ioc_local_t *local = NULL;
- local = CALLOC (1, sizeof (ioc_local_t));
+ local = GF_CALLOC (1, sizeof (ioc_local_t), gf_ioc_mt_ioc_local_t);
if (local == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
STACK_UNWIND_STRICT (open, frame, -1, ENOMEM, NULL);
@@ -698,8 +702,8 @@ ioc_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
mode_t mode, fd_t *fd)
{
ioc_local_t *local = NULL;
-
- local = CALLOC (1, sizeof (ioc_local_t));
+
+ local = GF_CALLOC (1, sizeof (ioc_local_t), gf_ioc_mt_ioc_local_t);
if (local == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
STACK_UNWIND_STRICT (create, frame, -1, ENOMEM, NULL, NULL,
@@ -1021,7 +1025,8 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
return 0;
}
- local = (ioc_local_t *) CALLOC (1, sizeof (ioc_local_t));
+ local = (ioc_local_t *) GF_CALLOC (1, sizeof (ioc_local_t),
+ gf_ioc_mt_ioc_local_t);
if (local == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
op_errno = ENOMEM;
@@ -1105,7 +1110,7 @@ ioc_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
ioc_local_t *local = NULL;
uint64_t ioc_inode = 0;
- local = CALLOC (1, sizeof (ioc_local_t));
+ local = GF_CALLOC (1, sizeof (ioc_local_t), gf_ioc_mt_ioc_local_t);
if (local == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -1270,7 +1275,7 @@ ioc_get_priority_list (const char *opt_str, struct list_head *first)
char *string = NULL;
struct ioc_priority *curr = NULL, *tmp = NULL;
- string = strdup (opt_str);
+ string = gf_strdup (opt_str);
if (string == NULL) {
max_pri = -1;
goto out;
@@ -1284,7 +1289,8 @@ ioc_get_priority_list (const char *opt_str, struct list_head *first)
*/
stripe_str = strtok_r (string, ",", &tmp_str);
while (stripe_str) {
- curr = CALLOC (1, sizeof (struct ioc_priority));
+ curr = GF_CALLOC (1, sizeof (struct ioc_priority),
+ gf_ioc_mt_ioc_priority);
if (curr == NULL) {
max_pri = -1;
goto out;
@@ -1292,7 +1298,7 @@ ioc_get_priority_list (const char *opt_str, struct list_head *first)
list_add_tail (&curr->list, first);
- dup_str = strdup (stripe_str);
+ dup_str = gf_strdup (stripe_str);
if (dup_str == NULL) {
max_pri = -1;
goto out;
@@ -1315,7 +1321,7 @@ ioc_get_priority_list (const char *opt_str, struct list_head *first)
pattern,
priority);
- curr->pattern = strdup (pattern);
+ curr->pattern = gf_strdup (pattern);
if (curr->pattern == NULL) {
max_pri = -1;
goto out;
@@ -1329,31 +1335,50 @@ ioc_get_priority_list (const char *opt_str, struct list_head *first)
max_pri = max (max_pri, curr->priority);
}
- free (dup_str);
+ GF_FREE (dup_str);
dup_str = NULL;
stripe_str = strtok_r (NULL, ",", &tmp_str);
}
out:
if (string != NULL) {
- free (string);
+ GF_FREE (string);
}
if (dup_str != NULL) {
- free (dup_str);
+ GF_FREE (dup_str);
}
if (max_pri == -1) {
list_for_each_entry_safe (curr, tmp, first, list) {
list_del_init (&curr->list);
- free (curr->pattern);
- free (curr);
+ GF_FREE (curr->pattern);
+ GF_FREE (curr);
}
}
return max_pri;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_ioc_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
/*
* init -
* @this:
@@ -1381,7 +1406,7 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- table = (void *) CALLOC (1, sizeof (*table));
+ table = (void *) GF_CALLOC (1, sizeof (*table), gf_ioc_mt_ioc_table_t);
if (table == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
goto out;
@@ -1477,7 +1502,9 @@ init (xlator_t *this)
goto out;
}
- table->inode_lru = CALLOC (table->max_pri, sizeof (struct list_head));
+ table->inode_lru = GF_CALLOC (table->max_pri,
+ sizeof (struct list_head),
+ gf_ioc_mt_list_head);
if (table->inode_lru == NULL) {
goto out;
}
@@ -1495,8 +1522,8 @@ init (xlator_t *this)
out:
if (ret == -1) {
if (table != NULL) {
- free (table->inode_lru);
- free (table);
+ GF_FREE (table->inode_lru);
+ GF_FREE (table);
}
}
@@ -1518,7 +1545,7 @@ fini (xlator_t *this)
return;
pthread_mutex_destroy (&table->table_lock);
- FREE (table);
+ GF_FREE (table);
this->private = NULL;
return;
diff --git a/xlators/performance/io-cache/src/ioc-inode.c b/xlators/performance/io-cache/src/ioc-inode.c
index 763f329db..561913481 100644
--- a/xlators/performance/io-cache/src/ioc-inode.c
+++ b/xlators/performance/io-cache/src/ioc-inode.c
@@ -23,6 +23,7 @@
#endif
#include "io-cache.h"
+#include "ioc-mem-types.h"
extern int ioc_log2_page_size;
@@ -51,7 +52,7 @@ ptr_to_str (void *ptr)
{
int ret = 0;
char *str = NULL;
- ret = asprintf (&str, "%p", ptr);
+ ret = gf_asprintf (&str, "%p", ptr);
if (-1 == ret) {
gf_log ("ioc", GF_LOG_ERROR,
"asprintf failed while converting ptr to str");
@@ -137,7 +138,7 @@ ioc_inode_wakeup (call_frame_t *frame, ioc_inode_t *ioc_inode,
waiter = waiter->next;
waited->data = NULL;
- free (waited);
+ GF_FREE (waited);
}
}
@@ -157,7 +158,8 @@ ioc_inode_update (ioc_table_t *table, inode_t *inode, uint32_t weight)
ioc_inode_t *ioc_inode = NULL;
unsigned long no_of_pages = 0;
- ioc_inode = CALLOC (1, sizeof (ioc_inode_t));
+ ioc_inode = GF_CALLOC (1, sizeof (ioc_inode_t),
+ gf_ioc_mt_ioc_inode_t);
if (ioc_inode == NULL) {
goto out;
}
@@ -213,5 +215,5 @@ ioc_inode_destroy (ioc_inode_t *ioc_inode)
rbthash_table_destroy (ioc_inode->cache.page_table);
pthread_mutex_destroy (&ioc_inode->inode_lock);
- free (ioc_inode);
+ GF_FREE (ioc_inode);
}
diff --git a/xlators/performance/io-cache/src/ioc-mem-types.h b/xlators/performance/io-cache/src/ioc-mem-types.h
new file mode 100644
index 000000000..d1da65ca1
--- /dev/null
+++ b/xlators/performance/io-cache/src/ioc-mem-types.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (c) 2007-2009 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __IOC_MT_H__
+#define __IOC_MT_H__
+
+#include "mem-types.h"
+
+enum gf_ioc_mem_types_ {
+ gf_ioc_mt_iovec = gf_common_mt_end + 1,
+ gf_ioc_mt_ioc_table_t,
+ gf_ioc_mt_char,
+ gf_ioc_mt_ioc_local_t,
+ gf_ioc_mt_ioc_waitq_t,
+ gf_ioc_mt_ioc_priority,
+ gf_ioc_mt_list_head,
+ gf_ioc_mt_call_pool_t,
+ gf_ioc_mt_ioc_inode_t,
+ gf_ioc_mt_ioc_fill_t,
+ gf_ioc_mt_ioc_newpage_t,
+ gf_ioc_mt_end
+};
+#endif
+
diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c
index 28be2b358..7209abb08 100644
--- a/xlators/performance/io-cache/src/page.c
+++ b/xlators/performance/io-cache/src/page.c
@@ -27,6 +27,7 @@
#include "dict.h"
#include "xlator.h"
#include "io-cache.h"
+#include "ioc-mem-types.h"
#include <assert.h>
#include <sys/time.h>
@@ -86,7 +87,7 @@ ioc_page_destroy (ioc_page_t *page)
if (page->vector){
iobref_unref (page->iobref);
- free (page->vector);
+ GF_FREE (page->vector);
page->vector = NULL;
}
@@ -95,7 +96,7 @@ ioc_page_destroy (ioc_page_t *page)
if (page_size != -1) {
pthread_mutex_destroy (&page->page_lock);
- free (page);
+ GF_FREE (page);
}
return page_size;
@@ -194,7 +195,8 @@ ioc_page_create (ioc_inode_t *ioc_inode, off_t offset)
table = ioc_inode->table;
rounded_offset = floor (offset, table->page_size);
- newpage = CALLOC (1, sizeof (*newpage));
+ newpage = GF_CALLOC (1, sizeof (*newpage),
+ gf_ioc_mt_ioc_newpage_t);
if (newpage == NULL) {
goto out;
}
@@ -202,7 +204,7 @@ ioc_page_create (ioc_inode_t *ioc_inode, off_t offset)
if (ioc_inode) {
table = ioc_inode->table;
} else {
- free (newpage);
+ GF_FREE (newpage);
newpage = NULL;
goto out;
}
@@ -241,7 +243,7 @@ ioc_wait_on_page (ioc_page_t *page, call_frame_t *frame, off_t offset,
ioc_waitq_t *waitq = NULL;
ioc_local_t *local = frame->local;
- waitq = CALLOC (1, sizeof (*waitq));
+ waitq = GF_CALLOC (1, sizeof (*waitq), gf_ioc_mt_ioc_waitq_t);
if (waitq == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
@@ -322,7 +324,7 @@ ioc_waitq_return (ioc_waitq_t *waitq)
frame = trav->data;
ioc_frame_return (frame);
- free (trav);
+ GF_FREE (trav);
}
}
@@ -394,7 +396,7 @@ ioc_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
} else {
if (page->vector) {
iobref_unref (page->iobref);
- free (page->vector);
+ GF_FREE (page->vector);
page->vector = NULL;
}
@@ -507,7 +509,8 @@ ioc_page_fault (ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd,
goto err;
}
- fault_local = CALLOC (1, sizeof (ioc_local_t));
+ fault_local = GF_CALLOC (1, sizeof (ioc_local_t),
+ gf_ioc_mt_ioc_local_t);
if (fault_local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -603,7 +606,8 @@ ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset,
copy_size, src_offset, dst_offset);
{
- new = CALLOC (1, sizeof (*new));
+ new = GF_CALLOC (1, sizeof (*new),
+ gf_ioc_mt_ioc_fill_t);
if (new == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
@@ -622,14 +626,15 @@ ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset,
src_offset + copy_size,
NULL);
- new->vector = CALLOC (new->count,
- sizeof (struct iovec));
+ new->vector = GF_CALLOC (new->count,
+ sizeof (struct iovec),
+ gf_ioc_mt_iovec);
if (new->vector == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
iobref_unref (new->iobref);
- FREE (new);
+ GF_FREE (new);
ret = -1;
gf_log (page->inode->table->xl->name,
@@ -722,7 +727,7 @@ ioc_frame_unwind (call_frame_t *frame)
count += fill->count;
}
- vector = CALLOC (count, sizeof (*vector));
+ vector = GF_CALLOC (count, sizeof (*vector), gf_ioc_mt_iovec);
if (vector == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -743,8 +748,8 @@ ioc_frame_unwind (call_frame_t *frame)
list_del (&fill->list);
iobref_unref (fill->iobref);
- free (fill->vector);
- free (fill);
+ GF_FREE (fill->vector);
+ GF_FREE (fill);
}
if (op_ret != -1) {
@@ -764,12 +769,12 @@ ioc_frame_unwind (call_frame_t *frame)
}
if (vector != NULL) {
- free (vector);
+ GF_FREE (vector);
vector = NULL;
}
pthread_mutex_destroy (&local->local_lock);
- free (local);
+ GF_FREE (local);
return;
}
diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c
index 5ef716733..c2cca7888 100644
--- a/xlators/performance/io-threads/src/io-threads.c
+++ b/xlators/performance/io-threads/src/io-threads.c
@@ -2111,6 +2111,24 @@ set_stack_size (iot_conf_t *conf)
}
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_iot_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
int
init (xlator_t *this)
@@ -2132,7 +2150,8 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- conf = (void *) CALLOC (1, sizeof (*conf));
+ conf = (void *) GF_CALLOC (1, sizeof (*conf),
+ gf_iot_mt_iot_conf_t);
if (conf == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"out of memory");
@@ -2169,7 +2188,7 @@ init (xlator_t *this)
if (ret == -1) {
gf_log (this->name, GF_LOG_ERROR,
"cannot initialize worker threads, exiting init");
- FREE (conf);
+ GF_FREE (conf);
goto out;
}
@@ -2185,7 +2204,7 @@ fini (xlator_t *this)
{
iot_conf_t *conf = this->private;
- FREE (conf);
+ GF_FREE (conf);
this->private = NULL;
return;
diff --git a/xlators/performance/io-threads/src/io-threads.h b/xlators/performance/io-threads/src/io-threads.h
index 85836ff58..137418034 100644
--- a/xlators/performance/io-threads/src/io-threads.h
+++ b/xlators/performance/io-threads/src/io-threads.h
@@ -35,6 +35,7 @@
#include "list.h"
#include <stdlib.h>
#include "locking.h"
+#include "iot-mem-types.h"
#include <semaphore.h>
diff --git a/xlators/performance/io-threads/src/iot-mem-types.h b/xlators/performance/io-threads/src/iot-mem-types.h
new file mode 100644
index 000000000..c083f83b4
--- /dev/null
+++ b/xlators/performance/io-threads/src/iot-mem-types.h
@@ -0,0 +1,31 @@
+/*
+ Copyright (c) 2008-2009 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef __IOT_MEM_TYPES_H__
+#define __IOT_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_iot_mem_types_ {
+ gf_iot_mt_iot_conf_t = gf_common_mt_end + 1,
+ gf_iot_mt_end
+};
+#endif
+
diff --git a/xlators/performance/quick-read/src/quick-read-mem-types.h b/xlators/performance/quick-read/src/quick-read-mem-types.h
new file mode 100644
index 000000000..1e7a5d56d
--- /dev/null
+++ b/xlators/performance/quick-read/src/quick-read-mem-types.h
@@ -0,0 +1,35 @@
+/*
+ Copyright (c) 2008-2009 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef __QR_MEM_TYPES_H__
+#define __QR_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_qr_mem_types_ {
+ gf_qr_mt_qr_file_t = gf_common_mt_end + 1,
+ gf_qr_mt_qr_fd_ctx_t,
+ gf_qr_mt_qr_local_t,
+ gf_qr_mt_iovec,
+ gf_qr_mt_qr_conf_t,
+ gf_qr_mt_end
+};
+#endif
+
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c
index 6cdb735a0..15d4b6378 100644
--- a/xlators/performance/quick-read/src/quick-read.c
+++ b/xlators/performance/quick-read/src/quick-read.c
@@ -33,7 +33,7 @@ qr_loc_wipe (loc_t *loc)
}
if (loc->path) {
- FREE (loc->path);
+ GF_FREE ((char *)loc->path);
loc->path = NULL;
}
@@ -65,10 +65,10 @@ qr_loc_fill (loc_t *loc, inode_t *inode, char *path)
}
loc->inode = inode_ref (inode);
- loc->path = strdup (path);
+ loc->path = gf_strdup (path);
loc->ino = inode->ino;
- parent = strdup (path);
+ parent = gf_strdup (path);
if (parent == NULL) {
ret = -1;
goto out;
@@ -92,7 +92,7 @@ out:
}
if (parent) {
- FREE (parent);
+ GF_FREE (parent);
}
return ret;
@@ -139,8 +139,8 @@ qr_fd_ctx_free (qr_fd_ctx_t *qr_fd_ctx)
assert (list_empty (&qr_fd_ctx->waiting_ops));
- FREE (qr_fd_ctx->path);
- FREE (qr_fd_ctx);
+ GF_FREE (qr_fd_ctx->path);
+ GF_FREE (qr_fd_ctx);
out:
return;
@@ -184,7 +184,8 @@ qr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
{
ret = __inode_ctx_get (inode, this, &value);
if (ret == -1) {
- qr_file = CALLOC (1, sizeof (*qr_file));
+ qr_file = GF_CALLOC (1, sizeof (*qr_file),
+ gf_qr_mt_qr_file_t);
if (qr_file == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -195,7 +196,7 @@ qr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = __inode_ctx_put (inode, this,
(uint64_t)(long)qr_file);
if (ret == -1) {
- FREE (qr_file);
+ GF_FREE (qr_file);
qr_file = NULL;
op_ret = -1;
op_errno = EINVAL;
@@ -430,7 +431,8 @@ qr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
conf = this->private;
- tmp_fd_ctx = qr_fd_ctx = CALLOC (1, sizeof (*qr_fd_ctx));
+ tmp_fd_ctx = qr_fd_ctx = GF_CALLOC (1, sizeof (*qr_fd_ctx),
+ gf_qr_mt_qr_fd_ctx_t);
if (qr_fd_ctx == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -441,7 +443,7 @@ qr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
LOCK_INIT (&qr_fd_ctx->lock);
INIT_LIST_HEAD (&qr_fd_ctx->waiting_ops);
- qr_fd_ctx->path = strdup (loc->path);
+ qr_fd_ctx->path = gf_strdup (loc->path);
qr_fd_ctx->flags = flags;
qr_fd_ctx->wbflags = wbflags;
@@ -453,7 +455,8 @@ qr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
}
tmp_fd_ctx = NULL;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_qr_mt_qr_local_t);
if (local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -515,7 +518,7 @@ unwind:
}
if (local != NULL) {
- FREE (local);
+ GF_FREE (local);
}
STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd);
@@ -599,8 +602,8 @@ qr_validate_cache_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
frame->local = NULL;
call_resume (local->stub);
-
- FREE (local);
+
+ GF_FREE (local);
return 0;
unwind:
@@ -657,7 +660,8 @@ qr_validate_cache (call_frame_t *frame, xlator_t *this, fd_t *fd,
call_stub_t *validate_stub = NULL;
char need_open = 0, can_wind = 0;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_qr_mt_qr_local_t);
if (local == NULL) {
goto out;
}
@@ -839,8 +843,9 @@ qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
goto unlock;
}
- vector = CALLOC (count,
- sizeof (*vector));
+ vector = GF_CALLOC (count,
+ sizeof (*vector),
+ gf_qr_mt_iovec);
if (vector == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -977,7 +982,7 @@ out:
}
if (vector) {
- FREE (vector);
+ GF_FREE (vector);
}
if (iobref) {
@@ -1942,8 +1947,9 @@ qr_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
if (ret == 0) {
qr_fd_ctx = (qr_fd_ctx_t *)(long)value;
}
-
- local = CALLOC (1, sizeof (*local));
+
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_qr_mt_qr_local_t);
if (local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -2152,7 +2158,7 @@ qr_forget (xlator_t *this, inode_t *inode)
UNLOCK (&qr_file->lock);
}
- FREE (qr_file);
+ GF_FREE (qr_file);
}
return 0;
@@ -2189,6 +2195,25 @@ qr_priv_dump (xlator_t *this)
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_qr_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
int32_t
init (xlator_t *this)
{
@@ -2208,7 +2233,8 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- conf = CALLOC (1, sizeof (*conf));
+ conf = GF_CALLOC (1, sizeof (*conf),
+ gf_qr_mt_qr_conf_t);
if (conf == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"out of memory");
@@ -2249,7 +2275,7 @@ init (xlator_t *this)
this->private = conf;
out:
if ((ret == -1) && conf) {
- FREE (conf);
+ GF_FREE (conf);
}
return ret;
diff --git a/xlators/performance/quick-read/src/quick-read.h b/xlators/performance/quick-read/src/quick-read.h
index e6aebecc1..7b832ff88 100644
--- a/xlators/performance/quick-read/src/quick-read.h
+++ b/xlators/performance/quick-read/src/quick-read.h
@@ -40,6 +40,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include "quick-read-mem-types.h"
#define GLUSTERFS_CONTENT_KEY "glusterfs.content"
diff --git a/xlators/performance/read-ahead/src/page.c b/xlators/performance/read-ahead/src/page.c
index 063258c8f..0e271a9ac 100644
--- a/xlators/performance/read-ahead/src/page.c
+++ b/xlators/performance/read-ahead/src/page.c
@@ -62,7 +62,8 @@ ra_page_create (ra_file_t *file, off_t offset)
page = page->next;
if (page == &file->pages || page->offset != rounded_offset) {
- newpage = CALLOC (1, sizeof (*newpage));
+ newpage = GF_CALLOC (1, sizeof (*newpage),
+ gf_ra_mt_ra_page_t);
if (!newpage)
return NULL;
@@ -87,7 +88,8 @@ ra_wait_on_page (ra_page_t *page, call_frame_t *frame)
ra_local_t *local = NULL;
local = frame->local;
- waitq = CALLOC (1, sizeof (*waitq));
+ waitq = GF_CALLOC (1, sizeof (*waitq),
+ gf_ra_mt_ra_waitq_t);
if (!waitq) {
gf_log (frame->this->name, GF_LOG_ERROR,
"out of memory");
@@ -123,7 +125,7 @@ ra_waitq_return (ra_waitq_t *waitq)
frame = trav->data;
ra_frame_return (frame);
- free (trav);
+ GF_FREE (trav);
}
}
@@ -176,7 +178,7 @@ ra_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (page->vector) {
iobref_unref (page->iobref);
- free (page->vector);
+ GF_FREE (page->vector);
}
page->vector = iov_dup (vector, count);
@@ -200,7 +202,7 @@ unlock:
fd_unref (local->fd);
- free (frame->local);
+ GF_FREE (frame->local);
frame->local = NULL;
STACK_DESTROY (frame->root);
@@ -225,7 +227,8 @@ ra_page_fault (ra_file_t *file, call_frame_t *frame, off_t offset)
goto err;
}
- fault_local = CALLOC (1, sizeof (ra_local_t));
+ fault_local = GF_CALLOC (1, sizeof (ra_local_t),
+ gf_ra_mt_ra_local_t);
if (fault_local == NULL) {
STACK_DESTROY (fault_frame->root);
op_ret = -1;
@@ -297,7 +300,8 @@ ra_frame_fill (ra_page_t *page, call_frame_t *frame)
fill = fill->next;
}
- new = CALLOC (1, sizeof (*new));
+ new = GF_CALLOC (1, sizeof (*new),
+ gf_ra_mt_ra_fill_t);
if (new == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
@@ -310,11 +314,12 @@ ra_frame_fill (ra_page_t *page, call_frame_t *frame)
new->count = iov_subset (page->vector, page->count,
src_offset, src_offset+copy_size,
NULL);
- new->vector = CALLOC (new->count, sizeof (struct iovec));
+ new->vector = GF_CALLOC (new->count, sizeof (struct iovec),
+ gf_ra_mt_iovec);
if (new->vector == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
- FREE (new);
+ GF_FREE (new);
goto out;
}
@@ -366,7 +371,8 @@ ra_frame_unwind (call_frame_t *frame)
fill = fill->next;
}
- vector = CALLOC (count, sizeof (*vector));
+ vector = GF_CALLOC (count, sizeof (*vector),
+ gf_ra_mt_iovec);
if (vector == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
@@ -391,8 +397,8 @@ ra_frame_unwind (call_frame_t *frame)
fill->prev->next = fill->prev;
iobref_unref (fill->iobref);
- free (fill->vector);
- free (fill);
+ GF_FREE (fill->vector);
+ GF_FREE (fill);
fill = next;
}
@@ -406,8 +412,8 @@ ra_frame_unwind (call_frame_t *frame)
iobref_unref (iobref);
pthread_mutex_destroy (&local->local_lock);
- free (local);
- free (vector);
+ GF_FREE (local);
+ GF_FREE (vector);
return;
}
@@ -475,8 +481,8 @@ ra_page_purge (ra_page_t *page)
if (page->iobref) {
iobref_unref (page->iobref);
}
- free (page->vector);
- free (page);
+ GF_FREE (page->vector);
+ GF_FREE (page);
}
/*
@@ -541,5 +547,5 @@ ra_file_destroy (ra_file_t *file)
}
pthread_mutex_destroy (&file->file_lock);
- free (file);
+ GF_FREE (file);
}
diff --git a/xlators/performance/read-ahead/src/read-ahead-mem-types.h b/xlators/performance/read-ahead/src/read-ahead-mem-types.h
new file mode 100644
index 000000000..b21d0595a
--- /dev/null
+++ b/xlators/performance/read-ahead/src/read-ahead-mem-types.h
@@ -0,0 +1,37 @@
+/*
+ Copyright (c) 2008-2009 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef __RA_MEM_TYPES_H__
+#define __RA_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_ra_mem_types_ {
+ gf_ra_mt_ra_file_t = gf_common_mt_end + 1,
+ gf_ra_mt_ra_local_t,
+ gf_ra_mt_ra_conf_t,
+ gf_ra_mt_ra_page_t,
+ gf_ra_mt_ra_waitq_t,
+ gf_ra_mt_ra_fill_t,
+ gf_ra_mt_iovec,
+ gf_ra_mt_end
+};
+#endif
+
diff --git a/xlators/performance/read-ahead/src/read-ahead.c b/xlators/performance/read-ahead/src/read-ahead.c
index c0a432582..9f97c72e9 100644
--- a/xlators/performance/read-ahead/src/read-ahead.c
+++ b/xlators/performance/read-ahead/src/read-ahead.c
@@ -59,7 +59,7 @@ ra_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
wbflags = (long)frame->local;
- file = CALLOC (1, sizeof (*file));
+ file = GF_CALLOC (1, sizeof (*file), gf_ra_mt_ra_file_t);
if (!file) {
op_ret = -1;
op_errno = ENOMEM;
@@ -129,7 +129,7 @@ ra_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto unwind;
}
- file = CALLOC (1, sizeof (*file));
+ file = GF_CALLOC (1, sizeof (*file), gf_ra_mt_ra_file_t);
if (!file) {
op_ret = -1;
op_errno = ENOMEM;
@@ -480,7 +480,8 @@ ra_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
return 0;
}
- local = (void *) CALLOC (1, sizeof (*local));
+ local = (void *) GF_CALLOC (1, sizeof (*local),
+ gf_ra_mt_ra_local_t);
if (!local) {
gf_log (this->name, GF_LOG_ERROR,
"out of memory");
@@ -823,6 +824,25 @@ ra_priv_dump (xlator_t *this)
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_ra_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
int
init (xlator_t *this)
{
@@ -843,7 +863,8 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- conf = (void *) CALLOC (1, sizeof (*conf));
+ conf = (void *) GF_CALLOC (1, sizeof (*conf),
+ gf_ra_mt_ra_conf_t);
if (conf == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"FATAL: Out of memory");
@@ -897,7 +918,7 @@ init (xlator_t *this)
out:
if (ret == -1) {
if (conf != NULL) {
- FREE (conf);
+ GF_FREE (conf);
}
}
@@ -913,7 +934,7 @@ fini (xlator_t *this)
return;
pthread_mutex_destroy (&conf->conf_lock);
- FREE (conf);
+ GF_FREE (conf);
this->private = NULL;
return;
diff --git a/xlators/performance/read-ahead/src/read-ahead.h b/xlators/performance/read-ahead/src/read-ahead.h
index 0ad47fc75..1f56e85d2 100644
--- a/xlators/performance/read-ahead/src/read-ahead.h
+++ b/xlators/performance/read-ahead/src/read-ahead.h
@@ -31,6 +31,7 @@
#include "dict.h"
#include "xlator.h"
#include "common-utils.h"
+#include "read-ahead-mem-types.h"
struct ra_conf;
struct ra_local;
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch-mem-types.h b/xlators/performance/stat-prefetch/src/stat-prefetch-mem-types.h
new file mode 100644
index 000000000..f3d25a8af
--- /dev/null
+++ b/xlators/performance/stat-prefetch/src/stat-prefetch-mem-types.h
@@ -0,0 +1,36 @@
+/*
+ Copyright (c) 2008-2009 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef __SP_MEM_TYPES_H__
+#define __SP_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_sp_mem_types_ {
+ gf_sp_mt_sp_cache_t = gf_common_mt_end + 1,
+ gf_sp_mt_sp_fd_ctx_t,
+ gf_sp_mt_stat,
+ gf_sp_mt_sp_local_t,
+ gf_sp_mt_sp_inode_ctx_t,
+ gf_sp_mt_sp_private_t,
+ gf_sp_mt_end
+};
+#endif
+
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c
index c54042130..e7dd8958f 100644
--- a/xlators/performance/stat-prefetch/src/stat-prefetch.c
+++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c
@@ -59,7 +59,7 @@ sp_inode_ctx_free (xlator_t *this, sp_inode_ctx_t *ctx)
UNLOCK (&ctx->lock);
LOCK_DESTROY (&ctx->lock);
- FREE (ctx);
+ GF_FREE (ctx);
out:
return;
@@ -71,7 +71,8 @@ sp_inode_ctx_init ()
{
sp_inode_ctx_t *inode_ctx = NULL;
- inode_ctx = CALLOC (1, sizeof (*inode_ctx));
+ inode_ctx = GF_CALLOC (1, sizeof (*inode_ctx),
+ gf_sp_mt_sp_inode_ctx_t);
if (inode_ctx == NULL) {
goto out;
}
@@ -224,7 +225,7 @@ sp_cache_unref (sp_cache_t *cache)
if (refcount == 0) {
rbthash_table_destroy (cache->table);
- FREE (cache);
+ GF_FREE (cache);
}
out:
@@ -272,7 +273,8 @@ sp_process_inode_ctx (call_frame_t *frame, xlator_t *this, loc_t *loc,
{
if (!(inode_ctx->looked_up || inode_ctx->lookup_in_progress)) {
if (frame->local == NULL) {
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name,
local,
unlock,
@@ -340,14 +342,14 @@ sp_cache_init (xlator_t *this)
if (!priv->mem_pool)
goto out;
- cache = CALLOC (1, sizeof (*cache));
+ cache = GF_CALLOC (1, sizeof (*cache), gf_sp_mt_sp_cache_t);
if (cache) {
cache->table =
rbthash_table_init (GF_SP_CACHE_BUCKETS,
sp_hashfn, free,
0, priv->mem_pool);
if (cache->table == NULL) {
- FREE (cache);
+ GF_FREE (cache);
cache = NULL;
goto out;
}
@@ -366,7 +368,7 @@ sp_local_free (sp_local_t *local)
{
if (local) {
loc_wipe (&local->loc);
- FREE (local);
+ GF_FREE (local);
}
}
@@ -400,7 +402,7 @@ sp_cache_remove_entry (sp_cache_t *cache, char *name, char remove_all)
table = cache->table;
cache->table = rbthash_table_init (GF_SP_CACHE_BUCKETS,
sp_hashfn,
- free,
+ __gf_free,
0,
priv->mem_pool);
if (cache->table == NULL) {
@@ -412,7 +414,7 @@ sp_cache_remove_entry (sp_cache_t *cache, char *name, char remove_all)
} else {
data = rbthash_remove (cache->table, name,
strlen (name));
- FREE (data);
+ GF_FREE (data);
ret = 0;
}
}
@@ -526,7 +528,7 @@ sp_fd_ctx_free (sp_fd_ctx_t *fd_ctx)
}
if (fd_ctx->name) {
- FREE (fd_ctx->name);
+ GF_FREE (fd_ctx->name);
fd_ctx->name = NULL;
}
@@ -534,7 +536,7 @@ sp_fd_ctx_free (sp_fd_ctx_t *fd_ctx)
sp_cache_free (fd_ctx->cache);
}
- FREE (fd_ctx);
+ GF_FREE (fd_ctx);
out:
return;
}
@@ -545,7 +547,7 @@ sp_fd_ctx_init (void)
{
sp_fd_ctx_t *fd_ctx = NULL;
- fd_ctx = CALLOC (1, sizeof (*fd_ctx));
+ fd_ctx = GF_CALLOC (1, sizeof (*fd_ctx), gf_sp_mt_sp_fd_ctx_t);
return fd_ctx;
}
@@ -567,7 +569,7 @@ sp_fd_ctx_new (xlator_t *this, inode_t *parent, char *name, sp_cache_t *cache)
}
if (name) {
- fd_ctx->name = strdup (name);
+ fd_ctx->name = gf_strdup (name);
if (fd_ctx->name == NULL) {
sp_fd_ctx_free (fd_ctx);
fd_ctx = NULL;
@@ -713,7 +715,7 @@ sp_cache_add_entries (sp_cache_t *cache, gf_dirent_t *entries)
ret = rbthash_insert (cache->table, new, new->d_name,
strlen (new->d_name));
if (ret == -1) {
- FREE (new);
+ GF_FREE (new);
continue;
}
@@ -807,7 +809,7 @@ sp_get_ancestors (char *path, char **parent, char **grand_parent)
break;
}
- cpy = strdup (path);
+ cpy = gf_strdup (path);
if (cpy == NULL) {
goto out;
}
@@ -851,13 +853,13 @@ sp_cache_remove_parent_entry (call_frame_t *frame, xlator_t *this,
cache_gp = sp_get_cache_inode (this, inode_gp,
frame->root->pid);
if (cache_gp) {
- cpy = strdup (parent);
+ cpy = gf_strdup (parent);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name,
cpy, out, errno,
ENOMEM);
path = basename (cpy);
sp_cache_remove_entry (cache_gp, path, 0);
- FREE (cpy);
+ GF_FREE (cpy);
sp_cache_unref (cache_gp);
}
@@ -868,11 +870,11 @@ sp_cache_remove_parent_entry (call_frame_t *frame, xlator_t *this,
ret = 0;
out:
if (parent) {
- FREE (parent);
+ GF_FREE (parent);
}
if (grand_parent) {
- FREE (grand_parent);
+ GF_FREE (grand_parent);
}
return ret;
@@ -1015,7 +1017,7 @@ sp_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req)
entry_cached = 1;
}
- FREE (dirent);
+ GF_FREE (dirent);
}
} else if (IA_ISDIR (loc->inode->ia_type)) {
cache = sp_get_cache_inode (this, loc->inode, frame->root->pid);
@@ -1032,7 +1034,7 @@ sp_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req)
entry_cached = 1;
}
- FREE (dirent);
+ GF_FREE (dirent);
}
}
}
@@ -1054,7 +1056,7 @@ wind:
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, stub, unwind,
op_errno, ENOMEM);
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, unwind,
op_errno, ENOMEM);
@@ -1204,14 +1206,14 @@ sp_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
ret = sp_cache_remove_parent_entry (frame, this, fd->inode->table,
path);
- FREE (path);
+ GF_FREE (path);
if (ret < 0) {
errno = -ret;
goto unwind;
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
if (local) {
local->fd = fd;
frame->local = local;
@@ -1341,7 +1343,7 @@ sp_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, loc->inode, out,
op_errno, EINVAL);
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, out, op_errno,
ENOMEM);
@@ -1453,7 +1455,7 @@ sp_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
goto out;
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, out, op_errno,
ENOMEM);
@@ -1541,7 +1543,7 @@ sp_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd)
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, loc->inode, out,
op_errno, EINVAL);
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, out, op_errno,
ENOMEM);
@@ -1643,7 +1645,7 @@ sp_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode)
goto out;
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, out, op_errno,
ENOMEM);
@@ -1706,7 +1708,7 @@ sp_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
goto out;
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, out, op_errno,
ENOMEM);
@@ -1769,7 +1771,7 @@ sp_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath,
goto out;
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_sp_mt_sp_local_t);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, out, op_errno,
ENOMEM);
@@ -3687,7 +3689,7 @@ sp_forget (xlator_t *this, inode_t *inode)
if (value) {
buf = (void *)(long)value;
- FREE (buf);
+ GF_FREE (buf);
}
return 0;
@@ -3717,7 +3719,24 @@ sp_release (xlator_t *this, fd_t *fd)
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_sp_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+ return ret;
+}
int32_t
init (xlator_t *this)
@@ -3733,7 +3752,8 @@ init (xlator_t *this)
goto out;
}
- priv = CALLOC (1, sizeof(sp_private_t));
+ priv = GF_CALLOC (1, sizeof(sp_private_t),
+ gf_sp_mt_sp_private_t);
LOCK_INIT (&priv->lock);
this->private = priv;
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.h b/xlators/performance/stat-prefetch/src/stat-prefetch.h
index 9ff2899a9..16edf76aa 100644
--- a/xlators/performance/stat-prefetch/src/stat-prefetch.h
+++ b/xlators/performance/stat-prefetch/src/stat-prefetch.h
@@ -33,6 +33,7 @@
#include "rbthash.h"
#include "hashfn.h"
#include "call-stub.h"
+#include "stat-prefetch-mem-types.h"
#include <libgen.h>
struct sp_cache {
diff --git a/xlators/performance/write-behind/src/write-behind-mem-types.h b/xlators/performance/write-behind/src/write-behind-mem-types.h
new file mode 100644
index 000000000..618461519
--- /dev/null
+++ b/xlators/performance/write-behind/src/write-behind-mem-types.h
@@ -0,0 +1,35 @@
+/*
+ Copyright (c) 2008-2009 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef __WB_MEM_TYPES_H__
+#define __WB_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_wb_mem_types_ {
+ gf_wb_mt_wb_file_t = gf_common_mt_end + 1,
+ gf_wb_mt_wb_local_t,
+ gf_wb_mt_wb_request_t,
+ gf_wb_mt_iovec,
+ gf_wb_mt_wb_conf_t,
+ gf_wb_mt_end
+};
+#endif
+
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index 3cbfc4975..bd0465006 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -35,6 +35,7 @@
#include "common-utils.h"
#include "call-stub.h"
#include "statedump.h"
+#include "write-behind-mem-types.h"
#define MAX_VECTOR_COUNT 8
#define WB_AGGREGATE_SIZE 131072 /* 128 KB */
@@ -141,7 +142,7 @@ __wb_request_unref (wb_request_t *this)
call_stub_destroy (this->stub);
}
- FREE (this);
+ GF_FREE (this);
}
}
@@ -209,7 +210,7 @@ wb_enqueue (wb_file_t *file, call_stub_t *stub)
struct iovec *vector = NULL;
int32_t count = 0;
- request = CALLOC (1, sizeof (*request));
+ request = GF_CALLOC (1, sizeof (*request), gf_wb_mt_wb_request_t);
if (request == NULL) {
goto out;
}
@@ -270,7 +271,7 @@ wb_file_create (xlator_t *this, fd_t *fd)
wb_file_t *file = NULL;
wb_conf_t *conf = this->private;
- file = CALLOC (1, sizeof (*file));
+ file = GF_CALLOC (1, sizeof (*file), gf_wb_mt_wb_file_t);
if (file == NULL) {
goto out;
}
@@ -307,7 +308,7 @@ wb_file_destroy (wb_file_t *file)
if (!refcount){
LOCK_DESTROY (&file->lock);
- FREE (file);
+ GF_FREE (file);
}
return;
@@ -407,7 +408,8 @@ wb_sync (call_frame_t *frame, wb_file_t *file, list_head_t *winds)
list_for_each_entry_safe (request, dummy, winds, winds) {
if (!vector) {
- vector = MALLOC (VECTORSIZE (MAX_VECTOR_COUNT));
+ vector = GF_MALLOC (VECTORSIZE (MAX_VECTOR_COUNT),
+ gf_wb_mt_iovec);
if (vector == NULL) {
bytes = -1;
goto out;
@@ -419,7 +421,8 @@ wb_sync (call_frame_t *frame, wb_file_t *file, list_head_t *winds)
goto out;
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
bytes = -1;
goto out;
@@ -488,7 +491,7 @@ wb_sync (call_frame_t *frame, wb_file_t *file, list_head_t *winds)
iobref);
iobref_unref (iobref);
- FREE (vector);
+ GF_FREE (vector);
first_request = NULL;
iobref = NULL;
vector = NULL;
@@ -505,7 +508,7 @@ out:
}
if (local != NULL) {
- FREE (local);
+ GF_FREE (local);
}
if (iobref != NULL) {
@@ -513,7 +516,7 @@ out:
}
if (vector != NULL) {
- FREE (vector);
+ GF_FREE (vector);
}
return bytes;
@@ -612,7 +615,8 @@ wb_stat (call_frame_t *frame, xlator_t *this, loc_t *loc)
}
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -726,7 +730,8 @@ wb_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd)
}
file = (wb_file_t *)(long)tmp_file;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
STACK_UNWIND_STRICT (fstat, frame, -1, ENOMEM, NULL);
return 0;
@@ -877,7 +882,8 @@ wb_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset)
}
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -994,7 +1000,8 @@ wb_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
file = (wb_file_t *)(long)tmp_file;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
STACK_UNWIND_STRICT (ftruncate, frame, -1, ENOMEM,
NULL, NULL);
@@ -1131,7 +1138,8 @@ wb_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
wb_request_t *request = NULL;
int32_t ret = -1, op_errno = EINVAL;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -1263,7 +1271,8 @@ wb_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
wb_local_t *local = NULL;
int32_t op_errno = EINVAL;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -1894,7 +1903,8 @@ wb_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
goto unwind;
}
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -2010,7 +2020,8 @@ wb_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
file = (wb_file_t *)(long)tmp_file;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
STACK_UNWIND_STRICT (readv, frame, -1, ENOMEM,
NULL, 0, NULL, NULL);
@@ -2165,7 +2176,8 @@ wb_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
file = (wb_file_t *)(long)tmp_file;
if (file != NULL) {
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
STACK_UNWIND (frame, -1, ENOMEM, NULL);
return 0;
@@ -2196,7 +2208,8 @@ wb_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
if (conf->flush_behind
&& (!disabled) && (disable_till == 0)) {
- tmp_local = CALLOC (1, sizeof (*local));
+ tmp_local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (tmp_local == NULL) {
STACK_UNWIND_STRICT (flush, frame, -1, ENOMEM);
@@ -2337,7 +2350,8 @@ wb_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync)
file = (wb_file_t *)(long)tmp_file;
- local = CALLOC (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local),
+ gf_wb_mt_wb_local_t);
if (local == NULL) {
STACK_UNWIND_STRICT (fsync, frame, -1, ENOMEM, NULL, NULL);
return 0;
@@ -2444,6 +2458,25 @@ wb_priv_dump (xlator_t *this)
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_wb_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
int32_t
init (xlator_t *this)
{
@@ -2468,7 +2501,7 @@ init (xlator_t *this)
options = this->options;
- conf = CALLOC (1, sizeof (*conf));
+ conf = GF_CALLOC (1, sizeof (*conf), gf_wb_mt_wb_conf_t);
if (conf == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"FATAL: Out of memory");
@@ -2521,7 +2554,7 @@ init (xlator_t *this)
"invalid number format \"%s\" of \"option "
"window-size\"",
str);
- FREE (conf);
+ GF_FREE (conf);
return -1;
}
}
@@ -2539,7 +2572,7 @@ init (xlator_t *this)
"aggregate-size(%"PRIu64") cannot be more than "
"window-size"
"(%"PRIu64")", conf->aggregate_size, conf->window_size);
- FREE (conf);
+ GF_FREE (conf);
return -1;
}
@@ -2586,7 +2619,7 @@ fini (xlator_t *this)
{
wb_conf_t *conf = this->private;
- FREE (conf);
+ GF_FREE (conf);
return;
}