Whamcloud - gitweb
i=liang,b=13065:
[fs/lustre-release.git] / lnet / lnet / api-ni.c
index 8a86dcc..a7a4f2b 100644 (file)
@@ -1,22 +1,37 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- *  Copyright (c) 2001-2003 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
@@ -44,10 +59,6 @@ static char *routes = "";
 CFS_MODULE_PARM(routes, "s", charp, 0444,
                 "routes to non-local networks");
 
-static char *portals_compatibility = "none";
-CFS_MODULE_PARM(portals_compatibility, "s", charp, 0444,
-                "wire protocol compatibility: 'strong'|'weak'|'none'");
-
 char *
 lnet_get_routes(void)
 {
@@ -65,7 +76,7 @@ lnet_get_networks(void)
                                    "'ip2nets' but not both at once\n");
                 return NULL;
         }
-        
+
         if (*ip2nets != 0) {
                 rc = lnet_parse_ip2nets(&nets, ip2nets);
                 return (rc == 0) ? nets : NULL;
@@ -77,28 +88,6 @@ lnet_get_networks(void)
         return "tcp";
 }
 
-int
-lnet_get_portals_compatibility(void)
-{
-        if (!strcmp(portals_compatibility, "none")) {
-                return 0;
-        }
-
-        if (!strcmp(portals_compatibility, "weak")) {
-                return 1;
-                LCONSOLE_WARN("Starting in weak portals-compatible mode\n");
-        }
-
-        if (!strcmp(portals_compatibility, "strong")) {
-                return 2;
-                LCONSOLE_WARN("Starting in strong portals-compatible mode\n");
-        } 
-
-        LCONSOLE_ERROR_MSG(0x102, "portals_compatibility=\"%s\" not supported\n",
-                           portals_compatibility);
-        return -EINVAL;
-}
-
 void
 lnet_init_locks(void)
 {
@@ -119,7 +108,7 @@ char *
 lnet_get_routes(void)
 {
         char *str = getenv("LNET_ROUTES");
-        
+
         return (str == NULL) ? "" : str;
 }
 
@@ -160,32 +149,26 @@ lnet_get_networks (void)
         str = default_networks;
         *str = 0;
         sep = "";
-                
+
         list_for_each (tmp, &the_lnet.ln_lnds) {
-                        lnd_t *lnd = list_entry(tmp, lnd_t, lnd_list);
-                        
-                        nob = snprintf(str, len, "%s%s", sep,
-                                       libcfs_lnd2str(lnd->lnd_type));
-                        len -= nob;
-                        if (len < 0) {
-                                /* overflowed the string; leave it where it was */
-                                *str = 0;
-                                break;
-                        }
-                        
-                        str += nob;
-                        sep = ",";
+                lnd_t *lnd = list_entry(tmp, lnd_t, lnd_list);
+
+                nob = snprintf(str, len, "%s%s", sep,
+                               libcfs_lnd2str(lnd->lnd_type));
+                len -= nob;
+                if (len < 0) {
+                        /* overflowed the string; leave it where it was */
+                        *str = 0;
+                        break;
+                }
+
+                str += nob;
+                sep = ",";
         }
 
         return default_networks;
 }
 
-int
-lnet_get_portals_compatibility(void)
-{
-        return 0;
-}
-
 # ifndef HAVE_LIBPTHREAD
 
 void lnet_init_locks(void)
@@ -317,7 +300,7 @@ void lnet_assert_wire_constants (void)
 }
 
 lnd_t *
-lnet_find_lnd_by_type (int type) 
+lnet_find_lnd_by_type (int type)
 {
         lnd_t              *lnd;
         struct list_head   *tmp;
@@ -326,10 +309,10 @@ lnet_find_lnd_by_type (int type)
         list_for_each (tmp, &the_lnet.ln_lnds) {
                 lnd = list_entry(tmp, lnd_t, lnd_list);
 
-                if (lnd->lnd_type == type)
+                if ((int)lnd->lnd_type == type)
                         return lnd;
         }
-        
+
         return NULL;
 }
 
