Whamcloud - gitweb
b=16909 add CNETERR() cleanup console messages
[fs/lustre-release.git] / lnet / lnet / config.c
index 7c1466c..fc9ca61 100644 (file)
@@ -1,31 +1,46 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- *  Copyright (c) 2005 Cluster File Systems, Inc.
+ * GPL HEADER START
  *
- *   This file is part of Lustre, http://www.sf.net/projects/lustre/
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *   Lustre is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
+ * 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.
  *
- *   Lustre 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 for more details.
+ * 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
- *   along with Lustre; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * 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.
  */
 
 #define DEBUG_SUBSYSTEM S_LNET
 #include <lnet/lib-lnet.h>
 
-typedef struct {                                /* tmp struct for parsing routes */
-       struct list_head   ltb_list;            /* stash on lists */
-       int                ltb_size;            /* allocated size */
-       char               ltb_text[0];         /* text buffer */
+typedef struct {                            /* tmp struct for parsing routes */
+       cfs_list_t         ltb_list;        /* stash on lists */
+       int                ltb_size;        /* allocated size */
+       char               ltb_text[0];     /* text buffer */
 } lnet_text_buf_t;
 
 static int lnet_tbnob = 0;                     /* track text buf allocation */
@@ -33,7 +48,7 @@ static int lnet_tbnob = 0;                    /* track text buf allocation */
 #define LNET_SINGLE_TEXTBUF_NOB  (4<<10)
 
 typedef struct {
-        struct list_head   lre_list;            /* stash in a list */
+        cfs_list_t         lre_list;            /* stash in a list */
         int                lre_min;             /* min value */
         int                lre_max;             /* max value */
         int                lre_stride;          /* stride */
@@ -41,7 +56,7 @@ typedef struct {
 
 static int lnet_re_alloc = 0;                   /* track expr allocation */
 
-void 
+void
 lnet_syntax(char *name, char *str, int offset, int width)
 {
         static char dots[LNET_SINGLE_TEXTBUF_NOB];
@@ -52,10 +67,10 @@ lnet_syntax(char *name, char *str, int offset, int width)
         memset(dashes, '-', sizeof(dashes));
         dashes[sizeof(dashes)-1] = 0;
         
-       LCONSOLE_ERROR(0x10f, "Error parsing '%s=\"%s\"'\n", name, str);
-       LCONSOLE_ERROR(0x110, "here...........%.*s..%.*s|%.*s|\n", 
-                       (int)strlen(name), dots, offset, dots,
-                       (width < 1) ? 0 : width - 1, dashes);
+       LCONSOLE_ERROR_MSG(0x10f, "Error parsing '%s=\"%s\"'\n", name, str);
+       LCONSOLE_ERROR_MSG(0x110, "here...........%.*s..%.*s|%.*s|\n", 
+                           (int)strlen(name), dots, offset, dots,
+                            (width < 1) ? 0 : width - 1, dashes);
 }
 
 int 
@@ -71,31 +86,17 @@ lnet_issep (char c)
        }
 }
 
-int
-lnet_iswhite (char c)
-{
-       switch (c) {
-       case ' ':
-       case '\t':
-       case '\n':
-       case '\r':
-               return 1;
-       default:
-               return 0;
-       }
-}
-
 char *
 lnet_trimwhite(char *str)
 {
        char *end;
-       
-       while (lnet_iswhite(*str))
+
+        while (cfs_iswhite(*str))
                str++;
-       
+
        end = str + strlen(str);
        while (end > str) {
-               if (!lnet_iswhite(end[-1]))
+                if (!cfs_iswhite(end[-1]))
                        break;
                end--;
        }
@@ -105,52 +106,53 @@ lnet_trimwhite(char *str)
 }
 
 int
-lnet_net_unique(__u32 net, struct list_head *nilist)
+lnet_net_unique(__u32 net, cfs_list_t *nilist)
 {
-        struct list_head *tmp;
+        cfs_list_t       *tmp;
         lnet_ni_t        *ni;
 
-        list_for_each (tmp, nilist) {
-                ni = list_entry(tmp, lnet_ni_t, ni_list);
+        cfs_list_for_each (tmp, nilist) {
+                ni = cfs_list_entry(tmp, lnet_ni_t, ni_list);
 
                 if (LNET_NIDNET(ni->ni_nid) == net)
                         return 0;
         }
-        
+
         return 1;
 }
 
 lnet_ni_t *
-lnet_new_ni(__u32 net, struct list_head *nilist)
+lnet_new_ni(__u32 net, cfs_list_t *nilist)
 {
         lnet_ni_t *ni;
 
         if (!lnet_net_unique(net, nilist)) {
-                LCONSOLE_ERROR(0x111, "Duplicate network specified: %s\n",
-                               libcfs_net2str(net));
+                LCONSOLE_ERROR_MSG(0x111, "Duplicate network specified: %s\n",
+                                   libcfs_net2str(net));
                 return NULL;
         }
-        
+
         LIBCFS_ALLOC(ni, sizeof(*ni));
         if (ni == NULL) {
                 CERROR("Out of memory creating network %s\n",
                        libcfs_net2str(net));
                 return NULL;
         }
-        
+
         /* zero counters/flags, NULL pointers... */
         memset(ni, 0, sizeof(*ni));
 
         /* LND will fill in the address part of the NID */
         ni->ni_nid = LNET_MKNID(net, 0);
         CFS_INIT_LIST_HEAD(&ni->ni_txq);
+        ni->ni_last_alive = cfs_time_current();
 
-        list_add_tail(&ni->ni_list, nilist);
+        cfs_list_add_tail(&ni->ni_list, nilist);
         return ni;
 }
 
 int
-lnet_parse_networks(struct list_head *nilist, char *networks)
+lnet_parse_networks(cfs_list_t *nilist, char *networks)
 {
        int        tokensize = strlen(networks) + 1;
         char      *tokens;
@@ -161,7 +163,8 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
 
        if (strlen(networks) > LNET_SINGLE_TEXTBUF_NOB) {
                /* _WAY_ conservative */
-               LCONSOLE_ERROR(0x112, "Can't parse networks: string too long\n");
+               LCONSOLE_ERROR_MSG(0x112, "Can't parse networks: string too "
+                                   "long\n");
                return -EINVAL;
        }
 
@@ -174,7 +177,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
         the_lnet.ln_network_tokens = tokens;
         the_lnet.ln_network_tokens_nob = tokensize;
         memcpy (tokens, networks, tokensize);
-       str = tokens;
+        str = tokens;
         
         /* Add in the loopback network */
         ni = lnet_new_ni(LNET_MKNET(LOLND, 0), nilist);
@@ -201,8 +204,9 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
                        
                        if (net == LNET_NIDNET(LNET_NID_ANY)) {
                                 lnet_syntax("networks", networks, 
-                                            str - tokens, strlen(str));
-                                LCONSOLE_ERROR(0x113, "Unrecognised network type\n");
+                                            (int)(str - tokens), strlen(str));
+                                LCONSOLE_ERROR_MSG(0x113, "Unrecognised network"
+                                                   " type\n");
                                 goto failed;
                         }
 
@@ -218,17 +222,10 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
                net = libcfs_str2net(lnet_trimwhite(str));
                if (net == LNET_NIDNET(LNET_NID_ANY)) {
                         lnet_syntax("networks", networks,
-                                    str - tokens, strlen(str));
+                                    (int)(str - tokens), strlen(str));
                         goto failed;
                 } 
 
-                if (nnets > 0 &&
-                    the_lnet.ln_ptlcompat > 0) {
-                        LCONSOLE_ERROR(0x114, "Only 1 network supported when "
-                                       "'portals_compatible' is set\n");
-                        goto failed;
-                }
-
                 nnets++;
                 ni = lnet_new_ni(net, nilist);
                 if (ni == NULL)
@@ -240,7 +237,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
                bracket = strchr(iface, ')');
                if (bracket == NULL) {
                         lnet_syntax("networks", networks,
-                                    iface - tokens, strlen(iface));
+                                    (int)(iface - tokens), strlen(iface));
                         goto failed;
                }
 
