Lines Matching refs:ls

90 static void do_purge(struct dlm_ls *ls, int nodeid, int pid);
200 static inline void dlm_lock_recovery(struct dlm_ls *ls) in dlm_lock_recovery() argument
202 down_read(&ls->ls_in_recovery); in dlm_lock_recovery()
205 void dlm_unlock_recovery(struct dlm_ls *ls) in dlm_unlock_recovery() argument
207 up_read(&ls->ls_in_recovery); in dlm_unlock_recovery()
210 int dlm_lock_recovery_try(struct dlm_ls *ls) in dlm_lock_recovery_try() argument
212 return down_read_trylock(&ls->ls_in_recovery); in dlm_lock_recovery_try()
330 static struct dlm_rsb *create_rsb(struct dlm_ls *ls, char *name, int len) in create_rsb() argument
334 r = dlm_allocate_rsb(ls, len); in create_rsb()
338 r->res_ls = ls; in create_rsb()
373 static int _search_rsb(struct dlm_ls *ls, char *name, int len, int b, in _search_rsb() argument
379 error = search_rsb_list(&ls->ls_rsbtbl[b].list, name, len, flags, &r); in _search_rsb()
384 error = search_rsb_list(&ls->ls_rsbtbl[b].toss, name, len, flags, &r); in _search_rsb()
388 list_move(&r->res_hashchain, &ls->ls_rsbtbl[b].list); in _search_rsb()
390 if (dlm_no_directory(ls)) in _search_rsb()
408 static int search_rsb(struct dlm_ls *ls, char *name, int len, int b, in search_rsb() argument
412 spin_lock(&ls->ls_rsbtbl[b].lock); in search_rsb()
413 error = _search_rsb(ls, name, len, b, flags, r_ret); in search_rsb()
414 spin_unlock(&ls->ls_rsbtbl[b].lock); in search_rsb()
432 static int find_rsb(struct dlm_ls *ls, char *name, int namelen, in find_rsb() argument
442 if (dlm_no_directory(ls)) in find_rsb()
447 bucket = hash & (ls->ls_rsbtbl_size - 1); in find_rsb()
449 error = search_rsb(ls, name, namelen, bucket, flags, &r); in find_rsb()
461 r = create_rsb(ls, name, namelen); in find_rsb()
471 if (dlm_no_directory(ls)) { in find_rsb()
478 spin_lock(&ls->ls_rsbtbl[bucket].lock); in find_rsb()
479 error = _search_rsb(ls, name, namelen, bucket, 0, &tmp); in find_rsb()
481 spin_unlock(&ls->ls_rsbtbl[bucket].lock); in find_rsb()
486 list_add(&r->res_hashchain, &ls->ls_rsbtbl[bucket].list); in find_rsb()
487 spin_unlock(&ls->ls_rsbtbl[bucket].lock); in find_rsb()
510 struct dlm_ls *ls = r->res_ls; in toss_rsb() local
514 list_move(&r->res_hashchain, &ls->ls_rsbtbl[r->res_bucket].toss); in toss_rsb()
527 struct dlm_ls *ls = r->res_ls; in put_rsb() local
530 spin_lock(&ls->ls_rsbtbl[bucket].lock); in put_rsb()
532 spin_unlock(&ls->ls_rsbtbl[bucket].lock); in put_rsb()
581 static int create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret) in create_lkb() argument
587 lkb = dlm_allocate_lkb(ls); in create_lkb()
600 bucket &= (ls->ls_lkbtbl_size - 1); in create_lkb()
602 write_lock(&ls->ls_lkbtbl[bucket].lock); in create_lkb()
607 lkid = (bucket << 16) | ls->ls_lkbtbl[bucket].counter++; in create_lkb()
609 list_for_each_entry(tmp, &ls->ls_lkbtbl[bucket].list, in create_lkb()
619 list_add(&lkb->lkb_idtbl_list, &ls->ls_lkbtbl[bucket].list); in create_lkb()
620 write_unlock(&ls->ls_lkbtbl[bucket].lock); in create_lkb()
626 static struct dlm_lkb *__find_lkb(struct dlm_ls *ls, uint32_t lkid) in __find_lkb() argument
631 list_for_each_entry(lkb, &ls->ls_lkbtbl[bucket].list, lkb_idtbl_list) { in __find_lkb()
638 static int find_lkb(struct dlm_ls *ls, uint32_t lkid, struct dlm_lkb **lkb_ret) in find_lkb() argument
643 if (bucket >= ls->ls_lkbtbl_size) in find_lkb()
646 read_lock(&ls->ls_lkbtbl[bucket].lock); in find_lkb()
647 lkb = __find_lkb(ls, lkid); in find_lkb()
650 read_unlock(&ls->ls_lkbtbl[bucket].lock); in find_lkb()
669 static int __put_lkb(struct dlm_ls *ls, struct dlm_lkb *lkb) in __put_lkb() argument
673 write_lock(&ls->ls_lkbtbl[bucket].lock); in __put_lkb()
676 write_unlock(&ls->ls_lkbtbl[bucket].lock); in __put_lkb()
686 write_unlock(&ls->ls_lkbtbl[bucket].lock); in __put_lkb()
693 struct dlm_ls *ls; in dlm_put_lkb() local
698 ls = lkb->lkb_resource->res_ls; in dlm_put_lkb()
699 return __put_lkb(ls, lkb); in dlm_put_lkb()
807 struct dlm_ls *ls = lkb->lkb_resource->res_ls; in add_to_waiters() local
810 mutex_lock(&ls->ls_waiters_mutex); in add_to_waiters()
833 log_debug(ls, "addwait %x cur %d overlap %d count %d f %x", in add_to_waiters()
846 list_add(&lkb->lkb_wait_reply, &ls->ls_waiters); in add_to_waiters()
849 log_error(ls, "addwait error %x %d flags %x %d %d %s", in add_to_waiters()
852 mutex_unlock(&ls->ls_waiters_mutex); in add_to_waiters()
864 struct dlm_ls *ls = lkb->lkb_resource->res_ls; in _remove_from_waiters() local
868 log_debug(ls, "remwait %x unlock_reply overlap", lkb->lkb_id); in _remove_from_waiters()
875 log_debug(ls, "remwait %x cancel_reply overlap", lkb->lkb_id); in _remove_from_waiters()
886 log_debug(ls, "remwait %x cancel_reply wait_type %d", in _remove_from_waiters()
902 log_debug(ls, "remwait %x convert_reply zap overlap_cancel", in _remove_from_waiters()
918 log_error(ls, "remwait error %x reply %d flags %x no wait_type", in _remove_from_waiters()
929 log_error(ls, "remwait error %x reply %d wait_type %d overlap", in _remove_from_waiters()
947 struct dlm_ls *ls = lkb->lkb_resource->res_ls; in remove_from_waiters() local
950 mutex_lock(&ls->ls_waiters_mutex); in remove_from_waiters()
952 mutex_unlock(&ls->ls_waiters_mutex); in remove_from_waiters()
961 struct dlm_ls *ls = lkb->lkb_resource->res_ls; in remove_from_waiters_ms() local
964 if (ms != &ls->ls_stub_ms) in remove_from_waiters_ms()
965 mutex_lock(&ls->ls_waiters_mutex); in remove_from_waiters_ms()
967 if (ms != &ls->ls_stub_ms) in remove_from_waiters_ms()
968 mutex_unlock(&ls->ls_waiters_mutex); in remove_from_waiters_ms()
990 static int shrink_bucket(struct dlm_ls *ls, int b) in shrink_bucket() argument
997 spin_lock(&ls->ls_rsbtbl[b].lock); in shrink_bucket()
998 list_for_each_entry_reverse(r, &ls->ls_rsbtbl[b].toss, in shrink_bucket()
1008 spin_unlock(&ls->ls_rsbtbl[b].lock); in shrink_bucket()
1014 spin_unlock(&ls->ls_rsbtbl[b].lock); in shrink_bucket()
1021 spin_unlock(&ls->ls_rsbtbl[b].lock); in shrink_bucket()
1022 log_error(ls, "tossed rsb in use %s", r->res_name); in shrink_bucket()
1029 void dlm_scan_rsbs(struct dlm_ls *ls) in dlm_scan_rsbs() argument
1033 for (i = 0; i < ls->ls_rsbtbl_size; i++) { in dlm_scan_rsbs()
1034 shrink_bucket(ls, i); in dlm_scan_rsbs()
1035 if (dlm_locking_stopped(ls)) in dlm_scan_rsbs()
1043 struct dlm_ls *ls = lkb->lkb_resource->res_ls; in add_timeout() local
1048 if (test_bit(LSFL_TIMEWARN, &ls->ls_flags) && in add_timeout()
1059 mutex_lock(&ls->ls_timeout_mutex); in add_timeout()
1061 list_add_tail(&lkb->lkb_time_list, &ls->ls_timeout); in add_timeout()
1062 mutex_unlock(&ls->ls_timeout_mutex); in add_timeout()
1067 struct dlm_ls *ls = lkb->lkb_resource->res_ls; in del_timeout() local
1069 mutex_lock(&ls->ls_timeout_mutex); in del_timeout()
1074 mutex_unlock(&ls->ls_timeout_mutex); in del_timeout()
1083 void dlm_scan_timeout(struct dlm_ls *ls) in dlm_scan_timeout() argument
1091 if (dlm_locking_stopped(ls)) in dlm_scan_timeout()
1096 mutex_lock(&ls->ls_timeout_mutex); in dlm_scan_timeout()
1097 list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) { in dlm_scan_timeout()
1115 mutex_unlock(&ls->ls_timeout_mutex); in dlm_scan_timeout()
1133 log_debug(ls, "timeout cancel %x node %d %s", in dlm_scan_timeout()
1150 void dlm_adjust_timeouts(struct dlm_ls *ls) in dlm_adjust_timeouts() argument
1153 u64 adj_us = jiffies_to_usecs(jiffies - ls->ls_recover_begin); in dlm_adjust_timeouts()
1155 ls->ls_recover_begin = 0; in dlm_adjust_timeouts()
1156 mutex_lock(&ls->ls_timeout_mutex); in dlm_adjust_timeouts()
1157 list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) in dlm_adjust_timeouts()
1159 mutex_unlock(&ls->ls_timeout_mutex); in dlm_adjust_timeouts()
1886 struct dlm_ls *ls = r->res_ls; in set_master() local
1928 error = dlm_dir_lookup(ls, our_nodeid, r->res_name, in set_master()
1932 log_debug(ls, "dir_lookup error %d %s", error, r->res_name); in set_master()
2080 static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, in validate_lock_args() argument
2117 log_debug(ls, "validate_lock_args %d %x %x %x %d %d %s", in validate_lock_args()
2133 struct dlm_ls *ls = lkb->lkb_resource->res_ls; in validate_unlock_args() local
2137 log_error(ls, "unlock on MSTCPY %x", lkb->lkb_id); in validate_unlock_args()
2147 log_debug(ls, "unlock on ENDOFLIFE %x", lkb->lkb_id); in validate_unlock_args()
2157 log_debug(ls, "unlock on rsb_lookup %x", lkb->lkb_id); in validate_unlock_args()
2254 log_debug(ls, "validate_unlock_args %d %x %x %x %x %d %s", rv, in validate_unlock_args()
2511 static int request_lock(struct dlm_ls *ls, struct dlm_lkb *lkb, char *name, in request_lock() argument
2517 error = validate_lock_args(ls, lkb, args); in request_lock()
2521 error = find_rsb(ls, name, len, R_CREATE, &r); in request_lock()
2539 static int convert_lock(struct dlm_ls *ls, struct dlm_lkb *lkb, in convert_lock() argument
2550 error = validate_lock_args(ls, lkb, args); in convert_lock()
2561 static int unlock_lock(struct dlm_ls *ls, struct dlm_lkb *lkb, in unlock_lock() argument
2583 static int cancel_lock(struct dlm_ls *ls, struct dlm_lkb *lkb, in cancel_lock() argument
2620 struct dlm_ls *ls; in dlm_lock() local
2625 ls = dlm_find_lockspace_local(lockspace); in dlm_lock()
2626 if (!ls) in dlm_lock()
2629 dlm_lock_recovery(ls); in dlm_lock()
2632 error = find_lkb(ls, lksb->sb_lkid, &lkb); in dlm_lock()
2634 error = create_lkb(ls, &lkb); in dlm_lock()
2645 error = convert_lock(ls, lkb, &args); in dlm_lock()
2647 error = request_lock(ls, lkb, name, namelen, &args); in dlm_lock()
2653 __put_lkb(ls, lkb); in dlm_lock()
2657 dlm_unlock_recovery(ls); in dlm_lock()
2658 dlm_put_lockspace(ls); in dlm_lock()
2668 struct dlm_ls *ls; in dlm_unlock() local
2673 ls = dlm_find_lockspace_local(lockspace); in dlm_unlock()
2674 if (!ls) in dlm_unlock()
2677 dlm_lock_recovery(ls); in dlm_unlock()
2679 error = find_lkb(ls, lkid, &lkb); in dlm_unlock()
2688 error = cancel_lock(ls, lkb, &args); in dlm_unlock()
2690 error = unlock_lock(ls, lkb, &args); in dlm_unlock()
2699 dlm_unlock_recovery(ls); in dlm_unlock()
2700 dlm_put_lockspace(ls); in dlm_unlock()
2726 static int _create_message(struct dlm_ls *ls, int mb_len, in _create_message() argument
2748 ms->m_header.h_lockspace = ls->ls_global_id; in _create_message()
3038 static int send_lookup_reply(struct dlm_ls *ls, struct dlm_message *ms_in, in send_lookup_reply() argument
3041 struct dlm_rsb *r = &ls->ls_stub_rsb; in send_lookup_reply()
3083 static int receive_lvb(struct dlm_ls *ls, struct dlm_lkb *lkb, in receive_lvb() argument
3090 lkb->lkb_lvbptr = dlm_allocate_lvb(ls); in receive_lvb()
3111 static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb, in receive_request_args() argument
3125 lkb->lkb_lvbptr = dlm_allocate_lvb(ls); in receive_request_args()
3133 static int receive_convert_args(struct dlm_ls *ls, struct dlm_lkb *lkb, in receive_convert_args() argument
3139 if (receive_lvb(ls, lkb, ms)) in receive_convert_args()
3148 static int receive_unlock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, in receive_unlock_args() argument
3151 if (receive_lvb(ls, lkb, ms)) in receive_unlock_args()
3159 static void setup_stub_lkb(struct dlm_ls *ls, struct dlm_message *ms) in setup_stub_lkb() argument
3161 struct dlm_lkb *lkb = &ls->ls_stub_lkb; in setup_stub_lkb()
3210 static void receive_request(struct dlm_ls *ls, struct dlm_message *ms) in receive_request() argument
3216 error = create_lkb(ls, &lkb); in receive_request()
3222 error = receive_request_args(ls, lkb, ms); in receive_request()
3224 __put_lkb(ls, lkb); in receive_request()
3230 error = find_rsb(ls, ms->m_extra, namelen, R_MASTER, &r); in receive_request()
3232 __put_lkb(ls, lkb); in receive_request()
3253 setup_stub_lkb(ls, ms); in receive_request()
3254 send_request_reply(&ls->ls_stub_rsb, &ls->ls_stub_lkb, error); in receive_request()
3257 static void receive_convert(struct dlm_ls *ls, struct dlm_message *ms) in receive_convert() argument
3263 error = find_lkb(ls, ms->m_remid, &lkb); in receive_convert()
3278 error = receive_convert_args(ls, lkb, ms); in receive_convert()
3297 setup_stub_lkb(ls, ms); in receive_convert()
3298 send_convert_reply(&ls->ls_stub_rsb, &ls->ls_stub_lkb, error); in receive_convert()
3301 static void receive_unlock(struct dlm_ls *ls, struct dlm_message *ms) in receive_unlock() argument
3307 error = find_lkb(ls, ms->m_remid, &lkb); in receive_unlock()
3322 error = receive_unlock_args(ls, lkb, ms); in receive_unlock()
3338 setup_stub_lkb(ls, ms); in receive_unlock()
3339 send_unlock_reply(&ls->ls_stub_rsb, &ls->ls_stub_lkb, error); in receive_unlock()
3342 static void receive_cancel(struct dlm_ls *ls, struct dlm_message *ms) in receive_cancel() argument
3348 error = find_lkb(ls, ms->m_remid, &lkb); in receive_cancel()
3373 setup_stub_lkb(ls, ms); in receive_cancel()
3374 send_cancel_reply(&ls->ls_stub_rsb, &ls->ls_stub_lkb, error); in receive_cancel()
3377 static void receive_grant(struct dlm_ls *ls, struct dlm_message *ms) in receive_grant() argument
3383 error = find_lkb(ls, ms->m_remid, &lkb); in receive_grant()
3385 log_debug(ls, "receive_grant from %d no lkb %x", in receive_grant()
3410 static void receive_bast(struct dlm_ls *ls, struct dlm_message *ms) in receive_bast() argument
3416 error = find_lkb(ls, ms->m_remid, &lkb); in receive_bast()
3418 log_debug(ls, "receive_bast from %d no lkb %x", in receive_bast()
3439 static void receive_lookup(struct dlm_ls *ls, struct dlm_message *ms) in receive_lookup() argument
3448 dir_nodeid = dlm_hash2nodeid(ls, ms->m_hash); in receive_lookup()
3450 log_error(ls, "lookup dir_nodeid %d from %d", in receive_lookup()
3457 error = dlm_dir_lookup(ls, from_nodeid, ms->m_extra, len, &ret_nodeid); in receive_lookup()
3461 receive_request(ls, ms); in receive_lookup()
3465 send_lookup_reply(ls, ms, ret_nodeid, error); in receive_lookup()
3468 static void receive_remove(struct dlm_ls *ls, struct dlm_message *ms) in receive_remove() argument
3476 dir_nodeid = dlm_hash2nodeid(ls, ms->m_hash); in receive_remove()
3478 log_error(ls, "remove dir entry dir_nodeid %d from %d", in receive_remove()
3483 dlm_dir_remove_entry(ls, from_nodeid, ms->m_extra, len); in receive_remove()
3486 static void receive_purge(struct dlm_ls *ls, struct dlm_message *ms) in receive_purge() argument
3488 do_purge(ls, ms->m_nodeid, ms->m_pid); in receive_purge()
3491 static void receive_request_reply(struct dlm_ls *ls, struct dlm_message *ms) in receive_request_reply() argument
3497 error = find_lkb(ls, ms->m_remid, &lkb); in receive_request_reply()
3499 log_debug(ls, "receive_request_reply from %d no lkb %x", in receive_request_reply()
3555 log_debug(ls, "receive_request_reply %x %x master diff %d %d", in receive_request_reply()
3570 log_error(ls, "receive_request_reply %x error %d", in receive_request_reply()
3575 log_debug(ls, "receive_request_reply %x result %d unlock", in receive_request_reply()
3581 log_debug(ls, "receive_request_reply %x cancel", lkb->lkb_id); in receive_request_reply()
3659 static void receive_convert_reply(struct dlm_ls *ls, struct dlm_message *ms) in receive_convert_reply() argument
3664 error = find_lkb(ls, ms->m_remid, &lkb); in receive_convert_reply()
3666 log_debug(ls, "receive_convert_reply from %d no lkb %x", in receive_convert_reply()
3711 static void receive_unlock_reply(struct dlm_ls *ls, struct dlm_message *ms) in receive_unlock_reply() argument
3716 error = find_lkb(ls, ms->m_remid, &lkb); in receive_unlock_reply()
3718 log_debug(ls, "receive_unlock_reply from %d no lkb %x", in receive_unlock_reply()
3763 static void receive_cancel_reply(struct dlm_ls *ls, struct dlm_message *ms) in receive_cancel_reply() argument
3768 error = find_lkb(ls, ms->m_remid, &lkb); in receive_cancel_reply()
3770 log_debug(ls, "receive_cancel_reply from %d no lkb %x", in receive_cancel_reply()
3779 static void receive_lookup_reply(struct dlm_ls *ls, struct dlm_message *ms) in receive_lookup_reply() argument
3785 error = find_lkb(ls, ms->m_lkid, &lkb); in receive_lookup_reply()
3787 log_error(ls, "receive_lookup_reply no lkb"); in receive_lookup_reply()
3813 log_debug(ls, "receive_lookup_reply %x unlock %x", in receive_lookup_reply()
3831 static void _receive_message(struct dlm_ls *ls, struct dlm_message *ms) in _receive_message() argument
3833 if (!dlm_is_member(ls, ms->m_header.h_nodeid)) { in _receive_message()
3834 log_debug(ls, "ignore non-member message %d from %d %x %x %d", in _receive_message()
3845 receive_request(ls, ms); in _receive_message()
3849 receive_convert(ls, ms); in _receive_message()
3853 receive_unlock(ls, ms); in _receive_message()
3857 receive_cancel(ls, ms); in _receive_message()
3863 receive_request_reply(ls, ms); in _receive_message()
3867 receive_convert_reply(ls, ms); in _receive_message()
3871 receive_unlock_reply(ls, ms); in _receive_message()
3875 receive_cancel_reply(ls, ms); in _receive_message()
3881 receive_grant(ls, ms); in _receive_message()
3885 receive_bast(ls, ms); in _receive_message()
3891 receive_lookup(ls, ms); in _receive_message()
3895 receive_remove(ls, ms); in _receive_message()
3901 receive_lookup_reply(ls, ms); in _receive_message()
3907 receive_purge(ls, ms); in _receive_message()
3911 log_error(ls, "unknown message type %d", ms->m_type); in _receive_message()
3925 static void dlm_receive_message(struct dlm_ls *ls, struct dlm_message *ms, in dlm_receive_message() argument
3928 if (dlm_locking_stopped(ls)) { in dlm_receive_message()
3929 dlm_add_requestqueue(ls, nodeid, ms); in dlm_receive_message()
3931 dlm_wait_requestqueue(ls); in dlm_receive_message()
3932 _receive_message(ls, ms); in dlm_receive_message()
3939 void dlm_receive_message_saved(struct dlm_ls *ls, struct dlm_message *ms) in dlm_receive_message_saved() argument
3941 _receive_message(ls, ms); in dlm_receive_message_saved()
3952 struct dlm_ls *ls; in dlm_receive_buffer() local
3975 ls = dlm_find_lockspace_global(hd->h_lockspace); in dlm_receive_buffer()
3976 if (!ls) { in dlm_receive_buffer()
3989 down_read(&ls->ls_recv_active); in dlm_receive_buffer()
3991 dlm_receive_message(ls, &p->message, nodeid); in dlm_receive_buffer()
3993 dlm_receive_rcom(ls, &p->rcom, nodeid); in dlm_receive_buffer()
3994 up_read(&ls->ls_recv_active); in dlm_receive_buffer()
3996 dlm_put_lockspace(ls); in dlm_receive_buffer()
3999 static void recover_convert_waiter(struct dlm_ls *ls, struct dlm_lkb *lkb) in recover_convert_waiter() argument
4003 ls->ls_stub_ms.m_type = DLM_MSG_CONVERT_REPLY; in recover_convert_waiter()
4004 ls->ls_stub_ms.m_result = -EINPROGRESS; in recover_convert_waiter()
4005 ls->ls_stub_ms.m_flags = lkb->lkb_flags; in recover_convert_waiter()
4006 ls->ls_stub_ms.m_header.h_nodeid = lkb->lkb_nodeid; in recover_convert_waiter()
4007 _receive_convert_reply(lkb, &ls->ls_stub_ms); in recover_convert_waiter()
4025 static int waiter_needs_recovery(struct dlm_ls *ls, struct dlm_lkb *lkb) in waiter_needs_recovery() argument
4027 if (dlm_is_removed(ls, lkb->lkb_nodeid)) in waiter_needs_recovery()
4030 if (!dlm_no_directory(ls)) in waiter_needs_recovery()
4045 void dlm_recover_waiters_pre(struct dlm_ls *ls) in dlm_recover_waiters_pre() argument
4050 mutex_lock(&ls->ls_waiters_mutex); in dlm_recover_waiters_pre()
4052 list_for_each_entry_safe(lkb, safe, &ls->ls_waiters, lkb_wait_reply) { in dlm_recover_waiters_pre()
4053 log_debug(ls, "pre recover waiter lkid %x type %d flags %x", in dlm_recover_waiters_pre()
4064 if (!waiter_needs_recovery(ls, lkb)) in dlm_recover_waiters_pre()
4088 log_debug(ls, "rwpre overlap %x %x %d %d %d", in dlm_recover_waiters_pre()
4100 recover_convert_waiter(ls, lkb); in dlm_recover_waiters_pre()
4105 ls->ls_stub_ms.m_type = DLM_MSG_UNLOCK_REPLY; in dlm_recover_waiters_pre()
4106 ls->ls_stub_ms.m_result = stub_unlock_result; in dlm_recover_waiters_pre()
4107 ls->ls_stub_ms.m_flags = lkb->lkb_flags; in dlm_recover_waiters_pre()
4108 ls->ls_stub_ms.m_header.h_nodeid = lkb->lkb_nodeid; in dlm_recover_waiters_pre()
4109 _receive_unlock_reply(lkb, &ls->ls_stub_ms); in dlm_recover_waiters_pre()
4115 ls->ls_stub_ms.m_type = DLM_MSG_CANCEL_REPLY; in dlm_recover_waiters_pre()
4116 ls->ls_stub_ms.m_result = stub_cancel_result; in dlm_recover_waiters_pre()
4117 ls->ls_stub_ms.m_flags = lkb->lkb_flags; in dlm_recover_waiters_pre()
4118 ls->ls_stub_ms.m_header.h_nodeid = lkb->lkb_nodeid; in dlm_recover_waiters_pre()
4119 _receive_cancel_reply(lkb, &ls->ls_stub_ms); in dlm_recover_waiters_pre()
4124 log_error(ls, "invalid lkb wait_type %d %d", in dlm_recover_waiters_pre()
4129 mutex_unlock(&ls->ls_waiters_mutex); in dlm_recover_waiters_pre()
4132 static struct dlm_lkb *find_resend_waiter(struct dlm_ls *ls) in find_resend_waiter() argument
4137 mutex_lock(&ls->ls_waiters_mutex); in find_resend_waiter()
4138 list_for_each_entry(lkb, &ls->ls_waiters, lkb_wait_reply) { in find_resend_waiter()
4145 mutex_unlock(&ls->ls_waiters_mutex); in find_resend_waiter()
4168 int dlm_recover_waiters_post(struct dlm_ls *ls) in dlm_recover_waiters_post() argument
4175 if (dlm_locking_stopped(ls)) { in dlm_recover_waiters_post()
4176 log_debug(ls, "recover_waiters_post aborted"); in dlm_recover_waiters_post()
4181 lkb = find_resend_waiter(ls); in dlm_recover_waiters_post()
4194 log_debug(ls, "recover_waiters_post %x type %d flags %x %s", in dlm_recover_waiters_post()
4206 mutex_lock(&ls->ls_waiters_mutex); in dlm_recover_waiters_post()
4208 mutex_unlock(&ls->ls_waiters_mutex); in dlm_recover_waiters_post()
4248 log_error(ls, "recover_waiters_post %x %d %x %d %d", in dlm_recover_waiters_post()
4259 int (*test)(struct dlm_ls *ls, struct dlm_lkb *lkb)) in purge_queue() argument
4261 struct dlm_ls *ls = r->res_ls; in purge_queue() local
4265 if (test(ls, lkb)) { in purge_queue()
4270 log_error(ls, "purged lkb not released"); in purge_queue()
4275 static int purge_dead_test(struct dlm_ls *ls, struct dlm_lkb *lkb) in purge_dead_test() argument
4277 return (is_master_copy(lkb) && dlm_is_removed(ls, lkb->lkb_nodeid)); in purge_dead_test()
4280 static int purge_mstcpy_test(struct dlm_ls *ls, struct dlm_lkb *lkb) in purge_mstcpy_test() argument
4301 int dlm_purge_locks(struct dlm_ls *ls) in dlm_purge_locks() argument
4305 log_debug(ls, "dlm_purge_locks"); in dlm_purge_locks()
4307 down_write(&ls->ls_root_sem); in dlm_purge_locks()
4308 list_for_each_entry(r, &ls->ls_root_list, res_root_list) { in dlm_purge_locks()
4318 up_write(&ls->ls_root_sem); in dlm_purge_locks()
4323 static struct dlm_rsb *find_purged_rsb(struct dlm_ls *ls, int bucket) in find_purged_rsb() argument
4327 spin_lock(&ls->ls_rsbtbl[bucket].lock); in find_purged_rsb()
4328 list_for_each_entry(r, &ls->ls_rsbtbl[bucket].list, res_hashchain) { in find_purged_rsb()
4336 spin_unlock(&ls->ls_rsbtbl[bucket].lock); in find_purged_rsb()
4340 void dlm_grant_after_purge(struct dlm_ls *ls) in dlm_grant_after_purge() argument
4346 r = find_purged_rsb(ls, bucket); in dlm_grant_after_purge()
4348 if (bucket == ls->ls_rsbtbl_size - 1) in dlm_grant_after_purge()
4394 static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, in receive_rcom_lock_args() argument
4416 if (lvblen > ls->ls_lvblen) in receive_rcom_lock_args()
4418 lkb->lkb_lvbptr = dlm_allocate_lvb(ls); in receive_rcom_lock_args()
4445 int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc) in dlm_recover_master_copy() argument
4457 error = find_rsb(ls, rl->rl_name, le16_to_cpu(rl->rl_namelen), in dlm_recover_master_copy()
4470 error = create_lkb(ls, &lkb); in dlm_recover_master_copy()
4474 error = receive_rcom_lock_args(ls, lkb, r, rc); in dlm_recover_master_copy()
4476 __put_lkb(ls, lkb); in dlm_recover_master_copy()
4494 log_debug(ls, "recover_master_copy %d %x", error, in dlm_recover_master_copy()
4501 int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc) in dlm_recover_process_copy() argument
4508 error = find_lkb(ls, le32_to_cpu(rl->rl_lkid), &lkb); in dlm_recover_process_copy()
4510 log_error(ls, "recover_process_copy no lkid %x", in dlm_recover_process_copy()
4528 log_debug(ls, "master copy not ready %x r %lx %s", lkb->lkb_id, in dlm_recover_process_copy()
4533 log_debug(ls, "master copy exists %x", lkb->lkb_id); in dlm_recover_process_copy()
4539 log_error(ls, "dlm_recover_process_copy unknown error %d %x", in dlm_recover_process_copy()
4554 int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua, in dlm_user_request() argument
4562 dlm_lock_recovery(ls); in dlm_user_request()
4564 error = create_lkb(ls, &lkb); in dlm_user_request()
4574 __put_lkb(ls, lkb); in dlm_user_request()
4589 __put_lkb(ls, lkb); in dlm_user_request()
4593 error = request_lock(ls, lkb, name, namelen, &args); in dlm_user_request()
4605 __put_lkb(ls, lkb); in dlm_user_request()
4615 dlm_unlock_recovery(ls); in dlm_user_request()
4619 int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, in dlm_user_convert() argument
4628 dlm_lock_recovery(ls); in dlm_user_convert()
4630 error = find_lkb(ls, lkid, &lkb); in dlm_user_convert()
4661 error = convert_lock(ls, lkb, &args); in dlm_user_convert()
4668 dlm_unlock_recovery(ls); in dlm_user_convert()
4673 int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, in dlm_user_unlock() argument
4681 dlm_lock_recovery(ls); in dlm_user_unlock()
4683 error = find_lkb(ls, lkid, &lkb); in dlm_user_unlock()
4699 error = unlock_lock(ls, lkb, &args); in dlm_user_unlock()
4717 dlm_unlock_recovery(ls); in dlm_user_unlock()
4722 int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, in dlm_user_cancel() argument
4730 dlm_lock_recovery(ls); in dlm_user_cancel()
4732 error = find_lkb(ls, lkid, &lkb); in dlm_user_cancel()
4745 error = cancel_lock(ls, lkb, &args); in dlm_user_cancel()
4755 dlm_unlock_recovery(ls); in dlm_user_cancel()
4760 int dlm_user_deadlock(struct dlm_ls *ls, uint32_t flags, uint32_t lkid) in dlm_user_deadlock() argument
4768 dlm_lock_recovery(ls); in dlm_user_deadlock()
4770 error = find_lkb(ls, lkid, &lkb); in dlm_user_deadlock()
4804 dlm_unlock_recovery(ls); in dlm_user_deadlock()
4811 static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb) in orphan_proc_lock() argument
4817 mutex_lock(&ls->ls_orphans_mutex); in orphan_proc_lock()
4818 list_add_tail(&lkb->lkb_ownqueue, &ls->ls_orphans); in orphan_proc_lock()
4819 mutex_unlock(&ls->ls_orphans_mutex); in orphan_proc_lock()
4823 error = cancel_lock(ls, lkb, &args); in orphan_proc_lock()
4832 static int unlock_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb) in unlock_proc_lock() argument
4839 error = unlock_lock(ls, lkb, &args); in unlock_proc_lock()
4849 static struct dlm_lkb *del_proc_lock(struct dlm_ls *ls, in del_proc_lock() argument
4854 mutex_lock(&ls->ls_clear_proc_locks); in del_proc_lock()
4866 mutex_unlock(&ls->ls_clear_proc_locks); in del_proc_lock()
4880 void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc) in dlm_clear_proc_locks() argument
4884 dlm_lock_recovery(ls); in dlm_clear_proc_locks()
4887 lkb = del_proc_lock(ls, proc); in dlm_clear_proc_locks()
4892 orphan_proc_lock(ls, lkb); in dlm_clear_proc_locks()
4894 unlock_proc_lock(ls, lkb); in dlm_clear_proc_locks()
4903 mutex_lock(&ls->ls_clear_proc_locks); in dlm_clear_proc_locks()
4919 mutex_unlock(&ls->ls_clear_proc_locks); in dlm_clear_proc_locks()
4920 dlm_unlock_recovery(ls); in dlm_clear_proc_locks()
4923 static void purge_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc) in purge_proc_locks() argument
4941 unlock_proc_lock(ls, lkb); in purge_proc_locks()
4965 static void do_purge(struct dlm_ls *ls, int nodeid, int pid) in do_purge() argument
4969 mutex_lock(&ls->ls_orphans_mutex); in do_purge()
4970 list_for_each_entry_safe(lkb, safe, &ls->ls_orphans, lkb_ownqueue) { in do_purge()
4973 unlock_proc_lock(ls, lkb); in do_purge()
4977 mutex_unlock(&ls->ls_orphans_mutex); in do_purge()
4980 static int send_purge(struct dlm_ls *ls, int nodeid, int pid) in send_purge() argument
4986 error = _create_message(ls, sizeof(struct dlm_message), nodeid, in send_purge()
4996 int dlm_user_purge(struct dlm_ls *ls, struct dlm_user_proc *proc, in dlm_user_purge() argument
5002 error = send_purge(ls, nodeid, pid); in dlm_user_purge()
5004 dlm_lock_recovery(ls); in dlm_user_purge()
5006 purge_proc_locks(ls, proc); in dlm_user_purge()
5008 do_purge(ls, nodeid, pid); in dlm_user_purge()
5009 dlm_unlock_recovery(ls); in dlm_user_purge()