1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (c) 2001-2003 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.sf.net/projects/lustre/
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #define DEBUG_SUBSYSTEM S_LNET
23 #include <lnet/lib-lnet.h>
26 #define D_LNI D_CONSOLE
28 #define D_LNI D_CONFIG
31 lnet_t the_lnet; /* THE state of the network */
35 static char *ip2nets = "";
36 CFS_MODULE_PARM(ip2nets, "s", charp, 0444,
37 "LNET network <- IP table");
39 static char *networks = "";
40 CFS_MODULE_PARM(networks, "s", charp, 0444,
43 static char *routes = "";
44 CFS_MODULE_PARM(routes, "s", charp, 0444,
45 "routes to non-local networks");
47 static char *portals_compatibility = "none";
48 CFS_MODULE_PARM(portals_compatibility, "s", charp, 0444,
49 "wire protocol compatibility: 'strong'|'weak'|'none'");
58 lnet_get_networks(void)
63 if (*networks != 0 && *ip2nets != 0) {
64 LCONSOLE_ERROR_MSG(0x101, "Please specify EITHER 'networks' or "
65 "'ip2nets' but not both at once\n");
70 rc = lnet_parse_ip2nets(&nets, ip2nets);
71 return (rc == 0) ? nets : NULL;
81 lnet_get_portals_compatibility(void)
83 if (!strcmp(portals_compatibility, "none")) {
87 if (!strcmp(portals_compatibility, "weak")) {
89 LCONSOLE_WARN("Starting in weak portals-compatible mode\n");
92 if (!strcmp(portals_compatibility, "strong")) {
94 LCONSOLE_WARN("Starting in strong portals-compatible mode\n");
97 LCONSOLE_ERROR_MSG(0x102, "portals_compatibility=\"%s\" not supported\n",
98 portals_compatibility);
103 lnet_init_locks(void)
105 spin_lock_init (&the_lnet.ln_lock);
106 cfs_waitq_init (&the_lnet.ln_waitq);
107 init_mutex(&the_lnet.ln_lnd_mutex);
108 init_mutex(&the_lnet.ln_api_mutex);
112 lnet_fini_locks(void)
119 lnet_get_routes(void)
121 char *str = getenv("LNET_ROUTES");
123 return (str == NULL) ? "" : str;
127 lnet_get_networks (void)
129 static char default_networks[256];
130 char *networks = getenv ("LNET_NETWORKS");
131 char *ip2nets = getenv ("LNET_IP2NETS");
137 struct list_head *tmp;
140 if (networks != NULL && ip2nets != NULL) {
141 LCONSOLE_ERROR_MSG(0x103, "Please set EITHER 'LNET_NETWORKS' or"
142 " 'LNET_IP2NETS' but not both at once\n");
146 if (ip2nets != NULL) {
147 rc = lnet_parse_ip2nets(&networks, ip2nets);
148 return (rc == 0) ? networks : NULL;
154 if (networks != NULL)
157 /* In userland, the default 'networks=' is the list of known net types */
159 len = sizeof(default_networks);
160 str = default_networks;
164 list_for_each (tmp, &the_lnet.ln_lnds) {
165 lnd_t *lnd = list_entry(tmp, lnd_t, lnd_list);
167 nob = snprintf(str, len, "%s%s", sep,
168 libcfs_lnd2str(lnd->lnd_type));
171 /* overflowed the string; leave it where it was */
180 return default_networks;
184 lnet_get_portals_compatibility(void)
189 # ifndef HAVE_LIBPTHREAD
191 void lnet_init_locks(void)
193 the_lnet.ln_lock = 0;
194 the_lnet.ln_lnd_mutex = 0;
195 the_lnet.ln_api_mutex = 0;
198 void lnet_fini_locks(void)
200 LASSERT (the_lnet.ln_api_mutex == 0);
201 LASSERT (the_lnet.ln_lnd_mutex == 0);
202 LASSERT (the_lnet.ln_lock == 0);
207 void lnet_init_locks(void)
209 pthread_cond_init(&the_lnet.ln_cond, NULL);
210 pthread_mutex_init(&the_lnet.ln_lock, NULL);
211 pthread_mutex_init(&the_lnet.ln_lnd_mutex, NULL);
212 pthread_mutex_init(&the_lnet.ln_api_mutex, NULL);
215 void lnet_fini_locks(void)
217 pthread_mutex_destroy(&the_lnet.ln_api_mutex);
218 pthread_mutex_destroy(&the_lnet.ln_lnd_mutex);
219 pthread_mutex_destroy(&the_lnet.ln_lock);
220 pthread_cond_destroy(&the_lnet.ln_cond);
226 void lnet_assert_wire_constants (void)
228 /* Wire protocol assertions generated by 'wirecheck'
229 * running on Linux robert.bartonsoftware.com 2.6.8-1.521
230 * #1 Mon Aug 16 09:01:18 EDT 2004 i686 athlon i386 GNU/Linux
231 * with gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7) */
234 CLASSERT (LNET_PROTO_TCP_MAGIC == 0xeebc0ded);
235 CLASSERT (LNET_PROTO_TCP_VERSION_MAJOR == 1);
236 CLASSERT (LNET_PROTO_TCP_VERSION_MINOR == 0);
237 CLASSERT (LNET_MSG_ACK == 0);
238 CLASSERT (LNET_MSG_PUT == 1);
239 CLASSERT (LNET_MSG_GET == 2);
240 CLASSERT (LNET_MSG_REPLY == 3);
241 CLASSERT (LNET_MSG_HELLO == 4);
243 /* Checks for struct ptl_handle_wire_t */
244 CLASSERT ((int)sizeof(lnet_handle_wire_t) == 16);
245 CLASSERT ((int)offsetof(lnet_handle_wire_t, wh_interface_cookie) == 0);
246 CLASSERT ((int)sizeof(((lnet_handle_wire_t *)0)->wh_interface_cookie) == 8);
247 CLASSERT ((int)offsetof(lnet_handle_wire_t, wh_object_cookie) == 8);
248 CLASSERT ((int)sizeof(((lnet_handle_wire_t *)0)->wh_object_cookie) == 8);
250 /* Checks for struct lnet_magicversion_t */
251 CLASSERT ((int)sizeof(lnet_magicversion_t) == 8);
252 CLASSERT ((int)offsetof(lnet_magicversion_t, magic) == 0);
253 CLASSERT ((int)sizeof(((lnet_magicversion_t *)0)->magic) == 4);
254 CLASSERT ((int)offsetof(lnet_magicversion_t, version_major) == 4);
255 CLASSERT ((int)sizeof(((lnet_magicversion_t *)0)->version_major) == 2);
256 CLASSERT ((int)offsetof(lnet_magicversion_t, version_minor) == 6);
257 CLASSERT ((int)sizeof(((lnet_magicversion_t *)0)->version_minor) == 2);
259 /* Checks for struct lnet_hdr_t */
260 CLASSERT ((int)sizeof(lnet_hdr_t) == 72);
261 CLASSERT ((int)offsetof(lnet_hdr_t, dest_nid) == 0);
262 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->dest_nid) == 8);
263 CLASSERT ((int)offsetof(lnet_hdr_t, src_nid) == 8);
264 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->src_nid) == 8);
265 CLASSERT ((int)offsetof(lnet_hdr_t, dest_pid) == 16);
266 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->dest_pid) == 4);
267 CLASSERT ((int)offsetof(lnet_hdr_t, src_pid) == 20);
268 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->src_pid) == 4);
269 CLASSERT ((int)offsetof(lnet_hdr_t, type) == 24);
270 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->type) == 4);
271 CLASSERT ((int)offsetof(lnet_hdr_t, payload_length) == 28);
272 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->payload_length) == 4);
273 CLASSERT ((int)offsetof(lnet_hdr_t, msg) == 32);
274 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg) == 40);
277 CLASSERT ((int)offsetof(lnet_hdr_t, msg.ack.dst_wmd) == 32);
278 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.ack.dst_wmd) == 16);
279 CLASSERT ((int)offsetof(lnet_hdr_t, msg.ack.match_bits) == 48);
280 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.ack.match_bits) == 8);
281 CLASSERT ((int)offsetof(lnet_hdr_t, msg.ack.mlength) == 56);
282 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.ack.mlength) == 4);
285 CLASSERT ((int)offsetof(lnet_hdr_t, msg.put.ack_wmd) == 32);
286 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.put.ack_wmd) == 16);
287 CLASSERT ((int)offsetof(lnet_hdr_t, msg.put.match_bits) == 48);
288 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.put.match_bits) == 8);
289 CLASSERT ((int)offsetof(lnet_hdr_t, msg.put.hdr_data) == 56);
290 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.put.hdr_data) == 8);
291 CLASSERT ((int)offsetof(lnet_hdr_t, msg.put.ptl_index) == 64);
292 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.put.ptl_index) == 4);
293 CLASSERT ((int)offsetof(lnet_hdr_t, msg.put.offset) == 68);
294 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.put.offset) == 4);
297 CLASSERT ((int)offsetof(lnet_hdr_t, msg.get.return_wmd) == 32);
298 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.get.return_wmd) == 16);
299 CLASSERT ((int)offsetof(lnet_hdr_t, msg.get.match_bits) == 48);
300 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.get.match_bits) == 8);
301 CLASSERT ((int)offsetof(lnet_hdr_t, msg.get.ptl_index) == 56);
302 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.get.ptl_index) == 4);
303 CLASSERT ((int)offsetof(lnet_hdr_t, msg.get.src_offset) == 60);
304 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.get.src_offset) == 4);
305 CLASSERT ((int)offsetof(lnet_hdr_t, msg.get.sink_length) == 64);
306 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.get.sink_length) == 4);
309 CLASSERT ((int)offsetof(lnet_hdr_t, msg.reply.dst_wmd) == 32);
310 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.reply.dst_wmd) == 16);
313 CLASSERT ((int)offsetof(lnet_hdr_t, msg.hello.incarnation) == 32);
314 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.hello.incarnation) == 8);
315 CLASSERT ((int)offsetof(lnet_hdr_t, msg.hello.type) == 40);
316 CLASSERT ((int)sizeof(((lnet_hdr_t *)0)->msg.hello.type) == 4);
320 lnet_find_lnd_by_type (int type)
323 struct list_head *tmp;
325 /* holding lnd mutex */
326 list_for_each (tmp, &the_lnet.ln_lnds) {
327 lnd = list_entry(tmp, lnd_t, lnd_list);
329 if (lnd->lnd_type == type)
337 lnet_register_lnd (lnd_t *lnd)
339 LNET_MUTEX_DOWN(&the_lnet.ln_lnd_mutex);
341 LASSERT (the_lnet.ln_init);
342 LASSERT (libcfs_isknown_lnd(lnd->lnd_type));
343 LASSERT (lnet_find_lnd_by_type(lnd->lnd_type) == NULL);
345 list_add_tail (&lnd->lnd_list, &the_lnet.ln_lnds);
346 lnd->lnd_refcount = 0;
348 CDEBUG(D_NET, "%s LND registered\n", libcfs_lnd2str(lnd->lnd_type));
350 LNET_MUTEX_UP(&the_lnet.ln_lnd_mutex);
354 lnet_unregister_lnd (lnd_t *lnd)
356 LNET_MUTEX_DOWN(&the_lnet.ln_lnd_mutex);
358 LASSERT (the_lnet.ln_init);
359 LASSERT (lnet_find_lnd_by_type(lnd->lnd_type) == lnd);
360 LASSERT (lnd->lnd_refcount == 0);
362 list_del (&lnd->lnd_list);
363 CDEBUG(D_NET, "%s LND unregistered\n", libcfs_lnd2str(lnd->lnd_type));
365 LNET_MUTEX_UP(&the_lnet.ln_lnd_mutex);
368 #ifndef LNET_USE_LIB_FREELIST
371 lnet_descriptor_setup (void)
377 lnet_descriptor_cleanup (void)
384 lnet_freelist_init (lnet_freelist_t *fl, int n, int size)
390 size += offsetof (lnet_freeobj_t, fo_contents);
392 LIBCFS_ALLOC(space, n * size);
396 CFS_INIT_LIST_HEAD (&fl->fl_list);
399 fl->fl_objsize = size;
403 memset (space, 0, size);
404 list_add ((struct list_head *)space, &fl->fl_list);
412 lnet_freelist_fini (lnet_freelist_t *fl)
414 struct list_head *el;
417 if (fl->fl_nobjs == 0)
421 for (el = fl->fl_list.next; el != &fl->fl_list; el = el->next)
424 LASSERT (count == fl->fl_nobjs);
426 LIBCFS_FREE(fl->fl_objs, fl->fl_nobjs * fl->fl_objsize);
427 memset (fl, 0, sizeof (fl));
431 lnet_descriptor_setup (void)
433 /* NB on failure caller must still call lnet_descriptor_cleanup */
437 memset (&the_lnet.ln_free_mes, 0, sizeof (the_lnet.ln_free_mes));
438 memset (&the_lnet.ln_free_msgs, 0, sizeof (the_lnet.ln_free_msgs));
439 memset (&the_lnet.ln_free_mds, 0, sizeof (the_lnet.ln_free_mds));
440 memset (&the_lnet.ln_free_eqs, 0, sizeof (the_lnet.ln_free_eqs));
442 rc = lnet_freelist_init(&the_lnet.ln_free_mes,
443 MAX_MES, sizeof (lnet_me_t));
447 rc = lnet_freelist_init(&the_lnet.ln_free_msgs,
448 MAX_MSGS, sizeof (lnet_msg_t));
452 rc = lnet_freelist_init(&the_lnet.ln_free_mds,
453 MAX_MDS, sizeof (lnet_libmd_t));
457 rc = lnet_freelist_init(&the_lnet.ln_free_eqs,
458 MAX_EQS, sizeof (lnet_eq_t));
463 lnet_descriptor_cleanup (void)
465 lnet_freelist_fini (&the_lnet.ln_free_mes);
466 lnet_freelist_fini (&the_lnet.ln_free_msgs);
467 lnet_freelist_fini (&the_lnet.ln_free_mds);
468 lnet_freelist_fini (&the_lnet.ln_free_eqs);
474 lnet_create_interface_cookie (void)
476 /* NB the interface cookie in wire handles guards against delayed
477 * replies and ACKs appearing valid after reboot. Initialisation time,
478 * even if it's only implemented to millisecond resolution is probably
479 * easily good enough. */
483 int rc = gettimeofday (&tv, NULL);
486 do_gettimeofday(&tv);
490 cookie += tv.tv_usec;
495 lnet_setup_handle_hash (void)
499 /* Arbitrary choice of hash table size */
501 the_lnet.ln_lh_hash_size = CFS_PAGE_SIZE / sizeof (struct list_head);
503 the_lnet.ln_lh_hash_size = (MAX_MES + MAX_MDS + MAX_EQS)/4;
505 LIBCFS_ALLOC(the_lnet.ln_lh_hash_table,
506 the_lnet.ln_lh_hash_size * sizeof (struct list_head));
507 if (the_lnet.ln_lh_hash_table == NULL)
510 for (i = 0; i < the_lnet.ln_lh_hash_size; i++)
511 CFS_INIT_LIST_HEAD (&the_lnet.ln_lh_hash_table[i]);
513 the_lnet.ln_next_object_cookie = LNET_COOKIE_TYPES;
519 lnet_cleanup_handle_hash (void)
521 if (the_lnet.ln_lh_hash_table == NULL)
524 LIBCFS_FREE(the_lnet.ln_lh_hash_table,
525 the_lnet.ln_lh_hash_size * sizeof (struct list_head));
529 lnet_lookup_cookie (__u64 cookie, int type)
531 /* ALWAYS called with LNET_LOCK held */
532 struct list_head *list;
533 struct list_head *el;
536 if ((cookie & (LNET_COOKIE_TYPES - 1)) != type)
539 hash = ((unsigned int)cookie) % the_lnet.ln_lh_hash_size;
540 list = &the_lnet.ln_lh_hash_table[hash];
542 list_for_each (el, list) {
543 lnet_libhandle_t *lh = list_entry (el, lnet_libhandle_t,
546 if (lh->lh_cookie == cookie)
554 lnet_initialise_handle (lnet_libhandle_t *lh, int type)
556 /* ALWAYS called with LNET_LOCK held */
559 LASSERT (type >= 0 && type < LNET_COOKIE_TYPES);
560 lh->lh_cookie = the_lnet.ln_next_object_cookie | type;
561 the_lnet.ln_next_object_cookie += LNET_COOKIE_TYPES;
563 hash = ((unsigned int)lh->lh_cookie) % the_lnet.ln_lh_hash_size;
564 list_add (&lh->lh_hash_chain, &the_lnet.ln_lh_hash_table[hash]);
568 lnet_invalidate_handle (lnet_libhandle_t *lh)
570 /* ALWAYS called with LNET_LOCK held */
571 list_del (&lh->lh_hash_chain);
575 lnet_init_finalizers(void)
580 the_lnet.ln_nfinalizers = num_online_cpus();
582 LIBCFS_ALLOC(the_lnet.ln_finalizers,
583 the_lnet.ln_nfinalizers *
584 sizeof(*the_lnet.ln_finalizers));
585 if (the_lnet.ln_finalizers == NULL) {
586 CERROR("Can't allocate ln_finalizers\n");
590 for (i = 0; i < the_lnet.ln_nfinalizers; i++)
591 the_lnet.ln_finalizers[i] = NULL;
593 the_lnet.ln_finalizing = 0;
596 CFS_INIT_LIST_HEAD(&the_lnet.ln_finalizeq);
601 lnet_fini_finalizers(void)
606 for (i = 0; i < the_lnet.ln_nfinalizers; i++)
607 LASSERT (the_lnet.ln_finalizers[i] == NULL);
609 LIBCFS_FREE(the_lnet.ln_finalizers,
610 the_lnet.ln_nfinalizers *
611 sizeof(*the_lnet.ln_finalizers));
613 LASSERT (!the_lnet.ln_finalizing);
615 LASSERT (list_empty(&the_lnet.ln_finalizeq));
619 /* Temporary workaround to allow uOSS and test programs force server
620 * mode in userspace. See comments near ln_server_mode_flag in
621 * lnet/lib-types.h */
625 the_lnet.ln_server_mode_flag = 1;
630 lnet_prepare(lnet_pid_t requested_pid)
632 /* Prepare to bring up the network */
636 LASSERT (the_lnet.ln_refcount == 0);
638 the_lnet.ln_routing = 0;
641 LASSERT ((requested_pid & LNET_PID_USERFLAG) == 0);
642 the_lnet.ln_pid = requested_pid;
644 if (the_lnet.ln_server_mode_flag) {/* server case (uOSS) */
645 LASSERT ((requested_pid & LNET_PID_USERFLAG) == 0);
647 if (cfs_curproc_uid())/* Only root can run user-space server */
649 the_lnet.ln_pid = requested_pid;
651 } else {/* client case (liblustre) */
653 /* My PID must be unique on this node and flag I'm userspace */
654 the_lnet.ln_pid = getpid() | LNET_PID_USERFLAG;
658 rc = lnet_descriptor_setup();
662 memset(&the_lnet.ln_counters, 0,
663 sizeof(the_lnet.ln_counters));
665 CFS_INIT_LIST_HEAD (&the_lnet.ln_active_msgs);
666 CFS_INIT_LIST_HEAD (&the_lnet.ln_active_mds);
667 CFS_INIT_LIST_HEAD (&the_lnet.ln_active_eqs);
668 CFS_INIT_LIST_HEAD (&the_lnet.ln_test_peers);
669 CFS_INIT_LIST_HEAD (&the_lnet.ln_nis);
670 CFS_INIT_LIST_HEAD (&the_lnet.ln_zombie_nis);
671 CFS_INIT_LIST_HEAD (&the_lnet.ln_remote_nets);
672 CFS_INIT_LIST_HEAD (&the_lnet.ln_routers);
674 the_lnet.ln_interface_cookie = lnet_create_interface_cookie();
676 lnet_init_rtrpools();
678 rc = lnet_setup_handle_hash ();
682 rc = lnet_create_peer_table();
686 rc = lnet_init_finalizers();
690 the_lnet.ln_nportals = MAX_PORTALS;
691 LIBCFS_ALLOC(the_lnet.ln_portals,
692 the_lnet.ln_nportals *
693 sizeof(*the_lnet.ln_portals));
694 if (the_lnet.ln_portals == NULL) {
699 for (i = 0; i < the_lnet.ln_nportals; i++) {
700 CFS_INIT_LIST_HEAD(&(the_lnet.ln_portals[i].ptl_ml));
701 CFS_INIT_LIST_HEAD(&(the_lnet.ln_portals[i].ptl_msgq));
702 the_lnet.ln_portals[i].ptl_options = 0;
708 lnet_fini_finalizers();
710 lnet_destroy_peer_table();
712 lnet_cleanup_handle_hash();
714 lnet_descriptor_cleanup();
719 lnet_unprepare (void)
723 /* NB no LNET_LOCK since this is the last reference. All LND instances
724 * have shut down already, so it is safe to unlink and free all
725 * descriptors, even those that appear committed to a network op (eg MD
726 * with non-zero pending count) */
728 lnet_fail_nid(LNET_NID_ANY, 0);
730 LASSERT (list_empty(&the_lnet.ln_test_peers));
731 LASSERT (the_lnet.ln_refcount == 0);
732 LASSERT (list_empty(&the_lnet.ln_nis));
733 LASSERT (list_empty(&the_lnet.ln_zombie_nis));
734 LASSERT (the_lnet.ln_nzombie_nis == 0);
736 for (idx = 0; idx < the_lnet.ln_nportals; idx++) {
737 LASSERT (list_empty(&the_lnet.ln_portals[idx].ptl_msgq));
739 while (!list_empty (&the_lnet.ln_portals[idx].ptl_ml)) {
740 lnet_me_t *me = list_entry (the_lnet.ln_portals[idx].ptl_ml.next,
743 CERROR ("Active me %p on exit\n", me);
744 list_del (&me->me_list);
749 while (!list_empty (&the_lnet.ln_active_mds)) {
750 lnet_libmd_t *md = list_entry (the_lnet.ln_active_mds.next,
751 lnet_libmd_t, md_list);
753 CERROR ("Active md %p on exit\n", md);
754 list_del (&md->md_list);
758 while (!list_empty (&the_lnet.ln_active_eqs)) {
759 lnet_eq_t *eq = list_entry (the_lnet.ln_active_eqs.next,
762 CERROR ("Active eq %p on exit\n", eq);
763 list_del (&eq->eq_list);
767 while (!list_empty (&the_lnet.ln_active_msgs)) {
768 lnet_msg_t *msg = list_entry (the_lnet.ln_active_msgs.next,
769 lnet_msg_t, msg_activelist);
771 CERROR ("Active msg %p on exit\n", msg);
772 LASSERT (msg->msg_onactivelist);
773 msg->msg_onactivelist = 0;
774 list_del (&msg->msg_activelist);
778 LIBCFS_FREE(the_lnet.ln_portals,
779 the_lnet.ln_nportals * sizeof(*the_lnet.ln_portals));
781 lnet_free_rtrpools();
782 lnet_fini_finalizers();
783 lnet_destroy_peer_table();
784 lnet_cleanup_handle_hash();
785 lnet_descriptor_cleanup();
791 lnet_net2ni_locked (__u32 net)
793 struct list_head *tmp;
796 list_for_each (tmp, &the_lnet.ln_nis) {
797 ni = list_entry(tmp, lnet_ni_t, ni_list);
799 if (lnet_ptlcompat_matchnet(LNET_NIDNET(ni->ni_nid), net)) {
800 lnet_ni_addref_locked(ni);
809 lnet_islocalnet (__u32 net)
814 ni = lnet_net2ni_locked(net);
816 lnet_ni_decref_locked(ni);
823 lnet_nid2ni_locked (lnet_nid_t nid)
825 struct list_head *tmp;
828 list_for_each (tmp, &the_lnet.ln_nis) {
829 ni = list_entry(tmp, lnet_ni_t, ni_list);
831 if (lnet_ptlcompat_matchnid(ni->ni_nid, nid)) {
832 lnet_ni_addref_locked(ni);
841 lnet_islocalnid (lnet_nid_t nid)
846 ni = lnet_nid2ni_locked(nid);
848 lnet_ni_decref_locked(ni);
855 lnet_count_acceptor_nis (lnet_ni_t **first_ni)
857 /* Return the # of NIs that need the acceptor. Return the first one in
858 * *first_ni so the acceptor can pass it connections "blind" to retain
859 * binary compatibility. */
861 struct list_head *tmp;
865 list_for_each (tmp, &the_lnet.ln_nis) {
866 ni = list_entry(tmp, lnet_ni_t, ni_list);
868 if (ni->ni_lnd->lnd_accept != NULL) {
869 /* This LND uses the acceptor */
870 if (count == 0 && first_ni != NULL) {
871 lnet_ni_addref_locked(ni);
883 lnet_shutdown_lndnis (void)
889 /* NB called holding the global mutex */
891 /* All quiet on the API front */
892 LASSERT (!the_lnet.ln_shutdown);
893 LASSERT (the_lnet.ln_refcount == 0);
894 LASSERT (list_empty(&the_lnet.ln_zombie_nis));
895 LASSERT (the_lnet.ln_nzombie_nis == 0);
896 LASSERT (list_empty(&the_lnet.ln_remote_nets));
899 the_lnet.ln_shutdown = 1; /* flag shutdown */
901 /* Unlink NIs from the global table */
902 while (!list_empty(&the_lnet.ln_nis)) {
903 ni = list_entry(the_lnet.ln_nis.next,
905 list_del (&ni->ni_list);
907 the_lnet.ln_nzombie_nis++;
908 lnet_ni_decref_locked(ni); /* drop apini's ref */
911 /* Drop the cached eqwait NI. */
912 if (the_lnet.ln_eqwaitni != NULL) {
913 lnet_ni_decref_locked(the_lnet.ln_eqwaitni);
914 the_lnet.ln_eqwaitni = NULL;
917 /* Drop the cached loopback NI. */
918 if (the_lnet.ln_loni != NULL) {
919 lnet_ni_decref_locked(the_lnet.ln_loni);
920 the_lnet.ln_loni = NULL;
925 /* Clear lazy portals and drop delayed messages which hold refs
926 * on their lnet_msg_t::msg_rxpeer */
927 for (i = 0; i < the_lnet.ln_nportals; i++)
928 LNetClearLazyPortal(i);
930 /* Clear the peer table and wait for all peers to go (they hold refs on
932 lnet_clear_peer_table();
935 /* Now wait for the NI's I just nuked to show up on apini_zombie_nis
936 * and shut them down in guaranteed thread context */
938 while (the_lnet.ln_nzombie_nis != 0) {
940 while (list_empty(&the_lnet.ln_zombie_nis)) {
944 CDEBUG(D_WARNING,"Waiting for %d zombie NIs\n",
945 the_lnet.ln_nzombie_nis);
946 cfs_pause(cfs_time_seconds(1));
950 ni = list_entry(the_lnet.ln_zombie_nis.next,
952 list_del(&ni->ni_list);
953 ni->ni_lnd->lnd_refcount--;
957 islo = ni->ni_lnd->lnd_type == LOLND;
959 LASSERT (!in_interrupt ());
960 (ni->ni_lnd->lnd_shutdown)(ni);
962 /* can't deref lnd anymore now; it might have unregistered
966 CDEBUG(D_LNI, "Removed LNI %s\n",
967 libcfs_nid2str(ni->ni_nid));
969 LIBCFS_FREE(ni, sizeof(*ni));
972 the_lnet.ln_nzombie_nis--;
975 the_lnet.ln_shutdown = 0;
978 if (the_lnet.ln_network_tokens != NULL) {
979 LIBCFS_FREE(the_lnet.ln_network_tokens,
980 the_lnet.ln_network_tokens_nob);
981 the_lnet.ln_network_tokens = NULL;
986 lnet_startup_lndnis (void)
990 struct list_head nilist;
994 char *nets = lnet_get_networks();
996 INIT_LIST_HEAD(&nilist);
1001 rc = lnet_parse_networks(&nilist, nets);
1005 while (!list_empty(&nilist)) {
1006 ni = list_entry(nilist.next, lnet_ni_t, ni_list);
1007 lnd_type = LNET_NETTYP(LNET_NIDNET(ni->ni_nid));
1009 LASSERT (libcfs_isknown_lnd(lnd_type));
1011 LNET_MUTEX_DOWN(&the_lnet.ln_lnd_mutex);
1012 lnd = lnet_find_lnd_by_type(lnd_type);
1016 LNET_MUTEX_UP(&the_lnet.ln_lnd_mutex);
1017 rc = request_module(libcfs_lnd2modname(lnd_type));
1018 LNET_MUTEX_DOWN(&the_lnet.ln_lnd_mutex);
1020 lnd = lnet_find_lnd_by_type(lnd_type);
1022 LNET_MUTEX_UP(&the_lnet.ln_lnd_mutex);
1023 CERROR("Can't load LND %s, module %s, rc=%d\n",
1024 libcfs_lnd2str(lnd_type),
1025 libcfs_lnd2modname(lnd_type), rc);
1027 LCONSOLE_ERROR_MSG(0x104, "Your kernel must be "
1028 "compiled with CONFIG_KMOD set for "
1029 "automatic module loading.");
1036 LNET_MUTEX_UP(&the_lnet.ln_lnd_mutex);
1037 CERROR("LND %s not supported\n",
1038 libcfs_lnd2str(lnd_type));
1043 ni->ni_refcount = 1;
1046 lnd->lnd_refcount++;
1051 rc = (lnd->lnd_startup)(ni);
1053 LNET_MUTEX_UP(&the_lnet.ln_lnd_mutex);
1056 LCONSOLE_ERROR_MSG(0x105, "Error %d starting up LNI %s"
1058 rc, libcfs_lnd2str(lnd->lnd_type));
1060 lnd->lnd_refcount--;
1065 list_del(&ni->ni_list);
1068 list_add_tail(&ni->ni_list, &the_lnet.ln_nis);
1071 if (lnd->lnd_type == LOLND) {
1073 LASSERT (the_lnet.ln_loni == NULL);
1074 the_lnet.ln_loni = ni;
1079 if (lnd->lnd_wait != NULL) {
1080 if (the_lnet.ln_eqwaitni == NULL) {
1082 the_lnet.ln_eqwaitni = ni;
1085 # ifndef HAVE_LIBPTHREAD
1086 LCONSOLE_ERROR_MSG(0x106, "LND %s not supported in a "
1087 "single-threaded runtime\n",
1088 libcfs_lnd2str(lnd_type));
1093 if (ni->ni_peertxcredits == 0 ||
1094 ni->ni_maxtxcredits == 0) {
1095 LCONSOLE_ERROR_MSG(0x107, "LNI %s has no %scredits\n",
1096 libcfs_lnd2str(lnd->lnd_type),
1097 ni->ni_peertxcredits == 0 ?
1102 ni->ni_txcredits = ni->ni_mintxcredits = ni->ni_maxtxcredits;
1104 CDEBUG(D_LNI, "Added LNI %s [%d/%d]\n",
1105 libcfs_nid2str(ni->ni_nid),
1106 ni->ni_peertxcredits, ni->ni_txcredits);
1108 /* Handle nidstrings for network 0 just like this one */
1109 if (the_lnet.ln_ptlcompat > 0) {
1111 LCONSOLE_ERROR_MSG(0x108, "Can't run > 1 "
1112 "network when portals_compatibility is "
1116 libcfs_setnet0alias(lnd->lnd_type);
1122 if (the_lnet.ln_eqwaitni != NULL && nicount > 1) {
1123 lnd_type = the_lnet.ln_eqwaitni->ni_lnd->lnd_type;
1124 LCONSOLE_ERROR_MSG(0x109, "LND %s can only run single-network"
1126 libcfs_lnd2str(lnd_type));
1133 lnet_shutdown_lndnis();
1135 while (!list_empty(&nilist)) {
1136 ni = list_entry(nilist.next, lnet_ni_t, ni_list);
1137 list_del(&ni->ni_list);
1138 LIBCFS_FREE(ni, sizeof(*ni));
1149 lnet_assert_wire_constants ();
1150 LASSERT (!the_lnet.ln_init);
1152 memset(&the_lnet, 0, sizeof(the_lnet));
1154 rc = lnet_get_portals_compatibility();
1159 CFS_INIT_LIST_HEAD(&the_lnet.ln_lnds);
1160 the_lnet.ln_ptlcompat = rc;
1161 the_lnet.ln_refcount = 0;
1162 the_lnet.ln_init = 1;
1165 /* All LNDs apart from the LOLND are in separate modules. They
1166 * register themselves when their module loads, and unregister
1167 * themselves when their module is unloaded. */
1170 * NB the order here determines default 'networks=' order */
1172 LNET_REGISTER_ULND(the_ptllnd);
1174 # ifdef HAVE_LIBPTHREAD
1175 LNET_REGISTER_ULND(the_tcplnd);
1178 lnet_register_lnd(&the_lolnd);
1185 LASSERT (the_lnet.ln_init);
1186 LASSERT (the_lnet.ln_refcount == 0);
1188 while (!list_empty(&the_lnet.ln_lnds))
1189 lnet_unregister_lnd(list_entry(the_lnet.ln_lnds.next,
1193 the_lnet.ln_init = 0;
1197 LNetNIInit(lnet_pid_t requested_pid)
1199 int im_a_router = 0;
1202 LNET_MUTEX_DOWN(&the_lnet.ln_api_mutex);
1204 LASSERT (the_lnet.ln_init);
1205 CDEBUG(D_OTHER, "refs %d\n", the_lnet.ln_refcount);
1207 if (the_lnet.ln_refcount > 0) {
1208 rc = the_lnet.ln_refcount++;
1212 if (requested_pid == LNET_PID_ANY) {
1213 /* Don't instantiate LNET just for me */
1218 rc = lnet_prepare(requested_pid);
1222 rc = lnet_startup_lndnis();
1226 rc = lnet_parse_routes(lnet_get_routes(), &im_a_router);
1230 rc = lnet_check_routes();
1234 rc = lnet_alloc_rtrpools(im_a_router);
1238 rc = lnet_acceptor_start();
1242 the_lnet.ln_refcount = 1;
1243 /* Now I may use my own API functions... */
1245 rc = lnet_router_checker_start();
1249 rc = lnet_ping_target_init();
1257 lnet_router_checker_stop();
1259 the_lnet.ln_refcount = 0;
1260 lnet_acceptor_stop();
1262 lnet_destroy_routes();
1263 lnet_shutdown_lndnis();
1269 LNET_MUTEX_UP(&the_lnet.ln_api_mutex);
1276 LNET_MUTEX_DOWN(&the_lnet.ln_api_mutex);
1278 LASSERT (the_lnet.ln_init);
1279 LASSERT (the_lnet.ln_refcount > 0);
1281 if (the_lnet.ln_refcount != 1) {
1282 the_lnet.ln_refcount--;
1284 LASSERT (!the_lnet.ln_niinit_self);
1287 lnet_ping_target_fini();
1288 lnet_router_checker_stop();
1290 /* Teardown fns that use my own API functions BEFORE here */
1291 the_lnet.ln_refcount = 0;
1293 lnet_acceptor_stop();
1294 lnet_destroy_routes();
1295 lnet_shutdown_lndnis();
1299 LNET_MUTEX_UP(&the_lnet.ln_api_mutex);
1304 LNetCtl(unsigned int cmd, void *arg)
1306 struct libcfs_ioctl_data *data = arg;
1307 lnet_process_id_t id;
1311 LASSERT (the_lnet.ln_init);
1312 LASSERT (the_lnet.ln_refcount > 0);
1315 case IOC_LIBCFS_GET_NI:
1316 rc = LNetGetId(data->ioc_count, &id);
1317 data->ioc_nid = id.nid;
1320 case IOC_LIBCFS_FAIL_NID:
1321 return lnet_fail_nid(data->ioc_nid, data->ioc_count);
1323 case IOC_LIBCFS_ADD_ROUTE:
1324 rc = lnet_add_route(data->ioc_net, data->ioc_count,
1326 return (rc != 0) ? rc : lnet_check_routes();
1328 case IOC_LIBCFS_DEL_ROUTE:
1329 return lnet_del_route(data->ioc_net, data->ioc_nid);
1331 case IOC_LIBCFS_GET_ROUTE:
1332 return lnet_get_route(data->ioc_count,
1333 &data->ioc_net, &data->ioc_count,
1334 &data->ioc_nid, &data->ioc_flags);
1335 case IOC_LIBCFS_NOTIFY_ROUTER:
1336 return lnet_notify(NULL, data->ioc_nid, data->ioc_flags,
1337 (time_t)data->ioc_u64[0]);
1339 case IOC_LIBCFS_PORTALS_COMPATIBILITY:
1340 return the_lnet.ln_ptlcompat;
1342 case IOC_LIBCFS_LNET_DIST:
1343 rc = LNetDist(data->ioc_nid, &data->ioc_nid, &data->ioc_u32[1]);
1344 if (rc < 0 && rc != -EHOSTUNREACH)
1347 data->ioc_u32[0] = rc;
1350 case IOC_LIBCFS_TESTPROTOCOMPAT:
1352 the_lnet.ln_testprotocompat = data->ioc_flags;
1356 case IOC_LIBCFS_PING:
1357 rc = lnet_ping((lnet_process_id_t) {.nid = data->ioc_nid,
1358 .pid = data->ioc_u32[0]},
1359 data->ioc_u32[1], /* timeout */
1360 (lnet_process_id_t *)data->ioc_pbuf1,
1361 data->ioc_plen1/sizeof(lnet_process_id_t));
1364 data->ioc_count = rc;
1367 case IOC_LIBCFS_DEBUG_PEER: {
1368 /* CAVEAT EMPTOR: this one designed for calling directly; not
1370 lnet_process_id_t *id = arg;
1372 lnet_debug_peer(id->nid);
1374 ni = lnet_net2ni(LNET_NIDNET(id->nid));
1376 CDEBUG(D_WARNING, "No NI for %s\n", libcfs_id2str(*id));
1378 if (ni->ni_lnd->lnd_ctl == NULL) {
1379 CDEBUG(D_WARNING, "No ctl for %s\n",
1380 libcfs_id2str(*id));
1382 (void)ni->ni_lnd->lnd_ctl(ni, cmd, arg);
1391 ni = lnet_net2ni(data->ioc_net);
1395 if (ni->ni_lnd->lnd_ctl == NULL)
1398 rc = ni->ni_lnd->lnd_ctl(ni, cmd, arg);
1407 LNetGetId(unsigned int index, lnet_process_id_t *id)
1410 struct list_head *tmp;
1413 LASSERT (the_lnet.ln_init);
1414 LASSERT (the_lnet.ln_refcount > 0);
1418 list_for_each(tmp, &the_lnet.ln_nis) {
1422 ni = list_entry(tmp, lnet_ni_t, ni_list);
1424 id->nid = ni->ni_nid;
1425 id->pid = the_lnet.ln_pid;
1436 LNetSnprintHandle(char *str, int len, lnet_handle_any_t h)
1438 snprintf(str, len, LPX64, h.cookie);
1443 lnet_ping_target_init(void)
1445 lnet_handle_me_t meh;
1446 lnet_process_id_t id;
1453 for (n = 0; ; n++) {
1454 rc = LNetGetId(n, &id);
1461 infosz = offsetof(lnet_ping_info_t, pi_nid[n]);
1462 LIBCFS_ALLOC(the_lnet.ln_ping_info, infosz);
1463 if (the_lnet.ln_ping_info == NULL) {
1464 CERROR("Can't allocate ping info[%d]\n", n);
1468 the_lnet.ln_ping_info->pi_magic = LNET_PROTO_PING_MAGIC;
1469 the_lnet.ln_ping_info->pi_version = LNET_PROTO_PING_VERSION;
1470 the_lnet.ln_ping_info->pi_pid = the_lnet.ln_pid;
1471 the_lnet.ln_ping_info->pi_nnids = n;
1473 for (i = 0; i < n; i++) {
1474 rc = LNetGetId(i, &id);
1476 the_lnet.ln_ping_info->pi_nid[i] = id.nid;
1479 /* We can have a tiny EQ since we only need to see the unlink event on
1480 * teardown, which by definition is the last one! */
1481 rc = LNetEQAlloc(2, LNET_EQ_HANDLER_NONE, &the_lnet.ln_ping_target_eq);
1483 CERROR("Can't allocate ping EQ: %d\n", rc);
1487 rc = LNetMEAttach(LNET_RESERVED_PORTAL,
1488 (lnet_process_id_t){.nid = LNET_NID_ANY,
1489 .pid = LNET_PID_ANY},
1490 LNET_PROTO_PING_MATCHBITS, 0LL,
1491 LNET_UNLINK, LNET_INS_AFTER,
1494 CERROR("Can't create ping ME: %d\n", rc);
1498 rc = LNetMDAttach(meh,
1499 (lnet_md_t){.start = the_lnet.ln_ping_info,
1501 .threshold = LNET_MD_THRESH_INF,
1502 .options = (LNET_MD_OP_GET |
1504 LNET_MD_MANAGE_REMOTE),
1505 .eq_handle = the_lnet.ln_ping_target_eq},
1507 &the_lnet.ln_ping_target_md);
1509 CERROR("Can't attach ping MD: %d\n", rc);
1516 rc2 = LNetMEUnlink(meh);
1519 rc2 = LNetEQFree(the_lnet.ln_ping_target_eq);
1522 LIBCFS_FREE(the_lnet.ln_ping_info, infosz);
1528 lnet_ping_target_fini(void)
1533 int timeout_ms = 1000;
1534 cfs_sigset_t blocked = cfs_block_allsigs();
1536 LNetMDUnlink(the_lnet.ln_ping_target_md);
1537 /* NB md could be busy; this just starts the unlink */
1540 rc = LNetEQPoll(&the_lnet.ln_ping_target_eq, 1,
1541 timeout_ms, &event, &which);
1543 /* I expect overflow... */
1544 LASSERT (rc >= 0 || rc == -EOVERFLOW);
1547 /* timed out: provide a diagnostic */
1548 CWARN("Still waiting for ping MD to unlink\n");
1553 /* Got a valid event */
1558 rc = LNetEQFree(the_lnet.ln_ping_target_eq);
1561 LIBCFS_FREE(the_lnet.ln_ping_info,
1562 offsetof(lnet_ping_info_t,
1563 pi_nid[the_lnet.ln_ping_info->pi_nnids]));
1565 cfs_restore_sigs(blocked);
1569 lnet_ping (lnet_process_id_t id, int timeout_ms, lnet_process_id_t *ids, int n_ids)
1571 lnet_handle_eq_t eqh;
1572 lnet_handle_md_t mdh;
1577 const int a_long_time = 60000; /* mS */
1578 int infosz = offsetof(lnet_ping_info_t, pi_nid[n_ids]);
1579 lnet_ping_info_t *info;
1580 lnet_process_id_t tmpid;
1585 cfs_sigset_t blocked;
1588 id.nid == LNET_NID_ANY ||
1589 timeout_ms > 500000 || /* arbitrary limit! */
1590 n_ids > 20) /* arbitrary limit! */
1593 if (id.pid == LNET_PID_ANY)
1594 id.pid = LUSTRE_SRV_LNET_PID;
1596 LIBCFS_ALLOC(info, infosz);
1600 /* NB 2 events max (including any unlink event) */
1601 rc = LNetEQAlloc(2, LNET_EQ_HANDLER_NONE, &eqh);
1603 CERROR("Can't allocate EQ: %d\n", rc);
1607 rc = LNetMDBind((lnet_md_t){.start = info,
1609 .threshold = 2, /* GET/REPLY */
1610 .options = LNET_MD_TRUNCATE,
1615 CERROR("Can't bind MD: %d\n", rc);
1619 rc = LNetGet(LNET_NID_ANY, mdh, id,
1620 LNET_RESERVED_PORTAL,
1621 LNET_PROTO_PING_MATCHBITS, 0);
1624 /* Don't CERROR; this could be deliberate! */
1626 rc2 = LNetMDUnlink(mdh);
1629 /* NB must wait for the UNLINK event below... */
1631 timeout_ms = a_long_time;
1635 /* MUST block for unlink to complete */
1637 blocked = cfs_block_allsigs();
1639 rc2 = LNetEQPoll(&eqh, 1, timeout_ms, &event, &which);
1642 cfs_restore_sigs(blocked);
1644 CDEBUG(D_NET, "poll %d(%d %d)%s\n", rc2,
1645 (rc2 <= 0) ? -1 : event.type,
1646 (rc2 <= 0) ? -1 : event.status,
1647 (rc2 > 0 && event.unlinked) ? " unlinked" : "");
1649 LASSERT (rc2 != -EOVERFLOW); /* can't miss anything */
1651 if (rc2 <= 0 || event.status != 0) {
1652 /* timeout or error */
1653 if (!replied && rc == 0)
1654 rc = (rc2 < 0) ? rc2 :
1655 (rc2 == 0) ? -ETIMEDOUT :
1659 /* Ensure completion in finite time... */
1661 /* No assertion (racing with network) */
1663 timeout_ms = a_long_time;
1664 } else if (rc2 == 0) {
1665 /* timed out waiting for unlink */
1666 CWARN("ping %s: late network completion\n",
1670 } else if (event.type == LNET_EVENT_REPLY) {
1675 } while (rc2 <= 0 || !event.unlinked);
1679 CWARN("%s: Unexpected rc >= 0 but no reply!\n",
1686 LASSERT (nob >= 0 && nob <= infosz);
1688 rc = -EPROTO; /* if I can't parse... */
1691 /* can't check magic/version */
1692 CERROR("%s: ping info too short %d\n",
1693 libcfs_id2str(id), nob);
1697 if (info->pi_magic == __swab32(LNET_PROTO_PING_MAGIC)) {
1698 /* NB I might be swabbing garbage until I check below, but it
1700 __swab32s(&info->pi_version);
1701 __swab32s(&info->pi_pid);
1702 __swab32s(&info->pi_nnids);
1703 for (i = 0; i < info->pi_nnids && i < n_ids; i++)
1704 __swab64s(&info->pi_nid[i]);
1706 } else if (info->pi_magic != LNET_PROTO_PING_MAGIC) {
1707 CERROR("%s: Unexpected magic %08x\n",
1708 libcfs_id2str(id), info->pi_magic);
1712 if (info->pi_version != LNET_PROTO_PING_VERSION) {
1713 CERROR("%s: Unexpected version 0x%x\n",
1714 libcfs_id2str(id), info->pi_version);
1718 if (nob < offsetof(lnet_ping_info_t, pi_nid[0])) {
1719 CERROR("%s: Short reply %d(%d min)\n", libcfs_id2str(id),
1720 nob, (int)offsetof(lnet_ping_info_t, pi_nid[0]));
1724 if (info->pi_nnids < n_ids)
1725 n_ids = info->pi_nnids;
1727 if (nob < offsetof(lnet_ping_info_t, pi_nid[n_ids])) {
1728 CERROR("%s: Short reply %d(%d expected)\n", libcfs_id2str(id),
1729 nob, (int)offsetof(lnet_ping_info_t, pi_nid[n_ids]));
1733 rc = -EFAULT; /* If I SEGV... */
1735 for (i = 0; i < n_ids; i++) {
1736 tmpid.pid = info->pi_pid;
1737 tmpid.nid = info->pi_nid[i];
1739 if (copy_to_user(&ids[i], &tmpid, sizeof(tmpid)))
1745 rc = info->pi_nnids;
1748 rc2 = LNetEQFree(eqh);
1750 CERROR("rc2 %d\n", rc2);
1754 LIBCFS_FREE(info, infosz);