Whamcloud - gitweb
add enough arguments for the printf format string.
[fs/lustre-release.git] / lustre / ptlrpc / events.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (c) 2002, 2003 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
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.
11  *
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.
16  *
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.
20  *
21  */
22
23 #define DEBUG_SUBSYSTEM S_RPC
24
25 #ifdef __KERNEL__
26 #include <linux/module.h>
27 #else
28 #include <liblustre.h>
29 #endif
30 #include <linux/obd_class.h>
31 #include <linux/lustre_net.h>
32 #include "ptlrpc_internal.h"
33
34 #if !defined(__KERNEL__) && CRAY_PORTALS
35 /* forward ref in events.c */
36 static void cray_portals_callback(ptl_event_t *ev);
37 #endif
38
39
40 struct ptlrpc_ni  ptlrpc_interfaces[8];
41 int               ptlrpc_ninterfaces;
42
43 /*  
44  *  Client's outgoing request callback
45  */
46 void request_out_callback(ptl_event_t *ev)
47 {
48         struct ptlrpc_cb_id   *cbid = ev->md.user_ptr;
49         struct ptlrpc_request *req = cbid->cbid_arg;
50         unsigned long          flags;
51         ENTRY;
52
53         LASSERT (ev->type == PTL_EVENT_SEND_END ||
54                  ev->type == PTL_EVENT_UNLINK);
55         LASSERT (ev->unlinked);
56
57         DEBUG_REQ((ev->ni_fail_type == PTL_NI_OK) ? D_NET : D_ERROR, req,
58                   "type %d, status %d", ev->type, ev->ni_fail_type);
59
60         if (ev->type == PTL_EVENT_UNLINK ||
61             ev->ni_fail_type != PTL_NI_OK) {
62
63                 /* Failed send: make it seem like the reply timed out, just
64                  * like failing sends in client.c does currently...  */
65
66                 spin_lock_irqsave(&req->rq_lock, flags);
67                 req->rq_net_err = 1;
68                 spin_unlock_irqrestore(&req->rq_lock, flags);
69                 
70                 ptlrpc_wake_client_req(req);
71         }
72
73         /* this balances the atomic_inc in ptl_send_rpc() */
74         ptlrpc_req_finished(req);
75         EXIT;
76 }
77
78 /*
79  * Client's incoming reply callback
80  */
81 void reply_in_callback(ptl_event_t *ev)
82 {
83         struct ptlrpc_cb_id   *cbid = ev->md.user_ptr;
84         struct ptlrpc_request *req = cbid->cbid_arg;
85         unsigned long flags;
86         ENTRY;
87
88         LASSERT (ev->type == PTL_EVENT_PUT_END ||
89                  ev->type == PTL_EVENT_UNLINK);
90         LASSERT (ev->unlinked);
91         LASSERT (ev->md.start == req->rq_repmsg);
92         LASSERT (ev->offset == 0);
93         LASSERT (ev->mlength <= req->rq_replen);
94         
95         DEBUG_REQ((ev->ni_fail_type == PTL_NI_OK) ? D_NET : D_ERROR, req,
96                   "type %d, status %d", ev->type, ev->ni_fail_type);
97
98         spin_lock_irqsave (&req->rq_lock, flags);
99
100         LASSERT (req->rq_receiving_reply);
101         req->rq_receiving_reply = 0;
102
103         if (ev->type == PTL_EVENT_PUT_END &&
104             ev->ni_fail_type == PTL_NI_OK) {
105                 req->rq_replied = 1;
106                 req->rq_nob_received = ev->mlength;
107         }
108
109         /* NB don't unlock till after wakeup; req can disappear under us
110          * since we don't have our own ref */
111         ptlrpc_wake_client_req(req);
112
113         spin_unlock_irqrestore (&req->rq_lock, flags);
114         EXIT;
115 }
116
117 /* 
118  * Client's bulk has been written/read
119  */
120 void client_bulk_callback (ptl_event_t *ev)
121 {
122         struct ptlrpc_cb_id     *cbid = ev->md.user_ptr;
123         struct ptlrpc_bulk_desc *desc = cbid->cbid_arg;
124         unsigned long            flags;
125         ENTRY;
126
127         LASSERT ((desc->bd_type == BULK_PUT_SINK && 
128                   ev->type == PTL_EVENT_PUT_END) ||
129                  (desc->bd_type == BULK_GET_SOURCE &&
130                   ev->type == PTL_EVENT_GET_END) ||
131                  ev->type == PTL_EVENT_UNLINK);
132         LASSERT (ev->unlinked);
133
134         CDEBUG((ev->ni_fail_type == PTL_NI_OK) ? D_NET : D_ERROR,
135                "event type %d, status %d, desc %p\n", 
136                ev->type, ev->ni_fail_type, desc);
137
138         spin_lock_irqsave (&desc->bd_lock, flags);
139
140         LASSERT(desc->bd_network_rw);
141         desc->bd_network_rw = 0;
142
143         if (ev->type != PTL_EVENT_UNLINK &&
144             ev->ni_fail_type == PTL_NI_OK) {
145                 desc->bd_success = 1;
146                 desc->bd_nob_transferred = ev->mlength;
147         }
148
149         /* NB don't unlock till after wakeup; desc can disappear under us
150          * otherwise */
151         ptlrpc_wake_client_req(desc->bd_req);
152
153         spin_unlock_irqrestore (&desc->bd_lock, flags);
154         EXIT;
155 }
156
157 /* 
158  * Server's incoming request callback
159  */
160 void request_in_callback(ptl_event_t *ev)
161 {
162         struct ptlrpc_cb_id               *cbid = ev->md.user_ptr;
163         struct ptlrpc_request_buffer_desc *rqbd = cbid->cbid_arg;
164         struct ptlrpc_srv_ni              *srv_ni = rqbd->rqbd_srv_ni;
165         struct ptlrpc_service             *service = srv_ni->sni_service;
166         struct ptlrpc_request             *req;
167         char                              str[PTL_NALFMT_SIZE];
168         unsigned long                     flags;
169         ENTRY;
170
171         LASSERT (ev->type == PTL_EVENT_PUT_END ||
172                  ev->type == PTL_EVENT_UNLINK);
173         LASSERT ((char *)ev->md.start >= rqbd->rqbd_buffer);
174         LASSERT ((char *)ev->md.start + ev->offset + ev->mlength <=
175                  rqbd->rqbd_buffer + service->srv_buf_size);
176
177         CDEBUG((ev->ni_fail_type == PTL_OK) ? D_NET : D_ERROR,
178                "event type %d, status %d, service %s\n", 
179                ev->type, ev->ni_fail_type, service->srv_name);
180
181         if (ev->unlinked) {
182                 /* If this is the last request message to fit in the
183                  * request buffer we can use the request object embedded in
184                  * rqbd.  Note that if we failed to allocate a request,
185                  * we'd have to re-post the rqbd, which we can't do in this
186                  * context. */
187                 req = &rqbd->rqbd_req;
188                 memset(req, 0, sizeof (*req));
189         } else {
190                 LASSERT (ev->type == PTL_EVENT_PUT_END);
191                 if (ev->ni_fail_type != PTL_NI_OK) {
192                         /* We moaned above already... */
193                         return;
194                 }
195                 OBD_ALLOC_GFP(req, sizeof(*req), GFP_ATOMIC);
196                 if (req == NULL) {
197                         CERROR("Can't allocate incoming request descriptor: "
198                                "Dropping %s RPC from %s\n",
199                                service->srv_name, 
200                                portals_id2str(srv_ni->sni_ni->pni_number,
201                                               ev->initiator, str));
202                         return;
203                 }
204         }
205
206         /* NB we ABSOLUTELY RELY on req being zeroed, so pointers are NULL,
207          * flags are reset and scalars are zero.  We only set the message
208          * size to non-zero if this was a successful receive. */
209         req->rq_xid = ev->match_bits;
210         req->rq_reqmsg = ev->md.start + ev->offset;
211         if (ev->type == PTL_EVENT_PUT_END &&
212             ev->ni_fail_type == PTL_NI_OK)
213                 req->rq_reqlen = ev->mlength;
214         do_gettimeofday(&req->rq_arrival_time);
215         req->rq_peer.peer_id = ev->initiator;
216         req->rq_peer.peer_ni = rqbd->rqbd_srv_ni->sni_ni;
217         ptlrpc_id2str(&req->rq_peer, req->rq_peerstr);
218         req->rq_rqbd = rqbd;
219         req->rq_phase = RQ_PHASE_NEW;
220         
221         spin_lock_irqsave (&service->srv_lock, flags);
222
223         req->rq_history_seq = service->srv_request_seq++;
224         list_add_tail(&req->rq_history_list, &service->srv_request_history);
225
226         if (ev->unlinked) {
227                 srv_ni->sni_nrqbd_receiving--;
228                 if (ev->type != PTL_EVENT_UNLINK &&
229                     srv_ni->sni_nrqbd_receiving == 0) {
230                         /* This service is off-air on this interface because
231                          * all its request buffers are busy.  Portals will
232                          * start dropping incoming requests until more buffers
233                          * get posted.  NB don't moan if it's because we're
234                          * tearing down the service. */
235                         CWARN("All %s %s request buffers busy\n",
236                               service->srv_name, srv_ni->sni_ni->pni_name);
237                 }
238                 /* req takes over the network's ref on rqbd */
239         } else {
240                 /* req takes a ref on rqbd */
241                 rqbd->rqbd_refcount++;
242         }
243
244         list_add_tail(&req->rq_list, &service->srv_request_queue);
245         service->srv_n_queued_reqs++;
246
247         /* NB everything can disappear under us once the request
248          * has been queued and we unlock, so do the wake now... */
249         wake_up(&service->srv_waitq);
250
251         spin_unlock_irqrestore(&service->srv_lock, flags);
252         EXIT;
253 }
254
255 /*  
256  *  Server's outgoing reply callback
257  */
258 void reply_out_callback(ptl_event_t *ev)
259 {
260         struct ptlrpc_cb_id       *cbid = ev->md.user_ptr;
261         struct ptlrpc_reply_state *rs = cbid->cbid_arg;
262         struct ptlrpc_srv_ni      *sni = rs->rs_srv_ni;
263         struct ptlrpc_service     *svc = sni->sni_service;
264         unsigned long              flags;
265         ENTRY;
266
267         LASSERT (ev->type == PTL_EVENT_SEND_END ||
268                  ev->type == PTL_EVENT_ACK ||
269                  ev->type == PTL_EVENT_UNLINK);
270
271         if (!rs->rs_difficult) {
272                 /* 'Easy' replies have no further processing so I drop the
273                  * net's ref on 'rs' */
274                 LASSERT (ev->unlinked);
275                 ptlrpc_rs_decref(rs);
276                 atomic_dec (&svc->srv_outstanding_replies);
277                 EXIT;
278                 return;
279         }
280
281         LASSERT (rs->rs_on_net);
282
283         if (ev->unlinked) {
284                 /* Last network callback.  The net's ref on 'rs' stays put
285                  * until ptlrpc_server_handle_reply() is done with it */
286                 spin_lock_irqsave (&svc->srv_lock, flags);
287                 rs->rs_on_net = 0;
288                 ptlrpc_schedule_difficult_reply (rs);
289                 spin_unlock_irqrestore (&svc->srv_lock, flags);
290         }
291
292         EXIT;
293 }
294
295 /*
296  * Server's bulk completion callback
297  */
298 void server_bulk_callback (ptl_event_t *ev)
299 {
300         struct ptlrpc_cb_id     *cbid = ev->md.user_ptr;
301         struct ptlrpc_bulk_desc *desc = cbid->cbid_arg;
302         unsigned long            flags;
303         ENTRY;
304
305         LASSERT (ev->type == PTL_EVENT_SEND_END ||
306                  ev->type == PTL_EVENT_UNLINK ||
307                  (desc->bd_type == BULK_PUT_SOURCE &&
308                   ev->type == PTL_EVENT_ACK) ||
309                  (desc->bd_type == BULK_GET_SINK &&
310                   ev->type == PTL_EVENT_REPLY_END));
311
312         CDEBUG((ev->ni_fail_type == PTL_NI_OK) ? D_NET : D_ERROR,
313                "event type %d, status %d, desc %p\n", 
314                ev->type, ev->ni_fail_type, desc);
315
316         spin_lock_irqsave (&desc->bd_lock, flags);
317         
318         if ((ev->type == PTL_EVENT_ACK ||
319              ev->type == PTL_EVENT_REPLY_END) &&
320             ev->ni_fail_type == PTL_NI_OK) {
321                 /* We heard back from the peer, so even if we get this
322                  * before the SENT event (oh yes we can), we know we
323                  * read/wrote the peer buffer and how much... */
324                 desc->bd_success = 1;
325                 desc->bd_nob_transferred = ev->mlength;
326         }
327
328         if (ev->unlinked) {
329                 /* This is the last callback no matter what... */
330                 desc->bd_network_rw = 0;
331                 wake_up(&desc->bd_waitq);
332         }
333
334         spin_unlock_irqrestore (&desc->bd_lock, flags);
335         EXIT;
336 }
337
338 static void ptlrpc_master_callback(ptl_event_t *ev)
339 {
340         struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
341         void (*callback)(ptl_event_t *ev) = cbid->cbid_fn;
342
343         /* Honestly, it's best to find out early. */
344         LASSERT (cbid->cbid_arg != LP_POISON);
345         LASSERT (callback == request_out_callback ||
346                  callback == reply_in_callback ||
347                  callback == client_bulk_callback ||
348                  callback == request_in_callback ||
349                  callback == reply_out_callback ||
350                  callback == server_bulk_callback);
351         
352         callback (ev);
353 }
354
355 int ptlrpc_uuid_to_peer (struct obd_uuid *uuid, struct ptlrpc_peer *peer)
356 {
357         struct ptlrpc_ni   *pni;
358         __u32               peer_nal;
359         ptl_nid_t           peer_nid;
360         int                 i;
361         char                str[PTL_NALFMT_SIZE];
362         int                 rc = lustre_uuid_to_peer(uuid->uuid, 
363                                                      &peer_nal, &peer_nid);
364         if (rc != 0)
365                 RETURN (rc);
366
367         for (i = 0; i < ptlrpc_ninterfaces; i++) {
368                 pni = &ptlrpc_interfaces[i];
369
370                 if (pni->pni_number == peer_nal) {
371                         peer->peer_id.nid = peer_nid;
372                         peer->peer_id.pid = LUSTRE_SRV_PTL_PID;
373                         peer->peer_ni = pni;
374                         return (0);
375                 }
376         }
377
378         CERROR("Can't find ptlrpc interface for NAL %x, NID %s\n",
379                peer_nal, portals_nid2str(peer_nal, peer_nid, str));
380         return (-ENOENT);
381 }
382
383 void ptlrpc_ni_fini(struct ptlrpc_ni *pni)
384 {
385         wait_queue_head_t   waitq;
386         struct l_wait_info  lwi;
387         int                 rc;
388         int                 retries;
389         
390         /* Wait for the event queue to become idle since there may still be
391          * messages in flight with pending events (i.e. the fire-and-forget
392          * messages == client requests and "non-difficult" server
393          * replies */
394
395         for (retries = 0;; retries++) {
396                 rc = PtlEQFree(pni->pni_eq_h);
397                 switch (rc) {
398                 default:
399                         LBUG();
400
401                 case PTL_OK:
402                         PtlNIFini(pni->pni_ni_h);
403                         return;
404                         
405                 case PTL_EQ_IN_USE:
406                         if (retries != 0)
407                                 CWARN("Event queue for %s still busy\n",
408                                       pni->pni_name);
409                         
410                         /* Wait for a bit */
411                         init_waitqueue_head(&waitq);
412                         lwi = LWI_TIMEOUT(2*HZ, NULL, NULL);
413                         l_wait_event(waitq, 0, &lwi);
414                         break;
415                 }
416         }
417         /* notreached */
418 }
419
420 ptl_pid_t ptl_get_pid(void)
421 {
422         ptl_pid_t        pid;
423
424 #ifndef  __KERNEL__
425         pid = getpid();
426 #else
427         pid = LUSTRE_SRV_PTL_PID;
428 #endif
429         return pid;
430 }
431         
432 int ptlrpc_ni_init(int number, char *name, struct ptlrpc_ni *pni)
433 {
434         int              rc;
435         char             str[20];
436         ptl_handle_ni_t  nih;
437         ptl_pid_t        pid;
438         
439         pid = ptl_get_pid();
440         
441         /* We're not passing any limits yet... */
442         rc = PtlNIInit(number, pid, NULL, NULL, &nih);
443         if (rc != PTL_OK && rc != PTL_IFACE_DUP) {
444                 CDEBUG (D_NET, "Can't init network interface %s: %d\n", 
445                         name, rc);
446                 return (-ENOENT);
447         }
448
449         CDEBUG(D_NET, "My pid is: %x\n", ptl_get_pid());
450         
451         PtlSnprintHandle(str, sizeof(str), nih);
452         CDEBUG (D_NET, "init %x %s: %s\n", number, name, str);
453
454         pni->pni_name = name;
455         pni->pni_number = number;
456         pni->pni_ni_h = nih;
457
458         pni->pni_eq_h = PTL_INVALID_HANDLE;
459
460         /* CAVEAT EMPTOR: how we process portals events is _radically_
461          * different depending on... */
462 #ifdef __KERNEL__
463         /* kernel portals calls our master callback when events are added to
464          * the event queue.  In fact lustre never pulls events off this queue,
465          * so it's only sized for some debug history. */
466         rc = PtlEQAlloc(pni->pni_ni_h, 1024, ptlrpc_master_callback,
467                         &pni->pni_eq_h);
468 #else
469         /* liblustre calls the master callback when it removes events from the
470          * event queue.  The event queue has to be big enough not to drop
471          * anything */
472 # if CRAY_PORTALS
473         /* cray portals implements a non-standard callback to notify us there
474          * are buffered events even when the app is not doing a filesystem
475          * call. */
476         rc = PtlEQAlloc(pni->pni_ni_h, 10240, cray_portals_callback,
477                         &pni->pni_eq_h);
478 # else
479         rc = PtlEQAlloc(pni->pni_ni_h, 10240, PTL_EQ_HANDLER_NONE,
480                         &pni->pni_eq_h);
481 # endif
482 #endif
483         if (rc != PTL_OK)
484                 GOTO (fail, rc = -ENOMEM);
485
486         return (0);
487  fail:
488         CERROR ("Failed to initialise network interface %s: %d\n",
489                 name, rc);
490
491         /* OK to do complete teardown since we invalidated the handles above */
492         ptlrpc_ni_fini (pni);
493         return (rc);
494 }
495
496 #ifndef __KERNEL__
497 LIST_HEAD(liblustre_wait_callbacks);
498 void *liblustre_services_callback;
499
500 void *
501 liblustre_register_wait_callback (int (*fn)(void *arg), void *arg)
502 {
503         struct liblustre_wait_callback *llwc;
504         
505         OBD_ALLOC(llwc, sizeof(*llwc));
506         LASSERT (llwc != NULL);
507         
508         llwc->llwc_fn = fn;
509         llwc->llwc_arg = arg;
510         list_add_tail(&llwc->llwc_list, &liblustre_wait_callbacks);
511         
512         return (llwc);
513 }
514
515 void
516 liblustre_deregister_wait_callback (void *opaque)
517 {
518         struct liblustre_wait_callback *llwc = opaque;
519         
520         list_del(&llwc->llwc_list);
521         OBD_FREE(llwc, sizeof(*llwc));
522 }
523
524 int
525 liblustre_check_events (int timeout)
526 {
527         ptl_event_t ev;
528         int         rc;
529         int         i;
530         ENTRY;
531
532         rc = PtlEQPoll(&ptlrpc_interfaces[0].pni_eq_h, 1, timeout * 1000,
533                        &ev, &i);
534         if (rc == PTL_EQ_EMPTY)
535                 RETURN(0);
536         
537         LASSERT (rc == PTL_EQ_DROPPED || rc == PTL_OK);
538         
539         /* liblustre: no asynch callback so we can't affort to miss any
540          * events... */
541         if (rc == PTL_EQ_DROPPED) {
542                 CERROR ("Dropped an event!!!\n");
543                 abort();
544         }
545         
546         ptlrpc_master_callback (&ev);
547         RETURN(1);
548 }
549
550 int liblustre_waiting = 0;
551
552 int
553 liblustre_wait_event (int timeout)
554 {
555         struct list_head               *tmp;
556         struct liblustre_wait_callback *llwc;
557         int                             found_something = 0;
558
559         /* single threaded recursion check... */
560         liblustre_waiting = 1;
561
562         for (;;) {
563                 /* Deal with all pending events */
564                 while (liblustre_check_events(0))
565                         found_something = 1;
566
567                 /* Give all registered callbacks a bite at the cherry */
568                 list_for_each(tmp, &liblustre_wait_callbacks) {
569                         llwc = list_entry(tmp, struct liblustre_wait_callback, 
570                                           llwc_list);
571                 
572                         if (llwc->llwc_fn(llwc->llwc_arg))
573                                 found_something = 1;
574                 }
575
576                 if (found_something || timeout == 0)
577                         break;
578
579                 /* Nothing so far, but I'm allowed to block... */
580                 found_something = liblustre_check_events(timeout);
581                 if (!found_something)           /* still nothing */
582                         break;                  /* I timed out */
583         }
584
585         liblustre_waiting = 0;
586
587         return found_something;
588 }
589
590 #if CRAY_PORTALS
591 static void cray_portals_callback(ptl_event_t *ev)
592 {
593         /* We get a callback from the client Cray portals implementation
594          * whenever anyone calls PtlEQPoll(), and an event queue with a
595          * callback handler has outstanding events.
596          *
597          * If it's not liblustre calling PtlEQPoll(), this lets us know we
598          * have outstanding events which we handle with
599          * liblustre_wait_event().
600          *
601          * Otherwise, we're already eagerly consuming events and we'd
602          * handle events out of order if we recursed. */
603         if (!liblustre_waiting)
604                 liblustre_wait_event(0);
605 }
606 #endif
607 #endif /* __KERNEL__ */
608
609 int ptlrpc_default_nal(void)
610 {
611         if (ptlrpc_ninterfaces == 0)
612                 return (-ENOENT);
613
614         return (ptlrpc_interfaces[0].pni_number);
615 }
616
617 int ptlrpc_init_portals(void)
618 {
619         /* Add new portals network interfaces here.
620          * Order is irrelevent! */
621         static struct {
622                 int   number;
623                 char *name;
624         } ptl_nis[] = {
625 #if !CRAY_PORTALS
626                 {QSWNAL,    "qswnal"},
627                 {SOCKNAL,   "socknal"},
628                 {GMNAL,     "gmnal"},
629                 {OPENIBNAL, "openibnal"},
630                 {IIBNAL,    "iibnal"},
631                 {VIBNAL,    "vibnal"},
632                 {TCPNAL,    "tcpnal"},
633                 {LONAL,     "lonal"},
634                 {RANAL,     "ranal"},
635 #else
636                 {CRAY_KB_ERNAL, "cray_kb_ernal"},
637 #endif
638         };
639         int   rc;
640         int   i;
641
642         LASSERT(ptlrpc_ninterfaces == 0);
643
644         for (i = 0; i < sizeof (ptl_nis) / sizeof (ptl_nis[0]); i++) {
645                 LASSERT(ptlrpc_ninterfaces < (sizeof(ptlrpc_interfaces) /
646                                               sizeof(ptlrpc_interfaces[0])));
647
648                 rc = ptlrpc_ni_init(ptl_nis[i].number, ptl_nis[i].name,
649                                     &ptlrpc_interfaces[ptlrpc_ninterfaces]);
650                 if (rc == 0)
651                         ptlrpc_ninterfaces++;
652         }
653
654         if (ptlrpc_ninterfaces == 0) {
655                 CERROR("network initialisation failed: is a NAL module "
656                        "loaded?\n");
657                 return -EIO;
658         }
659 #ifndef __KERNEL__
660         liblustre_services_callback = 
661                 liblustre_register_wait_callback(&liblustre_check_services, NULL);
662 #endif
663         return 0;
664 }
665
666 void ptlrpc_exit_portals(void)
667 {
668 #ifndef __KERNEL__
669         liblustre_deregister_wait_callback(liblustre_services_callback);
670 #endif
671         while (ptlrpc_ninterfaces > 0)
672                 ptlrpc_ni_fini (&ptlrpc_interfaces[--ptlrpc_ninterfaces]);
673 }