Whamcloud - gitweb
LU-15102 lnet: Reset ni_ping_count only on receive
[fs/lustre-release.git] / lnet / lnet / lib-msg.c
index 7dab8d5..1ed75cd 100644 (file)
@@ -466,7 +466,7 @@ lnet_ni_add_to_recoveryq_locked(struct lnet_ni *ni,
        lnet_ni_set_next_ping(ni, now);
 
        CDEBUG(D_NET, "%s added to recovery queue. ping count: %u next ping: %lld health :%d\n",
-              libcfs_nid2str(ni->ni_nid),
+              libcfs_nidstr(&ni->ni_nid),
               ni->ni_ping_count,
               ni->ni_next_ping,
               atomic_read(&ni->ni_healthv));
@@ -800,10 +800,11 @@ lnet_health_check(struct lnet_msg *msg)
         * if we're sending to the LOLND then the msg_txpeer will not be
         * set. So no need to sanity check it.
         */
-       if (msg->msg_tx_committed && msg->msg_txni->ni_nid != LNET_NID_LO_0)
+       if (msg->msg_tx_committed &&
+           !nid_is_lo0(&msg->msg_txni->ni_nid))
                LASSERT(msg->msg_txpeer);
        else if (msg->msg_tx_committed &&
-                msg->msg_txni->ni_nid == LNET_NID_LO_0)
+                nid_is_lo0(&msg->msg_txni->ni_nid))
                lo = true;
 
        if (hstatus != LNET_MSG_STATUS_OK &&
@@ -824,53 +825,58 @@ lnet_health_check(struct lnet_msg *msg)
                attempt_local_resend = attempt_remote_resend = false;
        }
 
-       /* Don't further decrement the health value if a recovery message
-        * failed.
-        */
-       if (msg->msg_recovery)
-               handle_local_health = handle_remote_health = false;
-       else
-               handle_local_health = handle_remote_health = true;
-
-       /* For local failures, health/recovery/resends are not needed if I only
-        * have a single (non-lolnd) interface. NB: pb_nnis includes the lolnd
-        * interface, so a single-rail node would have pb_nnis == 2.
-        */
-       if (the_lnet.ln_ping_target->pb_nnis <= 2) {
-               handle_local_health = false;
-               attempt_local_resend = false;
-       }
-
-       /* For remote failures, health/recovery/resends are not needed if the
-        * peer only has a single interface. Special case for routers where we
-        * rely on health feature to manage route aliveness. NB: unlike pb_nnis
-        * above, lp_nnis does _not_ include the lolnd, so a single-rail node
-        * would have lp_nnis == 1.
-        */
-       if (lpni && lpni->lpni_peer_net->lpn_peer->lp_nnis <= 1) {
-               attempt_remote_resend = false;
-               if (!lnet_isrouter(lpni))
-                       handle_remote_health = false;
-       }
-
        if (!lo)
                LASSERT(ni && lpni);
        else
                LASSERT(ni);
 
        CDEBUG(D_NET, "health check: %s->%s: %s: %s\n",
-              libcfs_nid2str(ni->ni_nid),
-              (lo) ? "self" : libcfs_nid2str(lpni->lpni_nid),
+              libcfs_nidstr(&ni->ni_nid),
+              (lo) ? "self" : libcfs_nidstr(&lpni->lpni_nid),
               lnet_msgtyp2str(msg->msg_type),
               lnet_health_error2str(hstatus));
 
        /*
         * stats are only incremented for errors so avoid wasting time
-        * incrementing statistics if there is no error.
+        * incrementing statistics if there is no error. Similarly, whether to
+        * update health values or perform resends is only applicable for
+        * messages with a health status != OK.
         */
        if (hstatus != LNET_MSG_STATUS_OK) {
+               /* Don't further decrement the health value if a recovery
+                * message failed.
+                */
+               if (msg->msg_recovery)
+                       handle_local_health = handle_remote_health = false;
+               else
+                       handle_local_health = handle_remote_health = true;
+
+               /* For local failures, health/recovery/resends are not needed if
+                * I only have a single (non-lolnd) interface. NB: pb_nnis
+                * includes the lolnd interface, so a single-rail node would
+                * have pb_nnis == 2.
+                */
+               if (the_lnet.ln_ping_target->pb_nnis <= 2) {
+                       handle_local_health = false;
+                       attempt_local_resend = false;
+               }
+
                lnet_net_lock(0);
                lnet_incr_hstats(ni, lpni, hstatus);
+               /* For remote failures, health/recovery/resends are not needed
+                * if the peer only has a single interface. Special case for
+                * routers where we rely on health feature to manage route
+                * aliveness. NB: unlike pb_nnis above, lp_nnis does _not_
+                * include the lolnd, so a single-rail node would have
+                * lp_nnis == 1.
+                */
+               if (lpni && lpni->lpni_peer_net &&
+                   lpni->lpni_peer_net->lpn_peer &&
+                   lpni->lpni_peer_net->lpn_peer->lp_nnis <= 1) {
+                       attempt_remote_resend = false;
+                       if (!lnet_isrouter(lpni))
+                               handle_remote_health = false;
+               }
                lnet_net_unlock(0);
        }
 
@@ -884,8 +890,6 @@ lnet_health_check(struct lnet_msg *msg)
                 * faster recovery.
                 */
                lnet_inc_healthv(&ni->ni_healthv, lnet_health_sensitivity);
-               lnet_net_lock(0);
-               ni->ni_ping_count = 0;
                /*
                 * It's possible msg_txpeer is NULL in the LOLND
                 * case. Only increment the peer's health if we're
@@ -895,7 +899,9 @@ lnet_health_check(struct lnet_msg *msg)
                 * as indication that the router is fully healthy.
                 */
                if (lpni && msg->msg_rx_committed) {
+                       lnet_net_lock(0);
                        lpni->lpni_ping_count = 0;
+                       ni->ni_ping_count = 0;
                        /*
                         * If we're receiving a message from the router or
                         * I'm a router, then set that lpni's health to
@@ -921,8 +927,8 @@ lnet_health_check(struct lnet_msg *msg)
                                                &the_lnet.ln_mt_peerNIRecovq,
                                                ktime_get_seconds());
                        }
+                       lnet_net_unlock(0);
                }
-               lnet_net_unlock(0);
 
                /* we can finalize this message */
                return -1;
@@ -1107,7 +1113,7 @@ lnet_send_error_simulation(struct lnet_msg *msg,
 
        CDEBUG(D_NET, "src %s(%s)->dst %s: %s simulate health error: %s\n",
                libcfs_nid2str(msg->msg_hdr.src_nid),
-               libcfs_nid2str(msg->msg_txni->ni_nid),
+               libcfs_nidstr(&msg->msg_txni->ni_nid),
                libcfs_nid2str(msg->msg_hdr.dest_nid),
                lnet_msgtyp2str(msg->msg_type),
                lnet_health_error2str(*hstatus));