X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lnet%2Futils%2Flst.c;h=94cf02aaf1cd95ffbb8192154baaa85139b3d4ae;hp=e7d0d554feff1be83586723ee07ce35a9be86bd8;hb=5b3eecce0bad98c81a45712594037b6ec7a9024f;hpb=2f5681ce80a3faa1241a8d0dca7f71f83aadb745 diff --git a/lnet/utils/lst.c b/lnet/utils/lst.c index e7d0d55..94cf02a 100644 --- a/lnet/utils/lst.c +++ b/lnet/utils/lst.c @@ -1,23 +1,53 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Author: Liang Zhen * - * This file is part of Lustre, http://www.lustre.org + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + * GPL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. + * + * lnet/selftest/conctl.c + * + * Author: Liang Zhen */ -#include -#include -#include -#include -#include +#define _GNU_SOURCE + +#include #include #include -#include "parser.h" -static command_t lst_cmdlist[]; + +lst_sid_t LST_INVALID_SID = {LNET_NID_ANY, -1}; static lst_sid_t session_id; -static int session_key; +static int session_key; static lstcon_trans_stat_t trans_stat; typedef struct list_string { @@ -26,7 +56,9 @@ typedef struct list_string { char lstr_str[0]; } lstr_t; -#define offsetof(typ,memb) ((unsigned long)((char *)&(((typ *)0)->memb))) +#ifndef offsetof +# define offsetof(typ,memb) ((unsigned long)((char *)&(((typ *)0)->memb))) +#endif static int alloc_count = 0; static int alloc_nob = 0; @@ -76,7 +108,7 @@ new_lstrs(lstr_t **list, char *prefix, char *postfix, int n2 = strlen(postfix); int sz = n1 + 20 + n2 + 1; - do { + do { lstr_t *n = alloc_lstr(sz); snprintf(n->lstr_str, sz - 1, "%s%u%s", @@ -100,9 +132,9 @@ expand_lstr(lstr_t **list, lstr_t *l) int x; int y; int z; - int n; + int n; - b1 = strchr(l->lstr_str, '['); + b1 = strchr(l->lstr_str, '['); if (b1 == NULL) { l->lstr_next = *list; *list = l; @@ -359,33 +391,33 @@ lst_print_error(char *sub, const char *def_format, ...) } void -lst_free_rpcent(struct list_head *head) +lst_free_rpcent(cfs_list_t *head) { lstcon_rpc_ent_t *ent; - while (!list_empty(head)) { - ent = list_entry(head->next, lstcon_rpc_ent_t, rpe_link); + while (!cfs_list_empty(head)) { + ent = cfs_list_entry(head->next, lstcon_rpc_ent_t, rpe_link); - list_del(&ent->rpe_link); + cfs_list_del(&ent->rpe_link); free(ent); } } void -lst_reset_rpcent(struct list_head *head) +lst_reset_rpcent(cfs_list_t *head) { lstcon_rpc_ent_t *ent; - list_for_each_entry(ent, head, rpe_link) { + cfs_list_for_each_entry_typed(ent, head, lstcon_rpc_ent_t, rpe_link) { ent->rpe_sid = LST_INVALID_SID; - ent->rpe_peer.nid = LNET_NID_ANY; + ent->rpe_peer.nid = LNET_NID_ANY; ent->rpe_peer.pid = LNET_PID_ANY; ent->rpe_rpc_errno = ent->rpe_fwk_errno = 0; } } int -lst_alloc_rpcent(struct list_head *head, int count, int offset) +lst_alloc_rpcent(cfs_list_t *head, int count, int offset) { lstcon_rpc_ent_t *ent; int i; @@ -400,20 +432,20 @@ lst_alloc_rpcent(struct list_head *head, int count, int offset) memset(ent, 0, offsetof(lstcon_rpc_ent_t, rpe_payload[offset])); ent->rpe_sid = LST_INVALID_SID; - ent->rpe_peer.nid = LNET_NID_ANY; + ent->rpe_peer.nid = LNET_NID_ANY; ent->rpe_peer.pid = LNET_PID_ANY; - list_add(&ent->rpe_link, head); + cfs_list_add(&ent->rpe_link, head); } return 0; } void -lst_print_transerr(struct list_head *head, char *optstr) +lst_print_transerr(cfs_list_t *head, char *optstr) { lstcon_rpc_ent_t *ent; - list_for_each_entry(ent, head, rpe_link) { + cfs_list_for_each_entry_typed(ent, head, lstcon_rpc_ent_t, rpe_link) { if (ent->rpe_rpc_errno == 0 && ent->rpe_fwk_errno == 0) continue; @@ -424,12 +456,22 @@ lst_print_transerr(struct list_head *head, char *optstr) continue; } - fprintf(stderr, "%s failed on %s: %s\n", + fprintf(stderr, "%s failed on %s: %s\n", optstr, libcfs_id2str(ent->rpe_peer), strerror(ent->rpe_fwk_errno)); } } +int lst_info_batch_ioctl(char *batch, int test, int server, + lstcon_test_batch_ent_t *entp, int *idxp, + int *ndentp, lstcon_node_ent_t *dentsp); + +int lst_info_group_ioctl(char *name, lstcon_ndlist_ent_t *gent, + int *idx, int *count, lstcon_node_ent_t *dents); + +int lst_query_batch_ioctl(char *batch, int test, int server, + int timeout, cfs_list_t *head); + int lst_ioctl(unsigned int opc, void *buf, int len) { @@ -465,14 +507,14 @@ lst_ioctl(unsigned int opc, void *buf, int len) int lst_new_session_ioctl (char *name, int timeout, int force, lst_sid_t *sid) { - lstio_session_new_args_t args = { - .lstio_ses_key = session_key, - .lstio_ses_timeout = timeout, - .lstio_ses_force = force, - .lstio_ses_idp = sid, - .lstio_ses_namep = name, - .lstio_ses_nmlen = strlen(name), - }; + lstio_session_new_args_t args = {0}; + + args.lstio_ses_key = session_key; + args.lstio_ses_timeout = timeout; + args.lstio_ses_force = force; + args.lstio_ses_idp = sid; + args.lstio_ses_nmlen = strlen(name); + args.lstio_ses_namep = name; return lst_ioctl (LSTIO_SESSION_NEW, &args, sizeof(args)); } @@ -508,7 +550,7 @@ jt_lst_new_session(int argc, char **argv) if (c == -1) break; - + switch (c) { case 'f': force = 1; @@ -552,7 +594,7 @@ jt_lst_new_session(int argc, char **argv) snprintf(buf, LST_NAME_SIZE, "%s@%s", user, host); name = buf; - } else { + } else { lst_print_usage(argv[0]); return -1; } @@ -575,13 +617,13 @@ int lst_session_info_ioctl(char *name, int len, int *key, lst_sid_t *sid, lstcon_ndlist_ent_t *ndinfo) { - lstio_session_info_args_t args = { - .lstio_ses_keyp = key, - .lstio_ses_idp = sid, - .lstio_ses_ndinfo = ndinfo, - .lstio_ses_nmlen = len, - .lstio_ses_namep = name, - }; + lstio_session_info_args_t args = {0}; + + args.lstio_ses_idp = sid; + args.lstio_ses_keyp = key; + args.lstio_ses_ndinfo = ndinfo; + args.lstio_ses_nmlen = len; + args.lstio_ses_namep = name; return lst_ioctl(LSTIO_SESSION_INFO, &args, sizeof(args)); } @@ -603,7 +645,7 @@ jt_lst_show_session(int argc, char **argv) return -1; } - fprintf(stdout, "%s ID: %Lu@%s, KEY: %d NODES: %d\n", + fprintf(stdout, "%s ID: "LPU64"@%s, KEY: %d NODES: %d\n", name, sid.ses_stamp, libcfs_nid2str(sid.ses_nid), key, ndinfo.nle_nnode); @@ -613,10 +655,9 @@ jt_lst_show_session(int argc, char **argv) int lst_end_session_ioctl(void) { - lstio_session_end_args_t args = { - .lstio_ses_key = session_key, - }; + lstio_session_end_args_t args = {0}; + args.lstio_ses_key = session_key; return lst_ioctl (LSTIO_SESSION_END, &args, sizeof(args)); } @@ -662,34 +703,24 @@ jt_lst_end_session(int argc, char **argv) } int -lst_ping_ioctl(char *str, int type, int timeout, - int count, lnet_process_id_t *ids, struct list_head *head) -{ - lstio_debug_args_t args = { - .lstio_dbg_key = session_key, - .lstio_dbg_type = type, - .lstio_dbg_flags = 0, - .lstio_dbg_timeout = timeout, - .lstio_dbg_nmlen = (str == NULL) ? 0: strlen(str), - .lstio_dbg_namep = str, - .lstio_dbg_count = count, - .lstio_dbg_idsp = ids, - .lstio_dbg_resultp = head, - }; +lst_ping_ioctl(char *str, int type, int timeout, + int count, lnet_process_id_t *ids, cfs_list_t *head) +{ + lstio_debug_args_t args = {0}; + + args.lstio_dbg_key = session_key; + args.lstio_dbg_type = type; + args.lstio_dbg_flags = 0; + args.lstio_dbg_timeout = timeout; + args.lstio_dbg_nmlen = (str == NULL) ? 0: strlen(str); + args.lstio_dbg_namep = str; + args.lstio_dbg_count = count; + args.lstio_dbg_idsp = ids; + args.lstio_dbg_resultp = head; return lst_ioctl (LSTIO_DEBUG, &args, sizeof(args)); } -int lst_info_batch_ioctl(char *batch, int test, int server, - lstcon_test_batch_ent_t *entp, int *idxp, - int *ndentp, lstcon_node_ent_t *dentsp); - -int lst_info_group_ioctl(char *name, lstcon_ndlist_ent_t *gent, - int *idx, int *count, lstcon_node_ent_t *dents); - -int lst_query_batch_ioctl(char *batch, int test, int server, - int timeout, struct list_head *head); - int lst_get_node_count(int type, char *str, int *countp, lnet_process_id_t **idspp) { @@ -711,7 +742,7 @@ lst_get_node_count(int type, char *str, int *countp, lnet_process_id_t **idspp) case LST_OPC_BATCHCLI: rc = lst_info_batch_ioctl(str, 0, 0, &ent, NULL, NULL, NULL); break; - + case LST_OPC_GROUP: rc = lst_info_group_ioctl(str, entp, NULL, NULL, NULL); break; @@ -725,7 +756,7 @@ lst_get_node_count(int type, char *str, int *countp, lnet_process_id_t **idspp) break; } - if (rc == 0) + if (rc == 0) *countp = entp->nle_nnode; return rc; @@ -734,7 +765,7 @@ lst_get_node_count(int type, char *str, int *countp, lnet_process_id_t **idspp) int jt_lst_ping(int argc, char **argv) { - struct list_head head; + cfs_list_t head; lnet_process_id_t *ids = NULL; lstcon_rpc_ent_t *ent = NULL; char *str = NULL; @@ -770,7 +801,7 @@ jt_lst_ping(int argc, char **argv) if (c == -1) break; - + switch (c) { case 's': type = LST_OPC_SESSION; @@ -844,7 +875,7 @@ jt_lst_ping(int argc, char **argv) } /* ignore RPC errors and framwork errors */ - list_for_each_entry(ent, &head, rpe_link) { + cfs_list_for_each_entry_typed(ent, &head, lstcon_rpc_ent_t, rpe_link) { fprintf(stdout, "\t%s: %s [session: %s id: %s]\n", libcfs_id2str(ent->rpe_peer), lst_node_state2str(ent->rpe_state), @@ -862,21 +893,21 @@ out: free(ids); return rc; - + } int lst_add_nodes_ioctl (char *name, int count, lnet_process_id_t *ids, - struct list_head *resultp) -{ - lstio_group_nodes_args_t args = { - .lstio_grp_key = session_key, - .lstio_grp_nmlen = strlen(name), - .lstio_grp_namep = name, - .lstio_grp_count = count, - .lstio_grp_idsp = ids, - .lstio_grp_resultp = resultp, - }; + cfs_list_t *resultp) +{ + lstio_group_nodes_args_t args = {0}; + + args.lstio_grp_key = session_key; + args.lstio_grp_nmlen = strlen(name); + args.lstio_grp_namep = name; + args.lstio_grp_count = count; + args.lstio_grp_idsp = ids; + args.lstio_grp_resultp = resultp; return lst_ioctl(LSTIO_NODES_ADD, &args, sizeof(args)); } @@ -884,11 +915,11 @@ lst_add_nodes_ioctl (char *name, int count, lnet_process_id_t *ids, int lst_add_group_ioctl (char *name) { - lstio_group_add_args_t args = { - .lstio_grp_key = session_key, - .lstio_grp_nmlen = strlen(name), - .lstio_grp_namep = name, - }; + lstio_group_add_args_t args = {0}; + + args.lstio_grp_key = session_key; + args.lstio_grp_nmlen = strlen(name); + args.lstio_grp_namep = name; return lst_ioctl(LSTIO_GROUP_ADD, &args, sizeof(args)); } @@ -896,7 +927,7 @@ lst_add_group_ioctl (char *name) int jt_lst_add_group(int argc, char **argv) { - struct list_head head; + cfs_list_t head; lnet_process_id_t *ids; char *name; int count; @@ -975,11 +1006,11 @@ jt_lst_add_group(int argc, char **argv) int lst_del_group_ioctl (char *name) { - lstio_group_del_args_t args = { - .lstio_grp_key = session_key, - .lstio_grp_nmlen = strlen(name), - .lstio_grp_namep = name, - }; + lstio_group_del_args_t args = {0}; + + args.lstio_grp_key = session_key; + args.lstio_grp_nmlen = strlen(name); + args.lstio_grp_namep = name; return lst_ioctl(LSTIO_GROUP_DEL, &args, sizeof(args)); } @@ -1016,7 +1047,7 @@ jt_lst_del_group(int argc, char **argv) if (trans_stat.trs_rpc_errno != 0) { fprintf(stderr, "[RPC] Failed to send %d end session RPCs: %s\n", - lstcon_rpc_stat_failure(&trans_stat, 0), + lstcon_rpc_stat_failure(&trans_stat, 0), strerror(trans_stat.trs_rpc_errno)); } @@ -1032,18 +1063,18 @@ jt_lst_del_group(int argc, char **argv) int lst_update_group_ioctl(int opc, char *name, int clean, int count, - lnet_process_id_t *ids, struct list_head *resultp) -{ - lstio_group_update_args_t args = { - .lstio_grp_key = session_key, - .lstio_grp_opc = opc, - .lstio_grp_args = clean, - .lstio_grp_nmlen = strlen(name), - .lstio_grp_namep = name, - .lstio_grp_count = count, - .lstio_grp_idsp = ids, - .lstio_grp_resultp = resultp, - }; + lnet_process_id_t *ids, cfs_list_t *resultp) +{ + lstio_group_update_args_t args = {0}; + + args.lstio_grp_key = session_key; + args.lstio_grp_opc = opc; + args.lstio_grp_args = clean; + args.lstio_grp_nmlen = strlen(name); + args.lstio_grp_namep = name; + args.lstio_grp_count = count; + args.lstio_grp_idsp = ids; + args.lstio_grp_resultp = resultp; return lst_ioctl(LSTIO_GROUP_UPDATE, &args, sizeof(args)); } @@ -1051,7 +1082,7 @@ lst_update_group_ioctl(int opc, char *name, int clean, int count, int jt_lst_update_group(int argc, char **argv) { - struct list_head head; + cfs_list_t head; lnet_process_id_t *ids = NULL; char *str = NULL; char *grp = NULL; @@ -1083,7 +1114,7 @@ jt_lst_update_group(int argc, char **argv) /* Detect the end of the options. */ if (c == -1) break; - + switch (c) { case 'f': if (opc != 0) { @@ -1147,7 +1178,7 @@ jt_lst_update_group(int argc, char **argv) return -1; } - } + } rc = lst_update_group_ioctl(opc, grp, clean, count, ids, &head); @@ -1176,12 +1207,12 @@ jt_lst_update_group(int argc, char **argv) int lst_list_group_ioctl(int len, char *name, int idx) { - lstio_group_list_args_t args = { - .lstio_grp_key = session_key, - .lstio_grp_idx = idx, - .lstio_grp_nmlen = len, - .lstio_grp_namep = name, - }; + lstio_group_list_args_t args = {0}; + + args.lstio_grp_key = session_key; + args.lstio_grp_idx = idx; + args.lstio_grp_nmlen = len; + args.lstio_grp_namep = name; return lst_ioctl(LSTIO_GROUP_LIST, &args, sizeof(args)); } @@ -1190,15 +1221,15 @@ int lst_info_group_ioctl(char *name, lstcon_ndlist_ent_t *gent, int *idx, int *count, lstcon_node_ent_t *dents) { - lstio_group_info_args_t args = { - .lstio_grp_key = session_key, - .lstio_grp_nmlen = strlen(name), - .lstio_grp_namep = name, - .lstio_grp_entp = gent, - .lstio_grp_idxp = idx, - .lstio_grp_ndentp = count, - .lstio_grp_dentsp = dents, - }; + lstio_group_info_args_t args = {0}; + + args.lstio_grp_key = session_key; + args.lstio_grp_nmlen = strlen(name); + args.lstio_grp_namep = name; + args.lstio_grp_entp = gent; + args.lstio_grp_idxp = idx; + args.lstio_grp_ndentp = count; + args.lstio_grp_dentsp = dents; return lst_ioctl(LSTIO_GROUP_INFO, &args, sizeof(args)); } @@ -1218,7 +1249,7 @@ lst_list_group_all(void) continue; } - if (errno == ENOENT) + if (errno == ENOENT) break; lst_print_error("group", "Failed to list group: %s\n", @@ -1274,7 +1305,7 @@ jt_lst_list_group(int argc, char **argv) if (c == -1) break; - + switch (c) { case 'a': verbose = active = 1; @@ -1382,27 +1413,27 @@ jt_lst_list_group(int argc, char **argv) int lst_stat_ioctl (char *name, int count, lnet_process_id_t *idsp, - int timeout, struct list_head *resultp) -{ - lstio_stat_args_t args = { - .lstio_sta_key = session_key, - .lstio_sta_timeout = timeout, - .lstio_sta_nmlen = strlen(name), - .lstio_sta_namep = name, - .lstio_sta_count = count, - .lstio_sta_idsp = idsp, - .lstio_sta_resultp = resultp, - }; + int timeout, cfs_list_t *resultp) +{ + lstio_stat_args_t args = {0}; + + args.lstio_sta_key = session_key; + args.lstio_sta_timeout = timeout; + args.lstio_sta_nmlen = strlen(name); + args.lstio_sta_namep = name; + args.lstio_sta_count = count; + args.lstio_sta_idsp = idsp; + args.lstio_sta_resultp = resultp; return lst_ioctl (LSTIO_STAT_QUERY, &args, sizeof(args)); } typedef struct { - struct list_head srp_link; + cfs_list_t srp_link; int srp_count; char *srp_name; lnet_process_id_t *srp_ids; - struct list_head srp_result[2]; + cfs_list_t srp_result[2]; } lst_stat_req_param_t; static void @@ -1410,7 +1441,7 @@ lst_stat_req_param_free(lst_stat_req_param_t *srp) { int i; - for (i = 0; i < 2; i++) + for (i = 0; i < 2; i++) lst_free_rpcent(&srp->srp_result[i]); if (srp->srp_ids != NULL) @@ -1420,9 +1451,10 @@ lst_stat_req_param_free(lst_stat_req_param_t *srp) } static int -lst_stat_req_param_alloc(char *name, lst_stat_req_param_t **srpp) +lst_stat_req_param_alloc(char *name, lst_stat_req_param_t **srpp, int save_old) { lst_stat_req_param_t *srp = NULL; + int count = save_old ? 2 : 1; int rc; int i; @@ -1436,14 +1468,15 @@ lst_stat_req_param_alloc(char *name, lst_stat_req_param_t **srpp) rc = lst_get_node_count(LST_OPC_GROUP, name, &srp->srp_count, NULL); - if (rc != 0) { + if (rc != 0 && errno == ENOENT) { rc = lst_get_node_count(LST_OPC_NODES, name, &srp->srp_count, &srp->srp_ids); } if (rc != 0) { fprintf(stderr, - "Failed to get count of nodes from %s\n", name); + "Failed to get count of nodes from %s: %s\n", + name, strerror(errno)); lst_stat_req_param_free(srp); return rc; @@ -1451,7 +1484,7 @@ lst_stat_req_param_alloc(char *name, lst_stat_req_param_t **srpp) srp->srp_name = name; - for (i = 0; i < 2; i++) { + for (i = 0; i < count; i++) { rc = lst_alloc_rpcent(&srp->srp_result[i], srp->srp_count, sizeof(sfw_counters_t) + sizeof(srpc_counters_t) + @@ -1474,6 +1507,7 @@ lst_stat_req_param_alloc(char *name, lst_stat_req_param_t **srpp) typedef struct { /* TODO */ + int foo; } lst_srpc_stat_result; #define LST_LNET_AVG 0 @@ -1515,7 +1549,7 @@ lst_lnet_stat_value(int bw, int send, int off) &lnet_stat_result.lnet_avg_sndrate; if (!send) - p += 4; + p += 4; p += off; @@ -1631,7 +1665,7 @@ lst_print_lnet_stat(char *name, int bwrt, int rdwr, int type) i == 0 ? "Rates" : "Bandwidth", name); for (j = start2; j <= end2; j++) { - fprintf(stdout, "[%c] ", j == 0 ? 'W' : 'R'); + fprintf(stdout, "[%c] ", j == 0 ? 'R' : 'W'); if ((type & 1) != 0) { fprintf(stdout, i == 0 ? "Avg: %-8.0f RPC/s " : @@ -1657,10 +1691,10 @@ lst_print_lnet_stat(char *name, int bwrt, int rdwr, int type) } void -lst_print_stat(char *name, struct list_head *resultp, +lst_print_stat(char *name, cfs_list_t *resultp, int idx, int lnet, int bwrt, int rdwr, int type) { - struct list_head tmp[2]; + cfs_list_t tmp[2]; lstcon_rpc_ent_t *new; lstcon_rpc_ent_t *old; sfw_counters_t *sfwk_new; @@ -1678,14 +1712,16 @@ lst_print_stat(char *name, struct list_head *resultp, memset(&lnet_stat_result, 0, sizeof(lnet_stat_result)); - while (!list_empty(&resultp[idx])) { - if (list_empty(&resultp[1 - idx])) { + while (!cfs_list_empty(&resultp[idx])) { + if (cfs_list_empty(&resultp[1 - idx])) { fprintf(stderr, "Group is changed, re-run stat\n"); break; } - new = list_entry(resultp[idx].next, lstcon_rpc_ent_t, rpe_link); - old = list_entry(resultp[1 - idx].next, lstcon_rpc_ent_t, rpe_link); + new = cfs_list_entry(resultp[idx].next, lstcon_rpc_ent_t, + rpe_link); + old = cfs_list_entry(resultp[1 - idx].next, lstcon_rpc_ent_t, + rpe_link); /* first time get stats result, can't calculate diff */ if (new->rpe_peer.nid == LNET_NID_ANY) @@ -1697,11 +1733,11 @@ lst_print_stat(char *name, struct list_head *resultp, break; } - list_del(&new->rpe_link); - list_add_tail(&new->rpe_link, &tmp[idx]); + cfs_list_del(&new->rpe_link); + cfs_list_add_tail(&new->rpe_link, &tmp[idx]); - list_del(&old->rpe_link); - list_add_tail(&old->rpe_link, &tmp[1 - idx]); + cfs_list_del(&old->rpe_link); + cfs_list_add_tail(&old->rpe_link, &tmp[1 - idx]); if (new->rpe_rpc_errno != 0 || new->rpe_fwk_errno != 0 || old->rpe_rpc_errno != 0 || old->rpe_fwk_errno != 0) { @@ -1724,12 +1760,12 @@ lst_print_stat(char *name, struct list_head *resultp, if (!lnet) /* TODO */ continue; - + lst_cal_lnet_stat(delta, lnet_new, lnet_old); } - list_splice(&tmp[idx], &resultp[idx]); - list_splice(&tmp[1 - idx], &resultp[1 - idx]); + cfs_list_splice(&tmp[idx], &resultp[idx]); + cfs_list_splice(&tmp[1 - idx], &resultp[1 - idx]); if (errcount > 0) fprintf(stdout, "Failed to stat on %d nodes\n", errcount); @@ -1743,9 +1779,8 @@ lst_print_stat(char *name, struct list_head *resultp, int jt_lst_stat(int argc, char **argv) { - struct list_head head; + cfs_list_t head; lst_stat_req_param_t *srp; - char *name = NULL; time_t last = 0; int optidx = 0; int timeout = 5; /* default timeout, 5 sec */ @@ -1785,7 +1820,7 @@ jt_lst_stat(int argc, char **argv) if (c == -1) break; - + switch (c) { case 't': timeout = atoi(optarg); @@ -1851,18 +1886,16 @@ jt_lst_stat(int argc, char **argv) CFS_INIT_LIST_HEAD(&head); while (optind < argc) { - name = argv[optind++]; - - rc = lst_stat_req_param_alloc(name, &srp); - if (rc != 0) + rc = lst_stat_req_param_alloc(argv[optind++], &srp, 1); + if (rc != 0) goto out; - list_add_tail(&srp->srp_link, &head); + cfs_list_add_tail(&srp->srp_link, &head); } while (1) { time_t now = time(NULL); - + if (now - last < delay) { sleep(delay - now + last); time(&now); @@ -1870,13 +1903,14 @@ jt_lst_stat(int argc, char **argv) last = now; - list_for_each_entry(srp, &head, srp_link) { + cfs_list_for_each_entry_typed(srp, &head, lst_stat_req_param_t, + srp_link) { rc = lst_stat_ioctl(srp->srp_name, srp->srp_count, srp->srp_ids, timeout, &srp->srp_result[idx]); if (rc == -1) { lst_print_error("stat", "Failed to stat %s: %s\n", - name, strerror(errno)); + srp->srp_name, strerror(errno)); goto out; } @@ -1890,10 +1924,10 @@ jt_lst_stat(int argc, char **argv) } out: - while (!list_empty(&head)) { - srp = list_entry(head.next, lst_stat_req_param_t, srp_link); + while (!cfs_list_empty(&head)) { + srp = cfs_list_entry(head.next, lst_stat_req_param_t, srp_link); - list_del(&srp->srp_link); + cfs_list_del(&srp->srp_link); lst_stat_req_param_free(srp); } @@ -1903,26 +1937,21 @@ out: int jt_lst_show_error(int argc, char **argv) { - struct list_head head; + cfs_list_t head; + lst_stat_req_param_t *srp; lstcon_rpc_ent_t *ent; sfw_counters_t *sfwk; srpc_counters_t *srpc; lnet_counters_t *lnet; - lnet_process_id_t *idsp = NULL; - char *name = NULL; - int optidx = 0; - int count = 0; - int type = 0; - int timeout = 5; - int ecount = 0; - int rc; + int show_rpc = 1; + int optidx = 0; + int rc = 0; + int ecount; int c; - - static struct option show_error_opts[] = + static struct option show_error_opts[] = { - {"group" , required_argument, 0, 'g' }, - {"nodes" , required_argument, 0, 'n' }, + {"session", no_argument, 0, 's' }, {0, 0, 0, 0 } }; @@ -1933,106 +1962,115 @@ jt_lst_show_error(int argc, char **argv) } while (1) { - c = getopt_long(argc, argv, "g:n:", show_error_opts, &optidx); + c = getopt_long(argc, argv, "s", show_error_opts, &optidx); if (c == -1) break; - + switch (c) { - case 'g': - type = LST_OPC_GROUP; - name = optarg; - break; - case 'n': - type = LST_OPC_NODES; - name = optarg; + case 's': + show_rpc = 0; break; + default: lst_print_usage(argv[0]); return -1; } } - if (optind != argc || type == 0) { + if (optind == argc) { lst_print_usage(argv[0]); return -1; } - if (name == NULL) { - fprintf(stderr, "Missing name of target (group | nodes)\n"); - return -1; - } - - rc = lst_get_node_count(type, name, &count, &idsp); - if (rc < 0) { - fprintf(stderr, "Failed to get count of nodes from %s: %s\n", - name, strerror(errno)); - return -1; - } - CFS_INIT_LIST_HEAD(&head); - rc = lst_alloc_rpcent(&head, count, sizeof(sfw_counters_t) + - sizeof(srpc_counters_t) + - sizeof(lnet_counters_t)); - if (rc != 0) { - fprintf(stderr, "Out of memory\n"); - goto out; - } + while (optind < argc) { + rc = lst_stat_req_param_alloc(argv[optind++], &srp, 0); + if (rc != 0) + goto out; - rc = lst_stat_ioctl(name, count, idsp, timeout, &head); - if (rc == -1) { - lst_print_error(name, "Failed to show errors of %s: %s\n", - name, strerror(errno)); - goto out; + cfs_list_add_tail(&srp->srp_link, &head); } - list_for_each_entry(ent, &head, rpe_link) { - if (ent->rpe_rpc_errno != 0) { - ecount ++; - fprintf(stderr, "RPC failure, can't show error on %s\n", - libcfs_id2str(ent->rpe_peer)); - continue; + cfs_list_for_each_entry_typed(srp, &head, lst_stat_req_param_t, + srp_link) { + rc = lst_stat_ioctl(srp->srp_name, srp->srp_count, + srp->srp_ids, 10, &srp->srp_result[0]); + + if (rc == -1) { + lst_print_error(srp->srp_name, "Failed to show errors of %s: %s\n", + srp->srp_name, strerror(errno)); + goto out; } - if (ent->rpe_fwk_errno != 0) { + fprintf(stdout, "%s:\n", srp->srp_name); + + ecount = 0; + + cfs_list_for_each_entry_typed(ent, &srp->srp_result[0], + lstcon_rpc_ent_t, rpe_link) { + if (ent->rpe_rpc_errno != 0) { + ecount ++; + fprintf(stderr, "RPC failure, can't show error on %s\n", + libcfs_id2str(ent->rpe_peer)); + continue; + } + + if (ent->rpe_fwk_errno != 0) { + ecount ++; + fprintf(stderr, "Framework failure, can't show error on %s\n", + libcfs_id2str(ent->rpe_peer)); + continue; + } + + sfwk = (sfw_counters_t *)&ent->rpe_payload[0]; + srpc = (srpc_counters_t *)((char *)sfwk + sizeof(*sfwk)); + lnet = (lnet_counters_t *)((char *)srpc + sizeof(*srpc)); + + if (srpc->errors == 0 && + sfwk->brw_errors == 0 && sfwk->ping_errors == 0) + continue; + + if (!show_rpc && + sfwk->brw_errors == 0 && sfwk->ping_errors == 0) + continue; + ecount ++; - fprintf(stderr, "Framework failure, can't show error on %s\n", - libcfs_id2str(ent->rpe_peer)); - continue; - } - sfwk = (sfw_counters_t *)&ent->rpe_payload[0]; - srpc = (srpc_counters_t *)((char *)sfwk + sizeof(*sfwk)); - lnet = (lnet_counters_t *)((char *)srpc + sizeof(*srpc)); + fprintf(stderr, "%s: [Session %d brw errors, %d ping errors]%c", + libcfs_id2str(ent->rpe_peer), + sfwk->brw_errors, sfwk->ping_errors, + show_rpc ? ' ' : '\n'); - if (srpc->errors == 0 && - sfwk->brw_errors == 0 && sfwk->ping_errors == 0) - continue; + if (!show_rpc) + continue; - ecount ++; - fprintf(stderr, "[%s]: %d RPC errors, %d brw errors, %d ping errors\n", - libcfs_id2str(ent->rpe_peer), srpc->errors, - sfwk->brw_errors, sfwk->ping_errors); - } + fprintf(stderr, "[RPC: %d errors, %d dropped, %d expired]\n", + srpc->errors, srpc->rpcs_dropped, srpc->rpcs_expired); + } - fprintf(stdout, "Total %d errors in %s\n", ecount, name); + fprintf(stdout, "Total %d error nodes in %s\n", ecount, srp->srp_name); + } out: - lst_free_rpcent(&head); - if (idsp != NULL) - free(idsp); + while (!cfs_list_empty(&head)) { + srp = cfs_list_entry(head.next, lst_stat_req_param_t, srp_link); - return 0; + cfs_list_del(&srp->srp_link); + lst_stat_req_param_free(srp); + } + + return rc; } int lst_add_batch_ioctl (char *name) { - lstio_batch_add_args_t args = { - .lstio_bat_key = session_key, - .lstio_bat_nmlen = strlen(name), - .lstio_bat_namep = name, - }; + lstio_batch_add_args_t args = {0}; + + args.lstio_bat_key = session_key; + args.lstio_bat_nmlen = strlen(name); + args.lstio_bat_namep = name; return lst_ioctl (LSTIO_BATCH_ADD, &args, sizeof(args)); } @@ -2054,7 +2092,7 @@ jt_lst_add_batch(int argc, char **argv) return -1; } - name = argv[1]; + name = argv[1]; if (strlen(name) >= LST_NAME_SIZE) { fprintf(stderr, "Name length is limited to %d\n", LST_NAME_SIZE - 1); @@ -2072,15 +2110,15 @@ jt_lst_add_batch(int argc, char **argv) } int -lst_start_batch_ioctl (char *name, int timeout, struct list_head *resultp) -{ - lstio_batch_run_args_t args = { - .lstio_bat_key = session_key, - .lstio_bat_timeout = timeout, - .lstio_bat_nmlen = strlen(name), - .lstio_bat_namep = name, - .lstio_bat_resultp = resultp, - }; +lst_start_batch_ioctl (char *name, int timeout, cfs_list_t *resultp) +{ + lstio_batch_run_args_t args = {0}; + + args.lstio_bat_key = session_key; + args.lstio_bat_timeout = timeout; + args.lstio_bat_nmlen = strlen(name); + args.lstio_bat_namep = name; + args.lstio_bat_resultp = resultp; return lst_ioctl(LSTIO_BATCH_START, &args, sizeof(args)); } @@ -2088,7 +2126,7 @@ lst_start_batch_ioctl (char *name, int timeout, struct list_head *resultp) int jt_lst_start_batch(int argc, char **argv) { - struct list_head head; + cfs_list_t head; char *batch; int optidx = 0; int timeout = 0; @@ -2115,7 +2153,7 @@ jt_lst_start_batch(int argc, char **argv) /* Detect the end of the options. */ if (c == -1) break; - + switch (c) { case 't': timeout = atoi(optarg); @@ -2125,7 +2163,7 @@ jt_lst_start_batch(int argc, char **argv) return -1; } } - + if (optind == argc) { batch = LST_DEFAULT_BATCH; @@ -2175,15 +2213,15 @@ jt_lst_start_batch(int argc, char **argv) } int -lst_stop_batch_ioctl(char *name, int force, struct list_head *resultp) -{ - lstio_batch_stop_args_t args = { - .lstio_bat_key = session_key, - .lstio_bat_force = force, - .lstio_bat_nmlen = strlen(name), - .lstio_bat_namep = name, - .lstio_bat_resultp = resultp, - }; +lst_stop_batch_ioctl(char *name, int force, cfs_list_t *resultp) +{ + lstio_batch_stop_args_t args = {0}; + + args.lstio_bat_key = session_key; + args.lstio_bat_force = force; + args.lstio_bat_nmlen = strlen(name); + args.lstio_bat_namep = name; + args.lstio_bat_resultp = resultp; return lst_ioctl(LSTIO_BATCH_STOP, &args, sizeof(args)); } @@ -2191,7 +2229,7 @@ lst_stop_batch_ioctl(char *name, int force, struct list_head *resultp) int jt_lst_stop_batch(int argc, char **argv) { - struct list_head head; + cfs_list_t head; char *batch; int force = 0; int optidx; @@ -2218,7 +2256,7 @@ jt_lst_stop_batch(int argc, char **argv) /* Detect the end of the options. */ if (c == -1) break; - + switch (c) { case 'f': force = 1; @@ -2297,12 +2335,12 @@ out: int lst_list_batch_ioctl(int len, char *name, int index) { - lstio_batch_list_args_t args = { - .lstio_bat_key = session_key, - .lstio_bat_idx = index, - .lstio_bat_nmlen = len, - .lstio_bat_namep = name, - }; + lstio_batch_list_args_t args = {0}; + + args.lstio_bat_key = session_key; + args.lstio_bat_idx = index; + args.lstio_bat_nmlen = len; + args.lstio_bat_namep = name; return lst_ioctl(LSTIO_BATCH_LIST, &args, sizeof(args)); } @@ -2312,17 +2350,17 @@ lst_info_batch_ioctl(char *batch, int test, int server, lstcon_test_batch_ent_t *entp, int *idxp, int *ndentp, lstcon_node_ent_t *dentsp) { - lstio_batch_info_args_t args = { - .lstio_bat_key = session_key, - .lstio_bat_nmlen = strlen(batch), - .lstio_bat_namep = batch, - .lstio_bat_server = server, - .lstio_bat_testidx = test, - .lstio_bat_entp = entp, - .lstio_bat_idxp = idxp, - .lstio_bat_ndentp = ndentp, - .lstio_bat_dentsp = dentsp, - }; + lstio_batch_info_args_t args = {0}; + + args.lstio_bat_key = session_key; + args.lstio_bat_nmlen = strlen(batch); + args.lstio_bat_namep = batch; + args.lstio_bat_server = server; + args.lstio_bat_testidx = test; + args.lstio_bat_entp = entp; + args.lstio_bat_idxp = idxp; + args.lstio_bat_ndentp = ndentp; + args.lstio_bat_dentsp = dentsp; return lst_ioctl(LSTIO_BATCH_INFO, &args, sizeof(args)); } @@ -2341,7 +2379,7 @@ lst_list_batch_all(void) continue; } - if (errno == ENOENT) + if (errno == ENOENT) break; lst_print_error("batch", "Failed to list batch: %s\n", @@ -2364,7 +2402,7 @@ lst_list_tsb_nodes(char *batch, int test, int server, int c; int i; - if (count == 0) + if (count == 0) return 0; /* verbose list, show nodes in batch or test */ @@ -2389,7 +2427,7 @@ lst_list_tsb_nodes(char *batch, int test, int server, if ((!active && dents[i].nde_state == LST_NODE_ACTIVE) || (!invalid && (dents[i].nde_state == LST_NODE_BUSY || dents[i].nde_state == LST_NODE_DOWN || - dents[i].nde_state == LST_NODE_UNKNOWN))) + dents[i].nde_state == LST_NODE_UNKNOWN))) continue; fprintf(stdout, "\t%s: %s\n", @@ -2397,7 +2435,7 @@ lst_list_tsb_nodes(char *batch, int test, int server, lst_node_state2str(dents[i].nde_state)); c++; } - + fprintf(stdout, "Total %d nodes\n", c); free(dents); @@ -2441,7 +2479,7 @@ jt_lst_list_batch(int argc, char **argv) if (c == -1) break; - + switch (c) { case 'a': verbose = active = 1; @@ -2480,7 +2518,7 @@ jt_lst_list_batch(int argc, char **argv) lst_print_usage(argv[0]); return -1; } - + batch = argv[optind]; loop: @@ -2525,7 +2563,7 @@ loop: fprintf(stdout, LST_NODES_TITLE); fprintf(stdout, "client\t%d\t%d\t%d\t%d\t%d\n" "server\t%d\t%d\t%d\t%d\t%d\n", - ent.tbe_cli_nle.nle_nactive, + ent.tbe_cli_nle.nle_nactive, ent.tbe_cli_nle.nle_nbusy, ent.tbe_cli_nle.nle_ndown, ent.tbe_cli_nle.nle_nunknown, @@ -2544,28 +2582,28 @@ loop: int lst_query_batch_ioctl(char *batch, int test, int server, - int timeout, struct list_head *head) -{ - lstio_batch_query_args_t args = { - .lstio_bat_key = session_key, - .lstio_bat_testidx = test, - .lstio_bat_client = !(server), - .lstio_bat_timeout = timeout, - .lstio_bat_nmlen = strlen(batch), - .lstio_bat_namep = batch, - .lstio_bat_resultp = head, - }; + int timeout, cfs_list_t *head) +{ + lstio_batch_query_args_t args = {0}; + + args.lstio_bat_key = session_key; + args.lstio_bat_testidx = test; + args.lstio_bat_client = !(server); + args.lstio_bat_timeout = timeout; + args.lstio_bat_nmlen = strlen(batch); + args.lstio_bat_namep = batch; + args.lstio_bat_resultp = head; return lst_ioctl(LSTIO_BATCH_QUERY, &args, sizeof(args)); } void -lst_print_tsb_verbose(struct list_head *head, +lst_print_tsb_verbose(cfs_list_t *head, int active, int idle, int error) { lstcon_rpc_ent_t *ent; - list_for_each_entry(ent, head, rpe_link) { + cfs_list_for_each_entry_typed(ent, head, lstcon_rpc_ent_t, rpe_link) { if (ent->rpe_priv[0] == 0 && active) continue; @@ -2588,23 +2626,23 @@ int jt_lst_query_batch(int argc, char **argv) { lstcon_test_batch_ent_t ent; - struct list_head head; - char *batch = NULL; - time_t last = 0; - int optidx = 0; - int verbose = 0; - int server = 0; - int timeout = 5; /* default 5 seconds */ - int delay = 5; /* default 5 seconds */ - int loop = 1; /* default 1 loop */ - int active = 0; - int error = 0; - int idle = 0; - int count = 0; - int test = 0; - int rc = 0; - int c = 0; - int i; + cfs_list_t head; + char *batch = NULL; + time_t last = 0; + int optidx = 0; + int verbose = 0; + int server = 0; + int timeout = 5; /* default 5 seconds */ + int delay = 5; /* default 5 seconds */ + int loop = 1; /* default 1 loop */ + int active = 0; + int error = 0; + int idle = 0; + int count = 0; + int test = 0; + int rc = 0; + int c = 0; + int i; static struct option query_batch_opts[] = { @@ -2633,7 +2671,7 @@ jt_lst_query_batch(int argc, char **argv) /* Detect the end of the options. */ if (c == -1) break; - + switch (c) { case 'o': timeout = atoi(optarg); @@ -2712,7 +2750,7 @@ jt_lst_query_batch(int argc, char **argv) for (i = 0; i < loop; i++) { time_t now = time(NULL); - + if (now - last < delay) { sleep(delay - now + last); time(&now); @@ -2766,7 +2804,7 @@ jt_lst_query_batch(int argc, char **argv) return rc; } - + int lst_parse_distribute(char *dstr, int *dist, int *span) { @@ -2775,7 +2813,7 @@ lst_parse_distribute(char *dstr, int *dist, int *span) return -1; dstr = strchr(dstr, ':'); - if (dstr == NULL) + if (dstr == NULL) return -1; *span = atoi(dstr + 1); @@ -2786,67 +2824,104 @@ lst_parse_distribute(char *dstr, int *dist, int *span) } int +lst_get_bulk_param(int argc, char **argv, lst_test_bulk_param_t *bulk) +{ + char *tok = NULL; + char *end = NULL; + int rc = 0; + int i = 0; + + bulk->blk_size = 4096; + bulk->blk_opc = LST_BRW_READ; + bulk->blk_flags = LST_BRW_CHECK_NONE; + + while (i < argc) { + if (strcasestr(argv[i], "check=") == argv[i] || + strcasestr(argv[i], "c=") == argv[i]) { + tok = strchr(argv[i], '=') + 1; + + if (strcasecmp(tok, "full") == 0) { + bulk->blk_flags = LST_BRW_CHECK_FULL; + } else if (strcasecmp(tok, "simple") == 0) { + bulk->blk_flags = LST_BRW_CHECK_SIMPLE; + } else { + fprintf(stderr, "Unknow flag %s\n", tok); + return -1; + } + + } else if (strcasestr(argv[i], "size=") == argv[i] || + strcasestr(argv[i], "s=") == argv[i]) { + tok = strchr(argv[i], '=') + 1; + + bulk->blk_size = strtol(tok, &end, 0); + if (bulk->blk_size <= 0) { + fprintf(stderr, "Invalid size %s\n", tok); + return -1; + } + + if (end == NULL) + return 0; + + if (*end == 'k' || *end == 'K') + bulk->blk_size *= 1024; + else if (*end == 'm' || *end == 'M') + bulk->blk_size *= 1024 * 1024; + + if (bulk->blk_size > CFS_PAGE_SIZE * LNET_MAX_IOV) { + fprintf(stderr, "Size exceed limitation: %d bytes\n", + bulk->blk_size); + return -1; + } + + } else if (strcasecmp(argv[i], "read") == 0 || + strcasecmp(argv[i], "r") == 0) { + bulk->blk_opc = LST_BRW_READ; + + } else if (strcasecmp(argv[i], "write") == 0 || + strcasecmp(argv[i], "w") == 0) { + bulk->blk_opc = LST_BRW_WRITE; + + } else { + fprintf(stderr, "Unknow parameter: %s\n", argv[i]); + return -1; + } + + i++; + } + + return rc; +} + +int lst_get_test_param(char *test, int argc, char **argv, void **param, int *plen) { lst_test_bulk_param_t *bulk = NULL; int type; - int i = 0; type = lst_test_name2type(test); - if (type < 0) - return -EINVAL; + if (type < 0) { + fprintf(stderr, "Unknow test name %s\n", test); + return -1; + } switch (type) { case LST_TEST_PING: break; case LST_TEST_BULK: - if (i == argc) - return -EINVAL; - bulk = malloc(sizeof(*bulk)); - if (bulk == NULL) - return -ENOMEM; + if (bulk == NULL) { + fprintf(stderr, "Out of memory\n"); + return -1; + } memset(bulk, 0, sizeof(*bulk)); - if (strcmp(argv[i], "w") == 0) - bulk->blk_opc = LST_BRW_WRITE; - else /* read by default */ - bulk->blk_opc = LST_BRW_READ; - - if (++i == argc) { - /* 1 page by default */ - bulk->blk_flags = LST_BRW_CHECK_NONE; - bulk->blk_npg = 1; - *param = bulk; - *plen = sizeof(*bulk); - break; - - } - - bulk->blk_npg = atoi(argv[i]); - if (bulk->blk_npg <= 0 || - bulk->blk_npg >= LNET_MAX_IOV) { + if (lst_get_bulk_param(argc, argv, bulk) != 0) { free(bulk); - return -EINVAL; - } - - if (++i == argc) { - bulk->blk_flags = LST_BRW_CHECK_NONE; - *param = bulk; - *plen = sizeof(*bulk); - break; + return -1; } - /* posion pages */ - if (strcmp(argv[i], "s") == 0) - bulk->blk_flags = LST_BRW_CHECK_SIMPLE; - else if (strcmp(argv[i], "f") == 0) - bulk->blk_flags = LST_BRW_CHECK_FULL; - else - bulk->blk_flags = LST_BRW_CHECK_NONE; - *param = bulk; *plen = sizeof(*bulk); @@ -2855,7 +2930,7 @@ lst_get_test_param(char *test, int argc, char **argv, void **param, int *plen) default: break; } - + /* TODO: parse more parameter */ return type; } @@ -2863,26 +2938,27 @@ lst_get_test_param(char *test, int argc, char **argv, void **param, int *plen) int lst_add_test_ioctl(char *batch, int type, int loop, int concur, int dist, int span, char *sgrp, char *dgrp, - void *param, int plen, int *retp, struct list_head *resultp) -{ - lstio_test_args_t args = { - .lstio_tes_key = session_key, - .lstio_tes_bat_nmlen = strlen(batch), - .lstio_tes_bat_name = batch, - .lstio_tes_type = type, - .lstio_tes_loop = loop, - .lstio_tes_concur = concur, - .lstio_tes_dist = dist, - .lstio_tes_span = span, - .lstio_tes_sgrp_nmlen = strlen(sgrp), - .lstio_tes_sgrp_name = sgrp, - .lstio_tes_dgrp_nmlen = strlen(dgrp), - .lstio_tes_dgrp_name = dgrp, - .lstio_tes_param_len = plen, - .lstio_tes_param = param, - .lstio_tes_retp = retp, - .lstio_tes_resultp = resultp, - }; + void *param, int plen, int *retp, cfs_list_t *resultp) +{ + lstio_test_args_t args = {0}; + + args.lstio_tes_key = session_key; + args.lstio_tes_bat_nmlen = strlen(batch); + args.lstio_tes_bat_name = batch; + args.lstio_tes_type = type; + args.lstio_tes_oneside = 0; + args.lstio_tes_loop = loop; + args.lstio_tes_concur = concur; + args.lstio_tes_dist = dist; + args.lstio_tes_span = span; + args.lstio_tes_sgrp_nmlen = strlen(sgrp); + args.lstio_tes_sgrp_name = sgrp; + args.lstio_tes_dgrp_nmlen = strlen(dgrp); + args.lstio_tes_dgrp_name = dgrp; + args.lstio_tes_param_len = plen; + args.lstio_tes_param = param; + args.lstio_tes_retp = retp; + args.lstio_tes_resultp = resultp; return lst_ioctl(LSTIO_TEST_ADD, &args, sizeof(args)); } @@ -2890,25 +2966,25 @@ lst_add_test_ioctl(char *batch, int type, int loop, int concur, int jt_lst_add_test(int argc, char **argv) { - struct list_head head; - char *batch = NULL; - char *test = NULL; - char *dstr = NULL; - char *from = NULL; - char *to = NULL; - void *param = NULL; - int optidx = 0; - int concur = 1; - int loop = -1; - int dist = 1; - int span = 1; - int plen = 0; - int fcount = 0; - int tcount = 0; - int ret = 0; - int type; - int rc; - int c; + cfs_list_t head; + char *batch = NULL; + char *test = NULL; + char *dstr = NULL; + char *from = NULL; + char *to = NULL; + void *param = NULL; + int optidx = 0; + int concur = 1; + int loop = -1; + int dist = 1; + int span = 1; + int plen = 0; + int fcount = 0; + int tcount = 0; + int ret = 0; + int type; + int rc; + int c; static struct option add_test_opts[] = { @@ -2934,7 +3010,7 @@ jt_lst_add_test(int argc, char **argv) /* Detect the end of the options. */ if (c == -1) break; - + switch (c) { case 'b': batch = optarg; @@ -2988,8 +3064,7 @@ jt_lst_add_test(int argc, char **argv) type = lst_get_test_param(test, argc, argv, ¶m, &plen); if (type < 0) { - fprintf(stderr, "Can't parse test (%s) parameter: %s\n", - test, strerror(-type)); + fprintf(stderr, "Failed to add test (%s)\n", test); return -1; } @@ -3066,7 +3141,7 @@ static command_t lst_cmdlist[] = { "Usage: lst stat [--bw] [--rate] [--read] [--write] [--max] [--min] [--avg] " " [--timeout #] [--delay #] GROUP [GROUP]" }, {"show_error", jt_lst_show_error, NULL, - "Usage: lst show_error [--group NAME] | [--nodes IDS]" }, + "Usage: lst show_error NAME | IDS ..." }, {"add_batch", jt_lst_add_batch, NULL, "Usage: lst add_batch NAME" }, {"run", jt_lst_start_batch, NULL, @@ -3104,20 +3179,32 @@ lst_initialize(void) int main(int argc, char **argv) { + int rc = 0; + setlinebuf(stdout); - if (lst_initialize() < 0) - exit(0); + rc = libcfs_arch_init(); + if (rc < 0) + return rc; + + rc = lst_initialize(); + if (rc < 0) + goto errorout; - if (ptl_initialize(argc, argv) < 0) - exit(0); + rc = ptl_initialize(argc, argv); + if (rc < 0) + goto errorout; Parser_init("lst > ", lst_cmdlist); - if (argc != 1) - return Parser_execarg(argc - 1, argv + 1, lst_cmdlist); + if (argc != 1) { + rc = Parser_execarg(argc - 1, argv + 1, lst_cmdlist); + goto errorout; + } Parser_commands(); - return 0; +errorout: + libcfs_arch_cleanup(); + return rc; }