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 <linux/lustre_idl.h>
39 #include <linux/lustre_ha.h>
40 #include <linux/lustre_import.h>
41 #include <linux/lprocfs_status.h>
43 /* MD flags we _always_ use */
44 #define PTLRPC_MD_OPTIONS (PTL_MD_EVENT_START_DISABLE | \
45 PTL_MD_LUSTRE_COMPLETION_SEMANTICS)
47 /* Define some large-ish maxima for bulk I/O
48 * CAVEAT EMPTOR, with multinet (i.e. gateways forwarding between networks)
49 * these limits are system wide and not interface-local. */
50 #define PTLRPC_MAX_BRW_SIZE (1 << 20)
51 #define PTLRPC_MAX_BRW_PAGES 512
53 /* ...reduce to fit... */
56 /* include a cray header here if relevant
57 * NB liblustre SIZE/PAGES is affected too, but it merges contiguous
58 * chunks, so FTTB, it always used contiguous MDs */
60 # include <portals/lib-types.h>
63 #if (defined(PTL_MTU) && (PTL_MTU < PTLRPC_MAX_BRW_SIZE))
64 # undef PTLRPC_MAX_BRW_SIZE
65 # define PTLRPC_MAX_BRW_SIZE PTL_MTU
67 #if (defined(PTL_MD_MAX_IOV) && (PTL_MD_MAX_IOV < PTLRPC_MAX_BRW_PAGES ))
68 # undef PTLRPC_MAX_BRW_PAGES
69 # define PTLRPC_MAX_BRW_PAGES PTL_MD_MAX_IOV
72 /* ...and make consistent... */
74 #if (PTLRPC_MAX_BRW_SIZE > PTLRPC_MAX_BRW_PAGES * PAGE_SIZE)
75 # undef PTLRPC_MAX_BRW_SIZE
76 # define PTLRPC_MAX_BRW_SIZE (PTLRPC_MAX_BRW_PAGES * PAGE_SIZE)
78 # undef PTLRPC_MAX_BRW_PAGES
79 # define PTLRPC_MAX_BRW_PAGES (PTLRPC_MAX_BRW_SIZE / PAGE_SIZE)
82 #if ((PTLRPC_MAX_BRW_PAGES & (PTLRPC_MAX_BRW_PAGES - 1)) != 0)
83 #error "PTLRPC_MAX_BRW_PAGES isn't a power of two"
86 /* Size over which to OBD_VMALLOC() rather than OBD_ALLOC() service request
88 #define SVC_BUF_VMALLOC_THRESHOLD (2*PAGE_SIZE)
90 /* The following constants determine how memory is used to buffer incoming
93 * ?_NBUFS # buffers to allocate when growing the pool
94 * ?_BUFSIZE # bytes in a single request buffer
95 * ?_MAXREQSIZE # maximum request service will receive
97 * When fewer than ?_NBUFS/2 buffers are posted for receive, another chunk
98 * of ?_NBUFS is added to the pool.
100 * Messages larger than ?_MAXREQSIZE are dropped. Request buffers are
101 * considered full when less than ?_MAXREQSIZE is left in them.
104 #define LDLM_NUM_THREADS min(smp_num_cpus * smp_num_cpus * 8, 64)
105 #define LDLM_NBUFS 64
106 #define LDLM_BUFSIZE (8 * 1024)
107 #define LDLM_MAXREQSIZE (5 * 1024)
109 #define MDT_MAX_THREADS 32UL
110 #define MDT_NUM_THREADS max(min_t(unsigned long, num_physpages / 8192, \
111 MDT_MAX_THREADS), 2UL)
112 #define MDS_NBUFS (64 * smp_num_cpus)
113 #define MDS_BUFSIZE (8 * 1024)
114 /* Assume file name length = FNAME_MAX = 256 (true for extN).
115 * path name length = PATH_MAX = 4096
116 * LOV MD size max = EA_MAX = 4000
117 * symlink: FNAME_MAX + PATH_MAX <- largest
118 * link: FNAME_MAX + PATH_MAX (mds_rec_link < mds_rec_create)
119 * rename: FNAME_MAX + FNAME_MAX
120 * open: FNAME_MAX + EA_MAX
122 * MDS_MAXREQSIZE ~= 4736 bytes =
123 * lustre_msg + ldlm_request + mds_body + mds_rec_create + FNAME_MAX + PATH_MAX
125 * Realistic size is about 512 bytes (20 character name + 128 char symlink),
126 * except in the open case where there are a large number of OSTs in a LOV.
128 #define MDS_MAXREQSIZE (5 * 1024)
130 #define OST_MAX_THREADS 36UL
131 #define OST_NUM_THREADS max(min_t(unsigned long, num_physpages / 8192, \
132 OST_MAX_THREADS), 2UL)
133 #define OST_NBUFS (64 * smp_num_cpus)
134 #define OST_BUFSIZE (8 * 1024)
135 /* OST_MAXREQSIZE ~= 1640 bytes =
136 * lustre_msg + obdo + 16 * obd_ioobj + 64 * niobuf_remote
138 * - single object with 16 pages is 512 bytes
139 * - OST_MAXREQSIZE must be at least 1 page of cookies plus some spillover
141 #define OST_MAXREQSIZE (5 * 1024)
143 #define PTLBD_NUM_THREADS 4
144 #define PTLBD_NBUFS 64
145 #define PTLBD_BUFSIZE (32 * 1024)
146 #define PTLBD_MAXREQSIZE 1024
151 ptl_process_id_t peer_id;
152 struct ptlrpc_ni *peer_ni;
155 struct ptlrpc_connection {
156 struct list_head c_link;
157 struct ptlrpc_peer c_peer;
158 struct obd_uuid c_remote_uuid;
162 struct ptlrpc_client {
163 __u32 cli_request_portal;
164 __u32 cli_reply_portal;
168 /* state flags of requests */
169 /* XXX only ones left are those used by the bulk descs as well! */
170 #define PTL_RPC_FL_INTR (1 << 0) /* reply wait was interrupted by user */
171 #define PTL_RPC_FL_TIMEOUT (1 << 7) /* request timed out waiting for reply */
173 #define REQ_MAX_ACK_LOCKS 8
175 #define SWAB_PARANOIA 1
177 /* unpacking: assert idx not unpacked already */
178 #define LASSERT_REQSWAB(rq, idx) \
180 LASSERT ((idx) < sizeof ((rq)->rq_req_swab_mask) * 8); \
181 LASSERT (((rq)->rq_req_swab_mask & (1 << (idx))) == 0); \
182 (rq)->rq_req_swab_mask |= (1 << (idx)); \
185 #define LASSERT_REPSWAB(rq, idx) \
187 LASSERT ((idx) < sizeof ((rq)->rq_rep_swab_mask) * 8); \
188 LASSERT (((rq)->rq_rep_swab_mask & (1 << (idx))) == 0); \
189 (rq)->rq_rep_swab_mask |= (1 << (idx)); \
192 /* just looking: assert idx already unpacked */
193 #define LASSERT_REQSWABBED(rq, idx) \
194 LASSERT ((idx) < sizeof ((rq)->rq_req_swab_mask) * 8 && \
195 ((rq)->rq_req_swab_mask & (1 << (idx))) != 0)
197 #define LASSERT_REPSWABBED(rq, idx) \
198 LASSERT ((idx) < sizeof ((rq)->rq_rep_swab_mask) * 8 && \
199 ((rq)->rq_rep_swab_mask & (1 << (idx))) != 0)
201 #define LASSERT_REQSWAB(rq, idx)
202 #define LASSERT_REPSWAB(rq, idx)
203 #define LASSERT_REQSWABBED(rq, idx)
204 #define LASSERT_REPSWABBED(rq, idx)
207 union ptlrpc_async_args {
208 /* Scratchpad for passing args to completion interpreter. Users
209 * cast to the struct of their choosing, and LASSERT that this is
210 * big enough. For _tons_ of context, OBD_ALLOC a struct and store
211 * a pointer to it here. The pointer_arg ensures this struct is at
212 * least big enough for that. */
213 void *pointer_arg[9];
217 struct ptlrpc_request_set;
218 typedef int (*set_interpreter_func)(struct ptlrpc_request_set *, void *, int);
220 struct ptlrpc_request_set {
221 int set_remaining; /* # uncompleted requests */
222 wait_queue_head_t set_waitq;
223 wait_queue_head_t *set_wakeup_ptr;
224 struct list_head set_requests;
225 set_interpreter_func set_interpret; /* completion callback */
226 union ptlrpc_async_args set_args; /* completion context */
227 /* locked so that any old caller can communicate requests to
228 * the set holder who can then fold them into the lock-free set */
229 spinlock_t set_new_req_lock;
230 struct list_head set_new_requests;
233 struct ptlrpc_bulk_desc;
236 * ptlrpc callback & work item stuff
238 struct ptlrpc_cb_id {
239 void (*cbid_fn)(ptl_event_t *ev); /* specific callback fn */
240 void *cbid_arg; /* additional arg */
243 #define RS_MAX_LOCKS 4
246 struct ptlrpc_reply_state {
247 struct ptlrpc_cb_id rs_cb_id;
248 struct list_head rs_list;
249 struct list_head rs_exp_list;
250 struct list_head rs_obd_list;
252 struct list_head rs_debug_list;
254 /* updates to following flag serialised by srv_request_lock */
255 unsigned int rs_difficult:1; /* ACK/commit stuff */
256 unsigned int rs_scheduled:1; /* being handled? */
257 unsigned int rs_scheduled_ever:1; /* any schedule attempts? */
258 unsigned int rs_handled:1; /* been handled yet? */
259 unsigned int rs_on_net:1; /* reply_out_callback pending? */
264 struct obd_export *rs_export;
265 struct ptlrpc_srv_ni *rs_srv_ni;
266 ptl_handle_md_t rs_md_h;
268 /* locks awaiting client reply ACK */
270 struct lustre_handle rs_locks[RS_MAX_LOCKS];
271 ldlm_mode_t rs_modes[RS_MAX_LOCKS];
272 struct llog_create_locks *rs_llog_locks;
274 /* last member: variable sized reply message */
275 struct lustre_msg rs_msg;
278 struct ptlrpc_request {
279 int rq_type; /* one of PTL_RPC_MSG_* */
280 struct list_head rq_list;
283 /* client-side flags */
284 unsigned int rq_intr:1, rq_replied:1, rq_err:1,
285 rq_timedout:1, rq_resend:1, rq_restart:1, rq_replay:1,
286 rq_no_resend:1, rq_waiting:1, rq_receiving_reply:1,
287 rq_no_delay:1, rq_net_err:1;
289 /* client-side refcount for SENT race */
290 atomic_t rq_refcount;
292 int rq_request_portal; /* XXX FIXME bug 249 */
293 int rq_reply_portal; /* XXX FIXME bug 249 */
295 /* client-side # reply bytes actually received */
299 struct lustre_msg *rq_reqmsg;
303 struct lustre_msg *rq_repmsg;
306 struct list_head rq_replay_list;
309 __u32 rq_req_swab_mask;
310 __u32 rq_rep_swab_mask;
313 int rq_import_generation;
314 enum lustre_imp_state rq_send_state;
316 /* client+server request */
317 ptl_handle_md_t rq_req_md_h;
318 struct ptlrpc_cb_id rq_req_cbid;
321 struct timeval rq_rpcd_start;
324 struct timeval rq_arrival_time; /* request arrival time */
325 struct ptlrpc_reply_state *rq_reply_state; /* separated reply state */
326 struct ptlrpc_request_buffer_desc *rq_rqbd; /* incoming request buffer */
328 /* client-only incoming reply */
329 ptl_handle_md_t rq_reply_md_h;
330 wait_queue_head_t rq_reply_waitq;
331 struct ptlrpc_cb_id rq_reply_cbid;
333 struct ptlrpc_peer rq_peer; /* XXX see service.c can this be factored away? */
334 struct obd_export *rq_export;
335 struct obd_import *rq_import;
337 void (*rq_replay_cb)(struct ptlrpc_request *);
338 void (*rq_commit_cb)(struct ptlrpc_request *);
341 struct ptlrpc_bulk_desc *rq_bulk; /* client side bulk */
342 time_t rq_sent; /* when the request was sent */
344 struct ptlrpc_service *rq_svc;
347 struct list_head rq_set_chain;
348 struct ptlrpc_request_set *rq_set;
349 void *rq_interpret_reply; /* Async completion handler */
350 union ptlrpc_async_args rq_async_args; /* Async completion context */
351 void * rq_ptlrpcd_data;
355 #define RQ_PHASE_NEW 0xebc0de00
356 #define RQ_PHASE_RPC 0xebc0de01
357 #define RQ_PHASE_BULK 0xebc0de02
358 #define RQ_PHASE_INTERPRET 0xebc0de03
359 #define RQ_PHASE_COMPLETE 0xebc0de04
361 /* Spare the preprocessor, spoil the bugs. */
362 #define FLAG(field, str) (field ? str : "")
364 #define DEBUG_REQ_FLAGS(req) \
365 ((req->rq_phase == RQ_PHASE_NEW) ? "New" : \
366 (req->rq_phase == RQ_PHASE_RPC) ? "Rpc" : \
367 (req->rq_phase == RQ_PHASE_INTERPRET) ? "Interpret" : \
368 (req->rq_phase == RQ_PHASE_COMPLETE) ? "Complete" : "?phase?"), \
369 FLAG(req->rq_intr, "I"), FLAG(req->rq_replied, "R"), \
370 FLAG(req->rq_err, "E"), \
371 FLAG(req->rq_timedout, "X") /* eXpired */, FLAG(req->rq_resend, "S"), \
372 FLAG(req->rq_restart, "T"), FLAG(req->rq_replay, "P"), \
373 FLAG(req->rq_no_resend, "N"), \
374 FLAG(req->rq_waiting, "W")
376 #define REQ_FLAGS_FMT "%s:%s%s%s%s%s%s%s%s%s"
378 #define DEBUG_REQ(level, req, fmt, args...) \
380 CDEBUG(level, "@@@ " fmt \
381 " req@%p x"LPD64"/t"LPD64" o%d->%s@%s:%d lens %d/%d ref %d fl " \
382 REQ_FLAGS_FMT"/%x/%x rc %d/%d\n" , ## args, req, req->rq_xid, \
384 req->rq_reqmsg ? req->rq_reqmsg->opc : -1, \
385 req->rq_import ? (char *)req->rq_import->imp_target_uuid.uuid : "<?>", \
387 (char *)req->rq_import->imp_connection->c_remote_uuid.uuid : "<?>", \
388 (req->rq_import && req->rq_import->imp_client) ? \
389 req->rq_import->imp_client->cli_request_portal : -1, \
390 req->rq_reqlen, req->rq_replen, \
391 atomic_read(&req->rq_refcount), \
392 DEBUG_REQ_FLAGS(req), \
393 req->rq_reqmsg ? req->rq_reqmsg->flags : 0, \
394 req->rq_repmsg ? req->rq_repmsg->flags : 0, \
395 req->rq_status, req->rq_repmsg ? req->rq_repmsg->status : 0); \
398 struct ptlrpc_bulk_page {
399 struct list_head bp_link;
401 int bp_pageoffset; /* offset within a page */
402 struct page *bp_page;
405 #define BULK_GET_SOURCE 0
406 #define BULK_PUT_SINK 1
407 #define BULK_GET_SINK 2
408 #define BULK_PUT_SOURCE 3
410 struct ptlrpc_bulk_desc {
411 unsigned int bd_success:1; /* completed successfully */
412 unsigned int bd_network_rw:1; /* accessible to the network */
413 unsigned int bd_type:2; /* {put,get}{source,sink} */
414 unsigned int bd_registered:1; /* client side */
415 spinlock_t bd_lock; /* serialise with callback */
416 int bd_import_generation;
417 struct obd_export *bd_export;
418 struct obd_import *bd_import;
420 struct ptlrpc_request *bd_req; /* associated request */
421 wait_queue_head_t bd_waitq; /* server side only WQ */
422 int bd_iov_count; /* # entries in bd_iov */
423 int bd_max_iov; /* allocated size of bd_iov */
424 int bd_nob; /* # bytes covered */
425 int bd_nob_transferred; /* # bytes GOT/PUT */
429 struct ptlrpc_cb_id bd_cbid; /* network callback info */
430 ptl_handle_md_t bd_md_h; /* associated MD */
432 #if (!CRAY_PORTALS && defined(__KERNEL__))
433 ptl_kiov_t bd_iov[0];
435 ptl_md_iovec_t bd_iov[0];
439 struct ptlrpc_thread {
440 struct list_head t_link;
443 wait_queue_head_t t_ctl_waitq;
446 struct ptlrpc_request_buffer_desc {
447 struct list_head rqbd_list;
448 struct ptlrpc_srv_ni *rqbd_srv_ni;
449 ptl_handle_md_t rqbd_md_h;
452 struct ptlrpc_cb_id rqbd_cbid;
453 struct ptlrpc_request rqbd_req;
456 /* event queues are per-ni, because one day we may get a hardware
457 * supported NAL that delivers events asynchonously wrt kernel portals
460 struct ptlrpc_ni { /* Generic interface state */
463 ptl_handle_ni_t pni_ni_h;
464 ptl_handle_eq_t pni_eq_h;
467 struct ptlrpc_srv_ni {
468 /* Interface-specific service state */
469 struct ptlrpc_service *sni_service; /* owning service */
470 struct ptlrpc_ni *sni_ni; /* network interface */
471 struct list_head sni_active_rqbds; /* req buffers receiving */
472 struct list_head sni_active_replies; /* all the active replies */
473 int sni_nrqbd_receiving; /* # posted request buffers */
476 typedef int (*svc_handler_t)(struct ptlrpc_request *req);
478 struct ptlrpc_service {
479 struct list_head srv_list; /* chain thru all services */
480 int srv_max_req_size; /* biggest request to receive */
481 int srv_buf_size; /* size of individual buffers */
482 int srv_nbuf_per_group; /* # buffers to allocate in 1 group */
483 int srv_nbufs; /* total # req buffer descs allocated */
484 int srv_nthreads; /* # running threads */
485 int srv_n_difficult_replies; /* # 'difficult' replies */
486 int srv_n_active_reqs; /* # reqs being served */
487 int srv_rqbd_timeout; /* timeout before re-posting reqs */
489 __u32 srv_req_portal;
490 __u32 srv_rep_portal;
492 int srv_n_queued_reqs; /* # reqs waiting to be served */
493 struct list_head srv_request_queue; /* reqs waiting for service */
495 struct list_head srv_idle_rqbds; /* request buffers to be reposted */
497 atomic_t srv_outstanding_replies;
498 struct list_head srv_reply_queue; /* replies waiting for service */
500 wait_queue_head_t srv_waitq; /* all threads sleep on this */
502 struct list_head srv_threads;
503 struct obd_device *srv_obddev;
504 svc_handler_t srv_handler;
506 char *srv_name; /* only statically allocated strings here; we don't clean them */
510 struct proc_dir_entry *srv_procroot;
511 struct lprocfs_stats *srv_stats;
513 struct ptlrpc_srv_ni srv_interfaces[0];
516 static inline char *ptlrpc_peernid2str(struct ptlrpc_peer *p, char *str)
518 LASSERT(p->peer_ni != NULL);
519 return (portals_nid2str(p->peer_ni->pni_number, p->peer_id.nid, str));
523 static inline char *ptlrpc_id2str(struct ptlrpc_peer *p, char *str)
525 LASSERT(p->peer_ni != NULL);
526 return (portals_id2str(p->peer_ni->pni_number, p->peer_id, str));
530 /* ptlrpc/events.c */
531 extern struct ptlrpc_ni ptlrpc_interfaces[];
532 extern int ptlrpc_ninterfaces;
533 extern int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, struct ptlrpc_peer *peer);
534 extern void request_out_callback (ptl_event_t *ev);
535 extern void reply_in_callback(ptl_event_t *ev);
536 extern void client_bulk_callback (ptl_event_t *ev);
537 extern void request_in_callback(ptl_event_t *ev);
538 extern void reply_out_callback(ptl_event_t *ev);
539 extern void server_bulk_callback (ptl_event_t *ev);
540 extern int ptlrpc_default_nal(void);
542 /* ptlrpc/connection.c */
543 void ptlrpc_dump_connections(void);
544 void ptlrpc_readdress_connection(struct ptlrpc_connection *, struct obd_uuid *);
545 struct ptlrpc_connection *ptlrpc_get_connection(struct ptlrpc_peer *peer,
546 struct obd_uuid *uuid);
547 int ptlrpc_put_connection(struct ptlrpc_connection *c);
548 struct ptlrpc_connection *ptlrpc_connection_addref(struct ptlrpc_connection *);
549 void ptlrpc_init_connection(void);
550 void ptlrpc_cleanup_connection(void);
551 extern ptl_pid_t ptl_get_pid(void);
553 /* ptlrpc/niobuf.c */
554 int ptlrpc_start_bulk_transfer(struct ptlrpc_bulk_desc *desc);
555 void ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *desc);
556 int ptlrpc_register_bulk(struct ptlrpc_request *req);
557 void ptlrpc_unregister_bulk (struct ptlrpc_request *req);
559 static inline int ptlrpc_bulk_active (struct ptlrpc_bulk_desc *desc)
564 spin_lock_irqsave (&desc->bd_lock, flags);
565 rc = desc->bd_network_rw;
566 spin_unlock_irqrestore (&desc->bd_lock, flags);
570 int ptlrpc_send_reply(struct ptlrpc_request *req, int);
571 int ptlrpc_reply(struct ptlrpc_request *req);
572 int ptlrpc_error(struct ptlrpc_request *req);
573 void ptlrpc_resend_req(struct ptlrpc_request *request);
574 int ptl_send_rpc(struct ptlrpc_request *request);
575 int ptlrpc_register_rqbd (struct ptlrpc_request_buffer_desc *rqbd);
577 /* ptlrpc/client.c */
578 void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
579 struct ptlrpc_client *);
580 void ptlrpc_cleanup_client(struct obd_import *imp);
581 struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid);
584 ptlrpc_client_receiving_reply (struct ptlrpc_request *req)
589 spin_lock_irqsave(&req->rq_lock, flags);
590 rc = req->rq_receiving_reply;
591 spin_unlock_irqrestore(&req->rq_lock, flags);
596 ptlrpc_client_replied (struct ptlrpc_request *req)
601 spin_lock_irqsave(&req->rq_lock, flags);
602 rc = req->rq_replied;
603 spin_unlock_irqrestore(&req->rq_lock, flags);
608 ptlrpc_wake_client_req (struct ptlrpc_request *req)
610 if (req->rq_set == NULL)
611 wake_up(&req->rq_reply_waitq);
613 wake_up(&req->rq_set->set_waitq);
616 int ptlrpc_queue_wait(struct ptlrpc_request *req);
617 int ptlrpc_replay_req(struct ptlrpc_request *req);
618 void ptlrpc_unregister_reply(struct ptlrpc_request *req);
619 void ptlrpc_restart_req(struct ptlrpc_request *req);
620 void ptlrpc_abort_inflight(struct obd_import *imp);
622 struct ptlrpc_request_set *ptlrpc_prep_set(void);
623 int ptlrpc_set_next_timeout(struct ptlrpc_request_set *);
624 int ptlrpc_check_set(struct ptlrpc_request_set *set);
625 int ptlrpc_set_wait(struct ptlrpc_request_set *);
626 int ptlrpc_expired_set(void *data);
627 void ptlrpc_interrupted_set(void *data);
628 void ptlrpc_mark_interrupted(struct ptlrpc_request *req);
629 void ptlrpc_set_destroy(struct ptlrpc_request_set *);
630 void ptlrpc_set_add_req(struct ptlrpc_request_set *, struct ptlrpc_request *);
631 void ptlrpc_set_add_new_req(struct ptlrpc_request_set *,
632 struct ptlrpc_request *);
634 struct ptlrpc_request *ptlrpc_prep_req(struct obd_import *imp, __u32 version,
635 int opcode, int count, int *lengths,
637 void ptlrpc_free_req(struct ptlrpc_request *request);
638 void ptlrpc_req_finished(struct ptlrpc_request *request);
639 void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request);
640 struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req);
641 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp (struct ptlrpc_request *req,
642 int npages, int type, int portal);
643 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_exp(struct ptlrpc_request *req,
644 int npages, int type, int portal);
645 void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *bulk);
646 void ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
647 struct page *page, int pageoffset, int len);
648 void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
649 struct obd_import *imp);
650 __u64 ptlrpc_next_xid(void);
652 /* ptlrpc/service.c */
653 void ptlrpc_require_repack (struct ptlrpc_request *req);
654 void ptlrpc_save_lock (struct ptlrpc_request *req,
655 struct lustre_handle *lock, int mode);
656 void ptlrpc_save_llog_lock (struct ptlrpc_request *req,
657 struct llog_create_locks *lcl);
658 void ptlrpc_commit_replies (struct obd_device *obd);
659 void ptlrpc_schedule_difficult_reply (struct ptlrpc_reply_state *rs);
660 struct ptlrpc_service *ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size,
661 int req_portal, int rep_portal,
662 svc_handler_t, char *name,
663 struct proc_dir_entry *proc_entry);
664 void ptlrpc_stop_all_threads(struct ptlrpc_service *svc);
665 int ptlrpc_start_n_threads(struct obd_device *dev, struct ptlrpc_service *svc,
666 int cnt, char *base_name);
667 int ptlrpc_start_thread(struct obd_device *dev, struct ptlrpc_service *svc,
669 int ptlrpc_unregister_service(struct ptlrpc_service *service);
670 int liblustre_check_services (void *arg);
671 void ptlrpc_daemonize(void);
674 struct ptlrpc_svc_data {
676 struct ptlrpc_service *svc;
677 struct ptlrpc_thread *thread;
678 struct obd_device *dev;
681 /* ptlrpc/import.c */
682 int ptlrpc_connect_import(struct obd_import *imp, char * new_uuid);
683 int ptlrpc_init_import(struct obd_import *imp);
684 int ptlrpc_disconnect_import(struct obd_import *imp);
685 int ptlrpc_import_recovery_state_machine(struct obd_import *imp);
687 /* ptlrpc/pack_generic.c */
688 int lustre_msg_swabbed(struct lustre_msg *msg);
689 int lustre_msg_check_version(struct lustre_msg *msg, __u32 version);
690 int lustre_pack_request(struct ptlrpc_request *, int count, int *lens,
692 int lustre_pack_reply(struct ptlrpc_request *, int count, int *lens,
694 void lustre_free_reply_state(struct ptlrpc_reply_state *rs);
695 int lustre_msg_size(int count, int *lengths);
696 int lustre_unpack_msg(struct lustre_msg *m, int len);
697 void *lustre_msg_buf(struct lustre_msg *m, int n, int minlen);
698 char *lustre_msg_string (struct lustre_msg *m, int n, int max_len);
699 void *lustre_swab_buf(struct lustre_msg *, int n, int minlen, void *swabber);
700 void *lustre_swab_reqbuf (struct ptlrpc_request *req, int n, int minlen,
702 void *lustre_swab_repbuf (struct ptlrpc_request *req, int n, int minlen,
705 void lustre_init_msg (struct lustre_msg *msg, int count,
706 int *lens, char **bufs);
707 void *mdc_setattr_pack(struct lustre_msg *msg, int offset,
708 struct mdc_op_data *data, struct iattr *iattr,
709 void *ea, int ealen, void *ea2, int ea2len);
710 void *mdc_create_pack(struct lustre_msg *msg, int offset,
711 struct mdc_op_data *op_data, __u32 mode, __u64 rdev,
712 const void *data, int datalen);
713 void *mdc_unlink_pack(struct lustre_msg *msg, int offset,
714 struct mdc_op_data *data);
715 void *mdc_link_pack(struct lustre_msg *msg, int offset,
716 struct mdc_op_data *data);
717 void *mdc_rename_pack(struct lustre_msg *msg, int offset,
718 struct mdc_op_data *data,
719 const char *old, int oldlen, const char *new, int newlen);
721 /* ldlm/ldlm_lib.c */
722 int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf);
723 int client_obd_cleanup(struct obd_device * obddev, int flags);
724 int client_connect_import(struct lustre_handle *conn, struct obd_device *obd,
725 struct obd_uuid *cluuid, unsigned long);
726 int client_disconnect_export(struct obd_export *exp, int failover);
728 int client_import_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
730 int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid);
731 int import_set_conn_priority(struct obd_import *imp, struct obd_uuid *uuid);
734 /* ptlrpc/pinger.c */
735 int ptlrpc_pinger_add_import(struct obd_import *imp);
736 int ptlrpc_pinger_del_import(struct obd_import *imp);
738 /* ptlrpc/ptlrpcd.c */
739 void ptlrpcd_wake(struct ptlrpc_request *req);
740 void ptlrpcd_add_req(struct ptlrpc_request *req);
741 int ptlrpcd_addref(void);
742 void ptlrpcd_decref(void);
744 /* ptlrpc/lproc_ptlrpc.c */
746 void ptlrpc_lprocfs_register_obd(struct obd_device *obddev);
747 void ptlrpc_lprocfs_unregister_obd(struct obd_device *obddev);
749 #define ptlrpc_lprocfs_register_obd(param...) do{}while(0)
750 #define ptlrpc_lprocfs_unregister_obd(param...) do{}while(0)
753 /* ptlrpc/llog_server.c */
754 int llog_origin_handle_open(struct ptlrpc_request *req);
755 int llog_origin_handle_prev_block(struct ptlrpc_request *req);
756 int llog_origin_handle_next_block(struct ptlrpc_request *req);
757 int llog_origin_handle_read_header(struct ptlrpc_request *req);
758 int llog_origin_handle_close(struct ptlrpc_request *req);
759 int llog_origin_handle_cancel(struct ptlrpc_request *req);
760 int llog_catinfo(struct ptlrpc_request *req);
762 /* ptlrpc/llog_client.c */
763 extern struct llog_operations llog_client_ops;