X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Futils%2Fportals.c;h=33e1f1a81229f38c66f5007587670f199364c33c;hb=d2b8a0efaa4b5faea675bd4bd4bfe1f80dad4011;hp=e50037f002b53213c3d7afa842c24e8577143c49;hpb=6268df8208e0b89a2c189998183659643ee04b36;p=fs%2Flustre-release.git diff --git a/lnet/utils/portals.c b/lnet/utils/portals.c index e50037f..33e1f1a 100644 --- a/lnet/utils/portals.c +++ b/lnet/utils/portals.c @@ -1,7 +1,7 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * * This file is part of Portals, http://www.sf.net/projects/lustre/ * @@ -195,6 +195,19 @@ lnet_parse_time (time_t *t, char *str) return (0); } +int +lnet_parse_nid(char *nid_str, lnet_process_id_t *id_ptr) +{ + id_ptr->pid = LNET_PID_ANY; + id_ptr->nid = libcfs_str2nid(nid_str); + if (id_ptr->nid == LNET_NID_ANY) { + fprintf (stderr, "Can't parse nid \"%s\"\n", nid_str); + return -1; + } + + return 0; +} + int g_net_is_set (char *cmd) { if (g_net_set) @@ -293,6 +306,14 @@ int jt_ptl_network(int argc, char **argv) return -1; } + if (LNET_NETTYP(net) == CIBLND || + LNET_NETTYP(net) == OPENIBLND || + LNET_NETTYP(net) == IIBLND || + LNET_NETTYP(net) == VIBLND) { + fprintf(stderr, "Net %s obsoleted\n", libcfs_lnd2str(net)); + return -1; + } + g_net_set = 1; g_net = net; return 0; @@ -544,7 +565,7 @@ jt_ptl_print_peers (int argc, char **argv) int rc; if (!g_net_is_compatible (argv[0], SOCKLND, RALND, PTLLND, MXLND, - OPENIBLND, CIBLND, IIBLND, VIBLND, O2IBLND, 0)) + O2IBLND, 0)) return -1; for (index = 0;;index++) { @@ -585,7 +606,7 @@ jt_ptl_print_peers (int argc, char **argv) data.ioc_u32[5] & 0xffff, /* nactiveq */ data.ioc_u32[6] >> 16, /* credits */ data.ioc_u32[6] & 0xffff); /* outstanding_credits */ - } else if (g_net_is_compatible(NULL, RALND, OPENIBLND, CIBLND, VIBLND, 0)) { + } else if (g_net_is_compatible(NULL, RALND, 0)) { printf ("%-20s [%d]@%s:%d\n", libcfs_nid2str(data.ioc_nid), /* peer nid */ data.ioc_count, /* peer persistence */ @@ -618,24 +639,12 @@ jt_ptl_add_peer (int argc, char **argv) int port = 0; int rc; - if (!g_net_is_compatible (argv[0], SOCKLND, RALND, - OPENIBLND, CIBLND, IIBLND, VIBLND, 0)) + if (!g_net_is_compatible (argv[0], SOCKLND, RALND, 0)) return -1; - if (g_net_is_compatible(NULL, SOCKLND, OPENIBLND, CIBLND, RALND, 0)) { - if (argc != 4) { - fprintf (stderr, "usage(tcp,openib,cib,ra): %s nid ipaddr port\n", - argv[0]); - return 0; - } - } else if (g_net_is_compatible(NULL, VIBLND, 0)) { - if (argc != 3) { - fprintf (stderr, "usage(vib): %s nid ipaddr\n", - argv[0]); - return 0; - } - } else if (argc != 2) { - fprintf (stderr, "usage(iib): %s nid\n", argv[0]); + if (argc != 4) { + fprintf (stderr, "usage(tcp,ra): %s nid ipaddr port\n", + argv[0]); return 0; } @@ -645,14 +654,12 @@ jt_ptl_add_peer (int argc, char **argv) return -1; } - if (g_net_is_compatible (NULL, SOCKLND, OPENIBLND, CIBLND, VIBLND, RALND, 0) && - lnet_parse_ipaddr (&ip, argv[2]) != 0) { + if (lnet_parse_ipaddr (&ip, argv[2]) != 0) { fprintf (stderr, "Can't parse ip addr: %s\n", argv[2]); return -1; } - if (g_net_is_compatible (NULL, SOCKLND, OPENIBLND, CIBLND, RALND, 0) && - lnet_parse_port (&port, argv[3]) != 0) { + if (lnet_parse_port (&port, argv[3]) != 0) { fprintf (stderr, "Can't parse port: %s\n", argv[3]); return -1; } @@ -684,7 +691,7 @@ jt_ptl_del_peer (int argc, char **argv) int rc; if (!g_net_is_compatible (argv[0], SOCKLND, RALND, MXLND, PTLLND, - OPENIBLND, CIBLND, IIBLND, VIBLND, O2IBLND, 0)) + O2IBLND, 0)) return -1; if (g_net_is_compatible(NULL, SOCKLND, 0)) { @@ -753,8 +760,7 @@ jt_ptl_print_connections (int argc, char **argv) int index; int rc; - if (!g_net_is_compatible (argv[0], SOCKLND, RALND, MXLND, - OPENIBLND, CIBLND, IIBLND, VIBLND, O2IBLND, 0)) + if (!g_net_is_compatible (argv[0], SOCKLND, RALND, MXLND, O2IBLND, 0)) return -1; for (index = 0; ; index++) { @@ -819,8 +825,7 @@ int jt_ptl_disconnect(int argc, char **argv) return 0; } - if (!g_net_is_compatible (NULL, SOCKLND, RALND, MXLND, - OPENIBLND, CIBLND, IIBLND, VIBLND, O2IBLND, 0)) + if (!g_net_is_compatible (NULL, SOCKLND, RALND, MXLND, O2IBLND, 0)) return 0; if (argc >= 2 && @@ -946,12 +951,9 @@ int jt_ptl_ping(int argc, char **argv) sep = strchr(argv[1], '-'); if (sep == NULL) { - id.pid = LNET_PID_ANY; - id.nid = libcfs_str2nid(argv[1]); - if (id.nid == LNET_NID_ANY) { - fprintf (stderr, "Can't parse nid \"%s\"\n", argv[1]); + rc = lnet_parse_nid(argv[1], &id); + if (rc != 0) return -1; - } } else { char *end; @@ -961,12 +963,19 @@ int jt_ptl_ping(int argc, char **argv) else id.pid = strtoul(argv[1], &end, 0); - id.nid = libcfs_str2nid(sep + 1); + if (end != sep) { /* assuming '-' is part of hostname */ + rc = lnet_parse_nid(argv[1], &id); + if (rc != 0) + return -1; + } else { + id.nid = libcfs_str2nid(sep + 1); - if (end != sep || - id.nid == LNET_NID_ANY) { - fprintf(stderr, "Can't parse process id \"%s\"\n", argv[1]); - return -1; + if (id.nid == LNET_NID_ANY) { + fprintf(stderr, + "Can't parse process id \"%s\"\n", + argv[1]); + return -1; + } } } @@ -1265,7 +1274,7 @@ lwt_control(int enable, int clear) } static int -lwt_snapshot(cycles_t *now, int *ncpu, int *totalsize, +lwt_snapshot(cfs_cycles_t *now, int *ncpu, int *totalsize, lwt_event_t *events, int size) { struct libcfs_ioctl_data data; @@ -1362,7 +1371,8 @@ lwt_put_string(char *ustr) } static int -lwt_print(FILE *f, cycles_t t0, cycles_t tlast, double mhz, int cpu, lwt_event_t *e) +lwt_print(FILE *f, cfs_cycles_t t0, cfs_cycles_t tlast, double mhz, int cpu, + lwt_event_t *e) { #ifndef __WORDSIZE # error "__WORDSIZE not defined" @@ -1427,9 +1437,9 @@ jt_ptl_lwt(int argc, char **argv) int rc; int i; double mhz; - cycles_t t0; - cycles_t tlast; - cycles_t tnow; + cfs_cycles_t t0; + cfs_cycles_t tlast; + cfs_cycles_t tnow; struct timeval tvnow; int printed_date = 0; int nlines = 0; @@ -1569,7 +1579,7 @@ jt_ptl_lwt(int argc, char **argv) if (t0 <= next_event[cpu]->lwte_when) { /* on or after the first event */ if (!printed_date) { - cycles_t du = (tnow - t0) / mhz; + cfs_cycles_t du = (tnow - t0) / mhz; time_t then = tvnow.tv_sec - du/1000000; if (du % 1000000 > tvnow.tv_usec)