From 398f4071dc17c83e6ac1600174b46e2675579ce7 Mon Sep 17 00:00:00 2001 From: Amir Shehata Date: Fri, 19 Oct 2018 18:02:05 -0700 Subject: [PATCH] LU-11300 lnet: cache ni status 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 Change-Id: I14de2460f578fb7f47d329a97b8833f49c569b74 Reviewed-on: https://review.whamcloud.com/33450 Reviewed-by: Chris Horn Reviewed-by: Olaf Weber Tested-by: Jenkins --- lnet/include/lnet/lib-types.h | 2 ++ lnet/lnet/peer.c | 48 ++++++++++++++++++++++++++++++------------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h index 6690f07..96dafdc 100644 --- a/lnet/include/lnet/lib-types.h +++ b/lnet/include/lnet/lib-types.h @@ -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 */ diff --git a/lnet/lnet/peer.c b/lnet/lnet/peer.c index 9e95805..28bad27 100644 --- a/lnet/lnet/peer.c +++ b/lnet/lnet/peer.c @@ -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); -- 1.8.3.1