blob: b46278f9ae446ac1b139bd89c69649c66ea807b9 [file] [log] [blame]
Kurt Hackel6714d8e2005-12-15 14:31:23 -08001/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * dlmast.c
5 *
6 * AST and BAST functionality for local and remote nodes
7 *
8 * Copyright (C) 2004 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; either
13 * version 2 of the License, or (at your option) any later version.
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 * You should have received a copy of the GNU General Public
21 * License along with this program; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 * Boston, MA 021110-1307, USA.
24 *
25 */
26
27
28#include <linux/module.h>
29#include <linux/fs.h>
30#include <linux/types.h>
Kurt Hackel6714d8e2005-12-15 14:31:23 -080031#include <linux/highmem.h>
Kurt Hackel6714d8e2005-12-15 14:31:23 -080032#include <linux/init.h>
33#include <linux/sysctl.h>
34#include <linux/random.h>
35#include <linux/blkdev.h>
36#include <linux/socket.h>
37#include <linux/inet.h>
38#include <linux/spinlock.h>
39
40
41#include "cluster/heartbeat.h"
42#include "cluster/nodemanager.h"
43#include "cluster/tcp.h"
Kurt Hackel6714d8e2005-12-15 14:31:23 -080044
45#include "dlmapi.h"
46#include "dlmcommon.h"
47
48#define MLOG_MASK_PREFIX ML_DLM
49#include "cluster/masklog.h"
50
51static void dlm_update_lvb(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
52 struct dlm_lock *lock);
53static int dlm_should_cancel_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock);
54
55/* Should be called as an ast gets queued to see if the new
56 * lock level will obsolete a pending bast.
57 * For example, if dlm_thread queued a bast for an EX lock that
58 * was blocking another EX, but before sending the bast the
59 * lock owner downconverted to NL, the bast is now obsolete.
60 * Only the ast should be sent.
61 * This is needed because the lock and convert paths can queue
62 * asts out-of-band (not waiting for dlm_thread) in order to
63 * allow for LKM_NOQUEUE to get immediate responses. */
64static int dlm_should_cancel_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
65{
66 assert_spin_locked(&dlm->ast_lock);
67 assert_spin_locked(&lock->spinlock);
68
69 if (lock->ml.highest_blocked == LKM_IVMODE)
70 return 0;
71 BUG_ON(lock->ml.highest_blocked == LKM_NLMODE);
72
73 if (lock->bast_pending &&
74 list_empty(&lock->bast_list))
75 /* old bast already sent, ok */
76 return 0;
77
78 if (lock->ml.type == LKM_EXMODE)
79 /* EX blocks anything left, any bast still valid */
80 return 0;
81 else if (lock->ml.type == LKM_NLMODE)
82 /* NL blocks nothing, no reason to send any bast, cancel it */
83 return 1;
84 else if (lock->ml.highest_blocked != LKM_EXMODE)
85 /* PR only blocks EX */
86 return 1;
87
88 return 0;
89}
90
Wengang Wangd9ef7522010-05-17 20:20:44 +080091void __dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
Kurt Hackel6714d8e2005-12-15 14:31:23 -080092{
Sunil Mushran8e17d162010-11-19 15:06:49 -080093 struct dlm_lock_resource *res;
Kurt Hackel6714d8e2005-12-15 14:31:23 -080094
95 BUG_ON(!dlm);
96 BUG_ON(!lock);
97
Sunil Mushran8e17d162010-11-19 15:06:49 -080098 res = lock->lockres;
99
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800100 assert_spin_locked(&dlm->ast_lock);
Sunil Mushran8e17d162010-11-19 15:06:49 -0800101
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800102 if (!list_empty(&lock->ast_list)) {
Sunil Mushran8e17d162010-11-19 15:06:49 -0800103 mlog(ML_ERROR, "%s: res %.*s, lock %u:%llu, "
104 "AST list not empty, pending %d, newlevel %d\n",
105 dlm->name, res->lockname.len, res->lockname.name,
106 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)),
107 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)),
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800108 lock->ast_pending, lock->ml.type);
109 BUG();
110 }
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800111 if (lock->ast_pending)
Sunil Mushran8e17d162010-11-19 15:06:49 -0800112 mlog(0, "%s: res %.*s, lock %u:%llu, AST getting flushed\n",
113 dlm->name, res->lockname.len, res->lockname.name,
114 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)),
115 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)));
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800116
117 /* putting lock on list, add a ref */
118 dlm_lock_get(lock);
119 spin_lock(&lock->spinlock);
120
121 /* check to see if this ast obsoletes the bast */
122 if (dlm_should_cancel_bast(dlm, lock)) {
Sunil Mushran8e17d162010-11-19 15:06:49 -0800123 mlog(0, "%s: res %.*s, lock %u:%llu, Cancelling BAST\n",
124 dlm->name, res->lockname.len, res->lockname.name,
125 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)),
126 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)));
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800127 lock->bast_pending = 0;
128 list_del_init(&lock->bast_list);
129 lock->ml.highest_blocked = LKM_IVMODE;
130 /* removing lock from list, remove a ref. guaranteed
131 * this won't be the last ref because of the get above,
132 * so res->spinlock will not be taken here */
133 dlm_lock_put(lock);
134 /* free up the reserved bast that we are cancelling.
135 * guaranteed that this will not be the last reserved
Sunil Mushran2bd63212010-01-25 16:57:38 -0800136 * ast because *both* an ast and a bast were reserved
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800137 * to get to this point. the res->spinlock will not be
138 * taken here */
139 dlm_lockres_release_ast(dlm, res);
140 }
141 list_add_tail(&lock->ast_list, &dlm->pending_asts);
142 lock->ast_pending = 1;
143 spin_unlock(&lock->spinlock);
144}
145
146void dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
147{
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800148 BUG_ON(!dlm);
149 BUG_ON(!lock);
150
151 spin_lock(&dlm->ast_lock);
152 __dlm_queue_ast(dlm, lock);
153 spin_unlock(&dlm->ast_lock);
154}
155
156
Wengang Wangd9ef7522010-05-17 20:20:44 +0800157void __dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800158{
Sunil Mushran8e17d162010-11-19 15:06:49 -0800159 struct dlm_lock_resource *res;
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800160
161 BUG_ON(!dlm);
162 BUG_ON(!lock);
Sunil Mushran8e17d162010-11-19 15:06:49 -0800163
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800164 assert_spin_locked(&dlm->ast_lock);
165
Sunil Mushran8e17d162010-11-19 15:06:49 -0800166 res = lock->lockres;
167
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800168 BUG_ON(!list_empty(&lock->bast_list));
169 if (lock->bast_pending)
Sunil Mushran8e17d162010-11-19 15:06:49 -0800170 mlog(0, "%s: res %.*s, lock %u:%llu, BAST getting flushed\n",
171 dlm->name, res->lockname.len, res->lockname.name,
172 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)),
173 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)));
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800174
175 /* putting lock on list, add a ref */
176 dlm_lock_get(lock);
177 spin_lock(&lock->spinlock);
178 list_add_tail(&lock->bast_list, &dlm->pending_basts);
179 lock->bast_pending = 1;
180 spin_unlock(&lock->spinlock);
181}
182
183void dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
184{
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800185 BUG_ON(!dlm);
186 BUG_ON(!lock);
187
188 spin_lock(&dlm->ast_lock);
189 __dlm_queue_bast(dlm, lock);
190 spin_unlock(&dlm->ast_lock);
191}
192
193static void dlm_update_lvb(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
194 struct dlm_lock *lock)
195{
196 struct dlm_lockstatus *lksb = lock->lksb;
197 BUG_ON(!lksb);
198
199 /* only updates if this node masters the lockres */
Wengang Wang428257f2010-03-24 22:40:44 +0800200 spin_lock(&res->spinlock);
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800201 if (res->owner == dlm->node_num) {
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800202 /* check the lksb flags for the direction */
203 if (lksb->flags & DLM_LKSB_GET_LVB) {
204 mlog(0, "getting lvb from lockres for %s node\n",
205 lock->ml.node == dlm->node_num ? "master" :
206 "remote");
207 memcpy(lksb->lvb, res->lvb, DLM_LVB_LEN);
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800208 }
Mark Fashehc0a85202006-04-27 19:07:45 -0700209 /* Do nothing for lvb put requests - they should be done in
210 * place when the lock is downconverted - otherwise we risk
211 * racing gets and puts which could result in old lvb data
212 * being propagated. We leave the put flag set and clear it
213 * here. In the future we might want to clear it at the time
214 * the put is actually done.
215 */
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800216 }
Wengang Wang428257f2010-03-24 22:40:44 +0800217 spin_unlock(&res->spinlock);
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800218
219 /* reset any lvb flags on the lksb */
220 lksb->flags &= ~(DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB);
221}
222
223void dlm_do_local_ast(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
224 struct dlm_lock *lock)
225{
226 dlm_astlockfunc_t *fn;
227 struct dlm_lockstatus *lksb;
228
Sunil Mushran8e17d162010-11-19 15:06:49 -0800229 mlog(0, "%s: res %.*s, lock %u:%llu, Local AST\n", dlm->name,
230 res->lockname.len, res->lockname.name,
231 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)),
232 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)));
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800233
234 lksb = lock->lksb;
235 fn = lock->ast;
236 BUG_ON(lock->ml.node != dlm->node_num);
237
238 dlm_update_lvb(dlm, res, lock);
239 (*fn)(lock->astdata);
240}
241
242
243int dlm_do_remote_ast(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
244 struct dlm_lock *lock)
245{
246 int ret;
247 struct dlm_lockstatus *lksb;
248 int lksbflags;
249
Sunil Mushran8e17d162010-11-19 15:06:49 -0800250 mlog(0, "%s: res %.*s, lock %u:%llu, Remote AST\n", dlm->name,
251 res->lockname.len, res->lockname.name,
252 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)),
253 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)));
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800254
255 lksb = lock->lksb;
256 BUG_ON(lock->ml.node == dlm->node_num);
257
258 lksbflags = lksb->flags;
259 dlm_update_lvb(dlm, res, lock);
260
261 /* lock request came from another node
262 * go do the ast over there */
263 ret = dlm_send_proxy_ast(dlm, res, lock, lksbflags);
264 return ret;
265}
266
267void dlm_do_local_bast(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
268 struct dlm_lock *lock, int blocked_type)
269{
270 dlm_bastlockfunc_t *fn = lock->bast;
271
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800272 BUG_ON(lock->ml.node != dlm->node_num);
273
Sunil Mushran8e17d162010-11-19 15:06:49 -0800274 mlog(0, "%s: res %.*s, lock %u:%llu, Local BAST, blocked %d\n",
275 dlm->name, res->lockname.len, res->lockname.name,
276 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)),
277 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)),
278 blocked_type);
279
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800280 (*fn)(lock->astdata, blocked_type);
281}
282
283
284
Kurt Hackeld74c9802007-01-17 17:04:25 -0800285int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data,
286 void **ret_data)
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800287{
288 int ret;
289 unsigned int locklen;
290 struct dlm_ctxt *dlm = data;
291 struct dlm_lock_resource *res = NULL;
292 struct dlm_lock *lock = NULL;
293 struct dlm_proxy_ast *past = (struct dlm_proxy_ast *) msg->buf;
294 char *name;
Dong Fangdf53cd32013-09-11 14:19:50 -0700295 struct list_head *head = NULL;
Al Viro85158412012-04-12 18:47:13 -0400296 __be64 cookie;
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800297 u32 flags;
Sunil Mushran57dff262008-12-16 15:49:20 -0800298 u8 node;
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800299
300 if (!dlm_grab(dlm)) {
301 dlm_error(DLM_REJECTED);
302 return DLM_REJECTED;
303 }
304
305 mlog_bug_on_msg(!dlm_domain_fully_joined(dlm),
306 "Domain %s not fully joined!\n", dlm->name);
307
308 name = past->name;
309 locklen = past->namelen;
Sunil Mushran57dff262008-12-16 15:49:20 -0800310 cookie = past->cookie;
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800311 flags = be32_to_cpu(past->flags);
Sunil Mushran57dff262008-12-16 15:49:20 -0800312 node = past->node_idx;
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800313
314 if (locklen > DLM_LOCKID_NAME_MAX) {
315 ret = DLM_IVBUFLEN;
Sunil Mushran57dff262008-12-16 15:49:20 -0800316 mlog(ML_ERROR, "Invalid name length (%d) in proxy ast "
317 "handler!\n", locklen);
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800318 goto leave;
319 }
320
321 if ((flags & (LKM_PUT_LVB|LKM_GET_LVB)) ==
322 (LKM_PUT_LVB|LKM_GET_LVB)) {
Sunil Mushran57dff262008-12-16 15:49:20 -0800323 mlog(ML_ERROR, "Both PUT and GET lvb specified, (0x%x)\n",
324 flags);
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800325 ret = DLM_BADARGS;
326 goto leave;
327 }
328
329 mlog(0, "lvb: %s\n", flags & LKM_PUT_LVB ? "put lvb" :
330 (flags & LKM_GET_LVB ? "get lvb" : "none"));
331
332 mlog(0, "type=%d, blocked_type=%d\n", past->type, past->blocked_type);
333
334 if (past->type != DLM_AST &&
335 past->type != DLM_BAST) {
Kurt Hackel29004852006-03-02 16:43:36 -0800336 mlog(ML_ERROR, "Unknown ast type! %d, cookie=%u:%llu"
Sunil Mushran57dff262008-12-16 15:49:20 -0800337 "name=%.*s, node=%u\n", past->type,
338 dlm_get_lock_cookie_node(be64_to_cpu(cookie)),
339 dlm_get_lock_cookie_seq(be64_to_cpu(cookie)),
340 locklen, name, node);
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800341 ret = DLM_IVLOCKID;
342 goto leave;
343 }
344
345 res = dlm_lookup_lockres(dlm, name, locklen);
346 if (!res) {
Sunil Mushran57dff262008-12-16 15:49:20 -0800347 mlog(0, "Got %sast for unknown lockres! cookie=%u:%llu, "
348 "name=%.*s, node=%u\n", (past->type == DLM_AST ? "" : "b"),
349 dlm_get_lock_cookie_node(be64_to_cpu(cookie)),
350 dlm_get_lock_cookie_seq(be64_to_cpu(cookie)),
351 locklen, name, node);
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800352 ret = DLM_IVLOCKID;
353 goto leave;
354 }
355
356 /* cannot get a proxy ast message if this node owns it */
357 BUG_ON(res->owner == dlm->node_num);
358
Sunil Mushran8e17d162010-11-19 15:06:49 -0800359 mlog(0, "%s: res %.*s\n", dlm->name, res->lockname.len,
360 res->lockname.name);
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800361
362 spin_lock(&res->spinlock);
363 if (res->state & DLM_LOCK_RES_RECOVERING) {
Sunil Mushran57dff262008-12-16 15:49:20 -0800364 mlog(0, "Responding with DLM_RECOVERING!\n");
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800365 ret = DLM_RECOVERING;
366 goto unlock_out;
367 }
368 if (res->state & DLM_LOCK_RES_MIGRATING) {
Sunil Mushran57dff262008-12-16 15:49:20 -0800369 mlog(0, "Responding with DLM_MIGRATING!\n");
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800370 ret = DLM_MIGRATING;
371 goto unlock_out;
372 }
373 /* try convert queue for both ast/bast */
374 head = &res->converting;
375 lock = NULL;
Dong Fangdf53cd32013-09-11 14:19:50 -0700376 list_for_each_entry(lock, head, list) {
Sunil Mushran57dff262008-12-16 15:49:20 -0800377 if (lock->ml.cookie == cookie)
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800378 goto do_ast;
379 }
380
381 /* if not on convert, try blocked for ast, granted for bast */
382 if (past->type == DLM_AST)
383 head = &res->blocked;
384 else
385 head = &res->granted;
386
Dong Fangdf53cd32013-09-11 14:19:50 -0700387 list_for_each_entry(lock, head, list) {
Sunil Mushran57dff262008-12-16 15:49:20 -0800388 if (lock->ml.cookie == cookie)
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800389 goto do_ast;
390 }
391
Sunil Mushran57dff262008-12-16 15:49:20 -0800392 mlog(0, "Got %sast for unknown lock! cookie=%u:%llu, name=%.*s, "
393 "node=%u\n", past->type == DLM_AST ? "" : "b",
394 dlm_get_lock_cookie_node(be64_to_cpu(cookie)),
395 dlm_get_lock_cookie_seq(be64_to_cpu(cookie)),
396 locklen, name, node);
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800397
398 ret = DLM_NORMAL;
399unlock_out:
400 spin_unlock(&res->spinlock);
401 goto leave;
402
403do_ast:
404 ret = DLM_NORMAL;
405 if (past->type == DLM_AST) {
406 /* do not alter lock refcount. switching lists. */
Akinobu Mitaf1166292006-06-26 00:24:46 -0700407 list_move_tail(&lock->list, &res->granted);
Sunil Mushran8e17d162010-11-19 15:06:49 -0800408 mlog(0, "%s: res %.*s, lock %u:%llu, Granted type %d => %d\n",
409 dlm->name, res->lockname.len, res->lockname.name,
410 dlm_get_lock_cookie_node(be64_to_cpu(cookie)),
411 dlm_get_lock_cookie_seq(be64_to_cpu(cookie)),
412 lock->ml.type, lock->ml.convert_type);
413
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800414 if (lock->ml.convert_type != LKM_IVMODE) {
415 lock->ml.type = lock->ml.convert_type;
416 lock->ml.convert_type = LKM_IVMODE;
417 } else {
418 // should already be there....
419 }
420
421 lock->lksb->status = DLM_NORMAL;
422
423 /* if we requested the lvb, fetch it into our lksb now */
424 if (flags & LKM_GET_LVB) {
425 BUG_ON(!(lock->lksb->flags & DLM_LKSB_GET_LVB));
426 memcpy(lock->lksb->lvb, past->lvb, DLM_LVB_LEN);
427 }
428 }
429 spin_unlock(&res->spinlock);
430
431 if (past->type == DLM_AST)
432 dlm_do_local_ast(dlm, res, lock);
433 else
434 dlm_do_local_bast(dlm, res, lock, past->blocked_type);
435
436leave:
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800437 if (res)
438 dlm_lockres_put(res);
439
440 dlm_put(dlm);
441 return ret;
442}
443
444
445
446int dlm_send_proxy_ast_msg(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
447 struct dlm_lock *lock, int msg_type,
448 int blocked_type, int flags)
449{
450 int ret = 0;
451 struct dlm_proxy_ast past;
452 struct kvec vec[2];
453 size_t veclen = 1;
454 int status;
455
Sunil Mushran8e17d162010-11-19 15:06:49 -0800456 mlog(0, "%s: res %.*s, to %u, type %d, blocked_type %d\n", dlm->name,
457 res->lockname.len, res->lockname.name, lock->ml.node, msg_type,
458 blocked_type);
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800459
460 memset(&past, 0, sizeof(struct dlm_proxy_ast));
461 past.node_idx = dlm->node_num;
462 past.type = msg_type;
463 past.blocked_type = blocked_type;
464 past.namelen = res->lockname.len;
465 memcpy(past.name, res->lockname.name, past.namelen);
466 past.cookie = lock->ml.cookie;
467
468 vec[0].iov_len = sizeof(struct dlm_proxy_ast);
469 vec[0].iov_base = &past;
470 if (flags & DLM_LKSB_GET_LVB) {
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800471 be32_add_cpu(&past.flags, LKM_GET_LVB);
472 vec[1].iov_len = DLM_LVB_LEN;
473 vec[1].iov_base = lock->lksb->lvb;
474 veclen++;
475 }
476
477 ret = o2net_send_message_vec(DLM_PROXY_AST_MSG, dlm->key, vec, veclen,
478 lock->ml.node, &status);
479 if (ret < 0)
Sunil Mushran8e17d162010-11-19 15:06:49 -0800480 mlog(ML_ERROR, "%s: res %.*s, error %d send AST to node %u\n",
481 dlm->name, res->lockname.len, res->lockname.name, ret,
Wengang Wanga5196ec2010-03-30 12:09:22 +0800482 lock->ml.node);
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800483 else {
484 if (status == DLM_RECOVERING) {
485 mlog(ML_ERROR, "sent AST to node %u, it thinks this "
486 "node is dead!\n", lock->ml.node);
487 BUG();
488 } else if (status == DLM_MIGRATING) {
489 mlog(ML_ERROR, "sent AST to node %u, it returned "
490 "DLM_MIGRATING!\n", lock->ml.node);
491 BUG();
Mark Fashehe2c73692006-09-08 11:37:32 -0700492 } else if (status != DLM_NORMAL && status != DLM_IVLOCKID) {
Kurt Hackel6714d8e2005-12-15 14:31:23 -0800493 mlog(ML_ERROR, "AST to node %u returned %d!\n",
494 lock->ml.node, status);
495 /* ignore it */
496 }
497 ret = 0;
498 }
499 return ret;
500}