@@ -341,7 +324,7 @@ lnet_register_lnd (lnd_t *lnd)
         LASSERT (the_lnet.ln_init);
         LASSERT (libcfs_isknown_lnd(lnd->lnd_type));
         LASSERT (lnet_find_lnd_by_type(lnd->lnd_type) == NULL);
-        
+
         list_add_tail (&lnd->lnd_list, &the_lnet.ln_lnds);
         lnd->lnd_refcount = 0;
 
@@ -358,7 +341,7 @@ lnet_unregister_lnd (lnd_t *lnd)
         LASSERT (the_lnet.ln_init);
         LASSERT (lnet_find_lnd_by_type(lnd->lnd_type) == lnd);
         LASSERT (lnd->lnd_refcount == 0);
-        
+
         list_del (&lnd->lnd_list);
         CDEBUG(D_NET, "%s LND unregistered\n", libcfs_lnd2str(lnd->lnd_type));
 
@@ -424,7 +407,7 @@ lnet_freelist_fini (lnet_freelist_t *fl)
         LASSERT (count == fl->fl_nobjs);
 
         LIBCFS_FREE(fl->fl_objs, fl->fl_nobjs * fl->fl_objsize);
-        memset (fl, 0, sizeof (fl));
+        memset (fl, 0, sizeof (*fl));
 }
 
 int
@@ -492,10 +475,10 @@ lnet_create_interface_cookie (void)
 }
 
 int
-lnet_setup_handle_hash (void) 
+lnet_setup_handle_hash (void)
 {
         int       i;
-        
+
         /* Arbitrary choice of hash table size */
 #ifdef __KERNEL__
         the_lnet.ln_lh_hash_size = CFS_PAGE_SIZE / sizeof (struct list_head);
@@ -506,12 +489,12 @@ lnet_setup_handle_hash (void)
                      the_lnet.ln_lh_hash_size * sizeof (struct list_head));
         if (the_lnet.ln_lh_hash_table == NULL)
                 return (-ENOMEM);
-        
+
         for (i = 0; i < the_lnet.ln_lh_hash_size; i++)
                 CFS_INIT_LIST_HEAD (&the_lnet.ln_lh_hash_table[i]);
 
         the_lnet.ln_next_object_cookie = LNET_COOKIE_TYPES;
-        
+
         return (0);
 }
 
@@ -520,13 +503,13 @@ lnet_cleanup_handle_hash (void)
 {
         if (the_lnet.ln_lh_hash_table == NULL)
                 return;
-        
+
         LIBCFS_FREE(the_lnet.ln_lh_hash_table,
                     the_lnet.ln_lh_hash_size * sizeof (struct list_head));
 }
 
 lnet_libhandle_t *
-lnet_lookup_cookie (__u64 cookie, int type) 
+lnet_lookup_cookie (__u64 cookie, int type)
 {
         /* ALWAYS called with LNET_LOCK held */
         struct list_head    *list;
@@ -535,23 +518,23 @@ lnet_lookup_cookie (__u64 cookie, int type)
 
         if ((cookie & (LNET_COOKIE_TYPES - 1)) != type)
                 return (NULL);
-        
+
         hash = ((unsigned int)cookie) % the_lnet.ln_lh_hash_size;
         list = &the_lnet.ln_lh_hash_table[hash];
-        
+
         list_for_each (el, list) {
                 lnet_libhandle_t *lh = list_entry (el, lnet_libhandle_t,
                                                   lh_hash_chain);
-                
+
                 if (lh->lh_cookie == cookie)
                         return (lh);
         }
-        
+
         return (NULL);
 }
 
 void
-lnet_initialise_handle (lnet_libhandle_t *lh, int type) 
+lnet_initialise_handle (lnet_libhandle_t *lh, int type)
 {
         /* ALWAYS called with LNET_LOCK held */
         unsigned int    hash;
@@ -559,7 +542,7 @@ lnet_initialise_handle (lnet_libhandle_t *lh, int type)
         LASSERT (type >= 0 && type < LNET_COOKIE_TYPES);
         lh->lh_cookie = the_lnet.ln_next_object_cookie | type;
         the_lnet.ln_next_object_cookie += LNET_COOKIE_TYPES;
-        
+
         hash = ((unsigned int)lh->lh_cookie) % the_lnet.ln_lh_hash_size;
         list_add (&lh->lh_hash_chain, &the_lnet.ln_lh_hash_table[hash]);
 }
