Whamcloud - gitweb
LU-7734 lnet: Multi-Rail local_ni/peer_ni selection
[fs/lustre-release.git] / lnet / lnet / api-ni.c
index 4910d3a..8f5dc24 100644 (file)
@@ -62,6 +62,15 @@ module_param(use_tcp_bonding, int, 0444);
 MODULE_PARM_DESC(use_tcp_bonding,
                 "Set to 1 to use socklnd bonding. 0 to use Multi-Rail");
 
+/*
+ * This sequence number keeps track of how many times DLC was used to
+ * update the configuration. It is incremented on any DLC update and
+ * checked when sending a message to determine if there is a need to
+ * re-run the selection algorithm to handle configuration change.
+ * Look at lnet_select_pathway() for more details on its usage.
+ */
+static atomic_t lnet_dlc_seq_no = ATOMIC_INIT(0);
+
 static int lnet_ping(lnet_process_id_t id, signed long timeout,
                     lnet_process_id_t __user *ids, int n_ids);
 
@@ -589,6 +598,7 @@ lnet_prepare(lnet_pid_t requested_pid)
        the_lnet.ln_pid = requested_pid;
 
        INIT_LIST_HEAD(&the_lnet.ln_test_peers);
+       INIT_LIST_HEAD(&the_lnet.ln_peers);
        INIT_LIST_HEAD(&the_lnet.ln_nets);
        INIT_LIST_HEAD(&the_lnet.ln_routers);
        INIT_LIST_HEAD(&the_lnet.ln_drop_rules);
@@ -745,7 +755,7 @@ lnet_get_net_locked(__u32 net_id)
        return NULL;
 }
 
-static unsigned int
+unsigned int
 lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number)
 {
        __u64           key = nid;
@@ -1564,6 +1574,7 @@ lnet_startup_lndnet(struct lnet_net *net, struct lnet_lnd_tunables *tun)
 
        lnet_net_lock(LNET_LOCK_EX);
        list_splice_tail(&local_ni_list, &net_l->net_ni_list);
+       lnet_incr_dlc_seq();
        lnet_net_unlock(LNET_LOCK_EX);
 
        /* if the network is not unique then we don't want to keep
@@ -2242,6 +2253,16 @@ out:
        return rc;
 }
 
+void lnet_incr_dlc_seq(void)
+{
+       atomic_inc(&lnet_dlc_seq_no);
+}
+
+__u32 lnet_get_dlc_seq_locked(void)
+{
+       return atomic_read(&lnet_dlc_seq_no);
+}
+
 /**
  * LNet ioctl handler.
  *