Whamcloud - gitweb
LU-8776 build: Fix weird inline definitions
[fs/lustre-release.git] / lnet / klnds / gnilnd / gnilnd_cb.c
index 7376443..bcf5c6d 100644 (file)
@@ -237,7 +237,7 @@ kgnilnd_free_tx(kgn_tx_t *tx)
 
        /* Only free the buffer if we used it */
        if (tx->tx_buffer_copy != NULL) {
-               vfree(tx->tx_buffer_copy);
+               kgnilnd_vfree(tx->tx_buffer_copy, tx->tx_rdma_desc.length);
                tx->tx_buffer_copy = NULL;
                CDEBUG(D_MALLOC, "vfreed buffer2\n");
        }
@@ -302,7 +302,7 @@ kgnilnd_cksum(void *ptr, size_t nob)
        return sum;
 }
 
-inline __u16
+__u16
 kgnilnd_cksum_kiov(unsigned int nkiov, lnet_kiov_t *kiov,
                    unsigned int offset, unsigned int nob, int dump_blob)
 {
@@ -1656,7 +1656,7 @@ kgnilnd_sendmsg_trylock(kgn_tx_t *tx, void *immediate, unsigned int immediatenob
 }
 
 /* lets us know if we can push this RDMA through now */
-inline int
+static int
 kgnilnd_auth_rdma_bytes(kgn_device_t *dev, kgn_tx_t *tx)
 {
        long    bytes_left;
@@ -1805,7 +1805,7 @@ kgnilnd_launch_tx(kgn_tx_t *tx, kgn_net_t *net, lnet_process_id_t *target)
                }
 
                /* don't create a connection if the peer is marked down */
-               if (peer->gnp_down == GNILND_RCA_NODE_DOWN) {
+               if (peer->gnp_state != GNILND_PEER_UP) {
                        read_unlock(&kgnilnd_data.kgn_peer_conn_lock);
                        rc = -ENETRESET;
                        GOTO(no_peer, rc);
@@ -1844,7 +1844,7 @@ kgnilnd_launch_tx(kgn_tx_t *tx, kgn_net_t *net, lnet_process_id_t *target)
        kgnilnd_add_peer_locked(target->nid, new_peer, &peer);
 
        /* don't create a connection if the peer is not up */
-       if (peer->gnp_down != GNILND_RCA_NODE_UP) {
+       if (peer->gnp_state != GNILND_PEER_UP) {
                write_unlock(&kgnilnd_data.kgn_peer_conn_lock);
                rc = -ENETRESET;
                GOTO(no_peer, rc);
@@ -1936,7 +1936,7 @@ kgnilnd_rdma(kgn_tx_t *tx, int type,
                        if (tx->tx_buffer_copy == NULL) {
                                /* Allocate the largest copy buffer we will need, this will prevent us from overwriting data
                                 * and require at most we allocate a few extra bytes. */
-                               tx->tx_buffer_copy = vmalloc(desc_nob);
+                               tx->tx_buffer_copy = kgnilnd_vzalloc(desc_nob);
 
                                if (!tx->tx_buffer_copy) {
                                        /* allocation of buffer failed nak the rdma */
@@ -1948,7 +1948,8 @@ kgnilnd_rdma(kgn_tx_t *tx, int type,
                                rc = kgnilnd_mem_register(conn->gnc_device->gnd_handle, (__u64)tx->tx_buffer_copy, desc_nob, NULL, GNI_MEM_READWRITE, &tx->tx_buffer_copy_map_key);
                                if (rc != GNI_RC_SUCCESS) {
                                        /* Registration Failed nak rdma and kill the tx. */
-                                       vfree(tx->tx_buffer_copy);
+                                       kgnilnd_vfree(tx->tx_buffer_copy,
+                                                     desc_nob);
                                        tx->tx_buffer_copy = NULL;
                                        kgnilnd_nak_rdma(tx->tx_conn, tx->tx_msg.gnm_type, -EFAULT, cookie, tx->tx_msg.gnm_srcnid);
                                        kgnilnd_tx_done(tx, -EFAULT);
@@ -1970,8 +1971,10 @@ kgnilnd_rdma(kgn_tx_t *tx, int type,
        tx->tx_rdma_desc.remote_mem_hndl = sink->gnrd_key;
        tx->tx_rdma_desc.length = desc_nob;
        tx->tx_nob_rdma = nob;
-       if (*kgnilnd_tunables.kgn_bte_dlvr_mode)
-               tx->tx_rdma_desc.dlvr_mode = *kgnilnd_tunables.kgn_bte_dlvr_mode;
+       if (post_type == GNI_POST_RDMA_PUT && *kgnilnd_tunables.kgn_bte_put_dlvr_mode)
+               tx->tx_rdma_desc.dlvr_mode = *kgnilnd_tunables.kgn_bte_put_dlvr_mode;
+       if (post_type == GNI_POST_RDMA_GET && *kgnilnd_tunables.kgn_bte_get_dlvr_mode)
+               tx->tx_rdma_desc.dlvr_mode = *kgnilnd_tunables.kgn_bte_get_dlvr_mode;
        /* prep final completion message */
        kgnilnd_init_msg(&tx->tx_msg, type, tx->tx_msg.gnm_srcnid);
        tx->tx_msg.gnm_u.completion.gncm_cookie = cookie;
@@ -2012,7 +2015,7 @@ kgnilnd_rdma(kgn_tx_t *tx, int type,
                kgnilnd_unmap_buffer(tx, 0);
 
                if (tx->tx_buffer_copy != NULL) {
-                       vfree(tx->tx_buffer_copy);
+                       kgnilnd_vfree(tx->tx_buffer_copy, desc_nob);
                        tx->tx_buffer_copy = NULL;
                }
 
@@ -2746,7 +2749,7 @@ kgnilnd_check_conn_timeouts_locked(kgn_conn_t *conn)
        if (time_after_eq(now, newest_last_rx + timeout)) {
                uint32_t level = D_CONSOLE|D_NETERROR;
 
-               if (conn->gnc_peer->gnp_down == GNILND_RCA_NODE_DOWN) {
+               if (conn->gnc_peer->gnp_state == GNILND_PEER_DOWN) {
                        level = D_NET;
                }
                        GNIDBG_CONN(level, conn,
@@ -2822,6 +2825,14 @@ kgnilnd_check_peer_timeouts_locked(kgn_peer_t *peer, struct list_head *todie,
                                conn->gnc_close_recvd = GNILND_CLOSE_INJECT1;
                                conn->gnc_peer_error = -ETIMEDOUT;
                        }
+
+                       if (*kgnilnd_tunables.kgn_to_reconn_disable &&
+                           rc == -ETIMEDOUT) {
+                               peer->gnp_state = GNILND_PEER_TIMED_OUT;
+                               CDEBUG(D_WARNING, "%s conn timed out, will "
+                                      "reconnect upon request from peer\n",
+                                      libcfs_nid2str(conn->gnc_peer->gnp_nid));
+                       }
                        /* Once we mark closed, any of the scheduler threads could
                         * get it and move through before we hit the fail loc code */
                        kgnilnd_close_conn_locked(conn, rc);
@@ -2865,7 +2876,7 @@ kgnilnd_check_peer_timeouts_locked(kgn_peer_t *peer, struct list_head *todie,
        /* Don't reconnect if we are still trying to clear out old conns.
         * This prevents us sending traffic on the new mbox before ensuring we are done
         * with the old one */
-       reconnect = (peer->gnp_down == GNILND_RCA_NODE_UP) &&
+       reconnect = (peer->gnp_state == GNILND_PEER_UP) &&
                    (atomic_read(&peer->gnp_dirty_eps) == 0);
 
        /* fast reconnect after a timeout */