Whamcloud - gitweb
LU-13782 lnet: Have LNet routers monitor the ni_fatal flag
[fs/lustre-release.git] / lnet / include / lnet / lib-lnet.h
index dbe8ba5..6bfe88d 100644 (file)
@@ -215,6 +215,35 @@ extern struct kmem_cache *lnet_small_mds_cachep; /* <= LNET_SMALL_MD_SIZE bytes
 extern struct kmem_cache *lnet_rspt_cachep;
 extern struct kmem_cache *lnet_msg_cachep;
 
+static inline bool
+lnet_ni_set_status_locked(struct lnet_ni *ni, __u32 status)
+__must_hold(&ni->ni_lock)
+{
+       bool update = false;
+
+       if (ni->ni_status && ni->ni_status->ns_status != status) {
+               CDEBUG(D_NET, "ni %s status changed from %#x to %#x\n",
+                      libcfs_nid2str(ni->ni_nid),
+                      ni->ni_status->ns_status, status);
+               ni->ni_status->ns_status = status;
+               update = true;
+       }
+
+       return update;
+}
+
+static inline bool
+lnet_ni_set_status(struct lnet_ni *ni, __u32 status)
+{
+       bool update;
+
+       lnet_ni_lock(ni);
+       update = lnet_ni_set_status_locked(ni, status);
+       lnet_ni_unlock(ni);
+
+       return update;
+}
+
 static inline void
 lnet_md_free(struct lnet_libmd *md)
 {