Lines Matching full:lock

37 			   struct dlm_lock *lock);
38 static int dlm_should_cancel_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock);
41 * lock level will obsolete a pending bast.
42 * For example, if dlm_thread queued a bast for an EX lock that
44 * lock owner downconverted to NL, the bast is now obsolete.
46 * This is needed because the lock and convert paths can queue
49 static int dlm_should_cancel_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock) in dlm_should_cancel_bast() argument
52 assert_spin_locked(&lock->spinlock); in dlm_should_cancel_bast()
54 if (lock->ml.highest_blocked == LKM_IVMODE) in dlm_should_cancel_bast()
56 BUG_ON(lock->ml.highest_blocked == LKM_NLMODE); in dlm_should_cancel_bast()
58 if (lock->bast_pending && in dlm_should_cancel_bast()
59 list_empty(&lock->bast_list)) in dlm_should_cancel_bast()
63 if (lock->ml.type == LKM_EXMODE) in dlm_should_cancel_bast()
66 else if (lock->ml.type == LKM_NLMODE) in dlm_should_cancel_bast()
69 else if (lock->ml.highest_blocked != LKM_EXMODE) in dlm_should_cancel_bast()
76 void __dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock) in __dlm_queue_ast() argument
81 BUG_ON(!lock); in __dlm_queue_ast()
83 res = lock->lockres; in __dlm_queue_ast()
87 if (!list_empty(&lock->ast_list)) { in __dlm_queue_ast()
88 mlog(ML_ERROR, "%s: res %.*s, lock %u:%llu, " in __dlm_queue_ast()
91 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_ast()
92 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_ast()
93 lock->ast_pending, lock->ml.type); in __dlm_queue_ast()
96 if (lock->ast_pending) in __dlm_queue_ast()
97 mlog(0, "%s: res %.*s, lock %u:%llu, AST getting flushed\n", in __dlm_queue_ast()
99 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_ast()
100 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in __dlm_queue_ast()
102 /* putting lock on list, add a ref */ in __dlm_queue_ast()
103 dlm_lock_get(lock); in __dlm_queue_ast()
104 spin_lock(&lock->spinlock); in __dlm_queue_ast()
107 if (dlm_should_cancel_bast(dlm, lock)) { in __dlm_queue_ast()
108 mlog(0, "%s: res %.*s, lock %u:%llu, Cancelling BAST\n", in __dlm_queue_ast()
110 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_ast()
111 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in __dlm_queue_ast()
112 lock->bast_pending = 0; in __dlm_queue_ast()
113 list_del_init(&lock->bast_list); in __dlm_queue_ast()
114 lock->ml.highest_blocked = LKM_IVMODE; in __dlm_queue_ast()
115 /* removing lock from list, remove a ref. guaranteed in __dlm_queue_ast()
118 dlm_lock_put(lock); in __dlm_queue_ast()
126 list_add_tail(&lock->ast_list, &dlm->pending_asts); in __dlm_queue_ast()
127 lock->ast_pending = 1; in __dlm_queue_ast()
128 spin_unlock(&lock->spinlock); in __dlm_queue_ast()
131 void dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock) in dlm_queue_ast() argument
134 BUG_ON(!lock); in dlm_queue_ast()
137 __dlm_queue_ast(dlm, lock); in dlm_queue_ast()
142 void __dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock) in __dlm_queue_bast() argument
147 BUG_ON(!lock); in __dlm_queue_bast()
151 res = lock->lockres; in __dlm_queue_bast()
153 BUG_ON(!list_empty(&lock->bast_list)); in __dlm_queue_bast()
154 if (lock->bast_pending) in __dlm_queue_bast()
155 mlog(0, "%s: res %.*s, lock %u:%llu, BAST getting flushed\n", in __dlm_queue_bast()
157 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_bast()
158 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in __dlm_queue_bast()
160 /* putting lock on list, add a ref */ in __dlm_queue_bast()
161 dlm_lock_get(lock); in __dlm_queue_bast()
162 spin_lock(&lock->spinlock); in __dlm_queue_bast()
163 list_add_tail(&lock->bast_list, &dlm->pending_basts); in __dlm_queue_bast()
164 lock->bast_pending = 1; in __dlm_queue_bast()
165 spin_unlock(&lock->spinlock); in __dlm_queue_bast()
168 void dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock) in dlm_queue_bast() argument
171 BUG_ON(!lock); in dlm_queue_bast()
174 __dlm_queue_bast(dlm, lock); in dlm_queue_bast()
179 struct dlm_lock *lock) in dlm_update_lvb() argument
181 struct dlm_lockstatus *lksb = lock->lksb; in dlm_update_lvb()
190 lock->ml.node == dlm->node_num ? "master" : in dlm_update_lvb()
195 * place when the lock is downconverted - otherwise we risk in dlm_update_lvb()
209 struct dlm_lock *lock) in dlm_do_local_ast() argument
213 mlog(0, "%s: res %.*s, lock %u:%llu, Local AST\n", dlm->name, in dlm_do_local_ast()
215 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in dlm_do_local_ast()
216 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in dlm_do_local_ast()
218 fn = lock->ast; in dlm_do_local_ast()
219 BUG_ON(lock->ml.node != dlm->node_num); in dlm_do_local_ast()
221 dlm_update_lvb(dlm, res, lock); in dlm_do_local_ast()
222 (*fn)(lock->astdata); in dlm_do_local_ast()
227 struct dlm_lock *lock) in dlm_do_remote_ast() argument
233 mlog(0, "%s: res %.*s, lock %u:%llu, Remote AST\n", dlm->name, in dlm_do_remote_ast()
235 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in dlm_do_remote_ast()
236 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in dlm_do_remote_ast()
238 lksb = lock->lksb; in dlm_do_remote_ast()
239 BUG_ON(lock->ml.node == dlm->node_num); in dlm_do_remote_ast()
242 dlm_update_lvb(dlm, res, lock); in dlm_do_remote_ast()
244 /* lock request came from another node in dlm_do_remote_ast()
246 ret = dlm_send_proxy_ast(dlm, res, lock, lksbflags); in dlm_do_remote_ast()
251 struct dlm_lock *lock, int blocked_type) in dlm_do_local_bast() argument
253 dlm_bastlockfunc_t *fn = lock->bast; in dlm_do_local_bast()
255 BUG_ON(lock->ml.node != dlm->node_num); in dlm_do_local_bast()
257 mlog(0, "%s: res %.*s, lock %u:%llu, Local BAST, blocked %d\n", in dlm_do_local_bast()
259 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in dlm_do_local_bast()
260 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)), in dlm_do_local_bast()
263 (*fn)(lock->astdata, blocked_type); in dlm_do_local_bast()
275 struct dlm_lock *lock = NULL; in dlm_proxy_ast_handler() local
358 lock = NULL; in dlm_proxy_ast_handler()
359 list_for_each_entry(lock, head, list) { in dlm_proxy_ast_handler()
360 if (lock->ml.cookie == cookie) in dlm_proxy_ast_handler()
370 list_for_each_entry(lock, head, list) { in dlm_proxy_ast_handler()
371 /* if lock is found but unlock is pending ignore the bast */ in dlm_proxy_ast_handler()
372 if (lock->ml.cookie == cookie) { in dlm_proxy_ast_handler()
373 if (lock->unlock_pending) in dlm_proxy_ast_handler()
379 mlog(0, "Got %sast for unknown lock! cookie=%u:%llu, name=%.*s, " in dlm_proxy_ast_handler()
393 /* do not alter lock refcount. switching lists. */ in dlm_proxy_ast_handler()
394 list_move_tail(&lock->list, &res->granted); in dlm_proxy_ast_handler()
395 mlog(0, "%s: res %.*s, lock %u:%llu, Granted type %d => %d\n", in dlm_proxy_ast_handler()
399 lock->ml.type, lock->ml.convert_type); in dlm_proxy_ast_handler()
401 if (lock->ml.convert_type != LKM_IVMODE) { in dlm_proxy_ast_handler()
402 lock->ml.type = lock->ml.convert_type; in dlm_proxy_ast_handler()
403 lock->ml.convert_type = LKM_IVMODE; in dlm_proxy_ast_handler()
408 lock->lksb->status = DLM_NORMAL; in dlm_proxy_ast_handler()
412 BUG_ON(!(lock->lksb->flags & DLM_LKSB_GET_LVB)); in dlm_proxy_ast_handler()
413 memcpy(lock->lksb->lvb, past->lvb, DLM_LVB_LEN); in dlm_proxy_ast_handler()
419 dlm_do_local_ast(dlm, res, lock); in dlm_proxy_ast_handler()
421 dlm_do_local_bast(dlm, res, lock, past->blocked_type); in dlm_proxy_ast_handler()
434 struct dlm_lock *lock, int msg_type, in dlm_send_proxy_ast_msg() argument
444 res->lockname.len, res->lockname.name, lock->ml.node, msg_type, in dlm_send_proxy_ast_msg()
453 past.cookie = lock->ml.cookie; in dlm_send_proxy_ast_msg()
460 vec[1].iov_base = lock->lksb->lvb; in dlm_send_proxy_ast_msg()
465 lock->ml.node, &status); in dlm_send_proxy_ast_msg()
469 lock->ml.node); in dlm_send_proxy_ast_msg()
473 "node is dead!\n", lock->ml.node); in dlm_send_proxy_ast_msg()
477 "DLM_MIGRATING!\n", lock->ml.node); in dlm_send_proxy_ast_msg()
481 lock->ml.node, status); in dlm_send_proxy_ast_msg()