Whamcloud - gitweb
make fld really stand-alone service independent from mdt
[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
38 void ptlrpc_request_handle_notconn(struct ptlrpc_request *);
39 void lustre_assert_wire_constants(void);
40 int ptlrpc_import_in_recovery(struct obd_import *imp);
41 int ptlrpc_set_import_discon(struct obd_import *imp, __u32 conn_cnt);
42 void ptlrpc_handle_failed_import(struct obd_import *imp);
43 int ptlrpc_replay_next(struct obd_import *imp, int *inflight);
44 void ptlrpc_initiate_recovery(struct obd_import *imp);
45
46
47 #ifdef LPROCFS
48 void ptlrpc_lprocfs_register_service(struct proc_dir_entry *proc_entry,
49                                      struct ptlrpc_service *svc);
50 void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc);
51 void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req);
52 void ptlrpc_lprocfs_do_request_stat (struct ptlrpc_request *req,
53                                      long q_usec, long work_usec);
54 #else
55 #define ptlrpc_lprocfs_register_service(params...) do{}while(0)
56 #define ptlrpc_lprocfs_unregister_service(params...) do{}while(0)
57 #define ptlrpc_lprocfs_rpc_sent(params...) do{}while(0)
58 #define ptlrpc_lprocfs_do_request_stat(params...) do{}while(0)
59 #endif /* LPROCFS */
60
61 /* recovd_thread.c */
62 int llog_init_commit_master(void);
63 int llog_cleanup_commit_master(int force);
64
65 static inline int opcode_offset(__u32 opc) {
66         if (opc < OST_LAST_OPC) {
67                  /* OST opcode */
68                 return (opc - OST_FIRST_OPC);
69         } else if (opc < MDS_LAST_OPC) {
70                 /* MDS opcode */
71                 return (opc - MDS_FIRST_OPC +
72                         (OST_LAST_OPC - OST_FIRST_OPC));
73         } else if (opc < LDLM_LAST_OPC) {
74                 /* LDLM Opcode */
75                 return (opc - LDLM_FIRST_OPC +
76                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
77                         (OST_LAST_OPC - OST_FIRST_OPC));
78         } else if (opc < OBD_LAST_OPC) {
79                 /* OBD Ping */
80                 return (opc - OBD_FIRST_OPC +
81                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
82                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
83                         (OST_LAST_OPC - OST_FIRST_OPC));
84         } else if (opc < FLD_LAST_OPC) {
85                 /* FLD opcode */
86                 return (opc - FLD_FIRST_OPC +
87                         (OBD_LAST_OPC - OBD_FIRST_OPC) +
88                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
89                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
90                         (OST_LAST_OPC - OST_FIRST_OPC));
91         } else {
92                 /* Unknown Opcode */
93                 return -1;
94         }
95 }
96
97 #define LUSTRE_MAX_OPCODES ((LDLM_LAST_OPC - LDLM_FIRST_OPC)   + \
98                             (MDS_LAST_OPC - MDS_FIRST_OPC)     + \
99                             (OST_LAST_OPC - OST_FIRST_OPC)     + \
100                             (OBD_LAST_OPC - OBD_FIRST_OPC)     + \
101                             (FLD_LAST_OPC - FLD_FIRST_OPC))
102
103 enum {
104         PTLRPC_REQWAIT_CNTR = 0,
105         PTLRPC_REQQDEPTH_CNTR,
106         PTLRPC_REQACTIVE_CNTR,
107         PTLRPC_REQBUF_AVAIL_CNTR,
108         PTLRPC_LAST_CNTR
109 };
110
111 int ptlrpc_expire_one_request(struct ptlrpc_request *req);
112
113 /* pers.c */
114 void ptlrpc_fill_bulk_md(lnet_md_t *md, struct ptlrpc_bulk_desc *desc);
115 void ptlrpc_add_bulk_page(struct ptlrpc_bulk_desc *desc, struct page *page,
116                           int pageoffset, int len);
117 void ptl_rpc_wipe_bulk_pages(struct ptlrpc_bulk_desc *desc);
118
119 /* pinger.c */
120 int ptlrpc_start_pinger(void);
121 int ptlrpc_stop_pinger(void);
122 void ptlrpc_pinger_sending_on_import(struct obd_import *imp);
123 void ptlrpc_pinger_wake_up(void);
124 void ptlrpc_ping_import_soon(struct obd_import *imp);
125 #ifdef __KERNEL__
126 int ping_evictor_wake(struct obd_export *exp);
127 #else
128 #define ping_evictor_wake(exp)     1
129 #endif
130
131 #endif /* PTLRPC_INTERNAL_H */