summaryrefslogtreecommitdiffstats
path: root/xlators/features/quota/src
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/features/quota/src
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/features/quota/src')
-rw-r--r--xlators/features/quota/src/quota-mem-types.h31
-rw-r--r--xlators/features/quota/src/quota.c40
2 files changed, 64 insertions, 7 deletions
diff --git a/xlators/features/quota/src/quota-mem-types.h b/xlators/features/quota/src/quota-mem-types.h
new file mode 100644
index 00000000000..b71314ed8e6
--- /dev/null
+++ b/xlators/features/quota/src/quota-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 __QUOTA_MEM_TYPES_H__
+#define __QUOTA_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_quota_mem_types_ {
+ gf_quota_mt_quota_local = gf_common_mt_end + 1,
+ gf_quota_mt_quota_priv,
+ gf_quota_mt_end
+};
+#endif
+
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index 822c29bd375..3b4690bf0ae 100644
--- a/xlators/features/quota/src/quota.c
+++ b/xlators/features/quota/src/quota.c
@@ -27,6 +27,7 @@
#include "xlator.h"
#include "defaults.h"
#include "common-utils.h"
+#include "quota-mem-types.h"
#ifndef MAX_IOVEC
#define MAX_IOVEC 16
@@ -204,7 +205,8 @@ quota_truncate (call_frame_t *frame, xlator_t *this,
priv = this->private;
if (priv->disk_usage_limit) {
- local = CALLOC (1, sizeof (struct quota_local));
+ local = GF_CALLOC (1, sizeof (struct quota_local),
+ gf_quota_mt_quota_local);
frame->local = local;
loc_copy (&local->loc, loc);
@@ -279,7 +281,8 @@ quota_ftruncate (call_frame_t *frame, xlator_t *this,
priv = this->private;
if (priv->disk_usage_limit) {
- local = CALLOC (1, sizeof (struct quota_local));
+ local = GF_CALLOC (1, sizeof (struct quota_local),
+ gf_quota_mt_quota_local);
frame->local = local;
local->fd = fd_ref (fd);
@@ -462,7 +465,8 @@ quota_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc)
priv = this->private;
if (priv->disk_usage_limit) {
- local = CALLOC (1, sizeof (struct quota_local));
+ local = GF_CALLOC (1, sizeof (struct quota_local),
+ gf_quota_mt_quota_local);
frame->local = local;
loc_copy (&local->loc, loc);
@@ -534,7 +538,8 @@ quota_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc)
priv = this->private;
if (priv->disk_usage_limit) {
- local = CALLOC (1, sizeof (struct quota_local));
+ local = GF_CALLOC (1, sizeof (struct quota_local),
+ gf_quota_mt_quota_local);
frame->local = local;
loc_copy (&local->loc, loc);
@@ -772,7 +777,8 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
}
if (priv->disk_usage_limit) {
- local = CALLOC (1, sizeof (struct quota_local));
+ local = GF_CALLOC (1, sizeof (struct quota_local),
+ gf_quota_mt_quota_local);
local->fd = fd_ref (fd);
local->iobref = iobref_ref (iobref);
for (i = 0; i < count; i++) {
@@ -1018,7 +1024,26 @@ quota_lookup (call_frame_t *frame,
loc,
xattr_req);
return 0;
- }
+}
+
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_quota_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)
@@ -1038,7 +1063,8 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- _private = CALLOC (1, sizeof (struct quota_priv));
+ _private = GF_CALLOC (1, sizeof (struct quota_priv),
+ gf_quota_mt_quota_priv);
_private->disk_usage_limit = 0;
data = dict_get (this->options, "disk-usage-limit");
if (data) {