X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fportals.c;h=ca2eb34630f10cac43ab1c633f023aa80044571a;hb=21d671b3af09af65d38a454e677c5da9830e0c7a;hp=e5cf799278bb681b7fe66d28c0f7875d964760a8;hpb=73867ddf0c34d5e702ee4dcda850cf974bdb33da;p=fs%2Flustre-release.git diff --git a/lustre/utils/portals.c b/lustre/utils/portals.c index e5cf799..ca2eb34 100644 --- a/lustre/utils/portals.c +++ b/lustre/utils/portals.c @@ -3,7 +3,7 @@ * * Copyright (c) 2013, 2017, Intel Corporation. * - * This file is part of Lustre, https://wiki.hpdd.intel.com/ + * This file is part of Lustre, https://wiki.whamcloud.com/ * * Portals is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -35,13 +35,13 @@ #include #include -#include #include #include #include #include #include #include +#include unsigned int libcfs_debug; unsigned int libcfs_printk = D_CANTMASK; @@ -177,7 +177,7 @@ ptl_ipaddr_2_str(__u32 ipaddr, char *str, size_t strsize, int lookup) net_ip = htonl (ipaddr); he = gethostbyaddr (&net_ip, sizeof (net_ip), AF_INET); if (he != NULL) { - strlcpy(str, he->h_name, strsize); + snprintf(str, strsize, "%s", he->h_name); return (str); } } @@ -299,9 +299,6 @@ int jt_ptl_network(int argc, char **argv) __u32 net = LNET_NIDNET(LNET_NID_ANY); int rc; - fprintf(stderr, "lctl %s: has been deprecated. Please use " - "'lnetctl net'\n", argv[0]); - if (argc != 2) { fprintf(stderr, "usage: %s |up|down\n", argv[0]); return -1; @@ -360,9 +357,6 @@ jt_ptl_list_nids(int argc, char **argv) int count; int rc; - fprintf(stderr, "lctl %s: has been deprecated. Please use " - "'lnetctl net show'\n", argv[0]); - all = (argc == 2) && (strcmp(argv[1], "all") == 0); /* Hack to pass back value */ return_nid = (argc == 2) && (argv[1][0] == 1); @@ -924,9 +918,6 @@ int jt_ptl_ping(int argc, char **argv) char *sep; int i; - fprintf(stderr, "lctl %s: has been deprecated. Please use " - "'lnetctl ping'\n", argv[0]); - if (argc < 2) { fprintf(stderr, "usage: %s id [timeout (secs)]\n", argv[0]); return 0; @@ -1232,9 +1223,6 @@ jt_ptl_print_routes (int argc, char **argv) int alive; unsigned int pri; - fprintf(stderr, "lctl %s: has been deprecated. Please use " - "'lnetctl route show'\n", argv[0]); - for (index = 0; ; index++) { LIBCFS_IOC_INIT_V2(data, cfg_hdr); data.cfg_count = index; @@ -1327,6 +1315,57 @@ fault_attr_ptl_parse(char *ptl_str, __u64 *mask_p) } static int +fault_attr_health_error_parse(char *error, __u32 *mask) +{ + if (!strcasecmp(error, "local_interrupt")) { + *mask |= HSTATUS_LOCAL_INTERRUPT_BIT; + return 0; + } + if (!strcasecmp(error, "local_dropped")) { + *mask |= HSTATUS_LOCAL_DROPPED_BIT; + return 0; + } + if (!strcasecmp(error, "local_aborted")) { + *mask |= HSTATUS_LOCAL_ABORTED_BIT; + return 0; + } + if (!strcasecmp(error, "local_no_route")) { + *mask |= HSTATUS_LOCAL_NO_ROUTE_BIT; + return 0; + } + if (!strcasecmp(error, "local_error")) { + *mask |= HSTATUS_LOCAL_ERROR_BIT; + return 0; + } + if (!strcasecmp(error, "local_timeout")) { + *mask |= HSTATUS_LOCAL_TIMEOUT_BIT; + return 0; + } + if (!strcasecmp(error, "remote_error")) { + *mask |= HSTATUS_REMOTE_ERROR_BIT; + return 0; + } + if (!strcasecmp(error, "remote_dropped")) { + *mask |= HSTATUS_REMOTE_DROPPED_BIT; + return 0; + } + if (!strcasecmp(error, "remote_timeout")) { + *mask |= HSTATUS_REMOTE_TIMEOUT_BIT; + return 0; + } + if (!strcasecmp(error, "network_timeout")) { + *mask |= HSTATUS_NETWORK_TIMEOUT_BIT; + return 0; + } + if (!strcasecmp(error, "random")) { + *mask = HSTATUS_RANDOM; + return 0; + } + + return -1; +} + +static int fault_simul_rule_add(__u32 opc, char *name, int argc, char **argv) { struct libcfs_ioctl_data data = { { 0 } }; @@ -1339,9 +1378,13 @@ fault_simul_rule_add(__u32 opc, char *name, int argc, char **argv) { .name = "dest", .has_arg = required_argument, .val = 'd' }, { .name = "rate", .has_arg = required_argument, .val = 'r' }, { .name = "interval", .has_arg = required_argument, .val = 'i' }, + { .name = "random", .has_arg = no_argument, .val = 'n' }, { .name = "latency", .has_arg = required_argument, .val = 'l' }, { .name = "portal", .has_arg = required_argument, .val = 'p' }, { .name = "message", .has_arg = required_argument, .val = 'm' }, + { .name = "health_error", .has_arg = required_argument, .val = 'e' }, + { .name = "local_nid", .has_arg = required_argument, .val = 'o' }, + { .name = "drop_all", .has_arg = no_argument, .val = 'x' }, { .name = NULL } }; if (argc == 1) { @@ -1350,7 +1393,7 @@ fault_simul_rule_add(__u32 opc, char *name, int argc, char **argv) return -1; } - optstr = opc == LNET_CTL_DROP_ADD ? "s:d:r:i:p:m:" : "s:d:r:l:p:m:"; + optstr = opc == LNET_CTL_DROP_ADD ? "s:d:o:r:i:p:m:e:nx" : "s:d:o:r:l:p:m:"; memset(&attr, 0, sizeof(attr)); while (1) { char c = getopt_long(argc, argv, optstr, opts, NULL); @@ -1359,6 +1402,11 @@ fault_simul_rule_add(__u32 opc, char *name, int argc, char **argv) break; switch (c) { + case 'o': + rc = fault_attr_nid_parse(optarg, &attr.fa_local_nid); + if (rc != 0) + goto getopt_failed; + break; case 's': /* source NID/NET */ rc = fault_attr_nid_parse(optarg, &attr.fa_src); if (rc != 0) @@ -1378,6 +1426,25 @@ fault_simul_rule_add(__u32 opc, char *name, int argc, char **argv) attr.u.delay.la_rate = strtoul(optarg, NULL, 0); break; + case 'e': + if (opc == LNET_CTL_DROP_ADD) { + rc = fault_attr_health_error_parse(optarg, + &attr.u.drop.da_health_error_mask); + if (rc) + goto getopt_failed; + } + break; + + case 'x': + if (opc == LNET_CTL_DROP_ADD) + attr.u.drop.da_drop_all = true; + break; + + case 'n': + if (opc == LNET_CTL_DROP_ADD) + attr.u.drop.da_random = true; + break; + case 'i': /* time interval (# seconds) for message drop */ if (opc == LNET_CTL_DROP_ADD) attr.u.drop.da_interval = strtoul(optarg, @@ -1420,6 +1487,12 @@ fault_simul_rule_add(__u32 opc, char *name, int argc, char **argv) "but not both at the same time.\n"); return -1; } + + if (attr.u.drop.da_random && + attr.u.drop.da_interval == 0) { + fprintf(stderr, "please provide an interval to randomize\n"); + return -1; + } } else if (opc == LNET_CTL_DELAY_ADD) { if (!((attr.u.delay.la_rate == 0) ^ (attr.u.delay.la_interval == 0))) { @@ -1441,6 +1514,9 @@ fault_simul_rule_add(__u32 opc, char *name, int argc, char **argv) return -1; } + if (attr.fa_local_nid == 0) + attr.fa_local_nid = LNET_NID_ANY; + data.ioc_flags = opc; data.ioc_inllen1 = sizeof(attr); data.ioc_inlbuf1 = (char *)&attr;