Whamcloud - gitweb
LU-11130 osd-ldiskfs: create non-empty local agent symlinks
[fs/lustre-release.git] / lnet / utils / lst.c
index 6d77a61..7d11a24 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2016, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 #include <libcfs/util/list.h>
 #include <libcfs/util/ioctl.h>
 #include <libcfs/util/parser.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 = { .ses_nid = LNET_NID_ANY, .ses_stamp = -1 };
 static struct lst_sid session_id;
 static int                 session_key;
 
 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;
 
 /* 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
 }
 
 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;
 {
         lstr_t  *head = NULL;
         lstr_t  *l;
@@ -270,7 +271,7 @@ lst_parse_nids(char *str, int *countp, lnet_process_id_t **idspp)
                 c++;
         }
 
                 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;
         if (*idspp == NULL) {
                 fprintf(stderr, "Out of memory\n");
                 rc = -1;
@@ -715,7 +716,7 @@ jt_lst_end_session(int argc, char **argv)
 
 int
 lst_ping_ioctl(char *str, int type, int timeout,
 
 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 };
 
 {
        struct lstio_debug_args args = { 0 };
 
@@ -733,7 +734,8 @@ lst_ping_ioctl(char *str, int type, int timeout,
 }
 
 int
 }
 
 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;
 {
         char                    buf[LST_NAME_SIZE];
        struct lstcon_test_batch_ent ent;
@@ -778,7 +780,7 @@ int
 jt_lst_ping(int argc,  char **argv)
 {
        struct list_head   head;
 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;
        struct lstcon_rpc_ent  *ent = NULL;
        char              *str = NULL;
        int                optidx  = 0;
@@ -907,7 +909,7 @@ out:
 }
 
 int
 }
 
 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 };
                    unsigned *featp, struct list_head *resultp)
 {
        struct lstio_group_nodes_args args = { 0 };
@@ -987,7 +989,7 @@ int
 jt_lst_add_group(int argc, char **argv)
 {
        struct list_head   head;
 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;
        char              *name;
        unsigned           feats = session_features;
        int                count;
@@ -1138,7 +1140,7 @@ jt_lst_del_group(int argc, char **argv)
 
 int
 lst_update_group_ioctl(int opc, char *name, int clean, int count,
 
 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 };
 
 {
        struct lstio_group_update_args args = { 0 };
 
@@ -1158,7 +1160,7 @@ int
 jt_lst_update_group(int argc, char **argv)
 {
        struct list_head   head;
 jt_lst_update_group(int argc, char **argv)
 {
        struct list_head   head;
-       lnet_process_id_t *ids = NULL;
+       struct lnet_process_id *ids = NULL;
        char              *str = NULL;
        char              *grp = NULL;
        int                optidx = 0;
        char              *str = NULL;
        char              *grp = NULL;
        int                optidx = 0;
@@ -1483,8 +1485,8 @@ jt_lst_list_group(int argc, char **argv)
 }
 
 int
 }
 
 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 };
 
 {
        struct lstio_stat_args args = { 0 };
 
@@ -1503,7 +1505,7 @@ typedef struct {
        struct list_head              srp_link;
         int                     srp_count;
         char                   *srp_name;
        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;
 
        struct list_head              srp_result[2];
 } lst_stat_req_param_t;
 
@@ -1553,27 +1555,27 @@ lst_stat_req_param_alloc(char *name, lst_stat_req_param_t **srpp, int save_old)
                 return rc;
         }
 
                 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(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 {
 }
 
 typedef struct {
@@ -1644,16 +1646,16 @@ lst_timeval_diff(struct timeval *tv1,
 }
 
 static void
 }
 
 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);
 {
        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 ||
        lnet_stat_result.lnet_total_sndperf += perf;
 
        if (lnet_stat_result.lnet_min_sndperf > perf ||
@@ -1663,8 +1665,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;
 
        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 ||
        lnet_stat_result.lnet_total_rcvperf += perf;
 
        if (lnet_stat_result.lnet_min_rcvperf > perf ||
@@ -1674,7 +1676,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;
 
        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 ||
        lnet_stat_result.lnet_total_sndrate += rate;
 
        if (lnet_stat_result.lnet_min_sndrate > rate ||
@@ -1684,7 +1686,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;
 
        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 ||
        lnet_stat_result.lnet_total_rcvrate += rate;
 
        if (lnet_stat_result.lnet_min_rcvrate > rate ||
@@ -1770,17 +1772,17 @@ lst_print_stat(char *name, struct list_head *resultp,
               int idx, int lnet, int bwrt, int rdwr, int type,
               int mbs)
 {
               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 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]);
 
        INIT_LIST_HEAD(&tmp[0]);
        INIT_LIST_HEAD(&tmp[1]);
@@ -1823,28 +1825,32 @@ 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];
 
                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));
+               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));
+               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 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
 
                /* 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. */
-
+                * 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
                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 -
+                        * the kernel.
+                        */
+                       delta = (float)(sfwk_new->running_ms -
                                        sfwk_old->running_ms) / 1000;
                } else {
                                        sfwk_old->running_ms) / 1000;
                } else {
-                       struct timeval    tv;
+                       struct timeval tv;
 
                        lst_timeval_diff(&new->rpe_stamp, &old->rpe_stamp, &tv);
                        delta = tv.tv_sec + (float)tv.tv_usec / 1000000;
 
                        lst_timeval_diff(&new->rpe_stamp, &old->rpe_stamp, &tv);
                        delta = tv.tv_sec + (float)tv.tv_usec / 1000000;
@@ -2950,8 +2956,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]) {
 
                } 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);
                         tok = strchr(argv[i], '=') + 1;
 
                         bulk->blk_size = strtol(tok, &end, 0);
@@ -2968,7 +2972,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;
 
                         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;
                                 fprintf(stderr, "Size exceed limitation: %d bytes\n",
                                         bulk->blk_size);
                                 return -1;
@@ -3276,6 +3280,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"                   },
          "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                    }
 };
 
         {0,                     0,                      0,      NULL                    }
 };
 
@@ -3309,6 +3314,15 @@ lst_initialize(void)
         return 0;
 }
 
         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)
 {
 int
 main(int argc, char **argv)
 {
@@ -3320,9 +3334,9 @@ main(int argc, char **argv)
         if (rc < 0)
                 goto errorout;
 
         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);
 
 
         Parser_init("lst > ", lst_cmdlist);