diff options
Diffstat (limited to 'glusterfsd')
| -rw-r--r-- | glusterfsd/src/glusterfsd-mgmt.c | 77 | ||||
| -rw-r--r-- | glusterfsd/src/glusterfsd.c | 10 | ||||
| -rw-r--r-- | glusterfsd/src/glusterfsd.h | 2 |
3 files changed, 58 insertions, 31 deletions
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index c47fa3883c9..a7c96d1e7a0 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -1903,9 +1903,14 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, switch (event) { case RPC_CLNT_DISCONNECT: - GF_LOG_OCCASIONALLY (log_ctr1, "glusterfsd-mgmt", GF_LOG_ERROR, - "failed to connect with remote-host: %s (%s)", - ctx->cmd_args.volfile_server, strerror (errno)); + ctx->cmd_args.connect_attempts++; + + gf_log ("glusterfsd-mgmt", GF_LOG_ERROR, + "Connect attempt with remote-host: %s (%s) (%u/%d)", + ctx->cmd_args.volfile_server, + strerror (errno), + ctx->cmd_args.connect_attempts, + ctx->cmd_args.max_connect_attempts); if (!rpc->disabled) { /* * Check if dnscache is exhausted for current server @@ -1916,8 +1921,14 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, break; } } + + /* If we run out of servers, AND we attempted to connect + * max connect times, then we should return ENOTCONN + */ server = ctx->cmd_args.curr_server; - if (server->list.next == &ctx->cmd_args.volfile_servers) { + if ((ctx->cmd_args.connect_attempts >= + ctx->cmd_args.max_connect_attempts) && + server->list.next == &ctx->cmd_args.volfile_servers) { if (!ctx->active) need_term = 1; emval = ENOTCONN; @@ -1926,24 +1937,33 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, "Exhausted all volfile servers"); break; } - server = list_entry (server->list.next, typeof(*server), list); - ctx->cmd_args.curr_server = server; - ctx->cmd_args.volfile_server = server->volfile_server; - - ret = dict_set_str (rpc_trans->options, "remote-host", - server->volfile_server); - if (ret != 0) { - gf_log ("glusterfsd-mgmt", GF_LOG_ERROR, - "failed to set remote-host: %s", + + /* If we exceed the # of connect attempts, we should + * move onto the next server + */ + if (ctx->cmd_args.connect_attempts >= + ctx->cmd_args.max_connect_attempts || !server) { + server = list_entry (server->list.next, + typeof(*server), list); + ctx->cmd_args.curr_server = server; + ctx->cmd_args.volfile_server = server->volfile_server; + + ret = dict_set_str (rpc_trans->options, "remote-host", + server->volfile_server); + if (ret != 0) { + gf_log ("glusterfsd-mgmt", GF_LOG_ERROR, + "failed to set remote-host: %s", + server->volfile_server); + if (!ctx->active) + need_term = 1; + emval = ENOTCONN; + break; + } + ctx->cmd_args.connect_attempts = 0; + gf_log ("glusterfsd-mgmt", GF_LOG_INFO, + "connecting to next volfile server %s", server->volfile_server); - if (!ctx->active) - need_term = 1; - emval = ENOTCONN; - break; } - gf_log ("glusterfsd-mgmt", GF_LOG_INFO, - "connecting to next volfile server %s", - server->volfile_server); break; case RPC_CLNT_CONNECT: rpc_clnt_set_connected (&((struct rpc_clnt*)ctx->mgmt)->conn); @@ -1960,7 +1980,7 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, } } - + ctx->cmd_args.connect_attempts = 0; if (is_mgmt_rpc_reconnect) glusterfs_mgmt_pmap_signin (ctx); @@ -2120,6 +2140,7 @@ glusterfs_mgmt_init (glusterfs_ctx_t *ctx) int ret = -1; int port = GF_DEFAULT_BASE_PORT; char *host = NULL; + char *addr_family = NULL; cmd_args = &ctx->cmd_args; GF_VALIDATE_OR_GOTO (THIS->name, cmd_args->volfile_server, out); @@ -2136,7 +2157,19 @@ glusterfs_mgmt_init (glusterfs_ctx_t *ctx) !strcmp (cmd_args->volfile_server_transport, "unix")) { ret = rpc_transport_unix_options_build (&options, host, 0); } else { - ret = rpc_transport_inet_options_build (&options, host, port); + xlator_cmdline_option_t *cmd_option = NULL; + + list_for_each_entry (cmd_option, + &cmd_args->xlator_options, cmd_args) { + if (!strcmp(cmd_option->key, + "transport.address-family")) { + addr_family = cmd_option->value; + break; + } + } + + ret = rpc_transport_inet_options_build (&options, host, port, + addr_family); } if (ret) goto out; diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 6c7a7c883fa..5022cfc22da 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -986,7 +986,7 @@ parse_opts (int key, char *arg, struct argp_state *state) cmd_args->debug_mode = ENABLE_DEBUG_MODE; break; case ARGP_VOLFILE_MAX_FETCH_ATTEMPTS: - cmd_args->max_connect_attempts = 1; + cmd_args->max_connect_attempts = DEFAULT_MAX_CONNECT_ATTEMPTS; break; case ARGP_DIRECT_IO_MODE_KEY: @@ -1955,13 +1955,7 @@ parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx) } } - /* - This option was made obsolete but parsing it for backward - compatibility with third party applications - */ - if (cmd_args->max_connect_attempts) { - gf_msg ("glusterfs", GF_LOG_WARNING, 0, glusterfsd_msg_33); - } + cmd_args->max_connect_attempts = DEFAULT_MAX_CONNECT_ATTEMPTS; #ifdef GF_DARWIN_HOST_OS if (cmd_args->mount_point) diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h index e442bede5db..b5c6b27b534 100644 --- a/glusterfsd/src/glusterfsd.h +++ b/glusterfsd/src/glusterfsd.h @@ -16,7 +16,7 @@ #define DEFAULT_GLUSTERD_VOLFILE CONFDIR "/glusterd.vol" #define DEFAULT_CLIENT_VOLFILE CONFDIR "/glusterfs.vol" #define DEFAULT_SERVER_VOLFILE CONFDIR "/glusterfsd.vol" - +#define DEFAULT_MAX_CONNECT_ATTEMPTS 200 #define DEFAULT_EVENT_POOL_SIZE 16384 #define ARGP_LOG_LEVEL_NONE_OPTION "NONE" |
