X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Futils%2Flnetctl.c;h=c935e8fc0c468df3fa3326a7588df3da152a648b;hb=3f2844dc9333c86452c37bd7b4519729b1351371;hp=9a899b92cec7f6684962cf0c63d882637eab505d;hpb=cf47570b0273e11f81be0fc67126172fe73ad367;p=fs%2Flustre-release.git diff --git a/lnet/utils/lnetctl.c b/lnet/utils/lnetctl.c index 9a899b9..c935e8f 100644 --- a/lnet/utils/lnetctl.c +++ b/lnet/utils/lnetctl.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include "lnetconfig/cyaml.h" #include "lnetconfig/liblnetconfig.h" #define LNET_CONFIGURE true @@ -48,18 +48,27 @@ 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_show_udsp(int argc, char **argv); static int jt_set_tiny(int argc, char **argv); 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_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_reset_stats(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_add_udsp(int argc, char **argv); +static int jt_del_udsp(int argc, char **argv); /*static int jt_show_peer(int argc, char **argv);*/ static int lnetctl_list_commands(int argc, char **argv); static int jt_import(int argc, char **argv); @@ -71,26 +80,38 @@ 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); - +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); +static int jt_set_recovery_limit(int argc, char **argv); +static int jt_udsp(int argc, char **argv); command_t cmd_list[] = { {"lnet", jt_lnet, 0, "lnet {configure | unconfigure} [--all]"}, {"route", jt_route, 0, "route {add | del | show | help}"}, - {"net", jt_net, 0, "net {add | del | show | help}"}, + {"net", jt_net, 0, "net {add | del | show | set | help}"}, {"routing", jt_routing, 0, "routing {show | help}"}, {"set", jt_set, 0, "set {tiny_buffers | small_buffers | large_buffers" " | routing | numa_range | max_interfaces" - " | discovery}"}, + " | discovery | drop_asym_route | retry_count" + " | transaction_timeout | health_sensitivity" + " | recovery_interval | router_sensitivity" + " | response_tracking | recovery_limit}"}, {"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}"}, + {"peer", jt_peers, 0, "peer {add | del | show | list | set | help}"}, {"ping", jt_ping, 0, "ping nid,[nid,...]"}, {"discover", jt_discover, 0, "discover nid[,nid,...]"}, + {"service-id", jt_calc_service_id, 0, "Calculate IB Lustre service ID\n"}, + {"udsp", jt_udsp, 0, "udsp {add | del | help}"}, {"help", Parser_help, 0, "help"}, {"exit", Parser_quit, 0, "quit"}, {"quit", Parser_quit, 0, "quit"}, @@ -110,7 +131,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"}, @@ -119,6 +141,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 } }; @@ -132,7 +155,8 @@ command_t net_cmds[] = { "\t--peer-credits: define the max number of inflight messages\n" "\t--peer-buffer-credits: the number of buffer credits per peer\n" "\t--credits: Network Interface credits\n" - "\t--cpt: CPU Partitions configured net uses (e.g. [0,1]\n"}, + "\t--cpt: CPU Partitions configured net uses (e.g. [0,1]\n" + "\t--conns-per-peer: number of connections per peer\n"}, {"del", jt_del_ni, 0, "delete a network\n" "\t--net: net name (e.g. tcp0)\n" "\t--if: physical interface (e.g. eth0)\n"}, @@ -140,6 +164,11 @@ command_t net_cmds[] = { "\t--net: net name (e.g. tcp0) to filter on\n" "\t--verbose: display detailed output per network." " Optional argument of '2' outputs more stats\n"}, + {"set", jt_set_ni_value, 0, "set local NI specific parameter\n" + "\t--nid: NI NID to set the\n" + "\t--health: specify health value to set\n" + "\t--conns-per-peer: number of connections per peer\n" + "\t--all: set all NIs value to the one specified\n"}, { 0, 0, 0, NULL } }; @@ -150,6 +179,14 @@ command_t routing_cmds[] = { command_t stats_cmds[] = { {"show", jt_show_stats, 0, "show LNET statistics\n"}, + {"reset", jt_reset_stats, 0, "reset LNET statistics\n"}, + { 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 } }; @@ -176,19 +213,41 @@ 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"}, {"transaction_timeout", jt_set_transaction_to, 0, "Message/Response timeout\n" "\t>0 - timeout in seconds\n"}, + {"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"}, + {"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"}, + {"recovery_limit", jt_set_recovery_limit, 0, + "Set how long LNet will attempt to recover unhealthy interfaces.\n" + "\t0 - Recover indefinitely (default)\n" + "\t>0 - Recover for the specified number of seconds.\n"}, { 0, 0, 0, NULL } }; command_t peer_cmds[] = { {"add", jt_add_peer_nid, 0, "add a peer NID\n" - "\t--prim_nid: Primary NID of the peer. If not provided then the first\n" - "\t NID in the list becomes the Primary NID of a newly created\n" - "\t peer. \n" + "\t--prim_nid: Primary NID of the peer.\n" "\t--nid: one or more peer NIDs\n" "\t--non_mr: create this peer as not Multi-Rail capable\n" "\t--ip2nets: specify a range of nids per peer"}, @@ -202,9 +261,46 @@ command_t peer_cmds[] = { "\t--verbose: display detailed output per peer." " Optional argument of '2' outputs more stats\n"}, {"list", jt_list_peer, 0, "list all peers\n"}, + {"set", jt_set_peer_ni_value, 0, "set peer ni specific parameter\n" + "\t--nid: Peer NI NID to set the\n" + "\t--health: specify health value to set\n" + "\t--all: set all peer_nis values to the one specified\n"}, + { 0, 0, 0, NULL } +}; + +command_t udsp_cmds[] = { + {"add", jt_add_udsp, 0, "add a udsp\n" + "\t--src: ip2nets syntax specifying the local NID to match\n" + "\t--dst: ip2nets syntax specifying the remote NID to match\n" + "\t--rte: ip2nets syntax specifying the router NID to match\n" + "\t--priority: priority value (0 - highest priority)\n" + "\t--idx: index of where to insert the rule.\n" + "\t By default, appends to the end of the rule list.\n"}, + {"del", jt_del_udsp, 0, "delete a udsp\n" + "\t--idx: index of the Policy.\n"}, + {"show", jt_show_udsp, 0, "show udsps\n" + "\t --idx: index of the policy to show.\n"}, { 0, 0, 0, NULL } }; +static int jt_calc_service_id(int argc, char **argv) +{ + int rc; + __u64 service_id; + + rc = lustre_lnet_calc_service_id(&service_id); + if (rc != LUSTRE_CFG_RC_NO_ERR) + return rc; + + /* + * cYAML currently doesn't support printing hex values. + * Therefore just print it locally here + */ + printf("service id:\n value: 0x%jx\n", (uintmax_t)service_id); + + return rc; +} + static inline void print_help(const command_t cmds[], const char *cmd_type, const char *pc_name) { @@ -279,6 +375,64 @@ 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_recovery_limit(int argc, char **argv) +{ + long int value; + int rc; + struct cYAML *err_rc = NULL; + + rc = check_cmd(set_cmds, "set", "recovery_limit", 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_limit value", + &err_rc); + cYAML_print_tree2file(stderr, err_rc); + cYAML_free_tree(err_rc); + return -1; + } + + rc = lustre_lnet_config_recovery_limit(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; @@ -335,6 +489,108 @@ 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; + int rc; + struct cYAML *err_rc = NULL; + + rc = check_cmd(set_cmds, "set", "health_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 health sensitivity value", &err_rc); + cYAML_print_tree2file(stderr, err_rc); + cYAML_free_tree(err_rc); + return -1; + } + + rc = lustre_lnet_config_hsensitivity(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_reset_stats(int argc, char **argv) +{ + int rc; + struct cYAML *err_rc = NULL; + + rc = check_cmd(stats_cmds, "stats", "reset", 0, argc, argv); + if (rc) + return rc; + + rc = lustre_lnet_reset_stats(-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_transaction_to(int argc, char **argv) { long int value; @@ -419,6 +675,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; @@ -593,7 +878,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; @@ -603,6 +888,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); @@ -634,12 +920,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); @@ -652,7 +950,7 @@ static int jt_add_route(int argc, char **argv) static int jt_add_ni(int argc, char **argv) { char *ip2net = NULL; - long int pto = -1, pc = -1, pbc = -1, cre = -1; + long int pto = -1, pc = -1, pbc = -1, cre = -1, cpp = -1; struct cYAML *err_rc = NULL; int rc, opt, cpt_rc = -1; struct lnet_dlc_network_descr nw_descr; @@ -663,17 +961,19 @@ static int jt_add_ni(int argc, char **argv) memset(&tunables, 0, sizeof(tunables)); lustre_lnet_init_nw_descr(&nw_descr); - const char *const short_options = "n:i:p:t:c:b:r:s:"; + const char *const short_options = "b:c:i:m:n:p:r:s:t:"; static const struct option long_options[] = { - { .name = "net", .has_arg = required_argument, .val = 'n' }, - { .name = "if", .has_arg = required_argument, .val = 'i' }, - { .name = "ip2net", .has_arg = required_argument, .val = 'p' }, - { .name = "peer-timeout", .has_arg = required_argument, .val = 't' }, - { .name = "peer-credits", .has_arg = required_argument, .val = 'c' }, { .name = "peer-buffer-credits", .has_arg = required_argument, .val = 'b' }, + { .name = "peer-credits", .has_arg = required_argument, .val = 'c' }, + { .name = "if", .has_arg = required_argument, .val = 'i' }, + { .name = "conns-per-peer", + .has_arg = required_argument, .val = 'm' }, + { .name = "net", .has_arg = required_argument, .val = 'n' }, + { .name = "ip2net", .has_arg = required_argument, .val = 'p' }, { .name = "credits", .has_arg = required_argument, .val = 'r' }, { .name = "cpt", .has_arg = required_argument, .val = 's' }, + { .name = "peer-timeout", .has_arg = required_argument, .val = 't' }, { .name = NULL } }; rc = check_cmd(net_cmds, "net", "add", 0, argc, argv); @@ -683,26 +983,11 @@ static int jt_add_ni(int argc, char **argv) while ((opt = getopt_long(argc, argv, short_options, long_options, NULL)) != -1) { switch (opt) { - case 'n': - nw_descr.nw_id = libcfs_str2net(optarg); - break; - case 'i': - rc = lustre_lnet_parse_interfaces(optarg, &nw_descr); - if (rc != 0) { - cYAML_build_error(-1, -1, "ni", "add", - "bad interface list", - &err_rc); - goto failed; - } - break; - case 'p': - ip2net = optarg; - break; - case 't': - rc = parse_long(optarg, &pto); + case 'b': + rc = parse_long(optarg, &pbc); if (rc != 0) { /* ignore option */ - pto = -1; + pbc = -1; continue; } break; @@ -714,14 +999,30 @@ static int jt_add_ni(int argc, char **argv) continue; } break; - case 'b': - rc = parse_long(optarg, &pbc); + case 'i': + rc = lustre_lnet_parse_interfaces(optarg, &nw_descr); + if (rc != 0) { + cYAML_build_error(-1, -1, "ni", "add", + "bad interface list", + &err_rc); + goto failed; + } + break; + case 'm': + rc = parse_long(optarg, &cpp); if (rc != 0) { /* ignore option */ - pbc = -1; + cpp = -1; continue; } break; + + case 'n': + nw_descr.nw_id = libcfs_str2net(optarg); + break; + case 'p': + ip2net = optarg; + break; case 'r': rc = parse_long(optarg, &cre); if (rc != 0) { @@ -735,12 +1036,22 @@ static int jt_add_ni(int argc, char **argv) strlen(optarg), 0, UINT_MAX, &global_cpts); break; + case 't': + rc = parse_long(optarg, &pto); + if (rc != 0) { + /* ignore option */ + pto = -1; + continue; + } + break; + case '?': + print_help(net_cmds, "net", "add"); default: return 0; } } - if (pto > 0 || pc > 0 || pbc > 0 || cre > 0) { + if (pto > 0 || pc > 0 || pbc > 0 || cre > 0 || cpp > -1) { tunables.lt_cmn.lct_peer_timeout = pto; tunables.lt_cmn.lct_peer_tx_credits = pc; tunables.lt_cmn.lct_peer_rtr_credits = pbc; @@ -751,7 +1062,7 @@ static int jt_add_ni(int argc, char **argv) rc = lustre_lnet_config_ni(&nw_descr, (cpt_rc == 0) ? global_cpts: NULL, ip2net, (found) ? &tunables : NULL, - -1, &err_rc); + cpp, -1, &err_rc); if (global_cpts != NULL) cfs_expr_list_free(global_cpts); @@ -790,6 +1101,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; } @@ -838,6 +1151,8 @@ static int jt_del_ni(int argc, char **argv) goto out; } break; + case '?': + print_help(net_cmds, "net", "del"); default: return 0; } @@ -902,6 +1217,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; } @@ -921,17 +1238,174 @@ static int jt_show_route(int argc, char **argv) return rc; } -static int jt_show_net(int argc, char **argv) +static int set_value_helper(int argc, char **argv, + int (*cb)(int, bool, char*, int, struct cYAML**)) { - char *network = NULL; + char *nid = NULL; + long int healthv = -1; + bool all = false; int rc, opt; - struct cYAML *err_rc = NULL, *show_rc = NULL; - long int detail = 0; + struct cYAML *err_rc = NULL; - const char *const short_options = "n:v"; + const char *const short_options = "t:n:a"; static const struct option long_options[] = { - { .name = "net", .has_arg = required_argument, .val = 'n' }, - { .name = "verbose", .has_arg = optional_argument, .val = 'v' }, + { .name = "nid", .has_arg = required_argument, .val = 'n' }, + { .name = "health", .has_arg = required_argument, .val = 't' }, + { .name = "all", .has_arg = no_argument, .val = 'a' }, + { .name = NULL } }; + + rc = check_cmd(net_cmds, "net", "set", 0, argc, argv); + if (rc) + return rc; + + while ((opt = getopt_long(argc, argv, short_options, + long_options, NULL)) != -1) { + switch (opt) { + case 'n': + nid = optarg; + break; + case 't': + if (parse_long(optarg, &healthv) != 0) + healthv = -1; + break; + case 'a': + all = true; + break; + default: + return 0; + } + } + + rc = cb(healthv, all, nid, -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_ni_value(int argc, char **argv) +{ + char *nid = NULL; + long int healthv = -1, cpp = -1; + bool all = false; + int rc, opt; + struct cYAML *err_rc = NULL; + + const char *const short_options = "a:m:n:t:"; + static const struct option long_options[] = { + { .name = "all", .has_arg = no_argument, .val = 'a' }, + { .name = "conns-per-peer", .has_arg = required_argument, .val = 'm' }, + { .name = "nid", .has_arg = required_argument, .val = 'n' }, + { .name = "health", .has_arg = required_argument, .val = 't' }, + { .name = NULL } }; + + rc = check_cmd(net_cmds, "net", "set", 0, argc, argv); + if (rc) + return rc; + + while ((opt = getopt_long(argc, argv, short_options, + long_options, NULL)) != -1) { + switch (opt) { + case 'a': + all = true; + break; + case 'm': + rc = parse_long(optarg, &cpp); + if (rc != 0) { + /* ignore option */ + cpp = -1; + continue; + } + break; + case 'n': + nid = optarg; + break; + case 't': + if (parse_long(optarg, &healthv) != 0) { + /* ignore option */ + healthv = -1; + continue; + } + break; + default: + return 0; + } + } + + if (cpp > -1) + rc = lustre_lnet_config_ni_conns_per_peer(cpp, all, nid, + -1, &err_rc); + if (healthv > -1) + rc = lustre_lnet_config_ni_healthv(healthv, all, nid, + -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_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; + int rc, opt; + struct cYAML *err_rc = NULL, *show_rc = NULL; + long int detail = 0; + + const char *const short_options = "n:v"; + static const struct option long_options[] = { + { .name = "net", .has_arg = required_argument, .val = 'n' }, + { .name = "verbose", .has_arg = optional_argument, .val = 'v' }, { .name = NULL } }; rc = check_cmd(net_cmds, "net", "show", 0, argc, argv); @@ -953,6 +1427,8 @@ static int jt_show_net(int argc, char **argv) detail = 1; } break; + case '?': + print_help(net_cmds, "net", "show"); default: return 0; } @@ -1016,6 +1492,48 @@ static int jt_show_stats(int argc, char **argv) return rc; } +static int jt_show_udsp(int argc, char **argv) +{ + int idx = -1; + int rc, opt; + struct cYAML *err_rc = NULL, *show_rc = NULL; + + const char *const short_options = "i:"; + static const struct option long_options[] = { + { .name = "idx", .has_arg = required_argument, .val = 'i' }, + { .name = NULL } + }; + + rc = check_cmd(udsp_cmds, "udsp", "show", 0, argc, argv); + if (rc) + return rc; + + while ((opt = getopt_long(argc, argv, short_options, + long_options, NULL)) != -1) { + switch (opt) { + case 'i': + idx = atoi(optarg); + break; + case '?': + print_help(net_cmds, "net", "show"); + default: + return 0; + } + } + + rc = lustre_lnet_show_udsp(idx, -1, &show_rc, &err_rc); + + 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_global(int argc, char **argv) { int rc; @@ -1043,6 +1561,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); @@ -1055,6 +1579,42 @@ static int jt_show_global(int argc, char **argv) goto out; } + rc = lustre_lnet_show_hsensitivity(-1, &show_rc, &err_rc); + if (rc != LUSTRE_CFG_RC_NO_ERR) { + cYAML_print_tree2file(stderr, err_rc); + 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; + } + + rc = lustre_lnet_show_lnd_timeout(-1, &show_rc, &err_rc); + if (rc != LUSTRE_CFG_RC_NO_ERR) { + cYAML_print_tree2file(stderr, err_rc); + 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; + } + + rc = lustre_lnet_show_recovery_limit(-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); @@ -1120,6 +1680,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; @@ -1153,6 +1724,17 @@ static int jt_set(int argc, char **argv) return Parser_execarg(argc - 1, &argv[1], set_cmds); } +static int jt_udsp(int argc, char **argv) +{ + int rc; + + rc = check_cmd(udsp_cmds, "udsp", NULL, 2, argc, argv); + if (rc) + return rc; + + return Parser_execarg(argc - 1, &argv[1], udsp_cmds); +} + static int jt_import(int argc, char **argv) { char *file = NULL; @@ -1330,6 +1912,70 @@ 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; + } + + rc = lustre_lnet_show_retry_count(-1, &show_rc, &err_rc); + if (rc != LUSTRE_CFG_RC_NO_ERR) { + cYAML_print_tree2file(stderr, err_rc); + err_rc = NULL; + } + + rc = lustre_lnet_show_transaction_to(-1, &show_rc, &err_rc); + if (rc != LUSTRE_CFG_RC_NO_ERR) { + cYAML_print_tree2file(stderr, err_rc); + err_rc = NULL; + } + + rc = lustre_lnet_show_hsensitivity(-1, &show_rc, &err_rc); + if (rc != LUSTRE_CFG_RC_NO_ERR) { + cYAML_print_tree2file(stderr, err_rc); + err_rc = NULL; + } + + rc = lustre_lnet_show_recov_intrv(-1, &show_rc, &err_rc); + if (rc != LUSTRE_CFG_RC_NO_ERR) { + cYAML_print_tree2file(stderr, err_rc); + err_rc = NULL; + } + + rc = lustre_lnet_show_rtr_sensitivity(-1, &show_rc, &err_rc); + if (rc != LUSTRE_CFG_RC_NO_ERR) { + cYAML_print_tree2file(stderr, err_rc); + err_rc = NULL; + } + + rc = lustre_lnet_show_lnd_timeout(-1, &show_rc, &err_rc); + if (rc != LUSTRE_CFG_RC_NO_ERR) { + cYAML_print_tree2file(stderr, err_rc); + 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; + } + + rc = lustre_lnet_show_recovery_limit(-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; + } + + rc = lustre_lnet_show_udsp(-1, -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); @@ -1341,22 +1987,19 @@ static int jt_export(int argc, char **argv) return 0; } -static int jt_add_peer_nid(int argc, char **argv) +static int jt_peer_nid_common(int argc, char **argv, int cmd) { - char *prim_nid = NULL; - char **nids = NULL, **nids2 = NULL; - int size = 0; + int rc = LUSTRE_CFG_RC_NO_ERR, opt; + bool is_mr = true; + char *prim_nid = NULL, *nidstr = NULL; + char err_str[LNET_MAX_STR_LEN] = "Error"; struct cYAML *err_rc = NULL; - int rc = LUSTRE_CFG_RC_NO_ERR, opt, i; - bool non_mr = false; - bool ip2nets = false, nid_list = false, prim_nid_present = false; const char *const short_opts = "k:mn:"; const struct option long_opts[] = { { .name = "prim_nid", .has_arg = required_argument, .val = 'k' }, { .name = "non_mr", .has_arg = no_argument, .val = 'm' }, { .name = "nid", .has_arg = required_argument, .val = 'n' }, - { .name = "ip2nets", .has_arg = required_argument, .val = 'i' }, { .name = NULL } }; rc = check_cmd(peer_cmds, "peer", "add", 2, argc, argv); @@ -1367,66 +2010,39 @@ static int jt_add_peer_nid(int argc, char **argv) long_opts, NULL)) != -1) { switch (opt) { case 'k': - prim_nid_present = true; - if (ip2nets) { - cYAML_build_error(-1, -1, "peer", "add", - "ip2nets can not be specified" - " along side prim_nid parameter.", - &err_rc); - goto failed; - } prim_nid = optarg; break; - case 'i': case 'n': - if (opt == 'i') - ip2nets = true; - - if (opt == 'n') - nid_list = true; - - if (ip2nets && (nid_list || prim_nid_present)) { - cYAML_build_error(-1, -1, "peer", "add", - "ip2nets can not be specified" - " along side nid or prim_nid" - " parameters", &err_rc); - goto failed; - } - - size = lustre_lnet_parse_nids(optarg, nids, size, - &nids2); - if (nids2 == NULL) - goto failed; - nids = nids2; - rc = LUSTRE_CFG_RC_OUT_OF_MEM; + nidstr = optarg; break; case 'm': - non_mr = true; + if (cmd == LNETCTL_DEL_CMD) { + rc = LUSTRE_CFG_RC_BAD_PARAM; + snprintf(err_str, LNET_MAX_STR_LEN, + "Unrecognized option '-%c'", opt); + goto build_error; + } + is_mr = false; break; + case '?': + print_help(peer_cmds, "peer", + cmd == LNETCTL_ADD_CMD ? "add" : "del"); default: return 0; } } - for (; optind < argc; optind++) { - size = lustre_lnet_parse_nids(argv[optind], nids, size, - &nids2); - if (nids2 == NULL) - goto failed; - nids = nids2; - } - - rc = lustre_lnet_config_peer_nid(prim_nid, nids, size, - !non_mr, ip2nets, -1, &err_rc); + rc = lustre_lnet_modify_peer(prim_nid, nidstr, is_mr, cmd, + -1, &err_rc); + if (rc != LUSTRE_CFG_RC_NO_ERR) + goto out; -failed: - if (nids) { - /* free the array of nids */ - for (i = 0; i < size; i++) - free(nids[i]); - free(nids); - } +build_error: + cYAML_build_error(rc, -1, "peer", + cmd == LNETCTL_ADD_CMD ? "add" : "del", + err_str, &err_rc); +out: if (rc != LUSTRE_CFG_RC_NO_ERR) cYAML_print_tree2file(stderr, err_rc); @@ -1435,89 +2051,14 @@ failed: return rc; } -static int jt_del_peer_nid(int argc, char **argv) +static int jt_add_peer_nid(int argc, char **argv) { - char *prim_nid = NULL; - char **nids = NULL, **nids2 = NULL; - struct cYAML *err_rc = NULL; - int rc = LUSTRE_CFG_RC_NO_ERR, opt, i, size = 0; - bool ip2nets = false, nid_list = false, prim_nid_present = false; - - const char *const short_opts = "k:n:"; - const struct option long_opts[] = { - { .name = "prim_nid", .has_arg = required_argument, .val = 'k' }, - { .name = "nid", .has_arg = required_argument, .val = 'n' }, - { .name = "ip2nets", .has_arg = required_argument, .val = 'i' }, - { .name = NULL } }; - - rc = check_cmd(peer_cmds, "peer", "del", 2, argc, argv); - if (rc) - return rc; - - while ((opt = getopt_long(argc, argv, short_opts, - long_opts, NULL)) != -1) { - switch (opt) { - case 'k': - prim_nid_present = true; - if (ip2nets) { - cYAML_build_error(-1, -1, "peer", "add", - "ip2nets can not be specified" - " along side prim_nid parameter.", - &err_rc); - goto failed; - } - prim_nid = optarg; - break; - case 'i': - case 'n': - if (opt == 'i') - ip2nets = true; - - if (opt == 'n') - nid_list = true; - - if (ip2nets && (nid_list || prim_nid_present)) { - cYAML_build_error(-1, -1, "peer", "add", - "ip2nets can not be specified" - " along side nid or prim_nid" - " parameters", &err_rc); - goto failed; - } - size = lustre_lnet_parse_nids(optarg, nids, size, - &nids2); - if (nids2 == NULL) - goto failed; - nids = nids2; - rc = LUSTRE_CFG_RC_OUT_OF_MEM; - break; - default: - return 0; - } - } - - for (; optind < argc; optind++) { - size = lustre_lnet_parse_nids(argv[optind], nids, size, - &nids2); - if (nids2 == NULL) - goto failed; - nids = nids2; - } - - rc = lustre_lnet_del_peer_nid(prim_nid, nids, size, ip2nets, -1, &err_rc); - -failed: - if (nids) { - for (i = 0; i < size; i++) - free(nids[i]); - free(nids); - } - - if (rc != LUSTRE_CFG_RC_NO_ERR) - cYAML_print_tree2file(stderr, err_rc); - - cYAML_free_tree(err_rc); + return jt_peer_nid_common(argc, argv, LNETCTL_ADD_CMD); +} - return rc; +static int jt_del_peer_nid(int argc, char **argv) +{ + return jt_peer_nid_common(argc, argv, LNETCTL_DEL_CMD); } static int jt_show_peer(int argc, char **argv) @@ -1553,6 +2094,8 @@ static int jt_show_peer(int argc, char **argv) detail = 1; } break; + case '?': + print_help(peer_cmds, "peer", "show"); default: return 0; } @@ -1683,6 +2226,109 @@ static int jt_discover(int argc, char **argv) return rc; } +static int jt_add_udsp(int argc, char **argv) +{ + char *src = NULL, *dst = NULL, *rte = NULL; + struct cYAML *err_rc = NULL; + union lnet_udsp_action udsp_action; + long int idx = -1, priority = -1; + int opt, rc = 0; + char *action_type = "pref"; + + const char *const short_options = "s:d:r:p:i:"; + static const struct option long_options[] = { + { .name = "src", .has_arg = required_argument, .val = 's' }, + { .name = "dst", .has_arg = required_argument, .val = 'd' }, + { .name = "rte", .has_arg = required_argument, .val = 'r' }, + { .name = "priority", .has_arg = required_argument, .val = 'p' }, + { .name = "idx", .has_arg = required_argument, .val = 'i' }, + { .name = NULL } }; + + rc = check_cmd(udsp_cmds, "udsp", "add", 0, argc, argv); + if (rc) + return rc; + + while ((opt = getopt_long(argc, argv, short_options, + long_options, NULL)) != -1) { + switch (opt) { + case 's': + src = optarg; + break; + case 'd': + dst = optarg; + break; + case 'r': + rte = optarg; + break; + case 'p': + rc = parse_long(optarg, &priority); + if (rc != 0) + priority = -1; + action_type = "priority"; + udsp_action.udsp_priority = priority; + break; + case 'i': + rc = parse_long(optarg, &idx); + if (rc != 0) + idx = 0; + break; + case '?': + print_help(udsp_cmds, "udsp", "add"); + default: + return 0; + } + } + + rc = lustre_lnet_add_udsp(src, dst, rte, action_type, &udsp_action, + idx, -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_del_udsp(int argc, char **argv) +{ + struct cYAML *err_rc = NULL; + long int idx = 0; + int opt, rc = 0; + + const char *const short_options = "i:"; + static const struct option long_options[] = { + { .name = "idx", .has_arg = required_argument, .val = 'i' }, + { .name = NULL } }; + + rc = check_cmd(udsp_cmds, "udsp", "del", 0, argc, argv); + if (rc) + return rc; + + while ((opt = getopt_long(argc, argv, short_options, + long_options, NULL)) != -1) { + switch (opt) { + case 'i': + rc = parse_long(optarg, &idx); + if (rc != 0) + idx = 0; + break; + case '?': + print_help(udsp_cmds, "udsp", "add"); + default: + return 0; + } + } + + rc = lustre_lnet_del_udsp(idx, -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 lnetctl_list_commands(int argc, char **argv) { char buffer[81] = ""; /* 80 printable chars + terminating NUL */