Whamcloud - gitweb
LU-13510 lnet: Add lnet_lnd_timeout to lnetctl 64/38464/5
authorChris Horn <hornc@cray.com>
Sun, 3 May 2020 15:02:57 +0000 (10:02 -0500)
committerOleg Drokin <green@whamcloud.com>
Wed, 27 May 2020 05:05:18 +0000 (05:05 +0000)
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 <hornc@cray.com>
Change-Id: I516d2d8082951014835c9e8c8a7ac2111f48e7ce
Reviewed-on: https://review.whamcloud.com/38464
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/utils/lnetconfig/liblnetconfig.c
lnet/utils/lnetconfig/liblnetconfig.h
lnet/utils/lnetctl.c

index 10818b4..8e7cfd8 100644 (file)
@@ -52,6 +52,8 @@
 #include <ifaddrs.h>
 #include <rdma/rdma_user_cm.h>
 #include "liblnetconfig.h"
+#include <glob.h>
+#include <libcfs/util/param.h>
 
 #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)
 {
index 176e1cd..2d34038 100644 (file)
@@ -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);
 
index d600730..b75f684 100644 (file)
@@ -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);