Whamcloud - gitweb
LU-6245 libcfs: remove tcpip abstraction from libcfs
[fs/lustre-release.git] / lnet / klnds / o2iblnd / o2iblnd_cb.c
index de402e7..41a4ca5 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -189,24 +189,28 @@ kiblnd_post_rx (kib_rx_t *rx, int credit)
 
         rx->rx_nob = -1;                        /* flag posted */
 
-        rc = ib_post_recv(conn->ibc_cmid->qp, &rx->rx_wrq, &bad_wrq);
-        if (rc != 0) {
-                CERROR("Can't post rx for %s: %d, bad_wrq: %p\n",
-                       libcfs_nid2str(conn->ibc_peer->ibp_nid), rc, bad_wrq);
-                rx->rx_nob = 0;
-        }
+       /* NB: need an extra reference after ib_post_recv because we don't
+        * own this rx (and rx::rx_conn) anymore, LU-5678.
+        */
+       kiblnd_conn_addref(conn);
+       rc = ib_post_recv(conn->ibc_cmid->qp, &rx->rx_wrq, &bad_wrq);
+       if (unlikely(rc != 0)) {
+               CERROR("Can't post rx for %s: %d, bad_wrq: %p\n",
+                      libcfs_nid2str(conn->ibc_peer->ibp_nid), rc, bad_wrq);
+               rx->rx_nob = 0;
+       }
 
-        if (conn->ibc_state < IBLND_CONN_ESTABLISHED) /* Initial post */
-                return rc;
+       if (conn->ibc_state < IBLND_CONN_ESTABLISHED) /* Initial post */
+               goto out;
 
-        if (rc != 0) {
-                kiblnd_close_conn(conn, rc);
-                kiblnd_drop_rx(rx);             /* No more posts for this rx */
-                return rc;
-        }
+       if (unlikely(rc != 0)) {
+               kiblnd_close_conn(conn, rc);
+               kiblnd_drop_rx(rx);     /* No more posts for this rx */
+               goto out;
+       }
 
-        if (credit == IBLND_POSTRX_NO_CREDIT)
-                return 0;
+       if (credit == IBLND_POSTRX_NO_CREDIT)
+               goto out;
 
        spin_lock(&conn->ibc_lock);
        if (credit == IBLND_POSTRX_PEER_CREDIT)
@@ -216,7 +220,9 @@ kiblnd_post_rx (kib_rx_t *rx, int credit)
        spin_unlock(&conn->ibc_lock);
 
        kiblnd_check_sends(conn);
-       return 0;
+out:
+       kiblnd_conn_decref(conn);
+       return rc;
 }
 
 static kib_tx_t *
@@ -1187,7 +1193,9 @@ kiblnd_queue_tx_locked(kib_tx_t *tx, kib_conn_t *conn)
        LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED);
 
        tx->tx_queued = 1;
-       tx->tx_deadline = jiffies + (*kiblnd_tunables.kib_timeout * HZ);
+       tx->tx_deadline = jiffies +
+                         msecs_to_jiffies(*kiblnd_tunables.kib_timeout *
+                                          MSEC_PER_SEC);
 
         if (tx->tx_conn == NULL) {
                 kiblnd_conn_addref(conn);
@@ -1334,9 +1342,9 @@ kiblnd_connect_peer (kib_peer_t *peer)
         }
 
         LASSERT (cmid->device != NULL);
-        CDEBUG(D_NET, "%s: connection bound to %s:%u.%u.%u.%u:%s\n",
+       CDEBUG(D_NET, "%s: connection bound to %s:%pI4h:%s\n",
                libcfs_nid2str(peer->ibp_nid), dev->ibd_ifname,
-               HIPQUAD(dev->ibd_ifip), cmid->device->name);
+              &dev->ibd_ifip, cmid->device->name);
 
         return;
 
@@ -2193,7 +2201,7 @@ kiblnd_reject(struct rdma_cm_id *cmid, kib_rej_t *rej)
 }
 
 static int
-kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
+kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
 {
        rwlock_t                *g_lock = &kiblnd_data.kib_global_lock;
         kib_msg_t             *reqmsg = priv;
@@ -2225,9 +2233,9 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
         peer_addr = (struct sockaddr_in *)&(cmid->route.addr.dst_addr);
         if (*kiblnd_tunables.kib_require_priv_port &&
             ntohs(peer_addr->sin_port) >= PROT_SOCK) {
-                __u32 ip = ntohl(peer_addr->sin_addr.s_addr);
-                CERROR("Peer's port (%u.%u.%u.%u:%hu) is not privileged\n",
-                       HIPQUAD(ip), ntohs(peer_addr->sin_port));
+               __u32 ip = ntohl(peer_addr->sin_addr.s_addr);
+               CERROR("Peer's port (%pI4h:%hu) is not privileged\n",
+                      &ip, ntohs(peer_addr->sin_port));
                 goto failed;
         }
 
@@ -2271,11 +2279,11 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
         if (ni == NULL ||                         /* no matching net */
             ni->ni_nid != reqmsg->ibm_dstnid ||   /* right NET, wrong NID! */
             net->ibn_dev != ibdev) {              /* wrong device */
-                CERROR("Can't accept %s on %s (%s:%d:%u.%u.%u.%u): "
+               CERROR("Can't accept %s on %s (%s:%d:%pI4h): "
                        "bad dst nid %s\n", libcfs_nid2str(nid),
                        ni == NULL ? "NA" : libcfs_nid2str(ni->ni_nid),
                        ibdev->ibd_ifname, ibdev->ibd_nnets,
-                       HIPQUAD(ibdev->ibd_ifip),
+                       &ibdev->ibd_ifip,
                        libcfs_nid2str(reqmsg->ibm_dstnid));
 
                 goto failed;
@@ -3221,7 +3229,7 @@ kiblnd_connd (void *arg)
                                             kiblnd_data.kib_peer_hash_size;
                        }
 
-                       deadline += p * HZ;
+                       deadline += msecs_to_jiffies(p * MSEC_PER_SEC);
                        spin_lock_irqsave(&kiblnd_data.kib_connd_lock, flags);
                }