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
This commit is contained in:
parent
72baa17282
commit
582de0677d
36
glusterfsd/src/glusterfsd-mem-types.h
Normal file
36
glusterfsd/src/glusterfsd-mem-types.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
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
|
||||
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 __GLUSTERFSD_MEM_TYPES_H__
|
||||
#define __GLUSTERFSD_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
#define GF_MEM_TYPE_START (gf_common_mt_end + 1)
|
||||
|
||||
enum gfd_mem_types_ {
|
||||
gfd_mt_xlator_list_t = GF_MEM_TYPE_START,
|
||||
gfd_mt_xlator_t,
|
||||
gfd_mt_xlator_cmdline_option_t,
|
||||
gfd_mt_char,
|
||||
gfd_mt_call_pool_t,
|
||||
gfd_mt_end
|
||||
|
||||
};
|
||||
#endif
|
@ -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.
|
||||
@ -70,6 +70,7 @@
|
||||
#include "globals.h"
|
||||
#include "statedump.h"
|
||||
#include "latency.h"
|
||||
#include "glusterfsd-mem-types.h"
|
||||
|
||||
#include <fnmatch.h>
|
||||
|
||||
@ -298,12 +299,14 @@ _add_fuse_mount (xlator_t *graph)
|
||||
ctx = graph->ctx;
|
||||
cmd_args = &ctx->cmd_args;
|
||||
|
||||
xlchild = CALLOC (sizeof (*xlchild), 1);
|
||||
xlchild = GF_CALLOC (sizeof (*xlchild), 1,
|
||||
gfd_mt_xlator_list_t);
|
||||
ERR_ABORT (xlchild);
|
||||
xlchild->xlator = graph;
|
||||
|
||||
top = CALLOC (1, sizeof (*top));
|
||||
top->name = strdup ("fuse");
|
||||
top = GF_CALLOC (1, sizeof (*top),
|
||||
gfd_mt_xlator_t);
|
||||
top->name = gf_strdup ("fuse");
|
||||
if (xlator_set_type (top, ZR_XLATOR_FUSE) == -1) {
|
||||
fprintf (stderr,
|
||||
"MOUNT-POINT %s initialization failed",
|
||||
@ -368,7 +371,8 @@ _add_fuse_mount (xlator_t *graph)
|
||||
|
||||
#endif /* GF_DARWIN_HOST_OS */
|
||||
|
||||
graph->parents = CALLOC (1, sizeof (xlator_list_t));
|
||||
graph->parents = GF_CALLOC (1, sizeof (xlator_list_t),
|
||||
gfd_mt_xlator_list_t);
|
||||
graph->parents->xlator = top;
|
||||
|
||||
return top;
|
||||
@ -696,6 +700,10 @@ glusterfs_graph_init (xlator_t *graph, int fuse)
|
||||
"validating translator failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (graph->mem_acct_init (graph) != 0)
|
||||
return -1;
|
||||
|
||||
if (xlator_init (graph) != 0)
|
||||
return -1;
|
||||
|
||||
@ -730,27 +738,30 @@ gf_remember_xlator_option (struct list_head *options, char *arg)
|
||||
ctx = get_global_ctx_ptr ();
|
||||
cmd_args = &ctx->cmd_args;
|
||||
|
||||
option = CALLOC (1, sizeof (xlator_cmdline_option_t));
|
||||
option = GF_CALLOC (1, sizeof (xlator_cmdline_option_t),
|
||||
gfd_mt_xlator_cmdline_option_t);
|
||||
INIT_LIST_HEAD (&option->cmd_args);
|
||||
|
||||
dot = strchr (arg, '.');
|
||||
if (!dot)
|
||||
goto out;
|
||||
|
||||
option->volume = CALLOC ((dot - arg), sizeof (char));
|
||||
option->volume = GF_CALLOC ((dot - arg), sizeof (char),
|
||||
gfd_mt_char);
|
||||
strncpy (option->volume, arg, (dot - arg));
|
||||
|
||||
equals = strchr (arg, '=');
|
||||
if (!equals)
|
||||
goto out;
|
||||
|
||||
option->key = CALLOC ((equals - dot), sizeof (char));
|
||||
option->key = GF_CALLOC ((equals - dot), sizeof (char),
|
||||
gfd_mt_char);
|
||||
strncpy (option->key, dot + 1, (equals - dot - 1));
|
||||
|
||||
if (!*(equals + 1))
|
||||
goto out;
|
||||
|
||||
option->value = strdup (equals + 1);
|
||||
option->value = gf_strdup (equals + 1);
|
||||
|
||||
list_add (&option->cmd_args, &cmd_args->xlator_options);
|
||||
|
||||
@ -759,13 +770,13 @@ out:
|
||||
if (ret == -1) {
|
||||
if (option) {
|
||||
if (option->volume)
|
||||
FREE (option->volume);
|
||||
GF_FREE (option->volume);
|
||||
if (option->key)
|
||||
FREE (option->key);
|
||||
GF_FREE (option->key);
|
||||
if (option->value)
|
||||
FREE (option->value);
|
||||
GF_FREE (option->value);
|
||||
|
||||
FREE (option);
|
||||
GF_FREE (option);
|
||||
}
|
||||
}
|
||||
|
||||
@ -819,7 +830,7 @@ parse_opts (int key, char *arg, struct argp_state *state)
|
||||
|
||||
switch (key) {
|
||||
case ARGP_VOLFILE_SERVER_KEY:
|
||||
cmd_args->volfile_server = strdup (arg);
|
||||
cmd_args->volfile_server = gf_strdup (arg);
|
||||
break;
|
||||
|
||||
case ARGP_VOLFILE_MAX_FETCH_ATTEMPTS:
|
||||
@ -839,11 +850,11 @@ parse_opts (int key, char *arg, struct argp_state *state)
|
||||
break;
|
||||
|
||||
case ARGP_VOLUME_FILE_KEY:
|
||||
cmd_args->volume_file = strdup (arg);
|
||||
cmd_args->volume_file = gf_strdup (arg);
|
||||
break;
|
||||
|
||||
case ARGP_LOG_SERVER_KEY:
|
||||
cmd_args->log_server = strdup (arg);
|
||||
cmd_args->log_server = gf_strdup (arg);
|
||||
break;
|
||||
|
||||
case ARGP_LOG_LEVEL_KEY:
|
||||
@ -880,7 +891,7 @@ parse_opts (int key, char *arg, struct argp_state *state)
|
||||
break;
|
||||
|
||||
case ARGP_LOG_FILE_KEY:
|
||||
cmd_args->log_file = strdup (arg);
|
||||
cmd_args->log_file = gf_strdup (arg);
|
||||
break;
|
||||
|
||||
case ARGP_VOLFILE_SERVER_PORT_KEY:
|
||||
@ -908,15 +919,15 @@ parse_opts (int key, char *arg, struct argp_state *state)
|
||||
break;
|
||||
|
||||
case ARGP_VOLFILE_SERVER_TRANSPORT_KEY:
|
||||
cmd_args->volfile_server_transport = strdup (arg);
|
||||
cmd_args->volfile_server_transport = gf_strdup (arg);
|
||||
break;
|
||||
|
||||
case ARGP_VOLFILE_ID_KEY:
|
||||
cmd_args->volfile_id = strdup (arg);
|
||||
cmd_args->volfile_id = gf_strdup (arg);
|
||||
break;
|
||||
|
||||
case ARGP_PID_FILE_KEY:
|
||||
cmd_args->pid_file = strdup (arg);
|
||||
cmd_args->pid_file = gf_strdup (arg);
|
||||
break;
|
||||
|
||||
case ARGP_NO_DAEMON_KEY:
|
||||
@ -924,7 +935,7 @@ parse_opts (int key, char *arg, struct argp_state *state)
|
||||
break;
|
||||
|
||||
case ARGP_RUN_ID_KEY:
|
||||
cmd_args->run_id = strdup (arg);
|
||||
cmd_args->run_id = gf_strdup (arg);
|
||||
break;
|
||||
|
||||
case ARGP_DEBUG_KEY:
|
||||
@ -969,7 +980,7 @@ parse_opts (int key, char *arg, struct argp_state *state)
|
||||
break;
|
||||
|
||||
case ARGP_VOLUME_NAME_KEY:
|
||||
cmd_args->volume_name = strdup (arg);
|
||||
cmd_args->volume_name = gf_strdup (arg);
|
||||
break;
|
||||
|
||||
case ARGP_XLATOR_OPTION_KEY:
|
||||
@ -990,7 +1001,7 @@ parse_opts (int key, char *arg, struct argp_state *state)
|
||||
if (state->arg_num >= 1)
|
||||
argp_usage (state);
|
||||
|
||||
cmd_args->mount_point = strdup (arg);
|
||||
cmd_args->mount_point = gf_strdup (arg);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1064,7 +1075,7 @@ zr_build_process_uuid ()
|
||||
snprintf (tmp_str, 1024, "%s-%d-%s:%ld",
|
||||
hostname, getpid(), now_str, tv.tv_usec);
|
||||
|
||||
return strdup (tmp_str);
|
||||
return gf_strdup (tmp_str);
|
||||
}
|
||||
|
||||
#define GF_SERVER_PROCESS 0
|
||||
@ -1076,7 +1087,7 @@ gf_get_process_mode (char *exec_name)
|
||||
char *dup_execname = NULL, *base = NULL;
|
||||
uint8_t ret = 0;
|
||||
|
||||
dup_execname = strdup (exec_name);
|
||||
dup_execname = gf_strdup (exec_name);
|
||||
base = basename (dup_execname);
|
||||
|
||||
if (!strncmp (base, "glusterfsd", 10)) {
|
||||
@ -1085,7 +1096,7 @@ gf_get_process_mode (char *exec_name)
|
||||
ret = GF_CLIENT_PROCESS;
|
||||
}
|
||||
|
||||
free (dup_execname);
|
||||
GF_FREE (dup_execname);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1110,9 +1121,9 @@ set_log_file_path (cmd_args_t *cmd_args)
|
||||
if (cmd_args->mount_point[i] == '/')
|
||||
tmp_str[j] = '-';
|
||||
}
|
||||
ret = asprintf (&cmd_args->log_file,
|
||||
DEFAULT_LOG_FILE_DIRECTORY "/%s.log",
|
||||
tmp_str);
|
||||
ret = gf_asprintf (&cmd_args->log_file,
|
||||
DEFAULT_LOG_FILE_DIRECTORY "/%s.log",
|
||||
tmp_str);
|
||||
if (-1 == ret) {
|
||||
gf_log ("glusterfsd", GF_LOG_ERROR,
|
||||
"asprintf failed while setting up log-file");
|
||||
@ -1130,7 +1141,7 @@ set_log_file_path (cmd_args_t *cmd_args)
|
||||
if (cmd_args->volume_file[i] == '/')
|
||||
tmp_str[j] = '-';
|
||||
}
|
||||
ret = asprintf (&cmd_args->log_file,
|
||||
ret = gf_asprintf (&cmd_args->log_file,
|
||||
DEFAULT_LOG_FILE_DIRECTORY "/%s.log",
|
||||
tmp_str);
|
||||
if (-1 == ret) {
|
||||
@ -1149,9 +1160,9 @@ set_log_file_path (cmd_args_t *cmd_args)
|
||||
if (cmd_args->volfile_id)
|
||||
tmp_ptr = cmd_args->volfile_id;
|
||||
|
||||
ret = asprintf (&cmd_args->log_file,
|
||||
DEFAULT_LOG_FILE_DIRECTORY "/%s-%s-%d.log",
|
||||
cmd_args->volfile_server, tmp_ptr, port);
|
||||
ret = gf_asprintf (&cmd_args->log_file,
|
||||
DEFAULT_LOG_FILE_DIRECTORY "/%s-%s-%d.log",
|
||||
cmd_args->volfile_server, tmp_ptr, port);
|
||||
if (-1 == ret) {
|
||||
gf_log ("glusterfsd", GF_LOG_ERROR,
|
||||
"asprintf failed while setting up log-file");
|
||||
@ -1190,6 +1201,10 @@ main (int argc, char *argv[])
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = xlator_mem_acct_init (THIS, gfd_mt_end);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
utime = time (NULL);
|
||||
ctx = glusterfs_ctx_get ();
|
||||
process_mode = gf_get_process_mode (argv[0]);
|
||||
@ -1215,9 +1230,9 @@ main (int argc, char *argv[])
|
||||
if ((cmd_args->volfile_server == NULL)
|
||||
&& (cmd_args->volume_file == NULL)) {
|
||||
if (process_mode == GF_SERVER_PROCESS)
|
||||
cmd_args->volume_file = strdup (DEFAULT_SERVER_VOLUME_FILE);
|
||||
cmd_args->volume_file = gf_strdup (DEFAULT_SERVER_VOLUME_FILE);
|
||||
else
|
||||
cmd_args->volume_file = strdup (DEFAULT_CLIENT_VOLUME_FILE);
|
||||
cmd_args->volume_file = gf_strdup (DEFAULT_CLIENT_VOLUME_FILE);
|
||||
}
|
||||
|
||||
if (cmd_args->log_file == NULL) {
|
||||
@ -1233,7 +1248,8 @@ main (int argc, char *argv[])
|
||||
ctx->iobuf_pool = iobuf_pool_new (8 * GF_UNIT_MB, ctx->page_size);
|
||||
ctx->event_pool = event_pool_new (DEFAULT_EVENT_POOL_SIZE);
|
||||
pthread_mutex_init (&(ctx->lock), NULL);
|
||||
pool = ctx->pool = CALLOC (1, sizeof (call_pool_t));
|
||||
pool = ctx->pool = GF_CALLOC (1, sizeof (call_pool_t),
|
||||
gfd_mt_call_pool_t);
|
||||
ERR_ABORT (ctx->pool);
|
||||
LOCK_INIT (&pool->lock);
|
||||
INIT_LIST_HEAD (&pool->all_frames);
|
||||
@ -1256,17 +1272,17 @@ main (int argc, char *argv[])
|
||||
/* Create symlink to actual log file */
|
||||
unlink (cmd_args->log_file);
|
||||
|
||||
tmp_logfile_dyn = strdup (tmp_logfile);
|
||||
tmp_logfile_dyn = gf_strdup (tmp_logfile);
|
||||
tmp_logfilebase = basename (tmp_logfile_dyn);
|
||||
ret = symlink (tmp_logfilebase, cmd_args->log_file);
|
||||
if (-1 == ret) {
|
||||
fprintf (stderr, "symlink of logfile failed");
|
||||
} else {
|
||||
FREE (cmd_args->log_file);
|
||||
cmd_args->log_file = strdup (tmp_logfile);
|
||||
GF_FREE (cmd_args->log_file);
|
||||
cmd_args->log_file = gf_strdup (tmp_logfile);
|
||||
}
|
||||
|
||||
FREE (tmp_logfile_dyn);
|
||||
GF_FREE (tmp_logfile_dyn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ init (dict_t *this,
|
||||
key = "addr";
|
||||
}
|
||||
|
||||
ret = asprintf (&auth_file, "%s/%s.so", LIBDIR, key);
|
||||
ret = gf_asprintf (&auth_file, "%s/%s.so", LIBDIR, key);
|
||||
if (-1 == ret) {
|
||||
gf_log ("authenticate", GF_LOG_ERROR, "asprintf failed");
|
||||
dict_set (this, key, data_from_dynptr (NULL, 0));
|
||||
@ -71,11 +71,11 @@ init (dict_t *this,
|
||||
gf_log ("authenticate", GF_LOG_ERROR, "dlopen(%s): %s\n",
|
||||
auth_file, dlerror ());
|
||||
dict_set (this, key, data_from_dynptr (NULL, 0));
|
||||
FREE (auth_file);
|
||||
GF_FREE (auth_file);
|
||||
*error = -1;
|
||||
return;
|
||||
}
|
||||
FREE (auth_file);
|
||||
GF_FREE (auth_file);
|
||||
|
||||
authenticate = dlsym (handle, "gf_auth");
|
||||
if (!authenticate) {
|
||||
@ -86,14 +86,16 @@ init (dict_t *this,
|
||||
return;
|
||||
}
|
||||
|
||||
auth_handle = CALLOC (1, sizeof (*auth_handle));
|
||||
auth_handle = GF_CALLOC (1, sizeof (*auth_handle),
|
||||
gf_common_mt_auth_handle_t);
|
||||
if (!auth_handle) {
|
||||
gf_log ("authenticate", GF_LOG_ERROR, "Out of memory");
|
||||
dict_set (this, key, data_from_dynptr (NULL, 0));
|
||||
*error = -1;
|
||||
return;
|
||||
}
|
||||
auth_handle->vol_opt = CALLOC (1, sizeof (volume_opt_list_t));
|
||||
auth_handle->vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t),
|
||||
gf_common_mt_volume_opt_list_t);
|
||||
auth_handle->vol_opt->given_opt = dlsym (handle, "options");
|
||||
if (auth_handle->vol_opt->given_opt == NULL) {
|
||||
gf_log ("authenticate", GF_LOG_DEBUG,
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "md5.h"
|
||||
#include "call-stub.h"
|
||||
#include "mem-types.h"
|
||||
|
||||
|
||||
static call_stub_t *
|
||||
@ -37,7 +38,7 @@ stub_new (call_frame_t *frame,
|
||||
|
||||
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
|
||||
|
||||
new = CALLOC (1, sizeof (*new));
|
||||
new = GF_CALLOC (1, sizeof (*new), gf_common_mt_call_stub_t);
|
||||
GF_VALIDATE_OR_GOTO ("call-stub", new, out);
|
||||
|
||||
new->frame = frame;
|
||||
@ -383,7 +384,7 @@ fop_readlink_cbk_stub (call_frame_t *frame,
|
||||
stub->args.readlink_cbk.op_ret = op_ret;
|
||||
stub->args.readlink_cbk.op_errno = op_errno;
|
||||
if (path)
|
||||
stub->args.readlink_cbk.buf = strdup (path);
|
||||
stub->args.readlink_cbk.buf = gf_strdup (path);
|
||||
if (sbuf)
|
||||
stub->args.readlink_cbk.sbuf = *sbuf;
|
||||
out:
|
||||
@ -614,7 +615,7 @@ fop_symlink_stub (call_frame_t *frame,
|
||||
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
|
||||
|
||||
stub->args.symlink.fn = fn;
|
||||
stub->args.symlink.linkname = strdup (linkname);
|
||||
stub->args.symlink.linkname = gf_strdup (linkname);
|
||||
loc_copy (&stub->args.symlink.loc, loc);
|
||||
out:
|
||||
return stub;
|
||||
@ -1291,7 +1292,7 @@ fop_getxattr_stub (call_frame_t *frame,
|
||||
loc_copy (&stub->args.getxattr.loc, loc);
|
||||
|
||||
if (name)
|
||||
stub->args.getxattr.name = strdup (name);
|
||||
stub->args.getxattr.name = gf_strdup (name);
|
||||
out:
|
||||
return stub;
|
||||
}
|
||||
@ -1388,7 +1389,7 @@ fop_fgetxattr_stub (call_frame_t *frame,
|
||||
stub->args.fgetxattr.fd = fd_ref (fd);
|
||||
|
||||
if (name)
|
||||
stub->args.fgetxattr.name = strdup (name);
|
||||
stub->args.fgetxattr.name = gf_strdup (name);
|
||||
out:
|
||||
return stub;
|
||||
}
|
||||
@ -1437,7 +1438,7 @@ fop_removexattr_stub (call_frame_t *frame,
|
||||
|
||||
stub->args.removexattr.fn = fn;
|
||||
loc_copy (&stub->args.removexattr.loc, loc);
|
||||
stub->args.removexattr.name = strdup (name);
|
||||
stub->args.removexattr.name = gf_strdup (name);
|
||||
out:
|
||||
return stub;
|
||||
}
|
||||
@ -1529,7 +1530,7 @@ fop_inodelk_stub (call_frame_t *frame, fop_inodelk_t fn,
|
||||
stub->args.inodelk.fn = fn;
|
||||
|
||||
if (volume)
|
||||
stub->args.inodelk.volume = strdup (volume);
|
||||
stub->args.inodelk.volume = gf_strdup (volume);
|
||||
|
||||
loc_copy (&stub->args.inodelk.loc, loc);
|
||||
stub->args.inodelk.cmd = cmd;
|
||||
@ -1578,7 +1579,7 @@ fop_finodelk_stub (call_frame_t *frame, fop_finodelk_t fn,
|
||||
stub->args.finodelk.fd = fd_ref (fd);
|
||||
|
||||
if (volume)
|
||||
stub->args.finodelk.volume = strdup (volume);
|
||||
stub->args.finodelk.volume = gf_strdup (volume);
|
||||
|
||||
stub->args.finodelk.cmd = cmd;
|
||||
stub->args.finodelk.lock = *lock;
|
||||
@ -1625,14 +1626,14 @@ fop_entrylk_stub (call_frame_t *frame, fop_entrylk_t fn,
|
||||
stub->args.entrylk.fn = fn;
|
||||
|
||||
if (volume)
|
||||
stub->args.entrylk.volume = strdup (volume);
|
||||
stub->args.entrylk.volume = gf_strdup (volume);
|
||||
|
||||
loc_copy (&stub->args.entrylk.loc, loc);
|
||||
|
||||
stub->args.entrylk.cmd = cmd;
|
||||
stub->args.entrylk.type = type;
|
||||
if (name)
|
||||
stub->args.entrylk.name = strdup (name);
|
||||
stub->args.entrylk.name = gf_strdup (name);
|
||||
|
||||
return stub;
|
||||
}
|
||||
@ -1675,14 +1676,14 @@ fop_fentrylk_stub (call_frame_t *frame, fop_fentrylk_t fn,
|
||||
stub->args.fentrylk.fn = fn;
|
||||
|
||||
if (volume)
|
||||
stub->args.fentrylk.volume = strdup (volume);
|
||||
stub->args.fentrylk.volume = gf_strdup (volume);
|
||||
|
||||
if (fd)
|
||||
stub->args.fentrylk.fd = fd_ref (fd);
|
||||
stub->args.fentrylk.cmd = cmd;
|
||||
stub->args.fentrylk.type = type;
|
||||
if (name)
|
||||
stub->args.fentrylk.name = strdup (name);
|
||||
stub->args.fentrylk.name = gf_strdup (name);
|
||||
|
||||
return stub;
|
||||
}
|
||||
@ -3222,8 +3223,8 @@ call_resume_unwind (call_stub_t *stub)
|
||||
stub->args.checksum_cbk.dir_checksum);
|
||||
if (stub->args.checksum_cbk.op_ret >= 0)
|
||||
{
|
||||
FREE (stub->args.checksum_cbk.file_checksum);
|
||||
FREE (stub->args.checksum_cbk.dir_checksum);
|
||||
GF_FREE (stub->args.checksum_cbk.file_checksum);
|
||||
GF_FREE (stub->args.checksum_cbk.dir_checksum);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -3247,7 +3248,7 @@ call_resume_unwind (call_stub_t *stub)
|
||||
stub->args.rchecksum_cbk.strong_checksum);
|
||||
if (stub->args.rchecksum_cbk.op_ret >= 0)
|
||||
{
|
||||
FREE (stub->args.rchecksum_cbk.strong_checksum);
|
||||
GF_FREE (stub->args.rchecksum_cbk.strong_checksum);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -3438,7 +3439,7 @@ call_stub_destroy_wind (call_stub_t *stub)
|
||||
|
||||
case GF_FOP_SYMLINK:
|
||||
{
|
||||
FREE (stub->args.symlink.linkname);
|
||||
GF_FREE ((char *)stub->args.symlink.linkname);
|
||||
loc_wipe (&stub->args.symlink.loc);
|
||||
}
|
||||
break;
|
||||
@ -3475,7 +3476,7 @@ call_stub_destroy_wind (call_stub_t *stub)
|
||||
struct iobref *iobref = stub->args.writev.iobref;
|
||||
if (stub->args.writev.fd)
|
||||
fd_unref (stub->args.writev.fd);
|
||||
FREE (stub->args.writev.vector);
|
||||
GF_FREE (stub->args.writev.vector);
|
||||
if (iobref)
|
||||
iobref_unref (iobref);
|
||||
break;
|
||||
@ -3511,7 +3512,7 @@ call_stub_destroy_wind (call_stub_t *stub)
|
||||
case GF_FOP_GETXATTR:
|
||||
{
|
||||
if (stub->args.getxattr.name)
|
||||
FREE (stub->args.getxattr.name);
|
||||
GF_FREE ((char *)stub->args.getxattr.name);
|
||||
loc_wipe (&stub->args.getxattr.loc);
|
||||
break;
|
||||
}
|
||||
@ -3527,7 +3528,7 @@ call_stub_destroy_wind (call_stub_t *stub)
|
||||
case GF_FOP_FGETXATTR:
|
||||
{
|
||||
if (stub->args.fgetxattr.name)
|
||||
FREE (stub->args.fgetxattr.name);
|
||||
GF_FREE ((char *)stub->args.fgetxattr.name);
|
||||
fd_unref (stub->args.fgetxattr.fd);
|
||||
break;
|
||||
}
|
||||
@ -3535,7 +3536,7 @@ call_stub_destroy_wind (call_stub_t *stub)
|
||||
case GF_FOP_REMOVEXATTR:
|
||||
{
|
||||
loc_wipe (&stub->args.removexattr.loc);
|
||||
FREE (stub->args.removexattr.name);
|
||||
GF_FREE ((char *)stub->args.removexattr.name);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3584,7 +3585,7 @@ call_stub_destroy_wind (call_stub_t *stub)
|
||||
case GF_FOP_INODELK:
|
||||
{
|
||||
if (stub->args.inodelk.volume)
|
||||
FREE (stub->args.inodelk.volume);
|
||||
GF_FREE ((char *)stub->args.inodelk.volume);
|
||||
|
||||
loc_wipe (&stub->args.inodelk.loc);
|
||||
break;
|
||||
@ -3592,7 +3593,7 @@ call_stub_destroy_wind (call_stub_t *stub)
|
||||
case GF_FOP_FINODELK:
|
||||
{
|
||||
if (stub->args.finodelk.volume)
|
||||
FREE (stub->args.finodelk.volume);
|
||||
GF_FREE ((char *)stub->args.finodelk.volume);
|
||||
|
||||
if (stub->args.finodelk.fd)
|
||||
fd_unref (stub->args.finodelk.fd);
|
||||
@ -3601,20 +3602,20 @@ call_stub_destroy_wind (call_stub_t *stub)
|
||||
case GF_FOP_ENTRYLK:
|
||||
{
|
||||
if (stub->args.entrylk.volume)
|
||||
FREE (stub->args.entrylk.volume);
|
||||
GF_FREE ((char *)stub->args.entrylk.volume);
|
||||
|
||||
if (stub->args.entrylk.name)
|
||||
FREE (stub->args.entrylk.name);
|
||||
GF_FREE ((char *)stub->args.entrylk.name);
|
||||
loc_wipe (&stub->args.entrylk.loc);
|
||||
break;
|
||||
}
|
||||
case GF_FOP_FENTRYLK:
|
||||
{
|
||||
if (stub->args.fentrylk.volume)
|
||||
FREE (stub->args.fentrylk.volume);
|
||||
GF_FREE ((char *)stub->args.fentrylk.volume);
|
||||
|
||||
if (stub->args.fentrylk.name)
|
||||
FREE (stub->args.fentrylk.name);
|
||||
GF_FREE ((char *)stub->args.fentrylk.name);
|
||||
|
||||
if (stub->args.fentrylk.fd)
|
||||
fd_unref (stub->args.fentrylk.fd);
|
||||
@ -3717,7 +3718,7 @@ call_stub_destroy_unwind (call_stub_t *stub)
|
||||
case GF_FOP_READLINK:
|
||||
{
|
||||
if (stub->args.readlink_cbk.buf)
|
||||
FREE (stub->args.readlink_cbk.buf);
|
||||
GF_FREE ((char *)stub->args.readlink_cbk.buf);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -3765,7 +3766,7 @@ call_stub_destroy_unwind (call_stub_t *stub)
|
||||
{
|
||||
if (stub->args.readv_cbk.op_ret >= 0) {
|
||||
struct iobref *iobref = stub->args.readv_cbk.iobref;
|
||||
FREE (stub->args.readv_cbk.vector);
|
||||
GF_FREE (stub->args.readv_cbk.vector);
|
||||
|
||||
if (iobref) {
|
||||
iobref_unref (iobref);
|
||||
@ -3856,8 +3857,8 @@ call_stub_destroy_unwind (call_stub_t *stub)
|
||||
case GF_FOP_CHECKSUM:
|
||||
{
|
||||
if (stub->args.checksum_cbk.op_ret >= 0) {
|
||||
FREE (stub->args.checksum_cbk.file_checksum);
|
||||
FREE (stub->args.checksum_cbk.dir_checksum);
|
||||
GF_FREE (stub->args.checksum_cbk.file_checksum);
|
||||
GF_FREE (stub->args.checksum_cbk.dir_checksum);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -3865,7 +3866,7 @@ call_stub_destroy_unwind (call_stub_t *stub)
|
||||
case GF_FOP_RCHECKSUM:
|
||||
{
|
||||
if (stub->args.rchecksum_cbk.op_ret >= 0) {
|
||||
FREE (stub->args.rchecksum_cbk.strong_checksum);
|
||||
GF_FREE (stub->args.rchecksum_cbk.strong_checksum);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -3931,7 +3932,7 @@ call_stub_destroy (call_stub_t *stub)
|
||||
call_stub_destroy_unwind (stub);
|
||||
}
|
||||
|
||||
FREE (stub);
|
||||
GF_FREE (stub);
|
||||
out:
|
||||
return;
|
||||
}
|
||||
|
@ -89,7 +89,8 @@ gf_resolve_ip6 (const char *hostname,
|
||||
}
|
||||
|
||||
if (!*dnscache) {
|
||||
*dnscache = CALLOC (1, sizeof (struct dnscache6));
|
||||
*dnscache = GF_CALLOC (1, sizeof (struct dnscache6),
|
||||
gf_common_mt_dnscache6);
|
||||
}
|
||||
|
||||
cache = *dnscache;
|
||||
@ -111,7 +112,7 @@ gf_resolve_ip6 (const char *hostname,
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_ADDRCONFIG;
|
||||
|
||||
ret = asprintf (&port_str, "%d", port);
|
||||
ret = gf_asprintf (&port_str, "%d", port);
|
||||
if (-1 == ret) {
|
||||
gf_log ("resolver", GF_LOG_ERROR, "asprintf failed");
|
||||
return -1;
|
||||
@ -120,12 +121,12 @@ gf_resolve_ip6 (const char *hostname,
|
||||
gf_log ("resolver", GF_LOG_ERROR,
|
||||
"getaddrinfo failed (%s)", gai_strerror (ret));
|
||||
|
||||
free (*dnscache);
|
||||
GF_FREE (*dnscache);
|
||||
*dnscache = NULL;
|
||||
free (port_str);
|
||||
GF_FREE (port_str);
|
||||
return -1;
|
||||
}
|
||||
free (port_str);
|
||||
GF_FREE (port_str);
|
||||
|
||||
cache->next = cache->first;
|
||||
}
|
||||
@ -173,7 +174,7 @@ gf_resolve_ip6 (const char *hostname,
|
||||
err:
|
||||
freeaddrinfo (cache->first);
|
||||
cache->first = cache->next = NULL;
|
||||
free (cache);
|
||||
GF_FREE (cache);
|
||||
*dnscache = NULL;
|
||||
return -1;
|
||||
}
|
||||
@ -509,7 +510,8 @@ gf_strsplit (const char *str, const char *delim,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((_running = strdup (str)) == NULL)
|
||||
_running = gf_strdup (str);
|
||||
if (_running == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@ -520,17 +522,19 @@ gf_strsplit (const char *str, const char *delim,
|
||||
if (token[0] != '\0')
|
||||
count++;
|
||||
}
|
||||
free (_running);
|
||||
GF_FREE (_running);
|
||||
|
||||
if ((_running = strdup (str)) == NULL)
|
||||
_running = gf_strdup (str);
|
||||
if (_running == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
running = _running;
|
||||
|
||||
if ((token_list = CALLOC (count, sizeof (char *))) == NULL)
|
||||
if ((token_list = GF_CALLOC (count, sizeof (char *),
|
||||
gf_common_mt_char)) == NULL)
|
||||
{
|
||||
free (_running);
|
||||
GF_FREE (_running);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -539,23 +543,25 @@ gf_strsplit (const char *str, const char *delim,
|
||||
if (token[0] == '\0')
|
||||
continue;
|
||||
|
||||
if ((token_list[i++] = strdup (token)) == NULL)
|
||||
token_list[i] = gf_strdup (token);
|
||||
if (token_list[i] == NULL)
|
||||
goto free_exit;
|
||||
i++;
|
||||
}
|
||||
|
||||
free (_running);
|
||||
GF_FREE (_running);
|
||||
|
||||
*tokens = token_list;
|
||||
*token_count = count;
|
||||
return 0;
|
||||
|
||||
free_exit:
|
||||
free (_running);
|
||||
GF_FREE (_running);
|
||||
for (j = 0; j < i; j++)
|
||||
{
|
||||
free (token_list[j]);
|
||||
GF_FREE (token_list[j]);
|
||||
}
|
||||
free (token_list);
|
||||
GF_FREE (token_list);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ iov_free (struct iovec *vector, int count)
|
||||
for (i = 0; i < count; i++)
|
||||
FREE (vector[i].iov_base);
|
||||
|
||||
FREE (vector);
|
||||
GF_FREE (vector);
|
||||
}
|
||||
|
||||
|
||||
@ -172,7 +172,7 @@ iov_dup (struct iovec *vector, int count)
|
||||
struct iovec *newvec = NULL;
|
||||
|
||||
bytecount = (count * sizeof (struct iovec));
|
||||
newvec = MALLOC (bytecount);
|
||||
newvec = GF_MALLOC (bytecount, gf_common_mt_iovec);
|
||||
if (!newvec)
|
||||
return NULL;
|
||||
|
||||
@ -282,7 +282,7 @@ memdup (const void *ptr, size_t size)
|
||||
{
|
||||
void *newptr = NULL;
|
||||
|
||||
newptr = MALLOC (size);
|
||||
newptr = GF_MALLOC (size, gf_common_mt_memdup);
|
||||
if (!newptr)
|
||||
return NULL;
|
||||
|
||||
|
@ -1383,3 +1383,13 @@ default_fsetattr (call_frame_t *frame,
|
||||
fd, stbuf, valid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t
|
||||
default_mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
ret = xlator_mem_acct_init (this, gf_common_mt_end);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -432,4 +432,6 @@ default_writev_cbk (call_frame_t *frame,
|
||||
struct iatt *prebuf,
|
||||
struct iatt *postbuf);
|
||||
|
||||
int32_t
|
||||
default_mem_acct_init (xlator_t *this);
|
||||
#endif /* _DEFAULTS_H */
|
||||
|
@ -41,7 +41,8 @@ get_new_data_pair ()
|
||||
{
|
||||
data_pair_t *data_pair_ptr = NULL;
|
||||
|
||||
data_pair_ptr = (data_pair_t *) CALLOC (1, sizeof (data_pair_t));
|
||||
data_pair_ptr = (data_pair_t *) GF_CALLOC (1, sizeof (data_pair_t),
|
||||
gf_common_mt_data_pair_t);
|
||||
ERR_ABORT (data_pair_ptr);
|
||||
|
||||
return data_pair_ptr;
|
||||
@ -52,7 +53,7 @@ get_new_data ()
|
||||
{
|
||||
data_t *data = NULL;
|
||||
|
||||
data = (data_t *) CALLOC (1, sizeof (data_t));
|
||||
data = (data_t *) GF_CALLOC (1, sizeof (data_t), gf_common_mt_data_t);
|
||||
if (!data) {
|
||||
gf_log ("dict", GF_LOG_CRITICAL,
|
||||
"calloc () returned NULL");
|
||||
@ -66,7 +67,7 @@ get_new_data ()
|
||||
dict_t *
|
||||
get_new_dict_full (int size_hint)
|
||||
{
|
||||
dict_t *dict = CALLOC (1, sizeof (dict_t));
|
||||
dict_t *dict = GF_CALLOC (1, sizeof (dict_t), gf_common_mt_dict_t);
|
||||
|
||||
if (!dict) {
|
||||
gf_log ("dict", GF_LOG_CRITICAL,
|
||||
@ -75,7 +76,8 @@ get_new_dict_full (int size_hint)
|
||||
}
|
||||
|
||||
dict->hash_size = size_hint;
|
||||
dict->members = CALLOC (size_hint, sizeof (data_pair_t *));
|
||||
dict->members = GF_CALLOC (size_hint, sizeof (data_pair_t *),
|
||||
gf_common_mt_data_pair_t);
|
||||
|
||||
if (!dict->members) {
|
||||
gf_log ("dict", GF_LOG_CRITICAL,
|
||||
@ -138,14 +140,14 @@ data_destroy (data_t *data)
|
||||
|
||||
if (!data->is_static) {
|
||||
if (data->data)
|
||||
FREE (data->data);
|
||||
GF_FREE (data->data);
|
||||
if (data->vec)
|
||||
FREE (data->vec);
|
||||
GF_FREE (data->vec);
|
||||
}
|
||||
|
||||
data->len = 0xbabababa;
|
||||
if (!data->is_const)
|
||||
FREE (data);
|
||||
GF_FREE (data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,7 +160,8 @@ data_copy (data_t *old)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data_t *newdata = (data_t *) CALLOC (1, sizeof (*newdata));
|
||||
data_t *newdata = (data_t *) GF_CALLOC (1, sizeof (*newdata),
|
||||
gf_common_mt_data_t);
|
||||
|
||||
if (!newdata) {
|
||||
gf_log ("dict", GF_LOG_CRITICAL,
|
||||
@ -229,7 +232,7 @@ _dict_set (dict_t *this,
|
||||
int ret = 0;
|
||||
|
||||
if (!key) {
|
||||
ret = asprintf (&key, "ref:%p", value);
|
||||
ret = gf_asprintf (&key, "ref:%p", value);
|
||||
if (-1 == ret) {
|
||||
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
|
||||
return -1;
|
||||
@ -246,18 +249,20 @@ _dict_set (dict_t *this,
|
||||
pair->value = data_ref (value);
|
||||
data_unref (unref_data);
|
||||
if (key_free)
|
||||
FREE (key);
|
||||
GF_FREE (key);
|
||||
/* Indicates duplicate key */
|
||||
return 0;
|
||||
}
|
||||
pair = (data_pair_t *) CALLOC (1, sizeof (*pair));
|
||||
pair = (data_pair_t *) GF_CALLOC (1, sizeof (*pair),
|
||||
gf_common_mt_data_pair_t);
|
||||
if (!pair) {
|
||||
gf_log ("dict", GF_LOG_CRITICAL,
|
||||
"@pair - NULL returned by CALLOC");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pair->key = (char *) CALLOC (1, strlen (key) + 1);
|
||||
pair->key = (char *) GF_CALLOC (1, strlen (key) + 1,
|
||||
gf_common_mt_char);
|
||||
if (!pair->key) {
|
||||
gf_log ("dict", GF_LOG_CRITICAL,
|
||||
"@pair->key - NULL returned by CALLOC");
|
||||
@ -280,7 +285,7 @@ _dict_set (dict_t *this,
|
||||
this->count++;
|
||||
|
||||
if (key_free)
|
||||
FREE (key);
|
||||
GF_FREE (key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -364,8 +369,8 @@ dict_del (dict_t *this,
|
||||
if (pair->next)
|
||||
pair->next->prev = pair->prev;
|
||||
|
||||
FREE (pair->key);
|
||||
FREE (pair);
|
||||
GF_FREE (pair->key);
|
||||
GF_FREE (pair);
|
||||
this->count--;
|
||||
break;
|
||||
}
|
||||
@ -396,18 +401,18 @@ dict_destroy (dict_t *this)
|
||||
while (prev) {
|
||||
pair = pair->next;
|
||||
data_unref (prev->value);
|
||||
FREE (prev->key);
|
||||
FREE (prev);
|
||||
GF_FREE (prev->key);
|
||||
GF_FREE (prev);
|
||||
prev = pair;
|
||||
}
|
||||
|
||||
FREE (this->members);
|
||||
GF_FREE (this->members);
|
||||
|
||||
if (this->extra_free)
|
||||
FREE (this->extra_free);
|
||||
GF_FREE (this->extra_free);
|
||||
|
||||
if (!this->is_static)
|
||||
FREE (this);
|
||||
GF_FREE (this);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -630,7 +635,7 @@ dict_unserialize_old (char *buf, int32_t size, dict_t **fill)
|
||||
goto ret;
|
||||
|
||||
err:
|
||||
FREE (*fill);
|
||||
GF_FREE (*fill);
|
||||
*fill = NULL;
|
||||
|
||||
ret:
|
||||
@ -744,7 +749,7 @@ int_to_data (int64_t value)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = asprintf (&data->data, "%"PRId64, value);
|
||||
ret = gf_asprintf (&data->data, "%"PRId64, value);
|
||||
if (-1 == ret) {
|
||||
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
|
||||
return NULL;
|
||||
@ -765,7 +770,7 @@ data_from_int64 (int64_t value)
|
||||
"@data - NULL returned by CALLOC");
|
||||
return NULL;
|
||||
}
|
||||
ret = asprintf (&data->data, "%"PRId64, value);
|
||||
ret = gf_asprintf (&data->data, "%"PRId64, value);
|
||||
if (-1 == ret) {
|
||||
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
|
||||
return NULL;
|
||||
@ -786,7 +791,7 @@ data_from_int32 (int32_t value)
|
||||
"@data - NULL returned by CALLOC");
|
||||
return NULL;
|
||||
}
|
||||
ret = asprintf (&data->data, "%"PRId32, value);
|
||||
ret = gf_asprintf (&data->data, "%"PRId32, value);
|
||||
if (-1 == ret) {
|
||||
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
|
||||
return NULL;
|
||||
@ -808,7 +813,7 @@ data_from_int16 (int16_t value)
|
||||
"@data - NULL returned by CALLOC");
|
||||
return NULL;
|
||||
}
|
||||
ret = asprintf (&data->data, "%"PRId16, value);
|
||||
ret = gf_asprintf (&data->data, "%"PRId16, value);
|
||||
if (-1 == ret) {
|
||||
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
|
||||
return NULL;
|
||||
@ -830,7 +835,7 @@ data_from_int8 (int8_t value)
|
||||
"@data - NULL returned by CALLOC");
|
||||
return NULL;
|
||||
}
|
||||
ret = asprintf (&data->data, "%d", value);
|
||||
ret = gf_asprintf (&data->data, "%d", value);
|
||||
if (-1 == ret) {
|
||||
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
|
||||
return NULL;
|
||||
@ -852,7 +857,7 @@ data_from_uint64 (uint64_t value)
|
||||
"@data - NULL returned by CALLOC");
|
||||
return NULL;
|
||||
}
|
||||
ret = asprintf (&data->data, "%"PRIu64, value);
|
||||
ret = gf_asprintf (&data->data, "%"PRIu64, value);
|
||||
if (-1 == ret) {
|
||||
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
|
||||
return NULL;
|
||||
@ -877,7 +882,7 @@ data_from_double (double value)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = asprintf (&data->data, "%f", value);
|
||||
ret = gf_asprintf (&data->data, "%f", value);
|
||||
if (ret == -1) {
|
||||
gf_log ("dict", GF_LOG_CRITICAL,
|
||||
"@data - allocation failed by ASPRINTF");
|
||||
@ -900,7 +905,7 @@ data_from_uint32 (uint32_t value)
|
||||
"@data - NULL returned by CALLOC");
|
||||
return NULL;
|
||||
}
|
||||
ret = asprintf (&data->data, "%"PRIu32, value);
|
||||
ret = gf_asprintf (&data->data, "%"PRIu32, value);
|
||||
if (-1 == ret) {
|
||||
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
|
||||
return NULL;
|
||||
@ -923,7 +928,7 @@ data_from_uint16 (uint16_t value)
|
||||
"@data - NULL returned by CALLOC");
|
||||
return NULL;
|
||||
}
|
||||
ret = asprintf (&data->data, "%"PRIu16, value);
|
||||
ret = gf_asprintf (&data->data, "%"PRIu16, value);
|
||||
if (-1 == ret) {
|
||||
gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
|
||||
return NULL;
|
||||
@ -2513,7 +2518,7 @@ dict_allocate_and_serialize (dict_t *this, char **buf, size_t *length)
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
*buf = CALLOC (1, len);
|
||||
*buf = GF_CALLOC (1, len, gf_common_mt_char);
|
||||
if (*buf == NULL) {
|
||||
ret = -ENOMEM;
|
||||
gf_log ("dict", GF_LOG_ERROR, "out of memory");
|
||||
@ -2522,7 +2527,7 @@ dict_allocate_and_serialize (dict_t *this, char **buf, size_t *length)
|
||||
|
||||
ret = _dict_serialize (this, *buf);
|
||||
if (ret < 0) {
|
||||
FREE (*buf);
|
||||
GF_FREE (*buf);
|
||||
*buf = NULL;
|
||||
goto unlock;
|
||||
}
|
||||
|
@ -97,19 +97,21 @@ event_pool_new_poll (int count)
|
||||
struct event_pool *event_pool = NULL;
|
||||
int ret = -1;
|
||||
|
||||
event_pool = CALLOC (1, sizeof (*event_pool));
|
||||
event_pool = GF_CALLOC (1, sizeof (*event_pool),
|
||||
gf_common_mt_event_pool);
|
||||
|
||||
if (!event_pool)
|
||||
return NULL;
|
||||
|
||||
event_pool->count = count;
|
||||
event_pool->reg = CALLOC (event_pool->count,
|
||||
sizeof (*event_pool->reg));
|
||||
event_pool->reg = GF_CALLOC (event_pool->count,
|
||||
sizeof (*event_pool->reg),
|
||||
gf_common_mt_reg);
|
||||
|
||||
if (!event_pool->reg) {
|
||||
gf_log ("poll", GF_LOG_CRITICAL,
|
||||
"failed to allocate event registry");
|
||||
free (event_pool);
|
||||
GF_FREE (event_pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -120,8 +122,8 @@ event_pool_new_poll (int count)
|
||||
if (ret == -1) {
|
||||
gf_log ("poll", GF_LOG_ERROR,
|
||||
"pipe creation failed (%s)", strerror (errno));
|
||||
free (event_pool->reg);
|
||||
free (event_pool);
|
||||
GF_FREE (event_pool->reg);
|
||||
GF_FREE (event_pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -134,8 +136,8 @@ event_pool_new_poll (int count)
|
||||
close (event_pool->breaker[1]);
|
||||
event_pool->breaker[0] = event_pool->breaker[1] = -1;
|
||||
|
||||
free (event_pool->reg);
|
||||
free (event_pool);
|
||||
GF_FREE (event_pool->reg);
|
||||
GF_FREE (event_pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -149,8 +151,8 @@ event_pool_new_poll (int count)
|
||||
close (event_pool->breaker[1]);
|
||||
event_pool->breaker[0] = event_pool->breaker[1] = -1;
|
||||
|
||||
free (event_pool->reg);
|
||||
free (event_pool);
|
||||
GF_FREE (event_pool->reg);
|
||||
GF_FREE (event_pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -163,8 +165,8 @@ event_pool_new_poll (int count)
|
||||
close (event_pool->breaker[1]);
|
||||
event_pool->breaker[0] = event_pool->breaker[1] = -1;
|
||||
|
||||
free (event_pool->reg);
|
||||
free (event_pool);
|
||||
GF_FREE (event_pool->reg);
|
||||
GF_FREE (event_pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -190,9 +192,9 @@ event_register_poll (struct event_pool *event_pool, int fd,
|
||||
{
|
||||
event_pool->count += 256;
|
||||
|
||||
event_pool->reg = realloc (event_pool->reg,
|
||||
event_pool->count *
|
||||
sizeof (*event_pool->reg));
|
||||
event_pool->reg = GF_REALLOC (event_pool->reg,
|
||||
event_pool->count *
|
||||
sizeof (*event_pool->reg));
|
||||
}
|
||||
|
||||
idx = event_pool->used++;
|
||||
@ -392,14 +394,15 @@ event_dispatch_poll_resize (struct event_pool *event_pool,
|
||||
|
||||
if (event_pool->used > event_pool->evcache_size) {
|
||||
if (event_pool->evcache)
|
||||
free (event_pool->evcache);
|
||||
GF_FREE (event_pool->evcache);
|
||||
|
||||
event_pool->evcache = ufds = NULL;
|
||||
|
||||
event_pool->evcache_size = event_pool->used;
|
||||
|
||||
ufds = CALLOC (sizeof (struct pollfd),
|
||||
event_pool->evcache_size);
|
||||
ufds = GF_CALLOC (sizeof (struct pollfd),
|
||||
event_pool->evcache_size,
|
||||
gf_common_mt_pollfd);
|
||||
event_pool->evcache = ufds;
|
||||
}
|
||||
|
||||
@ -478,19 +481,21 @@ event_pool_new_epoll (int count)
|
||||
struct event_pool *event_pool = NULL;
|
||||
int epfd = -1;
|
||||
|
||||
event_pool = CALLOC (1, sizeof (*event_pool));
|
||||
event_pool = GF_CALLOC (1, sizeof (*event_pool),
|
||||
gf_common_mt_event_pool);
|
||||
|
||||
if (!event_pool)
|
||||
return NULL;
|
||||
|
||||
event_pool->count = count;
|
||||
event_pool->reg = CALLOC (event_pool->count,
|
||||
sizeof (*event_pool->reg));
|
||||
event_pool->reg = GF_CALLOC (event_pool->count,
|
||||
sizeof (*event_pool->reg),
|
||||
gf_common_mt_reg);
|
||||
|
||||
if (!event_pool->reg) {
|
||||
gf_log ("epoll", GF_LOG_CRITICAL,
|
||||
"event registry allocation failed");
|
||||
free (event_pool);
|
||||
GF_FREE (event_pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -499,8 +504,8 @@ event_pool_new_epoll (int count)
|
||||
if (epfd == -1) {
|
||||
gf_log ("epoll", GF_LOG_ERROR, "epoll fd creation failed (%s)",
|
||||
strerror (errno));
|
||||
free (event_pool->reg);
|
||||
free (event_pool);
|
||||
GF_FREE (event_pool->reg);
|
||||
GF_FREE (event_pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -536,7 +541,7 @@ event_register_epoll (struct event_pool *event_pool, int fd,
|
||||
if (event_pool->count == event_pool->used) {
|
||||
event_pool->count *= 2;
|
||||
|
||||
event_pool->reg = realloc (event_pool->reg,
|
||||
event_pool->reg = GF_REALLOC (event_pool->reg,
|
||||
event_pool->count *
|
||||
sizeof (*event_pool->reg));
|
||||
|
||||
@ -832,15 +837,16 @@ event_dispatch_epoll (struct event_pool *event_pool)
|
||||
|
||||
if (event_pool->used > event_pool->evcache_size) {
|
||||
if (event_pool->evcache)
|
||||
free (event_pool->evcache);
|
||||
GF_FREE (event_pool->evcache);
|
||||
|
||||
event_pool->evcache = events = NULL;
|
||||
|
||||
event_pool->evcache_size =
|
||||
event_pool->used + 256;
|
||||
|
||||
events = CALLOC (event_pool->evcache_size,
|
||||
sizeof (struct epoll_event));
|
||||
events = GF_CALLOC (event_pool->evcache_size,
|
||||
sizeof (struct epoll_event),
|
||||
gf_common_mt_epoll_event);
|
||||
|
||||
event_pool->evcache = events;
|
||||
}
|
||||
|
@ -99,7 +99,8 @@ gf_fd_fdtable_expand (fdtable_t *fdtable, uint32_t nr)
|
||||
oldfds = fdtable->fdentries;
|
||||
oldmax_fds = fdtable->max_fds;
|
||||
|
||||
fdtable->fdentries = CALLOC (nr, sizeof (fdentry_t));
|
||||
fdtable->fdentries = GF_CALLOC (nr, sizeof (fdentry_t),
|
||||
gf_common_mt_fdentry_t);
|
||||
ERR_ABORT (fdtable->fdentries);
|
||||
fdtable->max_fds = nr;
|
||||
|
||||
@ -116,7 +117,7 @@ gf_fd_fdtable_expand (fdtable_t *fdtable, uint32_t nr)
|
||||
* using the expanded table.
|
||||
*/
|
||||
fdtable->first_free = oldmax_fds;
|
||||
FREE (oldfds);
|
||||
GF_FREE (oldfds);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -125,7 +126,7 @@ gf_fd_fdtable_alloc (void)
|
||||
{
|
||||
fdtable_t *fdtable = NULL;
|
||||
|
||||
fdtable = CALLOC (1, sizeof (*fdtable));
|
||||
fdtable = GF_CALLOC (1, sizeof (*fdtable), gf_common_mt_fdtable_t);
|
||||
if (!fdtable)
|
||||
return NULL;
|
||||
|
||||
@ -150,7 +151,8 @@ __gf_fd_fdtable_get_all_fds (fdtable_t *fdtable, uint32_t *count)
|
||||
}
|
||||
|
||||
fdentries = fdtable->fdentries;
|
||||
fdtable->fdentries = calloc (fdtable->max_fds, sizeof (fdentry_t));
|
||||
fdtable->fdentries = GF_CALLOC (fdtable->max_fds, sizeof (fdentry_t),
|
||||
gf_common_mt_fdentry_t);
|
||||
gf_fd_chain_fd_entries (fdtable->fdentries, 0, fdtable->max_fds);
|
||||
*count = fdtable->max_fds;
|
||||
|
||||
@ -190,7 +192,7 @@ gf_fd_fdtable_destroy (fdtable_t *fdtable)
|
||||
pthread_mutex_lock (&fdtable->lock);
|
||||
{
|
||||
fdentries = __gf_fd_fdtable_get_all_fds (fdtable, &fd_count);
|
||||
FREE (fdtable->fdentries);
|
||||
GF_FREE (fdtable->fdentries);
|
||||
}
|
||||
pthread_mutex_unlock (&fdtable->lock);
|
||||
|
||||
@ -202,9 +204,9 @@ gf_fd_fdtable_destroy (fdtable_t *fdtable)
|
||||
}
|
||||
}
|
||||
|
||||
FREE (fdentries);
|
||||
GF_FREE (fdentries);
|
||||
pthread_mutex_destroy (&fdtable->lock);
|
||||
FREE (fdtable);
|
||||
GF_FREE (fdtable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -425,10 +427,10 @@ fd_destroy (fd_t *fd)
|
||||
|
||||
LOCK_DESTROY (&fd->lock);
|
||||
|
||||
FREE (fd->_ctx);
|
||||
GF_FREE (fd->_ctx);
|
||||
inode_unref (fd->inode);
|
||||
fd->inode = (inode_t *)0xaaaaaaaa;
|
||||
FREE (fd);
|
||||
GF_FREE (fd);
|
||||
|
||||
out:
|
||||
return;
|
||||
@ -488,11 +490,12 @@ fd_create (inode_t *inode, pid_t pid)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fd = CALLOC (1, sizeof (fd_t));
|
||||
fd = GF_CALLOC (1, sizeof (fd_t), gf_common_mt_fd_t);
|
||||
ERR_ABORT (fd);
|
||||
|
||||
fd->_ctx = CALLOC (1, (sizeof (struct _fd_ctx) *
|
||||
inode->table->xl->ctx->xl_count));
|
||||
fd->_ctx = GF_CALLOC (1, (sizeof (struct _fd_ctx) *
|
||||
inode->table->xl->ctx->xl_count),
|
||||
gf_common_mt_fd_ctx);
|
||||
fd->inode = inode_ref (inode);
|
||||
fd->pid = pid;
|
||||
INIT_LIST_HEAD (&fd->inode_list);
|
||||
|
@ -75,7 +75,8 @@ gf_dirent_for_name (const char *name)
|
||||
gf_dirent_t *gf_dirent = NULL;
|
||||
|
||||
/* TODO: use mem-pool */
|
||||
gf_dirent = CALLOC (gf_dirent_size (name), 1);
|
||||
gf_dirent = GF_CALLOC (gf_dirent_size (name), 1,
|
||||
gf_common_mt_gf_dirent_t);
|
||||
if (!gf_dirent)
|
||||
return NULL;
|
||||
|
||||
@ -105,7 +106,7 @@ gf_dirent_free (gf_dirent_t *entries)
|
||||
|
||||
list_for_each_entry_safe (entry, tmp, &entries->list, list) {
|
||||
list_del (&entry->list);
|
||||
FREE (entry);
|
||||
GF_FREE (entry);
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,7 +166,7 @@ gf_dirent_unserialize (gf_dirent_t *entries, const char *buf, size_t buf_size)
|
||||
}
|
||||
|
||||
entry_len = sizeof (gf_dirent_t) + entry_strlen + 1;
|
||||
entry = CALLOC (1, entry_len);
|
||||
entry = GF_CALLOC (1, entry_len, gf_common_mt_gf_dirent_t);
|
||||
if (!entry) {
|
||||
break;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "globals.h"
|
||||
#include "glusterfs.h"
|
||||
#include "xlator.h"
|
||||
#include "mem-pool.h"
|
||||
|
||||
|
||||
/* CTX */
|
||||
@ -221,6 +222,9 @@ glusterfs_globals_init ()
|
||||
ret = glusterfs_central_log_flag_init ();
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
gf_mem_acct_enable_set ();
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
@ -138,14 +138,14 @@ __dentry_unset (dentry_t *dentry)
|
||||
list_del_init (&dentry->inode_list);
|
||||
|
||||
if (dentry->name)
|
||||
FREE (dentry->name);
|
||||
GF_FREE (dentry->name);
|
||||
|
||||
if (dentry->parent) {
|
||||
__inode_unref (dentry->parent);
|
||||
dentry->parent = NULL;
|
||||
}
|
||||
|
||||
FREE (dentry);
|
||||
GF_FREE (dentry);
|
||||
}
|
||||
|
||||
|
||||
@ -292,11 +292,11 @@ __inode_destroy (inode_t *inode)
|
||||
}
|
||||
}
|
||||
|
||||
FREE (inode->_ctx);
|
||||
GF_FREE (inode->_ctx);
|
||||
noctx:
|
||||
LOCK_DESTROY (&inode->lock);
|
||||
// memset (inode, 0xb, sizeof (*inode));
|
||||
FREE (inode);
|
||||
GF_FREE (inode);
|
||||
}
|
||||
|
||||
|
||||
@ -424,7 +424,8 @@ __dentry_create (inode_t *inode, inode_t *parent, const char *name)
|
||||
{
|
||||
dentry_t *newd = NULL;
|
||||
|
||||
newd = (void *) CALLOC (1, sizeof (*newd));
|
||||
newd = (void *) GF_CALLOC (1, sizeof (*newd),
|
||||
gf_common_mt_dentry_t);
|
||||
if (newd == NULL) {
|
||||
gf_log ("inode", GF_LOG_ERROR, "out of memory");
|
||||
goto out;
|
||||
@ -433,10 +434,10 @@ __dentry_create (inode_t *inode, inode_t *parent, const char *name)
|
||||
INIT_LIST_HEAD (&newd->inode_list);
|
||||
INIT_LIST_HEAD (&newd->hash);
|
||||
|
||||
newd->name = strdup (name);
|
||||
newd->name = gf_strdup (name);
|
||||
if (newd->name == NULL) {
|
||||
gf_log ("inode", GF_LOG_ERROR, "out of memory");
|
||||
FREE (newd);
|
||||
GF_FREE (newd);
|
||||
newd = NULL;
|
||||
goto out;
|
||||
}
|
||||
@ -457,7 +458,7 @@ __inode_create (inode_table_t *table)
|
||||
{
|
||||
inode_t *newi = NULL;
|
||||
|
||||
newi = (void *) CALLOC (1, sizeof (*newi));
|
||||
newi = (void *) GF_CALLOC (1, sizeof (*newi), gf_common_mt_inode_t);
|
||||
if (!newi) {
|
||||
gf_log ("inode", GF_LOG_ERROR, "out of memory");
|
||||
goto out;
|
||||
@ -472,12 +473,13 @@ __inode_create (inode_table_t *table)
|
||||
INIT_LIST_HEAD (&newi->hash);
|
||||
INIT_LIST_HEAD (&newi->dentry_list);
|
||||
|
||||
newi->_ctx = CALLOC (1, (sizeof (struct _inode_ctx) *
|
||||
table->xl->ctx->xl_count));
|
||||
newi->_ctx = GF_CALLOC (1, (sizeof (struct _inode_ctx) *
|
||||
table->xl->ctx->xl_count),
|
||||
gf_common_mt_inode_ctx);
|
||||
if (newi->_ctx == NULL) {
|
||||
gf_log ("inode", GF_LOG_ERROR, "out of memory");
|
||||
LOCK_DESTROY (&newi->lock);
|
||||
FREE (newi);
|
||||
GF_FREE (newi);
|
||||
newi = NULL;
|
||||
goto out;
|
||||
}
|
||||
@ -486,6 +488,7 @@ __inode_create (inode_table_t *table)
|
||||
table->lru_size++;
|
||||
|
||||
out:
|
||||
|
||||
return newi;
|
||||
}
|
||||
|
||||
@ -936,7 +939,7 @@ inode_path (inode_t *inode, const char *name, char **bufp)
|
||||
|
||||
ret = i;
|
||||
size = i + 1;
|
||||
buf = CALLOC (size, sizeof (char));
|
||||
buf = GF_CALLOC (size, sizeof (char), gf_common_mt_char);
|
||||
if (buf) {
|
||||
|
||||
buf[size - 1] = 0;
|
||||
@ -968,9 +971,9 @@ unlock:
|
||||
if (inode->ino == 1 && !name) {
|
||||
ret = 1;
|
||||
if (buf) {
|
||||
FREE (buf);
|
||||
GF_FREE (buf);
|
||||
}
|
||||
buf = CALLOC (ret + 1, sizeof (char));
|
||||
buf = GF_CALLOC (ret + 1, sizeof (char), gf_common_mt_char);
|
||||
if (buf) {
|
||||
strcpy (buf, "/");
|
||||
*bufp = buf;
|
||||
@ -1049,7 +1052,7 @@ inode_table_new (size_t lru_limit, xlator_t *xl)
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
|
||||
new = (void *)calloc (1, sizeof (*new));
|
||||
new = (void *)GF_CALLOC(1, sizeof (*new), gf_common_mt_inode_table_t);
|
||||
if (!new)
|
||||
return NULL;
|
||||
|
||||
@ -1059,18 +1062,20 @@ inode_table_new (size_t lru_limit, xlator_t *xl)
|
||||
|
||||
new->hashsize = 14057; /* TODO: Random Number?? */
|
||||
|
||||
new->inode_hash = (void *)calloc (new->hashsize,
|
||||
sizeof (struct list_head));
|
||||
new->inode_hash = (void *)GF_CALLOC (new->hashsize,
|
||||
sizeof (struct list_head),
|
||||
gf_common_mt_list_head);
|
||||
if (!new->inode_hash) {
|
||||
FREE (new);
|
||||
GF_FREE (new);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new->name_hash = (void *)calloc (new->hashsize,
|
||||
sizeof (struct list_head));
|
||||
new->name_hash = (void *)GF_CALLOC (new->hashsize,
|
||||
sizeof (struct list_head),
|
||||
gf_common_mt_list_head);
|
||||
if (!new->name_hash) {
|
||||
FREE (new->inode_hash);
|
||||
FREE (new);
|
||||
GF_FREE (new->inode_hash);
|
||||
GF_FREE (new);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1088,7 +1093,7 @@ inode_table_new (size_t lru_limit, xlator_t *xl)
|
||||
INIT_LIST_HEAD (&new->purge);
|
||||
INIT_LIST_HEAD (&new->attic);
|
||||
|
||||
ret = asprintf (&new->name, "%s/inode", xl->name);
|
||||
ret = gf_asprintf (&new->name, "%s/inode", xl->name);
|
||||
if (-1 == ret) {
|
||||
/* TODO: This should be ok to continue, check with avati */
|
||||
;
|
||||
@ -1114,7 +1119,7 @@ inode_from_path (inode_table_t *itable, const char *path)
|
||||
char *strtokptr = NULL;
|
||||
|
||||
/* top-down approach */
|
||||
pathname = strdup (path);
|
||||
pathname = gf_strdup (path);
|
||||
if (pathname == NULL) {
|
||||
gf_log ("inode", GF_LOG_ERROR, "out of memory");
|
||||
goto out;
|
||||
@ -1153,7 +1158,7 @@ inode_from_path (inode_table_t *itable, const char *path)
|
||||
inode_unref (parent);
|
||||
|
||||
if (pathname)
|
||||
free (pathname);
|
||||
GF_FREE (pathname);
|
||||
|
||||
out:
|
||||
return inode;
|
||||
|
@ -41,7 +41,8 @@ __iobuf_arena_init_iobufs (struct iobuf_arena *iobuf_arena)
|
||||
page_size = iobuf_arena->iobuf_pool->page_size;
|
||||
iobuf_cnt = arena_size / page_size;
|
||||
|
||||
iobuf_arena->iobufs = CALLOC (sizeof (*iobuf), iobuf_cnt);
|
||||
iobuf_arena->iobufs = GF_CALLOC (sizeof (*iobuf), iobuf_cnt,
|
||||
gf_common_mt_iobuf);
|
||||
if (!iobuf_arena->iobufs)
|
||||
return;
|
||||
|
||||
@ -87,7 +88,7 @@ __iobuf_arena_destroy_iobufs (struct iobuf_arena *iobuf_arena)
|
||||
iobuf++;
|
||||
}
|
||||
|
||||
FREE (iobuf_arena->iobufs);
|
||||
GF_FREE (iobuf_arena->iobufs);
|
||||
}
|
||||
|
||||
|
||||
@ -107,7 +108,7 @@ __iobuf_arena_destroy (struct iobuf_arena *iobuf_arena)
|
||||
&& iobuf_arena->mem_base != MAP_FAILED)
|
||||
munmap (iobuf_arena->mem_base, iobuf_pool->arena_size);
|
||||
|
||||
FREE (iobuf_arena);
|
||||
GF_FREE (iobuf_arena);
|
||||
}
|
||||
|
||||
|
||||
@ -117,7 +118,8 @@ __iobuf_arena_alloc (struct iobuf_pool *iobuf_pool)
|
||||
struct iobuf_arena *iobuf_arena = NULL;
|
||||
size_t arena_size = 0;
|
||||
|
||||
iobuf_arena = CALLOC (sizeof (*iobuf_arena), 1);
|
||||
iobuf_arena = GF_CALLOC (sizeof (*iobuf_arena), 1,
|
||||
gf_common_mt_iobuf_arena);
|
||||
if (!iobuf_arena)
|
||||
goto err;
|
||||
|
||||
@ -224,7 +226,8 @@ iobuf_pool_new (size_t arena_size, size_t page_size)
|
||||
if (arena_size < page_size)
|
||||
return NULL;
|
||||
|
||||
iobuf_pool = CALLOC (sizeof (*iobuf_pool), 1);
|
||||
iobuf_pool = GF_CALLOC (sizeof (*iobuf_pool), 1,
|
||||
gf_common_mt_iobuf_pool);
|
||||
if (!iobuf_pool)
|
||||
return NULL;
|
||||
|
||||
@ -463,7 +466,8 @@ iobref_new ()
|
||||
{
|
||||
struct iobref *iobref = NULL;
|
||||
|
||||
iobref = CALLOC (sizeof (*iobref), 1);
|
||||
iobref = GF_CALLOC (sizeof (*iobref), 1,
|
||||
gf_common_mt_iobref);
|
||||
if (!iobref)
|
||||
return NULL;
|
||||
|
||||
@ -508,7 +512,7 @@ iobref_destroy (struct iobref *iobref)
|
||||
iobuf_unref (iobuf);
|
||||
}
|
||||
|
||||
FREE (iobref);
|
||||
GF_FREE (iobref);
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,7 +84,7 @@ gf_log_init (const char *file)
|
||||
|
||||
pthread_mutex_init (&logfile_mutex, NULL);
|
||||
|
||||
filename = strdup (file);
|
||||
filename = gf_strdup (file);
|
||||
if (!filename) {
|
||||
fprintf (stderr, "gf_log_init: strdup error\n");
|
||||
return -1;
|
||||
@ -153,11 +153,11 @@ __get_dummy_xlator (glusterfs_ctx_t *ctx, const char *remote_host,
|
||||
xlator_list_t * parent = NULL;
|
||||
xlator_list_t * tmp = NULL;
|
||||
|
||||
top = CALLOC (1, sizeof (*top));
|
||||
top = GF_CALLOC (1, sizeof (*top), gf_common_mt_xlator_t);
|
||||
if (!top)
|
||||
goto out;
|
||||
|
||||
trans = CALLOC (1, sizeof (*trans));
|
||||
trans = GF_CALLOC (1, sizeof (*trans), gf_common_mt_xlator_t);
|
||||
if (!trans)
|
||||
goto out;
|
||||
|
||||
@ -169,7 +169,8 @@ __get_dummy_xlator (glusterfs_ctx_t *ctx, const char *remote_host,
|
||||
top->next = trans;
|
||||
top->init = dummy_init;
|
||||
top->notify = gf_log_notify;
|
||||
top->children = (void *) CALLOC (1, sizeof (*top->children));
|
||||
top->children = (void *) GF_CALLOC (1, sizeof (*top->children),
|
||||
gf_common_mt_xlator_list_t);
|
||||
|
||||
if (!top->children)
|
||||
goto out;
|
||||
@ -183,7 +184,7 @@ __get_dummy_xlator (glusterfs_ctx_t *ctx, const char *remote_host,
|
||||
trans->notify = default_notify;
|
||||
trans->options = get_new_dict ();
|
||||
|
||||
parent = CALLOC (1, sizeof(*parent));
|
||||
parent = GF_CALLOC (1, sizeof(*parent), gf_common_mt_xlator_list_t);
|
||||
|
||||
if (!parent)
|
||||
goto out;
|
||||
@ -219,7 +220,8 @@ __get_dummy_xlator (glusterfs_ctx_t *ctx, const char *remote_host,
|
||||
ret = dict_set_static_ptr (trans->options, "non-blocking-io", "off");
|
||||
|
||||
if (transport) {
|
||||
char *transport_type = CALLOC (1, strlen (transport) + 10);
|
||||
char *transport_type = GF_CALLOC (1, strlen (transport) + 10,
|
||||
gf_common_mt_char);
|
||||
ERR_ABORT (transport_type);
|
||||
strcpy(transport_type, transport);
|
||||
|
||||
@ -293,7 +295,7 @@ gf_log_central_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
|
||||
msg = (struct _log_msg *) cookie;
|
||||
|
||||
FREE (msg->msg);
|
||||
GF_FREE ((char *)(msg->msg));
|
||||
|
||||
STACK_DESTROY (frame->root);
|
||||
|
||||
@ -375,14 +377,14 @@ gf_log_central (const char *msg)
|
||||
{
|
||||
struct _log_msg *lm = NULL;
|
||||
|
||||
lm = CALLOC (1, sizeof (*lm));
|
||||
lm = GF_CALLOC (1, sizeof (*lm), gf_common_mt_log_msg);
|
||||
|
||||
if (!lm)
|
||||
goto out;
|
||||
|
||||
INIT_LIST_HEAD (&lm->queue);
|
||||
|
||||
lm->msg = strdup (msg);
|
||||
lm->msg = gf_strdup (msg);
|
||||
|
||||
pthread_mutex_lock (&msg_queue_mutex);
|
||||
{
|
||||
@ -491,10 +493,10 @@ log:
|
||||
else
|
||||
basename = file;
|
||||
|
||||
ret = asprintf (&str1, "[%s] %s [%s:%d:%s] %s: ",
|
||||
timestr, level_strings[level],
|
||||
basename, line, function,
|
||||
domain);
|
||||
ret = gf_asprintf (&str1, "[%s] %s [%s:%d:%s] %s: ",
|
||||
timestr, level_strings[level],
|
||||
basename, line, function,
|
||||
domain);
|
||||
if (-1 == ret) {
|
||||
goto unlock;
|
||||
}
|
||||
@ -507,7 +509,7 @@ log:
|
||||
va_end (ap);
|
||||
|
||||
len = strlen (str1);
|
||||
msg = malloc (len + strlen (str2) + 1);
|
||||
msg = GF_MALLOC (len + strlen (str2) + 1, gf_common_mt_char);
|
||||
|
||||
strcpy (msg, str1);
|
||||
strcpy (msg + len, str2);
|
||||
@ -528,11 +530,11 @@ unlock:
|
||||
}
|
||||
glusterfs_central_log_flag_unset ();
|
||||
}
|
||||
FREE (msg);
|
||||
GF_FREE (msg);
|
||||
}
|
||||
|
||||
if (str1)
|
||||
FREE (str1);
|
||||
GF_FREE (str1);
|
||||
|
||||
if (str2)
|
||||
FREE (str2);
|
||||
@ -559,12 +561,12 @@ client_log_init (struct _client_log *cl, char *identifier)
|
||||
|
||||
cl->identifier = identifier;
|
||||
|
||||
ret = asprintf (&path, "%s.client-%s", filename, identifier);
|
||||
ret = gf_asprintf (&path, "%s.client-%s", filename, identifier);
|
||||
if (-1 == ret) {
|
||||
return;
|
||||
}
|
||||
cl->file = fopen (path, "a");
|
||||
FREE (path);
|
||||
GF_FREE (path);
|
||||
|
||||
INIT_LIST_HEAD (&cl->list);
|
||||
}
|
||||
@ -576,7 +578,8 @@ __logfile_for_client (char *identifier)
|
||||
struct _client_log *client = NULL;
|
||||
|
||||
if (!client_logs) {
|
||||
client = CALLOC (1, sizeof (*client));
|
||||
client = GF_CALLOC (1, sizeof (*client),
|
||||
gf_common_mt_client_log);
|
||||
client_log_init (client, identifier);
|
||||
|
||||
client_logs = client;
|
||||
@ -588,7 +591,8 @@ __logfile_for_client (char *identifier)
|
||||
}
|
||||
|
||||
if (!client) {
|
||||
client = CALLOC (1, sizeof (*client));
|
||||
client = GF_CALLOC (1, sizeof (*client),
|
||||
gf_common_mt_client_log);
|
||||
|
||||
client_log_init (client, identifier);
|
||||
|
||||
|
@ -19,13 +19,278 @@
|
||||
|
||||
#include "mem-pool.h"
|
||||
#include "logging.h"
|
||||
#include "xlator.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
#define GF_MEM_POOL_PAD_BOUNDARY (sizeof(struct list_head))
|
||||
#define mem_pool_chunkhead2ptr(head) ((head) + GF_MEM_POOL_PAD_BOUNDARY)
|
||||
#define mem_pool_ptr2chunkhead(ptr) ((ptr) - GF_MEM_POOL_PAD_BOUNDARY)
|
||||
|
||||
#define GF_MEM_HEADER_SIZE (4 + sizeof (size_t) + sizeof (xlator_t *) + 4)
|
||||
#define GF_MEM_TRAILER_SIZE 4
|
||||
|
||||
#define GF_MEM_HEADER_MAGIC 0xCAFEBABE
|
||||
#define GF_MEM_TRAILER_MAGIC 0xBAADF00D
|
||||
|
||||
#define GLUSTERFS_ENV_MEM_ACCT_STR "GLUSTERFS_DISABLE_MEM_ACCT"
|
||||
|
||||
static int gf_mem_acct_enable = 1;
|
||||
|
||||
int
|
||||
gf_mem_acct_is_enabled ()
|
||||
{
|
||||
return gf_mem_acct_enable;
|
||||
}
|
||||
|
||||
void
|
||||
gf_mem_acct_enable_set ()
|
||||
{
|
||||
char *opt = NULL;
|
||||
long val = -1;
|
||||
|
||||
opt = getenv (GLUSTERFS_ENV_MEM_ACCT_STR);
|
||||
|
||||
if (!opt)
|
||||
return;
|
||||
|
||||
val = strtol (opt, NULL, 0);
|
||||
|
||||
if (val)
|
||||
gf_mem_acct_enable = 0;
|
||||
else
|
||||
gf_mem_acct_enable = 1;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
gf_mem_set_acct_info (xlator_t *xl, char **alloc_ptr,
|
||||
size_t size, uint32_t type)
|
||||
{
|
||||
|
||||
char *ptr = NULL;
|
||||
|
||||
if (!alloc_ptr)
|
||||
return;
|
||||
|
||||
ptr = (char *) (*alloc_ptr);
|
||||
|
||||
if (!xl) {
|
||||
assert (0);
|
||||
}
|
||||
|
||||
if (!(xl->mem_acct.rec)) {
|
||||
assert (0);
|
||||
}
|
||||
|
||||
if (type > xl->mem_acct.num_types) {
|
||||
assert (0);
|
||||
}
|
||||
|
||||
LOCK(&xl->mem_acct.rec[type].lock);
|
||||
{
|
||||
xl->mem_acct.rec[type].size += size;
|
||||
xl->mem_acct.rec[type].num_allocs++;
|
||||
xl->mem_acct.rec[type].max_size =
|
||||
max (xl->mem_acct.rec[type].max_size,
|
||||
xl->mem_acct.rec[type].size);
|
||||
xl->mem_acct.rec[type].max_num_allocs =
|
||||
max (xl->mem_acct.rec[type].max_num_allocs,
|
||||
xl->mem_acct.rec[type].num_allocs);
|
||||
}
|
||||
UNLOCK(&xl->mem_acct.rec[type].lock);
|
||||
|
||||
*(uint32_t *)(ptr) = type;
|
||||
ptr = ptr + 4;
|
||||
memcpy (ptr, &size, sizeof(size_t));
|
||||
ptr += sizeof (size_t);
|
||||
memcpy (ptr, &xl, sizeof(xlator_t *));
|
||||
ptr += sizeof (xlator_t *);
|
||||
*(uint32_t *)(ptr) = GF_MEM_HEADER_MAGIC;
|
||||
ptr = ptr + 4;
|
||||
*(uint32_t *) (ptr + size) = GF_MEM_TRAILER_MAGIC;
|
||||
|
||||
*alloc_ptr = (void *)ptr;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
__gf_calloc (size_t nmemb, size_t size, uint32_t type)
|
||||
{
|
||||
size_t tot_size = 0;
|
||||
size_t req_size = 0;
|
||||
char *ptr = NULL;
|
||||
xlator_t *xl = NULL;
|
||||
|
||||
if (!gf_mem_acct_enable)
|
||||
return CALLOC (nmemb, size);
|
||||
|
||||
xl = THIS;
|
||||
|
||||
req_size = nmemb * size;
|
||||
tot_size = req_size + GF_MEM_HEADER_SIZE + GF_MEM_TRAILER_SIZE;
|
||||
|
||||
ptr = calloc (1, tot_size);
|
||||
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
||||
gf_mem_set_acct_info (xl, &ptr, req_size, type);
|
||||
|
||||
return (void *)ptr;
|
||||
}
|
||||
|
||||
void *
|
||||
__gf_malloc (size_t size, uint32_t type)
|
||||
{
|
||||
size_t tot_size = 0;
|
||||
char *ptr = NULL;
|
||||
xlator_t *xl = NULL;
|
||||
|
||||
if (!gf_mem_acct_enable)
|
||||
return MALLOC (size);
|
||||
|
||||
xl = THIS;
|
||||
|
||||
tot_size = size + GF_MEM_HEADER_SIZE + GF_MEM_TRAILER_SIZE;
|
||||
|
||||
ptr = malloc (tot_size);
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
||||
gf_mem_set_acct_info (xl, &ptr, size, type);
|
||||
|
||||
return (void *)ptr;
|
||||
}
|
||||
|
||||
void *
|
||||
__gf_realloc (void *ptr, size_t size)
|
||||
{
|
||||
size_t tot_size = 0;
|
||||
char *orig_ptr = NULL;
|
||||
xlator_t *xl = NULL;
|
||||
uint32_t type = 0;
|
||||
|
||||
|
||||
tot_size = size + GF_MEM_HEADER_SIZE + GF_MEM_TRAILER_SIZE;
|
||||
|
||||
orig_ptr = (char *)ptr - 4;
|
||||
|
||||
assert (*(uint32_t *)orig_ptr == GF_MEM_HEADER_MAGIC);
|
||||
|
||||
orig_ptr = orig_ptr - sizeof(xlator_t *);
|
||||
xl = *((xlator_t **)orig_ptr);
|
||||
|
||||
orig_ptr = (char *)ptr - GF_MEM_HEADER_SIZE;
|
||||
type = *(uint32_t *)orig_ptr;
|
||||
|
||||
ptr = realloc (orig_ptr, tot_size);
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
||||
gf_mem_set_acct_info (xl, (char **)&ptr, size, type);
|
||||
|
||||
return (void *)ptr;
|
||||
}
|
||||
|
||||
int
|
||||
gf_asprintf (char **string_ptr, const char *format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
char *str = NULL;
|
||||
int size = 0;
|
||||
int rv = 0;
|
||||
|
||||
if (!string_ptr || !format)
|
||||
return -1;
|
||||
|
||||
va_start (arg, format);
|
||||
size = vsnprintf (NULL, 0, format, arg);
|
||||
size++;
|
||||
va_start (arg, format);
|
||||
str = GF_MALLOC (size, gf_common_mt_asprintf);
|
||||
if (str == NULL) {
|
||||
va_end (arg);
|
||||
/*
|
||||
* Strictly speaking, GNU asprintf doesn't do this,
|
||||
* but the caller isn't checking the return value.
|
||||
*/
|
||||
gf_log ("libglusterfs", GF_LOG_CRITICAL,
|
||||
"failed to allocate memory");
|
||||
return -1;
|
||||
}
|
||||
rv = vsnprintf( str, size, format, arg);
|
||||
va_end (arg);
|
||||
|
||||
*string_ptr = str;
|
||||
return (rv);
|
||||
}
|
||||
|
||||
void
|
||||
__gf_free (void *free_ptr)
|
||||
{
|
||||
size_t req_size = 0;
|
||||
char *ptr = NULL;
|
||||
uint32_t type = 0;
|
||||
xlator_t *xl = NULL;
|
||||
|
||||
if (!gf_mem_acct_enable) {
|
||||
FREE (free_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!free_ptr)
|
||||
return;
|
||||
|
||||
|
||||
ptr = (char *)free_ptr - 4;
|
||||
|
||||
if (GF_MEM_HEADER_MAGIC != *(uint32_t *)ptr) {
|
||||
//Possible corruption, assert here
|
||||
assert (0);
|
||||
}
|
||||
|
||||
*(uint32_t *)ptr = 0;
|
||||
|
||||
ptr = ptr - sizeof(xlator_t *);
|
||||
memcpy (&xl, ptr, sizeof(xlator_t *));
|
||||
|
||||
if (!xl) {
|
||||
//gf_free expects xl to be available
|
||||
assert (0);
|
||||
}
|
||||
|
||||
if (!xl->mem_acct.rec) {
|
||||
ptr = (char *)free_ptr - GF_MEM_HEADER_SIZE;
|
||||
goto free;
|
||||
}
|
||||
|
||||
|
||||
ptr = ptr - sizeof(size_t);
|
||||
memcpy (&req_size, ptr, sizeof (size_t));
|
||||
ptr = ptr - 4;
|
||||
type = *(uint32_t *)ptr;
|
||||
|
||||
if (GF_MEM_TRAILER_MAGIC != *(uint32_t *)
|
||||
((char *)free_ptr + req_size)) {
|
||||
// This points to a memory overrun
|
||||
assert (0);
|
||||
}
|
||||
*(uint32_t *) ((char *)free_ptr + req_size) = 0;
|
||||
|
||||
LOCK (&xl->mem_acct.rec[type].lock);
|
||||
{
|
||||
xl->mem_acct.rec[type].size -= req_size;
|
||||
xl->mem_acct.rec[type].num_allocs--;
|
||||
}
|
||||
UNLOCK (&xl->mem_acct.rec[type].lock);
|
||||
free:
|
||||
FREE (ptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct mem_pool *
|
||||
mem_pool_new_fn (unsigned long sizeof_type,
|
||||
@ -36,14 +301,14 @@ mem_pool_new_fn (unsigned long sizeof_type,
|
||||
void *pool = NULL;
|
||||
int i = 0;
|
||||
struct list_head *list = NULL;
|
||||
|
||||
|
||||
if (!sizeof_type || !count) {
|
||||
gf_log ("mem-pool", GF_LOG_ERROR, "invalid argument");
|
||||
return NULL;
|
||||
}
|
||||
padded_sizeof_type = sizeof_type + GF_MEM_POOL_PAD_BOUNDARY;
|
||||
|
||||
mem_pool = CALLOC (sizeof (*mem_pool), 1);
|
||||
|
||||
mem_pool = GF_CALLOC (sizeof (*mem_pool), 1, gf_common_mt_mem_pool);
|
||||
if (!mem_pool)
|
||||
return NULL;
|
||||
|
||||
@ -54,9 +319,9 @@ mem_pool_new_fn (unsigned long sizeof_type,
|
||||
mem_pool->cold_count = count;
|
||||
mem_pool->real_sizeof_type = sizeof_type;
|
||||
|
||||
pool = CALLOC (count, padded_sizeof_type);
|
||||
pool = GF_CALLOC (count, padded_sizeof_type, gf_common_mt_long);
|
||||
if (!pool) {
|
||||
FREE (mem_pool);
|
||||
GF_FREE (mem_pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -78,7 +343,7 @@ mem_get (struct mem_pool *mem_pool)
|
||||
{
|
||||
struct list_head *list = NULL;
|
||||
void *ptr = NULL;
|
||||
|
||||
|
||||
if (!mem_pool) {
|
||||
gf_log ("mem-pool", GF_LOG_ERROR, "invalid argument");
|
||||
return NULL;
|
||||
@ -141,7 +406,7 @@ __is_member (struct mem_pool *pool, void *ptr)
|
||||
gf_log ("mem-pool", GF_LOG_ERROR, "invalid argument");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (ptr < pool->pool || ptr >= pool->pool_end)
|
||||
return 0;
|
||||
|
||||
@ -157,12 +422,12 @@ void
|
||||
mem_put (struct mem_pool *pool, void *ptr)
|
||||
{
|
||||
struct list_head *list = NULL;
|
||||
|
||||
|
||||
if (!pool || !ptr) {
|
||||
gf_log ("mem-pool", GF_LOG_ERROR, "invalid argument");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
LOCK (&pool->lock);
|
||||
{
|
||||
|
||||
@ -210,8 +475,8 @@ mem_pool_destroy (struct mem_pool *pool)
|
||||
return;
|
||||
|
||||
LOCK_DESTROY (&pool->lock);
|
||||
FREE (pool->pool);
|
||||
FREE (pool);
|
||||
GF_FREE (pool->pool);
|
||||
GF_FREE (pool);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -22,7 +22,10 @@
|
||||
|
||||
#include "list.h"
|
||||
#include "locking.h"
|
||||
#include "mem-types.h"
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define MALLOC(size) malloc(size)
|
||||
@ -34,6 +37,65 @@
|
||||
ptr = (void *)0xeeeeeeee; \
|
||||
}
|
||||
|
||||
struct mem_acct {
|
||||
uint32_t num_types;
|
||||
struct mem_acct_rec *rec;
|
||||
};
|
||||
|
||||
struct mem_acct_rec {
|
||||
size_t size;
|
||||
size_t max_size;
|
||||
uint32_t num_allocs;
|
||||
uint32_t max_num_allocs;
|
||||
gf_lock_t lock;
|
||||
};
|
||||
|
||||
|
||||
void *
|
||||
__gf_calloc (size_t cnt, size_t size, uint32_t type);
|
||||
|
||||
void *
|
||||
__gf_malloc (size_t size, uint32_t type);
|
||||
|
||||
void *
|
||||
__gf_realloc (void *ptr, size_t size);
|
||||
|
||||
int
|
||||
gf_asprintf (char **string_ptr, const char *format, ...);
|
||||
|
||||
#define GF_CALLOC(nmemb, size, type) __gf_calloc (nmemb, size, type)
|
||||
|
||||
#define GF_MALLOC(size, type) __gf_malloc (size, type)
|
||||
|
||||
#define GF_REALLOC(ptr, size) __gf_realloc (ptr, size)
|
||||
|
||||
void
|
||||
__gf_free (void *ptr);
|
||||
|
||||
|
||||
#define GF_FREE(free_ptr) __gf_free (free_ptr);
|
||||
|
||||
static inline
|
||||
char * gf_strdup (const char *src)
|
||||
{
|
||||
|
||||
char *dup_str = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
len = strlen (src) + 1;
|
||||
|
||||
dup_str = GF_CALLOC(1, len, gf_common_mt_strdup);
|
||||
|
||||
if (!dup_str)
|
||||
return NULL;
|
||||
|
||||
memcpy (dup_str, src, len);
|
||||
|
||||
return dup_str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct mem_pool {
|
||||
struct list_head list;
|
||||
int hot_count;
|
||||
@ -55,4 +117,7 @@ void *mem_get (struct mem_pool *pool);
|
||||
|
||||
void mem_pool_destroy (struct mem_pool *pool);
|
||||
|
||||
int gf_mem_acct_is_enabled ();
|
||||
void gf_mem_acct_enable_set ();
|
||||
|
||||
#endif /* _MEM_POOL_H */
|
||||
|
82
libglusterfs/src/mem-types.h
Normal file
82
libglusterfs/src/mem-types.h
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
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
|
||||
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 __MEM_TYPES_H__
|
||||
#define __MEM_TYPES_H__
|
||||
|
||||
|
||||
enum gf_common_mem_types_ {
|
||||
gf_common_mt_call_stub_t = 0,
|
||||
gf_common_mt_dnscache6,
|
||||
gf_common_mt_data_pair_t,
|
||||
gf_common_mt_data_t,
|
||||
gf_common_mt_dict_t,
|
||||
gf_common_mt_event_pool,
|
||||
gf_common_mt_reg,
|
||||
gf_common_mt_pollfd,
|
||||
gf_common_mt_epoll_event,
|
||||
gf_common_mt_fdentry_t,
|
||||
gf_common_mt_fdtable_t,
|
||||
gf_common_mt_fd_t,
|
||||
gf_common_mt_fd_ctx,
|
||||
gf_common_mt_gf_dirent_t,
|
||||
gf_common_mt_glusterfs_ctx_t,
|
||||
gf_common_mt_dentry_t,
|
||||
gf_common_mt_inode_t,
|
||||
gf_common_mt_inode_ctx,
|
||||
gf_common_mt_list_head,
|
||||
gf_common_mt_inode_table_t,
|
||||
gf_common_mt_xlator_t,
|
||||
gf_common_mt_xlator_list_t,
|
||||
gf_common_mt_log_msg,
|
||||
gf_common_mt_client_log,
|
||||
gf_common_mt_volume_opt_list_t,
|
||||
gf_common_mt_gf_hdr_common_t,
|
||||
gf_common_mt_call_frame_t,
|
||||
gf_common_mt_call_stack_t,
|
||||
gf_common_mt_gf_timer_t,
|
||||
gf_common_mt_gf_timer_registry_t,
|
||||
gf_common_mt_transport,
|
||||
gf_common_mt_transport_msg,
|
||||
gf_common_mt_auth_handle_t,
|
||||
gf_common_mt_iobuf,
|
||||
gf_common_mt_iobuf_arena,
|
||||
gf_common_mt_iobref,
|
||||
gf_common_mt_iobuf_pool,
|
||||
gf_common_mt_iovec,
|
||||
gf_common_mt_memdup,
|
||||
gf_common_mt_asprintf,
|
||||
gf_common_mt_strdup,
|
||||
gf_common_mt_socket_private_t,
|
||||
gf_common_mt_ioq,
|
||||
gf_common_mt_transport_t,
|
||||
gf_common_mt_socket_local_t,
|
||||
gf_common_mt_char,
|
||||
gf_common_mt_rbthash_table_t,
|
||||
gf_common_mt_rbthash_bucket,
|
||||
gf_common_mt_mem_pool,
|
||||
gf_common_mt_long,
|
||||
gf_common_mt_rpcsvc_auth_list,
|
||||
gf_common_mt_rpcsvc_t,
|
||||
gf_common_mt_rpcsvc_conn_t,
|
||||
gf_common_mt_rpcsvc_program_t,
|
||||
gf_common_mt_rpcsvc_stage_t,
|
||||
gf_common_mt_end
|
||||
};
|
||||
#endif
|
@ -999,7 +999,8 @@ __gf_hdr_new (int size)
|
||||
gf_hdr_common_t *hdr = NULL;
|
||||
|
||||
/* TODO: use mem-pool */
|
||||
hdr = CALLOC (sizeof (gf_hdr_common_t) + size, 1);
|
||||
hdr = GF_CALLOC (sizeof (gf_hdr_common_t) + size, 1,
|
||||
gf_common_mt_gf_hdr_common_t);
|
||||
|
||||
if (!hdr) {
|
||||
return NULL;
|
||||
|
@ -116,11 +116,13 @@ rbthash_table_init (int buckets, rbt_hasher_t hfunc,
|
||||
}
|
||||
|
||||
|
||||
newtab = CALLOC (1, sizeof (*newtab));
|
||||
newtab = GF_CALLOC (1, sizeof (*newtab),
|
||||
gf_common_mt_rbthash_table_t);
|
||||
if (!newtab)
|
||||
return NULL;
|
||||
|
||||
newtab->buckets = CALLOC (buckets, sizeof (struct rbthash_bucket));
|
||||
newtab->buckets = GF_CALLOC (buckets, sizeof (struct rbthash_bucket),
|
||||
gf_common_mt_rbthash_bucket);
|
||||
if (!newtab->buckets) {
|
||||
gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to allocate memory");
|
||||
goto free_newtab;
|
||||
@ -157,11 +159,11 @@ rbthash_table_init (int buckets, rbt_hasher_t hfunc,
|
||||
|
||||
free_buckets:
|
||||
if (ret == -1)
|
||||
FREE (newtab->buckets);
|
||||
GF_FREE (newtab->buckets);
|
||||
|
||||
free_newtab:
|
||||
if (ret == -1) {
|
||||
FREE (newtab);
|
||||
GF_FREE (newtab);
|
||||
newtab = NULL;
|
||||
}
|
||||
|
||||
@ -185,7 +187,7 @@ rbthash_init_entry (rbthash_table_t *tbl, void *data, void *key, int keylen)
|
||||
}
|
||||
|
||||
entry->data = data;
|
||||
entry->key = CALLOC (keylen, sizeof (char));
|
||||
entry->key = GF_CALLOC (keylen, sizeof (char), gf_common_mt_char);
|
||||
if (!entry->key) {
|
||||
gf_log (GF_RBTHASH, GF_LOG_ERROR, "Memory allocation failed");
|
||||
goto free_entry;
|
||||
@ -216,7 +218,7 @@ rbthash_deinit_entry (rbthash_table_t *tbl, rbthash_entry_t *entry)
|
||||
return;
|
||||
|
||||
if (entry->key)
|
||||
FREE (entry->key);
|
||||
GF_FREE (entry->key);
|
||||
|
||||
if (tbl) {
|
||||
if ((entry->data) && (tbl->dfunc))
|
||||
@ -374,7 +376,7 @@ rbthash_remove (rbthash_table_t *tbl, void *key, int keylen)
|
||||
if (!entry)
|
||||
return NULL;
|
||||
|
||||
FREE (entry->key);
|
||||
GF_FREE (entry->key);
|
||||
dataref = entry->data;
|
||||
mem_put (tbl->entrypool, entry);
|
||||
|
||||
@ -418,7 +420,7 @@ rbthash_table_destroy (rbthash_table_t *tbl)
|
||||
if (tbl->pool_alloced)
|
||||
mem_pool_destroy (tbl->entrypool);
|
||||
|
||||
FREE (tbl->buckets);
|
||||
FREE (tbl);
|
||||
GF_FREE (tbl->buckets);
|
||||
GF_FREE (tbl);
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ get_scheduler (xlator_t *xl, const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = asprintf (&sched_file, "%s/%s.so", SCHEDULERDIR, name);
|
||||
ret = gf_asprintf (&sched_file, "%s/%s.so", SCHEDULERDIR, name);
|
||||
if (-1 == ret) {
|
||||
gf_log ("scheduler", GF_LOG_ERROR, "asprintf failed");
|
||||
return NULL;
|
||||
@ -66,7 +66,8 @@ get_scheduler (xlator_t *xl, const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vol_opt = CALLOC (1, sizeof (volume_opt_list_t));
|
||||
vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t),
|
||||
gf_common_mt_volume_opt_list_t);
|
||||
vol_opt->given_opt = dlsym (handle, "options");
|
||||
if (vol_opt->given_opt == NULL) {
|
||||
gf_log ("scheduler", GF_LOG_DEBUG,
|
||||
@ -80,6 +81,7 @@ get_scheduler (xlator_t *xl, const char *name)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
GF_FREE(sched_file);
|
||||
|
||||
return tmp_sched;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ struct sched_ops {
|
||||
void (*update) (xlator_t *this);
|
||||
xlator_t *(*schedule) (xlator_t *this, const void *path);
|
||||
void (*notify) (xlator_t *xl, int32_t event, void *data);
|
||||
int32_t (*mem_acct_init) (xlator_t *this);
|
||||
};
|
||||
|
||||
extern struct sched_ops *get_scheduler (xlator_t *xl, const char *name);
|
||||
|
@ -137,9 +137,9 @@ FRAME_DESTROY (call_frame_t *frame)
|
||||
if (frame->prev)
|
||||
frame->prev->next = frame->next;
|
||||
if (frame->local)
|
||||
FREE (frame->local);
|
||||
GF_FREE (frame->local);
|
||||
LOCK_DESTROY (&frame->lock);
|
||||
FREE (frame);
|
||||
GF_FREE (frame);
|
||||
}
|
||||
|
||||
|
||||
@ -161,7 +161,7 @@ STACK_DESTROY (call_stack_t *stack)
|
||||
UNLOCK (&stack->pool->lock);
|
||||
|
||||
if (stack->frames.local)
|
||||
FREE (stack->frames.local);
|
||||
GF_FREE (stack->frames.local);
|
||||
|
||||
LOCK_DESTROY (&stack->frames.lock);
|
||||
|
||||
@ -172,7 +172,7 @@ STACK_DESTROY (call_stack_t *stack)
|
||||
|
||||
FRAME_DESTROY (stack->frames.next);
|
||||
}
|
||||
FREE (stack);
|
||||
GF_FREE (stack);
|
||||
}
|
||||
|
||||
|
||||
@ -185,7 +185,8 @@ STACK_DESTROY (call_stack_t *stack)
|
||||
call_frame_t *_new = NULL; \
|
||||
xlator_t *old_THIS = NULL; \
|
||||
\
|
||||
_new = CALLOC (1, sizeof (call_frame_t)); \
|
||||
_new = GF_CALLOC (1, sizeof (call_frame_t), \
|
||||
gf_common_mt_call_frame_t); \
|
||||
ERR_ABORT (_new); \
|
||||
typeof(fn##_cbk) tmp_cbk = rfn; \
|
||||
_new->root = frame->root; \
|
||||
@ -219,7 +220,8 @@ STACK_DESTROY (call_stack_t *stack)
|
||||
call_frame_t *_new = NULL; \
|
||||
xlator_t *old_THIS = NULL; \
|
||||
\
|
||||
_new = CALLOC (1, sizeof (call_frame_t)); \
|
||||
_new = GF_CALLOC (1, sizeof (call_frame_t), \
|
||||
gf_common_mt_call_frame_t); \
|
||||
ERR_ABORT (_new); \
|
||||
typeof(fn##_cbk) tmp_cbk = rfn; \
|
||||
_new->root = frame->root; \
|
||||
@ -304,7 +306,8 @@ copy_frame (call_frame_t *frame)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
newstack = (void *) CALLOC (1, sizeof (*newstack));
|
||||
newstack = (void *) GF_CALLOC (1, sizeof (*newstack),
|
||||
gf_common_mt_call_stack_t);
|
||||
if (newstack == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -347,7 +350,7 @@ create_frame (xlator_t *xl, call_pool_t *pool)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
stack = CALLOC (1, sizeof (*stack));
|
||||
stack = GF_CALLOC (1, sizeof (*stack),gf_common_mt_call_stack_t);
|
||||
if (!stack)
|
||||
return NULL;
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include <malloc.h>
|
||||
#endif /* MALLOC_H */
|
||||
|
||||
extern xlator_t global_xlator;
|
||||
|
||||
static pthread_mutex_t gf_proc_dump_mutex;
|
||||
static int gf_dump_fd = -1;
|
||||
|
||||
@ -115,6 +117,46 @@ gf_proc_dump_write (char *key, char *value,...)
|
||||
ret = write(gf_dump_fd, buf, strlen(buf));
|
||||
}
|
||||
|
||||
static void
|
||||
gf_proc_dump_xlator_mem_info (xlator_t *xl)
|
||||
{
|
||||
char key[GF_DUMP_MAX_BUF_LEN];
|
||||
char prefix[GF_DUMP_MAX_BUF_LEN];
|
||||
int i = 0;
|
||||
struct mem_acct rec = {0,};
|
||||
|
||||
if (!xl)
|
||||
return;
|
||||
|
||||
if (!xl->mem_acct.rec)
|
||||
return;
|
||||
|
||||
gf_proc_dump_add_section("%s.%s - Memory usage", xl->type,xl->name);
|
||||
gf_proc_dump_write("num_types", "%d", xl->mem_acct.num_types);
|
||||
|
||||
for (i = 0; i < xl->mem_acct.num_types; i++) {
|
||||
if (!(memcmp (&xl->mem_acct.rec[i], &rec,
|
||||
sizeof(struct mem_acct))))
|
||||
continue;
|
||||
|
||||
gf_proc_dump_add_section("%s.%s - usage-type %d", xl->type,
|
||||
xl->name,i);
|
||||
gf_proc_dump_build_key(prefix, "memusage", "%s.%s.type.%d",
|
||||
xl->type, xl->name, i);
|
||||
gf_proc_dump_build_key(key, prefix, "size");
|
||||
gf_proc_dump_write(key, "%u", xl->mem_acct.rec[i].size);
|
||||
gf_proc_dump_build_key(key, prefix, "num_allocs");
|
||||
gf_proc_dump_write(key, "%u", xl->mem_acct.rec[i].num_allocs);
|
||||
gf_proc_dump_build_key(key, prefix, "max_size");
|
||||
gf_proc_dump_write(key, "%u", xl->mem_acct.rec[i].max_size);
|
||||
gf_proc_dump_build_key(key, prefix, "max_num_allocs");
|
||||
gf_proc_dump_write(key, "%u", xl->mem_acct.rec[i].max_num_allocs);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Currently this dumps only mallinfo. More can be built on here */
|
||||
void
|
||||
@ -138,6 +180,7 @@ gf_proc_dump_mem_info ()
|
||||
gf_proc_dump_write("mallinfo_fordblks", "%d", info.fordblks);
|
||||
gf_proc_dump_write("mallinfo_keepcost", "%d", info.keepcost);
|
||||
#endif
|
||||
gf_proc_dump_xlator_mem_info(&global_xlator);
|
||||
|
||||
}
|
||||
|
||||
@ -151,7 +194,9 @@ gf_proc_dump_xlator_info (xlator_t *this_xl)
|
||||
return;
|
||||
|
||||
while (this_xl) {
|
||||
|
||||
gf_proc_dump_latency_info (this_xl);
|
||||
gf_proc_dump_xlator_mem_info(this_xl);
|
||||
|
||||
if (!this_xl->dumpops) {
|
||||
this_xl = this_xl->next;
|
||||
|
@ -25,13 +25,14 @@
|
||||
#include "timer.h"
|
||||
#include "logging.h"
|
||||
#include "common-utils.h"
|
||||
#include "globals.h"
|
||||
|
||||
#define TS(tv) ((((unsigned long long) tv.tv_sec) * 1000000) + (tv.tv_usec))
|
||||
|
||||
gf_timer_t *
|
||||
gf_timer_call_after (glusterfs_ctx_t *ctx,
|
||||
struct timeval delta,
|
||||
gf_timer_cbk_t cbk,
|
||||
gf_timer_cbk_t callbk,
|
||||
void *data)
|
||||
{
|
||||
gf_timer_registry_t *reg = NULL;
|
||||
@ -52,7 +53,7 @@ gf_timer_call_after (glusterfs_ctx_t *ctx,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
event = CALLOC (1, sizeof (*event));
|
||||
event = GF_CALLOC (1, sizeof (*event), gf_common_mt_gf_timer_t);
|
||||
if (!event) {
|
||||
gf_log ("timer", GF_LOG_CRITICAL, "Not enough memory");
|
||||
return NULL;
|
||||
@ -62,8 +63,9 @@ gf_timer_call_after (glusterfs_ctx_t *ctx,
|
||||
event->at.tv_sec += ((event->at.tv_usec + delta.tv_usec) / 1000000);
|
||||
event->at.tv_sec += delta.tv_sec;
|
||||
at = TS (event->at);
|
||||
event->cbk = cbk;
|
||||
event->callbk = callbk;
|
||||
event->data = data;
|
||||
event->xl = THIS;
|
||||
pthread_mutex_lock (®->lock);
|
||||
{
|
||||
trav = reg->active.prev;
|
||||
@ -126,7 +128,7 @@ gf_timer_call_cancel (glusterfs_ctx_t *ctx,
|
||||
}
|
||||
pthread_mutex_unlock (®->lock);
|
||||
|
||||
FREE (event);
|
||||
GF_FREE (event);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -168,8 +170,10 @@ gf_timer_proc (void *ctx)
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock (®->lock);
|
||||
if (event->xl)
|
||||
THIS = event->xl;
|
||||
if (need_cbk)
|
||||
event->cbk (event->data);
|
||||
event->callbk (event->data);
|
||||
|
||||
else
|
||||
break;
|
||||
@ -189,7 +193,7 @@ gf_timer_proc (void *ctx)
|
||||
}
|
||||
pthread_mutex_unlock (®->lock);
|
||||
pthread_mutex_destroy (®->lock);
|
||||
FREE (((glusterfs_ctx_t *)ctx)->timer);
|
||||
GF_FREE (((glusterfs_ctx_t *)ctx)->timer);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -206,7 +210,8 @@ gf_timer_registry_init (glusterfs_ctx_t *ctx)
|
||||
if (!ctx->timer) {
|
||||
gf_timer_registry_t *reg = NULL;
|
||||
|
||||
ctx->timer = reg = CALLOC (1, sizeof (*reg));
|
||||
ctx->timer = reg = GF_CALLOC (1, sizeof (*reg),
|
||||
gf_common_mt_gf_timer_registry_t);
|
||||
ERR_ABORT (reg);
|
||||
pthread_mutex_init (®->lock, NULL);
|
||||
reg->active.next = ®->active;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#endif
|
||||
|
||||
#include "glusterfs.h"
|
||||
#include "xlator.h"
|
||||
#include <sys/time.h>
|
||||
#include <pthread.h>
|
||||
|
||||
@ -34,8 +35,9 @@ typedef void (*gf_timer_cbk_t) (void *);
|
||||
struct _gf_timer {
|
||||
struct _gf_timer *next, *prev;
|
||||
struct timeval at;
|
||||
gf_timer_cbk_t cbk;
|
||||
gf_timer_cbk_t callbk;
|
||||
void *data;
|
||||
xlator_t *xl;
|
||||
};
|
||||
|
||||
struct _gf_timer_registry {
|
||||
|
@ -52,7 +52,8 @@ transport_load (dict_t *options,
|
||||
GF_VALIDATE_OR_GOTO("transport", options, fail);
|
||||
GF_VALIDATE_OR_GOTO("transport", xl, fail);
|
||||
|
||||
trans = CALLOC (1, sizeof (struct transport));
|
||||
trans = GF_CALLOC (1, sizeof (struct transport),
|
||||
gf_common_mt_transport);
|
||||
GF_VALIDATE_OR_GOTO("transport", trans, fail);
|
||||
|
||||
trans->xl = xl;
|
||||
@ -107,14 +108,14 @@ transport_load (dict_t *options,
|
||||
|
||||
ret = dict_get_str (options, "transport-type", &type);
|
||||
if (ret < 0) {
|
||||
FREE (trans);
|
||||
GF_FREE (trans);
|
||||
gf_log ("transport", GF_LOG_ERROR,
|
||||
"'option transport-type <xx>' missing in volume '%s'",
|
||||
xl->name);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = asprintf (&name, "%s/%s.so", TRANSPORTDIR, type);
|
||||
ret = gf_asprintf (&name, "%s/%s.so", TRANSPORTDIR, type);
|
||||
if (-1 == ret) {
|
||||
gf_log ("transport", GF_LOG_ERROR, "asprintf failed");
|
||||
goto fail;
|
||||
@ -129,17 +130,17 @@ transport_load (dict_t *options,
|
||||
"volume '%s': transport-type '%s' is not valid or "
|
||||
"not found on this machine",
|
||||
xl->name, type);
|
||||
FREE (name);
|
||||
FREE (trans);
|
||||
GF_FREE (name);
|
||||
GF_FREE (trans);
|
||||
goto fail;
|
||||
}
|
||||
FREE (name);
|
||||
GF_FREE (name);
|
||||
|
||||
trans->ops = dlsym (handle, "tops");
|
||||
if (trans->ops == NULL) {
|
||||
gf_log ("transport", GF_LOG_ERROR,
|
||||
"dlsym (transport_ops) on %s", dlerror ());
|
||||
FREE (trans);
|
||||
GF_FREE (trans);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -147,7 +148,7 @@ transport_load (dict_t *options,
|
||||
if (trans->init == NULL) {
|
||||
gf_log ("transport", GF_LOG_ERROR,
|
||||
"dlsym (gf_transport_init) on %s", dlerror ());
|
||||
FREE (trans);
|
||||
GF_FREE (trans);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -155,11 +156,12 @@ transport_load (dict_t *options,
|
||||
if (trans->fini == NULL) {
|
||||
gf_log ("transport", GF_LOG_ERROR,
|
||||
"dlsym (gf_transport_fini) on %s", dlerror ());
|
||||
FREE (trans);
|
||||
GF_FREE (trans);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
vol_opt = CALLOC (1, sizeof (volume_opt_list_t));
|
||||
vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t),
|
||||
gf_common_mt_volume_opt_list_t);
|
||||
vol_opt->given_opt = dlsym (handle, "options");
|
||||
if (vol_opt->given_opt == NULL) {
|
||||
gf_log ("transport", GF_LOG_DEBUG,
|
||||
@ -171,7 +173,7 @@ transport_load (dict_t *options,
|
||||
vol_opt->given_opt)) {
|
||||
gf_log ("transport", GF_LOG_ERROR,
|
||||
"volume option validation failed");
|
||||
FREE (trans);
|
||||
GF_FREE (trans);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
@ -180,7 +182,7 @@ transport_load (dict_t *options,
|
||||
if (ret != 0) {
|
||||
gf_log ("transport", GF_LOG_ERROR,
|
||||
"'%s' initialization failed", type);
|
||||
FREE (trans);
|
||||
GF_FREE (trans);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -204,7 +206,8 @@ transport_submit (transport_t *this, char *buf, int32_t len,
|
||||
if (this->peer_trans) {
|
||||
peer_trans = this->peer_trans;
|
||||
|
||||
msg = CALLOC (1, sizeof (*msg));
|
||||
msg = GF_CALLOC (1, sizeof (*msg),
|
||||
gf_common_mt_transport_msg);
|
||||
if (!msg) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -215,8 +218,8 @@ transport_submit (transport_t *this, char *buf, int32_t len,
|
||||
if (vector) {
|
||||
iobuf = iobuf_get (this->xl->ctx->iobuf_pool);
|
||||
if (!iobuf) {
|
||||
FREE (msg->hdr);
|
||||
FREE (msg);
|
||||
GF_FREE (msg->hdr);
|
||||
GF_FREE (msg);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@ -293,7 +296,7 @@ transport_destroy (transport_t *this)
|
||||
this->fini (this);
|
||||
|
||||
pthread_mutex_destroy (&this->lock);
|
||||
FREE (this);
|
||||
GF_FREE (this);
|
||||
fail:
|
||||
return ret;
|
||||
}
|
||||
@ -391,7 +394,7 @@ transport_peerproc (void *trans_data)
|
||||
|
||||
xlator_notify (trans->xl, GF_EVENT_POLLIN, trans);
|
||||
|
||||
FREE (msg);
|
||||
GF_FREE (msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,9 @@ fill_defaults (xlator_t *xl)
|
||||
if (!xl->notify)
|
||||
xl->notify = default_notify;
|
||||
|
||||
if (!xl->mem_acct_init)
|
||||
xl->mem_acct_init = default_mem_acct_init;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -146,7 +149,8 @@ valid_ipv4_address (char *address, int length)
|
||||
char *tmp = NULL, *ptr = NULL, *prev = NULL, *endptr = NULL;
|
||||
char ret = 1;
|
||||
|
||||
prev = tmp = strdup (address);
|
||||
tmp = gf_strdup (address);
|
||||
prev = tmp;
|
||||
prev = strtok_r (tmp, ".", &ptr);
|
||||
|
||||
while (prev != NULL)
|
||||
@ -166,7 +170,7 @@ valid_ipv4_address (char *address, int length)
|
||||
}
|
||||
|
||||
out:
|
||||
FREE (tmp);
|
||||
GF_FREE (tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -178,7 +182,7 @@ valid_ipv6_address (char *address, int length)
|
||||
char *tmp = NULL, *ptr = NULL, *prev = NULL, *endptr = NULL;
|
||||
char ret = 1;
|
||||
|
||||
tmp = strdup (address);
|
||||
tmp = gf_strdup (address);
|
||||
prev = strtok_r (tmp, ":", &ptr);
|
||||
|
||||
while (prev != NULL)
|
||||
@ -199,7 +203,7 @@ valid_ipv6_address (char *address, int length)
|
||||
}
|
||||
|
||||
out:
|
||||
FREE (tmp);
|
||||
GF_FREE (tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -650,7 +654,7 @@ validate_xlator_volume_options (xlator_t *xl, volume_option_t *opt)
|
||||
" with correction",
|
||||
trav->key[i], trav->key[0]);
|
||||
/* TODO: some bytes lost */
|
||||
pairs->key = strdup (trav->key[0]);
|
||||
pairs->key = gf_strdup (trav->key[0]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -684,9 +688,9 @@ xlator_set_type (xlator_t *xl,
|
||||
return -1;
|
||||
}
|
||||
|
||||
xl->type = strdup (type);
|
||||
xl->type = gf_strdup (type);
|
||||
|
||||
ret = asprintf (&name, "%s/%s.so", XLATORDIR, type);
|
||||
ret = gf_asprintf (&name, "%s/%s.so", XLATORDIR, type);
|
||||
if (-1 == ret) {
|
||||
gf_log ("xlator", GF_LOG_ERROR, "asprintf failed");
|
||||
return -1;
|
||||
@ -740,9 +744,16 @@ xlator_set_type (xlator_t *xl,
|
||||
"dlsym(dumpops) on %s -- neglecting", dlerror ());
|
||||
}
|
||||
|
||||
if (!(xl->mem_acct_init = dlsym (handle, "mem_acct_init"))) {
|
||||
gf_log (xl->name, GF_LOG_DEBUG,
|
||||
"dlsym(mem_acct_init) on %s -- neglecting",
|
||||
dlerror ());
|
||||
}
|
||||
|
||||
INIT_LIST_HEAD (&xl->volume_options);
|
||||
|
||||
vol_opt = CALLOC (1, sizeof (volume_opt_list_t));
|
||||
vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t),
|
||||
gf_common_mt_volume_opt_list_t);
|
||||
|
||||
if (!(vol_opt->given_opt = dlsym (handle, "options"))) {
|
||||
dlerror ();
|
||||
@ -753,7 +764,7 @@ xlator_set_type (xlator_t *xl,
|
||||
|
||||
fill_defaults (xl);
|
||||
|
||||
FREE (name);
|
||||
GF_FREE (name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -825,6 +836,8 @@ xlator_init_rec (xlator_t *xl)
|
||||
|
||||
while (trav) {
|
||||
ret = -1;
|
||||
if (trav->mem_acct_init)
|
||||
trav->mem_acct_init (trav);
|
||||
if (trav->init && !trav->ready) {
|
||||
ret = xlator_init (trav);
|
||||
if (ret) {
|
||||
@ -940,6 +953,39 @@ xlator_init (xlator_t *xl)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
xlator_mem_acct_init (xlator_t *xl, int num_types)
|
||||
{
|
||||
int i = 0;
|
||||
int ret = 0;
|
||||
|
||||
if (!gf_mem_acct_is_enabled())
|
||||
return 0;
|
||||
|
||||
if (!xl)
|
||||
return -1;
|
||||
|
||||
xl->mem_acct.num_types = num_types;
|
||||
|
||||
xl->mem_acct.rec = calloc(num_types, sizeof(struct mem_acct_rec));
|
||||
|
||||
if (!xl->mem_acct.rec) {
|
||||
gf_log("xlator", GF_LOG_ERROR, "Out of Memory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
gf_log(xl->name, GF_LOG_DEBUG, "Allocated mem_acct_rec for %d types",
|
||||
num_types);
|
||||
|
||||
for (i = 0; i < num_types; i++) {
|
||||
ret = LOCK_INIT(&(xl->mem_acct.rec[i].lock));
|
||||
if (ret) {
|
||||
fprintf(stderr, "Unable to lock..errno : %d",errno);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
xlator_tree_fini (xlator_t *xl)
|
||||
@ -969,9 +1015,9 @@ xlator_tree_free (xlator_t *tree)
|
||||
while (prev) {
|
||||
trav = prev->next;
|
||||
dict_destroy (prev->options);
|
||||
FREE (prev->name);
|
||||
FREE (prev->type);
|
||||
FREE (prev);
|
||||
GF_FREE (prev->name);
|
||||
GF_FREE (prev->type);
|
||||
GF_FREE (prev);
|
||||
prev = trav;
|
||||
}
|
||||
|
||||
@ -987,7 +1033,7 @@ loc_wipe (loc_t *loc)
|
||||
loc->inode = NULL;
|
||||
}
|
||||
if (loc->path) {
|
||||
FREE (loc->path);
|
||||
GF_FREE ((char *)loc->path);
|
||||
loc->path = NULL;
|
||||
}
|
||||
|
||||
@ -1011,7 +1057,7 @@ loc_copy (loc_t *dst, loc_t *src)
|
||||
if (src->parent)
|
||||
dst->parent = inode_ref (src->parent);
|
||||
|
||||
dst->path = strdup (src->path);
|
||||
dst->path = gf_strdup (src->path);
|
||||
|
||||
if (!dst->path)
|
||||
goto out;
|
||||
|
@ -846,6 +846,7 @@ struct _xlator {
|
||||
|
||||
void (*fini) (xlator_t *this);
|
||||
int32_t (*init) (xlator_t *this);
|
||||
int32_t (*mem_acct_init) (xlator_t *this);
|
||||
event_notify_fn_t notify;
|
||||
|
||||
/* for latency measurement */
|
||||
@ -857,6 +858,7 @@ struct _xlator {
|
||||
char ready;
|
||||
char init_succeeded;
|
||||
void *private;
|
||||
struct mem_acct mem_acct;
|
||||
};
|
||||
|
||||
#define xlator_has_parent(xl) (xl->parents != NULL)
|
||||
@ -888,6 +890,7 @@ void inode_destroy_notify (inode_t *inode, const char *xlname);
|
||||
int loc_copy (loc_t *dst, loc_t *src);
|
||||
#define loc_dup(src, dst) loc_copy(dst, src)
|
||||
void loc_wipe (loc_t *loc);
|
||||
int xlator_mem_acct_init (xlator_t *xl, int num_types);
|
||||
|
||||
#define GF_STAT_PRINT_FMT_STR "%"PRIx64",%"PRIx64",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx64",%"PRIx64",%"PRIx32",%"PRIx64",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32"\n"
|
||||
|
||||
|
35
scheduler/alu/src/alu-mem-types.h
Normal file
35
scheduler/alu/src/alu-mem-types.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
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 __ALU_MEM_TYPES_H__
|
||||
#define __ALU_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_alu_mem_types_ {
|
||||
gf_alu_mt_alu_threshold = gf_common_mt_end + 1,
|
||||
gf_alu_mt_alu_sched,
|
||||
gf_alu_mt_alu_limits,
|
||||
gf_alu_mt_alu_sched_struct,
|
||||
gf_alu_mt_alu_sched_node,
|
||||
gf_alu_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <stdint.h>
|
||||
#include "stack.h"
|
||||
#include "alu.h"
|
||||
#include "alu-mem-types.h"
|
||||
|
||||
#define ALU_DISK_USAGE_ENTRY_THRESHOLD_DEFAULT (1 * GF_UNIT_GB)
|
||||
#define ALU_DISK_USAGE_EXIT_THRESHOLD_DEFAULT (512 * GF_UNIT_MB)
|
||||
@ -146,7 +147,9 @@ alu_parse_options (xlator_t *xl, struct alu_sched *alu_sched)
|
||||
if (strcmp (order_str, "disk-usage") == 0) {
|
||||
/* Disk usage */
|
||||
_threshold_fn =
|
||||
CALLOC (1, sizeof (struct alu_threshold));
|
||||
GF_CALLOC (1,
|
||||
sizeof (struct alu_threshold),
|
||||
gf_alu_mt_alu_threshold);
|
||||
ERR_ABORT (_threshold_fn);
|
||||
_threshold_fn->diff_value = get_max_diff_disk_usage;
|
||||
_threshold_fn->sched_value = get_stats_disk_usage;
|
||||
@ -199,7 +202,7 @@ alu_parse_options (xlator_t *xl, struct alu_sched *alu_sched)
|
||||
} else if (strcmp (order_str, "write-usage") == 0) {
|
||||
/* Handle "write-usage" */
|
||||
|
||||
_threshold_fn = CALLOC (1, sizeof (struct alu_threshold));
|
||||
_threshold_fn = GF_CALLOC (1, sizeof (struct alu_threshold), gf_alu_mt_alu_threshold);
|
||||
ERR_ABORT (_threshold_fn);
|
||||
_threshold_fn->diff_value = get_max_diff_write_usage;
|
||||
_threshold_fn->sched_value = get_stats_write_usage;
|
||||
@ -252,7 +255,7 @@ alu_parse_options (xlator_t *xl, struct alu_sched *alu_sched)
|
||||
} else if (strcmp (order_str, "read-usage") == 0) {
|
||||
/* Read usage */
|
||||
|
||||
_threshold_fn = CALLOC (1, sizeof (struct alu_threshold));
|
||||
_threshold_fn = GF_CALLOC (1, sizeof (struct alu_threshold), gf_alu_mt_alu_threshold);
|
||||
ERR_ABORT (_threshold_fn);
|
||||
_threshold_fn->diff_value = get_max_diff_read_usage;
|
||||
_threshold_fn->sched_value = get_stats_read_usage;
|
||||
@ -311,7 +314,7 @@ alu_parse_options (xlator_t *xl, struct alu_sched *alu_sched)
|
||||
} else if (strcmp (order_str, "open-files-usage") == 0) {
|
||||
/* Open files counter */
|
||||
|
||||
_threshold_fn = CALLOC (1, sizeof (struct alu_threshold));
|
||||
_threshold_fn = GF_CALLOC (1, sizeof (struct alu_threshold), gf_alu_mt_alu_threshold);
|
||||
ERR_ABORT (_threshold_fn);
|
||||
_threshold_fn->diff_value = get_max_diff_file_usage;
|
||||
_threshold_fn->sched_value = get_stats_file_usage;
|
||||
@ -372,7 +375,7 @@ alu_parse_options (xlator_t *xl, struct alu_sched *alu_sched)
|
||||
} else if (strcmp (order_str, "disk-speed-usage") == 0) {
|
||||
/* Disk speed */
|
||||
|
||||
_threshold_fn = CALLOC (1, sizeof (struct alu_threshold));
|
||||
_threshold_fn = GF_CALLOC (1, sizeof (struct alu_threshold), gf_alu_mt_alu_threshold);
|
||||
ERR_ABORT (_threshold_fn);
|
||||
_threshold_fn->diff_value = get_max_diff_disk_speed;
|
||||
_threshold_fn->sched_value = get_stats_disk_speed;
|
||||
@ -423,7 +426,8 @@ alu_init (xlator_t *xl)
|
||||
uint32_t min_free_disk = 0;
|
||||
data_t *limits = NULL;
|
||||
|
||||
alu_sched = CALLOC (1, sizeof (struct alu_sched));
|
||||
alu_sched = GF_CALLOC (1, sizeof (struct alu_sched),
|
||||
gf_alu_mt_alu_sched);
|
||||
ERR_ABORT (alu_sched);
|
||||
|
||||
{
|
||||
@ -435,7 +439,8 @@ alu_init (xlator_t *xl)
|
||||
limits = dict_get (xl->options,
|
||||
"scheduler.limits.min-free-disk");
|
||||
if (limits) {
|
||||
_limit_fn = CALLOC (1, sizeof (struct alu_limits));
|
||||
_limit_fn = GF_CALLOC (1, sizeof (struct alu_limits),
|
||||
gf_alu_mt_alu_limits);
|
||||
ERR_ABORT (_limit_fn);
|
||||
_limit_fn->min_value = get_stats_free_disk;
|
||||
_limit_fn->cur_value = get_stats_free_disk;
|
||||
@ -470,7 +475,8 @@ alu_init (xlator_t *xl)
|
||||
"scheduler.limits.max-open-files");
|
||||
if (limits) {
|
||||
// Update alu_sched->priority properly
|
||||
_limit_fn = CALLOC (1, sizeof (struct alu_limits));
|
||||
_limit_fn = GF_CALLOC (1, sizeof (struct alu_limits),
|
||||
gf_alu_mt_alu_limits);
|
||||
ERR_ABORT (_limit_fn);
|
||||
_limit_fn->max_value = get_stats_file_usage;
|
||||
_limit_fn->cur_value = get_stats_file_usage;
|
||||
@ -539,7 +545,7 @@ alu_init (xlator_t *xl)
|
||||
trav_xl = trav_xl->next;
|
||||
}
|
||||
alu_sched->child_count = index;
|
||||
sched_array = CALLOC (index, sizeof (struct alu_sched_struct));
|
||||
sched_array = GF_CALLOC (index, sizeof (struct alu_sched_struct), gf_alu_mt_alu_sched_struct);
|
||||
ERR_ABORT (sched_array);
|
||||
trav_xl = xl->children;
|
||||
index = 0;
|
||||
@ -556,7 +562,7 @@ alu_init (xlator_t *xl)
|
||||
if (data) {
|
||||
char *child = NULL;
|
||||
char *tmp = NULL;
|
||||
char *childs_data = strdup (data->data);
|
||||
char *childs_data = gf_strdup (data->data);
|
||||
|
||||
child = strtok_r (childs_data, ",", &tmp);
|
||||
while (child) {
|
||||
@ -604,18 +610,18 @@ alu_fini (xlator_t *xl)
|
||||
struct alu_threshold *threshold = alu_sched->threshold_fn;
|
||||
void *tmp = NULL;
|
||||
pthread_mutex_destroy (&alu_sched->alu_mutex);
|
||||
free (alu_sched->array);
|
||||
GF_FREE (alu_sched->array);
|
||||
while (limit) {
|
||||
tmp = limit;
|
||||
limit = limit->next;
|
||||
free (tmp);
|
||||
GF_FREE (tmp);
|
||||
}
|
||||
while (threshold) {
|
||||
tmp = threshold;
|
||||
threshold = threshold->next;
|
||||
free (tmp);
|
||||
GF_FREE (tmp);
|
||||
}
|
||||
free (alu_sched);
|
||||
GF_FREE (alu_sched);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
@ -785,7 +791,7 @@ alu_scheduler (xlator_t *xl, const void *path)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
tmp_sched_node = CALLOC (1, sizeof (struct alu_sched_node));
|
||||
tmp_sched_node = GF_CALLOC (1, sizeof (struct alu_sched_node), gf_alu_mt_alu_sched_node);
|
||||
ERR_ABORT (tmp_sched_node);
|
||||
tmp_sched_node->index = idx;
|
||||
if (!alu_sched->sched_node) {
|
||||
@ -808,7 +814,7 @@ alu_scheduler (xlator_t *xl, const void *path)
|
||||
if (alu_sched->array[sched_index].eligible)
|
||||
break;
|
||||
alu_sched->sched_node = trav_sched_node->next;
|
||||
free (trav_sched_node);
|
||||
GF_FREE (trav_sched_node);
|
||||
alu_sched->sched_nodes_pending--;
|
||||
}
|
||||
if (alu_sched->sched_nodes_pending) {
|
||||
@ -823,7 +829,7 @@ alu_scheduler (xlator_t *xl, const void *path)
|
||||
/* Free the allocated info for the node :) */
|
||||
pthread_mutex_lock (&alu_sched->alu_mutex);
|
||||
alu_sched->sched_node = trav_sched_node->next;
|
||||
free (trav_sched_node);
|
||||
GF_FREE (trav_sched_node);
|
||||
trav_sched_node = alu_sched->sched_node;
|
||||
alu_sched->sched_nodes_pending--;
|
||||
pthread_mutex_unlock (&alu_sched->alu_mutex);
|
||||
@ -832,7 +838,7 @@ alu_scheduler (xlator_t *xl, const void *path)
|
||||
/* if there is no exit value, then exit after scheduling once */
|
||||
pthread_mutex_lock (&alu_sched->alu_mutex);
|
||||
alu_sched->sched_node = trav_sched_node->next;
|
||||
free (trav_sched_node);
|
||||
GF_FREE (trav_sched_node);
|
||||
trav_sched_node = alu_sched->sched_node;
|
||||
alu_sched->sched_nodes_pending--;
|
||||
pthread_mutex_unlock (&alu_sched->alu_mutex);
|
||||
@ -928,12 +934,32 @@ alu_notify (xlator_t *xl, int32_t event, void *data)
|
||||
|
||||
}
|
||||
|
||||
int32_t
|
||||
alu_mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!this)
|
||||
return ret;
|
||||
|
||||
ret = xlator_mem_acct_init (this, gf_alu_mt_end + 1);
|
||||
|
||||
if (ret != 0) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
|
||||
"failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct sched_ops sched = {
|
||||
.init = alu_init,
|
||||
.fini = alu_fini,
|
||||
.update = alu_update,
|
||||
.schedule = alu_scheduler,
|
||||
.notify = alu_notify
|
||||
.notify = alu_notify,
|
||||
.mem_acct_init = alu_mem_acct_init,
|
||||
};
|
||||
|
||||
struct volume_options options[] = {
|
||||
|
33
scheduler/nufa/src/nufa-mem-types.h
Normal file
33
scheduler/nufa/src/nufa-mem-types.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
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 __NUFA_MEM_TYPES_H__
|
||||
#define __NUFA_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_locks_mem_types_ {
|
||||
gf_nufa_mt_nufa_struct = gf_common_mt_end + 1,
|
||||
gf_nufa_mt_nufa_sched_struct,
|
||||
gf_nufa_mt_int32_t,
|
||||
gf_nufa_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "scheduler.h"
|
||||
#include "common-utils.h"
|
||||
#include "nufa-mem-types.h"
|
||||
|
||||
struct nufa_sched_struct {
|
||||
xlator_t *xl;
|
||||
@ -63,7 +64,8 @@ nufa_init (xlator_t *xl)
|
||||
xlator_list_t *trav_xl = xl->children;
|
||||
struct nufa_struct *nufa_buf = NULL;
|
||||
|
||||
nufa_buf = CALLOC (1, sizeof (struct nufa_struct));
|
||||
nufa_buf = GF_CALLOC (1, sizeof (struct nufa_struct),
|
||||
gf_nufa_mt_nufa_struct);
|
||||
ERR_ABORT (nufa_buf);
|
||||
|
||||
data = dict_get (xl->options, "scheduler.limits.min-free-disk");
|
||||
@ -112,9 +114,11 @@ nufa_init (xlator_t *xl)
|
||||
}
|
||||
nufa_buf->child_count = index;
|
||||
nufa_buf->sched_index = 0;
|
||||
nufa_buf->array = CALLOC (index, sizeof (struct nufa_sched_struct));
|
||||
nufa_buf->array = GF_CALLOC (index, sizeof (struct nufa_sched_struct),
|
||||
gf_nufa_mt_nufa_sched_struct);
|
||||
ERR_ABORT (nufa_buf->array);
|
||||
nufa_buf->local_array = CALLOC (index, sizeof (int32_t));
|
||||
nufa_buf->local_array = GF_CALLOC (index, sizeof (int32_t),
|
||||
gf_nufa_mt_int32_t);
|
||||
ERR_ABORT (nufa_buf->array);
|
||||
trav_xl = xl->children;
|
||||
|
||||
@ -123,9 +127,9 @@ nufa_init (xlator_t *xl)
|
||||
/* Error */
|
||||
gf_log ("nufa", GF_LOG_ERROR,
|
||||
"No 'local-volume-name' option given in volume file");
|
||||
FREE (nufa_buf->array);
|
||||
FREE (nufa_buf->local_array);
|
||||
FREE (nufa_buf);
|
||||
GF_FREE (nufa_buf->array);
|
||||
GF_FREE (nufa_buf->local_array);
|
||||
GF_FREE (nufa_buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -147,7 +151,7 @@ nufa_init (xlator_t *xl)
|
||||
int32_t array_index = 0;
|
||||
char *child = NULL;
|
||||
char *tmp = NULL;
|
||||
char *childs_data = strdup (local_name->data);
|
||||
char *childs_data = gf_strdup (local_name->data);
|
||||
|
||||
child = strtok_r (childs_data, ",", &tmp);
|
||||
while (child) {
|
||||
@ -168,9 +172,9 @@ nufa_init (xlator_t *xl)
|
||||
gf_log ("nufa", GF_LOG_ERROR,
|
||||
"option 'scheduler.local-volume-name' "
|
||||
"%s is wrong", child);
|
||||
FREE (nufa_buf->array);
|
||||
FREE (nufa_buf->local_array);
|
||||
FREE (nufa_buf);
|
||||
GF_FREE (nufa_buf->array);
|
||||
GF_FREE (nufa_buf->local_array);
|
||||
GF_FREE (nufa_buf);
|
||||
return -1;
|
||||
} else {
|
||||
nufa_buf->local_array[array_index++] = index;
|
||||
@ -178,7 +182,7 @@ nufa_init (xlator_t *xl)
|
||||
}
|
||||
child = strtok_r (NULL, ",", &tmp);
|
||||
}
|
||||
free (childs_data);
|
||||
GF_FREE (childs_data);
|
||||
}
|
||||
|
||||
LOCK_INIT (&nufa_buf->nufa_lock);
|
||||
@ -193,9 +197,9 @@ nufa_fini (xlator_t *xl)
|
||||
(struct nufa_struct *)*((long *)xl->private);
|
||||
|
||||
LOCK_DESTROY (&nufa_buf->nufa_lock);
|
||||
FREE (nufa_buf->local_array);
|
||||
FREE (nufa_buf->array);
|
||||
FREE (nufa_buf);
|
||||
GF_FREE (nufa_buf->local_array);
|
||||
GF_FREE (nufa_buf->array);
|
||||
GF_FREE (nufa_buf);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
@ -379,12 +383,32 @@ nufa_notify (xlator_t *xl, int32_t event, void *data)
|
||||
|
||||
}
|
||||
|
||||
int32_t
|
||||
nufa_mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!this)
|
||||
return ret;
|
||||
|
||||
ret = xlator_mem_acct_init (this, gf_nufa_mt_end + 1);
|
||||
|
||||
if (ret != 0) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
|
||||
"failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct sched_ops sched = {
|
||||
.init = nufa_init,
|
||||
.fini = nufa_fini,
|
||||
.update = nufa_update,
|
||||
.schedule = nufa_schedule,
|
||||
.notify = nufa_notify
|
||||
.notify = nufa_notify,
|
||||
.mem_acct_init = nufa_mem_acct_init,
|
||||
};
|
||||
|
||||
struct volume_options options[] = {
|
||||
|
32
scheduler/random/src/random-mem-types.h
Normal file
32
scheduler/random/src/random-mem-types.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
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 __RANDOM_MEM_TYPES_H__
|
||||
#define __RANDOM_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_random_mem_types_ {
|
||||
gf_random_mt_random_struct = gf_common_mt_end + 1,
|
||||
gf_random_mt_random_sched_struct,
|
||||
gf_random_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -26,6 +26,7 @@
|
||||
#endif
|
||||
|
||||
#include "random.h"
|
||||
#include "random-mem-types.h"
|
||||
|
||||
#define RANDOM_LIMITS_MIN_FREE_DISK_DEFAULT 15
|
||||
#define RANDOM_REFRESH_INTERVAL_DEFAULT 10
|
||||
@ -39,7 +40,8 @@ random_init (xlator_t *xl)
|
||||
data_t *limit = NULL;
|
||||
int32_t index = 0;
|
||||
|
||||
random_buf = CALLOC (1, sizeof (struct random_struct));
|
||||
random_buf = GF_CALLOC (1, sizeof (struct random_struct),
|
||||
gf_random_mt_random_struct);
|
||||
ERR_ABORT (random_buf);
|
||||
|
||||
/* Set the seed for the 'random' function */
|
||||
@ -89,8 +91,9 @@ random_init (xlator_t *xl)
|
||||
trav_xl = trav_xl->next;
|
||||
}
|
||||
random_buf->child_count = index;
|
||||
random_buf->array = CALLOC (index,
|
||||
sizeof (struct random_sched_struct));
|
||||
random_buf->array = GF_CALLOC (index,
|
||||
sizeof (struct random_sched_struct),
|
||||
gf_random_mt_random_sched_struct);
|
||||
ERR_ABORT (random_buf->array);
|
||||
trav_xl = xl->children;
|
||||
index = 0;
|
||||
@ -115,8 +118,8 @@ random_fini (xlator_t *xl)
|
||||
|
||||
random_buf = (struct random_struct *)*((long *)xl->private);
|
||||
pthread_mutex_destroy (&random_buf->random_mutex);
|
||||
free (random_buf->array);
|
||||
free (random_buf);
|
||||
GF_FREE (random_buf->array);
|
||||
GF_FREE (random_buf);
|
||||
}
|
||||
|
||||
|
||||
@ -222,6 +225,24 @@ random_schedule (xlator_t *xl, const void *path)
|
||||
return random_buf->array[rand].xl;
|
||||
}
|
||||
|
||||
int32_t
|
||||
random_mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!this)
|
||||
return ret;
|
||||
|
||||
ret = xlator_mem_acct_init (this, gf_random_mt_end + 1);
|
||||
|
||||
if (ret != 0) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
|
||||
" failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* notify
|
||||
@ -267,7 +288,8 @@ struct sched_ops sched = {
|
||||
.fini = random_fini,
|
||||
.update = random_update,
|
||||
.schedule = random_schedule,
|
||||
.notify = random_notify
|
||||
.notify = random_notify,
|
||||
.mem_acct_init = random_mem_acct_init,
|
||||
};
|
||||
|
||||
struct volume_options options[] = {
|
||||
|
32
scheduler/rr/src/rr-mem-types.h
Normal file
32
scheduler/rr/src/rr-mem-types.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
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 __RR_MEM_TYPES_H__
|
||||
#define __RR_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_rr_mem_types_ {
|
||||
gf_rr_mt_rr_t = gf_common_mt_end + 1,
|
||||
gf_rr_mt_rr_subvolume_t,
|
||||
gf_rr_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -143,9 +143,9 @@ _rr_options_read_only_subvolumes_validate (const char *value_string,
|
||||
free_exit:
|
||||
for (i = 0; i < vcount; i++)
|
||||
{
|
||||
free (vlist[i]);
|
||||
GF_FREE (vlist[i]);
|
||||
}
|
||||
free (vlist);
|
||||
GF_FREE (vlist);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include "rr-options.h"
|
||||
#include "rr.h"
|
||||
#include "rr-mem-types.h"
|
||||
|
||||
#define RR_MIN_FREE_DISK_NOT_REACHED 0
|
||||
#define RR_MIN_FREE_DISK_REACHED 1
|
||||
@ -58,14 +59,14 @@ _cleanup_rr (rr_t *rr)
|
||||
{
|
||||
for (i = 0; i < rr->options.read_only_subvolume_count; i++)
|
||||
{
|
||||
free (rr->options.read_only_subvolume_list[i]);
|
||||
GF_FREE (rr->options.read_only_subvolume_list[i]);
|
||||
}
|
||||
free (rr->options.read_only_subvolume_list);
|
||||
GF_FREE (rr->options.read_only_subvolume_list);
|
||||
}
|
||||
|
||||
free (rr->subvolume_list);
|
||||
GF_FREE (rr->subvolume_list);
|
||||
|
||||
free (rr);
|
||||
GF_FREE (rr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -95,14 +96,14 @@ rr_init (xlator_t *this_xl)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((rr = CALLOC (1, sizeof (rr_t))) == NULL)
|
||||
if ((rr = GF_CALLOC (1, sizeof (rr_t), gf_rr_mt_rr_t)) == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rr_options_validate (options, &rr->options) != 0)
|
||||
{
|
||||
free (rr);
|
||||
GF_FREE (rr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -147,8 +148,9 @@ rr_init (xlator_t *this_xl)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((rr->subvolume_list = CALLOC (rr->subvolume_count,
|
||||
sizeof (rr_subvolume_t))) == NULL)
|
||||
if ((rr->subvolume_list = GF_CALLOC (rr->subvolume_count,
|
||||
sizeof (rr_subvolume_t),
|
||||
gf_rr_mt_rr_subvolume_t)) == NULL)
|
||||
{
|
||||
_cleanup_rr (rr);
|
||||
return -1;
|
||||
@ -476,7 +478,7 @@ rr_notify (xlator_t *this_xl, int32_t event, void *data)
|
||||
if (xattr)
|
||||
dict_ref (xattr);
|
||||
|
||||
loc.path = strdup ("/");
|
||||
loc.path = gf_strdup ("/");
|
||||
for (trav = this_xl->parents->xlator; trav; trav = trav->parents->xlator) {
|
||||
if (trav->itable) {
|
||||
loc.inode = trav->itable->root;
|
||||
|
33
scheduler/switch/src/switch-mem-types.h
Normal file
33
scheduler/switch/src/switch-mem-types.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
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 __SWITCH_MEM_TYPES_H__
|
||||
#define __SWITCH_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_switch_mem_types_ {
|
||||
gf_switch_mt_switch_struct = gf_common_mt_end + 1,
|
||||
gf_switch_mt_switch_sched_struct,
|
||||
gf_switch_mt_switch_sched_array,
|
||||
gf_switch_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "xlator.h"
|
||||
#include "scheduler.h"
|
||||
#include "switch-mem-types.h"
|
||||
|
||||
struct switch_sched_array {
|
||||
xlator_t *xl;
|
||||
@ -58,20 +59,20 @@ static xlator_t *
|
||||
switch_get_matching_xl (const char *path, struct switch_sched_struct *cond)
|
||||
{
|
||||
struct switch_sched_struct *trav = cond;
|
||||
char *pathname = strdup (path);
|
||||
char *pathname = gf_strdup (path);
|
||||
int index = 0;
|
||||
|
||||
while (trav) {
|
||||
if (fnmatch (trav->path_pattern,
|
||||
pathname, FNM_NOESCAPE) == 0) {
|
||||
free (pathname);
|
||||
GF_FREE (pathname);
|
||||
trav->node_index %= trav->num_child;
|
||||
index = (trav->node_index++) % trav->num_child;
|
||||
return trav->array[index].xl;
|
||||
}
|
||||
trav = trav->next;
|
||||
}
|
||||
free (pathname);
|
||||
GF_FREE (pathname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -107,7 +108,8 @@ switch_init (xlator_t *xl)
|
||||
xlator_list_t *trav_xl = xl->children;
|
||||
struct switch_struct *switch_buf = NULL;
|
||||
|
||||
switch_buf = CALLOC (1, sizeof (struct switch_struct));
|
||||
switch_buf = GF_CALLOC (1, sizeof (struct switch_struct),
|
||||
gf_switch_mt_switch_struct);
|
||||
ERR_ABORT (switch_buf);
|
||||
|
||||
while (trav_xl) {
|
||||
@ -115,8 +117,9 @@ switch_init (xlator_t *xl)
|
||||
trav_xl = trav_xl->next;
|
||||
}
|
||||
switch_buf->child_count = index;
|
||||
switch_buf->array = CALLOC (index + 1,
|
||||
sizeof (struct switch_sched_struct));
|
||||
switch_buf->array = GF_CALLOC (index + 1,
|
||||
sizeof (struct switch_sched_struct),
|
||||
gf_switch_mt_switch_sched_struct);
|
||||
ERR_ABORT (switch_buf->array);
|
||||
trav_xl = xl->children;
|
||||
index = 0;
|
||||
@ -130,7 +133,7 @@ switch_init (xlator_t *xl)
|
||||
|
||||
data = dict_get (xl->options, "scheduler.read-only-subvolumes");
|
||||
if (data) {
|
||||
childs_data = strdup (data->data);
|
||||
childs_data = gf_strdup (data->data);
|
||||
child = strtok_r (childs_data, ",", &tmp);
|
||||
while (child) {
|
||||
for (index = 1;
|
||||
@ -148,7 +151,7 @@ switch_init (xlator_t *xl)
|
||||
}
|
||||
child = strtok_r (NULL, ",", &tmp);
|
||||
}
|
||||
free (childs_data);
|
||||
GF_FREE (childs_data);
|
||||
}
|
||||
|
||||
data = dict_get (xl->options, "scheduler.local-volume-name");
|
||||
@ -176,10 +179,9 @@ switch_init (xlator_t *xl)
|
||||
"option block-size *avi:10MB" etc */
|
||||
switch_str = strtok_r (data->data, ";", &tmp_str);
|
||||
while (switch_str) {
|
||||
dup_str = strdup (switch_str);
|
||||
dup_str = gf_strdup (switch_str);
|
||||
switch_opt =
|
||||
CALLOC (1,
|
||||
sizeof (struct switch_sched_struct));
|
||||
GF_CALLOC (1, sizeof (struct switch_sched_struct), gf_switch_mt_switch_sched_struct);
|
||||
ERR_ABORT (switch_opt);
|
||||
|
||||
/* Link it to the main structure */
|
||||
@ -201,7 +203,7 @@ switch_init (xlator_t *xl)
|
||||
"for all the unconfigured child nodes,"
|
||||
" hence neglecting current option");
|
||||
switch_str = strtok_r (NULL, ";", &tmp_str);
|
||||
free (dup_str);
|
||||
GF_FREE (dup_str);
|
||||
continue;
|
||||
}
|
||||
memcpy (switch_opt->path_pattern,
|
||||
@ -212,7 +214,7 @@ switch_init (xlator_t *xl)
|
||||
char *dup_childs = NULL;
|
||||
/* TODO: get the list of child nodes for
|
||||
the given pattern */
|
||||
dup_childs = strdup (childs);
|
||||
dup_childs = gf_strdup (childs);
|
||||
child = strtok_r (dup_childs, ",", &tmp);
|
||||
while (child) {
|
||||
if (gf_unify_valid_child (child, xl)) {
|
||||
@ -229,11 +231,11 @@ switch_init (xlator_t *xl)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
free (dup_childs);
|
||||
GF_FREE (dup_childs);
|
||||
child = strtok_r (childs, ",", &tmp1);
|
||||
switch_opt->num_child = idx;
|
||||
switch_opt->array =
|
||||
CALLOC (1, idx * sizeof (struct switch_sched_array));
|
||||
GF_CALLOC (1, idx * sizeof (struct switch_sched_array), gf_switch_mt_switch_sched_array);
|
||||
ERR_ABORT (switch_opt->array);
|
||||
idx = 0;
|
||||
child = strtok_r (childs, ",", &tmp);
|
||||
@ -267,11 +269,11 @@ switch_init (xlator_t *xl)
|
||||
gf_log ("switch", GF_LOG_ERROR,
|
||||
"Check \"scheduler.switch.case\" "
|
||||
"option in unify volume. Exiting");
|
||||
free (switch_buf->array);
|
||||
free (switch_buf);
|
||||
GF_FREE (switch_buf->array);
|
||||
GF_FREE (switch_buf);
|
||||
return -1;
|
||||
}
|
||||
free (dup_str);
|
||||
GF_FREE (dup_str);
|
||||
switch_str = strtok_r (NULL, ";", &tmp_str);
|
||||
}
|
||||
}
|
||||
@ -293,7 +295,7 @@ switch_init (xlator_t *xl)
|
||||
"No nodes left for pattern '*'. Exiting.");
|
||||
return -1;
|
||||
}
|
||||
switch_opt = CALLOC (1, sizeof (struct switch_sched_struct));
|
||||
switch_opt = GF_CALLOC (1, sizeof (struct switch_sched_struct), gf_switch_mt_switch_sched_struct);
|
||||
ERR_ABORT (switch_opt);
|
||||
if (switch_buf->cond) {
|
||||
/* there are already few entries */
|
||||
@ -309,7 +311,7 @@ switch_init (xlator_t *xl)
|
||||
memcpy (switch_opt->path_pattern, "*", 2);
|
||||
switch_opt->num_child = flag;
|
||||
switch_opt->array =
|
||||
CALLOC (1, flag * sizeof (struct switch_sched_array));
|
||||
GF_CALLOC (1, flag * sizeof (struct switch_sched_array), gf_switch_mt_switch_sched_array);
|
||||
ERR_ABORT (switch_opt->array);
|
||||
flag = 0;
|
||||
for (index=0; index < switch_buf->child_count; index++) {
|
||||
@ -343,8 +345,8 @@ switch_fini (xlator_t *xl)
|
||||
switch_buf = (struct switch_struct *)*((long *)xl->private);
|
||||
|
||||
pthread_mutex_destroy (&switch_buf->switch_mutex);
|
||||
free (switch_buf->array);
|
||||
free (switch_buf);
|
||||
GF_FREE (switch_buf->array);
|
||||
GF_FREE (switch_buf);
|
||||
}
|
||||
|
||||
static xlator_t *
|
||||
@ -403,13 +405,33 @@ switch_update (xlator_t *xl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t
|
||||
switch_mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!this)
|
||||
return ret;
|
||||
|
||||
ret = xlator_mem_acct_init (this, gf_switch_mt_end + 1);
|
||||
|
||||
if (ret != 0) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
|
||||
" failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct sched_ops sched = {
|
||||
.init = switch_init,
|
||||
.fini = switch_fini,
|
||||
.update = switch_update,
|
||||
.schedule = switch_schedule,
|
||||
.notify = switch_notify
|
||||
.notify = switch_notify,
|
||||
.mem_acct_init = switch_mem_acct_init,
|
||||
};
|
||||
|
||||
struct volume_options options[] = {
|
||||
|
39
transport/ib-verbs/src/ib-verbs-mem-types.h
Normal file
39
transport/ib-verbs/src/ib-verbs-mem-types.h
Normal file
@ -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 __IB_VERBS_MEM_TYPES_H__
|
||||
#define __IB_VERBS_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_ib_verbs_mem_types_ {
|
||||
gf_ibv_mt_ib_verbs_private_t = gf_common_mt_end + 1,
|
||||
gf_ibv_mt_ib_verbs_ioq_t,
|
||||
gf_ibv_mt_transport_t,
|
||||
gf_ibv_mt_ib_verbs_local_t,
|
||||
gf_ibv_mt_ib_verbs_post_t,
|
||||
gf_ibv_mt_char,
|
||||
gf_ibv_mt_qpent,
|
||||
gf_ibv_mt_ib_verbs_device_t,
|
||||
gf_ibv_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -156,7 +156,8 @@ ib_verbs_new_post (ib_verbs_device_t *device, int32_t len)
|
||||
{
|
||||
ib_verbs_post_t *post;
|
||||
|
||||
post = (ib_verbs_post_t *) CALLOC (1, sizeof (*post));
|
||||
post = (ib_verbs_post_t *) GF_CALLOC (1, sizeof (*post),
|
||||
gf_ibv_mt_ib_verbs_post_t);
|
||||
if (!post)
|
||||
return NULL;
|
||||
|
||||
@ -164,7 +165,7 @@ ib_verbs_new_post (ib_verbs_device_t *device, int32_t len)
|
||||
|
||||
post->buf = valloc (len);
|
||||
if (!post->buf) {
|
||||
free (post);
|
||||
GF_FREE (post);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -174,7 +175,7 @@ ib_verbs_new_post (ib_verbs_device_t *device, int32_t len)
|
||||
IBV_ACCESS_LOCAL_WRITE);
|
||||
if (!post->mr) {
|
||||
free (post->buf);
|
||||
free (post);
|
||||
GF_FREE (post);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -216,7 +217,7 @@ ib_verbs_destroy_post (ib_verbs_post_t *post)
|
||||
{
|
||||
ibv_dereg_mr (post->mr);
|
||||
free (post->buf);
|
||||
free (post);
|
||||
GF_FREE (post);
|
||||
}
|
||||
|
||||
|
||||
@ -258,10 +259,10 @@ __ib_verbs_ioq_entry_free (ib_verbs_ioq_t *entry)
|
||||
iobref_unref (entry->iobref);
|
||||
|
||||
/* TODO: use mem-pool */
|
||||
free (entry->buf);
|
||||
GF_FREE (entry->buf);
|
||||
|
||||
/* TODO: use mem-pool */
|
||||
free (entry);
|
||||
GF_FREE (entry);
|
||||
}
|
||||
|
||||
|
||||
@ -497,7 +498,7 @@ ib_verbs_ioq_new (char *buf, int len, struct iovec *vector,
|
||||
ib_verbs_ioq_t *entry = NULL;
|
||||
|
||||
/* TODO: use mem-pool */
|
||||
entry = CALLOC (1, sizeof (*entry));
|
||||
entry = GF_CALLOC (1, sizeof (*entry), gf_ibv_mt_ib_verbs_ioq_t);
|
||||
|
||||
assert (count <= (MAX_IOVEC-2));
|
||||
|
||||
@ -602,7 +603,7 @@ ib_verbs_receive (transport_t *this, char **hdr_p, size_t *hdrlen_p,
|
||||
copy_from += sizeof (*header);
|
||||
|
||||
if (size1) {
|
||||
hdr = CALLOC (1, size1);
|
||||
hdr = GF_CALLOC (1, size1, gf_ibv_mt_char);
|
||||
if (!hdr) {
|
||||
gf_log (this->xl->name, GF_LOG_ERROR,
|
||||
"unable to allocate header for peer %s",
|
||||
@ -729,7 +730,7 @@ ib_verbs_register_peer (ib_verbs_device_t *device,
|
||||
pthread_mutex_unlock (&qpreg->lock);
|
||||
return;
|
||||
}
|
||||
ent = (struct _qpent *) CALLOC (1, sizeof (*ent));
|
||||
ent = (struct _qpent *) GF_CALLOC (1, sizeof (*ent), gf_ibv_mt_qpent);
|
||||
ERR_ABORT (ent);
|
||||
/* TODO: ref reg->peer */
|
||||
ent->peer = peer;
|
||||
@ -762,7 +763,7 @@ ib_verbs_unregister_peer (ib_verbs_device_t *device,
|
||||
ent->prev->next = ent->next;
|
||||
ent->next->prev = ent->prev;
|
||||
/* TODO: unref reg->peer */
|
||||
free (ent);
|
||||
GF_FREE (ent);
|
||||
qpreg->count--;
|
||||
pthread_mutex_unlock (&qpreg->lock);
|
||||
}
|
||||
@ -1476,7 +1477,7 @@ ib_verbs_options_init (transport_t *this)
|
||||
temp = dict_get (this->xl->options,
|
||||
"transport.ib-verbs.device-name");
|
||||
if (temp)
|
||||
options->device_name = strdup (temp->data);
|
||||
options->device_name = gf_strdup (temp->data);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1519,7 +1520,8 @@ ib_verbs_get_device (transport_t *this,
|
||||
|
||||
if (!trav) {
|
||||
|
||||
trav = CALLOC (1, sizeof (*trav));
|
||||
trav = GF_CALLOC (1, sizeof (*trav),
|
||||
gf_ibv_mt_ib_verbs_device_t);
|
||||
ERR_ABORT (trav);
|
||||
priv->device = trav;
|
||||
|
||||
@ -1555,7 +1557,7 @@ ib_verbs_get_device (transport_t *this,
|
||||
"port: %u", port);
|
||||
}
|
||||
|
||||
trav->device_name = strdup (device_name);
|
||||
trav->device_name = gf_strdup (device_name);
|
||||
trav->port = port;
|
||||
|
||||
trav->next = ctx->ib;
|
||||
@ -1684,7 +1686,7 @@ ib_verbs_init (transport_t *this)
|
||||
if (!options->device_name) {
|
||||
if (*dev_list) {
|
||||
options->device_name =
|
||||
strdup (ibv_get_device_name (*dev_list));
|
||||
gf_strdup (ibv_get_device_name (*dev_list));
|
||||
} else {
|
||||
gf_log ("transport/ib-verbs", GF_LOG_CRITICAL,
|
||||
"IB device list is empty. Check for "
|
||||
@ -1828,7 +1830,7 @@ ib_verbs_handshake_pollin (transport_t *this)
|
||||
switch (priv->handshake.incoming.state)
|
||||
{
|
||||
case IB_VERBS_HANDSHAKE_START:
|
||||
buf = priv->handshake.incoming.buf = CALLOC (1, 256);
|
||||
buf = priv->handshake.incoming.buf = GF_CALLOC (1, 256, gf_ibv_mt_char);
|
||||
ib_verbs_fill_handshake_data (buf, &priv->handshake.incoming, priv);
|
||||
buf[0] = 0;
|
||||
priv->handshake.incoming.state = IB_VERBS_HANDSHAKE_RECEIVING_DATA;
|
||||
@ -1941,7 +1943,7 @@ ib_verbs_handshake_pollin (transport_t *this)
|
||||
(struct sockaddr *) &this->peerinfo.sockaddr,
|
||||
&sock_len);
|
||||
|
||||
FREE (priv->handshake.incoming.buf);
|
||||
GF_FREE (priv->handshake.incoming.buf);
|
||||
priv->handshake.incoming.buf = NULL;
|
||||
priv->handshake.incoming.state = IB_VERBS_HANDSHAKE_COMPLETE;
|
||||
}
|
||||
@ -1981,7 +1983,7 @@ ib_verbs_handshake_pollout (transport_t *this)
|
||||
switch (priv->handshake.outgoing.state)
|
||||
{
|
||||
case IB_VERBS_HANDSHAKE_START:
|
||||
buf = priv->handshake.outgoing.buf = CALLOC (1, 256);
|
||||
buf = priv->handshake.outgoing.buf = GF_CALLOC (1, 256, gf_ibv_mt_char);
|
||||
ib_verbs_fill_handshake_data (buf, &priv->handshake.outgoing, priv);
|
||||
priv->handshake.outgoing.state = IB_VERBS_HANDSHAKE_SENDING_DATA;
|
||||
break;
|
||||
@ -2031,7 +2033,7 @@ ib_verbs_handshake_pollout (transport_t *this)
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
FREE (priv->handshake.outgoing.buf);
|
||||
GF_FREE (priv->handshake.outgoing.buf);
|
||||
priv->handshake.outgoing.buf = NULL;
|
||||
priv->handshake.outgoing.state = IB_VERBS_HANDSHAKE_COMPLETE;
|
||||
}
|
||||
@ -2082,14 +2084,14 @@ ib_verbs_handshake_pollerr (transport_t *this)
|
||||
}
|
||||
|
||||
if (priv->handshake.incoming.buf) {
|
||||
FREE (priv->handshake.incoming.buf);
|
||||
GF_FREE (priv->handshake.incoming.buf);
|
||||
priv->handshake.incoming.buf = NULL;
|
||||
}
|
||||
|
||||
priv->handshake.incoming.state = IB_VERBS_HANDSHAKE_START;
|
||||
|
||||
if (priv->handshake.outgoing.buf) {
|
||||
FREE (priv->handshake.outgoing.buf);
|
||||
GF_FREE (priv->handshake.outgoing.buf);
|
||||
priv->handshake.outgoing.buf = NULL;
|
||||
}
|
||||
|
||||
@ -2352,9 +2354,11 @@ ib_verbs_server_event_handler (int fd, int idx, void *data,
|
||||
if (!poll_in)
|
||||
return 0;
|
||||
|
||||
this = CALLOC (1, sizeof (transport_t));
|
||||
this = GF_CALLOC (1, sizeof (transport_t),
|
||||
gf_ibv_mt_transport_t);
|
||||
ERR_ABORT (this);
|
||||
priv = CALLOC (1, sizeof (ib_verbs_private_t));
|
||||
priv = GF_CALLOC (1, sizeof (ib_verbs_private_t),
|
||||
gf_ibv_mt_ib_verbs_private_t);
|
||||
ERR_ABORT (priv);
|
||||
this->private = priv;
|
||||
/* Copy all the ib_verbs related values in priv, from trans_priv
|
||||
@ -2381,8 +2385,8 @@ ib_verbs_server_event_handler (int fd, int idx, void *data,
|
||||
gf_log ("ib-verbs/server", GF_LOG_ERROR,
|
||||
"accept() failed: %s",
|
||||
strerror (errno));
|
||||
free (this->private);
|
||||
free (this);
|
||||
GF_FREE (this->private);
|
||||
GF_FREE (this);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2445,7 +2449,7 @@ ib_verbs_listen (transport_t *this)
|
||||
gf_log ("ib-verbs/server", GF_LOG_CRITICAL,
|
||||
"init: failed to create socket, error: %s",
|
||||
strerror (errno));
|
||||
free (this->private);
|
||||
GF_FREE (this->private);
|
||||
ret = -1;
|
||||
goto err;
|
||||
}
|
||||
@ -2504,7 +2508,8 @@ struct transport_ops tops = {
|
||||
int32_t
|
||||
init (transport_t *this)
|
||||
{
|
||||
ib_verbs_private_t *priv = CALLOC (1, sizeof (*priv));
|
||||
ib_verbs_private_t *priv = GF_CALLOC (1, sizeof (*priv),
|
||||
gf_ibv_mt_ib_verbs_private_t);
|
||||
this->private = priv;
|
||||
priv->sock = -1;
|
||||
|
||||
@ -2532,10 +2537,29 @@ fini (struct transport *this)
|
||||
gf_log (this->xl->name, GF_LOG_TRACE,
|
||||
"called fini on transport: %p",
|
||||
this);
|
||||
free (priv);
|
||||
GF_FREE (priv);
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t
|
||||
mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!this)
|
||||
return ret;
|
||||
|
||||
ret = xlator_mem_acct_init (this, gf_common_mt_end + 1);
|
||||
|
||||
if (ret != 0) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
|
||||
"failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* TODO: expand each option */
|
||||
struct volume_options options[] = {
|
||||
{ .key = {"transport.ib-verbs.port",
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include "xlator.h"
|
||||
#include "event.h"
|
||||
#include "ib-verbs-mem-types.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <list.h>
|
||||
|
36
transport/socket/src/socket-mem-types.h
Normal file
36
transport/socket/src/socket-mem-types.h
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
/*
|
||||
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 __SOCKET_MEM_TYPES_H__
|
||||
#define __SOCKET_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_socket_mem_types_ {
|
||||
gf_socket_mt_socket_private_t = gf_common_mt_end + 1,
|
||||
gf_socket_mt_ioq,
|
||||
gf_socket_mt_transport_t,
|
||||
gf_socket_mt_socket_local_t,
|
||||
gf_socket_mt_char,
|
||||
gf_socket_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -273,7 +273,7 @@ __socket_reset (transport_t *this)
|
||||
/* TODO: use mem-pool on incoming data */
|
||||
|
||||
if (priv->incoming.hdr_p)
|
||||
free (priv->incoming.hdr_p);
|
||||
GF_FREE (priv->incoming.hdr_p);
|
||||
|
||||
if (priv->incoming.iobuf)
|
||||
iobuf_unref (priv->incoming.iobuf);
|
||||
@ -298,7 +298,8 @@ __socket_ioq_new (transport_t *this, char *buf, int len,
|
||||
priv = this->private;
|
||||
|
||||
/* TODO: use mem-pool */
|
||||
entry = CALLOC (1, sizeof (*entry));
|
||||
entry = GF_CALLOC (1, sizeof (*entry),
|
||||
gf_common_mt_ioq);
|
||||
if (!entry)
|
||||
return NULL;
|
||||
|
||||
@ -346,10 +347,10 @@ __socket_ioq_entry_free (struct ioq *entry)
|
||||
iobref_unref (entry->iobref);
|
||||
|
||||
/* TODO: use mem-pool */
|
||||
free (entry->buf);
|
||||
GF_FREE (entry->buf);
|
||||
|
||||
/* TODO: use mem-pool */
|
||||
free (entry);
|
||||
GF_FREE (entry);
|
||||
}
|
||||
|
||||
|
||||
@ -607,7 +608,8 @@ __socket_proto_state_machine (transport_t *this)
|
||||
priv->incoming.buflen = size2;
|
||||
|
||||
/* TODO: use mem-pool */
|
||||
priv->incoming.hdr_p = MALLOC (size1);
|
||||
priv->incoming.hdr_p = GF_MALLOC (size1,
|
||||
gf_common_mt_char);
|
||||
if (size2) {
|
||||
/* TODO: sanity check size2 < page size
|
||||
*/
|
||||
@ -891,7 +893,8 @@ socket_server_event_handler (int fd, int idx, void *data,
|
||||
}
|
||||
}
|
||||
|
||||
new_trans = CALLOC (1, sizeof (*new_trans));
|
||||
new_trans = GF_CALLOC (1, sizeof (*new_trans),
|
||||
gf_common_mt_transport_t);
|
||||
new_trans->xl = this->xl;
|
||||
new_trans->fini = this->fini;
|
||||
|
||||
@ -1376,7 +1379,8 @@ socket_init (transport_t *this)
|
||||
return -1;
|
||||
}
|
||||
|
||||
priv = CALLOC (1, sizeof (*priv));
|
||||
priv = GF_CALLOC (1, sizeof (*priv),
|
||||
gf_common_mt_socket_private_t);
|
||||
if (!priv) {
|
||||
gf_log (this->xl->name, GF_LOG_ERROR,
|
||||
"calloc (1, %"GF_PRI_SIZET") returned NULL",
|
||||
@ -1465,9 +1469,27 @@ fini (transport_t *this)
|
||||
"transport %p destroyed", this);
|
||||
|
||||
pthread_mutex_destroy (&priv->lock);
|
||||
FREE (priv);
|
||||
GF_FREE (priv);
|
||||
}
|
||||
|
||||
int32_t
|
||||
mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!this)
|
||||
return ret;
|
||||
|
||||
ret = xlator_mem_acct_init (this, gf_common_mt_end + 1);
|
||||
|
||||
if (ret != 0) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
|
||||
"failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t
|
||||
init (transport_t *this)
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "logging.h"
|
||||
#include "dict.h"
|
||||
#include "mem-pool.h"
|
||||
#include "socket-mem-types.h"
|
||||
|
||||
#ifndef MAX_IOVEC
|
||||
#define MAX_IOVEC 16
|
||||
|
@ -188,8 +188,9 @@ afr_examine_dir (call_frame_t *frame, xlator_t *this)
|
||||
local = frame->local;
|
||||
priv = this->private;
|
||||
|
||||
local->cont.opendir.checksum = CALLOC (priv->child_count,
|
||||
sizeof (*local->cont.opendir.checksum));
|
||||
local->cont.opendir.checksum = GF_CALLOC (priv->child_count,
|
||||
sizeof (*local->cont.opendir.checksum),
|
||||
gf_afr_mt_int32_t);
|
||||
|
||||
call_count = afr_up_children_count (priv->child_count, local->child_up);
|
||||
|
||||
@ -387,8 +388,8 @@ afr_remember_entries (gf_dirent_t *entries, fd_t *fd)
|
||||
fd_ctx = (afr_fd_ctx_t *)(long) ctx;
|
||||
|
||||
list_for_each_entry (entry, &entries->list, list) {
|
||||
n = CALLOC (1, sizeof (*n));
|
||||
n->name = strdup (entry->d_name);
|
||||
n = GF_CALLOC (1, sizeof (*n), gf_afr_mt_entry_name);
|
||||
n->name = gf_strdup (entry->d_name);
|
||||
INIT_LIST_HEAD (&n->list);
|
||||
|
||||
list_add (&n->list, &fd_ctx->entries);
|
||||
@ -421,7 +422,7 @@ afr_filter_entries (gf_dirent_t *entries, fd_t *fd)
|
||||
|
||||
if (remembered_name (entry->d_name, &fd_ctx->entries)) {
|
||||
list_del (&entry->list);
|
||||
FREE (entry);
|
||||
GF_FREE (entry);
|
||||
}
|
||||
}
|
||||
|
||||
@ -448,9 +449,9 @@ afr_forget_entries (fd_t *fd)
|
||||
fd_ctx = (afr_fd_ctx_t *)(long) ctx;
|
||||
|
||||
list_for_each_entry_safe (entry, tmp, &fd_ctx->entries, list) {
|
||||
FREE (entry->name);
|
||||
GF_FREE (entry->name);
|
||||
list_del (&entry->list);
|
||||
FREE (entry);
|
||||
GF_FREE (entry);
|
||||
}
|
||||
}
|
||||
|
||||
@ -485,7 +486,7 @@ afr_readdir_cbk (call_frame_t *frame, void *cookie,
|
||||
if ((local->fd->inode == local->fd->inode->table->root)
|
||||
&& !strcmp (entry->d_name, GF_REPLICATE_TRASH_DIR)) {
|
||||
list_del_init (&entry->list);
|
||||
FREE (entry);
|
||||
GF_FREE (entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -571,7 +572,7 @@ afr_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
if ((local->fd->inode == local->fd->inode->table->root)
|
||||
&& !strcmp (entry->d_name, GF_REPLICATE_TRASH_DIR)) {
|
||||
list_del_init (&entry->list);
|
||||
FREE (entry);
|
||||
GF_FREE (entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ afr_build_parent_loc (loc_t *parent, loc_t *child)
|
||||
return;
|
||||
}
|
||||
|
||||
tmp = strdup (child->path);
|
||||
parent->path = strdup (dirname (tmp));
|
||||
FREE (tmp);
|
||||
tmp = gf_strdup (child->path);
|
||||
parent->path = gf_strdup (dirname (tmp));
|
||||
GF_FREE (tmp);
|
||||
|
||||
parent->name = strrchr (parent->path, '/');
|
||||
if (parent->name)
|
||||
@ -1315,7 +1315,7 @@ afr_symlink (call_frame_t *frame, xlator_t *this,
|
||||
}
|
||||
UNLOCK (&priv->read_child_lock);
|
||||
|
||||
local->cont.symlink.linkpath = strdup (linkpath);
|
||||
local->cont.symlink.linkpath = gf_strdup (linkpath);
|
||||
|
||||
if (loc->parent)
|
||||
local->cont.symlink.parent_ino = loc->parent->ino;
|
||||
|
@ -566,7 +566,7 @@ __gather_xattr_keys (dict_t *dict, char *key, data_t *value,
|
||||
if (!strncmp (key, AFR_XATTR_PREFIX,
|
||||
strlen (AFR_XATTR_PREFIX))) {
|
||||
|
||||
xkey = CALLOC (1, sizeof (*xkey));
|
||||
xkey = GF_CALLOC (1, sizeof (*xkey), gf_afr_mt_xattr_key);
|
||||
if (!xkey)
|
||||
return;
|
||||
|
||||
@ -596,7 +596,7 @@ __filter_xattrs (dict_t *dict)
|
||||
|
||||
list_del_init (&key->list);
|
||||
|
||||
FREE (key);
|
||||
GF_FREE (key);
|
||||
}
|
||||
}
|
||||
|
||||
@ -713,7 +713,7 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
|
||||
|
||||
loc_copy (&local->loc, loc);
|
||||
if (name)
|
||||
local->cont.getxattr.name = strdup (name);
|
||||
local->cont.getxattr.name = gf_strdup (name);
|
||||
|
||||
STACK_WIND_COOKIE (frame, afr_getxattr_cbk,
|
||||
(void *) (long) call_child,
|
||||
|
@ -1600,7 +1600,7 @@ afr_removexattr (call_frame_t *frame, xlator_t *this,
|
||||
|
||||
local->op_ret = -1;
|
||||
|
||||
local->cont.removexattr.name = strdup (name);
|
||||
local->cont.removexattr.name = gf_strdup (name);
|
||||
|
||||
local->transaction.fop = afr_removexattr_wind;
|
||||
local->transaction.done = afr_removexattr_done;
|
||||
|
46
xlators/cluster/afr/src/afr-mem-types.h
Normal file
46
xlators/cluster/afr/src/afr-mem-types.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
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_afr_mem_types_ {
|
||||
gf_afr_mt_iovec = gf_common_mt_end + 1,
|
||||
gf_afr_mt_afr_fd_ctx_t,
|
||||
gf_afr_mt_afr_local_t,
|
||||
gf_afr_mt_afr_private_t,
|
||||
gf_afr_mt_int32_t,
|
||||
gf_afr_mt_char,
|
||||
gf_afr_mt_xattr_key,
|
||||
gf_afr_mt_dict_t,
|
||||
gf_afr_mt_xlator_t,
|
||||
gf_afr_mt_stat,
|
||||
gf_afr_mt_int,
|
||||
gf_afr_mt_afr_node_character,
|
||||
gf_afr_mt_sh_diff_loop_state,
|
||||
gf_afr_mt_uint8_t,
|
||||
gf_afr_mt_loc_t,
|
||||
gf_afr_mt_entry_name,
|
||||
gf_afr_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -66,7 +66,7 @@ sh_full_private_cleanup (call_frame_t *frame, xlator_t *this)
|
||||
sh_priv = sh->private;
|
||||
|
||||
if (sh_priv)
|
||||
FREE (sh_priv);
|
||||
GF_FREE (sh_priv);
|
||||
}
|
||||
|
||||
|
||||
@ -384,7 +384,8 @@ afr_sh_algo_full (call_frame_t *frame, xlator_t *this)
|
||||
local = frame->local;
|
||||
sh = &local->self_heal;
|
||||
|
||||
sh_priv = CALLOC (1, sizeof (*sh_priv));
|
||||
sh_priv = GF_CALLOC (1, sizeof (*sh_priv),
|
||||
gf_afr_mt_afr_private_t);
|
||||
|
||||
LOCK_INIT (&sh_priv->lock);
|
||||
|
||||
@ -422,18 +423,18 @@ sh_diff_private_cleanup (call_frame_t *frame, xlator_t *this)
|
||||
for (i = 0; i < priv->data_self_heal_window_size; i++) {
|
||||
if (sh_priv->loops[i]) {
|
||||
if (sh_priv->loops[i]->write_needed)
|
||||
FREE (sh_priv->loops[i]->write_needed);
|
||||
GF_FREE (sh_priv->loops[i]->write_needed);
|
||||
|
||||
if (sh_priv->loops[i]->checksum)
|
||||
FREE (sh_priv->loops[i]->checksum);
|
||||
GF_FREE (sh_priv->loops[i]->checksum);
|
||||
}
|
||||
}
|
||||
|
||||
if (sh_priv) {
|
||||
if (sh_priv->loops)
|
||||
FREE (sh_priv->loops);
|
||||
GF_FREE (sh_priv->loops);
|
||||
|
||||
FREE (sh_priv);
|
||||
GF_FREE (sh_priv);
|
||||
}
|
||||
|
||||
|
||||
@ -1034,7 +1035,8 @@ afr_sh_algo_diff (call_frame_t *frame, xlator_t *this)
|
||||
local = frame->local;
|
||||
sh = &local->self_heal;
|
||||
|
||||
sh_priv = CALLOC (1, sizeof (*sh_priv));
|
||||
sh_priv = GF_CALLOC (1, sizeof (*sh_priv),
|
||||
gf_afr_mt_afr_private_t);
|
||||
|
||||
sh_priv->block_size = this->ctx->page_size;
|
||||
|
||||
@ -1044,16 +1046,19 @@ afr_sh_algo_diff (call_frame_t *frame, xlator_t *this)
|
||||
|
||||
local->call_count = 0;
|
||||
|
||||
sh_priv->loops = CALLOC (priv->data_self_heal_window_size,
|
||||
sizeof (*sh_priv->loops));
|
||||
sh_priv->loops = GF_CALLOC (priv->data_self_heal_window_size,
|
||||
sizeof (*sh_priv->loops),
|
||||
gf_afr_mt_sh_diff_loop_state);
|
||||
|
||||
for (i = 0; i < priv->data_self_heal_window_size; i++) {
|
||||
sh_priv->loops[i] = CALLOC (1, sizeof (*sh_priv->loops[i]));
|
||||
sh_priv->loops[i] = GF_CALLOC (1, sizeof (*sh_priv->loops[i]),
|
||||
gf_afr_mt_sh_diff_loop_state);
|
||||
|
||||
sh_priv->loops[i]->checksum = CALLOC (priv->child_count,
|
||||
MD5_DIGEST_LEN);
|
||||
sh_priv->loops[i]->write_needed = CALLOC (priv->child_count,
|
||||
sizeof (*sh_priv->loops[i]->write_needed));
|
||||
sh_priv->loops[i]->checksum = GF_CALLOC (priv->child_count,
|
||||
MD5_DIGEST_LEN, gf_afr_mt_uint8_t);
|
||||
sh_priv->loops[i]->write_needed = GF_CALLOC (priv->child_count,
|
||||
sizeof (*sh_priv->loops[i]->write_needed),
|
||||
gf_afr_mt_char);
|
||||
}
|
||||
|
||||
sh_diff_loop_driver (frame, this);
|
||||
|
@ -98,7 +98,7 @@ afr_sh_print_pending_matrix (int32_t *pending_matrix[], xlator_t *this)
|
||||
int i, j;
|
||||
|
||||
/* 10 digits per entry + 1 space + '[' and ']' */
|
||||
buf = MALLOC (priv->child_count * 11 + 8);
|
||||
buf = GF_MALLOC (priv->child_count * 11 + 8, gf_afr_mt_char);
|
||||
|
||||
for (i = 0; i < priv->child_count; i++) {
|
||||
ptr = buf;
|
||||
@ -111,7 +111,7 @@ afr_sh_print_pending_matrix (int32_t *pending_matrix[], xlator_t *this)
|
||||
"pending_matrix: %s", buf);
|
||||
}
|
||||
|
||||
FREE (buf);
|
||||
GF_FREE (buf);
|
||||
}
|
||||
|
||||
|
||||
@ -129,7 +129,8 @@ afr_sh_build_pending_matrix (afr_private_t *priv,
|
||||
|
||||
unsigned char *ignorant_subvols = NULL;
|
||||
|
||||
ignorant_subvols = CALLOC (sizeof (*ignorant_subvols), child_count);
|
||||
ignorant_subvols = GF_CALLOC (sizeof (*ignorant_subvols), child_count,
|
||||
gf_afr_mt_char);
|
||||
|
||||
/* start clean */
|
||||
for (i = 0; i < child_count; i++) {
|
||||
@ -177,7 +178,7 @@ afr_sh_build_pending_matrix (afr_private_t *priv,
|
||||
}
|
||||
}
|
||||
|
||||
FREE (ignorant_subvols);
|
||||
GF_FREE (ignorant_subvols);
|
||||
}
|
||||
|
||||
|
||||
@ -479,8 +480,9 @@ afr_sh_mark_sources (afr_self_heal_t *sh, int child_count,
|
||||
|
||||
/* stores the 'characters' (innocent, fool, wise) of the nodes */
|
||||
afr_node_character *
|
||||
characters = CALLOC (sizeof (afr_node_character),
|
||||
child_count);
|
||||
characters = GF_CALLOC (sizeof (afr_node_character),
|
||||
child_count,
|
||||
gf_afr_mt_afr_node_character) ;
|
||||
|
||||
/* start clean */
|
||||
for (i = 0; i < child_count; i++) {
|
||||
@ -543,7 +545,7 @@ afr_sh_mark_sources (afr_self_heal_t *sh, int child_count,
|
||||
}
|
||||
|
||||
out:
|
||||
FREE (characters);
|
||||
GF_FREE (characters);
|
||||
|
||||
return nsources;
|
||||
}
|
||||
@ -612,7 +614,8 @@ afr_sh_delta_to_xattr (afr_private_t *priv,
|
||||
continue;
|
||||
|
||||
for (j = 0; j < child_count; j++) {
|
||||
pending = CALLOC (sizeof (int32_t), 3);
|
||||
pending = GF_CALLOC (sizeof (int32_t), 3,
|
||||
gf_afr_mt_int32_t);
|
||||
/* 3 = data+metadata+entry */
|
||||
|
||||
k = afr_index_for_transaction_type (type);
|
||||
@ -882,7 +885,7 @@ sh_destroy_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
|
||||
if (parent_loc) {
|
||||
loc_wipe (parent_loc);
|
||||
FREE (parent_loc);
|
||||
GF_FREE (parent_loc);
|
||||
}
|
||||
|
||||
call_count = afr_frame_return (frame);
|
||||
@ -935,7 +938,8 @@ sh_missing_entries_newentry_cbk (call_frame_t *frame, void *cookie,
|
||||
if (op_ret == 0) {
|
||||
setattr_frame = copy_frame (frame);
|
||||
|
||||
setattr_frame->local = CALLOC (1, sizeof (afr_local_t));
|
||||
setattr_frame->local = GF_CALLOC (1, sizeof (afr_local_t),
|
||||
gf_afr_mt_afr_local_t);
|
||||
|
||||
((afr_local_t *)setattr_frame->local)->call_count = 2;
|
||||
|
||||
@ -950,7 +954,8 @@ sh_missing_entries_newentry_cbk (call_frame_t *frame, void *cookie,
|
||||
&local->loc, &stbuf, valid);
|
||||
|
||||
valid = GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME;
|
||||
parent_loc = CALLOC (1, sizeof (*parent_loc));
|
||||
parent_loc = GF_CALLOC (1, sizeof (*parent_loc),
|
||||
gf_afr_mt_loc_t);
|
||||
afr_build_parent_loc (parent_loc, &local->loc);
|
||||
|
||||
STACK_WIND_COOKIE (setattr_frame, sh_destroy_cbk,
|
||||
@ -1452,7 +1457,9 @@ afr_local_t *afr_local_copy (afr_local_t *l, xlator_t *this)
|
||||
|
||||
sh = &l->self_heal;
|
||||
|
||||
lc = CALLOC (1, sizeof (afr_local_t));
|
||||
lc = GF_CALLOC (1, sizeof (afr_local_t),
|
||||
gf_afr_mt_afr_local_t);
|
||||
|
||||
shc = &lc->self_heal;
|
||||
|
||||
shc->unwind = sh->unwind;
|
||||
@ -1567,23 +1574,35 @@ afr_self_heal (call_frame_t *frame, xlator_t *this)
|
||||
sh->completion_cbk = afr_self_heal_completion_cbk;
|
||||
|
||||
|
||||
sh->buf = CALLOC (priv->child_count, sizeof (struct stat));
|
||||
sh->child_errno = CALLOC (priv->child_count, sizeof (int));
|
||||
sh->success = CALLOC (priv->child_count, sizeof (int));
|
||||
sh->xattr = CALLOC (priv->child_count, sizeof (dict_t *));
|
||||
sh->sources = CALLOC (priv->child_count, sizeof (*sh->sources));
|
||||
sh->locked_nodes = CALLOC (priv->child_count, sizeof (*sh->locked_nodes));
|
||||
sh->buf = GF_CALLOC (priv->child_count, sizeof (struct stat),
|
||||
gf_afr_mt_stat);
|
||||
sh->child_errno = GF_CALLOC (priv->child_count, sizeof (int),
|
||||
gf_afr_mt_int);
|
||||
sh->success = GF_CALLOC (priv->child_count, sizeof (int),
|
||||
gf_afr_mt_int);
|
||||
sh->xattr = GF_CALLOC (priv->child_count, sizeof (dict_t *),
|
||||
gf_afr_mt_dict_t);
|
||||
sh->sources = GF_CALLOC (sizeof (*sh->sources), priv->child_count,
|
||||
gf_afr_mt_int);
|
||||
sh->locked_nodes = GF_CALLOC (sizeof (*sh->locked_nodes),
|
||||
priv->child_count,
|
||||
gf_afr_mt_int);
|
||||
|
||||
sh->pending_matrix = GF_CALLOC (sizeof (int32_t *), priv->child_count,
|
||||
gf_afr_mt_int32_t);
|
||||
|
||||
sh->pending_matrix = CALLOC (sizeof (int32_t *), priv->child_count);
|
||||
for (i = 0; i < priv->child_count; i++) {
|
||||
sh->pending_matrix[i] = CALLOC (sizeof (int32_t),
|
||||
priv->child_count);
|
||||
sh->pending_matrix[i] = GF_CALLOC (sizeof (int32_t),
|
||||
priv->child_count,
|
||||
gf_afr_mt_int32_t);
|
||||
}
|
||||
|
||||
sh->delta_matrix = CALLOC (sizeof (int32_t *), priv->child_count);
|
||||
sh->delta_matrix = GF_CALLOC (sizeof (int32_t *), priv->child_count,
|
||||
gf_afr_mt_int32_t);
|
||||
for (i = 0; i < priv->child_count; i++) {
|
||||
sh->delta_matrix[i] = CALLOC (sizeof (int32_t),
|
||||
priv->child_count);
|
||||
sh->delta_matrix[i] = GF_CALLOC (sizeof (int32_t),
|
||||
priv->child_count,
|
||||
gf_afr_mt_int32_t);
|
||||
}
|
||||
|
||||
if (local->success_count && local->enoent_count) {
|
||||
|
@ -387,7 +387,8 @@ afr_sh_data_erase_pending (call_frame_t *frame, xlator_t *this)
|
||||
afr_sh_pending_to_delta (priv, sh->xattr, sh->delta_matrix, sh->success,
|
||||
priv->child_count, AFR_DATA_TRANSACTION);
|
||||
|
||||
erase_xattr = CALLOC (sizeof (*erase_xattr), priv->child_count);
|
||||
erase_xattr = GF_CALLOC (sizeof (*erase_xattr), priv->child_count,
|
||||
gf_afr_mt_dict_t);
|
||||
|
||||
for (i = 0; i < priv->child_count; i++) {
|
||||
if (sh->xattr[i]) {
|
||||
@ -425,7 +426,7 @@ afr_sh_data_erase_pending (call_frame_t *frame, xlator_t *this)
|
||||
dict_unref (erase_xattr[i]);
|
||||
}
|
||||
}
|
||||
FREE (erase_xattr);
|
||||
GF_FREE (erase_xattr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -766,13 +767,16 @@ afr_self_heal_get_source (xlator_t *this, afr_local_t *local, dict_t **xattr)
|
||||
sh = &local->self_heal;
|
||||
priv = this->private;
|
||||
|
||||
sh->pending_matrix = CALLOC (sizeof (int32_t *), priv->child_count);
|
||||
sh->pending_matrix = GF_CALLOC (sizeof (int32_t *), priv->child_count,
|
||||
gf_afr_mt_int32_t);
|
||||
for (i = 0; i < priv->child_count; i++) {
|
||||
sh->pending_matrix[i] = CALLOC (sizeof (int32_t),
|
||||
priv->child_count);
|
||||
sh->pending_matrix[i] = GF_CALLOC (sizeof (int32_t),
|
||||
priv->child_count,
|
||||
gf_afr_mt_int32_t);
|
||||
}
|
||||
|
||||
sh->sources = CALLOC (priv->child_count, sizeof (*sh->sources));
|
||||
sh->sources = GF_CALLOC (priv->child_count, sizeof (*sh->sources),
|
||||
gf_afr_mt_int32_t);
|
||||
|
||||
afr_sh_build_pending_matrix (priv, sh->pending_matrix, xattr,
|
||||
priv->child_count, AFR_DATA_TRANSACTION);
|
||||
|
@ -236,7 +236,8 @@ afr_sh_entry_erase_pending (call_frame_t *frame, xlator_t *this)
|
||||
afr_sh_pending_to_delta (priv, sh->xattr, sh->delta_matrix, sh->success,
|
||||
priv->child_count, AFR_ENTRY_TRANSACTION);
|
||||
|
||||
erase_xattr = CALLOC (sizeof (*erase_xattr), priv->child_count);
|
||||
erase_xattr = GF_CALLOC (sizeof (*erase_xattr), priv->child_count,
|
||||
gf_afr_mt_dict_t);
|
||||
|
||||
for (i = 0; i < priv->child_count; i++) {
|
||||
if (sh->xattr[i]) {
|
||||
@ -277,7 +278,7 @@ afr_sh_entry_erase_pending (call_frame_t *frame, xlator_t *this)
|
||||
dict_unref (erase_xattr[i]);
|
||||
}
|
||||
}
|
||||
FREE (erase_xattr);
|
||||
GF_FREE (erase_xattr);
|
||||
|
||||
if (need_unwind)
|
||||
afr_sh_entry_finish (frame, this);
|
||||
@ -373,10 +374,10 @@ build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name)
|
||||
}
|
||||
|
||||
if (strcmp (parent->path, "/") == 0)
|
||||
ret = asprintf ((char **)&child->path, "/%s", name);
|
||||
ret = gf_asprintf ((char **)&child->path, "/%s", name);
|
||||
else
|
||||
ret = asprintf ((char **)&child->path, "%s/%s", parent->path,
|
||||
name);
|
||||
ret = gf_asprintf ((char **)&child->path, "%s/%s",
|
||||
parent->path, name);
|
||||
|
||||
if (-1 == ret) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
@ -532,7 +533,7 @@ afr_sh_entry_expunge_rename_cbk (call_frame_t *expunge_frame, void *cookie,
|
||||
static void
|
||||
init_trash_loc (loc_t *trash_loc, inode_table_t *table)
|
||||
{
|
||||
trash_loc->path = strdup ("/" GF_REPLICATE_TRASH_DIR);
|
||||
trash_loc->path = gf_strdup ("/" GF_REPLICATE_TRASH_DIR);
|
||||
trash_loc->name = GF_REPLICATE_TRASH_DIR;
|
||||
trash_loc->parent = table->root;
|
||||
trash_loc->inode = inode_new (table);
|
||||
@ -545,7 +546,8 @@ make_trash_path (const char *path)
|
||||
char *c = NULL;
|
||||
char *tp = NULL;
|
||||
|
||||
tp = CALLOC (strlen ("/" GF_REPLICATE_TRASH_DIR) + strlen (path) + 1, sizeof (char));
|
||||
tp = GF_CALLOC (strlen ("/" GF_REPLICATE_TRASH_DIR) + strlen (path) + 1,
|
||||
sizeof (char), gf_afr_mt_char);
|
||||
|
||||
strcpy (tp, GF_REPLICATE_TRASH_DIR);
|
||||
strcat (tp, path);
|
||||
@ -1263,7 +1265,7 @@ afr_sh_entry_impunge_parent_setattr_cbk (call_frame_t *setattr_frame,
|
||||
|
||||
loc_wipe (parent_loc);
|
||||
|
||||
FREE (parent_loc);
|
||||
GF_FREE (parent_loc);
|
||||
|
||||
AFR_STACK_DESTROY (setattr_frame);
|
||||
return 0;
|
||||
@ -1336,7 +1338,7 @@ afr_sh_entry_impunge_newfile_cbk (call_frame_t *impunge_frame, void *cookie,
|
||||
parentbuf = impunge_sh->parentbuf;
|
||||
setattr_frame = copy_frame (impunge_frame);
|
||||
|
||||
parent_loc = CALLOC (1, sizeof (*parent_loc));
|
||||
parent_loc = GF_CALLOC (1, sizeof (*parent_loc), gf_afr_mt_loc_t);
|
||||
afr_build_parent_loc (parent_loc, &impunge_local->loc);
|
||||
|
||||
STACK_WIND_COOKIE (impunge_frame, afr_sh_entry_impunge_xattrop_cbk,
|
||||
@ -1668,7 +1670,7 @@ afr_sh_entry_impunge_readlink_cbk (call_frame_t *impunge_frame, void *cookie,
|
||||
goto out;
|
||||
}
|
||||
|
||||
impunge_sh->linkname = strdup (linkname);
|
||||
impunge_sh->linkname = gf_strdup (linkname);
|
||||
|
||||
afr_sh_entry_impunge_readlink_sink (impunge_frame, this, child_index);
|
||||
|
||||
|
@ -225,7 +225,8 @@ afr_sh_metadata_erase_pending (call_frame_t *frame, xlator_t *this)
|
||||
sh->success, priv->child_count,
|
||||
AFR_METADATA_TRANSACTION);
|
||||
|
||||
erase_xattr = CALLOC (sizeof (*erase_xattr), priv->child_count);
|
||||
erase_xattr = GF_CALLOC (sizeof (*erase_xattr), priv->child_count,
|
||||
gf_afr_mt_dict_t);
|
||||
|
||||
for (i = 0; i < priv->child_count; i++) {
|
||||
if (sh->xattr[i]) {
|
||||
@ -272,7 +273,7 @@ afr_sh_metadata_erase_pending (call_frame_t *frame, xlator_t *this)
|
||||
dict_unref (erase_xattr[i]);
|
||||
}
|
||||
}
|
||||
FREE (erase_xattr);
|
||||
GF_FREE (erase_xattr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ afr_local_sh_cleanup (afr_local_t *local, xlator_t *this)
|
||||
priv = this->private;
|
||||
|
||||
if (sh->buf)
|
||||
FREE (sh->buf);
|
||||
GF_FREE (sh->buf);
|
||||
|
||||
if (sh->xattr) {
|
||||
for (i = 0; i < priv->child_count; i++) {
|
||||
@ -248,34 +248,34 @@ afr_local_sh_cleanup (afr_local_t *local, xlator_t *this)
|
||||
sh->xattr[i] = NULL;
|
||||
}
|
||||
}
|
||||
FREE (sh->xattr);
|
||||
GF_FREE (sh->xattr);
|
||||
}
|
||||
|
||||
if (sh->child_errno)
|
||||
FREE (sh->child_errno);
|
||||
GF_FREE (sh->child_errno);
|
||||
|
||||
if (sh->pending_matrix) {
|
||||
for (i = 0; i < priv->child_count; i++) {
|
||||
FREE (sh->pending_matrix[i]);
|
||||
GF_FREE (sh->pending_matrix[i]);
|
||||
}
|
||||
FREE (sh->pending_matrix);
|
||||
GF_FREE (sh->pending_matrix);
|
||||
}
|
||||
|
||||
if (sh->delta_matrix) {
|
||||
for (i = 0; i < priv->child_count; i++) {
|
||||
FREE (sh->delta_matrix[i]);
|
||||
GF_FREE (sh->delta_matrix[i]);
|
||||
}
|
||||
FREE (sh->delta_matrix);
|
||||
GF_FREE (sh->delta_matrix);
|
||||
}
|
||||
|
||||
if (sh->sources)
|
||||
FREE (sh->sources);
|
||||
GF_FREE (sh->sources);
|
||||
|
||||
if (sh->success)
|
||||
FREE (sh->success);
|
||||
GF_FREE (sh->success);
|
||||
|
||||
if (sh->locked_nodes)
|
||||
FREE (sh->locked_nodes);
|
||||
GF_FREE (sh->locked_nodes);
|
||||
|
||||
if (sh->healing_fd && !sh->healing_fd_opened) {
|
||||
fd_unref (sh->healing_fd);
|
||||
@ -283,7 +283,7 @@ afr_local_sh_cleanup (afr_local_t *local, xlator_t *this)
|
||||
}
|
||||
|
||||
if (sh->linkname)
|
||||
FREE (sh->linkname);
|
||||
GF_FREE ((char *)sh->linkname);
|
||||
|
||||
loc_wipe (&sh->parent_loc);
|
||||
}
|
||||
@ -299,17 +299,17 @@ afr_local_transaction_cleanup (afr_local_t *local, xlator_t *this)
|
||||
|
||||
for (i = 0; i < priv->child_count; i++) {
|
||||
if (local->pending && local->pending[i])
|
||||
FREE (local->pending[i]);
|
||||
GF_FREE (local->pending[i]);
|
||||
}
|
||||
|
||||
FREE (local->pending);
|
||||
GF_FREE (local->pending);
|
||||
|
||||
FREE (local->transaction.locked_nodes);
|
||||
FREE (local->transaction.child_errno);
|
||||
FREE (local->child_errno);
|
||||
GF_FREE (local->transaction.locked_nodes);
|
||||
GF_FREE (local->transaction.child_errno);
|
||||
GF_FREE (local->child_errno);
|
||||
|
||||
FREE (local->transaction.basename);
|
||||
FREE (local->transaction.new_basename);
|
||||
GF_FREE (local->transaction.basename);
|
||||
GF_FREE (local->transaction.new_basename);
|
||||
|
||||
loc_wipe (&local->transaction.parent_loc);
|
||||
loc_wipe (&local->transaction.new_parent_loc);
|
||||
@ -340,7 +340,7 @@ afr_local_cleanup (afr_local_t *local, xlator_t *this)
|
||||
if (local->xattr_req)
|
||||
dict_unref (local->xattr_req);
|
||||
|
||||
FREE (local->child_up);
|
||||
GF_FREE (local->child_up);
|
||||
|
||||
{ /* lookup */
|
||||
if (local->cont.lookup.xattrs) {
|
||||
@ -350,7 +350,7 @@ afr_local_cleanup (afr_local_t *local, xlator_t *this)
|
||||
local->cont.lookup.xattrs[i] = NULL;
|
||||
}
|
||||
}
|
||||
FREE (local->cont.lookup.xattrs);
|
||||
GF_FREE (local->cont.lookup.xattrs);
|
||||
local->cont.lookup.xattrs = NULL;
|
||||
}
|
||||
|
||||
@ -365,19 +365,19 @@ afr_local_cleanup (afr_local_t *local, xlator_t *this)
|
||||
|
||||
{ /* getxattr */
|
||||
if (local->cont.getxattr.name)
|
||||
FREE (local->cont.getxattr.name);
|
||||
GF_FREE (local->cont.getxattr.name);
|
||||
}
|
||||
|
||||
{ /* lk */
|
||||
if (local->cont.lk.locked_nodes)
|
||||
FREE (local->cont.lk.locked_nodes);
|
||||
GF_FREE (local->cont.lk.locked_nodes);
|
||||
}
|
||||
|
||||
{ /* checksum */
|
||||
if (local->cont.checksum.file_checksum)
|
||||
FREE (local->cont.checksum.file_checksum);
|
||||
GF_FREE (local->cont.checksum.file_checksum);
|
||||
if (local->cont.checksum.dir_checksum)
|
||||
FREE (local->cont.checksum.dir_checksum);
|
||||
GF_FREE (local->cont.checksum.dir_checksum);
|
||||
}
|
||||
|
||||
{ /* create */
|
||||
@ -386,7 +386,7 @@ afr_local_cleanup (afr_local_t *local, xlator_t *this)
|
||||
}
|
||||
|
||||
{ /* writev */
|
||||
FREE (local->cont.writev.vector);
|
||||
GF_FREE (local->cont.writev.vector);
|
||||
}
|
||||
|
||||
{ /* setxattr */
|
||||
@ -395,16 +395,16 @@ afr_local_cleanup (afr_local_t *local, xlator_t *this)
|
||||
}
|
||||
|
||||
{ /* removexattr */
|
||||
FREE (local->cont.removexattr.name);
|
||||
GF_FREE (local->cont.removexattr.name);
|
||||
}
|
||||
|
||||
{ /* symlink */
|
||||
FREE (local->cont.symlink.linkpath);
|
||||
GF_FREE (local->cont.symlink.linkpath);
|
||||
}
|
||||
|
||||
{ /* opendir */
|
||||
if (local->cont.opendir.checksum)
|
||||
FREE (local->cont.opendir.checksum);
|
||||
GF_FREE (local->cont.opendir.checksum);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1005,8 +1005,9 @@ afr_lookup (call_frame_t *frame, xlator_t *this,
|
||||
|
||||
local->child_up = memdup (priv->child_up, priv->child_count);
|
||||
|
||||
local->cont.lookup.xattrs = CALLOC (priv->child_count,
|
||||
sizeof (*local->cont.lookup.xattr));
|
||||
local->cont.lookup.xattrs = GF_CALLOC (priv->child_count,
|
||||
sizeof (*local->cont.lookup.xattr),
|
||||
gf_afr_mt_dict_t);
|
||||
|
||||
local->call_count = afr_up_children_count (priv->child_count,
|
||||
local->child_up);
|
||||
@ -1083,7 +1084,8 @@ afr_fd_ctx_set (xlator_t *this, fd_t *fd)
|
||||
if (ret == 0)
|
||||
goto unlock;
|
||||
|
||||
fd_ctx = CALLOC (1, sizeof (afr_fd_ctx_t));
|
||||
fd_ctx = GF_CALLOC (1, sizeof (afr_fd_ctx_t),
|
||||
gf_afr_mt_afr_fd_ctx_t);
|
||||
if (!fd_ctx) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory");
|
||||
@ -1092,8 +1094,9 @@ afr_fd_ctx_set (xlator_t *this, fd_t *fd)
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
fd_ctx->pre_op_done = CALLOC (sizeof (*fd_ctx->pre_op_done),
|
||||
priv->child_count);
|
||||
fd_ctx->pre_op_done = GF_CALLOC (sizeof (*fd_ctx->pre_op_done),
|
||||
priv->child_count,
|
||||
gf_afr_mt_char);
|
||||
if (!fd_ctx->pre_op_done) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory");
|
||||
@ -1101,8 +1104,9 @@ afr_fd_ctx_set (xlator_t *this, fd_t *fd)
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
fd_ctx->opened_on = CALLOC (sizeof (*fd_ctx->opened_on),
|
||||
priv->child_count);
|
||||
fd_ctx->opened_on = GF_CALLOC (sizeof (*fd_ctx->opened_on),
|
||||
priv->child_count,
|
||||
gf_afr_mt_char);
|
||||
if (!fd_ctx->opened_on) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory");
|
||||
@ -1110,8 +1114,10 @@ afr_fd_ctx_set (xlator_t *this, fd_t *fd)
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
fd_ctx->child_failed = CALLOC (sizeof (*fd_ctx->child_failed),
|
||||
priv->child_count);
|
||||
fd_ctx->child_failed = GF_CALLOC (
|
||||
sizeof (*fd_ctx->child_failed),
|
||||
priv->child_count,
|
||||
gf_afr_mt_char);
|
||||
|
||||
if (!fd_ctx->child_failed) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
@ -1436,15 +1442,15 @@ afr_cleanup_fd_ctx (xlator_t *this, fd_t *fd)
|
||||
|
||||
if (fd_ctx) {
|
||||
if (fd_ctx->child_failed)
|
||||
FREE (fd_ctx->child_failed);
|
||||
GF_FREE (fd_ctx->child_failed);
|
||||
|
||||
if (fd_ctx->pre_op_done)
|
||||
FREE (fd_ctx->pre_op_done);
|
||||
GF_FREE (fd_ctx->pre_op_done);
|
||||
|
||||
if (fd_ctx->opened_on)
|
||||
FREE (fd_ctx->opened_on);
|
||||
GF_FREE (fd_ctx->opened_on);
|
||||
|
||||
FREE (fd_ctx);
|
||||
GF_FREE (fd_ctx);
|
||||
}
|
||||
|
||||
out:
|
||||
@ -2176,11 +2182,13 @@ afr_checksum_cbk (call_frame_t *frame, void *cookie,
|
||||
if (op_ret == 0 && (local->op_ret != 0)) {
|
||||
local->op_ret = 0;
|
||||
|
||||
local->cont.checksum.file_checksum = MALLOC (NAME_MAX);
|
||||
local->cont.checksum.file_checksum =
|
||||
GF_MALLOC (NAME_MAX, gf_afr_mt_char);
|
||||
memcpy (local->cont.checksum.file_checksum, file_checksum,
|
||||
NAME_MAX);
|
||||
|
||||
local->cont.checksum.dir_checksum = MALLOC (NAME_MAX);
|
||||
local->cont.checksum.dir_checksum =
|
||||
GF_MALLOC (NAME_MAX, gf_afr_mt_char);
|
||||
memcpy (local->cont.checksum.dir_checksum, dir_checksum,
|
||||
NAME_MAX);
|
||||
|
||||
@ -2486,8 +2494,9 @@ afr_lk (call_frame_t *frame, xlator_t *this,
|
||||
|
||||
frame->local = local;
|
||||
|
||||
local->cont.lk.locked_nodes = CALLOC (priv->child_count,
|
||||
sizeof (*local->cont.lk.locked_nodes));
|
||||
local->cont.lk.locked_nodes = GF_CALLOC (priv->child_count,
|
||||
sizeof (*local->cont.lk.locked_nodes),
|
||||
gf_afr_mt_char);
|
||||
|
||||
if (!local->cont.lk.locked_nodes) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "Out of memory");
|
||||
@ -2676,6 +2685,25 @@ notify (xlator_t *this, int32_t event,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t
|
||||
mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!this)
|
||||
return ret;
|
||||
|
||||
ret = xlator_mem_acct_init (this, gf_afr_mt_end + 1);
|
||||
|
||||
if (ret != 0) {
|
||||
gf_log(this->name, GF_LOG_ERROR, "Memory accounting init"
|
||||
"failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static const char *favorite_child_warning_str = "You have specified subvolume '%s' "
|
||||
"as the 'favorite child'. This means that if a discrepancy in the content "
|
||||
@ -2718,6 +2746,7 @@ init (xlator_t *this)
|
||||
int read_ret = -1;
|
||||
int dict_ret = -1;
|
||||
|
||||
|
||||
if (!this->children) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"replicate translator needs more than one "
|
||||
@ -2730,6 +2759,7 @@ init (xlator_t *this)
|
||||
"Volume is dangling.");
|
||||
}
|
||||
|
||||
|
||||
ALLOC_OR_GOTO (this->private, afr_private_t, out);
|
||||
|
||||
priv = this->private;
|
||||
@ -2775,7 +2805,7 @@ init (xlator_t *this)
|
||||
dict_ret = dict_get_str (this->options, "data-self-heal-algorithm",
|
||||
&algo);
|
||||
if (dict_ret == 0) {
|
||||
priv->data_self_heal_algorithm = strdup (algo);
|
||||
priv->data_self_heal_algorithm = gf_strdup (algo);
|
||||
}
|
||||
|
||||
|
||||
@ -2946,7 +2976,8 @@ init (xlator_t *this)
|
||||
LOCK_INIT (&priv->lock);
|
||||
LOCK_INIT (&priv->read_child_lock);
|
||||
|
||||
priv->child_up = CALLOC (sizeof (unsigned char), child_count);
|
||||
priv->child_up = GF_CALLOC (sizeof (unsigned char), child_count,
|
||||
gf_afr_mt_char);
|
||||
if (!priv->child_up) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory.");
|
||||
@ -2954,7 +2985,8 @@ init (xlator_t *this)
|
||||
goto out;
|
||||
}
|
||||
|
||||
priv->children = CALLOC (sizeof (xlator_t *), child_count);
|
||||
priv->children = GF_CALLOC (sizeof (xlator_t *), child_count,
|
||||
gf_afr_mt_xlator_t);
|
||||
if (!priv->children) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory.");
|
||||
@ -2962,7 +2994,9 @@ init (xlator_t *this)
|
||||
goto out;
|
||||
}
|
||||
|
||||
priv->pending_key = CALLOC (sizeof (*priv->pending_key), child_count);
|
||||
priv->pending_key = GF_CALLOC (sizeof (*priv->pending_key),
|
||||
child_count,
|
||||
gf_afr_mt_char);
|
||||
if (!priv->pending_key) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory.");
|
||||
@ -2975,8 +3009,9 @@ init (xlator_t *this)
|
||||
while (i < child_count) {
|
||||
priv->children[i] = trav->xlator;
|
||||
|
||||
ret = asprintf (&priv->pending_key[i], "%s.%s", AFR_XATTR_PREFIX,
|
||||
trav->xlator->name);
|
||||
ret = gf_asprintf (&priv->pending_key[i], "%s.%s",
|
||||
AFR_XATTR_PREFIX,
|
||||
trav->xlator->name);
|
||||
if (-1 == ret) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"asprintf failed to set pending key");
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "scheduler.h"
|
||||
#include "call-stub.h"
|
||||
#include "compat-errno.h"
|
||||
#include "afr-mem-types.h"
|
||||
|
||||
#define AFR_XATTR_PREFIX "trusted.afr"
|
||||
|
||||
@ -302,7 +303,7 @@ typedef struct _afr_local {
|
||||
} readlink;
|
||||
|
||||
struct {
|
||||
const char *name;
|
||||
char *name;
|
||||
int last_tried;
|
||||
} getxattr;
|
||||
|
||||
@ -401,7 +402,7 @@ typedef struct _afr_local {
|
||||
} setxattr;
|
||||
|
||||
struct {
|
||||
const char *name;
|
||||
char *name;
|
||||
} removexattr;
|
||||
|
||||
/* dir write */
|
||||
@ -509,8 +510,8 @@ typedef struct _afr_local {
|
||||
unsigned char *locked_nodes;
|
||||
int lock_count;
|
||||
|
||||
const char *basename;
|
||||
const char *new_basename;
|
||||
char *basename;
|
||||
char *new_basename;
|
||||
|
||||
loc_t parent_loc;
|
||||
loc_t new_parent_loc;
|
||||
@ -559,7 +560,8 @@ typedef struct {
|
||||
|
||||
/* try alloc and if it fails, goto label */
|
||||
#define ALLOC_OR_GOTO(var, type, label) do { \
|
||||
var = CALLOC (sizeof (type), 1); \
|
||||
var = GF_CALLOC (sizeof (type), 1, \
|
||||
gf_afr_mt_##type); \
|
||||
if (!var) { \
|
||||
gf_log (this->name, GF_LOG_ERROR, \
|
||||
"out of memory :("); \
|
||||
@ -643,7 +645,7 @@ afr_cleanup_fd_ctx (xlator_t *this, fd_t *fd);
|
||||
frame->local = NULL; \
|
||||
STACK_UNWIND_STRICT (fop, frame, params); \
|
||||
afr_local_cleanup (__local, __this); \
|
||||
free (__local); \
|
||||
GF_FREE (__local); \
|
||||
} while (0);
|
||||
|
||||
#define AFR_STACK_DESTROY(frame) \
|
||||
@ -655,7 +657,7 @@ afr_cleanup_fd_ctx (xlator_t *this, fd_t *fd);
|
||||
frame->local = NULL; \
|
||||
STACK_DESTROY (frame->root); \
|
||||
afr_local_cleanup (__local, __this); \
|
||||
free (__local); \
|
||||
GF_FREE (__local); \
|
||||
} while (0);
|
||||
|
||||
/* allocate and return a string that is the basename of argument */
|
||||
@ -664,9 +666,9 @@ AFR_BASENAME (const char *str)
|
||||
{
|
||||
char *__tmp_str = NULL;
|
||||
char *__basename_str = NULL;
|
||||
__tmp_str = strdup (str);
|
||||
__basename_str = strdup (basename (__tmp_str));
|
||||
FREE (__tmp_str);
|
||||
__tmp_str = gf_strdup (str);
|
||||
__basename_str = gf_strdup (basename (__tmp_str));
|
||||
GF_FREE (__tmp_str);
|
||||
return __basename_str;
|
||||
}
|
||||
|
||||
@ -674,8 +676,9 @@ AFR_BASENAME (const char *str)
|
||||
static inline int
|
||||
AFR_LOCAL_INIT (afr_local_t *local, afr_private_t *priv)
|
||||
{
|
||||
local->child_up = CALLOC (sizeof (*local->child_up),
|
||||
priv->child_count);
|
||||
local->child_up = GF_CALLOC (sizeof (*local->child_up),
|
||||
priv->child_count,
|
||||
gf_afr_mt_char);
|
||||
if (!local->child_up) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -731,31 +734,36 @@ afr_transaction_local_init (afr_local_t *local, afr_private_t *priv)
|
||||
|
||||
local->first_up_child = afr_first_up_child (priv);
|
||||
|
||||
local->child_errno = CALLOC (sizeof (*local->child_errno),
|
||||
priv->child_count);
|
||||
local->child_errno = GF_CALLOC (sizeof (*local->child_errno),
|
||||
priv->child_count,
|
||||
gf_afr_mt_int32_t);
|
||||
if (!local->child_errno) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
local->pending = CALLOC (sizeof (*local->pending),
|
||||
priv->child_count);
|
||||
local->pending = GF_CALLOC (sizeof (*local->pending),
|
||||
priv->child_count,
|
||||
gf_afr_mt_int32_t);
|
||||
|
||||
if (!local->pending) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
for (i = 0; i < priv->child_count; i++) {
|
||||
local->pending[i] = CALLOC (sizeof (*local->pending[i]),
|
||||
3); /* data + metadata + entry */
|
||||
local->pending[i] = GF_CALLOC (sizeof (*local->pending[i]),
|
||||
3, /* data + metadata + entry */
|
||||
gf_afr_mt_int32_t);
|
||||
if (!local->pending[i])
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
local->transaction.locked_nodes = CALLOC (sizeof (*local->transaction.locked_nodes),
|
||||
priv->child_count);
|
||||
local->transaction.locked_nodes = GF_CALLOC (sizeof (*local->transaction.locked_nodes),
|
||||
priv->child_count,
|
||||
gf_afr_mt_char);
|
||||
|
||||
local->transaction.child_errno = CALLOC (sizeof (*local->transaction.child_errno),
|
||||
priv->child_count);
|
||||
local->transaction.child_errno = GF_CALLOC (sizeof (*local->transaction.child_errno),
|
||||
priv->child_count,
|
||||
gf_afr_mt_int32_t);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -3557,7 +3557,8 @@ dht_rmdir_is_subvol_empty (call_frame_t *frame, xlator_t *this,
|
||||
goto err;
|
||||
}
|
||||
|
||||
lookup_local = CALLOC (sizeof (*local), 1);
|
||||
lookup_local = GF_CALLOC (sizeof (*local), 1,
|
||||
gf_dht_mt_dht_local_t);
|
||||
if (!lookup_local) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of Memory");
|
||||
@ -4235,7 +4236,8 @@ dht_init_subvolumes (xlator_t *this, dht_conf_t *conf)
|
||||
for (subvols = this->children; subvols; subvols = subvols->next)
|
||||
cnt++;
|
||||
|
||||
conf->subvolumes = CALLOC (cnt, sizeof (xlator_t *));
|
||||
conf->subvolumes = GF_CALLOC (cnt, sizeof (xlator_t *),
|
||||
gf_dht_mt_xlator_t);
|
||||
if (!conf->subvolumes) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory");
|
||||
@ -4247,7 +4249,8 @@ dht_init_subvolumes (xlator_t *this, dht_conf_t *conf)
|
||||
for (subvols = this->children; subvols; subvols = subvols->next)
|
||||
conf->subvolumes[cnt++] = subvols->xlator;
|
||||
|
||||
conf->subvolume_status = CALLOC (cnt, sizeof (char));
|
||||
conf->subvolume_status = GF_CALLOC (cnt, sizeof (char),
|
||||
gf_dht_mt_char);
|
||||
if (!conf->subvolume_status) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory");
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "dht-mem-types.h"
|
||||
|
||||
#ifndef _DHT_H
|
||||
#define _DHT_H
|
||||
|
||||
|
@ -148,7 +148,7 @@ dht_local_wipe (xlator_t *this, dht_local_t *local)
|
||||
local->selfheal.layout = NULL;
|
||||
}
|
||||
|
||||
FREE (local);
|
||||
GF_FREE (local);
|
||||
}
|
||||
|
||||
|
||||
@ -158,7 +158,8 @@ dht_local_init (call_frame_t *frame)
|
||||
dht_local_t *local = NULL;
|
||||
|
||||
/* TODO: use mem-pool */
|
||||
local = CALLOC (1, sizeof (*local));
|
||||
local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_dht_mt_dht_local_t);
|
||||
|
||||
if (!local)
|
||||
return NULL;
|
||||
@ -408,9 +409,9 @@ dht_build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name)
|
||||
}
|
||||
|
||||
if (strcmp (parent->path, "/") == 0)
|
||||
asprintf ((char **)&child->path, "/%s", name);
|
||||
gf_asprintf ((char **)&child->path, "/%s", name);
|
||||
else
|
||||
asprintf ((char **)&child->path, "%s/%s", parent->path, name);
|
||||
gf_asprintf ((char **)&child->path, "%s/%s", parent->path, name);
|
||||
|
||||
if (!child->path) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
|
@ -44,7 +44,8 @@ dht_layout_new (xlator_t *this, int cnt)
|
||||
|
||||
conf = this->private;
|
||||
|
||||
layout = CALLOC (1, layout_size (cnt));
|
||||
layout = GF_CALLOC (1, layout_size (cnt),
|
||||
gf_dht_mt_dht_layout_t);
|
||||
if (!layout) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory");
|
||||
@ -131,7 +132,7 @@ dht_layout_unref (xlator_t *this, dht_layout_t *layout)
|
||||
UNLOCK (&conf->layout_lock);
|
||||
|
||||
if (!ref)
|
||||
FREE (layout);
|
||||
GF_FREE (layout);
|
||||
}
|
||||
|
||||
|
||||
@ -218,8 +219,9 @@ dht_layouts_init (xlator_t *this, dht_conf_t *conf)
|
||||
int ret = -1;
|
||||
|
||||
|
||||
conf->file_layouts = CALLOC (conf->subvolume_cnt,
|
||||
sizeof (dht_layout_t *));
|
||||
conf->file_layouts = GF_CALLOC (conf->subvolume_cnt,
|
||||
sizeof (dht_layout_t *),
|
||||
gf_dht_mt_dht_layout_t);
|
||||
if (!conf->file_layouts) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory");
|
||||
@ -253,7 +255,8 @@ dht_disk_layout_extract (xlator_t *this, dht_layout_t *layout,
|
||||
int ret = -1;
|
||||
int32_t *disk_layout = NULL;
|
||||
|
||||
disk_layout = CALLOC (5, sizeof (int));
|
||||
disk_layout = GF_CALLOC (5, sizeof (int),
|
||||
gf_dht_mt_int32_t);
|
||||
if (!disk_layout) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory");
|
||||
|
42
xlators/cluster/dht/src/dht-mem-types.h
Normal file
42
xlators/cluster/dht/src/dht-mem-types.h
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
/*
|
||||
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 __DHT_MEM_TYPES_H__
|
||||
#define __DHT_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_dht_mem_types_ {
|
||||
gf_dht_mt_dht_du_t = gf_common_mt_end + 1,
|
||||
gf_dht_mt_dht_conf_t,
|
||||
gf_dht_mt_char,
|
||||
gf_dht_mt_int32_t,
|
||||
gf_dht_mt_dht_local_t,
|
||||
gf_dht_mt_xlator_t,
|
||||
gf_dht_mt_dht_layout_t,
|
||||
gf_switch_mt_dht_conf_t,
|
||||
gf_switch_mt_dht_du_t,
|
||||
gf_switch_mt_switch_sched_array,
|
||||
gf_switch_mt_switch_struct,
|
||||
gf_dht_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -138,7 +138,7 @@ err:
|
||||
dict_destroy (xattr);
|
||||
|
||||
if (disk_layout)
|
||||
FREE (disk_layout);
|
||||
GF_FREE (disk_layout);
|
||||
|
||||
dht_selfheal_dir_xattr_cbk (frame, subvol, frame->this,
|
||||
-1, ENOMEM);
|
||||
|
@ -212,26 +212,45 @@ fini (xlator_t *this)
|
||||
if (conf) {
|
||||
if (conf->file_layouts) {
|
||||
for (i = 0; i < conf->subvolume_cnt; i++) {
|
||||
FREE (conf->file_layouts[i]);
|
||||
GF_FREE (conf->file_layouts[i]);
|
||||
}
|
||||
FREE (conf->file_layouts);
|
||||
GF_FREE (conf->file_layouts);
|
||||
}
|
||||
|
||||
if (conf->default_dir_layout)
|
||||
FREE (conf->default_dir_layout);
|
||||
GF_FREE (conf->default_dir_layout);
|
||||
|
||||
if (conf->subvolumes)
|
||||
FREE (conf->subvolumes);
|
||||
GF_FREE (conf->subvolumes);
|
||||
|
||||
if (conf->subvolume_status)
|
||||
FREE (conf->subvolume_status);
|
||||
GF_FREE (conf->subvolume_status);
|
||||
|
||||
FREE (conf);
|
||||
GF_FREE (conf);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t
|
||||
mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!this)
|
||||
return ret;
|
||||
|
||||
ret = xlator_mem_acct_init (this, gf_dht_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)
|
||||
{
|
||||
@ -241,6 +260,7 @@ init (xlator_t *this)
|
||||
int i = 0;
|
||||
uint32_t temp_free_disk = 0;
|
||||
|
||||
|
||||
if (!this->children) {
|
||||
gf_log (this->name, GF_LOG_CRITICAL,
|
||||
"Distribute needs more than one subvolume");
|
||||
@ -252,7 +272,7 @@ init (xlator_t *this)
|
||||
"dangling volume. check volfile");
|
||||
}
|
||||
|
||||
conf = CALLOC (1, sizeof (*conf));
|
||||
conf = GF_CALLOC (1, sizeof (*conf), gf_dht_mt_dht_conf_t);
|
||||
if (!conf) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory");
|
||||
@ -302,7 +322,8 @@ init (xlator_t *this)
|
||||
goto err;
|
||||
}
|
||||
|
||||
conf->du_stats = CALLOC (conf->subvolume_cnt, sizeof (dht_du_t));
|
||||
conf->du_stats = GF_CALLOC (conf->subvolume_cnt, sizeof (dht_du_t),
|
||||
gf_dht_mt_dht_du_t);
|
||||
if (!conf->du_stats) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory");
|
||||
@ -322,24 +343,24 @@ err:
|
||||
if (conf) {
|
||||
if (conf->file_layouts) {
|
||||
for (i = 0; i < conf->subvolume_cnt; i++) {
|
||||
FREE (conf->file_layouts[i]);
|
||||
GF_FREE (conf->file_layouts[i]);
|
||||
}
|
||||
FREE (conf->file_layouts);
|
||||
GF_FREE (conf->file_layouts);
|
||||
}
|
||||
|
||||
if (conf->default_dir_layout)
|
||||
FREE (conf->default_dir_layout);
|
||||
GF_FREE (conf->default_dir_layout);
|
||||
|
||||
if (conf->subvolumes)
|
||||
FREE (conf->subvolumes);
|
||||
GF_FREE (conf->subvolumes);
|
||||
|
||||
if (conf->subvolume_status)
|
||||
FREE (conf->subvolume_status);
|
||||
GF_FREE (conf->subvolume_status);
|
||||
|
||||
if (conf->du_stats)
|
||||
FREE (conf->du_stats);
|
||||
GF_FREE (conf->du_stats);
|
||||
|
||||
FREE (conf);
|
||||
GF_FREE (conf);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -513,21 +513,21 @@ fini (xlator_t *this)
|
||||
if (conf) {
|
||||
if (conf->file_layouts) {
|
||||
for (i = 0; i < conf->subvolume_cnt; i++) {
|
||||
FREE (conf->file_layouts[i]);
|
||||
GF_FREE (conf->file_layouts[i]);
|
||||
}
|
||||
FREE (conf->file_layouts);
|
||||
GF_FREE (conf->file_layouts);
|
||||
}
|
||||
|
||||
if (conf->default_dir_layout)
|
||||
FREE (conf->default_dir_layout);
|
||||
GF_FREE (conf->default_dir_layout);
|
||||
|
||||
if (conf->subvolumes)
|
||||
FREE (conf->subvolumes);
|
||||
GF_FREE (conf->subvolumes);
|
||||
|
||||
if (conf->subvolume_status)
|
||||
FREE (conf->subvolume_status);
|
||||
GF_FREE (conf->subvolume_status);
|
||||
|
||||
FREE (conf);
|
||||
GF_FREE (conf);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -557,7 +557,8 @@ init (xlator_t *this)
|
||||
"dangling volume. check volfile");
|
||||
}
|
||||
|
||||
conf = CALLOC (1, sizeof (*conf));
|
||||
conf = GF_CALLOC (1, sizeof (*conf),
|
||||
gf_dht_mt_dht_conf_t);
|
||||
if (!conf) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory");
|
||||
@ -642,7 +643,8 @@ init (xlator_t *this)
|
||||
}
|
||||
}
|
||||
|
||||
conf->du_stats = CALLOC (conf->subvolume_cnt, sizeof (dht_du_t));
|
||||
conf->du_stats = GF_CALLOC (conf->subvolume_cnt, sizeof (dht_du_t),
|
||||
gf_dht_mt_dht_du_t);
|
||||
if (!conf->du_stats) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory");
|
||||
@ -657,24 +659,24 @@ err:
|
||||
if (conf) {
|
||||
if (conf->file_layouts) {
|
||||
for (i = 0; i < conf->subvolume_cnt; i++) {
|
||||
FREE (conf->file_layouts[i]);
|
||||
GF_FREE (conf->file_layouts[i]);
|
||||
}
|
||||
FREE (conf->file_layouts);
|
||||
GF_FREE (conf->file_layouts);
|
||||
}
|
||||
|
||||
if (conf->default_dir_layout)
|
||||
FREE (conf->default_dir_layout);
|
||||
GF_FREE (conf->default_dir_layout);
|
||||
|
||||
if (conf->subvolumes)
|
||||
FREE (conf->subvolumes);
|
||||
GF_FREE (conf->subvolumes);
|
||||
|
||||
if (conf->subvolume_status)
|
||||
FREE (conf->subvolume_status);
|
||||
GF_FREE (conf->subvolume_status);
|
||||
|
||||
if (conf->du_stats)
|
||||
FREE (conf->du_stats);
|
||||
GF_FREE (conf->du_stats);
|
||||
|
||||
FREE (conf);
|
||||
GF_FREE (conf);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#endif
|
||||
|
||||
#include "dht-common.c"
|
||||
#include "dht-mem-types.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
@ -82,7 +83,7 @@ get_switch_matching_subvol (const char *path, dht_conf_t *conf,
|
||||
return hashed_subvol;
|
||||
|
||||
trav = cond;
|
||||
pathname = strdup (path);
|
||||
pathname = gf_strdup (path);
|
||||
while (trav) {
|
||||
if (fnmatch (trav->path_pattern,
|
||||
pathname, FNM_NOESCAPE) == 0) {
|
||||
@ -96,7 +97,7 @@ get_switch_matching_subvol (const char *path, dht_conf_t *conf,
|
||||
}
|
||||
trav = trav->next;
|
||||
}
|
||||
free (pathname);
|
||||
GF_FREE (pathname);
|
||||
return hashed_subvol;
|
||||
}
|
||||
|
||||
@ -620,29 +621,29 @@ fini (xlator_t *this)
|
||||
conf->private = NULL;
|
||||
while (trav) {
|
||||
if (trav->array)
|
||||
FREE (trav->array);
|
||||
GF_FREE (trav->array);
|
||||
prev = trav;
|
||||
trav = trav->next;
|
||||
FREE (prev);
|
||||
GF_FREE (prev);
|
||||
}
|
||||
|
||||
if (conf->file_layouts) {
|
||||
for (i = 0; i < conf->subvolume_cnt; i++) {
|
||||
FREE (conf->file_layouts[i]);
|
||||
GF_FREE (conf->file_layouts[i]);
|
||||
}
|
||||
FREE (conf->file_layouts);
|
||||
GF_FREE (conf->file_layouts);
|
||||
}
|
||||
|
||||
if (conf->default_dir_layout)
|
||||
FREE (conf->default_dir_layout);
|
||||
GF_FREE (conf->default_dir_layout);
|
||||
|
||||
if (conf->subvolumes)
|
||||
FREE (conf->subvolumes);
|
||||
GF_FREE (conf->subvolumes);
|
||||
|
||||
if (conf->subvolume_status)
|
||||
FREE (conf->subvolume_status);
|
||||
GF_FREE (conf->subvolume_status);
|
||||
|
||||
FREE (conf);
|
||||
GF_FREE (conf);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -679,8 +680,9 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
|
||||
trav_xl = trav_xl->next;
|
||||
}
|
||||
child_count = index;
|
||||
switch_buf_array = CALLOC ((index + 1),
|
||||
sizeof (struct switch_sched_array));
|
||||
switch_buf_array = GF_CALLOC ((index + 1),
|
||||
sizeof (struct switch_sched_array),
|
||||
gf_switch_mt_switch_sched_array);
|
||||
if (!switch_buf_array)
|
||||
goto err;
|
||||
|
||||
@ -698,11 +700,12 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
|
||||
|
||||
/* Get the pattern for considering switch case.
|
||||
"option block-size *avi:10MB" etc */
|
||||
option_string = strdup (pattern_str);
|
||||
option_string = gf_strdup (pattern_str);
|
||||
switch_str = strtok_r (option_string, ";", &tmp_str);
|
||||
while (switch_str) {
|
||||
dup_str = strdup (switch_str);
|
||||
switch_opt = CALLOC (1, sizeof (struct switch_struct));
|
||||
dup_str = gf_strdup (switch_str);
|
||||
switch_opt = GF_CALLOC (1, sizeof (struct switch_struct),
|
||||
gf_switch_mt_switch_struct);
|
||||
if (!switch_opt)
|
||||
goto err;
|
||||
|
||||
@ -714,12 +717,12 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
|
||||
"for all the unconfigured child nodes,"
|
||||
" hence neglecting current option");
|
||||
switch_str = strtok_r (NULL, ";", &tmp_str);
|
||||
free (dup_str);
|
||||
GF_FREE (dup_str);
|
||||
continue;
|
||||
}
|
||||
memcpy (switch_opt->path_pattern, pattern, strlen (pattern));
|
||||
if (childs) {
|
||||
dup_childs = strdup (childs);
|
||||
dup_childs = gf_strdup (childs);
|
||||
child = strtok_r (dup_childs, ",", &tmp);
|
||||
while (child) {
|
||||
if (gf_switch_valid_child (this, child)) {
|
||||
@ -734,11 +737,12 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
free (dup_childs);
|
||||
GF_FREE (dup_childs);
|
||||
child = strtok_r (childs, ",", &tmp1);
|
||||
switch_opt->num_child = idx;
|
||||
switch_opt->array = CALLOC (1, (idx *
|
||||
sizeof (struct switch_sched_array)));
|
||||
switch_opt->array = GF_CALLOC (1, (idx *
|
||||
sizeof (struct switch_sched_array)),
|
||||
gf_switch_mt_switch_sched_array);
|
||||
if (!switch_opt->array)
|
||||
goto err;
|
||||
idx = 0;
|
||||
@ -772,7 +776,7 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
|
||||
"option in unify volume. Exiting");
|
||||
goto err;
|
||||
}
|
||||
free (dup_str);
|
||||
GF_FREE (dup_str);
|
||||
|
||||
/* Link it to the main structure */
|
||||
if (switch_buf) {
|
||||
@ -803,7 +807,8 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
|
||||
"No nodes left for pattern '*'. Exiting");
|
||||
goto err;
|
||||
}
|
||||
switch_opt = CALLOC (1, sizeof (struct switch_struct));
|
||||
switch_opt = GF_CALLOC (1, sizeof (struct switch_struct),
|
||||
gf_switch_mt_switch_struct);
|
||||
if (!switch_opt)
|
||||
goto err;
|
||||
|
||||
@ -811,7 +816,9 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
|
||||
memcpy (switch_opt->path_pattern, "*", 2);
|
||||
switch_opt->num_child = flag;
|
||||
switch_opt->array =
|
||||
CALLOC (1, flag * sizeof (struct switch_sched_array));
|
||||
GF_CALLOC (1,
|
||||
flag * sizeof (struct switch_sched_array),
|
||||
gf_switch_mt_switch_sched_array);
|
||||
if (!switch_opt->array)
|
||||
goto err;
|
||||
flag = 0;
|
||||
@ -846,14 +853,14 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
|
||||
err:
|
||||
if (switch_buf) {
|
||||
if (switch_buf_array)
|
||||
FREE (switch_buf_array);
|
||||
GF_FREE (switch_buf_array);
|
||||
trav = switch_buf;
|
||||
while (trav) {
|
||||
if (trav->array)
|
||||
FREE (trav->array);
|
||||
GF_FREE (trav->array);
|
||||
switch_opt = trav;
|
||||
trav = trav->next;
|
||||
FREE (switch_opt);
|
||||
GF_FREE (switch_opt);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@ -881,7 +888,7 @@ init (xlator_t *this)
|
||||
"dangling volume. check volfile");
|
||||
}
|
||||
|
||||
conf = CALLOC (1, sizeof (*conf));
|
||||
conf = GF_CALLOC (1, sizeof (*conf), gf_switch_mt_dht_conf_t);
|
||||
if (!conf) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory");
|
||||
@ -947,7 +954,8 @@ init (xlator_t *this)
|
||||
|
||||
conf->gen = 1;
|
||||
|
||||
conf->du_stats = CALLOC (conf->subvolume_cnt, sizeof (dht_du_t));
|
||||
conf->du_stats = GF_CALLOC (conf->subvolume_cnt, sizeof (dht_du_t),
|
||||
gf_switch_mt_dht_du_t);
|
||||
if (!conf->du_stats) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory");
|
||||
@ -962,24 +970,24 @@ err:
|
||||
if (conf) {
|
||||
if (conf->file_layouts) {
|
||||
for (i = 0; i < conf->subvolume_cnt; i++) {
|
||||
FREE (conf->file_layouts[i]);
|
||||
GF_FREE (conf->file_layouts[i]);
|
||||
}
|
||||
FREE (conf->file_layouts);
|
||||
GF_FREE (conf->file_layouts);
|
||||
}
|
||||
|
||||
if (conf->default_dir_layout)
|
||||
FREE (conf->default_dir_layout);
|
||||
GF_FREE (conf->default_dir_layout);
|
||||
|
||||
if (conf->subvolumes)
|
||||
FREE (conf->subvolumes);
|
||||
GF_FREE (conf->subvolumes);
|
||||
|
||||
if (conf->subvolume_status)
|
||||
FREE (conf->subvolume_status);
|
||||
GF_FREE (conf->subvolume_status);
|
||||
|
||||
if (conf->du_stats)
|
||||
FREE (conf->du_stats);
|
||||
GF_FREE (conf->du_stats);
|
||||
|
||||
FREE (conf);
|
||||
GF_FREE (conf);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -49,12 +49,14 @@ int ha_alloc_init_fd (call_frame_t *frame, fd_t *fd)
|
||||
goto out;
|
||||
}
|
||||
hafdp = (hafd_t *)(long)tmp_hafdp;
|
||||
local = frame->local = CALLOC (1, sizeof (*local));
|
||||
local = frame->local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_ha_mt_ha_local_t);
|
||||
if (local == NULL) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
local->state = CALLOC (1, child_count);
|
||||
local->state = GF_CALLOC (1, child_count,
|
||||
gf_ha_mt_child_count);
|
||||
if (local->state == NULL) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
@ -147,7 +149,7 @@ int ha_handle_cbk (call_frame_t *frame, void *cookie, int op_ret, int op_errno)
|
||||
}
|
||||
|
||||
if (local->fd) {
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
local->state = NULL;
|
||||
|
||||
fd_unref (local->fd);
|
||||
@ -170,7 +172,8 @@ int ha_alloc_init_inode (call_frame_t *frame, inode_t *inode)
|
||||
local = frame->local;
|
||||
|
||||
if (local == NULL) {
|
||||
local = frame->local = CALLOC (1, sizeof (*local));
|
||||
local = frame->local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_ha_mt_ha_local_t);
|
||||
if (local == NULL) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
|
37
xlators/cluster/ha/src/ha-mem-types.h
Normal file
37
xlators/cluster/ha/src/ha-mem-types.h
Normal file
@ -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 __HA_MEM_TYPES_H__
|
||||
#define __HA_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_ha_mem_types_ {
|
||||
gf_ha_mt_ha_local_t = gf_common_mt_end + 1,
|
||||
gf_ha_mt_hafd_t,
|
||||
gf_ha_mt_char,
|
||||
gf_ha_mt_child_count,
|
||||
gf_ha_mt_xlator_t,
|
||||
gf_ha_mt_ha_private_t,
|
||||
gf_ha_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -50,7 +50,7 @@ ha_local_wipe (ha_local_t *local)
|
||||
}
|
||||
|
||||
if (local->state) {
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
local->state = NULL;
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ ha_local_wipe (ha_local_t *local)
|
||||
local->inode = NULL;
|
||||
}
|
||||
|
||||
FREE (local);
|
||||
GF_FREE (local);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ ha_forget (xlator_t *this,
|
||||
char *state = NULL;
|
||||
if (!inode_ctx_del (inode, this, &stateino)) {
|
||||
state = ((char *)(long)stateino);
|
||||
FREE (state);
|
||||
GF_FREE (state);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -193,7 +193,8 @@ ha_lookup (call_frame_t *frame,
|
||||
child_count = pvt->child_count;
|
||||
children = pvt->children;
|
||||
|
||||
frame->local = local = CALLOC (1, sizeof (*local));
|
||||
frame->local = local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_ha_mt_ha_local_t);
|
||||
if (!local) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
op_errno = ENOMEM;
|
||||
@ -205,7 +206,7 @@ ha_lookup (call_frame_t *frame,
|
||||
|
||||
ret = inode_ctx_get (loc->inode, this, NULL);
|
||||
if (ret) {
|
||||
state = CALLOC (1, child_count);
|
||||
state = GF_CALLOC (1, child_count, gf_ha_mt_child_count);
|
||||
if (state == NULL) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
op_errno = ENOMEM;
|
||||
@ -645,7 +646,7 @@ ha_mknod_lookup_cbk (call_frame_t *frame,
|
||||
|
||||
if (cnt == 0) {
|
||||
call_stub_t *stub = local->stub;
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
STACK_UNWIND (frame,
|
||||
local->op_ret,
|
||||
local->op_errno,
|
||||
@ -715,7 +716,7 @@ ha_mknod_cbk (call_frame_t *frame,
|
||||
|
||||
if (cnt == 0 || i == child_count) {
|
||||
call_stub_t *stub = local->stub;
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
stub = local->stub;
|
||||
STACK_UNWIND (frame, local->op_ret, local->op_errno,
|
||||
local->stub->args.mknod.loc.inode, &local->buf,
|
||||
@ -770,7 +771,8 @@ ha_mknod (call_frame_t *frame,
|
||||
pvt = this->private;
|
||||
child_count = pvt->child_count;
|
||||
|
||||
frame->local = local = CALLOC (1, sizeof (*local));
|
||||
frame->local = local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_ha_mt_ha_local_t);
|
||||
if (!local) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
op_errno = ENOMEM;
|
||||
@ -786,7 +788,7 @@ ha_mknod (call_frame_t *frame,
|
||||
|
||||
local->op_ret = -1;
|
||||
local->op_errno = ENOTCONN;
|
||||
local->state = CALLOC (1, child_count);
|
||||
local->state = GF_CALLOC (1, child_count, gf_ha_mt_char);
|
||||
if (!local->state) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
op_errno = ENOMEM;
|
||||
@ -796,7 +798,7 @@ ha_mknod (call_frame_t *frame,
|
||||
memcpy (local->state, pvt->state, child_count);
|
||||
local->active = -1;
|
||||
|
||||
stateino = CALLOC (1, child_count);
|
||||
stateino = GF_CALLOC (1, child_count, gf_ha_mt_char);
|
||||
if (!stateino) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
op_errno = ENOMEM;
|
||||
@ -875,7 +877,7 @@ ha_mkdir_lookup_cbk (call_frame_t *frame,
|
||||
|
||||
if (cnt == 0) {
|
||||
call_stub_t *stub = local->stub;
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
STACK_UNWIND (frame,
|
||||
local->op_ret,
|
||||
local->op_errno,
|
||||
@ -940,7 +942,7 @@ ha_mkdir_cbk (call_frame_t *frame,
|
||||
|
||||
if (cnt == 0 || i == child_count) {
|
||||
call_stub_t *stub = local->stub;
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
stub = local->stub;
|
||||
STACK_UNWIND (frame, local->op_ret, local->op_errno,
|
||||
local->stub->args.mkdir.loc.inode, &local->buf,
|
||||
@ -993,7 +995,8 @@ ha_mkdir (call_frame_t *frame,
|
||||
pvt = this->private;
|
||||
child_count = pvt->child_count;
|
||||
|
||||
frame->local = local = CALLOC (1, sizeof (*local));
|
||||
frame->local = local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_ha_mt_ha_local_t);
|
||||
if (!frame->local) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
op_errno = ENOMEM;
|
||||
@ -1009,7 +1012,7 @@ ha_mkdir (call_frame_t *frame,
|
||||
|
||||
local->op_ret = -1;
|
||||
local->op_errno = ENOTCONN;
|
||||
local->state = CALLOC (1, child_count);
|
||||
local->state = GF_CALLOC (1, child_count, gf_ha_mt_char);
|
||||
if (!local->state) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
op_errno = ENOMEM;
|
||||
@ -1019,7 +1022,7 @@ ha_mkdir (call_frame_t *frame,
|
||||
memcpy (local->state, pvt->state, child_count);
|
||||
local->active = -1;
|
||||
|
||||
stateino = CALLOC (1, child_count);
|
||||
stateino = GF_CALLOC (1, child_count, gf_ha_mt_char);
|
||||
if (!stateino) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
op_errno = ENOMEM;
|
||||
@ -1204,7 +1207,7 @@ ha_symlink_lookup_cbk (call_frame_t *frame,
|
||||
|
||||
if (cnt == 0) {
|
||||
call_stub_t *stub = local->stub;
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
STACK_UNWIND (frame,
|
||||
local->op_ret,
|
||||
local->op_errno,
|
||||
@ -1268,7 +1271,7 @@ ha_symlink_cbk (call_frame_t *frame,
|
||||
|
||||
if (cnt == 0 || i == child_count) {
|
||||
call_stub_t *stub = local->stub;
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
stub = local->stub;
|
||||
STACK_UNWIND (frame, local->op_ret, local->op_errno,
|
||||
local->stub->args.symlink.loc.inode, &local->buf,
|
||||
@ -1321,7 +1324,8 @@ ha_symlink (call_frame_t *frame,
|
||||
pvt = this->private;
|
||||
child_count = pvt->child_count;
|
||||
|
||||
frame->local = local = CALLOC (1, sizeof (*local));
|
||||
frame->local = local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_ha_mt_ha_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
@ -1337,7 +1341,7 @@ ha_symlink (call_frame_t *frame,
|
||||
|
||||
local->op_ret = -1;
|
||||
local->op_errno = ENOTCONN;
|
||||
local->state = CALLOC (1, child_count);
|
||||
local->state = GF_CALLOC (1, child_count, gf_ha_mt_char);
|
||||
if (!local->state) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
@ -1347,7 +1351,7 @@ ha_symlink (call_frame_t *frame,
|
||||
memcpy (local->state, pvt->state, child_count);
|
||||
local->active = -1;
|
||||
|
||||
stateino = CALLOC (1, child_count);
|
||||
stateino = GF_CALLOC (1, child_count, gf_ha_mt_char);
|
||||
if (!stateino) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
@ -1481,7 +1485,7 @@ ha_link_lookup_cbk (call_frame_t *frame,
|
||||
|
||||
if (cnt == 0) {
|
||||
call_stub_t *stub = local->stub;
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
STACK_UNWIND (frame,
|
||||
local->op_ret,
|
||||
local->op_errno,
|
||||
@ -1545,7 +1549,7 @@ ha_link_cbk (call_frame_t *frame,
|
||||
|
||||
if (cnt == 0 || i == child_count) {
|
||||
call_stub_t *stub = local->stub;
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
stub = local->stub;
|
||||
STACK_UNWIND (frame, local->op_ret, local->op_errno,
|
||||
local->stub->args.link.oldloc.inode, &local->buf,
|
||||
@ -1613,7 +1617,8 @@ ha_link (call_frame_t *frame,
|
||||
pvt = this->private;
|
||||
child_count = pvt->child_count;
|
||||
|
||||
frame->local = local = CALLOC (1, sizeof (*local));
|
||||
frame->local = local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_ha_mt_ha_local_t);
|
||||
if (!frame->local) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
op_errno = ENOMEM;
|
||||
@ -1629,7 +1634,7 @@ ha_link (call_frame_t *frame,
|
||||
|
||||
local->op_ret = -1;
|
||||
local->op_errno = ENOTCONN;
|
||||
local->state = CALLOC (1, child_count);
|
||||
local->state = GF_CALLOC (1, child_count, gf_ha_mt_char);
|
||||
if (!local->state) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
op_errno = ENOMEM;
|
||||
@ -1741,7 +1746,7 @@ ha_create_cbk (call_frame_t *frame,
|
||||
stub->args.create.fd,
|
||||
stub->args.create.loc.inode, &local->buf,
|
||||
&local->preparent, &local->postparent);
|
||||
FREE (state);
|
||||
GF_FREE (state);
|
||||
call_stub_destroy (stub);
|
||||
return 0;
|
||||
}
|
||||
@ -1785,7 +1790,8 @@ ha_create (call_frame_t *frame,
|
||||
children = pvt->children;
|
||||
|
||||
if (local == NULL) {
|
||||
local = frame->local = CALLOC (1, sizeof (*local));
|
||||
frame->local = local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_ha_mt_ha_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
@ -1799,7 +1805,7 @@ ha_create (call_frame_t *frame,
|
||||
goto err;
|
||||
}
|
||||
|
||||
local->state = CALLOC (1, child_count);
|
||||
local->state = GF_CALLOC (1, child_count, gf_ha_mt_char);
|
||||
if (!local->state) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
@ -1819,28 +1825,28 @@ ha_create (call_frame_t *frame,
|
||||
}
|
||||
}
|
||||
/* FIXME handle active -1 */
|
||||
stateino = CALLOC (1, child_count);
|
||||
stateino = GF_CALLOC (1, child_count, gf_ha_mt_char);
|
||||
if (!stateino) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
goto err;
|
||||
}
|
||||
|
||||
hafdp = CALLOC (1, sizeof (*hafdp));
|
||||
hafdp = GF_CALLOC (1, sizeof (*hafdp), gf_ha_mt_hafd_t);
|
||||
if (!hafdp) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
goto err;
|
||||
}
|
||||
|
||||
hafdp->fdstate = CALLOC (1, child_count);
|
||||
hafdp->fdstate = GF_CALLOC (1, child_count, gf_ha_mt_char);
|
||||
if (!hafdp->fdstate) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
goto err;
|
||||
}
|
||||
|
||||
hafdp->path = strdup(loc->path);
|
||||
hafdp->path = gf_strdup(loc->path);
|
||||
if (!hafdp->path) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
@ -1865,20 +1871,20 @@ err:
|
||||
ha_local_wipe (local);
|
||||
|
||||
if (stateino) {
|
||||
FREE (stateino);
|
||||
GF_FREE (stateino);
|
||||
stateino = NULL;
|
||||
}
|
||||
|
||||
if (hafdp) {
|
||||
if (hafdp->fdstate) {
|
||||
FREE (hafdp->fdstate);
|
||||
GF_FREE (hafdp->fdstate);
|
||||
}
|
||||
|
||||
if (hafdp->path) {
|
||||
FREE (hafdp->path);
|
||||
GF_FREE (hafdp->path);
|
||||
}
|
||||
|
||||
FREE (hafdp);
|
||||
GF_FREE (hafdp);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1955,7 +1961,8 @@ ha_open (call_frame_t *frame,
|
||||
child_count = pvt->child_count;
|
||||
|
||||
|
||||
local = frame->local = CALLOC (1, sizeof (*local));
|
||||
frame->local = local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_ha_mt_ha_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
@ -1966,21 +1973,21 @@ ha_open (call_frame_t *frame,
|
||||
local->op_errno = ENOTCONN;
|
||||
local->fd = fd;
|
||||
|
||||
hafdp = CALLOC (1, sizeof (*hafdp));
|
||||
hafdp = GF_CALLOC (1, sizeof (*hafdp), gf_ha_mt_hafd_t);
|
||||
if (!hafdp) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
goto err;
|
||||
}
|
||||
|
||||
hafdp->fdstate = CALLOC (1, child_count);
|
||||
hafdp->fdstate = GF_CALLOC (1, child_count, gf_ha_mt_char);
|
||||
if (!hafdp->fdstate) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
goto err;
|
||||
}
|
||||
|
||||
hafdp->path = strdup (loc->path);
|
||||
hafdp->path = gf_strdup (loc->path);
|
||||
if (!hafdp->path) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
@ -2020,16 +2027,16 @@ err:
|
||||
STACK_UNWIND (frame, -1, op_errno, fd);
|
||||
if (hafdp) {
|
||||
if (hafdp->fdstate) {
|
||||
FREE (hafdp->fdstate);
|
||||
GF_FREE (hafdp->fdstate);
|
||||
hafdp->fdstate = NULL;
|
||||
}
|
||||
|
||||
if (hafdp->path) {
|
||||
FREE (hafdp->path);
|
||||
GF_FREE (hafdp->path);
|
||||
hafdp->path = NULL;
|
||||
}
|
||||
|
||||
FREE (hafdp);
|
||||
GF_FREE (hafdp);
|
||||
}
|
||||
|
||||
ha_local_wipe (local);
|
||||
@ -2420,7 +2427,8 @@ ha_opendir (call_frame_t *frame,
|
||||
children = pvt->children;
|
||||
child_count = pvt->child_count;
|
||||
|
||||
local = frame->local = CALLOC (1, sizeof (*local));
|
||||
frame->local = local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_ha_mt_ha_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
@ -2431,21 +2439,21 @@ ha_opendir (call_frame_t *frame,
|
||||
local->op_errno = ENOTCONN;
|
||||
local->fd = fd;
|
||||
|
||||
hafdp = CALLOC (1, sizeof (*hafdp));
|
||||
hafdp = GF_CALLOC (1, sizeof (*hafdp), gf_ha_mt_hafd_t);
|
||||
if (!hafdp) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
goto err;
|
||||
}
|
||||
|
||||
hafdp->fdstate = CALLOC (1, child_count);
|
||||
hafdp->fdstate = GF_CALLOC (1, child_count, gf_ha_mt_char);
|
||||
if (!hafdp->fdstate) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
goto err;
|
||||
}
|
||||
|
||||
hafdp->path = strdup (loc->path);
|
||||
hafdp->path = gf_strdup (loc->path);
|
||||
if (!hafdp->path) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
@ -2484,16 +2492,16 @@ err:
|
||||
ha_local_wipe (local);
|
||||
if (hafdp) {
|
||||
if (hafdp->fdstate) {
|
||||
FREE (hafdp->fdstate);
|
||||
GF_FREE (hafdp->fdstate);
|
||||
hafdp->fdstate = NULL;
|
||||
}
|
||||
|
||||
if (hafdp->path) {
|
||||
FREE (hafdp->path);
|
||||
GF_FREE (hafdp->path);
|
||||
hafdp->path = NULL;
|
||||
}
|
||||
|
||||
FREE (hafdp);
|
||||
GF_FREE (hafdp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -2733,7 +2741,8 @@ ha_statfs (call_frame_t *frame,
|
||||
/* The normal way of handling failover doesn't work here
|
||||
* as loc->inode may be null in this case.
|
||||
*/
|
||||
local = CALLOC (1, sizeof (*local));
|
||||
local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_ha_mt_ha_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -3073,7 +3082,7 @@ ha_lk_setlk_unlck_cbk (call_frame_t *frame,
|
||||
|
||||
if (cnt == 0) {
|
||||
stub = local->stub;
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
if (stub->args.lk.lock.l_type == F_UNLCK) {
|
||||
STACK_UNWIND (frame, local->op_ret, local->op_errno, &stub->args.lk.lock);
|
||||
} else {
|
||||
@ -3122,7 +3131,7 @@ ha_lk_setlk_cbk (call_frame_t *frame,
|
||||
}
|
||||
if (i == child_count) {
|
||||
call_stub_t *stub = local->stub;
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
STACK_UNWIND (frame, 0, op_errno, &stub->args.lk.lock);
|
||||
call_stub_destroy (stub);
|
||||
return 0;
|
||||
@ -3163,7 +3172,7 @@ ha_lk_setlk_cbk (call_frame_t *frame,
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
call_stub_destroy (local->stub);
|
||||
STACK_UNWIND (frame,
|
||||
op_ret,
|
||||
@ -3197,7 +3206,7 @@ ha_lk_getlk_cbk (call_frame_t *frame,
|
||||
prev_frame = cookie;
|
||||
|
||||
if (op_ret == 0) {
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
call_stub_destroy (local->stub);
|
||||
STACK_UNWIND (frame, 0, 0, lock);
|
||||
return 0;
|
||||
@ -3214,7 +3223,7 @@ ha_lk_getlk_cbk (call_frame_t *frame,
|
||||
}
|
||||
|
||||
if (i == child_count) {
|
||||
FREE (local->state);
|
||||
GF_FREE (local->state);
|
||||
call_stub_destroy (local->stub);
|
||||
STACK_UNWIND (frame, op_ret, op_errno, lock);
|
||||
return 0;
|
||||
@ -3255,7 +3264,8 @@ ha_lk (call_frame_t *frame,
|
||||
gf_log (this->name, GF_LOG_ERROR, "fd_ctx_get failed");
|
||||
|
||||
if (local == NULL) {
|
||||
local = frame->local = CALLOC (1, sizeof (*local));
|
||||
local = frame->local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_ha_mt_ha_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
@ -3280,7 +3290,7 @@ ha_lk (call_frame_t *frame,
|
||||
goto err;
|
||||
}
|
||||
|
||||
local->state = CALLOC (1, child_count);
|
||||
local->state = GF_CALLOC (1, child_count, gf_ha_mt_char);
|
||||
if (!local->state) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
@ -3636,7 +3646,8 @@ ha_stats (call_frame_t *frame,
|
||||
int i = 0;
|
||||
int32_t op_errno = EINVAL;
|
||||
|
||||
local = frame->local = CALLOC (1, sizeof (*local));
|
||||
local = frame->local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_ha_mt_ha_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
@ -3737,7 +3748,8 @@ ha_getspec (call_frame_t *frame,
|
||||
int i = 0;
|
||||
int32_t op_errno = EINVAL;
|
||||
|
||||
local = frame->local = CALLOC (1, sizeof (*local));
|
||||
local = frame->local = GF_CALLOC (1, sizeof (*local),
|
||||
gf_ha_mt_ha_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
@ -3791,8 +3803,8 @@ ha_closedir (xlator_t *this,
|
||||
}
|
||||
hafdp = (hafd_t *)(long)tmp_hafdp;
|
||||
|
||||
FREE (hafdp->fdstate);
|
||||
FREE (hafdp->path);
|
||||
GF_FREE (hafdp->fdstate);
|
||||
GF_FREE (hafdp->path);
|
||||
LOCK_DESTROY (&hafdp->lock);
|
||||
return 0;
|
||||
}
|
||||
@ -3812,8 +3824,8 @@ ha_close (xlator_t *this,
|
||||
}
|
||||
hafdp = (hafd_t *)(long)tmp_hafdp;
|
||||
|
||||
FREE (hafdp->fdstate);
|
||||
FREE (hafdp->path);
|
||||
GF_FREE (hafdp->fdstate);
|
||||
GF_FREE (hafdp->path);
|
||||
LOCK_DESTROY (&hafdp->lock);
|
||||
return 0;
|
||||
}
|
||||
@ -3884,6 +3896,25 @@ notify (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_ha_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)
|
||||
{
|
||||
@ -3891,6 +3922,7 @@ init (xlator_t *this)
|
||||
xlator_list_t *trav = NULL;
|
||||
int count = 0, ret = 0;
|
||||
|
||||
|
||||
if (!this->children) {
|
||||
gf_log (this->name,GF_LOG_ERROR,
|
||||
"FATAL: ha should have one or more child defined");
|
||||
@ -3903,7 +3935,7 @@ init (xlator_t *this)
|
||||
}
|
||||
|
||||
trav = this->children;
|
||||
pvt = CALLOC (1, sizeof (ha_private_t));
|
||||
pvt = GF_CALLOC (1, sizeof (ha_private_t), gf_ha_mt_ha_private_t);
|
||||
|
||||
ret = dict_get_int32 (this->options, "preferred-subvolume",
|
||||
&pvt->pref_subvol);
|
||||
@ -3918,7 +3950,8 @@ init (xlator_t *this)
|
||||
}
|
||||
|
||||
pvt->child_count = count;
|
||||
pvt->children = CALLOC (count, sizeof (xlator_t*));
|
||||
pvt->children = GF_CALLOC (count, sizeof (xlator_t*),
|
||||
gf_ha_mt_xlator_t);
|
||||
|
||||
trav = this->children;
|
||||
count = 0;
|
||||
@ -3928,7 +3961,7 @@ init (xlator_t *this)
|
||||
trav = trav->next;
|
||||
}
|
||||
|
||||
pvt->state = CALLOC (1, count);
|
||||
pvt->state = GF_CALLOC (1, count, gf_ha_mt_char);
|
||||
this->private = pvt;
|
||||
return 0;
|
||||
}
|
||||
@ -3938,7 +3971,7 @@ fini (xlator_t *this)
|
||||
{
|
||||
ha_private_t *priv = NULL;
|
||||
priv = this->private;
|
||||
FREE (priv);
|
||||
GF_FREE (priv);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
#ifndef __HA_H_
|
||||
#define __HA_H_
|
||||
|
||||
#include "ha-mem-types.h"
|
||||
|
||||
typedef struct {
|
||||
call_stub_t *stub;
|
||||
int32_t op_ret, op_errno;
|
||||
|
@ -256,14 +256,15 @@ verify_dir_and_assign_subvol (xlator_t *this,
|
||||
goto out;
|
||||
}
|
||||
|
||||
tmp_map = CALLOC (1, sizeof (struct map_pattern));
|
||||
tmp_map = GF_CALLOC (1, sizeof (struct map_pattern),
|
||||
gf_map_mt_map_pattern);
|
||||
tmp_map->xl = trav->xlator;
|
||||
tmp_map->dir_len = strlen (directory);
|
||||
|
||||
/* make sure that the top level directory starts
|
||||
* with '/' and ends without '/'
|
||||
*/
|
||||
tmp_map->directory = strdup (directory);
|
||||
tmp_map->directory = gf_strdup (directory);
|
||||
if (directory[tmp_map->dir_len - 1] == '/') {
|
||||
tmp_map->dir_len--;
|
||||
}
|
||||
|
35
xlators/cluster/map/src/map-mem-types.h
Normal file
35
xlators/cluster/map/src/map-mem-types.h
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
/*
|
||||
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 __MAP_MEM_TYPES_H__
|
||||
#define __MAP_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_map_mem_types_ {
|
||||
gf_map_mt_map_private_t = gf_common_mt_end + 1,
|
||||
gf_map_mt_map_local_t,
|
||||
gf_map_mt_map_xlator_array,
|
||||
gf_map_mt_map_pattern,
|
||||
gf_map_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -2147,7 +2147,8 @@ map_lookup (call_frame_t *frame,
|
||||
return 0;
|
||||
|
||||
root_inode:
|
||||
local = CALLOC (1, sizeof (map_local_t));
|
||||
local = GF_CALLOC (1, sizeof (map_local_t),
|
||||
gf_map_mt_map_local_t);
|
||||
|
||||
frame->local = local;
|
||||
local->call_count = priv->child_count;
|
||||
@ -2199,7 +2200,8 @@ map_statfs (call_frame_t *frame,
|
||||
return 0;
|
||||
|
||||
root_inode:
|
||||
local = CALLOC (1, sizeof (map_local_t));
|
||||
local = GF_CALLOC (1, sizeof (map_local_t),
|
||||
gf_map_mt_map_local_t);
|
||||
|
||||
priv = this->private;
|
||||
frame->local = local;
|
||||
@ -2251,7 +2253,8 @@ map_opendir (call_frame_t *frame,
|
||||
return 0;
|
||||
|
||||
root_inode:
|
||||
local = CALLOC (1, sizeof (map_local_t));
|
||||
local = GF_CALLOC (1, sizeof (map_local_t),
|
||||
gf_map_mt_map_local_t);
|
||||
|
||||
priv = this->private;
|
||||
frame->local = local;
|
||||
@ -2310,7 +2313,8 @@ map_do_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
|
||||
|
||||
root_inode:
|
||||
/* readdir on '/' */
|
||||
local = CALLOC (1, sizeof (map_local_t));
|
||||
local = GF_CALLOC (1, sizeof (map_local_t),
|
||||
gf_map_mt_map_local_t);
|
||||
if (!local) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"memory allocation failed :(");
|
||||
@ -2372,21 +2376,40 @@ fini (xlator_t *this)
|
||||
|
||||
if (priv) {
|
||||
if (priv->xlarray)
|
||||
FREE (priv->xlarray);
|
||||
GF_FREE (priv->xlarray);
|
||||
|
||||
trav_map = priv->map;
|
||||
while (trav_map) {
|
||||
tmp_map = trav_map;
|
||||
trav_map = trav_map->next;
|
||||
FREE (tmp_map);
|
||||
GF_FREE (tmp_map);
|
||||
}
|
||||
|
||||
FREE(priv);
|
||||
GF_FREE(priv);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t
|
||||
mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!this)
|
||||
return ret;
|
||||
|
||||
ret = xlator_mem_acct_init (this, gf_map_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)
|
||||
{
|
||||
@ -2403,6 +2426,7 @@ init (xlator_t *this)
|
||||
char *subvol_str = NULL;
|
||||
char *map_xl = NULL;
|
||||
|
||||
|
||||
if (!this->children) {
|
||||
gf_log (this->name,GF_LOG_ERROR,
|
||||
"FATAL: map should have one or more child defined");
|
||||
@ -2414,7 +2438,8 @@ init (xlator_t *this)
|
||||
"dangling volume. check volfile ");
|
||||
}
|
||||
|
||||
priv = CALLOC (1, sizeof (map_private_t));
|
||||
priv = GF_CALLOC (1, sizeof (map_private_t),
|
||||
gf_map_mt_map_private_t);
|
||||
this->private = priv;
|
||||
|
||||
/* allocate xlator array */
|
||||
@ -2423,7 +2448,8 @@ init (xlator_t *this)
|
||||
count++;
|
||||
trav = trav->next;
|
||||
}
|
||||
priv->xlarray = CALLOC (1, sizeof (struct map_xlator_array) * count);
|
||||
priv->xlarray = GF_CALLOC (1, sizeof (struct map_xlator_array) * count,
|
||||
gf_map_mt_map_xlator_array);
|
||||
priv->child_count = count;
|
||||
|
||||
/* build xlator array */
|
||||
@ -2443,7 +2469,7 @@ init (xlator_t *this)
|
||||
}
|
||||
map_pair_str = strtok_r (pattern_string, ";", &tmp_str);
|
||||
while (map_pair_str) {
|
||||
dup_map_pair = strdup (map_pair_str);
|
||||
dup_map_pair = gf_strdup (map_pair_str);
|
||||
dir_str = strtok_r (dup_map_pair, ":", &tmp_str1);
|
||||
if (!dir_str) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
@ -2465,7 +2491,7 @@ init (xlator_t *this)
|
||||
goto err;
|
||||
}
|
||||
|
||||
FREE (dup_map_pair);
|
||||
GF_FREE (dup_map_pair);
|
||||
|
||||
map_pair_str = strtok_r (NULL, ";", &tmp_str);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define __MAP_H__
|
||||
|
||||
#include "xlator.h"
|
||||
#include "map-mem-types.h"
|
||||
|
||||
struct map_pattern {
|
||||
struct map_pattern *next;
|
||||
|
40
xlators/cluster/stripe/src/stripe-mem-types.h
Normal file
40
xlators/cluster/stripe/src/stripe-mem-types.h
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
/*
|
||||
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 __STRIPE_MEM_TYPES_H__
|
||||
#define __STRIPE_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_stripe_mem_types_ {
|
||||
gf_stripe_mt_stripe_local_t = gf_common_mt_end + 1,
|
||||
gf_stripe_mt_iovec,
|
||||
gf_stripe_mt_readv_replies,
|
||||
gf_stripe_mt_stripe_fd_ctx_t,
|
||||
gf_stripe_mt_char,
|
||||
gf_stripe_mt_int8_t,
|
||||
gf_stripe_mt_xlator_t,
|
||||
gf_stripe_mt_stripe_private_t,
|
||||
gf_stripe_mt_stripe_options,
|
||||
gf_stripe_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -53,7 +53,7 @@ stripe_get_matching_bs (const char *path, struct stripe_options *opts,
|
||||
uint64_t block_size = 0;
|
||||
|
||||
block_size = default_bs;
|
||||
pathname = strdup (path);
|
||||
pathname = gf_strdup (path);
|
||||
trav = opts;
|
||||
|
||||
while (trav) {
|
||||
@ -63,7 +63,8 @@ stripe_get_matching_bs (const char *path, struct stripe_options *opts,
|
||||
}
|
||||
trav = trav->next;
|
||||
}
|
||||
free (pathname);
|
||||
|
||||
GF_FREE (pathname);
|
||||
|
||||
return block_size;
|
||||
}
|
||||
@ -572,7 +573,8 @@ stripe_entry_self_heal (call_frame_t *frame, xlator_t *this,
|
||||
if (!rframe) {
|
||||
goto out;
|
||||
}
|
||||
rlocal = CALLOC (1, sizeof (stripe_local_t));
|
||||
rlocal = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!rlocal) {
|
||||
goto out;
|
||||
}
|
||||
@ -709,7 +711,8 @@ stripe_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
|
||||
trav = this->children;
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -760,7 +763,8 @@ stripe_stat (call_frame_t *frame, xlator_t *this, loc_t *loc)
|
||||
}
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -844,7 +848,8 @@ stripe_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc)
|
||||
priv = this->private;
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -893,7 +898,8 @@ stripe_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset)
|
||||
}
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -1008,7 +1014,8 @@ stripe_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
|
||||
}
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -1049,7 +1056,8 @@ stripe_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
|
||||
trav = this->children;
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -1215,7 +1223,8 @@ stripe_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
|
||||
}
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -1270,7 +1279,8 @@ stripe_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc)
|
||||
}
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -1356,7 +1366,8 @@ stripe_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc)
|
||||
}
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -1617,7 +1628,8 @@ stripe_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
|
||||
}
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -1684,7 +1696,8 @@ stripe_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode)
|
||||
}
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -1735,7 +1748,8 @@ stripe_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc)
|
||||
}
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -1936,7 +1950,8 @@ stripe_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
|
||||
/* */
|
||||
if (local->op_ret >= 0) {
|
||||
fctx = CALLOC (1, sizeof (stripe_fd_ctx_t));
|
||||
fctx = GF_CALLOC (1, sizeof (stripe_fd_ctx_t),
|
||||
gf_stripe_mt_stripe_fd_ctx_t);
|
||||
if (fctx) {
|
||||
fctx->stripe_size = local->stripe_size;
|
||||
fctx->stripe_count = priv->child_count;
|
||||
@ -2035,7 +2050,8 @@ stripe_create (call_frame_t *frame, xlator_t *this, loc_t *loc,
|
||||
}
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -2107,8 +2123,8 @@ stripe_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
if (local->op_ret == -1) {
|
||||
if (local->fctx) {
|
||||
if (!local->fctx->static_array)
|
||||
FREE (local->fctx->xl_array);
|
||||
FREE (local->fctx);
|
||||
GF_FREE (local->fctx->xl_array);
|
||||
GF_FREE (local->fctx);
|
||||
}
|
||||
} else {
|
||||
fd_ctx_set (local->fd, this,
|
||||
@ -2167,7 +2183,8 @@ stripe_open_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
}
|
||||
|
||||
if (!local->fctx) {
|
||||
local->fctx = CALLOC (1, sizeof (stripe_fd_ctx_t));
|
||||
local->fctx = GF_CALLOC (1, sizeof (stripe_fd_ctx_t),
|
||||
gf_stripe_mt_stripe_fd_ctx_t);
|
||||
if (!local->fctx) {
|
||||
local->op_errno = ENOMEM;
|
||||
local->op_ret = -1;
|
||||
@ -2209,9 +2226,11 @@ stripe_open_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
local->op_errno = EIO;
|
||||
goto unlock;
|
||||
}
|
||||
local->fctx->xl_array =
|
||||
CALLOC (local->fctx->stripe_count,
|
||||
sizeof (xlator_t *));
|
||||
|
||||
local->fctx->xl_array =
|
||||
GF_CALLOC (local->fctx->stripe_count,
|
||||
sizeof (xlator_t *),
|
||||
gf_stripe_mt_xlator_t);
|
||||
}
|
||||
if (local->fctx->stripe_count != data_to_int32 (data)) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
@ -2326,7 +2345,8 @@ stripe_open (call_frame_t *frame, xlator_t *this, loc_t *loc,
|
||||
}
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -2354,7 +2374,8 @@ stripe_open (call_frame_t *frame, xlator_t *this, loc_t *loc,
|
||||
trav = trav->next;
|
||||
}
|
||||
} else {
|
||||
local->fctx = CALLOC (1, sizeof (stripe_fd_ctx_t));
|
||||
local->fctx = GF_CALLOC (1, sizeof (stripe_fd_ctx_t),
|
||||
gf_stripe_mt_stripe_fd_ctx_t);
|
||||
if (!local->fctx) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -2448,7 +2469,8 @@ stripe_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd)
|
||||
}
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -2537,7 +2559,8 @@ stripe_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
|
||||
priv = this->private;
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -2582,7 +2605,8 @@ stripe_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
|
||||
goto err;
|
||||
}
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -2624,7 +2648,8 @@ stripe_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags)
|
||||
trav = this->children;
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -2668,7 +2693,8 @@ stripe_fstat (call_frame_t *frame,
|
||||
trav = this->children;
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -2710,7 +2736,8 @@ stripe_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
|
||||
trav = this->children;
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -2752,7 +2779,8 @@ stripe_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags)
|
||||
trav = this->children;
|
||||
|
||||
/* Initialization */
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -2802,7 +2830,8 @@ stripe_readv_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
op_ret = 0;
|
||||
|
||||
/* Keep extra space for filling in '\0's */
|
||||
vec = CALLOC ((local->count * 2), sizeof (struct iovec));
|
||||
vec = GF_CALLOC ((local->count * 2), sizeof (struct iovec),
|
||||
gf_stripe_mt_iovec);
|
||||
if (!vec) {
|
||||
op_ret = -1;
|
||||
goto done;
|
||||
@ -2932,7 +2961,8 @@ stripe_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
if (need_to_check_proper_size)
|
||||
goto check_size;
|
||||
|
||||
final_vec = CALLOC (mlocal->count, sizeof (struct iovec));
|
||||
final_vec = GF_CALLOC (mlocal->count, sizeof (struct iovec),
|
||||
gf_stripe_mt_iovec);
|
||||
|
||||
if (!final_vec) {
|
||||
op_ret = -1;
|
||||
@ -2964,7 +2994,8 @@ stripe_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
|
||||
iobref_unref (tmp_iobref);
|
||||
if (final_vec)
|
||||
FREE (final_vec);
|
||||
GF_FREE (final_vec);
|
||||
}
|
||||
|
||||
goto out;
|
||||
|
||||
@ -2977,7 +3008,7 @@ stripe_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
(fctx->xl_array[index])->fops->fstat,
|
||||
mlocal->fd);
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
STACK_DESTROY (frame->root);
|
||||
return 0;
|
||||
@ -3027,8 +3058,9 @@ stripe_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
|
||||
rounded_start = floor (offset, stripe_size);
|
||||
rounded_end = roof (offset+size, stripe_size);
|
||||
num_stripe = rounded_end/stripe_size - rounded_start/stripe_size;
|
||||
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -3036,7 +3068,8 @@ stripe_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
|
||||
frame->local = local;
|
||||
|
||||
/* This is where all the vectors should be copied. */
|
||||
local->replies = CALLOC (num_stripe, sizeof (struct readv_replies));
|
||||
local->replies = GF_CALLOC (num_stripe, sizeof (struct readv_replies),
|
||||
gf_stripe_mt_readv_replies);
|
||||
if (!local->replies) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -3051,7 +3084,8 @@ stripe_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
|
||||
|
||||
for (index = off_index; index < (num_stripe + off_index); index++) {
|
||||
rframe = copy_frame (frame);
|
||||
rlocal = CALLOC (1, sizeof (stripe_local_t));
|
||||
rlocal = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!rlocal) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -3173,7 +3207,8 @@ stripe_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
|
||||
}
|
||||
remaining_size = total_size;
|
||||
|
||||
local = CALLOC (1, sizeof (stripe_local_t));
|
||||
local = GF_CALLOC (1, sizeof (stripe_local_t),
|
||||
gf_stripe_mt_stripe_local_t);
|
||||
if (!local) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -3198,7 +3233,8 @@ stripe_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
|
||||
|
||||
tmp_count = iov_subset (vector, count, offset_offset,
|
||||
offset_offset + fill_size, NULL);
|
||||
tmp_vec = CALLOC (tmp_count, sizeof (struct iovec));
|
||||
tmp_vec = GF_CALLOC (tmp_count, sizeof (struct iovec),
|
||||
gf_stripe_mt_iovec);
|
||||
if (!tmp_vec) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -3213,7 +3249,7 @@ stripe_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
|
||||
STACK_WIND(frame, stripe_writev_cbk, fctx->xl_array[idx],
|
||||
fctx->xl_array[idx]->fops->writev, fd, tmp_vec,
|
||||
tmp_count, offset + offset_offset, iobref);
|
||||
FREE (tmp_vec);
|
||||
GF_FREE (tmp_vec);
|
||||
offset_offset += fill_size;
|
||||
if (remaining_size == 0)
|
||||
break;
|
||||
@ -3243,10 +3279,10 @@ stripe_release (xlator_t *this, fd_t *fd)
|
||||
fctx = (stripe_fd_ctx_t *)(long)tmp_fctx;
|
||||
|
||||
if (!fctx->static_array)
|
||||
FREE (fctx->xl_array);
|
||||
|
||||
FREE (fctx);
|
||||
|
||||
GF_FREE (fctx->xl_array);
|
||||
|
||||
GF_FREE (fctx);
|
||||
|
||||
out:
|
||||
return 0;
|
||||
}
|
||||
@ -3345,10 +3381,11 @@ set_stripe_block_size (xlator_t *this, stripe_private_t *priv, char *data)
|
||||
"option block-size *avi:10MB" etc */
|
||||
stripe_str = strtok_r (data, ",", &tmp_str);
|
||||
while (stripe_str) {
|
||||
dup_str = strdup (stripe_str);
|
||||
stripe_opt = CALLOC (1, sizeof (struct stripe_options));
|
||||
dup_str = gf_strdup (stripe_str);
|
||||
stripe_opt = GF_CALLOC (1, sizeof (struct stripe_options),
|
||||
gf_stripe_mt_stripe_options);
|
||||
if (!stripe_opt) {
|
||||
FREE (dup_str);
|
||||
GF_FREE (dup_str);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -3378,6 +3415,7 @@ set_stripe_block_size (xlator_t *this, stripe_private_t *priv, char *data)
|
||||
temp_stripeopt->next = stripe_opt;
|
||||
}
|
||||
stripe_str = strtok_r (NULL, ",", &tmp_str);
|
||||
GF_FREE (dup_str);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
@ -3385,6 +3423,25 @@ set_stripe_block_size (xlator_t *this, stripe_private_t *priv, char *data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t
|
||||
mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!this)
|
||||
return ret;
|
||||
|
||||
ret = xlator_mem_acct_init (this, gf_stripe_mt_end + 1);
|
||||
|
||||
if (ret != 0) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
|
||||
"failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* init - This function is called when xlator-graph gets initialized.
|
||||
* The option given in volfiles are parsed here.
|
||||
@ -3423,14 +3480,19 @@ init (xlator_t *this)
|
||||
" please check the volume. exiting");
|
||||
goto out;
|
||||
}
|
||||
priv = CALLOC (1, sizeof (stripe_private_t));
|
||||
|
||||
priv = GF_CALLOC (1, sizeof (stripe_private_t),
|
||||
gf_stripe_mt_stripe_private_t);
|
||||
|
||||
if (!priv)
|
||||
goto out;
|
||||
priv->xl_array = CALLOC (count, sizeof (xlator_t *));
|
||||
priv->xl_array = GF_CALLOC (count, sizeof (xlator_t *),
|
||||
gf_stripe_mt_xlator_t);
|
||||
if (!priv->xl_array)
|
||||
goto out;
|
||||
|
||||
priv->state = CALLOC (count, sizeof (int8_t));
|
||||
priv->state = GF_CALLOC (count, sizeof (int8_t),
|
||||
gf_stripe_mt_int8_t);
|
||||
if (!priv->state)
|
||||
goto out;
|
||||
|
||||
@ -3485,8 +3547,8 @@ init (xlator_t *this)
|
||||
if (ret) {
|
||||
if (priv) {
|
||||
if (priv->xl_array)
|
||||
FREE (priv->xl_array);
|
||||
FREE (priv);
|
||||
GF_FREE (priv->xl_array);
|
||||
GF_FREE (priv);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -3506,16 +3568,16 @@ fini (xlator_t *this)
|
||||
priv = this->private;
|
||||
if (priv) {
|
||||
if (priv->xl_array)
|
||||
FREE (priv->xl_array);
|
||||
GF_FREE (priv->xl_array);
|
||||
|
||||
trav = priv->pattern;
|
||||
while (trav) {
|
||||
prev = trav;
|
||||
trav = trav->next;
|
||||
FREE (prev);
|
||||
GF_FREE (prev);
|
||||
}
|
||||
LOCK_DESTROY (&priv->lock);
|
||||
FREE (priv);
|
||||
GF_FREE (priv);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "common-utils.h"
|
||||
#include "compat.h"
|
||||
#include "compat-errno.h"
|
||||
#include "stripe-mem-types.h"
|
||||
#include <fnmatch.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
41
xlators/cluster/unify/src/unify-mem-types.h
Normal file
41
xlators/cluster/unify/src/unify-mem-types.h
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
/*
|
||||
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 __UNIFY_MEM_TYPES_H__
|
||||
#define __UNIFY_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_unify_mem_types_ {
|
||||
gf_unify_mt_char = gf_common_mt_end + 1,
|
||||
gf_unify_mt_int16_t,
|
||||
gf_unify_mt_xlator_t,
|
||||
gf_unify_mt_unify_private_t,
|
||||
gf_unify_mt_xlator_list_t,
|
||||
gf_unify_mt_dir_entry_t,
|
||||
gf_unify_mt_off_t,
|
||||
gf_unify_mt_int,
|
||||
gf_unify_mt_unify_self_heal_struct,
|
||||
gf_unify_mt_unify_local_t,
|
||||
gf_unify_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -93,20 +93,20 @@ unify_local_wipe (unify_local_t *local)
|
||||
{
|
||||
/* Free the strdup'd variables in the local structure */
|
||||
if (local->name) {
|
||||
FREE (local->name);
|
||||
GF_FREE (local->name);
|
||||
}
|
||||
|
||||
if (local->sh_struct) {
|
||||
if (local->sh_struct->offset_list)
|
||||
FREE (local->sh_struct->offset_list);
|
||||
GF_FREE (local->sh_struct->offset_list);
|
||||
|
||||
if (local->sh_struct->entry_list)
|
||||
FREE (local->sh_struct->entry_list);
|
||||
GF_FREE (local->sh_struct->entry_list);
|
||||
|
||||
if (local->sh_struct->count_list)
|
||||
FREE (local->sh_struct->count_list);
|
||||
GF_FREE (local->sh_struct->count_list);
|
||||
|
||||
FREE (local->sh_struct);
|
||||
GF_FREE (local->sh_struct);
|
||||
}
|
||||
|
||||
loc_wipe (&local->loc1);
|
||||
@ -144,13 +144,13 @@ unify_sh_setdents_cbk (call_frame_t *frame,
|
||||
trav = entry->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 (entry);
|
||||
GF_FREE (entry);
|
||||
}
|
||||
|
||||
if (!local->flags) {
|
||||
@ -202,7 +202,8 @@ unify_sh_ns_getdents_cbk (call_frame_t *frame,
|
||||
unify_private_t *priv = this->private;
|
||||
long index = 0;
|
||||
unsigned long final = 0;
|
||||
dir_entry_t *tmp = CALLOC (1, sizeof (dir_entry_t));
|
||||
dir_entry_t *tmp = GF_CALLOC (1, sizeof (dir_entry_t),
|
||||
gf_unify_mt_dir_entry_t);
|
||||
|
||||
local->sh_struct->entry_list[0] = tmp;
|
||||
local->sh_struct->count_list[0] = count;
|
||||
@ -259,13 +260,13 @@ unify_sh_ns_setdents_cbk (call_frame_t *frame,
|
||||
trav = entry->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 (entry);
|
||||
GF_FREE (entry);
|
||||
}
|
||||
}
|
||||
UNLOCK (&frame->lock);
|
||||
@ -341,7 +342,8 @@ unify_sh_getdents_cbk (call_frame_t *frame,
|
||||
|
||||
if (op_ret >= 0 && count > 0) {
|
||||
/* There is some dentry found, just send the dentry to NS */
|
||||
tmp = CALLOC (1, sizeof (dir_entry_t));
|
||||
tmp = GF_CALLOC (1, sizeof (dir_entry_t),
|
||||
gf_unify_mt_dir_entry_t);
|
||||
local->sh_struct->entry_list[index] = tmp;
|
||||
local->sh_struct->count_list[index] = count;
|
||||
if (entry) {
|
||||
@ -458,18 +460,21 @@ unify_sh_opendir_cbk (call_frame_t *frame,
|
||||
* STACK_WIND.
|
||||
*/
|
||||
local->sh_struct->offset_list =
|
||||
calloc (priv->child_count,
|
||||
sizeof (off_t));
|
||||
GF_CALLOC (priv->child_count,
|
||||
sizeof (off_t),
|
||||
gf_unify_mt_off_t);
|
||||
ERR_ABORT (local->sh_struct->offset_list);
|
||||
|
||||
local->sh_struct->entry_list =
|
||||
calloc (priv->child_count,
|
||||
sizeof (dir_entry_t *));
|
||||
GF_CALLOC (priv->child_count,
|
||||
sizeof (dir_entry_t *),
|
||||
gf_unify_mt_dir_entry_t);
|
||||
ERR_ABORT (local->sh_struct->entry_list);
|
||||
|
||||
local->sh_struct->count_list =
|
||||
calloc (priv->child_count,
|
||||
sizeof (int));
|
||||
GF_CALLOC (priv->child_count,
|
||||
sizeof (int),
|
||||
gf_unify_mt_int);
|
||||
ERR_ABORT (local->sh_struct->count_list);
|
||||
|
||||
/* Send getdents on all the fds */
|
||||
@ -668,13 +673,13 @@ unify_bgsh_setdents_cbk (call_frame_t *frame,
|
||||
trav = entry->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 (entry);
|
||||
GF_FREE (entry);
|
||||
}
|
||||
|
||||
if (!local->flags) {
|
||||
@ -718,7 +723,8 @@ unify_bgsh_ns_getdents_cbk (call_frame_t *frame,
|
||||
unify_private_t *priv = this->private;
|
||||
long index = 0;
|
||||
unsigned long final = 0;
|
||||
dir_entry_t *tmp = CALLOC (1, sizeof (dir_entry_t));
|
||||
dir_entry_t *tmp = GF_CALLOC (1, sizeof (dir_entry_t),
|
||||
gf_unify_mt_dir_entry_t);
|
||||
|
||||
local->sh_struct->entry_list[0] = tmp;
|
||||
local->sh_struct->count_list[0] = count;
|
||||
@ -775,13 +781,13 @@ unify_bgsh_ns_setdents_cbk (call_frame_t *frame,
|
||||
trav = entry->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 (entry);
|
||||
GF_FREE (entry);
|
||||
}
|
||||
|
||||
if (local->sh_struct->count_list[index] <
|
||||
@ -855,7 +861,8 @@ unify_bgsh_getdents_cbk (call_frame_t *frame,
|
||||
|
||||
if (op_ret >= 0 && count > 0) {
|
||||
/* There is some dentry found, just send the dentry to NS */
|
||||
tmp = CALLOC (1, sizeof (dir_entry_t));
|
||||
tmp = GF_CALLOC (1, sizeof (dir_entry_t),
|
||||
gf_unify_mt_dir_entry_t);
|
||||
local->sh_struct->entry_list[index] = tmp;
|
||||
local->sh_struct->count_list[index] = count;
|
||||
if (entry) {
|
||||
@ -969,18 +976,21 @@ unify_bgsh_opendir_cbk (call_frame_t *frame,
|
||||
track of offset sent to each node during
|
||||
STACK_WIND. */
|
||||
local->sh_struct->offset_list =
|
||||
calloc (priv->child_count,
|
||||
sizeof (off_t));
|
||||
GF_CALLOC (priv->child_count,
|
||||
sizeof (off_t),
|
||||
gf_unify_mt_off_t);
|
||||
ERR_ABORT (local->sh_struct->offset_list);
|
||||
|
||||
local->sh_struct->entry_list =
|
||||
calloc (priv->child_count,
|
||||
sizeof (dir_entry_t *));
|
||||
GF_CALLOC (priv->child_count,
|
||||
sizeof (dir_entry_t *),
|
||||
gf_unify_mt_dir_entry_t);
|
||||
ERR_ABORT (local->sh_struct->entry_list);
|
||||
|
||||
local->sh_struct->count_list =
|
||||
calloc (priv->child_count,
|
||||
sizeof (int));
|
||||
GF_CALLOC (priv->child_count,
|
||||
sizeof (int),
|
||||
gf_unify_mt_int);
|
||||
ERR_ABORT (local->sh_struct->count_list);
|
||||
|
||||
/* Send getdents on all the fds */
|
||||
@ -1161,7 +1171,8 @@ zr_unify_self_heal (call_frame_t *frame,
|
||||
local->failed = 0;
|
||||
local->call_count = priv->child_count + 1;
|
||||
local->sh_struct =
|
||||
calloc (1, sizeof (struct unify_self_heal_struct));
|
||||
GF_CALLOC (1, sizeof (struct unify_self_heal_struct),
|
||||
gf_unify_mt_unify_self_heal_struct);
|
||||
|
||||
/* +1 is for NS */
|
||||
for (index = 0;
|
||||
@ -1188,7 +1199,8 @@ zr_unify_self_heal (call_frame_t *frame,
|
||||
bg_local->failed = 0;
|
||||
bg_local->call_count = priv->child_count + 1;
|
||||
bg_local->sh_struct =
|
||||
calloc (1, sizeof (struct unify_self_heal_struct));
|
||||
GF_CALLOC (1, sizeof (struct unify_self_heal_struct),
|
||||
gf_unify_mt_unify_self_heal_struct);
|
||||
|
||||
/* +1 is for NS */
|
||||
for (index = 0; index < (priv->child_count + 1); index++) {
|
||||
|
@ -82,7 +82,7 @@ unify_local_wipe (unify_local_t *local)
|
||||
{
|
||||
/* Free the strdup'd variables in the local structure */
|
||||
if (local->name) {
|
||||
FREE (local->name);
|
||||
GF_FREE (local->name);
|
||||
}
|
||||
loc_wipe (&local->loc1);
|
||||
loc_wipe (&local->loc2);
|
||||
@ -421,7 +421,8 @@ unify_lookup_cbk (call_frame_t *frame,
|
||||
if (!local->list) {
|
||||
/* list is not allocated, allocate
|
||||
the max possible range */
|
||||
local->list = CALLOC (1, 2 * (priv->child_count + 2));
|
||||
local->list = GF_CALLOC (1, 2 * (priv->child_count + 2),
|
||||
gf_unify_mt_int16_t);
|
||||
if (!local->list) {
|
||||
gf_log (this->name,
|
||||
GF_LOG_CRITICAL,
|
||||
@ -494,11 +495,12 @@ unify_lookup_cbk (call_frame_t *frame,
|
||||
/* If its a file, big array is useless,
|
||||
allocate the smaller one */
|
||||
int16_t *list = NULL;
|
||||
list = CALLOC (1, 2 * (local->index + 1));
|
||||
list = GF_CALLOC (1, 2 * (local->index + 1),
|
||||
gf_unify_mt_int16_t);
|
||||
ERR_ABORT (list);
|
||||
memcpy (list, local->list, 2 * local->index);
|
||||
/* Make the end of the list as -1 */
|
||||
FREE (local->list);
|
||||
GF_FREE (local->list);
|
||||
local->list = list;
|
||||
local->list [local->index] = -1;
|
||||
/* Update the inode's ctx with proper array */
|
||||
@ -524,7 +526,7 @@ unify_lookup_cbk (call_frame_t *frame,
|
||||
}
|
||||
if (local->op_ret == -1) {
|
||||
if (!local->revalidate && local->list)
|
||||
FREE (local->list);
|
||||
GF_FREE (local->list);
|
||||
}
|
||||
|
||||
if ((local->op_ret >= 0) && local->failed &&
|
||||
@ -1219,19 +1221,20 @@ unify_open_readlink_cbk (call_frame_t *frame,
|
||||
}
|
||||
|
||||
if (path[0] == '/') {
|
||||
local->name = strdup (path);
|
||||
local->name = gf_strdup (path);
|
||||
ERR_ABORT (local->name);
|
||||
} else {
|
||||
char *tmp_str = strdup (local->loc1.path);
|
||||
char *tmp_str = gf_strdup (local->loc1.path);
|
||||
char *tmp_base = dirname (tmp_str);
|
||||
local->name = CALLOC (1, ZR_PATH_MAX);
|
||||
local->name = GF_CALLOC (1, ZR_PATH_MAX, gf_unify_mt_char);
|
||||
strcpy (local->name, tmp_base);
|
||||
strncat (local->name, "/", 1);
|
||||
strcat (local->name, path);
|
||||
FREE (tmp_str);
|
||||
GF_FREE (tmp_str);
|
||||
}
|
||||
|
||||
local->list = CALLOC (1, sizeof (int16_t) * 3);
|
||||
local->list = GF_CALLOC (1, sizeof (int16_t) * 3,
|
||||
gf_unify_mt_int16_t);
|
||||
ERR_ABORT (local->list);
|
||||
local->call_count = priv->child_count + 1;
|
||||
local->op_ret = -1;
|
||||
@ -1663,7 +1666,8 @@ unify_ns_create_cbk (call_frame_t *frame,
|
||||
local->op_ret = -1;
|
||||
|
||||
/* Start the mapping list */
|
||||
list = CALLOC (1, sizeof (int16_t) * 3);
|
||||
list = GF_CALLOC (1, sizeof (int16_t) * 3,
|
||||
gf_unify_mt_int16_t);
|
||||
ERR_ABORT (list);
|
||||
inode_ctx_put (inode, this, (uint64_t)(long)list);
|
||||
list[0] = priv->child_count;
|
||||
@ -1709,7 +1713,8 @@ unify_ns_create_cbk (call_frame_t *frame,
|
||||
"File(%s) already exists on namespace, sending "
|
||||
"open instead", local->loc1.path);
|
||||
|
||||
local->list = CALLOC (1, sizeof (int16_t) * 3);
|
||||
local->list = GF_CALLOC (1, sizeof (int16_t) * 3,
|
||||
gf_unify_mt_int16_t);
|
||||
ERR_ABORT (local->list);
|
||||
local->call_count = priv->child_count + 1;
|
||||
local->op_ret = -1;
|
||||
@ -2827,7 +2832,7 @@ unify_setxattr (call_frame_t *frame,
|
||||
content only if file exists */
|
||||
local->flags = flags;
|
||||
local->dict = dict;
|
||||
local->name = strdup (trav->key);
|
||||
local->name = gf_strdup (trav->key);
|
||||
flags |= XATTR_REPLACE;
|
||||
}
|
||||
|
||||
@ -3207,7 +3212,7 @@ unify_ns_mknod_cbk (call_frame_t *frame,
|
||||
local->oldpreparent = *preparent;
|
||||
local->oldpostparent = *postparent;
|
||||
|
||||
list = CALLOC (1, sizeof (int16_t) * 3);
|
||||
list = GF_CALLOC (1, sizeof (int16_t) * 3, gf_unify_mt_int16_t);
|
||||
ERR_ABORT (list);
|
||||
list[0] = priv->child_count;
|
||||
list[2] = -1;
|
||||
@ -3383,7 +3388,7 @@ unify_ns_symlink_cbk (call_frame_t *frame,
|
||||
|
||||
/* Start the mapping list */
|
||||
|
||||
list = CALLOC (1, sizeof (int16_t) * 3);
|
||||
list = GF_CALLOC (1, sizeof (int16_t) * 3, gf_unify_mt_int16_t);
|
||||
ERR_ABORT (list);
|
||||
list[0] = priv->child_count; //namespace's index
|
||||
list[2] = -1;
|
||||
@ -3439,7 +3444,7 @@ unify_symlink (call_frame_t *frame,
|
||||
/* Initialization */
|
||||
INIT_LOCAL (frame, local);
|
||||
loc_copy (&local->loc1, loc);
|
||||
local->name = strdup (linkpath);
|
||||
local->name = gf_strdup (linkpath);
|
||||
|
||||
if ((local->name == NULL) ||
|
||||
(local->loc1.path == NULL)) {
|
||||
@ -3620,7 +3625,8 @@ unify_rename_cbk (call_frame_t *frame,
|
||||
|
||||
if (list) {
|
||||
for (index = 0; list[index] != -1; index++);
|
||||
tmp_list = CALLOC (1, index * 2);
|
||||
tmp_list = GF_CALLOC (1, index * 2,
|
||||
gf_unify_mt_int16_t);
|
||||
memcpy (tmp_list, list, index * 2);
|
||||
|
||||
for (index = 0; list[index] != -1; index++) {
|
||||
@ -3668,11 +3674,11 @@ unify_rename_cbk (call_frame_t *frame,
|
||||
}
|
||||
}
|
||||
|
||||
FREE (tmp_list);
|
||||
GF_FREE (tmp_list);
|
||||
return 0;
|
||||
}
|
||||
if (tmp_list)
|
||||
FREE (tmp_list);
|
||||
GF_FREE (tmp_list);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4183,7 +4189,7 @@ unify_forget (xlator_t *this,
|
||||
inode_ctx_get (inode, this, &tmp_list);
|
||||
if (tmp_list) {
|
||||
list = (int16_t *)(long)tmp_list;
|
||||
FREE (list);
|
||||
GF_FREE (list);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4271,6 +4277,25 @@ notify (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_unify_mt_end + 1);
|
||||
|
||||
if (ret != 0) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
|
||||
"failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* init - This function is called first in the xlator, while initializing.
|
||||
* All the config file options are checked and appropriate flags are set.
|
||||
@ -4290,6 +4315,7 @@ init (xlator_t *this)
|
||||
xlator_list_t *parent = NULL;
|
||||
unify_private_t *_private = NULL;
|
||||
|
||||
|
||||
/* Check for number of child nodes, if there is no child nodes, exit */
|
||||
if (!this->children) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
@ -4347,20 +4373,21 @@ init (xlator_t *this)
|
||||
gf_log (this->name, GF_LOG_DEBUG,
|
||||
"namespace node specified as %s", data->data);
|
||||
|
||||
_private = CALLOC (1, sizeof (*_private));
|
||||
_private = GF_CALLOC (1, sizeof (*_private),
|
||||
gf_unify_mt_unify_private_t);
|
||||
ERR_ABORT (_private);
|
||||
_private->sched_ops = get_scheduler (this, scheduler->data);
|
||||
if (!_private->sched_ops) {
|
||||
gf_log (this->name, GF_LOG_CRITICAL,
|
||||
"Error while loading scheduler. Exiting");
|
||||
FREE (_private);
|
||||
GF_FREE (_private);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ns_xl->parents) {
|
||||
gf_log (this->name, GF_LOG_CRITICAL,
|
||||
"Namespace node should not be a child of any other node. Exiting");
|
||||
FREE (_private);
|
||||
GF_FREE (_private);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -4390,8 +4417,9 @@ init (xlator_t *this)
|
||||
" you may hit some performance penalty");
|
||||
}
|
||||
|
||||
_private->xl_array = CALLOC (1,
|
||||
sizeof (xlator_t) * (count + 1));
|
||||
_private->xl_array = GF_CALLOC (1,
|
||||
sizeof (xlator_t) * (count + 1),
|
||||
gf_unify_mt_xlator_t);
|
||||
ERR_ABORT (_private->xl_array);
|
||||
|
||||
count = 0;
|
||||
@ -4435,21 +4463,29 @@ init (xlator_t *this)
|
||||
/* Now that everything is fine. */
|
||||
this->private = (void *)_private;
|
||||
{
|
||||
ret = _private->sched_ops->mem_acct_init (this);
|
||||
|
||||
if (ret == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Initialize scheduler, if everything else is successful */
|
||||
ret = _private->sched_ops->init (this);
|
||||
if (ret == -1) {
|
||||
gf_log (this->name, GF_LOG_CRITICAL,
|
||||
"Initializing scheduler failed, Exiting");
|
||||
FREE (_private);
|
||||
GF_FREE (_private);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
/* This section is required because some fops may look
|
||||
* for 'xl->parent' variable
|
||||
*/
|
||||
xlparent = CALLOC (1, sizeof (*xlparent));
|
||||
xlparent = GF_CALLOC (1, sizeof (*xlparent),
|
||||
gf_unify_mt_xlator_list_t);
|
||||
xlparent->xlator = this;
|
||||
if (!ns_xl->parents) {
|
||||
ns_xl->parents = xlparent;
|
||||
@ -4477,8 +4513,8 @@ fini (xlator_t *this)
|
||||
priv->sched_ops->fini (this);
|
||||
this->private = NULL;
|
||||
LOCK_DESTROY (&priv->lock);
|
||||
FREE (priv->xl_array);
|
||||
FREE (priv);
|
||||
GF_FREE (priv->xl_array);
|
||||
GF_FREE (priv);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "scheduler.h"
|
||||
#include "list.h"
|
||||
#include "unify-mem-types.h"
|
||||
|
||||
#define MAX_DIR_ENTRY_STRING (32 * 1024)
|
||||
|
||||
@ -42,7 +43,7 @@
|
||||
/* This is used to allocate memory for local structure */
|
||||
#define INIT_LOCAL(fr, loc) \
|
||||
do { \
|
||||
loc = CALLOC (1, sizeof (unify_local_t)); \
|
||||
loc = GF_CALLOC (1, sizeof (unify_local_t), gf_unify_mt_unify_local_t); \
|
||||
ERR_ABORT (loc); \
|
||||
if (!loc) { \
|
||||
STACK_UNWIND (fr, -1, ENOMEM); \
|
||||
|
33
xlators/debug/io-stats/src/io-stats-mem-types.h
Normal file
33
xlators/debug/io-stats/src/io-stats-mem-types.h
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
/*
|
||||
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 __IO_STATS_MEM_TYPES_H__
|
||||
#define __IO_STATS_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_io_stats_mem_types_ {
|
||||
gf_io_stats_mt_ios_conf = gf_common_mt_end + 1,
|
||||
gf_io_stats_mt_ios_fd,
|
||||
gf_io_stats_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <errno.h>
|
||||
#include "glusterfs.h"
|
||||
#include "xlator.h"
|
||||
#include "io-stats-mem-types.h"
|
||||
|
||||
|
||||
struct ios_global_stats {
|
||||
@ -360,13 +361,13 @@ io_stats_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
goto unwind;
|
||||
|
||||
if (op_ret < 0) {
|
||||
FREE (path);
|
||||
GF_FREE (path);
|
||||
goto unwind;
|
||||
}
|
||||
|
||||
iosfd = CALLOC (1, sizeof (*iosfd));
|
||||
iosfd = GF_CALLOC (1, sizeof (*iosfd), gf_io_stats_mt_ios_fd);
|
||||
if (!iosfd) {
|
||||
FREE (path);
|
||||
GF_FREE (path);
|
||||
goto unwind;
|
||||
}
|
||||
|
||||
@ -396,13 +397,13 @@ io_stats_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
goto unwind;
|
||||
|
||||
if (op_ret < 0) {
|
||||
FREE (path);
|
||||
GF_FREE (path);
|
||||
goto unwind;
|
||||
}
|
||||
|
||||
iosfd = CALLOC (1, sizeof (*iosfd));
|
||||
iosfd = GF_CALLOC (1, sizeof (*iosfd), gf_io_stats_mt_ios_fd);
|
||||
if (!iosfd) {
|
||||
FREE (path);
|
||||
GF_FREE (path);
|
||||
goto unwind;
|
||||
}
|
||||
|
||||
@ -1024,7 +1025,7 @@ io_stats_open (call_frame_t *frame, xlator_t *this,
|
||||
{
|
||||
BUMP_FOP (OPEN);
|
||||
|
||||
frame->local = strdup (loc->path);
|
||||
frame->local = gf_strdup (loc->path);
|
||||
|
||||
STACK_WIND (frame, io_stats_open_cbk,
|
||||
FIRST_CHILD(this),
|
||||
@ -1040,7 +1041,7 @@ io_stats_create (call_frame_t *frame, xlator_t *this,
|
||||
{
|
||||
BUMP_FOP (CREATE);
|
||||
|
||||
frame->local = strdup (loc->path);
|
||||
frame->local = gf_strdup (loc->path);
|
||||
|
||||
STACK_WIND (frame, io_stats_create_cbk,
|
||||
FIRST_CHILD(this),
|
||||
@ -1382,8 +1383,8 @@ io_stats_release (xlator_t *this, fd_t *fd)
|
||||
io_stats_dump_fd (this, iosfd);
|
||||
|
||||
if (iosfd->filename)
|
||||
FREE (iosfd->filename);
|
||||
FREE (iosfd);
|
||||
GF_FREE (iosfd->filename);
|
||||
GF_FREE (iosfd);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1407,6 +1408,24 @@ io_stats_forget (xlator_t *this, fd_t *fd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t
|
||||
mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!this)
|
||||
return ret;
|
||||
|
||||
ret = xlator_mem_acct_init (this, gf_io_stats_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)
|
||||
@ -1432,7 +1451,7 @@ init (xlator_t *this)
|
||||
|
||||
options = this->options;
|
||||
|
||||
conf = CALLOC (1, sizeof(*conf));
|
||||
conf = GF_CALLOC (1, sizeof(*conf), gf_io_stats_mt_ios_conf);
|
||||
|
||||
LOCK_INIT (&conf->lock);
|
||||
|
||||
|
@ -75,7 +75,7 @@ trace_stat_to_str (struct iatt *stbuf)
|
||||
strftime (ctime_buf, 256, "[%b %d %H:%M:%S]",
|
||||
localtime ((time_t *)&stbuf->ia_ctime));
|
||||
|
||||
asprint_ret_value = asprintf (&statstr,
|
||||
asprint_ret_value = gf_asprintf (&statstr,
|
||||
"ia_ino=%"PRIu64", ia_gen=%"PRIu64
|
||||
", st_mode=%o, ia_nlink=%"GF_PRI_NLINK", "
|
||||
"ia_uid=%d, ia_gid=%d, ia_size=%"PRId64", ia_blocks=%"PRId64
|
||||
@ -118,11 +118,11 @@ trace_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
statstr, preparentstr, postparentstr);
|
||||
|
||||
if (statstr)
|
||||
FREE (statstr);
|
||||
GF_FREE (statstr);
|
||||
if (preparentstr)
|
||||
FREE (preparentstr);
|
||||
GF_FREE (preparentstr);
|
||||
if (postparentstr)
|
||||
FREE (postparentstr);
|
||||
GF_FREE (postparentstr);
|
||||
} else {
|
||||
gf_log (this->name, GF_LOG_NORMAL,
|
||||
"%"PRId64": (op_ret=%d, op_errno=%d)",
|
||||
@ -255,10 +255,10 @@ trace_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
preopstr, postopstr);
|
||||
|
||||
if (preopstr)
|
||||
FREE (preopstr);
|
||||
GF_FREE (preopstr);
|
||||
|
||||
if (postopstr)
|
||||
FREE (postopstr);
|
||||
GF_FREE (postopstr);
|
||||
} else {
|
||||
gf_log (this->name, GF_LOG_NORMAL,
|
||||
"%"PRId64": (op_ret=%d, op_errno=%d)",
|
||||
@ -324,10 +324,10 @@ trace_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
preopstr, postopstr);
|
||||
|
||||
if (preopstr)
|
||||
FREE (preopstr);
|
||||
GF_FREE (preopstr);
|
||||
|
||||
if (postopstr)
|
||||
FREE (postopstr);
|
||||
GF_FREE (postopstr);
|
||||
} else {
|
||||
gf_log (this->name, GF_LOG_NORMAL,
|
||||
"%"PRId64": (op_ret=%d, op_errno=%d)",
|
||||
@ -472,10 +472,10 @@ trace_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
postparentstr);
|
||||
|
||||
if (preparentstr)
|
||||
FREE (preparentstr);
|
||||
GF_FREE (preparentstr);
|
||||
|
||||
if (postparentstr)
|
||||
FREE (postparentstr);
|
||||
GF_FREE (postparentstr);
|
||||
} else {
|
||||
gf_log (this->name, GF_LOG_NORMAL,
|
||||
"%"PRId64": (op_ret=%d, op_errno=%d)",
|
||||
@ -519,16 +519,16 @@ trace_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
prenewparentstr, postnewparentstr);
|
||||
|
||||
if (preoldparentstr)
|
||||
FREE (preoldparentstr);
|
||||
GF_FREE (preoldparentstr);
|
||||
|
||||
if (postoldparentstr)
|
||||
FREE (postoldparentstr);
|
||||
GF_FREE (postoldparentstr);
|
||||
|
||||
if (prenewparentstr)
|
||||
FREE (prenewparentstr);
|
||||
GF_FREE (prenewparentstr);
|
||||
|
||||
if (postnewparentstr)
|
||||
FREE (postnewparentstr);
|
||||
GF_FREE (postnewparentstr);
|
||||
} else {
|
||||
gf_log (this->name, GF_LOG_NORMAL,
|
||||
"%"PRId64": (op_ret=%d, op_errno=%d)",
|
||||
@ -569,7 +569,7 @@ trace_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
frame->root->unique, op_ret, op_errno);
|
||||
|
||||
if (statstr)
|
||||
FREE (statstr);
|
||||
GF_FREE (statstr);
|
||||
}
|
||||
|
||||
STACK_UNWIND_STRICT (readlink, frame, op_ret, op_errno, buf, stbuf);
|
||||
@ -598,9 +598,9 @@ trace_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
statstr, postparentstr);
|
||||
|
||||
if (statstr)
|
||||
FREE (statstr);
|
||||
GF_FREE (statstr);
|
||||
if (postparentstr)
|
||||
FREE (postparentstr);
|
||||
GF_FREE (postparentstr);
|
||||
} else {
|
||||
gf_log (this->name, GF_LOG_NORMAL,
|
||||
"%"PRId64": (op_ret=%d, op_errno=%d)",
|
||||
@ -638,13 +638,13 @@ trace_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
statstr, preparentstr, postparentstr);
|
||||
|
||||
if (statstr)
|
||||
FREE (statstr);
|
||||
GF_FREE (statstr);
|
||||
|
||||
if (preparentstr)
|
||||
FREE (preparentstr);
|
||||
GF_FREE (preparentstr);
|
||||
|
||||
if (postparentstr)
|
||||
FREE (postparentstr);
|
||||
GF_FREE (postparentstr);
|
||||
|
||||
} else {
|
||||
gf_log (this->name, GF_LOG_NORMAL,
|
||||
@ -683,13 +683,13 @@ trace_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
statstr, preparentstr, postparentstr);
|
||||
|
||||
if (statstr)
|
||||
FREE (statstr);
|
||||
GF_FREE (statstr);
|
||||
|
||||
if (preparentstr)
|
||||
FREE (preparentstr);
|
||||
GF_FREE (preparentstr);
|
||||
|
||||
if (postparentstr)
|
||||
FREE (postparentstr);
|
||||
GF_FREE (postparentstr);
|
||||
} else {
|
||||
gf_log (this->name, GF_LOG_NORMAL,
|
||||
"%"PRId64": (op_ret=%d, op_errno=%d)",
|
||||
@ -727,13 +727,13 @@ trace_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
statstr, preparentstr, postparentstr);
|
||||
|
||||
if (statstr)
|
||||
FREE (statstr);
|
||||
GF_FREE (statstr);
|
||||
|
||||
if (preparentstr)
|
||||
FREE (preparentstr);
|
||||
GF_FREE (preparentstr);
|
||||
|
||||
if (postparentstr)
|
||||
FREE (postparentstr);
|
||||
GF_FREE (postparentstr);
|
||||
} else {
|
||||
gf_log (this->name, GF_LOG_NORMAL,
|
||||
"%"PRId64": (op_ret=%d, op_errno=%d)",
|
||||
@ -771,13 +771,13 @@ trace_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
statstr, preparentstr, postparentstr);
|
||||
|
||||
if (statstr)
|
||||
FREE (statstr);
|
||||
GF_FREE (statstr);
|
||||
|
||||
if (preparentstr)
|
||||
FREE (preparentstr);
|
||||
GF_FREE (preparentstr);
|
||||
|
||||
if (postparentstr)
|
||||
FREE (postparentstr);
|
||||
GF_FREE (postparentstr);
|
||||
} else {
|
||||
gf_log (this->name, GF_LOG_NORMAL,
|
||||
"%"PRId64": (op_ret=%d, op_errno=%d)",
|
||||
@ -841,10 +841,10 @@ trace_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
postparentstr);
|
||||
|
||||
if (preparentstr)
|
||||
FREE (preparentstr);
|
||||
GF_FREE (preparentstr);
|
||||
|
||||
if (postparentstr)
|
||||
FREE (postparentstr);
|
||||
GF_FREE (postparentstr);
|
||||
} else {
|
||||
gf_log (this->name, GF_LOG_NORMAL,
|
||||
"%"PRId64": (op_ret=%d, op_errno=%d)",
|
||||
@ -878,10 +878,10 @@ trace_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
postopstr);
|
||||
|
||||
if (preopstr)
|
||||
FREE (preopstr);
|
||||
GF_FREE (preopstr);
|
||||
|
||||
if (postopstr)
|
||||
FREE (postopstr);
|
||||
GF_FREE (postopstr);
|
||||
} else {
|
||||
gf_log (this->name, GF_LOG_NORMAL,
|
||||
"%"PRId64": (op_ret=%d, op_errno=%d)",
|
||||
@ -1017,10 +1017,10 @@ trace_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
prebufstr, postbufstr);
|
||||
|
||||
if (prebufstr)
|
||||
FREE (prebufstr);
|
||||
GF_FREE (prebufstr);
|
||||
|
||||
if (postbufstr)
|
||||
FREE (postbufstr);
|
||||
GF_FREE (postbufstr);
|
||||
|
||||
} else {
|
||||
gf_log (this->name, GF_LOG_NORMAL,
|
||||
|
30
xlators/features/filter/src/filter-mem-types.h
Normal file
30
xlators/features/filter/src/filter-mem-types.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
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 __FILTER_MEM_TYPES_H__
|
||||
#define __FILTER_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_filter_mem_types_ {
|
||||
gf_filter_mt_gf_filter = gf_common_mt_end + 1,
|
||||
gf_filter_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "logging.h"
|
||||
#include "dict.h"
|
||||
#include "xlator.h"
|
||||
#include "filter-mem-types.h"
|
||||
|
||||
#define GF_FILTER_NOBODY_UID 65534
|
||||
#define GF_FILTER_NOBODY_GID 65534
|
||||
@ -1355,6 +1356,25 @@ filter_removexattr (call_frame_t *frame,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t
|
||||
mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!this)
|
||||
return ret;
|
||||
|
||||
ret = xlator_mem_acct_init (this, gf_filter_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)
|
||||
{
|
||||
@ -1384,7 +1404,7 @@ init (xlator_t *this)
|
||||
"dangling volume. check volfile ");
|
||||
}
|
||||
|
||||
filter = CALLOC (sizeof (*filter), 1);
|
||||
filter = GF_CALLOC (sizeof (*filter), 1, gf_filter_mt_gf_filter);
|
||||
ERR_ABORT (filter);
|
||||
|
||||
if (dict_get (this->options, "read-only")) {
|
||||
@ -1419,11 +1439,11 @@ init (xlator_t *this)
|
||||
option_data = dict_get (this->options, "translate-uid");
|
||||
value = strtok_r (option_data->data, ",", &tmp_str);
|
||||
while (value) {
|
||||
dup_str = strdup (value);
|
||||
dup_str = gf_strdup (value);
|
||||
input_value_str1 = strtok_r (dup_str, "=", &tmp_str1);
|
||||
if (input_value_str1) {
|
||||
/* Check for n-m */
|
||||
char *temp_string = strdup (input_value_str1);
|
||||
char *temp_string = gf_strdup (input_value_str1);
|
||||
input_value_str2 = strtok_r (temp_string, "-", &tmp_str2);
|
||||
if (gf_string2int (input_value_str2, &input_value) != 0) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
@ -1442,7 +1462,7 @@ init (xlator_t *this)
|
||||
}
|
||||
}
|
||||
filter->translate_input_uid[filter->translate_num_uid_entries][1] = input_value;
|
||||
FREE (temp_string);
|
||||
GF_FREE (temp_string);
|
||||
output_value_str = strtok_r (NULL, "=", &tmp_str1);
|
||||
if (output_value_str) {
|
||||
if (gf_string2int (output_value_str, &output_value) != 0) {
|
||||
@ -1471,7 +1491,7 @@ init (xlator_t *this)
|
||||
if (filter->translate_num_uid_entries == GF_MAXIMUM_FILTERING_ALLOWED)
|
||||
break;
|
||||
value = strtok_r (NULL, ",", &tmp_str);
|
||||
FREE (dup_str);
|
||||
GF_FREE (dup_str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1483,11 +1503,11 @@ init (xlator_t *this)
|
||||
option_data = dict_get (this->options, "translate-gid");
|
||||
value = strtok_r (option_data->data, ",", &tmp_str);
|
||||
while (value) {
|
||||
dup_str = strdup (value);
|
||||
dup_str = gf_strdup (value);
|
||||
input_value_str1 = strtok_r (dup_str, "=", &tmp_str1);
|
||||
if (input_value_str1) {
|
||||
/* Check for n-m */
|
||||
char *temp_string = strdup (input_value_str1);
|
||||
char *temp_string = gf_strdup (input_value_str1);
|
||||
input_value_str2 = strtok_r (temp_string, "-", &tmp_str2);
|
||||
if (gf_string2int (input_value_str2, &input_value) != 0) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
@ -1506,7 +1526,7 @@ init (xlator_t *this)
|
||||
}
|
||||
}
|
||||
filter->translate_input_gid[filter->translate_num_gid_entries][1] = input_value;
|
||||
FREE (temp_string);
|
||||
GF_FREE (temp_string);
|
||||
output_value_str = strtok_r (NULL, "=", &tmp_str1);
|
||||
if (output_value_str) {
|
||||
if (gf_string2int (output_value_str, &output_value) != 0) {
|
||||
@ -1536,7 +1556,7 @@ init (xlator_t *this)
|
||||
if (filter->translate_num_gid_entries == GF_MAXIMUM_FILTERING_ALLOWED)
|
||||
break;
|
||||
value = strtok_r (NULL, ",", &tmp_str);
|
||||
FREE (dup_str);
|
||||
GF_FREE (dup_str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1547,7 +1567,7 @@ init (xlator_t *this)
|
||||
option_data = dict_get (this->options, "filter-uid");
|
||||
value = strtok_r (option_data->data, ",", &tmp_str);
|
||||
while (value) {
|
||||
dup_str = strdup (value);
|
||||
dup_str = gf_strdup (value);
|
||||
/* Check for n-m */
|
||||
input_value_str1 = strtok_r (dup_str, "-", &tmp_str1);
|
||||
if (gf_string2int (input_value_str1, &input_value) != 0) {
|
||||
@ -1577,7 +1597,7 @@ init (xlator_t *this)
|
||||
if (filter->filter_num_uid_entries == GF_MAXIMUM_FILTERING_ALLOWED)
|
||||
break;
|
||||
value = strtok_r (NULL, ",", &tmp_str);
|
||||
FREE (dup_str);
|
||||
GF_FREE (dup_str);
|
||||
}
|
||||
filter->partial_filter = 1;
|
||||
}
|
||||
@ -1589,7 +1609,7 @@ init (xlator_t *this)
|
||||
option_data = dict_get (this->options, "filter-gid");
|
||||
value = strtok_r (option_data->data, ",", &tmp_str);
|
||||
while (value) {
|
||||
dup_str = strdup (value);
|
||||
dup_str = gf_strdup (value);
|
||||
/* Check for n-m */
|
||||
input_value_str1 = strtok_r (dup_str, "-", &tmp_str1);
|
||||
if (gf_string2int (input_value_str1, &input_value) != 0) {
|
||||
@ -1619,7 +1639,7 @@ init (xlator_t *this)
|
||||
if (filter->filter_num_gid_entries == GF_MAXIMUM_FILTERING_ALLOWED)
|
||||
break;
|
||||
value = strtok_r (NULL, ",", &tmp_str);
|
||||
FREE (dup_str);
|
||||
GF_FREE (dup_str);
|
||||
}
|
||||
gf_log (this->name, GF_LOG_ERROR, "this option is not supported currently.. exiting");
|
||||
return -1;
|
||||
@ -1660,7 +1680,7 @@ fini (xlator_t *this)
|
||||
{
|
||||
struct gf_filter *filter = this->private;
|
||||
|
||||
FREE (filter);
|
||||
GF_FREE (filter);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -48,12 +48,13 @@ allocate_domain (const char *volume)
|
||||
{
|
||||
pl_dom_list_t *dom = NULL;
|
||||
|
||||
dom = CALLOC (1, sizeof (*dom));
|
||||
dom = GF_CALLOC (1, sizeof (*dom),
|
||||
gf_locks_mt_pl_dom_list_t);
|
||||
if (!dom)
|
||||
return NULL;
|
||||
|
||||
|
||||
dom->domain = strdup(volume);
|
||||
dom->domain = gf_strdup(volume);
|
||||
if (!dom->domain) {
|
||||
gf_log ("posix-locks", GF_LOG_TRACE,
|
||||
"Out of Memory");
|
||||
@ -151,7 +152,7 @@ pl_print_lockee (char *str, int size, fd_t *fd, loc_t *loc)
|
||||
}
|
||||
|
||||
if (loc && loc->path) {
|
||||
ipath = strdup (loc->path);
|
||||
ipath = gf_strdup (loc->path);
|
||||
} else {
|
||||
ret = inode_path (inode, NULL, &ipath);
|
||||
if (ret <= 0)
|
||||
@ -163,7 +164,7 @@ pl_print_lockee (char *str, int size, fd_t *fd, loc_t *loc)
|
||||
ipath ? ipath : "<nul>");
|
||||
|
||||
if (ipath)
|
||||
FREE (ipath);
|
||||
GF_FREE (ipath);
|
||||
}
|
||||
|
||||
|
||||
@ -418,7 +419,8 @@ pl_inode_get (xlator_t *this, inode_t *inode)
|
||||
pl_inode = (pl_inode_t *)(long)tmp_pl_inode;
|
||||
goto out;
|
||||
}
|
||||
pl_inode = CALLOC (1, sizeof (*pl_inode));
|
||||
pl_inode = GF_CALLOC (1, sizeof (*pl_inode),
|
||||
gf_locks_mt_pl_inode_t);
|
||||
if (!pl_inode) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory.");
|
||||
@ -454,7 +456,8 @@ new_posix_lock (struct flock *flock, transport_t *transport, pid_t client_pid,
|
||||
{
|
||||
posix_lock_t *lock = NULL;
|
||||
|
||||
lock = CALLOC (1, sizeof (posix_lock_t));
|
||||
lock = GF_CALLOC (1, sizeof (posix_lock_t),
|
||||
gf_locks_mt_posix_lock_t);
|
||||
if (!lock) {
|
||||
return NULL;
|
||||
}
|
||||
@ -490,7 +493,7 @@ __delete_lock (pl_inode_t *pl_inode, posix_lock_t *lock)
|
||||
void
|
||||
__destroy_lock (posix_lock_t *lock)
|
||||
{
|
||||
free (lock);
|
||||
GF_FREE (lock);
|
||||
}
|
||||
|
||||
|
||||
@ -567,7 +570,8 @@ add_locks (posix_lock_t *l1, posix_lock_t *l2)
|
||||
{
|
||||
posix_lock_t *sum = NULL;
|
||||
|
||||
sum = CALLOC (1, sizeof (posix_lock_t));
|
||||
sum = GF_CALLOC (1, sizeof (posix_lock_t),
|
||||
gf_locks_mt_posix_lock_t);
|
||||
if (!sum)
|
||||
return NULL;
|
||||
|
||||
@ -591,7 +595,8 @@ subtract_locks (posix_lock_t *big, posix_lock_t *small)
|
||||
if ((big->fl_start == small->fl_start) &&
|
||||
(big->fl_end == small->fl_end)) {
|
||||
/* both edges coincide with big */
|
||||
v.locks[0] = CALLOC (1, sizeof (posix_lock_t));
|
||||
v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
|
||||
gf_locks_mt_posix_lock_t);
|
||||
ERR_ABORT (v.locks[0]);
|
||||
memcpy (v.locks[0], big, sizeof (posix_lock_t));
|
||||
v.locks[0]->fl_type = small->fl_type;
|
||||
@ -599,11 +604,14 @@ subtract_locks (posix_lock_t *big, posix_lock_t *small)
|
||||
else if ((small->fl_start > big->fl_start) &&
|
||||
(small->fl_end < big->fl_end)) {
|
||||
/* both edges lie inside big */
|
||||
v.locks[0] = CALLOC (1, sizeof (posix_lock_t));
|
||||
v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
|
||||
gf_locks_mt_posix_lock_t);
|
||||
ERR_ABORT (v.locks[0]);
|
||||
v.locks[1] = CALLOC (1, sizeof (posix_lock_t));
|
||||
v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t),
|
||||
gf_locks_mt_posix_lock_t);
|
||||
ERR_ABORT (v.locks[1]);
|
||||
v.locks[2] = CALLOC (1, sizeof (posix_lock_t));
|
||||
v.locks[2] = GF_CALLOC (1, sizeof (posix_lock_t),
|
||||
gf_locks_mt_posix_lock_t);
|
||||
ERR_ABORT (v.locks[2]);
|
||||
|
||||
memcpy (v.locks[0], big, sizeof (posix_lock_t));
|
||||
@ -615,9 +623,11 @@ subtract_locks (posix_lock_t *big, posix_lock_t *small)
|
||||
}
|
||||
/* one edge coincides with big */
|
||||
else if (small->fl_start == big->fl_start) {
|
||||
v.locks[0] = CALLOC (1, sizeof (posix_lock_t));
|
||||
v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
|
||||
gf_locks_mt_posix_lock_t);
|
||||
ERR_ABORT (v.locks[0]);
|
||||
v.locks[1] = CALLOC (1, sizeof (posix_lock_t));
|
||||
v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t),
|
||||
gf_locks_mt_posix_lock_t);
|
||||
ERR_ABORT (v.locks[1]);
|
||||
|
||||
memcpy (v.locks[0], big, sizeof (posix_lock_t));
|
||||
@ -626,9 +636,11 @@ subtract_locks (posix_lock_t *big, posix_lock_t *small)
|
||||
memcpy (v.locks[1], small, sizeof (posix_lock_t));
|
||||
}
|
||||
else if (small->fl_end == big->fl_end) {
|
||||
v.locks[0] = CALLOC (1, sizeof (posix_lock_t));
|
||||
v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t),
|
||||
gf_locks_mt_posix_lock_t);
|
||||
ERR_ABORT (v.locks[0]);
|
||||
v.locks[1] = CALLOC (1, sizeof (posix_lock_t));
|
||||
v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t),
|
||||
gf_locks_mt_posix_lock_t);
|
||||
ERR_ABORT (v.locks[1]);
|
||||
|
||||
memcpy (v.locks[0], big, sizeof (posix_lock_t));
|
||||
@ -800,7 +812,8 @@ __grant_blocked_locks (xlator_t *this, pl_inode_t *pl_inode, struct list_head *g
|
||||
list_del_init (&l->list);
|
||||
|
||||
if (__is_lock_grantable (pl_inode, l)) {
|
||||
conf = CALLOC (1, sizeof (*conf));
|
||||
conf = GF_CALLOC (1, sizeof (*conf),
|
||||
gf_locks_mt_posix_lock_t);
|
||||
|
||||
if (!conf) {
|
||||
l->blocked = 1;
|
||||
@ -855,7 +868,7 @@ grant_blocked_locks (xlator_t *this, pl_inode_t *pl_inode)
|
||||
|
||||
STACK_UNWIND (lock->frame, 0, 0, &lock->user_flock);
|
||||
|
||||
FREE (lock);
|
||||
GF_FREE (lock);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -40,12 +40,13 @@ new_entrylk_lock (pl_inode_t *pinode, const char *basename, entrylk_type type,
|
||||
{
|
||||
pl_entry_lock_t *newlock = NULL;
|
||||
|
||||
newlock = CALLOC (1, sizeof (pl_entry_lock_t));
|
||||
newlock = GF_CALLOC (1, sizeof (pl_entry_lock_t),
|
||||
gf_locks_mt_pl_entry_lock_t);
|
||||
if (!newlock) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
newlock->basename = basename ? strdup (basename) : NULL;
|
||||
newlock->basename = basename ? gf_strdup (basename) : NULL;
|
||||
newlock->type = type;
|
||||
newlock->trans = trans;
|
||||
newlock->volume = volume;
|
||||
@ -457,8 +458,8 @@ __grant_blocked_entry_locks (xlator_t *this, pl_inode_t *pl_inode,
|
||||
list_add (&bl->blocked_locks, granted);
|
||||
} else {
|
||||
if (bl->basename)
|
||||
FREE (bl->basename);
|
||||
FREE (bl);
|
||||
GF_FREE ((char *)bl->basename);
|
||||
GF_FREE (bl);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -490,12 +491,12 @@ grant_blocked_entry_locks (xlator_t *this, pl_inode_t *pl_inode,
|
||||
|
||||
STACK_UNWIND_STRICT (entrylk, lock->frame, 0, 0);
|
||||
|
||||
FREE (lock->basename);
|
||||
FREE (lock);
|
||||
GF_FREE ((char *)lock->basename);
|
||||
GF_FREE (lock);
|
||||
}
|
||||
|
||||
FREE (unlocked->basename);
|
||||
FREE (unlocked);
|
||||
GF_FREE ((char *)unlocked->basename);
|
||||
GF_FREE (unlocked);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -545,8 +546,8 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode,
|
||||
"releasing lock on held by "
|
||||
"{transport=%p}",trans);
|
||||
|
||||
FREE (lock->basename);
|
||||
FREE (lock);
|
||||
GF_FREE ((char *)lock->basename);
|
||||
GF_FREE (lock);
|
||||
}
|
||||
|
||||
__grant_blocked_entry_locks (this, pinode, dom, &granted);
|
||||
@ -561,8 +562,8 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode,
|
||||
STACK_UNWIND_STRICT (entrylk, lock->frame, -1, EAGAIN);
|
||||
|
||||
if (lock->basename)
|
||||
FREE (lock->basename);
|
||||
FREE (lock);
|
||||
GF_FREE ((char *)lock->basename);
|
||||
GF_FREE (lock);
|
||||
|
||||
}
|
||||
|
||||
@ -572,8 +573,8 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode,
|
||||
STACK_UNWIND_STRICT (entrylk, lock->frame, 0, 0);
|
||||
|
||||
if (lock->basename)
|
||||
FREE (lock->basename);
|
||||
FREE (lock);
|
||||
GF_FREE ((char *)lock->basename);
|
||||
GF_FREE (lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -42,7 +42,7 @@ __delete_inode_lock (pl_inode_lock_t *lock)
|
||||
void
|
||||
__destroy_inode_lock (pl_inode_lock_t *lock)
|
||||
{
|
||||
FREE (lock);
|
||||
GF_FREE (lock);
|
||||
}
|
||||
|
||||
/* Check if 2 inodelks are conflicting on type. Only 2 shared locks don't conflict */
|
||||
@ -439,7 +439,7 @@ release_inode_locks_of_transport (xlator_t *this, pl_dom_list_t *dom,
|
||||
}
|
||||
unlock:
|
||||
if (path)
|
||||
FREE (path);
|
||||
GF_FREE (path);
|
||||
|
||||
pthread_mutex_unlock (&pinode->mutex);
|
||||
|
||||
@ -447,7 +447,7 @@ unlock:
|
||||
list_del_init (&l->blocked_locks);
|
||||
|
||||
STACK_UNWIND_STRICT (inodelk, l->frame, -1, EAGAIN);
|
||||
FREE (l);
|
||||
GF_FREE (l);
|
||||
}
|
||||
|
||||
grant_blocked_inode_locks (this, pinode, dom);
|
||||
@ -515,7 +515,8 @@ new_inode_lock (struct flock *flock, transport_t *transport, pid_t client_pid,
|
||||
{
|
||||
pl_inode_lock_t *lock = NULL;
|
||||
|
||||
lock = CALLOC (1, sizeof (*lock));
|
||||
lock = GF_CALLOC (1, sizeof (*lock),
|
||||
gf_locks_mt_pl_inode_lock_t);
|
||||
if (!lock) {
|
||||
return NULL;
|
||||
}
|
||||
|
39
xlators/features/locks/src/locks-mem-types.h
Normal file
39
xlators/features/locks/src/locks-mem-types.h
Normal file
@ -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 __LOCKS_MEM_TYPES_H__
|
||||
#define __LOCKS_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_locks_mem_types_ {
|
||||
gf_locks_mt_pl_dom_list_t = gf_common_mt_end + 1,
|
||||
gf_locks_mt_pl_inode_t,
|
||||
gf_locks_mt_posix_lock_t,
|
||||
gf_locks_mt_pl_entry_lock_t,
|
||||
gf_locks_mt_pl_inode_lock_t,
|
||||
gf_locks_mt_truncate_ops,
|
||||
gf_locks_mt_pl_rw_req_t,
|
||||
gf_locks_mt_posix_locks_private_t,
|
||||
gf_locks_mt_pl_local_t,
|
||||
gf_locks_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "transport.h"
|
||||
#include "stack.h"
|
||||
#include "call-stub.h"
|
||||
#include "locks-mem-types.h"
|
||||
|
||||
struct __pl_fd;
|
||||
|
||||
|
@ -180,7 +180,8 @@ pl_truncate (call_frame_t *frame, xlator_t *this,
|
||||
{
|
||||
struct _truncate_ops *local = NULL;
|
||||
|
||||
local = CALLOC (1, sizeof (struct _truncate_ops));
|
||||
local = GF_CALLOC (1, sizeof (struct _truncate_ops),
|
||||
gf_locks_mt_truncate_ops);
|
||||
if (!local) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory.");
|
||||
@ -211,7 +212,8 @@ pl_ftruncate (call_frame_t *frame, xlator_t *this,
|
||||
{
|
||||
struct _truncate_ops *local = NULL;
|
||||
|
||||
local = CALLOC (1, sizeof (struct _truncate_ops));
|
||||
local = GF_CALLOC (1, sizeof (struct _truncate_ops),
|
||||
gf_locks_mt_truncate_ops);
|
||||
if (!local) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory.");
|
||||
@ -522,7 +524,7 @@ do_blocked_rw (pl_inode_t *pl_inode)
|
||||
list_for_each_entry_safe (rw, tmp, &wind_list, list) {
|
||||
list_del_init (&rw->list);
|
||||
call_resume (rw->stub);
|
||||
free (rw);
|
||||
GF_FREE (rw);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -601,7 +603,8 @@ pl_readv (call_frame_t *frame, xlator_t *this,
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
rw = CALLOC (1, sizeof (*rw));
|
||||
rw = GF_CALLOC (1, sizeof (*rw),
|
||||
gf_locks_mt_pl_rw_req_t);
|
||||
if (!rw) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory.");
|
||||
@ -617,7 +620,7 @@ pl_readv (call_frame_t *frame, xlator_t *this,
|
||||
"Out of memory.");
|
||||
op_errno = ENOMEM;
|
||||
op_ret = -1;
|
||||
free (rw);
|
||||
GF_FREE (rw);
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
@ -698,7 +701,8 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
rw = CALLOC (1, sizeof (*rw));
|
||||
rw = GF_CALLOC (1, sizeof (*rw),
|
||||
gf_locks_mt_pl_rw_req_t);
|
||||
if (!rw) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Out of memory.");
|
||||
@ -715,7 +719,7 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
|
||||
"Out of memory.");
|
||||
op_errno = ENOMEM;
|
||||
op_ret = -1;
|
||||
free (rw);
|
||||
GF_FREE (rw);
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
@ -876,7 +880,7 @@ pl_forget (xlator_t *this,
|
||||
list) {
|
||||
|
||||
list_del (&rw_req->list);
|
||||
FREE (rw_req);
|
||||
GF_FREE (rw_req);
|
||||
}
|
||||
}
|
||||
|
||||
@ -920,8 +924,8 @@ pl_forget (xlator_t *this,
|
||||
list_del_init (&entry_l->domain_list);
|
||||
|
||||
if (entry_l->basename)
|
||||
FREE (entry_l->basename);
|
||||
FREE (entry_l);
|
||||
GF_FREE ((char *)entry_l->basename);
|
||||
GF_FREE (entry_l);
|
||||
}
|
||||
|
||||
list_splice_init (&dom->blocked_entrylks, &entrylks_released);
|
||||
@ -930,8 +934,8 @@ pl_forget (xlator_t *this,
|
||||
list_del (&dom->inode_list);
|
||||
gf_log ("posix-locks", GF_LOG_TRACE,
|
||||
" Cleaning up domain: %s", dom->domain);
|
||||
FREE (dom->domain);
|
||||
FREE (dom);
|
||||
GF_FREE ((char *)(dom->domain));
|
||||
GF_FREE (dom);
|
||||
}
|
||||
|
||||
}
|
||||
@ -953,12 +957,12 @@ pl_forget (xlator_t *this,
|
||||
|
||||
STACK_UNWIND_STRICT (entrylk, entry_l->frame, -1, 0);
|
||||
if (entry_l->basename)
|
||||
FREE (entry_l->basename);
|
||||
FREE (entry_l);
|
||||
GF_FREE ((char *)entry_l->basename);
|
||||
GF_FREE (entry_l);
|
||||
|
||||
}
|
||||
|
||||
FREE (pl_inode);
|
||||
GF_FREE (pl_inode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1117,7 +1121,7 @@ pl_lookup_cbk (call_frame_t *frame,
|
||||
frame->local = NULL;
|
||||
|
||||
if (local != NULL)
|
||||
FREE (local);
|
||||
GF_FREE (local);
|
||||
|
||||
out:
|
||||
STACK_UNWIND (frame,
|
||||
@ -1143,7 +1147,7 @@ pl_lookup (call_frame_t *frame,
|
||||
VALIDATE_OR_GOTO (this, out);
|
||||
VALIDATE_OR_GOTO (loc, out);
|
||||
|
||||
local = CALLOC (1, sizeof (*local));
|
||||
local = GF_CALLOC (1, sizeof (*local), gf_locks_mt_pl_local_t);
|
||||
if (!local) {
|
||||
ret = -1;
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
@ -1437,7 +1441,24 @@ pl_dump_inode (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_locks_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)
|
||||
@ -1469,7 +1490,8 @@ init (xlator_t *this)
|
||||
return -1;
|
||||
}
|
||||
|
||||
priv = CALLOC (1, sizeof (*priv));
|
||||
priv = GF_CALLOC (1, sizeof (*priv),
|
||||
gf_locks_mt_posix_locks_private_t);
|
||||
|
||||
mandatory = dict_get (this->options, "mandatory-locks");
|
||||
if (mandatory)
|
||||
@ -1497,7 +1519,7 @@ fini (xlator_t *this)
|
||||
posix_locks_private_t *priv = NULL;
|
||||
|
||||
priv = this->private;
|
||||
free (priv);
|
||||
GF_FREE (priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
32
xlators/features/path-convertor/src/path-mem-types.h
Normal file
32
xlators/features/path-convertor/src/path-mem-types.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
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 __PATH_MEM_TYPES_H__
|
||||
#define __PATH_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_path_mem_types_ {
|
||||
gf_path_mt_path_private_t = gf_common_mt_end + 1,
|
||||
gf_path_mt_char,
|
||||
gf_path_mt_regex_t,
|
||||
gf_path_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <errno.h>
|
||||
#include "glusterfs.h"
|
||||
#include "xlator.h"
|
||||
#include "path-mem-types.h"
|
||||
|
||||
typedef struct path_private
|
||||
{
|
||||
@ -63,7 +64,9 @@ name_this_to_that (xlator_t *xl, const char *path, const char *name)
|
||||
|
||||
if (priv->end_off && (total_len > priv->end_off)) {
|
||||
j = priv->start_off;
|
||||
tmp_name = CALLOC (1, (total_len + ZR_FILE_CONTENT_STRLEN));
|
||||
tmp_name = GF_CALLOC (1, (total_len +
|
||||
ZR_FILE_CONTENT_STRLEN),
|
||||
gf_path_mt_char);
|
||||
ERR_ABORT (tmp_name);
|
||||
|
||||
/* Get the complete path for the file first */
|
||||
@ -104,7 +107,7 @@ path_this_to_that (xlator_t *xl, const char *path)
|
||||
int32_t i = 0, j = 0;
|
||||
|
||||
if (priv->end_off && (path_len > priv->start_off)) {
|
||||
priv_path = CALLOC (1, path_len);
|
||||
priv_path = GF_CALLOC (1, path_len, gf_path_mt_char);
|
||||
ERR_ABORT (priv_path);
|
||||
|
||||
if (priv->start_off && (path_len > priv->start_off))
|
||||
@ -378,7 +381,7 @@ path_lookup (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -405,7 +408,7 @@ path_stat (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -434,7 +437,7 @@ path_readlink (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -465,7 +468,7 @@ path_mknod (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -494,7 +497,7 @@ path_mkdir (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -521,7 +524,7 @@ path_unlink (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -548,7 +551,7 @@ path_rmdir (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -577,7 +580,7 @@ path_symlink (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -615,11 +618,11 @@ path_rename (call_frame_t *frame,
|
||||
|
||||
oldloc->path = oldloc_path;
|
||||
if (tmp_oldloc_path != oldloc_path)
|
||||
FREE (tmp_oldloc_path);
|
||||
GF_FREE (tmp_oldloc_path);
|
||||
|
||||
newloc->path = newloc_path;
|
||||
if (tmp_newloc_path != newloc_path)
|
||||
FREE (tmp_newloc_path);
|
||||
GF_FREE (tmp_newloc_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -657,11 +660,11 @@ path_link (call_frame_t *frame,
|
||||
|
||||
oldloc->path = oldloc_path;
|
||||
if (tmp_oldloc_path != oldloc_path)
|
||||
FREE (tmp_oldloc_path);
|
||||
GF_FREE (tmp_oldloc_path);
|
||||
|
||||
newloc->path = newloc_path;
|
||||
if (tmp_newloc_path != newloc_path)
|
||||
FREE (tmp_newloc_path);
|
||||
GF_FREE (tmp_newloc_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -704,7 +707,7 @@ path_setattr (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -734,7 +737,7 @@ path_truncate (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -768,7 +771,7 @@ path_open (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -801,7 +804,7 @@ path_create (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -843,10 +846,10 @@ path_setxattr (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
if (tmp_name)
|
||||
FREE (tmp_name);
|
||||
GF_FREE (tmp_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -880,10 +883,10 @@ path_getxattr (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
if (tmp_name != name)
|
||||
FREE (tmp_name);
|
||||
GF_FREE (tmp_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -917,10 +920,10 @@ path_removexattr (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
if (tmp_name != name)
|
||||
FREE (tmp_name);
|
||||
GF_FREE (tmp_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -949,7 +952,7 @@ path_opendir (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -978,7 +981,7 @@ path_access (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1020,7 +1023,7 @@ path_checksum (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1047,7 +1050,7 @@ path_entrylk (call_frame_t *frame, xlator_t *this,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1073,7 +1076,7 @@ path_inodelk (call_frame_t *frame, xlator_t *this,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1105,11 +1108,29 @@ path_xattrop (call_frame_t *frame,
|
||||
|
||||
loc->path = loc_path;
|
||||
if (tmp_path != loc_path)
|
||||
FREE (tmp_path);
|
||||
GF_FREE (tmp_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t
|
||||
mem_acct_init (xlator_t *this)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!this)
|
||||
return ret;
|
||||
|
||||
ret = xlator_mem_acct_init (this, gf_path_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)
|
||||
@ -1128,7 +1149,7 @@ init (xlator_t *this)
|
||||
"dangling volume. check volfile ");
|
||||
}
|
||||
|
||||
priv = CALLOC (1, sizeof (*priv));
|
||||
priv = GF_CALLOC (1, sizeof (*priv), gf_path_mt_path_private_t);
|
||||
ERR_ABORT (priv);
|
||||
if (dict_get (options, "start-offset")) {
|
||||
priv->start_off = data_to_int32 (dict_get (options,
|
||||
@ -1141,7 +1162,8 @@ init (xlator_t *this)
|
||||
|
||||
if (dict_get (options, "regex")) {
|
||||
int32_t ret = 0;
|
||||
priv->preg = CALLOC (1, sizeof (regex_t));
|
||||
priv->preg = GF_CALLOC (1, sizeof (regex_t),
|
||||
gf_path_mt_regex_t);
|
||||
ERR_ABORT (priv->preg);
|
||||
ret = regcomp (priv->preg,
|
||||
data_to_str (dict_get (options, "regex")),
|
||||
@ -1149,7 +1171,7 @@ init (xlator_t *this)
|
||||
if (ret) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Failed to compile the 'option regex'");
|
||||
FREE (priv);
|
||||
GF_FREE (priv);
|
||||
return -1;
|
||||
}
|
||||
if (dict_get (options, "replace-with")) {
|
||||
|
31
xlators/features/quota/src/quota-mem-types.h
Normal file
31
xlators/features/quota/src/quota-mem-types.h
Normal file
@ -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
|
||||
|
@ -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) {
|
||||
|
33
xlators/features/trash/src/trash-mem-types.h
Normal file
33
xlators/features/trash/src/trash-mem-types.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
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 __TRASH_MEM_TYPES_H__
|
||||
#define __TRASH_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_trash_mem_types_ {
|
||||
gf_trash_mt_trash_local_t = gf_common_mt_end + 1,
|
||||
gf_trash_mt_trash_private_t,
|
||||
gf_trash_mt_char,
|
||||
gf_trash_mt_trash_elim_pattern_t,
|
||||
gf_trash_mt_end
|
||||
};
|
||||
#endif
|
||||
|
@ -23,7 +23,7 @@
|
||||
#endif
|
||||
|
||||
#include "trash.h"
|
||||
|
||||
#include "trash-mem-types.h"
|
||||
|
||||
int32_t
|
||||
trash_ftruncate_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
@ -63,7 +63,7 @@ trash_local_wipe (trash_local_t *local)
|
||||
if (local->newfd)
|
||||
fd_unref (local->newfd);
|
||||
|
||||
FREE (local);
|
||||
GF_FREE (local);
|
||||
out:
|
||||
return;
|
||||
}
|
||||
@ -94,7 +94,7 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
loc_t tmp_loc = {0,};
|
||||
|
||||
local = frame->local;
|
||||
tmp_str = strdup (local->newpath);
|
||||
tmp_str = gf_strdup (local->newpath);
|
||||
if (!tmp_str) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
}
|
||||
@ -166,8 +166,8 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
&tmp_loc, 0755);
|
||||
|
||||
out:
|
||||
free (cookie);
|
||||
free (tmp_str);
|
||||
GF_FREE (cookie);
|
||||
GF_FREE (tmp_str);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -195,7 +195,7 @@ trash_unlink_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
local = frame->local;
|
||||
|
||||
if ((op_ret == -1) && (op_errno == ENOENT)) {
|
||||
tmp_str = strdup (local->newpath);
|
||||
tmp_str = gf_strdup (local->newpath);
|
||||
if (!tmp_str) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
}
|
||||
@ -203,7 +203,7 @@ trash_unlink_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
|
||||
tmp_loc.path = dir_name;
|
||||
|
||||
tmp_cookie = strdup (dir_name);
|
||||
tmp_cookie = gf_strdup (dir_name);
|
||||
if (!tmp_cookie) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
}
|
||||
@ -213,7 +213,7 @@ trash_unlink_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
FIRST_CHILD(this)->fops->mkdir,
|
||||
&tmp_loc, 0755);
|
||||
|
||||
free (tmp_str);
|
||||
GF_FREE (tmp_str);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -337,7 +337,7 @@ trash_rename_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
|
||||
local = frame->local;
|
||||
if ((op_ret == -1) && (op_errno == ENOENT)) {
|
||||
tmp_str = strdup (local->newpath);
|
||||
tmp_str = gf_strdup (local->newpath);
|
||||
if (!tmp_str) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
}
|
||||
@ -346,7 +346,7 @@ trash_rename_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
/* check for the errno, if its ENOENT create directory and call
|
||||
* rename later
|
||||
*/
|
||||
tmp_path = strdup (dir_name);
|
||||
tmp_path = gf_strdup (dir_name);
|
||||
if (!tmp_path) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
}
|
||||
@ -358,7 +358,7 @@ trash_rename_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
this->children->xlator->fops->mkdir,
|
||||
&tmp_loc, 0755);
|
||||
|
||||
free (tmp_str);
|
||||
GF_FREE (tmp_str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ trash_rename_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
loc_t tmp_loc = {0,};
|
||||
|
||||
local = frame->local;
|
||||
tmp_str = strdup (local->newpath);
|
||||
tmp_str = gf_strdup (local->newpath);
|
||||
if (!tmp_str) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
}
|
||||
@ -438,8 +438,8 @@ trash_rename_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
}
|
||||
|
||||
out:
|
||||
free (cookie); /* strdup (dir_name) was sent here :) */
|
||||
free (tmp_str);
|
||||
GF_FREE (cookie); /* strdup (dir_name) was sent here :) */
|
||||
GF_FREE (tmp_str);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -529,7 +529,8 @@ trash_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
|
||||
return 0;
|
||||
}
|
||||
|
||||
local = CALLOC (1, sizeof (trash_local_t));
|
||||
local = GF_CALLOC (1, sizeof (trash_local_t),
|
||||
gf_trash_mt_trash_local_t);
|
||||
if (!local) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
TRASH_STACK_UNWIND (frame, -1, ENOMEM,
|
||||
@ -605,7 +606,8 @@ trash_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
local = CALLOC (1, sizeof (trash_local_t));
|
||||
local = GF_CALLOC (1, sizeof (trash_local_t),
|
||||
gf_trash_mt_trash_local_t);
|
||||
if (!local) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
TRASH_STACK_UNWIND (frame, -1, ENOMEM, NULL, NULL);
|
||||
@ -781,13 +783,13 @@ trash_truncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
|
||||
if ((op_ret == -1) && (op_errno == ENOENT)) {
|
||||
//Creating the directory structure here.
|
||||
tmp_str = strdup (local->newpath);
|
||||
tmp_str = gf_strdup (local->newpath);
|
||||
if (!tmp_str) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
}
|
||||
dir_name = dirname (tmp_str);
|
||||
|
||||
tmp_path = strdup (dir_name);
|
||||
tmp_path = gf_strdup (dir_name);
|
||||
if (!tmp_path) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
}
|
||||
@ -798,7 +800,7 @@ trash_truncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
tmp_path, FIRST_CHILD(this),
|
||||
FIRST_CHILD(this)->fops->mkdir,
|
||||
&tmp_loc, 0755);
|
||||
free (tmp_str);
|
||||
GF_FREE (tmp_str);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -850,7 +852,7 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
|
||||
loop_count = local->loop_count;
|
||||
|
||||
tmp_str = strdup (local->newpath);
|
||||
tmp_str = gf_strdup (local->newpath);
|
||||
if (!tmp_str) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
}
|
||||
@ -923,8 +925,8 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
&tmp_loc, 0755);
|
||||
|
||||
out:
|
||||
free (cookie); /* strdup (dir_name) was sent here :) */
|
||||
free (tmp_str);
|
||||
GF_FREE (cookie); /* strdup (dir_name) was sent here :) */
|
||||
GF_FREE (tmp_str);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -979,8 +981,8 @@ trash_truncate_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
strcpy (loc_newname,local->loc.name);
|
||||
strcat (loc_newname,timestr);
|
||||
|
||||
local->newloc.name = strdup (loc_newname);
|
||||
local->newloc.path = strdup (local->newpath);
|
||||
local->newloc.name = gf_strdup (loc_newname);
|
||||
local->newloc.path = gf_strdup (local->newpath);
|
||||
local->newloc.inode = inode_new (local->loc.inode->table);
|
||||
local->newloc.ino = local->newloc.inode->ino;
|
||||
local->newfd = fd_create (local->newloc.inode, frame->root->pid);
|
||||
@ -1036,7 +1038,8 @@ trash_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc,
|
||||
|
||||
LOCK_INIT (&frame->lock);
|
||||
|
||||
local = CALLOC (1, sizeof (trash_local_t));
|
||||
local = GF_CALLOC (1, sizeof (trash_local_t),
|
||||
gf_trash_mt_trash_local_t);
|
||||
if (!local) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
TRASH_STACK_UNWIND (frame, -1, ENOMEM, NULL);
|
||||
@ -1154,13 +1157,13 @@ trash_ftruncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
local = frame->local;
|
||||
|
||||
if ((op_ret == -1) && (op_errno == ENOENT)) {
|
||||
tmp_str = strdup (local->newpath);
|
||||
tmp_str = gf_strdup (local->newpath);
|
||||
if (!tmp_str) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
}
|
||||
dir_name = dirname (tmp_str);
|
||||
|
||||
tmp_path = strdup (dir_name);
|
||||
tmp_path = gf_strdup (dir_name);
|
||||
if (!tmp_path) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
}
|
||||
@ -1171,7 +1174,7 @@ trash_ftruncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
tmp_path, FIRST_CHILD(this),
|
||||
FIRST_CHILD(this)->fops->mkdir,
|
||||
&tmp_loc, 0755);
|
||||
free (tmp_str);
|
||||
GF_FREE (tmp_str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1214,7 +1217,7 @@ trash_ftruncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
|
||||
loop_count = local->loop_count;
|
||||
|
||||
tmp_str = strdup (local->newpath);
|
||||
tmp_str = gf_strdup (local->newpath);
|
||||
if (!tmp_str) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
}
|
||||
@ -1288,8 +1291,8 @@ trash_ftruncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
&tmp_loc, 0755);
|
||||
|
||||
out:
|
||||
free (cookie); /* strdup (dir_name) was sent here :) */
|
||||
free (tmp_str);
|
||||
GF_FREE (cookie); /* strdup (dir_name) was sent here :) */
|
||||
GF_FREE (tmp_str);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1374,7 +1377,8 @@ trash_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
|
||||
return 0;
|
||||
}
|
||||
|
||||
local = CALLOC (1, sizeof (trash_local_t));
|
||||
local = GF_CALLOC (1, sizeof (trash_local_t),
|
||||
gf_trash_mt_trash_local_t);
|
||||
if (!local) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
TRASH_STACK_UNWIND (frame, -1, ENOMEM, NULL, NULL);
|
||||
@ -1438,7 +1442,7 @@ init (xlator_t *this)
|
||||
"dangling volume. check volfile ");
|
||||
}
|
||||
|
||||
_priv = CALLOC (1, sizeof (*_priv));
|
||||
_priv = GF_CALLOC (1, sizeof (*_priv), gf_trash_mt_trash_private_t);
|
||||
if (!_priv) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "out of memory");
|
||||
return -1;
|
||||
@ -1449,17 +1453,17 @@ init (xlator_t *this)
|
||||
gf_log (this->name, GF_LOG_NORMAL,
|
||||
"no option specified for 'trash-dir', "
|
||||
"using \"/.trashcan/\"");
|
||||
_priv->trash_dir = strdup ("/.trashcan");
|
||||
_priv->trash_dir = gf_strdup ("/.trashcan");
|
||||
} else {
|
||||
/* Need a path with '/' as the first char, if not
|
||||
given, append it */
|
||||
if (data->data[0] == '/') {
|
||||
_priv->trash_dir = strdup (data->data);
|
||||
_priv->trash_dir = gf_strdup (data->data);
|
||||
} else {
|
||||
/* TODO: Make sure there is no ".." in the path */
|
||||
strcpy (trash_dir, "/");
|
||||
strcat (trash_dir, data->data);
|
||||
_priv->trash_dir = strdup (trash_dir);
|
||||
_priv->trash_dir = gf_strdup (trash_dir);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1468,7 +1472,7 @@ init (xlator_t *this)
|
||||
gf_log (this->name, GF_LOG_TRACE,
|
||||
"no option specified for 'eliminate', using NULL");
|
||||
} else {
|
||||
tmp_str = strdup (data->data);
|
||||
tmp_str = gf_strdup (data->data);
|
||||
if (!tmp_str) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
}
|
||||
@ -1476,7 +1480,8 @@ init (xlator_t *this)
|
||||
/* Match Filename to option specified in eliminate. */
|
||||
component = strtok_r (tmp_str, "|", &strtokptr);
|
||||
while (component) {
|
||||
trav = CALLOC (1, sizeof (*trav));
|
||||
trav = GF_CALLOC (1, sizeof (*trav),
|
||||
gf_trash_mt_trash_elim_pattern_t);
|
||||
if (!trav) {
|
||||
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
|
||||
}
|
||||
@ -1521,7 +1526,7 @@ fini (xlator_t *this)
|
||||
|
||||
priv = this->private;
|
||||
if (priv)
|
||||
FREE (priv);
|
||||
GF_FREE (priv);
|
||||
|
||||
return;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user