diff options
author | Manikandan Selvaganesh <mselvaga@redhat.com> | 2015-03-11 20:11:09 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2015-04-29 22:33:41 -0700 |
commit | dc089a1a51988c2b407040e1684d7b0adbd79556 (patch) | |
tree | 530b8b1e1aa6e695ff6e495cd0907a87cbe8628c /xlators/protocol/server/src/server.c | |
parent | 00700a0d665fa18e28b6898b5fd09c34fc0150bc (diff) |
protocol/server : port log messages to new framework.
Change-Id: I7901f55d06716161cc31d2b79a600a16b5ec2ef8
BUG: 1194640
Signed-off-by: Manikandan Selvaganesh <mselvaga@redhat.com>
Reviewed-on: http://review.gluster.org/9874
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Tested-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/protocol/server/src/server.c')
-rw-r--r-- | xlators/protocol/server/src/server.c | 137 |
1 files changed, 77 insertions, 60 deletions
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index aea88b623cc..470c57dac41 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -26,6 +26,7 @@ #include "defaults.h" #include "authenticate.h" #include "event.h" +#include "server-messages.h" rpcsvc_cbk_program_t server_cbk_prog = { .progname = "Gluster Callback", @@ -48,13 +49,15 @@ grace_time_handler (void *data) GF_VALIDATE_OR_GOTO (THIS->name, this, out); - gf_log (this->name, GF_LOG_INFO, "grace timer expired for %s", - client->client_uid); + gf_msg (this->name, GF_LOG_INFO, 0, PS_MSG_GRACE_TIMER_EXPD, "grace " + "timer expired for %s", client->client_uid); serv_ctx = server_ctx_get (client, this); if (serv_ctx == NULL) { - gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed"); + gf_msg (this->name, GF_LOG_INFO, 0, + PS_MSG_SERVER_CTX_GET_FAILED, "server_ctx_get() " + "failed"); goto out; } @@ -173,7 +176,8 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg, iob = gfs_serialize_reply (req, arg, &rsp, xdrproc); if (!iob) { - gf_log ("", GF_LOG_ERROR, "Failed to serialize reply"); + gf_msg ("", GF_LOG_ERROR, 0, PS_MSG_SERIALIZE_REPLY_FAILED, + "Failed to serialize reply"); goto ret; } @@ -355,13 +359,14 @@ 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_log ("server", GF_LOG_WARNING, + gf_msg ("server", GF_LOG_WARNING, 0, + PS_MSG_AUTH_IP_ERROR, "assuming 'auth.ip' to be 'auth.addr'"); } ret = dict_set_dynptr (auth_dict, tmp, NULL, 0); if (ret < 0) { - gf_log ("server", GF_LOG_DEBUG, - "failed to dict_set_dynptr"); + gf_msg_debug ("server", 0, "failed to " + "dict_set_dynptr"); } } @@ -388,7 +393,7 @@ _check_for_auth_option (dict_t *d, char *k, data_t *v, goto out; if (strncmp(tail, "addr.", 5) != 0) { - gf_log (xl->name, GF_LOG_INFO, + gf_msg (xl->name, GF_LOG_INFO, 0, PS_MSG_SKIP_FORMAT_CHK, "skip format check for non-addr auth option %s", k); goto out; } @@ -423,7 +428,8 @@ _check_for_auth_option (dict_t *d, char *k, data_t *v, ret = 0; } else { ret = -1; - gf_log (xl->name, GF_LOG_ERROR, + gf_msg (xl->name, GF_LOG_ERROR, 0, + PS_MSG_INTERNET_ADDR_ERROR, "internet address '%s'" " does not conform to" " standards.", addr); @@ -456,10 +462,10 @@ validate_auth_options (xlator_t *this, dict_t *dict) trav->xlator); if (-1 == error) { - gf_log (this->name, GF_LOG_ERROR, - "volume '%s' defined as subvolume, but no " - "authentication defined for the same", - trav->xlator->name); + 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); break; } trav = trav->next; @@ -526,8 +532,9 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, if (!client) break; - gf_log (this->name, GF_LOG_INFO, "disconnecting connection " - "from %s", client->client_uid); + gf_msg (this->name, GF_LOG_INFO, 0, + PS_MSG_CLIENT_DISCONNECTING, "disconnecting connection" + " from %s", client->client_uid); /* If lock self heal is off, then destroy the conn object, else register a grace timer event */ @@ -546,7 +553,8 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, serv_ctx = server_ctx_get (client, this); if (serv_ctx == NULL) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + PS_MSG_SERVER_CTX_GET_FAILED, "server_ctx_get() failed"); goto out; } @@ -555,7 +563,8 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, { if (!serv_ctx->grace_timer) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + PS_MSG_GRACE_TIMER_START, "starting a grace timer for %s", client->client_uid); @@ -593,8 +602,8 @@ mem_acct_init (xlator_t *this) ret = xlator_mem_acct_init (this, gf_server_mt_end + 1); if (ret != 0) { - gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" - "failed"); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, PS_MSG_NO_MEMORY, + "Memory accounting init failed"); return ret; } out: @@ -659,8 +668,8 @@ server_init_grace_timer (xlator_t *this, dict_t *options, if (!ret) gf_string2boolean (lk_heal, &conf->lk_heal); - gf_log (this->name, GF_LOG_DEBUG, "lk-heal = %s", - (conf->lk_heal) ? "on" : "off"); + gf_msg_debug (this->name, 0, "lk-heal = %s", + (conf->lk_heal) ? "on" : "off"); ret = dict_get_int32 (options, "grace-timeout", &grace_timeout); if (!ret) @@ -670,8 +679,8 @@ server_init_grace_timer (xlator_t *this, dict_t *options, gf_time_fmt (timestr, sizeof timestr, conf->grace_ts.tv_sec, gf_timefmt_s); - gf_log (this->name, GF_LOG_DEBUG, "Server grace timeout value = %s", - timestr); + gf_msg_debug (this->name, 0, "Server grace timeout value = %s", + timestr); conf->grace_ts.tv_nsec = 0; @@ -716,8 +725,8 @@ reconfigure (xlator_t *this, dict_t *options) if (dict_get_int32 ( options, "inode-lru-limit", &inode_lru_limit) == 0){ conf->inode_lru_limit = inode_lru_limit; - gf_log (this->name, GF_LOG_TRACE, "Reconfigured inode-lru-limit" - " to %d", conf->inode_lru_limit); + gf_msg_trace (this->name, 0, "Reconfigured inode-lru-limit to " + "%d", conf->inode_lru_limit); /* traverse through the xlator graph. For each xlator in the graph check whether it is a bound_xl or not (bound_xl means @@ -732,22 +741,23 @@ reconfigure (xlator_t *this, dict_t *options) if (data) { ret = gf_string2boolean (data->data, &trace); if (ret != 0) { - gf_log (this->name, GF_LOG_WARNING, - "'trace' takes on only boolean values. " - "Neglecting option"); + gf_msg (this->name, GF_LOG_WARNING, EINVAL, + PS_MSG_INVALID_ENTRY, "'trace' takes on only " + "boolean values. Neglecting option"); ret = -1; goto out; } conf->trace = trace; - gf_log (this->name, GF_LOG_TRACE, "Reconfigured trace" - " to %d", conf->trace); + gf_msg_trace (this->name, 0, "Reconfigured trace to %d", + conf->trace); } GF_OPTION_RECONF ("statedump-path", statedump_path, options, path, out); if (!statedump_path) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + PS_MSG_STATEDUMP_PATH_ERROR, "Error while reconfiguring statedump path"); ret = -1; goto out; @@ -780,14 +790,15 @@ reconfigure (xlator_t *this, dict_t *options) GF_OPTION_RECONF ("gid-timeout", conf->gid_cache_timeout, options, int32, out); if (gid_cache_reconf (&conf->gid_cache, conf->gid_cache_timeout) < 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reconfigure group " - "cache."); + gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_GRP_CACHE_ERROR, + "Failed to reconfigure group cache."); goto out; } rpc_conf = conf->rpc; if (!rpc_conf) { - gf_log (this->name, GF_LOG_ERROR, "No rpc_conf !!!!"); + gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONF_ERROR, + "No rpc_conf !!!!"); goto out; } @@ -797,7 +808,7 @@ reconfigure (xlator_t *this, dict_t *options) ret = rpcsvc_set_outstanding_rpc_limit (rpc_conf, options, RPCSVC_DEFAULT_OUTSTANDING_RPC_LIMIT); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONF_ERROR, "Failed to reconfigure outstanding-rpc-limit"); goto out; } @@ -807,8 +818,9 @@ reconfigure (xlator_t *this, dict_t *options) if (listeners->trans->reconfigure ) listeners->trans->reconfigure (listeners->trans, options); else - gf_log (this->name, GF_LOG_ERROR, - "Reconfigure not found for transport" ); + gf_msg (this->name, GF_LOG_ERROR, 0, + PS_MSG_TRANSPORT_ERROR, "Reconfigure " + "not found for transport"); } } @@ -821,7 +833,7 @@ reconfigure (xlator_t *this, dict_t *options) ret = server_init_grace_timer (this, options, conf); out: - gf_log ("", GF_LOG_DEBUG, "returning %d", ret); + gf_msg_debug ("", 0, "returning %d", ret); return ret; } @@ -858,13 +870,13 @@ init (xlator_t *this) GF_VALIDATE_OR_GOTO ("init", this, out); if (this->children == NULL) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_SUBVOL_NULL, "protocol/server should have subvolume"); goto out; } if (this->parents != NULL) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_PARENT_VOL_ERROR, "protocol/server should not have parent volumes"); goto out; } @@ -906,7 +918,8 @@ init (xlator_t *this) gf_path_strip_trailing_slashes (statedump_path); this->ctx->statedump_path = gf_strdup (statedump_path); } else { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + PS_MSG_STATEDUMP_PATH_ERROR, "Error setting statedump path"); ret = -1; goto out; @@ -937,16 +950,17 @@ 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_log(this->name, GF_LOG_ERROR, "Failed to initialize " - "group cache."); + gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_GRP_CACHE_ERROR, + "Failed to initialize group cache."); goto out; } /* RPC related */ conf->rpc = rpcsvc_init (this, this->ctx, this->options, 0); if (conf->rpc == NULL) { - gf_log (this->name, GF_LOG_ERROR, - "creation of rpcsvc failed"); + gf_msg (this->name, GF_LOG_ERROR, 0, + PS_MSG_RPCSVC_CREATE_FAILED, "creation of rpcsvc " + "failed"); ret = -1; goto out; } @@ -954,7 +968,7 @@ init (xlator_t *this) ret = rpcsvc_set_outstanding_rpc_limit (conf->rpc, this->options, RPCSVC_DEFAULT_OUTSTANDING_RPC_LIMIT); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONF_ERROR, "Failed to configure outstanding-rpc-limit"); goto out; } @@ -967,14 +981,14 @@ init (xlator_t *this) ret = dict_get_str (this->options, "transport-type", &transport_type); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_TRANSPORT_ERROR, "option transport-type not set"); ret = -1; goto out; } total_transport = rpc_transport_count (transport_type); if (total_transport <= 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_TRANSPORT_ERROR, "failed to get total number of available tranpsorts"); ret = -1; goto out; @@ -982,19 +996,21 @@ init (xlator_t *this) ret = rpcsvc_create_listeners (conf->rpc, this->options, this->name); if (ret < 1) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + PS_MSG_RPCSVC_LISTENER_CREATE_FAILED, "creation of listener failed"); ret = -1; goto out; } else if (ret < total_transport) { - gf_log (this->name, GF_LOG_ERROR, + 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)); } ret = rpcsvc_register_notify (conf->rpc, server_rpc_notify, this); if (ret) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, PS_MSG_RPCSVC_NOTIFY, "registration of notify with rpcsvc failed"); goto out; } @@ -1002,7 +1018,7 @@ init (xlator_t *this) glusterfs3_3_fop_prog.options = this->options; ret = rpcsvc_program_register (conf->rpc, &glusterfs3_3_fop_prog); if (ret) { - gf_log (this->name, GF_LOG_WARNING, + 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, @@ -1013,7 +1029,7 @@ init (xlator_t *this) gluster_handshake_prog.options = this->options; ret = rpcsvc_program_register (conf->rpc, &gluster_handshake_prog); if (ret) { - gf_log (this->name, GF_LOG_WARNING, + 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, @@ -1030,19 +1046,20 @@ init (xlator_t *this) lim.rlim_max = 1048576; if (setrlimit (RLIMIT_NOFILE, &lim) == -1) { - gf_log (this->name, GF_LOG_WARNING, - "WARNING: Failed to set 'ulimit -n 1M': %s", - strerror(errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + PS_MSG_ULIMIT_SET_FAILED, "WARNING: Failed to " + "set 'ulimit -n 1M': %s", strerror(errno)); lim.rlim_cur = 65536; lim.rlim_max = 65536; if (setrlimit (RLIMIT_NOFILE, &lim) == -1) { - gf_log (this->name, GF_LOG_WARNING, - "Failed to set max open fd to 64k: %s", + gf_msg (this->name, GF_LOG_WARNING, errno, + PS_MSG_FD_NOT_FOUND, "Failed to set " + "max open fd to 64k: %s", strerror(errno)); } else { - gf_log (this->name, GF_LOG_TRACE, - "max open fd set to 64k"); + gf_msg_trace (this->name, 0, "max open fd set " + "to 64k"); } } } |