Whamcloud - gitweb
LU-11300 lnet: cache ni status 50/33450/30
authorAmir Shehata <ashehata@whamcloud.com>
Sat, 20 Oct 2018 01:02:05 +0000 (18:02 -0700)
committerAmir Shehata <ashehata@whamcloud.com>
Fri, 7 Jun 2019 18:13:33 +0000 (18:13 +0000)
When processing the data in the PUSH or the REPLY make sure to cache
the ns_status. This is the status of the peer_ni as reported by the
peer itself.

Test-Parameters: forbuildonly
Signed-off-by: Amir Shehata <ashehata@whamcloud.com>
Change-Id: I14de2460f578fb7f47d329a97b8833f49c569b74
Reviewed-on: https://review.whamcloud.com/33450
Reviewed-by: Chris Horn <hornc@cray.com>
Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
Tested-by: Jenkins
lnet/include/lnet/lib-types.h
lnet/lnet/peer.c

index 6690f07..96dafdc 100644 (file)
@@ -599,6 +599,8 @@ struct lnet_peer_ni {
        int                     lpni_cpt;
        /* state flags -- protected by lpni_lock */
        unsigned                lpni_state;
+       /* status of the peer NI as reported by the peer */
+       __u32                   lpni_ns_status;
        /* sequence number used to round robin over peer nis within a net */
        __u32                   lpni_seq;
        /* sequence number used to round robin over gateways */
index 9e95805..28bad27 100644 (file)
@@ -170,8 +170,10 @@ lnet_peer_ni_alloc(lnet_nid_t nid)
 
        spin_lock_init(&lpni->lpni_lock);
 
-       lpni->lpni_alive = !lnet_peers_start_down(); /* 1 bit!! */
-       lpni->lpni_last_alive = ktime_get_seconds(); /* assumes alive */
+       if (lnet_peers_start_down())
+               lpni->lpni_ns_status = LNET_NI_STATUS_DOWN;
+       else
+               lpni->lpni_ns_status = LNET_NI_STATUS_UP;
        lpni->lpni_ping_feats = LNET_PING_FEAT_INVAL;
        lpni->lpni_nid = nid;
        lpni->lpni_cpt = cpt;
@@ -2417,7 +2419,7 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
 {
        struct lnet_peer_ni *lpni;
        lnet_nid_t *curnis = NULL;
-       lnet_nid_t *addnis = NULL;
+       struct lnet_ni_status *addnis = NULL;
        lnet_nid_t *delnis = NULL;
        unsigned flags;
        int ncurnis;
@@ -2433,9 +2435,9 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
                flags |= LNET_PEER_MULTI_RAIL;
 
        nnis = MAX(lp->lp_nnis, pbuf->pb_info.pi_nnis);
-       LIBCFS_ALLOC(curnis, nnis * sizeof(lnet_nid_t));
-       LIBCFS_ALLOC(addnis, nnis * sizeof(lnet_nid_t));
-       LIBCFS_ALLOC(delnis, nnis * sizeof(lnet_nid_t));
+       LIBCFS_ALLOC(curnis, nnis * sizeof(*curnis));
+       LIBCFS_ALLOC(addnis, nnis * sizeof(*addnis));
+       LIBCFS_ALLOC(delnis, nnis * sizeof(*delnis));
        if (!curnis || !addnis || !delnis) {
                rc = -ENOMEM;
                goto out;
@@ -2458,7 +2460,7 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
                        if (pbuf->pb_info.pi_ni[i].ns_nid == curnis[j])
                                break;
                if (j == ncurnis)
-                       addnis[naddnis++] = pbuf->pb_info.pi_ni[i].ns_nid;
+                       addnis[naddnis++] = pbuf->pb_info.pi_ni[i];
        }
        /*
         * Check for NIDs in curnis[] not present in pbuf.
@@ -2470,23 +2472,41 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
        for (i = 0; i < ncurnis; i++) {
                if (LNET_NETTYP(LNET_NIDNET(curnis[i])) == LOLND)
                        continue;
-               for (j = 1; j < pbuf->pb_info.pi_nnis; j++)
-                       if (curnis[i] == pbuf->pb_info.pi_ni[j].ns_nid)
+               for (j = 1; j < pbuf->pb_info.pi_nnis; j++) {
+                       if (curnis[i] == pbuf->pb_info.pi_ni[j].ns_nid) {
+                               /*
+                                * update the information we cache for the
+                                * peer with the latest information we
+                                * received
+                                */
+                               lpni = lnet_find_peer_ni_locked(curnis[i]);
+                               if (lpni) {
+                                       lpni->lpni_ns_status = pbuf->pb_info.pi_ni[j].ns_status;
+                                       lnet_peer_ni_decref_locked(lpni);
+                               }
                                break;
+                       }
+               }
                if (j == pbuf->pb_info.pi_nnis)
                        delnis[ndelnis++] = curnis[i];
        }
 
        for (i = 0; i < naddnis; i++) {
-               rc = lnet_peer_add_nid(lp, addnis[i], flags);
+               rc = lnet_peer_add_nid(lp, addnis[i].ns_nid, flags);
                if (rc) {
                        CERROR("Error adding NID %s to peer %s: %d\n",
-                              libcfs_nid2str(addnis[i]),
+                              libcfs_nid2str(addnis[i].ns_nid),
                               libcfs_nid2str(lp->lp_primary_nid), rc);
                        if (rc == -ENOMEM)
                                goto out;
                }
+               lpni = lnet_find_peer_ni_locked(addnis[i].ns_nid);
+               if (lpni) {
+                       lpni->lpni_ns_status = addnis[i].ns_status;
+                       lnet_peer_ni_decref_locked(lpni);
+               }
        }
+
        for (i = 0; i < ndelnis; i++) {
                rc = lnet_peer_del_nid(lp, delnis[i], flags);
                if (rc) {
@@ -2504,9 +2524,9 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
         */
        rc = 0;
 out:
-       LIBCFS_FREE(curnis, nnis * sizeof(lnet_nid_t));
-       LIBCFS_FREE(addnis, nnis * sizeof(lnet_nid_t));
-       LIBCFS_FREE(delnis, nnis * sizeof(lnet_nid_t));
+       LIBCFS_FREE(curnis, nnis * sizeof(*curnis));
+       LIBCFS_FREE(addnis, nnis * sizeof(*addnis));
+       LIBCFS_FREE(delnis, nnis * sizeof(*delnis));
        lnet_ping_buffer_decref(pbuf);
        CDEBUG(D_NET, "peer %s: %d\n", libcfs_nid2str(lp->lp_primary_nid), rc);