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;
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)
{
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");
: -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;
}
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");
: -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;
}
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");
: -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;
}
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
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);
{"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 }
};
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;
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);
{"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"},