Whamcloud - gitweb
* landing portals b1_4_sfw on HEAD
[fs/lustre-release.git] / lnet / klnds / iiblnd / iiblnd_cb.c
index a827ba5..16ed937 100644 (file)
@@ -485,17 +485,20 @@ kibnal_rx_callback (IB_WORK_COMPLETION *wc)
                         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;
                         
@@ -628,9 +631,9 @@ kibnal_fill_ibrm(kib_tx_t *tx, struct page *page, unsigned long page_offset,
 
         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;
@@ -845,7 +848,7 @@ kibnal_map_kiov (kib_tx_t *tx, IB_ACCESS_CONTROL access,
                 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;
         }
 
@@ -1090,6 +1093,10 @@ kibnal_ca_callback (void *ca_arg, void *cq_arg)
 
         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
@@ -1306,7 +1313,7 @@ kibnal_start_passive_rdma (int type, ptl_nid_t nid,
         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;
@@ -1408,7 +1415,7 @@ kibnal_start_active_rdma (int type, int status,
         } 
 
         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;
@@ -1439,7 +1446,7 @@ kibnal_start_active_rdma (int type, int status,
 
                 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);
@@ -1453,7 +1460,7 @@ kibnal_start_active_rdma (int type, int status,
                 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)
@@ -2394,7 +2401,9 @@ kibnal_listen_callback(IB_HANDLE cep, CM_CONN_INFO *info, void *arg)
         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);
         }