diff options
author | Joel Becker <joel.becker@oracle.com> | 2008-02-01 15:14:57 -0500 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2008-04-18 11:56:03 -0400 |
commit | bd3e76105d4478ab89951a52d1a35250d24a9f16 (patch) | |
tree | 3a024471d62491f0160031663e0db23f42be37b8 /fs/ocfs2/stackglue.c | |
parent | 24ef1815e5e13e50196eb1ab8ddc0d783443bdf8 (diff) |
ocfs2: Use global DLM_ constants in generic code.
The ocfs2 generic code should use the values in <linux/dlmconstants.h>.
stackglue.c will convert them to o2dlm values.
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/stackglue.c')
-rw-r--r-- | fs/ocfs2/stackglue.c | 71 |
1 files changed, 64 insertions, 7 deletions
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c index 4f44f23795f0..99538043fc17 100644 --- a/fs/ocfs2/stackglue.c +++ b/fs/ocfs2/stackglue.c | |||
@@ -18,15 +18,65 @@ | |||
18 | * General Public License for more details. | 18 | * General Public License for more details. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/types.h> | ||
22 | #include <linux/list.h> | ||
23 | |||
24 | #include "dlm/dlmapi.h" | ||
25 | |||
26 | #include "stackglue.h" | 21 | #include "stackglue.h" |
27 | 22 | ||
28 | static struct ocfs2_locking_protocol *lproto; | 23 | static struct ocfs2_locking_protocol *lproto; |
29 | 24 | ||
25 | /* These should be identical */ | ||
26 | #if (DLM_LOCK_IV != LKM_IVMODE) | ||
27 | # error Lock modes do not match | ||
28 | #endif | ||
29 | #if (DLM_LOCK_NL != LKM_NLMODE) | ||
30 | # error Lock modes do not match | ||
31 | #endif | ||
32 | #if (DLM_LOCK_CR != LKM_CRMODE) | ||
33 | # error Lock modes do not match | ||
34 | #endif | ||
35 | #if (DLM_LOCK_CW != LKM_CWMODE) | ||
36 | # error Lock modes do not match | ||
37 | #endif | ||
38 | #if (DLM_LOCK_PR != LKM_PRMODE) | ||
39 | # error Lock modes do not match | ||
40 | #endif | ||
41 | #if (DLM_LOCK_PW != LKM_PWMODE) | ||
42 | # error Lock modes do not match | ||
43 | #endif | ||
44 | #if (DLM_LOCK_EX != LKM_EXMODE) | ||
45 | # error Lock modes do not match | ||
46 | #endif | ||
47 | static inline int mode_to_o2dlm(int mode) | ||
48 | { | ||
49 | BUG_ON(mode > LKM_MAXMODE); | ||
50 | |||
51 | return mode; | ||
52 | } | ||
53 | |||
54 | #define map_flag(_generic, _o2dlm) \ | ||
55 | if (flags & (_generic)) { \ | ||
56 | flags &= ~(_generic); \ | ||
57 | o2dlm_flags |= (_o2dlm); \ | ||
58 | } | ||
59 | static int flags_to_o2dlm(u32 flags) | ||
60 | { | ||
61 | int o2dlm_flags = 0; | ||
62 | |||
63 | map_flag(DLM_LKF_NOQUEUE, LKM_NOQUEUE); | ||
64 | map_flag(DLM_LKF_CANCEL, LKM_CANCEL); | ||
65 | map_flag(DLM_LKF_CONVERT, LKM_CONVERT); | ||
66 | map_flag(DLM_LKF_VALBLK, LKM_VALBLK); | ||
67 | map_flag(DLM_LKF_IVVALBLK, LKM_INVVALBLK); | ||
68 | map_flag(DLM_LKF_ORPHAN, LKM_ORPHAN); | ||
69 | map_flag(DLM_LKF_FORCEUNLOCK, LKM_FORCE); | ||
70 | map_flag(DLM_LKF_TIMEOUT, LKM_TIMEOUT); | ||
71 | map_flag(DLM_LKF_LOCAL, LKM_LOCAL); | ||
72 | |||
73 | /* map_flag() should have cleared every flag passed in */ | ||
74 | BUG_ON(flags != 0); | ||
75 | |||
76 | return o2dlm_flags; | ||
77 | } | ||
78 | #undef map_flag | ||
79 | |||
30 | enum dlm_status ocfs2_dlm_lock(struct dlm_ctxt *dlm, | 80 | enum dlm_status ocfs2_dlm_lock(struct dlm_ctxt *dlm, |
31 | int mode, | 81 | int mode, |
32 | struct dlm_lockstatus *lksb, | 82 | struct dlm_lockstatus *lksb, |
@@ -35,8 +85,12 @@ enum dlm_status ocfs2_dlm_lock(struct dlm_ctxt *dlm, | |||
35 | unsigned int namelen, | 85 | unsigned int namelen, |
36 | void *astarg) | 86 | void *astarg) |
37 | { | 87 | { |
88 | int o2dlm_mode = mode_to_o2dlm(mode); | ||
89 | int o2dlm_flags = flags_to_o2dlm(flags); | ||
90 | |||
38 | BUG_ON(lproto == NULL); | 91 | BUG_ON(lproto == NULL); |
39 | return dlmlock(dlm, mode, lksb, flags, name, namelen, | 92 | |
93 | return dlmlock(dlm, o2dlm_mode, lksb, o2dlm_flags, name, namelen, | ||
40 | lproto->lp_lock_ast, astarg, | 94 | lproto->lp_lock_ast, astarg, |
41 | lproto->lp_blocking_ast); | 95 | lproto->lp_blocking_ast); |
42 | } | 96 | } |
@@ -46,9 +100,12 @@ enum dlm_status ocfs2_dlm_unlock(struct dlm_ctxt *dlm, | |||
46 | u32 flags, | 100 | u32 flags, |
47 | void *astarg) | 101 | void *astarg) |
48 | { | 102 | { |
103 | int o2dlm_flags = flags_to_o2dlm(flags); | ||
104 | |||
49 | BUG_ON(lproto == NULL); | 105 | BUG_ON(lproto == NULL); |
50 | 106 | ||
51 | return dlmunlock(dlm, lksb, flags, lproto->lp_unlock_ast, astarg); | 107 | return dlmunlock(dlm, lksb, o2dlm_flags, |
108 | lproto->lp_unlock_ast, astarg); | ||
52 | } | 109 | } |
53 | 110 | ||
54 | 111 | ||