Whamcloud - gitweb
LU-13502 lnet: Add response tracking param to lnetctl 14/38514/11
authorChris Horn <hornc@cray.com>
Tue, 5 May 2020 21:13:18 +0000 (16:13 -0500)
committerOleg Drokin <green@whamcloud.com>
Sat, 12 Sep 2020 15:43:28 +0000 (15:43 +0000)
Add support for the lnet_response_tracking parameter to lnetctl.

Test-Parameters: trivial testlist=sanity-lnet
HPE-bug-id: LUS-8827
Signed-off-by: Chris Horn <hornc@cray.com>
Change-Id: I952a415e27582a7a6d920bfeb16618766c0235da
Reviewed-on: https://review.whamcloud.com/38514
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/utils/lnetconfig/liblnetconfig.c
lnet/utils/lnetconfig/liblnetconfig.h
lnet/utils/lnetctl.c
lustre/doc/lnetctl.8
lustre/tests/sanity-lnet.sh

index f7c7929..7d81eb8 100644 (file)
@@ -2432,6 +2432,36 @@ int lustre_lnet_config_retry_count(int count, int seq_no, struct cYAML **err_rc)
        return rc;
 }
 
+int lustre_lnet_config_response_tracking(int val, int seq_no,
+                                        struct cYAML **err_rc)
+{
+       int rc = LUSTRE_CFG_RC_NO_ERR;
+       char err_str[LNET_MAX_STR_LEN];
+       char val_str[LNET_MAX_STR_LEN];
+
+       if (val < 0 || val > 3) {
+               rc = LUSTRE_CFG_RC_BAD_PARAM;
+               snprintf(err_str, sizeof(err_str),
+                        "\"Valid values are: 0, 1, 2, or 3\"");
+       } else {
+               snprintf(err_str, sizeof(err_str), "\"success\"");
+
+               snprintf(val_str, sizeof(val_str), "%d", val);
+
+               rc = write_sysfs_file(modparam_path, "lnet_response_tracking",
+                                     val_str, 1, strlen(val_str) + 1);
+               if (rc)
+                       snprintf(err_str, sizeof(err_str),
+                                "\"cannot configure response tracking: %s\"",
+                                strerror(errno));
+       }
+
+       cYAML_build_error(rc, seq_no, ADD_CMD, "response_tracking", err_str,
+                         err_rc);
+
+       return rc;
+}
+
 int lustre_lnet_config_max_intf(int max, int seq_no, struct cYAML **err_rc)
 {
        int rc = LUSTRE_CFG_RC_NO_ERR;
@@ -3531,6 +3561,31 @@ int lustre_lnet_show_peer_ni_recovq(int seq_no, struct cYAML **show_rc,
                                   seq_no, show_rc, err_rc);
 }
 
