From a4e11fd67e3608c828e5bb8abf7a310b4f0a3017 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Mon, 16 Jul 2012 15:50:30 -0700 Subject: 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 Reviewed-on: http://review.gluster.com/3678 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi --- glusterfsd/src/glusterfsd-mgmt.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'glusterfsd/src/glusterfsd-mgmt.c') 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"); -- cgit