From: Amir Shehata Date: Fri, 26 Oct 2018 18:18:10 +0000 (-0700) Subject: LU-11468 lnet: set recovery interval from lnetctl X-Git-Tag: 2.12.0-RC1~86 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=b7f8d156db696fcc15fd37cfdfbee6549148fb69 LU-11468 lnet: set recovery interval from lnetctl Configure lnet_recovery_interval from lnetctl Test-Parameters: trivial Signed-off-by: Amir Shehata Change-Id: I75e3e40ea1eb87bcd6599caa4707f53cc33abea4 Reviewed-on: https://review.whamcloud.com/33498 Tested-by: Jenkins Reviewed-by: Doug Oucharek Reviewed-by: Sonia Sharma Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lnet/utils/lnetconfig/liblnetconfig.c b/lnet/utils/lnetconfig/liblnetconfig.c index a3d8a5c..a194ce0 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.c +++ b/lnet/utils/lnetconfig/liblnetconfig.c @@ -2529,6 +2529,28 @@ int ioctl_set_value(__u32 val, int ioc, char *name, return rc; } +int lustre_lnet_config_recov_intrv(int intrv, 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), "%d", intrv); + + rc = write_sysfs_file(modparam_path, "lnet_recovery_interval", val, + 1, strlen(val) + 1); + if (rc) + snprintf(err_str, sizeof(err_str), + "\"cannot configure recovery interval: %s\"", + strerror(errno)); + + cYAML_build_error(rc, seq_no, ADD_CMD, "recovery_interval", err_str, err_rc); + + return rc; +} + int lustre_lnet_config_hsensitivity(int sen, int seq_no, struct cYAML **err_rc) { int rc = LUSTRE_CFG_RC_NO_ERR; @@ -3382,6 +3404,31 @@ static int ioctl_show_global_values(int ioc, int seq_no, char *name, data.sv_value, show_rc, err_rc, l_errno); } +int lustre_lnet_show_recov_intrv(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]; + int intrv = -1, l_errno = 0; + char err_str[LNET_MAX_STR_LEN]; + + snprintf(err_str, sizeof(err_str), "\"out of memory\""); + + rc = read_sysfs_file(modparam_path, "lnet_recovery_interval", val, + 1, sizeof(val)); + if (rc) { + l_errno = -errno; + snprintf(err_str, sizeof(err_str), + "\"cannot get recovery interval: %d\"", rc); + } else { + intrv = atoi(val); + } + + return build_global_yaml_entry(err_str, sizeof(err_str), seq_no, + "recovery_interval", intrv, show_rc, + err_rc, l_errno); +} + int lustre_lnet_show_hsensitivity(int seq_no, struct cYAML **show_rc, struct cYAML **err_rc) { @@ -4512,7 +4559,7 @@ static int handle_yaml_config_global_settings(struct cYAML *tree, struct cYAML **err_rc) { struct cYAML *max_intf, *numa, *discovery, *retry, *tto, *seq_no, - *sen; + *sen, *recov; int rc = 0; seq_no = cYAML_get_object_item(tree, "seq_no"); @@ -4558,6 +4605,13 @@ static int handle_yaml_config_global_settings(struct cYAML *tree, : -1, err_rc); + recov = cYAML_get_object_item(tree, "recovery_interval"); + if (recov) + rc = lustre_lnet_config_recov_intrv(recov->cy_valueint, + seq_no ? seq_no->cy_valueint + : -1, + err_rc); + return rc; } @@ -4599,7 +4653,7 @@ static int handle_yaml_show_global_settings(struct cYAML *tree, struct cYAML **err_rc) { struct cYAML *max_intf, *numa, *discovery, *retry, *tto, *seq_no, - *sen; + *sen, *recov; int rc = 0; seq_no = cYAML_get_object_item(tree, "seq_no"); @@ -4639,6 +4693,12 @@ static int handle_yaml_show_global_settings(struct cYAML *tree, : -1, show_rc, err_rc); + recov = cYAML_get_object_item(tree, "recovery_interval"); + if (recov) + rc = lustre_lnet_show_recov_intrv(seq_no ? seq_no->cy_valueint + : -1, + show_rc, err_rc); + return rc; } diff --git a/lnet/utils/lnetconfig/liblnetconfig.h b/lnet/utils/lnetconfig/liblnetconfig.h index 4cd6d5e..504b797 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.h +++ b/lnet/utils/lnetconfig/liblnetconfig.h @@ -255,6 +255,30 @@ int lustre_lnet_config_peer_ni_healthv(int value, bool all, char *pni_nid, int seq_no, struct cYAML **err_rc); /* + * lustre_lnet_config_recov_intrv + * set the recovery interval in seconds. That's the interval to ping an + * unhealthy interface. + * + * intrv - recovery interval value to configure + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_config_recov_intrv(int intrv, int seq_no, struct cYAML **err_rc); + +/* + * lustre_lnet_show_recov_intrv + * show the recovery interval set in the system + * + * seq_no - sequence number of the request + * show_rc - [OUT] struct cYAML tree containing health sensitivity info + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_show_recov_intrv(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); + +/* * lustre_lnet_config_hsensitivity * sets the health sensitivity; the value by which to decrement the * health value of a local or peer NI. If 0 then health is turned off diff --git a/lnet/utils/lnetctl.c b/lnet/utils/lnetctl.c index 4932aaf..504e189 100644 --- a/lnet/utils/lnetctl.c +++ b/lnet/utils/lnetctl.c @@ -56,6 +56,7 @@ static int jt_set_large(int argc, char **argv); static int jt_set_numa(int argc, char **argv); static int jt_set_retry_count(int argc, char **argv); static int jt_set_transaction_to(int argc, char **argv); +static int jt_set_recov_intrv(int argc, char **argv); static int jt_set_hsensitivity(int argc, char **argv); static int jt_add_peer_nid(int argc, char **argv); static int jt_del_peer_nid(int argc, char **argv); @@ -200,6 +201,8 @@ command_t set_cmds[] = { {"health_sensitivity", jt_set_hsensitivity, 0, "sensitivity to failure\n" "\t0 - turn off health evaluation\n" "\t>0 - sensitivity value not more than 1000\n"}, + {"recovery_interval", jt_set_recov_intrv, 0, "interval to ping in seconds (at least 1)\n" + "\t>0 - time in seconds between pings\n"}, { 0, 0, 0, NULL } }; @@ -358,6 +361,34 @@ static int jt_set_numa(int argc, char **argv) return rc; } +static int jt_set_recov_intrv(int argc, char **argv) +{ + long int value; + int rc; + struct cYAML *err_rc = NULL; + + rc = check_cmd(set_cmds, "set", "recovery_interval", 2, argc, argv); + if (rc) + return rc; + + rc = parse_long(argv[1], &value); + if (rc != 0) { + cYAML_build_error(-1, -1, "parser", "set", + "cannot parse recovery interval value", &err_rc); + cYAML_print_tree2file(stderr, err_rc); + cYAML_free_tree(err_rc); + return -1; + } + + rc = lustre_lnet_config_recov_intrv(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_hsensitivity(int argc, char **argv) { long int value; @@ -1222,6 +1253,12 @@ static int jt_show_global(int argc, char **argv) goto out; } + rc = lustre_lnet_show_recov_intrv(-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);