1 From cf6620acc0f6fac57968aafef79ab372bdcf6157 Mon Sep 17 00:00:00 2001
2 From: David Teigland <teigland@redhat.com>
3 Date: Wed, 24 Feb 2010 11:59:23 -0600
4 Subject: dlm: send reply before bast
6 From: David Teigland <teigland@redhat.com>
8 commit cf6620acc0f6fac57968aafef79ab372bdcf6157 upstream.
10 When the lock master processes a successful operation (request,
11 convert, cancel, or unlock), it will process the effects of the
12 change before sending the reply for the operation. The "effects"
15 - blocking callbacks (basts) for any newly granted locks
16 - waiting or converting locks that can now be granted
18 The cast is queued on the local node when the reply from the lock
19 master is received. This means that a lock holder can receive a
20 bast for a lock mode that is doesn't yet know has been granted.
22 Signed-off-by: David Teigland <teigland@redhat.com>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
26 fs/dlm/lock.c | 110 ++++++++++++++++++++++++++++++++++++++++++++--------------
27 1 file changed, 84 insertions(+), 26 deletions(-)
31 @@ -2280,20 +2280,30 @@ static int do_request(struct dlm_rsb *r,
32 if (can_be_queued(lkb)) {
34 add_lkb(r, lkb, DLM_LKSTS_WAITING);
35 - send_blocking_asts(r, lkb);
41 - if (force_blocking_asts(lkb))
42 - send_blocking_asts_all(r, lkb);
43 queue_cast(r, lkb, -EAGAIN);
49 +static void do_request_effects(struct dlm_rsb *r, struct dlm_lkb *lkb,
54 + if (force_blocking_asts(lkb))
55 + send_blocking_asts_all(r, lkb);
58 + send_blocking_asts(r, lkb);
63 static int do_convert(struct dlm_rsb *r, struct dlm_lkb *lkb)
66 @@ -2304,7 +2314,6 @@ static int do_convert(struct dlm_rsb *r,
67 if (can_be_granted(r, lkb, 1, &deadlk)) {
69 queue_cast(r, lkb, 0);
70 - grant_pending_locks(r);
74 @@ -2334,7 +2343,6 @@ static int do_convert(struct dlm_rsb *r,
75 if (_can_be_granted(r, lkb, 1)) {
77 queue_cast(r, lkb, 0);
78 - grant_pending_locks(r);
81 /* else fall through and move to convert queue */
82 @@ -2344,28 +2352,47 @@ static int do_convert(struct dlm_rsb *r,
85 add_lkb(r, lkb, DLM_LKSTS_CONVERT);
86 - send_blocking_asts(r, lkb);
92 - if (force_blocking_asts(lkb))
93 - send_blocking_asts_all(r, lkb);
94 queue_cast(r, lkb, -EAGAIN);
100 +static void do_convert_effects(struct dlm_rsb *r, struct dlm_lkb *lkb,
105 + grant_pending_locks(r);
106 + /* grant_pending_locks also sends basts */
109 + if (force_blocking_asts(lkb))
110 + send_blocking_asts_all(r, lkb);
113 + send_blocking_asts(r, lkb);
118 static int do_unlock(struct dlm_rsb *r, struct dlm_lkb *lkb)
121 queue_cast(r, lkb, -DLM_EUNLOCK);
122 - grant_pending_locks(r);
126 +static void do_unlock_effects(struct dlm_rsb *r, struct dlm_lkb *lkb,
129 + grant_pending_locks(r);
132 /* returns: 0 did nothing, -DLM_ECANCEL canceled lock */
134 static int do_cancel(struct dlm_rsb *r, struct dlm_lkb *lkb)
135 @@ -2375,12 +2402,18 @@ static int do_cancel(struct dlm_rsb *r,
136 error = revert_lock(r, lkb);
138 queue_cast(r, lkb, -DLM_ECANCEL);
139 - grant_pending_locks(r);
145 +static void do_cancel_effects(struct dlm_rsb *r, struct dlm_lkb *lkb,
149 + grant_pending_locks(r);
153 * Four stage 3 varieties:
154 * _request_lock(), _convert_lock(), _unlock_lock(), _cancel_lock()
155 @@ -2402,11 +2435,15 @@ static int _request_lock(struct dlm_rsb
160 + if (is_remote(r)) {
161 /* receive_request() calls do_request() on remote node */
162 error = send_request(r, lkb);
165 error = do_request(r, lkb);
166 + /* for remote locks the request_reply is sent
167 + between do_request and do_request_effects */
168 + do_request_effects(r, lkb, error);
173 @@ -2417,11 +2454,15 @@ static int _convert_lock(struct dlm_rsb
178 + if (is_remote(r)) {
179 /* receive_convert() calls do_convert() on remote node */
180 error = send_convert(r, lkb);
183 error = do_convert(r, lkb);
184 + /* for remote locks the convert_reply is sent
185 + between do_convert and do_convert_effects */
186 + do_convert_effects(r, lkb, error);
191 @@ -2432,11 +2473,15 @@ static int _unlock_lock(struct dlm_rsb *
196 + if (is_remote(r)) {
197 /* receive_unlock() calls do_unlock() on remote node */
198 error = send_unlock(r, lkb);
201 error = do_unlock(r, lkb);
202 + /* for remote locks the unlock_reply is sent
203 + between do_unlock and do_unlock_effects */
204 + do_unlock_effects(r, lkb, error);
209 @@ -2447,11 +2492,15 @@ static int _cancel_lock(struct dlm_rsb *
214 + if (is_remote(r)) {
215 /* receive_cancel() calls do_cancel() on remote node */
216 error = send_cancel(r, lkb);
219 error = do_cancel(r, lkb);
220 + /* for remote locks the cancel_reply is sent
221 + between do_cancel and do_cancel_effects */
222 + do_cancel_effects(r, lkb, error);
227 @@ -3191,6 +3240,7 @@ static void receive_request(struct dlm_l
229 error = do_request(r, lkb);
230 send_request_reply(r, lkb, error);
231 + do_request_effects(r, lkb, error);
235 @@ -3226,15 +3276,19 @@ static void receive_convert(struct dlm_l
238 receive_flags(lkb, ms);
240 error = receive_convert_args(ls, lkb, ms);
244 + send_convert_reply(r, lkb, error);
248 reply = !down_conversion(lkb);
250 error = do_convert(r, lkb);
253 send_convert_reply(r, lkb, error);
254 + do_convert_effects(r, lkb, error);
258 @@ -3266,13 +3320,16 @@ static void receive_unlock(struct dlm_ls
261 receive_flags(lkb, ms);
263 error = receive_unlock_args(ls, lkb, ms);
267 + send_unlock_reply(r, lkb, error);
271 error = do_unlock(r, lkb);
273 send_unlock_reply(r, lkb, error);
274 + do_unlock_effects(r, lkb, error);
278 @@ -3307,6 +3364,7 @@ static void receive_cancel(struct dlm_ls
280 error = do_cancel(r, lkb);
281 send_cancel_reply(r, lkb, error);
282 + do_cancel_effects(r, lkb, error);