Lines Matching full:ls

42 int dlm_wait_function(struct dlm_ls *ls, int (*testfn) (struct dlm_ls *ls))  in dlm_wait_function()  argument
48 rv = wait_event_timeout(ls->ls_wait_general, in dlm_wait_function()
49 testfn(ls) || dlm_recovery_stopped(ls), in dlm_wait_function()
53 if (test_bit(LSFL_RCOM_WAIT, &ls->ls_flags)) { in dlm_wait_function()
54 log_debug(ls, "dlm_wait_function timed out"); in dlm_wait_function()
59 if (dlm_recovery_stopped(ls)) { in dlm_wait_function()
60 log_debug(ls, "dlm_wait_function aborted"); in dlm_wait_function()
74 uint32_t dlm_recover_status(struct dlm_ls *ls) in dlm_recover_status() argument
77 spin_lock(&ls->ls_recover_lock); in dlm_recover_status()
78 status = ls->ls_recover_status; in dlm_recover_status()
79 spin_unlock(&ls->ls_recover_lock); in dlm_recover_status()
83 static void _set_recover_status(struct dlm_ls *ls, uint32_t status) in _set_recover_status() argument
85 ls->ls_recover_status |= status; in _set_recover_status()
88 void dlm_set_recover_status(struct dlm_ls *ls, uint32_t status) in dlm_set_recover_status() argument
90 spin_lock(&ls->ls_recover_lock); in dlm_set_recover_status()
91 _set_recover_status(ls, status); in dlm_set_recover_status()
92 spin_unlock(&ls->ls_recover_lock); in dlm_set_recover_status()
95 static int wait_status_all(struct dlm_ls *ls, uint32_t wait_status, in wait_status_all() argument
98 struct dlm_rcom *rc = ls->ls_recover_buf; in wait_status_all()
102 list_for_each_entry(memb, &ls->ls_nodes, list) { in wait_status_all()
105 if (dlm_recovery_stopped(ls)) { in wait_status_all()
110 error = dlm_rcom_status(ls, memb->nodeid, 0); in wait_status_all()
115 dlm_slot_save(ls, rc, memb); in wait_status_all()
128 static int wait_status_low(struct dlm_ls *ls, uint32_t wait_status, in wait_status_low() argument
131 struct dlm_rcom *rc = ls->ls_recover_buf; in wait_status_low()
132 int error = 0, delay = 0, nodeid = ls->ls_low_nodeid; in wait_status_low()
135 if (dlm_recovery_stopped(ls)) { in wait_status_low()
140 error = dlm_rcom_status(ls, nodeid, status_flags); in wait_status_low()
154 static int wait_status(struct dlm_ls *ls, uint32_t status) in wait_status() argument
159 if (ls->ls_low_nodeid == dlm_our_nodeid()) { in wait_status()
160 error = wait_status_all(ls, status, 0); in wait_status()
162 dlm_set_recover_status(ls, status_all); in wait_status()
164 error = wait_status_low(ls, status_all, 0); in wait_status()
169 int dlm_recover_members_wait(struct dlm_ls *ls) in dlm_recover_members_wait() argument
177 list_for_each_entry(memb, &ls->ls_nodes, list) { in dlm_recover_members_wait()
182 if (ls->ls_low_nodeid == dlm_our_nodeid()) { in dlm_recover_members_wait()
183 error = wait_status_all(ls, DLM_RS_NODES, 1); in dlm_recover_members_wait()
189 rv = dlm_slots_assign(ls, &num_slots, &slots_size, &slots, &gen); in dlm_recover_members_wait()
191 spin_lock(&ls->ls_recover_lock); in dlm_recover_members_wait()
192 _set_recover_status(ls, DLM_RS_NODES_ALL); in dlm_recover_members_wait()
193 ls->ls_num_slots = num_slots; in dlm_recover_members_wait()
194 ls->ls_slots_size = slots_size; in dlm_recover_members_wait()
195 ls->ls_slots = slots; in dlm_recover_members_wait()
196 ls->ls_generation = gen; in dlm_recover_members_wait()
197 spin_unlock(&ls->ls_recover_lock); in dlm_recover_members_wait()
199 dlm_set_recover_status(ls, DLM_RS_NODES_ALL); in dlm_recover_members_wait()
202 error = wait_status_low(ls, DLM_RS_NODES_ALL, DLM_RSF_NEED_SLOTS); in dlm_recover_members_wait()
206 dlm_slots_copy_in(ls); in dlm_recover_members_wait()
212 int dlm_recover_directory_wait(struct dlm_ls *ls) in dlm_recover_directory_wait() argument
214 return wait_status(ls, DLM_RS_DIR); in dlm_recover_directory_wait()
217 int dlm_recover_locks_wait(struct dlm_ls *ls) in dlm_recover_locks_wait() argument
219 return wait_status(ls, DLM_RS_LOCKS); in dlm_recover_locks_wait()
222 int dlm_recover_done_wait(struct dlm_ls *ls) in dlm_recover_done_wait() argument
224 return wait_status(ls, DLM_RS_DONE); in dlm_recover_done_wait()
239 static int recover_list_empty(struct dlm_ls *ls) in recover_list_empty() argument
243 spin_lock(&ls->ls_recover_list_lock); in recover_list_empty()
244 empty = list_empty(&ls->ls_recover_list); in recover_list_empty()
245 spin_unlock(&ls->ls_recover_list_lock); in recover_list_empty()
252 struct dlm_ls *ls = r->res_ls; in recover_list_add() local
254 spin_lock(&ls->ls_recover_list_lock); in recover_list_add()
256 list_add_tail(&r->res_recover_list, &ls->ls_recover_list); in recover_list_add()
257 ls->ls_recover_list_count++; in recover_list_add()
260 spin_unlock(&ls->ls_recover_list_lock); in recover_list_add()
265 struct dlm_ls *ls = r->res_ls; in recover_list_del() local
267 spin_lock(&ls->ls_recover_list_lock); in recover_list_del()
269 ls->ls_recover_list_count--; in recover_list_del()
270 spin_unlock(&ls->ls_recover_list_lock); in recover_list_del()
275 static void recover_list_clear(struct dlm_ls *ls) in recover_list_clear() argument
279 spin_lock(&ls->ls_recover_list_lock); in recover_list_clear()
280 list_for_each_entry_safe(r, s, &ls->ls_recover_list, res_recover_list) { in recover_list_clear()
284 ls->ls_recover_list_count--; in recover_list_clear()
287 if (ls->ls_recover_list_count != 0) { in recover_list_clear()
288 log_error(ls, "warning: recover_list_count %d", in recover_list_clear()
289 ls->ls_recover_list_count); in recover_list_clear()
290 ls->ls_recover_list_count = 0; in recover_list_clear()
292 spin_unlock(&ls->ls_recover_list_lock); in recover_list_clear()
295 static int recover_idr_empty(struct dlm_ls *ls) in recover_idr_empty() argument
299 spin_lock(&ls->ls_recover_idr_lock); in recover_idr_empty()
300 if (ls->ls_recover_list_count) in recover_idr_empty()
302 spin_unlock(&ls->ls_recover_idr_lock); in recover_idr_empty()
309 struct dlm_ls *ls = r->res_ls; in recover_idr_add() local
313 spin_lock(&ls->ls_recover_idr_lock); in recover_idr_add()
318 rv = idr_alloc(&ls->ls_recover_idr, r, 1, 0, GFP_NOWAIT); in recover_idr_add()
323 ls->ls_recover_list_count++; in recover_idr_add()
327 spin_unlock(&ls->ls_recover_idr_lock); in recover_idr_add()
334 struct dlm_ls *ls = r->res_ls; in recover_idr_del() local
336 spin_lock(&ls->ls_recover_idr_lock); in recover_idr_del()
337 idr_remove(&ls->ls_recover_idr, r->res_id); in recover_idr_del()
339 ls->ls_recover_list_count--; in recover_idr_del()
340 spin_unlock(&ls->ls_recover_idr_lock); in recover_idr_del()
345 static struct dlm_rsb *recover_idr_find(struct dlm_ls *ls, uint64_t id) in recover_idr_find() argument
349 spin_lock(&ls->ls_recover_idr_lock); in recover_idr_find()
350 r = idr_find(&ls->ls_recover_idr, (int)id); in recover_idr_find()
351 spin_unlock(&ls->ls_recover_idr_lock); in recover_idr_find()
355 static void recover_idr_clear(struct dlm_ls *ls) in recover_idr_clear() argument
360 spin_lock(&ls->ls_recover_idr_lock); in recover_idr_clear()
362 idr_for_each_entry(&ls->ls_recover_idr, r, id) { in recover_idr_clear()
363 idr_remove(&ls->ls_recover_idr, id); in recover_idr_clear()
366 ls->ls_recover_list_count--; in recover_idr_clear()
371 if (ls->ls_recover_list_count != 0) { in recover_idr_clear()
372 log_error(ls, "warning: recover_list_count %d", in recover_idr_clear()
373 ls->ls_recover_list_count); in recover_idr_clear()
374 ls->ls_recover_list_count = 0; in recover_idr_clear()
376 spin_unlock(&ls->ls_recover_idr_lock); in recover_idr_clear()
446 struct dlm_ls *ls = r->res_ls; in recover_master() local
454 is_removed = dlm_is_removed(ls, r->res_nodeid); in recover_master()
523 int dlm_recover_masters(struct dlm_ls *ls) in dlm_recover_masters() argument
528 int nodir = dlm_no_directory(ls); in dlm_recover_masters()
531 log_rinfo(ls, "dlm_recover_masters"); in dlm_recover_masters()
533 down_read(&ls->ls_root_sem); in dlm_recover_masters()
534 list_for_each_entry(r, &ls->ls_root_list, res_root_list) { in dlm_recover_masters()
535 if (dlm_recovery_stopped(ls)) { in dlm_recover_masters()
536 up_read(&ls->ls_root_sem); in dlm_recover_masters()
551 up_read(&ls->ls_root_sem); in dlm_recover_masters()
555 up_read(&ls->ls_root_sem); in dlm_recover_masters()
557 log_rinfo(ls, "dlm_recover_masters %u of %u", count, total); in dlm_recover_masters()
559 error = dlm_wait_function(ls, &recover_idr_empty); in dlm_recover_masters()
562 recover_idr_clear(ls); in dlm_recover_masters()
566 int dlm_recover_master_reply(struct dlm_ls *ls, struct dlm_rcom *rc) in dlm_recover_master_reply() argument
571 r = recover_idr_find(ls, rc->rc_id); in dlm_recover_master_reply()
573 log_error(ls, "dlm_recover_master_reply no id %llx", in dlm_recover_master_reply()
592 if (recover_idr_empty(ls)) in dlm_recover_master_reply()
593 wake_up(&ls->ls_wait_general); in dlm_recover_master_reply()
659 int dlm_recover_locks(struct dlm_ls *ls) in dlm_recover_locks() argument
664 down_read(&ls->ls_root_sem); in dlm_recover_locks()
665 list_for_each_entry(r, &ls->ls_root_list, res_root_list) { in dlm_recover_locks()
674 if (dlm_recovery_stopped(ls)) { in dlm_recover_locks()
676 up_read(&ls->ls_root_sem); in dlm_recover_locks()
682 up_read(&ls->ls_root_sem); in dlm_recover_locks()
688 up_read(&ls->ls_root_sem); in dlm_recover_locks()
690 log_rinfo(ls, "dlm_recover_locks %d out", count); in dlm_recover_locks()
692 error = dlm_wait_function(ls, &recover_list_empty); in dlm_recover_locks()
695 recover_list_clear(ls); in dlm_recover_locks()
821 struct dlm_ls *ls = r->res_ls; in recover_conversion() local
837 log_debug(ls, "recover_conversion %x set gr to rq %d", in recover_conversion()
841 log_debug(ls, "recover_conversion %x set gr %d", in recover_conversion()
858 void dlm_recover_rsbs(struct dlm_ls *ls) in dlm_recover_rsbs() argument
863 down_read(&ls->ls_root_sem); in dlm_recover_rsbs()
864 list_for_each_entry(r, &ls->ls_root_list, res_root_list) { in dlm_recover_rsbs()
885 up_read(&ls->ls_root_sem); in dlm_recover_rsbs()
888 log_rinfo(ls, "dlm_recover_rsbs %d done", count); in dlm_recover_rsbs()
893 int dlm_create_root_list(struct dlm_ls *ls) in dlm_create_root_list() argument
899 down_write(&ls->ls_root_sem); in dlm_create_root_list()
900 if (!list_empty(&ls->ls_root_list)) { in dlm_create_root_list()
901 log_error(ls, "root list not empty"); in dlm_create_root_list()
906 for (i = 0; i < ls->ls_rsbtbl_size; i++) { in dlm_create_root_list()
907 spin_lock(&ls->ls_rsbtbl[i].lock); in dlm_create_root_list()
908 for (n = rb_first(&ls->ls_rsbtbl[i].keep); n; n = rb_next(n)) { in dlm_create_root_list()
910 list_add(&r->res_root_list, &ls->ls_root_list); in dlm_create_root_list()
914 if (!RB_EMPTY_ROOT(&ls->ls_rsbtbl[i].toss)) in dlm_create_root_list()
915 log_error(ls, "dlm_create_root_list toss not empty"); in dlm_create_root_list()
916 spin_unlock(&ls->ls_rsbtbl[i].lock); in dlm_create_root_list()
919 up_write(&ls->ls_root_sem); in dlm_create_root_list()
923 void dlm_release_root_list(struct dlm_ls *ls) in dlm_release_root_list() argument
927 down_write(&ls->ls_root_sem); in dlm_release_root_list()
928 list_for_each_entry_safe(r, safe, &ls->ls_root_list, res_root_list) { in dlm_release_root_list()
932 up_write(&ls->ls_root_sem); in dlm_release_root_list()
935 void dlm_clear_toss(struct dlm_ls *ls) in dlm_clear_toss() argument
942 for (i = 0; i < ls->ls_rsbtbl_size; i++) { in dlm_clear_toss()
943 spin_lock(&ls->ls_rsbtbl[i].lock); in dlm_clear_toss()
944 for (n = rb_first(&ls->ls_rsbtbl[i].toss); n; n = next) { in dlm_clear_toss()
947 rb_erase(n, &ls->ls_rsbtbl[i].toss); in dlm_clear_toss()
951 spin_unlock(&ls->ls_rsbtbl[i].lock); in dlm_clear_toss()
955 log_rinfo(ls, "dlm_clear_toss %u done", count); in dlm_clear_toss()