Whamcloud - gitweb
LU-5596 lnet: Remove obsolete LNET variable
[fs/lustre-release.git] / lnet / utils / lst.c
index 63db07d..1aacbda 100644 (file)
  * Author: Liang Zhen <liangzhen@clusterfs.com>
  */
 
-#define _GNU_SOURCE
-
 #include <libcfs/libcfsutil.h>
 #include <lnet/lnetctl.h>
 #include <lnet/lnetst.h>
+#include <lnet/nidstr.h>
 /* NB: these includes are layering violation */
 #include <lustre_ver.h>
 #include <lustre/lustre_idl.h>
@@ -51,19 +50,14 @@ lst_sid_t LST_INVALID_SID = {LNET_NID_ANY, -1};
 static lst_sid_t           session_id;
 static int                 session_key;
 
-#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 6, 50, 0)
-/* assume all nodes can understand feature LST_FEAT_BULK_LEN */
-static unsigned                   session_features = LST_FEATS_MASK;
-#else
-static unsigned                   session_features = LST_FEATS_EMPTY;
-#endif
-
-static lstcon_trans_stat_t trans_stat;
+/* All nodes running 2.6.50 or later understand feature LST_FEAT_BULK_LEN */
+static unsigned                session_features = LST_FEATS_MASK;
+static lstcon_trans_stat_t     trans_stat;
 
 typedef struct list_string {
-        struct list_string *lstr_next;
-        int                 lstr_sz;
-        char                lstr_str[0];
+       struct list_string *lstr_next;
+       int                 lstr_sz;
+       char                lstr_str[0];
 } lstr_t;
 
 #ifndef offsetof
@@ -401,33 +395,33 @@ lst_print_error(char *sub, const char *def_format, ...)
 }
 
 void
-lst_free_rpcent(cfs_list_t *head)
+lst_free_rpcent(struct list_head *head)
 {
-        lstcon_rpc_ent_t *ent;
+       lstcon_rpc_ent_t *ent;
 
-        while (!cfs_list_empty(head)) {
-                ent = cfs_list_entry(head->next, lstcon_rpc_ent_t, rpe_link);
+       while (!list_empty(head)) {
+               ent = list_entry(head->next, lstcon_rpc_ent_t, rpe_link);
 
-                cfs_list_del(&ent->rpe_link);
-                free(ent);
-        }
+               list_del(&ent->rpe_link);
+               free(ent);
+       }
 }
 
 void
-lst_reset_rpcent(cfs_list_t *head)
+lst_reset_rpcent(struct list_head *head)
 {
-        lstcon_rpc_ent_t *ent;
+       lstcon_rpc_ent_t *ent;
 
-        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.pid = LNET_PID_ANY;
-                ent->rpe_rpc_errno = ent->rpe_fwk_errno = 0;
-        }
+       list_for_each_entry(ent, head, rpe_link) {
+               ent->rpe_sid       = LST_INVALID_SID;
+               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(cfs_list_t *head, int count, int offset)
+lst_alloc_rpcent(struct list_head *head, int count, int offset)
 {
         lstcon_rpc_ent_t *ent;
         int               i;
@@ -441,23 +435,23 @@ lst_alloc_rpcent(cfs_list_t *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.pid = LNET_PID_ANY;
-                cfs_list_add(&ent->rpe_link, head);
-        }
+               ent->rpe_sid      = LST_INVALID_SID;
+               ent->rpe_peer.nid = LNET_NID_ANY;
+               ent->rpe_peer.pid = LNET_PID_ANY;
+               list_add(&ent->rpe_link, head);
+       }
 
-        return 0;
+       return 0;
 }
 
 void
