20 #include <linux/kernel.h>
22 #include <linux/slab.h>
23 #include <linux/module.h>
42 #if (DLM_LOCK_IV != LKM_IVMODE)
43 # error Lock modes do not match
45 #if (DLM_LOCK_NL != LKM_NLMODE)
46 # error Lock modes do not match
48 #if (DLM_LOCK_CR != LKM_CRMODE)
49 # error Lock modes do not match
51 #if (DLM_LOCK_CW != LKM_CWMODE)
52 # error Lock modes do not match
54 #if (DLM_LOCK_PR != LKM_PRMODE)
55 # error Lock modes do not match
57 #if (DLM_LOCK_PW != LKM_PWMODE)
58 # error Lock modes do not match
60 #if (DLM_LOCK_EX != LKM_EXMODE)
61 # error Lock modes do not match
63 static inline int mode_to_o2dlm(
int mode)
70 #define map_flag(_generic, _o2dlm) \
71 if (flags & (_generic)) { \
72 flags &= ~(_generic); \
73 o2dlm_flags |= (_o2dlm); \
112 static int status_map[] = {
161 return status_map[
status];
164 static void o2dlm_lock_ast_wrapper(
void *astarg)
168 lksb->
lksb_conn->cc_proto->lp_lock_ast(lksb);
171 static void o2dlm_blocking_ast_wrapper(
void *astarg,
int level)
175 lksb->
lksb_conn->cc_proto->lp_blocking_ast(lksb, level);
178 static void o2dlm_unlock_ast_wrapper(
void *astarg,
enum dlm_status status)
181 int error = dlm_status_to_errno(status);
197 lksb->
lksb_conn->cc_proto->lp_unlock_ast(lksb, error);
208 int o2dlm_mode = mode_to_o2dlm(mode);
209 int o2dlm_flags = flags_to_o2dlm(flags);
213 o2dlm_flags, name, namelen,
214 o2dlm_lock_ast_wrapper, lksb,
215 o2dlm_blocking_ast_wrapper);
216 ret = dlm_status_to_errno(status);
225 int o2dlm_flags = flags_to_o2dlm(flags);
229 o2dlm_flags, o2dlm_unlock_ast_wrapper, lksb);
230 ret = dlm_status_to_errno(status);
236 return dlm_status_to_errno(lksb->
lksb_o2dlm.status);
263 static int o2cb_cluster_check(
void)
284 #define O2CB_MAP_STABILIZE_COUNT 60
290 "Global" :
"Local"));
296 if (!
memcmp(hbmap, netmap,
sizeof(hbmap)))
298 if (i < O2CB_MAP_STABILIZE_COUNT)
318 static void o2dlm_eviction_cb(
int node_num,
void *
data)
340 rc = o2cb_cluster_check();
343 "before retrying.\n");
362 fs_version.pv_major = conn->
cc_version.pv_major;
363 fs_version.pv_minor = conn->
cc_version.pv_minor;
372 conn->
cc_version.pv_major = fs_version.pv_major;
373 conn->
cc_version.pv_minor = fs_version.pv_minor;
401 static int o2cb_cluster_this_node(
unsigned int *
node)
417 .connect = o2cb_cluster_connect,
418 .disconnect = o2cb_cluster_disconnect,
419 .this_node = o2cb_cluster_this_node,
420 .dlm_lock = o2cb_dlm_lock,
421 .dlm_unlock = o2cb_dlm_unlock,
422 .lock_status = o2cb_dlm_lock_status,
423 .lvb_valid = o2cb_dlm_lvb_valid,
424 .lock_lvb = o2cb_dlm_lvb,
425 .dump_lksb = o2cb_dump_lksb,
430 .sp_ops = &o2cb_stack_ops,
434 static int __init o2cb_stack_init(
void)
439 static void __exit o2cb_stack_exit(
void)