+int lustre_lnet_show_response_tracking(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 rsp_tracking = -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_response_tracking", val,
+                            1, sizeof(val));
+       if (rc) {
+               l_errno = -errno;
+               snprintf(err_str, sizeof(err_str),
+                        "\"cannot get lnet_response_tracking value: %d\"", rc);
+       } else {
+               rsp_tracking = atoi(val);
+       }
+
+       return build_global_yaml_entry(err_str, sizeof(err_str), seq_no,
+                                      "response_tracking", rsp_tracking,
+                                      show_rc, err_rc, l_errno);
+}
+
 int lustre_lnet_show_max_intf(int seq_no, struct cYAML **show_rc,
                              struct cYAML **err_rc)
 {
@@ -4526,7 +4581,7 @@ static int handle_yaml_config_global_settings(struct cYAML *tree,
                                              struct cYAML **err_rc)
 {
        struct cYAML *max_intf, *numa, *discovery, *retry, *tto, *seq_no,
-                    *sen, *recov, *rsen, *drop_asym_route;
+                    *sen, *recov, *rsen, *drop_asym_route, *rsp_tracking;
        int rc = 0;
 
        seq_no = cYAML_get_object_item(tree, "seq_no");
@@ -4593,6 +4648,13 @@ static int handle_yaml_config_global_settings(struct cYAML *tree,
                                                        : -1,
                                                     err_rc);
 
+       rsp_tracking = cYAML_get_object_item(tree, "response_tracking");
+       if (rsp_tracking)
+               rc = lustre_lnet_config_response_tracking(rsp_tracking->cy_valueint,
+                                                    seq_no ? seq_no->cy_valueint
+                                                       : -1,
+                                                    err_rc);
+
        return rc;
 }
 
@@ -4640,7 +4702,7 @@ static int handle_yaml_show_global_settings(struct cYAML *tree,
                                            struct cYAML **err_rc)
 {
        struct cYAML *max_intf, *numa, *discovery, *retry, *tto, *seq_no,
-                    *sen, *recov, *rsen, *drop_asym_route;
+                    *sen, *recov, *rsen, *drop_asym_route, *rsp_tracking;
        int rc = 0;
 
        seq_no = cYAML_get_object_item(tree, "seq_no");
@@ -4698,6 +4760,13 @@ static int handle_yaml_show_global_settings(struct cYAML *tree,
                                                        : -1,
                                                     show_rc, err_rc);
 
+       rsp_tracking = cYAML_get_object_item(tree, "response_tracking");
+       if (rsp_tracking)
+               rc = lustre_lnet_show_response_tracking(seq_no ?
+                                                       seq_no->cy_valueint :
+                                                       -1,
+                                                       show_rc, err_rc);
+
        return rc;
 }
 
index af4456b..b6ea68b 100644 (file)
@@ -399,6 +399,10 @@ int lustre_lnet_show_local_ni_recovq(int seq_no, struct cYAML **show_rc,
 
 int lustre_lnet_show_peer_ni_recovq(int seq_no, struct cYAML **show_rc,
                                    struct cYAML **err_rc);
+int lustre_lnet_config_response_tracking(int count, int seq_no,
+                                        struct cYAML **err_rc);
+int lustre_lnet_show_response_tracking(int seq_no, struct cYAML **show_rc,
+                                      struct cYAML **err_rc);
 
 /*
  * lustre_lnet_config_max_intf
index 40deca5..c2a5f82 100644 (file)
@@ -83,6 +83,7 @@ static int jt_peers(int argc, char **argv);
 static int jt_set_ni_value(int argc, char **argv);
 static int jt_set_peer_ni_value(int argc, char **argv);
 static int jt_calc_service_id(int argc, char **argv);
+static int jt_set_response_tracking(int argc, char **argv);
 
 command_t cmd_list[] = {
        {"lnet", jt_lnet, 0, "lnet {configure | unconfigure} [--all]"},
@@ -216,6 +217,14 @@ command_t set_cmds[] = {
        {"router_sensitivity", jt_set_rtr_sensitivity, 0, "router sensitivity %\n"
         "\t100 - router interfaces need to be fully healthy to be used\n"
         "\t<100 - router interfaces can be used even if not healthy\n"},
+       {"response_tracking", jt_set_response_tracking, 0,
+        "Set the behavior of response tracking\n"
+        "\t0 - Only LNet pings and discovery pushes utilize response tracking\n"
+        "\t1 - GETs are eligible for response tracking\n"
+        "\t2 - PUTs are eligible for response tracking\n"
+        "\t3 - Both PUTs and GETs are eligible for response tracking (default)\n"
+        "\tNote: Regardless of the value of the response_tracking parameter LNet\n"
+        "\t      pings and discovery pushes always utilize response tracking\n"},
        { 0, 0, 0, NULL }
 };
 
@@ -334,6 +343,35 @@ out:
        return rc;
 }
 
+static int jt_set_response_tracking(int argc, char **argv)
+{
+       long int value;
+       int rc;
+       struct cYAML *err_rc = NULL;
+
+       rc = check_cmd(set_cmds, "set", "response_tracking", 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 response_tracking value",
+                                 &err_rc);
+               cYAML_print_tree2file(stderr, err_rc);
+               cYAML_free_tree(err_rc);
+               return -1;
+       }
+
+       rc = lustre_lnet_config_response_tracking(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_max_intf(int argc, char **argv)
 {
        long int value;
@@ -1374,6 +1412,12 @@ static int jt_show_global(int argc, char **argv)
                goto out;
        }
 
+       rc = lustre_lnet_show_response_tracking(-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);
 
@@ -1667,6 +1711,13 @@ static int jt_export(int argc, char **argv)
                err_rc = NULL;
        }
 
+       rc = lustre_lnet_show_response_tracking(-1, &show_rc, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR) {
+               cYAML_print_tree2file(stderr, err_rc);
+               cYAML_free_tree(err_rc);
+               err_rc = NULL;
+       }
+
        if (show_rc != NULL) {
                cYAML_print_tree2file(f, show_rc);
                cYAML_free_tree(show_rc);
index 8ae8cf7..a27f25d 100644 (file)
@@ -251,6 +251,16 @@ count will be used\.
 drop them\. Asymmetrical route is when a message from a remote peer is coming
 through a router that would not be used by this node to reach the remote peer\.
 .
+.TP
+\fBlnetctl set\fR response_tracking \fI[0, 1, 2, 3]\fR
+Set the behavior of response tracking\.
+  0 - Only LNet pings and discovery pushes utilize response tracking\.
+  1 - GETs are eligible for response tracking\.
+  2 - PUTs are eligible for response tracking\.
+  3 - Both PUTs and GETs are eligible for response tracking (default)\.
+  Note: Regardless of the value of the response_tracking parameter LNet
+        pings and discovery pushes always utilize response tracking\.
+.
 .SS "Import and Export YAML Configuration Files"
 LNet configuration can be represented in YAML format\. A YAML configuration
 file can be passed to the lnetctl utility via the \fBimport\fR command\. The
index 483e669..ec536cc 100755 (executable)
@@ -1178,6 +1178,63 @@ test_103() {
 }
 run_test 103 "Delete route with multiple gw (tcp)"
 
+test_104() {
+       local tyaml="$TMP/sanity-lnet-$testnum-expected.yaml"
+
+       reinit_dlc || return $?
+
+       # Default value is '3'
+       local val=$($LNETCTL global show | awk '/response_tracking/{print $NF}')
+       [[ $val -ne 3 ]] &&
+               error "Expect 3 found $val"
+
+       echo "Set < 0;  Should fail"
+       do_lnetctl set response_tracking -1 &&
+                error "should have failed $?"
+
+       reinit_dlc || return $?
+       cat <<EOF > $tyaml
+global:
+    response_tracking: -10
+EOF
+       do_lnetctl import < $tyaml &&
+               error "should have failed $?"
+
+       echo "Check valid values; Should succeed"
+       local i
+       for ((i = 0; i < 4; i++)); do
+               reinit_dlc || return $?
+               do_lnetctl set response_tracking $i ||
+                        error "should have succeeded $?"
+               $LNETCTL global show | grep -q "response_tracking: $i" ||
+                       error "Failed to set response_tracking to $i"
+               reinit_dlc || return $?
+               cat <<EOF > $tyaml
+global:
+    response_tracking: $i
+EOF
+               do_lnetctl import < $tyaml ||
+                       error "should have succeeded $?"
+               $LNETCTL global show | grep -q "response_tracking: $i" ||
+                       error "Failed to set response_tracking to $i"
+       done
+
+       reinit_dlc || return $?
+       echo "Set > 3; Should fail"
+       do_lnetctl set response_tracking 4 &&
+                error "should have failed $?"
+
+       reinit_dlc || return $?
+       cat <<EOF > $tyaml
+global:
+    response_tracking: 10
+EOF
+       do_lnetctl import < $tyaml &&
+               error "should have failed $?"
+       return 0
+}
+run_test 104 "Set/check response_tracking param"
+
 ### load lnet in default namespace, configure in target namespace
 
 test_200() {