summaryrefslogtreecommitdiff
path: root/source4/cluster/ctdb/ib/ibwrapper.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/cluster/ctdb/ib/ibwrapper.c')
-rw-r--r--source4/cluster/ctdb/ib/ibwrapper.c64
1 files changed, 41 insertions, 23 deletions
diff --git a/source4/cluster/ctdb/ib/ibwrapper.c b/source4/cluster/ctdb/ib/ibwrapper.c
index 8ef798c88b..31acbc4a2d 100644
--- a/source4/cluster/ctdb/ib/ibwrapper.c
+++ b/source4/cluster/ctdb/ib/ibwrapper.c
@@ -37,8 +37,9 @@
#include "lib/events/events.h"
#include "ibwrapper.h"
+#include <infiniband/kern-abi.h>
+#include <rdma/rdma_cma_abi.h>
#include <rdma/rdma_cma.h>
-#include "infiniband/sa-kern-abi.h"
#include "ibwrapper_internal.h"
#include "lib/util/dlinklist.h"
@@ -82,7 +83,7 @@ static void *ibw_alloc_mr(struct ibw_ctx_priv *pctx, struct ibw_conn_priv *pconn
static void ibw_free_mr(char **ppbuf, struct ibv_mr **ppmr)
{
- DEBUG(10, ("ibw_free_mr(%u %u)\n", (uint32_t)*ppbuf, (uint32_t)*ppmr));
+ DEBUG(10, ("ibw_free_mr(%p %p)\n", *ppbuf, *ppmr));
if (*ppmr!=NULL) {
ibv_dereg_mr(*ppmr);
*ppmr = NULL;
@@ -132,7 +133,7 @@ static int ibw_init_memory(struct ibw_conn *conn)
static int ibw_ctx_priv_destruct(struct ibw_ctx_priv *pctx)
{
- DEBUG(10, ("ibw_ctx_priv_destruct(%u)\n", (uint32_t)pctx));
+ DEBUG(10, ("ibw_ctx_priv_destruct(%p)\n", pctx));
/* destroy cm */
if (pctx->cm_channel) {
@@ -154,7 +155,7 @@ static int ibw_ctx_priv_destruct(struct ibw_ctx_priv *pctx)
static int ibw_ctx_destruct(struct ibw_ctx *ctx)
{
- DEBUG(10, ("ibw_ctx_destruct(%u)\n", (uint32_t)ctx));
+ DEBUG(10, ("ibw_ctx_destruct(%p)\n", ctx));
return 0;
}
@@ -216,7 +217,7 @@ static int ibw_wr_destruct(struct ibw_wr *wr)
static int ibw_conn_destruct(struct ibw_conn *conn)
{
- DEBUG(10, ("ibw_conn_destruct(%u)\n", (uint32_t)conn));
+ DEBUG(10, ("ibw_conn_destruct(%p)\n", conn));
/* important here: ctx is a talloc _parent_ */
DLIST_REMOVE(conn->ctx->conn_list, conn);
@@ -427,6 +428,7 @@ static void ibw_event_handler_cm(struct event_context *ev,
rc = rdma_get_cm_event(pctx->cm_channel, &event);
if (rc) {
ctx->state = IBWS_ERROR;
+ event = NULL;
sprintf(ibw_lasterr, "rdma_get_cm_event error %d\n", rc);
goto error;
}
@@ -492,7 +494,7 @@ static void ibw_event_handler_cm(struct event_context *ev,
case RDMA_CM_EVENT_ESTABLISHED:
/* expected after ibw_accept and ibw_connect[not directly] */
- DEBUG(0, ("ESTABLISHED (conn: %p)\n", cma_id->context));
+ DEBUG(1, ("ESTABLISHED (conn: %p)\n", cma_id->context));
conn = talloc_get_type(cma_id->context, struct ibw_conn);
assert(conn!=NULL); /* important assumption */
@@ -513,17 +515,21 @@ static void ibw_event_handler_cm(struct event_context *ev,
sprintf(ibw_lasterr, "RDMA_CM_EVENT_CONNECT_ERROR, error %d\n", event->status);
case RDMA_CM_EVENT_UNREACHABLE:
sprintf(ibw_lasterr, "RDMA_CM_EVENT_UNREACHABLE, error %d\n", event->status);
+ goto error;
case RDMA_CM_EVENT_REJECTED:
sprintf(ibw_lasterr, "RDMA_CM_EVENT_REJECTED, error %d\n", event->status);
+ DEBUG(1, ("cm event handler: %s", ibw_lasterr));
conn = talloc_get_type(cma_id->context, struct ibw_conn);
if (conn) {
+ /* must be done BEFORE connstate */
if ((rc=rdma_ack_cm_event(event)))
DEBUG(0, ("reject/rdma_ack_cm_event failed with %d\n", rc));
- event = NULL;
- pconn = talloc_get_type(conn->internal, struct ibw_conn_priv);
- ibw_conn_priv_destruct(pconn);
+ event = NULL; /* not to touch cma_id or conn */
+ conn->state = IBWC_ERROR;
+ /* it should free the conn */
+ pctx->connstate_func(NULL, conn);
}
- goto error;
+ break; /* this is not strictly an error */
case RDMA_CM_EVENT_DISCONNECTED:
DEBUG(11, ("RDMA_CM_EVENT_DISCONNECTED\n"));
@@ -555,22 +561,26 @@ static void ibw_event_handler_cm(struct event_context *ev,
return;
error:
- if (event!=NULL && (rc=rdma_ack_cm_event(event))) {
- sprintf(ibw_lasterr, "rdma_ack_cm_event failed with %d\n", rc);
- goto error;
- }
-
DEBUG(0, ("cm event handler: %s", ibw_lasterr));
- if (cma_id!=pctx->cm_id) {
- conn = talloc_get_type(cma_id->context, struct ibw_conn);
- if (conn)
- conn->state = IBWC_ERROR;
- pctx->connstate_func(NULL, conn);
- } else {
- ctx->state = IBWS_ERROR;
- pctx->connstate_func(ctx, NULL);
+ if (event!=NULL) {
+ if (cma_id!=NULL && cma_id!=pctx->cm_id) {
+ conn = talloc_get_type(cma_id->context, struct ibw_conn);
+ if (conn) {
+ conn->state = IBWC_ERROR;
+ pctx->connstate_func(NULL, conn);
+ }
+ } else {
+ ctx->state = IBWS_ERROR;
+ pctx->connstate_func(ctx, NULL);
+ }
+
+ if ((rc=rdma_ack_cm_event(event))!=0) {
+ DEBUG(0, ("rdma_ack_cm_event failed with %d\n", rc));
+ }
}
+
+ return;
}
static void ibw_event_handler_verbs(struct event_context *ev,
@@ -966,7 +976,11 @@ struct ibw_ctx *ibw_init(struct ibw_initattr *attr, int nattr,
pctx->cm_channel_event = event_add_fd(pctx->ectx, pctx,
pctx->cm_channel->fd, EVENT_FD_READ, ibw_event_handler_cm, ctx);
+#if RDMA_USER_CM_MAX_ABI_VERSION >= 2
rc = rdma_create_id(pctx->cm_channel, &pctx->cm_id, ctx, RDMA_PS_TCP);
+#else
+ rc = rdma_create_id(pctx->cm_channel, &pctx->cm_id, ctx);
+#endif
if (rc) {
rc = errno;
sprintf(ibw_lasterr, "rdma_create_id error %d\n", rc);
@@ -1087,7 +1101,11 @@ int ibw_connect(struct ibw_conn *conn, struct sockaddr_in *serv_addr, void *conn
}
/* init cm */
+#if RDMA_USER_CM_MAX_ABI_VERSION >= 2
rc = rdma_create_id(pctx->cm_channel, &pconn->cm_id, conn, RDMA_PS_TCP);
+#else
+ rc = rdma_create_id(pctx->cm_channel, &pconn->cm_id, conn);
+#endif
if (rc) {
rc = errno;
sprintf(ibw_lasterr, "ibw_connect/rdma_create_id error %d\n", rc);