@@ -577,10 +560,10 @@ lnet_init_finalizers(void)
 #ifdef __KERNEL__
         int    i;
 
-        the_lnet.ln_nfinalizers = num_online_cpus();
+        the_lnet.ln_nfinalizers = (int) num_online_cpus();
 
         LIBCFS_ALLOC(the_lnet.ln_finalizers,
-                     the_lnet.ln_nfinalizers * 
+                     the_lnet.ln_nfinalizers *
                      sizeof(*the_lnet.ln_finalizers));
         if (the_lnet.ln_finalizers == NULL) {
                 CERROR("Can't allocate ln_finalizers\n");
@@ -602,7 +585,7 @@ lnet_fini_finalizers(void)
 {
 #ifdef __KERNEL__
         int    i;
-        
+
         for (i = 0; i < the_lnet.ln_nfinalizers; i++)
                 LASSERT (the_lnet.ln_finalizers[i] == NULL);
 
@@ -624,7 +607,7 @@ void
 lnet_server_mode() {
         the_lnet.ln_server_mode_flag = 1;
 }
-#endif        
+#endif
 
 int
 lnet_prepare(lnet_pid_t requested_pid)
@@ -643,7 +626,7 @@ lnet_prepare(lnet_pid_t requested_pid)
 #else
         if (the_lnet.ln_server_mode_flag) {/* server case (uOSS) */
                 LASSERT ((requested_pid & LNET_PID_USERFLAG) == 0);
-                
+
                 if (cfs_curproc_uid())/* Only root can run user-space server */
                         return -EPERM;
                 the_lnet.ln_pid = requested_pid;
@@ -652,14 +635,14 @@ lnet_prepare(lnet_pid_t requested_pid)
 
                 /* My PID must be unique on this node and flag I'm userspace */
                 the_lnet.ln_pid = getpid() | LNET_PID_USERFLAG;
-        }        
+        }
 #endif
 
         rc = lnet_descriptor_setup();
         if (rc != 0)
                 goto failed0;
 
-        memset(&the_lnet.ln_counters, 0, 
+        memset(&the_lnet.ln_counters, 0,
                sizeof(the_lnet.ln_counters));
 
         CFS_INIT_LIST_HEAD (&the_lnet.ln_active_msgs);
@@ -688,8 +671,8 @@ lnet_prepare(lnet_pid_t requested_pid)
                 goto failed2;
 
         the_lnet.ln_nportals = MAX_PORTALS;
-        LIBCFS_ALLOC(the_lnet.ln_portals, 
-                     the_lnet.ln_nportals * 
+        LIBCFS_ALLOC(the_lnet.ln_portals,
+                     the_lnet.ln_nportals *
                      sizeof(*the_lnet.ln_portals));
         if (the_lnet.ln_portals == NULL) {
                 rc = -ENOMEM;
@@ -703,7 +686,7 @@ lnet_prepare(lnet_pid_t requested_pid)
         }
 
         return 0;
-        
+
  failed3:
         lnet_fini_finalizers();
  failed2:
@@ -719,7 +702,7 @@ int
 lnet_unprepare (void)
 {
         int       idx;
-        
+
         /* NB no LNET_LOCK since this is the last reference.  All LND instances
          * have shut down already, so it is safe to unlink and free all
          * descriptors, even those that appear committed to a network op (eg MD
@@ -732,7 +715,7 @@ lnet_unprepare (void)
         LASSERT (list_empty(&the_lnet.ln_nis));
         LASSERT (list_empty(&the_lnet.ln_zombie_nis));
         LASSERT (the_lnet.ln_nzombie_nis == 0);
-               
+
         for (idx = 0; idx < the_lnet.ln_nportals; idx++) {
                 LASSERT (list_empty(&the_lnet.ln_portals[idx].ptl_msgq));
 
@@ -751,7 +734,7 @@ lnet_unprepare (void)
                                                lnet_libmd_t, md_list);
 
                 CERROR ("Active md %p on exit\n", md);
-                list_del (&md->md_list);
+                list_del_init (&md->md_list);
                 lnet_md_free (md);
         }
 
@@ -796,12 +779,12 @@ lnet_net2ni_locked (__u32 net)
         list_for_each (tmp, &the_lnet.ln_nis) {
                 ni = list_entry(tmp, lnet_ni_t, ni_list);
 
-                if (lnet_ptlcompat_matchnet(LNET_NIDNET(ni->ni_nid), net)) {
+                if (LNET_NIDNET(ni->ni_nid) == net) {
                         lnet_ni_addref_locked(ni);
                         return ni;
                 }
         }
-        
+
         return NULL;
 }
 
@@ -809,7 +792,7 @@ int
 lnet_islocalnet (__u32 net)
 {
         lnet_ni_t        *ni;
-        
+
         LNET_LOCK();
         ni = lnet_net2ni_locked(net);
         if (ni != NULL)
@@ -828,12 +811,12 @@ lnet_nid2ni_locked (lnet_nid_t nid)
         list_for_each (tmp, &the_lnet.ln_nis) {
                 ni = list_entry(tmp, lnet_ni_t, ni_list);
 
-                if (lnet_ptlcompat_matchnid(ni->ni_nid, nid)) {
+                if (ni->ni_nid == nid) {
                         lnet_ni_addref_locked(ni);
                         return ni;
                 }
         }
-        
+
         return NULL;
 }
 
@@ -841,7 +824,7 @@ int
 lnet_islocalnid (lnet_nid_t nid)
 {
         lnet_ni_t     *ni;
-        
+
         LNET_LOCK();
         ni = lnet_nid2ni_locked(nid);
         if (ni != NULL)
@@ -852,11 +835,9 @@ lnet_islocalnid (lnet_nid_t nid)
 }
 
 int
-lnet_count_acceptor_nis (lnet_ni_t **first_ni)
+lnet_count_acceptor_nis (void)
 {
-        /* Return the # of NIs that need the acceptor.  Return the first one in
-         * *first_ni so the acceptor can pass it connections "blind" to retain
-         * binary compatibility. */
+        /* Return the # of NIs that need the acceptor. */
         int                count = 0;
 #if defined(__KERNEL__) || defined(HAVE_LIBPTHREAD)
         struct list_head  *tmp;
@@ -866,16 +847,10 @@ lnet_count_acceptor_nis (lnet_ni_t **first_ni)
         list_for_each (tmp, &the_lnet.ln_nis) {
                 ni = list_entry(tmp, lnet_ni_t, ni_list);
 
-                if (ni->ni_lnd->lnd_accept != NULL) {
-                        /* This LND uses the acceptor */
-                        if (count == 0 && first_ni != NULL) {
-                                lnet_ni_addref_locked(ni);
-                                *first_ni = ni;
-                        }
+                if (ni->ni_lnd->lnd_accept != NULL)
                         count++;
-                }
         }
-        
+
         LNET_UNLOCK();
 
 #endif /* defined(__KERNEL__) || defined(HAVE_LIBPTHREAD) */
@@ -1065,6 +1040,8 @@ lnet_startup_lndnis (void)
                         goto failed;
                 }
 
+                LASSERT (ni->ni_peertimeout <= 0 || lnd->lnd_query != NULL);
+
                 list_del(&ni->ni_list);
 
                 LNET_LOCK();
@@ -1104,21 +1081,11 @@ lnet_startup_lndnis (void)
 
                 ni->ni_txcredits = ni->ni_mintxcredits = ni->ni_maxtxcredits;
 
-                CDEBUG(D_LNI, "Added LNI %s [%d/%d]\n",
+                CDEBUG(D_LNI, "Added LNI %s [%d/%d/%d/%d]\n",
                        libcfs_nid2str(ni->ni_nid),
-                       ni->ni_peertxcredits, ni->ni_txcredits);
-
-                /* Handle nidstrings for network 0 just like this one */
-                if (the_lnet.ln_ptlcompat > 0) {
-                        if (nicount > 0) {
-                                LCONSOLE_ERROR_MSG(0x108, "Can't run > 1 "
-                                       "network when portals_compatibility is "
-                                       "set\n");
-                                goto failed;
-                        }
-                        libcfs_setnet0alias(lnd->lnd_type);
-                }
-                
+                       ni->ni_peertxcredits, ni->ni_txcredits,
+                       ni->ni_peerrtrcredits, ni->ni_peertimeout);
+
                 nicount++;
         }
 
@@ -1147,20 +1114,13 @@ lnet_startup_lndnis (void)
 int
 LNetInit(void)
 {
-        int    rc;
-
         lnet_assert_wire_constants ();
         LASSERT (!the_lnet.ln_init);
 
         memset(&the_lnet, 0, sizeof(the_lnet));
 
-        rc = lnet_get_portals_compatibility();
-        if (rc < 0)
-                return rc;
-
         lnet_init_locks();
         CFS_INIT_LIST_HEAD(&the_lnet.ln_lnds);
-        the_lnet.ln_ptlcompat = rc;
         the_lnet.ln_refcount = 0;
         the_lnet.ln_init = 1;
 
@@ -1212,6 +1172,8 @@ LNetNIInit(lnet_pid_t requested_pid)
                 goto out;
         }
 
+        lnet_get_tunables();
+
         if (requested_pid == LNET_PID_ANY) {
                 /* Don't instantiate LNET just for me */
                 rc = -ENETDOWN;
@@ -1307,7 +1269,7 @@ int
 LNetCtl(unsigned int cmd, void *arg)
 {
         struct libcfs_ioctl_data *data = arg;
-        lnet_process_id_t         id;
+        lnet_process_id_t         id = {0};
         lnet_ni_t                *ni;
         int                       rc;
 
@@ -1322,31 +1284,32 @@ LNetCtl(unsigned int cmd, void *arg)
 
         case IOC_LIBCFS_FAIL_NID:
                 return lnet_fail_nid(data->ioc_nid, data->ioc_count);
-                
+
         case IOC_LIBCFS_ADD_ROUTE:
-                rc = lnet_add_route(data->ioc_net, data->ioc_count, 
+                rc = lnet_add_route(data->ioc_net, data->ioc_count,
                                     data->ioc_nid);
                 return (rc != 0) ? rc : lnet_check_routes();
-                
+
         case IOC_LIBCFS_DEL_ROUTE:
                 return lnet_del_route(data->ioc_net, data->ioc_nid);
 
         case IOC_LIBCFS_GET_ROUTE:
-                return lnet_get_route(data->ioc_count, 
-                                      &data->ioc_net, &data->ioc_count, 
+                return lnet_get_route(data->ioc_count,
+                                      &data->ioc_net, &data->ioc_count,
                                       &data->ioc_nid, &data->ioc_flags);
         case IOC_LIBCFS_NOTIFY_ROUTER:
-                return lnet_notify(NULL, data->ioc_nid, data->ioc_flags, 
+                return lnet_notify(NULL, data->ioc_nid, data->ioc_flags,
                                    (time_t)data->ioc_u64[0]);
 
         case IOC_LIBCFS_PORTALS_COMPATIBILITY:
-                return the_lnet.ln_ptlcompat;
+                /* This can be removed once lustre stops calling it */
+                return 0;
 
         case IOC_LIBCFS_LNET_DIST:
                 rc = LNetDist(data->ioc_nid, &data->ioc_nid, &data->ioc_u32[1]);
                 if (rc < 0 && rc != -EHOSTUNREACH)
                         return rc;
-                
+
                 data->ioc_u32[0] = rc;
                 return 0;
 
@@ -1357,9 +1320,9 @@ LNetCtl(unsigned int cmd, void *arg)
                 return 0;
 
         case IOC_LIBCFS_PING:
-                rc = lnet_ping((lnet_process_id_t) {.nid = data->ioc_nid,
-                                                    .pid = data->ioc_u32[0]},
-                               data->ioc_u32[1], /* timeout */
+                id.nid = data->ioc_nid;
+                id.pid = data->ioc_u32[0];
+                rc = lnet_ping(id, data->ioc_u32[1], /* timeout */
                                (lnet_process_id_t *)data->ioc_pbuf1,
                                data->ioc_plen1/sizeof(lnet_process_id_t));
                 if (rc < 0)
@@ -1370,26 +1333,26 @@ LNetCtl(unsigned int cmd, void *arg)
         case IOC_LIBCFS_DEBUG_PEER: {
                 /* CAVEAT EMPTOR: this one designed for calling directly; not
                  * via an ioctl */
-                lnet_process_id_t *id = arg;
+                id = *((lnet_process_id_t *) arg);
 
-                lnet_debug_peer(id->nid);
+                lnet_debug_peer(id.nid);
 
-                ni = lnet_net2ni(LNET_NIDNET(id->nid));
+                ni = lnet_net2ni(LNET_NIDNET(id.nid));
                 if (ni == NULL) {
-                        CDEBUG(D_WARNING, "No NI for %s\n", libcfs_id2str(*id));
+                        CDEBUG(D_WARNING, "No NI for %s\n", libcfs_id2str(id));
                 } else {
                         if (ni->ni_lnd->lnd_ctl == NULL) {
                                 CDEBUG(D_WARNING, "No ctl for %s\n",
-                                       libcfs_id2str(*id));
+                                       libcfs_id2str(id));
                         } else {
                                 (void)ni->ni_lnd->lnd_ctl(ni, cmd, arg);
                         }
-                        
+
                         lnet_ni_decref(ni);
                 }
                 return 0;
         }
-                
+
         default:
                 ni = lnet_net2ni(data->ioc_net);
                 if (ni == NULL)
@@ -1421,7 +1384,7 @@ LNetGetId(unsigned int index, lnet_process_id_t *id)
         list_for_each(tmp, &the_lnet.ln_nis) {
                 if (index-- != 0)
                         continue;
-                
+
                 ni = list_entry(tmp, lnet_ni_t, ni_list);
 
                 id->nid = ni->ni_nid;
@@ -1447,12 +1410,13 @@ lnet_ping_target_init(void)
 {
         lnet_handle_me_t  meh;
         lnet_process_id_t id;
+        lnet_md_t         md = {0};
         int               rc;
         int               rc2;
         int               n;
-        int               infosz;
+        unsigned int      infosz;
         int               i;
-        
+
         for (n = 0; ; n++) {
                 rc = LNetGetId(n, &id);
                 if (rc == -ENOENT)
@@ -1478,7 +1442,7 @@ lnet_ping_target_init(void)
                 LASSERT (rc == 0);
                 the_lnet.ln_ping_info->pi_nid[i] = id.nid;
         }
-        
+
         /* We can have a tiny EQ since we only need to see the unlink event on
          * teardown, which by definition is the last one! */
         rc = LNetEQAlloc(2, LNET_EQ_HANDLER_NONE, &the_lnet.ln_ping_target_eq);
@@ -1487,10 +1451,12 @@ lnet_ping_target_init(void)
                 goto failed_0;
         }
 
-        rc = LNetMEAttach(LNET_RESERVED_PORTAL,
-                          (lnet_process_id_t){.nid = LNET_NID_ANY,
-                                              .pid = LNET_PID_ANY},
-                          LNET_PROTO_PING_MATCHBITS, 0LL,
+        memset(&id, 0, sizeof(lnet_process_id_t));
+        id.nid = LNET_NID_ANY;
+        id.pid = LNET_PID_ANY;
+
+        rc = LNetMEAttach(LNET_RESERVED_PORTAL, id,
+                          LNET_PROTO_PING_MATCHBITS, 0,
                           LNET_UNLINK, LNET_INS_AFTER,
                           &meh);
         if (rc != 0) {
@@ -1498,14 +1464,17 @@ lnet_ping_target_init(void)
                 goto failed_1;
         }
 
-        rc = LNetMDAttach(meh,
-                          (lnet_md_t){.start = the_lnet.ln_ping_info,
-                                      .length = infosz,
-                                      .threshold = LNET_MD_THRESH_INF,
-                                      .options = (LNET_MD_OP_GET |
-                                                  LNET_MD_TRUNCATE |
-                                                  LNET_MD_MANAGE_REMOTE),
-                                      .eq_handle = the_lnet.ln_ping_target_eq},
+        /* initialize md content */
+        md.start     = the_lnet.ln_ping_info;
+        md.length    = infosz;
+        md.threshold = LNET_MD_THRESH_INF;
+        md.max_size  = 0;
+        md.options   = LNET_MD_OP_GET | LNET_MD_TRUNCATE |
+                       LNET_MD_MANAGE_REMOTE;
+        md.user_ptr  = NULL;
+        md.eq_handle = the_lnet.ln_ping_target_eq;
+
+        rc = LNetMDAttach(meh, md,
                           LNET_RETAIN,
                           &the_lnet.ln_ping_target_md);
         if (rc != 0) {
@@ -1574,6 +1543,7 @@ lnet_ping (lnet_process_id_t id, int timeout_ms, lnet_process_id_t *ids, int n_i
         lnet_handle_eq_t     eqh;
         lnet_handle_md_t     mdh;
         lnet_event_t         event;
+        lnet_md_t            md = {0};
         int                  which;
         int                  unlinked = 0;
         int                  replied = 0;
@@ -1607,13 +1577,16 @@ lnet_ping (lnet_process_id_t id, int timeout_ms, lnet_process_id_t *ids, int n_i
                 goto out_0;
         }
 
-        rc = LNetMDBind((lnet_md_t){.start = info,
-                                    .length = infosz,
-                                    .threshold = 2, /* GET/REPLY */
-                                    .options = LNET_MD_TRUNCATE,
-                                    .eq_handle = eqh},
-                        LNET_UNLINK,
-                        &mdh);
+        /* initialize md content */
+        md.start     = info;
+        md.length    = infosz;
+        md.threshold = 2; /*GET/REPLY*/
+        md.max_size  = 0;
+        md.options   = LNET_MD_TRUNCATE;
+        md.user_ptr  = NULL;
+        md.eq_handle = eqh;
+
+        rc = LNetMDBind(md, LNET_UNLINK, &mdh);
         if (rc != 0) {
                 CERROR("Can't bind MD: %d\n", rc);
                 goto out_1;
@@ -1703,7 +1676,7 @@ lnet_ping (lnet_process_id_t id, int timeout_ms, lnet_process_id_t *ids, int n_i
                 __swab32s(&info->pi_version);
                 __swab32s(&info->pi_pid);
                 __swab32s(&info->pi_nnids);
-                for (i = 0; i < info->pi_nnids && i < n_ids; i++)
+                for (i = 0; i < (int)info->pi_nnids && i < (int)n_ids; i++)
                         __swab64s(&info->pi_nid[i]);
 
         } else if (info->pi_magic != LNET_PROTO_PING_MAGIC) {
@@ -1718,17 +1691,17 @@ lnet_ping (lnet_process_id_t id, int timeout_ms, lnet_process_id_t *ids, int n_i
                 goto out_1;
         }
 
-        if (nob < offsetof(lnet_ping_info_t, pi_nid[0])) {
-                CERROR("%s: Short reply %d(%d min)\n", libcfs_id2str(id), 
+        if (nob < (int)offsetof(lnet_ping_info_t, pi_nid[0])) {
+                CERROR("%s: Short reply %d(%d min)\n", libcfs_id2str(id),
                        nob, (int)offsetof(lnet_ping_info_t, pi_nid[0]));
                 goto out_1;
         }
 
-        if (info->pi_nnids < n_ids)
+        if ((int) info->pi_nnids < n_ids)
                 n_ids = info->pi_nnids;
 
-        if (nob < offsetof(lnet_ping_info_t, pi_nid[n_ids])) {
-                CERROR("%s: Short reply %d(%d expected)\n", libcfs_id2str(id), 
+        if (nob < (int)offsetof(lnet_ping_info_t, pi_nid[n_ids])) {
+                CERROR("%s: Short reply %d(%d expected)\n", libcfs_id2str(id),
                        nob, (int)offsetof(lnet_ping_info_t, pi_nid[n_ids]));
                 goto out_1;
         }