Whamcloud - gitweb
575ed078bc0ee7efa5f0881a9ce8589273b043b3
[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 Lustre, http://www.lustre.org.
7  *
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.
11  *
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.
16  *
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.
20  *
21  */
22
23 /* Intramodule declarations for ptlrpc. */
24
25 #ifndef PTLRPC_INTERNAL_H
26 #define PTLRPC_INTERNAL_H
27
28 struct ldlm_namespace;
29 struct obd_import;
30 struct ldlm_res_id;
31
32 /* ldlm hooks that we need, managed via inter_module_{get,put} */
33 extern int (*ptlrpc_ldlm_namespace_cleanup)(struct ldlm_namespace *, int);
34 extern int (*ptlrpc_ldlm_cli_cancel_unused)(struct ldlm_namespace *,
35                                      struct ldlm_res_id *, int);
36 extern int (*ptlrpc_ldlm_replay_locks)(struct obd_import *);
37
38 int ptlrpc_get_ldlm_hooks(void);
39 void ptlrpc_daemonize(void);
40
41 int ptlrpc_request_handle_eviction(struct ptlrpc_request *);
42 void lustre_assert_wire_constants (void);
43
44 void ptlrpc_lprocfs_register_service(struct obd_device *obddev,
45                                      struct ptlrpc_service *svc);
46 void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc);
47
48
49 static inline int opcode_offset(__u32 opc) {
50         if (opc < OST_LAST_OPC) {
51                  /* OST opcode */
52                 return (opc - OST_FIRST_OPC);
53         } else if (opc < MDS_LAST_OPC) {
54                 /* MDS opcode */
55                 return (opc - MDS_FIRST_OPC +
56                         (OST_LAST_OPC - OST_FIRST_OPC));
57         } else if (opc < LDLM_LAST_OPC) {
58                 /* LDLM Opcode */
59                 return (opc - LDLM_FIRST_OPC +
60                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
61                         (OST_LAST_OPC - OST_FIRST_OPC));
62         } else if (opc < PTLBD_LAST_OPC) {
63                 /* Portals Block Device */
64                 return (opc - PTLBD_FIRST_OPC +
65                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
66                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
67                         (OST_LAST_OPC - OST_FIRST_OPC));
68         } else if (opc == OBD_PING) {
69                 /* OBD Ping */
70                 return (opc - OBD_PING +
71                         (PTLBD_LAST_OPC - PTLBD_FIRST_OPC) +
72                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
73                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
74                         (OST_LAST_OPC - OST_FIRST_OPC));
75         } else {
76                 /* Unknown Opcode */
77                 return -1;
78         }
79 }
80
81 #define LUSTRE_MAX_OPCODES (1 + (PTLBD_LAST_OPC - PTLBD_FIRST_OPC) \
82                               + (LDLM_LAST_OPC - LDLM_FIRST_OPC)   \
83                               + (MDS_LAST_OPC - MDS_FIRST_OPC)     \
84                               + (OST_LAST_OPC - OST_FIRST_OPC))
85
86 enum {
87         PTLRPC_REQWAIT_CNTR     = 0,
88         PTLRPC_SVCIDLETIME_CNTR = 1,
89         //PTLRPC_SVCEQDEPTH_CNTR,
90         PTLRPC_LAST_CNTR
91 };
92
93 #endif /* PTLRPC_INTERNAL_H */