Whamcloud - gitweb
LU-9120 lnet: set transaction timeout from lnetctl 78/32778/16
authorAmir Shehata <amir.shehata@intel.com>
Wed, 4 Jul 2018 00:24:31 +0000 (17:24 -0700)
committerAmir Shehata <ashehata@whamcloud.com>
Fri, 17 Aug 2018 20:18:48 +0000 (20:18 +0000)
Added an lnetctl command to set the transaction timeout
from userspace.

lnetctl set transaction_timeout {>0}

>0 - timeout in seconds.

Test-Parameters: forbuildonly
Signed-off-by: Amir Shehata <ashehata@whamcloud.com>
Change-Id: I71274e82fd46bff8017e36c37de449d8a7639ec6
Reviewed-on: https://review.whamcloud.com/32778
Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
Reviewed-by: Sonia Sharma <sharmaso@whamcloud.com>
Tested-by: Jenkins
lnet/utils/lnetconfig/liblnetconfig.c
lnet/utils/lnetconfig/liblnetconfig.h
lnet/utils/lnetctl.c

index 4ae90e8..925210e 100644 (file)
@@ -2429,6 +2429,28 @@ int ioctl_set_value(__u32 val, int ioc, char *name,
        return rc;
 }
 
+int lustre_lnet_config_transaction_to(int timeout, 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", timeout);
+
+       rc = write_sysfs_file(modparam_path, "lnet_transaction_timeout", val,
+                             1, strlen(val) + 1);
+       if (rc)
+               snprintf(err_str, sizeof(err_str),
+                        "\"cannot configure transaction timeout: %s\"",
+                        strerror(errno));
+
+       cYAML_build_error(rc, seq_no, ADD_CMD, "transaction_timeout", err_str, err_rc);
+
+       return rc;
+}
+
 int lustre_lnet_config_retry_count(int count, int seq_no, struct cYAML **err_rc)
 {
        int rc = LUSTRE_CFG_RC_NO_ERR;
@@ -3209,6 +3231,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_transaction_to(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 tto = -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_transaction_timeout", val,
+                            1, sizeof(val));
+       if (rc) {
+               l_errno = -errno;
+               snprintf(err_str, sizeof(err_str),
+                        "\"cannot get transaction timeout: %d\"", rc);
+       } else {
+               tto = atoi(val);
+       }
+
+       return build_global_yaml_entry(err_str, sizeof(err_str), seq_no,
+                                      "transaction_timeout", tto, show_rc,
+                                      err_rc, l_errno);
+}
+
 int lustre_lnet_show_retry_count(int seq_no, struct cYAML **show_rc,
                                 struct cYAML **err_rc)
 {
@@ -4130,7 +4177,7 @@ static int handle_yaml_config_global_settings(struct cYAML *tree,
                                              struct cYAML **show_rc,
                                              struct cYAML **err_rc)
 {
-       struct cYAML *max_intf, *numa, *discovery, *retry, *seq_no;
+       struct cYAML *max_intf, *numa, *discovery, *retry, *tto, *seq_no;
        int rc = 0;
 
        seq_no = cYAML_get_object_item(tree, "seq_no");
@@ -4162,6 +4209,13 @@ static int handle_yaml_config_global_settings(struct cYAML *tree,
                                                        : -1,
                                                    err_rc);
 
+       tto = cYAML_get_object_item(tree, "transaction_timeout");
+       if (tto)
+               rc = lustre_lnet_config_transaction_to(tto->cy_valueint,
+                                                      seq_no ? seq_no->cy_valueint
+                                                               : -1,
+                                                      err_rc);
+
        return rc;
 }
 
@@ -4202,7 +4256,7 @@ static int handle_yaml_show_global_settings(struct cYAML *tree,
                                            struct cYAML **show_rc,
                                            struct cYAML **err_rc)
 {
-       struct cYAML *max_intf, *numa, *discovery, *retry, *seq_no;
+       struct cYAML *max_intf, *numa, *discovery, *retry, *tto, *seq_no;
        int rc = 0;
 
        seq_no = cYAML_get_object_item(tree, "seq_no");
@@ -4230,6 +4284,11 @@ static int handle_yaml_show_global_settings(struct cYAML *tree,
                                                        : -1,
                                                  show_rc, err_rc);
 
+       tto = cYAML_get_object_item(tree, "transaction_timeout");
+       if (tto)
+               rc = lustre_lnet_show_transaction_to(seq_no ? seq_no->cy_valueint
+                                                       : -1,
+                                                    show_rc, err_rc);
 
        return rc;
 }
index 55348a0..49c71c6 100644 (file)
@@ -225,6 +225,30 @@ int lustre_lnet_show_numa_range(int seq_no, struct cYAML **show_rc,
                                struct cYAML **err_rc);
 
 /*
+ * lustre_lnet_config_transaction_to
+ *   sets the timeout after which a message expires or a timeout event is
+ *   propagated for an expired response.
+ *
+ *   timeout - timeout 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_transaction_to(int timeout, int seq_no, struct cYAML **err_rc);
+
+/*
+ * lustre_lnet_show_transaction_to
+ *    show the transaction timeout in the system
+ *
+ *   seq_no - sequence number of the request
+ *   show_rc - [OUT] struct cYAML tree containing transaction timeout info
+ *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
+ *   caller
+ */
+int lustre_lnet_show_transaction_to(int seq_no, struct cYAML **show_rc,
+                                   struct cYAML **err_rc);
+
+/*
  * lustre_lnet_config_retry_count
  *   sets the maximum number of retries to resend a message
  *
index 27ba97d..9a899b9 100644 (file)
@@ -54,6 +54,7 @@ static int jt_set_small(int argc, char **argv);
 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_add_peer_nid(int argc, char **argv);
 static int jt_del_peer_nid(int argc, char **argv);
 static int jt_set_max_intf(int argc, char **argv);
@@ -178,6 +179,8 @@ command_t set_cmds[] = {
        {"retry_count", jt_set_retry_count, 0, "number of retries\n"
         "\t0 - turn of retries\n"
         "\t>0 - number of retries\n"},
+       {"transaction_timeout", jt_set_transaction_to, 0, "Message/Response timeout\n"
+        "\t>0 - timeout in seconds\n"},
        { 0, 0, 0, NULL }
 };
 
@@ -332,6 +335,34 @@ static int jt_set_numa(int argc, char **argv)
        return rc;
 }
 
+static int jt_set_transaction_to(int argc, char **argv)
+{
+       long int value;
+       int rc;
+       struct cYAML *err_rc = NULL;
+
+       rc = check_cmd(set_cmds, "set", "transaction_timeout", 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 transaction timeout value", &err_rc);
+               cYAML_print_tree2file(stderr, err_rc);
+               cYAML_free_tree(err_rc);
+               return -1;
+       }
+
+       rc = lustre_lnet_config_transaction_to(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_retry_count(int argc, char **argv)
 {
        long int value;
@@ -1018,6 +1049,12 @@ static int jt_show_global(int argc, char **argv)
                goto out;
        }
 
+       rc = lustre_lnet_show_transaction_to(-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);