Whamcloud - gitweb
LU-12457 kernel: new kernel [RHEL 7.7 3.10.0-1062.el7]
[fs/lustre-release.git] / lnet / utils / lnetctl.c
index e6e4255..6bdce42 100644 (file)
@@ -48,6 +48,7 @@ static int jt_show_net(int argc, char **argv);
 static int jt_show_routing(int argc, char **argv);
 static int jt_show_stats(int argc, char **argv);
 static int jt_show_peer(int argc, char **argv);
+static int jt_show_recovery(int argc, char **argv);
 static int jt_show_global(int argc, char **argv);
 static int jt_set_tiny(int argc, char **argv);
 static int jt_set_small(int argc, char **argv);
@@ -55,11 +56,14 @@ 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_set_recov_intrv(int argc, char **argv);
+static int jt_set_rtr_sensitivity(int argc, char **argv);
 static int jt_set_hsensitivity(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);
 static int jt_set_discovery(int argc, char **argv);
+static int jt_set_drop_asym_route(int argc, char **argv);
 static int jt_list_peer(int argc, char **argv);
 /*static int jt_show_peer(int argc, char **argv);*/
 static int lnetctl_list_commands(int argc, char **argv);
@@ -72,6 +76,7 @@ static int jt_route(int argc, char **argv);
 static int jt_net(int argc, char **argv);
 static int jt_routing(int argc, char **argv);
 static int jt_set(int argc, char **argv);
+static int jt_debug(int argc, char **argv);
 static int jt_stats(int argc, char **argv);
 static int jt_global(int argc, char **argv);
 static int jt_peers(int argc, char **argv);
@@ -89,6 +94,7 @@ command_t cmd_list[] = {
        {"import", jt_import, 0, "import FILE.yaml"},
        {"export", jt_export, 0, "export FILE.yaml"},
        {"stats", jt_stats, 0, "stats {show | help}"},
+       {"debug", jt_debug, 0, "debug recovery {local | peer}"},
        {"global", jt_global, 0, "global {show | help}"},
        {"peer", jt_peers, 0, "peer {add | del | show | help}"},
        {"ping", jt_ping, 0, "ping nid,[nid,...]"},
@@ -112,7 +118,8 @@ command_t route_cmds[] = {
         "\t--net: net name (e.g. tcp0)\n"
         "\t--gateway: gateway nid (e.g. 10.1.1.2@tcp)\n"
         "\t--hop: number to final destination (1 < hops < 255)\n"
-        "\t--priority: priority of route (0 - highest prio\n"},
+        "\t--priority: priority of route (0 - highest prio\n"
+        "\t--health_sensitivity: gateway health sensitivity (>= 1)\n"},
        {"del", jt_del_route, 0, "delete a route\n"
         "\t--net: net name (e.g. tcp0)\n"
         "\t--gateway: gateway nid (e.g. 10.1.1.2@tcp)\n"},
@@ -121,6 +128,7 @@ command_t route_cmds[] = {
         "\t--gateway: gateway nid (e.g. 10.1.1.2@tcp) to filter on\n"
         "\t--hop: number to final destination (1 < hops < 255) to filter on\n"
         "\t--priority: priority of route (0 - highest prio to filter on\n"
+        "\t--health_sensitivity: gateway health sensitivity (>= 1)\n"
         "\t--verbose: display detailed output per route\n"},
        { 0, 0, 0, NULL }
 };
@@ -159,6 +167,13 @@ command_t stats_cmds[] = {
        { 0, 0, 0, NULL }
 };
 
