summaryrefslogtreecommitdiffstats
path: root/glusterfsd
diff options
context:
space:
mode:
Diffstat (limited to 'glusterfsd')
-rw-r--r--glusterfsd/src/glusterfsd-mgmt.c28
-rw-r--r--glusterfsd/src/glusterfsd.c58
-rw-r--r--glusterfsd/src/glusterfsd.h2
3 files changed, 48 insertions, 40 deletions
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
index f3712987816..2b7b4aa516f 100644
--- a/glusterfsd/src/glusterfsd-mgmt.c
+++ b/glusterfsd/src/glusterfsd-mgmt.c
@@ -63,7 +63,7 @@ mgmt_cbk_spec (struct rpc_clnt *rpc, void *mydata, void *data)
xlator_t *this = NULL;
this = mydata;
- ctx = glusterfs_ctx_get ();
+ ctx = glusterfsd_ctx;
gf_log ("mgmt", GF_LOG_INFO, "Volume file changed");
glusterfs_volfile_fetch (ctx);
@@ -269,7 +269,7 @@ glusterfs_handle_translator_info_get_cont (gfd_vol_top_priv_t *priv)
goto cont;
cont:
- ctx = glusterfs_ctx_get ();
+ ctx = glusterfsd_ctx;
GF_ASSERT (ctx);
active = ctx->active;
any = active->first;
@@ -658,7 +658,7 @@ glusterfs_handle_translator_op (void *data)
goto out;
}
- ctx = glusterfs_ctx_get ();
+ ctx = glusterfsd_ctx;
active = ctx->active;
any = active->first;
input = dict_new ();
@@ -735,7 +735,7 @@ glusterfs_handle_defrag (rpcsvc_request_t *req)
this = THIS;
GF_ASSERT (this);
- ctx = glusterfs_ctx_get ();
+ ctx = glusterfsd_ctx;
GF_ASSERT (ctx);
active = ctx->active;
@@ -841,7 +841,7 @@ glusterfs_handle_brick_status (rpcsvc_request_t *req)
goto out;
}
- ctx = glusterfs_ctx_get ();
+ ctx = glusterfsd_ctx;
GF_ASSERT (ctx);
active = ctx->active;
any = active->first;
@@ -977,7 +977,7 @@ glusterfs_handle_node_status (rpcsvc_request_t *req)
goto out;
}
- ctx = glusterfs_ctx_get ();
+ ctx = glusterfsd_ctx;
GF_ASSERT (ctx);
active = ctx->active;
any = active->first;
@@ -1140,7 +1140,7 @@ glusterfs_handle_nfs_profile (rpcsvc_request_t *req)
goto out;
}
- ctx = glusterfs_ctx_get ();
+ ctx = glusterfsd_ctx;
GF_ASSERT (ctx);
active = ctx->active;
@@ -1482,13 +1482,7 @@ glusterfs_volfile_reconfigure (FILE *newvolfile_fp)
"Only options have changed in the new "
"graph");
- ctx = glusterfs_ctx_get ();
-
- if (!ctx) {
- gf_log ("glusterfsd-mgmt", GF_LOG_ERROR,
- "glusterfs_ctx_get() returned NULL");
- goto out;
- }
+ ctx = glusterfsd_ctx;
oldvolfile_graph = ctx->active;
@@ -1732,7 +1726,7 @@ glusterfs_rebalance_event_notify (dict_t *dict)
cmd_args_t *cmd_args = NULL;
call_frame_t *frame = NULL;
- ctx = glusterfs_ctx_get ();
+ ctx = glusterfsd_ctx;
cmd_args = &ctx->cmd_args;
frame = create_frame (THIS, ctx->pool);
@@ -2068,7 +2062,7 @@ mgmt_pmap_signin_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- ctx = glusterfs_ctx_get ();
+ ctx = glusterfsd_ctx;
cmd_args = &ctx->cmd_args;
if (!cmd_args->brick_port2) {
@@ -2137,7 +2131,7 @@ mgmt_pmap_signout_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- ctx = glusterfs_ctx_get ();
+ ctx = glusterfsd_ctx;
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_pmap_signout_rsp);
if (ret < 0) {
gf_log (THIS->name, GF_LOG_ERROR, "XDR decoding failed");
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index c9c7ad065a5..2b6ee54523b 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -492,7 +492,7 @@ gf_remember_xlator_option (struct list_head *options, char *arg)
char *dot = NULL;
char *equals = NULL;
- ctx = glusterfs_ctx_get ();
+ ctx = glusterfsd_ctx;
cmd_args = &ctx->cmd_args;
option = GF_CALLOC (1, sizeof (xlator_cmdline_option_t),
@@ -560,7 +560,6 @@ out:
static error_t
parse_opts (int key, char *arg, struct argp_state *state)
{
- glusterfs_ctx_t *ctx = NULL;
cmd_args_t *cmd_args = NULL;
uint32_t n = 0;
double d = 0.0;
@@ -833,8 +832,7 @@ parse_opts (int key, char *arg, struct argp_state *state)
case ARGP_MEM_ACCOUNTING_KEY:
/* TODO: it should have got handled much earlier */
- ctx = glusterfs_ctx_get ();
- ctx->mem_accounting = 1;
+ gf_mem_acct_enable_set ();
break;
case ARGP_FOPEN_KEEP_CACHE_KEY:
@@ -859,7 +857,7 @@ cleanup_and_exit (int signum)
glusterfs_ctx_t *ctx = NULL;
xlator_t *trav = NULL;
- ctx = glusterfs_ctx_get ();
+ ctx = glusterfsd_ctx;
if (!ctx)
return;
@@ -918,7 +916,7 @@ reincarnate (int signum)
glusterfs_ctx_t *ctx = NULL;
cmd_args_t *cmd_args = NULL;
- ctx = glusterfs_ctx_get ();
+ ctx = glusterfsd_ctx;
cmd_args = &ctx->cmd_args;
if (cmd_args->volfile_server) {
@@ -1190,12 +1188,12 @@ logging_init (glusterfs_ctx_t *ctx)
}
void
-gf_check_and_set_mem_acct (int argc, char *argv[], glusterfs_ctx_t *ctx)
+gf_check_and_set_mem_acct (int argc, char *argv[])
{
int i = 0;
for (i = 0; i < argc; i++) {
if (strcmp (argv[i], "--mem-accounting") == 0) {
- ctx->mem_accounting = 1;
+ gf_mem_acct_enable_set ();
break;
}
}
@@ -1463,10 +1461,10 @@ glusterfs_sigwaiter (void *arg)
reincarnate (sig);
break;
case SIGUSR1:
- gf_proc_dump_info (sig);
+ gf_proc_dump_info (sig, glusterfsd_ctx);
break;
case SIGUSR2:
- gf_latency_toggle (sig);
+ gf_latency_toggle (sig, glusterfsd_ctx);
break;
default:
@@ -1478,6 +1476,13 @@ glusterfs_sigwaiter (void *arg)
}
+void
+glusterfsd_print_trace (int signum)
+{
+ gf_print_trace (signum, glusterfsd_ctx);
+}
+
+
int
glusterfs_signals_setup (glusterfs_ctx_t *ctx)
{
@@ -1487,12 +1492,12 @@ glusterfs_signals_setup (glusterfs_ctx_t *ctx)
sigemptyset (&set);
/* common setting for all threads */
- signal (SIGSEGV, gf_print_trace);
- signal (SIGABRT, gf_print_trace);
- signal (SIGILL, gf_print_trace);
- signal (SIGTRAP, gf_print_trace);
- signal (SIGFPE, gf_print_trace);
- signal (SIGBUS, gf_print_trace);
+ signal (SIGSEGV, glusterfsd_print_trace);
+ signal (SIGABRT, glusterfsd_print_trace);
+ signal (SIGILL, glusterfsd_print_trace);
+ signal (SIGTRAP, glusterfsd_print_trace);
+ signal (SIGFPE, glusterfsd_print_trace);
+ signal (SIGBUS, glusterfsd_print_trace);
signal (SIGINT, cleanup_and_exit);
signal (SIGPIPE, SIG_IGN);
@@ -1504,7 +1509,7 @@ glusterfs_signals_setup (glusterfs_ctx_t *ctx)
ret = pthread_sigmask (SIG_BLOCK, &set, NULL);
if (ret) {
- gf_log ("", GF_LOG_WARNING,
+ gf_log ("glusterfsd", GF_LOG_WARNING,
"failed to execute pthread_signmask %s",
strerror (errno));
return ret;
@@ -1518,7 +1523,7 @@ glusterfs_signals_setup (glusterfs_ctx_t *ctx)
fallback to signals getting handled by other threads.
setup the signal handlers
*/
- gf_log ("", GF_LOG_WARNING,
+ gf_log ("glusterfsd", GF_LOG_WARNING,
"failed to create pthread %s",
strerror (errno));
return ret;
@@ -1667,6 +1672,9 @@ out:
}
+/* This is the only legal global pointer */
+glusterfs_ctx_t *glusterfsd_ctx;
+
int
main (int argc, char *argv[])
{
@@ -1677,16 +1685,20 @@ main (int argc, char *argv[])
if (ret)
return ret;
- ctx = glusterfs_ctx_get ();
+#ifndef DEBUG
+ /* Enable memory accounting on the fly based on argument */
+ gf_check_and_set_mem_acct (argc, argv);
+#endif
+
+ ctx = glusterfs_ctx_new ();
if (!ctx) {
gf_log ("glusterfs", GF_LOG_CRITICAL,
"ERROR: glusterfs context not initialized");
return ENOMEM;
}
-#ifndef DEBUG
- /* Enable memory accounting on the fly based on argument */
- gf_check_and_set_mem_acct (argc, argv, ctx);
-#endif
+ glusterfsd_ctx = ctx;
+ THIS->ctx = ctx;
+
ret = glusterfs_ctx_defaults_init (ctx);
if (ret)
goto out;
diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h
index 5c00acb5db8..75edff6a633 100644
--- a/glusterfsd/src/glusterfsd.h
+++ b/glusterfsd/src/glusterfsd.h
@@ -109,4 +109,6 @@ void cleanup_and_exit (int signum);
void *glusterfs_volume_top_read_perf (void *args);
void *glusterfs_volume_top_write_perf (void *args);
+
+extern glusterfs_ctx_t *glusterfsd_ctx;
#endif /* __GLUSTERFSD_H__ */