Whamcloud - gitweb
LU-11468 lnet: set recovery interval from lnetctl
[fs/lustre-release.git] / lnet / utils / lnetctl.c
index e6975af..504e189 100644 (file)
@@ -56,6 +56,7 @@ 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_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);
@@ -200,6 +201,8 @@ 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"},
        { 0, 0, 0, NULL }
 };
 
@@ -358,6 +361,34 @@ 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_hsensitivity(int argc, char **argv)
 {
        long int value;
@@ -685,6 +716,8 @@ static int jt_add_route(int argc, char **argv)
                                continue;
                        }
                        break;
+               case '?':
+                       print_help(route_cmds, "route", "add");
                default:
                        return 0;
                }
@@ -786,6 +819,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;
                }
@@ -841,6 +876,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;
                }
@@ -889,6 +926,8 @@ static int jt_del_ni(int argc, char **argv)
                                goto out;
                        }
                        break;
+               case '?':
+                       print_help(net_cmds, "net", "del");
                default:
                        return 0;
                }
@@ -953,6 +992,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;
                }
@@ -981,10 +1022,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 } };
 
@@ -998,12 +1039,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;
                }
@@ -1101,6 +1143,8 @@ static int jt_show_net(int argc, char **argv)
                                detail = 1;
                        }
                        break;
+               case '?':
+                       print_help(net_cmds, "net", "show");
                default:
                        return 0;
                }
@@ -1209,6 +1253,12 @@ 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;
+       }
+
        if (show_rc)
                cYAML_print_tree(show_rc);
 
@@ -1568,6 +1618,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;
                }
@@ -1655,6 +1707,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;
                }
@@ -1718,6 +1772,8 @@ static int jt_show_peer(int argc, char **argv)
                                detail = 1;
                        }
                        break;
+               case '?':
+                       print_help(peer_cmds, "peer", "show");
                default:
                        return 0;
                }