Whamcloud - gitweb
i=liang,b=13065:
[fs/lustre-release.git] / lnet / lnet / config.c
index cd5e211..45bd89f 100644 (file)
@@ -1,22 +1,37 @@
 /* -*- 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  2008 Sun Microsystems, Inc. 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
@@ -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("Error parsing '%s=\"%s\"'\n", name, str);
-       LCONSOLE_ERROR("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--;
        }
@@ -126,8 +127,8 @@ lnet_new_ni(__u32 net, struct list_head *nilist)
         lnet_ni_t *ni;
 
         if (!lnet_net_unique(net, nilist)) {
-                LCONSOLE_ERROR("Duplicate network specified: %s\n",
-                               libcfs_net2str(net));
+                LCONSOLE_ERROR_MSG(0x111, "Duplicate network specified: %s\n",
+                                   libcfs_net2str(net));
                 return NULL;
         }
         
@@ -161,7 +162,8 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
 
        if (strlen(networks) > LNET_SINGLE_TEXTBUF_NOB) {
                /* _WAY_ conservative */
-               LCONSOLE_ERROR("Can't parse networks: string too long\n");
+               LCONSOLE_ERROR_MSG(0x112, "Can't parse networks: string too "
+                                   "long\n");
                return -EINVAL;
        }
 
@@ -174,7 +176,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 +203,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("Unrecognised network type\n");
+                                            (int)(str - tokens), strlen(str));
+                                LCONSOLE_ERROR_MSG(0x113, "Unrecognised network"
+                                                   " type\n");
                                 goto failed;
                         }
 
@@ -218,17 +221,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("Only 1 network supported when "
-                                       "'portals_compatible' is set\n");
-                        goto failed;
-                }
-
                 nnets++;
                 ni = lnet_new_ni(net, nilist);
                 if (ni == NULL)
@@ -240,7 +236,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 +249,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("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 +271,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,7 +281,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;
                 }
        }
@@ -378,12 +375,12 @@ lnet_str2tbs_sep (struct list_head *tbs, char *str)
         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 +388,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,7 +397,7 @@ 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];
@@ -432,7 +429,7 @@ lnet_expand1tb (struct list_head *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;
 
@@ -468,7 +465,7 @@ 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 */
@@ -493,7 +490,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;
@@ -575,7 +572,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 +584,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;
@@ -675,7 +672,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);
@@ -710,14 +707,6 @@ lnet_parse_routes (char *routes, int *im_a_router)
 
         *im_a_router = 0;
 
-        if (the_lnet.ln_ptlcompat > 0 && 
-            routes[0] != 0) {
-                /* Can't route when running in compatibility mode */
-                LCONSOLE_ERROR("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) {
@@ -943,7 +932,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 +940,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 +955,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;
                 }
 
@@ -1024,7 +1013,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, ')');
@@ -1065,7 +1054,7 @@ lnet_splitnets(char *source, struct list_head *nets)
                 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;
@@ -1276,14 +1265,14 @@ lnet_parse_ip2nets (char **networksp, char *ip2nets)
         int        rc;
 
         if (nip < 0) {
-                LCONSOLE_ERROR("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("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 +1280,13 @@ lnet_parse_ip2nets (char **networksp, char *ip2nets)
         lnet_ipaddr_free_enumeration(ipaddrs, nip);
 
         if (rc < 0) {
-                LCONSOLE_ERROR("Error %d parsing ip2nets\n", rc);
+                LCONSOLE_ERROR_MSG(0x119, "Error %d parsing ip2nets\n", rc);
                 return rc;
         }
 
         if (rc == 0) {
-                LCONSOLE_ERROR("ip2nets does not match "
-                               "any local IP interfaces\n");
+                LCONSOLE_ERROR_MSG(0x11a, "ip2nets does not match "
+                                   "any local IP interfaces\n");
                 return -ENOENT;
         }