goto failed;
}
+ if (flipped) {
+ __swab32(msg->ibm_u.rdma.rd_key);
+ }
+
for(i = 0; i < msg->ibm_u.rdma.ibrm_num_descs; i++) {
kib_rdma_desc_t *desc = &msg->ibm_u.rdma.ibrm_desc[i];
if (flipped) {
- __swab32(desc->rd_key);
__swab32(desc->rd_nob);
__swab64(desc->rd_addr);
}
CDEBUG(D_NET, " key %x, " "addr "LPX64", nob %u\n",
- desc->rd_key, desc->rd_addr, desc->rd_nob);
+ msg->ibm_u.rdma.rd_key, desc->rd_addr, desc->rd_nob);
}
break;
desc = &ibrm->ibrm_desc[ibrm->ibrm_num_descs];
if (active)
- desc->rd_key = kibnal_data.kib_md.md_lkey;
+ ibrm->rd_key = kibnal_data.kib_md.md_lkey;
else
- desc->rd_key = kibnal_data.kib_md.md_rkey;
+ ibrm->rd_key = kibnal_data.kib_md.md_rkey;
desc->rd_nob = len; /*PAGE_SIZE - kiov->kiov_offset; */
desc->rd_addr = kibnal_page2phys(page) + page_offset +
kibnal_data.kib_md.md_addr;
tx->tx_mapped = KIB_TX_MAPPED;
#endif
} else {
- CERROR ("Can't map phys: %d\n", rc);
+ CERROR ("Can't map phys: %d\n", frc);
rc = -EFAULT;
}
for(;;) {
while (iibt_cq_poll(cq, &wc) == FSUCCESS) {
+
+ /* We will need to rearm the CQ to avoid a potential race. */
+ armed = 0;
+
if (kibnal_wreqid_is_rx(wc.WorkReqId))
kibnal_rx_callback(&wc);
else
LASSERT (tx->tx_conn == NULL); /* only set when assigned a conn */
LASSERT (tx->tx_nsp > 0); /* work items have been set up */
- read_lock (g_lock);
+ read_lock_irqsave(g_lock, flags);
peer = kibnal_find_peer_locked (nid);
if (peer == NULL) {
- read_unlock (g_lock);
+ read_unlock_irqrestore(g_lock, flags);
tx->tx_status = -EHOSTUNREACH;
kibnal_tx_done (tx);
return;
conn, conn->ibc_state, conn->ibc_peer->ibp_nid,
atomic_read (&conn->ibc_refcount));
atomic_inc (&conn->ibc_refcount); /* 1 ref for the tx */
- read_unlock (g_lock);
+ read_unlock_irqrestore(g_lock, flags);
kibnal_queue_tx (tx, conn);
return;
}
/* Making one or more connections; I'll need a write lock... */
- read_unlock (g_lock);
- write_lock_irqsave (g_lock, flags);
+ read_unlock(g_lock);
+ write_lock(g_lock);
peer = kibnal_find_peer_locked (nid);
if (peer == NULL) {
ibmsg->ibm_u.rdma.ibrm_cookie = tx->tx_passive_rdma_cookie;
/* map_kiov alrady filled the rdma descs for the whole_mem case */
if (!kibnal_whole_mem()) {
- ibmsg->ibm_u.rdma.ibrm_desc[0].rd_key = tx->tx_md.md_rkey;
+ ibmsg->ibm_u.rdma.rd_key = tx->tx_md.md_rkey;
ibmsg->ibm_u.rdma.ibrm_desc[0].rd_addr = tx->tx_md.md_addr;
ibmsg->ibm_u.rdma.ibrm_desc[0].rd_nob = nob;
ibmsg->ibm_u.rdma.ibrm_num_descs = 1;
}
if (!kibnal_whole_mem()) {
- tx->tx_msg->ibm_u.rdma.ibrm_desc[0].rd_key = tx->tx_md.md_lkey;
+ tx->tx_msg->ibm_u.rdma.rd_key = tx->tx_md.md_lkey;
tx->tx_msg->ibm_u.rdma.ibrm_desc[0].rd_addr = tx->tx_md.md_addr;
tx->tx_msg->ibm_u.rdma.ibrm_desc[0].rd_nob = nob;
tx->tx_msg->ibm_u.rdma.ibrm_num_descs = 1;
ds->Address = ldesc->rd_addr;
ds->Length = ldesc->rd_nob;
- ds->Lkey = ldesc->rd_key;
+ ds->Lkey = tx->tx_msg->ibm_u.rdma.rd_key;
memset(wrq, 0, sizeof(*wrq));
wrq->WorkReqId = kibnal_ptr2wreqid(tx, 0);
wrq->Req.SendRC.Options.s.ImmediateData = 0;
wrq->Req.SendRC.Options.s.Fence = 0;
wrq->Req.SendRC.RemoteDS.Address = rdesc->rd_addr;
- wrq->Req.SendRC.RemoteDS.Rkey = rdesc->rd_key;
+ wrq->Req.SendRC.RemoteDS.Rkey = rxmsg->ibm_u.rdma.rd_key;
/* only the last rdma post triggers tx completion */
if (i == rxmsg->ibm_u.rdma.ibrm_num_descs - 1)
} else {
LASSERT (tx->tx_nsp == 1);
/* No RDMA: local completion happens now! */
- CDEBUG(D_WARNING,"No data: immediate completion\n");
+ CWARN("No data: immediate completion\n");
lib_finalize (&kibnal_lib, NULL, libmsg,
status == 0 ? PTL_OK : PTL_FAIL);
}
atomic_inc (&conn->ibc_refcount);
}
- if (list_empty (&peer->ibp_conns) &&
- peer->ibp_persistence == 0) {
- /* Non-persistent peer with no more conns... */
+ if (list_empty (&peer->ibp_conns) && /* no more conns */
+ peer->ibp_persistence == 0 && /* non-persistent peer */
+ kibnal_peer_active(peer)) { /* still in peer table */
kibnal_unlink_peer_locked (peer);
}
PORTAL_ALLOC(rep, sizeof(*rep));
PORTAL_ALLOC(rcv, sizeof(*rcv));
if (rep == NULL || rcv == NULL) {
- CERROR ("can't reply and receive buffers\n");
+ if (rep) PORTAL_FREE(rep, sizeof(*rep));
+ if (rcv) PORTAL_FREE(rcv, sizeof(*rcv));
+ CERROR ("can't allocate reply and receive buffers\n");
GOTO(out, reason = RC_INSUFFICIENT_RESP_RES);
}
goto out;
}
- CDEBUG(D_WARNING, "Connection %p -> "LPX64" ESTABLISHED.\n",
+ CWARN("Connection %p -> "LPX64" ESTABLISHED.\n",
conn, conn->ibc_peer->ibp_nid);
out:
kib_peer_t *peer;
kib_conn_t *conn;
struct list_head *ctmp;
+ unsigned long flags;
again:
/* NB. We expect to have a look at all the peers and not find any
* rdmas to time out, so we just use a shared lock while we
* take a look... */
- read_lock (&kibnal_data.kib_global_lock);
+ read_lock_irqsave(&kibnal_data.kib_global_lock, flags);
list_for_each (ptmp, peers) {
peer = list_entry (ptmp, kib_peer_t, ibp_list);
atomic_read (&conn->ibc_refcount));
atomic_inc (&conn->ibc_refcount);
- read_unlock (&kibnal_data.kib_global_lock);
+ read_unlock_irqrestore(&kibnal_data.kib_global_lock,
+ flags);
CERROR("Timed out RDMA with "LPX64"\n",
peer->ibp_nid);
}
}
- read_unlock (&kibnal_data.kib_global_lock);
+ read_unlock_irqrestore(&kibnal_data.kib_global_lock, flags);
}
static void