diff options
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.c | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.h | 1 | ||||
-rw-r--r-- | xlators/protocol/client/src/client-handshake.c | 262 | ||||
-rw-r--r-- | xlators/protocol/client/src/client-rpc-fops.c | 18 | ||||
-rw-r--r-- | xlators/protocol/client/src/client.c | 15 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-handshake.c | 1 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-rpc-fops.c | 1 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.h | 2 |
9 files changed, 12 insertions, 296 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index c840803fbf0..0a43fd69ae5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -4260,6 +4260,7 @@ __glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata, switch (event) { case RPC_CLNT_CONNECT: { + rpc_clnt_set_connected (&rpc->conn); gf_log (this->name, GF_LOG_DEBUG, "got RPC_CLNT_CONNECT"); peerinfo->connected = 1; peerinfo->quorum_action = _gf_true; @@ -4272,6 +4273,7 @@ __glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata, case RPC_CLNT_DISCONNECT: { + rpc_clnt_unset_connected (&rpc->conn); gf_log (this->name, GF_LOG_DEBUG, "got RPC_CLNT_DISCONNECT %d", peerinfo->state.state); diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index 1a6aa81d30c..691d410cd44 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -1648,5 +1648,11 @@ struct volume_options options[] = { .type = GF_OPTION_TYPE_STR, .description = "directory where the bricks for the snapshots will be created" }, + { .key = {"ping-timeout"}, + .type = GF_OPTION_TYPE_INT, + .min = 1, + .max = 100, + .default_value = "30", + }, { .key = {NULL} }, }; diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index 9e3eb417929..cbcaecd919d 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -179,6 +179,7 @@ typedef struct { char *snap_bricks_directory; gf_store_handle_t *missed_snaps_list_shandle; struct list_head missed_snaps_list; + int ping_timeout; } glusterd_conf_t; diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index 85b0f757bf4..cf91c3b723c 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -29,9 +29,6 @@ extern rpc_clnt_prog_t clnt3_3_fop_prog; extern rpc_clnt_prog_t clnt_pmap_prog; -int client_ping_cbk (struct rpc_req *req, struct iovec *iov, int count, - void *myframe); - int client_set_lk_version_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe); @@ -44,265 +41,6 @@ typedef struct client_fd_lk_local { clnt_fd_ctx_t *fdctx; }clnt_fd_lk_local_t; -/* Handshake */ - -void -rpc_client_ping_timer_expired (void *data) -{ - rpc_transport_t *trans = NULL; - rpc_clnt_connection_t *conn = NULL; - int disconnect = 0; - int transport_activity = 0; - struct timespec timeout = {0, }; - struct timeval current = {0, }; - struct rpc_clnt *clnt = NULL; - xlator_t *this = NULL; - clnt_conf_t *conf = NULL; - - this = data; - - if (!this || !this->private) { - gf_log (THIS->name, GF_LOG_WARNING, "xlator initialization not done"); - goto out; - } - - conf = this->private; - - clnt = conf->rpc; - if (!clnt) { - gf_log (this->name, GF_LOG_WARNING, "rpc not initialized"); - goto out; - } - - conn = &clnt->conn; - trans = conn->trans; - - if (!trans) { - gf_log (this->name, GF_LOG_WARNING, "transport not initialized"); - goto out; - } - - pthread_mutex_lock (&conn->lock); - { - if (conn->ping_timer) - gf_timer_call_cancel (this->ctx, - conn->ping_timer); - gettimeofday (¤t, NULL); - - if (((current.tv_sec - conn->last_received.tv_sec) < - conf->opt.ping_timeout) - || ((current.tv_sec - conn->last_sent.tv_sec) < - conf->opt.ping_timeout)) { - transport_activity = 1; - } - - if (transport_activity) { - gf_log (trans->name, GF_LOG_TRACE, - "ping timer expired but transport activity " - "detected - not bailing transport"); - timeout.tv_sec = conf->opt.ping_timeout; - timeout.tv_nsec = 0; - - conn->ping_timer = - gf_timer_call_after (this->ctx, timeout, - rpc_client_ping_timer_expired, - (void *) this); - if (conn->ping_timer == NULL) - gf_log (trans->name, GF_LOG_WARNING, - "unable to setup ping timer"); - - } else { - conn->ping_started = 0; - conn->ping_timer = NULL; - disconnect = 1; - } - } - pthread_mutex_unlock (&conn->lock); - - if (disconnect) { - gf_log (trans->name, GF_LOG_CRITICAL, - "server %s has not responded in the last %d " - "seconds, disconnecting.", - conn->trans->peerinfo.identifier, - conf->opt.ping_timeout); - - rpc_transport_disconnect (conn->trans); - } - -out: - return; -} - -void -client_start_ping (void *data) -{ - xlator_t *this = NULL; - clnt_conf_t *conf = NULL; - rpc_clnt_connection_t *conn = NULL; - int32_t ret = -1; - struct timespec timeout = {0, }; - call_frame_t *frame = NULL; - int frame_count = 0; - - this = data; - if (!this || !this->private) { - gf_log (THIS->name, GF_LOG_WARNING, "xlator not initialized"); - goto fail; - } - - conf = this->private; - if (!conf->rpc) { - gf_log (this->name, GF_LOG_WARNING, "rpc not initialized"); - goto fail; - } - conn = &conf->rpc->conn; - - if (conf->opt.ping_timeout == 0) { - gf_log (this->name, GF_LOG_INFO, "ping timeout is 0, returning"); - return; - } - - pthread_mutex_lock (&conn->lock); - { - if (conn->ping_timer) - gf_timer_call_cancel (this->ctx, conn->ping_timer); - - conn->ping_timer = NULL; - conn->ping_started = 0; - - if (conn->saved_frames) - /* treat the case where conn->saved_frames is NULL - as no pending frames */ - frame_count = conn->saved_frames->count; - - if ((frame_count == 0) || !conn->connected) { - /* using goto looked ugly here, - * hence getting out this way */ - /* unlock */ - gf_log (this->name, GF_LOG_DEBUG, - "returning as transport is already disconnected" - " OR there are no frames (%d || %d)", - frame_count, !conn->connected); - - pthread_mutex_unlock (&conn->lock); - return; - } - - if (frame_count < 0) { - gf_log (this->name, GF_LOG_WARNING, - "saved_frames->count is %"PRId64, - conn->saved_frames->count); - conn->saved_frames->count = 0; - } - - timeout.tv_sec = conf->opt.ping_timeout; - timeout.tv_nsec = 0; - - conn->ping_timer = - gf_timer_call_after (this->ctx, timeout, - rpc_client_ping_timer_expired, - (void *) this); - - if (conn->ping_timer == NULL) { - gf_log (this->name, GF_LOG_WARNING, - "unable to setup ping timer"); - } else { - conn->ping_started = 1; - } - } - pthread_mutex_unlock (&conn->lock); - - frame = create_frame (this, this->ctx->pool); - if (!frame) - goto fail; - - ret = client_submit_request (this, NULL, frame, conf->handshake, - GF_HNDSK_PING, client_ping_cbk, NULL, - NULL, 0, NULL, 0, NULL, (xdrproc_t)NULL); - if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, - "failed to start ping timer"); - } - - return; - -fail: - if (frame) { - STACK_DESTROY (frame->root); - } - - return; -} - - -int -client_ping_cbk (struct rpc_req *req, struct iovec *iov, int count, - void *myframe) -{ - xlator_t *this = NULL; - rpc_clnt_connection_t *conn = NULL; - struct timespec timeout = {0, }; - call_frame_t *frame = NULL; - clnt_conf_t *conf = NULL; - - if (!myframe) { - gf_log (THIS->name, GF_LOG_WARNING, - "frame with the request is NULL"); - goto out; - } - frame = myframe; - this = frame->this; - if (!this || !this->private) { - gf_log (THIS->name, GF_LOG_WARNING, - "xlator private is not set"); - goto out; - } - - conf = this->private; - conn = &conf->rpc->conn; - - pthread_mutex_lock (&conn->lock); - { - if (req->rpc_status == -1) { - if (conn->ping_timer != NULL) { - gf_log (this->name, GF_LOG_WARNING, - "socket or ib related error"); - gf_timer_call_cancel (this->ctx, - conn->ping_timer); - conn->ping_timer = NULL; - } else { - /* timer expired and transport bailed out */ - gf_log (this->name, GF_LOG_WARNING, - "timer must have expired"); - } - - goto unlock; - } - - - timeout.tv_sec = conf->opt.ping_timeout; - timeout.tv_nsec = 0; - - gf_timer_call_cancel (this->ctx, - conn->ping_timer); - - conn->ping_timer = - gf_timer_call_after (this->ctx, timeout, - client_start_ping, (void *)this); - - if (conn->ping_timer == NULL) - gf_log (this->name, GF_LOG_WARNING, - "failed to set the ping timer"); - } -unlock: - pthread_mutex_unlock (&conn->lock); -out: - if (frame) - STACK_DESTROY (frame->root); - return 0; -} - - int client3_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index 99a6f6d7492..e77da7a27d6 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -14,12 +14,12 @@ #endif #include "client.h" +#include "rpc-common-xdr.h" #include "glusterfs3-xdr.h" #include "glusterfs3.h" #include "compat-errno.h" int32_t client3_getspec (call_frame_t *frame, xlator_t *this, void *data); -void client_start_ping (void *data); rpc_clnt_prog_t clnt3_3_fop_prog; @@ -35,13 +35,10 @@ client_submit_vec_request (xlator_t *this, void *req, call_frame_t *frame, struct iovec iov = {0, }; struct iobuf *iobuf = NULL; int count = 0; - int start_ping = 0; struct iobref *new_iobref = NULL; ssize_t xdr_size = 0; struct rpc_req rpcreq = {0, }; - start_ping = 0; - conf = this->private; if (req && xdrproc) { @@ -95,19 +92,6 @@ client_submit_vec_request (xlator_t *this, void *req, call_frame_t *frame, gf_log (this->name, GF_LOG_DEBUG, "rpc_clnt_submit failed"); } - if (ret == 0) { - pthread_mutex_lock (&conf->rpc->conn.lock); - { - if (!conf->rpc->conn.ping_started) { - start_ping = 1; - } - } - pthread_mutex_unlock (&conf->rpc->conn.lock); - } - - if (start_ping) - client_start_ping ((void *) this); - if (new_iobref) iobref_unref (new_iobref); diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index 98fb10c34eb..7726c0b8445 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -29,7 +29,6 @@ extern rpc_clnt_prog_t clnt_dump_prog; extern struct rpcclnt_cb_program gluster_cbk_prog; int client_handshake (xlator_t *this, struct rpc_clnt *rpc); -void client_start_ping (void *data); int client_init_rpc (xlator_t *this); int client_destroy_rpc (xlator_t *this); int client_mark_fd_bad (xlator_t *this); @@ -156,7 +155,6 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame, struct iovec iov = {0, }; struct iobuf *iobuf = NULL; int count = 0; - char start_ping = 0; struct iobref *new_iobref = NULL; ssize_t xdr_size = 0; struct rpc_req rpcreq = {0, }; @@ -235,19 +233,6 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame, gf_log (this->name, GF_LOG_DEBUG, "rpc_clnt_submit failed"); } - if (ret == 0) { - pthread_mutex_lock (&conf->rpc->conn.lock); - { - if (!conf->rpc->conn.ping_started) { - start_ping = 1; - } - } - pthread_mutex_unlock (&conf->rpc->conn.lock); - } - - if (start_ping) - client_start_ping ((void *) this); - ret = 0; if (new_iobref) diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index a459f89e182..f3ae96ef2ae 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -16,6 +16,7 @@ #include "server.h" #include "server-helpers.h" +#include "rpc-common-xdr.h" #include "glusterfs3-xdr.h" #include "compat-errno.h" #include "glusterfs3.h" diff --git a/xlators/protocol/server/src/server-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c index ebe62ae7c42..ce844197d90 100644 --- a/xlators/protocol/server/src/server-rpc-fops.c +++ b/xlators/protocol/server/src/server-rpc-fops.c @@ -18,6 +18,7 @@ #include "server.h" #include "server-helpers.h" +#include "rpc-common-xdr.h" #include "glusterfs3-xdr.h" #include "glusterfs3.h" #include "compat-errno.h" diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h index 782327d775b..c5ab579140d 100644 --- a/xlators/protocol/server/src/server.h +++ b/xlators/protocol/server/src/server.h @@ -174,8 +174,6 @@ struct _server_state { extern struct rpcsvc_program gluster_handshake_prog; extern struct rpcsvc_program glusterfs3_3_fop_prog; -extern struct rpcsvc_program gluster_ping_prog; - typedef struct _server_ctx { gf_lock_t fdtable_lock; |