Whamcloud - gitweb
LU-12756 lnet: Remove unnecessary rtr_nid argument
[fs/lustre-release.git] / lnet / lnet / lib-move.c
index b735341..07dc2d3 100644 (file)
@@ -63,6 +63,12 @@ struct lnet_send_data {
        __u32 sd_send_case;
 };
 
+static inline bool
+lnet_msg_is_response(struct lnet_msg *msg)
+{
+       return msg->msg_type == LNET_MSG_ACK || msg->msg_type == LNET_MSG_REPLY;
+}
+
 static inline struct lnet_comm_count *
 get_stats_counts(struct lnet_element_stats *stats,
                 enum lnet_stats_type stats_type)
@@ -827,8 +833,7 @@ lnet_peer_alive_locked(struct lnet_ni *ni, struct lnet_peer_ni *lpni,
                return 1;
 
        /* always send any responses */
-       if (msg->msg_type == LNET_MSG_ACK ||
-           msg->msg_type == LNET_MSG_REPLY)
+       if (lnet_msg_is_response(msg))
                return 1;
 
        if (!lnet_is_peer_deadline_passed(lpni, now))
@@ -1845,8 +1850,7 @@ static inline void
 lnet_set_non_mr_pref_nid(struct lnet_peer_ni *lpni, struct lnet_ni *lni,
                         struct lnet_msg *msg)
 {
-       if (msg->msg_type != LNET_MSG_REPLY && msg->msg_type != LNET_MSG_ACK &&
-           lpni->lpni_pref_nnids == 0) {
+       if (!lnet_msg_is_response(msg) && lpni->lpni_pref_nnids == 0) {
                CDEBUG(D_NET, "Setting preferred local NID %s on NMR peer %s\n",
                       libcfs_nid2str(lni->ni_nid),
                       libcfs_nid2str(lpni->lpni_nid));
@@ -1947,12 +1951,10 @@ lnet_find_best_ni_on_spec_net(struct lnet_ni *cur_best_ni,
 }
 
 static int
-lnet_initiate_peer_discovery(struct lnet_peer_ni *lpni,
-                            struct lnet_msg *msg, lnet_nid_t rtr_nid,
+lnet_initiate_peer_discovery(struct lnet_peer_ni *lpni, struct lnet_msg *msg,
                             int cpt)
 {
        struct lnet_peer *peer;
-       lnet_nid_t primary_nid;
        int rc;
 
        lnet_peer_ni_addref_locked(lpni);
@@ -1983,17 +1985,15 @@ lnet_initiate_peer_discovery(struct lnet_peer_ni *lpni,
                return 0;
        }
        /* queue message and return */
-       msg->msg_rtr_nid_param = rtr_nid;
        msg->msg_sending = 0;
        msg->msg_txpeer = NULL;
        list_add_tail(&msg->msg_list, &peer->lp_dc_pendq);
-       primary_nid = peer->lp_primary_nid;
        spin_unlock(&peer->lp_lock);
 
        lnet_peer_ni_decref_locked(lpni);
 
        CDEBUG(D_NET, "msg %p delayed. %s pending discovery\n",
-               msg, libcfs_nid2str(primary_nid));
+              msg, libcfs_nid2str(peer->lp_primary_nid));
 
        return LNET_DC_WAIT;
 }
@@ -2102,8 +2102,7 @@ lnet_handle_find_routed_path(struct lnet_send_data *sd,
         * completed
         */
        sd->sd_msg->msg_src_nid_param = sd->sd_src_nid;
-       rc = lnet_initiate_peer_discovery(gwni, sd->sd_msg, sd->sd_rtr_nid,
-                                         sd->sd_cpt);
+       rc = lnet_initiate_peer_discovery(gwni, sd->sd_msg, sd->sd_cpt);
        if (rc)
                return rc;
 
@@ -2660,20 +2659,22 @@ again:
        }
 
        /*
-        * Cache the original src_nid. If we need to resend the message
-        * then we'll need to know whether the src_nid was originally
+        * Cache the original src_nid and rtr_nid. If we need to resend the
+        * message then we'll need to know whether the src_nid was originally
         * specified for this message. If it was originally specified,
         * then we need to keep using the same src_nid since it's
-        * continuing the same sequence of messages.
+        * continuing the same sequence of messages. Similarly, rtr_nid will
+        * affect our choice of next hop.
         */
        msg->msg_src_nid_param = src_nid;
+       msg->msg_rtr_nid_param = rtr_nid;
 
        /*
         * If necessary, perform discovery on the peer that owns this peer_ni.
         * Note, this can result in the ownership of this peer_ni changing
         * to another peer object.
         */
-       rc = lnet_initiate_peer_discovery(lpni, msg, rtr_nid, cpt);
+       rc = lnet_initiate_peer_discovery(lpni, msg, cpt);
        if (rc) {
                lnet_peer_ni_decref_locked(lpni);
                lnet_net_unlock(cpt);
@@ -2706,8 +2707,7 @@ again:
        else
                send_case |= MR_DST;
 
-       if (msg->msg_type == LNET_MSG_REPLY ||
-           msg->msg_type == LNET_MSG_ACK)
+       if (lnet_msg_is_response(msg))
                send_case |= SND_RESP;
 
        /* assign parameters to the send_data */