+command_t debug_cmds[] = {
+       {"recovery", jt_show_recovery, 0, "list recovery queues\n"
+               "\t--local : list local recovery queue\n"
+               "\t--peer : list peer recovery queue\n"},
+       { 0, 0, 0, NULL }
+};
+
 command_t global_cmds[] = {
        {"show", jt_show_global, 0, "show global variables\n"},
        { 0, 0, 0, NULL }
@@ -182,6 +197,10 @@ command_t set_cmds[] = {
        {"discovery", jt_set_discovery, 0, "enable/disable peer discovery\n"
         "\t0 - disable peer discovery\n"
         "\t1 - enable peer discovery (default)\n"},
+       {"drop_asym_route", jt_set_drop_asym_route, 0,
+        "drop/accept asymmetrical route messages\n"
+        "\t0 - accept asymmetrical route messages (default)\n"
+        "\t1 - drop asymmetrical route messages\n"},
        {"retry_count", jt_set_retry_count, 0, "number of retries\n"
         "\t0 - turn of retries\n"
         "\t>0 - number of retries\n"},
@@ -190,6 +209,11 @@ command_t set_cmds[] = {
        {"health_sensitivity", jt_set_hsensitivity, 0, "sensitivity to failure\n"
         "\t0 - turn off health evaluation\n"
         "\t>0 - sensitivity value not more than 1000\n"},
+       {"recovery_interval", jt_set_recov_intrv, 0, "interval to ping in seconds (at least 1)\n"
+        "\t>0 - time in seconds between pings\n"},
+       {"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"},
        { 0, 0, 0, NULL }
 };
 
@@ -348,6 +372,62 @@ static int jt_set_numa(int argc, char **argv)
        return rc;
 }
 
+static int jt_set_recov_intrv(int argc, char **argv)
+{
+       long int value;
+       int rc;
+       struct cYAML *err_rc = NULL;
+
+       rc = check_cmd(set_cmds, "set", "recovery_interval", 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 recovery interval value", &err_rc);
+               cYAML_print_tree2file(stderr, err_rc);
+               cYAML_free_tree(err_rc);
+               return -1;
+       }
+
+       rc = lustre_lnet_config_recov_intrv(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_rtr_sensitivity(int argc, char **argv)
+{
+       long int value;
+       int rc;
+       struct cYAML *err_rc = NULL;
+
+       rc = check_cmd(set_cmds, "set", "router_sensitivity", 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 router sensitivity value", &err_rc);
+               cYAML_print_tree2file(stderr, err_rc);
+               cYAML_free_tree(err_rc);
+               return -1;
+       }
+
+       rc = lustre_lnet_config_rtr_sensitivity(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_hsensitivity(int argc, char **argv)
 {
        long int value;
@@ -460,6 +540,35 @@ static int jt_set_discovery(int argc, char **argv)
        return rc;
 }
 
+static int jt_set_drop_asym_route(int argc, char **argv)
+{
+       long int value;
+       int rc;
+       struct cYAML *err_rc = NULL;
+
+       rc = check_cmd(set_cmds, "set", "drop_asym_route", 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 drop_asym_route value",
+                                 &err_rc);
+               cYAML_print_tree2file(stderr, err_rc);
+               cYAML_free_tree(err_rc);
+               return -1;
+       }
+
+       rc = lustre_lnet_config_drop_asym_route(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_tiny(int argc, char **argv)
 {
        long int value;
@@ -634,7 +743,7 @@ static int jt_unconfig_lnet(int argc, char **argv)
 static int jt_add_route(int argc, char **argv)
 {
        char *network = NULL, *gateway = NULL;
-       long int hop = -1, prio = -1;
+       long int hop = -1, prio = -1, sen = -1;
        struct cYAML *err_rc = NULL;
        int rc, opt;
 
@@ -644,6 +753,7 @@ static int jt_add_route(int argc, char **argv)
        { .name = "gateway",   .has_arg = required_argument, .val = 'g' },
        { .name = "hop-count", .has_arg = required_argument, .val = 'c' },
        { .name = "priority",  .has_arg = required_argument, .val = 'p' },
+       { .name = "health_sensitivity",  .has_arg = required_argument, .val = 's' },
        { .name = NULL } };
 
        rc = check_cmd(route_cmds, "route", "add", 0, argc, argv);
@@ -675,12 +785,24 @@ static int jt_add_route(int argc, char **argv)
                                continue;
                        }
                        break;
+               case 's':
+                       rc = parse_long(optarg, &sen);
+                       if (rc != 0) {
+                               /* ingore option */
+                               sen = -1;
+                               continue;
+                       }
+                       break;
+
+               case '?':
+                       print_help(route_cmds, "route", "add");
                default:
                        return 0;
                }
        }
 
-       rc = lustre_lnet_config_route(network, gateway, hop, prio, -1, &err_rc);
+       rc = lustre_lnet_config_route(network, gateway, hop, prio, sen, -1,
+                                     &err_rc);
 
        if (rc != LUSTRE_CFG_RC_NO_ERR)
                cYAML_print_tree2file(stderr, err_rc);
@@ -776,6 +898,8 @@ static int jt_add_ni(int argc, char **argv)
                                                     strlen(optarg), 0,
                                                     UINT_MAX, &global_cpts);
                        break;
+               case '?':
+                       print_help(net_cmds, "net", "add");
                default:
                        return 0;
                }
@@ -831,6 +955,8 @@ static int jt_del_route(int argc, char **argv)
                case 'g':
                        gateway = optarg;
                        break;
+               case '?':
+                       print_help(route_cmds, "route", "del");
                default:
                        return 0;
                }
@@ -879,6 +1005,8 @@ static int jt_del_ni(int argc, char **argv)
                                goto out;
                        }
                        break;
+               case '?':
+                       print_help(net_cmds, "net", "del");
                default:
                        return 0;
                }
@@ -943,6 +1071,8 @@ static int jt_show_route(int argc, char **argv)
                case 'v':
                        detail = 1;
                        break;
+               case '?':
+                       print_help(route_cmds, "route", "show");
                default:
                        return 0;
                }
