From bf5c2d232f708e8ac1f7b2a123d9ba92bff672f1 Mon Sep 17 00:00:00 2001 From: Chris Horn Date: Sun, 3 May 2020 10:02:57 -0500 Subject: [PATCH] LU-13510 lnet: Add lnet_lnd_timeout to lnetctl Add lnet_lnd_timeout to lnetctl. The param is read-only since it is calculated from transaction_timeout and retry_count. Test-Parameters: trivial Signed-off-by: Chris Horn Change-Id: I516d2d8082951014835c9e8c8a7ac2111f48e7ce Reviewed-on: https://review.whamcloud.com/38464 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Serguei Smirnov Reviewed-by: Amir Shehata Reviewed-by: Oleg Drokin --- lnet/utils/lnetconfig/liblnetconfig.c | 55 +++++++++++++++++++++++++++++++++++ lnet/utils/lnetconfig/liblnetconfig.h | 3 ++ lnet/utils/lnetctl.c | 6 ++++ 3 files changed, 64 insertions(+) diff --git a/lnet/utils/lnetconfig/liblnetconfig.c b/lnet/utils/lnetconfig/liblnetconfig.c index 10818b4..8e7cfd8 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.c +++ b/lnet/utils/lnetconfig/liblnetconfig.c @@ -52,6 +52,8 @@ #include #include #include "liblnetconfig.h" +#include +#include #define CONFIG_CMD "configure" #define UNCONFIG_CMD "unconfigure" @@ -3359,6 +3361,59 @@ int lustre_lnet_show_rtr_sensitivity(int seq_no, struct cYAML **show_rc, err_rc, l_errno); } +int lustre_lnet_show_lnd_timeout(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc) +{ + char val[LNET_MAX_STR_LEN]; + char err_str[LNET_MAX_STR_LEN]; + int lnd_to = -1; + int l_errno = 0; + int rc; + int fd; + glob_t path; + + snprintf(err_str, sizeof(err_str), "\"out of memory\""); + + rc = cfs_get_param_paths(&path, "lnet_lnd_timeout"); + if (rc < 0) { + l_errno = -errno; + snprintf(err_str, sizeof(err_str), + "\"cannot get LND timeout: %d\"", rc); + return build_global_yaml_entry(err_str, sizeof(err_str), seq_no, + "lnd_timeout", lnd_to, show_rc, + err_rc, l_errno); + } + + fd = open(path.gl_pathv[0], O_RDONLY); + if (fd < 0) { + l_errno = -errno; + snprintf(err_str, sizeof(err_str), + "\"error opening %s\"", path.gl_pathv[0]); + goto failed; + } + + rc = read(fd, val, sizeof(val)); + if (rc < 0) + l_errno = -errno; + + close(fd); + + if (rc < 0) { + snprintf(err_str, sizeof(err_str), + "\"error reading %s\"", path.gl_pathv[0]); + goto failed; + } + + lnd_to = atoi(val); + +failed: + cfs_free_param_data(&path); + + return build_global_yaml_entry(err_str, sizeof(err_str), seq_no, + "lnd_timeout", lnd_to, show_rc, + err_rc, l_errno); +} + int lustre_lnet_show_transaction_to(int seq_no, struct cYAML **show_rc, struct cYAML **err_rc) { diff --git a/lnet/utils/lnetconfig/liblnetconfig.h b/lnet/utils/lnetconfig/liblnetconfig.h index 176e1cd..2d34038 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.h +++ b/lnet/utils/lnetconfig/liblnetconfig.h @@ -393,6 +393,9 @@ int lustre_lnet_config_retry_count(int count, int seq_no, struct cYAML **err_rc) int lustre_lnet_show_retry_count(int seq_no, struct cYAML **show_rc, struct cYAML **err_rc); +int lustre_lnet_show_lnd_timeout(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); + int lustre_lnet_show_local_ni_recovq(int seq_no, struct cYAML **show_rc, struct cYAML **err_rc); diff --git a/lnet/utils/lnetctl.c b/lnet/utils/lnetctl.c index d600730..b75f684 100644 --- a/lnet/utils/lnetctl.c +++ b/lnet/utils/lnetctl.c @@ -1370,6 +1370,12 @@ static int jt_show_global(int argc, char **argv) goto out; } + rc = lustre_lnet_show_lnd_timeout(-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); -- 1.8.3.1