1 /* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
6 * Code which implements an OCFS2 specific interface to underlying
9 * Copyright (C) 2007 Oracle. All rights reserved.
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public
13 * License as published by the Free Software Foundation, version 2.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
21 #include <linux/slab.h>
22 #include <linux/kmod.h>
24 /* Needed for AOP_TRUNCATED_PAGE in mlog_errno() */
27 #include "cluster/masklog.h"
29 #include "stackglue.h"
31 struct ocfs2_locking_protocol *stack_glue_lproto;
34 int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn,
36 union ocfs2_dlm_lksb *lksb,
42 BUG_ON(stack_glue_lproto == NULL);
44 return o2cb_stack_ops.dlm_lock(conn, mode, lksb, flags,
45 name, namelen, astarg);
48 int ocfs2_dlm_unlock(struct ocfs2_cluster_connection *conn,
49 union ocfs2_dlm_lksb *lksb,
53 BUG_ON(stack_glue_lproto == NULL);
55 return o2cb_stack_ops.dlm_unlock(conn, lksb, flags, astarg);
58 int ocfs2_dlm_lock_status(union ocfs2_dlm_lksb *lksb)
60 return o2cb_stack_ops.lock_status(lksb);
64 * Why don't we cast to ocfs2_meta_lvb? The "clean" answer is that we
65 * don't cast at the glue level. The real answer is that the header
66 * ordering is nigh impossible.
68 void *ocfs2_dlm_lvb(union ocfs2_dlm_lksb *lksb)
70 return o2cb_stack_ops.lock_lvb(lksb);
73 void ocfs2_dlm_dump_lksb(union ocfs2_dlm_lksb *lksb)
75 o2cb_stack_ops.dump_lksb(lksb);
78 int ocfs2_cluster_connect(const char *group,
80 void (*recovery_handler)(int node_num,
83 struct ocfs2_cluster_connection **conn)
86 struct ocfs2_cluster_connection *new_conn;
88 BUG_ON(group == NULL);
90 BUG_ON(recovery_handler == NULL);
92 if (grouplen > GROUP_NAME_MAX) {
97 new_conn = kzalloc(sizeof(struct ocfs2_cluster_connection),
104 memcpy(new_conn->cc_name, group, grouplen);
105 new_conn->cc_namelen = grouplen;
106 new_conn->cc_recovery_handler = recovery_handler;
107 new_conn->cc_recovery_data = recovery_data;
109 /* Start the new connection at our maximum compatibility level */
110 new_conn->cc_version = stack_glue_lproto->lp_max_version;
112 rc = o2cb_stack_ops.connect(new_conn);
128 int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn)
132 BUG_ON(conn == NULL);
134 ret = o2cb_stack_ops.disconnect(conn);
136 /* XXX Should we free it anyway? */
143 void ocfs2_cluster_hangup(const char *group, int grouplen)
145 BUG_ON(group == NULL);
146 BUG_ON(group[grouplen] != '\0');
148 o2cb_stack_ops.hangup(group, grouplen);
151 int ocfs2_cluster_this_node(unsigned int *node)
153 return o2cb_stack_ops.this_node(node);
156 void ocfs2_stack_glue_set_locking_protocol(struct ocfs2_locking_protocol *proto)
158 BUG_ON(proto != NULL);
160 stack_glue_lproto = proto;