Whamcloud - gitweb
LU-9480 lnet: tune lnet_peer_discovery_disabled with lnetctl 87/25787/21
authorOlaf Weber <olaf@sgi.com>
Tue, 28 Mar 2017 09:09:32 +0000 (11:09 +0200)
committerAmir Shehata <amir.shehata@intel.com>
Tue, 22 Aug 2017 16:26:08 +0000 (16:26 +0000)
A new tunable, lnet_peer_discovery_disabled, has been introduced.
Make it tunable with lnetctl. Note that the state of discovery is
reported as 1/enabled, or 0/disabled, which is the inverse of the
module parameter.

Test-Parameters: trivial
Signed-off-by: Olaf Weber <olaf@sgi.com>
Signed-off-by: Amir Shehata <amir.shehata@intel.com>
Change-Id: I67333d86520c5b6db8ff99c924054c4b487c8029
Reviewed-on: https://review.whamcloud.com/25787
Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
lnet/utils/lnetconfig/liblnetconfig.c
lnet/utils/lnetconfig/liblnetconfig.h
lnet/utils/lnetctl.c

index c182e6c..fd7e898 100644 (file)
@@ -1859,6 +1859,29 @@ int lustre_lnet_config_max_intf(int max, int seq_no, struct cYAML **err_rc)
        return rc;
 }
 
+int lustre_lnet_config_discovery(int enable, int seq_no, struct cYAML **err_rc)
+{
+       int rc = LUSTRE_CFG_RC_NO_ERR;
+       char err_str[LNET_MAX_STR_LEN];
+       char val[LNET_MAX_STR_LEN];
+
+       snprintf(err_str, sizeof(err_str), "\"success\"");
+
+       snprintf(val, sizeof(val), "%u", (enable) ? 0 : 1);
+
+       rc = write_sysfs_file(modparam_path, "lnet_peer_discovery_disabled", val,
+                             1, strlen(val) + 1);
+       if (rc)
+               snprintf(err_str, sizeof(err_str),
+                        "\"cannot configure discovery: %s\"",
+                        strerror(errno));
+
+       cYAML_build_error(rc, seq_no, ADD_CMD, "discovery", err_str, err_rc);
+
+       return rc;
+
+}
+
 int lustre_lnet_config_numa_range(int range, int seq_no, struct cYAML **err_rc)
 {
        struct lnet_ioctl_set_value data;
@@ -2358,6 +2381,61 @@ out:
        return rc;
 }
 
