aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/stack_o2cb.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/stack_o2cb.c')
-rw-r--r--fs/ocfs2/stack_o2cb.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c
index e49c41050264..0d3049f696c5 100644
--- a/fs/ocfs2/stack_o2cb.c
+++ b/fs/ocfs2/stack_o2cb.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/crc32.h> 21#include <linux/crc32.h>
22#include <linux/slab.h>
22#include <linux/module.h> 23#include <linux/module.h>
23 24
24/* Needed for AOP_TRUNCATED_PAGE in mlog_errno() */ 25/* Needed for AOP_TRUNCATED_PAGE in mlog_errno() */
@@ -161,24 +162,23 @@ static int dlm_status_to_errno(enum dlm_status status)
161 162
162static void o2dlm_lock_ast_wrapper(void *astarg) 163static void o2dlm_lock_ast_wrapper(void *astarg)
163{ 164{
164 BUG_ON(o2cb_stack.sp_proto == NULL); 165 struct ocfs2_dlm_lksb *lksb = astarg;
165 166
166 o2cb_stack.sp_proto->lp_lock_ast(astarg); 167 lksb->lksb_conn->cc_proto->lp_lock_ast(lksb);
167} 168}
168 169
169static void o2dlm_blocking_ast_wrapper(void *astarg, int level) 170static void o2dlm_blocking_ast_wrapper(void *astarg, int level)
170{ 171{
171 BUG_ON(o2cb_stack.sp_proto == NULL); 172 struct ocfs2_dlm_lksb *lksb = astarg;
172 173
173 o2cb_stack.sp_proto->lp_blocking_ast(astarg, level); 174 lksb->lksb_conn->cc_proto->lp_blocking_ast(lksb, level);
174} 175}
175 176
176static void o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status) 177static void o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status)
177{ 178{
179 struct ocfs2_dlm_lksb *lksb = astarg;
178 int error = dlm_status_to_errno(status); 180 int error = dlm_status_to_errno(status);
179 181
180 BUG_ON(o2cb_stack.sp_proto == NULL);
181
182 /* 182 /*
183 * In o2dlm, you can get both the lock_ast() for the lock being 183 * In o2dlm, you can get both the lock_ast() for the lock being
184 * granted and the unlock_ast() for the CANCEL failing. A 184 * granted and the unlock_ast() for the CANCEL failing. A
@@ -193,16 +193,15 @@ static void o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status)
193 if (status == DLM_CANCELGRANT) 193 if (status == DLM_CANCELGRANT)
194 return; 194 return;
195 195
196 o2cb_stack.sp_proto->lp_unlock_ast(astarg, error); 196 lksb->lksb_conn->cc_proto->lp_unlock_ast(lksb, error);
197} 197}
198 198
199static int o2cb_dlm_lock(struct ocfs2_cluster_connection *conn, 199static int o2cb_dlm_lock(struct ocfs2_cluster_connection *conn,
200 int mode, 200 int mode,
201 union ocfs2_dlm_lksb *lksb, 201 struct ocfs2_dlm_lksb *lksb,
202 u32 flags, 202 u32 flags,
203 void *name, 203 void *name,
204 unsigned int namelen, 204 unsigned int namelen)
205 void *astarg)
206{ 205{
207 enum dlm_status status; 206 enum dlm_status status;
208 int o2dlm_mode = mode_to_o2dlm(mode); 207 int o2dlm_mode = mode_to_o2dlm(mode);
@@ -211,28 +210,27 @@ static int o2cb_dlm_lock(struct ocfs2_cluster_connection *conn,
211 210
212 status = dlmlock(conn->cc_lockspace, o2dlm_mode, &lksb->lksb_o2dlm, 211 status = dlmlock(conn->cc_lockspace, o2dlm_mode, &lksb->lksb_o2dlm,
213 o2dlm_flags, name, namelen, 212 o2dlm_flags, name, namelen,
214 o2dlm_lock_ast_wrapper, astarg, 213 o2dlm_lock_ast_wrapper, lksb,
215 o2dlm_blocking_ast_wrapper); 214 o2dlm_blocking_ast_wrapper);
216 ret = dlm_status_to_errno(status); 215 ret = dlm_status_to_errno(status);
217 return ret; 216 return ret;
218} 217}
219 218
220static int o2cb_dlm_unlock(struct ocfs2_cluster_connection *conn, 219static int o2cb_dlm_unlock(struct ocfs2_cluster_connection *conn,
221 union ocfs2_dlm_lksb *lksb, 220 struct ocfs2_dlm_lksb *lksb,
222 u32 flags, 221 u32 flags)
223 void *astarg)
224{ 222{
225 enum dlm_status status; 223 enum dlm_status status;
226 int o2dlm_flags = flags_to_o2dlm(flags); 224 int o2dlm_flags = flags_to_o2dlm(flags);
227 int ret; 225 int ret;
228 226
229 status = dlmunlock(conn->cc_lockspace, &lksb->lksb_o2dlm, 227 status = dlmunlock(conn->cc_lockspace, &lksb->lksb_o2dlm,
230 o2dlm_flags, o2dlm_unlock_ast_wrapper, astarg); 228 o2dlm_flags, o2dlm_unlock_ast_wrapper, lksb);
231 ret = dlm_status_to_errno(status); 229 ret = dlm_status_to_errno(status);
232 return ret; 230 return ret;
233} 231}
234 232
235static int o2cb_dlm_lock_status(union ocfs2_dlm_lksb *lksb) 233static int o2cb_dlm_lock_status(struct ocfs2_dlm_lksb *lksb)
236{ 234{
237 return dlm_status_to_errno(lksb->lksb_o2dlm.status); 235 return dlm_status_to_errno(lksb->lksb_o2dlm.status);
238} 236}
@@ -242,17 +240,17 @@ static int o2cb_dlm_lock_status(union ocfs2_dlm_lksb *lksb)
242 * contents, it will zero out the LVB. Thus the caller can always trust 240 * contents, it will zero out the LVB. Thus the caller can always trust
243 * the contents. 241 * the contents.
244 */ 242 */
245static int o2cb_dlm_lvb_valid(union ocfs2_dlm_lksb *lksb) 243static int o2cb_dlm_lvb_valid(struct ocfs2_dlm_lksb *lksb)
246{ 244{
247 return 1; 245 return 1;
248} 246}
249 247
250static void *o2cb_dlm_lvb(union ocfs2_dlm_lksb *lksb) 248static void *o2cb_dlm_lvb(struct ocfs2_dlm_lksb *lksb)
251{ 249{
252 return (void *)(lksb->lksb_o2dlm.lvb); 250 return (void *)(lksb->lksb_o2dlm.lvb);
253} 251}
254 252
255static void o2cb_dump_lksb(union ocfs2_dlm_lksb *lksb) 253static void o2cb_dump_lksb(struct ocfs2_dlm_lksb *lksb)
256{ 254{
257 dlm_print_one_lock(lksb->lksb_o2dlm.lockid); 255 dlm_print_one_lock(lksb->lksb_o2dlm.lockid);
258} 256}
@@ -277,10 +275,10 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn)
277 u32 dlm_key; 275 u32 dlm_key;
278 struct dlm_ctxt *dlm; 276 struct dlm_ctxt *dlm;
279 struct o2dlm_private *priv; 277 struct o2dlm_private *priv;
280 struct dlm_protocol_version dlm_version; 278 struct dlm_protocol_version fs_version;
281 279
282 BUG_ON(conn == NULL); 280 BUG_ON(conn == NULL);
283 BUG_ON(o2cb_stack.sp_proto == NULL); 281 BUG_ON(conn->cc_proto == NULL);
284 282
285 /* for now we only have one cluster/node, make sure we see it 283 /* for now we only have one cluster/node, make sure we see it
286 * in the heartbeat universe */ 284 * in the heartbeat universe */
@@ -304,18 +302,18 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn)
304 /* used by the dlm code to make message headers unique, each 302 /* used by the dlm code to make message headers unique, each
305 * node in this domain must agree on this. */ 303 * node in this domain must agree on this. */
306 dlm_key = crc32_le(0, conn->cc_name, conn->cc_namelen); 304 dlm_key = crc32_le(0, conn->cc_name, conn->cc_namelen);
307 dlm_version.pv_major = conn->cc_version.pv_major; 305 fs_version.pv_major = conn->cc_version.pv_major;
308 dlm_version.pv_minor = conn->cc_version.pv_minor; 306 fs_version.pv_minor = conn->cc_version.pv_minor;
309 307
310 dlm = dlm_register_domain(conn->cc_name, dlm_key, &dlm_version); 308 dlm = dlm_register_domain(conn->cc_name, dlm_key, &fs_version);
311 if (IS_ERR(dlm)) { 309 if (IS_ERR(dlm)) {
312 rc = PTR_ERR(dlm); 310 rc = PTR_ERR(dlm);
313 mlog_errno(rc); 311 mlog_errno(rc);
314 goto out_free; 312 goto out_free;
315 } 313 }
316 314
317 conn->cc_version.pv_major = dlm_version.pv_major; 315 conn->cc_version.pv_major = fs_version.pv_major;
318 conn->cc_version.pv_minor = dlm_version.pv_minor; 316 conn->cc_version.pv_minor = fs_version.pv_minor;
319 conn->cc_lockspace = dlm; 317 conn->cc_lockspace = dlm;
320 318
321 dlm_register_eviction_cb(dlm, &priv->op_eviction_cb); 319 dlm_register_eviction_cb(dlm, &priv->op_eviction_cb);