@@ -971,10 +1101,10 @@ static int set_value_helper(int argc, char **argv,
        int rc, opt;
        struct cYAML *err_rc = NULL;
 
-       const char *const short_options = "h:n:a";
+       const char *const short_options = "t:n:a";
        static const struct option long_options[] = {
                { .name = "nid", .has_arg = required_argument, .val = 'n' },
-               { .name = "health", .has_arg = required_argument, .val = 'h' },
+               { .name = "health", .has_arg = required_argument, .val = 't' },
                { .name = "all", .has_arg = no_argument, .val = 'a' },
                { .name = NULL } };
 
@@ -988,12 +1118,13 @@ static int set_value_helper(int argc, char **argv,
                case 'n':
                        nid = optarg;
                        break;
-               case 'h':
-                       if (parse_long(argv[optind++], &healthv) != 0)
+               case 't':
+                       if (parse_long(optarg, &healthv) != 0)
                                healthv = -1;
                        break;
                case 'a':
                        all = true;
+                       break;
                default:
                        return 0;
                }
@@ -1019,6 +1150,46 @@ static int jt_set_peer_ni_value(int argc, char **argv)
        return set_value_helper(argc, argv, lustre_lnet_config_peer_ni_healthv);
 }
 
+static int jt_show_recovery(int argc, char **argv)
+{
+       int rc, opt;
+       struct cYAML *err_rc = NULL, *show_rc = NULL;
+
+       const char *const short_options = "lp";
+       static const struct option long_options[] = {
+               { .name = "local", .has_arg = no_argument, .val = 'l' },
+               { .name = "peer", .has_arg = no_argument, .val = 'p' },
+               { .name = NULL } };
+
+       rc = check_cmd(debug_cmds, "recovery", NULL, 0, argc, argv);
+       if (rc)
+               return rc;
+
+       while ((opt = getopt_long(argc, argv, short_options,
+                                  long_options, NULL)) != -1) {
+               switch (opt) {
+               case 'l':
+                       rc = lustre_lnet_show_local_ni_recovq(-1, &show_rc, &err_rc);
+                       break;
+               case 'p':
+                       rc = lustre_lnet_show_peer_ni_recovq(-1, &show_rc, &err_rc);
+                       break;
+               default:
+                       return 0;
+               }
+       }
+
+       if (rc != LUSTRE_CFG_RC_NO_ERR)
+               cYAML_print_tree2file(stderr, err_rc);
+       else if (show_rc)
+               cYAML_print_tree(show_rc);
+
+       cYAML_free_tree(err_rc);
+       cYAML_free_tree(show_rc);
+
+       return rc;
+}
+
 static int jt_show_net(int argc, char **argv)
 {
        char *network = NULL;
@@ -1051,6 +1222,8 @@ static int jt_show_net(int argc, char **argv)
                                detail = 1;
                        }
                        break;
+               case '?':
+                       print_help(net_cmds, "net", "show");
                default:
                        return 0;
                }
@@ -1141,6 +1314,12 @@ static int jt_show_global(int argc, char **argv)
                goto out;
        }
 
+       rc = lustre_lnet_show_drop_asym_route(-1, &show_rc, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR) {
+               cYAML_print_tree2file(stderr, err_rc);
+               goto out;
+       }
+
        rc = lustre_lnet_show_retry_count(-1, &show_rc, &err_rc);
        if (rc != LUSTRE_CFG_RC_NO_ERR) {
                cYAML_print_tree2file(stderr, err_rc);
@@ -1159,6 +1338,18 @@ static int jt_show_global(int argc, char **argv)
                goto out;
        }
 
+       rc = lustre_lnet_show_recov_intrv(-1, &show_rc, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR) {
+               cYAML_print_tree2file(stderr, err_rc);
+               goto out;
+       }
+
+       rc = lustre_lnet_show_rtr_sensitivity(-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);
 
@@ -1224,6 +1415,17 @@ static int jt_stats(int argc, char **argv)
        return Parser_execarg(argc - 1, &argv[1], stats_cmds);
 }
 
+static int jt_debug(int argc, char **argv)
+{
+       int rc;
+
+       rc = check_cmd(debug_cmds, "recovery", NULL, 2, argc, argv);
+       if (rc)
+               return rc;
+
+       return Parser_execarg(argc - 1, &argv[1], debug_cmds);
+}
+
 static int jt_global(int argc, char **argv)
 {
        int rc;
@@ -1434,6 +1636,13 @@ static int jt_export(int argc, char **argv)
                err_rc = NULL;
        }
 
+       rc = lustre_lnet_show_drop_asym_route(-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);
@@ -1507,6 +1716,8 @@ static int jt_add_peer_nid(int argc, char **argv)
                case 'm':
                        non_mr = true;
                        break;
+               case '?':
+                       print_help(peer_cmds, "peer", "add");
                default:
                        return 0;
                }
@@ -1594,6 +1805,8 @@ static int jt_del_peer_nid(int argc, char **argv)
                        nids = nids2;
                        rc = LUSTRE_CFG_RC_OUT_OF_MEM;
                        break;
+               case '?':
+                       print_help(peer_cmds, "peer", "del");
                default:
                        return 0;
                }
@@ -1657,6 +1870,8 @@ static int jt_show_peer(int argc, char **argv)
                                detail = 1;
                        }
                        break;
+               case '?':
+                       print_help(peer_cmds, "peer", "show");
                default:
                        return 0;
                }