summaryrefslogtreecommitdiffstats
path: root/xlators/performance/read-ahead
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/performance/read-ahead')
-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
4 files changed, 88 insertions, 23 deletions
diff --git a/xlators/performance/read-ahead/src/page.c b/xlators/performance/read-ahead/src/page.c
index 063258c8f37..0e271a9ac70 100644
--- a/xlators/performance/read-ahead/src/page.c
+++ b/xlators/performance/read-ahead/src/page.c
@@ -62,7 +62,8 @@ ra_page_create (ra_file_t *file, off_t offset)
page = page->next;
if (page == &file->pages || page->offset != rounded_offset) {
- newpage = CALLOC (1, sizeof (*newpage));
+ newpage = GF_CALLOC (1, sizeof (*newpage),
+ gf_ra_mt_ra_page_t);
if (!newpage)
return NULL;
@@ -87,7 +88,8 @@ ra_wait_on_page (ra_page_t *page, call_frame_t *frame)
ra_local_t *local = NULL;
local = frame->local;
- waitq = CALLOC (1, sizeof (*waitq));
+ waitq = GF_CALLOC (1, sizeof (*waitq),
+ gf_ra_mt_ra_waitq_t);
if (!waitq) {
gf_log (frame->this->name, GF_LOG_ERROR,
"out of memory");
@@ -123,7 +125,7 @@ ra_waitq_return (ra_waitq_t *waitq)
frame = trav->data;
ra_frame_return (frame);
- free (trav);
+ GF_FREE (trav);
}
}
@@ -176,7 +178,7 @@ ra_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (page->vector) {
iobref_unref (page->iobref);
- free (page->vector);
+ GF_FREE (page->vector);
}
page->vector = iov_dup (vector, count);
@@ -200,7 +202,7 @@ unlock:
fd_unref (local->fd);
- free (frame->local);
+ GF_FREE (frame->local);
frame->local = NULL;
STACK_DESTROY (frame->root);
@@ -225,7 +227,8 @@ ra_page_fault (ra_file_t *file, call_frame_t *frame, off_t offset)
goto err;
}
- fault_local = CALLOC (1, sizeof (ra_local_t));
+ fault_local = GF_CALLOC (1, sizeof (ra_local_t),
+ gf_ra_mt_ra_local_t);
if (fault_local == NULL) {
STACK_DESTROY (fault_frame->root);
op_ret = -1;
@@ -297,7 +300,8 @@ ra_frame_fill (ra_page_t *page, call_frame_t *frame)
fill = fill->next;
}
- new = CALLOC (1, sizeof (*new));
+ new = GF_CALLOC (1, sizeof (*new),
+ gf_ra_mt_ra_fill_t);
if (new == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
@@ -310,11 +314,12 @@ ra_frame_fill (ra_page_t *page, call_frame_t *frame)
new->count = iov_subset (page->vector, page->count,
src_offset, src_offset+copy_size,
NULL);
- new->vector = CALLOC (new->count, sizeof (struct iovec));
+ new->vector = GF_CALLOC (new->count, sizeof (struct iovec),
+ gf_ra_mt_iovec);
if (new->vector == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
- FREE (new);
+ GF_FREE (new);
goto out;
}
@@ -366,7 +371,8 @@ ra_frame_unwind (call_frame_t *frame)
fill = fill->next;
}
- vector = CALLOC (count, sizeof (*vector));
+ vector = GF_CALLOC (count, sizeof (*vector),
+ gf_ra_mt_iovec);
if (vector == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
@@ -391,8 +397,8 @@ ra_frame_unwind (call_frame_t *frame)
fill->prev->next = fill->prev;
iobref_unref (fill->iobref);
- free (fill->vector);
- free (fill);
+ GF_FREE (fill->vector);
+ GF_FREE (fill);
fill = next;
}
@@ -406,8 +412,8 @@ ra_frame_unwind (call_frame_t *frame)
iobref_unref (iobref);
pthread_mutex_destroy (&local->local_lock);
- free (local);
- free (vector);
+ GF_FREE (local);
+ GF_FREE (vector);
return;
}
@@ -475,8 +481,8 @@ ra_page_purge (ra_page_t *page)
if (page->iobref) {
iobref_unref (page->iobref);
}
- free (page->vector);
- free (page);
+ GF_FREE (page->vector);
+ GF_FREE (page);
}
/*
@@ -541,5 +547,5 @@ ra_file_destroy (ra_file_t *file)
}
pthread_mutex_destroy (&file->file_lock);
- free (file);
+ GF_FREE (file);
}
diff --git a/xlators/performance/read-ahead/src/read-ahead-mem-types.h b/xlators/performance/read-ahead/src/read-ahead-mem-types.h
new file mode 100644
index 00000000000..b21d0595a2d
--- /dev/null
+++ b/xlators/performance/read-ahead/src/read-ahead-mem-types.h
@@ -0,0 +1,37 @@
+/*
+ Copyright (c) 2008-2009 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef __RA_MEM_TYPES_H__
+#define __RA_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_ra_mem_types_ {
+ gf_ra_mt_ra_file_t = gf_common_mt_end + 1,
+ gf_ra_mt_ra_local_t,
+ gf_ra_mt_ra_conf_t,
+ gf_ra_mt_ra_page_t,
+ gf_ra_mt_ra_waitq_t,
+ gf_ra_mt_ra_fill_t,
+ gf_ra_mt_iovec,
+ gf_ra_mt_end
+};
+#endif
+
diff --git a/xlators/performance/read-ahead/src/read-ahead.c b/xlators/performance/read-ahead/src/read-ahead.c
index c0a43258242..9f97c72e933 100644
--- a/xlators/performance/read-ahead/src/read-ahead.c
+++ b/xlators/performance/read-ahead/src/read-ahead.c
@@ -59,7 +59,7 @@ ra_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
wbflags = (long)frame->local;
- file = CALLOC (1, sizeof (*file));
+ file = GF_CALLOC (1, sizeof (*file), gf_ra_mt_ra_file_t);
if (!file) {
op_ret = -1;
op_errno = ENOMEM;
@@ -129,7 +129,7 @@ ra_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto unwind;
}
- file = CALLOC (1, sizeof (*file));
+ file = GF_CALLOC (1, sizeof (*file), gf_ra_mt_ra_file_t);
if (!file) {
op_ret = -1;
op_errno = ENOMEM;
@@ -480,7 +480,8 @@ ra_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
return 0;
}
- local = (void *) CALLOC (1, sizeof (*local));
+ local = (void *) GF_CALLOC (1, sizeof (*local),
+ gf_ra_mt_ra_local_t);
if (!local) {
gf_log (this->name, GF_LOG_ERROR,
"out of memory");
@@ -823,6 +824,25 @@ ra_priv_dump (xlator_t *this)
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_ra_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
int
init (xlator_t *this)
{
@@ -843,7 +863,8 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- conf = (void *) CALLOC (1, sizeof (*conf));
+ conf = (void *) GF_CALLOC (1, sizeof (*conf),
+ gf_ra_mt_ra_conf_t);
if (conf == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"FATAL: Out of memory");
@@ -897,7 +918,7 @@ init (xlator_t *this)
out:
if (ret == -1) {
if (conf != NULL) {
- FREE (conf);
+ GF_FREE (conf);
}
}
@@ -913,7 +934,7 @@ fini (xlator_t *this)
return;
pthread_mutex_destroy (&conf->conf_lock);
- FREE (conf);
+ GF_FREE (conf);
this->private = NULL;
return;
diff --git a/xlators/performance/read-ahead/src/read-ahead.h b/xlators/performance/read-ahead/src/read-ahead.h
index 0ad47fc756b..1f56e85d2ea 100644
--- a/xlators/performance/read-ahead/src/read-ahead.h
+++ b/xlators/performance/read-ahead/src/read-ahead.h
@@ -31,6 +31,7 @@
#include "dict.h"
#include "xlator.h"
#include "common-utils.h"
+#include "read-ahead-mem-types.h"
struct ra_conf;
struct ra_local;