Lines Matching refs:lock
35 struct dlm_lock *lock);
36 static int dlm_should_cancel_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock);
47 static int dlm_should_cancel_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock) in dlm_should_cancel_bast() argument
50 assert_spin_locked(&lock->spinlock); in dlm_should_cancel_bast()
52 if (lock->ml.highest_blocked == LKM_IVMODE) in dlm_should_cancel_bast()
54 BUG_ON(lock->ml.highest_blocked == LKM_NLMODE); in dlm_should_cancel_bast()
56 if (lock->bast_pending && in dlm_should_cancel_bast()
57 list_empty(&lock->bast_list)) in dlm_should_cancel_bast()
61 if (lock->ml.type == LKM_EXMODE) in dlm_should_cancel_bast()
64 else if (lock->ml.type == LKM_NLMODE) in dlm_should_cancel_bast()
67 else if (lock->ml.highest_blocked != LKM_EXMODE) in dlm_should_cancel_bast()
74 void __dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock) in __dlm_queue_ast() argument
79 BUG_ON(!lock); in __dlm_queue_ast()
81 res = lock->lockres; in __dlm_queue_ast()
85 if (!list_empty(&lock->ast_list)) { in __dlm_queue_ast()
89 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_ast()
90 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_ast()
91 lock->ast_pending, lock->ml.type); in __dlm_queue_ast()
94 if (lock->ast_pending) in __dlm_queue_ast()
97 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_ast()
98 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in __dlm_queue_ast()
101 dlm_lock_get(lock); in __dlm_queue_ast()
102 spin_lock(&lock->spinlock); in __dlm_queue_ast()
105 if (dlm_should_cancel_bast(dlm, lock)) { in __dlm_queue_ast()
108 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_ast()
109 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in __dlm_queue_ast()
110 lock->bast_pending = 0; in __dlm_queue_ast()
111 list_del_init(&lock->bast_list); in __dlm_queue_ast()
112 lock->ml.highest_blocked = LKM_IVMODE; in __dlm_queue_ast()
116 dlm_lock_put(lock); in __dlm_queue_ast()
124 list_add_tail(&lock->ast_list, &dlm->pending_asts); in __dlm_queue_ast()
125 lock->ast_pending = 1; in __dlm_queue_ast()
126 spin_unlock(&lock->spinlock); in __dlm_queue_ast()
129 void dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock) in dlm_queue_ast() argument
132 BUG_ON(!lock); in dlm_queue_ast()
135 __dlm_queue_ast(dlm, lock); in dlm_queue_ast()
140 void __dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock) in __dlm_queue_bast() argument
145 BUG_ON(!lock); in __dlm_queue_bast()
149 res = lock->lockres; in __dlm_queue_bast()
151 BUG_ON(!list_empty(&lock->bast_list)); in __dlm_queue_bast()
152 if (lock->bast_pending) in __dlm_queue_bast()
155 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in __dlm_queue_bast()
156 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in __dlm_queue_bast()
159 dlm_lock_get(lock); in __dlm_queue_bast()
160 spin_lock(&lock->spinlock); in __dlm_queue_bast()
161 list_add_tail(&lock->bast_list, &dlm->pending_basts); in __dlm_queue_bast()
162 lock->bast_pending = 1; in __dlm_queue_bast()
163 spin_unlock(&lock->spinlock); in __dlm_queue_bast()
167 struct dlm_lock *lock) in dlm_update_lvb() argument
169 struct dlm_lockstatus *lksb = lock->lksb; in dlm_update_lvb()
178 lock->ml.node == dlm->node_num ? "master" : in dlm_update_lvb()
197 struct dlm_lock *lock) in dlm_do_local_ast() argument
203 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in dlm_do_local_ast()
204 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in dlm_do_local_ast()
206 fn = lock->ast; in dlm_do_local_ast()
207 BUG_ON(lock->ml.node != dlm->node_num); in dlm_do_local_ast()
209 dlm_update_lvb(dlm, res, lock); in dlm_do_local_ast()
210 (*fn)(lock->astdata); in dlm_do_local_ast()
215 struct dlm_lock *lock) in dlm_do_remote_ast() argument
223 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in dlm_do_remote_ast()
224 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie))); in dlm_do_remote_ast()
226 lksb = lock->lksb; in dlm_do_remote_ast()
227 BUG_ON(lock->ml.node == dlm->node_num); in dlm_do_remote_ast()
230 dlm_update_lvb(dlm, res, lock); in dlm_do_remote_ast()
234 ret = dlm_send_proxy_ast(dlm, res, lock, lksbflags); in dlm_do_remote_ast()
239 struct dlm_lock *lock, int blocked_type) in dlm_do_local_bast() argument
241 dlm_bastlockfunc_t *fn = lock->bast; in dlm_do_local_bast()
243 BUG_ON(lock->ml.node != dlm->node_num); in dlm_do_local_bast()
247 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in dlm_do_local_bast()
248 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)), in dlm_do_local_bast()
251 (*fn)(lock->astdata, blocked_type); in dlm_do_local_bast()
263 struct dlm_lock *lock = NULL; in dlm_proxy_ast_handler() local
346 lock = NULL; in dlm_proxy_ast_handler()
347 list_for_each_entry(lock, head, list) { in dlm_proxy_ast_handler()
348 if (lock->ml.cookie == cookie) in dlm_proxy_ast_handler()
358 list_for_each_entry(lock, head, list) { in dlm_proxy_ast_handler()
360 if (lock->ml.cookie == cookie) { in dlm_proxy_ast_handler()
361 if (lock->unlock_pending) in dlm_proxy_ast_handler()
382 list_move_tail(&lock->list, &res->granted); in dlm_proxy_ast_handler()
387 lock->ml.type, lock->ml.convert_type); in dlm_proxy_ast_handler()
389 if (lock->ml.convert_type != LKM_IVMODE) { in dlm_proxy_ast_handler()
390 lock->ml.type = lock->ml.convert_type; in dlm_proxy_ast_handler()
391 lock->ml.convert_type = LKM_IVMODE; in dlm_proxy_ast_handler()
396 lock->lksb->status = DLM_NORMAL; in dlm_proxy_ast_handler()
400 BUG_ON(!(lock->lksb->flags & DLM_LKSB_GET_LVB)); in dlm_proxy_ast_handler()
401 memcpy(lock->lksb->lvb, past->lvb, DLM_LVB_LEN); in dlm_proxy_ast_handler()
407 dlm_do_local_ast(dlm, res, lock); in dlm_proxy_ast_handler()
409 dlm_do_local_bast(dlm, res, lock, past->blocked_type); in dlm_proxy_ast_handler()
422 struct dlm_lock *lock, int msg_type, in dlm_send_proxy_ast_msg() argument
432 res->lockname.len, res->lockname.name, lock->ml.node, msg_type, in dlm_send_proxy_ast_msg()
441 past.cookie = lock->ml.cookie; in dlm_send_proxy_ast_msg()
448 vec[1].iov_base = lock->lksb->lvb; in dlm_send_proxy_ast_msg()
453 lock->ml.node, &status); in dlm_send_proxy_ast_msg()
457 lock->ml.node); in dlm_send_proxy_ast_msg()
461 "node is dead!\n", lock->ml.node); in dlm_send_proxy_ast_msg()
465 "DLM_MIGRATING!\n", lock->ml.node); in dlm_send_proxy_ast_msg()
469 lock->ml.node, status); in dlm_send_proxy_ast_msg()