Whamcloud - gitweb
LU-9480 lnet: add lnet_interfaces_max tunable
[fs/lustre-release.git] / lnet / lnet / api-ni.c
index 1a5aa34..2db2d7a 100644 (file)
@@ -33,6 +33,7 @@
 #define DEBUG_SUBSYSTEM S_LNET
 #include <linux/log2.h>
 #include <linux/ktime.h>
+#include <linux/moduleparam.h>
 
 #include <lnet/lib-lnet.h>
 
@@ -67,6 +68,13 @@ module_param(lnet_numa_range, uint, 0444);
 MODULE_PARM_DESC(lnet_numa_range,
                "NUMA range to consider during Multi-Rail selection");
 
+static int lnet_interfaces_max = LNET_INTERFACES_MAX_DEFAULT;
+static int intf_max_set(const char *val, struct kernel_param *kp);
+module_param_call(lnet_interfaces_max, intf_max_set, param_get_int,
+                 &lnet_interfaces_max, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(lnet_interfaces_max,
+               "Maximum number of interfaces in a node.");
+
 /*
  * This sequence number keeps track of how many times DLC was used to
  * update the local NIs. It is incremented when a NI is added or
@@ -79,6 +87,28 @@ static atomic_t lnet_dlc_seq_no = ATOMIC_INIT(0);
 static int lnet_ping(struct lnet_process_id id, signed long timeout,
                     struct lnet_process_id __user *ids, int n_ids);
 
+static int
+intf_max_set(const char *val, struct kernel_param *kp)
+{
+       int value, rc;
+
+       rc = kstrtoint(val, 0, &value);
+       if (rc) {
+               CERROR("Invalid module parameter value for 'lnet_interfaces_max'\n");
+               return rc;
+       }
+
+       if (value < LNET_INTERFACES_MIN) {
+               CWARN("max interfaces provided are too small, setting to %d\n",
+                     LNET_INTERFACES_MIN);
+               value = LNET_INTERFACES_MIN;
+       }
+
+       *(int *)kp->arg = value;
+
+       return 0;
+}
+
 static char *
 lnet_get_routes(void)
 {
@@ -3010,23 +3040,23 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout,
        struct lnet_handle_md mdh;
        struct lnet_event event;
        struct lnet_md md = { NULL };
-       int                  which;
-       int                  unlinked = 0;
-       int                  replied = 0;
+       int which;
+       int unlinked = 0;
+       int replied = 0;
        const signed long a_long_time = msecs_to_jiffies(60 * MSEC_PER_SEC);
-       int                  infosz;
+       int infosz;
        struct lnet_ping_info *info;
        struct lnet_process_id tmpid;
-       int                  i;
-       int                  nob;
-       int                  rc;
-       int                  rc2;
-       sigset_t         blocked;
+       int i;
+       int nob;
+       int rc;
+       int rc2;
+       sigset_t blocked;
 
        infosz = offsetof(struct lnet_ping_info, pi_ni[n_ids]);
 
        /* n_ids limit is arbitrary */
-       if (n_ids <= 0 || n_ids > 20 || id.nid == LNET_NID_ANY)
+       if (n_ids <= 0 || n_ids > lnet_interfaces_max || id.nid == LNET_NID_ANY)
                return -EINVAL;
 
        if (id.pid == LNET_PID_ANY)