summaryrefslogtreecommitdiffstats
path: root/xlators/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/protocol')
-rw-r--r--xlators/protocol/client/src/client-mem-types.h43
-rw-r--r--xlators/protocol/client/src/client-protocol.c178
-rw-r--r--xlators/protocol/client/src/saved-frames.c13
-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
8 files changed, 343 insertions, 203 deletions
diff --git a/xlators/protocol/client/src/client-mem-types.h b/xlators/protocol/client/src/client-mem-types.h
new file mode 100644
index 00000000000..1eee8d93159
--- /dev/null
+++ b/xlators/protocol/client/src/client-mem-types.h
@@ -0,0 +1,43 @@
+
+/*
+ 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 __CLIENT_MEM_TYPES_H__
+#define __CLIENT_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_client_mem_types_ {
+ gf_client_mt_dir_entry_t = gf_common_mt_end + 1,
+ gf_client_mt_volfile_ctx,
+ gf_client_mt_client_state_t,
+ gf_client_mt_client_conf_t,
+ gf_client_mt_locker,
+ gf_client_mt_lock_table,
+ gf_client_mt_char,
+ gf_client_mt_client_connection_t,
+ gf_client_mt_client_fd_ctx_t,
+ gf_client_mt_client_local_t,
+ gf_client_mt_saved_frames,
+ gf_client_mt_saved_frame,
+ gf_client_mt_end
+};
+#endif
+
diff --git a/xlators/protocol/client/src/client-protocol.c b/xlators/protocol/client/src/client-protocol.c
index 36a31c5c918..df890cc3ca6 100644
--- a/xlators/protocol/client/src/client-protocol.c
+++ b/xlators/protocol/client/src/client-protocol.c
@@ -37,6 +37,7 @@
#include "compat.h"
#include "compat-errno.h"
#include "statedump.h"
+#include "client-mem-types.h"
#include <sys/resource.h>
#include <inttypes.h>
@@ -169,7 +170,7 @@ client_local_wipe (client_local_t *local)
if (local->fd)
fd_unref (local->fd);
- free (local);
+ GF_FREE (local);
}
return 0;
@@ -234,7 +235,7 @@ call_bail (void *data)
/* Chaining to get call-always functionality from
call-once timer */
if (conn->timer) {
- timer_cbk = conn->timer->cbk;
+ timer_cbk = conn->timer->callbk;
timeout.tv_sec = 10;
timeout.tv_usec = 0;
@@ -320,7 +321,7 @@ call_bail (void *data)
gf_ops[trav->op] (frame, &hdr, sizeof (hdr), NULL);
list_del_init (&trav->list);
- FREE (trav);
+ GF_FREE (trav);
}
out:
return;
@@ -507,7 +508,7 @@ client_start_ping (void *data)
return;
err:
if (hdr)
- FREE (hdr);
+ GF_FREE (hdr);
if (dummy_frame)
STACK_DESTROY (dummy_frame->root);
@@ -661,7 +662,7 @@ protocol_client_xfer (call_frame_t *frame, xlator_t *this, transport_t *trans,
gf_cbks[op] (frame, &rsphdr, sizeof (rsphdr), NULL);
}
- FREE (hdr);
+ GF_FREE (hdr);
}
return ret;
@@ -695,7 +696,7 @@ client_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
client_local_t *local = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
local->fd = fd_ref (fd);
@@ -735,7 +736,7 @@ client_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, fd, NULL, NULL);
return 0;
@@ -765,7 +766,7 @@ client_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
uint64_t gen = 0;
client_local_t *local = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
local->fd = fd_ref (fd);
@@ -805,7 +806,7 @@ client_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, fd);
return 0;
@@ -860,7 +861,7 @@ client_stat (call_frame_t *frame, xlator_t *this, loc_t *loc)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -916,7 +917,7 @@ client_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -947,7 +948,7 @@ client_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
uint64_t gen = 0;
client_local_t *local = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
loc_copy (&local->loc, loc);
@@ -985,7 +986,7 @@ client_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, loc->inode, NULL);
return 0;
@@ -1014,7 +1015,7 @@ client_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode)
uint64_t gen = 0;
client_local_t *local = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
loc_copy (&local->loc, loc);
@@ -1051,7 +1052,7 @@ client_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, loc->inode, NULL);
return 0;
@@ -1107,7 +1108,7 @@ client_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -1163,7 +1164,7 @@ client_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -1195,7 +1196,7 @@ client_symlink (call_frame_t *frame, xlator_t *this, const char *linkname,
uint64_t gen = 0;
client_local_t *local = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
loc_copy (&local->loc, loc);
@@ -1232,7 +1233,7 @@ client_symlink (call_frame_t *frame, xlator_t *this, const char *linkname,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, loc->inode, NULL);
return 0;
@@ -1312,7 +1313,7 @@ client_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -1344,7 +1345,7 @@ client_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc)
uint64_t newgen = 0;
client_local_t *local = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
loc_copy (&local->loc, oldloc);
@@ -1395,7 +1396,7 @@ client_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, oldloc->inode, NULL);
return 0;
}
@@ -1450,7 +1451,7 @@ client_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -1523,7 +1524,7 @@ client_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
return 0;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL, 0, NULL);
return 0;
@@ -1596,7 +1597,7 @@ client_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -1653,7 +1654,7 @@ client_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -1721,7 +1722,7 @@ client_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
return 0;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -1790,7 +1791,7 @@ client_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -1844,7 +1845,7 @@ client_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc,
req->dict_len = hton32 (dict_len);
if (dict) {
memcpy (req->dict, buf, dict_len);
- FREE (buf);
+ GF_FREE (buf);
}
req->ino = hton64 (ino);
@@ -1858,7 +1859,7 @@ client_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -1942,7 +1943,7 @@ client_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EBADFD, NULL);
return 0;
@@ -2019,7 +2020,7 @@ client_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -2110,7 +2111,7 @@ client_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -2170,7 +2171,7 @@ client_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -2249,7 +2250,7 @@ client_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -2308,7 +2309,7 @@ client_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
}
@@ -2335,7 +2336,7 @@ client_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc,
size_t pathlen = 0;
client_local_t *local = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
loc_copy (&local->loc, loc);
@@ -2371,7 +2372,7 @@ client_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, fd);
return 0;
@@ -2437,7 +2438,7 @@ client_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
return 0;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EBADFD, NULL);
return 0;
@@ -2505,7 +2506,7 @@ client_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
return 0;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EBADFD, NULL);
return 0;
@@ -2624,7 +2625,7 @@ client_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -2693,7 +2694,7 @@ client_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -2759,7 +2760,7 @@ client_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd)
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -2857,7 +2858,7 @@ client_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -2949,7 +2950,7 @@ client_inodelk (call_frame_t *frame, xlator_t *this, const char *volume,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -3056,7 +3057,7 @@ client_finodelk (call_frame_t *frame, xlator_t *this, const char *volume,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -3118,7 +3119,7 @@ client_entrylk (call_frame_t *frame, xlator_t *this, const char *volume,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -3196,7 +3197,7 @@ client_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL);
return 0;
@@ -3230,7 +3231,7 @@ client_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
client_local_t *local = NULL;
char *buf = NULL;
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
loc_copy (&local->loc, loc);
@@ -3281,7 +3282,7 @@ client_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
if (dictlen > 0) {
memcpy (req->dict + pathlen + baselen, buf, dictlen);
- FREE (buf);
+ GF_FREE (buf);
}
req->dictlen = hton32 (dictlen);
@@ -3451,7 +3452,7 @@ client_fdctx_destroy (xlator_t *this, client_fd_ctx_t *fdctx)
out:
inode_unref (fdctx->inode);
- FREE (fdctx);
+ GF_FREE (fdctx);
return ret;
}
@@ -3598,7 +3599,7 @@ fail:
STACK_UNWIND (frame, op_ret, op_errno, dict);
if (dictbuf)
- free (dictbuf);
+ GF_FREE (dictbuf);
if (dict)
dict_unref (dict);
@@ -3657,7 +3658,7 @@ fail:
STACK_UNWIND (frame, op_ret, op_errno, dict);
if (dictbuf)
- free (dictbuf);
+ GF_FREE (dictbuf);
if (dict)
dict_unref (dict);
@@ -3724,7 +3725,8 @@ client_create_cbk (call_frame_t *frame, gf_hdr_common_t *hdr, size_t hdrlen,
local->loc.path);
}
- fdctx = CALLOC (1, sizeof (*fdctx));
+ fdctx = GF_CALLOC (1, sizeof (*fdctx),
+ gf_client_mt_client_fd_ctx_t);
if (!fdctx) {
op_ret = -1;
op_errno = ENOMEM;
@@ -3801,7 +3803,8 @@ client_open_cbk (call_frame_t *frame, gf_hdr_common_t *hdr, size_t hdrlen,
}
if (op_ret >= 0) {
- fdctx = CALLOC (1, sizeof (*fdctx));
+ fdctx = GF_CALLOC (1, sizeof (*fdctx),
+ gf_client_mt_client_fd_ctx_t);
if (!fdctx) {
op_ret = -1;
op_errno = ENOMEM;
@@ -4521,7 +4524,8 @@ client_opendir_cbk (call_frame_t *frame, gf_hdr_common_t *hdr, size_t hdrlen,
}
if (op_ret >= 0) {
- fdctx = CALLOC (1, sizeof (*fdctx));
+ fdctx = GF_CALLOC (1, sizeof (*fdctx),
+ gf_client_mt_client_fd_ctx_t);
if (!fdctx) {
op_ret = -1;
op_errno = ENOMEM;
@@ -4719,7 +4723,7 @@ fail:
client_local_wipe (local);
if (dictbuf)
- free (dictbuf);
+ GF_FREE (dictbuf);
if (xattr)
dict_unref (xattr);
@@ -4790,13 +4794,13 @@ gf_free_direntry (dir_entry_t *head)
trav = head->next;
while (trav) {
prev->next = trav->next;
- FREE (trav->name);
+ GF_FREE (trav->name);
if (IA_ISLNK (trav->buf.ia_type))
- FREE (trav->link);
- FREE (trav);
+ GF_FREE (trav->link);
+ GF_FREE (trav);
trav = prev->next;
}
- FREE (head);
+ GF_FREE (head);
fail:
return 0;
}
@@ -4945,7 +4949,7 @@ fail:
client_local_wipe (local);
if (dictbuf)
- free (dictbuf);
+ GF_FREE (dictbuf);
if (dict)
dict_unref (dict);
@@ -5133,7 +5137,7 @@ client_getspec (call_frame_t *frame, xlator_t *this, const char *key,
return ret;
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
}
@@ -5203,7 +5207,7 @@ client_log (call_frame_t *frame, xlator_t *this, const char *msg)
unwind:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
STACK_UNWIND (frame, -1, EINVAL, NULL);
return 0;
@@ -5477,7 +5481,7 @@ protocol_client_reopendir (xlator_t *this, client_fd_ctx_t *fdctx)
goto out;
}
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
if (!local) {
goto out;
}
@@ -5523,7 +5527,7 @@ out:
client_local_wipe (local);
if (path)
- FREE (path);
+ GF_FREE (path);
return 0;
}
@@ -5600,7 +5604,7 @@ protocol_client_reopen (xlator_t *this, client_fd_ctx_t *fdctx)
goto out;
}
- local = calloc (1, sizeof (*local));
+ local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t);
if (!local) {
goto out;
}
@@ -5647,7 +5651,7 @@ out:
client_local_wipe (local);
if (path)
- FREE (path);
+ GF_FREE (path);
return 0;
@@ -6120,6 +6124,26 @@ protocol_client_interpret (xlator_t *this, transport_t *trans,
return ret;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_client_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
+
/*
* init - initiliazation function. called during loading of client protocol
* @this:
@@ -6179,7 +6203,8 @@ init (xlator_t *this)
ping_timeout = GF_UNIVERSAL_ANSWER;
}
- conf = CALLOC (1, sizeof (client_conf_t));
+ conf = GF_CALLOC (1, sizeof (client_conf_t),
+ gf_client_mt_client_conf_t);
pthread_mutex_init (&conf->mutex, NULL);
INIT_LIST_HEAD (&conf->saved_fds);
@@ -6189,7 +6214,7 @@ init (xlator_t *this)
for (i = 0; i < CHANNEL_MAX; i++) {
if (CHANNEL_LOWLAT == i) {
dict_set (this->options, "transport.socket.lowlat",
- data_from_dynstr (strdup ("true")));
+ data_from_dynstr (gf_strdup ("true")));
}
trans = transport_load (this->options, this);
if (trans == NULL) {
@@ -6199,7 +6224,8 @@ init (xlator_t *this)
goto out;
}
- conn = CALLOC (1, sizeof (*conn));
+ conn = GF_CALLOC (1, sizeof (*conn),
+ gf_client_mt_client_connection_t);
conn->saved_frames = saved_frames_new ();
@@ -6262,7 +6288,7 @@ fini (xlator_t *this)
this->private = NULL;
if (conf) {
- FREE (conf);
+ GF_FREE (conf);
}
return;
}
@@ -6288,8 +6314,8 @@ protocol_client_handshake (xlator_t *this, transport_t *trans)
GF_PROTOCOL_VERSION);
}
- ret = asprintf (&process_uuid_xl, "%s-%s", this->ctx->process_uuid,
- this->name);
+ ret = gf_asprintf (&process_uuid_xl, "%s-%s", this->ctx->process_uuid,
+ this->name);
if (-1 == ret) {
gf_log (this->name, GF_LOG_ERROR,
"asprintf failed while setting process_uuid");
@@ -6345,7 +6371,7 @@ protocol_client_handshake (xlator_t *this, transport_t *trans)
return ret;
fail:
if (hdr)
- free (hdr);
+ GF_FREE (hdr);
return ret;
}
@@ -6393,7 +6419,7 @@ protocol_client_pollin (xlator_t *this, transport_t *trans)
}
/* TODO: use mem-pool */
- FREE (hdr);
+ GF_FREE (hdr);
return ret;
}
diff --git a/xlators/protocol/client/src/saved-frames.c b/xlators/protocol/client/src/saved-frames.c
index cd5349e21fb..770de19ad72 100644
--- a/xlators/protocol/client/src/saved-frames.c
+++ b/xlators/protocol/client/src/saved-frames.c
@@ -22,6 +22,7 @@
#include "common-utils.h"
#include "protocol.h"
#include "xlator.h"
+#include "client-mem-types.h"
@@ -30,7 +31,8 @@ saved_frames_new (void)
{
struct saved_frames *saved_frames = NULL;
- saved_frames = CALLOC (sizeof (*saved_frames), 1);
+ saved_frames = GF_CALLOC (sizeof (*saved_frames), 1,
+ gf_client_mt_saved_frames);
if (!saved_frames) {
return NULL;
}
@@ -76,7 +78,8 @@ saved_frames_put (struct saved_frames *frames, call_frame_t *frame,
head_frame = get_head_frame_for_type (frames, type);
- saved_frame = CALLOC (sizeof (*saved_frame), 1);
+ saved_frame = GF_CALLOC (sizeof (*saved_frame), 1,
+ gf_client_mt_saved_frame);
if (!saved_frame) {
return -ENOMEM;
}
@@ -119,7 +122,7 @@ saved_frames_get (struct saved_frames *frames, int32_t op,
if (saved_frame)
frame = saved_frame->frame;
- FREE (saved_frame);
+ GF_FREE (saved_frame);
return frame;
}
@@ -174,7 +177,7 @@ saved_frames_unwind (xlator_t *this, struct saved_frames *saved_frames,
gf_ops[trav->op] (frame, &hdr, sizeof (hdr), NULL);
list_del_init (&trav->list);
- FREE (trav);
+ GF_FREE (trav);
}
}
@@ -187,5 +190,5 @@ saved_frames_destroy (xlator_t *this, struct saved_frames *frames,
saved_frames_unwind (this, frames, &frames->mops, gf_mops, gf_mop_list);
saved_frames_unwind (this, frames, &frames->cbks, gf_cbks, gf_cbk_list);
- FREE (frames);
+ GF_FREE (frames);
}
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,