Whamcloud - gitweb
Landing b_recovery
[fs/lustre-release.git] / lustre / include / linux / lustre_net.h
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 #ifndef _LUSTRE_NET_H
24 #define _LUSTRE_NET_H
25
26 #ifdef __KERNEL__
27 #include <linux/version.h>
28 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
29 #include <linux/tqueue.h>
30 #else
31 #include <linux/workqueue.h>
32 #endif
33 #endif
34
35 #include <linux/kp30.h>
36 // #include <linux/obd.h>
37 #include <portals/p30.h>
38 #include <portals/lib-types.h>                  /* FIXME (for PTL_MD_MAX_IOV) */
39 #include <linux/lustre_idl.h>
40 #include <linux/lustre_ha.h>
41 #include <linux/lustre_import.h>
42 #include <linux/lprocfs_status.h>
43
44 /* The following constants determine how much memory is devoted to
45  * buffering in the lustre services.
46  *
47  * ?_NEVENTS            # event queue entries
48  *
49  * ?_NBUFS              # request buffers
50  * ?_BUFSIZE            # bytes in a single request buffer
51  * total memory = ?_NBUFS * ?_BUFSIZE
52  *
53  * ?_MAXREQSIZE         # maximum request service will receive
54  * larger messages will get dropped.
55  * request buffers are auto-unlinked when less than ?_MAXREQSIZE
56  * is left in them.
57  */
58
59 #define LDLM_NUM_THREADS        min(smp_num_cpus * smp_num_cpus * 8, 64)
60 #define LDLM_NEVENT_MAX 8192UL
61 #define LDLM_NEVENTS    min_t(unsigned long, num_physpages / 64,  \
62                               LDLM_NEVENT_MAX)
63 #define LDLM_NBUF_MAX   256UL
64 #define LDLM_NBUFS      min(LDLM_NEVENTS / 16, LDLM_NBUF_MAX)
65 #define LDLM_BUFSIZE    (8 * 1024)
66 #define LDLM_MAXREQSIZE (5 * 1024)
67
68 #define MDT_MAX_THREADS 32UL
69 #define MDT_NUM_THREADS max(min_t(unsigned long, num_physpages / 8192, \
70                                   MDT_MAX_THREADS), 2UL)
71 #define MDS_NEVENT_MAX  8192UL
72 #define MDS_NEVENTS     min_t(unsigned long, num_physpages / 64, \
73                               MDS_NEVENT_MAX)
74 #define MDS_NBUF_MAX    512UL
75 #define MDS_NBUFS       min(MDS_NEVENTS / 16, MDS_NBUF_MAX)
76 #define MDS_BUFSIZE     (8 * 1024)
77 /* Assume file name length = FNAME_MAX = 256 (true for extN).
78  *        path name length = PATH_MAX = 4096
79  *        LOV MD size max  = EA_MAX = 4000
80  * symlink:  FNAME_MAX + PATH_MAX  <- largest
81  * link:     FNAME_MAX + PATH_MAX  (mds_rec_link < mds_rec_create)
82  * rename:   FNAME_MAX + FNAME_MAX
83  * open:     FNAME_MAX + EA_MAX
84  *
85  * MDS_MAXREQSIZE ~= 4736 bytes =
86  * lustre_msg + ldlm_request + mds_body + mds_rec_create + FNAME_MAX + PATH_MAX
87  *
88  * Realistic size is about 512 bytes (20 character name + 128 char symlink),
89  * except in the open case where there are a large number of OSTs in a LOV.
90  */
91 #define MDS_MAXREQSIZE  (5 * 1024)
92
93 #define OST_MAX_THREADS 36UL
94 #define OST_NUM_THREADS max(min_t(unsigned long, num_physpages / 8192, \
95                                   OST_MAX_THREADS), 2UL)
96 #define OST_NEVENT_MAX  16384UL
97 #define OST_NEVENTS     min_t(unsigned long, num_physpages / 16, \
98                               OST_NEVENT_MAX)
99 #define OST_NBUF_MAX    5000UL
100 #define OST_NBUFS       min(OST_NEVENTS / 2, OST_NBUF_MAX)
101 #define OST_BUFSIZE     (8 * 1024)
102 /* OST_MAXREQSIZE ~= 1640 bytes =
103  * lustre_msg + obdo + 16 * obd_ioobj + 64 * niobuf_remote
104  *
105  * - single object with 16 pages is 512 bytes
106  * - OST_MAXREQSIZE must be at least 1 page of cookies plus some spillover
107  */
108 #define OST_MAXREQSIZE  (5 * 1024)
109
110 #define PTLBD_NUM_THREADS        4
111 #define PTLBD_NEVENTS    1024
112 #define PTLBD_NBUFS      20
113 #define PTLBD_BUFSIZE    (32 * 1024)
114 #define PTLBD_MAXREQSIZE 1024
115
116 struct ptlrpc_peer {
117         ptl_nid_t         peer_nid;
118         struct ptlrpc_ni *peer_ni;
119 };
120
121 struct ptlrpc_connection {
122         struct list_head        c_link;
123         struct ptlrpc_peer      c_peer;
124         struct obd_uuid         c_remote_uuid;
125         atomic_t                c_refcount;
126 };
127
128 struct ptlrpc_client {
129         __u32                     cli_request_portal;
130         __u32                     cli_reply_portal;
131         char                     *cli_name;
132 };
133
134 /* state flags of requests */
135 /* XXX only ones left are those used by the bulk descs as well! */
136 #define PTL_RPC_FL_INTR      (1 << 0)  /* reply wait was interrupted by user */
137 #define PTL_RPC_FL_TIMEOUT   (1 << 7)  /* request timed out waiting for reply */
138
139 #define REQ_MAX_ACK_LOCKS 8
140
141 #define SWAB_PARANOIA 1
142 #if SWAB_PARANOIA
143 /* unpacking: assert idx not unpacked already */
144 #define LASSERT_REQSWAB(rq, idx)                                \
145 do {                                                            \
146         LASSERT ((idx) < sizeof ((rq)->rq_req_swab_mask) * 8);  \
147         LASSERT (((rq)->rq_req_swab_mask & (1 << (idx))) == 0); \
148         (rq)->rq_req_swab_mask |= (1 << (idx));                 \
149 } while (0)
150
151 #define LASSERT_REPSWAB(rq, idx)                                \
152 do {                                                            \
153         LASSERT ((idx) < sizeof ((rq)->rq_rep_swab_mask) * 8);  \
154         LASSERT (((rq)->rq_rep_swab_mask & (1 << (idx))) == 0); \
155         (rq)->rq_rep_swab_mask |= (1 << (idx));                 \
156 } while (0)
157
158 /* just looking: assert idx already unpacked */
159 #define LASSERT_REQSWABBED(rq, idx)                     \
160 LASSERT ((idx) < sizeof ((rq)->rq_req_swab_mask) * 8 && \
161          ((rq)->rq_req_swab_mask & (1 << (idx))) != 0)
162
163 #define LASSERT_REPSWABBED(rq, idx)                     \
164 LASSERT ((idx) < sizeof ((rq)->rq_rep_swab_mask) * 8 && \
165          ((rq)->rq_rep_swab_mask & (1 << (idx))) != 0)
166 #else
167 #define LASSERT_REQSWAB(rq, idx)
168 #define LASSERT_REPSWAB(rq, idx)
169 #define LASSERT_REQSWABBED(rq, idx)
170 #define LASSERT_REPSWABBED(rq, idx)
171 #endif
172
173 union ptlrpc_async_args {
174         /* Scratchpad for passing args to completion interpreter. Users
175          * cast to the struct of their choosing, and LASSERT that this is
176          * big enough.  For _tons_ of context, OBD_ALLOC a struct and store
177          * a pointer to it here.  The pointer_arg ensures this struct is at
178          * least big enough for that. */
179         void      *pointer_arg[9];
180         __u64      space[4];
181 };
182
183 struct ptlrpc_request_set;
184 typedef int (*set_interpreter_func)(struct ptlrpc_request_set *, void *, int);
185
186 struct ptlrpc_request_set {
187         int               set_remaining; /* # uncompleted requests */
188         wait_queue_head_t set_waitq;
189         wait_queue_head_t *set_wakeup_ptr;
190         struct list_head  set_requests;
191         set_interpreter_func    set_interpret; /* completion callback */
192         union ptlrpc_async_args set_args; /* completion context */
193         /* locked so that any old caller can communicate requests to
194          * the set holder who can then fold them into the lock-free set */
195         spinlock_t        set_new_req_lock;
196         struct list_head  set_new_requests;
197 };
198
199 struct ptlrpc_bulk_desc;
200
201 struct ptlrpc_request {
202         int rq_type; /* one of PTL_RPC_MSG_* */
203         struct list_head rq_list;
204         int rq_status;
205         spinlock_t rq_lock;
206         unsigned int rq_intr:1, rq_replied:1, rq_want_ack:1, rq_err:1,
207             rq_timedout:1, rq_resend:1, rq_restart:1, rq_replay:1,
208             rq_no_resend:1, rq_resent:1, rq_waiting:1, rq_receiving_reply:1;
209         int rq_phase;
210                 
211         atomic_t rq_refcount;
212
213         int rq_request_portal; /* XXX FIXME bug 249 */
214         int rq_reply_portal; /* XXX FIXME bug 249 */
215
216         int rq_reqlen;
217         struct lustre_msg *rq_reqmsg;
218
219         int rq_timeout;
220         int rq_replen;
221         struct lustre_msg *rq_repmsg;
222         __u64 rq_transno;
223         __u64 rq_xid;
224         struct list_head rq_replay_list;
225
226 #if SWAB_PARANOIA
227         __u32 rq_req_swab_mask;
228         __u32 rq_rep_swab_mask;
229 #endif
230
231         int rq_import_generation;
232         enum lustre_imp_state rq_send_state;
233         wait_queue_head_t rq_reply_waitq; /* XXX also _for_ack */
234
235         /* incoming reply */
236         ptl_md_t rq_reply_md;
237         ptl_handle_md_t rq_reply_md_h;
238
239         /* outgoing req/rep */
240         ptl_md_t rq_req_md;
241
242         struct ptlrpc_peer rq_peer; /* XXX see service.c can this be factored away? */
243         struct obd_export *rq_export;
244         struct obd_import *rq_import;
245         struct ptlrpc_service *rq_svc;
246
247         void (*rq_replay_cb)(struct ptlrpc_request *);
248         void (*rq_commit_cb)(struct ptlrpc_request *);
249         void  *rq_cb_data;
250
251         struct ptlrpc_bulk_desc *rq_bulk;       /* client side bulk */
252         time_t rq_sent;                         /* when the request was sent */
253
254         /* Multi-rpc bits */
255         struct list_head rq_set_chain;
256         struct ptlrpc_request_set *rq_set;
257         void *rq_interpret_reply;               /* Async completion handler */
258         union ptlrpc_async_args rq_async_args;  /* Async completion context */
259
260         /* Only used on the server side for tracking acks. */
261         struct ptlrpc_req_ack_lock {
262                 struct lustre_handle lock;
263                 __u32                mode;
264         } rq_ack_locks[REQ_MAX_ACK_LOCKS];
265 };
266
267
268 #define RQ_PHASE_NEW           0xebc0de00
269 #define RQ_PHASE_RPC           0xebc0de01
270 #define RQ_PHASE_BULK          0xebc0de02
271 #define RQ_PHASE_INTERPRET     0xebc0de03
272 #define RQ_PHASE_COMPLETE      0xebc0de04
273
274 /* Spare the preprocessor, spoil the bugs. */
275 #define FLAG(field, str) (field ? str : "")
276
277 #define PTLRPC_REQUEST_COMPLETE(req) ((req)->rq_phase > RQ_PHASE_RPC)
278
279 #define DEBUG_REQ_FLAGS(req)                                                   \
280         ((req->rq_phase == RQ_PHASE_NEW) ? "New" :                             \
281          (req->rq_phase == RQ_PHASE_RPC) ? "RPC" :                             \
282          (req->rq_phase == RQ_PHASE_INTERPRET) ? "Interpret" :                 \
283          (req->rq_phase == RQ_PHASE_COMPLETE) ? "Complete" :                   \
284          (req->rq_phase == RQ_PHASE_BULK) ? "Bulk" : "?phase?"),               \
285         FLAG(req->rq_intr, "I"), FLAG(req->rq_replied, "R"),                   \
286         FLAG(req->rq_want_ack, "A"), FLAG(req->rq_err, "E"),                   \
287         FLAG(req->rq_timedout, "X") /* eXpired */, FLAG(req->rq_resend, "S"),  \
288         FLAG(req->rq_restart, "T"), FLAG(req->rq_replay, "P"),                 \
289         FLAG(req->rq_no_resend, "N"), FLAG(req->rq_resent, "s"),               \
290         FLAG(req->rq_waiting, "W")
291
292 #define REQ_FLAGS_FMT "%s:%s%s%s%s%s%s%s%s%s%s%s"
293
294 #define DEBUG_REQ(level, req, fmt, args...)                                    \
295 do {                                                                           \
296 CDEBUG(level, "@@@ " fmt                                                       \
297        " req@%p x"LPD64"/t"LPD64" o%d->%s@%s:%d lens %d/%d ref %d fl "         \
298        REQ_FLAGS_FMT"/%x/%x rc %x\n" ,  ## args, req, req->rq_xid,             \
299        req->rq_transno,                                                        \
300        req->rq_reqmsg ? req->rq_reqmsg->opc : -1,                              \
301        req->rq_import ? (char *)req->rq_import->imp_target_uuid.uuid : "<?>",  \
302        req->rq_import ?                                                        \
303           (char *)req->rq_import->imp_connection->c_remote_uuid.uuid : "<?>",  \
304        (req->rq_import && req->rq_import->imp_client) ?                        \
305            req->rq_import->imp_client->cli_request_portal : -1,                \
306        req->rq_reqlen, req->rq_replen,                                         \
307        atomic_read(&req->rq_refcount),                                         \
308        DEBUG_REQ_FLAGS(req),                                                   \
309        req->rq_reqmsg ? req->rq_reqmsg->flags : 0,                             \
310        req->rq_repmsg ? req->rq_repmsg->flags : 0,                             \
311        req->rq_status);                                                        \
312 } while (0)
313
314 struct ptlrpc_bulk_page {
315         struct ptlrpc_bulk_desc *bp_desc;
316         struct list_head bp_link;
317         int bp_buflen;
318         int bp_pageoffset;                      /* offset within a page */
319         struct page *bp_page;
320 };
321
322 #define BULK_GET_SOURCE   0
323 #define BULK_PUT_SINK     1
324 #define BULK_GET_SINK     2
325 #define BULK_PUT_SOURCE   3
326
327 struct ptlrpc_bulk_desc {
328         unsigned int bd_complete:1;
329         unsigned int bd_network_rw:1;           /* accessible to the network */
330         unsigned int bd_type:2;                 /* {put,get}{source,sink} */
331         unsigned int bd_registered:1;           /* client side */
332         spinlock_t   bd_lock;                   /* serialise with callback */
333         int bd_import_generation;
334         struct obd_export *bd_export;
335         struct obd_import *bd_import;
336         __u32 bd_portal;
337         struct ptlrpc_request *bd_req;          /* associated request */
338         wait_queue_head_t bd_waitq;             /* server side only WQ */
339         struct list_head bd_page_list;
340         __u32 bd_page_count;
341         __u32 bd_last_xid;
342         
343         ptl_md_t bd_md;
344         ptl_handle_md_t bd_md_h;
345         ptl_handle_me_t bd_me_h;
346
347         int bd_callback_count;                  /* server side callbacks */
348
349 #ifdef __KERNEL__
350         ptl_kiov_t bd_iov[PTL_MD_MAX_IOV];
351 #else
352         struct iovec bd_iov[PTL_MD_MAX_IOV];
353 #endif
354 };
355
356 struct ptlrpc_thread {
357         struct list_head t_link;
358
359         __u32 t_flags;
360         wait_queue_head_t t_ctl_waitq;
361 };
362
363 struct ptlrpc_request_buffer_desc {
364         struct list_head       rqbd_list;
365         struct ptlrpc_srv_ni  *rqbd_srv_ni;
366         ptl_handle_me_t        rqbd_me_h;
367         atomic_t               rqbd_refcount;
368         char                  *rqbd_buffer;
369 };
370
371 /* event queues are per-ni, because one day we may get a hardware
372  * supported NAL that delivers events asynchonously wrt kernel portals
373  * into the eq.
374  */
375 struct ptlrpc_ni { /* Generic interface state */
376         char                   *pni_name;
377         int                     pni_number;
378         ptl_handle_ni_t         pni_ni_h;
379         ptl_handle_eq_t         pni_request_out_eq_h;
380         ptl_handle_eq_t         pni_reply_in_eq_h;
381         ptl_handle_eq_t         pni_reply_out_eq_h;
382         ptl_handle_eq_t         pni_bulk_put_source_eq_h;
383         ptl_handle_eq_t         pni_bulk_put_sink_eq_h;
384         ptl_handle_eq_t         pni_bulk_get_source_eq_h;
385         ptl_handle_eq_t         pni_bulk_get_sink_eq_h;
386 };
387
388 struct ptlrpc_srv_ni {
389         /* Interface-specific service state */
390         struct ptlrpc_service  *sni_service;    /* owning service */
391         struct ptlrpc_ni       *sni_ni;         /* network interface */
392         ptl_handle_eq_t         sni_eq_h;       /* event queue handle */
393         struct list_head        sni_rqbds;      /* all the request buffer descriptors */
394         __u32                   sni_nrqbds;     /* # request buffers */
395         atomic_t                sni_nrqbds_receiving; /* # request buffers posted */
396 };
397
398 struct ptlrpc_service {
399         time_t srv_time;
400         time_t srv_timeout;
401
402         struct list_head srv_ni_list;          /* list of interfaces */
403         __u32            srv_max_req_size;     /* biggest request to receive */
404         __u32            srv_buf_size;         /* # bytes in a request buffer */
405
406         __u32 srv_req_portal;
407         __u32 srv_rep_portal;
408
409         __u32 srv_xid;
410
411         wait_queue_head_t srv_waitq; /* all threads sleep on this */
412
413         spinlock_t srv_lock;
414         struct list_head srv_threads;
415         int (*srv_handler)(struct ptlrpc_request *req);
416         char *srv_name;  /* only statically allocated strings here; we don't clean them */
417         struct proc_dir_entry *srv_procroot;
418         struct lprocfs_stats  *srv_stats;
419
420         int                  srv_interface_rover;
421         struct ptlrpc_srv_ni srv_interfaces[0];
422 };
423
424 typedef int (*svc_handler_t)(struct ptlrpc_request *req);
425
426 /* ptlrpc/events.c */
427 extern struct ptlrpc_ni ptlrpc_interfaces[];
428 extern int              ptlrpc_ninterfaces;
429 extern int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, struct ptlrpc_peer *peer);
430
431 /* ptlrpc/connection.c */
432 void ptlrpc_dump_connections(void);
433 void ptlrpc_readdress_connection(struct ptlrpc_connection *, struct obd_uuid *);
434 struct ptlrpc_connection *ptlrpc_get_connection(struct ptlrpc_peer *peer,
435                                                 struct obd_uuid *uuid);
436 int ptlrpc_put_connection(struct ptlrpc_connection *c);
437 struct ptlrpc_connection *ptlrpc_connection_addref(struct ptlrpc_connection *);
438 void ptlrpc_init_connection(void);
439 void ptlrpc_cleanup_connection(void);
440
441 /* ptlrpc/niobuf.c */
442 int ptlrpc_bulk_put(struct ptlrpc_bulk_desc *);
443 int ptlrpc_bulk_get(struct ptlrpc_bulk_desc *);
444 void ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *bulk);
445 int ptlrpc_register_bulk(struct ptlrpc_request *req);
446 void ptlrpc_unregister_bulk (struct ptlrpc_request *req);
447
448 static inline int ptlrpc_bulk_complete (struct ptlrpc_bulk_desc *desc) 
449 {
450         unsigned long flags;
451         int           rc;
452
453         spin_lock_irqsave (&desc->bd_lock, flags);
454         rc = desc->bd_complete;
455         spin_unlock_irqrestore (&desc->bd_lock, flags);
456         return (rc);
457 }
458
459 int ptlrpc_reply(struct ptlrpc_request *req);
460 int ptlrpc_error(struct ptlrpc_request *req);
461 void ptlrpc_resend_req(struct ptlrpc_request *request);
462 int ptl_send_rpc(struct ptlrpc_request *request);
463 void ptlrpc_link_svc_me(struct ptlrpc_request_buffer_desc *rqbd);
464
465 /* ptlrpc/client.c */
466 void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
467                         struct ptlrpc_client *);
468 void ptlrpc_cleanup_client(struct obd_import *imp);
469 struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid);
470
471 int ptlrpc_queue_wait(struct ptlrpc_request *req);
472 int ptlrpc_replay_req(struct ptlrpc_request *req);
473 void ptlrpc_unregister_reply(struct ptlrpc_request *req);
474 void ptlrpc_restart_req(struct ptlrpc_request *req);
475 void ptlrpc_abort_inflight(struct obd_import *imp);
476
477 struct ptlrpc_request_set *ptlrpc_prep_set(void);
478 int ptlrpc_set_next_timeout(struct ptlrpc_request_set *);
479 int ptlrpc_check_set(struct ptlrpc_request_set *set);
480 int ptlrpc_set_wait(struct ptlrpc_request_set *);
481 int ptlrpc_expired_set(void *data);
482 void ptlrpc_interrupted_set(void *data);
483 void ptlrpc_mark_interrupted(struct ptlrpc_request *req);
484 void ptlrpc_set_destroy(struct ptlrpc_request_set *);
485 void ptlrpc_set_add_req(struct ptlrpc_request_set *, struct ptlrpc_request *);
486 void ptlrpc_set_add_new_req(struct ptlrpc_request_set *,
487                             struct ptlrpc_request *);
488
489 struct ptlrpc_request *ptlrpc_prep_req(struct obd_import *imp, int opcode,
490                                        int count, int *lengths, char **bufs);
491 void ptlrpc_free_req(struct ptlrpc_request *request);
492 void ptlrpc_req_finished(struct ptlrpc_request *request);
493 void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request);
494 struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req);
495 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp (struct ptlrpc_request *req,
496                                                int type, int portal);
497 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_exp(struct ptlrpc_request *req,
498                                               int type, int portal);
499 void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *bulk);
500 int ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
501                           struct page *page, int pageoffset, int len);
502 void ptlrpc_free_bulk_page(struct ptlrpc_bulk_page *page);
503 void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
504                                       struct obd_import *imp);
505 __u64 ptlrpc_next_xid(void);
506
507 /* ptlrpc/service.c */
508 struct ptlrpc_service *
509 ptlrpc_init_svc(__u32 nevents, __u32 nbufs, __u32 bufsize, __u32 max_req_size,
510                 int req_portal, int rep_portal, svc_handler_t, char *name,
511                 struct proc_dir_entry *proc_entry);
512 void ptlrpc_stop_all_threads(struct ptlrpc_service *svc);
513 int ptlrpc_start_n_threads(struct obd_device *dev, struct ptlrpc_service *svc,
514                            int cnt, char *base_name);
515 int ptlrpc_start_thread(struct obd_device *dev, struct ptlrpc_service *svc,
516                         char *name);
517 int ptlrpc_unregister_service(struct ptlrpc_service *service);
518
519 struct ptlrpc_svc_data {
520         char *name;
521         struct ptlrpc_service *svc;
522         struct ptlrpc_thread *thread;
523         struct obd_device *dev;
524 };
525
526 /* ptlrpc/import.c */
527 int ptlrpc_connect_import(struct obd_import *imp, char * new_uuid);
528 int ptlrpc_init_import(struct obd_import *imp);
529 int ptlrpc_disconnect_import(struct obd_import *imp);
530
531 /* ptlrpc/pack_generic.c */
532 int lustre_msg_swabbed(struct lustre_msg *msg);
533 int lustre_pack_request(struct ptlrpc_request *, int count, int *lens,
534                         char **bufs);
535 int lustre_pack_reply(struct ptlrpc_request *, int count, int *lens,
536                       char **bufs);
537 int lustre_msg_size(int count, int *lengths);
538 int lustre_unpack_msg(struct lustre_msg *m, int len);
539 void *lustre_msg_buf(struct lustre_msg *m, int n, int minlen);
540 char *lustre_msg_string (struct lustre_msg *m, int n, int max_len);
541 void *lustre_swab_reqbuf (struct ptlrpc_request *req, int n, int minlen,
542                           void *swabber);
543 void *lustre_swab_repbuf (struct ptlrpc_request *req, int n, int minlen,
544                           void *swabber);
545
546 /* ldlm/ldlm_lib.c */
547 int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf);
548 int client_obd_cleanup(struct obd_device * obddev, int flags);
549 int client_connect_import(struct lustre_handle *conn, struct obd_device *obd,
550                           struct obd_uuid *cluuid);
551 int client_disconnect_export(struct obd_export *exp, int failover);
552
553 /* ptlrpc/pinger.c */
554 int ptlrpc_pinger_add_import(struct obd_import *imp);
555 int ptlrpc_pinger_del_import(struct obd_import *imp);
556
557 /* ptlrpc/ptlrpcd.c */
558 void ptlrpcd_wake(void);
559 void ptlrpcd_add_req(struct ptlrpc_request *req);
560 int ptlrpcd_addref(void);
561 void ptlrpcd_decref(void);
562
563 /* ptlrpc/lproc_ptlrpc.c */
564 #ifdef __KERNEL__
565 void ptlrpc_lprocfs_register_obd(struct obd_device *obddev);
566 void ptlrpc_lprocfs_unregister_obd(struct obd_device *obddev);
567 #else
568 #define ptlrpc_lprocfs_register_obd(param...) do{}while(0)
569 #define ptlrpc_lprocfs_unregister_obd(param...) do{}while(0)
570 #endif
571
572 /* ptlrpc/llog_server.c */
573 struct llog_obd_ctxt;
574 int llog_origin_handle_create(struct ptlrpc_request *req);
575 int llog_origin_handle_next_block(struct ptlrpc_request *req);
576 int llog_origin_handle_read_header(struct ptlrpc_request *req);
577 int llog_origin_handle_close(struct ptlrpc_request *req);
578 int llog_origin_handle_cancel(struct ptlrpc_request *req);
579 int llog_catinfo(struct ptlrpc_request *req);
580
581 /* ptlrpc/llog_client.c */
582 extern struct llog_operations llog_client_ops;
583
584 #endif