Whamcloud - gitweb
LU-7734 lnet: Fix lnet_msg_free()
[fs/lustre-release.git] / lnet / include / lnet / lib-lnet.h
index 0d3fc99..97ca7a4 100644 (file)
@@ -451,13 +451,6 @@ static inline void
 lnet_msg_free(lnet_msg_t *msg)
 {
        LASSERT(!msg->msg_onactivelist);
-
-       /* Make sure we have no references to an NI. */
-       if (msg->msg_txni)
-               lnet_ni_decref_locked(msg->msg_txni, msg->msg_tx_cpt);
-       if (msg->msg_rxni)
-               lnet_ni_decref_locked(msg->msg_rxni, msg->msg_rx_cpt);
-
        LIBCFS_FREE(msg, sizeof(*msg));
 }
 
@@ -470,6 +463,9 @@ lnet_net_alloc(__u32 net_type, struct list_head *netlist);
 struct lnet_ni *
 lnet_ni_alloc(struct lnet_net *net, struct cfs_expr_list *el,
              char *iface);
+struct lnet_ni *
+lnet_ni_alloc_w_cpt_array(struct lnet_net *net, __u32 *cpts, __u32 ncpts,
+                         char *iface);
 
 static inline int
 lnet_nid2peerhash(lnet_nid_t nid)
@@ -494,8 +490,9 @@ extern int lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni);
 extern lnet_ni_t *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
 extern lnet_ni_t *lnet_nid2ni_addref(lnet_nid_t nid);
 extern lnet_ni_t *lnet_net2ni_locked(__u32 net, int cpt);
-extern lnet_ni_t *lnet_net2ni(__u32 net);
+extern lnet_ni_t *lnet_net2ni_addref(__u32 net);
 bool lnet_is_ni_healthy_locked(struct lnet_ni *ni);
+struct lnet_net *lnet_get_net_locked(__u32 net_id);
 
 int lnet_lib_init(void);
 void lnet_lib_exit(void);
@@ -542,9 +539,10 @@ int lnet_rtrpools_enable(void);
 void lnet_rtrpools_disable(void);
 void lnet_rtrpools_free(int keep_pools);
 lnet_remotenet_t *lnet_find_rnet_locked(__u32 net);
-int lnet_dyn_add_ni(lnet_pid_t requested_pid,
-                   struct lnet_ioctl_config_data *conf);
-int lnet_dyn_del_ni(__u32 net);
+int lnet_dyn_add_net(struct lnet_ioctl_config_data *conf);
+int lnet_dyn_del_net(__u32 net);
+int lnet_dyn_add_ni(struct lnet_ioctl_config_ni *conf);
+int lnet_dyn_del_ni(struct lnet_ioctl_config_ni *conf);
 int lnet_clear_lazy_portal(struct lnet_ni *ni, int portal, char *reason);
 struct lnet_net *lnet_get_net_locked(__u32 net_id);
 