+int lustre_lnet_show_discovery(int seq_no, struct cYAML **show_rc,
+                              struct cYAML **err_rc)
+{
+       int rc = LUSTRE_CFG_RC_OUT_OF_MEM;
+       char val[LNET_MAX_STR_LEN];
+       __u32 discovery;
+       char err_str[LNET_MAX_STR_LEN];
+       struct cYAML *root = NULL, *global = NULL;
+
+       snprintf(err_str, sizeof(err_str), "\"out of memory\"");
+
+       rc = read_sysfs_file(modparam_path, "lnet_peer_discovery_disabled", val,
+                            1, sizeof(val));
+       if (rc) {
+               snprintf(err_str, sizeof(err_str),
+                        "\"cannot get discovery value: %d\"", rc);
+               goto out;
+       }
+
+       /*
+        * the sysfs parameter read indicates if discovery is disabled,
+        * but we report if discovery is enabled.
+        */
+       discovery = !atoi(val);
+
+       root = cYAML_create_object(NULL, NULL);
+       if (root == NULL)
+               goto out;
+
+       global = cYAML_create_object(root, "global");
+       if (global == NULL)
+               goto out;
+
+       if (cYAML_create_number(global, "discovery",
+                               discovery) == NULL)
+               goto out;
+
+       if (show_rc == NULL)
+               cYAML_print_tree(root);
+
+       snprintf(err_str, sizeof(err_str), "\"success\"");
+out:
+       if (show_rc == NULL || rc != LUSTRE_CFG_RC_NO_ERR) {
+               cYAML_free_tree(root);
+       } else if (show_rc != NULL && *show_rc != NULL) {
+               add_to_global(*show_rc, global, root);
+       } else {
+               *show_rc = root;
+       }
+
+       cYAML_build_error(rc, seq_no, SHOW_CMD, "global", err_str, err_rc);
+
+       return rc;
+}
+
 int lustre_lnet_show_numa_range(int seq_no, struct cYAML **show_rc,
                                struct cYAML **err_rc)
 {
@@ -3178,7 +3256,7 @@ static int handle_yaml_config_global_settings(struct cYAML *tree,
                                              struct cYAML **show_rc,
                                              struct cYAML **err_rc)
 {
-       struct cYAML *max_intf, *numa, *seq_no;
+       struct cYAML *max_intf, *numa, *discovery, *seq_no;
        int rc = 0;
 
        seq_no = cYAML_get_object_item(tree, "seq_no");
@@ -3196,6 +3274,13 @@ static int handle_yaml_config_global_settings(struct cYAML *tree,
                                                        : -1,
                                                   err_rc);
 
+       discovery = cYAML_get_object_item(tree, "discovery");
+       if (discovery)
+               rc = lustre_lnet_config_discovery(discovery->cy_valueint,
+                                                 seq_no ? seq_no->cy_valueint
+                                                       : -1,
+                                                 err_rc);
+
        return rc;
 }
 
@@ -3203,7 +3288,7 @@ static int handle_yaml_del_global_settings(struct cYAML *tree,
                                           struct cYAML **show_rc,
                                           struct cYAML **err_rc)
 {
-       struct cYAML *max_intf, *numa, *seq_no;
+       struct cYAML *max_intf, *numa, *discovery, *seq_no;
        int rc = 0;
 
        seq_no = cYAML_get_object_item(tree, "seq_no");
@@ -3221,6 +3306,14 @@ static int handle_yaml_del_global_settings(struct cYAML *tree,
                                                        : -1,
                                                   err_rc);
 
+       /* peer discovery is enabled by default */
+       discovery = cYAML_get_object_item(tree, "discovery");
+       if (discovery)
+               rc = lustre_lnet_config_discovery(1,
+                                                 seq_no ? seq_no->cy_valueint
+                                                       : -1,
+                                                 err_rc);
+
        return rc;
 }
 
@@ -3228,7 +3321,7 @@ static int handle_yaml_show_global_settings(struct cYAML *tree,
                                            struct cYAML **show_rc,
                                            struct cYAML **err_rc)
 {
-       struct cYAML *max_intf, *numa, *seq_no;
+       struct cYAML *max_intf, *numa, *discovery, *seq_no;
        int rc = 0;
 
        seq_no = cYAML_get_object_item(tree, "seq_no");
@@ -3244,6 +3337,12 @@ static int handle_yaml_show_global_settings(struct cYAML *tree,
                                                        : -1,
                                                 show_rc, err_rc);
 
+       discovery = cYAML_get_object_item(tree, "discovery");
+       if (discovery)
+               rc = lustre_lnet_show_discovery(seq_no ? seq_no->cy_valueint
+                                                       : -1,
+                                               show_rc, err_rc);
+
        return rc;
 }
 
index 8e69ebb..627399e 100644 (file)
@@ -241,6 +241,29 @@ int lustre_lnet_show_max_intf(int seq_no, struct cYAML **show_rc,
                              struct cYAML **err_rc);
 
 /*
+ * lustre_lnet_config_discovery
+ *   Enable or disable peer discovery. Peer discovery is enabled by default.
+ *
+ *   enable - non-0 enables, 0 disables
+ *   seq_no - sequence number of the request
+ *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
+ *   caller
+ */
+int lustre_lnet_config_discovery(int enable, int seq_no, struct cYAML **err_rc);
+
+/*
+ * lustre_lnet_show_discovery
+ *    show current peer discovery setting
+ *
+ *   seq_no - sequence number of the request
+ *   show_rc - [OUT] struct cYAML tree containing NUMA range info
+ *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
+ *   caller
+ */
+int lustre_lnet_show_discovery(int seq_no, struct cYAML **show_rc,
+                              struct cYAML **err_rc);
+
+/*
  * lustre_lnet_config_buffers
  *   Send down an IOCTL to configure routing buffer sizes.  A value of 0 means
  *   default that particular buffer to default size. A value of -1 means
index efd58dd..430d91f 100644 (file)
@@ -56,6 +56,7 @@ static int jt_set_numa(int argc, char **argv);
 static int jt_add_peer_nid(int argc, char **argv);
 static int jt_del_peer_nid(int argc, char **argv);
 static int jt_set_max_intf(int argc, char **argv);
+static int jt_set_discovery(int argc, char **argv);
 /*static int jt_show_peer(int argc, char **argv);*/
 static int lnetctl_list_commands(int argc, char **argv);
 
@@ -133,6 +134,9 @@ command_t set_cmds[] = {
        {"max_interfaces", jt_set_max_intf, 0, "set the default value for "
                "max interfaces\n"
         "\tValue must be greater than 16\n"},
+       {"discovery", jt_set_discovery, 0, "enable/disable peer discovery\n"
+        "\t0 - disable peer discovery\n"
+        "\t1 - enable peer discovery (default)\n"},
        { 0, 0, 0, NULL }
 };
 
@@ -268,6 +272,33 @@ static int jt_set_numa(int argc, char **argv)
        return rc;
 }
 
+static int jt_set_discovery(int argc, char **argv)
+{
+       long int value;
+       int rc;
+       struct cYAML *err_rc = NULL;
+
+       if (handle_help(set_cmds, "set", "discovery", argc, argv) == 0)
+               return 0;
+
+       rc = parse_long(argv[1], &value);
+       if (rc != 0) {
+               cYAML_build_error(-1, -1, "parser", "set",
+                                 "cannot parse discovery value", &err_rc);
+               cYAML_print_tree2file(stderr, err_rc);
+               cYAML_free_tree(err_rc);
+               return -1;
+       }
+
+       rc = lustre_lnet_config_discovery(value, -1, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR)
+               cYAML_print_tree2file(stderr, err_rc);
+
+       cYAML_free_tree(err_rc);
+
+       return rc;
+}
+
 static int jt_set_tiny(int argc, char **argv)
 {
        long int value;
@@ -870,6 +901,12 @@ static int jt_show_global(int argc, char **argv)
                goto out;
        }
 
+       rc = lustre_lnet_show_discovery(-1, &show_rc, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR) {
+               cYAML_print_tree2file(stderr, err_rc);
+               goto out;
+       }
+
        if (show_rc)
                cYAML_print_tree(show_rc);
 
@@ -1290,7 +1327,8 @@ command_t list[] = {
        {"net", jt_net, 0, "net {add | del | show | help}"},
        {"routing", jt_routing, 0, "routing {show | help}"},
        {"set", jt_set, 0, "set {tiny_buffers | small_buffers | large_buffers"
-                          " | routing | numa_range | max_interfaces}"},
+                          " | routing | numa_range | max_interfaces"
+                          " | discovery}"},
        {"import", jt_import, 0, "import {--add | --del | --show | "
                                 "--help} FILE.yaml"},
        {"export", jt_export, 0, "export {--help} FILE.yaml"},