Whamcloud - gitweb
LU-5570 lnet: check router aliveness timestamp
[fs/lustre-release.git] / lnet / include / lnet / lib-lnet.h
index 8c09022..73a4d68 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2012, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -41,7 +41,7 @@
 #ifndef __LNET_LIB_LNET_H__
 #define __LNET_LIB_LNET_H__
 
-#include <lnet/linux/lib-lnet.h>
+#define LNET_ROUTER
 
 #include <libcfs/libcfs.h>
 #include <lnet/types.h>
@@ -651,6 +651,31 @@ lnet_isrouter(lnet_peer_t *lp)
         return lp->lp_rtr_refcount != 0;
 }
 
+/* check if it's a router checker ping */
+static inline int
+lnet_msg_is_rc_ping(struct lnet_msg *msg)
+{
+       lnet_hdr_t      *hdr = &msg->msg_hdr;
+
+       return msg->msg_type == LNET_MSG_GET &&
+              hdr->msg.get.ptl_index == cpu_to_le32(LNET_RESERVED_PORTAL) &&
+              hdr->msg.get.match_bits ==
+                           cpu_to_le64(LNET_PROTO_PING_MATCHBITS);
+}
+
+/* peer aliveness is enabled in a network where lnet_ni_t::ni_peertimeout has
+ * been set to a positive value, it's only valid for router peers or peers on
+ * routers.
+ */
+static inline int
+lnet_peer_aliveness_enabled(struct lnet_peer *lp)
+{
+       if (lp->lp_ni->ni_peertimeout <= 0)
+               return 0;
+
+       return the_lnet.ln_routing || lnet_isrouter(lp);
+}
+
 static inline void
 lnet_ni_addref_locked(lnet_ni_t *ni, int cpt)
 {
@@ -702,6 +727,7 @@ lnet_net2rnethash(__u32 net)
 }
 
 extern lnd_t the_lolnd;
+extern int avoid_asym_router_failure;
 
 #ifndef __KERNEL__
 /* unconditional registration */
@@ -836,11 +862,22 @@ void lnet_portals_destroy(void);
 /* message functions */
 int lnet_parse (lnet_ni_t *ni, lnet_hdr_t *hdr,
                 lnet_nid_t fromnid, void *private, int rdma_req);
+int lnet_parse_local(lnet_ni_t *ni, lnet_msg_t *msg);
+int lnet_parse_forward_locked(lnet_ni_t *ni, lnet_msg_t *msg);
+
 void lnet_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
                unsigned int offset, unsigned int mlen, unsigned int rlen);
+void lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg,
+                 int delayed, unsigned int offset,
+                 unsigned int mlen, unsigned int rlen);
+
 lnet_msg_t *lnet_create_reply_msg (lnet_ni_t *ni, lnet_msg_t *get_msg);
 void lnet_set_reply_msg_len(lnet_ni_t *ni, lnet_msg_t *msg, unsigned int len);
+
 void lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int rc);
+
+void lnet_drop_message(lnet_ni_t *ni, int cpt, void *private,
+                      unsigned int nob);
 void lnet_drop_delayed_msg_list(struct list_head *head, char *reason);
 void lnet_recv_delayed_msg_list(struct list_head *head);
 
@@ -853,6 +890,24 @@ char *lnet_msgtyp2str (int type);
 void lnet_print_hdr (lnet_hdr_t * hdr);
 int lnet_fail_nid(lnet_nid_t nid, unsigned int threshold);
 
+/** \addtogroup lnet_fault_simulation @{ */
+
+int lnet_fault_ctl(int cmd, struct libcfs_ioctl_data *data);
+int lnet_fault_init(void);
+void lnet_fault_fini(void);
+
+bool lnet_drop_rule_match(lnet_hdr_t *hdr);
+
+int lnet_delay_rule_add(struct lnet_fault_attr *attr);
+int lnet_delay_rule_del(lnet_nid_t src, lnet_nid_t dst, bool shutdown);
+int lnet_delay_rule_list(int pos, struct lnet_fault_attr *attr,
+                        struct lnet_fault_stat *stat);
+void lnet_delay_rule_reset(void);
+void lnet_delay_rule_check(void);
+bool lnet_delay_rule_match_locked(lnet_hdr_t *hdr, struct lnet_msg *msg);
+
+/** @} lnet_fault_simulation */
+
 void lnet_counters_get(lnet_counters_t *counters);
 void lnet_counters_reset(void);
 
@@ -960,6 +1015,7 @@ int lnet_peer_buffer_credits(lnet_ni_t *ni);
 
 int lnet_router_checker_start(void);
 void lnet_router_checker_stop(void);
+void lnet_router_ni_update_locked(lnet_peer_t *gw, __u32 net);
 void lnet_swap_pinginfo(lnet_ping_info_t *info);
 
 int lnet_parse_ip2nets(char **networksp, char *ip2nets);
@@ -981,6 +1037,14 @@ int lnet_get_peer_info(__u32 peer_index, __u64 *nid,
                       __u32 *peer_rtr_credits, __u32 *peer_min_rtr_credtis,
                       __u32 *peer_tx_qnob);
 
+static inline void
+lnet_peer_set_alive(lnet_peer_t *lp)
+{
+       lp->lp_last_alive = lp->lp_last_query = cfs_time_current();
+       if (!lp->lp_alive)
+               lnet_notify_locked(lp, 0, 1, lp->lp_last_alive);
+}
+
 #ifndef __KERNEL__
 static inline int
 lnet_parse_int_tunable(int *value, char *name)