Whamcloud - gitweb
c2610aae9b71a5ce44a362b379123703358e15ca
[fs/lustre-release.git] / lustre / ptlrpc / ptlrpc_internal.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2003 Cluster File Systems, Inc.
5  *
6  *   This file is part of the Lustre file system, http://www.lustre.org
7  *   Lustre is a trademark of Cluster File Systems, Inc.
8  *
9  *   You may have signed or agreed to another license before downloading
10  *   this software.  If so, you are bound by the terms and conditions
11  *   of that agreement, and the following does not apply to you.  See the
12  *   LICENSE file included with this distribution for more information.
13  *
14  *   If you did not agree to a different license, then this copy of Lustre
15  *   is open source software; you can redistribute it and/or modify it
16  *   under the terms of version 2 of the GNU General Public License as
17  *   published by the Free Software Foundation.
18  *
19  *   In either case, Lustre is distributed in the hope that it will be
20  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  *   license text for more details.
23  *
24  */
25
26 /* Intramodule declarations for ptlrpc. */
27
28 #ifndef PTLRPC_INTERNAL_H
29 #define PTLRPC_INTERNAL_H
30
31 #include "../ldlm/ldlm_internal.h"
32
33 struct ldlm_namespace;
34 struct obd_import;
35 struct ldlm_res_id;
36 struct ptlrpc_request_set;
37 extern int test_req_buffer_pressure;
38
39 void ptlrpc_request_handle_notconn(struct ptlrpc_request *);
40 void lustre_assert_wire_constants(void);
41 int ptlrpc_import_in_recovery(struct obd_import *imp);
42 int ptlrpc_set_import_discon(struct obd_import *imp, __u32 conn_cnt);
43 void ptlrpc_handle_failed_import(struct obd_import *imp);
44 int ptlrpc_replay_next(struct obd_import *imp, int *inflight);
45 void ptlrpc_initiate_recovery(struct obd_import *imp);
46
47 int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset);
48 int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset);
49
50
51 #ifdef LPROCFS
52 void ptlrpc_lprocfs_register_service(struct proc_dir_entry *proc_entry,
53                                      struct ptlrpc_service *svc);
54 void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc);
55 void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req);
56 void ptlrpc_lprocfs_do_request_stat (struct ptlrpc_request *req,
57                                      long q_usec, long work_usec);
58 #else
59 #define ptlrpc_lprocfs_register_service(params...) do{}while(0)
60 #define ptlrpc_lprocfs_unregister_service(params...) do{}while(0)
61 #define ptlrpc_lprocfs_rpc_sent(params...) do{}while(0)
62 #define ptlrpc_lprocfs_do_request_stat(params...) do{}while(0)
63 #endif /* LPROCFS */
64
65 /* recovd_thread.c */
66 int llog_init_commit_master(void);
67 int llog_cleanup_commit_master(int force);
68
69 static inline int opcode_offset(__u32 opc) {
70         if (opc < OST_LAST_OPC) {
71                  /* OST opcode */
72                 return (opc - OST_FIRST_OPC);
73         } else if (opc < MDS_LAST_OPC) {
74                 /* MDS opcode */
75                 return (opc - MDS_FIRST_OPC +
76                         (OST_LAST_OPC - OST_FIRST_OPC));
77         } else if (opc < LDLM_LAST_OPC) {
78                 /* LDLM Opcode */
79                 return (opc - LDLM_FIRST_OPC +
80                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
81                         (OST_LAST_OPC - OST_FIRST_OPC));
82         } else if (opc < MGS_LAST_OPC) {
83                 /* MGS Opcode */
84                 return (opc - MGS_FIRST_OPC +
85                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
86                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
87                         (OST_LAST_OPC - OST_FIRST_OPC));
88         } else if (opc < OBD_LAST_OPC) {
89                 /* OBD Ping */
90                 return (opc - OBD_FIRST_OPC +
91                         (MGS_LAST_OPC - MGS_FIRST_OPC) +
92                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
93                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
94                         (OST_LAST_OPC - OST_FIRST_OPC));
95         } else if (opc < LLOG_LAST_OPC) {
96                 /* LLOG opcode */
97                 return (opc - LLOG_FIRST_OPC +
98                         (OBD_LAST_OPC - OBD_FIRST_OPC) +
99                         (MGS_LAST_OPC - MGS_FIRST_OPC) +
100                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
101                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
102                         (OST_LAST_OPC - OST_FIRST_OPC));
103         } else if (opc < FLD_LAST_OPC) {
104                 /* FLD opcode */
105                 return (opc - FLD_FIRST_OPC +
106                         (LLOG_LAST_OPC - LLOG_FIRST_OPC) +
107                         (OBD_LAST_OPC - OBD_FIRST_OPC) +
108                         (MGS_LAST_OPC - MGS_FIRST_OPC) +
109                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
110                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
111                         (OST_LAST_OPC - OST_FIRST_OPC));
112         } else if (opc < SEQ_LAST_OPC) {
113                 /* SEQ opcode */
114                 return (opc - SEQ_FIRST_OPC +
115                         (FLD_LAST_OPC - FLD_FIRST_OPC) +
116                         (LLOG_LAST_OPC - LLOG_FIRST_OPC) +
117                         (OBD_LAST_OPC - OBD_FIRST_OPC) +
118                         (MGS_LAST_OPC - MGS_FIRST_OPC) +
119                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
120                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
121                         (OST_LAST_OPC - OST_FIRST_OPC));
122         } else if (opc < SEC_LAST_OPC) {
123                 /* SEC opcode */
124                 return (opc - SEC_FIRST_OPC +
125                         (SEQ_LAST_OPC - SEQ_FIRST_OPC) +
126                         (FLD_LAST_OPC - FLD_FIRST_OPC) +
127                         (LLOG_LAST_OPC - LLOG_FIRST_OPC) +
128                         (OBD_LAST_OPC - OBD_FIRST_OPC) +
129                         (MGS_LAST_OPC - MGS_FIRST_OPC) +
130                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
131                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
132                         (OST_LAST_OPC - OST_FIRST_OPC));
133         } else {
134                 /* Unknown Opcode */
135                 return -1;
136         }
137 }
138
139 #define LUSTRE_MAX_OPCODES ((LDLM_LAST_OPC - LDLM_FIRST_OPC)   + \
140                             (MDS_LAST_OPC - MDS_FIRST_OPC)     + \
141                             (OST_LAST_OPC - OST_FIRST_OPC)     + \
142                             (OBD_LAST_OPC - OBD_FIRST_OPC)     + \
143                             (FLD_LAST_OPC - FLD_FIRST_OPC)     + \
144                             (SEQ_LAST_OPC - SEQ_FIRST_OPC)     + \
145                             (MGS_LAST_OPC - MGS_FIRST_OPC)     + \
146                             (LLOG_LAST_OPC - LLOG_FIRST_OPC)   + \
147                             (SEC_LAST_OPC - SEC_FIRST_OPC))
148 enum {
149         PTLRPC_REQWAIT_CNTR = 0,
150         PTLRPC_REQQDEPTH_CNTR,
151         PTLRPC_REQACTIVE_CNTR,
152         PTLRPC_REQBUF_AVAIL_CNTR,
153         PTLRPC_LAST_CNTR
154 };
155
156 int ptlrpc_expire_one_request(struct ptlrpc_request *req);
157
158 /* pers.c */
159 void ptlrpc_fill_bulk_md(lnet_md_t *md, struct ptlrpc_bulk_desc *desc);
160 void ptlrpc_add_bulk_page(struct ptlrpc_bulk_desc *desc, cfs_page_t *page, 
161                           int pageoffset, int len);
162 void ptl_rpc_wipe_bulk_pages(struct ptlrpc_bulk_desc *desc);
163
164 /* pack_generic.c */
165 struct ptlrpc_reply_state *lustre_get_emerg_rs(struct ptlrpc_service *svc);
166 void lustre_put_emerg_rs(struct ptlrpc_reply_state *rs);
167
168 /* pinger.c */
169 int ptlrpc_start_pinger(void);
170 int ptlrpc_stop_pinger(void);
171 void ptlrpc_pinger_sending_on_import(struct obd_import *imp);
172 void ptlrpc_pinger_wake_up(void);
173 void ptlrpc_ping_import_soon(struct obd_import *imp);
174 #ifdef __KERNEL__
175 int ping_evictor_wake(struct obd_export *exp);
176 #else
177 #define ping_evictor_wake(exp)     1
178 #endif
179
180 /* sec_null.c */
181 int  sptlrpc_null_init(void);
182 void sptlrpc_null_fini(void);
183
184 /* sec_plain.c */
185 int  sptlrpc_plain_init(void);
186 void sptlrpc_plain_fini(void);
187
188 /* sec_bulk.c */
189 int  sptlrpc_enc_pool_init(void);
190 void sptlrpc_enc_pool_fini(void);
191 int sptlrpc_proc_read_enc_pool(char *page, char **start, off_t off, int count,
192                                int *eof, void *data);
193 const char * sptlrpc_bulk_csum_alg2name(__u32 csum_alg);
194
195 /* sec_lproc.c */
196 int  sptlrpc_lproc_init(void);
197 void sptlrpc_lproc_fini(void);
198
199 /* sec_gc.c */
200 void sptlrpc_gc_add_sec(struct ptlrpc_sec *sec);
201 void sptlrpc_gc_del_sec(struct ptlrpc_sec *sec);
202 int sptlrpc_gc_start_thread(void);
203 void sptlrpc_gc_stop_thread(void);
204
205 /* sec.c */
206 int  __init sptlrpc_init(void);
207 void __exit sptlrpc_fini(void);
208
209 #endif /* PTLRPC_INTERNAL_H */