-void
-lnet_notify_locked(struct lnet_peer_ni *lp, int notifylnd, int alive,
- time64_t when)
-{
- if (lp->lpni_timestamp > when) { /* out of date information */
- CDEBUG(D_NET, "Out of date\n");
- return;
- }
-
- /*
- * This function can be called with different cpt locks being
- * held. lpni_alive_count modification needs to be properly protected.
- * Significant reads to lpni_alive_count are also protected with
- * the same lock
- */
- spin_lock(&lp->lpni_lock);
-
- lp->lpni_timestamp = when; /* update timestamp */
-
- /* got old news */
- if (lp->lpni_alive_count != 0 &&
- /* new date for old news */
- (!lnet_is_peer_ni_alive(lp)) == (!alive)) {
- spin_unlock(&lp->lpni_lock);
- CDEBUG(D_NET, "Old news\n");
- return;
- }
-
- /* Flag that notification is outstanding */
-
- lp->lpni_alive_count++;
- lp->lpni_notify = 1;
- lp->lpni_notifylnd = notifylnd;
- if (lnet_is_peer_ni_alive(lp))
- lp->lpni_ping_feats = LNET_PING_FEAT_INVAL; /* reset */
-
- spin_unlock(&lp->lpni_lock);
-
- CDEBUG(D_NET, "set %s %d\n", libcfs_nid2str(lp->lpni_nid), alive);
-}
-
-/*
- * This function will always be called with lp->lpni_cpt lock held.
- */
-static void
-lnet_ni_notify_locked(struct lnet_ni *ni, struct lnet_peer_ni *lp)
-{
- int alive;
- int notifylnd;
-
- /* Notify only in 1 thread at any time to ensure ordered notification.
- * NB individual events can be missed; the only guarantee is that you
- * always get the most recent news */
-
- spin_lock(&lp->lpni_lock);
-
- if (lp->lpni_notifying || ni == NULL) {
- spin_unlock(&lp->lpni_lock);
- return;
- }
-
- lp->lpni_notifying = 1;
-
- /*
- * lp->lpni_notify needs to be protected because it can be set in
- * lnet_notify_locked().
- */
- while (lp->lpni_notify) {
- alive = lnet_is_peer_ni_alive(lp);
- notifylnd = lp->lpni_notifylnd;
-
- lp->lpni_notifylnd = 0;
- lp->lpni_notify = 0;
-
- if (notifylnd && ni->ni_net->net_lnd->lnd_notify != NULL) {
- spin_unlock(&lp->lpni_lock);
- lnet_net_unlock(lp->lpni_cpt);
-
- /* A new notification could happen now; I'll handle it
- * when control returns to me */
-
- (ni->ni_net->net_lnd->lnd_notify)(ni, lp->lpni_nid,
- alive);
-
- lnet_net_lock(lp->lpni_cpt);
- spin_lock(&lp->lpni_lock);
- }
- }
-
- lp->lpni_notifying = 0;
- spin_unlock(&lp->lpni_lock);
-}
-