Whamcloud - gitweb
LU-14945 lnet: don't use hops to determine the route state
[fs/lustre-release.git] / lnet / utils / lst.c
index ff6b01e..97eeb9f 100644 (file)
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * lnet/selftest/conctl.c
  *
 #include <string.h>
 #include <sys/ioctl.h>
 #include <time.h>
+#include <linux/types.h>
 
 #include <libcfs/util/list.h>
 #include <libcfs/util/ioctl.h>
 #include <libcfs/util/parser.h>
-#include <lnet/lnetctl.h>
-#include <lnet/lnetst.h>
-#include <lnet/lnet.h>
-#include <utils/obdctl.h>
+#include <linux/lnet/lnetctl.h>
+#include <linux/lnet/lnetst.h>
+#include <linux/lnet/nidstr.h>
+#include "lnetconfig/liblnetconfig.h"
 
-struct lst_sid LST_INVALID_SID = {LNET_NID_ANY, -1};
+struct lst_sid LST_INVALID_SID = { .ses_nid = LNET_NID_ANY, .ses_stamp = -1 };
 static struct lst_sid session_id;
 static int                 session_key;
+static int lst_list_commands(int argc, char **argv);
 
 /* All nodes running 2.6.50 or later understand feature LST_FEAT_BULK_LEN */
 static unsigned                session_features = LST_FEATS_MASK;
@@ -252,7 +253,7 @@ expand_strs(char *str, lstr_t **head)
 }
 
 int
-lst_parse_nids(char *str, int *countp, lnet_process_id_t **idspp)
+lst_parse_nids(char *str, int *countp, struct lnet_process_id **idspp)
 {
         lstr_t  *head = NULL;
         lstr_t  *l;
@@ -270,7 +271,7 @@ lst_parse_nids(char *str, int *countp, lnet_process_id_t **idspp)
                 c++;
         }
 
-        *idspp = malloc(c * sizeof(lnet_process_id_t));
+       *idspp = malloc(c * sizeof(struct lnet_process_id));
         if (*idspp == NULL) {
                 fprintf(stderr, "Out of memory\n");
                 rc = -1;
@@ -532,22 +533,20 @@ lst_new_session_ioctl(char *name, int timeout, int force, struct lst_sid *sid)
 }
 
 int
