diff options
Diffstat (limited to 'xlators/protocol/server/src/server.c')
| -rw-r--r-- | xlators/protocol/server/src/server.c | 340 |
1 files changed, 191 insertions, 149 deletions
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index 77e5d74e7c5..721968004a0 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -14,15 +14,14 @@ #include "server.h" #include "server-helpers.h" #include "glusterfs3-xdr.h" -#include "call-stub.h" -#include "statedump.h" -#include "defaults.h" +#include <glusterfs/call-stub.h> +#include <glusterfs/statedump.h> +#include <glusterfs/defaults.h> #include "authenticate.h" -#include "gf-event.h" -#include "events.h" +#include <glusterfs/gf-event.h> +#include <glusterfs/events.h> #include "server-messages.h" #include "rpc-clnt.h" -#include "glusterfsd.h" rpcsvc_cbk_program_t server_cbk_prog = { .progname = "Gluster Callback", @@ -109,8 +108,7 @@ server_submit_reply(call_frame_t *frame, rpcsvc_request_t *req, void *arg, iob = gfs_serialize_reply(req, arg, &rsp, xdrproc); if (!iob) { - gf_msg("", GF_LOG_ERROR, 0, PS_MSG_SERIALIZE_REPLY_FAILED, - "Failed to serialize reply"); + gf_smsg("", GF_LOG_ERROR, 0, PS_MSG_SERIALIZE_REPLY_FAILED, NULL); goto ret; } @@ -169,6 +167,7 @@ server_priv_to_dict(xlator_t *this, dict_t *dict, char *brickname) char key[32] = { 0, }; + int keylen; int count = 0; int ret = -1; @@ -188,8 +187,8 @@ server_priv_to_dict(xlator_t *this, dict_t *dict, char *brickname) (xprt->xl_private->bound_xl->name) && (brickname) && (!strcmp(brickname, xprt->xl_private->bound_xl->name))) { peerinfo = &xprt->peerinfo; - snprintf(key, sizeof(key), "client%d.hostname", count); - ret = dict_set_str(dict, key, peerinfo->identifier); + keylen = snprintf(key, sizeof(key), "client%d.hostname", count); + ret = dict_set_strn(dict, key, keylen, peerinfo->identifier); if (ret) goto unlock; @@ -208,8 +207,9 @@ server_priv_to_dict(xlator_t *this, dict_t *dict, char *brickname) if (ret) goto unlock; - snprintf(key, sizeof(key), "client%d.name", count); - ret = dict_set_str(dict, key, xprt->xl_private->client_name); + keylen = snprintf(key, sizeof(key), "client%d.name", count); + ret = dict_set_strn(dict, key, keylen, + xprt->xl_private->client_name); if (ret) goto unlock; @@ -222,7 +222,7 @@ unlock: if (ret) goto out; - ret = dict_set_int32(dict, "clientcount", count); + ret = dict_set_int32_sizen(dict, "clientcount", count); out: return ret; @@ -267,6 +267,8 @@ server_priv(xlator_t *this) gf_proc_dump_build_key(key, "server", "total-bytes-write"); gf_proc_dump_write(key, "%" PRIu64, total_write); + rpcsvc_statedump(conf->rpc); + ret = 0; out: if (ret) @@ -302,8 +304,7 @@ get_auth_types(dict_t *this, char *key, data_t *value, void *data) /* TODO: backward compatibility, remove when newer versions are available */ tmp = "addr"; - gf_msg("server", GF_LOG_WARNING, 0, PS_MSG_AUTH_IP_ERROR, - "assuming 'auth.ip' to be 'auth.addr'"); + gf_smsg("server", GF_LOG_WARNING, 0, PS_MSG_AUTH_IP_ERROR, NULL); } ret = dict_set_dynptr(auth_dict, tmp, NULL, 0); if (ret < 0) { @@ -332,8 +333,8 @@ _check_for_auth_option(dict_t *d, char *k, data_t *v, void *tmp) goto out; if (strncmp(tail, "addr.", 5) != 0) { - gf_msg(xl->name, GF_LOG_TRACE, 0, PS_MSG_SKIP_FORMAT_CHK, - "skip format check for non-addr auth option %s", k); + gf_smsg(xl->name, GF_LOG_TRACE, 0, PS_MSG_SKIP_FORMAT_CHK, "option=%s", + k, NULL); goto out; } @@ -355,10 +356,8 @@ _check_for_auth_option(dict_t *d, char *k, data_t *v, void *tmp) ret = xlator_option_validate_addr_list(xl, "auth-*", v->data, NULL, NULL); if (ret) - gf_msg(xl->name, GF_LOG_ERROR, 0, PS_MSG_INTERNET_ADDR_ERROR, - "internet address '%s' does not conform " - "to standards.", - v->data); + gf_smsg(xl->name, GF_LOG_ERROR, 0, PS_MSG_INTERNET_ADDR_ERROR, + "data=%s", v->data, NULL); } out: return ret; @@ -378,11 +377,8 @@ validate_auth_options(xlator_t *this, dict_t *dict) error = dict_foreach(dict, _check_for_auth_option, trav->xlator); if (-1 == error) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_AUTHENTICATE_ERROR, - "volume '%s' " - "defined as subvolume, but no authentication " - "defined for the same", - trav->xlator->name); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_AUTHENTICATE_ERROR, + "name=%s", trav->xlator->name, NULL); break; } trav = trav->next; @@ -409,7 +405,14 @@ server_call_xlator_mem_cleanup(xlator_t *this, char *victim_name) arg = calloc(1, sizeof(*arg)); arg->this = this; - arg->victim_name = gf_strdup(victim_name); + arg->victim_name = strdup(victim_name); + if (!arg->victim_name) { + gf_smsg(this->name, GF_LOG_CRITICAL, ENOMEM, LG_MSG_NO_MEMORY, + "Memory allocation is failed"); + free(arg); + return; + } + th_ret = gf_thread_create_detached(&th_id, server_graph_janitor_threads, arg, "graphjanitor"); if (th_ret) { @@ -417,7 +420,7 @@ server_call_xlator_mem_cleanup(xlator_t *this, char *victim_name) "graph janitor Thread" " creation is failed for brick %s", victim_name); - GF_FREE(arg->victim_name); + free(arg->victim_name); free(arg); } } @@ -436,14 +439,15 @@ server_rpc_notify(rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, void *data) uint64_t xprtrefcount = 0; gf_boolean_t fd_exist = _gf_false; - if (!xl || !data) { + this = xl; + trans = data; + + if (!this || !data || !this->ctx || !this->ctx->active) { gf_msg_callingfn("server", GF_LOG_WARNING, 0, PS_MSG_RPC_NOTIFY_ERROR, "Calling rpc_notify without initializing"); goto out; } - this = xl; - trans = data; conf = this->private; switch (event) { @@ -475,6 +479,10 @@ server_rpc_notify(rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, void *data) break; } + /* Set the disconnect_progress flag to 1 to avoid races + during brick detach while brick mux is enabled + */ + GF_ATOMIC_INIT(trans->disconnect_progress, 1); /* transport has to be removed from the list upon disconnect * irrespective of whether lock self heal is off or on, since * new transport will be created upon reconnect. @@ -488,15 +496,13 @@ server_rpc_notify(rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, void *data) if (!client) goto unref_transport; - gf_msg(this->name, GF_LOG_INFO, 0, PS_MSG_CLIENT_DISCONNECTING, - "disconnecting connection" - " from %s", - client->client_uid); + gf_smsg(this->name, GF_LOG_INFO, 0, PS_MSG_CLIENT_DISCONNECTING, + "client-uid=%s", client->client_uid, NULL); - ret = dict_get_str(this->options, "auth-path", &auth_path); + ret = dict_get_str_sizen(this->options, "auth-path", &auth_path); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PS_MSG_DICT_GET_FAILED, - "failed to get auth-path"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PS_MSG_DICT_GET_FAILED, + "type=auth-path", NULL); auth_path = NULL; } @@ -576,6 +582,7 @@ server_graph_janitor_threads(void *data) gf_boolean_t victim_found = _gf_false; xlator_list_t **trav_p = NULL; xlator_t *top = NULL; + uint32_t parent_down = 0; GF_ASSERT(data); @@ -594,7 +601,10 @@ server_graph_janitor_threads(void *data) victim = (*trav_p)->xlator; if (victim->cleanup_starting && strcmp(victim->name, victim_name) == 0) { - victim_found = _gf_true; + parent_down = victim->parent_down; + victim->parent_down = 1; + if (!parent_down) + victim_found = _gf_true; break; } } @@ -620,7 +630,7 @@ server_graph_janitor_threads(void *data) } out: - GF_FREE(arg->victim_name); + free(arg->victim_name); free(arg); return NULL; } @@ -635,8 +645,7 @@ server_mem_acct_init(xlator_t *this) ret = xlator_mem_acct_init(this, gf_server_mt_end + 1); if (ret != 0) { - gf_msg(this->name, GF_LOG_ERROR, ENOMEM, PS_MSG_NO_MEMORY, - "Memory accounting init failed"); + gf_smsg(this->name, GF_LOG_ERROR, ENOMEM, PS_MSG_NO_MEMORY, NULL); return ret; } out: @@ -692,7 +701,7 @@ server_check_event_threads(xlator_t *this, server_conf_t *conf, int32_t new) return 0; } - return event_reconfigure_threads(pool, target); + return gf_event_reconfigure_threads(pool, target); } int @@ -738,14 +747,15 @@ server_reconfigure(xlator_t *this, dict_t *options) * translator itself. */ kid = NULL; - if (dict_get_str(options, "auth-path", &auth_path) == 0) { + if (dict_get_str_sizen(options, "auth-path", &auth_path) == 0) { kid = get_xlator_by_name(this, auth_path); } if (!kid) { kid = this; } - if (dict_get_int32(options, "inode-lru-limit", &inode_lru_limit) == 0) { + if (dict_get_int32_sizen(options, "inode-lru-limit", &inode_lru_limit) == + 0) { conf->inode_lru_limit = inode_lru_limit; gf_msg_trace(this->name, 0, "Reconfigured inode-lru-limit to " @@ -760,13 +770,12 @@ server_reconfigure(xlator_t *this, dict_t *options) xlator_foreach(this, xlator_set_inode_lru_limit, &inode_lru_limit); } - data = dict_get(options, "trace"); + data = dict_get_sizen(options, "trace"); if (data) { ret = gf_string2boolean(data->data, &trace); if (ret != 0) { - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PS_MSG_INVALID_ENTRY, - "'trace' takes on only " - "boolean values. Neglecting option"); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PS_MSG_INVALID_ENTRY, + NULL); ret = -1; goto out; } @@ -776,8 +785,7 @@ server_reconfigure(xlator_t *this, dict_t *options) GF_OPTION_RECONF("statedump-path", statedump_path, options, path, do_auth); if (!statedump_path) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_STATEDUMP_PATH_ERROR, - "Error while reconfiguring statedump path"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_STATEDUMP_PATH_ERROR, NULL); goto do_auth; } gf_path_strip_trailing_slashes(statedump_path); @@ -810,16 +818,14 @@ do_auth: GF_OPTION_RECONF("gid-timeout", conf->gid_cache_timeout, options, int32, do_rpc); if (gid_cache_reconf(&conf->gid_cache, conf->gid_cache_timeout) < 0) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_GRP_CACHE_ERROR, - "Failed to reconfigure group cache."); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_GRP_CACHE_ERROR, NULL); goto do_rpc; } do_rpc: rpc_conf = conf->rpc; if (!rpc_conf) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONF_ERROR, - "No rpc_conf !!!!"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONF_ERROR, NULL); goto out; } @@ -863,8 +869,8 @@ do_rpc: * connections that are relevant to the brick * we're reconfiguring. */ - if (dict_get_str(xprt->clnt_options, "remote-subvolume", - &xprt_path) != 0) { + if (dict_get_str_sizen(xprt->clnt_options, "remote-subvolume", + &xprt_path) != 0) { continue; } if (strcmp(xprt_path, auth_path) != 0) { @@ -873,9 +879,8 @@ do_rpc: ret = gf_authenticate(xprt->clnt_options, options, conf->auth_modules); if (ret == AUTH_ACCEPT) { - gf_msg(kid->name, GF_LOG_TRACE, 0, PS_MSG_CLIENT_ACCEPTED, - "authorized client, hence we " - "continue with this connection"); + gf_smsg(kid->name, GF_LOG_TRACE, 0, PS_MSG_CLIENT_ACCEPTED, + NULL); } else { gf_event(EVENT_CLIENT_AUTH_REJECT, "client_uid=%s;" @@ -885,11 +890,10 @@ do_rpc: xprt->xl_private->client_uid, xprt->peerinfo.identifier, xprt->myinfo.identifier, auth_path); - gf_msg(this->name, GF_LOG_INFO, EACCES, - PS_MSG_AUTHENTICATE_ERROR, - "unauthorized client, hence " - "terminating the connection %s", - xprt->peerinfo.identifier); + gf_smsg(this->name, GF_LOG_INFO, EACCES, + PS_MSG_UNAUTHORIZED_CLIENT, + "peerinfo-identifier=%s", xprt->peerinfo.identifier, + NULL); rpc_transport_disconnect(xprt, _gf_false); } } @@ -900,8 +904,7 @@ do_rpc: ret = rpcsvc_set_outstanding_rpc_limit( rpc_conf, options, RPCSVC_DEFAULT_OUTSTANDING_RPC_LIMIT); if (ret < 0) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONF_ERROR, - "Failed to reconfigure outstanding-rpc-limit"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_RECONFIGURE_FAILED, NULL); goto out; } @@ -911,9 +914,8 @@ do_rpc: if (listeners->trans->reconfigure) listeners->trans->reconfigure(listeners->trans, options); else - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_TRANSPORT_ERROR, - "Reconfigure " - "not found for transport"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_TRANSPORT_ERROR, + NULL); } } @@ -986,6 +988,49 @@ server_dump_metrics(xlator_t *this, int fd) return 0; } +void +server_cleanup(xlator_t *this, server_conf_t *conf) +{ + if (!this || !conf) + return; + + LOCK_DESTROY(&conf->itable_lock); + pthread_mutex_destroy(&conf->mutex); + + if (this->ctx->event_pool) { + /* Free the event pool */ + (void)gf_event_pool_destroy(this->ctx->event_pool); + } + + if (dict_get_sizen(this->options, "config-directory")) { + GF_FREE(conf->conf_dir); + conf->conf_dir = NULL; + } + + if (conf->child_status) { + GF_FREE(conf->child_status); + conf->child_status = NULL; + } + + if (this->ctx->statedump_path) { + GF_FREE(this->ctx->statedump_path); + this->ctx->statedump_path = NULL; + } + + if (conf->auth_modules) { + gf_auth_fini(conf->auth_modules); + dict_unref(conf->auth_modules); + } + + if (conf->rpc) { + (void)rpcsvc_destroy(conf->rpc); + conf->rpc = NULL; + } + + GF_FREE(conf); + this->private = NULL; +} + int server_init(xlator_t *this) { @@ -998,14 +1043,12 @@ server_init(xlator_t *this) GF_VALIDATE_OR_GOTO("init", this, out); if (this->children == NULL) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_SUBVOL_NULL, - "protocol/server should have subvolume"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_SUBVOL_NULL, NULL); goto out; } if (this->parents != NULL) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_PARENT_VOL_ERROR, - "protocol/server should not have parent volumes"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_PARENT_VOL_ERROR, NULL); goto out; } @@ -1028,7 +1071,8 @@ server_init(xlator_t *this) if (ret) goto out; - ret = dict_get_str(this->options, "config-directory", &conf->conf_dir); + ret = dict_get_str_sizen(this->options, "config-directory", + &conf->conf_dir); if (ret) conf->conf_dir = CONFDIR; @@ -1041,8 +1085,8 @@ server_init(xlator_t *this) gf_path_strip_trailing_slashes(statedump_path); this->ctx->statedump_path = gf_strdup(statedump_path); } else { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_STATEDUMP_PATH_ERROR, - "Error setting statedump path"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_SET_STATEDUMP_PATH_ERROR, + NULL); ret = -1; goto out; } @@ -1061,6 +1105,7 @@ server_init(xlator_t *this) ret = gf_auth_init(this, conf->auth_modules); if (ret) { dict_unref(conf->auth_modules); + conf->auth_modules = NULL; goto out; } @@ -1072,8 +1117,7 @@ server_init(xlator_t *this) GF_OPTION_INIT("gid-timeout", conf->gid_cache_timeout, int32, out); if (gid_cache_init(&conf->gid_cache, conf->gid_cache_timeout) < 0) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_GRP_CACHE_ERROR, - "Failed to initialize group cache."); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_INIT_GRP_CACHE_ERROR, NULL); goto out; } @@ -1092,9 +1136,7 @@ server_init(xlator_t *this) /* RPC related */ conf->rpc = rpcsvc_init(this, this->ctx, this->options, 0); if (conf->rpc == NULL) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_RPCSVC_CREATE_FAILED, - "creation of rpcsvc " - "failed"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_RPCSVC_CREATE_FAILED, NULL); ret = -1; goto out; } @@ -1102,8 +1144,7 @@ server_init(xlator_t *this) ret = rpcsvc_set_outstanding_rpc_limit( conf->rpc, this->options, RPCSVC_DEFAULT_OUTSTANDING_RPC_LIMIT); if (ret < 0) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONF_ERROR, - "Failed to configure outstanding-rpc-limit"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONFIGURE_FAILED, NULL); goto out; } @@ -1113,43 +1154,40 @@ server_init(xlator_t *this) */ this->ctx->secure_srvr = MGMT_SSL_COPY_IO; - ret = dict_get_str(this->options, "transport-type", &transport_type); + ret = dict_get_str_sizen(this->options, "transport-type", &transport_type); if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_TRANSPORT_ERROR, - "option transport-type not set"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_TRANSPORT_TYPE_NOT_SET, + NULL); ret = -1; goto out; } total_transport = rpc_transport_count(transport_type); if (total_transport <= 0) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_TRANSPORT_ERROR, - "failed to get total number of available tranpsorts"); + gf_smsg(this->name, GF_LOG_ERROR, 0, + PS_MSG_GET_TOTAL_AVAIL_TRANSPORT_FAILED, NULL); ret = -1; goto out; } - ret = dict_set_int32(this->options, "notify-poller-death", 1); + ret = dict_set_int32_sizen(this->options, "notify-poller-death", 1); ret = rpcsvc_create_listeners(conf->rpc, this->options, this->name); if (ret < 1) { - gf_msg(this->name, GF_LOG_WARNING, 0, - PS_MSG_RPCSVC_LISTENER_CREATE_FAILED, - "creation of listener failed"); + gf_smsg(this->name, GF_LOG_WARNING, 0, + PS_MSG_RPCSVC_LISTENER_CREATE_FAILED, NULL); if (ret != -EADDRINUSE) ret = -1; goto out; } else if (ret < total_transport) { - gf_msg(this->name, GF_LOG_ERROR, 0, - PS_MSG_RPCSVC_LISTENER_CREATE_FAILED, - "creation of %d listeners failed, continuing with " - "succeeded transport", - (total_transport - ret)); + gf_smsg(this->name, GF_LOG_ERROR, 0, + PS_MSG_RPCSVC_LISTENER_CREATE_FAILED, "number=%d", + "continuing with succeeded transport", (total_transport - ret), + NULL); } ret = rpcsvc_register_notify(conf->rpc, server_rpc_notify, this); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PS_MSG_RPCSVC_NOTIFY, - "registration of notify with rpcsvc failed"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PS_MSG_RPCSVC_NOTIFY, NULL); goto out; } @@ -1159,11 +1197,10 @@ server_init(xlator_t *this) */ ret = rpcsvc_program_register(conf->rpc, &glusterfs3_3_fop_prog, _gf_true); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PS_MSG_PGM_REG_FAILED, - "registration of program (name:%s, prognum:%d, " - "progver:%d) failed", - glusterfs3_3_fop_prog.progname, glusterfs3_3_fop_prog.prognum, - glusterfs3_3_fop_prog.progver); + gf_smsg(this->name, GF_LOG_WARNING, 0, PS_MSG_PGM_REG_FAILED, "name=%s", + glusterfs3_3_fop_prog.progname, "prognum=%d", + glusterfs3_3_fop_prog.prognum, "progver=%d", + glusterfs3_3_fop_prog.progver, NULL); goto out; } @@ -1183,11 +1220,10 @@ server_init(xlator_t *this) ret = rpcsvc_program_register(conf->rpc, &gluster_handshake_prog, _gf_false); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PS_MSG_PGM_REG_FAILED, - "registration of program (name:%s, prognum:%d, " - "progver:%d) failed", - gluster_handshake_prog.progname, gluster_handshake_prog.prognum, - gluster_handshake_prog.progver); + gf_smsg(this->name, GF_LOG_WARNING, 0, PS_MSG_PGM_REG_FAILED, "name=%s", + gluster_handshake_prog.progname, "prognum=%d", + gluster_handshake_prog.prognum, "progver=%d", + gluster_handshake_prog.progver, NULL); rpcsvc_program_unregister(conf->rpc, &glusterfs3_3_fop_prog); rpcsvc_program_unregister(conf->rpc, &glusterfs4_0_fop_prog); goto out; @@ -1201,18 +1237,14 @@ server_init(xlator_t *this) lim.rlim_max = 1048576; if (setrlimit(RLIMIT_NOFILE, &lim) == -1) { - gf_msg(this->name, GF_LOG_WARNING, errno, PS_MSG_ULIMIT_SET_FAILED, - "WARNING: Failed to " - "set 'ulimit -n 1M': %s", - strerror(errno)); + gf_smsg(this->name, GF_LOG_WARNING, errno, PS_MSG_ULIMIT_SET_FAILED, + "errno=%s", strerror(errno), NULL); lim.rlim_cur = 65536; lim.rlim_max = 65536; if (setrlimit(RLIMIT_NOFILE, &lim) == -1) { - gf_msg(this->name, GF_LOG_WARNING, errno, PS_MSG_FD_NOT_FOUND, - "Failed to set " - "max open fd to 64k: %s", - strerror(errno)); + gf_smsg(this->name, GF_LOG_WARNING, errno, PS_MSG_FD_NOT_FOUND, + "errno=%s", strerror(errno), NULL); } else { gf_msg_trace(this->name, 0, "max open fd set " @@ -1224,9 +1256,8 @@ server_init(xlator_t *this) if (!this->ctx->cmd_args.volfile_id) { /* In some use cases this is a valid case, but document this to be annoying log in that case */ - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PS_MSG_VOL_FILE_OPEN_FAILED, - "volfile-id argument not given. " - "This is mandatory argument, defaulting to 'gluster'"); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PS_MSG_VOL_FILE_OPEN_FAILED, + NULL); this->ctx->cmd_args.volfile_id = gf_strdup("gluster"); } FIRST_CHILD(this)->volfile_id = gf_strdup(this->ctx->cmd_args.volfile_id); @@ -1239,15 +1270,7 @@ out: if (this != NULL) { this->fini(this); } - - if (conf && conf->rpc) { - rpcsvc_listener_t *listener, *next; - list_for_each_entry_safe(listener, next, &conf->rpc->listeners, - list) - { - rpcsvc_listener_destroy(listener); - } - } + server_cleanup(this, conf); } return ret; @@ -1370,9 +1393,9 @@ server_process_event_upcall(xlator_t *this, void *data) xdrproc = (xdrproc_t)xdr_gfs4_entrylk_contention_req; break; default: - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PS_MSG_INVALID_ENTRY, - "Received invalid upcall event(%d)", - upcall_data->event_type); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, + PS_MSG_INVLAID_UPCALL_EVENT, "event-type=%d", + upcall_data->event_type, NULL); goto out; } @@ -1446,6 +1469,8 @@ server_process_child_event(xlator_t *this, int32_t event, void *data, INIT_LIST_HEAD(&tmp->status_list); tmp->name = gf_strdup(victim->name); tmp->child_up = _gf_true; + memcpy(tmp->volume_id, victim->graph->volume_id, + GF_UUID_BUF_SIZE); list_add_tail(&tmp->status_list, &conf->child_status->status_list); } @@ -1462,10 +1487,8 @@ server_process_child_event(xlator_t *this, int32_t event, void *data, } if (!tmp->name) - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_CHILD_STATUS_FAILED, - "No xlator %s is found in " - "child status list", - victim->name); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_CHILD_STATUS_FAILED, + "name=%s", victim->name, NULL); } list_for_each_entry(xprt, &conf->xprt_list, list) { @@ -1500,6 +1523,7 @@ server_notify(xlator_t *this, int32_t event, void *data, ...) glusterfs_ctx_t *ctx = NULL; gf_boolean_t xprt_found = _gf_false; uint64_t totxprt = 0; + uint64_t totdisconnect = 0; GF_VALIDATE_OR_GOTO(THIS->name, this, out); conf = this->private; @@ -1513,9 +1537,8 @@ server_notify(xlator_t *this, int32_t event, void *data, ...) ret = server_process_event_upcall(this, data); if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - PS_MSG_SERVER_EVENT_UPCALL_FAILED, - "server_process_event_upcall failed"); + gf_smsg(this->name, GF_LOG_ERROR, 0, + PS_MSG_SERVER_EVENT_UPCALL_FAILED, NULL); goto out; } break; @@ -1534,9 +1557,8 @@ server_notify(xlator_t *this, int32_t event, void *data, ...) ret = server_process_child_event(this, event, data, GF_CBK_CHILD_UP); if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - PS_MSG_SERVER_EVENT_UPCALL_FAILED, - "server_process_child_event failed"); + gf_smsg(this->name, GF_LOG_ERROR, 0, + PS_MSG_SERVER_CHILD_EVENT_FAILED, NULL); goto out; } default_notify(this, event, data); @@ -1553,9 +1575,8 @@ server_notify(xlator_t *this, int32_t event, void *data, ...) ret = server_process_child_event(this, event, data, GF_CBK_CHILD_DOWN); if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - PS_MSG_SERVER_EVENT_UPCALL_FAILED, - "server_process_child_event failed"); + gf_smsg(this->name, GF_LOG_ERROR, 0, + PS_MSG_SERVER_CHILD_EVENT_FAILED, NULL); goto out; } default_notify(this, event, data); @@ -1573,6 +1594,10 @@ server_notify(xlator_t *this, int32_t event, void *data, ...) if (!xprt->xl_private) { continue; } + + if (GF_ATOMIC_GET(xprt->disconnect_progress)) + continue; + if (xprt->xl_private->bound_xl == data) { totxprt++; } @@ -1599,14 +1624,22 @@ server_notify(xlator_t *this, int32_t event, void *data, ...) if (!xprt->xl_private) { continue; } + + if (GF_ATOMIC_GET(xprt->disconnect_progress)) + continue; + if (xprt->xl_private->bound_xl == data) { gf_log(this->name, GF_LOG_INFO, "disconnecting %s", xprt->peerinfo.identifier); xprt_found = _gf_true; + totdisconnect++; rpc_transport_disconnect(xprt, _gf_false); } } + if (totxprt > totdisconnect) + GF_ATOMIC_SUB(victim->xprtrefcnt, (totxprt - totdisconnect)); + pthread_mutex_unlock(&conf->mutex); if (this->ctx->active) { top = this->ctx->active->first; @@ -1712,13 +1745,22 @@ struct volume_options server_options[] = { "as user bin or group staff.", .op_version = {2}, .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, + {.key = {"all-squash"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "off", + .description = "Map requests from any uid/gid to the anonymous " + "uid/gid. Note that this does not apply to any other " + "uids or gids that might be equally sensitive, such " + "as user bin or group staff.", + .op_version = {GD_OP_VERSION_6_0}, + .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, {.key = {"anonuid"}, .type = GF_OPTION_TYPE_INT, .default_value = "65534", /* RPC_NOBODY_UID */ .min = 0, .max = (uint32_t)-1, .description = "value of the uid used for the anonymous " - "user/nfsnobody when root-squash is enabled.", + "user/nfsnobody when root-squash/all-squash is enabled.", .op_version = {3}, .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, {.key = {"anongid"}, @@ -1727,7 +1769,7 @@ struct volume_options server_options[] = { .min = 0, .max = (uint32_t)-1, .description = "value of the gid used for the anonymous " - "user/nfsnobody when root-squash is enabled.", + "user/nfsnobody when root-squash/all-squash is enabled.", .op_version = {3}, .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, {.key = {"statedump-path"}, @@ -1804,7 +1846,7 @@ struct volume_options server_options[] = { .type = GF_OPTION_TYPE_INT, .min = 1, .max = 1024, - .default_value = "1", + .default_value = "2", .description = "Specifies the number of event threads to execute " "in parallel. Larger values would help process" " responses faster, depending on available processing" |
