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 = { .ses_nid = LNET_NID_ANY, .ses_stamp = -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, struct lnet_process_id **idspp)
263 rc = expand_strs(str, &head);
273 *idspp = malloc(c * sizeof(struct lnet_process_id));
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 const struct option session_opts[] = {
546 { .name = "timeout", .has_arg = required_argument, .val = 't' },
547 { .name = "force", .has_arg = no_argument, .val = 'f' },
550 if (session_key == 0) {
552 "Can't find env LST_SESSION or value is not valid\n");
558 c = getopt_long(argc, argv, "ft:",
559 session_opts, &optidx);
569 timeout = atoi(optarg);
572 lst_print_usage(argv[0]);
578 fprintf(stderr, "Invalid timeout value\n");
582 if (optind == argc - 1) {
583 name = argv[optind ++];
584 if (strlen(name) >= LST_NAME_SIZE) {
585 fprintf(stderr, "Name size is limited to %d\n",
590 } else if (optind == argc) {
591 char user[LST_NAME_SIZE];
592 char host[LST_NAME_SIZE];
593 struct passwd *pw = getpwuid(getuid());
596 snprintf(user, sizeof(user), "%d", (int)getuid());
598 snprintf(user, sizeof(user), "%s", pw->pw_name);
600 rc = gethostname(host, sizeof(host));
602 snprintf(host, sizeof(host), "unknown_host");
604 snprintf(buf, sizeof(buf), "%s@%s", user, host);
608 lst_print_usage(argv[0]);
612 rc = lst_new_session_ioctl(name, timeout, force, &session_id);
614 lst_print_error("session", "Failed to create session: %s\n",
619 fprintf(stdout, "SESSION: %s FEATURES: %x TIMEOUT: %d FORCE: %s\n",
620 name, session_features, timeout, force ? "Yes" : "No");
625 lst_session_info_ioctl(char *name, int len, int *key, unsigned *featp,
626 struct lst_sid *sid, struct lstcon_ndlist_ent *ndinfo)
628 struct lstio_session_info_args args = { 0 };
630 args.lstio_ses_idp = sid;
631 args.lstio_ses_keyp = key;
632 args.lstio_ses_featp = featp;
633 args.lstio_ses_ndinfo = ndinfo;
634 args.lstio_ses_nmlen = len;
635 args.lstio_ses_namep = name;
637 return lst_ioctl(LSTIO_SESSION_INFO, &args, sizeof(args));
641 jt_lst_show_session(int argc, char **argv)
643 struct lstcon_ndlist_ent ndinfo;
645 char name[LST_NAME_SIZE];
650 rc = lst_session_info_ioctl(name, sizeof(name), &key,
651 &feats, &sid, &ndinfo);
654 lst_print_error("session", "Failed to show session: %s\n",
659 fprintf(stdout, "%s ID: %ju@%s, KEY: %d FEATURES: %x NODES: %d\n",
660 name, (uintmax_t)sid.ses_stamp, libcfs_nid2str(sid.ses_nid),
661 key, feats, ndinfo.nle_nnode);
667 lst_end_session_ioctl(void)
669 struct lstio_session_end_args args = { 0 };
671 args.lstio_ses_key = session_key;
672 return lst_ioctl(LSTIO_SESSION_END, &args, sizeof(args));
676 jt_lst_end_session(int argc, char **argv)
680 if (session_key == 0) {
682 "Can't find env LST_SESSION or value is not valid\n");
686 rc = lst_end_session_ioctl();
689 fprintf(stdout, "session is ended\n");
694 lst_print_error("session", "Failed to end session: %s\n",
699 if (trans_stat.trs_rpc_errno != 0) {
701 "[RPC] Failed to send %d session RPCs: %s\n",
702 lstcon_rpc_stat_failure(&trans_stat, 0),
703 strerror(trans_stat.trs_rpc_errno));
706 if (trans_stat.trs_fwk_errno != 0) {
708 "[FWK] Failed to end session on %d nodes: %s\n",
709 lstcon_sesop_stat_failure(&trans_stat, 0),
710 strerror(trans_stat.trs_fwk_errno));
717 lst_ping_ioctl(char *str, int type, int timeout,
718 int count, struct lnet_process_id *ids, struct list_head *head)
720 struct lstio_debug_args args = { 0 };
722 args.lstio_dbg_key = session_key;
723 args.lstio_dbg_type = type;
724 args.lstio_dbg_flags = 0;
725 args.lstio_dbg_timeout = timeout;
726 args.lstio_dbg_nmlen = (str == NULL) ? 0: strlen(str);
727 args.lstio_dbg_namep = str;
728 args.lstio_dbg_count = count;
729 args.lstio_dbg_idsp = ids;
730 args.lstio_dbg_resultp = head;
732 return lst_ioctl (LSTIO_DEBUG, &args, sizeof(args));
736 lst_get_node_count(int type, char *str, int *countp,
737 struct lnet_process_id **idspp)
739 char buf[LST_NAME_SIZE];
740 struct lstcon_test_batch_ent ent;
741 struct lstcon_ndlist_ent *entp = &ent.tbe_cli_nle;
748 case LST_OPC_SESSION:
749 rc = lst_session_info_ioctl(buf, LST_NAME_SIZE,
750 &key, &feats, &sid, entp);
753 case LST_OPC_BATCHSRV:
754 entp = &ent.tbe_srv_nle;
755 case LST_OPC_BATCHCLI:
756 rc = lst_info_batch_ioctl(str, 0, 0, &ent, NULL, NULL, NULL);
760 rc = lst_info_group_ioctl(str, entp, NULL, NULL, NULL);
764 rc = lst_parse_nids(str, &entp->nle_nnode, idspp) < 0 ? -1 : 0;
773 *countp = entp->nle_nnode;
779 jt_lst_ping(int argc, char **argv)
781 struct list_head head;
782 struct lnet_process_id *ids = NULL;
783 struct lstcon_rpc_ent *ent = NULL;
793 static const struct option ping_opts[] = {
794 { .name = "session", .has_arg = no_argument, .val = 's' },
795 { .name = "server", .has_arg = no_argument, .val = 'v' },
796 { .name = "batch", .has_arg = required_argument, .val = 'b' },
797 { .name = "group", .has_arg = required_argument, .val = 'g' },
798 { .name = "nodes", .has_arg = required_argument, .val = 'n' },
799 { .name = "timeout", .has_arg = required_argument, .val = 't' },
802 if (session_key == 0) {
804 "Can't find env LST_SESSION or value is not valid\n");
810 c = getopt_long(argc, argv, "g:b:n:t:sv",
818 type = LST_OPC_SESSION;
822 type = LST_OPC_GROUP;
827 type = LST_OPC_BATCHCLI;
832 type = LST_OPC_NODES;
837 timeout = atoi(optarg);
845 lst_print_usage(argv[0]);
850 if (type == 0 || timeout <= 0 || optind != argc) {
851 lst_print_usage(argv[0]);
855 if (type == LST_OPC_BATCHCLI && server)
856 type = LST_OPC_BATCHSRV;
858 rc = lst_get_node_count(type, str, &count, &ids);
860 fprintf(stderr, "Failed to get count of nodes from %s: %s\n",
861 (str == NULL) ? "session" : str, strerror(errno));
865 INIT_LIST_HEAD(&head);
867 rc = lst_alloc_rpcent(&head, count, LST_NAME_SIZE);
869 fprintf(stderr, "Out of memory\n");
874 fprintf(stdout, "Target %s is empty\n",
875 (str == NULL) ? "session" : str);
879 rc = lst_ping_ioctl(str, type, timeout, count, ids, &head);
880 if (rc == -1) { /* local failure */
881 lst_print_error("debug", "Failed to ping %s: %s\n",
882 (str == NULL) ? "session" : str,
888 /* ignore RPC errors and framwork errors */
889 list_for_each_entry(ent, &head, rpe_link) {
890 fprintf(stdout, "\t%s: %s [session: %s id: %s]\n",
891 libcfs_id2str(ent->rpe_peer),
892 lst_node_state2str(ent->rpe_state),
893 (ent->rpe_state == LST_NODE_ACTIVE ||
894 ent->rpe_state == LST_NODE_BUSY) ?
895 (ent->rpe_rpc_errno == 0 ?
896 &ent->rpe_payload[0] : "Unknown") :
897 "<NULL>", libcfs_nid2str(ent->rpe_sid.ses_nid));
901 lst_free_rpcent(&head);
911 lst_add_nodes_ioctl(char *name, int count, struct lnet_process_id *ids,
912 unsigned *featp, struct list_head *resultp)
914 struct lstio_group_nodes_args args = { 0 };
916 args.lstio_grp_key = session_key;
917 args.lstio_grp_nmlen = strlen(name);
918 args.lstio_grp_namep = name;
919 args.lstio_grp_count = count;
920 args.lstio_grp_featp = featp;
921 args.lstio_grp_idsp = ids;
922 args.lstio_grp_resultp = resultp;
924 return lst_ioctl(LSTIO_NODES_ADD, &args, sizeof(args));
928 lst_del_group_ioctl(char *name)
930 struct lstio_group_del_args args = { 0 };
932 args.lstio_grp_key = session_key;
933 args.lstio_grp_nmlen = strlen(name);
934 args.lstio_grp_namep = name;
936 return lst_ioctl(LSTIO_GROUP_DEL, &args, sizeof(args));
940 lst_del_group(char *grp_name)
944 rc = lst_del_group_ioctl(grp_name);
946 fprintf(stdout, "Group is deleted\n");
951 lst_print_error("group", "Failed to delete group: %s\n",
956 fprintf(stderr, "Group is deleted with some errors\n");
958 if (trans_stat.trs_rpc_errno != 0) {
960 "[RPC] Failed to send %d end session RPCs: %s\n",
961 lstcon_rpc_stat_failure(&trans_stat, 0),
962 strerror(trans_stat.trs_rpc_errno));
965 if (trans_stat.trs_fwk_errno != 0) {
967 "[FWK] Failed to end session on %d nodes: %s\n",
968 lstcon_sesop_stat_failure(&trans_stat, 0),
969 strerror(trans_stat.trs_fwk_errno));
976 lst_add_group_ioctl(char *name)
978 struct lstio_group_add_args args = { 0 };
980 args.lstio_grp_key = session_key;
981 args.lstio_grp_nmlen = strlen(name);
982 args.lstio_grp_namep = name;
984 return lst_ioctl(LSTIO_GROUP_ADD, &args, sizeof(args));
988 jt_lst_add_group(int argc, char **argv)
990 struct list_head head;
991 struct lnet_process_id *ids;
993 unsigned feats = session_features;
997 bool nodes_added = false;
999 if (session_key == 0) {
1001 "Can't find env LST_SESSION or value is not valid\n");
1006 lst_print_usage(argv[0]);
1011 if (strlen(name) >= LST_NAME_SIZE) {
1012 fprintf(stderr, "Name length is limited to %d\n",
1017 rc = lst_add_group_ioctl(name);
1019 lst_print_error("group", "Failed to add group %s: %s\n",
1020 name, strerror(errno));
1024 INIT_LIST_HEAD(&head);
1026 for (i = 2; i < argc; i++) {
1027 /* parse address list */
1028 rc = lst_parse_nids(argv[i], &count, &ids);
1030 fprintf(stderr, "Ignore invalid id list %s\n",
1038 rc = lst_alloc_rpcent(&head, count, 0);
1040 fprintf(stderr, "Out of memory\n");
1046 rc = lst_add_nodes_ioctl(name, count, ids, &feats, &head);
1053 fprintf(stdout, "%s are added to session\n", argv[i]);
1057 if ((feats & session_features) != session_features) {
1059 "Warning, this session will run with "
1060 "compatible mode because some test nodes "
1061 "might not understand these features: %x\n",
1062 (~feats & session_features));
1065 lst_free_rpcent(&head);
1070 * The selftest kernel module expects that a group should
1071 * have at least one node, since it doesn't make sense for
1072 * an empty group to be added to a test.
1075 "No nodes added successfully, deleting group %s\n",
1077 rc = lst_del_group(name);
1080 "Failed to delete group %s."
1081 " Group is empty.\n", name);
1089 lst_print_error("group", "Failed to add nodes %s: %s\n",
1090 argv[i], strerror(errno));
1093 if (trans_stat.trs_fwk_errno == EPROTO) {
1095 "test nodes might have different LST "
1096 "features, please disable some features by "
1097 "setting LST_FEATURES\n");
1100 lst_print_transerr(&head, "create session");
1103 lst_free_rpcent(&head);
1107 "No nodes added successfully, deleting group %s\n",
1109 if (lst_del_group(name) != 0) {
1111 "Failed to delete group %s."
1112 " Group is empty.\n", name);
1120 jt_lst_del_group(int argc, char **argv)
1124 if (session_key == 0) {
1126 "Can't find env LST_SESSION or value is not valid\n");
1131 lst_print_usage(argv[0]);
1135 rc = lst_del_group(argv[1]);
1141 lst_update_group_ioctl(int opc, char *name, int clean, int count,
1142 struct lnet_process_id *ids, struct list_head *resultp)
1144 struct lstio_group_update_args args = { 0 };
1146 args.lstio_grp_key = session_key;
1147 args.lstio_grp_opc = opc;
1148 args.lstio_grp_args = clean;
1149 args.lstio_grp_nmlen = strlen(name);
1150 args.lstio_grp_namep = name;
1151 args.lstio_grp_count = count;
1152 args.lstio_grp_idsp = ids;
1153 args.lstio_grp_resultp = resultp;
1155 return lst_ioctl(LSTIO_GROUP_UPDATE, &args, sizeof(args));
1159 jt_lst_update_group(int argc, char **argv)
1161 struct list_head head;
1162 struct lnet_process_id *ids = NULL;
1172 static const struct option update_group_opts[] = {
1173 { .name = "refresh", .has_arg = no_argument, .val = 'f' },
1174 { .name = "clean", .has_arg = required_argument, .val = 'c' },
1175 { .name = "remove", .has_arg = required_argument, .val = 'r' },
1178 if (session_key == 0) {
1180 "Can't find env LST_SESSION or value is not valid\n");
1185 c = getopt_long(argc, argv, "fc:r:",
1186 update_group_opts, &optidx);
1188 /* Detect the end of the options. */
1195 lst_print_usage(argv[0]);
1198 opc = LST_GROUP_REFRESH;
1203 lst_print_usage(argv[0]);
1206 opc = LST_GROUP_RMND;
1211 clean = lst_node_str2state(optarg);
1212 if (opc != 0 || clean <= 0) {
1213 lst_print_usage(argv[0]);
1216 opc = LST_GROUP_CLEAN;
1220 lst_print_usage(argv[0]);
1225 /* no OPC or group is specified */
1226 if (opc == 0 || optind != argc - 1) {
1227 lst_print_usage(argv[0]);
1233 INIT_LIST_HEAD(&head);
1235 if (opc == LST_GROUP_RMND || opc == LST_GROUP_REFRESH) {
1236 rc = lst_get_node_count(opc == LST_GROUP_RMND ? LST_OPC_NODES :
1238 opc == LST_GROUP_RMND ? str : grp,
1242 fprintf(stderr, "Can't get count of nodes from %s: %s\n",
1243 opc == LST_GROUP_RMND ? str : grp,
1248 rc = lst_alloc_rpcent(&head, count, 0);
1250 fprintf(stderr, "Out of memory\n");
1257 rc = lst_update_group_ioctl(opc, grp, clean, count, ids, &head);
1263 lst_free_rpcent(&head);
1268 lst_free_rpcent(&head);
1269 lst_print_error("group", "Failed to update group: %s\n",
1274 lst_print_transerr(&head, "Updating group");
1276 lst_free_rpcent(&head);
1282 lst_list_group_ioctl(int len, char *name, int idx)
1284 struct lstio_group_list_args args = { 0 };
1286 args.lstio_grp_key = session_key;
1287 args.lstio_grp_idx = idx;
1288 args.lstio_grp_nmlen = len;
1289 args.lstio_grp_namep = name;
1291 return lst_ioctl(LSTIO_GROUP_LIST, &args, sizeof(args));
1295 lst_info_group_ioctl(char *name, struct lstcon_ndlist_ent *gent,
1296 int *idx, int *count, struct lstcon_node_ent *dents)
1298 struct lstio_group_info_args args = { 0 };
1300 args.lstio_grp_key = session_key;
1301 args.lstio_grp_nmlen = strlen(name);
1302 args.lstio_grp_namep = name;
1303 args.lstio_grp_entp = gent;
1304 args.lstio_grp_idxp = idx;
1305 args.lstio_grp_ndentp = count;
1306 args.lstio_grp_dentsp = dents;
1308 return lst_ioctl(LSTIO_GROUP_INFO, &args, sizeof(args));
1312 lst_list_group_all(void)
1314 char name[LST_NAME_SIZE];
1318 /* no group is specified, list name of all groups */
1319 for (i = 0; ; i++) {
1320 rc = lst_list_group_ioctl(LST_NAME_SIZE, name, i);
1322 fprintf(stdout, "%d) %s\n", i + 1, name);
1326 if (errno == ENOENT)
1329 lst_print_error("group", "Failed to list group: %s\n",
1334 fprintf(stdout, "Total %d groups\n", i);
1339 #define LST_NODES_TITLE "\tACTIVE\tBUSY\tDOWN\tUNKNOWN\tTOTAL\n"
1342 jt_lst_list_group(int argc, char **argv)
1344 struct lstcon_ndlist_ent gent;
1345 struct lstcon_node_ent *dents;
1360 static const struct option list_group_opts[] = {
1361 { .name = "active", .has_arg = no_argument, .val = 'a' },
1362 { .name = "busy", .has_arg = no_argument, .val = 'b' },
1363 { .name = "down", .has_arg = no_argument, .val = 'd' },
1364 { .name = "unknown", .has_arg = no_argument, .val = 'u' },
1365 { .name = "all", .has_arg = no_argument, .val = 'l' },
1366 { .name = NULL, } };
1368 if (session_key == 0) {
1370 "Can't find env LST_SESSION or value is not valid\n");
1375 c = getopt_long(argc, argv, "abdul",
1376 list_group_opts, &optidx);
1383 verbose = active = 1;
1395 verbose = unknown = 1;
1402 lst_print_usage(argv[0]);
1407 if (optind == argc) {
1408 /* no group is specified, list name of all groups */
1409 rc = lst_list_group_all();
1415 fprintf(stdout, LST_NODES_TITLE);
1417 /* list nodes in specified groups */
1418 for (i = optind; i < argc; i++) {
1419 rc = lst_info_group_ioctl(argv[i], &gent, NULL, NULL, NULL);
1421 if (errno == ENOENT) {
1426 lst_print_error("group", "Failed to list group\n",
1432 fprintf(stdout, "\t%d\t%d\t%d\t%d\t%d\t%s\n",
1433 gent.nle_nactive, gent.nle_nbusy,
1434 gent.nle_ndown, gent.nle_nunknown,
1435 gent.nle_nnode, argv[i]);
1439 fprintf(stdout, "Group [ %s ]\n", argv[i]);
1441 if (gent.nle_nnode == 0) {
1442 fprintf(stdout, "No nodes found [ %s ]\n", argv[i]);
1446 count = gent.nle_nnode;
1448 dents = malloc(count * sizeof(struct lstcon_node_ent));
1449 if (dents == NULL) {
1450 fprintf(stderr, "Failed to malloc: %s\n",
1456 rc = lst_info_group_ioctl(argv[i], &gent, &index, &count, dents);
1458 lst_print_error("group", "Failed to list group: %s\n",
1464 for (j = 0, c = 0; j < count; j++) {
1466 ((active && dents[j].nde_state == LST_NODE_ACTIVE) ||
1467 (busy && dents[j].nde_state == LST_NODE_BUSY) ||
1468 (down && dents[j].nde_state == LST_NODE_DOWN) ||
1469 (unknown && dents[j].nde_state == LST_NODE_UNKNOWN))) {
1471 fprintf(stdout, "\t%s: %s\n",
1472 libcfs_id2str(dents[j].nde_id),
1473 lst_node_state2str(dents[j].nde_state));
1478 fprintf(stdout, "Total %d nodes [ %s ]\n", c, argv[i]);
1487 lst_stat_ioctl(char *name, int count, struct lnet_process_id *idsp,
1488 int timeout, struct list_head *resultp)
1490 struct lstio_stat_args args = { 0 };
1492 args.lstio_sta_key = session_key;
1493 args.lstio_sta_timeout = timeout;
1494 args.lstio_sta_nmlen = strlen(name);
1495 args.lstio_sta_namep = name;
1496 args.lstio_sta_count = count;
1497 args.lstio_sta_idsp = idsp;
1498 args.lstio_sta_resultp = resultp;
1500 return lst_ioctl(LSTIO_STAT_QUERY, &args, sizeof(args));
1504 struct list_head srp_link;
1507 struct lnet_process_id *srp_ids;
1508 struct list_head srp_result[2];
1509 } lst_stat_req_param_t;
1512 lst_stat_req_param_free(lst_stat_req_param_t *srp)
1516 for (i = 0; i < 2; i++)
1517 lst_free_rpcent(&srp->srp_result[i]);
1519 if (srp->srp_ids != NULL)
1526 lst_stat_req_param_alloc(char *name, lst_stat_req_param_t **srpp, int save_old)
1528 lst_stat_req_param_t *srp = NULL;
1529 int count = save_old ? 2 : 1;
1533 srp = malloc(sizeof(*srp));
1537 memset(srp, 0, sizeof(*srp));
1538 INIT_LIST_HEAD(&srp->srp_result[0]);
1539 INIT_LIST_HEAD(&srp->srp_result[1]);
1541 rc = lst_get_node_count(LST_OPC_GROUP, name,
1542 &srp->srp_count, NULL);
1543 if (rc != 0 && errno == ENOENT) {
1544 rc = lst_get_node_count(LST_OPC_NODES, name,
1545 &srp->srp_count, &srp->srp_ids);
1550 "Failed to get count of nodes from %s: %s\n",
1551 name, strerror(errno));
1552 lst_stat_req_param_free(srp);
1557 srp->srp_name = name;
1559 for (i = 0; i < count; i++) {
1560 rc = lst_alloc_rpcent(&srp->srp_result[i], srp->srp_count,
1561 sizeof(struct sfw_counters) +
1562 sizeof(struct srpc_counters) +
1563 sizeof(struct lnet_counters));
1565 fprintf(stderr, "Out of memory\n");
1575 lst_stat_req_param_free(srp);
1583 } lst_srpc_stat_result;
1585 #define LST_LNET_AVG 0
1586 #define LST_LNET_MIN 1
1587 #define LST_LNET_MAX 2
1590 float lnet_avg_sndrate;
1591 float lnet_min_sndrate;
1592 float lnet_max_sndrate;
1593 float lnet_total_sndrate;
1595 float lnet_avg_rcvrate;
1596 float lnet_min_rcvrate;
1597 float lnet_max_rcvrate;
1598 float lnet_total_rcvrate;
1600 float lnet_avg_sndperf;
1601 float lnet_min_sndperf;
1602 float lnet_max_sndperf;
1603 float lnet_total_sndperf;
1605 float lnet_avg_rcvperf;
1606 float lnet_min_rcvperf;
1607 float lnet_max_rcvperf;
1608 float lnet_total_rcvperf;
1610 int lnet_stat_count;
1611 } lst_lnet_stat_result_t;
1613 lst_lnet_stat_result_t lnet_stat_result;
1616 lst_lnet_stat_value(int bw, int send, int off)
1620 p = bw ? &lnet_stat_result.lnet_avg_sndperf :
1621 &lnet_stat_result.lnet_avg_sndrate;
1632 lst_timeval_diff(struct timeval *tv1,
1633 struct timeval *tv2, struct timeval *df)
1635 if (tv1->tv_usec >= tv2->tv_usec) {
1636 df->tv_sec = tv1->tv_sec - tv2->tv_sec;
1637 df->tv_usec = tv1->tv_usec - tv2->tv_usec;
1641 df->tv_sec = tv1->tv_sec - 1 - tv2->tv_sec;
1642 df->tv_usec = tv1->tv_usec + 1000000 - tv2->tv_usec;
1648 lst_cal_lnet_stat(float delta, struct lnet_counters *lnet_new,
1649 struct lnet_counters *lnet_old, int mbs)
1653 unsigned int unit_divisor;
1655 unit_divisor = (mbs) ? (1000 * 1000) : (1024 * 1024);
1656 perf = (float)(lnet_new->send_length -
1657 lnet_old->send_length) / unit_divisor / delta;
1658 lnet_stat_result.lnet_total_sndperf += perf;
1660 if (lnet_stat_result.lnet_min_sndperf > perf ||
1661 lnet_stat_result.lnet_min_sndperf == 0)
1662 lnet_stat_result.lnet_min_sndperf = perf;
1664 if (lnet_stat_result.lnet_max_sndperf < perf)
1665 lnet_stat_result.lnet_max_sndperf = perf;
1667 perf = (float)(lnet_new->recv_length -
1668 lnet_old->recv_length) / unit_divisor / delta;
1669 lnet_stat_result.lnet_total_rcvperf += perf;
1671 if (lnet_stat_result.lnet_min_rcvperf > perf ||
1672 lnet_stat_result.lnet_min_rcvperf == 0)
1673 lnet_stat_result.lnet_min_rcvperf = perf;
1675 if (lnet_stat_result.lnet_max_rcvperf < perf)
1676 lnet_stat_result.lnet_max_rcvperf = perf;
1678 rate = (lnet_new->send_count - lnet_old->send_count) / delta;
1679 lnet_stat_result.lnet_total_sndrate += rate;
1681 if (lnet_stat_result.lnet_min_sndrate > rate ||
1682 lnet_stat_result.lnet_min_sndrate == 0)
1683 lnet_stat_result.lnet_min_sndrate = rate;
1685 if (lnet_stat_result.lnet_max_sndrate < rate)
1686 lnet_stat_result.lnet_max_sndrate = rate;
1688 rate = (lnet_new->recv_count - lnet_old->recv_count) / delta;
1689 lnet_stat_result.lnet_total_rcvrate += rate;
1691 if (lnet_stat_result.lnet_min_rcvrate > rate ||
1692 lnet_stat_result.lnet_min_rcvrate == 0)
1693 lnet_stat_result.lnet_min_rcvrate = rate;
1695 if (lnet_stat_result.lnet_max_rcvrate < rate)
1696 lnet_stat_result.lnet_max_rcvrate = rate;
1698 lnet_stat_result.lnet_stat_count++;
1700 lnet_stat_result.lnet_avg_sndrate = lnet_stat_result.lnet_total_sndrate /
1701 lnet_stat_result.lnet_stat_count;
1702 lnet_stat_result.lnet_avg_rcvrate = lnet_stat_result.lnet_total_rcvrate /
1703 lnet_stat_result.lnet_stat_count;
1705 lnet_stat_result.lnet_avg_sndperf = lnet_stat_result.lnet_total_sndperf /
1706 lnet_stat_result.lnet_stat_count;
1707 lnet_stat_result.lnet_avg_rcvperf = lnet_stat_result.lnet_total_rcvperf /
1708 lnet_stat_result.lnet_stat_count;
1712 lst_print_lnet_stat(char *name, int bwrt, int rdwr, int type, int mbs)
1722 if (lnet_stat_result.lnet_stat_count == 0)
1725 units = (mbs) ? "MB/s " : "MiB/s ";
1727 if (bwrt == 1) /* bw only */
1730 if (bwrt == 2) /* rates only */
1733 if (rdwr == 1) /* recv only */
1736 if (rdwr == 2) /* send only */
1739 for (i = start1; i <= end1; i++) {
1740 fprintf(stdout, "[LNet %s of %s]\n",
1741 i == 0 ? "Rates" : "Bandwidth", name);
1743 for (j = start2; j <= end2; j++) {
1744 fprintf(stdout, "[%c] ", j == 0 ? 'R' : 'W');
1746 if ((type & 1) != 0) {
1747 fprintf(stdout, i == 0 ? "Avg: %-8.0f RPC/s " :
1749 lst_lnet_stat_value(i, j, 0), units);
1752 if ((type & 2) != 0) {
1753 fprintf(stdout, i == 0 ? "Min: %-8.0f RPC/s " :
1755 lst_lnet_stat_value(i, j, 1), units);
1758 if ((type & 4) != 0) {
1759 fprintf(stdout, i == 0 ? "Max: %-8.0f RPC/s" :
1761 lst_lnet_stat_value(i, j, 2), units);
1764 fprintf(stdout, "\n");
1770 lst_print_stat(char *name, struct list_head *resultp,
1771 int idx, int lnet, int bwrt, int rdwr, int type,
1774 struct list_head tmp[2];
1775 struct lstcon_rpc_ent *new;
1776 struct lstcon_rpc_ent *old;
1777 struct sfw_counters *sfwk_new;
1778 struct sfw_counters *sfwk_old;
1779 struct srpc_counters *srpc_new;
1780 struct srpc_counters *srpc_old;
1781 struct lnet_counters *lnet_new;
1782 struct lnet_counters *lnet_old;
1786 INIT_LIST_HEAD(&tmp[0]);
1787 INIT_LIST_HEAD(&tmp[1]);
1789 memset(&lnet_stat_result, 0, sizeof(lnet_stat_result));
1791 while (!list_empty(&resultp[idx])) {
1792 if (list_empty(&resultp[1 - idx])) {
1793 fprintf(stderr, "Group is changed, re-run stat\n");
1797 new = list_entry(resultp[idx].next, struct lstcon_rpc_ent,
1799 old = list_entry(resultp[1 - idx].next, struct lstcon_rpc_ent,
1802 /* first time get stats result, can't calculate diff */
1803 if (new->rpe_peer.nid == LNET_NID_ANY)
1806 if (new->rpe_peer.nid != old->rpe_peer.nid ||
1807 new->rpe_peer.pid != old->rpe_peer.pid) {
1808 /* Something wrong. i.e, somebody change the group */
1812 list_del(&new->rpe_link);
1813 list_add_tail(&new->rpe_link, &tmp[idx]);
1815 list_del(&old->rpe_link);
1816 list_add_tail(&old->rpe_link, &tmp[1 - idx]);
1818 if (new->rpe_rpc_errno != 0 || new->rpe_fwk_errno != 0 ||
1819 old->rpe_rpc_errno != 0 || old->rpe_fwk_errno != 0) {
1824 sfwk_new = (struct sfw_counters *)&new->rpe_payload[0];
1825 sfwk_old = (struct sfw_counters *)&old->rpe_payload[0];
1827 srpc_new = (struct srpc_counters *)((char *)sfwk_new + sizeof(*sfwk_new));
1828 srpc_old = (struct srpc_counters *)((char *)sfwk_old + sizeof(*sfwk_old));
1830 lnet_new = (struct lnet_counters *)((char *)srpc_new + sizeof(*srpc_new));
1831 lnet_old = (struct lnet_counters *)((char *)srpc_old + sizeof(*srpc_old));
1833 /* Prior to version 2.3, the running_ms field was a counter for
1834 * the number of running tests. We are looking at this value
1835 * to determine if it is a millisecond timestamep (>= 2.3) or a
1836 * test counter (< 2.3). The number 500 is being used for this
1837 * barrier as the test counter should never get this high, and
1838 * the timestamp should never get this low. */
1840 if (sfwk_new->running_ms > 500) {
1841 /* use the timestamp from the remote node, not our
1842 * rpe_stamp from when we copied up the data out of
1845 delta = (float) (sfwk_new->running_ms -
1846 sfwk_old->running_ms) / 1000;
1850 lst_timeval_diff(&new->rpe_stamp, &old->rpe_stamp, &tv);
1851 delta = tv.tv_sec + (float)tv.tv_usec / 1000000;
1854 if (!lnet) /* TODO */
1857 lst_cal_lnet_stat(delta, lnet_new, lnet_old, mbs);
1860 list_splice(&tmp[idx], &resultp[idx]);
1861 list_splice(&tmp[1 - idx], &resultp[1 - idx]);
1864 fprintf(stdout, "Failed to stat on %d nodes\n", errcount);
1866 if (!lnet) /* TODO */
1869 lst_print_lnet_stat(name, bwrt, rdwr, type, mbs);
1873 jt_lst_stat(int argc, char **argv)
1875 struct list_head head;
1876 lst_stat_req_param_t *srp;
1879 int timeout = 5; /* default timeout, 5 sec */
1880 int delay = 5; /* default delay, 5 sec */
1881 int count = -1; /* run forever */
1882 int lnet = 1; /* lnet stat by default */
1889 int mbs = 0; /* report as MB/s */
1891 static const struct option stat_opts[] = {
1892 { .name = "timeout", .has_arg = required_argument, .val = 't' },
1893 { .name = "delay", .has_arg = required_argument, .val = 'd' },
1894 { .name = "count", .has_arg = required_argument, .val = 'o' },
1895 { .name = "lnet", .has_arg = no_argument, .val = 'l' },
1896 { .name = "rpc", .has_arg = no_argument, .val = 'c' },
1897 { .name = "bw", .has_arg = no_argument, .val = 'b' },
1898 { .name = "rate", .has_arg = no_argument, .val = 'a' },
1899 { .name = "read", .has_arg = no_argument, .val = 'r' },
1900 { .name = "write", .has_arg = no_argument, .val = 'w' },
1901 { .name = "avg", .has_arg = no_argument, .val = 'g' },
1902 { .name = "min", .has_arg = no_argument, .val = 'n' },
1903 { .name = "max", .has_arg = no_argument, .val = 'x' },
1904 { .name = "mbs", .has_arg = no_argument, .val = 'm' },
1907 if (session_key == 0) {
1909 "Can't find env LST_SESSION or value is not valid\n");
1914 c = getopt_long(argc, argv, "t:d:lcbarwgnxm", stat_opts,
1922 timeout = atoi(optarg);
1925 delay = atoi(optarg);
1928 count = atoi(optarg);
1974 lst_print_usage(argv[0]);
1979 if (optind == argc) {
1980 lst_print_usage(argv[0]);
1984 if (timeout <= 0 || delay <= 0) {
1985 fprintf(stderr, "Invalid timeout or delay value\n");
1990 fprintf(stderr, "Invalid count value\n");
1994 /* extra count to get first data point */
1998 INIT_LIST_HEAD(&head);
2000 while (optind < argc) {
2001 rc = lst_stat_req_param_alloc(argv[optind++], &srp, 1);
2005 list_add_tail(&srp->srp_link, &head);
2009 time_t now = time(NULL);
2011 if (now - last < delay) {
2012 sleep(delay - now + last);
2017 list_for_each_entry(srp, &head, srp_link) {
2018 rc = lst_stat_ioctl(srp->srp_name,
2019 srp->srp_count, srp->srp_ids,
2020 timeout, &srp->srp_result[idx]);
2022 lst_print_error("stat", "Failed to stat %s: %s\n",
2023 srp->srp_name, strerror(errno));
2027 lst_print_stat(srp->srp_name, srp->srp_result,
2028 idx, lnet, bwrt, rdwr, type, mbs);
2030 lst_reset_rpcent(&srp->srp_result[1 - idx]);
2037 } while (count == -1 || count > 0);
2040 while (!list_empty(&head)) {
2041 srp = list_entry(head.next, lst_stat_req_param_t, srp_link);
2043 list_del(&srp->srp_link);
2044 lst_stat_req_param_free(srp);
2051 jt_lst_show_error(int argc, char **argv)
2053 struct list_head head;
2054 lst_stat_req_param_t *srp;
2055 struct lstcon_rpc_ent *ent;
2056 struct sfw_counters *sfwk;
2057 struct srpc_counters *srpc;
2064 static const struct option show_error_opts[] = {
2065 { .name = "session", .has_arg = no_argument, .val = 's' },
2066 { .name = NULL, } };
2068 if (session_key == 0) {
2070 "Can't find env LST_SESSION or value is not valid\n");
2075 c = getopt_long(argc, argv, "s", show_error_opts, &optidx);
2086 lst_print_usage(argv[0]);
2091 if (optind == argc) {
2092 lst_print_usage(argv[0]);
2096 INIT_LIST_HEAD(&head);
2098 while (optind < argc) {
2099 rc = lst_stat_req_param_alloc(argv[optind++], &srp, 0);
2103 list_add_tail(&srp->srp_link, &head);
2106 list_for_each_entry(srp, &head, srp_link) {
2107 rc = lst_stat_ioctl(srp->srp_name, srp->srp_count,
2108 srp->srp_ids, 10, &srp->srp_result[0]);
2111 lst_print_error(srp->srp_name, "Failed to show errors of %s: %s\n",
2112 srp->srp_name, strerror(errno));
2116 fprintf(stdout, "%s:\n", srp->srp_name);
2120 list_for_each_entry(ent, &srp->srp_result[0], rpe_link) {
2121 if (ent->rpe_rpc_errno != 0) {
2123 fprintf(stderr, "RPC failure, can't show error on %s\n",
2124 libcfs_id2str(ent->rpe_peer));
2128 if (ent->rpe_fwk_errno != 0) {
2130 fprintf(stderr, "Framework failure, can't show error on %s\n",
2131 libcfs_id2str(ent->rpe_peer));
2135 sfwk = (struct sfw_counters *)&ent->rpe_payload[0];
2136 srpc = (struct srpc_counters *)((char *)sfwk + sizeof(*sfwk));
2138 if (srpc->errors == 0 &&
2139 sfwk->brw_errors == 0 && sfwk->ping_errors == 0)
2143 sfwk->brw_errors == 0 && sfwk->ping_errors == 0)
2148 fprintf(stderr, "%s: [Session %d brw errors, %d ping errors]%c",
2149 libcfs_id2str(ent->rpe_peer),
2150 sfwk->brw_errors, sfwk->ping_errors,
2151 show_rpc ? ' ' : '\n');
2156 fprintf(stderr, "[RPC: %d errors, %d dropped, %d expired]\n",
2157 srpc->errors, srpc->rpcs_dropped, srpc->rpcs_expired);
2160 fprintf(stdout, "Total %d error nodes in %s\n", ecount, srp->srp_name);
2163 while (!list_empty(&head)) {
2164 srp = list_entry(head.next, lst_stat_req_param_t, srp_link);
2166 list_del(&srp->srp_link);
2167 lst_stat_req_param_free(srp);
2174 lst_add_batch_ioctl(char *name)
2176 struct lstio_batch_add_args args = { 0 };
2178 args.lstio_bat_key = session_key;
2179 args.lstio_bat_nmlen = strlen(name);
2180 args.lstio_bat_namep = name;
2182 return lst_ioctl (LSTIO_BATCH_ADD, &args, sizeof(args));
2186 jt_lst_add_batch(int argc, char **argv)
2191 if (session_key == 0) {
2193 "Can't find env LST_SESSION or value is not valid\n");
2198 lst_print_usage(argv[0]);
2203 if (strlen(name) >= LST_NAME_SIZE) {
2204 fprintf(stderr, "Name length is limited to %d\n",
2209 rc = lst_add_batch_ioctl(name);
2213 lst_print_error("batch", "Failed to create batch: %s\n",
2220 lst_start_batch_ioctl(char *name, int timeout, struct list_head *resultp)
2222 struct lstio_batch_run_args args = { 0 };
2224 args.lstio_bat_key = session_key;
2225 args.lstio_bat_timeout = timeout;
2226 args.lstio_bat_nmlen = strlen(name);
2227 args.lstio_bat_namep = name;
2228 args.lstio_bat_resultp = resultp;
2230 return lst_ioctl(LSTIO_BATCH_START, &args, sizeof(args));
2234 jt_lst_start_batch(int argc, char **argv)
2236 struct list_head head;
2244 static const struct option start_batch_opts[] = {
2245 { .name = "timeout", .has_arg = required_argument, .val = 't' },
2248 if (session_key == 0) {
2250 "Can't find env LST_SESSION or value is not valid\n");
2255 c = getopt_long(argc, argv, "t:",
2256 start_batch_opts, &optidx);
2258 /* Detect the end of the options. */
2264 timeout = atoi(optarg);
2267 lst_print_usage(argv[0]);
2272 if (optind == argc) {
2273 batch = LST_DEFAULT_BATCH;
2275 } else if (optind == argc - 1) {
2276 batch = argv[optind];
2279 lst_print_usage(argv[0]);
2283 rc = lst_get_node_count(LST_OPC_BATCHCLI, batch, &count, NULL);
2285 fprintf(stderr, "Failed to get count of nodes from %s: %s\n",
2286 batch, strerror(errno));
2290 INIT_LIST_HEAD(&head);
2292 rc = lst_alloc_rpcent(&head, count, 0);
2294 fprintf(stderr, "Out of memory\n");
2298 rc = lst_start_batch_ioctl(batch, timeout, &head);
2301 fprintf(stdout, "%s is running now\n", batch);
2302 lst_free_rpcent(&head);
2307 lst_print_error("batch", "Failed to start batch: %s\n",
2309 lst_free_rpcent(&head);
2313 lst_print_transerr(&head, "Run batch");
2315 lst_free_rpcent(&head);
2321 lst_stop_batch_ioctl(char *name, int force, struct list_head *resultp)
2323 struct lstio_batch_stop_args args = { 0 };
2325 args.lstio_bat_key = session_key;
2326 args.lstio_bat_force = force;
2327 args.lstio_bat_nmlen = strlen(name);
2328 args.lstio_bat_namep = name;
2329 args.lstio_bat_resultp = resultp;
2331 return lst_ioctl(LSTIO_BATCH_STOP, &args, sizeof(args));
2335 jt_lst_stop_batch(int argc, char **argv)
2337 struct list_head head;
2345 static const struct option stop_batch_opts[] = {
2346 { .name = "force", .has_arg = no_argument, .val = 'f' },
2349 if (session_key == 0) {
2351 "Can't find env LST_SESSION or value is not valid\n");
2356 c = getopt_long(argc, argv, "f",
2357 stop_batch_opts, &optidx);
2359 /* Detect the end of the options. */
2368 lst_print_usage(argv[0]);
2373 if (optind == argc) {
2374 batch = LST_DEFAULT_BATCH;
2376 } else if (optind == argc - 1) {
2377 batch = argv[optind];
2380 lst_print_usage(argv[0]);
2384 rc = lst_get_node_count(LST_OPC_BATCHCLI, batch, &count, NULL);
2386 fprintf(stderr, "Failed to get count of nodes from %s: %s\n",
2387 batch, strerror(errno));
2391 INIT_LIST_HEAD(&head);
2393 rc = lst_alloc_rpcent(&head, count, 0);
2395 fprintf(stderr, "Out of memory\n");
2399 rc = lst_stop_batch_ioctl(batch, force, &head);
2404 lst_reset_rpcent(&head);
2406 rc = lst_query_batch_ioctl(batch, 0, 0, 30, &head);
2410 if (lstcon_tsbqry_stat_run(&trans_stat, 0) == 0 &&
2411 lstcon_tsbqry_stat_failure(&trans_stat, 0) == 0)
2414 fprintf(stdout, "%d batch in stopping\n",
2415 lstcon_tsbqry_stat_run(&trans_stat, 0));
2419 fprintf(stdout, "Batch is stopped\n");
2420 lst_free_rpcent(&head);
2425 lst_print_error("batch", "Failed to stop batch: %s\n",
2427 lst_free_rpcent(&head);
2431 lst_print_transerr(&head, "stop batch");
2433 lst_free_rpcent(&head);
2439 lst_list_batch_ioctl(int len, char *name, int index)
2441 struct lstio_batch_list_args args = { 0 };
2443 args.lstio_bat_key = session_key;
2444 args.lstio_bat_idx = index;
2445 args.lstio_bat_nmlen = len;
2446 args.lstio_bat_namep = name;
2448 return lst_ioctl(LSTIO_BATCH_LIST, &args, sizeof(args));
2452 lst_info_batch_ioctl(char *batch, int test, int server,
2453 struct lstcon_test_batch_ent *entp, int *idxp,
2454 int *ndentp, struct lstcon_node_ent *dentsp)
2456 struct lstio_batch_info_args args = { 0 };
2458 args.lstio_bat_key = session_key;
2459 args.lstio_bat_nmlen = strlen(batch);
2460 args.lstio_bat_namep = batch;
2461 args.lstio_bat_server = server;
2462 args.lstio_bat_testidx = test;
2463 args.lstio_bat_entp = entp;
2464 args.lstio_bat_idxp = idxp;
2465 args.lstio_bat_ndentp = ndentp;
2466 args.lstio_bat_dentsp = dentsp;
2468 return lst_ioctl(LSTIO_BATCH_INFO, &args, sizeof(args));
2472 lst_list_batch_all(void)
2474 char name[LST_NAME_SIZE];
2478 for (i = 0; ; i++) {
2479 rc = lst_list_batch_ioctl(LST_NAME_SIZE, name, i);
2481 fprintf(stdout, "%d) %s\n", i + 1, name);
2485 if (errno == ENOENT)
2488 lst_print_error("batch", "Failed to list batch: %s\n",
2493 fprintf(stdout, "Total %d batches\n", i);
2499 lst_list_tsb_nodes(char *batch, int test, int server,
2500 int count, int active, int invalid)
2502 struct lstcon_node_ent *dents;
2511 /* verbose list, show nodes in batch or test */
2512 dents = malloc(count * sizeof(struct lstcon_node_ent));
2513 if (dents == NULL) {
2514 fprintf(stdout, "Can't allocate memory\n");
2518 rc = lst_info_batch_ioctl(batch, test, server,
2519 NULL, &index, &count, dents);
2522 lst_print_error((test > 0) ? "test" : "batch",
2523 (test > 0) ? "Failed to query test: %s\n" :
2524 "Failed to query batch: %s\n",
2529 for (i = 0, c = 0; i < count; i++) {
2530 if ((!active && dents[i].nde_state == LST_NODE_ACTIVE) ||
2531 (!invalid && (dents[i].nde_state == LST_NODE_BUSY ||
2532 dents[i].nde_state == LST_NODE_DOWN ||
2533 dents[i].nde_state == LST_NODE_UNKNOWN)))
2536 fprintf(stdout, "\t%s: %s\n",
2537 libcfs_id2str(dents[i].nde_id),
2538 lst_node_state2str(dents[i].nde_state));
2542 fprintf(stdout, "Total %d nodes\n", c);
2549 jt_lst_list_batch(int argc, char **argv)
2551 struct lstcon_test_batch_ent ent;
2554 int verbose = 0; /* list nodes in batch or test */
2563 static const struct option list_batch_opts[] = {
2564 { .name = "test", .has_arg = required_argument, .val = 't' },
2565 { .name = "invalid", .has_arg = no_argument, .val = 'i' },
2566 { .name = "active", .has_arg = no_argument, .val = 'a' },
2567 { .name = "all", .has_arg = no_argument, .val = 'l' },
2568 { .name = "server", .has_arg = no_argument, .val = 's' },
2569 { .name = NULL, } };
2571 if (session_key == 0) {
2573 "Can't find env LST_SESSION or value is not valid\n");
2578 c = getopt_long(argc, argv, "ailst:",
2579 list_batch_opts, &optidx);
2586 verbose = active = 1;
2589 verbose = invalid = 1;
2592 verbose = active = invalid = 1;
2598 test = atoi(optarg);
2602 lst_print_usage(argv[0]);
2607 if (optind == argc) {
2608 /* list all batches */
2609 rc = lst_list_batch_all();
2613 if (ntest == 1 && test <= 0) {
2614 fprintf(stderr, "Invalid test id, test id starts from 1\n");
2618 if (optind != argc - 1) {
2619 lst_print_usage(argv[0]);
2623 batch = argv[optind];
2626 /* show detail of specified batch or test */
2627 rc = lst_info_batch_ioctl(batch, test, server,
2628 &ent, NULL, NULL, NULL);
2630 lst_print_error((test > 0) ? "test" : "batch",
2631 (test > 0) ? "Failed to query test: %s\n" :
2632 "Failed to query batch: %s\n",
2638 /* list nodes in test or batch */
2639 rc = lst_list_tsb_nodes(batch, test, server,
2640 server ? ent.tbe_srv_nle.nle_nnode :
2641 ent.tbe_cli_nle.nle_nnode,
2646 /* only show number of hosts in batch or test */
2648 fprintf(stdout, "Batch: %s Tests: %d State: %d\n",
2649 batch, ent.u.tbe_batch.bae_ntest,
2650 ent.u.tbe_batch.bae_state);
2651 ntest = ent.u.tbe_batch.bae_ntest;
2652 test = 1; /* starting from test 1 */
2656 "\tTest %d(%s) (loop: %d, concurrency: %d)\n",
2657 test, lst_test_type2name(ent.u.tbe_test.tse_type),
2658 ent.u.tbe_test.tse_loop,
2659 ent.u.tbe_test.tse_concur);
2664 fprintf(stdout, LST_NODES_TITLE);
2665 fprintf(stdout, "client\t%d\t%d\t%d\t%d\t%d\n"
2666 "server\t%d\t%d\t%d\t%d\t%d\n",
2667 ent.tbe_cli_nle.nle_nactive,
2668 ent.tbe_cli_nle.nle_nbusy,
2669 ent.tbe_cli_nle.nle_ndown,
2670 ent.tbe_cli_nle.nle_nunknown,
2671 ent.tbe_cli_nle.nle_nnode,
2672 ent.tbe_srv_nle.nle_nactive,
2673 ent.tbe_srv_nle.nle_nbusy,
2674 ent.tbe_srv_nle.nle_ndown,
2675 ent.tbe_srv_nle.nle_nunknown,
2676 ent.tbe_srv_nle.nle_nnode);
2685 lst_query_batch_ioctl(char *batch, int test, int server,
2686 int timeout, struct list_head *head)
2688 struct lstio_batch_query_args args = { 0 };
2690 args.lstio_bat_key = session_key;
2691 args.lstio_bat_testidx = test;
2692 args.lstio_bat_client = !(server);
2693 args.lstio_bat_timeout = timeout;
2694 args.lstio_bat_nmlen = strlen(batch);
2695 args.lstio_bat_namep = batch;
2696 args.lstio_bat_resultp = head;
2698 return lst_ioctl(LSTIO_BATCH_QUERY, &args, sizeof(args));
2702 lst_print_tsb_verbose(struct list_head *head,
2703 int active, int idle, int error)
2705 struct lstcon_rpc_ent *ent;
2707 list_for_each_entry(ent, head, rpe_link) {
2708 if (ent->rpe_priv[0] == 0 && active)
2711 if (ent->rpe_priv[0] != 0 && idle)
2714 if (ent->rpe_fwk_errno == 0 && error)
2717 fprintf(stdout, "%s [%s]: %s\n",
2718 libcfs_id2str(ent->rpe_peer),
2719 lst_node_state2str(ent->rpe_state),
2720 ent->rpe_rpc_errno != 0 ?
2721 strerror(ent->rpe_rpc_errno) :
2722 (ent->rpe_priv[0] > 0 ? "Running" : "Idle"));
2727 jt_lst_query_batch(int argc, char **argv)
2729 struct lstcon_test_batch_ent ent;
2730 struct list_head head;
2736 int timeout = 5; /* default 5 seconds */
2737 int delay = 5; /* default 5 seconds */
2738 int loop = 1; /* default 1 loop */
2748 static const struct option query_batch_opts[] = {
2749 { .name = "timeout", .has_arg = required_argument, .val = 'o' },
2750 { .name = "delay", .has_arg = required_argument, .val = 'd' },
2751 { .name = "loop", .has_arg = required_argument, .val = 'c' },
2752 { .name = "test", .has_arg = required_argument, .val = 't' },
2753 { .name = "server", .has_arg = no_argument, .val = 's' },
2754 { .name = "active", .has_arg = no_argument, .val = 'a' },
2755 { .name = "idle", .has_arg = no_argument, .val = 'i' },
2756 { .name = "error", .has_arg = no_argument, .val = 'e' },
2757 { .name = "all", .has_arg = no_argument, .val = 'l' },
2758 { .name = NULL, } };
2760 if (session_key == 0) {
2762 "Can't find env LST_SESSION or value is not valid\n");
2767 c = getopt_long(argc, argv, "o:d:c:t:saiel",
2768 query_batch_opts, &optidx);
2770 /* Detect the end of the options. */
2776 timeout = atoi(optarg);
2779 delay = atoi(optarg);
2782 loop = atoi(optarg);
2785 test = atoi(optarg);
2791 active = verbose = 1;
2797 error = verbose = 1;
2803 lst_print_usage(argv[0]);
2808 if (test < 0 || timeout <= 0 || delay <= 0 || loop <= 0) {
2809 lst_print_usage(argv[0]);
2813 if (optind == argc) {
2814 batch = LST_DEFAULT_BATCH;
2816 } else if (optind == argc - 1) {
2817 batch = argv[optind];
2820 lst_print_usage(argv[0]);
2825 INIT_LIST_HEAD(&head);
2828 rc = lst_info_batch_ioctl(batch, test, server,
2829 &ent, NULL, NULL, NULL);
2831 fprintf(stderr, "Failed to query %s [%d]: %s\n",
2832 batch, test, strerror(errno));
2836 count = server ? ent.tbe_srv_nle.nle_nnode :
2837 ent.tbe_cli_nle.nle_nnode;
2839 fprintf(stdout, "Batch or test is empty\n");
2844 rc = lst_alloc_rpcent(&head, count, 0);
2846 fprintf(stderr, "Out of memory\n");
2850 for (i = 0; i < loop; i++) {
2851 time_t now = time(NULL);
2853 if (now - last < delay) {
2854 sleep(delay - now + last);
2860 rc = lst_query_batch_ioctl(batch, test,
2861 server, timeout, &head);
2863 fprintf(stderr, "Failed to query batch: %s\n",
2870 lst_print_tsb_verbose(&head, active, idle, error);
2874 fprintf(stdout, "%s [%d] ", batch, test);
2876 if (lstcon_rpc_stat_failure(&trans_stat, 0) != 0) {
2877 fprintf(stdout, "%d of %d nodes are unknown, ",
2878 lstcon_rpc_stat_failure(&trans_stat, 0),
2879 lstcon_rpc_stat_total(&trans_stat, 0));
2882 if (lstcon_rpc_stat_failure(&trans_stat, 0) == 0 &&
2883 lstcon_tsbqry_stat_run(&trans_stat, 0) == 0 &&
2884 lstcon_tsbqry_stat_failure(&trans_stat, 0) == 0) {
2885 fprintf(stdout, "is stopped\n");
2889 if (lstcon_rpc_stat_failure(&trans_stat, 0) == 0 &&
2890 lstcon_tsbqry_stat_idle(&trans_stat, 0) == 0 &&
2891 lstcon_tsbqry_stat_failure(&trans_stat, 0) == 0) {
2892 fprintf(stdout, "is running\n");
2896 fprintf(stdout, "stopped: %d , running: %d, failed: %d\n",
2897 lstcon_tsbqry_stat_idle(&trans_stat, 0),
2898 lstcon_tsbqry_stat_run(&trans_stat, 0),
2899 lstcon_tsbqry_stat_failure(&trans_stat, 0));
2902 lst_free_rpcent(&head);
2908 lst_parse_distribute(char *dstr, int *dist, int *span)
2914 dstr = strchr(dstr, ':');
2918 *span = atoi(dstr + 1);
2926 lst_get_bulk_param(int argc, char **argv, struct lst_test_bulk_param *bulk)
2933 bulk->blk_size = 4096;
2934 bulk->blk_opc = LST_BRW_READ;
2935 bulk->blk_flags = LST_BRW_CHECK_NONE;
2936 bulk->blk_srv_off = bulk->blk_cli_off = 0;
2939 if (strcasestr(argv[i], "check=") == argv[i] ||
2940 strcasestr(argv[i], "c=") == argv[i]) {
2941 tok = strchr(argv[i], '=') + 1;
2943 if (strcasecmp(tok, "full") == 0) {
2944 bulk->blk_flags = LST_BRW_CHECK_FULL;
2945 } else if (strcasecmp(tok, "simple") == 0) {
2946 bulk->blk_flags = LST_BRW_CHECK_SIMPLE;
2948 fprintf(stderr, "Unknow flag %s\n", tok);
2952 } else if (strcasestr(argv[i], "size=") == argv[i] ||
2953 strcasestr(argv[i], "s=") == argv[i]) {
2954 int max_size = sysconf(_SC_PAGESIZE) * LNET_MAX_IOV;
2956 tok = strchr(argv[i], '=') + 1;
2958 bulk->blk_size = strtol(tok, &end, 0);
2959 if (bulk->blk_size <= 0) {
2960 fprintf(stderr, "Invalid size %s\n", tok);
2967 if (*end == 'k' || *end == 'K')
2968 bulk->blk_size *= 1024;
2969 else if (*end == 'm' || *end == 'M')
2970 bulk->blk_size *= 1024 * 1024;
2972 if (bulk->blk_size > max_size) {
2973 fprintf(stderr, "Size exceed limitation: %d bytes\n",
2978 } else if (strcasestr(argv[i], "off=") == argv[i]) {
2981 tok = strchr(argv[i], '=') + 1;
2983 off = strtol(tok, &end, 0);
2984 /* NB: align with sizeof(__u64) to simplify page
2985 * checking implementation */
2986 if (off < 0 || off % sizeof(__u64) != 0) {
2988 "Invalid offset %s/%d, it should be "
2989 "postive value and multiple of %d\n",
2990 tok, off, (int)sizeof(__u64));
2994 /* NB: blk_srv_off is reserved so far */
2995 bulk->blk_cli_off = bulk->blk_srv_off = off;
2999 } else if (strcasecmp(argv[i], "read") == 0 ||
3000 strcasecmp(argv[i], "r") == 0) {
3001 bulk->blk_opc = LST_BRW_READ;
3003 } else if (strcasecmp(argv[i], "write") == 0 ||
3004 strcasecmp(argv[i], "w") == 0) {
3005 bulk->blk_opc = LST_BRW_WRITE;
3008 fprintf(stderr, "Unknow parameter: %s\n", argv[i]);
3019 lst_get_test_param(char *test, int argc, char **argv, void **param, int *plen)
3021 struct lst_test_bulk_param *bulk = NULL;
3024 type = lst_test_name2type(test);
3026 fprintf(stderr, "Unknow test name %s\n", test);
3035 bulk = malloc(sizeof(*bulk));
3037 fprintf(stderr, "Out of memory\n");
3041 memset(bulk, 0, sizeof(*bulk));
3043 if (lst_get_bulk_param(argc, argv, bulk) != 0) {
3049 *plen = sizeof(*bulk);
3057 /* TODO: parse more parameter */
3062 lst_add_test_ioctl(char *batch, int type, int loop, int concur,
3063 int dist, int span, char *sgrp, char *dgrp,
3064 void *param, int plen, int *retp, struct list_head *resultp)
3066 struct lstio_test_args args = { 0 };
3068 args.lstio_tes_key = session_key;
3069 args.lstio_tes_bat_nmlen = strlen(batch);
3070 args.lstio_tes_bat_name = batch;
3071 args.lstio_tes_type = type;
3072 args.lstio_tes_oneside = 0;
3073 args.lstio_tes_loop = loop;
3074 args.lstio_tes_concur = concur;
3075 args.lstio_tes_dist = dist;
3076 args.lstio_tes_span = span;
3077 args.lstio_tes_sgrp_nmlen = strlen(sgrp);
3078 args.lstio_tes_sgrp_name = sgrp;
3079 args.lstio_tes_dgrp_nmlen = strlen(dgrp);
3080 args.lstio_tes_dgrp_name = dgrp;
3081 args.lstio_tes_param_len = plen;
3082 args.lstio_tes_param = param;
3083 args.lstio_tes_retp = retp;
3084 args.lstio_tes_resultp = resultp;
3086 return lst_ioctl(LSTIO_TEST_ADD, &args, sizeof(args));
3090 jt_lst_add_test(int argc, char **argv)
3092 struct list_head head;
3112 static const struct option add_test_opts[] = {
3113 { .name = "batch", .has_arg = required_argument, .val = 'b' },
3114 { .name = "concurrency", .has_arg = required_argument, .val = 'c' },
3115 { .name = "distribute", .has_arg = required_argument, .val = 'd' },
3116 { .name = "from", .has_arg = required_argument, .val = 'f' },
3117 { .name = "to", .has_arg = required_argument, .val = 't' },
3118 { .name = "loop", .has_arg = required_argument, .val = 'l' },
3121 if (session_key == 0) {
3123 "Can't find env LST_SESSION or value is not valid\n");
3128 c = getopt_long(argc, argv, "b:c:d:f:l:t:",
3129 add_test_opts, &optidx);
3131 /* Detect the end of the options. */
3140 concur = atoi(optarg);
3149 loop = atoi(optarg);
3155 lst_print_usage(argv[0]);
3160 if (optind == argc || from == NULL || to == NULL) {
3161 lst_print_usage(argv[0]);
3165 if (concur <= 0 || concur > LST_MAX_CONCUR) {
3166 fprintf(stderr, "Invalid concurrency of test: %d\n", concur);
3171 batch = LST_DEFAULT_BATCH;
3174 rc = lst_parse_distribute(dstr, &dist, &span);
3176 fprintf(stderr, "Invalid distribution: %s\n", dstr);
3181 test = argv[optind++];
3186 type = lst_get_test_param(test, argc, argv, ¶m, &plen);
3188 fprintf(stderr, "Failed to add test (%s)\n", test);
3192 INIT_LIST_HEAD(&head);
3194 rc = lst_get_node_count(LST_OPC_GROUP, from, &fcount, NULL);
3196 fprintf(stderr, "Can't get count of nodes from %s: %s\n",
3197 from, strerror(errno));
3201 rc = lst_get_node_count(LST_OPC_GROUP, to, &tcount, NULL);
3203 fprintf(stderr, "Can't get count of nodes from %s: %s\n",
3204 to, strerror(errno));
3208 rc = lst_alloc_rpcent(&head, fcount > tcount ? fcount : tcount, 0);
3210 fprintf(stderr, "Out of memory\n");
3214 rc = lst_add_test_ioctl(batch, type, loop, concur,
3215 dist, span, from, to, param, plen, &ret, &head);
3218 fprintf(stdout, "Test was added successfully\n");
3220 fprintf(stdout, "Server group contains userland test "
3221 "nodes, old version of tcplnd can't accept "
3222 "connection request\n");
3229 lst_print_error("test", "Failed to add test: %s\n",
3234 lst_print_transerr(&head, "add test");
3236 lst_free_rpcent(&head);
3244 static command_t lst_cmdlist[] = {
3245 {"new_session", jt_lst_new_session, NULL,
3246 "Usage: lst new_session [--timeout TIME] [--force] [NAME]" },
3247 {"end_session", jt_lst_end_session, NULL,
3248 "Usage: lst end_session" },
3249 {"show_session", jt_lst_show_session, NULL,
3250 "Usage: lst show_session" },
3251 {"ping", jt_lst_ping , NULL,
3252 "Usage: lst ping [--group NAME] [--batch NAME] [--session] [--nodes IDS]" },
3253 {"add_group", jt_lst_add_group, NULL,
3254 "Usage: lst group NAME IDs [IDs]..." },
3255 {"del_group", jt_lst_del_group, NULL,
3256 "Usage: lst del_group NAME" },
3257 {"update_group", jt_lst_update_group, NULL,
3258 "Usage: lst update_group NAME [--clean] [--refresh] [--remove IDs]" },
3259 {"list_group", jt_lst_list_group, NULL,
3260 "Usage: lst list_group [--active] [--busy] [--down] [--unknown] GROUP ..." },
3261 {"stat", jt_lst_stat, NULL,
3262 "Usage: lst stat [--bw] [--rate] [--read] [--write] [--max] [--min] [--avg] "
3263 " [--mbs] [--timeout #] [--delay #] [--count #] GROUP [GROUP]" },
3264 {"show_error", jt_lst_show_error, NULL,
3265 "Usage: lst show_error NAME | IDS ..." },
3266 {"add_batch", jt_lst_add_batch, NULL,
3267 "Usage: lst add_batch NAME" },
3268 {"run", jt_lst_start_batch, NULL,
3269 "Usage: lst run [--timeout TIME] [NAME]" },
3270 {"stop", jt_lst_stop_batch, NULL,
3271 "Usage: lst stop [--force] BATCH_NAME" },
3272 {"list_batch", jt_lst_list_batch, NULL,
3273 "Usage: lst list_batch NAME [--test ID] [--server]" },
3274 {"query", jt_lst_query_batch, NULL,
3275 "Usage: lst query [--test ID] [--server] [--timeout TIME] NAME" },
3276 {"add_test", jt_lst_add_test, NULL,
3277 "Usage: lst add_test [--batch BATCH] [--loop #] [--concurrency #] "
3278 " [--distribute #:#] [--from GROUP] [--to GROUP] TEST..." },
3279 {"help", Parser_help, 0, "help" },
3284 lst_initialize(void)
3289 feats = getenv("LST_FEATURES");
3291 session_features = strtol(feats, NULL, 16);
3293 if ((session_features & ~LST_FEATS_MASK) != 0) {
3295 "Unsupported session features %x, "
3296 "only support these features so far: %x\n",
3297 (session_features & ~LST_FEATS_MASK), LST_FEATS_MASK);
3301 key = getenv("LST_SESSION");
3308 session_key = atoi(key);
3314 main(int argc, char **argv)
3320 rc = lst_initialize();
3324 rc = ptl_initialize(argc, argv);
3328 Parser_init("lst > ", lst_cmdlist);
3331 rc = Parser_execarg(argc - 1, argv + 1, lst_cmdlist);