Whamcloud - gitweb
LU-13569 lnet: Recover local NI w/exponential backoff interval
[fs/lustre-release.git] / lnet / include / lnet / lib-lnet.h
index 176c9a2..a620aaa 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * lnet/include/lnet/lib-lnet.h
  *
@@ -375,18 +374,15 @@ lnet_peer_decref_locked(struct lnet_peer *lp)
 static inline void
 lnet_peer_ni_addref_locked(struct lnet_peer_ni *lp)
 {
-       LASSERT(atomic_read(&lp->lpni_refcount) > 0);
-       atomic_inc(&lp->lpni_refcount);
+       kref_get(&lp->lpni_kref);
 }
 
-extern void lnet_destroy_peer_ni_locked(struct lnet_peer_ni *lp);
+extern void lnet_destroy_peer_ni_locked(struct kref *ref);
 
 static inline void
 lnet_peer_ni_decref_locked(struct lnet_peer_ni *lp)
 {
-       LASSERT(atomic_read(&lp->lpni_refcount) > 0);
-       if (atomic_dec_and_test(&lp->lpni_refcount))
-               lnet_destroy_peer_ni_locked(lp);
+       kref_put(&lp->lpni_kref, lnet_destroy_peer_ni_locked);
 }
 
 static inline int
@@ -564,6 +560,9 @@ extern void lnet_peer_clr_pref_nids(struct lnet_peer_ni *lpni);
 extern int lnet_peer_del_pref_nid(struct lnet_peer_ni *lpni, lnet_nid_t nid);
 void lnet_peer_ni_set_selection_priority(struct lnet_peer_ni *lpni,
                                         __u32 priority);
+extern void lnet_ni_add_to_recoveryq_locked(struct lnet_ni *ni,
+                                           struct list_head *queue,
+                                           time64_t now);
 
 void lnet_router_debugfs_init(void);
 void lnet_router_debugfs_fini(void);
@@ -1007,6 +1006,12 @@ lnet_peer_ni_set_next_ping(struct lnet_peer_ni *lpni, time64_t now)
                lnet_get_next_recovery_ping(lpni->lpni_ping_count, now);
 }
 
+static inline void
+lnet_ni_set_next_ping(struct lnet_ni *ni, time64_t now)
+{
+       ni->ni_next_ping = lnet_get_next_recovery_ping(ni->ni_ping_count, now);
+}
+
 /*
  * A peer NI is alive if it satisfies the following two conditions:
  *  1. peer NI health >= LNET_MAX_HEALTH_VALUE * router_sensitivity_percentage
@@ -1117,4 +1122,16 @@ __u32 lnet_sum_stats(struct lnet_element_stats *stats,
 void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
                              struct lnet_element_stats *stats);
 
+static inline void
+lnet_set_route_aliveness(struct lnet_route *route, bool alive)
+{
+       bool old = atomic_xchg(&route->lr_alive, alive);
+
+       if (old != alive)
+               CERROR("route to %s through %s has gone from %s to %s\n",
+                      libcfs_net2str(route->lr_net),
+                      libcfs_nid2str(route->lr_gateway->lp_primary_nid),
+                      old ? "up" : "down",
+                      alive ? "up" : "down");
+}
 #endif