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 <libcfs/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>
42 #include <linux/lustre_compat25.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 maxima for bulk I/O
49 * CAVEAT EMPTOR, with multinet (i.e. gateways forwarding between networks)
50 * these limits are system wide and not interface-local. */
51 #define PTLRPC_MAX_BRW_SIZE (1 << 20)
52 #define PTLRPC_MAX_BRW_PAGES 512
54 /* ...reduce to fit... */
57 /* include a cray header here if relevant
58 * NB liblustre SIZE/PAGES is affected too, but it merges contiguous
59 * chunks, so FTTB, it always used contiguous MDs */
61 # include <portals/lib-types.h>
64 #if (defined(PTL_MTU) && (PTL_MTU < PTLRPC_MAX_BRW_SIZE))
65 # undef PTLRPC_MAX_BRW_SIZE
66 # define PTLRPC_MAX_BRW_SIZE PTL_MTU
68 #if (defined(PTL_MD_MAX_IOV) && (PTL_MD_MAX_IOV < PTLRPC_MAX_BRW_PAGES ))
69 # undef PTLRPC_MAX_BRW_PAGES
70 # define PTLRPC_MAX_BRW_PAGES PTL_MD_MAX_IOV
73 /* ...and make consistent... */
75 #if (PTLRPC_MAX_BRW_SIZE > PTLRPC_MAX_BRW_PAGES * PAGE_SIZE)
76 # undef PTLRPC_MAX_BRW_SIZE
77 # define PTLRPC_MAX_BRW_SIZE (PTLRPC_MAX_BRW_PAGES * PAGE_SIZE)
79 # undef PTLRPC_MAX_BRW_PAGES
80 # define PTLRPC_MAX_BRW_PAGES (PTLRPC_MAX_BRW_SIZE / PAGE_SIZE)
83 #if ((PTLRPC_MAX_BRW_PAGES & (PTLRPC_MAX_BRW_PAGES - 1)) != 0)
84 #error "PTLRPC_MAX_BRW_PAGES isn't a power of two"
87 /* Size over which to OBD_VMALLOC() rather than OBD_ALLOC() service request
89 #define SVC_BUF_VMALLOC_THRESHOLD (2*PAGE_SIZE)
91 /* The following constants determine how memory is used to buffer incoming
94 * ?_NBUFS # buffers to allocate when growing the pool
95 * ?_BUFSIZE # bytes in a single request buffer
96 * ?_MAXREQSIZE # maximum request service will receive
98 * When fewer than ?_NBUFS/2 buffers are posted for receive, another chunk
99 * of ?_NBUFS is added to the pool.
101 * Messages larger than ?_MAXREQSIZE are dropped. Request buffers are
102 * considered full when less than ?_MAXREQSIZE is left in them.
105 #define LDLM_NUM_THREADS min(smp_num_cpus * smp_num_cpus * 8, 64)
106 #define LDLM_NBUFS 64
107 #define LDLM_BUFSIZE (8 * 1024)
108 #define LDLM_MAXREQSIZE (5 * 1024)
110 #define MDT_MAX_THREADS 32UL
111 #define MDT_NUM_THREADS max(min_t(unsigned long, num_physpages / 8192, \
112 MDT_MAX_THREADS), 2UL)
113 #define MDS_NBUFS (64 * smp_num_cpus)
114 #define MDS_BUFSIZE (8 * 1024)
115 /* Assume file name length = FNAME_MAX = 256 (true for extN).
116 * path name length = PATH_MAX = 4096
117 * LOV MD size max = EA_MAX = 4000
118 * symlink: FNAME_MAX + PATH_MAX <- largest
119 * link: FNAME_MAX + PATH_MAX (mds_rec_link < mds_rec_create)
120 * rename: FNAME_MAX + FNAME_MAX
121 * open: FNAME_MAX + EA_MAX
123 * MDS_MAXREQSIZE ~= 4736 bytes =
124 * lustre_msg + ldlm_request + mds_body + mds_rec_create + FNAME_MAX + PATH_MAX
126 * Realistic size is about 512 bytes (20 character name + 128 char symlink),
127 * except in the open case where there are a large number of OSTs in a LOV.
129 #define MDS_MAXREQSIZE (5 * 1024)
131 #define OST_MAX_THREADS 36UL
132 #define OST_NUM_THREADS max(min_t(unsigned long, num_physpages / 8192, \
133 OST_MAX_THREADS), 2UL)
134 #define OST_NBUFS (64 * smp_num_cpus)
135 #define OST_BUFSIZE (8 * 1024)
136 /*GSS service parameters*/
137 #define GKS_NBUFS (64 * smp_num_cpus)
138 #define GKS_BUFSIZE (8 * 1024)
139 #define GKT_MAX_THREADS 32UL
140 #define GKT_NUM_THREADS max(min_t(unsigned long, num_physpages / 8192, \
141 GKT_MAX_THREADS), 2UL)
143 #define GKS_MAXREQSIZE (5 * 1024)
146 /* OST_MAXREQSIZE ~= 1640 bytes =
147 * lustre_msg + obdo + 16 * obd_ioobj + 64 * niobuf_remote
149 * - single object with 16 pages is 512 bytes
150 * - OST_MAXREQSIZE must be at least 1 page of cookies plus some spillover
152 #define OST_MAXREQSIZE (5 * 1024)
154 #define PTLBD_NUM_THREADS 4
155 #define PTLBD_NBUFS 64
156 #define PTLBD_BUFSIZE (32 * 1024)
157 #define PTLBD_MAXREQSIZE 1024
160 ptl_process_id_t peer_id;
161 struct ptlrpc_ni *peer_ni;
164 struct ptlrpc_connection {
165 struct list_head c_link;
166 struct ptlrpc_peer c_peer;
167 struct obd_uuid c_remote_uuid;
171 struct ptlrpc_client {
172 __u32 cli_request_portal;
173 __u32 cli_reply_portal;
177 /* state flags of requests */
178 /* XXX only ones left are those used by the bulk descs as well! */
179 #define PTL_RPC_FL_INTR (1 << 0) /* reply wait was interrupted by user */
180 #define PTL_RPC_FL_TIMEOUT (1 << 7) /* request timed out waiting for reply */
182 #define REQ_MAX_ACK_LOCKS 8
184 #define SWAB_PARANOIA 1
186 /* unpacking: assert idx not unpacked already */
187 #define LASSERT_REQSWAB(rq, idx) \
189 LASSERT ((idx) < sizeof ((rq)->rq_req_swab_mask) * 8); \
190 LASSERT (((rq)->rq_req_swab_mask & (1 << (idx))) == 0); \
191 (rq)->rq_req_swab_mask |= (1 << (idx)); \
194 #define LASSERT_REPSWAB(rq, idx) \
196 LASSERT ((idx) < sizeof ((rq)->rq_rep_swab_mask) * 8); \
197 LASSERT (((rq)->rq_rep_swab_mask & (1 << (idx))) == 0); \
198 (rq)->rq_rep_swab_mask |= (1 << (idx)); \
201 /* just looking: assert idx already unpacked */
202 #define LASSERT_REQSWABBED(rq, idx) \
203 LASSERT ((idx) < sizeof ((rq)->rq_req_swab_mask) * 8 && \
204 ((rq)->rq_req_swab_mask & (1 << (idx))) != 0)
206 #define LASSERT_REPSWABBED(rq, idx) \
207 LASSERT ((idx) < sizeof ((rq)->rq_rep_swab_mask) * 8 && \
208 ((rq)->rq_rep_swab_mask & (1 << (idx))) != 0)
210 #define LASSERT_REQSWAB(rq, idx)
211 #define LASSERT_REPSWAB(rq, idx)
212 #define LASSERT_REQSWABBED(rq, idx)
213 #define LASSERT_REPSWABBED(rq, idx)
216 union ptlrpc_async_args {
217 /* Scratchpad for passing args to completion interpreter. Users
218 * cast to the struct of their choosing, and LASSERT that this is
219 * big enough. For _tons_ of context, OBD_ALLOC a struct and store
220 * a pointer to it here. The pointer_arg ensures this struct is at
221 * least big enough for that. */
222 void *pointer_arg[9];
226 struct ptlrpc_request_set;
227 typedef int (*set_interpreter_func)(struct ptlrpc_request_set *, void *, int);
229 struct ptlrpc_request_set {
230 int set_remaining; /* # uncompleted requests */
231 wait_queue_head_t set_waitq;
232 wait_queue_head_t *set_wakeup_ptr;
233 struct list_head set_requests;
234 set_interpreter_func set_interpret; /* completion callback */
235 void *set_arg; /* completion context */
236 /* locked so that any old caller can communicate requests to
237 * the set holder who can then fold them into the lock-free set */
238 spinlock_t set_new_req_lock;
239 struct list_head set_new_requests;
242 struct ptlrpc_bulk_desc;
245 * ptlrpc callback & work item stuff
247 struct ptlrpc_cb_id {
248 void (*cbid_fn)(ptl_event_t *ev); /* specific callback fn */
249 void *cbid_arg; /* additional arg */
253 struct ptlrpc_svcsec;
255 #define RS_MAX_LOCKS 4
258 struct ptlrpc_reply_state {
259 struct ptlrpc_cb_id rs_cb_id;
260 struct list_head rs_list;
261 struct list_head rs_exp_list;
262 struct list_head rs_obd_list;
264 struct list_head rs_debug_list;
266 /* updates to following flag serialised by srv_request_lock */
267 unsigned int rs_difficult:1; /* ACK/commit stuff */
268 unsigned int rs_scheduled:1; /* being handled? */
269 unsigned int rs_scheduled_ever:1; /* any schedule attempts? */
270 unsigned int rs_handled:1; /* been handled yet? */
271 unsigned int rs_on_net:1; /* reply_out_callback pending? */
273 struct ptlrpc_svcsec *rs_svcsec;
274 char *rs_buf; /* backend buffer */
275 int rs_buf_len; /* backend buffer length */
276 char *rs_repbuf; /* will be sent on wire */
277 int rs_repbuf_len; /* max on-wire data length */
278 int rs_repdata_len; /* actual on-wire data length */
279 struct lustre_msg *rs_msg; /* lustre msg pointer */
280 int rs_msg_len; /* length of lustre msg */
284 struct obd_export *rs_export;
285 struct ptlrpc_srv_ni *rs_srv_ni;
286 ptl_handle_md_t rs_md_h;
288 /* locks awaiting client reply ACK */
290 struct lustre_handle rs_locks[RS_MAX_LOCKS];
291 ldlm_mode_t rs_modes[RS_MAX_LOCKS];
292 struct llog_create_locks *rs_llog_locks;
295 struct ptlrpc_request {
296 int rq_type; /* one of PTL_RPC_MSG_* */
297 struct list_head rq_list;
300 /* client-side flags */
301 unsigned int rq_intr:1, rq_replied:1, rq_err:1,
302 rq_timedout:1, rq_resend:1, rq_restart:1, rq_replay:1,
303 rq_no_resend:1, rq_waiting:1, rq_receiving_reply:1,
304 rq_no_delay:1, rq_net_err:1, rq_req_wrapped:1,
305 rq_ptlrpcs_restart:1, rq_ptlrpcs_err:1;
307 /* client-side refcount for SENT race */
308 atomic_t rq_refcount;
310 int rq_request_portal; /* XXX FIXME bug 249 */
311 int rq_reply_portal; /* XXX FIXME bug 249 */
313 /* client-side # reply bytes actually received */
317 struct lustre_msg *rq_reqmsg;
321 struct lustre_msg *rq_repmsg;
324 struct list_head rq_replay_list;
326 struct ptlrpc_cred *rq_cred; /* client side */
327 struct ptlrpc_svcsec *rq_svcsec; /* server side */
328 /* flavor of request, on both client & server */
329 __u32 rq_req_secflvr;
330 /* server side security tracking data, need cleanup */
331 void *rq_svcsec_data; /* server security data */
332 unsigned int rq_remote_realm:1, /* from remote realm */
333 rq_auth_usr_mds:1, /* auth as mds svc cred */
334 rq_auth_usr_oss:1; /* auth as oss svc cred */
338 char *rq_reqbuf; /* backend request buffer */
339 int rq_reqbuf_len; /* backend request buffer length */
340 int rq_reqdata_len; /* actual request data length */
341 char *rq_repbuf; /* backend reply buffer */
342 int rq_repbuf_len; /* backend reply buffer length */
343 int rq_repdata_len; /* actual reply data length, not used yet */
346 __u32 rq_req_swab_mask;
347 __u32 rq_rep_swab_mask;
350 int rq_import_generation;
351 enum lustre_imp_state rq_send_state;
353 /* client+server request */
354 ptl_handle_md_t rq_req_md_h;
355 struct ptlrpc_cb_id rq_req_cbid;
358 struct timeval rq_rpcd_start;
361 struct timeval rq_arrival_time; /* request arrival time */
362 struct ptlrpc_reply_state *rq_reply_state; /* separated reply state */
363 struct ptlrpc_request_buffer_desc *rq_rqbd; /* incoming request buffer */
365 ptl_uid_t rq_uid; /* peer uid, used in MDS only */
368 /* client-only incoming reply */
369 ptl_handle_md_t rq_reply_md_h;
370 wait_queue_head_t rq_reply_waitq;
371 struct ptlrpc_cb_id rq_reply_cbid;
373 struct ptlrpc_peer rq_peer; /* XXX see service.c can this be factored away? */
374 char rq_peerstr[PTL_NALFMT_SIZE];
375 struct obd_export *rq_export;
376 struct obd_import *rq_import;
378 void (*rq_replay_cb)(struct ptlrpc_request *);
379 void (*rq_commit_cb)(struct ptlrpc_request *);
382 struct ptlrpc_bulk_desc *rq_bulk; /* client side bulk */
383 time_t rq_sent; /* when the request was sent */
385 struct ptlrpc_service *rq_svc;
388 struct list_head rq_set_chain;
389 struct ptlrpc_request_set *rq_set;
390 void *rq_interpret_reply; /* Async completion handler */
391 union ptlrpc_async_args rq_async_args; /* Async completion context */
392 void * rq_ptlrpcd_data;
396 #define RQ_PHASE_NEW 0xebc0de00
397 #define RQ_PHASE_RPC 0xebc0de01
398 #define RQ_PHASE_BULK 0xebc0de02
399 #define RQ_PHASE_INTERPRET 0xebc0de03
400 #define RQ_PHASE_COMPLETE 0xebc0de04
402 /* Spare the preprocessor, spoil the bugs. */
403 #define FLAG(field, str) (field ? str : "")
405 #define DEBUG_REQ_FLAGS(req) \
406 ((req->rq_phase == RQ_PHASE_NEW) ? "New" : \
407 (req->rq_phase == RQ_PHASE_RPC) ? "Rpc" : \
408 (req->rq_phase == RQ_PHASE_INTERPRET) ? "Interpret" : \
409 (req->rq_phase == RQ_PHASE_COMPLETE) ? "Complete" : "?phase?"), \
410 FLAG(req->rq_intr, "I"), FLAG(req->rq_replied, "R"), \
411 FLAG(req->rq_err, "E"), \
412 FLAG(req->rq_timedout, "X") /* eXpired */, FLAG(req->rq_resend, "S"), \
413 FLAG(req->rq_restart, "T"), FLAG(req->rq_replay, "P"), \
414 FLAG(req->rq_no_resend, "N"), \
415 FLAG(req->rq_waiting, "W")
417 #define REQ_FLAGS_FMT "%s:%s%s%s%s%s%s%s%s%s"
419 #define DEBUG_REQ(level, req, fmt, args...) \
421 CDEBUG(level, "@@@ " fmt \
422 " req@%p x"LPD64"/t"LPD64" o%d->%s@%s:%d lens %d/%d ref %d fl " \
423 REQ_FLAGS_FMT"/%x/%x rc %d/%d\n" , ## args, req, req->rq_xid, \
425 req->rq_reqmsg ? req->rq_reqmsg->opc : -1, \
426 req->rq_import ? (char *)req->rq_import->imp_target_uuid.uuid : "<?>", \
428 (char *)req->rq_import->imp_connection->c_remote_uuid.uuid : "<?>", \
429 (req->rq_import && req->rq_import->imp_client) ? \
430 req->rq_import->imp_client->cli_request_portal : -1, \
431 req->rq_reqlen, req->rq_replen, \
432 atomic_read(&req->rq_refcount), \
433 DEBUG_REQ_FLAGS(req), \
434 req->rq_reqmsg ? req->rq_reqmsg->flags : 0, \
435 req->rq_repmsg ? req->rq_repmsg->flags : 0, \
436 req->rq_status, req->rq_repmsg ? req->rq_repmsg->status : 0); \
439 struct ptlrpc_bulk_page {
440 struct list_head bp_link;
442 int bp_pageoffset; /* offset within a page */
443 struct page *bp_page;
446 #define BULK_GET_SOURCE 0
447 #define BULK_PUT_SINK 1
448 #define BULK_GET_SINK 2
449 #define BULK_PUT_SOURCE 3
451 struct ptlrpc_bulk_desc {
452 unsigned int bd_success:1; /* completed successfully */
453 unsigned int bd_network_rw:1; /* accessible to the network */
454 unsigned int bd_type:2; /* {put,get}{source,sink} */
455 unsigned int bd_registered:1; /* client side */
456 spinlock_t bd_lock; /* serialise with callback */
457 int bd_import_generation;
458 struct obd_export *bd_export;
459 struct obd_import *bd_import;
461 struct ptlrpc_request *bd_req; /* associated request */
462 wait_queue_head_t bd_waitq; /* server side only WQ */
463 int bd_iov_count; /* # entries in bd_iov */
464 int bd_max_iov; /* allocated size of bd_iov */
465 int bd_nob; /* # bytes covered */
466 int bd_nob_transferred; /* # bytes GOT/PUT */
470 struct ptlrpc_cb_id bd_cbid; /* network callback info */
471 ptl_handle_md_t bd_md_h; /* associated MD */
473 #if (!CRAY_PORTALS && defined(__KERNEL__))
474 ptl_kiov_t bd_iov[0];
476 ptl_md_iovec_t bd_iov[0];
480 struct ptlrpc_thread {
481 struct list_head t_link;
484 wait_queue_head_t t_ctl_waitq;
487 struct ptlrpc_request_buffer_desc {
488 struct list_head rqbd_list;
489 struct ptlrpc_srv_ni *rqbd_srv_ni;
490 ptl_handle_md_t rqbd_md_h;
493 struct ptlrpc_cb_id rqbd_cbid;
494 struct ptlrpc_request rqbd_req;
497 /* event queues are per-ni, because one day we may get a hardware
498 * supported NAL that delivers events asynchonously wrt kernel portals
501 struct ptlrpc_ni { /* Generic interface state */
504 ptl_handle_ni_t pni_ni_h;
505 ptl_handle_eq_t pni_eq_h;
508 struct ptlrpc_srv_ni {
509 /* Interface-specific service state */
510 struct ptlrpc_service *sni_service; /* owning service */
511 struct ptlrpc_ni *sni_ni; /* network interface */
512 struct list_head sni_active_rqbds; /* req buffers receiving */
513 struct list_head sni_active_replies; /* all the active replies */
514 int sni_nrqbd_receiving; /* # posted request buffers */
517 typedef int (*svc_handler_t)(struct ptlrpc_request *req);
519 struct ptlrpc_service {
520 struct list_head srv_list; /* chain thru all services */
521 int srv_max_req_size; /* biggest request to receive */
522 int srv_buf_size; /* size of individual buffers */
523 int srv_nbuf_per_group; /* # buffers to allocate in 1 group */
524 int srv_nbufs; /* total # req buffer descs allocated */
525 int srv_nthreads; /* # running threads */
526 int srv_n_difficult_replies; /* # 'difficult' replies */
527 int srv_n_active_reqs; /* # reqs being served */
528 int srv_rqbd_timeout; /* timeout before re-posting reqs */
529 int srv_watchdog_timeout; /* soft watchdog timeout, in ms */
531 __u32 srv_req_portal;
532 __u32 srv_rep_portal;
534 int srv_n_queued_reqs; /* # reqs waiting to be served */
535 struct list_head srv_request_queue; /* reqs waiting for service */
537 struct list_head srv_idle_rqbds; /* request buffers to be reposted */
539 atomic_t srv_outstanding_replies;
540 struct list_head srv_reply_queue; /* replies waiting for service */
542 wait_queue_head_t srv_waitq; /* all threads sleep on this */
544 struct list_head srv_threads;
545 struct obd_device *srv_obddev;
546 svc_handler_t srv_handler;
548 char *srv_name; /* only statically allocated strings here; we don't clean them */
552 struct proc_dir_entry *srv_procroot;
553 struct lprocfs_stats *srv_stats;
555 struct ptlrpc_srv_ni srv_interfaces[0];
558 static inline char *ptlrpc_peernid2str(struct ptlrpc_peer *p, char *str)
560 LASSERT(p->peer_ni != NULL);
561 return (portals_nid2str(p->peer_ni->pni_number, p->peer_id.nid, str));
564 static inline char *ptlrpc_id2str(struct ptlrpc_peer *p, char *str)
566 LASSERT(p->peer_ni != NULL);
567 return (portals_id2str(p->peer_ni->pni_number, p->peer_id, str));
571 /* ptlrpc/events.c */
572 extern struct ptlrpc_ni ptlrpc_interfaces[];
573 extern int ptlrpc_ninterfaces;
574 extern int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, struct ptlrpc_peer *peer);
575 extern void request_out_callback (ptl_event_t *ev);
576 extern void rawrpc_request_out_callback(ptl_event_t *ev);
577 extern void reply_in_callback(ptl_event_t *ev);
578 extern void client_bulk_callback (ptl_event_t *ev);
579 extern void request_in_callback(ptl_event_t *ev);
580 extern void reply_out_callback(ptl_event_t *ev);
581 extern void server_bulk_callback (ptl_event_t *ev);
582 extern int ptlrpc_default_nal(void);
584 /* ptlrpc/connection.c */
585 void ptlrpc_dump_connections(void);
586 void ptlrpc_readdress_connection(struct ptlrpc_connection *, struct obd_uuid *);
587 struct ptlrpc_connection *ptlrpc_get_connection(struct ptlrpc_peer *peer,
588 struct obd_uuid *uuid);
589 int ptlrpc_put_connection(struct ptlrpc_connection *c);
590 struct ptlrpc_connection *ptlrpc_connection_addref(struct ptlrpc_connection *);
591 void ptlrpc_init_connection(void);
592 void ptlrpc_cleanup_connection(void);
593 extern ptl_pid_t ptl_get_pid(void);
595 /* ptlrpc/niobuf.c */
596 int ptlrpc_start_bulk_transfer(struct ptlrpc_bulk_desc *desc);
597 void ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *desc);
598 int ptlrpc_register_bulk(struct ptlrpc_request *req);
599 void ptlrpc_unregister_bulk (struct ptlrpc_request *req);
601 static inline int ptlrpc_bulk_active (struct ptlrpc_bulk_desc *desc)
606 spin_lock_irqsave (&desc->bd_lock, flags);
607 rc = desc->bd_network_rw;
608 spin_unlock_irqrestore (&desc->bd_lock, flags);
612 int ptlrpc_send_reply(struct ptlrpc_request *req, int);
613 int ptlrpc_reply(struct ptlrpc_request *req);
614 int ptlrpc_error(struct ptlrpc_request *req);
615 void ptlrpc_resend_req(struct ptlrpc_request *request);
616 int ptl_send_rpc(struct ptlrpc_request *request);
617 int ptlrpc_register_rqbd (struct ptlrpc_request_buffer_desc *rqbd);
619 struct ptlrpc_request * ptl_do_rawrpc(struct obd_import *imp,
620 char *reqbuf, int reqbuf_len, int reqlen,
621 char *repbuf, int repbuf_len,
622 int *replenp, int timeout, int *res);
623 int ptl_do_rawrpc_simple(struct obd_import *imp,
624 char *reqbuf, int reqlen,
625 char *repbuf, int *replenp);
626 void rawrpc_req_finished(struct ptlrpc_request *req);
628 /* ptlrpc/client.c */
629 void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
630 struct ptlrpc_client *);
631 void ptlrpc_cleanup_client(struct obd_import *imp);
632 struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid);
635 ptlrpc_client_receiving_reply (struct ptlrpc_request *req)
640 spin_lock_irqsave(&req->rq_lock, flags);
641 rc = req->rq_receiving_reply;
642 spin_unlock_irqrestore(&req->rq_lock, flags);
647 ptlrpc_client_replied (struct ptlrpc_request *req)
652 spin_lock_irqsave(&req->rq_lock, flags);
653 rc = req->rq_replied;
654 spin_unlock_irqrestore(&req->rq_lock, flags);
659 ptlrpc_wake_client_req (struct ptlrpc_request *req)
661 if (req->rq_set == NULL)
662 wake_up(&req->rq_reply_waitq);
664 wake_up(&req->rq_set->set_waitq);
667 int ptlrpc_queue_wait(struct ptlrpc_request *req);
668 int ptlrpc_replay_req(struct ptlrpc_request *req);
669 void ptlrpc_unregister_reply(struct ptlrpc_request *req);
670 void ptlrpc_restart_req(struct ptlrpc_request *req);
671 void ptlrpc_abort_inflight(struct obd_import *imp);
673 struct ptlrpc_request_set *ptlrpc_prep_set(void);
674 int ptlrpc_set_next_timeout(struct ptlrpc_request_set *);
675 int ptlrpc_check_set(struct ptlrpc_request_set *set);
676 int ptlrpc_set_wait(struct ptlrpc_request_set *);
677 int ptlrpc_expired_set(void *data);
678 void ptlrpc_interrupted_set(void *data);
679 void ptlrpc_mark_interrupted(struct ptlrpc_request *req);
680 void ptlrpc_set_destroy(struct ptlrpc_request_set *);
681 void ptlrpc_set_add_req(struct ptlrpc_request_set *, struct ptlrpc_request *);
682 void ptlrpc_set_add_new_req(struct ptlrpc_request_set *,
683 struct ptlrpc_request *);
685 struct ptlrpc_request *ptlrpc_prep_req(struct obd_import *imp, __u32 version,
686 int opcode, int count, int *lengths,
688 void ptlrpc_free_req(struct ptlrpc_request *request);
689 void ptlrpc_req_finished(struct ptlrpc_request *request);
690 void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request);
691 struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req);
692 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp (struct ptlrpc_request *req,
693 int npages, int type, int portal);
694 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_exp(struct ptlrpc_request *req,
695 int npages, int type, int portal);
696 void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *bulk);
697 void ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
698 struct page *page, int pageoffset, int len);
699 void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
700 struct obd_import *imp);
701 __u64 ptlrpc_next_xid(void);
703 /* ptlrpc/service.c */
704 void ptlrpc_require_repack (struct ptlrpc_request *req);
705 void ptlrpc_save_lock (struct ptlrpc_request *req,
706 struct lustre_handle *lock, int mode);
707 void ptlrpc_save_llog_lock (struct ptlrpc_request *req,
708 struct llog_create_locks *lcl);
709 void ptlrpc_commit_replies (struct obd_device *obd);
710 void ptlrpc_schedule_difficult_reply (struct ptlrpc_reply_state *rs);
711 struct ptlrpc_service *ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size,
712 int req_portal, int rep_portal,
713 int watchdog_timeout, /* in ms */
714 svc_handler_t, char *name,
715 struct proc_dir_entry *proc_entry);
716 void ptlrpc_stop_all_threads(struct ptlrpc_service *svc);
717 int ptlrpc_start_n_threads(struct obd_device *dev, struct ptlrpc_service *svc,
718 int cnt, char *base_name);
719 int ptlrpc_start_thread(struct obd_device *dev, struct ptlrpc_service *svc,
721 int ptlrpc_unregister_service(struct ptlrpc_service *service);
722 int liblustre_check_services (void *arg);
723 void ptlrpc_daemonize(void);
726 struct ptlrpc_svc_data {
728 struct ptlrpc_service *svc;
729 struct ptlrpc_thread *thread;
730 struct obd_device *dev;
733 /* ptlrpc/import.c */
734 int ptlrpc_connect_import(struct obd_import *imp, char * new_uuid);
735 int ptlrpc_init_import(struct obd_import *imp);
736 int ptlrpc_disconnect_import(struct obd_import *imp);
737 int ptlrpc_import_recovery_state_machine(struct obd_import *imp);
739 /* ptlrpc/pack_generic.c */
740 int lustre_msg_swabbed(struct lustre_msg *msg);
741 int lustre_msg_check_version(struct lustre_msg *msg, __u32 version);
742 int lustre_secdesc_size(void);
743 void lustre_pack_secdesc(struct ptlrpc_request *req, int size);
744 int lustre_pack_request(struct ptlrpc_request *, int count, int *lens,
746 int lustre_pack_reply(struct ptlrpc_request *, int count, int *lens,
748 void lustre_free_reply_state(struct ptlrpc_reply_state *rs);
749 int lustre_msg_size(int count, int *lengths);
750 int lustre_unpack_msg(struct lustre_msg *m, int len);
751 void *lustre_msg_buf(struct lustre_msg *m, int n, int minlen);
752 char *lustre_msg_string (struct lustre_msg *m, int n, int max_len);
753 void *lustre_swab_buf(struct lustre_msg *, int n, int minlen, void *swabber);
754 void *lustre_swab_reqbuf (struct ptlrpc_request *req, int n, int minlen,
756 void *lustre_swab_repbuf (struct ptlrpc_request *req, int n, int minlen,
759 void lustre_init_msg (struct lustre_msg *msg, int count,
760 int *lens, char **bufs);
761 void *mdc_setattr_pack(struct lustre_msg *msg, int offset,
762 struct mdc_op_data *op_data, struct iattr *iattr,
763 void *ea, int ealen, void *ea2, int ea2len,
764 void *ea3, int ea3len);
765 void *mdc_create_pack(struct lustre_msg *msg, int offset,
766 struct mdc_op_data *op_data, __u32 mode,
767 __u64 rdev, const void *data, int datalen);
768 void *mdc_unlink_pack(struct lustre_msg *msg, int offset,
769 struct mdc_op_data *data);
770 void *mdc_link_pack(struct lustre_msg *msg, int offset,
771 struct mdc_op_data *data);
772 void *mdc_rename_pack(struct lustre_msg *msg, int offset,
773 struct mdc_op_data *data,
774 const char *old, int oldlen,
775 const char *new, int newlen);
776 __u32 mds_pack_open_flags(__u32 flags);
778 /* lustre id helper functions and macros. */
780 void mdc_pack_id(struct lustre_id *id, obd_id ino,
781 __u32 gen, int type, __u64 mds,
786 id->li_fid.lf_id = fid;
787 id->li_fid.lf_group = mds;
789 id->li_stc.u.e3s.l3s_ino = ino;
790 id->li_stc.u.e3s.l3s_gen = gen;
791 id->li_stc.u.e3s.l3s_type = type;
795 (id)->li_stc.u.e3s.l3s_ino
798 (id)->li_stc.u.e3s.l3s_gen
800 #define id_type(id) \
801 (id)->li_stc.u.e3s.l3s_type
806 #define id_group(id) \
807 (id)->li_fid.lf_group
810 #define id_version(id) \
811 (id)->li_fid.lf_version
813 #define id_version(id)
816 #define id_assign_fid(id1, id2) \
817 ((id1)->li_fid = (id2)->li_fid)
819 #define id_assign_stc(id1, id2) \
820 ((id1)->li_stc = (id2)->li_stc)
822 #define id_equal(id1, id2) \
823 (id_ino((id1)) == id_ino((id2)) && \
824 id_gen((id1)) == id_gen((id2)) && \
825 id_fid((id1)) == id_fid((id2)) && \
826 id_group((id1)) == id_group(id2))
828 #define id_equal_fid(id1, id2) \
829 (id_fid((id1)) == id_fid((id2)) && \
830 id_group((id1)) == id_group((id2)))
832 #define id_equal_stc(id1, id2) \
833 (id_ino((id1)) == id_ino((id2)) && \
834 id_gen((id1)) == id_gen((id2)))
836 #define id_le_to_cpu(id) \
838 id_fid((id)) = le64_to_cpu(id_fid((id))); \
839 id_group((id)) = le64_to_cpu(id_group((id))); \
840 /*id_version((id)) = le32_to_cpu(id_version((id)));*/ \
841 id_ino((id)) = le64_to_cpu(id_ino((id))); \
842 id_gen((id)) = le32_to_cpu(id_gen((id))); \
843 id_type((id)) = le32_to_cpu(id_type((id))); \
846 #define id_cpu_to_le(id) \
848 id_fid((id)) = cpu_to_le64(id_fid((id))); \
849 id_group((id)) = cpu_to_le64(id_group((id))); \
850 /*id_version((id)) = cpu_to_le32(id_version((id)));*/ \
851 id_ino((id)) = cpu_to_le64(id_ino((id))); \
852 id_gen((id)) = cpu_to_le32(id_gen((id))); \
853 id_type((id)) = cpu_to_le32(id_type((id))); \
856 /* ldlm/ldlm_lib.c */
857 int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf);
858 int client_obd_cleanup(struct obd_device * obddev, int flags);
859 int client_connect_import(struct lustre_handle *conn, struct obd_device *obd,
860 struct obd_uuid *cluuid,
861 struct obd_connect_data *conn_data,
863 int client_disconnect_export(struct obd_export *exp, unsigned long);
865 int client_import_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
867 int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid);
868 int import_set_conn_priority(struct obd_import *imp, struct obd_uuid *uuid);
871 /* ptlrpc/pinger.c */
872 int ptlrpc_pinger_add_import(struct obd_import *imp);
873 int ptlrpc_pinger_del_import(struct obd_import *imp);
874 int ptlrpc_check_and_wait_suspend(struct ptlrpc_request *req);
876 /* ptlrpc/ptlrpcd.c */
877 void ptlrpcd_wake(struct ptlrpc_request *req);
878 void ptlrpcd_add_req(struct ptlrpc_request *req);
879 int ptlrpcd_addref(void);
880 void ptlrpcd_decref(void);
882 /* ptlrpc/lproc_ptlrpc.c */
884 void ptlrpc_lprocfs_register_obd(struct obd_device *obddev);
885 void ptlrpc_lprocfs_unregister_obd(struct obd_device *obddev);
887 #define ptlrpc_lprocfs_register_obd(param...) do{}while(0)
888 #define ptlrpc_lprocfs_unregister_obd(param...) do{}while(0)
891 /* ptlrpc/llog_server.c */
892 int llog_origin_handle_open(struct ptlrpc_request *req);
893 int llog_origin_handle_prev_block(struct ptlrpc_request *req);
894 int llog_origin_handle_next_block(struct ptlrpc_request *req);
895 int llog_origin_handle_read_header(struct ptlrpc_request *req);
896 int llog_origin_handle_close(struct ptlrpc_request *req);
897 int llog_origin_handle_cancel(struct ptlrpc_request *req);
898 int llog_catinfo(struct ptlrpc_request *req);
900 /* ptlrpc/llog_client.c */
901 extern struct llog_operations llog_client_ops;