Lines Matching full:lock
52 struct dlm_lock *lock);
53 static int dlm_should_cancel_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock);
56 * lock level will obsolete a pending bast.
57 * For example, if dlm_thread queued a bast for an EX lock that
59 * lock owner downconverted to NL, the bast is now obsolete.
61 * This is needed because the lock and convert paths can queue
64 static int dlm_should_cancel_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock) in dlm_should_cancel_bast() argument
67 assert_spin_locked(&lock->spinlock); in dlm_should_cancel_bast()
69 if (lock->ml.highest_blocked == LKM_IVMODE) in dlm_should_cancel_bast()
71 BUG_ON(lock->ml.highest_blocked == LKM_NLMODE); in dlm_should_cancel_bast()
73 if (lock->bast_pending && in dlm_should_cancel_bast()
74 list_empty(&lock->bast_list)) in dlm_should_cancel_bast()
78 if (lock->ml.type == LKM_EXMODE) in dlm_should_cancel_bast()
81 else if (lock->ml.type == LKM_NLMODE) in dlm_should_cancel_bast()
84 else if (lock->ml.highest_blocked != LKM_EXMODE) in dlm_should_cancel_bast()
91 void __dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock) in __dlm_queue_ast() argument
96 BUG_ON(!lock); in __dlm_queue_ast()
98 res = lock->lockres; in __dlm_queue_ast()
102 if (!list_empty(&lock->ast_list)) { in __dlm_queue_ast()
103 mlog(ML_ERROR, "%s: res %.*s, lock %u:%llu, " in __dlm_queue_ast()
106 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_ast()
107 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_ast()
108 lock->ast_pending, lock->ml.type); in __dlm_queue_ast()
111 if (lock->ast_pending) in __dlm_queue_ast()
112 mlog(0, "%s: res %.*s, lock %u:%llu, AST getting flushed\n", in __dlm_queue_ast()
114 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_ast()
115 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in __dlm_queue_ast()
117 /* putting lock on list, add a ref */ in __dlm_queue_ast()
118 dlm_lock_get(lock); in __dlm_queue_ast()
119 spin_lock(&lock->spinlock); in __dlm_queue_ast()
122 if (dlm_should_cancel_bast(dlm, lock)) { in __dlm_queue_ast()
123 mlog(0, "%s: res %.*s, lock %u:%llu, Cancelling BAST\n", in __dlm_queue_ast()
125 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_ast()
126 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in __dlm_queue_ast()
127 lock->bast_pending = 0; in __dlm_queue_ast()
128 list_del_init(&lock->bast_list); in __dlm_queue_ast()
129 lock->ml.highest_blocked = LKM_IVMODE; in __dlm_queue_ast()
130 /* removing lock from list, remove a ref. guaranteed in __dlm_queue_ast()
133 dlm_lock_put(lock); in __dlm_queue_ast()
141 list_add_tail(&lock->ast_list, &dlm->pending_asts); in __dlm_queue_ast()
142 lock->ast_pending = 1; in __dlm_queue_ast()
143 spin_unlock(&lock->spinlock); in __dlm_queue_ast()
146 void dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock) in dlm_queue_ast() argument
149 BUG_ON(!lock); in dlm_queue_ast()
152 __dlm_queue_ast(dlm, lock); in dlm_queue_ast()
157 void __dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock) in __dlm_queue_bast() argument
162 BUG_ON(!lock); in __dlm_queue_bast()
166 res = lock->lockres; in __dlm_queue_bast()
168 BUG_ON(!list_empty(&lock->bast_list)); in __dlm_queue_bast()
169 if (lock->bast_pending) in __dlm_queue_bast()
170 mlog(0, "%s: res %.*s, lock %u:%llu, BAST getting flushed\n", in __dlm_queue_bast()
172 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_bast()
173 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in __dlm_queue_bast()
175 /* putting lock on list, add a ref */ in __dlm_queue_bast()
176 dlm_lock_get(lock); in __dlm_queue_bast()
177 spin_lock(&lock->spinlock); in __dlm_queue_bast()
178 list_add_tail(&lock->bast_list, &dlm->pending_basts); in __dlm_queue_bast()
179 lock->bast_pending = 1; in __dlm_queue_bast()
180 spin_unlock(&lock->spinlock); in __dlm_queue_bast()
183 void dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock) in dlm_queue_bast() argument
186 BUG_ON(!lock); in dlm_queue_bast()
189 __dlm_queue_bast(dlm, lock); in dlm_queue_bast()
194 struct dlm_lock *lock) in dlm_update_lvb() argument
196 struct dlm_lockstatus *lksb = lock->lksb; in dlm_update_lvb()
205 lock->ml.node == dlm->node_num ? "master" : in dlm_update_lvb()
210 * place when the lock is downconverted - otherwise we risk in dlm_update_lvb()
224 struct dlm_lock *lock) in dlm_do_local_ast() argument
229 mlog(0, "%s: res %.*s, lock %u:%llu, Local AST\n", dlm->name, in dlm_do_local_ast()
231 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in dlm_do_local_ast()
232 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in dlm_do_local_ast()
234 lksb = lock->lksb; in dlm_do_local_ast()
235 fn = lock->ast; in dlm_do_local_ast()
236 BUG_ON(lock->ml.node != dlm->node_num); in dlm_do_local_ast()
238 dlm_update_lvb(dlm, res, lock); in dlm_do_local_ast()
239 (*fn)(lock->astdata); in dlm_do_local_ast()
244 struct dlm_lock *lock) in dlm_do_remote_ast() argument
250 mlog(0, "%s: res %.*s, lock %u:%llu, Remote AST\n", dlm->name, in dlm_do_remote_ast()
252 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in dlm_do_remote_ast()
253 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in dlm_do_remote_ast()
255 lksb = lock->lksb; in dlm_do_remote_ast()
256 BUG_ON(lock->ml.node == dlm->node_num); in dlm_do_remote_ast()
259 dlm_update_lvb(dlm, res, lock); in dlm_do_remote_ast()
261 /* lock request came from another node in dlm_do_remote_ast()
263 ret = dlm_send_proxy_ast(dlm, res, lock, lksbflags); in dlm_do_remote_ast()
268 struct dlm_lock *lock, int blocked_type) in dlm_do_local_bast() argument
270 dlm_bastlockfunc_t *fn = lock->bast; in dlm_do_local_bast()
272 BUG_ON(lock->ml.node != dlm->node_num); in dlm_do_local_bast()
274 mlog(0, "%s: res %.*s, lock %u:%llu, Local BAST, blocked %d\n", in dlm_do_local_bast()
276 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in dlm_do_local_bast()
277 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)), in dlm_do_local_bast()
280 (*fn)(lock->astdata, blocked_type); in dlm_do_local_bast()
292 struct dlm_lock *lock = NULL; in dlm_proxy_ast_handler() local
375 lock = NULL; in dlm_proxy_ast_handler()
377 lock = list_entry (iter, struct dlm_lock, list); in dlm_proxy_ast_handler()
378 if (lock->ml.cookie == cookie) in dlm_proxy_ast_handler()
389 lock = list_entry (iter, struct dlm_lock, list); in dlm_proxy_ast_handler()
390 if (lock->ml.cookie == cookie) in dlm_proxy_ast_handler()
394 mlog(0, "Got %sast for unknown lock! cookie=%u:%llu, name=%.*s, " in dlm_proxy_ast_handler()
408 /* do not alter lock refcount. switching lists. */ in dlm_proxy_ast_handler()
409 list_move_tail(&lock->list, &res->granted); in dlm_proxy_ast_handler()
410 mlog(0, "%s: res %.*s, lock %u:%llu, Granted type %d => %d\n", in dlm_proxy_ast_handler()
414 lock->ml.type, lock->ml.convert_type); in dlm_proxy_ast_handler()
416 if (lock->ml.convert_type != LKM_IVMODE) { in dlm_proxy_ast_handler()
417 lock->ml.type = lock->ml.convert_type; in dlm_proxy_ast_handler()
418 lock->ml.convert_type = LKM_IVMODE; in dlm_proxy_ast_handler()
423 lock->lksb->status = DLM_NORMAL; in dlm_proxy_ast_handler()
427 BUG_ON(!(lock->lksb->flags & DLM_LKSB_GET_LVB)); in dlm_proxy_ast_handler()
428 memcpy(lock->lksb->lvb, past->lvb, DLM_LVB_LEN); in dlm_proxy_ast_handler()
434 dlm_do_local_ast(dlm, res, lock); in dlm_proxy_ast_handler()
436 dlm_do_local_bast(dlm, res, lock, past->blocked_type); in dlm_proxy_ast_handler()
449 struct dlm_lock *lock, int msg_type, in dlm_send_proxy_ast_msg() argument
459 res->lockname.len, res->lockname.name, lock->ml.node, msg_type, in dlm_send_proxy_ast_msg()
468 past.cookie = lock->ml.cookie; in dlm_send_proxy_ast_msg()
475 vec[1].iov_base = lock->lksb->lvb; in dlm_send_proxy_ast_msg()
480 lock->ml.node, &status); in dlm_send_proxy_ast_msg()
484 lock->ml.node); in dlm_send_proxy_ast_msg()
488 "node is dead!\n", lock->ml.node); in dlm_send_proxy_ast_msg()
492 "DLM_MIGRATING!\n", lock->ml.node); in dlm_send_proxy_ast_msg()
496 lock->ml.node, status); in dlm_send_proxy_ast_msg()