@@ -789,19 +787,92 @@ int lnet_parse_networks(struct list_head *nilist, char *networks,
 bool lnet_net_unique(__u32 net_id, struct list_head *nilist,
                     struct lnet_net **net);
 bool lnet_ni_unique_net(struct list_head *nilist, char *iface);
-
-int lnet_nid2peerni_locked(struct lnet_peer_ni **lpp, lnet_nid_t nid, int cpt);
-struct lnet_peer_ni *lnet_find_peer_ni_locked(lnet_nid_t nid, int cpt);
-void lnet_peer_tables_cleanup(lnet_ni_t *ni);
-void lnet_peer_tables_destroy(void);
+void lnet_incr_dlc_seq(void);
+__u32 lnet_get_dlc_seq_locked(void);
+inline __u32 lnet_get_numa_range(void);
+
+struct lnet_peer_ni *lnet_get_next_peer_ni_locked(struct lnet_peer *peer,
+                                                 struct lnet_peer_net *peer_net,
+                                                 struct lnet_peer_ni *prev);
+struct lnet_peer *lnet_find_or_create_peer_locked(lnet_nid_t dst_nid, int cpt);
+struct lnet_peer_ni *lnet_nid2peerni_locked(lnet_nid_t nid, int cpt);
+struct lnet_peer_ni *lnet_find_peer_ni_locked(lnet_nid_t nid);
+void lnet_peer_net_added(struct lnet_net *net);
+lnet_nid_t lnet_peer_primary_nid(lnet_nid_t nid);
+void lnet_peer_tables_cleanup(struct lnet_net *net);
+void lnet_peer_uninit(void);
 int lnet_peer_tables_create(void);
 void lnet_debug_peer(lnet_nid_t nid);
-int lnet_get_peer_info(__u32 peer_index, __u64 *nid,
-                      char alivness[LNET_MAX_STR_LEN],
-                      __u32 *cpt_iter, __u32 *refcount,
-                      __u32 *ni_peer_tx_credits, __u32 *peer_tx_credits,
-                      __u32 *peer_rtr_credits, __u32 *peer_min_rtr_credtis,
-                      __u32 *peer_tx_qnob);
+struct lnet_peer_net *lnet_peer_get_net_locked(struct lnet_peer *peer,
+                                              __u32 net_id);
+bool lnet_peer_is_ni_pref_locked(struct lnet_peer_ni *lpni,
+                                struct lnet_ni *ni);
+int lnet_add_peer_ni_to_peer(lnet_nid_t key_nid, lnet_nid_t nid, bool mr);
+int lnet_del_peer_ni_from_peer(lnet_nid_t key_nid, lnet_nid_t nid);
+int lnet_get_peer_info(__u32 idx, lnet_nid_t *primary_nid, lnet_nid_t *nid,
+                      bool *mr, struct lnet_peer_ni_credit_info *peer_ni_info,
+                      struct lnet_ioctl_element_stats *peer_ni_stats);
+int lnet_get_peer_ni_info(__u32 peer_index, __u64 *nid,
+                         char alivness[LNET_MAX_STR_LEN],
+                         __u32 *cpt_iter, __u32 *refcount,
+                         __u32 *ni_peer_tx_credits, __u32 *peer_tx_credits,
+                         __u32 *peer_rtr_credits, __u32 *peer_min_rtr_credtis,
+                         __u32 *peer_tx_qnob);
+
+
+static inline __u32
+lnet_get_num_peer_nis(struct lnet_peer *peer)
+{
+       struct lnet_peer_net *lpn;
+       struct lnet_peer_ni *lpni;
+       __u32 count = 0;
+
+       list_for_each_entry(lpn, &peer->lp_peer_nets, lpn_on_peer_list)
+               list_for_each_entry(lpni, &lpn->lpn_peer_nis,
+                                   lpni_on_peer_net_list)
+                       count++;
+
+       return count;
+}
+
+static inline bool
+lnet_is_peer_ni_healthy_locked(struct lnet_peer_ni *lpni)
+{
+       return lpni->lpni_healthy;
+}
+
+static inline void
+lnet_set_peer_ni_health_locked(struct lnet_peer_ni *lpni, bool health)
+{
+       lpni->lpni_healthy = health;
+}
+
+static inline bool
+lnet_is_peer_net_healthy_locked(struct lnet_peer_net *peer_net)
+{
+       struct lnet_peer_ni *lpni;
+
+       list_for_each_entry(lpni, &peer_net->lpn_peer_nis,
+                           lpni_on_peer_net_list) {
+               if (lnet_is_peer_ni_healthy_locked(lpni))
+                       return true;
+       }
+
+       return false;
+}
+
+static inline bool
+lnet_is_peer_healthy_locked(struct lnet_peer *peer)
+{
+       struct lnet_peer_net *peer_net;
+
+       list_for_each_entry(peer_net, &peer->lp_peer_nets, lpn_on_peer_list) {
+               if (lnet_is_peer_net_healthy_locked(peer_net))
+                       return true;
+       }
+
+       return false;
+}
 
 static inline void
 lnet_peer_set_alive(struct lnet_peer_ni *lp)