1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 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.
23 /* Intramodule declarations for ptlrpc. */
25 #ifndef PTLRPC_INTERNAL_H
26 #define PTLRPC_INTERNAL_H
28 #include "../ldlm/ldlm_internal.h"
30 struct ldlm_namespace;
33 struct ptlrpc_request_set;
35 void ptlrpc_daemonize(void);
37 void ptlrpc_request_handle_notconn(struct ptlrpc_request *);
38 void lustre_assert_wire_constants(void);
39 int ptlrpc_import_in_recovery(struct obd_import *imp);
40 int ptlrpc_set_import_discon(struct obd_import *imp);
41 void ptlrpc_handle_failed_import(struct obd_import *imp);
42 int ptlrpc_replay_next(struct obd_import *imp, int *inflight);
43 void ptlrpc_initiate_recovery(struct obd_import *imp);
47 void ptlrpc_lprocfs_register_service(struct proc_dir_entry *proc_entry,
48 struct ptlrpc_service *svc);
49 void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc);
50 void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req);
51 void ptlrpc_lprocfs_do_request_stat (struct ptlrpc_request *req,
52 long q_usec, long work_usec);
54 #define ptlrpc_lprocfs_register_service(params...) do{}while(0)
55 #define ptlrpc_lprocfs_unregister_service(params...) do{}while(0)
56 #define ptlrpc_lprocfs_rpc_sent(params...) do{}while(0)
57 #define ptlrpc_lprocfs_do_request_stat(params...) do{}while(0)
58 #endif /* __KERNEL__ */
61 int llog_init_commit_master(void);
62 int llog_cleanup_commit_master(int force);
64 static inline int opcode_offset(__u32 opc) {
65 if (opc < OST_LAST_OPC) {
67 return (opc - OST_FIRST_OPC);
68 } else if (opc < MDS_LAST_OPC) {
70 return (opc - MDS_FIRST_OPC +
71 (OST_LAST_OPC - OST_FIRST_OPC));
72 } else if (opc < LDLM_LAST_OPC) {
74 return (opc - LDLM_FIRST_OPC +
75 (MDS_LAST_OPC - MDS_FIRST_OPC) +
76 (OST_LAST_OPC - OST_FIRST_OPC));
77 } else if (opc < PTLBD_LAST_OPC) {
78 /* Portals Block Device */
79 return (opc - PTLBD_FIRST_OPC +
80 (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
81 (MDS_LAST_OPC - MDS_FIRST_OPC) +
82 (OST_LAST_OPC - OST_FIRST_OPC));
83 } else if (opc < OBD_LAST_OPC) {
85 return (opc - OBD_FIRST_OPC +
86 (PTLBD_LAST_OPC - PTLBD_FIRST_OPC) +
87 (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
88 (MDS_LAST_OPC - MDS_FIRST_OPC) +
89 (OST_LAST_OPC - OST_FIRST_OPC));
96 #define LUSTRE_MAX_OPCODES ((PTLBD_LAST_OPC - PTLBD_FIRST_OPC) + \
97 (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))
103 PTLRPC_REQWAIT_CNTR = 0,
104 PTLRPC_REQQDEPTH_CNTR,
105 PTLRPC_REQACTIVE_CNTR,
109 int ptlrpc_expire_one_request(struct ptlrpc_request *req);
111 /* XXX these should be run-time checks so we can have one build run against
113 #if defined(__KERNEL__)
114 #define ptl_requires_iov() 1
116 #define ptl_requires_iov() 0
119 #if defined(__KERNEL__)
120 # if defined(CRAY_PORTALS)
121 # define PTLRPC_PTL_MD_IOV (PTL_MD_IOVEC | PTL_MD_PHYS)
123 # define PTLRPC_PTL_MD_IOV PTL_MD_KIOV
126 # define PTLRPC_PTL_MD_IOV PTL_MD_IOVEC
129 #if !defined(__KERNEL__) && defined(CRAY_PORTALS)
130 #define ptl_md_max_iovs() 1
132 #define ptl_md_max_iovs() 0 /* unlimited */
135 /* XXX hopefully we can make the iov a consistent type across portals imps */
136 #if defined(__KERNEL__)
137 #define ptl_iov_base(kiov) (NULL) /* this is meaningless */
139 #define ptl_iov_base(iov) ((iov)->iov_base)
143 /* portals calls the callback when the event is added to the queue, so we don't
144 * care if we lose events */
145 # define PTLRPC_NUM_EQ 1024
146 # define PTLRPC_EQ_CALLBACK ptlrpc_master_callback
148 /* liblustre: no callback, or only when app polls event queues, so allocate a
149 * nice big event queue to ensure we don't drop any */
150 # define PTLRPC_NUM_EQ 10240
152 int cray_portals_callback(ptl_event_t *ev);
153 # define PTLRPC_EQ_CALLBACK cray_portals_callback
155 # define PTLRPC_EQ_CALLBACK PTL_EQ_HANDLER_NONE
160 void pers_bulk_add_page(struct ptlrpc_bulk_desc *desc, struct page *page,
161 int pageoffset, int len);
164 int ptlrpc_start_pinger(void);
165 int ptlrpc_stop_pinger(void);
166 void ptlrpc_pinger_sending_on_import(struct obd_import *imp);
167 void ptlrpc_pinger_wake_up(void);
169 #endif /* PTLRPC_INTERNAL_H */