diff options
author | Humble Devassy Chirammal <hchiramm@redhat.com> | 2015-04-29 11:38:11 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2015-04-29 22:18:01 -0700 |
commit | 4306245aef7cdcbfa6d7a59dccd031d4ada54105 (patch) | |
tree | 38ca1d65ba14864687f317e5406f010ca6ba7f6e /rpc/rpc-transport/rdma/src/name.c | |
parent | d28a99d6f20650e5d78accb1e16bd3721a2b6d02 (diff) |
rdma: porting rdma to a new message id logging format
Change-Id: I71e940817ae0a9378e82332d5a8569114fc13482
BUG: 1194640
Signed-off-by: Humble Devassy Chirammal <hchiramm@redhat.com>
Reviewed-on: http://review.gluster.org/9868
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 'rpc/rpc-transport/rdma/src/name.c')
-rw-r--r-- | rpc/rpc-transport/rdma/src/name.c | 149 |
1 files changed, 73 insertions, 76 deletions
diff --git a/rpc/rpc-transport/rdma/src/name.c b/rpc/rpc-transport/rdma/src/name.c index 52ce5bbce55..97b2e37121e 100644 --- a/rpc/rpc-transport/rdma/src/name.c +++ b/rpc/rpc-transport/rdma/src/name.c @@ -22,6 +22,8 @@ #include "rpc-transport.h" #include "rdma.h" #include "common-utils.h" +#include "rpc-lib-messages.h" +#include "rpc-trans-rdma-messages.h" int32_t @@ -38,7 +40,7 @@ af_inet_bind_to_port_lt_ceiling (struct rdma_cm_id *cm_id, { int32_t ret = -1; uint16_t port = ceiling - 1; - // by default assume none of the ports are blocked and all are available + /* by default assume none of the ports are blocked and all are available */ gf_boolean_t ports[1024] = {_gf_false,}; int i = 0; @@ -48,10 +50,8 @@ af_inet_bind_to_port_lt_ceiling (struct rdma_cm_id *cm_id, ports[i] = _gf_false; } - while (port) - { - switch (sockaddr->sa_family) - { + while (port) { + switch (sockaddr->sa_family) { case AF_INET6: ((struct sockaddr_in6 *)sockaddr)->sin6_port = htons (port); @@ -63,7 +63,7 @@ af_inet_bind_to_port_lt_ceiling (struct rdma_cm_id *cm_id, = htons (port); break; } - // ignore the reserved ports + /* ignore the reserved ports */ if (ports[port] == _gf_true) { port--; continue; @@ -134,7 +134,8 @@ client_fill_address_family (rpc_transport_t *this, struct sockaddr *sockaddr) if (!(remote_host_data || connect_path_data) || (remote_host_data && connect_path_data)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + TRANS_MSG_ADDR_FAMILY_NOT_SPECIFIED, "address-family not specified and not able to " "determine the same from other options " "(remote-host:%s and connect-path:%s)", @@ -144,14 +145,13 @@ client_fill_address_family (rpc_transport_t *this, struct sockaddr *sockaddr) } if (remote_host_data) { - gf_log (this->name, GF_LOG_DEBUG, - "address-family not specified, guessing it " - "to be inet/inet6"); + gf_msg_debug (this->name, 0, "address-family not " + "specified, guessing it to be " + "inet/inet6"); sockaddr->sa_family = AF_UNSPEC; } else { - gf_log (this->name, GF_LOG_DEBUG, - "address-family not specified, guessing it " - "to be unix"); + gf_msg_debug (this->name, 0, "address-family not " + "specified, guessing it to be unix"); sockaddr->sa_family = AF_UNIX; } @@ -166,7 +166,8 @@ client_fill_address_family (rpc_transport_t *this, struct sockaddr *sockaddr) } else if (!strcasecmp (address_family, "inet-sdp")) { sockaddr->sa_family = AF_INET_SDP; } else { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + TRANS_MSG_UNKNOWN_ADDR_FAMILY, "unknown address-family (%s) specified", address_family); sockaddr->sa_family = AF_UNSPEC; @@ -191,47 +192,40 @@ af_inet_client_get_remote_sockaddr (rpc_transport_t *this, int32_t ret = 0; remote_host_data = dict_get (options, "remote-host"); - if (remote_host_data == NULL) - { - gf_log (this->name, GF_LOG_ERROR, - "option remote-host missing in volume %s", - this->name); + if (remote_host_data == NULL) { + gf_msg (this->name, GF_LOG_ERROR, 0, + TRANS_MSG_REMOTE_HOST_ERROR, "option remote-host " + "missing in volume %s", this->name); ret = -1; goto err; } remote_host = data_to_str (remote_host_data); - if (remote_host == NULL) - { - gf_log (this->name, GF_LOG_ERROR, - "option remote-host has data NULL in volume %s", - this->name); + if (remote_host == NULL) { + gf_msg (this->name, GF_LOG_ERROR, 0, + TRANS_MSG_REMOTE_HOST_ERROR, "option remote-host " + "has data NULL in volume %s", this->name); ret = -1; goto err; } if (remote_port == 0) { remote_port_data = dict_get (options, "remote-port"); - if (remote_port_data == NULL) - { - gf_log (this->name, GF_LOG_DEBUG, - "option remote-port missing in volume %s. " - "Defaulting to %d", - this->name, GF_DEFAULT_RDMA_LISTEN_PORT); + if (remote_port_data == NULL) { + gf_msg_debug (this->name, 0, "option remote-port " + "missing in volume %s. Defaulting to %d", + this->name, GF_DEFAULT_RDMA_LISTEN_PORT); remote_port = GF_DEFAULT_RDMA_LISTEN_PORT; - } - else - { + } else { remote_port = data_to_uint16 (remote_port_data); } } - if (remote_port == -1) - { - gf_log (this->name, GF_LOG_ERROR, - "option remote-port has invalid port in volume %s", - this->name); + if (remote_port == -1) { + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + RDMA_MSG_INVALID_ENTRY, "option remote-port has " + "invalid port in volume %s", this->name); ret = -1; goto err; } @@ -242,7 +236,7 @@ af_inet_client_get_remote_sockaddr (rpc_transport_t *this, sockaddr->sa_family, &this->dnscache, &addr_info); if (ret == -1) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, TRANS_MSG_DNS_RESOL_FAILED, "DNS resolution failed on host %s", remote_host); goto err; } @@ -267,32 +261,32 @@ af_unix_client_get_remote_sockaddr (rpc_transport_t *this, connect_path_data = dict_get (this->options, "transport.rdma.connect-path"); if (!connect_path_data) { - gf_log (this->name, GF_LOG_ERROR, - "option transport.rdma.connect-path not " - "specified for address-family unix"); + gf_msg (this->name, GF_LOG_ERROR, 0, + TRANS_MSG_CONNECT_PATH_ERROR, "option " + "transport.rdma.connect-path not specified for " + "address-family unix"); ret = -1; goto err; } connect_path = data_to_str (connect_path_data); if (!connect_path) { - gf_log (this->name, GF_LOG_ERROR, - "connect-path is null-string"); + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + RDMA_MSG_INVALID_ENTRY, "connect-path is null-string"); ret = -1; goto err; } if (strlen (connect_path) > UNIX_PATH_MAX) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + TRANS_MSG_CONNECT_PATH_ERROR, "connect-path value length %"GF_PRI_SIZET" > " "%d octets", strlen (connect_path), UNIX_PATH_MAX); ret = -1; goto err; } - gf_log (this->name, - GF_LOG_DEBUG, - "using connect-path %s", connect_path); + gf_msg_debug (this->name, 0, "using connect-path %s", connect_path); sockaddr_un = (struct sockaddr_un *)sockaddr; strcpy (sockaddr_un->sun_path, connect_path); *sockaddr_len = sizeof (struct sockaddr_un); @@ -315,7 +309,8 @@ af_unix_server_get_local_sockaddr (rpc_transport_t *this, listen_path_data = dict_get (this->options, "transport.rdma.listen-path"); if (!listen_path_data) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + TRANS_MSG_LISTEN_PATH_ERROR, "missing option listen-path"); ret = -1; goto err; @@ -328,8 +323,9 @@ af_unix_server_get_local_sockaddr (rpc_transport_t *this, #endif if (strlen (listen_path) > UNIX_PATH_MAX) { - gf_log (this->name, GF_LOG_ERROR, - "option listen-path has value length %"GF_PRI_SIZET" > %d", + gf_msg (this->name, GF_LOG_ERROR, 0, + TRANS_MSG_LISTEN_PATH_ERROR, "option listen-path has " + "value length %"GF_PRI_SIZET" > %d", strlen (listen_path), UNIX_PATH_MAX); ret = -1; goto err; @@ -399,7 +395,8 @@ af_inet_server_get_local_sockaddr (rpc_transport_t *this, ret = getaddrinfo(listen_host, service, &hints, &res); if (ret != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ret, + TRANS_MSG_GET_ADDR_INFO_FAILED, "getaddrinfo failed for host %s, service %s (%s)", listen_host, service, gai_strerror (ret)); ret = -1; @@ -422,8 +419,7 @@ gf_rdma_client_bind (rpc_transport_t *this, struct sockaddr *sockaddr, int ret = 0; *sockaddr_len = sizeof (struct sockaddr_in6); - switch (sockaddr->sa_family) - { + switch (sockaddr->sa_family) { case AF_INET_SDP: case AF_INET: *sockaddr_len = sizeof (struct sockaddr_in); @@ -433,7 +429,8 @@ gf_rdma_client_bind (rpc_transport_t *this, struct sockaddr *sockaddr, *sockaddr_len, GF_CLIENT_PORT_CEILING); if (ret == -1) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, errno, + RDMA_MSG_PORT_BIND_FAILED, "cannot bind rdma_cm_id to port " "less than %d (%s)", GF_CLIENT_PORT_CEILING, strerror (errno)); @@ -457,7 +454,8 @@ gf_rdma_client_bind (rpc_transport_t *this, struct sockaddr *sockaddr, break; default: - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + TRANS_MSG_UNKNOWN_ADDR_FAMILY, "unknown address family %d", sockaddr->sa_family); ret = -1; break; @@ -481,8 +479,7 @@ gf_rdma_client_get_remote_sockaddr (rpc_transport_t *this, goto err; } - switch (sockaddr->sa_family) - { + switch (sockaddr->sa_family) { case AF_INET_SDP: sockaddr->sa_family = AF_INET; is_inet_sdp = 1; @@ -508,7 +505,8 @@ gf_rdma_client_get_remote_sockaddr (rpc_transport_t *this, break; default: - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + TRANS_MSG_UNKNOWN_ADDR_FAMILY, "unknown address-family %d", sockaddr->sa_family); ret = -1; } @@ -541,22 +539,20 @@ gf_rdma_server_get_local_sockaddr (rpc_transport_t *this, } else if (!strcasecmp (address_family, "unix")) { addr->sa_family = AF_UNIX; } else { - gf_log (this->name, GF_LOG_ERROR, - "unknown address family (%s) specified", - address_family); + gf_msg (this->name, GF_LOG_ERROR, 0, + TRANS_MSG_UNKNOWN_ADDR_FAMILY, "unknown address" + " family (%s) specified", address_family); addr->sa_family = AF_UNSPEC; ret = -1; goto err; } } else { - gf_log (this->name, GF_LOG_DEBUG, - "option address-family not specified, defaulting " - "to inet"); + gf_msg_debug (this->name, 0, "option address-family not " + "specified, defaulting to inet"); addr->sa_family = AF_INET; } - switch (addr->sa_family) - { + switch (addr->sa_family) { case AF_INET_SDP: is_inet_sdp = 1; addr->sa_family = AF_INET; @@ -639,8 +635,8 @@ fill_inet6_inet_identifiers (rpc_transport_t *this, struct sockaddr_storage *add service, sizeof (service), NI_NUMERICHOST | NI_NUMERICSERV); if (ret != 0) { - gf_log (this->name, - GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ret, + TRANS_MSG_GET_NAME_INFO_FAILED, "getnameinfo failed (%s)", gai_strerror (ret)); } @@ -655,21 +651,20 @@ gf_rdma_get_transport_identifiers (rpc_transport_t *this) int32_t ret = 0; char is_inet_sdp = 0; - switch (((struct sockaddr *) &this->myinfo.sockaddr)->sa_family) - { + switch (((struct sockaddr *) &this->myinfo.sockaddr)->sa_family) { case AF_INET_SDP: is_inet_sdp = 1; ((struct sockaddr *) &this->peerinfo.sockaddr)->sa_family = ((struct sockaddr *) &this->myinfo.sockaddr)->sa_family = AF_INET; case AF_INET: - case AF_INET6: - { + case AF_INET6: { ret = fill_inet6_inet_identifiers (this, &this->myinfo.sockaddr, this->myinfo.sockaddr_len, this->myinfo.identifier); if (ret == -1) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + TRANS_MSG_INET_ERROR, "can't fill inet/inet6 identifier for server"); goto err; } @@ -679,7 +674,8 @@ gf_rdma_get_transport_identifiers (rpc_transport_t *this) this->peerinfo.sockaddr_len, this->peerinfo.identifier); if (ret == -1) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + TRANS_MSG_INET_ERROR, "can't fill inet/inet6 identifier for client"); goto err; } @@ -703,7 +699,8 @@ gf_rdma_get_transport_identifiers (rpc_transport_t *this) break; default: - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + TRANS_MSG_UNKNOWN_ADDR_FAMILY, "unknown address family (%d)", ((struct sockaddr *) &this->myinfo.sockaddr)->sa_family); ret = -1; |