Whamcloud - gitweb
LU-11514 lnet: separate ni state from recovery
[fs/lustre-release.git] / lnet / lnet / config.c
index fbbc18c..240a27d 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2016, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -31,6 +31,8 @@
  */
 
 #define DEBUG_SUBSYSTEM S_LNET
+
+#include <linux/ctype.h>
 #include <linux/nsproxy.h>
 #include <net/net_namespace.h>
 #include <lnet/lib-lnet.h>
@@ -121,10 +123,10 @@ lnet_ni_unique_net(struct list_head *nilist, char *iface)
 /* check that the NI is unique to the interfaces with in the same NI.
  * This is only a consideration if use_tcp_bonding is set */
 static bool
-lnet_ni_unique_ni(char *iface_list[LNET_NUM_INTERFACES], char *iface)
+lnet_ni_unique_ni(char *iface_list[LNET_INTERFACES_NUM], char *iface)
 {
        int i;
-       for (i = 0; i < LNET_NUM_INTERFACES; i++) {
+       for (i = 0; i < LNET_INTERFACES_NUM; i++) {
                if (iface_list[i] != NULL &&
                    strncmp(iface_list[i], iface, strlen(iface)) == 0)
                        return false;
@@ -173,7 +175,7 @@ lnet_net_append_cpts(__u32 *cpts, __u32 ncpts, struct lnet_net *net)
                LIBCFS_ALLOC(net->net_cpts, sizeof(*net->net_cpts) * ncpts);
                if (net->net_cpts == NULL)
                        return -ENOMEM;
-               memcpy(net->net_cpts, cpts, ncpts);
+               memcpy(net->net_cpts, cpts, ncpts * sizeof(*net->net_cpts));
                net->net_ncpts = ncpts;
                return 0;
        }
@@ -307,7 +309,7 @@ lnet_ni_free(struct lnet_ni *ni)
        if (ni->ni_cpts != NULL)
                cfs_expr_list_values_free(ni->ni_cpts, ni->ni_ncpts);
 
-       for (i = 0; i < LNET_NUM_INTERFACES &&
+       for (i = 0; i < LNET_INTERFACES_NUM &&
                    ni->ni_interfaces[i] != NULL; i++) {
                LIBCFS_FREE(ni->ni_interfaces[i],
                            strlen(ni->ni_interfaces[i]) + 1);
@@ -407,11 +409,11 @@ lnet_ni_add_interface(struct lnet_ni *ni, char *iface)
         * can free the tokens at the end of the function.
         * The newly allocated ni_interfaces[] can be
         * freed when freeing the NI */
-       while (niface < LNET_NUM_INTERFACES &&
+       while (niface < LNET_INTERFACES_NUM &&
               ni->ni_interfaces[niface] != NULL)
                niface++;
 
-       if (niface >= LNET_NUM_INTERFACES) {
+       if (niface >= LNET_INTERFACES_NUM) {
                LCONSOLE_ERROR_MSG(0x115, "Too many interfaces "
                                   "for net %s\n",
                                   libcfs_net2str(LNET_NIDNET(ni->ni_nid)));
@@ -454,8 +456,8 @@ lnet_ni_alloc_common(struct lnet_net *net, char *iface)
        }
 
        spin_lock_init(&ni->ni_lock);
-       INIT_LIST_HEAD(&ni->ni_cptlist);
        INIT_LIST_HEAD(&ni->ni_netlist);
+       INIT_LIST_HEAD(&ni->ni_recovery);
        ni->ni_refs = cfs_percpt_alloc(lnet_cpt_table(),
                                       sizeof(*ni->ni_refs[0]));
        if (ni->ni_refs == NULL)