From b04c35874dca17a191ddbac9b52b005066a10dda Mon Sep 17 00:00:00 2001 From: Amir Shehata Date: Fri, 24 Aug 2018 12:08:31 -0700 Subject: [PATCH] LU-11283 lnet: fix setting health value manually Changed the health value option letter to 't' instead of 'h' to avoid conflict with help option. Don't increment optind unnecessarily. In the handling code in api-ni.c there was a missing return. Test-Parameters: trivial Signed-off-by: Amir Shehata Change-Id: Ib56f19d1781e44297158c64c5b26004220a1db21 Reviewed-on: https://review.whamcloud.com/33074 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Sonia Sharma Reviewed-by: Doug Oucharek Reviewed-by: Oleg Drokin --- lnet/lnet/api-ni.c | 1 + lnet/utils/lnetconfig/liblnetconfig.c | 3 ++- lnet/utils/lnetctl.c | 9 +++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index 8ce8136..acf349c 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -3674,6 +3674,7 @@ LNetCtl(unsigned int cmd, void *arg) lnet_peer_ni_set_healthv(cfg->rh_nid, value, cfg->rh_all); mutex_unlock(&the_lnet.ln_api_mutex); + return 0; } case IOC_LIBCFS_NOTIFY_ROUTER: { diff --git a/lnet/utils/lnetconfig/liblnetconfig.c b/lnet/utils/lnetconfig/liblnetconfig.c index c9ca32e..7c5128e 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.c +++ b/lnet/utils/lnetconfig/liblnetconfig.c @@ -2049,7 +2049,8 @@ lustre_lnet_config_healthv(int value, bool all, lnet_nid_t nid, if (rc != 0) { rc = -errno; snprintf(err_str, - sizeof(err_str), "Can not configure health value"); + sizeof(err_str), "Can not configure health value: %s", + strerror(errno)); } cYAML_build_error(rc, seq_no, ADD_CMD, name, err_str, err_rc); diff --git a/lnet/utils/lnetctl.c b/lnet/utils/lnetctl.c index 16801ef..4932aaf 100644 --- a/lnet/utils/lnetctl.c +++ b/lnet/utils/lnetctl.c @@ -991,10 +991,10 @@ static int set_value_helper(int argc, char **argv, int rc, opt; struct cYAML *err_rc = NULL; - const char *const short_options = "h:n:a"; + const char *const short_options = "t:n:a"; static const struct option long_options[] = { { .name = "nid", .has_arg = required_argument, .val = 'n' }, - { .name = "health", .has_arg = required_argument, .val = 'h' }, + { .name = "health", .has_arg = required_argument, .val = 't' }, { .name = "all", .has_arg = no_argument, .val = 'a' }, { .name = NULL } }; @@ -1008,12 +1008,13 @@ static int set_value_helper(int argc, char **argv, case 'n': nid = optarg; break; - case 'h': - if (parse_long(argv[optind++], &healthv) != 0) + case 't': + if (parse_long(optarg, &healthv) != 0) healthv = -1; break; case 'a': all = true; + break; default: return 0; } -- 1.8.3.1