summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2015-06-27 11:04:25 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-08-12 23:12:50 -0700
commitf7668938cd7745d024f3d2884e04cd744d0a69ab (patch)
treed93c18c1363ea5579891d5bc40420ef7191b8498 /rpc
parent546f66f546a9c9f63c4ee7d3f28fc3a494305263 (diff)
rpc: add owner xlator argument to rpc_clnt_new
The @owner argument tells RPC layer the xlator that owns the connection and to which xlator THIS needs be set during network notifications like CONNECT and DISCONNECT. Code paths that originate from the head of a (volume) graph and use STACK_WIND ensure that the RPC local endpoint has the right xlator saved in the frame of the call (callback pair). This guarantees that the callback is executed in the right xlator context. The client handshake process which includes fetching of brick ports from glusterd, setting lk-version on the brick for the session, don't have the correct xlator set in their frames. The problem lies with RPC notifications. It doesn't have the provision to set THIS with the xlator that is registered with the corresponding RPC programs. e.g, RPC_CLNT_CONNECT event received by protocol/client doesn't have THIS set to its xlator. This implies, call(-callbacks) originating from this thread don't have the right xlator set too. The fix would be to save the xlator registered with the RPC connection during rpc_clnt_new. e.g, protocol/client's xlator would be saved with the RPC connection that it 'owns'. RPC notifications such as CONNECT, DISCONNECT, etc inherit THIS from the RPC connection's xlator. Change-Id: I9dea2c35378c511d800ef58f7fa2ea5552f2c409 BUG: 1235582 Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/11436 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'rpc')
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.c19
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.h4
2 files changed, 21 insertions, 2 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index 7bc9010f0b9..11d6cedfe07 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -810,6 +810,16 @@ out:
static void
rpc_clnt_destroy (struct rpc_clnt *rpc);
+#define RPC_THIS_SAVE(xl) do { \
+ old_THIS = THIS ; \
+ if (!old_THIS) \
+ gf_log_callingfn ("rpc", GF_LOG_CRITICAL, \
+ "THIS is not initialised."); \
+ THIS = xl; \
+} while (0)
+
+#define RPC_THIS_RESTORE (THIS = old_THIS)
+
int
rpc_clnt_notify (rpc_transport_t *trans, void *mydata,
rpc_transport_event_t event, void *data, ...)
@@ -821,6 +831,7 @@ rpc_clnt_notify (rpc_transport_t *trans, void *mydata,
rpc_transport_pollin_t *pollin = NULL;
struct timespec ts = {0, };
void *clnt_mydata = NULL;
+ DECLARE_OLD_THIS;
conn = mydata;
if (conn == NULL) {
@@ -830,6 +841,8 @@ rpc_clnt_notify (rpc_transport_t *trans, void *mydata,
if (!clnt)
goto out;
+ RPC_THIS_SAVE (clnt->owner);
+
switch (event) {
case RPC_TRANSPORT_DISCONNECT:
{
@@ -930,6 +943,7 @@ rpc_clnt_notify (rpc_transport_t *trans, void *mydata,
}
out:
+ RPC_THIS_RESTORE;
return ret;
}
@@ -1034,11 +1048,13 @@ out:
}
struct rpc_clnt *
-rpc_clnt_new (dict_t *options, glusterfs_ctx_t *ctx, char *name,
+rpc_clnt_new (dict_t *options, xlator_t *owner, char *name,
uint32_t reqpool_size)
{
int ret = -1;
struct rpc_clnt *rpc = NULL;
+ glusterfs_ctx_t *ctx = owner->ctx;
+
rpc = GF_CALLOC (1, sizeof (*rpc), gf_common_mt_rpcclnt_t);
if (!rpc) {
@@ -1047,6 +1063,7 @@ rpc_clnt_new (dict_t *options, glusterfs_ctx_t *ctx, char *name,
pthread_mutex_init (&rpc->lock, NULL);
rpc->ctx = ctx;
+ rpc->owner = owner;
if (!reqpool_size)
reqpool_size = RPC_CLNT_DEFAULT_REQUEST_COUNT;
diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h
index ee46a9a9263..6a4bb40793f 100644
--- a/rpc/rpc-lib/src/rpc-clnt.h
+++ b/rpc/rpc-lib/src/rpc-clnt.h
@@ -188,9 +188,11 @@ typedef struct rpc_clnt {
int refcount;
int auth_null;
char disabled;
+ xlator_t *owner;
} rpc_clnt_t;
-struct rpc_clnt *rpc_clnt_new (dict_t *options, glusterfs_ctx_t *ctx,
+
+struct rpc_clnt *rpc_clnt_new (dict_t *options, xlator_t *owner,
char *name, uint32_t reqpool_size);
int rpc_clnt_start (struct rpc_clnt *rpc);