summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2012-07-16 15:50:30 -0700
committerAnand Avati <avati@redhat.com>2012-07-17 23:04:39 -0700
commita4e11fd67e3608c828e5bb8abf7a310b4f0a3017 (patch)
tree184938d2faa7521cc4608e0d9fddc0ebc50ef461
parent06c1d6b2b87e542479e069132ee3cf9efa11384e (diff)
glusterfs_ctx_t: un-globalize the filesystem context
So far there has been a global glusterfs_ctx_t object which represents the running instance of the filesystem (client or server). It contains the various graphs, connection to the management daemon over which new graphs are obtained, calls stacks issued on this filesystem, and a bunch of such things. With the introduction of libgfapi, it is no more true that there will be only one filesystem context in a process. Applications can be written to use libgfapi and obtain serveral instances of different filesystems/volumes in the same process. This involves messy untangling of assumptions inside libglusterfs that there would only be one global glusterfs_ctx_t and offload that assumption to glusterfsd/ and cli/ (where it is true). Change-Id: Ifd7d1259428c26076140a5764a2dc7361694139c BUG: 839950 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.com/3678 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com>
-rw-r--r--cli/src/cli.c3
-rw-r--r--glusterfsd/src/glusterfsd-mgmt.c28
-rw-r--r--glusterfsd/src/glusterfsd.c58
-rw-r--r--glusterfsd/src/glusterfsd.h2
-rw-r--r--libglusterfs/src/Makefile.am2
-rw-r--r--libglusterfs/src/common-utils.c4
-rw-r--r--libglusterfs/src/common-utils.h2
-rw-r--r--libglusterfs/src/ctx.c47
-rw-r--r--libglusterfs/src/globals.c45
-rw-r--r--libglusterfs/src/globals.h7
-rw-r--r--libglusterfs/src/glusterfs.h3
-rw-r--r--libglusterfs/src/latency.c6
-rw-r--r--libglusterfs/src/latency.h3
-rw-r--r--libglusterfs/src/mem-pool.c15
-rw-r--r--libglusterfs/src/statedump.c9
-rw-r--r--libglusterfs/src/statedump.h2
-rw-r--r--libglusterfs/src/xlator.c4
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c10
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-syncop.c2
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c2
20 files changed, 121 insertions, 133 deletions
diff --git a/cli/src/cli.c b/cli/src/cli.c
index 1a2081edc..ccbc88f02 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -552,9 +552,10 @@ main (int argc, char *argv[])
if (ret)
return ret;
- ctx = glusterfs_ctx_get ();
+ ctx = glusterfs_ctx_new ();
if (!ctx)
return ENOMEM;
+ THIS->ctx = ctx;
ret = glusterfs_ctx_defaults_init (ctx);
if (ret)
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
index f37129878..2b7b4aa51 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 c9c7ad065..2b6ee5452 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 5c00acb5d..75edff6a6 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__ */
diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am
index bcfe467af..85e061145 100644
--- a/libglusterfs/src/Makefile.am
+++ b/libglusterfs/src/Makefile.am
@@ -23,7 +23,7 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \
$(CONTRIBDIR)/uuid/uuid_time.c $(CONTRIBDIR)/uuid/compare.c \
$(CONTRIBDIR)/uuid/isnull.c $(CONTRIBDIR)/uuid/unpack.c syncop.c \
graph-print.c trie.c run.c options.c fd-lk.c circ-buff.c \
- event-history.c gidcache.c
+ event-history.c gidcache.c ctx.c
nodist_libglusterfs_la_SOURCES = y.tab.c graph.lex.c
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index cd7045277..e5056b1e8 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -392,8 +392,9 @@ out:
/* Obtain a backtrace and print it to stdout. */
/* TODO: It looks like backtrace_symbols allocates memory,
it may be problem because mostly memory allocation/free causes 'sigsegv' */
+
void
-gf_print_trace (int32_t signum)
+gf_print_trace (int32_t signum, glusterfs_ctx_t *ctx)
{
extern FILE *gf_log_logfile;
char msg[1024] = {0,};
@@ -409,7 +410,6 @@ gf_print_trace (int32_t signum)
goto out;
{
- glusterfs_ctx_t *ctx = glusterfs_ctx_get ();
struct list_head *trav = ((call_pool_t *)ctx->pool)->all_frames.next;
while (trav != (&((call_pool_t *)ctx->pool)->all_frames)) {
call_frame_t *tmp = (call_frame_t *)(&((call_stack_t *)trav)->frames);
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index f21ade40b..7fbaa87a8 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -107,7 +107,7 @@ void gf_global_variable_init(void);
in_addr_t gf_resolve_ip (const char *hostname, void **dnscache);
void gf_log_volume_file (FILE *specfp);
-void gf_print_trace (int32_t signal);
+void gf_print_trace (int32_t signal, glusterfs_ctx_t *ctx);
extern char *gf_fop_list[GF_FOP_MAXVALUE];
extern char *gf_mgmt_list[GF_MGMT_MAXVALUE];
diff --git a/libglusterfs/src/ctx.c b/libglusterfs/src/ctx.c
new file mode 100644
index 000000000..22591317d
--- /dev/null
+++ b/libglusterfs/src/ctx.c
@@ -0,0 +1,47 @@
+/*
+ Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif /* !_CONFIG_H */
+
+#include <pthread.h>
+
+#include "glusterfs.h"
+#include "mem-pool.h"
+
+
+glusterfs_ctx_t *
+glusterfs_ctx_new ()
+{
+ int ret = 0;
+ glusterfs_ctx_t *ctx = NULL;
+
+ /* no GF_CALLOC here, gf_acct_mem_set_enable is not
+ yet decided at this point */
+ ctx = CALLOC (1, sizeof (*ctx));
+ if (!ctx) {
+ ret = -1;
+ goto out;
+ }
+
+ INIT_LIST_HEAD (&ctx->graphs);
+ INIT_LIST_HEAD (&ctx->mempool_list);
+
+ ret = pthread_mutex_init (&ctx->lock, NULL);
+ if (ret) {
+ FREE (ctx);
+ ctx = NULL;
+ }
+out:
+ return ctx;
+}
+
diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c
index 703c5271d..49f118c6a 100644
--- a/libglusterfs/src/globals.c
+++ b/libglusterfs/src/globals.c
@@ -81,43 +81,6 @@ gf_op_list_init()
}
-/* CTX */
-static glusterfs_ctx_t *glusterfs_ctx;
-
-
-int
-glusterfs_ctx_init ()
-{
- int ret = 0;
-
- if (glusterfs_ctx) {
- gf_log_callingfn ("", GF_LOG_WARNING, "init called again");
- goto out;
- }
-
- glusterfs_ctx = CALLOC (1, sizeof (*glusterfs_ctx));
- if (!glusterfs_ctx) {
- ret = -1;
- goto out;
- }
-
- INIT_LIST_HEAD (&glusterfs_ctx->graphs);
- INIT_LIST_HEAD (&glusterfs_ctx->mempool_list);
- ret = pthread_mutex_init (&glusterfs_ctx->lock, NULL);
-
-out:
- return ret;
-}
-
-
-glusterfs_ctx_t *
-glusterfs_ctx_get ()
-{
- return glusterfs_ctx;
-
-}
-
-
/* THIS */
xlator_t global_xlator;
@@ -143,7 +106,6 @@ glusterfs_this_init ()
global_xlator.name = "glusterfs";
global_xlator.type = "global";
- global_xlator.ctx = glusterfs_ctx;
INIT_LIST_HEAD (&global_xlator.volume_options);
@@ -327,13 +289,6 @@ glusterfs_globals_init ()
gf_log_globals_init ();
- ret = glusterfs_ctx_init ();
- if (ret) {
- gf_log ("", GF_LOG_CRITICAL,
- "ERROR: glusterfs context init failed");
- goto out;
- }
-
ret = glusterfs_this_init ();
if (ret) {
gf_log ("", GF_LOG_CRITICAL,
diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h
index e797db184..7ccdb4a14 100644
--- a/libglusterfs/src/globals.h
+++ b/libglusterfs/src/globals.h
@@ -13,13 +13,6 @@
#define GF_DEFAULT_BASE_PORT 24007
-#include "glusterfs.h"
-
-/* CTX */
-#define CTX (glusterfs_ctx_get())
-
-glusterfs_ctx_t *glusterfs_ctx_get ();
-
#include "xlator.h"
/* THIS */
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 7e2c81356..d14666fb6 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -369,13 +369,12 @@ struct _glusterfs_ctx {
struct mem_pool *dict_pair_pool;
struct mem_pool *dict_data_pool;
- int mem_accounting; /* if value is other than 0, it
- will be set */
glusterfsd_mgmt_event_notify_fn_t notify; /* Used for xlators to make
call to fsd-mgmt */
};
typedef struct _glusterfs_ctx glusterfs_ctx_t;
+glusterfs_ctx_t *glusterfs_ctx_new (void);
/* If you edit this structure then, make a corresponding change in
* globals.c in the eventstring.
diff --git a/libglusterfs/src/latency.c b/libglusterfs/src/latency.c
index 58e8b9158..f7747b392 100644
--- a/libglusterfs/src/latency.c
+++ b/libglusterfs/src/latency.c
@@ -159,12 +159,8 @@ gf_proc_dump_latency_info (xlator_t *xl)
void
-gf_latency_toggle (int signum)
+gf_latency_toggle (int signum, glusterfs_ctx_t *ctx)
{
- glusterfs_ctx_t *ctx = NULL;
-
- ctx = glusterfs_ctx_get ();
-
if (ctx) {
ctx->measure_latency = !ctx->measure_latency;
gf_log ("[core]", GF_LOG_INFO,
diff --git a/libglusterfs/src/latency.h b/libglusterfs/src/latency.h
index 16c5994b0..81acbf484 100644
--- a/libglusterfs/src/latency.h
+++ b/libglusterfs/src/latency.h
@@ -11,6 +11,7 @@
#ifndef __LATENCY_H__
#define __LATENCY_H__
+#include "glusterfs.h"
typedef struct fop_latency {
uint64_t min; /* min time for the call (microseconds) */
@@ -22,6 +23,6 @@ typedef struct fop_latency {
} fop_latency_t;
void
-gf_latency_toggle (int signum);
+gf_latency_toggle (int signum, glusterfs_ctx_t *ctx);
#endif /* __LATENCY_H__ */
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index 3e8100c64..2df47756f 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -38,23 +38,14 @@ gf_mem_acct_is_enabled ()
return gf_mem_acct_enable;
}
+
void
gf_mem_acct_enable_set ()
{
-#ifdef DEBUG
- gf_mem_acct_enable = 1;
- return;
-#endif
- glusterfs_ctx_t *ctx = NULL;
char *opt = NULL;
long val = -1;
- gf_mem_acct_enable = 0;
-
- ctx = glusterfs_ctx_get ();
-
- if (ctx->mem_accounting) {
- gf_mem_acct_enable = 1;
+ if (gf_mem_acct_enable) {
return;
}
@@ -365,7 +356,7 @@ mem_pool_new_fn (unsigned long sizeof_type,
mem_pool->pool_end = pool + (count * (padded_sizeof_type));
/* add this pool to the global list */
- ctx = glusterfs_ctx_get ();
+ ctx = THIS->ctx;
if (!ctx)
goto out;
diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c
index 694146874..1abd603ad 100644
--- a/libglusterfs/src/statedump.c
+++ b/libglusterfs/src/statedump.c
@@ -381,7 +381,7 @@ gf_proc_dump_xlator_info (xlator_t *top)
if (!top)
return;
- ctx = glusterfs_ctx_get ();
+ ctx = top->ctx;
trav = top;
while (trav) {
@@ -436,7 +436,7 @@ gf_proc_dump_oldgraph_xlator_info (xlator_t *top)
if (!top)
return;
- ctx = glusterfs_ctx_get ();
+ ctx = top->ctx;
trav = top;
while (trav) {
@@ -614,18 +614,17 @@ gf_proc_dump_options_init ()
return 0;
}
+
void
-gf_proc_dump_info (int signum)
+gf_proc_dump_info (int signum, glusterfs_ctx_t *ctx)
{
int i = 0;
int ret = -1;
- glusterfs_ctx_t *ctx = NULL;
glusterfs_graph_t *trav = NULL;
char brick_name[PATH_MAX] = {0,};
gf_proc_dump_lock ();
- ctx = glusterfs_ctx_get ();
if (!ctx)
goto out;
diff --git a/libglusterfs/src/statedump.h b/libglusterfs/src/statedump.h
index dc56bda0c..03648ddd9 100644
--- a/libglusterfs/src/statedump.h
+++ b/libglusterfs/src/statedump.h
@@ -61,7 +61,7 @@ void gf_proc_dump_fini(void);
void gf_proc_dump_cleanup(void);
-void gf_proc_dump_info(int signum);
+void gf_proc_dump_info(int signum, glusterfs_ctx_t *ctx);
int gf_proc_dump_add_section(char *key,...);
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index 2bac24f04..7094f1ef5 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -460,7 +460,7 @@ xlator_mem_acct_init (xlator_t *xl, int num_types)
int i = 0;
int ret = 0;
- if (!gf_mem_acct_is_enabled())
+ if (!gf_mem_acct_is_enabled ())
return 0;
if (!xl)
@@ -721,7 +721,7 @@ is_gf_log_command (xlator_t *this, const char *name, char *value)
goto out;
}
- ctx = glusterfs_ctx_get();
+ ctx = this->ctx;
if (!ctx)
goto out;
if (!ctx->active)
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index e33875ffc..8f2f0adb2 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -944,14 +944,13 @@ dht_start_rebalance_task (xlator_t *this, call_frame_t *frame)
}
int
-gf_listener_stop (void)
+gf_listener_stop (xlator_t *this)
{
glusterfs_ctx_t *ctx = NULL;
cmd_args_t *cmd_args = NULL;
int ret = 0;
- xlator_t *this = NULL;
- ctx = glusterfs_ctx_get ();
+ ctx = this->ctx;
GF_ASSERT (ctx);
cmd_args = &ctx->cmd_args;
if (cmd_args->sock_file) {
@@ -962,7 +961,6 @@ gf_listener_stop (void)
}
if (ret) {
- this = THIS;
gf_log (this->name, GF_LOG_ERROR, "Failed to unlink listener "
"socket %s, error: %s", cmd_args->sock_file,
strerror (errno));
@@ -1431,7 +1429,7 @@ gf_defrag_start_crawl (void *data)
if (!this)
goto out;
- ctx = glusterfs_ctx_get ();
+ ctx = this->ctx;
if (!ctx)
goto out;
@@ -1528,7 +1526,7 @@ out:
static int
gf_defrag_done (int ret, call_frame_t *sync_frame, void *data)
{
- gf_listener_stop();
+ gf_listener_stop (sync_frame->this);
STACK_DESTROY (sync_frame->root);
kill (getpid(), SIGTERM);
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c
index 629829283..bc265de67 100644
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c
@@ -578,7 +578,7 @@ glusterd_op_begin_synctask (rpcsvc_request_t *req, glusterd_op_t op,
goto out;
}
- ctx = glusterfs_ctx_get ();
+ ctx = THIS->ctx;
ret = synctask_new (ctx->env, gd_sync_task_begin,
gd_sync_task_completion,
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index 3a620ac7e..d65de5f69 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -4447,7 +4447,7 @@ init (xlator_t *this_xl)
if (this_xl->options == NULL)
return -1;
- ctx = glusterfs_ctx_get ();
+ ctx = this_xl->ctx;
if (!ctx)
return -1;