diff options
author | Amar Tumballi <amar@gluster.com> | 2011-03-16 09:39:57 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2011-03-17 11:57:47 -0700 |
commit | 02d8dcbb5c7483ade3dd052d75e6430cb0253d1f (patch) | |
tree | 32fefe7cf6324b69a731fd12e4574ab4786b6803 /rpc/rpc-transport/rdma | |
parent | d4aae8327ac5581cd47dd0fcea796ddbb03be5ea (diff) |
rpc-transport: whitespace cleanup
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 2346 (Log message enhancements in GlusterFS - phase 1)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2346
Diffstat (limited to 'rpc/rpc-transport/rdma')
-rw-r--r-- | rpc/rpc-transport/rdma/src/name.c | 150 | ||||
-rw-r--r-- | rpc/rpc-transport/rdma/src/rdma.c | 428 | ||||
-rw-r--r-- | rpc/rpc-transport/rdma/src/rdma.h | 4 |
3 files changed, 291 insertions, 291 deletions
diff --git a/rpc/rpc-transport/rdma/src/name.c b/rpc/rpc-transport/rdma/src/name.c index ae5c5d3562e..3a8ce9d4350 100644 --- a/rpc/rpc-transport/rdma/src/name.c +++ b/rpc/rpc-transport/rdma/src/name.c @@ -37,14 +37,14 @@ #include "rdma.h" int32_t -gf_resolve_ip6 (const char *hostname, - uint16_t port, - int family, - void **dnscache, +gf_resolve_ip6 (const char *hostname, + uint16_t port, + int family, + void **dnscache, struct addrinfo **addr_info); static int32_t -af_inet_bind_to_port_lt_ceiling (int fd, struct sockaddr *sockaddr, +af_inet_bind_to_port_lt_ceiling (int fd, struct sockaddr *sockaddr, socklen_t sockaddr_len, int ceiling) { int32_t ret = -1; @@ -80,16 +80,16 @@ af_inet_bind_to_port_lt_ceiling (int fd, struct sockaddr *sockaddr, } static int32_t -af_unix_client_bind (rpc_transport_t *this, - struct sockaddr *sockaddr, - socklen_t sockaddr_len, +af_unix_client_bind (rpc_transport_t *this, + struct sockaddr *sockaddr, + socklen_t sockaddr_len, int sock) { data_t *path_data = NULL; struct sockaddr_un *addr = NULL; int32_t ret = -1; - path_data = dict_get (this->options, + path_data = dict_get (this->options, "transport.rdma.bind-path"); if (path_data) { char *path = data_to_str (path_data); @@ -106,7 +106,7 @@ af_unix_client_bind (rpc_transport_t *this, ret = bind (sock, (struct sockaddr *)addr, sockaddr_len); if (ret == -1) { gf_log (this->name, GF_LOG_ERROR, - "cannot bind to unix-domain socket %d (%s)", + "cannot bind to unix-domain socket %d (%s)", sock, strerror (errno)); goto err; } @@ -121,24 +121,24 @@ client_fill_address_family (rpc_transport_t *this, struct sockaddr *sockaddr) { data_t *address_family_data = NULL; - address_family_data = dict_get (this->options, + address_family_data = dict_get (this->options, "transport.address-family"); if (!address_family_data) { data_t *remote_host_data = NULL, *connect_path_data = NULL; remote_host_data = dict_get (this->options, "remote-host"); - connect_path_data = dict_get (this->options, + connect_path_data = dict_get (this->options, "transport.rdma.connect-path"); - if (!(remote_host_data || connect_path_data) || + if (!(remote_host_data || connect_path_data) || (remote_host_data && connect_path_data)) { gf_log (this->name, GF_LOG_ERROR, "address-family not specified and not able to " "determine the same from other options " - "(remote-host:%s and connect-path:%s)", - data_to_str (remote_host_data), + "(remote-host:%s and connect-path:%s)", + data_to_str (remote_host_data), data_to_str (connect_path_data)); return -1; - } + } if (remote_host_data) { gf_log (this->name, GF_LOG_DEBUG, @@ -167,7 +167,7 @@ client_fill_address_family (rpc_transport_t *this, struct sockaddr *sockaddr) sockaddr->sa_family = AF_UNSPEC; } else { gf_log (this->name, GF_LOG_ERROR, - "unknown address-family (%s) specified", + "unknown address-family (%s) specified", address_family); return -1; } @@ -177,8 +177,8 @@ client_fill_address_family (rpc_transport_t *this, struct sockaddr *sockaddr) } static int32_t -af_inet_client_get_remote_sockaddr (rpc_transport_t *this, - struct sockaddr *sockaddr, +af_inet_client_get_remote_sockaddr (rpc_transport_t *this, + struct sockaddr *sockaddr, socklen_t *sockaddr_len, int16_t remote_port) { @@ -193,7 +193,7 @@ af_inet_client_get_remote_sockaddr (rpc_transport_t *this, if (remote_host_data == NULL) { gf_log (this->name, GF_LOG_ERROR, - "option remote-host missing in volume %s", + "option remote-host missing in volume %s", this->name); ret = -1; goto err; @@ -203,7 +203,7 @@ af_inet_client_get_remote_sockaddr (rpc_transport_t *this, if (remote_host == NULL) { gf_log (this->name, GF_LOG_ERROR, - "option remote-host has data NULL in volume %s", + "option remote-host has data NULL in volume %s", this->name); ret = -1; goto err; @@ -238,7 +238,7 @@ af_inet_client_get_remote_sockaddr (rpc_transport_t *this, /* TODO: gf_resolve is a blocking call. kick in some non blocking dns techniques */ ret = gf_resolve_ip6 (remote_host, remote_port, - sockaddr->sa_family, + sockaddr->sa_family, &this->dnscache, &addr_info); if (ret == -1) { gf_log (this->name, GF_LOG_ERROR, @@ -254,8 +254,8 @@ err: } static int32_t -af_unix_client_get_remote_sockaddr (rpc_transport_t *this, - struct sockaddr *sockaddr, +af_unix_client_get_remote_sockaddr (rpc_transport_t *this, + struct sockaddr *sockaddr, socklen_t *sockaddr_len) { struct sockaddr_un *sockaddr_un = NULL; @@ -263,7 +263,7 @@ af_unix_client_get_remote_sockaddr (rpc_transport_t *this, data_t *connect_path_data = NULL; int32_t ret = 0; - connect_path_data = dict_get (this->options, + connect_path_data = dict_get (this->options, "transport.rdma.connect-path"); if (!connect_path_data) { gf_log (this->name, GF_LOG_ERROR, @@ -311,7 +311,7 @@ af_unix_server_get_local_sockaddr (rpc_transport_t *this, struct sockaddr_un *sunaddr = (struct sockaddr_un *)addr; - listen_path_data = dict_get (this->options, + listen_path_data = dict_get (this->options, "transport.rdma.listen-path"); if (!listen_path_data) { gf_log (this->name, GF_LOG_ERROR, @@ -342,9 +342,9 @@ err: return ret; } -static int32_t -af_inet_server_get_local_sockaddr (rpc_transport_t *this, - struct sockaddr *addr, +static int32_t +af_inet_server_get_local_sockaddr (rpc_transport_t *this, + struct sockaddr *addr, socklen_t *addr_len) { struct addrinfo hints, *res = 0; @@ -364,20 +364,20 @@ af_inet_server_get_local_sockaddr (rpc_transport_t *this, { listen_port = data_to_uint16 (listen_port_data); } else { - if (addr->sa_family == AF_INET6) { - struct sockaddr_in6 *in = (struct sockaddr_in6 *) addr; - in->sin6_addr = in6addr_any; - in->sin6_port = htons(listen_port); - *addr_len = sizeof(struct sockaddr_in6); + if (addr->sa_family == AF_INET6) { + struct sockaddr_in6 *in = (struct sockaddr_in6 *) addr; + in->sin6_addr = in6addr_any; + in->sin6_port = htons(listen_port); + *addr_len = sizeof(struct sockaddr_in6); goto out; - } else if (addr->sa_family == AF_INET) { - struct sockaddr_in *in = (struct sockaddr_in *) addr; - in->sin_addr.s_addr = htonl(INADDR_ANY); - in->sin_port = htons(listen_port); - *addr_len = sizeof(struct sockaddr_in); + } else if (addr->sa_family == AF_INET) { + struct sockaddr_in *in = (struct sockaddr_in *) addr; + in->sin_addr.s_addr = htonl(INADDR_ANY); + in->sin_port = htons(listen_port); + *addr_len = sizeof(struct sockaddr_in); goto out; - } - } + } + } if (listen_port == (uint16_t) -1) listen_port = GF_DEFAULT_RDMA_LISTEN_PORT; @@ -400,7 +400,7 @@ af_inet_server_get_local_sockaddr (rpc_transport_t *this, if (ret != 0) { gf_log (this->name, GF_LOG_ERROR, - "getaddrinfo failed for host %s, service %s (%s)", + "getaddrinfo failed for host %s, service %s (%s)", listen_host, service, gai_strerror (ret)); ret = -1; goto out; @@ -417,9 +417,9 @@ out: int32_t gf_rdma_client_bind (rpc_transport_t *this, - struct sockaddr *sockaddr, - socklen_t *sockaddr_len, - int sock) + struct sockaddr *sockaddr, + socklen_t *sockaddr_len, + int sock) { int ret = 0; @@ -431,13 +431,13 @@ gf_rdma_client_bind (rpc_transport_t *this, *sockaddr_len = sizeof (struct sockaddr_in); case AF_INET6: - ret = af_inet_bind_to_port_lt_ceiling (sock, sockaddr, - *sockaddr_len, + ret = af_inet_bind_to_port_lt_ceiling (sock, sockaddr, + *sockaddr_len, CLIENT_PORT_CEILING); if (ret == -1) { gf_log (this->name, GF_LOG_WARNING, "cannot bind inet socket (%d) to port " - "less than %d (%s)", + "less than %d (%s)", sock, CLIENT_PORT_CEILING, strerror (errno)); ret = 0; } @@ -445,7 +445,7 @@ gf_rdma_client_bind (rpc_transport_t *this, case AF_UNIX: *sockaddr_len = sizeof (struct sockaddr_un); - ret = af_unix_client_bind (this, (struct sockaddr *)sockaddr, + ret = af_unix_client_bind (this, (struct sockaddr *)sockaddr, *sockaddr_len, sock); break; @@ -473,7 +473,7 @@ gf_rdma_client_get_remote_sockaddr (rpc_transport_t *this, ret = -1; goto err; } - + switch (sockaddr->sa_family) { case AF_INET_SDP: @@ -483,7 +483,7 @@ gf_rdma_client_get_remote_sockaddr (rpc_transport_t *this, case AF_INET: case AF_INET6: case AF_UNSPEC: - ret = af_inet_client_get_remote_sockaddr (this, + ret = af_inet_client_get_remote_sockaddr (this, sockaddr, sockaddr_len, remote_port); @@ -495,8 +495,8 @@ gf_rdma_client_get_remote_sockaddr (rpc_transport_t *this, break; case AF_UNIX: - ret = af_unix_client_get_remote_sockaddr (this, - sockaddr, + ret = af_unix_client_get_remote_sockaddr (this, + sockaddr, sockaddr_len); break; @@ -505,21 +505,21 @@ gf_rdma_client_get_remote_sockaddr (rpc_transport_t *this, "unknown address-family %d", sockaddr->sa_family); ret = -1; } - + err: return ret; } int32_t gf_rdma_server_get_local_sockaddr (rpc_transport_t *this, - struct sockaddr *addr, - socklen_t *addr_len) + struct sockaddr *addr, + socklen_t *addr_len) { data_t *address_family_data = NULL; int32_t ret = 0; char is_inet_sdp = 0; - address_family_data = dict_get (this->options, + address_family_data = dict_get (this->options, "transport.address-family"); if (address_family_data) { char *address_family = NULL; @@ -538,7 +538,7 @@ gf_rdma_server_get_local_sockaddr (rpc_transport_t *this, addr->sa_family = AF_UNSPEC; } else { gf_log (this->name, GF_LOG_ERROR, - "unknown address family (%s) specified", + "unknown address family (%s) specified", address_family); ret = -1; goto err; @@ -574,8 +574,8 @@ err: return ret; } -int32_t -fill_inet6_inet_identifiers (rpc_transport_t *this, struct sockaddr_storage *addr, +int32_t +fill_inet6_inet_identifiers (rpc_transport_t *this, struct sockaddr_storage *addr, int32_t addr_len, char *identifier) { int32_t ret = 0, tmpaddr_len = 0; @@ -589,45 +589,45 @@ fill_inet6_inet_identifiers (rpc_transport_t *this, struct sockaddr_storage *add if (((struct sockaddr *) &tmpaddr)->sa_family == AF_INET6) { int32_t one_to_four, four_to_eight, twelve_to_sixteen; int16_t eight_to_ten, ten_to_twelve; - + one_to_four = four_to_eight = twelve_to_sixteen = 0; eight_to_ten = ten_to_twelve = 0; - - one_to_four = ((struct sockaddr_in6 *) + + one_to_four = ((struct sockaddr_in6 *) &tmpaddr)->sin6_addr.s6_addr32[0]; - four_to_eight = ((struct sockaddr_in6 *) + four_to_eight = ((struct sockaddr_in6 *) &tmpaddr)->sin6_addr.s6_addr32[1]; #ifdef GF_SOLARIS_HOST_OS - eight_to_ten = S6_ADDR16(((struct sockaddr_in6 *) + eight_to_ten = S6_ADDR16(((struct sockaddr_in6 *) &tmpaddr)->sin6_addr)[4]; #else - eight_to_ten = ((struct sockaddr_in6 *) + eight_to_ten = ((struct sockaddr_in6 *) &tmpaddr)->sin6_addr.s6_addr16[4]; #endif #ifdef GF_SOLARIS_HOST_OS - ten_to_twelve = S6_ADDR16(((struct sockaddr_in6 *) + ten_to_twelve = S6_ADDR16(((struct sockaddr_in6 *) &tmpaddr)->sin6_addr)[5]; #else - ten_to_twelve = ((struct sockaddr_in6 *) + ten_to_twelve = ((struct sockaddr_in6 *) &tmpaddr)->sin6_addr.s6_addr16[5]; #endif - twelve_to_sixteen = ((struct sockaddr_in6 *) + twelve_to_sixteen = ((struct sockaddr_in6 *) &tmpaddr)->sin6_addr.s6_addr32[3]; /* ipv4 mapped ipv6 address has bits 0-80: 0 bits 80-96: 0xffff - bits 96-128: ipv4 address + bits 96-128: ipv4 address */ - + if (one_to_four == 0 && four_to_eight == 0 && eight_to_ten == 0 && ten_to_twelve == -1) { struct sockaddr_in *in_ptr = (struct sockaddr_in *)&tmpaddr; memset (&tmpaddr, 0, sizeof (tmpaddr)); - + in_ptr->sin_family = AF_INET; in_ptr->sin_port = ((struct sockaddr_in6 *)addr)->sin6_port; in_ptr->sin_addr.s_addr = twelve_to_sixteen; @@ -666,8 +666,8 @@ gf_rdma_get_transport_identifiers (rpc_transport_t *this) case AF_INET: case AF_INET6: { - ret = fill_inet6_inet_identifiers (this, - &this->myinfo.sockaddr, + ret = fill_inet6_inet_identifiers (this, + &this->myinfo.sockaddr, this->myinfo.sockaddr_len, this->myinfo.identifier); if (ret == -1) { @@ -705,7 +705,7 @@ gf_rdma_get_transport_identifiers (rpc_transport_t *this) break; default: - gf_log (this->name, GF_LOG_ERROR, + gf_log (this->name, GF_LOG_ERROR, "unknown address family (%d)", ((struct sockaddr *) &this->myinfo.sockaddr)->sa_family); ret = -1; diff --git a/rpc/rpc-transport/rdma/src/rdma.c b/rpc/rpc-transport/rdma/src/rdma.c index 633f57db5b3..81e6e3cf632 100644 --- a/rpc/rpc-transport/rdma/src/rdma.c +++ b/rpc/rpc-transport/rdma/src/rdma.c @@ -44,13 +44,13 @@ int rdma_post_unref (rdma_post_t *post); int32_t -gf_resolve_ip6 (const char *hostname, - uint16_t port, - int family, - void **dnscache, +gf_resolve_ip6 (const char *hostname, + uint16_t port, + int family, + void **dnscache, struct addrinfo **addr_info); -static uint16_t +static uint16_t rdma_get_local_lid (struct ibv_context *context, int32_t port) { @@ -65,14 +65,14 @@ rdma_get_local_lid (struct ibv_context *context, static const char * get_port_state_str(enum ibv_port_state pstate) { - switch (pstate) { - case IBV_PORT_DOWN: return "PORT_DOWN"; - case IBV_PORT_INIT: return "PORT_INIT"; - case IBV_PORT_ARMED: return "PORT_ARMED"; - case IBV_PORT_ACTIVE: return "PORT_ACTIVE"; - case IBV_PORT_ACTIVE_DEFER: return "PORT_ACTIVE_DEFER"; - default: return "invalid state"; - } + switch (pstate) { + case IBV_PORT_DOWN: return "PORT_DOWN"; + case IBV_PORT_INIT: return "PORT_INIT"; + case IBV_PORT_ARMED: return "PORT_ARMED"; + case IBV_PORT_ACTIVE: return "PORT_ACTIVE"; + case IBV_PORT_ACTIVE_DEFER: return "PORT_ACTIVE_DEFER"; + default: return "invalid state"; + } } static int32_t @@ -84,10 +84,10 @@ ib_check_active_port (struct ibv_context *ctx, uint8_t port) const char *state_str = NULL; if (!ctx) { - gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, + gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "Error in supplied context"); return -1; - } + } ret = ibv_query_port (ctx, port, &port_attr); @@ -105,29 +105,29 @@ ib_check_active_port (struct ibv_context *ctx, uint8_t port) if (port_attr.state == IBV_PORT_ACTIVE) return 0; - return -1; + return -1; } static int32_t ib_get_active_port (struct ibv_context *ib_ctx) { - struct ibv_device_attr ib_device_attr; + struct ibv_device_attr ib_device_attr; - int32_t ret = -1; - uint8_t ib_port = 0; + int32_t ret = -1; + uint8_t ib_port = 0; - if (!ib_ctx) { - gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, + if (!ib_ctx) { + gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "Error in supplied context"); - return -1; - } - if (ibv_query_device (ib_ctx, &ib_device_attr)) { - gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, + return -1; + } + if (ibv_query_device (ib_ctx, &ib_device_attr)) { + gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "Failed to query device properties"); - return -1; - } + return -1; + } - for (ib_port = 1; ib_port <= ib_device_attr.phys_port_cnt; ++ib_port) { + for (ib_port = 1; ib_port <= ib_device_attr.phys_port_cnt; ++ib_port) { ret = ib_check_active_port (ib_ctx, ib_port); if (ret == 0) return ib_port; @@ -135,8 +135,8 @@ ib_get_active_port (struct ibv_context *ib_ctx) gf_log (RDMA_LOG_NAME, GF_LOG_TRACE, "Port:(%u) not active", ib_port); continue; - } - return ret; + } + return ret; } @@ -228,7 +228,7 @@ rdma_get_post (rdma_queue_t *queue) post = queue->passive_posts.next; if (post == &queue->passive_posts) post = NULL; - + if (post) { if (post->prev) post->prev->next = post->next; @@ -286,7 +286,7 @@ __rdma_quota_get (rdma_peer_t *peer) } */ -static void +static void __rdma_ioq_entry_free (rdma_ioq_t *entry) { list_del_init (&entry->list); @@ -333,7 +333,7 @@ __rdma_disconnect (rpc_transport_t *this) priv->tcp_connected = 0; } } - + return ret; } @@ -368,7 +368,7 @@ __rdma_encode_error(rdma_peer_t *peer, rdma_reply_info_t *reply_info, struct iovec *rpchdr, uint32_t *ptr, rdma_errcode_t err) { - uint32_t *startp = NULL; + uint32_t *startp = NULL; struct rpc_msg *rpc_msg = NULL; startp = ptr; @@ -382,16 +382,16 @@ __rdma_encode_error(rdma_peer_t *peer, rdma_reply_info_t *reply_info, *ptr++ = rpc_msg->rm_xid; } - *ptr++ = hton32(RDMA_VERSION); - *ptr++ = hton32(peer->send_count); - *ptr++ = hton32(RDMA_ERROR); - *ptr++ = hton32(err); - if (err == ERR_VERS) { - *ptr++ = hton32(RDMA_VERSION); - *ptr++ = hton32(RDMA_VERSION); - } + *ptr++ = hton32(RDMA_VERSION); + *ptr++ = hton32(peer->send_count); + *ptr++ = hton32(RDMA_ERROR); + *ptr++ = hton32(err); + if (err == ERR_VERS) { + *ptr++ = hton32(RDMA_VERSION); + *ptr++ = hton32(RDMA_VERSION); + } - return (int)((unsigned long)ptr - (unsigned long)startp); + return (int)((unsigned long)ptr - (unsigned long)startp); } @@ -438,7 +438,7 @@ __rdma_create_read_chunks_from_vector (rdma_peer_t *peer, rdma_private_t *priv = NULL; rdma_device_t *device = NULL; struct ibv_mr *mr = NULL; - rdma_read_chunk_t *readch = NULL; + rdma_read_chunk_t *readch = NULL; int32_t ret = -1; if ((peer == NULL) || (readch_ptr == NULL) || (*readch_ptr == NULL) @@ -576,7 +576,7 @@ __rdma_create_write_chunks_from_vector (rdma_peer_t *peer, rdma_private_t *priv = NULL; rdma_device_t *device = NULL; struct ibv_mr *mr = NULL; - rdma_write_chunk_t *writech = NULL; + rdma_write_chunk_t *writech = NULL; int32_t ret = -1; if ((peer == NULL) || (writech_ptr == NULL) || (*writech_ptr == NULL) @@ -588,7 +588,7 @@ __rdma_create_write_chunks_from_vector (rdma_peer_t *peer, priv = peer->trans->private; device = priv->device; - + for (i = 0; i < count; i++) { mr = ibv_reg_mr (device->pd, vector[i].iov_base, vector[i].iov_len, @@ -645,15 +645,15 @@ __rdma_create_write_chunks (rdma_peer_t *peer, rdma_ioq_t *entry, } /* - if ((chunk_type == rdma_writech) - && ((entry->msg.request.rsphdr_count == 0) - || (entry->msg.request.rsphdr_vec[0].iov_base == NULL))) { - gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG, - "vector specifying buffer to hold the program's reply " - "header should also be provided when buffers are " - "provided for holding the program's payload in reply"); - goto out; - } + if ((chunk_type == rdma_writech) + && ((entry->msg.request.rsphdr_count == 0) + || (entry->msg.request.rsphdr_vec[0].iov_base == NULL))) { + gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG, + "vector specifying buffer to hold the program's reply " + "header should also be provided when buffers are " + "provided for holding the program's payload in reply"); + goto out; + } */ if (chunk_type == rdma_writech) { @@ -684,7 +684,7 @@ __rdma_create_write_chunks (rdma_peer_t *peer, rdma_ioq_t *entry, **ptr = 0; *ptr = *ptr + 1; } else { - /* no write chunklist */ + /* no write chunklist */ **ptr = 0; *ptr = *ptr + 1; @@ -693,7 +693,7 @@ __rdma_create_write_chunks (rdma_peer_t *peer, rdma_ioq_t *entry, warray->wc_nchunks = hton32 (entry->msg.request.rsphdr_count); *ptr = (uint32_t *)&warray->wc_array[0]; - + ret = __rdma_create_write_chunks_from_vector (peer, (rdma_write_chunk_t **)ptr, entry->msg.request.rsphdr_vec, @@ -918,7 +918,7 @@ rdma_post_ref (rdma_post_t *post) post->refcount++; } pthread_mutex_unlock (&post->lock); - + out: return post; } @@ -928,7 +928,7 @@ int32_t __rdma_ioq_churn_request (rdma_peer_t *peer, rdma_ioq_t *entry, rdma_post_t *post) { - rdma_chunktype_t rtype = rdma_noch, wtype = rdma_noch; + rdma_chunktype_t rtype = rdma_noch, wtype = rdma_noch; uint64_t send_size = 0; rdma_header_t *hdr = NULL; struct rpc_msg *rpc_msg = NULL; @@ -1086,7 +1086,7 @@ __rdma_ioq_churn_request (rdma_peer_t *peer, rdma_ioq_t *entry, } len = buf - post->buf; - + rdma_post_ref (post); ret = rdma_post_send (peer->qp, post, len); @@ -1127,9 +1127,9 @@ __rdma_fill_reply_header (rdma_header_t *header, struct iovec *rpchdr, header->rm_xid = hton32 (reply_info->rm_xid); } else { rpc_msg = rpchdr[0].iov_base; /* assume rpchdr contains - * only one vector. - * (which is true) - */ + * only one vector. + * (which is true) + */ header->rm_xid = rpc_msg->rm_xid; } @@ -1188,7 +1188,7 @@ __rdma_send_reply_inline (rdma_peer_t *peer, rdma_ioq_t *entry, iov_unload (buf, entry->proghdr, entry->proghdr_count); buf += iov_length (entry->proghdr, entry->proghdr_count); } - + if (entry->prog_payload_count != 0) { iov_unload (buf, entry->prog_payload, entry->prog_payload_count); @@ -1250,7 +1250,7 @@ __rdma_reply_encode_write_chunks (rdma_peer_t *peer, uint32_t payload_size, target_array->wc_array[i].wc_target.rs_length = hton32 (min (payload_size, - reply_info->wc_array->wc_array[i].wc_target.rs_length)); + reply_info->wc_array->wc_array[i].wc_target.rs_length)); } target_array->wc_nchunks = hton32 (i); @@ -1313,7 +1313,7 @@ out: * 2. modifies vec */ int32_t -__rdma_write (rdma_peer_t *peer, rdma_post_t *post, struct iovec *vec, +__rdma_write (rdma_peer_t *peer, rdma_post_t *post, struct iovec *vec, uint32_t xfer_len, int *idx, rdma_write_chunk_t *writech) { int size = 0, num_sge = 0, i = 0; @@ -1389,7 +1389,7 @@ __rdma_do_rdma_write (rdma_peer_t *peer, rdma_post_t *post, int i = 0, payload_idx = 0; uint32_t payload_size = 0, xfer_len = 0; int32_t ret = -1; - + if (count != 0) { payload_size = iov_length (vector, count); } @@ -1488,7 +1488,7 @@ __rdma_send_reply_type_nomsg (rdma_peer_t *peer, rdma_ioq_t *entry, if (ret) { gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG, "rdma_post_send to client (%s) failed with " - "ret = %d (%s)", peer->trans->peerinfo.identifier, ret, + "ret = %d (%s)", peer->trans->peerinfo.identifier, ret, (ret > 0) ? strerror (ret) : ""); ret = -1; rdma_post_unref (post); @@ -1689,7 +1689,7 @@ __rdma_ioq_churn_entry (rdma_peer_t *peer, rdma_ioq_t *entry) quota = __rdma_quota_get (peer); if (quota > 0) { post = rdma_get_post (&device->sendq); - if (post == NULL) { + if (post == NULL) { post = rdma_new_post (device, (options->send_size + 2048), RDMA_SEND_POST); @@ -1821,7 +1821,7 @@ rdma_ioq_new (rpc_transport_t *this, rpc_transport_data_t *data) if (data->data.req.rsp.rsp_payload_count != 0) { for (i = 0; i < data->data.req.rsp.rsp_payload_count; i++) { - entry->msg.request.rsp_payload[i] + entry->msg.request.rsp_payload[i] = data->data.req.rsp.rsp_payload[i]; } @@ -1881,7 +1881,7 @@ rdma_submit_request (rpc_transport_t *this, { int32_t ret = 0; rdma_ioq_t *entry = NULL; - rpc_transport_data_t data = {0, }; + rpc_transport_data_t data = {0, }; if (req == NULL) { goto out; @@ -1985,7 +1985,7 @@ rdma_receive (rpc_transport_t *this, char **hdr_p, size_t *hdrlen_p, ret = -1; goto err; } - + copy_from += sizeof (*header); if (size1) { @@ -2027,11 +2027,11 @@ rdma_destroy_cq (rpc_transport_t *this) { rdma_private_t *priv = this->private; rdma_device_t *device = priv->device; - + if (device->recv_cq) ibv_destroy_cq (device->recv_cq); device->recv_cq = NULL; - + if (device->send_cq) ibv_destroy_cq (device->send_cq); device->send_cq = NULL; @@ -2072,7 +2072,7 @@ rdma_create_cq (rpc_transport_t *this) ret = -1; goto out; } - + do { ret = ibv_query_device (priv->device->context, &device_attr); if (ret != 0) { @@ -2219,7 +2219,7 @@ __rdma_lookup_peer (rdma_device_t *device, int32_t qp_num) { rdma_qpreg_t *qpreg = NULL; rdma_peer_t *peer = NULL; - + qpreg = &device->qpreg; pthread_mutex_lock (&qpreg->lock); { @@ -2269,7 +2269,7 @@ rdma_create_qp (rpc_transport_t *this) }, .qp_type = IBV_QPT_RC }; - + struct ibv_qp_attr attr = { .qp_state = IBV_QPS_INIT, .pkey_index = 0, @@ -2277,7 +2277,7 @@ rdma_create_qp (rpc_transport_t *this) .qp_access_flags = IBV_ACCESS_REMOTE_READ | IBV_ACCESS_REMOTE_WRITE }; - + peer->qp = ibv_create_qp (device->pd, &init_attr); if (!peer->qp) { gf_log (RDMA_LOG_NAME, @@ -2504,7 +2504,7 @@ __tcp_rwv (rpc_transport_t *this, struct iovec *vector, int count, if (ret == 0) { - gf_log (this->name, GF_LOG_DEBUG, + gf_log (this->name, GF_LOG_DEBUG, "EOF from peer %s", this->peerinfo.identifier); opcount = -1; errno = ENOTCONN; @@ -2519,7 +2519,7 @@ __tcp_rwv (rpc_transport_t *this, struct iovec *vector, int count, gf_log (this->name, GF_LOG_DEBUG, "%s failed (%s)", write ? "writev" : "readv", strerror (errno)); - if (write && !priv->connected && + if (write && !priv->connected && (errno == ECONNREFUSED)) gf_log (this->name, GF_LOG_ERROR, "possible mismatch of 'rpc-transport-type'" @@ -2569,7 +2569,7 @@ __tcp_readv (rpc_transport_t *this, struct iovec *vector, int count, { int ret = -1; - ret = __tcp_rwv (this, vector, count, + ret = __tcp_rwv (this, vector, count, pending_vector, pending_count, 0); return ret; @@ -2583,16 +2583,16 @@ __tcp_writev (rpc_transport_t *this, struct iovec *vector, int count, int ret = -1; rdma_private_t *priv = this->private; - ret = __tcp_rwv (this, vector, count, pending_vector, + ret = __tcp_rwv (this, vector, count, pending_vector, pending_count, 1); if (ret > 0) { - /* TODO: Avoid multiple calls when socket is already + /* TODO: Avoid multiple calls when socket is already registered for POLLOUT */ - priv->idx = event_select_on (this->ctx->event_pool, + priv->idx = event_select_on (this->ctx->event_pool, priv->sock, priv->idx, -1, 1); } else if (ret == 0) { - priv->idx = event_select_on (this->ctx->event_pool, + priv->idx = event_select_on (this->ctx->event_pool, priv->sock, priv->idx, -1, 0); } @@ -2696,14 +2696,14 @@ rdma_decode_error_msg (rdma_peer_t *peer, rdma_post_t *post, struct iobuf *iobuf = NULL; struct iobref *iobref = NULL; int32_t ret = -1; - + header = (rdma_header_t *)post->buf; header->rm_body.rm_error.rm_type = ntoh32 (header->rm_body.rm_error.rm_type); if (header->rm_body.rm_error.rm_type == ERR_VERS) { - header->rm_body.rm_error.rm_version.rdma_vers_low = + header->rm_body.rm_error.rm_version.rdma_vers_low = ntoh32 (header->rm_body.rm_error.rm_version.rdma_vers_low); - header->rm_body.rm_error.rm_version.rdma_vers_high = + header->rm_body.rm_error.rm_version.rdma_vers_high = ntoh32 (header->rm_body.rm_error.rm_version.rdma_vers_high); } @@ -2761,7 +2761,7 @@ rdma_decode_msg (rdma_peer_t *peer, rdma_post_t *post, rdma_reply_info_t *reply_info = NULL; char *ptr = NULL; rdma_write_array_t *write_ary = NULL; - size_t header_len = 0; + size_t header_len = 0; header = (rdma_header_t *)post->buf; @@ -2939,7 +2939,7 @@ rdma_do_reads (rdma_peer_t *peer, rdma_post_t *post, rdma_read_chunk_t *readch) { int32_t ret = -1, i = 0, count = 0; size_t size = 0; - char *ptr = NULL; + char *ptr = NULL; struct iobuf *iobuf = NULL; rdma_private_t *priv = NULL; @@ -3049,7 +3049,7 @@ rdma_pollin_notify (rdma_peer_t *peer, rdma_post_t *post) goto out; } - /* handling the case where both hdr and payload of + /* handling the case where both hdr and payload of * GF_FOP_READ_CBK were recieved in a single iobuf * because of server sending entire msg as inline without * doing rdma writes. @@ -3080,7 +3080,7 @@ rdma_pollin_notify (rdma_peer_t *peer, rdma_post_t *post) if (ret == -1) { gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG, "cannot get request information from rpc " - "layer"); + "layer"); goto out; } @@ -3132,7 +3132,7 @@ rdma_recv_reply (rdma_peer_t *peer, rdma_post_t *post) int i = 0; uint32_t *ptr = NULL; rdma_request_context_t *ctx = NULL; - rpc_request_info_t request_info = {0, }; + rpc_request_info_t request_info = {0, }; struct rpc_req *rpc_req = NULL; header = (rdma_header_t *)post->buf; @@ -3160,7 +3160,7 @@ rdma_recv_reply (rdma_peer_t *peer, rdma_post_t *post) post->ctx.vector[i + 1].iov_len = wc_array->wc_array[i].wc_target.rs_length; } - + post->ctx.count += wc_array->wc_nchunks; } @@ -3173,7 +3173,7 @@ rdma_recv_reply (rdma_peer_t *peer, rdma_post_t *post) if (ret == -1) { gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG, "cannot get request information from rpc " - "layer"); + "layer"); goto out; } @@ -3208,7 +3208,7 @@ rdma_recv_request (rdma_peer_t *peer, rdma_post_t *post, rdma_read_chunk_t *readch) { int32_t ret = -1; - + if (readch != NULL) { ret = rdma_do_reads (peer, post, readch); } else { @@ -3322,7 +3322,7 @@ rdma_recv_completion_proc (void *data) } device = event_ctx; - + ret = ibv_req_notify_cq (event_cq, 0); if (ret) { gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, @@ -3382,7 +3382,7 @@ rdma_recv_completion_proc (void *data) rdma_post_unref (post); } - + if (ret < 0) { gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, @@ -3419,7 +3419,7 @@ rdma_handle_failed_send_completion (rdma_peer_t *peer, struct ibv_wc *wc) "send work request on `%s' returned error " "wc.status = %d, wc.vendor_err = %d, post->buf = %p, " "wc.byte_len = %d, post->reused = %d", - (device != NULL) ? device->device_name : NULL, wc->status, + (device != NULL) ? device->device_name : NULL, wc->status, wc->vendor_err, post->buf, wc->byte_len, post->reused); if (wc->status == IBV_WC_RETRY_EXC_ERR) { @@ -3484,7 +3484,7 @@ rdma_send_completion_proc (void *data) struct ibv_wc wc = {0, }; char is_request = 0; int32_t ret = 0, quota_ret = 0; - + chan = data; while (1) { ret = ibv_get_cq_event (chan, &event_cq, &event_ctx); @@ -3494,7 +3494,7 @@ rdma_send_completion_proc (void *data) "send thread: %d (%d)", ret, errno); continue; } - + device = event_ctx; ret = ibv_req_notify_cq (event_cq, 0); @@ -3542,12 +3542,12 @@ rdma_send_completion_proc (void *data) && (post->type == RDMA_SEND_POST) && (peer != NULL)) { /* An RDMA_RECV_POST can end up in - * rdma_send_completion_proc for + * rdma_send_completion_proc for * rdma-reads, and we do not take * quota for getting an RDMA_RECV_POST. */ - /* + /* * if it is request, quota is returned * after reply has come. */ @@ -3577,7 +3577,7 @@ rdma_send_completion_proc (void *data) continue; } - ibv_ack_cq_events (event_cq, 1); + ibv_ack_cq_events (event_cq, 1); } return NULL; @@ -3688,7 +3688,7 @@ rdma_get_device (rpc_transport_t *this, port = priv->options.port; while (trav) { - if ((!strcmp (trav->device_name, device_name)) && + if ((!strcmp (trav->device_name, device_name)) && (trav->port == port)) break; trav = trav->next; @@ -3696,7 +3696,7 @@ rdma_get_device (rpc_transport_t *this, if (!trav) { - trav = GF_CALLOC (1, sizeof (*trav), + trav = GF_CALLOC (1, sizeof (*trav), gf_common_mt_rdma_device_t); if (trav == NULL) { gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory"); @@ -3707,18 +3707,18 @@ rdma_get_device (rpc_transport_t *this, trav->context = ibctx; - ret = ib_get_active_port (trav->context); + ret = ib_get_active_port (trav->context); - if (ret < 0) { - if (!port) { - gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, - "Failed to find any active ports and " - "none specified in volume file," + if (ret < 0) { + if (!port) { + gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, + "Failed to find any active ports and " + "none specified in volume file," " exiting"); GF_FREE (trav); - return NULL; - } - } + return NULL; + } + } trav->request_ctx_pool = mem_pool_new (rdma_request_context_t, RDMA_POOL_SIZE); @@ -3744,7 +3744,7 @@ rdma_get_device (rpc_transport_t *this, } - active_port = ret; + active_port = ret; if (port) { ret = ib_check_active_port (trav->context, port); @@ -3754,11 +3754,11 @@ rdma_get_device (rpc_transport_t *this, "found to be offline, continuing to " "use the same port", device_name, port); } - } else { - priv->options.port = active_port; - port = active_port; - gf_log (RDMA_LOG_NAME, GF_LOG_TRACE, - "Port unspecified in volume file using active " + } else { + priv->options.port = active_port; + port = active_port; + gf_log (RDMA_LOG_NAME, GF_LOG_TRACE, + "Port unspecified in volume file using active " "port: %u", port); } @@ -3780,7 +3780,7 @@ rdma_get_device (rpc_transport_t *this, GF_FREE (trav); return NULL; } - + trav->recv_chan = ibv_create_comp_channel (trav->context); if (!trav->recv_chan) { mem_pool_destroy (trav->ioq_pool); @@ -3794,7 +3794,7 @@ rdma_get_device (rpc_transport_t *this, /* TODO: cleanup current mess */ return NULL; } - + if (rdma_create_cq (this) < 0) { mem_pool_destroy (trav->ioq_pool); mem_pool_destroy (trav->request_ctx_pool); @@ -3914,7 +3914,7 @@ rdma_get_device (rpc_transport_t *this, "could not create recv completion thread"); return NULL; } - + /* qpreg */ pthread_mutex_init (&trav->qpreg.lock, NULL); for (i=0; i<42; i++) { @@ -3925,39 +3925,39 @@ rdma_get_device (rpc_transport_t *this, return trav; } -static int32_t +static int32_t rdma_init (rpc_transport_t *this) { rdma_private_t *priv = this->private; rdma_options_t *options = &priv->options; struct ibv_device **dev_list; - struct ibv_context *ib_ctx = NULL; - int32_t ret = 0; + struct ibv_context *ib_ctx = NULL; + int32_t ret = 0; rdma_options_init (this); { dev_list = ibv_get_device_list (NULL); - if (!dev_list) { + if (!dev_list) { gf_log (RDMA_LOG_NAME, GF_LOG_CRITICAL, "Failed to get IB devices"); - ret = -1; - goto cleanup; + ret = -1; + goto cleanup; } if (!*dev_list) { gf_log (RDMA_LOG_NAME, GF_LOG_CRITICAL, "No IB devices found"); - ret = -1; + ret = -1; goto cleanup; } if (!options->device_name) { if (*dev_list) { - options->device_name = + options->device_name = gf_strdup (ibv_get_device_name (*dev_list)); } else { gf_log (RDMA_LOG_NAME, GF_LOG_CRITICAL, @@ -3968,7 +3968,7 @@ rdma_init (rpc_transport_t *this) } } - while (*dev_list) { + while (*dev_list) { if (!strcmp (ibv_get_device_name (*dev_list), options->device_name)) { ib_ctx = ibv_open_device (*dev_list); @@ -3983,38 +3983,38 @@ rdma_init (rpc_transport_t *this) } break; } - ++dev_list; - } + ++dev_list; + } - priv->device = rdma_get_device (this, ib_ctx); + priv->device = rdma_get_device (this, ib_ctx); if (!priv->device) { gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "could not create rdma device for %s", options->device_name); ret = -1; - goto cleanup; + goto cleanup; } } priv->peer.trans = this; INIT_LIST_HEAD (&priv->peer.ioq); - + pthread_mutex_init (&priv->read_mutex, NULL); pthread_mutex_init (&priv->write_mutex, NULL); pthread_mutex_init (&priv->recv_mutex, NULL); pthread_cond_init (&priv->recv_cond, NULL); cleanup: - if (-1 == ret) { - if (ib_ctx) - ibv_close_device (ib_ctx); - } + if (-1 == ret) { + if (ib_ctx) + ibv_close_device (ib_ctx); + } - if (dev_list) - ibv_free_device_list (dev_list); + if (dev_list) + ibv_free_device_list (dev_list); - return ret; + return ret; } @@ -4023,7 +4023,7 @@ rdma_disconnect (rpc_transport_t *this) { rdma_private_t *priv = this->private; int32_t ret = 0; - + pthread_mutex_lock (&priv->write_mutex); { ret = __rdma_disconnect (this); @@ -4054,7 +4054,7 @@ __tcp_connect_finish (int fd) } static inline void -rdma_fill_handshake_data (char *buf, struct rdma_nbio *nbio, +rdma_fill_handshake_data (char *buf, struct rdma_nbio *nbio, rdma_private_t *priv) { sprintf (buf, @@ -4099,7 +4099,7 @@ rdma_handshake_pollin (rpc_transport_t *this) { while (priv->handshake.incoming.state != RDMA_HANDSHAKE_COMPLETE) { - switch (priv->handshake.incoming.state) + switch (priv->handshake.incoming.state) { case RDMA_HANDSHAKE_START: buf = priv->handshake.incoming.buf = GF_CALLOC (1, 256, gf_common_mt_char); @@ -4109,10 +4109,10 @@ rdma_handshake_pollin (rpc_transport_t *this) break; case RDMA_HANDSHAKE_RECEIVING_DATA: - ret = __tcp_readv (this, - &priv->handshake.incoming.vector, + ret = __tcp_readv (this, + &priv->handshake.incoming.vector, priv->handshake.incoming.count, - &priv->handshake.incoming.pending_vector, + &priv->handshake.incoming.pending_vector, &priv->handshake.incoming.pending_count); if (ret == -1) { goto unlock; @@ -4123,7 +4123,7 @@ rdma_handshake_pollin (rpc_transport_t *this) "partial header read on NB socket. continue later"); goto unlock; } - + if (!ret) { priv->handshake.incoming.state = RDMA_HANDSHAKE_RECEIVED_DATA; } @@ -4140,11 +4140,11 @@ rdma_handshake_pollin (rpc_transport_t *this) &priv->peer.remote_psn); if ((ret != 5) && (strncmp (buf, "QP1:", 4))) { - gf_log (RDMA_LOG_NAME, + gf_log (RDMA_LOG_NAME, GF_LOG_CRITICAL, "%s: remote-host(%s)'s " "transport type is different", - this->name, + this->name, this->peerinfo.identifier); ret = -1; goto unlock; @@ -4154,7 +4154,7 @@ rdma_handshake_pollin (rpc_transport_t *this) priv->peer.recv_size = recv_buf_size; if (send_buf_size < priv->peer.send_size) priv->peer.send_size = send_buf_size; - + gf_log (RDMA_LOG_NAME, GF_LOG_TRACE, "%s: transacted recv_size=%d " "send_size=%d", @@ -4164,7 +4164,7 @@ rdma_handshake_pollin (rpc_transport_t *this) priv->peer.quota = priv->peer.send_count; if (rdma_connect_qp (this)) { - gf_log (RDMA_LOG_NAME, + gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "%s: failed to connect with " "remote QP", this->name); @@ -4177,10 +4177,10 @@ rdma_handshake_pollin (rpc_transport_t *this) break; case RDMA_HANDSHAKE_RECEIVING_ACK: - ret = __tcp_readv (this, - &priv->handshake.incoming.vector, + ret = __tcp_readv (this, + &priv->handshake.incoming.vector, priv->handshake.incoming.count, - &priv->handshake.incoming.pending_vector, + &priv->handshake.incoming.pending_vector, &priv->handshake.incoming.pending_count); if (ret == -1) { goto unlock; @@ -4192,7 +4192,7 @@ rdma_handshake_pollin (rpc_transport_t *this) "socket. continue later"); goto unlock; } - + if (!ret) { priv->handshake.incoming.state = RDMA_HANDSHAKE_RECEIVED_ACK; } @@ -4200,7 +4200,7 @@ rdma_handshake_pollin (rpc_transport_t *this) case RDMA_HANDSHAKE_RECEIVED_ACK: if (strncmp (buf, "DONE", 4)) { - gf_log (RDMA_LOG_NAME, + gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG, "%s: handshake-3 did not " "return 'DONE' (%s)", @@ -4245,7 +4245,7 @@ unlock: return ret; } -static int +static int rdma_handshake_pollout (rpc_transport_t *this) { rdma_private_t *priv = this->private; @@ -4260,7 +4260,7 @@ rdma_handshake_pollout (rpc_transport_t *this) { while (priv->handshake.outgoing.state != RDMA_HANDSHAKE_COMPLETE) { - switch (priv->handshake.outgoing.state) + switch (priv->handshake.outgoing.state) { case RDMA_HANDSHAKE_START: buf = priv->handshake.outgoing.buf = GF_CALLOC (1, 256, gf_common_mt_char); @@ -4269,10 +4269,10 @@ rdma_handshake_pollout (rpc_transport_t *this) break; case RDMA_HANDSHAKE_SENDING_DATA: - ret = __tcp_writev (this, - &priv->handshake.outgoing.vector, + ret = __tcp_writev (this, + &priv->handshake.outgoing.vector, priv->handshake.outgoing.count, - &priv->handshake.outgoing.pending_vector, + &priv->handshake.outgoing.pending_vector, &priv->handshake.outgoing.pending_count); if (ret == -1) { goto unlock; @@ -4283,7 +4283,7 @@ rdma_handshake_pollout (rpc_transport_t *this) "partial header read on NB socket. continue later"); goto unlock; } - + if (!ret) { priv->handshake.outgoing.state = RDMA_HANDSHAKE_SENT_DATA; } @@ -4311,7 +4311,7 @@ rdma_handshake_pollout (rpc_transport_t *this) "socket. continue later"); goto unlock; } - + if (!ret) { GF_FREE (priv->handshake.outgoing.buf); priv->handshake.outgoing.buf = NULL; @@ -4350,7 +4350,7 @@ rdma_handshake_pollerr (rpc_transport_t *this) connected = priv->connected; if (priv->sock != -1) { - event_unregister (this->ctx->event_pool, + event_unregister (this->ctx->event_pool, priv->sock, priv->idx); need_unref = 1; @@ -4402,16 +4402,16 @@ tcp_connect_finish (rpc_transport_t *this) ret = __tcp_connect_finish (priv->sock); if (!ret) { - this->myinfo.sockaddr_len = + this->myinfo.sockaddr_len = sizeof (this->myinfo.sockaddr); ret = getsockname (priv->sock, - (struct sockaddr *)&this->myinfo.sockaddr, + (struct sockaddr *)&this->myinfo.sockaddr, &this->myinfo.sockaddr_len); - if (ret == -1) + if (ret == -1) { gf_log (this->name, GF_LOG_ERROR, "getsockname on new client-socket %d " - "failed (%s)", + "failed (%s)", priv->sock, strerror (errno)); close (priv->sock); error = 1; @@ -4424,7 +4424,7 @@ tcp_connect_finish (rpc_transport_t *this) if (ret == -1 && errno != EINPROGRESS) { gf_log (this->name, GF_LOG_ERROR, - "tcp connect to %s failed (%s)", + "tcp connect to %s failed (%s)", this->peerinfo.identifier, strerror (errno)); error = 1; } @@ -4508,9 +4508,9 @@ static int32_t rdma_connect (struct rpc_transport *this, int port) { dict_t *options = this->options; - + rdma_private_t *priv = this->private; - + int32_t ret = 0; gf_boolean_t non_blocking = 1; struct sockaddr_storage sockaddr; @@ -4523,7 +4523,7 @@ rdma_connect (struct rpc_transport *this, int port) if (dict_get (options, "non-blocking-io")) { char *nb_connect = data_to_str (dict_get (this->options, "non-blocking-io")); - + if (gf_string2boolean (nb_connect, &non_blocking) == -1) { gf_log (this->name, GF_LOG_ERROR, "'non-blocking-io' takes only boolean " @@ -4547,10 +4547,10 @@ rdma_connect (struct rpc_transport *this, int port) ret = 0; goto unlock; } - + priv->sock = socket (((struct sockaddr *)&sockaddr)->sa_family, SOCK_STREAM, 0); - + if (priv->sock == -1) { gf_log (this->name, GF_LOG_ERROR, "socket () - error: %s", strerror (errno)); @@ -4568,13 +4568,13 @@ rdma_connect (struct rpc_transport *this, int port) ((struct sockaddr_in *) (&sockaddr))->sin_port = htons (port); - ((struct sockaddr *) &this->myinfo.sockaddr)->sa_family = + ((struct sockaddr *) &this->myinfo.sockaddr)->sa_family = ((struct sockaddr *)&this->peerinfo.sockaddr)->sa_family; - if (non_blocking) + if (non_blocking) { ret = __tcp_nonblock (priv->sock); - + if (ret == -1) { gf_log (this->name, GF_LOG_ERROR, @@ -4599,13 +4599,13 @@ rdma_connect (struct rpc_transport *this, int port) goto unlock; } - ret = connect (priv->sock, - (struct sockaddr *)&this->peerinfo.sockaddr, + ret = connect (priv->sock, + (struct sockaddr *)&this->peerinfo.sockaddr, this->peerinfo.sockaddr_len); if (ret == -1 && errno != EINPROGRESS) { gf_log (this->name, GF_LOG_ERROR, - "connection attempt failed (%s)", + "connection attempt failed (%s)", strerror (errno)); close (priv->sock); priv->sock = -1; @@ -4618,10 +4618,10 @@ rdma_connect (struct rpc_transport *this, int port) priv->handshake.incoming.state = RDMA_HANDSHAKE_START; priv->handshake.outgoing.state = RDMA_HANDSHAKE_START; - - priv->idx = event_register (this->ctx->event_pool, + + priv->idx = event_register (this->ctx->event_pool, priv->sock, rdma_event_handler, - this, 1, 1); + this, 1, 1); } unlock: pthread_mutex_unlock (&priv->write_mutex); @@ -4660,7 +4660,7 @@ rdma_server_event_handler (int fd, int idx, void *data, return -1; } this->private = priv; - /* Copy all the rdma related values in priv, from trans_priv + /* Copy all the rdma related values in priv, from trans_priv as other than QP, all the values remain same */ priv->device = trans_priv->device; priv->options = trans_priv->options; @@ -4677,14 +4677,14 @@ rdma_server_event_handler (int fd, int idx, void *data, this->notify = trans->notify; this->mydata = trans->mydata; - memcpy (&this->myinfo.sockaddr, &trans->myinfo.sockaddr, + memcpy (&this->myinfo.sockaddr, &trans->myinfo.sockaddr, trans->myinfo.sockaddr_len); this->myinfo.sockaddr_len = trans->myinfo.sockaddr_len; main_sock = (trans_priv)->sock; this->peerinfo.sockaddr_len = sizeof (this->peerinfo.sockaddr); - priv->sock = accept (main_sock, - (struct sockaddr *)&this->peerinfo.sockaddr, + priv->sock = accept (main_sock, + (struct sockaddr *)&this->peerinfo.sockaddr, &this->peerinfo.sockaddr_len); if (priv->sock == -1) { gf_log ("rdma/server", GF_LOG_ERROR, @@ -4747,7 +4747,7 @@ rdma_listen (rpc_transport_t *this) goto err; } - priv->sock = socket (((struct sockaddr *)&sockaddr)->sa_family, + priv->sock = socket (((struct sockaddr *)&sockaddr)->sa_family, SOCK_STREAM, 0); if (priv->sock == -1) { gf_log ("rdma/server", GF_LOG_CRITICAL, @@ -4761,7 +4761,7 @@ rdma_listen (rpc_transport_t *this) memcpy (&this->myinfo.sockaddr, &sockaddr, sockaddr_len); this->myinfo.sockaddr_len = sockaddr_len; - ret = getnameinfo ((struct sockaddr *)&this->myinfo.sockaddr, + ret = getnameinfo ((struct sockaddr *)&this->myinfo.sockaddr, this->myinfo.sockaddr_len, host, sizeof (host), service, sizeof (service), @@ -4772,7 +4772,7 @@ rdma_listen (rpc_transport_t *this) goto err; } sprintf (this->myinfo.identifier, "%s:%s", host, service); - + setsockopt (priv->sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof (opt)); if (bind (priv->sock, (struct sockaddr *)&sockaddr, @@ -4794,7 +4794,7 @@ rdma_listen (rpc_transport_t *this) /* Register the main socket */ priv->idx = event_register (this->ctx->event_pool, priv->sock, - rdma_server_event_handler, + rdma_server_event_handler, rpc_transport_ref (this), 1, 0); err: @@ -4858,51 +4858,51 @@ fini (struct rpc_transport *this) /* TODO: expand each option */ struct volume_options options[] = { { .key = {"transport.rdma.port", - "rdma-port"}, + "rdma-port"}, .type = GF_OPTION_TYPE_INT, .min = 1, .max = 4, .description = "check the option by 'ibv_devinfo'" }, { .key = {"transport.rdma.mtu", - "rdma-mtu"}, + "rdma-mtu"}, .type = GF_OPTION_TYPE_INT, }, { .key = {"transport.rdma.device-name", - "rdma-device-name"}, + "rdma-device-name"}, .type = GF_OPTION_TYPE_ANY, .description = "check by 'ibv_devinfo'" }, { .key = {"transport.rdma.work-request-send-count", - "rdma-work-request-send-count"}, + "rdma-work-request-send-count"}, .type = GF_OPTION_TYPE_INT, }, { .key = {"transport.rdma.work-request-recv-count", - "rdma-work-request-recv-count"}, + "rdma-work-request-recv-count"}, .type = GF_OPTION_TYPE_INT, }, - { .key = {"remote-port", + { .key = {"remote-port", "transport.remote-port", - "transport.rdma.remote-port"}, - .type = GF_OPTION_TYPE_INT + "transport.rdma.remote-port"}, + .type = GF_OPTION_TYPE_INT }, - { .key = {"transport.rdma.listen-port", "listen-port"}, - .type = GF_OPTION_TYPE_INT + { .key = {"transport.rdma.listen-port", "listen-port"}, + .type = GF_OPTION_TYPE_INT }, - { .key = {"transport.rdma.connect-path", "connect-path"}, - .type = GF_OPTION_TYPE_ANY + { .key = {"transport.rdma.connect-path", "connect-path"}, + .type = GF_OPTION_TYPE_ANY }, - { .key = {"transport.rdma.bind-path", "bind-path"}, - .type = GF_OPTION_TYPE_ANY + { .key = {"transport.rdma.bind-path", "bind-path"}, + .type = GF_OPTION_TYPE_ANY }, - { .key = {"transport.rdma.listen-path", "listen-path"}, - .type = GF_OPTION_TYPE_ANY + { .key = {"transport.rdma.listen-path", "listen-path"}, + .type = GF_OPTION_TYPE_ANY }, { .key = {"transport.address-family", - "address-family"}, + "address-family"}, .value = {"inet", "inet6", "inet/inet6", "inet6/inet", "unix", "inet-sdp" }, - .type = GF_OPTION_TYPE_STR + .type = GF_OPTION_TYPE_STR }, { .key = {"transport.socket.lowlat"}, .type = GF_OPTION_TYPE_BOOL diff --git a/rpc/rpc-transport/rdma/src/rdma.h b/rpc/rpc-transport/rdma/src/rdma.h index dbd15d6689e..61cf550d438 100644 --- a/rpc/rpc-transport/rdma/src/rdma.h +++ b/rpc/rpc-transport/rdma/src/rdma.h @@ -200,7 +200,7 @@ struct __rdma_ioq { struct iobref *rsp_iobref; }request; - rdma_reply_info_t *reply_info; + rdma_reply_info_t *reply_info; }msg; struct mem_pool *pool; @@ -228,7 +228,7 @@ typedef enum __rdma_send_post_type { RDMA_SEND_POST_RDMA_READ, /* RDMA read */ RDMA_SEND_POST_RDMA_WRITE, /* RDMA write */ }rdma_send_post_type_t; - + /* represents one communication peer, two per transport_t */ struct __rdma_peer { rpc_transport_t *trans; |