X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fportals.c;h=abc7dbaf67f6cb7395e4259d0f824a5ce4e3d47b;hb=186b97e68abbc45c0e8d5ae7e2a0d10aaa918db6;hp=9466ea4b2488b71ef14c77a2873ea336f1d0939d;hpb=605a139a193e4ef212560673b4bb93eec763d088;p=fs%2Flustre-release.git diff --git a/lustre/utils/portals.c b/lustre/utils/portals.c index 9466ea4..abc7dba 100644 --- a/lustre/utils/portals.c +++ b/lustre/utils/portals.c @@ -352,44 +352,44 @@ int jt_ptl_network(int argc, char **argv) int jt_ptl_list_nids(int argc, char **argv) { - struct libcfs_ioctl_data data; - int all = 0, return_nid = 0; - int count; - int rc; + struct libcfs_ioctl_data data; + int all = 0, return_nid = 0; + int count; + int rc; - all = (argc == 2) && (strcmp(argv[1], "all") == 0); - /* Hack to pass back value */ - return_nid = (argc == 2) && (argv[1][0] == 1); + all = (argc == 2) && (strcmp(argv[1], "all") == 0); + /* Hack to pass back value */ + return_nid = (argc == 2) && (argv[1][0] == 1); - if ((argc > 2) && !(all || return_nid)) { - fprintf(stderr, "usage: %s [all]\n", argv[0]); - return 0; - } + if ((argc > 2) && !(all || return_nid)) { + fprintf(stderr, "usage: %s [all]\n", argv[0]); + return 0; + } - for (count = 0;; count++) { - LIBCFS_IOC_INIT (data); - data.ioc_count = count; - rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_NI, &data); - - if (rc < 0) { - if ((count > 0) && (errno == ENOENT)) - /* We found them all */ - break; - fprintf(stderr,"IOC_LIBCFS_GET_NI error %d: %s\n", - errno, strerror(errno)); - return -1; - } + for (count = 0;; count++) { + LIBCFS_IOC_INIT(data); + data.ioc_count = count; + rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_NI, &data); + + if (rc < 0) { + if ((count > 0) && (errno == ENOENT)) + /* We found them all */ + break; + fprintf(stderr, "IOC_LIBCFS_GET_NI error %d: %s\n", + errno, strerror(errno)); + return -1; + } - if (all || (LNET_NETTYP(LNET_NIDNET(data.ioc_nid)) != LOLND)) { - printf("%s\n", libcfs_nid2str(data.ioc_nid)); - if (return_nid) { - *(__u64 *)(argv[1]) = data.ioc_nid; - return_nid--; - } - } - } + if (all || (data.ioc_nid != LNET_NID_LO_0)) { + printf("%s\n", libcfs_nid2str(data.ioc_nid)); + if (return_nid) { + *(__u64 *)(argv[1]) = data.ioc_nid; + return_nid--; + } + } + } - return 0; + return 0; } int @@ -1383,6 +1383,8 @@ fault_simul_rule_add(__u32 opc, char *name, int argc, char **argv) { .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) { @@ -1391,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:e:n" : "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); @@ -1400,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) @@ -1428,6 +1435,11 @@ fault_simul_rule_add(__u32 opc, char *name, int argc, char **argv) } 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; @@ -1502,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;