@@ -253,13 +250,14 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
                        iface = lnet_trimwhite(iface);
                        if (*iface == 0) {
                                 lnet_syntax("networks", networks, 
-                                            iface - tokens, strlen(iface));
+                                            (int)(iface - tokens), strlen(iface));
                                 goto failed;
                         }
 
                         if (niface == LNET_MAX_INTERFACES) {
-                                LCONSOLE_ERROR(0x115, "Too many interfaces for net %s\n",
-                                               libcfs_net2str(net));
+                                LCONSOLE_ERROR_MSG(0x115, "Too many interfaces "
+                                                   "for net %s\n",
+                                                   libcfs_net2str(net));
                                 goto failed;
                         }
 
@@ -274,7 +272,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
                        str = lnet_trimwhite(str);
                        if (*str != 0) {
                                 lnet_syntax("networks", networks,
-                                            str - tokens, strlen(str));
+                                            (int)(str - tokens), strlen(str));
                                 goto failed;
                         }
                        str = comma + 1;
@@ -284,19 +282,19 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
                str = lnet_trimwhite(str);
                if (*str != 0) {
                         lnet_syntax("networks", networks,
-                                    str - tokens, strlen(str));
+                                    (int)(str - tokens), strlen(str));
                         goto failed;
                 }
        }
 
-        LASSERT (!list_empty(nilist));
+        LASSERT (!cfs_list_empty(nilist));
         return 0;
 
  failed:
