1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
40 #if defined(__linux__)
41 #include <linux/lustre_net.h>
42 #elif defined(__APPLE__)
43 #include <darwin/lustre_net.h>
44 #elif defined(__WINNT__)
45 #include <winnt/lustre_net.h>
47 #error Unsupported operating system.
50 #include <libcfs/libcfs.h>
52 #include <lnet/lnet.h>
53 #include <lustre/lustre_idl.h>
54 #include <lustre_ha.h>
55 #include <lustre_sec.h>
56 #include <lustre_import.h>
57 #include <lprocfs_status.h>
58 #include <lu_object.h>
59 #include <lustre_req_layout.h>
61 #include <obd_support.h>
63 /* MD flags we _always_ use */
64 #define PTLRPC_MD_OPTIONS 0
66 /* Define maxima for bulk I/O
67 * CAVEAT EMPTOR, with multinet (i.e. routers forwarding between networks)
68 * these limits are system wide and not interface-local. */
69 #define PTLRPC_MAX_BRW_BITS LNET_MTU_BITS
70 #define PTLRPC_MAX_BRW_SIZE (1<<LNET_MTU_BITS)
71 #define PTLRPC_MAX_BRW_PAGES (PTLRPC_MAX_BRW_SIZE >> CFS_PAGE_SHIFT)
73 /* When PAGE_SIZE is a constant, we can check our arithmetic here with cpp! */
75 # if ((PTLRPC_MAX_BRW_PAGES & (PTLRPC_MAX_BRW_PAGES - 1)) != 0)
76 # error "PTLRPC_MAX_BRW_PAGES isn't a power of two"
78 # if (PTLRPC_MAX_BRW_SIZE != (PTLRPC_MAX_BRW_PAGES * CFS_PAGE_SIZE))
79 # error "PTLRPC_MAX_BRW_SIZE isn't PTLRPC_MAX_BRW_PAGES * CFS_PAGE_SIZE"
81 # if (PTLRPC_MAX_BRW_SIZE > LNET_MTU)
82 # error "PTLRPC_MAX_BRW_SIZE too big"
84 # if (PTLRPC_MAX_BRW_PAGES > LNET_MAX_IOV)
85 # error "PTLRPC_MAX_BRW_PAGES too big"
87 #endif /* __KERNEL__ */
89 /* Size over which to OBD_VMALLOC() rather than OBD_ALLOC() service request
91 #define SVC_BUF_VMALLOC_THRESHOLD (2 * CFS_PAGE_SIZE)
93 /* The following constants determine how memory is used to buffer incoming
96 * ?_NBUFS # buffers to allocate when growing the pool
97 * ?_BUFSIZE # bytes in a single request buffer
98 * ?_MAXREQSIZE # maximum request service will receive
100 * When fewer than ?_NBUFS/2 buffers are posted for receive, another chunk
101 * of ?_NBUFS is added to the pool.
103 * Messages larger than ?_MAXREQSIZE are dropped. Request buffers are
104 * considered full when less than ?_MAXREQSIZE is left in them.
107 #define LDLM_THREADS_AUTO_MIN \
108 min((int)(num_online_cpus() * num_online_cpus() * 2), 8)
109 #define LDLM_THREADS_AUTO_MAX (LDLM_THREADS_AUTO_MIN * 16)
110 #define LDLM_BL_THREADS LDLM_THREADS_AUTO_MIN
111 #define LDLM_NBUFS (64 * num_online_cpus())
112 #define LDLM_BUFSIZE (8 * 1024)
113 #define LDLM_MAXREQSIZE (5 * 1024)
114 #define LDLM_MAXREPSIZE (1024)
116 #define MDT_MIN_THREADS 2UL
117 #define MDT_MAX_THREADS 512UL
118 #define MDT_NUM_THREADS max(min_t(unsigned long, MDT_MAX_THREADS, \
119 num_physpages >> (25 - CFS_PAGE_SHIFT)), 2UL)
120 #define FLD_NUM_THREADS max(min_t(unsigned long, MDT_MAX_THREADS, \
121 num_physpages >> (25 - CFS_PAGE_SHIFT)), 2UL)
122 #define SEQ_NUM_THREADS max(min_t(unsigned long, MDT_MAX_THREADS, \
123 num_physpages >> (25 - CFS_PAGE_SHIFT)), 2UL)
125 /* Absolute limits */
126 #define MDS_THREADS_MIN 2
127 #define MDS_THREADS_MAX 512
128 #define MDS_THREADS_MIN_READPAGE 2
129 #define MDS_NBUFS (64 * num_online_cpus())
130 #define MDS_BUFSIZE (8 * 1024)
131 /* Assume file name length = FNAME_MAX = 256 (true for ext3).
132 * path name length = PATH_MAX = 4096
133 * LOV MD size max = EA_MAX = 4000
134 * symlink: FNAME_MAX + PATH_MAX <- largest
135 * link: FNAME_MAX + PATH_MAX (mds_rec_link < mds_rec_create)
136 * rename: FNAME_MAX + FNAME_MAX
137 * open: FNAME_MAX + EA_MAX
139 * MDS_MAXREQSIZE ~= 4736 bytes =
140 * lustre_msg + ldlm_request + mds_body + mds_rec_create + FNAME_MAX + PATH_MAX
141 * MDS_MAXREPSIZE ~= 8300 bytes = lustre_msg + llog_header
142 * or, for mds_close() and mds_reint_unlink() on a many-OST filesystem:
143 * = 9210 bytes = lustre_msg + mds_body + 160 * (easize + cookiesize)
145 * Realistic size is about 512 bytes (20 character name + 128 char symlink),
146 * except in the open case where there are a large number of OSTs in a LOV.
148 #define MDS_MAXREQSIZE (5 * 1024)
149 #define MDS_MAXREPSIZE max(9 * 1024, 280 + LOV_MAX_STRIPE_COUNT * 56)
151 /* FLD_MAXREQSIZE == lustre_msg + __u32 padding + ptlrpc_body + opc + md_fld */
152 #define FLD_MAXREQSIZE (160)
154 /* FLD_MAXREPSIZE == lustre_msg + ptlrpc_body + md_fld */
155 #define FLD_MAXREPSIZE (152)
157 /* SEQ_MAXREQSIZE == lustre_msg + __u32 padding + ptlrpc_body + opc + lu_range +
159 #define SEQ_MAXREQSIZE (160)
161 /* SEQ_MAXREPSIZE == lustre_msg + ptlrpc_body + lu_range */
162 #define SEQ_MAXREPSIZE (152)
164 #define MGS_THREADS_AUTO_MIN 2
165 #define MGS_THREADS_AUTO_MAX 32
166 #define MGS_NBUFS (64 * num_online_cpus())
167 #define MGS_BUFSIZE (8 * 1024)
168 #define MGS_MAXREQSIZE (7 * 1024)
169 #define MGS_MAXREPSIZE (9 * 1024)
171 /* Absolute limits */
172 #define OSS_THREADS_MIN 2
173 #define OSS_THREADS_MAX 512
174 #define OST_NBUFS (64 * num_online_cpus())
175 #define OST_BUFSIZE (8 * 1024)
176 /* OST_MAXREQSIZE ~= 4768 bytes =
177 * lustre_msg + obdo + 16 * obd_ioobj + 256 * niobuf_remote
179 * - single object with 16 pages is 512 bytes
180 * - OST_MAXREQSIZE must be at least 1 page of cookies plus some spillover
182 #define OST_MAXREQSIZE (5 * 1024)
183 #define OST_MAXREPSIZE (9 * 1024)
185 /* Macro to hide a typecast. */
186 #define ptlrpc_req_async_args(req) ((void *)&req->rq_async_args)
188 struct ptlrpc_connection {
189 struct hlist_node c_hash;
191 lnet_process_id_t c_peer;
192 struct obd_uuid c_remote_uuid;
196 struct ptlrpc_client {
197 __u32 cli_request_portal;
198 __u32 cli_reply_portal;
202 /* state flags of requests */
203 /* XXX only ones left are those used by the bulk descs as well! */
204 #define PTL_RPC_FL_INTR (1 << 0) /* reply wait was interrupted by user */
205 #define PTL_RPC_FL_TIMEOUT (1 << 7) /* request timed out waiting for reply */
207 #define REQ_MAX_ACK_LOCKS 8
209 union ptlrpc_async_args {
210 /* Scratchpad for passing args to completion interpreter. Users
211 * cast to the struct of their choosing, and LASSERT that this is
212 * big enough. For _tons_ of context, OBD_ALLOC a struct and store
213 * a pointer to it here. The pointer_arg ensures this struct is at
214 * least big enough for that. */
215 void *pointer_arg[9];
219 struct ptlrpc_request_set;
220 typedef int (*set_interpreter_func)(struct ptlrpc_request_set *, void *, int);
222 struct ptlrpc_request_set {
223 int set_remaining; /* # uncompleted requests */
224 cfs_waitq_t set_waitq;
225 cfs_waitq_t *set_wakeup_ptr;
226 struct list_head set_requests;
227 struct list_head set_cblist; /* list of completion callbacks */
228 set_interpreter_func set_interpret; /* completion callback */
229 void *set_arg; /* completion context */
230 /* locked so that any old caller can communicate requests to
231 * the set holder who can then fold them into the lock-free set */
232 spinlock_t set_new_req_lock;
233 struct list_head set_new_requests;
236 struct ptlrpc_set_cbdata {
237 struct list_head psc_item;
238 set_interpreter_func psc_interpret;
242 struct ptlrpc_bulk_desc;
245 * ptlrpc callback & work item stuff
247 struct ptlrpc_cb_id {
248 void (*cbid_fn)(lnet_event_t *ev); /* specific callback fn */
249 void *cbid_arg; /* additional arg */
252 #define RS_MAX_LOCKS 8
255 struct ptlrpc_reply_state {
256 struct ptlrpc_cb_id rs_cb_id;
257 struct list_head rs_list;
258 struct list_head rs_exp_list;
259 struct list_head rs_obd_list;
261 struct list_head rs_debug_list;
263 /* updates to following flag serialised by srv_request_lock */
264 unsigned long rs_difficult:1; /* ACK/commit stuff */
265 unsigned long rs_no_ack:1; /* no ACK, even for
266 difficult requests */
267 unsigned long rs_scheduled:1; /* being handled? */
268 unsigned long rs_scheduled_ever:1;/* any schedule attempts? */
269 unsigned long rs_handled:1; /* been handled yet? */
270 unsigned long rs_on_net:1; /* reply_out_callback pending? */
271 unsigned long rs_prealloc:1; /* rs from prealloc list */
276 struct obd_export *rs_export;
277 struct ptlrpc_service *rs_service;
278 lnet_handle_md_t rs_md_h;
279 atomic_t rs_refcount;
281 struct ptlrpc_svc_ctx *rs_svc_ctx;
282 struct lustre_msg *rs_repbuf; /* wrapper */
283 int rs_repbuf_len; /* wrapper buf length */
284 int rs_repdata_len; /* wrapper msg length */
285 struct lustre_msg *rs_msg; /* reply message */
287 /* locks awaiting client reply ACK */
289 struct lustre_handle rs_locks[RS_MAX_LOCKS];
290 ldlm_mode_t rs_modes[RS_MAX_LOCKS];
293 struct ptlrpc_thread;
296 RQ_PHASE_NEW = 0xebc0de00,
297 RQ_PHASE_RPC = 0xebc0de01,
298 RQ_PHASE_BULK = 0xebc0de02,
299 RQ_PHASE_INTERPRET = 0xebc0de03,
300 RQ_PHASE_COMPLETE = 0xebc0de04,
301 RQ_PHASE_UNREGISTERING = 0xebc0de05,
302 RQ_PHASE_UNDEFINED = 0xebc0de06
305 /** Type of request interpreter call-back */
306 typedef int (*ptlrpc_interpterer_t)(const struct lu_env *env,
307 struct ptlrpc_request *req,
310 struct ptlrpc_request_pool {
312 struct list_head prp_req_list; /* list of ptlrpc_request structs */
314 void (*prp_populate)(struct ptlrpc_request_pool *, int);
321 * Represents remote procedure call.
323 struct ptlrpc_request {
324 int rq_type; /* one of PTL_RPC_MSG_* */
325 struct list_head rq_list;
326 struct list_head rq_timed_list; /* server-side early replies */
327 struct list_head rq_history_list; /* server-side history */
328 __u64 rq_history_seq; /* history sequence # */
331 /* client-side flags are serialized by rq_lock */
332 unsigned long rq_intr:1, rq_replied:1, rq_err:1,
333 rq_timedout:1, rq_resend:1, rq_restart:1,
335 * when ->rq_replay is set, request is kept by the client even
336 * after server commits corresponding transaction. This is
337 * used for operations that require sequence of multiple
338 * requests to be replayed. The only example currently is file
339 * open/close/dw/setattr. When last request in such a sequence
340 * is committed, ->rq_replay is cleared on all requests in the
344 /* this is the last request in the sequence. */
346 rq_no_resend:1, rq_waiting:1, rq_receiving_reply:1,
347 rq_no_delay:1, rq_net_err:1, rq_wait_ctx:1,
348 rq_early:1, rq_must_unlink:1,
349 /* server-side flags */
350 rq_packed_final:1, /* packed final reply */
351 rq_sent_final:1; /* stop sending early replies */
353 enum rq_phase rq_phase; /* one of RQ_PHASE_* */
354 enum rq_phase rq_next_phase; /* one of RQ_PHASE_* to be used next */
355 atomic_t rq_refcount; /* client-side refcount for SENT race,
356 server-side refcounf for multiple replies */
358 struct ptlrpc_thread *rq_svc_thread; /* initial thread servicing req */
360 int rq_request_portal; /* XXX FIXME bug 249 */
361 int rq_reply_portal; /* XXX FIXME bug 249 */
363 int rq_nob_received; /* client-side # reply bytes actually received */
366 struct lustre_msg *rq_reqmsg;
369 struct lustre_msg *rq_repmsg;
372 struct list_head rq_replay_list;
373 struct list_head rq_mod_list;
375 struct ptlrpc_cli_ctx *rq_cli_ctx; /* client's half ctx */
376 struct ptlrpc_svc_ctx *rq_svc_ctx; /* server's half ctx */
377 struct list_head rq_ctx_chain; /* link to waited ctx */
379 struct sptlrpc_flavor rq_flvr; /* client & server */
380 enum lustre_sec_part rq_sp_from;
382 unsigned long /* client/server security flags */
383 rq_ctx_init:1, /* context initiation */
384 rq_ctx_fini:1, /* context destroy */
385 rq_bulk_read:1, /* request bulk read */
386 rq_bulk_write:1, /* request bulk write */
387 /* server authentication flags */
388 rq_auth_gss:1, /* authenticated by gss */
389 rq_auth_remote:1, /* authed as remote user */
390 rq_auth_usr_root:1, /* authed as root */
391 rq_auth_usr_mdt:1, /* authed as mdt */
392 /* security tfm flags */
395 /* doesn't expect reply FIXME */
398 uid_t rq_auth_uid; /* authed uid */
399 uid_t rq_auth_mapped_uid; /* authed uid mapped to */
401 /* (server side), pointed directly into req buffer */
402 struct ptlrpc_user_desc *rq_user_desc;
404 /* early replies go to offset 0, regular replies go after that */
405 unsigned int rq_reply_off;
407 /* various buffer pointers */
408 struct lustre_msg *rq_reqbuf; /* req wrapper */
409 int rq_reqbuf_len; /* req wrapper buf len */
410 int rq_reqdata_len; /* req wrapper msg len */
411 char *rq_repbuf; /* rep buffer */
412 int rq_repbuf_len; /* rep buffer len */
413 struct lustre_msg *rq_repdata; /* rep wrapper msg */
414 int rq_repdata_len; /* rep wrapper msg len */
415 struct lustre_msg *rq_clrbuf; /* only in priv mode */
416 int rq_clrbuf_len; /* only in priv mode */
417 int rq_clrdata_len; /* only in priv mode */
419 __u32 rq_req_swab_mask;
420 __u32 rq_rep_swab_mask;
422 int rq_import_generation;
423 enum lustre_imp_state rq_send_state;
425 int rq_early_count; /* how many early replies (for stats) */
427 /* client+server request */
428 lnet_handle_md_t rq_req_md_h;
429 struct ptlrpc_cb_id rq_req_cbid;
432 struct timeval rq_arrival_time; /* request arrival time */
433 struct ptlrpc_reply_state *rq_reply_state; /* separated reply state */
434 struct ptlrpc_request_buffer_desc *rq_rqbd; /* incoming request buffer*/
436 __u32 rq_uid; /* peer uid, used in MDS only */
439 /* client-only incoming reply */
440 lnet_handle_md_t rq_reply_md_h;
441 cfs_waitq_t rq_reply_waitq;
442 struct ptlrpc_cb_id rq_reply_cbid;
445 lnet_process_id_t rq_peer;
446 struct obd_export *rq_export;
447 struct obd_import *rq_import;
449 void (*rq_replay_cb)(struct ptlrpc_request *);
450 void (*rq_commit_cb)(struct ptlrpc_request *);
453 struct ptlrpc_bulk_desc *rq_bulk;/* client side bulk */
455 /* client outgoing req */
456 time_t rq_sent; /* when request/reply sent (secs), or
457 * time when request should be sent */
459 volatile time_t rq_deadline; /* when request must finish. volatile
460 so that servers' early reply updates to the deadline aren't
461 kept in per-cpu cache */
462 time_t rq_reply_deadline; /* when req reply unlink must finish. */
463 int rq_timeout; /* service time estimate (secs) */
466 struct list_head rq_set_chain;
467 struct ptlrpc_request_set *rq_set;
468 /** Async completion handler */
469 ptlrpc_interpterer_t rq_interpret_reply;
470 union ptlrpc_async_args rq_async_args; /* Async completion context */
471 struct ptlrpc_request_pool *rq_pool; /* Pool if request from
473 struct lu_context rq_session;
476 struct req_capsule rq_pill;
479 static inline void ptlrpc_close_replay_seq(struct ptlrpc_request *req)
481 spin_lock(&req->rq_lock);
483 req->rq_sequence = 1;
484 spin_unlock(&req->rq_lock);
487 static inline void lustre_set_req_swabbed(struct ptlrpc_request *req, int index)
489 LASSERT(index < sizeof(req->rq_req_swab_mask) * 8);
490 LASSERT((req->rq_req_swab_mask & (1 << index)) == 0);
491 req->rq_req_swab_mask |= 1 << index;
494 static inline void lustre_set_rep_swabbed(struct ptlrpc_request *req, int index)
496 LASSERT(index < sizeof(req->rq_rep_swab_mask) * 8);
497 LASSERT((req->rq_rep_swab_mask & (1 << index)) == 0);
498 req->rq_rep_swab_mask |= 1 << index;
501 static inline int lustre_req_swabbed(struct ptlrpc_request *req, int index)
503 LASSERT(index < sizeof(req->rq_req_swab_mask) * 8);
504 return req->rq_req_swab_mask & (1 << index);
507 static inline int lustre_rep_swabbed(struct ptlrpc_request *req, int index)
509 LASSERT(index < sizeof(req->rq_rep_swab_mask) * 8);
510 return req->rq_rep_swab_mask & (1 << index);
513 static inline const char *
514 ptlrpc_phase2str(enum rq_phase phase)
523 case RQ_PHASE_INTERPRET:
525 case RQ_PHASE_COMPLETE:
527 case RQ_PHASE_UNREGISTERING:
528 return "Unregistering";
534 static inline const char *
535 ptlrpc_rqphase2str(struct ptlrpc_request *req)
537 return ptlrpc_phase2str(req->rq_phase);
540 /* Spare the preprocessor, spoil the bugs. */
541 #define FLAG(field, str) (field ? str : "")
543 #define DEBUG_REQ_FLAGS(req) \
544 ptlrpc_rqphase2str(req), \
545 FLAG(req->rq_intr, "I"), FLAG(req->rq_replied, "R"), \
546 FLAG(req->rq_err, "E"), \
547 FLAG(req->rq_timedout, "X") /* eXpired */, FLAG(req->rq_resend, "S"), \
548 FLAG(req->rq_restart, "T"), FLAG(req->rq_replay, "P"), \
549 FLAG(req->rq_no_resend, "N"), \
550 FLAG(req->rq_waiting, "W"), \
551 FLAG(req->rq_wait_ctx, "C")
553 #define REQ_FLAGS_FMT "%s:%s%s%s%s%s%s%s%s%s%s"
555 void _debug_req(struct ptlrpc_request *req, __u32 mask,
556 struct libcfs_debug_msg_data *data, const char *fmt, ...)
557 __attribute__ ((format (printf, 4, 5)));
559 #define debug_req(cdls, level, req, file, func, line, fmt, a...) \
563 if (((level) & D_CANTMASK) != 0 || \
564 ((libcfs_debug & (level)) != 0 && \
565 (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) { \
566 static struct libcfs_debug_msg_data _req_dbg_data = \
567 DEBUG_MSG_DATA_INIT(cdls, DEBUG_SUBSYSTEM, file, func, line); \
568 _debug_req((req), (level), &_req_dbg_data, fmt, ##a); \
572 /* for most callers (level is a constant) this is resolved at compile time */
573 #define DEBUG_REQ(level, req, fmt, args...) \
575 if ((level) & (D_ERROR | D_WARNING)) { \
576 static cfs_debug_limit_state_t cdls; \
577 debug_req(&cdls, level, req, __FILE__, __func__, __LINE__, \
578 "@@@ "fmt" ", ## args); \
580 debug_req(NULL, level, req, __FILE__, __func__, __LINE__, \
581 "@@@ "fmt" ", ## args); \
584 struct ptlrpc_bulk_page {
585 struct list_head bp_link;
587 int bp_pageoffset; /* offset within a page */
588 struct page *bp_page;
591 #define BULK_GET_SOURCE 0
592 #define BULK_PUT_SINK 1
593 #define BULK_GET_SINK 2
594 #define BULK_PUT_SOURCE 3
596 struct ptlrpc_bulk_desc {
597 unsigned long bd_success:1; /* completed successfully */
598 unsigned long bd_network_rw:1; /* accessible to the network */
599 unsigned long bd_type:2; /* {put,get}{source,sink} */
600 unsigned long bd_registered:1; /* client side */
601 spinlock_t bd_lock; /* serialise with callback */
602 int bd_import_generation;
603 struct obd_export *bd_export;
604 struct obd_import *bd_import;
606 struct ptlrpc_request *bd_req; /* associated request */
607 cfs_waitq_t bd_waitq; /* server side only WQ */
608 int bd_iov_count; /* # entries in bd_iov */
609 int bd_max_iov; /* allocated size of bd_iov */
610 int bd_nob; /* # bytes covered */
611 int bd_nob_transferred; /* # bytes GOT/PUT */
615 struct ptlrpc_cb_id bd_cbid; /* network callback info */
616 lnet_handle_md_t bd_md_h; /* associated MD */
617 lnet_nid_t bd_sender; /* stash event::sender */
619 cfs_page_t **bd_enc_pages;
620 #if defined(__KERNEL__)
621 lnet_kiov_t bd_iov[0];
623 lnet_md_iovec_t bd_iov[0];
627 struct ptlrpc_thread {
629 struct list_head t_link; /* active threads in svc->srv_threads */
631 void *t_data; /* thread-private data (preallocated memory) */
634 unsigned int t_id; /* service thread index, from ptlrpc_start_threads */
635 cfs_waitq_t t_ctl_waitq;
636 struct lu_env *t_env;
639 struct ptlrpc_request_buffer_desc {
640 struct list_head rqbd_list;
641 struct list_head rqbd_reqs;
642 struct ptlrpc_service *rqbd_service;
643 lnet_handle_md_t rqbd_md_h;
646 struct ptlrpc_cb_id rqbd_cbid;
647 struct ptlrpc_request rqbd_req;
650 typedef int (*svc_handler_t)(struct ptlrpc_request *req);
651 typedef void (*svcreq_printfn_t)(void *, struct ptlrpc_request *);
653 struct ptlrpc_service {
654 struct list_head srv_list; /* chain thru all services */
655 int srv_max_req_size; /* biggest request to receive */
656 int srv_max_reply_size; /* biggest reply to send */
657 int srv_buf_size; /* size of individual buffers */
658 int srv_nbuf_per_group; /* # buffers to allocate in 1 group */
659 int srv_nbufs; /* total # req buffer descs allocated */
660 int srv_threads_min; /* threads to start at SOW */
661 int srv_threads_max; /* thread upper limit */
662 int srv_threads_started; /* index of last started thread */
663 int srv_threads_running; /* # running threads */
664 int srv_n_difficult_replies; /* # 'difficult' replies */
665 int srv_n_active_reqs; /* # reqs being served */
666 cfs_duration_t srv_rqbd_timeout; /* timeout before re-posting reqs, in tick */
667 int srv_watchdog_factor; /* soft watchdog timeout mutiplier */
668 unsigned srv_cpu_affinity:1; /* bind threads to CPUs */
669 unsigned srv_at_check:1; /* check early replies */
670 unsigned srv_is_stopping:1; /* under unregister_service */
671 cfs_time_t srv_at_checktime; /* debug */
673 __u32 srv_req_portal;
674 __u32 srv_rep_portal;
677 struct adaptive_timeout srv_at_estimate;/* estimated rpc service time */
678 spinlock_t srv_at_lock;
679 struct list_head srv_at_list; /* reqs waiting for replies */
680 cfs_timer_t srv_at_timer; /* early reply timer */
682 int srv_n_queued_reqs; /* # reqs in either of the queues below */
683 struct list_head srv_req_in_queue; /* incoming reqs */
684 struct list_head srv_request_queue; /* reqs waiting for service */
686 struct list_head srv_request_history; /* request history */
687 __u64 srv_request_seq; /* next request sequence # */
688 __u64 srv_request_max_cull_seq; /* highest seq culled from history */
689 svcreq_printfn_t srv_request_history_print_fn; /* service-specific print fn */
691 struct list_head srv_idle_rqbds; /* request buffers to be reposted */
692 struct list_head srv_active_rqbds; /* req buffers receiving */
693 struct list_head srv_history_rqbds; /* request buffer history */
694 int srv_nrqbd_receiving; /* # posted request buffers */
695 int srv_n_history_rqbds; /* # request buffers in history */
696 int srv_max_history_rqbds;/* max # request buffers in history */
698 atomic_t srv_outstanding_replies;
699 struct list_head srv_active_replies; /* all the active replies */
700 struct list_head srv_reply_queue; /* replies waiting for service */
702 cfs_waitq_t srv_waitq; /* all threads sleep on this. This
703 * wait-queue is signalled when new
704 * incoming request arrives and when
705 * difficult reply has to be handled. */
707 struct list_head srv_threads; /* service thread list */
708 svc_handler_t srv_handler;
710 char *srv_name; /* only statically allocated strings here; we don't clean them */
711 char *srv_thread_name; /* only statically allocated strings here; we don't clean them */
715 cfs_proc_dir_entry_t *srv_procroot;
716 struct lprocfs_stats *srv_stats;
718 /* List of free reply_states */
719 struct list_head srv_free_rs_list;
720 /* waitq to run, when adding stuff to srv_free_rs_list */
721 cfs_waitq_t srv_free_rs_waitq;
724 * Tags for lu_context associated with this thread, see struct
729 * if non-NULL called during thread creation (ptlrpc_start_thread())
730 * to initialize service specific per-thread state.
732 int (*srv_init)(struct ptlrpc_thread *thread);
734 * if non-NULL called during thread shutdown (ptlrpc_main()) to
735 * destruct state created by ->srv_init().
737 void (*srv_done)(struct ptlrpc_thread *thread);
739 //struct ptlrpc_srv_ni srv_interfaces[0];
744 * Ptlrpc thread control flags (LIOD_START, LIOD_STOP, LIOD_STOP_FORCE)
746 unsigned long pc_flags;
748 * Thread lock protecting structure fields.
754 struct completion pc_starting;
758 struct completion pc_finishing;
760 * Thread requests set.
762 struct ptlrpc_request_set *pc_set;
764 * Thread name used in cfs_daemonize()
768 * Environment for request interpreters to run in.
770 struct lu_env pc_env;
773 * Async rpcs flag to make sure that ptlrpcd_check() is called only
778 * Currently not used.
782 * User-space async rpcs callback.
784 void *pc_wait_callback;
786 * User-space check idle rpcs callback.
788 void *pc_idle_callback;
792 /* Bits for pc_flags */
793 enum ptlrpcd_ctl_flags {
795 * Ptlrpc thread start flag.
799 * Ptlrpc thread stop flag.
803 * Ptlrpc thread stop force flag. This will cause also
804 * aborting any inflight rpcs handled by thread.
806 LIOD_STOP_FORCE = 1 << 2,
808 * This is a recovery ptlrpc thread.
810 LIOD_RECOVERY = 1 << 3
813 /* ptlrpc/events.c */
814 extern lnet_handle_eq_t ptlrpc_eq_h;
815 extern int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
816 lnet_process_id_t *peer, lnet_nid_t *self);
817 extern void request_out_callback (lnet_event_t *ev);
818 extern void reply_in_callback(lnet_event_t *ev);
819 extern void client_bulk_callback (lnet_event_t *ev);
820 extern void request_in_callback(lnet_event_t *ev);
821 extern void reply_out_callback(lnet_event_t *ev);
822 extern void server_bulk_callback (lnet_event_t *ev);
824 /* ptlrpc/connection.c */
825 struct ptlrpc_connection *ptlrpc_connection_get(lnet_process_id_t peer,
827 struct obd_uuid *uuid);
828 int ptlrpc_connection_put(struct ptlrpc_connection *c);
829 struct ptlrpc_connection *ptlrpc_connection_addref(struct ptlrpc_connection *);
830 int ptlrpc_connection_init(void);
831 void ptlrpc_connection_fini(void);
832 extern lnet_pid_t ptl_get_pid(void);
834 /* ptlrpc/niobuf.c */
835 int ptlrpc_start_bulk_transfer(struct ptlrpc_bulk_desc *desc);
836 void ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *desc);
837 int ptlrpc_register_bulk(struct ptlrpc_request *req);
838 void ptlrpc_unregister_bulk (struct ptlrpc_request *req);
840 static inline int ptlrpc_bulk_active (struct ptlrpc_bulk_desc *desc)
844 spin_lock(&desc->bd_lock);
845 rc = desc->bd_network_rw;
846 spin_unlock(&desc->bd_lock);
850 #define PTLRPC_REPLY_MAYBE_DIFFICULT 0x01
851 #define PTLRPC_REPLY_EARLY 0x02
852 int ptlrpc_send_reply(struct ptlrpc_request *req, int flags);
853 int ptlrpc_reply(struct ptlrpc_request *req);
854 int ptlrpc_send_error(struct ptlrpc_request *req, int difficult);
855 int ptlrpc_error(struct ptlrpc_request *req);
856 void ptlrpc_resend_req(struct ptlrpc_request *request);
857 int ptlrpc_at_get_net_latency(struct ptlrpc_request *req);
858 int ptl_send_rpc(struct ptlrpc_request *request, int noreply);
859 int ptlrpc_register_rqbd (struct ptlrpc_request_buffer_desc *rqbd);
861 /* ptlrpc/client.c */
862 void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
863 struct ptlrpc_client *);
864 void ptlrpc_cleanup_client(struct obd_import *imp);
865 struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid);
867 int ptlrpc_queue_wait(struct ptlrpc_request *req);
868 int ptlrpc_replay_req(struct ptlrpc_request *req);
869 int ptlrpc_unregister_reply(struct ptlrpc_request *req, int async);
870 void ptlrpc_restart_req(struct ptlrpc_request *req);
871 void ptlrpc_abort_inflight(struct obd_import *imp);
872 void ptlrpc_abort_set(struct ptlrpc_request_set *set);
874 struct ptlrpc_request_set *ptlrpc_prep_set(void);
875 int ptlrpc_set_add_cb(struct ptlrpc_request_set *set,
876 set_interpreter_func fn, void *data);
877 int ptlrpc_set_next_timeout(struct ptlrpc_request_set *);
878 int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set);
879 int ptlrpc_set_wait(struct ptlrpc_request_set *);
880 int ptlrpc_expired_set(void *data);
881 void ptlrpc_interrupted_set(void *data);
882 void ptlrpc_mark_interrupted(struct ptlrpc_request *req);
883 void ptlrpc_set_destroy(struct ptlrpc_request_set *);
884 void ptlrpc_set_add_req(struct ptlrpc_request_set *, struct ptlrpc_request *);
885 int ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc,
886 struct ptlrpc_request *req);
888 void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool);
889 void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq);
891 struct ptlrpc_request_pool *
892 ptlrpc_init_rq_pool(int, int,
893 void (*populate_pool)(struct ptlrpc_request_pool *, int));
895 void ptlrpc_at_set_req_timeout(struct ptlrpc_request *req);
896 struct ptlrpc_request *ptlrpc_request_alloc(struct obd_import *imp,
897 const struct req_format *format);
898 struct ptlrpc_request *ptlrpc_request_alloc_pool(struct obd_import *imp,
899 struct ptlrpc_request_pool *,
900 const struct req_format *format);
901 void ptlrpc_request_free(struct ptlrpc_request *request);
902 int ptlrpc_request_pack(struct ptlrpc_request *request,
903 __u32 version, int opcode);
904 struct ptlrpc_request *ptlrpc_request_alloc_pack(struct obd_import *imp,
905 const struct req_format *format,
906 __u32 version, int opcode);
907 int ptlrpc_request_bufs_pack(struct ptlrpc_request *request,
908 __u32 version, int opcode, char **bufs,
909 struct ptlrpc_cli_ctx *ctx);
910 struct ptlrpc_request *ptlrpc_prep_req(struct obd_import *imp, __u32 version,
911 int opcode, int count, __u32 *lengths,
913 struct ptlrpc_request *ptlrpc_prep_req_pool(struct obd_import *imp,
914 __u32 version, int opcode,
915 int count, __u32 *lengths, char **bufs,
916 struct ptlrpc_request_pool *pool);
917 void ptlrpc_req_finished(struct ptlrpc_request *request);
918 void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request);
919 struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req);
920 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp (struct ptlrpc_request *req,
921 int npages, int type, int portal);
922 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_exp(struct ptlrpc_request *req,
923 int npages, int type, int portal);
924 void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *bulk);
925 void ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
926 cfs_page_t *page, int pageoffset, int len);
927 void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
928 struct obd_import *imp);
929 __u64 ptlrpc_next_xid(void);
930 __u64 ptlrpc_sample_next_xid(void);
931 __u64 ptlrpc_req_xid(struct ptlrpc_request *request);
933 struct ptlrpc_service_conf {
936 int psc_max_req_size;
937 int psc_max_reply_size;
940 int psc_watchdog_factor;
946 /* ptlrpc/service.c */
947 void ptlrpc_save_lock (struct ptlrpc_request *req,
948 struct lustre_handle *lock, int mode, int no_ack);
949 void ptlrpc_commit_replies (struct obd_device *obd);
950 void ptlrpc_schedule_difficult_reply (struct ptlrpc_reply_state *rs);
951 struct ptlrpc_service *ptlrpc_init_svc_conf(struct ptlrpc_service_conf *c,
952 svc_handler_t h, char *name,
953 struct proc_dir_entry *proc_entry,
954 svcreq_printfn_t prntfn,
957 struct ptlrpc_service *ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size,
959 int req_portal, int rep_portal,
961 svc_handler_t, char *name,
962 cfs_proc_dir_entry_t *proc_entry,
964 int min_threads, int max_threads,
965 char *threadname, __u32 ctx_tags);
966 void ptlrpc_stop_all_threads(struct ptlrpc_service *svc);
968 int ptlrpc_start_threads(struct obd_device *dev, struct ptlrpc_service *svc);
969 int ptlrpc_start_thread(struct obd_device *dev, struct ptlrpc_service *svc);
970 int ptlrpc_unregister_service(struct ptlrpc_service *service);
971 int liblustre_check_services (void *arg);
972 void ptlrpc_daemonize(char *name);
973 int ptlrpc_service_health_check(struct ptlrpc_service *);
976 struct ptlrpc_svc_data {
978 struct ptlrpc_service *svc;
979 struct ptlrpc_thread *thread;
980 struct obd_device *dev;
983 /* ptlrpc/import.c */
984 int ptlrpc_connect_import(struct obd_import *imp, char * new_uuid);
985 int ptlrpc_init_import(struct obd_import *imp);
986 int ptlrpc_disconnect_import(struct obd_import *imp, int noclose);
987 int ptlrpc_import_recovery_state_machine(struct obd_import *imp);
989 /* ptlrpc/pack_generic.c */
990 int ptlrpc_reconnect_import(struct obd_import *imp);
991 int lustre_msg_swabbed(struct lustre_msg *msg);
992 int lustre_msg_check_version(struct lustre_msg *msg, __u32 version);
993 void lustre_init_msg_v2(struct lustre_msg_v2 *msg, int count, __u32 *lens,
995 int lustre_pack_request(struct ptlrpc_request *, __u32 magic, int count,
996 __u32 *lens, char **bufs);
997 int lustre_pack_reply(struct ptlrpc_request *, int count, __u32 *lens,
999 int lustre_pack_reply_v2(struct ptlrpc_request *req, int count,
1000 __u32 *lens, char **bufs, int flags);
1001 #define LPRFL_EARLY_REPLY 1
1002 int lustre_pack_reply_flags(struct ptlrpc_request *, int count, __u32 *lens,
1003 char **bufs, int flags);
1004 int lustre_shrink_msg(struct lustre_msg *msg, int segment,
1005 unsigned int newlen, int move_data);
1006 void lustre_free_reply_state(struct ptlrpc_reply_state *rs);
1007 int lustre_msg_hdr_size(__u32 magic, int count);
1008 int lustre_msg_size(__u32 magic, int count, __u32 *lengths);
1009 int lustre_msg_size_v2(int count, __u32 *lengths);
1010 int lustre_packed_msg_size(struct lustre_msg *msg);
1011 int lustre_msg_early_size(void);
1012 int lustre_unpack_msg(struct lustre_msg *m, int len);
1013 void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, int n, int min_size);
1014 void *lustre_msg_buf(struct lustre_msg *m, int n, int minlen);
1015 int lustre_msg_buflen(struct lustre_msg *m, int n);
1016 void lustre_msg_set_buflen(struct lustre_msg *m, int n, int len);
1017 int lustre_msg_bufcount(struct lustre_msg *m);
1018 char *lustre_msg_string (struct lustre_msg *m, int n, int max_len);
1019 void *lustre_swab_buf(struct lustre_msg *, int n, int minlen, void *swabber);
1020 void *lustre_swab_reqbuf(struct ptlrpc_request *req, int n, int minlen,
1022 void *lustre_swab_repbuf(struct ptlrpc_request *req, int n, int minlen,
1024 __u32 lustre_msghdr_get_flags(struct lustre_msg *msg);
1025 void lustre_msghdr_set_flags(struct lustre_msg *msg, __u32 flags);
1026 __u32 lustre_msg_get_flags(struct lustre_msg *msg);
1027 void lustre_msg_add_flags(struct lustre_msg *msg, int flags);
1028 void lustre_msg_set_flags(struct lustre_msg *msg, int flags);
1029 void lustre_msg_clear_flags(struct lustre_msg *msg, int flags);
1030 __u32 lustre_msg_get_op_flags(struct lustre_msg *msg);
1031 void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags);
1032 void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags);
1033 struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg);
1034 __u32 lustre_msg_get_type(struct lustre_msg *msg);
1035 __u32 lustre_msg_get_version(struct lustre_msg *msg);
1036 void lustre_msg_add_version(struct lustre_msg *msg, int version);
1037 __u32 lustre_msg_get_opc(struct lustre_msg *msg);
1038 __u64 lustre_msg_get_last_xid(struct lustre_msg *msg);
1039 __u64 lustre_msg_get_last_committed(struct lustre_msg *msg);
1040 __u64 lustre_msg_get_transno(struct lustre_msg *msg);
1041 __u64 lustre_msg_get_slv(struct lustre_msg *msg);
1042 __u32 lustre_msg_get_limit(struct lustre_msg *msg);
1043 void lustre_msg_set_slv(struct lustre_msg *msg, __u64 slv);
1044 void lustre_msg_set_limit(struct lustre_msg *msg, __u64 limit);
1045 int lustre_msg_get_status(struct lustre_msg *msg);
1046 __u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg);
1047 int lustre_msg_is_v1(struct lustre_msg *msg);
1048 __u32 lustre_msg_get_magic(struct lustre_msg *msg);
1049 __u32 lustre_msg_get_timeout(struct lustre_msg *msg);
1050 __u32 lustre_msg_get_service_time(struct lustre_msg *msg);
1051 __u32 lustre_msg_get_cksum(struct lustre_msg *msg);
1052 __u32 lustre_msg_calc_cksum(struct lustre_msg *msg);
1053 void lustre_msg_set_handle(struct lustre_msg *msg,struct lustre_handle *handle);
1054 void lustre_msg_set_type(struct lustre_msg *msg, __u32 type);
1055 void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc);
1056 void lustre_msg_set_last_xid(struct lustre_msg *msg, __u64 last_xid);
1057 void lustre_msg_set_last_committed(struct lustre_msg *msg,__u64 last_committed);
1058 void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno);
1059 void lustre_msg_set_status(struct lustre_msg *msg, __u32 status);
1060 void lustre_msg_set_conn_cnt(struct lustre_msg *msg, __u32 conn_cnt);
1061 void ptlrpc_req_set_repsize(struct ptlrpc_request *req, int count, __u32 *sizes);
1062 void ptlrpc_request_set_replen(struct ptlrpc_request *req);
1063 void lustre_msg_set_timeout(struct lustre_msg *msg, __u32 timeout);
1064 void lustre_msg_set_service_time(struct lustre_msg *msg, __u32 service_time);
1065 void lustre_msg_set_cksum(struct lustre_msg *msg, __u32 cksum);
1068 lustre_shrink_reply(struct ptlrpc_request *req, int segment,
1069 unsigned int newlen, int move_data)
1071 LASSERT(req->rq_reply_state);
1072 LASSERT(req->rq_repmsg);
1073 req->rq_replen = lustre_shrink_msg(req->rq_repmsg, segment,
1078 ptlrpc_rqphase_move(struct ptlrpc_request *req, enum rq_phase new_phase)
1080 if (req->rq_phase == new_phase)
1083 if (new_phase == RQ_PHASE_UNREGISTERING) {
1084 req->rq_next_phase = req->rq_phase;
1086 atomic_inc(&req->rq_import->imp_unregistering);
1089 if (req->rq_phase == RQ_PHASE_UNREGISTERING) {
1091 atomic_dec(&req->rq_import->imp_unregistering);
1094 DEBUG_REQ(D_RPCTRACE, req, "move req \"%s\" -> \"%s\"",
1095 ptlrpc_rqphase2str(req), ptlrpc_phase2str(new_phase));
1097 req->rq_phase = new_phase;
1101 ptlrpc_client_early(struct ptlrpc_request *req)
1103 if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_UNLINK) &&
1104 req->rq_reply_deadline > cfs_time_current_sec())
1106 return req->rq_early;
1110 ptlrpc_client_replied(struct ptlrpc_request *req)
1112 if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_UNLINK) &&
1113 req->rq_reply_deadline > cfs_time_current_sec())
1115 return req->rq_replied;
1119 ptlrpc_client_recv(struct ptlrpc_request *req)
1121 if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_UNLINK) &&
1122 req->rq_reply_deadline > cfs_time_current_sec())
1124 return req->rq_receiving_reply;
1128 ptlrpc_client_recv_or_unlink(struct ptlrpc_request *req)
1132 spin_lock(&req->rq_lock);
1133 if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_UNLINK) &&
1134 req->rq_reply_deadline > cfs_time_current_sec()) {
1135 spin_unlock(&req->rq_lock);
1138 rc = req->rq_receiving_reply || req->rq_must_unlink;
1139 spin_unlock(&req->rq_lock);
1144 ptlrpc_client_wake_req(struct ptlrpc_request *req)
1146 if (req->rq_set == NULL)
1147 cfs_waitq_signal(&req->rq_reply_waitq);
1149 cfs_waitq_signal(&req->rq_set->set_waitq);
1153 ptlrpc_rs_addref(struct ptlrpc_reply_state *rs)
1155 LASSERT(atomic_read(&rs->rs_refcount) > 0);
1156 atomic_inc(&rs->rs_refcount);
1160 ptlrpc_rs_decref(struct ptlrpc_reply_state *rs)
1162 LASSERT(atomic_read(&rs->rs_refcount) > 0);
1163 if (atomic_dec_and_test(&rs->rs_refcount))
1164 lustre_free_reply_state(rs);
1167 /* Should only be called once per req */
1168 static inline void ptlrpc_req_drop_rs(struct ptlrpc_request *req)
1170 if (req->rq_reply_state == NULL)
1171 return; /* shouldn't occur */
1172 ptlrpc_rs_decref(req->rq_reply_state);
1173 req->rq_reply_state = NULL;
1174 req->rq_repmsg = NULL;
1177 static inline __u32 lustre_request_magic(struct ptlrpc_request *req)
1179 return lustre_msg_get_magic(req->rq_reqmsg);
1182 static inline int ptlrpc_req_get_repsize(struct ptlrpc_request *req)
1184 switch (req->rq_reqmsg->lm_magic) {
1185 case LUSTRE_MSG_MAGIC_V2:
1186 return req->rq_reqmsg->lm_repsize;
1188 LASSERTF(0, "incorrect message magic: %08x\n",
1189 req->rq_reqmsg->lm_magic);
1194 /* ldlm/ldlm_lib.c */
1195 int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg);
1196 int client_obd_cleanup(struct obd_device *obddev);
1197 int client_connect_import(const struct lu_env *env,
1198 struct lustre_handle *conn, struct obd_device *obd,
1199 struct obd_uuid *cluuid, struct obd_connect_data *,
1201 int client_disconnect_export(struct obd_export *exp);
1202 int client_import_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
1204 int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid);
1205 int import_set_conn_priority(struct obd_import *imp, struct obd_uuid *uuid);
1207 /* ptlrpc/pinger.c */
1208 int ptlrpc_pinger_add_import(struct obd_import *imp);
1209 int ptlrpc_pinger_del_import(struct obd_import *imp);
1210 cfs_time_t ptlrpc_suspend_wakeup_time(void);
1212 void ping_evictor_start(void);
1213 void ping_evictor_stop(void);
1215 #define ping_evictor_start() do {} while (0)
1216 #define ping_evictor_stop() do {} while (0)
1218 int ptlrpc_check_and_wait_suspend(struct ptlrpc_request *req);
1220 /* ptlrpc/ptlrpcd.c */
1223 * Ptlrpcd scope is a set of two threads: ptlrpcd-foo and ptlrpcd-foo-rcv,
1224 * these threads are used to asynchronously send requests queued with
1225 * ptlrpcd_add_req(req, PCSOPE_FOO), and to handle completion call-backs for
1226 * such requests. Multiple scopes are needed to avoid dead-locks.
1228 enum ptlrpcd_scope {
1229 /** Scope of bulk read-write rpcs. */
1231 /** Everything else. */
1236 int ptlrpcd_start(const char *name, struct ptlrpcd_ctl *pc);
1237 void ptlrpcd_stop(struct ptlrpcd_ctl *pc, int force);
1238 void ptlrpcd_wake(struct ptlrpc_request *req);
1239 void ptlrpcd_add_req(struct ptlrpc_request *req, enum ptlrpcd_scope scope);
1240 int ptlrpcd_addref(void);
1241 void ptlrpcd_decref(void);
1243 /* ptlrpc/lproc_ptlrpc.c */
1244 const char* ll_opcode2str(__u32 opcode);
1246 void ptlrpc_lprocfs_register_obd(struct obd_device *obd);
1247 void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd);
1248 void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes);
1250 static inline void ptlrpc_lprocfs_register_obd(struct obd_device *obd) {}
1251 static inline void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd) {}
1252 static inline void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes) {}
1255 /* ptlrpc/llog_server.c */
1256 int llog_origin_handle_create(struct ptlrpc_request *req);
1257 int llog_origin_handle_destroy(struct ptlrpc_request *req);
1258 int llog_origin_handle_prev_block(struct ptlrpc_request *req);
1259 int llog_origin_handle_next_block(struct ptlrpc_request *req);
1260 int llog_origin_handle_read_header(struct ptlrpc_request *req);
1261 int llog_origin_handle_close(struct ptlrpc_request *req);
1262 int llog_origin_handle_cancel(struct ptlrpc_request *req);
1263 int llog_catinfo(struct ptlrpc_request *req);
1265 /* ptlrpc/llog_client.c */
1266 extern struct llog_operations llog_client_ops;