1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002, 2003 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
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.
27 #include <linux/version.h>
28 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
29 #include <linux/tqueue.h>
31 #include <linux/workqueue.h>
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>
44 /* MD flags we _always_ use */
45 #define PTLRPC_MD_OPTIONS (PTL_MD_EVENT_START_DISABLE | \
46 PTL_MD_LUSTRE_COMPLETION_SEMANTICS)
48 /* Define some large-ish defaults for MTU and MAX_IOV if portals ones
49 * aren't defined (i.e. no limits) or too large */
50 #if (defined(PTL_MTU) && (PTL_MTU <= (1 << 20)))
51 # define PTLRPC_MTU PTL_MTU
53 # define PTLRPC_MTU (1 << 20)
55 #if (defined(PTL_MAX_IOV) && (PTL_MAX_IOV <= 512))
56 # define PTLRPC_MAX_IOV PTL_MAX_IOV
58 # define PTLRPC_MAX_IOV 512
61 /* Define consistent max bulk size/pages */
62 #if (PTLRPC_MTU > PTLRPC_MAX_IOV * PAGE_SIZE)
63 # define PTLRPC_MAX_BRW_PAGES PTLRPC_MAX_IOV
64 # define PTLRPC_MAX_BRW_SIZE (PTLRPC_MAX_IOV * PAGE_SIZE)
66 # define PTLRPC_MAX_BRW_PAGES (PTLRPC_MTU / PAGE_SIZE)
67 # define PTLRPC_MAX_BRW_SIZE PTLRPC_MTU
70 /* Size over which to OBD_VMALLOC() rather than OBD_ALLOC() service request
72 #define SVC_BUF_VMALLOC_THRESHOLD (2*PAGE_SIZE)
74 /* The following constants determine how much memory is devoted to
75 * buffering in the lustre services.
77 * ?_NEVENTS # event queue entries
79 * ?_NBUFS # request buffers
80 * ?_BUFSIZE # bytes in a single request buffer
81 * total memory = ?_NBUFS * ?_BUFSIZE
83 * ?_MAXREQSIZE # maximum request service will receive
84 * messages larger than ?_MAXREQSIZE are dropped.
85 * request buffers are auto-unlinked when less than ?_MAXREQSIZE
89 #define LDLM_NUM_THREADS min(smp_num_cpus * smp_num_cpus * 8, 64)
90 #define LDLM_NBUF_MAX 256UL
91 #define LDLM_BUFSIZE (8 * 1024)
92 #define LDLM_MAXREQSIZE (5 * 1024)
93 #define LDLM_MAXMEM (num_physpages*(PAGE_SIZE/1024))
94 #define LDLM_NBUFS min(LDLM_MAXMEM/LDLM_BUFSIZE, LDLM_NBUF_MAX)
96 #define MDT_MAX_THREADS 32UL
97 #define MDT_NUM_THREADS max(min_t(unsigned long, num_physpages / 8192, \
98 MDT_MAX_THREADS), 2UL)
99 #define MDS_NBUF_MAX 512UL
100 #define MDS_BUFSIZE (8 * 1024)
101 /* Assume file name length = FNAME_MAX = 256 (true for extN).
102 * path name length = PATH_MAX = 4096
103 * LOV MD size max = EA_MAX = 4000
104 * symlink: FNAME_MAX + PATH_MAX <- largest
105 * link: FNAME_MAX + PATH_MAX (mds_rec_link < mds_rec_create)
106 * rename: FNAME_MAX + FNAME_MAX
107 * open: FNAME_MAX + EA_MAX
109 * MDS_MAXREQSIZE ~= 4736 bytes =
110 * lustre_msg + ldlm_request + mds_body + mds_rec_create + FNAME_MAX + PATH_MAX
112 * Realistic size is about 512 bytes (20 character name + 128 char symlink),
113 * except in the open case where there are a large number of OSTs in a LOV.
115 #define MDS_MAXREQSIZE (5 * 1024)
116 #define MDS_MAXMEM (num_physpages*(PAGE_SIZE/128))
117 #define MDS_NBUFS min(MDS_MAXMEM/MDS_BUFSIZE, MDS_NBUF_MAX)
119 #define OST_MAX_THREADS 36UL
120 #define OST_NUM_THREADS max(min_t(unsigned long, num_physpages / 8192, \
121 OST_MAX_THREADS), 2UL)
122 #define OST_NBUF_MAX 5000UL
123 #define OST_BUFSIZE (8 * 1024)
124 /* OST_MAXREQSIZE ~= 1640 bytes =
125 * lustre_msg + obdo + 16 * obd_ioobj + 64 * niobuf_remote
127 * - single object with 16 pages is 512 bytes
128 * - OST_MAXREQSIZE must be at least 1 page of cookies plus some spillover
130 #define OST_MAXREQSIZE (5 * 1024)
131 #define OST_MAXMEM (num_physpages*(PAGE_SIZE/128))
132 #define OST_NBUFS min(OST_MAXMEM/OST_BUFSIZE, OST_NBUF_MAX)
134 #define PTLBD_NUM_THREADS 4
135 #define PTLBD_NBUFS 20
136 #define PTLBD_BUFSIZE (32 * 1024)
137 #define PTLBD_MAXREQSIZE 1024
141 struct ptlrpc_ni *peer_ni;
144 struct ptlrpc_connection {
145 struct list_head c_link;
146 struct ptlrpc_peer c_peer;
147 struct obd_uuid c_remote_uuid;
151 struct ptlrpc_client {
152 __u32 cli_request_portal;
153 __u32 cli_reply_portal;
157 /* state flags of requests */
158 /* XXX only ones left are those used by the bulk descs as well! */
159 #define PTL_RPC_FL_INTR (1 << 0) /* reply wait was interrupted by user */
160 #define PTL_RPC_FL_TIMEOUT (1 << 7) /* request timed out waiting for reply */
162 #define REQ_MAX_ACK_LOCKS 8
164 #define SWAB_PARANOIA 1
166 /* unpacking: assert idx not unpacked already */
167 #define LASSERT_REQSWAB(rq, idx) \
169 LASSERT ((idx) < sizeof ((rq)->rq_req_swab_mask) * 8); \
170 LASSERT (((rq)->rq_req_swab_mask & (1 << (idx))) == 0); \
171 (rq)->rq_req_swab_mask |= (1 << (idx)); \
174 #define LASSERT_REPSWAB(rq, idx) \
176 LASSERT ((idx) < sizeof ((rq)->rq_rep_swab_mask) * 8); \
177 LASSERT (((rq)->rq_rep_swab_mask & (1 << (idx))) == 0); \
178 (rq)->rq_rep_swab_mask |= (1 << (idx)); \
181 /* just looking: assert idx already unpacked */
182 #define LASSERT_REQSWABBED(rq, idx) \
183 LASSERT ((idx) < sizeof ((rq)->rq_req_swab_mask) * 8 && \
184 ((rq)->rq_req_swab_mask & (1 << (idx))) != 0)
186 #define LASSERT_REPSWABBED(rq, idx) \
187 LASSERT ((idx) < sizeof ((rq)->rq_rep_swab_mask) * 8 && \
188 ((rq)->rq_rep_swab_mask & (1 << (idx))) != 0)
190 #define LASSERT_REQSWAB(rq, idx)
191 #define LASSERT_REPSWAB(rq, idx)
192 #define LASSERT_REQSWABBED(rq, idx)
193 #define LASSERT_REPSWABBED(rq, idx)
196 union ptlrpc_async_args {
197 /* Scratchpad for passing args to completion interpreter. Users
198 * cast to the struct of their choosing, and LASSERT that this is
199 * big enough. For _tons_ of context, OBD_ALLOC a struct and store
200 * a pointer to it here. The pointer_arg ensures this struct is at
201 * least big enough for that. */
202 void *pointer_arg[9];
206 struct ptlrpc_request_set;
207 typedef int (*set_interpreter_func)(struct ptlrpc_request_set *, void *, int);
209 struct ptlrpc_request_set {
210 int set_remaining; /* # uncompleted requests */
211 wait_queue_head_t set_waitq;
212 wait_queue_head_t *set_wakeup_ptr;
213 struct list_head set_requests;
214 set_interpreter_func set_interpret; /* completion callback */
215 union ptlrpc_async_args set_args; /* completion context */
216 /* locked so that any old caller can communicate requests to
217 * the set holder who can then fold them into the lock-free set */
218 spinlock_t set_new_req_lock;
219 struct list_head set_new_requests;
222 struct ptlrpc_bulk_desc;
225 * ptlrpc callback & work item stuff
227 struct ptlrpc_cb_id {
228 void (*cbid_fn)(ptl_event_t *ev); /* specific callback fn */
229 void *cbid_arg; /* additional arg */
232 #define RS_MAX_LOCKS 4
235 struct ptlrpc_reply_state {
236 struct ptlrpc_cb_id rs_cb_id;
237 struct list_head rs_list;
238 struct list_head rs_exp_list;
239 struct list_head rs_obd_list;
241 struct list_head rs_debug_list;
243 /* updates to following flag serialised by srv_request_lock */
244 unsigned int rs_difficult:1; /* ACK/commit stuff */
245 unsigned int rs_scheduled:1; /* being handled? */
246 unsigned int rs_scheduled_ever:1; /* any schedule attempts? */
247 unsigned int rs_handled:1; /* been handled yet? */
248 unsigned int rs_on_net:1; /* reply_out_callback pending? */
253 struct obd_export *rs_export;
254 struct ptlrpc_srv_ni *rs_srv_ni;
255 ptl_handle_md_t rs_md_h;
257 /* locks awaiting client reply ACK */
259 struct lustre_handle rs_locks[RS_MAX_LOCKS];
260 ldlm_mode_t rs_modes[RS_MAX_LOCKS];
261 /* last member: variable sized reply message */
262 struct lustre_msg rs_msg;
265 struct ptlrpc_request {
266 int rq_type; /* one of PTL_RPC_MSG_* */
267 struct list_head rq_list;
270 /* client-side flags */
271 unsigned int rq_intr:1, rq_replied:1, rq_err:1,
272 rq_timedout:1, rq_resend:1, rq_restart:1, rq_replay:1,
273 rq_no_resend:1, rq_waiting:1, rq_receiving_reply:1,
276 /* client-side refcount for SENT race */
277 atomic_t rq_refcount;
279 int rq_request_portal; /* XXX FIXME bug 249 */
280 int rq_reply_portal; /* XXX FIXME bug 249 */
282 /* client-side # reply bytes actually received */
286 struct lustre_msg *rq_reqmsg;
290 struct lustre_msg *rq_repmsg;
293 struct list_head rq_replay_list;
296 __u32 rq_req_swab_mask;
297 __u32 rq_rep_swab_mask;
300 int rq_import_generation;
301 enum lustre_imp_state rq_send_state;
303 /* client+server request */
304 ptl_handle_md_t rq_req_md_h;
305 struct ptlrpc_cb_id rq_req_cbid;
308 struct timeval rq_arrival_time; /* request arrival time */
309 struct ptlrpc_reply_state *rq_reply_state; /* separated reply state */
310 struct ptlrpc_request_buffer_desc *rq_rqbd; /* incoming request buffer */
312 /* client-only incoming reply */
313 ptl_handle_md_t rq_reply_md_h;
314 wait_queue_head_t rq_reply_waitq;
315 struct ptlrpc_cb_id rq_reply_cbid;
317 struct ptlrpc_peer rq_peer; /* XXX see service.c can this be factored away? */
318 struct obd_export *rq_export;
319 struct obd_import *rq_import;
321 void (*rq_replay_cb)(struct ptlrpc_request *);
322 void (*rq_commit_cb)(struct ptlrpc_request *);
325 struct ptlrpc_bulk_desc *rq_bulk; /* client side bulk */
326 time_t rq_sent; /* when the request was sent */
329 struct list_head rq_set_chain;
330 struct ptlrpc_request_set *rq_set;
331 void *rq_interpret_reply; /* Async completion handler */
332 union ptlrpc_async_args rq_async_args; /* Async completion context */
333 void * rq_ptlrpcd_data;
337 #define RQ_PHASE_NEW 0xebc0de00
338 #define RQ_PHASE_RPC 0xebc0de01
339 #define RQ_PHASE_BULK 0xebc0de02
340 #define RQ_PHASE_INTERPRET 0xebc0de03
341 #define RQ_PHASE_COMPLETE 0xebc0de04
343 /* Spare the preprocessor, spoil the bugs. */
344 #define FLAG(field, str) (field ? str : "")
346 #define PTLRPC_REQUEST_COMPLETE(req) ((req)->rq_phase > RQ_PHASE_RPC)
348 #define DEBUG_REQ_FLAGS(req) \
349 ((req->rq_phase == RQ_PHASE_NEW) ? "New" : \
350 (req->rq_phase == RQ_PHASE_RPC) ? "Rpc" : \
351 (req->rq_phase == RQ_PHASE_INTERPRET) ? "Interpret" : \
352 (req->rq_phase == RQ_PHASE_COMPLETE) ? "Complete" : "?phase?"), \
353 FLAG(req->rq_intr, "I"), FLAG(req->rq_replied, "R"), \
354 FLAG(req->rq_err, "E"), \
355 FLAG(req->rq_timedout, "X") /* eXpired */, FLAG(req->rq_resend, "S"), \
356 FLAG(req->rq_restart, "T"), FLAG(req->rq_replay, "P"), \
357 FLAG(req->rq_no_resend, "N"), \
358 FLAG(req->rq_waiting, "W")
360 #define REQ_FLAGS_FMT "%s:%s%s%s%s%s%s%s%s%s"
362 #define DEBUG_REQ(level, req, fmt, args...) \
364 CDEBUG(level, "@@@ " fmt \
365 " req@%p x"LPD64"/t"LPD64" o%d->%s@%s:%d lens %d/%d ref %d fl " \
366 REQ_FLAGS_FMT"/%x/%x rc %d/%d\n" , ## args, req, req->rq_xid, \
368 req->rq_reqmsg ? req->rq_reqmsg->opc : -1, \
369 req->rq_import ? (char *)req->rq_import->imp_target_uuid.uuid : "<?>", \
371 (char *)req->rq_import->imp_connection->c_remote_uuid.uuid : "<?>", \
372 (req->rq_import && req->rq_import->imp_client) ? \
373 req->rq_import->imp_client->cli_request_portal : -1, \
374 req->rq_reqlen, req->rq_replen, \
375 atomic_read(&req->rq_refcount), \
376 DEBUG_REQ_FLAGS(req), \
377 req->rq_reqmsg ? req->rq_reqmsg->flags : 0, \
378 req->rq_repmsg ? req->rq_repmsg->flags : 0, \
379 req->rq_status, req->rq_repmsg ? req->rq_repmsg->status : 0); \
382 struct ptlrpc_bulk_page {
383 struct list_head bp_link;
385 int bp_pageoffset; /* offset within a page */
386 struct page *bp_page;
389 #define BULK_GET_SOURCE 0
390 #define BULK_PUT_SINK 1
391 #define BULK_GET_SINK 2
392 #define BULK_PUT_SOURCE 3
394 struct ptlrpc_bulk_desc {
395 unsigned int bd_success:1; /* completed successfully */
396 unsigned int bd_network_rw:1; /* accessible to the network */
397 unsigned int bd_type:2; /* {put,get}{source,sink} */
398 unsigned int bd_registered:1; /* client side */
399 spinlock_t bd_lock; /* serialise with callback */
400 int bd_import_generation;
401 struct obd_export *bd_export;
402 struct obd_import *bd_import;
404 struct ptlrpc_request *bd_req; /* associated request */
405 wait_queue_head_t bd_waitq; /* server side only WQ */
406 int bd_iov_count; /* # entries in bd_iov */
407 int bd_max_iov; /* allocated size of bd_iov */
408 int bd_nob; /* # bytes covered */
409 int bd_nob_transferred; /* # bytes GOT/PUT */
413 struct ptlrpc_cb_id bd_cbid; /* network callback info */
414 ptl_handle_md_t bd_md_h; /* associated MD */
416 #if (!CRAY_PORTALS && defined(__KERNEL__))
417 ptl_kiov_t bd_iov[0];
419 struct iovec bd_iov[0];
423 struct ptlrpc_thread {
424 struct list_head t_link;
427 wait_queue_head_t t_ctl_waitq;
430 struct ptlrpc_request_buffer_desc {
431 struct list_head rqbd_list;
432 struct ptlrpc_srv_ni *rqbd_srv_ni;
433 ptl_handle_md_t rqbd_md_h;
436 struct ptlrpc_cb_id rqbd_cbid;
437 struct ptlrpc_request rqbd_req;
440 /* event queues are per-ni, because one day we may get a hardware
441 * supported NAL that delivers events asynchonously wrt kernel portals
444 struct ptlrpc_ni { /* Generic interface state */
447 ptl_handle_ni_t pni_ni_h;
448 ptl_handle_eq_t pni_eq_h;
451 struct ptlrpc_srv_ni {
452 /* Interface-specific service state */
453 struct ptlrpc_service *sni_service; /* owning service */
454 struct ptlrpc_ni *sni_ni; /* network interface */
455 struct list_head sni_active_rqbds; /* req buffers receiving */
456 struct list_head sni_active_replies; /* all the active replies */
457 int sni_nrqbd_receiving; /* # posted request buffers */
460 typedef int (*svc_handler_t)(struct ptlrpc_request *req);
462 struct ptlrpc_service {
463 struct list_head srv_list; /* chain thru all services */
464 int srv_max_req_size; /* biggest request to receive */
465 int srv_buf_size; /* size of individual buffers */
466 int srv_nbufs; /* total # req buffer descs allocated */
467 int srv_nthreads; /* # running threads */
468 int srv_n_difficult_replies; /* # 'difficult' replies */
469 int srv_n_active_reqs; /* # reqs being served */
470 int srv_rqbd_timeout; /* timeout before re-posting reqs */
472 __u32 srv_req_portal;
473 __u32 srv_rep_portal;
475 int srv_n_queued_reqs; /* # reqs waiting to be served */
476 struct list_head srv_request_queue; /* reqs waiting for service */
478 struct list_head srv_idle_rqbds; /* request buffers to be reposted */
480 atomic_t srv_outstanding_replies;
481 struct list_head srv_reply_queue; /* replies waiting for service */
483 wait_queue_head_t srv_waitq; /* all threads sleep on this */
485 struct list_head srv_threads;
486 struct obd_device *srv_obddev;
487 svc_handler_t srv_handler;
489 char *srv_name; /* only statically allocated strings here; we don't clean them */
493 struct proc_dir_entry *srv_procroot;
494 struct lprocfs_stats *srv_stats;
496 struct ptlrpc_srv_ni srv_interfaces[0];
499 /* ptlrpc/events.c */
500 extern struct ptlrpc_ni ptlrpc_interfaces[];
501 extern int ptlrpc_ninterfaces;
502 extern int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, struct ptlrpc_peer *peer);
503 extern void request_out_callback (ptl_event_t *ev);
504 extern void reply_in_callback(ptl_event_t *ev);
505 extern void client_bulk_callback (ptl_event_t *ev);
506 extern void request_in_callback(ptl_event_t *ev);
507 extern void reply_out_callback(ptl_event_t *ev);
508 extern void server_bulk_callback (ptl_event_t *ev);
510 /* ptlrpc/connection.c */
511 void ptlrpc_dump_connections(void);
512 void ptlrpc_readdress_connection(struct ptlrpc_connection *, struct obd_uuid *);
513 struct ptlrpc_connection *ptlrpc_get_connection(struct ptlrpc_peer *peer,
514 struct obd_uuid *uuid);
515 int ptlrpc_put_connection(struct ptlrpc_connection *c);
516 struct ptlrpc_connection *ptlrpc_connection_addref(struct ptlrpc_connection *);
517 void ptlrpc_init_connection(void);
518 void ptlrpc_cleanup_connection(void);
520 /* ptlrpc/niobuf.c */
521 int ptlrpc_start_bulk_transfer(struct ptlrpc_bulk_desc *desc);
522 void ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *desc);
523 int ptlrpc_register_bulk(struct ptlrpc_request *req);
524 void ptlrpc_unregister_bulk (struct ptlrpc_request *req);
526 static inline int ptlrpc_bulk_active (struct ptlrpc_bulk_desc *desc)
531 spin_lock_irqsave (&desc->bd_lock, flags);
532 rc = desc->bd_network_rw;
533 spin_unlock_irqrestore (&desc->bd_lock, flags);
537 int ptlrpc_send_reply(struct ptlrpc_request *req, int);
538 int ptlrpc_reply(struct ptlrpc_request *req);
539 int ptlrpc_error(struct ptlrpc_request *req);
540 void ptlrpc_resend_req(struct ptlrpc_request *request);
541 int ptl_send_rpc(struct ptlrpc_request *request);
542 int ptlrpc_register_rqbd (struct ptlrpc_request_buffer_desc *rqbd);
544 /* ptlrpc/client.c */
545 void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
546 struct ptlrpc_client *);
547 void ptlrpc_cleanup_client(struct obd_import *imp);
548 struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid);
551 ptlrpc_client_receiving_reply (struct ptlrpc_request *req)
556 spin_lock_irqsave(&req->rq_lock, flags);
557 rc = req->rq_receiving_reply;
558 spin_unlock_irqrestore(&req->rq_lock, flags);
563 ptlrpc_client_replied (struct ptlrpc_request *req)
568 spin_lock_irqsave(&req->rq_lock, flags);
569 rc = req->rq_replied;
570 spin_unlock_irqrestore(&req->rq_lock, flags);
575 ptlrpc_wake_client_req (struct ptlrpc_request *req)
577 if (req->rq_set == NULL)
578 wake_up(&req->rq_reply_waitq);
580 wake_up(&req->rq_set->set_waitq);
583 int ptlrpc_queue_wait(struct ptlrpc_request *req);
584 int ptlrpc_replay_req(struct ptlrpc_request *req);
585 void ptlrpc_unregister_reply(struct ptlrpc_request *req);
586 void ptlrpc_restart_req(struct ptlrpc_request *req);
587 void ptlrpc_abort_inflight(struct obd_import *imp);
589 struct ptlrpc_request_set *ptlrpc_prep_set(void);
590 int ptlrpc_set_next_timeout(struct ptlrpc_request_set *);
591 int ptlrpc_check_set(struct ptlrpc_request_set *set);
592 int ptlrpc_set_wait(struct ptlrpc_request_set *);
593 int ptlrpc_expired_set(void *data);
594 void ptlrpc_interrupted_set(void *data);
595 void ptlrpc_mark_interrupted(struct ptlrpc_request *req);
596 void ptlrpc_set_destroy(struct ptlrpc_request_set *);
597 void ptlrpc_set_add_req(struct ptlrpc_request_set *, struct ptlrpc_request *);
598 void ptlrpc_set_add_new_req(struct ptlrpc_request_set *,
599 struct ptlrpc_request *);
601 struct ptlrpc_request *ptlrpc_prep_req(struct obd_import *imp, int opcode,
602 int count, int *lengths, char **bufs);
603 void ptlrpc_free_req(struct ptlrpc_request *request);
604 void ptlrpc_req_finished(struct ptlrpc_request *request);
605 void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request);
606 struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req);
607 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp (struct ptlrpc_request *req,
608 int npages, int type, int portal);
609 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_exp(struct ptlrpc_request *req,
610 int npages, int type, int portal);
611 void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *bulk);
612 void ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
613 struct page *page, int pageoffset, int len);
614 void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
615 struct obd_import *imp);
616 __u64 ptlrpc_next_xid(void);
618 /* ptlrpc/service.c */
619 void ptlrpc_save_lock (struct ptlrpc_request *req,
620 struct lustre_handle *lock, int mode);
621 void ptlrpc_commit_replies (struct obd_device *obd);
622 void ptlrpc_schedule_difficult_reply (struct ptlrpc_reply_state *rs);
623 struct ptlrpc_service *ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size,
624 int req_portal, int rep_portal,
625 svc_handler_t, char *name,
626 struct proc_dir_entry *proc_entry);
627 void ptlrpc_stop_all_threads(struct ptlrpc_service *svc);
628 int ptlrpc_start_n_threads(struct obd_device *dev, struct ptlrpc_service *svc,
629 int cnt, char *base_name);
630 int ptlrpc_start_thread(struct obd_device *dev, struct ptlrpc_service *svc,
632 int ptlrpc_unregister_service(struct ptlrpc_service *service);
633 int liblustre_check_services (void *arg);
635 struct ptlrpc_svc_data {
637 struct ptlrpc_service *svc;
638 struct ptlrpc_thread *thread;
639 struct obd_device *dev;
642 /* ptlrpc/import.c */
643 int ptlrpc_connect_import(struct obd_import *imp, char * new_uuid);
644 int ptlrpc_init_import(struct obd_import *imp);
645 int ptlrpc_disconnect_import(struct obd_import *imp);
646 int ptlrpc_import_recovery_state_machine(struct obd_import *imp);
648 /* ptlrpc/pack_generic.c */
649 int lustre_msg_swabbed(struct lustre_msg *msg);
650 int lustre_pack_request(struct ptlrpc_request *, int count, int *lens,
652 int lustre_pack_reply(struct ptlrpc_request *, int count, int *lens,
654 void lustre_free_reply_state(struct ptlrpc_reply_state *rs);
655 int lustre_msg_size(int count, int *lengths);
656 int lustre_unpack_msg(struct lustre_msg *m, int len);
657 void *lustre_msg_buf(struct lustre_msg *m, int n, int minlen);
658 char *lustre_msg_string (struct lustre_msg *m, int n, int max_len);
659 void *lustre_swab_buf(struct lustre_msg *, int n, int minlen, void *swabber);
660 void *lustre_swab_reqbuf (struct ptlrpc_request *req, int n, int minlen,
662 void *lustre_swab_repbuf (struct ptlrpc_request *req, int n, int minlen,
665 /* ldlm/ldlm_lib.c */
666 int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf);
667 int client_obd_cleanup(struct obd_device * obddev, int flags);
668 int client_connect_import(struct lustre_handle *conn, struct obd_device *obd,
669 struct obd_uuid *cluuid);
670 int client_disconnect_export(struct obd_export *exp, int failover);
672 /* ptlrpc/pinger.c */
673 int ptlrpc_pinger_add_import(struct obd_import *imp);
674 int ptlrpc_pinger_del_import(struct obd_import *imp);
676 /* ptlrpc/ptlrpcd.c */
677 void ptlrpcd_wake(struct ptlrpc_request *req);
678 void ptlrpcd_add_req(struct ptlrpc_request *req);
679 int ptlrpcd_addref(void);
680 void ptlrpcd_decref(void);
682 /* ptlrpc/lproc_ptlrpc.c */
684 void ptlrpc_lprocfs_register_obd(struct obd_device *obddev);
685 void ptlrpc_lprocfs_unregister_obd(struct obd_device *obddev);
687 #define ptlrpc_lprocfs_register_obd(param...) do{}while(0)
688 #define ptlrpc_lprocfs_unregister_obd(param...) do{}while(0)
691 /* ptlrpc/llog_server.c */
692 int llog_origin_handle_create(struct ptlrpc_request *req);
693 int llog_origin_handle_next_block(struct ptlrpc_request *req);
694 int llog_origin_handle_read_header(struct ptlrpc_request *req);
695 int llog_origin_handle_close(struct ptlrpc_request *req);
696 int llog_origin_handle_cancel(struct ptlrpc_request *req);
697 int llog_catinfo(struct ptlrpc_request *req);
699 /* ptlrpc/llog_client.c */
700 extern struct llog_operations llog_client_ops;