-jt_lst_new_session(int argc,  char **argv)
-{
-        char  buf[LST_NAME_SIZE];
-        char *name;
-        int   optidx  = 0;
-        int   timeout = 300;
-        int   force   = 0;
-        int   c;
-        int   rc;
+jt_lst_new_session(int argc, char **argv)
+{
+       char  buf[LST_NAME_SIZE * 2 + 1];
+       char *name;
+       int   optidx = 0;
+       int   timeout = 300;
+       int   force = 0;
+       int   c;
+       int   rc;
 
-        static struct option session_opts[] =
-        {
-                {"timeout", required_argument,  0, 't' },
-                {"force",   no_argument,        0, 'f' },
-                {0,         0,                  0,  0  }
-        };
+       static const struct option session_opts[] = {
+               { .name = "timeout", .has_arg = required_argument, .val = 't' },
+               { .name = "force",   .has_arg = no_argument,       .val = 'f' },
+               { .name = NULL } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -717,7 +716,7 @@ 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)
+              int count, struct lnet_process_id *ids, struct list_head *head)
 {
        struct lstio_debug_args args = { 0 };
 
@@ -735,7 +734,8 @@ lst_ping_ioctl(char *str, int type, int timeout,
 }
 
 int
-lst_get_node_count(int type, char *str, int *countp, lnet_process_id_t **idspp)
+lst_get_node_count(int type, char *str, int *countp,
+                  struct lnet_process_id **idspp)
 {
         char                    buf[LST_NAME_SIZE];
        struct lstcon_test_batch_ent ent;
@@ -780,27 +780,25 @@ int
 jt_lst_ping(int argc,  char **argv)
 {
        struct list_head   head;
-       lnet_process_id_t *ids = NULL;
+       struct lnet_process_id *ids = NULL;
        struct lstcon_rpc_ent  *ent = NULL;
-        char              *str = NULL;
-        int                optidx  = 0;
-        int                server  = 0;
-        int                timeout = 5;
-        int                count   = 0;
-        int                type    = 0;
-        int                rc      = 0;
-        int                c;
-
-        static struct option ping_opts[] =
-        {
-                {"session", no_argument,       0, 's' },
-                {"server",  no_argument,       0, 'v' },
-                {"batch",   required_argument, 0, 'b' },
-                {"group",   required_argument, 0, 'g' },
-                {"nodes",   required_argument, 0, 'n' },
-                {"timeout", required_argument, 0, 't' },
-                {0,         0,                 0,  0  }
-        };
+       char              *str = NULL;
+       int                optidx  = 0;
+       int                server  = 0;
+       int                timeout = 5;
+       int                count   = 0;
+       int                type    = 0;
+       int                rc      = 0;
+       int                c;
+
+       static const struct option ping_opts[] = {
+               { .name = "session", .has_arg = no_argument,       .val = 's' },
+               { .name = "server",  .has_arg = no_argument,       .val = 'v' },
+               { .name = "batch",   .has_arg = required_argument, .val = 'b' },
+               { .name = "group",   .has_arg = required_argument, .val = 'g' },
+               { .name = "nodes",   .has_arg = required_argument, .val = 'n' },
+               { .name = "timeout", .has_arg = required_argument, .val = 't' },
+               { .name = NULL, } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -911,7 +909,7 @@ out:
 }
 
 int
-lst_add_nodes_ioctl(char *name, int count, lnet_process_id_t *ids,
+lst_add_nodes_ioctl(char *name, int count, struct lnet_process_id *ids,
                    unsigned *featp, struct list_head *resultp)
 {
        struct lstio_group_nodes_args args = { 0 };
@@ -991,7 +989,7 @@ int
 jt_lst_add_group(int argc, char **argv)
 {
        struct list_head   head;
-       lnet_process_id_t *ids;
+       struct lnet_process_id *ids;
        char              *name;
        unsigned           feats = session_features;
        int                count;
@@ -1142,7 +1140,7 @@ 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)
+                      struct lnet_process_id *ids, struct list_head *resultp)
 {
        struct lstio_group_update_args args = { 0 };
 
@@ -1161,24 +1159,22 @@ 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;
-        lnet_process_id_t *ids = NULL;
-        char              *str = NULL;
-        char              *grp = NULL;
-        int                optidx = 0;
-        int                count = 0;
-        int                clean = 0;
-        int                opc = 0;
-        int                rc;
-        int                c;
-
-        static struct option update_group_opts[] =
-        {
-                {"refresh", no_argument,       0, 'f' },
-                {"clean",   required_argument, 0, 'c' },
-                {"remove",  required_argument, 0, 'r' },
-                {0,         0,                 0,  0  }
-        };
+       struct list_head   head;
+       struct lnet_process_id *ids = NULL;
+       char              *str = NULL;
+       char              *grp = NULL;
+       int                optidx = 0;
+       int                count = 0;
+       int                clean = 0;
+       int                opc = 0;
+       int                rc;
+       int                c;
+
+       static const struct option update_group_opts[] = {
+               { .name = "refresh", .has_arg = no_argument,       .val = 'f' },
+               { .name = "clean",   .has_arg = required_argument, .val = 'c' },
+               { .name = "remove",  .has_arg = required_argument, .val = 'r' },
+               { .name = NULL } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -1348,29 +1344,27 @@ jt_lst_list_group(int argc, char **argv)
 {
        struct lstcon_ndlist_ent gent;
        struct lstcon_node_ent   *dents;
-        int               optidx  = 0;
-        int               verbose = 0;
-        int               active  = 0;
-        int               busy    = 0;
-        int               down    = 0;
-        int               unknown = 0;
-        int               all     = 0;
-        int               count;
-        int               index;
-        int               i;
-        int               j;
-        int               c;
-        int               rc = 0;
-
-        static struct option list_group_opts[] =
-        {
-                {"active",  no_argument, 0, 'a' },
-                {"busy",    no_argument, 0, 'b' },
-                {"down",    no_argument, 0, 'd' },
-                {"unknown", no_argument, 0, 'u' },
-                {"all",     no_argument, 0, 'l' },
-                {0,         0,           0,  0  }
-        };
+       int optidx  = 0;
+       int verbose = 0;
+       int active  = 0;
+       int busy    = 0;
+       int down    = 0;
+       int unknown = 0;
+       int all     = 0;
+       int count;
+       int index;
+       int i;
+       int j;
+       int c;
+       int rc      = 0;
+
+       static const struct option list_group_opts[] = {
+               { .name = "active",  .has_arg = no_argument, .val = 'a' },
+               { .name = "busy",    .has_arg = no_argument, .val = 'b' },
+               { .name = "down",    .has_arg = no_argument, .val = 'd' },
+               { .name = "unknown", .has_arg = no_argument, .val = 'u' },
+               { .name = "all",     .has_arg = no_argument, .val = 'l' },
+               { .name = NULL, } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -1491,8 +1485,8 @@ 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)
+lst_stat_ioctl(char *name, int count, struct lnet_process_id *idsp,
+              int timeout, struct list_head *resultp)
 {
        struct lstio_stat_args args = { 0 };
 
@@ -1511,7 +1505,7 @@ typedef struct {
        struct list_head              srp_link;
         int                     srp_count;
         char                   *srp_name;
-        lnet_process_id_t      *srp_ids;
+       struct lnet_process_id      *srp_ids;
        struct list_head              srp_result[2];
 } lst_stat_req_param_t;
 
@@ -1561,27 +1555,27 @@ lst_stat_req_param_alloc(char *name, lst_stat_req_param_t **srpp, int save_old)
                 return rc;
         }
 
-        srp->srp_name = name;
+       srp->srp_name = name;
 
-        for (i = 0; i < count; i++) {
-                rc = lst_alloc_rpcent(&srp->srp_result[i], srp->srp_count,
+       for (i = 0; i < count; i++) {
+               rc = lst_alloc_rpcent(&srp->srp_result[i], srp->srp_count,
                                      sizeof(struct sfw_counters)  +
                                      sizeof(struct srpc_counters) +
-                                      sizeof(lnet_counters_t));
-                if (rc != 0) {
-                        fprintf(stderr, "Out of memory\n");
-                        break;
-                }
-        }
+                                     sizeof(struct lnet_counters_common));
+               if (rc != 0) {
+                       fprintf(stderr, "Out of memory\n");
+                       break;
+               }
+       }
 
-        if (rc == 0) {
-                *srpp = srp;
-                return 0;
-        }
+       if (rc == 0) {
+               *srpp = srp;
+               return 0;
+       }
 
-        lst_stat_req_param_free(srp);
+       lst_stat_req_param_free(srp);
 
-        return rc;
+       return rc;
 }
 
 typedef struct {
@@ -1636,32 +1630,16 @@ lst_lnet_stat_value(int bw, int send, int off)
 }
 
 static void
-lst_timeval_diff(struct timeval *tv1,
-                struct timeval *tv2, struct timeval *df)
-{
-       if (tv1->tv_usec >= tv2->tv_usec) {
-               df->tv_sec  = tv1->tv_sec - tv2->tv_sec;
-               df->tv_usec = tv1->tv_usec - tv2->tv_usec;
-               return;
-       }
-
-       df->tv_sec  = tv1->tv_sec - 1 - tv2->tv_sec;
-       df->tv_usec = tv1->tv_usec + 1000000 - tv2->tv_usec;
-
-       return;
-}
-
-static void
-lst_cal_lnet_stat(float delta, lnet_counters_t *lnet_new,
-                 lnet_counters_t *lnet_old, int mbs)
+lst_cal_lnet_stat(float delta, struct lnet_counters_common *lnet_new,
+                 struct lnet_counters_common *lnet_old, int mbs)
 {
        float perf;
        float rate;
        unsigned int unit_divisor;
 
        unit_divisor = (mbs) ? (1000 * 1000) : (1024 * 1024);
-       perf = (float)(lnet_new->send_length -
-                      lnet_old->send_length) / unit_divisor / delta;
+       perf = (float)(lnet_new->lcc_send_length -
+                      lnet_old->lcc_send_length) / unit_divisor / delta;
        lnet_stat_result.lnet_total_sndperf += perf;
 
        if (lnet_stat_result.lnet_min_sndperf > perf ||
@@ -1671,8 +1649,8 @@ lst_cal_lnet_stat(float delta, lnet_counters_t *lnet_new,
        if (lnet_stat_result.lnet_max_sndperf < perf)
                lnet_stat_result.lnet_max_sndperf = perf;
 
-       perf = (float)(lnet_new->recv_length -
-                      lnet_old->recv_length) / unit_divisor / delta;
+       perf = (float)(lnet_new->lcc_recv_length -
+                      lnet_old->lcc_recv_length) / unit_divisor / delta;
        lnet_stat_result.lnet_total_rcvperf += perf;
 
        if (lnet_stat_result.lnet_min_rcvperf > perf ||
@@ -1682,7 +1660,7 @@ lst_cal_lnet_stat(float delta, lnet_counters_t *lnet_new,
        if (lnet_stat_result.lnet_max_rcvperf < perf)
                lnet_stat_result.lnet_max_rcvperf = perf;
 
-       rate = (lnet_new->send_count - lnet_old->send_count) / delta;
+       rate = (lnet_new->lcc_send_count - lnet_old->lcc_send_count) / delta;
        lnet_stat_result.lnet_total_sndrate += rate;
 
        if (lnet_stat_result.lnet_min_sndrate > rate ||
@@ -1692,7 +1670,7 @@ lst_cal_lnet_stat(float delta, lnet_counters_t *lnet_new,
        if (lnet_stat_result.lnet_max_sndrate < rate)
                lnet_stat_result.lnet_max_sndrate = rate;
 
-       rate = (lnet_new->recv_count - lnet_old->recv_count) / delta;
+       rate = (lnet_new->lcc_recv_count - lnet_old->lcc_recv_count) / delta;
        lnet_stat_result.lnet_total_rcvrate += rate;
 
        if (lnet_stat_result.lnet_min_rcvrate > rate ||
@@ -1778,17 +1756,17 @@ lst_print_stat(char *name, struct list_head *resultp,
               int idx, int lnet, int bwrt, int rdwr, int type,
               int mbs)
 {
-       struct list_head        tmp[2];
+       struct list_head tmp[2];
        struct lstcon_rpc_ent *new;
        struct lstcon_rpc_ent *old;
-       struct sfw_counters   *sfwk_new;
-       struct sfw_counters   *sfwk_old;
-       struct srpc_counters  *srpc_new;
-       struct srpc_counters  *srpc_old;
-        lnet_counters_t  *lnet_new;
-        lnet_counters_t  *lnet_old;
-        float             delta;
-        int               errcount = 0;
+       struct sfw_counters *sfwk_new;
+       struct sfw_counters *sfwk_old;
+       struct srpc_counters *srpc_new;
+       struct srpc_counters *srpc_old;
+       struct lnet_counters_common *lnet_new;
+       struct lnet_counters_common *lnet_old;
+       float delta;
+       int errcount = 0;
 
        INIT_LIST_HEAD(&tmp[0]);
        INIT_LIST_HEAD(&tmp[1]);
@@ -1816,11 +1794,9 @@ lst_print_stat(char *name, struct list_head *resultp,
                         break;
                 }
 
-               list_del(&new->rpe_link);
-               list_add_tail(&new->rpe_link, &tmp[idx]);
+               list_move_tail(&new->rpe_link, &tmp[idx]);
 
-               list_del(&old->rpe_link);
-               list_add_tail(&old->rpe_link, &tmp[1 - idx]);
+               list_move_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) {
@@ -1831,32 +1807,26 @@ lst_print_stat(char *name, struct list_head *resultp,
                sfwk_new = (struct sfw_counters *)&new->rpe_payload[0];
                sfwk_old = (struct sfw_counters *)&old->rpe_payload[0];
 
-               srpc_new = (struct srpc_counters *)((char *)sfwk_new + sizeof(*sfwk_new));
-               srpc_old = (struct srpc_counters *)((char *)sfwk_old + sizeof(*sfwk_old));
-
-                lnet_new = (lnet_counters_t *)((char *)srpc_new + sizeof(*srpc_new));
-                lnet_old = (lnet_counters_t *)((char *)srpc_old + sizeof(*srpc_old));
-
-               /* Prior to version 2.3, the running_ms field was a counter for
-                * the number of running tests.  We are looking at this value
-                * to determine if it is a millisecond timestamep (>= 2.3) or a
-                * test counter (< 2.3).  The number 500 is being used for this
-                * barrier as the test counter should never get this high, and
-                * the timestamp should never get this low. */
-
-               if (sfwk_new->running_ms > 500) {
-                       /* use the timestamp from the remote node, not our
-                        * rpe_stamp from when we copied up the data out of
-                        * the kernel */
-
-                       delta = (float) (sfwk_new->running_ms -
-                                       sfwk_old->running_ms) / 1000;
-               } else {
-                       struct timeval    tv;
-
-                       lst_timeval_diff(&new->rpe_stamp, &old->rpe_stamp, &tv);
-                       delta = tv.tv_sec + (float)tv.tv_usec / 1000000;
-               }
+               srpc_new = (struct srpc_counters *)((char *)sfwk_new +
+                                                   sizeof(*sfwk_new));
+               srpc_old = (struct srpc_counters *)((char *)sfwk_old +
+                                                   sizeof(*sfwk_old));
+
+               lnet_new = (struct lnet_counters_common *)((char *)srpc_new +
+                                                          sizeof(*srpc_new));
+               lnet_old = (struct lnet_counters_common *)((char *)srpc_old +
+                                                          sizeof(*srpc_old));
+
+               /* Prior to version 2.3, the running_ms was a counter for
+                * the number of running tests. Since 2.3, running_ms is
+                * changed to hold the millisecond since the start of
+                * the work item. The rpe_stamp field was formerly used,
+                * but is no longer. In 2.12 rpe_stamp was changed to
+                * struct timespec64 and has nanosecond resolution, in
+                * case it is needed in the future.
+                */
+               delta = (float)(sfwk_new->running_ms -
+                               sfwk_old->running_ms) / 1000;
 
                if (!lnet) /* TODO */
                        continue;
@@ -1895,22 +1865,21 @@ jt_lst_stat(int argc, char **argv)
        int                   c;
        int                   mbs     = 0; /* report as MB/s */
 
-       static struct option stat_opts[] = {
-               {"timeout"   , required_argument, 0, 't' },
-               {"delay"     , required_argument, 0, 'd' },
-               {"count"     , required_argument, 0, 'o' },
-               {"lnet"      , no_argument,      0, 'l' },
-               {"rpc"       , no_argument,      0, 'c' },
-               {"bw"        , no_argument,      0, 'b' },
-               {"rate"      , no_argument,      0, 'a' },
-               {"read"      , no_argument,      0, 'r' },
-               {"write"     , no_argument,      0, 'w' },
-               {"avg"       , no_argument,      0, 'g' },
-               {"min"       , no_argument,      0, 'n' },
-               {"max"       , no_argument,      0, 'x' },
-               {"mbs"       , no_argument,      0, 'm' },
-               {0,            0,                0,  0  }
-        };
+       static const struct option stat_opts[] = {
+               { .name = "timeout", .has_arg = required_argument, .val = 't' },
+               { .name = "delay",   .has_arg = required_argument, .val = 'd' },
+               { .name = "count",   .has_arg = required_argument, .val = 'o' },
+               { .name = "lnet",    .has_arg = no_argument,       .val = 'l' },
+               { .name = "rpc",     .has_arg = no_argument,       .val = 'c' },
+               { .name = "bw",      .has_arg = no_argument,       .val = 'b' },
+               { .name = "rate",    .has_arg = no_argument,       .val = 'a' },
+               { .name = "read",    .has_arg = no_argument,       .val = 'r' },
+               { .name = "write",   .has_arg = no_argument,       .val = 'w' },
+               { .name = "avg",     .has_arg = no_argument,       .val = 'g' },
+               { .name = "min",     .has_arg = no_argument,       .val = 'n' },
+               { .name = "max",     .has_arg = no_argument,       .val = 'x' },
+               { .name = "mbs",     .has_arg = no_argument,       .val = 'm' },
+               { .name = NULL } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -2058,22 +2027,20 @@ out:
 int
 jt_lst_show_error(int argc, char **argv)
 {
-       struct list_head            head;
-        lst_stat_req_param_t *srp;
-       struct lstcon_rpc_ent     *ent;
-       struct sfw_counters       *sfwk;
-       struct srpc_counters      *srpc;
-        int                   show_rpc = 1;
-        int                   optidx   = 0;
-        int                   rc       = 0;
-        int                   ecount;
-        int                   c;
-
-        static struct option  show_error_opts[] =
-        {
-                {"session", no_argument,       0, 's' },
-                {0,         0,                 0,  0  }
-        };
+       struct list_head       head;
+       lst_stat_req_param_t  *srp;
+       struct lstcon_rpc_ent *ent;
+       struct sfw_counters   *sfwk;
+       struct srpc_counters  *srpc;
+       int                    show_rpc = 1;
+       int                    optidx = 0;
+       int                    rc = 0;
+       int                    ecount;
+       int                    c;
+
+       static const struct option show_error_opts[] = {
+               { .name = "session", .has_arg = no_argument, .val = 's' },
+               { .name = NULL, } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -2243,19 +2210,17 @@ 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;
-        char             *batch;
-        int               optidx  = 0;
-        int               timeout = 0;
-        int               count = 0;
-        int               rc;
-        int               c;
+       struct list_head  head;
+       char             *batch;
+       int               optidx = 0;
+       int               timeout = 0;
+       int               count = 0;
+       int               rc;
+       int               c;
 
-        static struct option start_batch_opts[] =
-        {
-                {"timeout", required_argument, 0, 't' },
-                {0,         0,                 0,  0  }
-        };
+       static const struct option start_batch_opts[] = {
+               { .name = "timeout", .has_arg = required_argument, .val = 't' },
+               { .name = NULL } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -2346,19 +2311,17 @@ 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;
-        char             *batch;
-        int               force = 0;
-        int               optidx;
-        int               count;
-        int               rc;
-        int               c;
+       struct list_head  head;
+       char             *batch;
+       int               force = 0;
+       int               optidx;
+       int               count;
+       int               rc;
+       int               c;
 
-        static struct option stop_batch_opts[] =
-        {
-                {"force",   no_argument,   0, 'f' },
-                {0,         0,             0,  0  }
-        };
+       static const struct option stop_batch_opts[] = {
+               { .name = "force", .has_arg = no_argument, .val = 'f' },
+               { .name = NULL } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -2563,26 +2526,24 @@ int
 jt_lst_list_batch(int argc, char **argv)
 {
        struct lstcon_test_batch_ent ent;
-        char                *batch   = NULL;
-        int                  optidx  = 0;
-        int                  verbose = 0; /* list nodes in batch or test */
-        int                  invalid = 0;
-        int                  active  = 0;
-        int                  server  = 0;
-        int                  ntest   = 0;
-        int                  test    = 0;
-        int                  c       = 0;
-        int                  rc;
-
-        static struct option list_batch_opts[] =
-        {
-                {"test",    required_argument, 0, 't' },
-                {"invalid", no_argument,       0, 'i' },
-                {"active",  no_argument,       0, 'a' },
-                {"all",     no_argument,       0, 'l' },
-                {"server",  no_argument,       0, 's' },
-                {0,         0,                 0,  0  }
-        };
+       char *batch   = NULL;
+       int   optidx  = 0;
+       int   verbose = 0; /* list nodes in batch or test */
+       int   invalid = 0;
+       int   active  = 0;
+       int   server  = 0;
+       int   ntest   = 0;
+       int   test    = 0;
+       int   c       = 0;
+       int   rc;
+
+       static const struct option list_batch_opts[] = {
+               { .name = "test",    .has_arg = required_argument, .val = 't' },
+               { .name = "invalid", .has_arg = no_argument,       .val = 'i' },
+               { .name = "active",  .has_arg = no_argument,       .val = 'a' },
+               { .name = "all",     .has_arg = no_argument,       .val = 'l' },
+               { .name = "server",  .has_arg = no_argument,       .val = 's' },
+               { .name = NULL, } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -2743,37 +2704,35 @@ int
 jt_lst_query_batch(int argc, char **argv)
 {
        struct lstcon_test_batch_ent 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;
-
-        static struct option query_batch_opts[] =
-        {
-                {"timeout", required_argument, 0, 'o' },
-                {"delay",   required_argument, 0, 'd' },
-                {"loop",    required_argument, 0, 'c' },
-                {"test",    required_argument, 0, 't' },
-                {"server",  no_argument,       0, 's' },
-                {"active",  no_argument,       0, 'a' },
-                {"idle",    no_argument,       0, 'i' },
-                {"error",   no_argument,       0, 'e' },
-                {"all",     no_argument,       0, 'l' },
-                {0,         0,                 0,  0  }
-        };
+       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;
+
+       static const struct option query_batch_opts[] = {
+               { .name = "timeout", .has_arg = required_argument, .val = 'o' },
+               { .name = "delay",   .has_arg = required_argument, .val = 'd' },
+               { .name = "loop",    .has_arg = required_argument, .val = 'c' },
+               { .name = "test",    .has_arg = required_argument, .val = 't' },
+               { .name = "server",  .has_arg = no_argument,       .val = 's' },
+               { .name = "active",  .has_arg = no_argument,       .val = 'a' },
+               { .name = "idle",    .has_arg = no_argument,       .val = 'i' },
+               { .name = "error",   .has_arg = no_argument,       .val = 'e' },
+               { .name = "all",     .has_arg = no_argument,       .val = 'l' },
+               { .name = NULL, } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -2969,8 +2928,6 @@ lst_get_bulk_param(int argc, char **argv, struct lst_test_bulk_param *bulk)
 
                } else if (strcasestr(argv[i], "size=") == argv[i] ||
                           strcasestr(argv[i], "s=") == argv[i]) {
-                       int max_size = sysconf(_SC_PAGESIZE) * LNET_MAX_IOV;
-
                         tok = strchr(argv[i], '=') + 1;
 
                         bulk->blk_size = strtol(tok, &end, 0);
@@ -2987,7 +2944,7 @@ lst_get_bulk_param(int argc, char **argv, struct lst_test_bulk_param *bulk)
                         else if (*end == 'm' || *end == 'M')
                                 bulk->blk_size *= 1024 * 1024;
 
-                       if (bulk->blk_size > max_size) {
+                       if (bulk->blk_size > LNET_MTU) {
                                 fprintf(stderr, "Size exceed limitation: %d bytes\n",
                                         bulk->blk_size);
                                 return -1;
@@ -3107,36 +3064,34 @@ 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;
-
-        static struct option add_test_opts[] =
-        {
-                {"batch",       required_argument, 0, 'b' },
-                {"concurrency", required_argument, 0, 'c' },
-                {"distribute",  required_argument, 0, 'd' },
-                {"from",        required_argument, 0, 'f' },
-                {"to",          required_argument, 0, 't' },
-                {"loop",        required_argument, 0, 'l' },
-                {0,             0,                 0,  0  }
-        };
+       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;
+
+       static const struct option add_test_opts[] = {
+       { .name = "batch",       .has_arg = required_argument, .val = 'b' },
+       { .name = "concurrency", .has_arg = required_argument, .val = 'c' },
+       { .name = "distribute",  .has_arg = required_argument, .val = 'd' },
+       { .name = "from",        .has_arg = required_argument, .val = 'f' },
+       { .name = "to",          .has_arg = required_argument, .val = 't' },
+       { .name = "loop",        .has_arg = required_argument, .val = 'l' },
+       { .name = NULL } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -3297,6 +3252,7 @@ static command_t lst_cmdlist[] = {
          "Usage: lst add_test [--batch BATCH] [--loop #] [--concurrency #] "
          " [--distribute #:#] [--from GROUP] [--to GROUP] TEST..."                      },
         {"help",                Parser_help,            0,     "help"                   },
+       {"--list-commands",     lst_list_commands,      0,     "list commands"          },
         {0,                     0,                      0,      NULL                    }
 };
 
@@ -3330,6 +3286,15 @@ lst_initialize(void)
         return 0;
 }
 
+static int lst_list_commands(int argc, char **argv)
+{
+       char buffer[81] = ""; /* 80 printable chars + terminating NUL */
+
+       Parser_list_commands(lst_cmdlist, buffer, sizeof(buffer), NULL, 0, 4);
+
+       return 0;
+}
+
 int
 main(int argc, char **argv)
 {
@@ -3341,9 +3306,9 @@ main(int argc, char **argv)
         if (rc < 0)
                 goto errorout;
 
-        rc = ptl_initialize(argc, argv);
-        if (rc < 0)
-                goto errorout;
+       rc = lustre_lnet_config_lib_init();
+       if (rc < 0)
+               goto errorout;
 
         Parser_init("lst > ", lst_cmdlist);