X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lnet%2Futils%2Flnetconfig%2Fliblnetconfig.c;fp=lnet%2Futils%2Flnetconfig%2Fliblnetconfig.c;h=8e7cfd81f7636de2c87564cd614cdd00df7e8b31;hp=10818b4162bf124c7656481e315f0c5cbb08b056;hb=bf5c2d232f708e8ac1f7b2a123d9ba92bff672f1;hpb=17802b329cdea7057cb1db75a5b803f1c4e44a2b 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) {