4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, 2016, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lnet/selftest/conctl.c
34 * Author: Liang Zhen <liangzhen@clusterfs.com>
45 #include <sys/ioctl.h>
48 #include <libcfs/util/list.h>
49 #include <libcfs/util/ioctl.h>
50 #include <libcfs/util/parser.h>
51 #include <lnet/lnetctl.h>
52 #include <lnet/lnetst.h>
53 #include <lnet/lnet.h>
54 #include <utils/obdctl.h>
56 struct lst_sid LST_INVALID_SID = {LNET_NID_ANY, -1};
57 static struct lst_sid session_id;
58 static int session_key;
60 /* All nodes running 2.6.50 or later understand feature LST_FEAT_BULK_LEN */
61 static unsigned session_features = LST_FEATS_MASK;
62 static struct lstcon_trans_stat trans_stat;
64 typedef struct list_string {
65 struct list_string *lstr_next;
71 # define offsetof(typ,memb) ((unsigned long)((char *)&(((typ *)0)->memb)))
74 static int alloc_count = 0;
75 static int alloc_nob = 0;
80 lstr_t *lstr = malloc(offsetof(lstr_t, lstr_str[sz]));
83 fprintf(stderr, "Can't allocate lstr\n");
90 lstr->lstr_str[0] = 0;
96 free_lstr(lstr_t *lstr)
99 alloc_nob -= lstr->lstr_sz;
104 free_lstrs(lstr_t **list)
108 while ((lstr = *list) != NULL) {
109 *list = lstr->lstr_next;
115 new_lstrs(lstr_t **list, char *prefix, char *postfix,
116 int lo, int hi, int stride)
118 int n1 = strlen(prefix);
119 int n2 = strlen(postfix);
120 int sz = n1 + 20 + n2 + 1;
123 lstr_t *n = alloc_lstr(sz);
125 snprintf(n->lstr_str, sz - 1, "%s%u%s",
126 prefix, lo, postfix);
128 n->lstr_next = *list;
136 expand_lstr(lstr_t **list, lstr_t *l)
138 int nob = strlen(l->lstr_str);
148 b1 = strchr(l->lstr_str, '[');
150 l->lstr_next = *list;
155 b2 = strchr(b1, ']');
156 if (b2 == NULL || b2 == b1 + 1)
164 sep = strchr(expr, ',');
170 if (sscanf(expr, "%u%n", &x, &n) >= 1 && n == nob) {
172 new_lstrs(list, l->lstr_str, b2, x, x, 1);
177 if (sscanf(expr, "%u-%u%n", &x, &y, &n) >= 2 && n == nob &&
180 new_lstrs(list, l->lstr_str, b2, x, y, 1);
185 if (sscanf(expr, "%u-%u/%u%n", &x, &y, &z, &n) >= 3 && n == nob &&
188 new_lstrs(list, l->lstr_str, b2, x, y, z);
194 } while ((expr = sep) != NULL);
202 expand_strs(char *str, lstr_t **head)
210 l = alloc_lstr(strlen(str) + 1);
211 memcpy(l->lstr_str, str, strlen(str) + 1);
219 while ((l = list) != NULL) {
222 rc = expand_lstr(&nlist, l);
224 fprintf(stderr, "Syntax error in \"%s\"\n", str);
232 /* re-order onto 'list' */
233 while ((l = nlist) != NULL) {
234 nlist = l->lstr_next;
239 } while (expanded && rc > 0);
246 while ((l = list) != NULL) {
255 lst_parse_nids(char *str, int *countp, lnet_process_id_t **idspp)
263 rc = expand_strs(str, &head);
273 *idspp = malloc(c * sizeof(lnet_process_id_t));
274 if (*idspp == NULL) {
275 fprintf(stderr, "Out of memory\n");
282 while ((l = head) != NULL) {
286 (*idspp)[i].nid = libcfs_str2nid(l->lstr_str);
287 if ((*idspp)[i].nid == LNET_NID_ANY) {
288 fprintf(stderr, "Invalid nid: %s\n",
293 (*idspp)[i].pid = LNET_PID_LUSTRE;
310 lst_node_state2str(int state)
312 if (state == LST_NODE_ACTIVE)
314 if (state == LST_NODE_BUSY)
316 if (state == LST_NODE_DOWN)
323 lst_node_str2state(char *str)
325 if (strcasecmp(str, "active") == 0)
326 return LST_NODE_ACTIVE;
327 if (strcasecmp(str, "busy") == 0)
328 return LST_NODE_BUSY;
329 if (strcasecmp(str, "down") == 0)
330 return LST_NODE_DOWN;
331 if (strcasecmp(str, "unknown") == 0)
332 return LST_NODE_UNKNOWN;
333 if (strcasecmp(str, "invalid") == 0)
334 return (LST_NODE_UNKNOWN | LST_NODE_DOWN | LST_NODE_BUSY);
340 lst_test_type2name(int type)
342 if (type == LST_TEST_PING)
344 if (type == LST_TEST_BULK)
351 lst_test_name2type(char *name)
353 if (strcasecmp(name, "ping") == 0)
354 return LST_TEST_PING;
355 if (strcasecmp(name, "brw") == 0)
356 return LST_TEST_BULK;
362 lst_print_usage(char *cmd)
364 Parser_printhelp(cmd);
368 lst_print_error(char *sub, const char *def_format, ...)
372 /* local error returned from kernel */
375 fprintf(stderr, "No session exists\n");
378 fprintf(stderr, "Session is shutting down\n");
381 fprintf(stderr, "Unmatched session key or not root\n");
384 fprintf(stderr, "Can't find %s in current session\n", sub);
387 fprintf(stderr, "Invalid parameters list in command line\n");
390 fprintf(stderr, "Bad parameter address\n");
393 fprintf(stderr, "%s already exists\n", sub);
396 va_start(ap, def_format);
397 vfprintf(stderr, def_format, ap);
405 lst_free_rpcent(struct list_head *head)
407 struct lstcon_rpc_ent *ent;
409 while (!list_empty(head)) {
410 ent = list_entry(head->next, struct lstcon_rpc_ent, rpe_link);
412 list_del(&ent->rpe_link);
418 lst_reset_rpcent(struct list_head *head)
420 struct lstcon_rpc_ent *ent;
422 list_for_each_entry(ent, head, rpe_link) {
423 ent->rpe_sid = LST_INVALID_SID;
424 ent->rpe_peer.nid = LNET_NID_ANY;
425 ent->rpe_peer.pid = LNET_PID_ANY;
426 ent->rpe_rpc_errno = ent->rpe_fwk_errno = 0;
431 lst_alloc_rpcent(struct list_head *head, int count, int offset)
433 struct lstcon_rpc_ent *ent;
436 for (i = 0; i < count; i++) {
437 ent = malloc(offsetof(struct lstcon_rpc_ent, rpe_payload[offset]));
439 lst_free_rpcent(head);
443 memset(ent, 0, offsetof(struct lstcon_rpc_ent, rpe_payload[offset]));
445 ent->rpe_sid = LST_INVALID_SID;
446 ent->rpe_peer.nid = LNET_NID_ANY;
447 ent->rpe_peer.pid = LNET_PID_ANY;
448 list_add(&ent->rpe_link, head);
455 lst_print_transerr(struct list_head *head, char *optstr)
457 struct lstcon_rpc_ent *ent;
459 list_for_each_entry(ent, head, rpe_link) {
460 if (ent->rpe_rpc_errno == 0 && ent->rpe_fwk_errno == 0)
463 if (ent->rpe_rpc_errno != 0) {
464 fprintf(stderr, "%s RPC failed on %s: %s\n",
465 optstr, libcfs_id2str(ent->rpe_peer),
466 strerror(ent->rpe_rpc_errno));
470 fprintf(stderr, "operation %s failed on %s: %s\n",
471 optstr, libcfs_id2str(ent->rpe_peer),
472 strerror(ent->rpe_fwk_errno));
476 int lst_info_batch_ioctl(char *batch, int test, int server,
477 struct lstcon_test_batch_ent *entp, int *idxp,
478 int *ndentp, struct lstcon_node_ent *dentsp);
480 int lst_info_group_ioctl(char *name, struct lstcon_ndlist_ent *gent,
481 int *idx, int *count, struct lstcon_node_ent *dents);
483 int lst_query_batch_ioctl(char *batch, int test, int server,
484 int timeout, struct list_head *head);
487 lst_ioctl(unsigned int opc, void *buf, int len)
489 struct libcfs_ioctl_data data;
492 LIBCFS_IOC_INIT (data);
493 data.ioc_u32[0] = opc;
494 data.ioc_plen1 = len;
495 data.ioc_pbuf1 = (char *)buf;
496 data.ioc_plen2 = sizeof(trans_stat);
497 data.ioc_pbuf2 = (char *)&trans_stat;
499 memset(&trans_stat, 0, sizeof(trans_stat));
501 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_LNETST, &data);
503 /* local error, no valid RPC result */
508 if (trans_stat.trs_rpc_errno != 0)
511 /* Framework error */
512 if (trans_stat.trs_fwk_errno != 0)
519 lst_new_session_ioctl(char *name, int timeout, int force, struct lst_sid *sid)
521 struct lstio_session_new_args args = { 0 };
523 args.lstio_ses_key = session_key;
524 args.lstio_ses_timeout = timeout;
525 args.lstio_ses_force = force;
526 args.lstio_ses_idp = sid;
527 args.lstio_ses_feats = session_features;
528 args.lstio_ses_nmlen = strlen(name);
529 args.lstio_ses_namep = name;
531 return lst_ioctl (LSTIO_SESSION_NEW, &args, sizeof(args));
535 jt_lst_new_session(int argc, char **argv)
537 char buf[LST_NAME_SIZE];
545 static struct option session_opts[] =
547 {"timeout", required_argument, 0, 't' },
548 {"force", no_argument, 0, 'f' },
552 if (session_key == 0) {
554 "Can't find env LST_SESSION or value is not valid\n");
560 c = getopt_long(argc, argv, "ft:",
561 session_opts, &optidx);
571 timeout = atoi(optarg);
574 lst_print_usage(argv[0]);
580 fprintf(stderr, "Invalid timeout value\n");
584 if (optind == argc - 1) {
585 name = argv[optind ++];
586 if (strlen(name) >= LST_NAME_SIZE) {
587 fprintf(stderr, "Name size is limited to %d\n",
592 } else if (optind == argc) {
593 char user[LST_NAME_SIZE];
594 char host[LST_NAME_SIZE];
595 struct passwd *pw = getpwuid(getuid());
598 snprintf(user, sizeof(user), "%d", (int)getuid());
600 snprintf(user, sizeof(user), "%s", pw->pw_name);
602 rc = gethostname(host, sizeof(host));
604 snprintf(host, sizeof(host), "unknown_host");
606 snprintf(buf, sizeof(buf), "%s@%s", user, host);
610 lst_print_usage(argv[0]);
614 rc = lst_new_session_ioctl(name, timeout, force, &session_id);
616 lst_print_error("session", "Failed to create session: %s\n",
621 fprintf(stdout, "SESSION: %s FEATURES: %x TIMEOUT: %d FORCE: %s\n",
622 name, session_features, timeout, force ? "Yes" : "No");
627 lst_session_info_ioctl(char *name, int len, int *key, unsigned *featp,
628 struct lst_sid *sid, struct lstcon_ndlist_ent *ndinfo)
630 struct lstio_session_info_args args = { 0 };
632 args.lstio_ses_idp = sid;
633 args.lstio_ses_keyp = key;
634 args.lstio_ses_featp = featp;
635 args.lstio_ses_ndinfo = ndinfo;
636 args.lstio_ses_nmlen = len;
637 args.lstio_ses_namep = name;
639 return lst_ioctl(LSTIO_SESSION_INFO, &args, sizeof(args));
643 jt_lst_show_session(int argc, char **argv)
645 struct lstcon_ndlist_ent ndinfo;
647 char name[LST_NAME_SIZE];
652 rc = lst_session_info_ioctl(name, sizeof(name), &key,
653 &feats, &sid, &ndinfo);
656 lst_print_error("session", "Failed to show session: %s\n",
661 fprintf(stdout, "%s ID: %ju@%s, KEY: %d FEATURES: %x NODES: %d\n",
662 name, (uintmax_t)sid.ses_stamp, libcfs_nid2str(sid.ses_nid),
663 key, feats, ndinfo.nle_nnode);
669 lst_end_session_ioctl(void)
671 struct lstio_session_end_args args = { 0 };
673 args.lstio_ses_key = session_key;
674 return lst_ioctl(LSTIO_SESSION_END, &args, sizeof(args));
678 jt_lst_end_session(int argc, char **argv)
682 if (session_key == 0) {
684 "Can't find env LST_SESSION or value is not valid\n");
688 rc = lst_end_session_ioctl();
691 fprintf(stdout, "session is ended\n");
696 lst_print_error("session", "Failed to end session: %s\n",
701 if (trans_stat.trs_rpc_errno != 0) {
703 "[RPC] Failed to send %d session RPCs: %s\n",
704 lstcon_rpc_stat_failure(&trans_stat, 0),
705 strerror(trans_stat.trs_rpc_errno));
708 if (trans_stat.trs_fwk_errno != 0) {
710 "[FWK] Failed to end session on %d nodes: %s\n",
711 lstcon_sesop_stat_failure(&trans_stat, 0),
712 strerror(trans_stat.trs_fwk_errno));
719 lst_ping_ioctl(char *str, int type, int timeout,
720 int count, lnet_process_id_t *ids, struct list_head *head)
722 struct lstio_debug_args args = { 0 };
724 args.lstio_dbg_key = session_key;
725 args.lstio_dbg_type = type;
726 args.lstio_dbg_flags = 0;
727 args.lstio_dbg_timeout = timeout;
728 args.lstio_dbg_nmlen = (str == NULL) ? 0: strlen(str);
729 args.lstio_dbg_namep = str;
730 args.lstio_dbg_count = count;
731 args.lstio_dbg_idsp = ids;
732 args.lstio_dbg_resultp = head;
734 return lst_ioctl (LSTIO_DEBUG, &args, sizeof(args));
738 lst_get_node_count(int type, char *str, int *countp, lnet_process_id_t **idspp)
740 char buf[LST_NAME_SIZE];
741 struct lstcon_test_batch_ent ent;
742 struct lstcon_ndlist_ent *entp = &ent.tbe_cli_nle;
749 case LST_OPC_SESSION:
750 rc = lst_session_info_ioctl(buf, LST_NAME_SIZE,
751 &key, &feats, &sid, entp);
754 case LST_OPC_BATCHSRV:
755 entp = &ent.tbe_srv_nle;
756 case LST_OPC_BATCHCLI:
757 rc = lst_info_batch_ioctl(str, 0, 0, &ent, NULL, NULL, NULL);
761 rc = lst_info_group_ioctl(str, entp, NULL, NULL, NULL);
765 rc = lst_parse_nids(str, &entp->nle_nnode, idspp) < 0 ? -1 : 0;
774 *countp = entp->nle_nnode;
780 jt_lst_ping(int argc, char **argv)
782 struct list_head head;
783 lnet_process_id_t *ids = NULL;
784 struct lstcon_rpc_ent *ent = NULL;
794 static struct option ping_opts[] =
796 {"session", no_argument, 0, 's' },
797 {"server", no_argument, 0, 'v' },
798 {"batch", required_argument, 0, 'b' },
799 {"group", required_argument, 0, 'g' },
800 {"nodes", required_argument, 0, 'n' },
801 {"timeout", required_argument, 0, 't' },
805 if (session_key == 0) {
807 "Can't find env LST_SESSION or value is not valid\n");
813 c = getopt_long(argc, argv, "g:b:n:t:sv",
821 type = LST_OPC_SESSION;
825 type = LST_OPC_GROUP;
830 type = LST_OPC_BATCHCLI;
835 type = LST_OPC_NODES;
840 timeout = atoi(optarg);
848 lst_print_usage(argv[0]);
853 if (type == 0 || timeout <= 0 || optind != argc) {
854 lst_print_usage(argv[0]);
858 if (type == LST_OPC_BATCHCLI && server)
859 type = LST_OPC_BATCHSRV;
861 rc = lst_get_node_count(type, str, &count, &ids);
863 fprintf(stderr, "Failed to get count of nodes from %s: %s\n",
864 (str == NULL) ? "session" : str, strerror(errno));
868 INIT_LIST_HEAD(&head);
870 rc = lst_alloc_rpcent(&head, count, LST_NAME_SIZE);
872 fprintf(stderr, "Out of memory\n");
877 fprintf(stdout, "Target %s is empty\n",
878 (str == NULL) ? "session" : str);
882 rc = lst_ping_ioctl(str, type, timeout, count, ids, &head);
883 if (rc == -1) { /* local failure */
884 lst_print_error("debug", "Failed to ping %s: %s\n",
885 (str == NULL) ? "session" : str,
891 /* ignore RPC errors and framwork errors */
892 list_for_each_entry(ent, &head, rpe_link) {
893 fprintf(stdout, "\t%s: %s [session: %s id: %s]\n",
894 libcfs_id2str(ent->rpe_peer),
895 lst_node_state2str(ent->rpe_state),
896 (ent->rpe_state == LST_NODE_ACTIVE ||
897 ent->rpe_state == LST_NODE_BUSY) ?
898 (ent->rpe_rpc_errno == 0 ?
899 &ent->rpe_payload[0] : "Unknown") :
900 "<NULL>", libcfs_nid2str(ent->rpe_sid.ses_nid));
904 lst_free_rpcent(&head);
914 lst_add_nodes_ioctl(char *name, int count, lnet_process_id_t *ids,
915 unsigned *featp, struct list_head *resultp)
917 struct lstio_group_nodes_args args = { 0 };
919 args.lstio_grp_key = session_key;
920 args.lstio_grp_nmlen = strlen(name);
921 args.lstio_grp_namep = name;
922 args.lstio_grp_count = count;
923 args.lstio_grp_featp = featp;
924 args.lstio_grp_idsp = ids;
925 args.lstio_grp_resultp = resultp;
927 return lst_ioctl(LSTIO_NODES_ADD, &args, sizeof(args));
931 lst_del_group_ioctl(char *name)
933 struct lstio_group_del_args args = { 0 };
935 args.lstio_grp_key = session_key;
936 args.lstio_grp_nmlen = strlen(name);
937 args.lstio_grp_namep = name;
939 return lst_ioctl(LSTIO_GROUP_DEL, &args, sizeof(args));
943 lst_del_group(char *grp_name)
947 rc = lst_del_group_ioctl(grp_name);
949 fprintf(stdout, "Group is deleted\n");
954 lst_print_error("group", "Failed to delete group: %s\n",
959 fprintf(stderr, "Group is deleted with some errors\n");
961 if (trans_stat.trs_rpc_errno != 0) {
963 "[RPC] Failed to send %d end session RPCs: %s\n",
964 lstcon_rpc_stat_failure(&trans_stat, 0),
965 strerror(trans_stat.trs_rpc_errno));
968 if (trans_stat.trs_fwk_errno != 0) {
970 "[FWK] Failed to end session on %d nodes: %s\n",
971 lstcon_sesop_stat_failure(&trans_stat, 0),
972 strerror(trans_stat.trs_fwk_errno));
979 lst_add_group_ioctl(char *name)
981 struct lstio_group_add_args args = { 0 };
983 args.lstio_grp_key = session_key;
984 args.lstio_grp_nmlen = strlen(name);
985 args.lstio_grp_namep = name;
987 return lst_ioctl(LSTIO_GROUP_ADD, &args, sizeof(args));
991 jt_lst_add_group(int argc, char **argv)
993 struct list_head head;
994 lnet_process_id_t *ids;
996 unsigned feats = session_features;
1000 bool nodes_added = false;
1002 if (session_key == 0) {
1004 "Can't find env LST_SESSION or value is not valid\n");
1009 lst_print_usage(argv[0]);
1014 if (strlen(name) >= LST_NAME_SIZE) {
1015 fprintf(stderr, "Name length is limited to %d\n",
1020 rc = lst_add_group_ioctl(name);
1022 lst_print_error("group", "Failed to add group %s: %s\n",
1023 name, strerror(errno));
1027 INIT_LIST_HEAD(&head);
1029 for (i = 2; i < argc; i++) {
1030 /* parse address list */
1031 rc = lst_parse_nids(argv[i], &count, &ids);
1033 fprintf(stderr, "Ignore invalid id list %s\n",
1041 rc = lst_alloc_rpcent(&head, count, 0);
1043 fprintf(stderr, "Out of memory\n");
1049 rc = lst_add_nodes_ioctl(name, count, ids, &feats, &head);
1056 fprintf(stdout, "%s are added to session\n", argv[i]);
1060 if ((feats & session_features) != session_features) {
1062 "Warning, this session will run with "
1063 "compatible mode because some test nodes "
1064 "might not understand these features: %x\n",
1065 (~feats & session_features));
1068 lst_free_rpcent(&head);
1073 * The selftest kernel module expects that a group should
1074 * have at least one node, since it doesn't make sense for
1075 * an empty group to be added to a test.
1078 "No nodes added successfully, deleting group %s\n",
1080 rc = lst_del_group(name);
1083 "Failed to delete group %s."
1084 " Group is empty.\n", name);
1092 lst_print_error("group", "Failed to add nodes %s: %s\n",
1093 argv[i], strerror(errno));
1096 if (trans_stat.trs_fwk_errno == EPROTO) {
1098 "test nodes might have different LST "
1099 "features, please disable some features by "
1100 "setting LST_FEATURES\n");
1103 lst_print_transerr(&head, "create session");
1106 lst_free_rpcent(&head);
1110 "No nodes added successfully, deleting group %s\n",
1112 if (lst_del_group(name) != 0) {
1114 "Failed to delete group %s."
1115 " Group is empty.\n", name);
1123 jt_lst_del_group(int argc, char **argv)
1127 if (session_key == 0) {
1129 "Can't find env LST_SESSION or value is not valid\n");
1134 lst_print_usage(argv[0]);
1138 rc = lst_del_group(argv[1]);
1144 lst_update_group_ioctl(int opc, char *name, int clean, int count,
1145 lnet_process_id_t *ids, struct list_head *resultp)
1147 struct lstio_group_update_args args = { 0 };
1149 args.lstio_grp_key = session_key;
1150 args.lstio_grp_opc = opc;
1151 args.lstio_grp_args = clean;
1152 args.lstio_grp_nmlen = strlen(name);
1153 args.lstio_grp_namep = name;
1154 args.lstio_grp_count = count;
1155 args.lstio_grp_idsp = ids;
1156 args.lstio_grp_resultp = resultp;
1158 return lst_ioctl(LSTIO_GROUP_UPDATE, &args, sizeof(args));
1162 jt_lst_update_group(int argc, char **argv)
1164 struct list_head head;
1165 lnet_process_id_t *ids = NULL;
1175 static struct option update_group_opts[] =
1177 {"refresh", no_argument, 0, 'f' },
1178 {"clean", required_argument, 0, 'c' },
1179 {"remove", required_argument, 0, 'r' },
1183 if (session_key == 0) {
1185 "Can't find env LST_SESSION or value is not valid\n");
1190 c = getopt_long(argc, argv, "fc:r:",
1191 update_group_opts, &optidx);
1193 /* Detect the end of the options. */
1200 lst_print_usage(argv[0]);
1203 opc = LST_GROUP_REFRESH;
1208 lst_print_usage(argv[0]);
1211 opc = LST_GROUP_RMND;
1216 clean = lst_node_str2state(optarg);
1217 if (opc != 0 || clean <= 0) {
1218 lst_print_usage(argv[0]);
1221 opc = LST_GROUP_CLEAN;
1225 lst_print_usage(argv[0]);
1230 /* no OPC or group is specified */
1231 if (opc == 0 || optind != argc - 1) {
1232 lst_print_usage(argv[0]);
1238 INIT_LIST_HEAD(&head);
1240 if (opc == LST_GROUP_RMND || opc == LST_GROUP_REFRESH) {
1241 rc = lst_get_node_count(opc == LST_GROUP_RMND ? LST_OPC_NODES :
1243 opc == LST_GROUP_RMND ? str : grp,
1247 fprintf(stderr, "Can't get count of nodes from %s: %s\n",
1248 opc == LST_GROUP_RMND ? str : grp,
1253 rc = lst_alloc_rpcent(&head, count, 0);
1255 fprintf(stderr, "Out of memory\n");
1262 rc = lst_update_group_ioctl(opc, grp, clean, count, ids, &head);
1268 lst_free_rpcent(&head);
1273 lst_free_rpcent(&head);
1274 lst_print_error("group", "Failed to update group: %s\n",
1279 lst_print_transerr(&head, "Updating group");
1281 lst_free_rpcent(&head);
1287 lst_list_group_ioctl(int len, char *name, int idx)
1289 struct lstio_group_list_args args = { 0 };
1291 args.lstio_grp_key = session_key;
1292 args.lstio_grp_idx = idx;
1293 args.lstio_grp_nmlen = len;
1294 args.lstio_grp_namep = name;
1296 return lst_ioctl(LSTIO_GROUP_LIST, &args, sizeof(args));
1300 lst_info_group_ioctl(char *name, struct lstcon_ndlist_ent *gent,
1301 int *idx, int *count, struct lstcon_node_ent *dents)
1303 struct lstio_group_info_args args = { 0 };
1305 args.lstio_grp_key = session_key;
1306 args.lstio_grp_nmlen = strlen(name);
1307 args.lstio_grp_namep = name;
1308 args.lstio_grp_entp = gent;
1309 args.lstio_grp_idxp = idx;
1310 args.lstio_grp_ndentp = count;
1311 args.lstio_grp_dentsp = dents;
1313 return lst_ioctl(LSTIO_GROUP_INFO, &args, sizeof(args));
1317 lst_list_group_all(void)
1319 char name[LST_NAME_SIZE];
1323 /* no group is specified, list name of all groups */
1324 for (i = 0; ; i++) {
1325 rc = lst_list_group_ioctl(LST_NAME_SIZE, name, i);
1327 fprintf(stdout, "%d) %s\n", i + 1, name);
1331 if (errno == ENOENT)
1334 lst_print_error("group", "Failed to list group: %s\n",
1339 fprintf(stdout, "Total %d groups\n", i);
1344 #define LST_NODES_TITLE "\tACTIVE\tBUSY\tDOWN\tUNKNOWN\tTOTAL\n"
1347 jt_lst_list_group(int argc, char **argv)
1349 struct lstcon_ndlist_ent gent;
1350 struct lstcon_node_ent *dents;
1365 static struct option list_group_opts[] =
1367 {"active", no_argument, 0, 'a' },
1368 {"busy", no_argument, 0, 'b' },
1369 {"down", no_argument, 0, 'd' },
1370 {"unknown", no_argument, 0, 'u' },
1371 {"all", no_argument, 0, 'l' },
1375 if (session_key == 0) {
1377 "Can't find env LST_SESSION or value is not valid\n");
1382 c = getopt_long(argc, argv, "abdul",
1383 list_group_opts, &optidx);
1390 verbose = active = 1;
1402 verbose = unknown = 1;
1409 lst_print_usage(argv[0]);
1414 if (optind == argc) {
1415 /* no group is specified, list name of all groups */
1416 rc = lst_list_group_all();
1422 fprintf(stdout, LST_NODES_TITLE);
1424 /* list nodes in specified groups */
1425 for (i = optind; i < argc; i++) {
1426 rc = lst_info_group_ioctl(argv[i], &gent, NULL, NULL, NULL);
1428 if (errno == ENOENT) {
1433 lst_print_error("group", "Failed to list group\n",
1439 fprintf(stdout, "\t%d\t%d\t%d\t%d\t%d\t%s\n",
1440 gent.nle_nactive, gent.nle_nbusy,
1441 gent.nle_ndown, gent.nle_nunknown,
1442 gent.nle_nnode, argv[i]);
1446 fprintf(stdout, "Group [ %s ]\n", argv[i]);
1448 if (gent.nle_nnode == 0) {
1449 fprintf(stdout, "No nodes found [ %s ]\n", argv[i]);
1453 count = gent.nle_nnode;
1455 dents = malloc(count * sizeof(struct lstcon_node_ent));
1456 if (dents == NULL) {
1457 fprintf(stderr, "Failed to malloc: %s\n",
1463 rc = lst_info_group_ioctl(argv[i], &gent, &index, &count, dents);
1465 lst_print_error("group", "Failed to list group: %s\n",
1471 for (j = 0, c = 0; j < count; j++) {
1473 ((active && dents[j].nde_state == LST_NODE_ACTIVE) ||
1474 (busy && dents[j].nde_state == LST_NODE_BUSY) ||
1475 (down && dents[j].nde_state == LST_NODE_DOWN) ||
1476 (unknown && dents[j].nde_state == LST_NODE_UNKNOWN))) {
1478 fprintf(stdout, "\t%s: %s\n",
1479 libcfs_id2str(dents[j].nde_id),
1480 lst_node_state2str(dents[j].nde_state));
1485 fprintf(stdout, "Total %d nodes [ %s ]\n", c, argv[i]);
1494 lst_stat_ioctl (char *name, int count, lnet_process_id_t *idsp,
1495 int timeout, struct list_head *resultp)
1497 struct lstio_stat_args args = { 0 };
1499 args.lstio_sta_key = session_key;
1500 args.lstio_sta_timeout = timeout;
1501 args.lstio_sta_nmlen = strlen(name);
1502 args.lstio_sta_namep = name;
1503 args.lstio_sta_count = count;
1504 args.lstio_sta_idsp = idsp;
1505 args.lstio_sta_resultp = resultp;
1507 return lst_ioctl(LSTIO_STAT_QUERY, &args, sizeof(args));
1511 struct list_head srp_link;
1514 lnet_process_id_t *srp_ids;
1515 struct list_head srp_result[2];
1516 } lst_stat_req_param_t;
1519 lst_stat_req_param_free(lst_stat_req_param_t *srp)
1523 for (i = 0; i < 2; i++)
1524 lst_free_rpcent(&srp->srp_result[i]);
1526 if (srp->srp_ids != NULL)
1533 lst_stat_req_param_alloc(char *name, lst_stat_req_param_t **srpp, int save_old)
1535 lst_stat_req_param_t *srp = NULL;
1536 int count = save_old ? 2 : 1;
1540 srp = malloc(sizeof(*srp));
1544 memset(srp, 0, sizeof(*srp));
1545 INIT_LIST_HEAD(&srp->srp_result[0]);
1546 INIT_LIST_HEAD(&srp->srp_result[1]);
1548 rc = lst_get_node_count(LST_OPC_GROUP, name,
1549 &srp->srp_count, NULL);
1550 if (rc != 0 && errno == ENOENT) {
1551 rc = lst_get_node_count(LST_OPC_NODES, name,
1552 &srp->srp_count, &srp->srp_ids);
1557 "Failed to get count of nodes from %s: %s\n",
1558 name, strerror(errno));
1559 lst_stat_req_param_free(srp);
1564 srp->srp_name = name;
1566 for (i = 0; i < count; i++) {
1567 rc = lst_alloc_rpcent(&srp->srp_result[i], srp->srp_count,
1568 sizeof(struct sfw_counters) +
1569 sizeof(struct srpc_counters) +
1570 sizeof(lnet_counters_t));
1572 fprintf(stderr, "Out of memory\n");
1582 lst_stat_req_param_free(srp);
1590 } lst_srpc_stat_result;
1592 #define LST_LNET_AVG 0
1593 #define LST_LNET_MIN 1
1594 #define LST_LNET_MAX 2
1597 float lnet_avg_sndrate;
1598 float lnet_min_sndrate;
1599 float lnet_max_sndrate;
1600 float lnet_total_sndrate;
1602 float lnet_avg_rcvrate;
1603 float lnet_min_rcvrate;
1604 float lnet_max_rcvrate;
1605 float lnet_total_rcvrate;
1607 float lnet_avg_sndperf;
1608 float lnet_min_sndperf;
1609 float lnet_max_sndperf;
1610 float lnet_total_sndperf;
1612 float lnet_avg_rcvperf;
1613 float lnet_min_rcvperf;
1614 float lnet_max_rcvperf;
1615 float lnet_total_rcvperf;
1617 int lnet_stat_count;
1618 } lst_lnet_stat_result_t;
1620 lst_lnet_stat_result_t lnet_stat_result;
1623 lst_lnet_stat_value(int bw, int send, int off)
1627 p = bw ? &lnet_stat_result.lnet_avg_sndperf :
1628 &lnet_stat_result.lnet_avg_sndrate;
1639 lst_timeval_diff(struct timeval *tv1,
1640 struct timeval *tv2, struct timeval *df)
1642 if (tv1->tv_usec >= tv2->tv_usec) {
1643 df->tv_sec = tv1->tv_sec - tv2->tv_sec;
1644 df->tv_usec = tv1->tv_usec - tv2->tv_usec;
1648 df->tv_sec = tv1->tv_sec - 1 - tv2->tv_sec;
1649 df->tv_usec = tv1->tv_usec + 1000000 - tv2->tv_usec;
1655 lst_cal_lnet_stat(float delta, lnet_counters_t *lnet_new,
1656 lnet_counters_t *lnet_old, int mbs)
1660 unsigned int unit_divisor;
1662 unit_divisor = (mbs) ? (1000 * 1000) : (1024 * 1024);
1663 perf = (float)(lnet_new->send_length -
1664 lnet_old->send_length) / unit_divisor / delta;
1665 lnet_stat_result.lnet_total_sndperf += perf;
1667 if (lnet_stat_result.lnet_min_sndperf > perf ||
1668 lnet_stat_result.lnet_min_sndperf == 0)
1669 lnet_stat_result.lnet_min_sndperf = perf;
1671 if (lnet_stat_result.lnet_max_sndperf < perf)
1672 lnet_stat_result.lnet_max_sndperf = perf;
1674 perf = (float)(lnet_new->recv_length -
1675 lnet_old->recv_length) / unit_divisor / delta;
1676 lnet_stat_result.lnet_total_rcvperf += perf;
1678 if (lnet_stat_result.lnet_min_rcvperf > perf ||
1679 lnet_stat_result.lnet_min_rcvperf == 0)
1680 lnet_stat_result.lnet_min_rcvperf = perf;
1682 if (lnet_stat_result.lnet_max_rcvperf < perf)
1683 lnet_stat_result.lnet_max_rcvperf = perf;
1685 rate = (lnet_new->send_count - lnet_old->send_count) / delta;
1686 lnet_stat_result.lnet_total_sndrate += rate;
1688 if (lnet_stat_result.lnet_min_sndrate > rate ||
1689 lnet_stat_result.lnet_min_sndrate == 0)
1690 lnet_stat_result.lnet_min_sndrate = rate;
1692 if (lnet_stat_result.lnet_max_sndrate < rate)
1693 lnet_stat_result.lnet_max_sndrate = rate;
1695 rate = (lnet_new->recv_count - lnet_old->recv_count) / delta;
1696 lnet_stat_result.lnet_total_rcvrate += rate;
1698 if (lnet_stat_result.lnet_min_rcvrate > rate ||
1699 lnet_stat_result.lnet_min_rcvrate == 0)
1700 lnet_stat_result.lnet_min_rcvrate = rate;
1702 if (lnet_stat_result.lnet_max_rcvrate < rate)
1703 lnet_stat_result.lnet_max_rcvrate = rate;
1705 lnet_stat_result.lnet_stat_count++;
1707 lnet_stat_result.lnet_avg_sndrate = lnet_stat_result.lnet_total_sndrate /
1708 lnet_stat_result.lnet_stat_count;
1709 lnet_stat_result.lnet_avg_rcvrate = lnet_stat_result.lnet_total_rcvrate /
1710 lnet_stat_result.lnet_stat_count;
1712 lnet_stat_result.lnet_avg_sndperf = lnet_stat_result.lnet_total_sndperf /
1713 lnet_stat_result.lnet_stat_count;
1714 lnet_stat_result.lnet_avg_rcvperf = lnet_stat_result.lnet_total_rcvperf /
1715 lnet_stat_result.lnet_stat_count;
1719 lst_print_lnet_stat(char *name, int bwrt, int rdwr, int type, int mbs)
1729 if (lnet_stat_result.lnet_stat_count == 0)
1732 units = (mbs) ? "MB/s " : "MiB/s ";
1734 if (bwrt == 1) /* bw only */
1737 if (bwrt == 2) /* rates only */
1740 if (rdwr == 1) /* recv only */
1743 if (rdwr == 2) /* send only */
1746 for (i = start1; i <= end1; i++) {
1747 fprintf(stdout, "[LNet %s of %s]\n",
1748 i == 0 ? "Rates" : "Bandwidth", name);
1750 for (j = start2; j <= end2; j++) {
1751 fprintf(stdout, "[%c] ", j == 0 ? 'R' : 'W');
1753 if ((type & 1) != 0) {
1754 fprintf(stdout, i == 0 ? "Avg: %-8.0f RPC/s " :
1756 lst_lnet_stat_value(i, j, 0), units);
1759 if ((type & 2) != 0) {
1760 fprintf(stdout, i == 0 ? "Min: %-8.0f RPC/s " :
1762 lst_lnet_stat_value(i, j, 1), units);
1765 if ((type & 4) != 0) {
1766 fprintf(stdout, i == 0 ? "Max: %-8.0f RPC/s" :
1768 lst_lnet_stat_value(i, j, 2), units);
1771 fprintf(stdout, "\n");
1777 lst_print_stat(char *name, struct list_head *resultp,
1778 int idx, int lnet, int bwrt, int rdwr, int type,
1781 struct list_head tmp[2];
1782 struct lstcon_rpc_ent *new;
1783 struct lstcon_rpc_ent *old;
1784 struct sfw_counters *sfwk_new;
1785 struct sfw_counters *sfwk_old;
1786 struct srpc_counters *srpc_new;
1787 struct srpc_counters *srpc_old;
1788 lnet_counters_t *lnet_new;
1789 lnet_counters_t *lnet_old;
1793 INIT_LIST_HEAD(&tmp[0]);
1794 INIT_LIST_HEAD(&tmp[1]);
1796 memset(&lnet_stat_result, 0, sizeof(lnet_stat_result));
1798 while (!list_empty(&resultp[idx])) {
1799 if (list_empty(&resultp[1 - idx])) {
1800 fprintf(stderr, "Group is changed, re-run stat\n");
1804 new = list_entry(resultp[idx].next, struct lstcon_rpc_ent,
1806 old = list_entry(resultp[1 - idx].next, struct lstcon_rpc_ent,
1809 /* first time get stats result, can't calculate diff */
1810 if (new->rpe_peer.nid == LNET_NID_ANY)
1813 if (new->rpe_peer.nid != old->rpe_peer.nid ||
1814 new->rpe_peer.pid != old->rpe_peer.pid) {
1815 /* Something wrong. i.e, somebody change the group */
1819 list_del(&new->rpe_link);
1820 list_add_tail(&new->rpe_link, &tmp[idx]);
1822 list_del(&old->rpe_link);
1823 list_add_tail(&old->rpe_link, &tmp[1 - idx]);
1825 if (new->rpe_rpc_errno != 0 || new->rpe_fwk_errno != 0 ||
1826 old->rpe_rpc_errno != 0 || old->rpe_fwk_errno != 0) {
1831 sfwk_new = (struct sfw_counters *)&new->rpe_payload[0];
1832 sfwk_old = (struct sfw_counters *)&old->rpe_payload[0];
1834 srpc_new = (struct srpc_counters *)((char *)sfwk_new + sizeof(*sfwk_new));
1835 srpc_old = (struct srpc_counters *)((char *)sfwk_old + sizeof(*sfwk_old));
1837 lnet_new = (lnet_counters_t *)((char *)srpc_new + sizeof(*srpc_new));
1838 lnet_old = (lnet_counters_t *)((char *)srpc_old + sizeof(*srpc_old));
1840 /* Prior to version 2.3, the running_ms field was a counter for
1841 * the number of running tests. We are looking at this value
1842 * to determine if it is a millisecond timestamep (>= 2.3) or a
1843 * test counter (< 2.3). The number 500 is being used for this
1844 * barrier as the test counter should never get this high, and
1845 * the timestamp should never get this low. */
1847 if (sfwk_new->running_ms > 500) {
1848 /* use the timestamp from the remote node, not our
1849 * rpe_stamp from when we copied up the data out of
1852 delta = (float) (sfwk_new->running_ms -
1853 sfwk_old->running_ms) / 1000;
1857 lst_timeval_diff(&new->rpe_stamp, &old->rpe_stamp, &tv);
1858 delta = tv.tv_sec + (float)tv.tv_usec / 1000000;
1861 if (!lnet) /* TODO */
1864 lst_cal_lnet_stat(delta, lnet_new, lnet_old, mbs);
1867 list_splice(&tmp[idx], &resultp[idx]);
1868 list_splice(&tmp[1 - idx], &resultp[1 - idx]);
1871 fprintf(stdout, "Failed to stat on %d nodes\n", errcount);
1873 if (!lnet) /* TODO */
1876 lst_print_lnet_stat(name, bwrt, rdwr, type, mbs);
1880 jt_lst_stat(int argc, char **argv)
1882 struct list_head head;
1883 lst_stat_req_param_t *srp;
1886 int timeout = 5; /* default timeout, 5 sec */
1887 int delay = 5; /* default delay, 5 sec */
1888 int count = -1; /* run forever */
1889 int lnet = 1; /* lnet stat by default */
1896 int mbs = 0; /* report as MB/s */
1898 static struct option stat_opts[] = {
1899 {"timeout" , required_argument, 0, 't' },
1900 {"delay" , required_argument, 0, 'd' },
1901 {"count" , required_argument, 0, 'o' },
1902 {"lnet" , no_argument, 0, 'l' },
1903 {"rpc" , no_argument, 0, 'c' },
1904 {"bw" , no_argument, 0, 'b' },
1905 {"rate" , no_argument, 0, 'a' },
1906 {"read" , no_argument, 0, 'r' },
1907 {"write" , no_argument, 0, 'w' },
1908 {"avg" , no_argument, 0, 'g' },
1909 {"min" , no_argument, 0, 'n' },
1910 {"max" , no_argument, 0, 'x' },
1911 {"mbs" , no_argument, 0, 'm' },
1915 if (session_key == 0) {
1917 "Can't find env LST_SESSION or value is not valid\n");
1922 c = getopt_long(argc, argv, "t:d:lcbarwgnxm", stat_opts,
1930 timeout = atoi(optarg);
1933 delay = atoi(optarg);
1936 count = atoi(optarg);
1982 lst_print_usage(argv[0]);
1987 if (optind == argc) {
1988 lst_print_usage(argv[0]);
1992 if (timeout <= 0 || delay <= 0) {
1993 fprintf(stderr, "Invalid timeout or delay value\n");
1998 fprintf(stderr, "Invalid count value\n");
2002 /* extra count to get first data point */
2006 INIT_LIST_HEAD(&head);
2008 while (optind < argc) {
2009 rc = lst_stat_req_param_alloc(argv[optind++], &srp, 1);
2013 list_add_tail(&srp->srp_link, &head);
2017 time_t now = time(NULL);
2019 if (now - last < delay) {
2020 sleep(delay - now + last);
2025 list_for_each_entry(srp, &head, srp_link) {
2026 rc = lst_stat_ioctl(srp->srp_name,
2027 srp->srp_count, srp->srp_ids,
2028 timeout, &srp->srp_result[idx]);
2030 lst_print_error("stat", "Failed to stat %s: %s\n",
2031 srp->srp_name, strerror(errno));
2035 lst_print_stat(srp->srp_name, srp->srp_result,
2036 idx, lnet, bwrt, rdwr, type, mbs);
2038 lst_reset_rpcent(&srp->srp_result[1 - idx]);
2045 } while (count == -1 || count > 0);
2048 while (!list_empty(&head)) {
2049 srp = list_entry(head.next, lst_stat_req_param_t, srp_link);
2051 list_del(&srp->srp_link);
2052 lst_stat_req_param_free(srp);
2059 jt_lst_show_error(int argc, char **argv)
2061 struct list_head head;
2062 lst_stat_req_param_t *srp;
2063 struct lstcon_rpc_ent *ent;
2064 struct sfw_counters *sfwk;
2065 struct srpc_counters *srpc;
2072 static struct option show_error_opts[] =
2074 {"session", no_argument, 0, 's' },
2078 if (session_key == 0) {
2080 "Can't find env LST_SESSION or value is not valid\n");
2085 c = getopt_long(argc, argv, "s", show_error_opts, &optidx);
2096 lst_print_usage(argv[0]);
2101 if (optind == argc) {
2102 lst_print_usage(argv[0]);
2106 INIT_LIST_HEAD(&head);
2108 while (optind < argc) {
2109 rc = lst_stat_req_param_alloc(argv[optind++], &srp, 0);
2113 list_add_tail(&srp->srp_link, &head);
2116 list_for_each_entry(srp, &head, srp_link) {
2117 rc = lst_stat_ioctl(srp->srp_name, srp->srp_count,
2118 srp->srp_ids, 10, &srp->srp_result[0]);
2121 lst_print_error(srp->srp_name, "Failed to show errors of %s: %s\n",
2122 srp->srp_name, strerror(errno));
2126 fprintf(stdout, "%s:\n", srp->srp_name);
2130 list_for_each_entry(ent, &srp->srp_result[0], rpe_link) {
2131 if (ent->rpe_rpc_errno != 0) {
2133 fprintf(stderr, "RPC failure, can't show error on %s\n",
2134 libcfs_id2str(ent->rpe_peer));
2138 if (ent->rpe_fwk_errno != 0) {
2140 fprintf(stderr, "Framework failure, can't show error on %s\n",
2141 libcfs_id2str(ent->rpe_peer));
2145 sfwk = (struct sfw_counters *)&ent->rpe_payload[0];
2146 srpc = (struct srpc_counters *)((char *)sfwk + sizeof(*sfwk));
2148 if (srpc->errors == 0 &&
2149 sfwk->brw_errors == 0 && sfwk->ping_errors == 0)
2153 sfwk->brw_errors == 0 && sfwk->ping_errors == 0)
2158 fprintf(stderr, "%s: [Session %d brw errors, %d ping errors]%c",
2159 libcfs_id2str(ent->rpe_peer),
2160 sfwk->brw_errors, sfwk->ping_errors,
2161 show_rpc ? ' ' : '\n');
2166 fprintf(stderr, "[RPC: %d errors, %d dropped, %d expired]\n",
2167 srpc->errors, srpc->rpcs_dropped, srpc->rpcs_expired);
2170 fprintf(stdout, "Total %d error nodes in %s\n", ecount, srp->srp_name);
2173 while (!list_empty(&head)) {
2174 srp = list_entry(head.next, lst_stat_req_param_t, srp_link);
2176 list_del(&srp->srp_link);
2177 lst_stat_req_param_free(srp);
2184 lst_add_batch_ioctl(char *name)
2186 struct lstio_batch_add_args args = { 0 };
2188 args.lstio_bat_key = session_key;
2189 args.lstio_bat_nmlen = strlen(name);
2190 args.lstio_bat_namep = name;
2192 return lst_ioctl (LSTIO_BATCH_ADD, &args, sizeof(args));
2196 jt_lst_add_batch(int argc, char **argv)
2201 if (session_key == 0) {
2203 "Can't find env LST_SESSION or value is not valid\n");
2208 lst_print_usage(argv[0]);
2213 if (strlen(name) >= LST_NAME_SIZE) {
2214 fprintf(stderr, "Name length is limited to %d\n",
2219 rc = lst_add_batch_ioctl(name);
2223 lst_print_error("batch", "Failed to create batch: %s\n",
2230 lst_start_batch_ioctl(char *name, int timeout, struct list_head *resultp)
2232 struct lstio_batch_run_args args = { 0 };
2234 args.lstio_bat_key = session_key;
2235 args.lstio_bat_timeout = timeout;
2236 args.lstio_bat_nmlen = strlen(name);
2237 args.lstio_bat_namep = name;
2238 args.lstio_bat_resultp = resultp;
2240 return lst_ioctl(LSTIO_BATCH_START, &args, sizeof(args));
2244 jt_lst_start_batch(int argc, char **argv)
2246 struct list_head head;
2254 static struct option start_batch_opts[] =
2256 {"timeout", required_argument, 0, 't' },
2260 if (session_key == 0) {
2262 "Can't find env LST_SESSION or value is not valid\n");
2267 c = getopt_long(argc, argv, "t:",
2268 start_batch_opts, &optidx);
2270 /* Detect the end of the options. */
2276 timeout = atoi(optarg);
2279 lst_print_usage(argv[0]);
2284 if (optind == argc) {
2285 batch = LST_DEFAULT_BATCH;
2287 } else if (optind == argc - 1) {
2288 batch = argv[optind];
2291 lst_print_usage(argv[0]);
2295 rc = lst_get_node_count(LST_OPC_BATCHCLI, batch, &count, NULL);
2297 fprintf(stderr, "Failed to get count of nodes from %s: %s\n",
2298 batch, strerror(errno));
2302 INIT_LIST_HEAD(&head);
2304 rc = lst_alloc_rpcent(&head, count, 0);
2306 fprintf(stderr, "Out of memory\n");
2310 rc = lst_start_batch_ioctl(batch, timeout, &head);
2313 fprintf(stdout, "%s is running now\n", batch);
2314 lst_free_rpcent(&head);
2319 lst_print_error("batch", "Failed to start batch: %s\n",
2321 lst_free_rpcent(&head);
2325 lst_print_transerr(&head, "Run batch");
2327 lst_free_rpcent(&head);
2333 lst_stop_batch_ioctl(char *name, int force, struct list_head *resultp)
2335 struct lstio_batch_stop_args args = { 0 };
2337 args.lstio_bat_key = session_key;
2338 args.lstio_bat_force = force;
2339 args.lstio_bat_nmlen = strlen(name);
2340 args.lstio_bat_namep = name;
2341 args.lstio_bat_resultp = resultp;
2343 return lst_ioctl(LSTIO_BATCH_STOP, &args, sizeof(args));
2347 jt_lst_stop_batch(int argc, char **argv)
2349 struct list_head head;
2357 static struct option stop_batch_opts[] =
2359 {"force", no_argument, 0, 'f' },
2363 if (session_key == 0) {
2365 "Can't find env LST_SESSION or value is not valid\n");
2370 c = getopt_long(argc, argv, "f",
2371 stop_batch_opts, &optidx);
2373 /* Detect the end of the options. */
2382 lst_print_usage(argv[0]);
2387 if (optind == argc) {
2388 batch = LST_DEFAULT_BATCH;
2390 } else if (optind == argc - 1) {
2391 batch = argv[optind];
2394 lst_print_usage(argv[0]);
2398 rc = lst_get_node_count(LST_OPC_BATCHCLI, batch, &count, NULL);
2400 fprintf(stderr, "Failed to get count of nodes from %s: %s\n",
2401 batch, strerror(errno));
2405 INIT_LIST_HEAD(&head);
2407 rc = lst_alloc_rpcent(&head, count, 0);
2409 fprintf(stderr, "Out of memory\n");
2413 rc = lst_stop_batch_ioctl(batch, force, &head);
2418 lst_reset_rpcent(&head);
2420 rc = lst_query_batch_ioctl(batch, 0, 0, 30, &head);
2424 if (lstcon_tsbqry_stat_run(&trans_stat, 0) == 0 &&
2425 lstcon_tsbqry_stat_failure(&trans_stat, 0) == 0)
2428 fprintf(stdout, "%d batch in stopping\n",
2429 lstcon_tsbqry_stat_run(&trans_stat, 0));
2433 fprintf(stdout, "Batch is stopped\n");
2434 lst_free_rpcent(&head);
2439 lst_print_error("batch", "Failed to stop batch: %s\n",
2441 lst_free_rpcent(&head);
2445 lst_print_transerr(&head, "stop batch");
2447 lst_free_rpcent(&head);
2453 lst_list_batch_ioctl(int len, char *name, int index)
2455 struct lstio_batch_list_args args = { 0 };
2457 args.lstio_bat_key = session_key;
2458 args.lstio_bat_idx = index;
2459 args.lstio_bat_nmlen = len;
2460 args.lstio_bat_namep = name;
2462 return lst_ioctl(LSTIO_BATCH_LIST, &args, sizeof(args));
2466 lst_info_batch_ioctl(char *batch, int test, int server,
2467 struct lstcon_test_batch_ent *entp, int *idxp,
2468 int *ndentp, struct lstcon_node_ent *dentsp)
2470 struct lstio_batch_info_args args = { 0 };
2472 args.lstio_bat_key = session_key;
2473 args.lstio_bat_nmlen = strlen(batch);
2474 args.lstio_bat_namep = batch;
2475 args.lstio_bat_server = server;
2476 args.lstio_bat_testidx = test;
2477 args.lstio_bat_entp = entp;
2478 args.lstio_bat_idxp = idxp;
2479 args.lstio_bat_ndentp = ndentp;
2480 args.lstio_bat_dentsp = dentsp;
2482 return lst_ioctl(LSTIO_BATCH_INFO, &args, sizeof(args));
2486 lst_list_batch_all(void)
2488 char name[LST_NAME_SIZE];
2492 for (i = 0; ; i++) {
2493 rc = lst_list_batch_ioctl(LST_NAME_SIZE, name, i);
2495 fprintf(stdout, "%d) %s\n", i + 1, name);
2499 if (errno == ENOENT)
2502 lst_print_error("batch", "Failed to list batch: %s\n",
2507 fprintf(stdout, "Total %d batches\n", i);
2513 lst_list_tsb_nodes(char *batch, int test, int server,
2514 int count, int active, int invalid)
2516 struct lstcon_node_ent *dents;
2525 /* verbose list, show nodes in batch or test */
2526 dents = malloc(count * sizeof(struct lstcon_node_ent));
2527 if (dents == NULL) {
2528 fprintf(stdout, "Can't allocate memory\n");
2532 rc = lst_info_batch_ioctl(batch, test, server,
2533 NULL, &index, &count, dents);
2536 lst_print_error((test > 0) ? "test" : "batch",
2537 (test > 0) ? "Failed to query test: %s\n" :
2538 "Failed to query batch: %s\n",
2543 for (i = 0, c = 0; i < count; i++) {
2544 if ((!active && dents[i].nde_state == LST_NODE_ACTIVE) ||
2545 (!invalid && (dents[i].nde_state == LST_NODE_BUSY ||
2546 dents[i].nde_state == LST_NODE_DOWN ||
2547 dents[i].nde_state == LST_NODE_UNKNOWN)))
2550 fprintf(stdout, "\t%s: %s\n",
2551 libcfs_id2str(dents[i].nde_id),
2552 lst_node_state2str(dents[i].nde_state));
2556 fprintf(stdout, "Total %d nodes\n", c);
2563 jt_lst_list_batch(int argc, char **argv)
2565 struct lstcon_test_batch_ent ent;
2568 int verbose = 0; /* list nodes in batch or test */
2577 static struct option list_batch_opts[] =
2579 {"test", required_argument, 0, 't' },
2580 {"invalid", no_argument, 0, 'i' },
2581 {"active", no_argument, 0, 'a' },
2582 {"all", no_argument, 0, 'l' },
2583 {"server", no_argument, 0, 's' },
2587 if (session_key == 0) {
2589 "Can't find env LST_SESSION or value is not valid\n");
2594 c = getopt_long(argc, argv, "ailst:",
2595 list_batch_opts, &optidx);
2602 verbose = active = 1;
2605 verbose = invalid = 1;
2608 verbose = active = invalid = 1;
2614 test = atoi(optarg);
2618 lst_print_usage(argv[0]);
2623 if (optind == argc) {
2624 /* list all batches */
2625 rc = lst_list_batch_all();
2629 if (ntest == 1 && test <= 0) {
2630 fprintf(stderr, "Invalid test id, test id starts from 1\n");
2634 if (optind != argc - 1) {
2635 lst_print_usage(argv[0]);
2639 batch = argv[optind];
2642 /* show detail of specified batch or test */
2643 rc = lst_info_batch_ioctl(batch, test, server,
2644 &ent, NULL, NULL, NULL);
2646 lst_print_error((test > 0) ? "test" : "batch",
2647 (test > 0) ? "Failed to query test: %s\n" :
2648 "Failed to query batch: %s\n",
2654 /* list nodes in test or batch */
2655 rc = lst_list_tsb_nodes(batch, test, server,
2656 server ? ent.tbe_srv_nle.nle_nnode :
2657 ent.tbe_cli_nle.nle_nnode,
2662 /* only show number of hosts in batch or test */
2664 fprintf(stdout, "Batch: %s Tests: %d State: %d\n",
2665 batch, ent.u.tbe_batch.bae_ntest,
2666 ent.u.tbe_batch.bae_state);
2667 ntest = ent.u.tbe_batch.bae_ntest;
2668 test = 1; /* starting from test 1 */
2672 "\tTest %d(%s) (loop: %d, concurrency: %d)\n",
2673 test, lst_test_type2name(ent.u.tbe_test.tse_type),
2674 ent.u.tbe_test.tse_loop,
2675 ent.u.tbe_test.tse_concur);
2680 fprintf(stdout, LST_NODES_TITLE);
2681 fprintf(stdout, "client\t%d\t%d\t%d\t%d\t%d\n"
2682 "server\t%d\t%d\t%d\t%d\t%d\n",
2683 ent.tbe_cli_nle.nle_nactive,
2684 ent.tbe_cli_nle.nle_nbusy,
2685 ent.tbe_cli_nle.nle_ndown,
2686 ent.tbe_cli_nle.nle_nunknown,
2687 ent.tbe_cli_nle.nle_nnode,
2688 ent.tbe_srv_nle.nle_nactive,
2689 ent.tbe_srv_nle.nle_nbusy,
2690 ent.tbe_srv_nle.nle_ndown,
2691 ent.tbe_srv_nle.nle_nunknown,
2692 ent.tbe_srv_nle.nle_nnode);
2701 lst_query_batch_ioctl(char *batch, int test, int server,
2702 int timeout, struct list_head *head)
2704 struct lstio_batch_query_args args = { 0 };
2706 args.lstio_bat_key = session_key;
2707 args.lstio_bat_testidx = test;
2708 args.lstio_bat_client = !(server);
2709 args.lstio_bat_timeout = timeout;
2710 args.lstio_bat_nmlen = strlen(batch);
2711 args.lstio_bat_namep = batch;
2712 args.lstio_bat_resultp = head;
2714 return lst_ioctl(LSTIO_BATCH_QUERY, &args, sizeof(args));
2718 lst_print_tsb_verbose(struct list_head *head,
2719 int active, int idle, int error)
2721 struct lstcon_rpc_ent *ent;
2723 list_for_each_entry(ent, head, rpe_link) {
2724 if (ent->rpe_priv[0] == 0 && active)
2727 if (ent->rpe_priv[0] != 0 && idle)
2730 if (ent->rpe_fwk_errno == 0 && error)
2733 fprintf(stdout, "%s [%s]: %s\n",
2734 libcfs_id2str(ent->rpe_peer),
2735 lst_node_state2str(ent->rpe_state),
2736 ent->rpe_rpc_errno != 0 ?
2737 strerror(ent->rpe_rpc_errno) :
2738 (ent->rpe_priv[0] > 0 ? "Running" : "Idle"));
2743 jt_lst_query_batch(int argc, char **argv)
2745 struct lstcon_test_batch_ent ent;
2746 struct list_head head;
2752 int timeout = 5; /* default 5 seconds */
2753 int delay = 5; /* default 5 seconds */
2754 int loop = 1; /* default 1 loop */
2764 static struct option query_batch_opts[] =
2766 {"timeout", required_argument, 0, 'o' },
2767 {"delay", required_argument, 0, 'd' },
2768 {"loop", required_argument, 0, 'c' },
2769 {"test", required_argument, 0, 't' },
2770 {"server", no_argument, 0, 's' },
2771 {"active", no_argument, 0, 'a' },
2772 {"idle", no_argument, 0, 'i' },
2773 {"error", no_argument, 0, 'e' },
2774 {"all", no_argument, 0, 'l' },
2778 if (session_key == 0) {
2780 "Can't find env LST_SESSION or value is not valid\n");
2785 c = getopt_long(argc, argv, "o:d:c:t:saiel",
2786 query_batch_opts, &optidx);
2788 /* Detect the end of the options. */
2794 timeout = atoi(optarg);
2797 delay = atoi(optarg);
2800 loop = atoi(optarg);
2803 test = atoi(optarg);
2809 active = verbose = 1;
2815 error = verbose = 1;
2821 lst_print_usage(argv[0]);
2826 if (test < 0 || timeout <= 0 || delay <= 0 || loop <= 0) {
2827 lst_print_usage(argv[0]);
2831 if (optind == argc) {
2832 batch = LST_DEFAULT_BATCH;
2834 } else if (optind == argc - 1) {
2835 batch = argv[optind];
2838 lst_print_usage(argv[0]);
2843 INIT_LIST_HEAD(&head);
2846 rc = lst_info_batch_ioctl(batch, test, server,
2847 &ent, NULL, NULL, NULL);
2849 fprintf(stderr, "Failed to query %s [%d]: %s\n",
2850 batch, test, strerror(errno));
2854 count = server ? ent.tbe_srv_nle.nle_nnode :
2855 ent.tbe_cli_nle.nle_nnode;
2857 fprintf(stdout, "Batch or test is empty\n");
2862 rc = lst_alloc_rpcent(&head, count, 0);
2864 fprintf(stderr, "Out of memory\n");
2868 for (i = 0; i < loop; i++) {
2869 time_t now = time(NULL);
2871 if (now - last < delay) {
2872 sleep(delay - now + last);
2878 rc = lst_query_batch_ioctl(batch, test,
2879 server, timeout, &head);
2881 fprintf(stderr, "Failed to query batch: %s\n",
2888 lst_print_tsb_verbose(&head, active, idle, error);
2892 fprintf(stdout, "%s [%d] ", batch, test);
2894 if (lstcon_rpc_stat_failure(&trans_stat, 0) != 0) {
2895 fprintf(stdout, "%d of %d nodes are unknown, ",
2896 lstcon_rpc_stat_failure(&trans_stat, 0),
2897 lstcon_rpc_stat_total(&trans_stat, 0));
2900 if (lstcon_rpc_stat_failure(&trans_stat, 0) == 0 &&
2901 lstcon_tsbqry_stat_run(&trans_stat, 0) == 0 &&
2902 lstcon_tsbqry_stat_failure(&trans_stat, 0) == 0) {
2903 fprintf(stdout, "is stopped\n");
2907 if (lstcon_rpc_stat_failure(&trans_stat, 0) == 0 &&
2908 lstcon_tsbqry_stat_idle(&trans_stat, 0) == 0 &&
2909 lstcon_tsbqry_stat_failure(&trans_stat, 0) == 0) {
2910 fprintf(stdout, "is running\n");
2914 fprintf(stdout, "stopped: %d , running: %d, failed: %d\n",
2915 lstcon_tsbqry_stat_idle(&trans_stat, 0),
2916 lstcon_tsbqry_stat_run(&trans_stat, 0),
2917 lstcon_tsbqry_stat_failure(&trans_stat, 0));
2920 lst_free_rpcent(&head);
2926 lst_parse_distribute(char *dstr, int *dist, int *span)
2932 dstr = strchr(dstr, ':');
2936 *span = atoi(dstr + 1);
2944 lst_get_bulk_param(int argc, char **argv, struct lst_test_bulk_param *bulk)
2951 bulk->blk_size = 4096;
2952 bulk->blk_opc = LST_BRW_READ;
2953 bulk->blk_flags = LST_BRW_CHECK_NONE;
2954 bulk->blk_srv_off = bulk->blk_cli_off = 0;
2957 if (strcasestr(argv[i], "check=") == argv[i] ||
2958 strcasestr(argv[i], "c=") == argv[i]) {
2959 tok = strchr(argv[i], '=') + 1;
2961 if (strcasecmp(tok, "full") == 0) {
2962 bulk->blk_flags = LST_BRW_CHECK_FULL;
2963 } else if (strcasecmp(tok, "simple") == 0) {
2964 bulk->blk_flags = LST_BRW_CHECK_SIMPLE;
2966 fprintf(stderr, "Unknow flag %s\n", tok);
2970 } else if (strcasestr(argv[i], "size=") == argv[i] ||
2971 strcasestr(argv[i], "s=") == argv[i]) {
2972 int max_size = sysconf(_SC_PAGESIZE) * LNET_MAX_IOV;
2974 tok = strchr(argv[i], '=') + 1;
2976 bulk->blk_size = strtol(tok, &end, 0);
2977 if (bulk->blk_size <= 0) {
2978 fprintf(stderr, "Invalid size %s\n", tok);
2985 if (*end == 'k' || *end == 'K')
2986 bulk->blk_size *= 1024;
2987 else if (*end == 'm' || *end == 'M')
2988 bulk->blk_size *= 1024 * 1024;
2990 if (bulk->blk_size > max_size) {
2991 fprintf(stderr, "Size exceed limitation: %d bytes\n",
2996 } else if (strcasestr(argv[i], "off=") == argv[i]) {
2999 tok = strchr(argv[i], '=') + 1;
3001 off = strtol(tok, &end, 0);
3002 /* NB: align with sizeof(__u64) to simplify page
3003 * checking implementation */
3004 if (off < 0 || off % sizeof(__u64) != 0) {
3006 "Invalid offset %s/%d, it should be "
3007 "postive value and multiple of %d\n",
3008 tok, off, (int)sizeof(__u64));
3012 /* NB: blk_srv_off is reserved so far */
3013 bulk->blk_cli_off = bulk->blk_srv_off = off;
3017 } else if (strcasecmp(argv[i], "read") == 0 ||
3018 strcasecmp(argv[i], "r") == 0) {
3019 bulk->blk_opc = LST_BRW_READ;
3021 } else if (strcasecmp(argv[i], "write") == 0 ||
3022 strcasecmp(argv[i], "w") == 0) {
3023 bulk->blk_opc = LST_BRW_WRITE;
3026 fprintf(stderr, "Unknow parameter: %s\n", argv[i]);
3037 lst_get_test_param(char *test, int argc, char **argv, void **param, int *plen)
3039 struct lst_test_bulk_param *bulk = NULL;
3042 type = lst_test_name2type(test);
3044 fprintf(stderr, "Unknow test name %s\n", test);
3053 bulk = malloc(sizeof(*bulk));
3055 fprintf(stderr, "Out of memory\n");
3059 memset(bulk, 0, sizeof(*bulk));
3061 if (lst_get_bulk_param(argc, argv, bulk) != 0) {
3067 *plen = sizeof(*bulk);
3075 /* TODO: parse more parameter */
3080 lst_add_test_ioctl(char *batch, int type, int loop, int concur,
3081 int dist, int span, char *sgrp, char *dgrp,
3082 void *param, int plen, int *retp, struct list_head *resultp)
3084 struct lstio_test_args args = { 0 };
3086 args.lstio_tes_key = session_key;
3087 args.lstio_tes_bat_nmlen = strlen(batch);
3088 args.lstio_tes_bat_name = batch;
3089 args.lstio_tes_type = type;
3090 args.lstio_tes_oneside = 0;
3091 args.lstio_tes_loop = loop;
3092 args.lstio_tes_concur = concur;
3093 args.lstio_tes_dist = dist;
3094 args.lstio_tes_span = span;
3095 args.lstio_tes_sgrp_nmlen = strlen(sgrp);
3096 args.lstio_tes_sgrp_name = sgrp;
3097 args.lstio_tes_dgrp_nmlen = strlen(dgrp);
3098 args.lstio_tes_dgrp_name = dgrp;
3099 args.lstio_tes_param_len = plen;
3100 args.lstio_tes_param = param;
3101 args.lstio_tes_retp = retp;
3102 args.lstio_tes_resultp = resultp;
3104 return lst_ioctl(LSTIO_TEST_ADD, &args, sizeof(args));
3108 jt_lst_add_test(int argc, char **argv)
3110 struct list_head head;
3130 static struct option add_test_opts[] =
3132 {"batch", required_argument, 0, 'b' },
3133 {"concurrency", required_argument, 0, 'c' },
3134 {"distribute", required_argument, 0, 'd' },
3135 {"from", required_argument, 0, 'f' },
3136 {"to", required_argument, 0, 't' },
3137 {"loop", required_argument, 0, 'l' },
3141 if (session_key == 0) {
3143 "Can't find env LST_SESSION or value is not valid\n");
3148 c = getopt_long(argc, argv, "b:c:d:f:l:t:",
3149 add_test_opts, &optidx);
3151 /* Detect the end of the options. */
3160 concur = atoi(optarg);
3169 loop = atoi(optarg);
3175 lst_print_usage(argv[0]);
3180 if (optind == argc || from == NULL || to == NULL) {
3181 lst_print_usage(argv[0]);
3185 if (concur <= 0 || concur > LST_MAX_CONCUR) {
3186 fprintf(stderr, "Invalid concurrency of test: %d\n", concur);
3191 batch = LST_DEFAULT_BATCH;
3194 rc = lst_parse_distribute(dstr, &dist, &span);
3196 fprintf(stderr, "Invalid distribution: %s\n", dstr);
3201 test = argv[optind++];
3206 type = lst_get_test_param(test, argc, argv, ¶m, &plen);
3208 fprintf(stderr, "Failed to add test (%s)\n", test);
3212 INIT_LIST_HEAD(&head);
3214 rc = lst_get_node_count(LST_OPC_GROUP, from, &fcount, NULL);
3216 fprintf(stderr, "Can't get count of nodes from %s: %s\n",
3217 from, strerror(errno));
3221 rc = lst_get_node_count(LST_OPC_GROUP, to, &tcount, NULL);
3223 fprintf(stderr, "Can't get count of nodes from %s: %s\n",
3224 to, strerror(errno));
3228 rc = lst_alloc_rpcent(&head, fcount > tcount ? fcount : tcount, 0);
3230 fprintf(stderr, "Out of memory\n");
3234 rc = lst_add_test_ioctl(batch, type, loop, concur,
3235 dist, span, from, to, param, plen, &ret, &head);
3238 fprintf(stdout, "Test was added successfully\n");
3240 fprintf(stdout, "Server group contains userland test "
3241 "nodes, old version of tcplnd can't accept "
3242 "connection request\n");
3249 lst_print_error("test", "Failed to add test: %s\n",
3254 lst_print_transerr(&head, "add test");
3256 lst_free_rpcent(&head);
3264 static command_t lst_cmdlist[] = {
3265 {"new_session", jt_lst_new_session, NULL,
3266 "Usage: lst new_session [--timeout TIME] [--force] [NAME]" },
3267 {"end_session", jt_lst_end_session, NULL,
3268 "Usage: lst end_session" },
3269 {"show_session", jt_lst_show_session, NULL,
3270 "Usage: lst show_session" },
3271 {"ping", jt_lst_ping , NULL,
3272 "Usage: lst ping [--group NAME] [--batch NAME] [--session] [--nodes IDS]" },
3273 {"add_group", jt_lst_add_group, NULL,
3274 "Usage: lst group NAME IDs [IDs]..." },
3275 {"del_group", jt_lst_del_group, NULL,
3276 "Usage: lst del_group NAME" },
3277 {"update_group", jt_lst_update_group, NULL,
3278 "Usage: lst update_group NAME [--clean] [--refresh] [--remove IDs]" },
3279 {"list_group", jt_lst_list_group, NULL,
3280 "Usage: lst list_group [--active] [--busy] [--down] [--unknown] GROUP ..." },
3281 {"stat", jt_lst_stat, NULL,
3282 "Usage: lst stat [--bw] [--rate] [--read] [--write] [--max] [--min] [--avg] "
3283 " [--mbs] [--timeout #] [--delay #] [--count #] GROUP [GROUP]" },
3284 {"show_error", jt_lst_show_error, NULL,
3285 "Usage: lst show_error NAME | IDS ..." },
3286 {"add_batch", jt_lst_add_batch, NULL,
3287 "Usage: lst add_batch NAME" },
3288 {"run", jt_lst_start_batch, NULL,
3289 "Usage: lst run [--timeout TIME] [NAME]" },
3290 {"stop", jt_lst_stop_batch, NULL,
3291 "Usage: lst stop [--force] BATCH_NAME" },
3292 {"list_batch", jt_lst_list_batch, NULL,
3293 "Usage: lst list_batch NAME [--test ID] [--server]" },
3294 {"query", jt_lst_query_batch, NULL,
3295 "Usage: lst query [--test ID] [--server] [--timeout TIME] NAME" },
3296 {"add_test", jt_lst_add_test, NULL,
3297 "Usage: lst add_test [--batch BATCH] [--loop #] [--concurrency #] "
3298 " [--distribute #:#] [--from GROUP] [--to GROUP] TEST..." },
3299 {"help", Parser_help, 0, "help" },
3304 lst_initialize(void)
3309 feats = getenv("LST_FEATURES");
3311 session_features = strtol(feats, NULL, 16);
3313 if ((session_features & ~LST_FEATS_MASK) != 0) {
3315 "Unsupported session features %x, "
3316 "only support these features so far: %x\n",
3317 (session_features & ~LST_FEATS_MASK), LST_FEATS_MASK);
3321 key = getenv("LST_SESSION");
3328 session_key = atoi(key);
3334 main(int argc, char **argv)
3340 rc = lst_initialize();
3344 rc = ptl_initialize(argc, argv);
3348 Parser_init("lst > ", lst_cmdlist);
3351 rc = Parser_execarg(argc - 1, argv + 1, lst_cmdlist);