summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/protocol/server/src')
-rw-r--r--xlators/protocol/server/src/server-helpers.c97
-rw-r--r--xlators/protocol/server/src/server-mem-types.h39
-rw-r--r--xlators/protocol/server/src/server-protocol.c164
-rw-r--r--xlators/protocol/server/src/server-protocol.h1
-rw-r--r--xlators/protocol/server/src/server-resolve.c11
5 files changed, 190 insertions, 122 deletions
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c
index dc2620c9055..d07e841f287 100644
--- a/xlators/protocol/server/src/server-helpers.c
+++ b/xlators/protocol/server/src/server-helpers.c
@@ -101,7 +101,7 @@ server_loc_fill (loc_t *loc, server_state_t *state,
if (loc->name)
loc->name++;
} else {
- loc->path = strdup (path);
+ loc->path = gf_strdup (path);
loc->name = strrchr (loc->path, '/');
if (loc->name)
loc->name++;
@@ -142,7 +142,7 @@ stat_to_str (struct iatt *stbuf)
uint32_t ctime_nsec = stbuf->ia_ctime_nsec;
- ret = asprintf (&tmp_buf,
+ ret = gf_asprintf (&tmp_buf,
GF_STAT_PRINT_FMT_STR,
dev,
ino,
@@ -182,8 +182,8 @@ server_loc_wipe (loc_t *loc)
loc->inode = NULL;
}
- if (loc->path)
- FREE (loc->path);
+ if (loc->path)
+ GF_FREE ((char *)loc->path);
}
@@ -194,13 +194,13 @@ server_resolve_wipe (server_resolve_t *resolve)
int i = 0;
if (resolve->path)
- FREE (resolve->path);
+ GF_FREE (resolve->path);
if (resolve->bname)
- FREE (resolve->bname);
+ GF_FREE (resolve->bname);
if (resolve->resolved)
- FREE (resolve->resolved);
+ GF_FREE (resolve->resolved);
loc_wipe (&resolve->deep_loc);
@@ -210,7 +210,7 @@ server_resolve_wipe (server_resolve_t *resolve)
if (comp[i].inode)
inode_unref (comp[i].inode);
}
- FREE (resolve->components);
+ GF_FREE (resolve->components);
}
}
@@ -244,10 +244,10 @@ free_state (server_state_t *state)
}
if (state->volume)
- FREE (state->volume);
+ GF_FREE ((char *)state->volume);
if (state->name)
- FREE (state->name);
+ GF_FREE (state->name);
server_loc_wipe (&state->loc);
server_loc_wipe (&state->loc2);
@@ -255,7 +255,7 @@ free_state (server_state_t *state)
server_resolve_wipe (&state->resolve);
server_resolve_wipe (&state->resolve2);
- FREE (state);
+ GF_FREE (state);
}
@@ -269,7 +269,8 @@ server_copy_frame (call_frame_t *frame)
new_frame = copy_frame (frame);
- new_state = CALLOC (1, sizeof (server_state_t));
+ new_state = GF_CALLOC (1, sizeof (server_state_t),
+ gf_server_mt_server_state_t);
new_frame->root->op = frame->root->op;
new_frame->root->type = frame->root->type;
@@ -295,7 +296,8 @@ gf_add_locker (struct _lock_table *table, const char *volume,
struct _locker *new = NULL;
uint8_t dir = 0;
- new = CALLOC (1, sizeof (struct _locker));
+ new = GF_CALLOC (1, sizeof (struct _locker),
+ gf_server_mt_locker);
if (new == NULL) {
gf_log ("server", GF_LOG_ERROR,
"failed to allocate memory for \'struct _locker\'");
@@ -303,7 +305,7 @@ gf_add_locker (struct _lock_table *table, const char *volume,
}
INIT_LIST_HEAD (&new->lockers);
- new->volume = strdup (volume);
+ new->volume = gf_strdup (volume);
if (fd == NULL) {
loc_copy (&new->loc, loc);
@@ -381,9 +383,9 @@ gf_del_locker (struct _lock_table *table, const char *volume,
else
loc_wipe (&locker->loc);
- free (locker->volume);
- free (locker);
- }
+ GF_FREE (locker->volume);
+ GF_FREE (locker);
+ }
return ret;
}
@@ -419,7 +421,7 @@ gf_direntry_to_bin (dir_entry_t *head, char *buffer)
trav->name, tmp_buf,
trav->link);
- FREE (tmp_buf);
+ GF_FREE (tmp_buf);
trav = trav->next;
ptr += this_len;
}
@@ -435,7 +437,8 @@ gf_lock_table_new (void)
{
struct _lock_table *new = NULL;
- new = CALLOC (1, sizeof (struct _lock_table));
+ new = GF_CALLOC (1, sizeof (struct _lock_table),
+ gf_server_mt_lock_table);
if (new == NULL) {
gf_log ("server-protocol", GF_LOG_CRITICAL,
"failed to allocate memory for new lock table");
@@ -473,7 +476,7 @@ do_lock_table_cleanup (xlator_t *this, server_connection_t *conn,
}
UNLOCK (&ltable->lock);
- free (ltable);
+ GF_FREE (ltable);
flock.l_type = F_UNLCK;
flock.l_start = 0;
@@ -509,10 +512,10 @@ do_lock_table_cleanup (xlator_t *this, server_connection_t *conn,
loc_wipe (&locker->loc);
}
- free (locker->volume);
-
+ GF_FREE (locker->volume);
+
list_del_init (&locker->lockers);
- free (locker);
+ GF_FREE (locker);
}
tmp = NULL;
@@ -541,10 +544,10 @@ do_lock_table_cleanup (xlator_t *this, server_connection_t *conn,
loc_wipe (&locker->loc);
}
- free (locker->volume);
-
+ GF_FREE (locker->volume);
+
list_del_init (&locker->lockers);
- free (locker);
+ GF_FREE (locker);
}
ret = 0;
@@ -601,7 +604,7 @@ do_fd_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame,
}
}
- FREE (fdentries);
+ GF_FREE (fdentries);
ret = 0;
out:
@@ -631,7 +634,7 @@ do_connection_cleanup (xlator_t *this, server_connection_t *conn,
state = CALL_STATE (frame);
if (state)
- free (state);
+ GF_FREE (state);
STACK_DESTROY (frame->root);
@@ -733,7 +736,7 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn)
list_splice_init (&ltable->dir_lockers, &dir_lockers);
}
UNLOCK (&ltable->lock);
- free (ltable);
+ GF_FREE (ltable);
flock.l_type = F_UNLCK;
flock.l_start = 0;
@@ -764,11 +767,11 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn)
loc_wipe (&locker->loc);
}
- free (locker->volume);
+ GF_FREE (locker->volume);
- list_del_init (&locker->lockers);
- free (locker);
- }
+ list_del_init (&locker->lockers);
+ GF_FREE (locker);
+ }
tmp = NULL;
locker = NULL;
@@ -796,11 +799,12 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn)
loc_wipe (&locker->loc);
}
- free (locker->volume);
+ GF_FREE (locker->volume);
- list_del_init (&locker->lockers);
- free (locker);
- }
+
+ list_del_init (&locker->lockers);
+ GF_FREE (locker);
+ }
pthread_mutex_lock (&(conn->lock));
{
@@ -827,22 +831,22 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn)
fd);
}
}
- FREE (fdentries);
+ GF_FREE (fdentries);
}
}
if (frame) {
state = CALL_STATE (frame);
if (state)
- free (state);
+ GF_FREE (state);
STACK_DESTROY (frame->root);
}
gf_log (this->name, GF_LOG_INFO, "destroyed connection of %s",
conn->id);
- FREE (conn->id);
- FREE (conn);
+ GF_FREE (conn->id);
+ GF_FREE (conn);
out:
return ret;
@@ -867,12 +871,13 @@ server_connection_get (xlator_t *this, const char *id)
}
}
- if (!conn) {
- conn = (void *) CALLOC (1, sizeof (*conn));
+ if (!conn) {
+ conn = (void *) GF_CALLOC (1, sizeof (*conn),
+ gf_server_mt_server_connection_t);
- conn->id = strdup (id);
- conn->fdtable = gf_fd_fdtable_alloc ();
- conn->ltable = gf_lock_table_new ();
+ conn->id = gf_strdup (id);
+ conn->fdtable = gf_fd_fdtable_alloc ();
+ conn->ltable = gf_lock_table_new ();
pthread_mutex_init (&conn->lock, NULL);
diff --git a/xlators/protocol/server/src/server-mem-types.h b/xlators/protocol/server/src/server-mem-types.h
new file mode 100644
index 00000000000..86877d79dac
--- /dev/null
+++ b/xlators/protocol/server/src/server-mem-types.h
@@ -0,0 +1,39 @@
+/*
+ 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 __AFR_MEM_TYPES_H__
+#define __AFR_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_server_mem_types_ {
+ gf_server_mt_dir_entry_t = gf_common_mt_end + 1,
+ gf_server_mt_volfile_ctx,
+ gf_server_mt_server_state_t,
+ gf_server_mt_server_conf_t,
+ gf_server_mt_locker,
+ gf_server_mt_lock_table,
+ gf_server_mt_char,
+ gf_server_mt_server_connection_t,
+ gf_server_mt_resolve_comp,
+ gf_server_mt_end
+};
+#endif
+
diff --git a/xlators/protocol/server/src/server-protocol.c b/xlators/protocol/server/src/server-protocol.c
index 71c5a1fc38c..079b3f2e4c3 100644
--- a/xlators/protocol/server/src/server-protocol.c
+++ b/xlators/protocol/server/src/server-protocol.c
@@ -2,7 +2,7 @@
Copyright (c) 2006-2009 Gluster, Inc. <http://www.gluster.com>
This file is part of GlusterFS.
- GlusterFS is free software; you can redistribute it and/or modify
+ GlusterFS is GF_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.
@@ -2535,10 +2535,10 @@ server_lookup (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_DONTCARE;
state->resolve.par = ntoh64 (req->par);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
if (IS_NOT_ROOT (pathlen)) {
- state->resolve.bname = strdup (req->bname + pathlen);
+ state->resolve.bname = gf_strdup (req->bname + pathlen);
baselen = STRLEN_0 (state->resolve.bname);
}
@@ -2555,7 +2555,7 @@ server_lookup (call_frame_t *frame, xlator_t *bound_xl,
"unserialize req-buffer to dictionary",
frame->root->unique, state->resolve.path,
state->resolve.ino);
- FREE (req_dictbuf);
+ GF_FREE (req_dictbuf);
goto err;
}
@@ -2625,7 +2625,7 @@ server_stat (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_MUST;
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
}
resolve_and_resume (frame, server_stat_resume);
@@ -2670,7 +2670,7 @@ server_setattr (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_MUST;
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
gf_stat_to_iatt (&req->stbuf, &state->stbuf);
state->valid = ntoh32 (req->valid);
@@ -2762,7 +2762,7 @@ server_readlink (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_MUST;
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->size = ntoh32 (req->size);
@@ -2817,8 +2817,8 @@ server_create (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_NOT;
state->resolve.par = ntoh64 (req->par);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
- state->resolve.bname = strdup (req->bname + pathlen);
+ state->resolve.path = gf_strdup (req->path);
+ state->resolve.bname = gf_strdup (req->bname + pathlen);
state->mode = ntoh32 (req->mode);
state->flags = gf_flags_to_flags (ntoh32 (req->flags));
@@ -2867,7 +2867,7 @@ server_open (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_MUST;
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->flags = gf_flags_to_flags (ntoh32 (req->flags));
@@ -3208,7 +3208,7 @@ server_truncate (call_frame_t *frame, xlator_t *bound_xl,
state = CALL_STATE (frame);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
state->offset = ntoh64 (req->offset);
@@ -3257,8 +3257,8 @@ server_unlink (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_MUST;
state->resolve.par = ntoh64 (req->par);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
- state->resolve.bname = strdup (req->bname + pathlen);
+ state->resolve.path = gf_strdup (req->path);
+ state->resolve.bname = gf_strdup (req->bname + pathlen);
resolve_and_resume (frame, server_unlink_resume);
@@ -3306,7 +3306,7 @@ server_setxattr (call_frame_t *frame, xlator_t *bound_xl,
dict_len = ntoh32 (req->dict_len);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->path + dict_len);
+ state->resolve.path = gf_strdup (req->path + dict_len);
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
state->flags = ntoh32 (req->flags);
@@ -3323,7 +3323,7 @@ server_setxattr (call_frame_t *frame, xlator_t *bound_xl,
"unserialize request buffer to dictionary",
frame->root->unique, state->loc.path,
state->resolve.ino);
- FREE (req_dictbuf);
+ GF_FREE (req_dictbuf);
goto err;
}
@@ -3400,7 +3400,7 @@ server_fsetxattr (call_frame_t *frame, xlator_t *bound_xl,
"unserialize request buffer to dictionary",
frame->root->unique, state->loc.path,
state->resolve.ino);
- FREE (req_dictbuf);
+ GF_FREE (req_dictbuf);
goto err;
}
@@ -3478,7 +3478,7 @@ server_fxattrop (call_frame_t *frame, xlator_t *bound_xl,
"fd - %"PRId64" (%"PRId64"): failed to unserialize "
"request buffer to dictionary",
state->resolve.fd_no, state->fd->inode->ino);
- free (req_dictbuf);
+ GF_FREE (req_dictbuf);
goto fail;
}
dict->extra_free = req_dictbuf;
@@ -3538,7 +3538,7 @@ server_xattrop (call_frame_t *frame, xlator_t *bound_xl,
dict_len = ntoh32 (req->dict_len);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->path + dict_len);
+ state->resolve.path = gf_strdup (req->path + dict_len);
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
state->flags = ntoh32 (req->flags);
@@ -3555,7 +3555,7 @@ server_xattrop (call_frame_t *frame, xlator_t *bound_xl,
"fd - %"PRId64" (%"PRId64"): failed to unserialize "
"request buffer to dictionary",
state->resolve.fd_no, state->fd->inode->ino);
- free (req_dictbuf);
+ GF_FREE (req_dictbuf);
goto fail;
}
dict->extra_free = req_dictbuf;
@@ -3613,13 +3613,13 @@ server_getxattr (call_frame_t *frame, xlator_t *bound_xl,
pathlen = STRLEN_0 (req->path);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
namelen = ntoh32 (req->namelen);
if (namelen)
- state->name = strdup (req->name + pathlen);
+ state->name = gf_strdup (req->name + pathlen);
resolve_and_resume (frame, server_getxattr_resume);
@@ -3665,7 +3665,7 @@ server_fgetxattr (call_frame_t *frame, xlator_t *bound_xl,
namelen = ntoh32 (req->namelen);
if (namelen)
- state->name = strdup (req->name);
+ state->name = gf_strdup (req->name);
resolve_and_resume (frame, server_fgetxattr_resume);
@@ -3708,10 +3708,10 @@ server_removexattr (call_frame_t *frame, xlator_t *bound_xl,
pathlen = STRLEN_0 (req->path);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
- state->name = strdup (req->name + pathlen);
+ state->name = gf_strdup (req->name + pathlen);
resolve_and_resume (frame, server_removexattr_resume);
@@ -3758,7 +3758,7 @@ server_statfs (call_frame_t *frame, xlator_t *bound_xl,
if (!state->resolve.ino)
state->resolve.ino = 1;
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
resolve_and_resume (frame, server_statfs_resume);
@@ -3801,7 +3801,7 @@ server_opendir (call_frame_t *frame, xlator_t *bound_xl,
state = CALL_STATE (frame);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
@@ -4087,8 +4087,8 @@ server_mknod (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_NOT;
state->resolve.par = ntoh64 (req->par);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
- state->resolve.bname = strdup (req->bname + pathlen);
+ state->resolve.path = gf_strdup (req->path);
+ state->resolve.bname = gf_strdup (req->bname + pathlen);
state->mode = ntoh32 (req->mode);
state->dev = ntoh64 (req->dev);
@@ -4140,8 +4140,8 @@ server_mkdir (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_NOT;
state->resolve.par = ntoh64 (req->par);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
- state->resolve.bname = strdup (req->bname + pathlen);
+ state->resolve.path = gf_strdup (req->path);
+ state->resolve.bname = gf_strdup (req->bname + pathlen);
state->mode = ntoh32 (req->mode);
@@ -4186,8 +4186,8 @@ server_rmdir (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_MUST;
state->resolve.par = ntoh64 (req->par);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
- state->resolve.bname = strdup (req->bname + pathlen);
+ state->resolve.path = gf_strdup (req->path);
+ state->resolve.bname = gf_strdup (req->bname + pathlen);
resolve_and_resume (frame, server_rmdir_resume);
@@ -4235,7 +4235,7 @@ server_inodelk (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_EXACT;
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
cmd = ntoh32 (req->cmd);
switch (cmd) {
@@ -4251,7 +4251,7 @@ server_inodelk (call_frame_t *frame, xlator_t *bound_xl,
}
state->type = ntoh32 (req->type);
- state->volume = strdup (req->volume + pathlen);
+ state->volume = gf_strdup (req->volume + pathlen);
gf_flock_to_flock (&req->flock, &state->flock);
@@ -4310,7 +4310,7 @@ server_finodelk (call_frame_t *frame, xlator_t *bound_xl,
state = CALL_STATE(frame);
state->resolve.type = RESOLVE_EXACT;
- state->volume = strdup (req->volume);
+ state->volume = gf_strdup (req->volume);
state->resolve.fd_no = ntoh64 (req->fd);
state->cmd = ntoh32 (req->cmd);
@@ -4388,13 +4388,13 @@ server_entrylk (call_frame_t *frame, xlator_t *bound_xl,
vollen = STRLEN_0(req->volume + pathlen + namelen);
state->resolve.type = RESOLVE_EXACT;
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->resolve.ino = ntoh64 (req->ino);
state->resolve.gen = ntoh64 (req->gen);
if (namelen)
- state->name = strdup (req->name + pathlen);
- state->volume = strdup (req->volume + pathlen + namelen);
+ state->name = gf_strdup (req->name + pathlen);
+ state->volume = gf_strdup (req->volume + pathlen + namelen);
state->cmd = ntoh32 (req->cmd);
state->type = ntoh32 (req->type);
@@ -4451,7 +4451,7 @@ server_fentrylk (call_frame_t *frame, xlator_t *bound_xl,
namelen = ntoh64 (req->namelen);
if (namelen)
state->name = req->name;
- state->volume = strdup (req->volume + namelen);
+ state->volume = gf_strdup (req->volume + namelen);
resolve_and_resume (frame, server_finodelk_resume);
@@ -4495,7 +4495,7 @@ server_access (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_MUST;
state->resolve.ino = hton64 (req->ino);
state->resolve.gen = hton64 (req->gen);
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->mask = ntoh32 (req->mask);
@@ -4548,9 +4548,9 @@ server_symlink (call_frame_t *frame, xlator_t *bound_xl,
state->resolve.type = RESOLVE_NOT;
state->resolve.par = ntoh64 (req->par);
state->resolve.gen = ntoh64 (req->gen);
- state->resolve.path = strdup (req->path);
- state->resolve.bname = strdup (req->bname + pathlen);
- state->name = strdup (req->linkname + pathlen + baselen);
+ state->resolve.path = gf_strdup (req->path);
+ state->resolve.bname = gf_strdup (req->bname + pathlen);
+ state->name = gf_strdup (req->linkname + pathlen + baselen);
resolve_and_resume (frame, server_symlink_resume);
@@ -4610,13 +4610,13 @@ server_link (call_frame_t *frame, xlator_t *this,
newbaselen = STRLEN_0 (req->newbname + oldpathlen + newpathlen);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->oldpath);
+ state->resolve.path = gf_strdup (req->oldpath);
state->resolve.ino = ntoh64 (req->oldino);
state->resolve.gen = ntoh64 (req->oldgen);
state->resolve2.type = RESOLVE_NOT;
- state->resolve2.path = strdup (req->newpath + oldpathlen);
- state->resolve2.bname = strdup (req->newbname + oldpathlen + newpathlen);
+ state->resolve2.path = gf_strdup (req->newpath + oldpathlen);
+ state->resolve2.bname = gf_strdup (req->newbname + oldpathlen + newpathlen);
state->resolve2.par = ntoh64 (req->newpar);
state->resolve2.gen = ntoh64 (req->newgen);
@@ -4680,14 +4680,14 @@ server_rename (call_frame_t *frame, xlator_t *bound_xl,
oldbaselen + newpathlen);
state->resolve.type = RESOLVE_MUST;
- state->resolve.path = strdup (req->oldpath);
- state->resolve.bname = strdup (req->oldbname + oldpathlen);
+ state->resolve.path = gf_strdup (req->oldpath);
+ state->resolve.bname = gf_strdup (req->oldbname + oldpathlen);
state->resolve.par = ntoh64 (req->oldpar);
state->resolve.gen = ntoh64 (req->oldgen);
state->resolve2.type = RESOLVE_MAY;
- state->resolve2.path = strdup (req->newpath + oldpathlen + oldbaselen);
- state->resolve2.bname = strdup (req->newbname + oldpathlen + oldbaselen +
+ state->resolve2.path = gf_strdup (req->newpath + oldpathlen + oldbaselen);
+ state->resolve2.bname = gf_strdup (req->newbname + oldpathlen + oldbaselen +
newpathlen);
state->resolve2.par = ntoh64 (req->newpar);
state->resolve2.gen = ntoh64 (req->newgen);
@@ -4809,10 +4809,11 @@ _volfile_update_checksum (xlator_t *this, char *key, uint32_t checksum)
}
if (!temp_volfile) {
- temp_volfile = CALLOC (1, sizeof (struct _volfile_ctx));
+ temp_volfile = GF_CALLOC (1, sizeof (struct _volfile_ctx),
+ gf_server_mt_volfile_ctx);
temp_volfile->next = conf->volfile;
- temp_volfile->key = (key)? strdup (key): NULL;
+ temp_volfile->key = (key)? gf_strdup (key): NULL;
temp_volfile->checksum = checksum;
conf->volfile = temp_volfile;
@@ -4900,12 +4901,12 @@ build_volfile_path (xlator_t *this, const char *key, char *path,
goto out;
}
- conf_dir = strdup (conf_dir_data->data);
+ conf_dir = gf_strdup (conf_dir_data->data);
free_conf_dir = 1;
}
- ret = asprintf (&filename, "%s/%s.vol",
- conf_dir, key);
+ ret = gf_asprintf (&filename, "%s/%s.vol",
+ conf_dir, key);
if (-1 == ret)
goto out;
@@ -4933,10 +4934,10 @@ build_volfile_path (xlator_t *this, const char *key, char *path,
out:
if (free_conf_dir)
- free (conf_dir);
+ GF_FREE (conf_dir);
if (free_filename)
- free (filename);
+ GF_FREE (filename);
return ret;
}
@@ -5161,7 +5162,7 @@ server_checksum (call_frame_t *frame, xlator_t *bound_xl,
state = CALL_STATE (frame);
state->resolve.type = RESOLVE_MAY;
- state->resolve.path = strdup (req->path);
+ state->resolve.path = gf_strdup (req->path);
state->resolve.gen = ntoh64 (req->gen);
state->resolve.ino = ntoh64 (req->ino);
state->flags = ntoh32 (req->flag);
@@ -5397,11 +5398,11 @@ mop_setvolume (call_frame_t *frame, xlator_t *bound_xl,
ret = strcmp (version, GF_PROTOCOL_VERSION);
if (ret != 0) {
- ret = asprintf (&msg, "protocol version mismatch: client(%s) "
+ ret = gf_asprintf (&msg, "protocol version mismatch: client(%s) "
"- server(%s)", version, GF_PROTOCOL_VERSION);
if (-1 == ret) {
gf_log (trans->xl->name, GF_LOG_ERROR,
- "asprintf failed while setting up error msg");
+ "gf_asprintf failed while setting up error msg");
goto fail;
}
ret = dict_set_dynstr (reply, "ERROR", msg);
@@ -5430,11 +5431,11 @@ mop_setvolume (call_frame_t *frame, xlator_t *bound_xl,
xl = get_xlator_by_name (frame->this, name);
if (xl == NULL) {
- ret = asprintf (&msg, "remote-subvolume \"%s\" is not found",
+ ret = gf_asprintf (&msg, "remote-subvolume \"%s\" is not found",
name);
if (-1 == ret) {
gf_log (trans->xl->name, GF_LOG_ERROR,
- "asprintf failed while setting error msg");
+ "gf_asprintf failed while setting error msg");
goto fail;
}
ret = dict_set_dynstr (reply, "ERROR", msg);
@@ -5806,7 +5807,8 @@ get_frame_for_transport (transport_t *trans)
frame = create_frame (trans->xl, pool);
GF_VALIDATE_OR_GOTO("server", frame, out);
- state = CALLOC (1, sizeof (*state));
+ state = GF_CALLOC (1, sizeof (*state),
+ gf_server_mt_server_state_t);
GF_VALIDATE_OR_GOTO("server", state, out);
conn = trans->xl_private;
@@ -6187,7 +6189,7 @@ get_auth_types (dict_t *this, char *key, data_t *value, void *data)
int32_t ret = -1;
auth_dict = data;
- key_cpy = strdup (key);
+ key_cpy = gf_strdup (key);
GF_VALIDATE_OR_GOTO("server", key_cpy, out);
tmp = strtok_r (key_cpy, ".", &saveptr);
@@ -6208,7 +6210,7 @@ get_auth_types (dict_t *this, char *key, data_t *value, void *data)
}
}
- FREE (key_cpy);
+ GF_FREE (key_cpy);
out:
return;
}
@@ -6229,7 +6231,7 @@ validate_auth_options (xlator_t *this, dict_t *dict)
while (trav) {
error = -1;
for (pair = dict->members_list; pair; pair = pair->next) {
- key_cpy = strdup (pair->key);
+ key_cpy = gf_strdup (pair->key);
tmp = strtok_r (key_cpy, ".", &saveptr);
ret = strcmp (tmp, "auth");
if (ret == 0) {
@@ -6241,10 +6243,10 @@ validate_auth_options (xlator_t *this, dict_t *dict)
if (strcmp (tmp, trav->xlator->name) == 0) {
error = 0;
- free (key_cpy);
+ GF_FREE (key_cpy);
break;
}
- free (key_cpy);
+ GF_FREE (key_cpy);
}
if (-1 == error) {
gf_log (this->name, GF_LOG_ERROR,
@@ -6259,6 +6261,25 @@ validate_auth_options (xlator_t *this, dict_t *dict)
return error;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_server_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ " failed");
+ return ret;
+ }
+
+ return ret;
+}
+
/*
* init - called during server protocol initialization
@@ -6295,7 +6316,8 @@ init (xlator_t *this)
goto out;
}
- conf = CALLOC (1, sizeof (server_conf_t));
+ conf = GF_CALLOC (1, sizeof (server_conf_t),
+ gf_server_mt_server_conf_t);
GF_VALIDATE_OR_GOTO(this->name, conf, out);
INIT_LIST_HEAD (&conf->conns);
@@ -6409,7 +6431,7 @@ protocol_server_pollin (xlator_t *this, transport_t *trans)
hdrlen, iobuf);
/* TODO: use mem-pool */
- FREE (hdr);
+ GF_FREE (hdr);
return ret;
}
@@ -6433,7 +6455,7 @@ fini (xlator_t *this)
dict_unref (conf->auth_modules);
}
- FREE (conf);
+ GF_FREE (conf);
this->private = NULL;
out:
return;
diff --git a/xlators/protocol/server/src/server-protocol.h b/xlators/protocol/server/src/server-protocol.h
index 61fcb877e42..3d432614c27 100644
--- a/xlators/protocol/server/src/server-protocol.h
+++ b/xlators/protocol/server/src/server-protocol.h
@@ -34,6 +34,7 @@
#include "authenticate.h"
#include "fd.h"
#include "byte-order.h"
+#include "server-mem-types.h"
#define DEFAULT_BLOCK_SIZE 4194304 /* 4MB */
#define DEFAULT_VOLUME_FILE_PATH CONFDIR "/glusterfs.vol"
diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c
index f4c9ebad7a2..00f1728c5eb 100644
--- a/xlators/protocol/server/src/server-resolve.c
+++ b/xlators/protocol/server/src/server-resolve.c
@@ -69,11 +69,12 @@ prepare_components (call_frame_t *frame)
this = frame->this;
resolve = state->resolve_now;
- resolved = strdup (resolve->path);
+ resolved = gf_strdup (resolve->path);
resolve->resolved = resolved;
count = component_count (resolve->path);
- components = CALLOC (sizeof (*components), count);
+ components = GF_CALLOC (sizeof (*components), count,
+ gf_server_mt_resolve_comp);
resolve->components = components;
components[0].basename = "";
@@ -116,7 +117,7 @@ resolve_loc_touchup (call_frame_t *frame)
}
if (!path)
- path = strdup (resolve->path);
+ path = gf_strdup (resolve->path);
loc->path = path;
}
@@ -205,7 +206,7 @@ resolve_deep_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* join the current component with the path resolved until now */
*(components[i].basename - 1) = '/';
- resolve->deep_loc.path = strdup (resolve->resolved);
+ resolve->deep_loc.path = gf_strdup (resolve->resolved);
resolve->deep_loc.parent = inode_ref (components[i-1].inode);
resolve->deep_loc.inode = inode_new (state->itable);
resolve->deep_loc.name = components[i].basename;
@@ -241,7 +242,7 @@ resolve_path_deep (call_frame_t *frame)
/* start from the root */
resolve->deep_loc.inode = state->itable->root;
- resolve->deep_loc.path = strdup ("/");
+ resolve->deep_loc.path = gf_strdup ("/");
resolve->deep_loc.name = "";
STACK_WIND_COOKIE (frame, resolve_deep_cbk, (void *) (long) i,