-        while (!list_empty(nilist)) {
-                ni = list_entry(nilist->next, lnet_ni_t, ni_list);
+        while (!cfs_list_empty(nilist)) {
+                ni = cfs_list_entry(nilist->next, lnet_ni_t, ni_list);
                 
-                list_del(&ni->ni_list);
+                cfs_list_del(&ni->ni_list);
                 LIBCFS_FREE(ni, sizeof(*ni));
         }
        LIBCFS_FREE(tokens, tokensize);
@@ -342,26 +340,26 @@ lnet_free_text_buf (lnet_text_buf_t *ltb)
 }
 
 void
-lnet_free_text_bufs(struct list_head *tbs)
+lnet_free_text_bufs(cfs_list_t *tbs)
 {
        lnet_text_buf_t  *ltb;
-       
-       while (!list_empty(tbs)) {
-               ltb = list_entry(tbs->next, lnet_text_buf_t, ltb_list);
-               
-               list_del(&ltb->ltb_list);
+
+       while (!cfs_list_empty(tbs)) {
+               ltb = cfs_list_entry(tbs->next, lnet_text_buf_t, ltb_list);
+
+               cfs_list_del(&ltb->ltb_list);
                lnet_free_text_buf(ltb);
        }
 }
 
 void
-lnet_print_text_bufs(struct list_head *tbs)
+lnet_print_text_bufs(cfs_list_t *tbs)
 {
-       struct list_head  *tmp;
+       cfs_list_t        *tmp;
        lnet_text_buf_t   *ltb;
 
-       list_for_each (tmp, tbs) {
-               ltb = list_entry(tmp, lnet_text_buf_t, ltb_list);
+       cfs_list_for_each (tmp, tbs) {
+               ltb = cfs_list_entry(tmp, lnet_text_buf_t, ltb_list);
 
                CDEBUG(D_WARNING, "%s\n", ltb->ltb_text);
        }
@@ -370,20 +368,20 @@ lnet_print_text_bufs(struct list_head *tbs)
 }
 
 int
-lnet_str2tbs_sep (struct list_head *tbs, char *str) 
+lnet_str2tbs_sep (cfs_list_t *tbs, char *str) 
 {
-       struct list_head  pending;
+       cfs_list_t        pending;
        char             *sep;
        int               nob;
         int               i;
        lnet_text_buf_t  *ltb;
 
-       INIT_LIST_HEAD(&pending);
+       CFS_INIT_LIST_HEAD(&pending);
 
        /* Split 'str' into separate commands */
        for (;;) {
                 /* skip leading whitespace */
-                while (lnet_iswhite(*str))
+                while (cfs_iswhite(*str))
                         str++;
                 
                /* scan for separator or comment */
@@ -391,7 +389,7 @@ lnet_str2tbs_sep (struct list_head *tbs, char *str)
                        if (lnet_issep(*sep) || *sep == '#')
                                break;
 
-               nob = sep - str;
+               nob = (int)(sep - str);
                if (nob > 0) {
                        ltb = lnet_new_text_buf(nob);
                        if (ltb == NULL) {
@@ -400,14 +398,14 @@ lnet_str2tbs_sep (struct list_head *tbs, char *str)
                        }
                        
                         for (i = 0; i < nob; i++)
-                                if (lnet_iswhite(str[i]))
+                                if (cfs_iswhite(str[i]))
                                         ltb->ltb_text[i] = ' ';
                                 else
                                         ltb->ltb_text[i] = str[i];
 
                        ltb->ltb_text[nob] = 0;
 
-                       list_add_tail(&ltb->ltb_list, &pending);
+                       cfs_list_add_tail(&ltb->ltb_list, &pending);
                }
 
                if (*sep == '#') {
@@ -423,16 +421,16 @@ lnet_str2tbs_sep (struct list_head *tbs, char *str)
                str = sep + 1;
        }
 
-       list_splice(&pending, tbs->prev);
+       cfs_list_splice(&pending, tbs->prev);
        return 0;
 }
 
 int
-lnet_expand1tb (struct list_head *list, 
+lnet_expand1tb (cfs_list_t *list, 
               char *str, char *sep1, char *sep2, 
               char *item, int itemlen)
 {
-       int              len1 = sep1 - str;
+       int              len1 = (int)(sep1 - str);
        int              len2 = strlen(sep2 + 1);
        lnet_text_buf_t *ltb;
 
@@ -442,21 +440,21 @@ lnet_expand1tb (struct list_head *list,
        ltb = lnet_new_text_buf(len1 + itemlen + len2);
        if (ltb == NULL)
                return -ENOMEM;
-       
+
        memcpy(ltb->ltb_text, str, len1);
        memcpy(&ltb->ltb_text[len1], item, itemlen);
        memcpy(&ltb->ltb_text[len1+itemlen], sep2 + 1, len2);
        ltb->ltb_text[len1 + itemlen + len2] = 0;
-       
-       list_add_tail(&ltb->ltb_list, list);
+
+       cfs_list_add_tail(&ltb->ltb_list, list);
        return 0;
 }
 
 int
-lnet_str2tbs_expand (struct list_head *tbs, char *str)
+lnet_str2tbs_expand (cfs_list_t *tbs, char *str)
 {
        char              num[16];
-       struct list_head  pending;
+       cfs_list_t        pending;
        char             *sep;
        char             *sep2;
        char             *parsed;
@@ -468,8 +466,8 @@ lnet_str2tbs_expand (struct list_head *tbs, char *str)
        int               nob;
        int               scanned;
 
-       INIT_LIST_HEAD(&pending);
-       
+       CFS_INIT_LIST_HEAD(&pending);
+
        sep = strchr(str, '[');
        if (sep == NULL)                        /* nothing to expand */
                return 0;
@@ -493,7 +491,7 @@ lnet_str2tbs_expand (struct list_head *tbs, char *str)
 
                                /* simple string enumeration */
                                if (lnet_expand1tb(&pending, str, sep, sep2,
-                                                   parsed, enditem - parsed) != 0)
+                                                   parsed, (int)(enditem - parsed)) != 0)
                                        goto failed;
                                
                                continue;
@@ -524,7 +522,7 @@ lnet_str2tbs_expand (struct list_head *tbs, char *str)
                }
        }
                
-       list_splice(&pending, tbs->prev);
+       cfs_list_splice(&pending, tbs->prev);
        return 1;
        
  failed:
@@ -537,7 +535,7 @@ lnet_parse_hops (char *str, unsigned int *hops)
 {
         int     len = strlen(str);
         int     nob = len;
-        
+       
         return (sscanf(str, "%u%n", hops, &nob) >= 1 &&
                 nob == len &&
                 *hops > 0 && *hops < 256);
@@ -550,10 +548,10 @@ lnet_parse_route (char *str, int *im_a_router)
        /* static scratch buffer OK (single threaded) */
        static char       cmd[LNET_SINGLE_TEXTBUF_NOB];
 
-       struct list_head  nets;
-       struct list_head  gateways;
-       struct list_head *tmp1;
-       struct list_head *tmp2;
+       cfs_list_t        nets;
+       cfs_list_t        gateways;
+       cfs_list_t       *tmp1;
+       cfs_list_t       *tmp2;
        __u32             net;
        lnet_nid_t        nid;
        lnet_text_buf_t  *ltb;
@@ -575,7 +573,7 @@ lnet_parse_route (char *str, int *im_a_router)
        sep = str;
        for (;;) {
                /* scan for token start */
-               while (lnet_iswhite(*sep))
+                while (cfs_iswhite(*sep))
                        sep++;
                if (*sep == 0) {
                        if (ntokens < (got_hops ? 3 : 2))
@@ -587,7 +585,7 @@ lnet_parse_route (char *str, int *im_a_router)
                token = sep++;
 
                /* scan for token end */
-               while (*sep != 0 && !lnet_iswhite(*sep))
+                while (*sep != 0 && !cfs_iswhite(*sep))
                        sep++;
                if (*sep != 0)
                        *sep++ = 0;
@@ -608,10 +606,10 @@ lnet_parse_route (char *str, int *im_a_router)
 
                strcpy(ltb->ltb_text, token);
                tmp1 = &ltb->ltb_list;
-               list_add_tail(tmp1, tmp2);
+               cfs_list_add_tail(tmp1, tmp2);
                
                while (tmp1 != tmp2) {
-                       ltb = list_entry(tmp1, lnet_text_buf_t, ltb_list);
+                       ltb = cfs_list_entry(tmp1, lnet_text_buf_t, ltb_list);
 
                        rc = lnet_str2tbs_expand(tmp1->next, ltb->ltb_text);
                        if (rc < 0)
@@ -620,7 +618,7 @@ lnet_parse_route (char *str, int *im_a_router)
                        tmp1 = tmp1->next;
                        
                        if (rc > 0) {           /* expanded! */
-                               list_del(&ltb->ltb_list);
+                               cfs_list_del(&ltb->ltb_list);
                                lnet_free_text_buf(ltb);
                                continue;
                        }
@@ -642,16 +640,16 @@ lnet_parse_route (char *str, int *im_a_router)
         if (!got_hops)
                 hops = 1;
 
-       LASSERT (!list_empty(&nets));
-       LASSERT (!list_empty(&gateways));
+       LASSERT (!cfs_list_empty(&nets));
+       LASSERT (!cfs_list_empty(&gateways));
 
-       list_for_each (tmp1, &nets) {
-               ltb = list_entry(tmp1, lnet_text_buf_t, ltb_list);
+       cfs_list_for_each (tmp1, &nets) {
+               ltb = cfs_list_entry(tmp1, lnet_text_buf_t, ltb_list);
                net = libcfs_str2net(ltb->ltb_text);
                LASSERT (net != LNET_NIDNET(LNET_NID_ANY));
 
-               list_for_each (tmp2, &gateways) {
-                       ltb = list_entry(tmp2, lnet_text_buf_t, ltb_list);
+               cfs_list_for_each (tmp2, &gateways) {
+                       ltb = cfs_list_entry(tmp2, lnet_text_buf_t, ltb_list);
                        nid = libcfs_str2nid(ltb->ltb_text);
                        LASSERT (nid != LNET_NID_ANY);
 
@@ -675,7 +673,7 @@ lnet_parse_route (char *str, int *im_a_router)
         goto out;
         
  token_error:
-       lnet_syntax("routes", cmd, token - str, strlen(token));
+       lnet_syntax("routes", cmd, (int)(token - str), strlen(token));
  out:
        lnet_free_text_bufs(&nets);
        lnet_free_text_bufs(&gateways);
@@ -683,19 +681,19 @@ lnet_parse_route (char *str, int *im_a_router)
 }
 
 int
-lnet_parse_route_tbs(struct list_head *tbs, int *im_a_router)
+lnet_parse_route_tbs(cfs_list_t *tbs, int *im_a_router)
 {
        lnet_text_buf_t   *ltb;
 
-       while (!list_empty(tbs)) {
-               ltb = list_entry(tbs->next, lnet_text_buf_t, ltb_list);
+       while (!cfs_list_empty(tbs)) {
+               ltb = cfs_list_entry(tbs->next, lnet_text_buf_t, ltb_list);
 
                if (lnet_parse_route(ltb->ltb_text, im_a_router) < 0) {
                        lnet_free_text_bufs(tbs);
                        return -EINVAL;
                }
 
-               list_del(&ltb->ltb_list);
+               cfs_list_del(&ltb->ltb_list);
                lnet_free_text_buf(ltb);
        }
 
@@ -705,19 +703,11 @@ lnet_parse_route_tbs(struct list_head *tbs, int *im_a_router)
 int
 lnet_parse_routes (char *routes, int *im_a_router)
 {
-       struct list_head  tbs;
+       cfs_list_t        tbs;
        int               rc = 0;
 
         *im_a_router = 0;
 
-        if (the_lnet.ln_ptlcompat > 0 && 
-            routes[0] != 0) {
-                /* Can't route when running in compatibility mode */
-                LCONSOLE_ERROR(0x116, "Route tables are not supported when "
-                               "'portals_compatible' is set\n");
-                return -EINVAL;
-        }
-        
        CFS_INIT_LIST_HEAD(&tbs);
 
        if (lnet_str2tbs_sep(&tbs, routes) < 0) {
@@ -732,13 +722,13 @@ lnet_parse_routes (char *routes, int *im_a_router)
 }
 
 void
-lnet_print_range_exprs(struct list_head *exprs)
+lnet_print_range_exprs(cfs_list_t *exprs)
 {
-        struct list_head   *e;
+        cfs_list_t        *e;
         lnet_range_expr_t *lre;
-        
-        list_for_each(e, exprs) {
-                lre = list_entry(exprs->next, lnet_range_expr_t, lre_list);
+
+        cfs_list_for_each(e, exprs) {
+                lre = cfs_list_entry(exprs->next, lnet_range_expr_t, lre_list);
                 
                 CDEBUG(D_WARNING, "%d-%d/%d\n", 
                        lre->lre_min, lre->lre_max, lre->lre_stride);
@@ -748,7 +738,7 @@ lnet_print_range_exprs(struct list_head *exprs)
 }
 
 int
-lnet_new_range_expr(struct list_head *exprs, int min, int max, int stride)
+lnet_new_range_expr(cfs_list_t *exprs, int min, int max, int stride)
 {
         lnet_range_expr_t *lre;
 
@@ -767,26 +757,26 @@ lnet_new_range_expr(struct list_head *exprs, int min, int max, int stride)
         lre->lre_max = max;
         lre->lre_stride = stride;
         
-        list_add(&lre->lre_list, exprs);
+        cfs_list_add(&lre->lre_list, exprs);
         return 0;
 }
 
 void
-lnet_destroy_range_exprs(struct list_head *exprs)
+lnet_destroy_range_exprs(cfs_list_t *exprs)
 {
         lnet_range_expr_t *lre;
         
-        while (!list_empty(exprs)) {
-                lre = list_entry(exprs->next, lnet_range_expr_t, lre_list);
+        while (!cfs_list_empty(exprs)) {
+                lre = cfs_list_entry(exprs->next, lnet_range_expr_t, lre_list);
                 
-                list_del(&lre->lre_list);
+                cfs_list_del(&lre->lre_list);
                 LIBCFS_FREE(lre, sizeof(*lre));
                 lnet_re_alloc--;
         }
 }
 
 int
-lnet_parse_range_expr(struct list_head *exprs, char *str)
+lnet_parse_range_expr(cfs_list_t *exprs, char *str)
 {
         int                nob = strlen(str);
         char              *sep;
@@ -861,8 +851,8 @@ lnet_parse_range_expr(struct list_head *exprs, char *str)
 int
 lnet_match_network_token(char *token, __u32 *ipaddrs, int nip)
 {
-        struct list_head   exprs[4];
-        struct list_head  *e;
+        cfs_list_t         exprs[4];
+        cfs_list_t        *e;
         lnet_range_expr_t *re;
         char              *str;
         int                i;
@@ -895,13 +885,14 @@ lnet_match_network_token(char *token, __u32 *ipaddrs, int nip)
 
         for (match = i = 0; !match && i < nip; i++) {
                 ip = ipaddrs[i];
-                
+
                 for (match = 1, j = 0; match && j < 4; j++) {
                         n = (ip >> (8 * (3 - j))) & 0xff;
                         match = 0;
 
-                        list_for_each(e, &exprs[j]) {
-                                re = list_entry(e, lnet_range_expr_t, lre_list);
+                        cfs_list_for_each(e, &exprs[j]) {
+                                re = cfs_list_entry(e, lnet_range_expr_t,
+                                                    lre_list);
 
                                 if (re->lre_min <= n &&
                                     re->lre_max >= n &&
@@ -943,7 +934,7 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip)
         sep = tokens;
         for (;;) {
                 /* scan for token start */
-                while (lnet_iswhite(*sep))
+                while (cfs_iswhite(*sep))
                         sep++;
                 if (*sep == 0)
                         break;
@@ -951,7 +942,7 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip)
                 token = sep++;
                 
                 /* scan for token end */
-                while (*sep != 0 && !lnet_iswhite(*sep))
+                while (*sep != 0 && !cfs_iswhite(*sep))
                         sep++;
                 if (*sep != 0)
                         *sep++ = 0;
@@ -966,7 +957,7 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip)
                 rc = lnet_match_network_token(token, ipaddrs, nip);
                 if (rc < 0) {
                         lnet_syntax("ip2nets", net_entry,
-                                    token - tokens, len);
+                                    (int)(token - tokens), len);
                         return rc;
                 }
 
@@ -980,7 +971,7 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip)
         return 1;
 }
 
-__u32 
+__u32
 lnet_netspec2net(char *netspec)
 {
         char   *bracket = strchr(netspec, '(');
@@ -993,27 +984,27 @@ lnet_netspec2net(char *netspec)
 
         if (bracket != NULL)
                 *bracket = '(';
-                
+
         return net;
 }
 
 int
-lnet_splitnets(char *source, struct list_head *nets)
+lnet_splitnets(char *source, cfs_list_t *nets)
 {
         int               offset = 0;
         int               offset2;
         int               len;
         lnet_text_buf_t  *tb;
         lnet_text_buf_t  *tb2;
-        struct list_head *t;
+        cfs_list_t       *t;
         char             *sep;
         char             *bracket;
         __u32             net;
 
-        LASSERT (!list_empty(nets));
+        LASSERT (!cfs_list_empty(nets));
         LASSERT (nets->next == nets->prev);     /* single entry */
-        
-        tb = list_entry(nets->next, lnet_text_buf_t, ltb_list);
+
+        tb = cfs_list_entry(nets->next, lnet_text_buf_t, ltb_list);
 
         for (;;) {
                 sep = strchr(tb->ltb_text, ',');
@@ -1024,7 +1015,7 @@ lnet_splitnets(char *source, struct list_head *nets)
                     bracket < sep) {
                         /* netspec lists interfaces... */
 
-                        offset2 = offset + (bracket - tb->ltb_text);
+                        offset2 = offset + (int)(bracket - tb->ltb_text);
                         len = strlen(bracket);
 
                         bracket = strchr(bracket + 1, ')');
@@ -1048,8 +1039,8 @@ lnet_splitnets(char *source, struct list_head *nets)
                         return -EINVAL;
                 }
 
-                list_for_each(t, nets) {
-                        tb2 = list_entry(t, lnet_text_buf_t, ltb_list);
+                cfs_list_for_each(t, nets) {
+                        tb2 = cfs_list_entry(t, lnet_text_buf_t, ltb_list);
 
                         if (tb2 == tb)
                                 continue;
@@ -1061,17 +1052,17 @@ lnet_splitnets(char *source, struct list_head *nets)
                                 return -EINVAL;
                         }
                 }
-                
+
                 if (sep == NULL)
                         return 0;
 
-                offset += sep - tb->ltb_text;
+                offset += (int)(sep - tb->ltb_text);
                 tb2 = lnet_new_text_buf(strlen(sep));
                 if (tb2 == NULL)
                         return -ENOMEM;
-                        
+
                 strcpy(tb2->ltb_text, sep);
-                list_add_tail(&tb2->ltb_list, nets);
+                cfs_list_add_tail(&tb2->ltb_list, nets);
 
                 tb = tb2;
         }
@@ -1080,14 +1071,14 @@ lnet_splitnets(char *source, struct list_head *nets)
 int
 lnet_match_networks (char **networksp, char *ip2nets, __u32 *ipaddrs, int nip)
 {
-        static char  networks[LNET_SINGLE_TEXTBUF_NOB];
-        static char  source[LNET_SINGLE_TEXTBUF_NOB];
-
-        struct list_head    raw_entries;
-        struct list_head    matched_nets;
-        struct list_head    current_nets;
-        struct list_head   *t;
-        struct list_head   *t2;
+        static char        networks[LNET_SINGLE_TEXTBUF_NOB];
+        static char        source[LNET_SINGLE_TEXTBUF_NOB];
+
+        cfs_list_t          raw_entries;
+        cfs_list_t          matched_nets;
+        cfs_list_t          current_nets;
+        cfs_list_t         *t;
+        cfs_list_t         *t2;
         lnet_text_buf_t    *tb;
         lnet_text_buf_t    *tb2;
         __u32               net1;
@@ -1111,8 +1102,9 @@ lnet_match_networks (char **networksp, char *ip2nets, __u32 *ipaddrs, int nip)
         len = 0;
         rc = 0;
 
-        while (!list_empty(&raw_entries)) {
-                tb = list_entry(raw_entries.next, lnet_text_buf_t, ltb_list);
+        while (!cfs_list_empty(&raw_entries)) {
+                tb = cfs_list_entry(raw_entries.next, lnet_text_buf_t,
+                                    ltb_list);
 
                 strncpy(source, tb->ltb_text, sizeof(source)-1);
                 source[sizeof(source)-1] = 0;
@@ -1122,7 +1114,7 @@ lnet_match_networks (char **networksp, char *ip2nets, __u32 *ipaddrs, int nip)
                 if (rc < 0)
                         break;
 
-                list_del(&tb->ltb_list);
+                cfs_list_del(&tb->ltb_list);
 
                 if (rc == 0) {                  /* no match */
                         lnet_free_text_buf(tb);
@@ -1131,19 +1123,20 @@ lnet_match_networks (char **networksp, char *ip2nets, __u32 *ipaddrs, int nip)
 
                 /* split into separate networks */
                 CFS_INIT_LIST_HEAD(&current_nets);
-                list_add(&tb->ltb_list, &current_nets);
+                cfs_list_add(&tb->ltb_list, &current_nets);
                 rc = lnet_splitnets(source, &current_nets);
                 if (rc < 0)
                         break;
 
                 dup = 0;
-                list_for_each (t, &current_nets) {
-                        tb = list_entry(t, lnet_text_buf_t, ltb_list);
+                cfs_list_for_each (t, &current_nets) {
+                        tb = cfs_list_entry(t, lnet_text_buf_t, ltb_list);
                         net1 = lnet_netspec2net(tb->ltb_text);
                         LASSERT (net1 != LNET_NIDNET(LNET_NID_ANY));
 
-                        list_for_each(t2, &matched_nets) {
-                                tb2 = list_entry(t2, lnet_text_buf_t, ltb_list);
+                        cfs_list_for_each(t2, &matched_nets) {
+                                tb2 = cfs_list_entry(t2, lnet_text_buf_t,
+                                                     ltb_list);
                                 net2 = lnet_netspec2net(tb2->ltb_text);
                                 LASSERT (net2 != LNET_NIDNET(LNET_NID_ANY));
 
@@ -1162,11 +1155,11 @@ lnet_match_networks (char **networksp, char *ip2nets, __u32 *ipaddrs, int nip)
                         continue;
                 }
 
-                list_for_each_safe(t, t2, &current_nets) {
-                        tb = list_entry(t, lnet_text_buf_t, ltb_list);
+                cfs_list_for_each_safe(t, t2, &current_nets) {
+                        tb = cfs_list_entry(t, lnet_text_buf_t, ltb_list);
                         
-                        list_del(&tb->ltb_list);
-                        list_add_tail(&tb->ltb_list, &matched_nets);
+                        cfs_list_del(&tb->ltb_list);
+                        cfs_list_add_tail(&tb->ltb_list, &matched_nets);
 
                         len += snprintf(networks + len, sizeof(networks) - len,
                                         "%s%s", (len == 0) ? "" : ",", 
@@ -1190,7 +1183,7 @@ lnet_match_networks (char **networksp, char *ip2nets, __u32 *ipaddrs, int nip)
 
         if (rc < 0)
                 return rc;
-        
+
         *networksp = networks;
         return count;
 }
@@ -1217,7 +1210,7 @@ lnet_ipaddr_enumerate (__u32 **ipaddrsp)
 
         if (nif <= 0)
                 return nif;
-        
+
         LIBCFS_ALLOC(ipaddrs, nif * sizeof(*ipaddrs));
         if (ipaddrs == NULL) {
                 CERROR("Can't allocate ipaddrs[%d]\n", nif);
@@ -1228,8 +1221,8 @@ lnet_ipaddr_enumerate (__u32 **ipaddrsp)
         for (i = nip = 0; i < nif; i++) {
                 if (!strcmp(ifnames[i], "lo"))
                         continue;
-                
-                rc = libcfs_ipif_query(ifnames[i], &up, 
+
+                rc = libcfs_ipif_query(ifnames[i], &up,
                                        &ipaddrs[nip], &netmask);
                 if (rc != 0) {
                         CWARN("Can't query interface %s: %d\n",
@@ -1276,14 +1269,14 @@ lnet_parse_ip2nets (char **networksp, char *ip2nets)
         int        rc;
 
         if (nip < 0) {
-                LCONSOLE_ERROR(0x117, "Error %d enumerating local IP interfaces "
-                               "for ip2nets to match\n", nip);
+                LCONSOLE_ERROR_MSG(0x117, "Error %d enumerating local IP "
+                                   "interfaces for ip2nets to match\n", nip);
                 return nip;
         }
 
         if (nip == 0) {
-                LCONSOLE_ERROR(0x118, "No local IP interfaces "
-                               "for ip2nets to match\n");
+                LCONSOLE_ERROR_MSG(0x118, "No local IP interfaces "
+                                   "for ip2nets to match\n");
                 return -ENOENT;
         }
 
@@ -1291,13 +1284,13 @@ lnet_parse_ip2nets (char **networksp, char *ip2nets)
         lnet_ipaddr_free_enumeration(ipaddrs, nip);
 
         if (rc < 0) {
-                LCONSOLE_ERROR(0x119, "Error %d parsing ip2nets\n", rc);
+                LCONSOLE_ERROR_MSG(0x119, "Error %d parsing ip2nets\n", rc);
                 return rc;
         }
 
         if (rc == 0) {
-                LCONSOLE_ERROR(0x11a, "ip2nets does not match "
-                               "any local IP interfaces\n");
+                LCONSOLE_ERROR_MSG(0x11a, "ip2nets does not match "
+                                   "any local IP interfaces\n");
                 return -ENOENT;
         }
 
@@ -1305,7 +1298,7 @@ lnet_parse_ip2nets (char **networksp, char *ip2nets)
 }
 
 int
-lnet_set_ip_niaddr (lnet_ni_t *ni) 
+lnet_set_ip_niaddr (lnet_ni_t *ni)
 {
         __u32  net = LNET_NIDNET(ni->ni_nid);
         char **names;
@@ -1328,7 +1321,7 @@ lnet_set_ip_niaddr (lnet_ni_t *ni)
                                libcfs_net2str(net));
                         return -EPERM;
                 }
-                
+
                 rc = libcfs_ipif_query(ni->ni_interfaces[0],
                                        &up, &ip, &netmask);
                 if (rc != 0) {
@@ -1342,14 +1335,14 @@ lnet_set_ip_niaddr (lnet_ni_t *ni)
                                libcfs_net2str(net), ni->ni_interfaces[0]);
                         return -ENETDOWN;
                 }
-                
+
                 ni->ni_nid = LNET_MKNID(net, ip);
                 return 0;
         }
 
         n = libcfs_ipif_enumerate(&names);
         if (n <= 0) {
-                CERROR("Net %s can't enumerate interfaces: %d\n", 
+                CERROR("Net %s can't enumerate interfaces: %d\n",
                        libcfs_net2str(net), n);
                 return 0;
         }
@@ -1357,15 +1350,15 @@ lnet_set_ip_niaddr (lnet_ni_t *ni)
         for (i = 0; i < n; i++) {
                 if (!strcmp(names[i], "lo")) /* skip the loopback IF */
                         continue;
-                
+
                 rc = libcfs_ipif_query(names[i], &up, &ip, &netmask);
-                
+
                 if (rc != 0) {
                         CWARN("Net %s can't query interface %s: %d\n",
                               libcfs_net2str(net), names[i], rc);
                         continue;
                 }
-                        
+
                 if (!up) {
                         CWARN("Net %s ignoring interface %s (down)\n",
                               libcfs_net2str(net), names[i]);