aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ocfs2/Makefile1
-rw-r--r--fs/ocfs2/dlmglue.c110
-rw-r--r--fs/ocfs2/dlmglue.h3
-rw-r--r--fs/ocfs2/stackglue.c65
-rw-r--r--fs/ocfs2/stackglue.h45
-rw-r--r--fs/ocfs2/super.c4
6 files changed, 179 insertions, 49 deletions
diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile
index 4d4ce48bb42..3ba64af2695 100644
--- a/fs/ocfs2/Makefile
+++ b/fs/ocfs2/Makefile
@@ -24,6 +24,7 @@ ocfs2-objs := \
24 namei.o \ 24 namei.o \
25 resize.o \ 25 resize.o \
26 slot_map.o \ 26 slot_map.o \
27 stackglue.o \
27 suballoc.o \ 28 suballoc.o \
28 super.o \ 29 super.o \
29 symlink.o \ 30 symlink.o \
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 15a5167e051..aea3bef1917 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -53,6 +53,7 @@
53#include "heartbeat.h" 53#include "heartbeat.h"
54#include "inode.h" 54#include "inode.h"
55#include "journal.h" 55#include "journal.h"
56#include "stackglue.h"
56#include "slot_map.h" 57#include "slot_map.h"
57#include "super.h" 58#include "super.h"
58#include "uptodate.h" 59#include "uptodate.h"
@@ -888,22 +889,21 @@ static int ocfs2_lock_create(struct ocfs2_super *osb,
888 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); 889 lockres_or_flags(lockres, OCFS2_LOCK_BUSY);
889 spin_unlock_irqrestore(&lockres->l_lock, flags); 890 spin_unlock_irqrestore(&lockres->l_lock, flags);
890 891
891 status = dlmlock(osb->dlm, 892 status = ocfs2_dlm_lock(osb->dlm,
892 level, 893 level,
893 &lockres->l_lksb, 894 &lockres->l_lksb,
894 dlm_flags, 895 dlm_flags,
895 lockres->l_name, 896 lockres->l_name,
896 OCFS2_LOCK_ID_MAX_LEN - 1, 897 OCFS2_LOCK_ID_MAX_LEN - 1,
897 ocfs2_locking_ast, 898 lockres);
898 lockres,
899 ocfs2_blocking_ast);
900 if (status != DLM_NORMAL) { 899 if (status != DLM_NORMAL) {
901 ocfs2_log_dlm_error("dlmlock", status, lockres); 900 ocfs2_log_dlm_error("ocfs2_dlm_lock", status, lockres);
902 ret = -EINVAL; 901 ret = -EINVAL;
903 ocfs2_recover_from_dlm_error(lockres, 1); 902 ocfs2_recover_from_dlm_error(lockres, 1);
904 } 903 }
905 904
906 mlog(0, "lock %s, successfull return from dlmlock\n", lockres->l_name); 905 mlog(0, "lock %s, successfull return from ocfs2_dlm_lock\n",
906 lockres->l_name);
907 907
908bail: 908bail:
909 mlog_exit(ret); 909 mlog_exit(ret);
@@ -1091,29 +1091,27 @@ again:
1091 lockres->l_name, lockres->l_level, level); 1091 lockres->l_name, lockres->l_level, level);
1092 1092
1093 /* call dlm_lock to upgrade lock now */ 1093 /* call dlm_lock to upgrade lock now */
1094 status = dlmlock(osb->dlm, 1094 status = ocfs2_dlm_lock(osb->dlm,
1095 level, 1095 level,
1096 &lockres->l_lksb, 1096 &lockres->l_lksb,
1097 lkm_flags, 1097 lkm_flags,
1098 lockres->l_name, 1098 lockres->l_name,
1099 OCFS2_LOCK_ID_MAX_LEN - 1, 1099 OCFS2_LOCK_ID_MAX_LEN - 1,
1100 ocfs2_locking_ast, 1100 lockres);
1101 lockres,
1102 ocfs2_blocking_ast);
1103 if (status != DLM_NORMAL) { 1101 if (status != DLM_NORMAL) {
1104 if ((lkm_flags & LKM_NOQUEUE) && 1102 if ((lkm_flags & LKM_NOQUEUE) &&
1105 (status == DLM_NOTQUEUED)) 1103 (status == DLM_NOTQUEUED))
1106 ret = -EAGAIN; 1104 ret = -EAGAIN;
1107 else { 1105 else {
1108 ocfs2_log_dlm_error("dlmlock", status, 1106 ocfs2_log_dlm_error("ocfs2_dlm_lock",
1109 lockres); 1107 status, lockres);
1110 ret = -EINVAL; 1108 ret = -EINVAL;
1111 } 1109 }
1112 ocfs2_recover_from_dlm_error(lockres, 1); 1110 ocfs2_recover_from_dlm_error(lockres, 1);
1113 goto out; 1111 goto out;
1114 } 1112 }
1115 1113
1116 mlog(0, "lock %s, successfull return from dlmlock\n", 1114 mlog(0, "lock %s, successfull return from ocfs2_dlm_lock\n",
1117 lockres->l_name); 1115 lockres->l_name);
1118 1116
1119 /* At this point we've gone inside the dlm and need to 1117 /* At this point we've gone inside the dlm and need to
@@ -1503,14 +1501,14 @@ int ocfs2_file_lock(struct file *file, int ex, int trylock)
1503 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); 1501 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0);
1504 spin_unlock_irqrestore(&lockres->l_lock, flags); 1502 spin_unlock_irqrestore(&lockres->l_lock, flags);
1505 1503
1506 ret = dlmlock(osb->dlm, level, &lockres->l_lksb, lkm_flags, 1504 ret = ocfs2_dlm_lock(osb->dlm, level, &lockres->l_lksb, lkm_flags,
1507 lockres->l_name, OCFS2_LOCK_ID_MAX_LEN - 1, 1505 lockres->l_name, OCFS2_LOCK_ID_MAX_LEN - 1,
1508 ocfs2_locking_ast, lockres, ocfs2_blocking_ast); 1506 lockres);
1509 if (ret != DLM_NORMAL) { 1507 if (ret != DLM_NORMAL) {
1510 if (trylock && ret == DLM_NOTQUEUED) 1508 if (trylock && ret == DLM_NOTQUEUED)
1511 ret = -EAGAIN; 1509 ret = -EAGAIN;
1512 else { 1510 else {
1513 ocfs2_log_dlm_error("dlmlock", ret, lockres); 1511 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres);
1514 ret = -EINVAL; 1512 ret = -EINVAL;
1515 } 1513 }
1516 1514
@@ -2699,15 +2697,15 @@ static int ocfs2_drop_lock(struct ocfs2_super *osb,
2699 2697
2700 mlog(0, "lock %s\n", lockres->l_name); 2698 mlog(0, "lock %s\n", lockres->l_name);
2701 2699
2702 status = dlmunlock(osb->dlm, &lockres->l_lksb, lkm_flags, 2700 status = ocfs2_dlm_unlock(osb->dlm, &lockres->l_lksb, lkm_flags,
2703 ocfs2_unlock_ast, lockres); 2701 lockres);
2704 if (status != DLM_NORMAL) { 2702 if (status != DLM_NORMAL) {
2705 ocfs2_log_dlm_error("dlmunlock", status, lockres); 2703 ocfs2_log_dlm_error("ocfs2_dlm_unlock", status, lockres);
2706 mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags); 2704 mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags);
2707 dlm_print_one_lock(lockres->l_lksb.lockid); 2705 dlm_print_one_lock(lockres->l_lksb.lockid);
2708 BUG(); 2706 BUG();
2709 } 2707 }
2710 mlog(0, "lock %s, successfull return from dlmunlock\n", 2708 mlog(0, "lock %s, successfull return from ocfs2_dlm_unlock\n",
2711 lockres->l_name); 2709 lockres->l_name);
2712 2710
2713 ocfs2_wait_on_busy_lock(lockres); 2711 ocfs2_wait_on_busy_lock(lockres);
@@ -2832,17 +2830,15 @@ static int ocfs2_downconvert_lock(struct ocfs2_super *osb,
2832 if (lvb) 2830 if (lvb)
2833 dlm_flags |= LKM_VALBLK; 2831 dlm_flags |= LKM_VALBLK;
2834 2832
2835 status = dlmlock(osb->dlm, 2833 status = ocfs2_dlm_lock(osb->dlm,
2836 new_level, 2834 new_level,
2837 &lockres->l_lksb, 2835 &lockres->l_lksb,
2838 dlm_flags, 2836 dlm_flags,
2839 lockres->l_name, 2837 lockres->l_name,
2840 OCFS2_LOCK_ID_MAX_LEN - 1, 2838 OCFS2_LOCK_ID_MAX_LEN - 1,
2841 ocfs2_locking_ast, 2839 lockres);
2842 lockres,
2843 ocfs2_blocking_ast);
2844 if (status != DLM_NORMAL) { 2840 if (status != DLM_NORMAL) {
2845 ocfs2_log_dlm_error("dlmlock", status, lockres); 2841 ocfs2_log_dlm_error("ocfs2_dlm_lock", status, lockres);
2846 ret = -EINVAL; 2842 ret = -EINVAL;
2847 ocfs2_recover_from_dlm_error(lockres, 1); 2843 ocfs2_recover_from_dlm_error(lockres, 1);
2848 goto bail; 2844 goto bail;
@@ -2854,7 +2850,7 @@ bail:
2854 return ret; 2850 return ret;
2855} 2851}
2856 2852
2857/* returns 1 when the caller should unlock and call dlmunlock */ 2853/* returns 1 when the caller should unlock and call ocfs2_dlm_unlock */
2858static int ocfs2_prepare_cancel_convert(struct ocfs2_super *osb, 2854static int ocfs2_prepare_cancel_convert(struct ocfs2_super *osb,
2859 struct ocfs2_lock_res *lockres) 2855 struct ocfs2_lock_res *lockres)
2860{ 2856{
@@ -2896,18 +2892,17 @@ static int ocfs2_cancel_convert(struct ocfs2_super *osb,
2896 mlog(0, "lock %s\n", lockres->l_name); 2892 mlog(0, "lock %s\n", lockres->l_name);
2897 2893
2898 ret = 0; 2894 ret = 0;
2899 status = dlmunlock(osb->dlm, 2895 status = ocfs2_dlm_unlock(osb->dlm,
2900 &lockres->l_lksb, 2896 &lockres->l_lksb,
2901 LKM_CANCEL, 2897 LKM_CANCEL,
2902 ocfs2_unlock_ast, 2898 lockres);
2903 lockres);
2904 if (status != DLM_NORMAL) { 2899 if (status != DLM_NORMAL) {
2905 ocfs2_log_dlm_error("dlmunlock", status, lockres); 2900 ocfs2_log_dlm_error("ocfs2_dlm_unlock", status, lockres);
2906 ret = -EINVAL; 2901 ret = -EINVAL;
2907 ocfs2_recover_from_dlm_error(lockres, 0); 2902 ocfs2_recover_from_dlm_error(lockres, 0);
2908 } 2903 }
2909 2904
2910 mlog(0, "lock %s return from dlmunlock\n", lockres->l_name); 2905 mlog(0, "lock %s return from ocfs2_dlm_unlock\n", lockres->l_name);
2911 2906
2912 mlog_exit(ret); 2907 mlog_exit(ret);
2913 return ret; 2908 return ret;
@@ -3211,6 +3206,23 @@ static int ocfs2_dentry_convert_worker(struct ocfs2_lock_res *lockres,
3211 return UNBLOCK_CONTINUE_POST; 3206 return UNBLOCK_CONTINUE_POST;
3212} 3207}
3213 3208
3209static struct ocfs2_locking_protocol lproto = {
3210 .lp_lock_ast = ocfs2_locking_ast,
3211 .lp_blocking_ast = ocfs2_blocking_ast,
3212 .lp_unlock_ast = ocfs2_unlock_ast,
3213};
3214
3215/* This interface isn't the final one, hence the less-than-perfect names */
3216void dlmglue_init_stack(void)
3217{
3218 o2cb_get_stack(&lproto);
3219}
3220
3221void dlmglue_exit_stack(void)
3222{
3223 o2cb_put_stack();
3224}
3225
3214static void ocfs2_process_blocked_lock(struct ocfs2_super *osb, 3226static void ocfs2_process_blocked_lock(struct ocfs2_super *osb,
3215 struct ocfs2_lock_res *lockres) 3227 struct ocfs2_lock_res *lockres)
3216{ 3228{
diff --git a/fs/ocfs2/dlmglue.h b/fs/ocfs2/dlmglue.h
index e3cf902404b..32380439401 100644
--- a/fs/ocfs2/dlmglue.h
+++ b/fs/ocfs2/dlmglue.h
@@ -114,5 +114,8 @@ void ocfs2_wake_downconvert_thread(struct ocfs2_super *osb);
114struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void); 114struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void);
115void ocfs2_put_dlm_debug(struct ocfs2_dlm_debug *dlm_debug); 115void ocfs2_put_dlm_debug(struct ocfs2_dlm_debug *dlm_debug);
116 116
117void dlmglue_init_stack(void);
118void dlmglue_exit_stack(void);
119
117extern const struct dlm_protocol_version ocfs2_locking_protocol; 120extern const struct dlm_protocol_version ocfs2_locking_protocol;
118#endif /* DLMGLUE_H */ 121#endif /* DLMGLUE_H */
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
new file mode 100644
index 00000000000..4f44f23795f
--- /dev/null
+++ b/fs/ocfs2/stackglue.c
@@ -0,0 +1,65 @@
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * stackglue.c
5 *
6 * Code which implements an OCFS2 specific interface to underlying
7 * cluster stacks.
8 *
9 * Copyright (C) 2007 Oracle. All rights reserved.
10 *
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.
14 *
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.
19 */
20
21#include <linux/types.h>
22#include <linux/list.h>
23
24#include "dlm/dlmapi.h"
25
26#include "stackglue.h"
27
28static struct ocfs2_locking_protocol *lproto;
29
30enum dlm_status ocfs2_dlm_lock(struct dlm_ctxt *dlm,
31 int mode,
32 struct dlm_lockstatus *lksb,
33 u32 flags,
34 void *name,
35 unsigned int namelen,
36 void *astarg)
37{
38 BUG_ON(lproto == NULL);
39 return dlmlock(dlm, mode, lksb, flags, name, namelen,
40 lproto->lp_lock_ast, astarg,
41 lproto->lp_blocking_ast);
42}
43
44enum dlm_status ocfs2_dlm_unlock(struct dlm_ctxt *dlm,
45 struct dlm_lockstatus *lksb,
46 u32 flags,
47 void *astarg)
48{
49 BUG_ON(lproto == NULL);
50
51 return dlmunlock(dlm, lksb, flags, lproto->lp_unlock_ast, astarg);
52}
53
54
55void o2cb_get_stack(struct ocfs2_locking_protocol *proto)
56{
57 BUG_ON(proto == NULL);
58
59 lproto = proto;
60}
61
62void o2cb_put_stack(void)
63{
64 lproto = NULL;
65}
diff --git a/fs/ocfs2/stackglue.h b/fs/ocfs2/stackglue.h
new file mode 100644
index 00000000000..40a00241340
--- /dev/null
+++ b/fs/ocfs2/stackglue.h
@@ -0,0 +1,45 @@
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * stackglue.h
5 *
6 * Glue to the underlying cluster stack.
7 *
8 * Copyright (C) 2007 Oracle. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public
12 * License as published by the Free Software Foundation, version 2.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 */
19
20
21#ifndef STACKGLUE_H
22#define STACKGLUE_H
23
24struct ocfs2_locking_protocol {
25 void (*lp_lock_ast)(void *astarg);
26 void (*lp_blocking_ast)(void *astarg, int level);
27 void (*lp_unlock_ast)(void *astarg, enum dlm_status status);
28};
29
30enum dlm_status ocfs2_dlm_lock(struct dlm_ctxt *dlm,
31 int mode,
32 struct dlm_lockstatus *lksb,
33 u32 flags,
34 void *name,
35 unsigned int namelen,
36 void *astarg);
37enum dlm_status ocfs2_dlm_unlock(struct dlm_ctxt *dlm,
38 struct dlm_lockstatus *lksb,
39 u32 flags,
40 void *astarg);
41
42void o2cb_get_stack(struct ocfs2_locking_protocol *proto);
43void o2cb_put_stack(void);
44
45#endif /* STACKGLUE_H */
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 1a4c7c7850f..c8675464e29 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -933,6 +933,8 @@ static int __init ocfs2_init(void)
933 933
934 ocfs2_print_version(); 934 ocfs2_print_version();
935 935
936 dlmglue_init_stack();
937
936 status = init_ocfs2_uptodate_cache(); 938 status = init_ocfs2_uptodate_cache();
937 if (status < 0) { 939 if (status < 0) {
938 mlog_errno(status); 940 mlog_errno(status);
@@ -988,6 +990,8 @@ static void __exit ocfs2_exit(void)
988 990
989 exit_ocfs2_uptodate_cache(); 991 exit_ocfs2_uptodate_cache();
990 992
993 dlmglue_exit_stack();
994
991 mlog_exit_void(); 995 mlog_exit_void();
992} 996}
993 997