Lines Matching +full:lock +full:- +full:status
1 // SPDX-License-Identifier: GPL-2.0-or-later
43 struct dlm_lock *lock,
48 struct dlm_lock *lock,
54 struct dlm_lock *lock,
67 * So to unlock a converting lock, you must first cancel the
76 * taken: res->spinlock and lock->spinlock taken and dropped
78 * returns: DLM_NORMAL, DLM_NOLOCKMGR, status from network
79 * all callers should have taken an extra ref on lock coming in
83 struct dlm_lock *lock, in dlmunlock_common() argument
88 enum dlm_status status; in dlmunlock_common() local
98 BUG_ON(res->owner != dlm->node_num); in dlmunlock_common()
100 BUG_ON(res->owner == dlm->node_num); in dlmunlock_common()
102 spin_lock(&dlm->ast_lock); in dlmunlock_common()
103 /* We want to be sure that we're not freeing a lock in dlmunlock_common()
105 in_use = !list_empty(&lock->ast_list); in dlmunlock_common()
106 spin_unlock(&dlm->ast_lock); in dlmunlock_common()
109 "while waiting for an ast!", res->lockname.len, in dlmunlock_common()
110 res->lockname.name); in dlmunlock_common()
114 spin_lock(&res->spinlock); in dlmunlock_common()
115 if (res->state & DLM_LOCK_RES_IN_PROGRESS) { in dlmunlock_common()
118 spin_unlock(&res->spinlock); in dlmunlock_common()
123 res->state |= DLM_LOCK_RES_IN_PROGRESS; in dlmunlock_common()
125 spin_lock(&lock->spinlock); in dlmunlock_common()
127 if (res->state & DLM_LOCK_RES_RECOVERING) { in dlmunlock_common()
128 status = DLM_RECOVERING; in dlmunlock_common()
132 if (res->state & DLM_LOCK_RES_MIGRATING) { in dlmunlock_common()
133 status = DLM_MIGRATING; in dlmunlock_common()
138 * LKM_CANCEL and the lock queue state */ in dlmunlock_common()
140 status = dlm_get_cancel_actions(dlm, res, lock, lksb, &actions); in dlmunlock_common()
142 status = dlm_get_unlock_actions(dlm, res, lock, lksb, &actions); in dlmunlock_common()
144 if (status != DLM_NORMAL && (status != DLM_CANCELGRANT || !master_node)) in dlmunlock_common()
151 memcpy(res->lvb, lksb->lvb, DLM_LVB_LEN); in dlmunlock_common()
158 owner = res->owner; in dlmunlock_common()
161 lock->cancel_pending = 1; in dlmunlock_common()
163 lock->unlock_pending = 1; in dlmunlock_common()
164 spin_unlock(&lock->spinlock); in dlmunlock_common()
165 spin_unlock(&res->spinlock); in dlmunlock_common()
166 status = dlm_send_remote_unlock_request(dlm, res, lock, lksb, in dlmunlock_common()
168 spin_lock(&res->spinlock); in dlmunlock_common()
169 spin_lock(&lock->spinlock); in dlmunlock_common()
170 /* if the master told us the lock was already granted, in dlmunlock_common()
172 if (status == DLM_CANCELGRANT) { in dlmunlock_common()
176 } else if (status == DLM_RECOVERING || in dlmunlock_common()
177 status == DLM_MIGRATING || in dlmunlock_common()
178 status == DLM_FORWARD || in dlmunlock_common()
179 status == DLM_NOLOCKMGR in dlmunlock_common()
185 dlm->name, res->lockname.len, in dlmunlock_common()
186 res->lockname.name, in dlmunlock_common()
187 status==DLM_RECOVERING?"recovering": in dlmunlock_common()
188 (status==DLM_MIGRATING?"migrating": in dlmunlock_common()
189 (status == DLM_FORWARD ? "forward" : in dlmunlock_common()
194 lock->cancel_pending = 0; in dlmunlock_common()
196 if (!lock->unlock_pending) in dlmunlock_common()
199 lock->unlock_pending = 0; in dlmunlock_common()
203 /* get an extra ref on lock. if we are just switching in dlmunlock_common()
204 * lists here, we dont want the lock to go away. */ in dlmunlock_common()
205 dlm_lock_get(lock); in dlmunlock_common()
208 list_del_init(&lock->list); in dlmunlock_common()
209 dlm_lock_put(lock); in dlmunlock_common()
212 dlm_lock_get(lock); in dlmunlock_common()
213 list_add_tail(&lock->list, &res->granted); in dlmunlock_common()
217 master_node ? "" : "non-"); in dlmunlock_common()
218 lock->ml.convert_type = LKM_IVMODE; in dlmunlock_common()
221 /* remove the extra ref on lock */ in dlmunlock_common()
222 dlm_lock_put(lock); in dlmunlock_common()
225 res->state &= ~DLM_LOCK_RES_IN_PROGRESS; in dlmunlock_common()
226 if (!dlm_lock_on_list(&res->converting, lock)) in dlmunlock_common()
227 BUG_ON(lock->ml.convert_type != LKM_IVMODE); in dlmunlock_common()
229 BUG_ON(lock->ml.convert_type == LKM_IVMODE); in dlmunlock_common()
230 spin_unlock(&lock->spinlock); in dlmunlock_common()
231 spin_unlock(&res->spinlock); in dlmunlock_common()
232 wake_up(&res->wq); in dlmunlock_common()
235 spin_lock(&res->spinlock); in dlmunlock_common()
237 * and the lock is already removed from grant list. We have to in dlmunlock_common()
242 spin_unlock(&res->spinlock); in dlmunlock_common()
249 mlog(0, "lock %u:%llu should be gone now! refs=%d\n", in dlmunlock_common()
250 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in dlmunlock_common()
251 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)), in dlmunlock_common()
252 kref_read(&lock->lock_refs)-1); in dlmunlock_common()
253 dlm_lock_put(lock); in dlmunlock_common()
259 if (status == DLM_NORMAL) in dlmunlock_common()
260 lksb->flags &= ~(DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB); in dlmunlock_common()
262 return status; in dlmunlock_common()
266 struct dlm_lock *lock) in dlm_commit_pending_unlock() argument
270 list_del_init(&lock->list); in dlm_commit_pending_unlock()
274 struct dlm_lock *lock) in dlm_commit_pending_cancel() argument
276 list_move_tail(&lock->list, &res->granted); in dlm_commit_pending_cancel()
277 lock->ml.convert_type = LKM_IVMODE; in dlm_commit_pending_cancel()
283 struct dlm_lock *lock, in dlmunlock_master() argument
288 return dlmunlock_common(dlm, res, lock, lksb, flags, call_ast, 1); in dlmunlock_master()
293 struct dlm_lock *lock, in dlmunlock_remote() argument
297 return dlmunlock_common(dlm, res, lock, lksb, flags, call_ast, 0); in dlmunlock_remote()
305 * returns: DLM_NORMAL, DLM_NOLOCKMGR, status from network
309 struct dlm_lock *lock, in dlm_send_remote_unlock_request() argument
317 int status = 0; in dlm_send_remote_unlock_request() local
321 mlog(0, "%.*s\n", res->lockname.len, res->lockname.name); in dlm_send_remote_unlock_request()
323 if (owner == dlm->node_num) { in dlm_send_remote_unlock_request()
328 "migration, re-evaluate now\n", dlm->name, in dlm_send_remote_unlock_request()
329 res->lockname.len, res->lockname.name); in dlm_send_remote_unlock_request()
334 unlock.node_idx = dlm->node_num; in dlm_send_remote_unlock_request()
336 unlock.cookie = lock->ml.cookie; in dlm_send_remote_unlock_request()
337 unlock.namelen = res->lockname.len; in dlm_send_remote_unlock_request()
338 memcpy(unlock.name, res->lockname.name, unlock.namelen); in dlm_send_remote_unlock_request()
346 vec[1].iov_base = lock->lksb->lvb; in dlm_send_remote_unlock_request()
350 tmpret = o2net_send_message_vec(DLM_UNLOCK_LOCK_MSG, dlm->key, in dlm_send_remote_unlock_request()
351 vec, veclen, owner, &status); in dlm_send_remote_unlock_request()
354 if (status == DLM_FORWARD) in dlm_send_remote_unlock_request()
355 mlog(0, "master was in-progress. retry\n"); in dlm_send_remote_unlock_request()
356 ret = status; in dlm_send_remote_unlock_request()
359 "node %u\n", tmpret, DLM_UNLOCK_LOCK_MSG, dlm->key, owner); in dlm_send_remote_unlock_request()
384 * taken: takes and drops res->spinlock
393 struct dlm_unlock_lock *unlock = (struct dlm_unlock_lock *)msg->buf; in dlm_unlock_lock_handler()
395 struct dlm_lock *lock = NULL, *iter; in dlm_unlock_lock_handler() local
396 enum dlm_status status = DLM_NORMAL; in dlm_unlock_lock_handler() local
403 flags = be32_to_cpu(unlock->flags); in dlm_unlock_lock_handler()
416 if (unlock->namelen > DLM_LOCKID_NAME_MAX) { in dlm_unlock_lock_handler()
425 "Domain %s not fully joined!\n", dlm->name); in dlm_unlock_lock_handler()
429 res = dlm_lookup_lockres(dlm, unlock->name, unlock->namelen); in dlm_unlock_lock_handler()
431 /* We assume here that a no lock resource simply means in dlm_unlock_lock_handler()
434 mlog(0, "returning DLM_FORWARD -- res no longer exists\n"); in dlm_unlock_lock_handler()
435 status = DLM_FORWARD; in dlm_unlock_lock_handler()
439 queue=&res->granted; in dlm_unlock_lock_handler()
440 spin_lock(&res->spinlock); in dlm_unlock_lock_handler()
441 if (res->state & DLM_LOCK_RES_RECOVERING) { in dlm_unlock_lock_handler()
442 spin_unlock(&res->spinlock); in dlm_unlock_lock_handler()
444 status = DLM_RECOVERING; in dlm_unlock_lock_handler()
448 if (res->state & DLM_LOCK_RES_MIGRATING) { in dlm_unlock_lock_handler()
449 spin_unlock(&res->spinlock); in dlm_unlock_lock_handler()
451 status = DLM_MIGRATING; in dlm_unlock_lock_handler()
455 if (res->owner != dlm->node_num) { in dlm_unlock_lock_handler()
456 spin_unlock(&res->spinlock); in dlm_unlock_lock_handler()
457 mlog(0, "returning DLM_FORWARD -- not master\n"); in dlm_unlock_lock_handler()
458 status = DLM_FORWARD; in dlm_unlock_lock_handler()
464 if (iter->ml.cookie == unlock->cookie && in dlm_unlock_lock_handler()
465 iter->ml.node == unlock->node_idx) { in dlm_unlock_lock_handler()
467 lock = iter; in dlm_unlock_lock_handler()
471 if (lock) in dlm_unlock_lock_handler()
473 /* scan granted -> converting -> blocked queues */ in dlm_unlock_lock_handler()
476 spin_unlock(&res->spinlock); in dlm_unlock_lock_handler()
477 if (!lock) { in dlm_unlock_lock_handler()
478 status = DLM_IVLOCKID; in dlm_unlock_lock_handler()
482 /* lock was found on queue */ in dlm_unlock_lock_handler()
483 lksb = lock->lksb; in dlm_unlock_lock_handler()
485 lock->ml.type != LKM_EXMODE) in dlm_unlock_lock_handler()
490 lksb->flags |= DLM_LKSB_PUT_LVB; in dlm_unlock_lock_handler()
491 memcpy(&lksb->lvb[0], &unlock->lvb[0], DLM_LVB_LEN); in dlm_unlock_lock_handler()
494 /* if this is in-progress, propagate the DLM_FORWARD in dlm_unlock_lock_handler()
496 status = dlmunlock_master(dlm, res, lock, lksb, flags, &ignore); in dlm_unlock_lock_handler()
497 if (status == DLM_FORWARD) in dlm_unlock_lock_handler()
501 lksb->flags &= ~DLM_LKSB_PUT_LVB; in dlm_unlock_lock_handler()
507 if (!lock) in dlm_unlock_lock_handler()
508 mlog(ML_ERROR, "failed to find lock to unlock! " in dlm_unlock_lock_handler()
510 dlm_get_lock_cookie_node(be64_to_cpu(unlock->cookie)), in dlm_unlock_lock_handler()
511 dlm_get_lock_cookie_seq(be64_to_cpu(unlock->cookie))); in dlm_unlock_lock_handler()
513 dlm_lock_put(lock); in dlm_unlock_lock_handler()
521 return status; in dlm_unlock_lock_handler()
527 struct dlm_lock *lock, in dlm_get_cancel_actions() argument
531 enum dlm_status status; in dlm_get_cancel_actions() local
533 if (dlm_lock_on_list(&res->blocked, lock)) { in dlm_get_cancel_actions()
535 status = DLM_NORMAL; in dlm_get_cancel_actions()
538 } else if (dlm_lock_on_list(&res->converting, lock)) { in dlm_get_cancel_actions()
540 status = DLM_NORMAL; in dlm_get_cancel_actions()
545 } else if (dlm_lock_on_list(&res->granted, lock)) { in dlm_get_cancel_actions()
547 status = DLM_CANCELGRANT; in dlm_get_cancel_actions()
550 mlog(ML_ERROR, "lock to cancel is not on any list!\n"); in dlm_get_cancel_actions()
551 status = DLM_IVLOCKID; in dlm_get_cancel_actions()
554 return status; in dlm_get_cancel_actions()
559 struct dlm_lock *lock, in dlm_get_unlock_actions() argument
563 enum dlm_status status; in dlm_get_unlock_actions() local
566 if (!dlm_lock_on_list(&res->granted, lock)) { in dlm_get_unlock_actions()
567 status = DLM_DENIED; in dlm_get_unlock_actions()
568 dlm_error(status); in dlm_get_unlock_actions()
571 /* unlock granted lock */ in dlm_get_unlock_actions()
572 status = DLM_NORMAL; in dlm_get_unlock_actions()
577 return status; in dlm_get_unlock_actions()
587 enum dlm_status status; in dlmunlock() local
589 struct dlm_lock *lock = NULL; in dlmunlock() local
607 if (!lksb->lockid || !lksb->lockid->lockres) { in dlmunlock()
612 lock = lksb->lockid; in dlmunlock()
613 BUG_ON(!lock); in dlmunlock()
614 dlm_lock_get(lock); in dlmunlock()
616 res = lock->lockres; in dlmunlock()
622 mlog(0, "lock=%p res=%p\n", lock, res); in dlmunlock()
624 spin_lock(&res->spinlock); in dlmunlock()
625 is_master = (res->owner == dlm->node_num); in dlmunlock()
626 if (flags & LKM_VALBLK && lock->ml.type != LKM_EXMODE) in dlmunlock()
628 spin_unlock(&res->spinlock); in dlmunlock()
631 status = dlmunlock_master(dlm, res, lock, lksb, flags, in dlmunlock()
634 "call_ast is %d\n", status, call_ast); in dlmunlock()
636 status = dlmunlock_remote(dlm, res, lock, lksb, flags, in dlmunlock()
639 "call_ast is %d\n", status, call_ast); in dlmunlock()
642 if (status == DLM_RECOVERING || in dlmunlock()
643 status == DLM_MIGRATING || in dlmunlock()
644 status == DLM_FORWARD || in dlmunlock()
645 status == DLM_NOLOCKMGR) { in dlmunlock()
658 "migration/in-progress/reconnect\n"); in dlmunlock()
663 mlog(0, "calling unlockast(%p, %d)\n", data, status); in dlmunlock()
669 * since this lock has been removed from the in dlmunlock()
672 wait_event(dlm->ast_wq, in dlmunlock()
673 dlm_lock_basts_flushed(dlm, lock)); in dlmunlock()
675 (*unlockast)(data, status); in dlmunlock()
678 if (status == DLM_CANCELGRANT) in dlmunlock()
679 status = DLM_NORMAL; in dlmunlock()
681 if (status == DLM_NORMAL) { in dlmunlock()
685 dlm_error(status); in dlmunlock()
689 dlm_lock_put(lock); in dlmunlock()
691 mlog(0, "returning status=%d!\n", status); in dlmunlock()
692 return status; in dlmunlock()