diff options
author | Joel Becker <joel.becker@oracle.com> | 2008-02-01 15:16:57 -0500 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2008-04-18 11:56:04 -0400 |
commit | 8f2c9c1b16bf6ed0903b29c49d56fa0109a390e4 (patch) | |
tree | 8564370d96cbfb3a0125f17c93ee3587efef1ed1 | |
parent | 7431cd7e8dd0e46e9b12bd6a1ac1286f4b420371 (diff) |
ocfs2: Create the lock status block union.
Wrap the lock status block (lksb) in a union. Later we will add a union
element for the fs/dlm lksb. Create accessors for the status and lvb
fields.
Other than a debugging function, dlmglue.c does not directly reference
the o2dlm locking path anymore.
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
-rw-r--r-- | fs/ocfs2/dlmglue.c | 23 | ||||
-rw-r--r-- | fs/ocfs2/ocfs2.h | 5 | ||||
-rw-r--r-- | fs/ocfs2/stackglue.c | 29 | ||||
-rw-r--r-- | fs/ocfs2/stackglue.h | 11 |
4 files changed, 47 insertions, 21 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 6a222a5c81da..459037653e5a 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c | |||
@@ -112,7 +112,8 @@ static void ocfs2_dump_meta_lvb_info(u64 level, | |||
112 | unsigned int line, | 112 | unsigned int line, |
113 | struct ocfs2_lock_res *lockres) | 113 | struct ocfs2_lock_res *lockres) |
114 | { | 114 | { |
115 | struct ocfs2_meta_lvb *lvb = (struct ocfs2_meta_lvb *) lockres->l_lksb.lvb; | 115 | struct ocfs2_meta_lvb *lvb = |
116 | (struct ocfs2_meta_lvb *)ocfs2_dlm_lvb(&lockres->l_lksb); | ||
116 | 117 | ||
117 | mlog(level, "LVB information for %s (called from %s:%u):\n", | 118 | mlog(level, "LVB information for %s (called from %s:%u):\n", |
118 | lockres->l_name, function, line); | 119 | lockres->l_name, function, line); |
@@ -799,14 +800,14 @@ static void ocfs2_blocking_ast(void *opaque, int level) | |||
799 | static void ocfs2_locking_ast(void *opaque) | 800 | static void ocfs2_locking_ast(void *opaque) |
800 | { | 801 | { |
801 | struct ocfs2_lock_res *lockres = opaque; | 802 | struct ocfs2_lock_res *lockres = opaque; |
802 | struct dlm_lockstatus *lksb = &lockres->l_lksb; | ||
803 | unsigned long flags; | 803 | unsigned long flags; |
804 | 804 | ||
805 | spin_lock_irqsave(&lockres->l_lock, flags); | 805 | spin_lock_irqsave(&lockres->l_lock, flags); |
806 | 806 | ||
807 | if (lksb->status != DLM_NORMAL) { | 807 | if (ocfs2_dlm_lock_status(&lockres->l_lksb)) { |
808 | mlog(ML_ERROR, "lockres %s: lksb status value of %u!\n", | 808 | mlog(ML_ERROR, "lockres %s: lksb status value of %d!\n", |
809 | lockres->l_name, lksb->status); | 809 | lockres->l_name, |
810 | ocfs2_dlm_lock_status(&lockres->l_lksb)); | ||
810 | spin_unlock_irqrestore(&lockres->l_lock, flags); | 811 | spin_unlock_irqrestore(&lockres->l_lock, flags); |
811 | return; | 812 | return; |
812 | } | 813 | } |
@@ -1634,7 +1635,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode) | |||
1634 | 1635 | ||
1635 | mlog_entry_void(); | 1636 | mlog_entry_void(); |
1636 | 1637 | ||
1637 | lvb = (struct ocfs2_meta_lvb *) lockres->l_lksb.lvb; | 1638 | lvb = (struct ocfs2_meta_lvb *)ocfs2_dlm_lvb(&lockres->l_lksb); |
1638 | 1639 | ||
1639 | /* | 1640 | /* |
1640 | * Invalidate the LVB of a deleted inode - this way other | 1641 | * Invalidate the LVB of a deleted inode - this way other |
@@ -1686,7 +1687,7 @@ static void ocfs2_refresh_inode_from_lvb(struct inode *inode) | |||
1686 | 1687 | ||
1687 | mlog_meta_lvb(0, lockres); | 1688 | mlog_meta_lvb(0, lockres); |
1688 | 1689 | ||
1689 | lvb = (struct ocfs2_meta_lvb *) lockres->l_lksb.lvb; | 1690 | lvb = (struct ocfs2_meta_lvb *)ocfs2_dlm_lvb(&lockres->l_lksb); |
1690 | 1691 | ||
1691 | /* We're safe here without the lockres lock... */ | 1692 | /* We're safe here without the lockres lock... */ |
1692 | spin_lock(&oi->ip_lock); | 1693 | spin_lock(&oi->ip_lock); |
@@ -1721,7 +1722,8 @@ static void ocfs2_refresh_inode_from_lvb(struct inode *inode) | |||
1721 | static inline int ocfs2_meta_lvb_is_trustable(struct inode *inode, | 1722 | static inline int ocfs2_meta_lvb_is_trustable(struct inode *inode, |
1722 | struct ocfs2_lock_res *lockres) | 1723 | struct ocfs2_lock_res *lockres) |
1723 | { | 1724 | { |
1724 | struct ocfs2_meta_lvb *lvb = (struct ocfs2_meta_lvb *) lockres->l_lksb.lvb; | 1725 | struct ocfs2_meta_lvb *lvb = |
1726 | (struct ocfs2_meta_lvb *)ocfs2_dlm_lvb(&lockres->l_lksb); | ||
1725 | 1727 | ||
1726 | if (lvb->lvb_version == OCFS2_LVB_VERSION | 1728 | if (lvb->lvb_version == OCFS2_LVB_VERSION |
1727 | && be32_to_cpu(lvb->lvb_igeneration) == inode->i_generation) | 1729 | && be32_to_cpu(lvb->lvb_igeneration) == inode->i_generation) |
@@ -2379,7 +2381,7 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) | |||
2379 | lockres->l_blocking); | 2381 | lockres->l_blocking); |
2380 | 2382 | ||
2381 | /* Dump the raw LVB */ | 2383 | /* Dump the raw LVB */ |
2382 | lvb = lockres->l_lksb.lvb; | 2384 | lvb = ocfs2_dlm_lvb(&lockres->l_lksb); |
2383 | for(i = 0; i < DLM_LVB_LEN; i++) | 2385 | for(i = 0; i < DLM_LVB_LEN; i++) |
2384 | seq_printf(m, "0x%x\t", lvb[i]); | 2386 | seq_printf(m, "0x%x\t", lvb[i]); |
2385 | 2387 | ||
@@ -2692,7 +2694,8 @@ static int ocfs2_drop_lock(struct ocfs2_super *osb, | |||
2692 | if (ret) { | 2694 | if (ret) { |
2693 | ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres); | 2695 | ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres); |
2694 | mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags); | 2696 | mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags); |
2695 | dlm_print_one_lock(lockres->l_lksb.lockid); | 2697 | /* XXX Need to abstract this */ |
2698 | dlm_print_one_lock(lockres->l_lksb.lksb_o2dlm.lockid); | ||
2696 | BUG(); | 2699 | BUG(); |
2697 | } | 2700 | } |
2698 | mlog(0, "lock %s, successfull return from ocfs2_dlm_unlock\n", | 2701 | mlog(0, "lock %s, successfull return from ocfs2_dlm_unlock\n", |
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index f78e9ed53249..6d7c6d2d0c23 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h | |||
@@ -40,7 +40,8 @@ | |||
40 | #include "cluster/heartbeat.h" | 40 | #include "cluster/heartbeat.h" |
41 | #include "cluster/tcp.h" | 41 | #include "cluster/tcp.h" |
42 | 42 | ||
43 | #include "dlm/dlmapi.h" | 43 | /* For union ocfs2_dlm_lksb */ |
44 | #include "stackglue.h" | ||
44 | 45 | ||
45 | #include "ocfs2_fs.h" | 46 | #include "ocfs2_fs.h" |
46 | #include "ocfs2_lockid.h" | 47 | #include "ocfs2_lockid.h" |
@@ -120,7 +121,7 @@ struct ocfs2_lock_res { | |||
120 | int l_level; | 121 | int l_level; |
121 | unsigned int l_ro_holders; | 122 | unsigned int l_ro_holders; |
122 | unsigned int l_ex_holders; | 123 | unsigned int l_ex_holders; |
123 | struct dlm_lockstatus l_lksb; | 124 | union ocfs2_dlm_lksb l_lksb; |
124 | 125 | ||
125 | /* used from AST/BAST funcs. */ | 126 | /* used from AST/BAST funcs. */ |
126 | enum ocfs2_ast_action l_action; | 127 | enum ocfs2_ast_action l_action; |
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c index 0aec2fcf2175..eb88854cb976 100644 --- a/fs/ocfs2/stackglue.c +++ b/fs/ocfs2/stackglue.c | |||
@@ -199,7 +199,7 @@ static void o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status) | |||
199 | 199 | ||
200 | int ocfs2_dlm_lock(struct dlm_ctxt *dlm, | 200 | int ocfs2_dlm_lock(struct dlm_ctxt *dlm, |
201 | int mode, | 201 | int mode, |
202 | struct dlm_lockstatus *lksb, | 202 | union ocfs2_dlm_lksb *lksb, |
203 | u32 flags, | 203 | u32 flags, |
204 | void *name, | 204 | void *name, |
205 | unsigned int namelen, | 205 | unsigned int namelen, |
@@ -212,15 +212,16 @@ int ocfs2_dlm_lock(struct dlm_ctxt *dlm, | |||
212 | 212 | ||
213 | BUG_ON(lproto == NULL); | 213 | BUG_ON(lproto == NULL); |
214 | 214 | ||
215 | status = dlmlock(dlm, o2dlm_mode, lksb, o2dlm_flags, name, namelen, | 215 | status = dlmlock(dlm, o2dlm_mode, &lksb->lksb_o2dlm, o2dlm_flags, |
216 | o2dlm_lock_ast_wrapper, astarg, | 216 | name, namelen, |
217 | o2dlm_blocking_ast_wrapper); | 217 | o2dlm_lock_ast_wrapper, astarg, |
218 | o2dlm_blocking_ast_wrapper); | ||
218 | ret = dlm_status_to_errno(status); | 219 | ret = dlm_status_to_errno(status); |
219 | return ret; | 220 | return ret; |
220 | } | 221 | } |
221 | 222 | ||
222 | int ocfs2_dlm_unlock(struct dlm_ctxt *dlm, | 223 | int ocfs2_dlm_unlock(struct dlm_ctxt *dlm, |
223 | struct dlm_lockstatus *lksb, | 224 | union ocfs2_dlm_lksb *lksb, |
224 | u32 flags, | 225 | u32 flags, |
225 | void *astarg) | 226 | void *astarg) |
226 | { | 227 | { |
@@ -230,12 +231,26 @@ int ocfs2_dlm_unlock(struct dlm_ctxt *dlm, | |||
230 | 231 | ||
231 | BUG_ON(lproto == NULL); | 232 | BUG_ON(lproto == NULL); |
232 | 233 | ||
233 | status = dlmunlock(dlm, lksb, o2dlm_flags, | 234 | status = dlmunlock(dlm, &lksb->lksb_o2dlm, o2dlm_flags, |
234 | o2dlm_unlock_ast_wrapper, astarg); | 235 | o2dlm_unlock_ast_wrapper, astarg); |
235 | ret = dlm_status_to_errno(status); | 236 | ret = dlm_status_to_errno(status); |
236 | return ret; | 237 | return ret; |
237 | } | 238 | } |
238 | 239 | ||
240 | int ocfs2_dlm_lock_status(union ocfs2_dlm_lksb *lksb) | ||
241 | { | ||
242 | return dlm_status_to_errno(lksb->lksb_o2dlm.status); | ||
243 | } | ||
244 | |||
245 | /* | ||
246 | * Why don't we cast to ocfs2_meta_lvb? The "clean" answer is that we | ||
247 | * don't cast at the glue level. The real answer is that the header | ||
248 | * ordering is nigh impossible. | ||
249 | */ | ||
250 | void *ocfs2_dlm_lvb(union ocfs2_dlm_lksb *lksb) | ||
251 | { | ||
252 | return (void *)(lksb->lksb_o2dlm.lvb); | ||
253 | } | ||
239 | 254 | ||
240 | void o2cb_get_stack(struct ocfs2_locking_protocol *proto) | 255 | void o2cb_get_stack(struct ocfs2_locking_protocol *proto) |
241 | { | 256 | { |
diff --git a/fs/ocfs2/stackglue.h b/fs/ocfs2/stackglue.h index 8ebcfba62c7e..3c91e241892b 100644 --- a/fs/ocfs2/stackglue.h +++ b/fs/ocfs2/stackglue.h | |||
@@ -40,18 +40,25 @@ struct ocfs2_locking_protocol { | |||
40 | void (*lp_unlock_ast)(void *astarg, int error); | 40 | void (*lp_unlock_ast)(void *astarg, int error); |
41 | }; | 41 | }; |
42 | 42 | ||
43 | union ocfs2_dlm_lksb { | ||
44 | struct dlm_lockstatus lksb_o2dlm; | ||
45 | }; | ||
46 | |||
43 | int ocfs2_dlm_lock(struct dlm_ctxt *dlm, | 47 | int ocfs2_dlm_lock(struct dlm_ctxt *dlm, |
44 | int mode, | 48 | int mode, |
45 | struct dlm_lockstatus *lksb, | 49 | union ocfs2_dlm_lksb *lksb, |
46 | u32 flags, | 50 | u32 flags, |
47 | void *name, | 51 | void *name, |
48 | unsigned int namelen, | 52 | unsigned int namelen, |
49 | void *astarg); | 53 | void *astarg); |
50 | int ocfs2_dlm_unlock(struct dlm_ctxt *dlm, | 54 | int ocfs2_dlm_unlock(struct dlm_ctxt *dlm, |
51 | struct dlm_lockstatus *lksb, | 55 | union ocfs2_dlm_lksb *lksb, |
52 | u32 flags, | 56 | u32 flags, |
53 | void *astarg); | 57 | void *astarg); |
54 | 58 | ||
59 | int ocfs2_dlm_lock_status(union ocfs2_dlm_lksb *lksb); | ||
60 | void *ocfs2_dlm_lvb(union ocfs2_dlm_lksb *lksb); | ||
61 | |||
55 | void o2cb_get_stack(struct ocfs2_locking_protocol *proto); | 62 | void o2cb_get_stack(struct ocfs2_locking_protocol *proto); |
56 | void o2cb_put_stack(void); | 63 | void o2cb_put_stack(void); |
57 | 64 | ||