-lst_print_transerr(cfs_list_t *head, char *optstr)
+lst_print_transerr(struct list_head *head, char *optstr)
 {
-        lstcon_rpc_ent_t  *ent;
+       lstcon_rpc_ent_t *ent;
 
-        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;
+       list_for_each_entry(ent, head, rpe_link) {
+               if (ent->rpe_rpc_errno == 0 && ent->rpe_fwk_errno == 0)
+                       continue;
 
                 if (ent->rpe_rpc_errno != 0) {
                         fprintf(stderr, "%s RPC failed on %s: %s\n",
@@ -480,7 +474,7 @@ 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 timeout, struct list_head *head);
 
 int
 lst_ioctl(unsigned int opc, void *buf, int len)
@@ -602,7 +596,7 @@ jt_lst_new_session(int argc,  char **argv)
                 if (rc != 0)
                         snprintf(host, sizeof(host), "unknown_host");
 
-                snprintf(buf, LST_NAME_SIZE, "%s@%s", user, host);
+               snprintf(buf, sizeof(buf), "%s@%s", user, host);
                 name = buf;
 
         } else {
@@ -648,7 +642,7 @@ jt_lst_show_session(int argc, char **argv)
        int                 key;
        int                 rc;
 
-       rc = lst_session_info_ioctl(name, LST_NAME_SIZE, &key,
+       rc = lst_session_info_ioctl(name, sizeof(name), &key,
                                    &feats, &sid, &ndinfo);
 
         if (rc != 0) {
@@ -716,7 +710,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, cfs_list_t *head)
+              int count, lnet_process_id_t *ids, struct list_head *head)
 {
         lstio_debug_args_t args = {0};
 
@@ -778,9 +772,9 @@ lst_get_node_count(int type, char *str, int *countp, lnet_process_id_t **idspp)
 int
 jt_lst_ping(int argc,  char **argv)
 {
-        cfs_list_t         head;
-        lnet_process_id_t *ids = NULL;
-        lstcon_rpc_ent_t  *ent = NULL;
+       struct list_head   head;
+       lnet_process_id_t *ids = NULL;
+       lstcon_rpc_ent_t  *ent = NULL;
         char              *str = NULL;
         int                optidx  = 0;
         int                server  = 0;
@@ -864,7 +858,7 @@ jt_lst_ping(int argc,  char **argv)
                 return -1;
         }
 
-        CFS_INIT_LIST_HEAD(&head);
+       INIT_LIST_HEAD(&head);
 
         rc = lst_alloc_rpcent(&head, count, LST_NAME_SIZE);
         if (rc != 0) {
@@ -887,17 +881,17 @@ jt_lst_ping(int argc,  char **argv)
                 goto out;
         }
 
-        /* ignore RPC errors and framwork errors */
-        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),
-                        (ent->rpe_state == LST_NODE_ACTIVE ||
-                         ent->rpe_state == LST_NODE_BUSY)?
-                                 (ent->rpe_rpc_errno == 0 ?
-                                         &ent->rpe_payload[0] : "Unknown") :
-                                 "<NULL>", libcfs_nid2str(ent->rpe_sid.ses_nid));
-        }
+       /* ignore RPC errors and framwork errors */
+       list_for_each_entry(ent, &head, rpe_link) {
+               fprintf(stdout, "\t%s: %s [session: %s id: %s]\n",
+                       libcfs_id2str(ent->rpe_peer),
+                       lst_node_state2str(ent->rpe_state),
+                       (ent->rpe_state == LST_NODE_ACTIVE ||
+                        ent->rpe_state == LST_NODE_BUSY) ?
+                               (ent->rpe_rpc_errno == 0 ?
+                                       &ent->rpe_payload[0] : "Unknown") :
+                               "<NULL>", libcfs_nid2str(ent->rpe_sid.ses_nid));
+       }
 
 out:
         lst_free_rpcent(&head);
@@ -911,7 +905,7 @@ out:
 
 int
 lst_add_nodes_ioctl (char *name, int count, lnet_process_id_t *ids,
-                    unsigned *featp, cfs_list_t *resultp)
+                    unsigned *featp, struct list_head *resultp)
 {
         lstio_group_nodes_args_t args = {0};
 
@@ -927,6 +921,54 @@ lst_add_nodes_ioctl (char *name, int count, lnet_process_id_t *ids,
 }
 
 int
+lst_del_group_ioctl(char *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));
+}
+
+int
+lst_del_group(char *grp_name)
+{
+       int     rc;
+
+       rc = lst_del_group_ioctl(grp_name);
+       if (rc == 0) {
+               fprintf(stdout, "Group is deleted\n");
+               return 0;
+       }
+
+       if (rc == -1) {
+               lst_print_error("group", "Failed to delete group: %s\n",
+                               strerror(errno));
+               return rc;
+       }
+
+       fprintf(stderr, "Group is deleted with some errors\n");
+
+       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),
+                       strerror(trans_stat.trs_rpc_errno));
+       }
+
+       if (trans_stat.trs_fwk_errno != 0) {
+               fprintf(stderr,
+                       "[FWK] Failed to end session on %d nodes: %s\n",
+               lstcon_sesop_stat_failure(&trans_stat, 0),
+               strerror(trans_stat.trs_fwk_errno));
+       }
+
+       return -1;
+}
+
+int
 lst_add_group_ioctl (char *name)
 {
         lstio_group_add_args_t args = {0};
@@ -941,57 +983,60 @@ lst_add_group_ioctl (char *name)
 int
 jt_lst_add_group(int argc, char **argv)
 {
-        cfs_list_t         head;
-        lnet_process_id_t *ids;
-        char              *name;
+       struct list_head   head;
+       lnet_process_id_t *ids;
+       char              *name;
        unsigned           feats = session_features;
-        int                count;
-        int                rc;
-        int                i;
+       int                count;
+       int                rc;
+       int                i;
+       bool               nodes_added = false;
 
-        if (session_key == 0) {
-                fprintf(stderr,
-                        "Can't find env LST_SESSION or value is not valid\n");
-                return -1;
-        }
+       if (session_key == 0) {
+               fprintf(stderr,
+                       "Can't find env LST_SESSION or value is not valid\n");
+               return -1;
+       }
 
-        if (argc < 3) {
-                lst_print_usage(argv[0]);
-                return -1;
-        }
+       if (argc < 3) {
+               lst_print_usage(argv[0]);
+               return -1;
+       }
 
-        name = argv[1];
-        if (strlen(name) >= LST_NAME_SIZE) {
-                fprintf(stderr, "Name length is limited to %d\n",
-                        LST_NAME_SIZE - 1);
-                return -1;
-        }
+       name = argv[1];
+       if (strlen(name) >= LST_NAME_SIZE) {
+               fprintf(stderr, "Name length is limited to %d\n",
+                       LST_NAME_SIZE - 1);
+               return -1;
+       }
 
-        rc = lst_add_group_ioctl(name);
-        if (rc != 0) {
-                lst_print_error("group", "Failed to add group %s: %s\n",
-                                name, strerror(errno));
-                return -1;
-        }
+       rc = lst_add_group_ioctl(name);
+       if (rc != 0) {
+               lst_print_error("group", "Failed to add group %s: %s\n",
+                               name, strerror(errno));
+               return -1;
+       }
 
-        CFS_INIT_LIST_HEAD(&head);
+       INIT_LIST_HEAD(&head);
 
-        for (i = 2; i < argc; i++) {
-                /* parse address list */
-                rc = lst_parse_nids(argv[i], &count, &ids);
-                if (rc < 0) {
-                        fprintf(stderr, "Ignore invalid id list %s\n",
-                                argv[i]);
-                        continue;
-                }
+       for (i = 2; i < argc; i++) {
+               /* parse address list */
+               rc = lst_parse_nids(argv[i], &count, &ids);
+               if (rc < 0) {
+                       fprintf(stderr, "Ignore invalid id list %s\n",
+                               argv[i]);
+                       continue;
+               }
 
-                if (count == 0)
-                        continue;
+               if (count == 0)
+                       continue;
 
-                rc = lst_alloc_rpcent(&head, count, 0);
-                if (rc != 0) {
-                        fprintf(stderr, "Out of memory\n");
-                       return -1;
+               rc = lst_alloc_rpcent(&head, count, 0);
+               if (rc != 0) {
+                       fprintf(stderr, "Out of memory\n");
+                       free(ids);
+                       rc = -1;
+                       goto failed;
                }
 
                rc = lst_add_nodes_ioctl(name, count, ids, &feats, &head);
@@ -1003,6 +1048,8 @@ jt_lst_add_group(int argc, char **argv)
 
                fprintf(stdout, "%s are added to session\n", argv[i]);
 
+               nodes_added = true;
+
                if ((feats & session_features) != session_features) {
                        fprintf(stdout,
                                "Warning, this session will run with "
@@ -1014,7 +1061,24 @@ jt_lst_add_group(int argc, char **argv)
                lst_free_rpcent(&head);
        }
 
-       return 0;
+       if (!nodes_added) {
+               /*
+                * The selftest kernel module expects that a group should
+                * have at least one node, since it doesn't make sense for
+                * an empty group to be added to a test.
+                */
+               fprintf(stderr,
+                       "No nodes added successfully, deleting group %s\n",
+                       name);
+               rc = lst_del_group(name);
+               if (rc != 0) {
+                       fprintf(stderr,
+                               "Failed to delete group %s."
+                               "  Group is empty.\n", name);
+               }
+       }
+
+       return rc;
 
 failed:
        if (rc == -1) {
@@ -1034,19 +1098,18 @@ failed:
 
        lst_free_rpcent(&head);
 
-       return rc;
-}
-
-int
-lst_del_group_ioctl (char *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;
+       if (!nodes_added) {
+               fprintf(stderr,
+                       "No nodes added successfully, deleting group %s\n",
+                       name);
+               if (lst_del_group(name) != 0) {
+                       fprintf(stderr,
+                               "Failed to delete group %s."
+                               "  Group is empty.\n", name);
+               }
+       }
 
-        return lst_ioctl(LSTIO_GROUP_DEL, &args, sizeof(args));
+       return rc;
 }
 
 int
@@ -1065,39 +1128,14 @@ jt_lst_del_group(int argc, char **argv)
                 return -1;
         }
 
-        rc = lst_del_group_ioctl(argv[1]);
-        if (rc == 0) {
-                fprintf(stdout, "Group is deleted\n");
-                return 0;
-        }
-
-        if (rc == -1) {
-                lst_print_error("group", "Failed to delete group: %s\n",
-                                strerror(errno));
-                return rc;
-        }
-
-        fprintf(stderr, "Group is deleted with some errors\n");
+       rc = lst_del_group(argv[1]);
 
-        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),
-                        strerror(trans_stat.trs_rpc_errno));
-        }
-
-        if (trans_stat.trs_fwk_errno != 0) {
-                fprintf(stderr,
-                        "[FWK] Failed to end session on %d nodes: %s\n",
-                        lstcon_sesop_stat_failure(&trans_stat, 0),
-                        strerror(trans_stat.trs_fwk_errno));
-        }
-
-        return -1;
+       return rc;
 }
 
 int
 lst_update_group_ioctl(int opc, char *name, int clean, int count,
-                       lnet_process_id_t *ids, cfs_list_t *resultp)
+                      lnet_process_id_t *ids, struct list_head *resultp)
 {
         lstio_group_update_args_t args = {0};
 
@@ -1116,7 +1154,7 @@ lst_update_group_ioctl(int opc, char *name, int clean, int count,
 int
 jt_lst_update_group(int argc, char **argv)
 {
-        cfs_list_t         head;
+       struct list_head         head;
         lnet_process_id_t *ids = NULL;
         char              *str = NULL;
         char              *grp = NULL;
@@ -1190,7 +1228,7 @@ jt_lst_update_group(int argc, char **argv)
 
         grp = argv[optind];
 
-        CFS_INIT_LIST_HEAD(&head);
+       INIT_LIST_HEAD(&head);
 
         if (opc == LST_GROUP_RMND || opc == LST_GROUP_REFRESH) {
                 rc = lst_get_node_count(opc == LST_GROUP_RMND ? LST_OPC_NODES :
@@ -1447,7 +1485,7 @@ jt_lst_list_group(int argc, char **argv)
 
 int
 lst_stat_ioctl (char *name, int count, lnet_process_id_t *idsp,
-                int timeout, cfs_list_t *resultp)
+               int timeout, struct list_head *resultp)
 {
         lstio_stat_args_t args = {0};
 
@@ -1463,11 +1501,11 @@ lst_stat_ioctl (char *name, int count, lnet_process_id_t *idsp,
 }
 
 typedef struct {
-        cfs_list_t              srp_link;
+       struct list_head              srp_link;
         int                     srp_count;
         char                   *srp_name;
         lnet_process_id_t      *srp_ids;
-        cfs_list_t              srp_result[2];
+       struct list_head              srp_result[2];
 } lst_stat_req_param_t;
 
 static void
@@ -1497,8 +1535,8 @@ lst_stat_req_param_alloc(char *name, lst_stat_req_param_t **srpp, int save_old)
                 return -ENOMEM;
 
         memset(srp, 0, sizeof(*srp));
-        CFS_INIT_LIST_HEAD(&srp->srp_result[0]);
-        CFS_INIT_LIST_HEAD(&srp->srp_result[1]);
+       INIT_LIST_HEAD(&srp->srp_result[0]);
+       INIT_LIST_HEAD(&srp->srp_result[1]);
 
         rc = lst_get_node_count(LST_OPC_GROUP, name,
                                 &srp->srp_count, NULL);
@@ -1725,10 +1763,10 @@ lst_print_lnet_stat(char *name, int bwrt, int rdwr, int type)
 }
 
 void
-lst_print_stat(char *name, cfs_list_t *resultp,
+lst_print_stat(char *name, struct list_head *resultp,
               int idx, int lnet, int bwrt, int rdwr, int type)
 {
-        cfs_list_t        tmp[2];
+       struct list_head        tmp[2];
         lstcon_rpc_ent_t *new;
         lstcon_rpc_ent_t *old;
         sfw_counters_t   *sfwk_new;
@@ -1740,20 +1778,20 @@ lst_print_stat(char *name, cfs_list_t *resultp,
         float             delta;
         int               errcount = 0;
 
-        CFS_INIT_LIST_HEAD(&tmp[0]);
-        CFS_INIT_LIST_HEAD(&tmp[1]);
+       INIT_LIST_HEAD(&tmp[0]);
+       INIT_LIST_HEAD(&tmp[1]);
 
         memset(&lnet_stat_result, 0, sizeof(lnet_stat_result));
 
-        while (!cfs_list_empty(&resultp[idx])) {
-                if (cfs_list_empty(&resultp[1 - idx])) {
+       while (!list_empty(&resultp[idx])) {
+               if (list_empty(&resultp[1 - idx])) {
                         fprintf(stderr, "Group is changed, re-run stat\n");
                         break;
                 }
 
-                new = cfs_list_entry(resultp[idx].next, lstcon_rpc_ent_t,
+               new = list_entry(resultp[idx].next, lstcon_rpc_ent_t,
                                      rpe_link);
-                old = cfs_list_entry(resultp[1 - idx].next, lstcon_rpc_ent_t,
+               old = list_entry(resultp[1 - idx].next, lstcon_rpc_ent_t,
                                      rpe_link);
 
                 /* first time get stats result, can't calculate diff */
@@ -1766,11 +1804,11 @@ lst_print_stat(char *name, cfs_list_t *resultp,
                         break;
                 }
 
-                cfs_list_del(&new->rpe_link);
-                cfs_list_add_tail(&new->rpe_link, &tmp[idx]);
+               list_del(&new->rpe_link);
+               list_add_tail(&new->rpe_link, &tmp[idx]);
 
-                cfs_list_del(&old->rpe_link);
-                cfs_list_add_tail(&old->rpe_link, &tmp[1 - idx]);
+               list_del(&old->rpe_link);
+               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) {
@@ -1814,8 +1852,8 @@ lst_print_stat(char *name, cfs_list_t *resultp,
                 lst_cal_lnet_stat(delta, lnet_new, lnet_old);
         }
 
-        cfs_list_splice(&tmp[idx], &resultp[idx]);
-        cfs_list_splice(&tmp[1 - idx], &resultp[1 - idx]);
+       list_splice(&tmp[idx], &resultp[idx]);
+       list_splice(&tmp[1 - idx], &resultp[1 - idx]);
 
         if (errcount > 0)
                 fprintf(stdout, "Failed to stat on %d nodes\n", errcount);
@@ -1829,7 +1867,7 @@ lst_print_stat(char *name, cfs_list_t *resultp,
 int
 jt_lst_stat(int argc, char **argv)
 {
-        cfs_list_t            head;
+       struct list_head        head;
         lst_stat_req_param_t *srp;
         time_t                last    = 0;
         int                   optidx  = 0;
@@ -1948,14 +1986,14 @@ jt_lst_stat(int argc, char **argv)
         if (count != -1)
             count++;
 
-        CFS_INIT_LIST_HEAD(&head);
+       INIT_LIST_HEAD(&head);
 
         while (optind < argc) {
                 rc = lst_stat_req_param_alloc(argv[optind++], &srp, 1);
                 if (rc != 0)
                         goto out;
 
-                cfs_list_add_tail(&srp->srp_link, &head);
+               list_add_tail(&srp->srp_link, &head);
         }
 
         do {
@@ -1965,11 +2003,9 @@ jt_lst_stat(int argc, char **argv)
                         sleep(delay - now + last);
                         time(&now);
                 }
+               last = now;
 
-                last = now;
-
-                cfs_list_for_each_entry_typed(srp, &head, lst_stat_req_param_t,
-                                              srp_link) {
+               list_for_each_entry(srp, &head, srp_link) {
                         rc = lst_stat_ioctl(srp->srp_name,
                                             srp->srp_count, srp->srp_ids,
                                             timeout, &srp->srp_result[idx]);
@@ -1992,10 +2028,10 @@ jt_lst_stat(int argc, char **argv)
         } while (count == -1 || count > 0);
 
 out:
-        while (!cfs_list_empty(&head)) {
-                srp = cfs_list_entry(head.next, lst_stat_req_param_t, srp_link);
+       while (!list_empty(&head)) {
+               srp = list_entry(head.next, lst_stat_req_param_t, srp_link);
 
-                cfs_list_del(&srp->srp_link);
+               list_del(&srp->srp_link);
                 lst_stat_req_param_free(srp);
         }
 
@@ -2005,7 +2041,7 @@ out:
 int
 jt_lst_show_error(int argc, char **argv)
 {
-        cfs_list_t            head;
+       struct list_head            head;
         lst_stat_req_param_t *srp;
         lstcon_rpc_ent_t     *ent;
         sfw_counters_t       *sfwk;
@@ -2050,18 +2086,17 @@ jt_lst_show_error(int argc, char **argv)
                 return -1;
         }
 
-        CFS_INIT_LIST_HEAD(&head);
+       INIT_LIST_HEAD(&head);
 
         while (optind < argc) {
                 rc = lst_stat_req_param_alloc(argv[optind++], &srp, 0);
                 if (rc != 0)
                         goto out;
 
-                cfs_list_add_tail(&srp->srp_link, &head);
+               list_add_tail(&srp->srp_link, &head);
         }
 
-        cfs_list_for_each_entry_typed(srp, &head, lst_stat_req_param_t,
-                                      srp_link) {
+       list_for_each_entry(srp, &head, srp_link) {
                 rc = lst_stat_ioctl(srp->srp_name, srp->srp_count,
                                     srp->srp_ids, 10, &srp->srp_result[0]);
 
@@ -2075,8 +2110,7 @@ jt_lst_show_error(int argc, char **argv)
 
                 ecount = 0;
 
-                cfs_list_for_each_entry_typed(ent, &srp->srp_result[0],
-                                              lstcon_rpc_ent_t, rpe_link) {
+               list_for_each_entry(ent, &srp->srp_result[0], rpe_link) {
                         if (ent->rpe_rpc_errno != 0) {
                                 ecount ++;
                                 fprintf(stderr, "RPC failure, can't show error on %s\n",
@@ -2119,10 +2153,10 @@ jt_lst_show_error(int argc, char **argv)
                 fprintf(stdout, "Total %d error nodes in %s\n", ecount, srp->srp_name);
         }
 out:
-        while (!cfs_list_empty(&head)) {
-                srp = cfs_list_entry(head.next, lst_stat_req_param_t, srp_link);
+       while (!list_empty(&head)) {
+               srp = list_entry(head.next, lst_stat_req_param_t, srp_link);
 
-                cfs_list_del(&srp->srp_link);
+               list_del(&srp->srp_link);
                 lst_stat_req_param_free(srp);
         }
 
@@ -2176,7 +2210,7 @@ jt_lst_add_batch(int argc, char **argv)
 }
 
 int
-lst_start_batch_ioctl (char *name, int timeout, cfs_list_t *resultp)
+lst_start_batch_ioctl(char *name, int timeout, struct list_head *resultp)
 {
         lstio_batch_run_args_t args = {0};
 
@@ -2192,7 +2226,7 @@ lst_start_batch_ioctl (char *name, int timeout, cfs_list_t *resultp)
 int
 jt_lst_start_batch(int argc, char **argv)
 {
-        cfs_list_t        head;
+       struct list_head        head;
         char             *batch;
         int               optidx  = 0;
         int               timeout = 0;
@@ -2248,7 +2282,7 @@ jt_lst_start_batch(int argc, char **argv)
                 return -1;
         }
 
-        CFS_INIT_LIST_HEAD(&head);
+       INIT_LIST_HEAD(&head);
 
         rc = lst_alloc_rpcent(&head, count, 0);
         if (rc != 0) {
@@ -2279,7 +2313,7 @@ jt_lst_start_batch(int argc, char **argv)
 }
 
 int
-lst_stop_batch_ioctl(char *name, int force, cfs_list_t *resultp)
+lst_stop_batch_ioctl(char *name, int force, struct list_head *resultp)
 {
         lstio_batch_stop_args_t args = {0};
 
@@ -2295,7 +2329,7 @@ lst_stop_batch_ioctl(char *name, int force, cfs_list_t *resultp)
 int
 jt_lst_stop_batch(int argc, char **argv)
 {
-        cfs_list_t        head;
+       struct list_head        head;
         char             *batch;
         int               force = 0;
         int               optidx;
@@ -2351,7 +2385,7 @@ jt_lst_stop_batch(int argc, char **argv)
                 return -1;
         }
 
-        CFS_INIT_LIST_HEAD(&head);
+       INIT_LIST_HEAD(&head);
 
         rc = lst_alloc_rpcent(&head, count, 0);
         if (rc != 0) {
@@ -2648,7 +2682,7 @@ loop:
 
 int
 lst_query_batch_ioctl(char *batch, int test, int server,
-                      int timeout, cfs_list_t *head)
+                     int timeout, struct list_head *head)
 {
         lstio_batch_query_args_t args = {0};
 
@@ -2664,12 +2698,12 @@ lst_query_batch_ioctl(char *batch, int test, int server,
 }
 
 void
-lst_print_tsb_verbose(cfs_list_t *head,
+lst_print_tsb_verbose(struct list_head *head,
                       int active, int idle, int error)
 {
         lstcon_rpc_ent_t *ent;
 
-        cfs_list_for_each_entry_typed(ent, head, lstcon_rpc_ent_t, rpe_link) {
+       list_for_each_entry(ent, head, rpe_link) {
                 if (ent->rpe_priv[0] == 0 && active)
                         continue;
 
@@ -2692,7 +2726,7 @@ int
 jt_lst_query_batch(int argc, char **argv)
 {
         lstcon_test_batch_ent_t ent;
-        cfs_list_t              head;
+       struct list_head              head;
         char                   *batch   = NULL;
         time_t                  last    = 0;
         int                     optidx  = 0;
@@ -2789,7 +2823,7 @@ jt_lst_query_batch(int argc, char **argv)
         }
 
 
-        CFS_INIT_LIST_HEAD(&head);
+       INIT_LIST_HEAD(&head);
 
         if (verbose) {
                 rc = lst_info_batch_ioctl(batch, test, server,
@@ -2933,7 +2967,7 @@ lst_get_bulk_param(int argc, char **argv, lst_test_bulk_param_t *bulk)
                         else if (*end == 'm' || *end == 'M')
                                 bulk->blk_size *= 1024 * 1024;
 
-                        if (bulk->blk_size > CFS_PAGE_SIZE * LNET_MAX_IOV) {
+                       if (bulk->blk_size > PAGE_CACHE_SIZE * LNET_MAX_IOV) {
                                 fprintf(stderr, "Size exceed limitation: %d bytes\n",
                                         bulk->blk_size);
                                 return -1;
@@ -3004,7 +3038,7 @@ 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, cfs_list_t *resultp)
+                  void *param, int plen, int *retp, struct list_head *resultp)
 {
         lstio_test_args_t args = {0};
 
@@ -3032,7 +3066,7 @@ lst_add_test_ioctl(char *batch, int type, int loop, int concur,
 int
 jt_lst_add_test(int argc, char **argv)
 {
-        cfs_list_t    head;
+       struct list_head    head;
         char         *batch  = NULL;
         char         *test   = NULL;
         char         *dstr   = NULL;
@@ -3134,7 +3168,7 @@ jt_lst_add_test(int argc, char **argv)
                 return -1;
         }
 
-        CFS_INIT_LIST_HEAD(&head);
+       INIT_LIST_HEAD(&head);
 
         rc = lst_get_node_count(LST_OPC_GROUP, from, &fcount, NULL);
         if (rc != 0) {