1
2
3
4
5
6
7
8
9
10
11#ifndef STACKGLUE_H
12#define STACKGLUE_H
13
14#include <linux/types.h>
15#include <linux/list.h>
16#include <linux/dlmconstants.h>
17
18#include "dlm/dlmapi.h"
19#include <linux/dlm.h>
20
21
22struct file;
23struct file_lock;
24
25
26
27
28
29
30#define DLM_LKF_LOCAL 0x00100000
31
32
33
34
35
36#define GROUP_NAME_MAX 64
37
38
39#define CLUSTER_NAME_MAX 16
40
41
42
43
44
45
46struct ocfs2_protocol_version {
47 u8 pv_major;
48 u8 pv_minor;
49};
50
51
52
53
54
55
56struct fsdlm_lksb_plus_lvb {
57 struct dlm_lksb lksb;
58 char lvb[DLM_LVB_LEN];
59};
60
61
62
63
64
65
66struct ocfs2_cluster_connection;
67struct ocfs2_dlm_lksb {
68 union {
69 struct dlm_lockstatus lksb_o2dlm;
70 struct dlm_lksb lksb_fsdlm;
71 struct fsdlm_lksb_plus_lvb padding;
72 };
73 struct ocfs2_cluster_connection *lksb_conn;
74};
75
76
77
78
79struct ocfs2_locking_protocol {
80 struct ocfs2_protocol_version lp_max_version;
81 void (*lp_lock_ast)(struct ocfs2_dlm_lksb *lksb);
82 void (*lp_blocking_ast)(struct ocfs2_dlm_lksb *lksb, int level);
83 void (*lp_unlock_ast)(struct ocfs2_dlm_lksb *lksb, int error);
84};
85
86
87
88
89
90
91
92struct ocfs2_cluster_connection {
93 char cc_name[GROUP_NAME_MAX + 1];
94 int cc_namelen;
95 char cc_cluster_name[CLUSTER_NAME_MAX + 1];
96 int cc_cluster_name_len;
97 struct ocfs2_protocol_version cc_version;
98 struct ocfs2_locking_protocol *cc_proto;
99 void (*cc_recovery_handler)(int node_num, void *recovery_data);
100 void *cc_recovery_data;
101 void *cc_lockspace;
102 void *cc_private;
103};
104
105
106
107
108
109
110struct ocfs2_stack_operations {
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128 int (*connect)(struct ocfs2_cluster_connection *conn);
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144 int (*disconnect)(struct ocfs2_cluster_connection *conn);
145
146
147
148
149
150 int (*this_node)(struct ocfs2_cluster_connection *conn,
151 unsigned int *node);
152
153
154
155
156
157
158
159
160
161
162
163 int (*dlm_lock)(struct ocfs2_cluster_connection *conn,
164 int mode,
165 struct ocfs2_dlm_lksb *lksb,
166 u32 flags,
167 void *name,
168 unsigned int namelen);
169
170
171
172
173
174
175
176
177
178
179 int (*dlm_unlock)(struct ocfs2_cluster_connection *conn,
180 struct ocfs2_dlm_lksb *lksb,
181 u32 flags);
182
183
184
185
186
187
188
189 int (*lock_status)(struct ocfs2_dlm_lksb *lksb);
190
191
192
193
194 int (*lvb_valid)(struct ocfs2_dlm_lksb *lksb);
195
196
197
198
199 void *(*lock_lvb)(struct ocfs2_dlm_lksb *lksb);
200
201
202
203
204
205
206 int (*plock)(struct ocfs2_cluster_connection *conn,
207 u64 ino,
208 struct file *file,
209 int cmd,
210 struct file_lock *fl);
211
212
213
214
215
216 void (*dump_lksb)(struct ocfs2_dlm_lksb *lksb);
217};
218
219
220
221
222
223
224struct ocfs2_stack_plugin {
225 char *sp_name;
226 struct ocfs2_stack_operations *sp_ops;
227 struct module *sp_owner;
228
229
230 struct list_head sp_list;
231 unsigned int sp_count;
232 struct ocfs2_protocol_version sp_max_proto;
233};
234
235
236
237int ocfs2_cluster_connect(const char *stack_name,
238 const char *cluster_name,
239 int cluster_name_len,
240 const char *group,
241 int grouplen,
242 struct ocfs2_locking_protocol *lproto,
243 void (*recovery_handler)(int node_num,
244 void *recovery_data),
245 void *recovery_data,
246 struct ocfs2_cluster_connection **conn);
247
248
249
250
251int ocfs2_cluster_connect_agnostic(const char *group,
252 int grouplen,
253 struct ocfs2_locking_protocol *lproto,
254 void (*recovery_handler)(int node_num,
255 void *recovery_data),
256 void *recovery_data,
257 struct ocfs2_cluster_connection **conn);
258int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn,
259 int hangup_pending);
260void ocfs2_cluster_hangup(const char *group, int grouplen);
261int ocfs2_cluster_this_node(struct ocfs2_cluster_connection *conn,
262 unsigned int *node);
263
264struct ocfs2_lock_res;
265int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn,
266 int mode,
267 struct ocfs2_dlm_lksb *lksb,
268 u32 flags,
269 void *name,
270 unsigned int namelen);
271int ocfs2_dlm_unlock(struct ocfs2_cluster_connection *conn,
272 struct ocfs2_dlm_lksb *lksb,
273 u32 flags);
274
275int ocfs2_dlm_lock_status(struct ocfs2_dlm_lksb *lksb);
276int ocfs2_dlm_lvb_valid(struct ocfs2_dlm_lksb *lksb);
277void *ocfs2_dlm_lvb(struct ocfs2_dlm_lksb *lksb);
278void ocfs2_dlm_dump_lksb(struct ocfs2_dlm_lksb *lksb);
279
280int ocfs2_stack_supports_plocks(void);
281int ocfs2_plock(struct ocfs2_cluster_connection *conn, u64 ino,
282 struct file *file, int cmd, struct file_lock *fl);
283
284void ocfs2_stack_glue_set_max_proto_version(struct ocfs2_protocol_version *max_proto);
285
286
287
288int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin);
289void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin);
290
291extern struct kset *ocfs2_kset;
292
293#endif
294