Lines Matching refs:lock

45 					       struct dlm_lock *lock, int flags);
49 static void dlm_lock_detach_lockres(struct dlm_lock *lock);
74 struct dlm_lock *lock) in dlm_can_grant_new_lock() argument
79 if (!dlm_lock_compatible(tmplock->ml.type, lock->ml.type)) in dlm_can_grant_new_lock()
84 if (!dlm_lock_compatible(tmplock->ml.type, lock->ml.type)) in dlm_can_grant_new_lock()
87 lock->ml.type)) in dlm_can_grant_new_lock()
103 struct dlm_lock *lock, int flags) in dlmlock_master() argument
108 mlog(0, "type=%d\n", lock->ml.type); in dlmlock_master()
115 lock->ml.node != dlm->node_num) { in dlmlock_master()
124 if (dlm_can_grant_new_lock(res, lock)) { in dlmlock_master()
127 lock->lksb->status = DLM_NORMAL; in dlmlock_master()
129 dlm_lock_get(lock); in dlmlock_master()
130 list_add_tail(&lock->list, &res->granted); in dlmlock_master()
144 lock->ml.node); in dlmlock_master()
155 lock->ml.node); in dlmlock_master()
159 dlm_lock_get(lock); in dlmlock_master()
160 list_add_tail(&lock->list, &res->blocked); in dlmlock_master()
170 dlm_queue_ast(dlm, lock); in dlmlock_master()
182 struct dlm_lock *lock) in dlm_revert_pending_lock() argument
185 list_del_init(&lock->list); in dlm_revert_pending_lock()
186 lock->lksb->flags &= ~DLM_LKSB_GET_LVB; in dlm_revert_pending_lock()
199 struct dlm_lock *lock, int flags) in dlmlock_remote() argument
205 lock->ml.type, res->lockname.len, in dlmlock_remote()
221 dlm_lock_get(lock); in dlmlock_remote()
222 list_add_tail(&lock->list, &res->blocked); in dlmlock_remote()
223 lock->lock_pending = 1; in dlmlock_remote()
228 status = dlm_send_remote_lock_request(dlm, res, lock, flags); in dlmlock_remote()
232 lock->lock_pending = 0; in dlmlock_remote()
253 dlm_revert_pending_lock(res, lock); in dlmlock_remote()
254 dlm_lock_put(lock); in dlmlock_remote()
264 list_move_tail(&lock->list, &res->granted); in dlmlock_remote()
285 struct dlm_lock *lock, int flags) in dlm_send_remote_lock_request() argument
293 create.requested_type = lock->ml.type; in dlm_send_remote_lock_request()
294 create.cookie = lock->ml.cookie; in dlm_send_remote_lock_request()
324 void dlm_lock_get(struct dlm_lock *lock) in dlm_lock_get() argument
326 kref_get(&lock->lock_refs); in dlm_lock_get()
329 void dlm_lock_put(struct dlm_lock *lock) in dlm_lock_put() argument
331 kref_put(&lock->lock_refs, dlm_lock_release); in dlm_lock_put()
336 struct dlm_lock *lock; in dlm_lock_release() local
338 lock = container_of(kref, struct dlm_lock, lock_refs); in dlm_lock_release()
340 BUG_ON(!list_empty(&lock->list)); in dlm_lock_release()
341 BUG_ON(!list_empty(&lock->ast_list)); in dlm_lock_release()
342 BUG_ON(!list_empty(&lock->bast_list)); in dlm_lock_release()
343 BUG_ON(lock->ast_pending); in dlm_lock_release()
344 BUG_ON(lock->bast_pending); in dlm_lock_release()
346 dlm_lock_detach_lockres(lock); in dlm_lock_release()
348 if (lock->lksb_kernel_allocated) { in dlm_lock_release()
350 kfree(lock->lksb); in dlm_lock_release()
352 kmem_cache_free(dlm_lock_cache, lock); in dlm_lock_release()
356 void dlm_lock_attach_lockres(struct dlm_lock *lock, in dlm_lock_attach_lockres() argument
360 lock->lockres = res; in dlm_lock_attach_lockres()
364 static void dlm_lock_detach_lockres(struct dlm_lock *lock) in dlm_lock_detach_lockres() argument
368 res = lock->lockres; in dlm_lock_detach_lockres()
370 lock->lockres = NULL; in dlm_lock_detach_lockres()
408 struct dlm_lock *lock; in dlm_new_lock() local
411 lock = kmem_cache_zalloc(dlm_lock_cache, GFP_NOFS); in dlm_new_lock()
412 if (!lock) in dlm_new_lock()
419 kmem_cache_free(dlm_lock_cache, lock); in dlm_new_lock()
425 dlm_init_lock(lock, type, node, cookie); in dlm_new_lock()
427 lock->lksb_kernel_allocated = 1; in dlm_new_lock()
428 lock->lksb = lksb; in dlm_new_lock()
429 lksb->lockid = lock; in dlm_new_lock()
430 return lock; in dlm_new_lock()
547 struct dlm_lock *lock = NULL; in dlmlock() local
586 lock = lksb->lockid; in dlmlock()
587 if (!lock) { in dlmlock()
593 res = lock->lockres; in dlmlock()
606 if (lock->lksb != lksb || lock->ast != ast || in dlmlock()
607 lock->bast != bast || lock->astdata != data) { in dlmlock()
612 "astdata=%p\n", lock->lksb, lock->ast, in dlmlock()
613 lock->bast, lock->astdata); in dlmlock()
620 status = dlmconvert_master(dlm, res, lock, flags, mode); in dlmlock()
622 status = dlmconvert_remote(dlm, res, lock, flags, mode); in dlmlock()
651 lock = dlm_new_lock(mode, dlm->node_num, tmpcookie, lksb); in dlmlock()
652 if (!lock) { in dlmlock()
669 mlog(0, "creating lock: lock=%p res=%p\n", lock, res); in dlmlock()
671 dlm_lock_attach_lockres(lock, res); in dlmlock()
672 lock->ast = ast; in dlmlock()
673 lock->bast = bast; in dlmlock()
674 lock->astdata = data; in dlmlock()
686 lock->lksb->flags |= DLM_LKSB_GET_LVB; in dlmlock()
691 status = dlmlock_master(dlm, res, lock, flags); in dlmlock()
693 status = dlmlock_remote(dlm, res, lock, flags); in dlmlock()
721 lock->lksb->flags &= ~DLM_LKSB_GET_LVB; in dlmlock()
730 if (lock && !convert) in dlmlock()
731 dlm_lock_put(lock); in dlmlock()