summaryrefslogtreecommitdiffstats
path: root/xlators/meta/src/meta.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/meta/src/meta.c')
-rw-r--r--xlators/meta/src/meta.c88
1 files changed, 50 insertions, 38 deletions
diff --git a/xlators/meta/src/meta.c b/xlators/meta/src/meta.c
index 7843e8169..e69719f3c 100644
--- a/xlators/meta/src/meta.c
+++ b/xlators/meta/src/meta.c
@@ -1,22 +1,12 @@
/*
- Copyright (c) 2006-2009 Gluster, Inc. <http://www.gluster.com>
+ Copyright (c) 2006-2012 Red Hat, Inc. <http://www.redhat.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/>.
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
*/
-
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -32,6 +22,7 @@
#include "meta.h"
#include "view.h"
+#include "meta-mem-types.h"
int32_t
meta_getattr_cbk (call_frame_t *frame,
@@ -516,9 +507,9 @@ meta_open (call_frame_t *frame, xlator_t *this,
if (file) {
if (file->fops && file->fops->open) {
- struct _open_local *local = CALLOC (1, sizeof (struct _open_local));
+ struct _open_local *local = GF_CALLOC (1, sizeof (struct _open_local), gf_meta_mt__open_local);
ERR_ABORT (local);
- local->path = strdup (path);
+ local->path = gf_strdup (path);
frame->local = local;
STACK_WIND (frame, meta_open_cbk,
this, file->fops->open,
@@ -528,7 +519,7 @@ meta_open (call_frame_t *frame, xlator_t *this,
else {
dict_t *ctx = get_new_dict ();
dict_ref (ctx);
- dict_set (ctx, this->name, str_to_data (strdup (path)));
+ dict_set (ctx, this->name, str_to_data (gf_strdup (path)));
STACK_UNWIND (frame, 0, 0, ctx, file->stbuf);
return 0;
}
@@ -551,9 +542,9 @@ meta_create (call_frame_t *frame, xlator_t *this,
if (file) {
if (file->fops && file->fops->create) {
- struct _open_local *local = CALLOC (1, sizeof (struct _open_local));
+ struct _open_local *local = GF_CALLOC (1, sizeof (struct _open_local), gf_meta_mt__open_local);
ERR_ABORT (local);
- local->path = strdup (path);
+ local->path = gf_strdup (path);
frame->local = local;
STACK_WIND (frame, meta_open_cbk,
this, file->fops->create,
@@ -826,7 +817,7 @@ meta_opendir (call_frame_t *frame,
if (dir) {
dict_t *ctx = get_new_dict ();
- dict_set (ctx, this->name, str_to_data (strdup (path)));
+ dict_set (ctx, this->name, str_to_data (gf_strdup (path)));
STACK_UNWIND (frame, 0, 0, ctx);
return 0;
}
@@ -850,10 +841,11 @@ meta_readdir_cbk (call_frame_t *frame,
meta_private_t *priv = (meta_private_t *)this->private;
if ((int) cookie == 1) {
- dir_entry_t *dir = CALLOC (1, sizeof (dir_entry_t));
+ dir_entry_t *dir = GF_CALLOC (1, sizeof (dir_entry_t),
+ gf_meta_mt_dir_entry_t);
ERR_ABORT (dir);
- dir->name = strdup (".meta");
+ dir->name = gf_strdup (".meta");
memcpy (&dir->buf, priv->tree->stbuf, sizeof (struct stat));
dir->next = entries->next;
entries->next = dir;
@@ -887,7 +879,8 @@ meta_readdir (call_frame_t *frame,
dir_entry_t *entries = NULL;
while (dir) {
- dir_entry_t *d = CALLOC (1, sizeof (dir_entry_t));
+ dir_entry_t *d = GF_CALLOC (1, sizeof (dir_entry_t),
+ gf_meta_mt_dir_entry_t);
ERR_ABORT (d);
d->name = dir->name;
d->buf = *dir->stbuf;
@@ -897,7 +890,8 @@ meta_readdir (call_frame_t *frame,
dir = dir->next;
}
- dir_entry_t *header = CALLOC (1, sizeof (dir_entry_t));
+ dir_entry_t *header = GF_CALLOC (1, sizeof (dir_entry_t),
+ gf_meta_mt_dir_entry_t);
ERR_ABORT (header);
header->next = entries;
STACK_UNWIND (frame, 0, 0, header, count);
@@ -1132,7 +1126,7 @@ meta_lk_cbk (call_frame_t *frame,
xlator_t *this,
int32_t op_ret,
int32_t op_errno,
- struct flock *lock)
+ struct gf_flock *lock)
{
STACK_UNWIND (frame,
op_ret,
@@ -1146,7 +1140,7 @@ meta_lk (call_frame_t *frame,
xlator_t *this,
dict_t *file,
int32_t cmd,
- struct flock *lock)
+ struct gf_flock *lock)
{
STACK_WIND (frame,
meta_lk_cbk,
@@ -1163,16 +1157,16 @@ add_xlator_to_tree (meta_dirent_t *tree, xlator_t *this,
const char *prefix)
{
char *dir;
- asprintf (&dir, "%s/%s", prefix, this->name);
+ gf_asprintf (&dir, "%s/%s", prefix, this->name);
char *children;
- asprintf (&children, "%s/%s", dir, "subvolumes");
+ gf_asprintf (&children, "%s/%s", dir, "subvolumes");
char *type;
- asprintf (&type, "%s/%s", dir, "type");
+ gf_asprintf (&type, "%s/%s", dir, "type");
char *view;
- asprintf (&view, "%s/%s", dir, "view");
+ gf_asprintf (&view, "%s/%s", dir, "view");
insert_meta_entry (tree, dir, S_IFDIR, NULL, NULL);
insert_meta_entry (tree, children, S_IFDIR, NULL, NULL);
@@ -1194,9 +1188,10 @@ static void
build_meta_tree (xlator_t *this)
{
meta_private_t *priv = (meta_private_t *) this->private;
- priv->tree = CALLOC (1, sizeof (meta_dirent_t));
+ priv->tree = GF_CALLOC (1, sizeof (meta_dirent_t),
+ gf_meta_mt_meta_dirent_t);
ERR_ABORT (priv->tree);
- priv->tree->name = strdup (".meta");
+ priv->tree->name = gf_strdup (".meta");
priv->tree->stbuf = new_stbuf ();
priv->tree->stbuf->st_mode = S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH |
S_IXUSR | S_IXGRP | S_IXOTH;
@@ -1215,6 +1210,25 @@ build_meta_tree (xlator_t *this)
}
int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_meta_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)
{
if (this->parent != NULL) {
@@ -1222,12 +1236,13 @@ init (xlator_t *this)
return -1;
}
- meta_private_t *priv = CALLOC (1, sizeof (meta_private_t));
+ meta_private_t *priv = GF_CALLOC (1, sizeof (meta_private_t),
+ gf_meta_mt_meta_private_t);
ERR_ABORT (priv);
data_t *directory = dict_get (this->options, "directory");
if (directory) {
- priv->directory = strdup (data_to_str (directory));
+ priv->directory = gf_strdup (data_to_str (directory));
}
else {
priv->directory = ".meta";
@@ -1280,6 +1295,3 @@ struct xlator_fops fops = {
.create = meta_create,
.lk = meta_lk,
};
-
-struct xlator_mops mops = {
-};