X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lnet%2Futils%2Flnetctl.c;h=c2a5f82e70257bc135c5101a3232dc728e311784;hp=00b3bc9f621e1ead4d5befd67dcfba069dfb6e74;hb=b67a8e76a50ec744af80db8bc5c4b73cb1a9ccf9;hpb=aef3d58d585ee818b405b5ff197b7a98b6c5157d diff --git a/lnet/utils/lnetctl.c b/lnet/utils/lnetctl.c index 00b3bc9..c2a5f82 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 @@ -82,6 +82,8 @@ 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); command_t cmd_list[] = { {"lnet", jt_lnet, 0, "lnet {configure | unconfigure} [--all]"}, @@ -99,6 +101,7 @@ command_t cmd_list[] = { {"peer", jt_peers, 0, "peer {add | del | show | 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"}, {"help", Parser_help, 0, "help"}, {"exit", Parser_quit, 0, "quit"}, {"quit", Parser_quit, 0, "quit"}, @@ -118,7 +121,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"}, @@ -127,6 +131,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 } }; @@ -212,14 +217,20 @@ 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 } }; 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"}, @@ -240,6 +251,24 @@ command_t peer_cmds[] = { { 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%llx\n", service_id); + + return rc; +} + static inline void print_help(const command_t cmds[], const char *cmd_type, const char *pc_name) { @@ -314,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; @@ -741,7 +799,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; @@ -751,6 +809,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); @@ -782,6 +841,15 @@ 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: @@ -789,7 +857,8 @@ static int jt_add_route(int argc, char **argv) } } - 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); @@ -1337,6 +1406,18 @@ static int jt_show_global(int argc, char **argv) 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; + } + if (show_rc) cYAML_print_tree(show_rc); @@ -1630,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); @@ -1641,22 +1729,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); @@ -1667,68 +1752,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", "add"); + 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); @@ -1737,91 +1793,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; - case '?': - print_help(peer_cmds, "peer", "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_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)