]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | From: David Teigland <teigland@redhat.com> |
2 | commit fd22a51bcc0b7b76fc729b02316214fd979f9fe1 | |
3 | Author: David Teigland <teigland@redhat.com> | |
4 | Date: Tue Dec 9 11:55:46 2008 -0600 | |
5 | Subject: dlm: improve how bast mode handling | |
6 | ||
7 | The lkb bastmode value is set in the context of processing the | |
8 | lock, and read by the dlm_astd thread. Because it's accessed | |
9 | in these two separate contexts, the writing/reading ought to | |
10 | be done under a lock. This is simple to do by setting it and | |
11 | reading it when the lkb is added to and removed from dlm_astd's | |
12 | callback list which is properly locked. | |
13 | ||
14 | Signed-off-by: David Teigland <teigland@redhat.com> | |
15 | Signed-off-by: Coly Li <coly.li@suse.de> | |
16 | ||
17 | diff --git a/fs/dlm/ast.c b/fs/dlm/ast.c | |
18 | index 09b167d..fbe840d 100644 | |
19 | --- a/fs/dlm/ast.c | |
20 | +++ b/fs/dlm/ast.c | |
21 | @@ -2,7 +2,7 @@ | |
22 | ******************************************************************************* | |
23 | ** | |
24 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | |
25 | -** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. | |
26 | +** Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. | |
27 | ** | |
28 | ** This copyrighted material is made available to anyone wishing to use, | |
29 | ** modify, copy, or redistribute it subject to the terms and conditions | |
30 | @@ -33,10 +33,10 @@ void dlm_del_ast(struct dlm_lkb *lkb) | |
31 | spin_unlock(&ast_queue_lock); | |
32 | } | |
33 | ||
34 | -void dlm_add_ast(struct dlm_lkb *lkb, int type) | |
35 | +void dlm_add_ast(struct dlm_lkb *lkb, int type, int bastmode) | |
36 | { | |
37 | if (lkb->lkb_flags & DLM_IFL_USER) { | |
38 | - dlm_user_add_ast(lkb, type); | |
39 | + dlm_user_add_ast(lkb, type, bastmode); | |
40 | return; | |
41 | } | |
42 | ||
43 | @@ -46,6 +46,8 @@ void dlm_add_ast(struct dlm_lkb *lkb, int type) | |
44 | list_add_tail(&lkb->lkb_astqueue, &ast_queue); | |
45 | } | |
46 | lkb->lkb_ast_type |= type; | |
47 | + if (bastmode) | |
48 | + lkb->lkb_bastmode = bastmode; | |
49 | spin_unlock(&ast_queue_lock); | |
50 | ||
51 | set_bit(WAKE_ASTS, &astd_wakeflags); | |
52 | @@ -59,7 +61,7 @@ static void process_asts(void) | |
53 | struct dlm_lkb *lkb; | |
54 | void (*cast) (void *astparam); | |
55 | void (*bast) (void *astparam, int mode); | |
56 | - int type = 0, found, bmode; | |
57 | + int type = 0, found, bastmode; | |
58 | ||
59 | for (;;) { | |
60 | found = 0; | |
61 | @@ -74,6 +76,7 @@ static void process_asts(void) | |
62 | list_del(&lkb->lkb_astqueue); | |
63 | type = lkb->lkb_ast_type; | |
64 | lkb->lkb_ast_type = 0; | |
65 | + bastmode = lkb->lkb_bastmode; | |
66 | found = 1; | |
67 | break; | |
68 | } | |
69 | @@ -84,13 +87,12 @@ static void process_asts(void) | |
70 | ||
71 | cast = lkb->lkb_astfn; | |
72 | bast = lkb->lkb_bastfn; | |
73 | - bmode = lkb->lkb_bastmode; | |
74 | ||
75 | if ((type & AST_COMP) && cast) | |
76 | cast(lkb->lkb_astparam); | |
77 | ||
78 | if ((type & AST_BAST) && bast) | |
79 | - bast(lkb->lkb_astparam, bmode); | |
80 | + bast(lkb->lkb_astparam, bastmode); | |
81 | ||
82 | /* this removes the reference added by dlm_add_ast | |
83 | and may result in the lkb being freed */ | |
84 | diff --git a/fs/dlm/ast.h b/fs/dlm/ast.h | |
85 | index 6ee276c..1b5fc5f 100644 | |
86 | --- a/fs/dlm/ast.h | |
87 | +++ b/fs/dlm/ast.h | |
88 | @@ -1,7 +1,7 @@ | |
89 | /****************************************************************************** | |
90 | ******************************************************************************* | |
91 | ** | |
92 | -** Copyright (C) 2005 Red Hat, Inc. All rights reserved. | |
93 | +** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved. | |
94 | ** | |
95 | ** This copyrighted material is made available to anyone wishing to use, | |
96 | ** modify, copy, or redistribute it subject to the terms and conditions | |
97 | @@ -13,7 +13,7 @@ | |
98 | #ifndef __ASTD_DOT_H__ | |
99 | #define __ASTD_DOT_H__ | |
100 | ||
101 | -void dlm_add_ast(struct dlm_lkb *lkb, int type); | |
102 | +void dlm_add_ast(struct dlm_lkb *lkb, int type, int bastmode); | |
103 | void dlm_del_ast(struct dlm_lkb *lkb); | |
104 | ||
105 | void dlm_astd_wake(void); | |
106 | diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c | |
107 | index 724ddac..7b758da 100644 | |
108 | --- a/fs/dlm/lock.c | |
109 | +++ b/fs/dlm/lock.c | |
110 | @@ -307,7 +307,7 @@ static void queue_cast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rv) | |
111 | lkb->lkb_lksb->sb_status = rv; | |
112 | lkb->lkb_lksb->sb_flags = lkb->lkb_sbflags; | |
113 | ||
114 | - dlm_add_ast(lkb, AST_COMP); | |
115 | + dlm_add_ast(lkb, AST_COMP, 0); | |
116 | } | |
117 | ||
118 | static inline void queue_cast_overlap(struct dlm_rsb *r, struct dlm_lkb *lkb) | |
119 | @@ -320,10 +320,8 @@ static void queue_bast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rqmode) | |
120 | { | |
121 | if (is_master_copy(lkb)) | |
122 | send_bast(r, lkb, rqmode); | |
123 | - else { | |
124 | - lkb->lkb_bastmode = rqmode; | |
125 | - dlm_add_ast(lkb, AST_BAST); | |
126 | - } | |
127 | + else | |
128 | + dlm_add_ast(lkb, AST_BAST, rqmode); | |
129 | } | |
130 | ||
131 | /* | |
132 | diff --git a/fs/dlm/user.c b/fs/dlm/user.c | |
133 | index b3832c6..065149e 100644 | |
134 | --- a/fs/dlm/user.c | |
135 | +++ b/fs/dlm/user.c | |
136 | @@ -175,7 +175,7 @@ static int lkb_is_endoflife(struct dlm_lkb *lkb, int sb_status, int type) | |
137 | /* we could possibly check if the cancel of an orphan has resulted in the lkb | |
138 | being removed and then remove that lkb from the orphans list and free it */ | |
139 | ||
140 | -void dlm_user_add_ast(struct dlm_lkb *lkb, int type) | |
141 | +void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int bastmode) | |
142 | { | |
143 | struct dlm_ls *ls; | |
144 | struct dlm_user_args *ua; | |
145 | @@ -208,6 +208,8 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, int type) | |
146 | ||
147 | ast_type = lkb->lkb_ast_type; | |
148 | lkb->lkb_ast_type |= type; | |
149 | + if (bastmode) | |
150 | + lkb->lkb_bastmode = bastmode; | |
151 | ||
152 | if (!ast_type) { | |
153 | kref_get(&lkb->lkb_ref); | |
154 | diff --git a/fs/dlm/user.h b/fs/dlm/user.h | |
155 | index 35eb6a1..1c96864 100644 | |
156 | --- a/fs/dlm/user.h | |
157 | +++ b/fs/dlm/user.h | |
158 | @@ -9,7 +9,7 @@ | |
159 | #ifndef __USER_DOT_H__ | |
160 | #define __USER_DOT_H__ | |
161 | ||
162 | -void dlm_user_add_ast(struct dlm_lkb *lkb, int type); | |
163 | +void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int bastmode); | |
164 | int dlm_user_init(void); | |
165 | void dlm_user_exit(void); | |
166 | int dlm_device_deregister(struct dlm_ls *ls); |