Lines Matching refs:ls
28 void dlm_slot_save(struct dlm_ls *ls, struct dlm_rcom *rc, in dlm_slot_save() argument
40 void dlm_slots_copy_out(struct dlm_ls *ls, struct dlm_rcom *rc) in dlm_slots_copy_out() argument
50 for (i = 0; i < ls->ls_slots_size; i++) { in dlm_slots_copy_out()
51 slot = &ls->ls_slots[i]; in dlm_slots_copy_out()
62 static void log_slots(struct dlm_ls *ls, uint32_t gen, int num_slots, in log_slots() argument
94 log_rinfo(ls, "generation %u slots %d%s", gen, num_slots, line); in log_slots()
97 int dlm_slots_copy_in(struct dlm_ls *ls) in dlm_slots_copy_in() argument
100 struct dlm_rcom *rc = ls->ls_recover_buf; in dlm_slots_copy_in()
111 if (gen <= ls->ls_generation) { in dlm_slots_copy_in()
112 log_error(ls, "dlm_slots_copy_in gen %u old %u", in dlm_slots_copy_in()
113 gen, ls->ls_generation); in dlm_slots_copy_in()
115 ls->ls_generation = gen; in dlm_slots_copy_in()
123 log_slots(ls, gen, num_slots, ro0, NULL, 0); in dlm_slots_copy_in()
125 list_for_each_entry(memb, &ls->ls_nodes, list) { in dlm_slots_copy_in()
135 if (ls->ls_slot && ls->ls_slot != memb->slot) { in dlm_slots_copy_in()
136 log_error(ls, "dlm_slots_copy_in our slot " in dlm_slots_copy_in()
137 "changed %d %d", ls->ls_slot, in dlm_slots_copy_in()
142 if (!ls->ls_slot) in dlm_slots_copy_in()
143 ls->ls_slot = memb->slot; in dlm_slots_copy_in()
147 log_error(ls, "dlm_slots_copy_in nodeid %d no slot", in dlm_slots_copy_in()
160 int dlm_slots_assign(struct dlm_ls *ls, int *num_slots, int *slots_size, in dlm_slots_assign() argument
174 list_for_each_entry(memb, &ls->ls_nodes, list) { in dlm_slots_assign()
176 memb->slot = ls->ls_slot; in dlm_slots_assign()
177 memb->generation = ls->ls_generation; in dlm_slots_assign()
182 list_for_each_entry(memb, &ls->ls_nodes, list) { in dlm_slots_assign()
206 log_error(ls, "nodeid %d slot changed %d %d", in dlm_slots_assign()
222 list_for_each_entry(memb, &ls->ls_nodes, list) { in dlm_slots_assign()
227 log_error(ls, "invalid slot number %d", memb->slot); in dlm_slots_assign()
239 list_for_each_entry(memb, &ls->ls_nodes, list) { in dlm_slots_assign()
253 if (!ls->ls_slot && memb->nodeid == our_nodeid) in dlm_slots_assign()
254 ls->ls_slot = memb->slot; in dlm_slots_assign()
259 log_error(ls, "no free slot found"); in dlm_slots_assign()
267 log_slots(ls, gen, num, NULL, array, array_size); in dlm_slots_assign()
273 log_error(ls, "num_slots %d exceeds max_slots %d", in dlm_slots_assign()
286 static void add_ordered_member(struct dlm_ls *ls, struct dlm_member *new) in add_ordered_member() argument
291 struct list_head *head = &ls->ls_nodes; in add_ordered_member()
310 static int dlm_add_member(struct dlm_ls *ls, struct dlm_config_node *node) in dlm_add_member() argument
329 add_ordered_member(ls, memb); in dlm_add_member()
330 ls->ls_num_nodes++; in dlm_add_member()
345 int dlm_is_member(struct dlm_ls *ls, int nodeid) in dlm_is_member() argument
347 if (find_memb(&ls->ls_nodes, nodeid)) in dlm_is_member()
352 int dlm_is_removed(struct dlm_ls *ls, int nodeid) in dlm_is_removed() argument
354 if (find_memb(&ls->ls_nodes_gone, nodeid)) in dlm_is_removed()
378 void dlm_clear_members(struct dlm_ls *ls) in dlm_clear_members() argument
380 clear_memb_list(&ls->ls_nodes, clear_members_cb); in dlm_clear_members()
381 ls->ls_num_nodes = 0; in dlm_clear_members()
384 void dlm_clear_members_gone(struct dlm_ls *ls) in dlm_clear_members_gone() argument
386 clear_memb_list(&ls->ls_nodes_gone, NULL); in dlm_clear_members_gone()
389 static void make_member_array(struct dlm_ls *ls) in make_member_array() argument
394 kfree(ls->ls_node_array); in make_member_array()
395 ls->ls_node_array = NULL; in make_member_array()
397 list_for_each_entry(memb, &ls->ls_nodes, list) { in make_member_array()
405 total = ls->ls_num_nodes; in make_member_array()
409 ls->ls_total_weight = total; in make_member_array()
414 list_for_each_entry(memb, &ls->ls_nodes, list) { in make_member_array()
429 ls->ls_node_array = array; in make_member_array()
434 static int ping_members(struct dlm_ls *ls) in ping_members() argument
439 list_for_each_entry(memb, &ls->ls_nodes, list) { in ping_members()
440 if (dlm_recovery_stopped(ls)) { in ping_members()
444 error = dlm_rcom_status(ls, memb->nodeid, 0); in ping_members()
449 log_rinfo(ls, "ping_members aborted %d last nodeid %d", in ping_members()
450 error, ls->ls_recover_nodeid); in ping_members()
454 static void dlm_lsop_recover_prep(struct dlm_ls *ls) in dlm_lsop_recover_prep() argument
456 if (!ls->ls_ops || !ls->ls_ops->recover_prep) in dlm_lsop_recover_prep()
458 ls->ls_ops->recover_prep(ls->ls_ops_arg); in dlm_lsop_recover_prep()
461 static void dlm_lsop_recover_slot(struct dlm_ls *ls, struct dlm_member *memb) in dlm_lsop_recover_slot() argument
467 if (!ls->ls_ops || !ls->ls_ops->recover_slot) in dlm_lsop_recover_slot()
484 ls->ls_ops->recover_slot(ls->ls_ops_arg, &slot); in dlm_lsop_recover_slot()
487 void dlm_lsop_recover_done(struct dlm_ls *ls) in dlm_lsop_recover_done() argument
493 if (!ls->ls_ops || !ls->ls_ops->recover_done) in dlm_lsop_recover_done()
496 num = ls->ls_num_nodes; in dlm_lsop_recover_done()
502 list_for_each_entry(memb, &ls->ls_nodes, list) { in dlm_lsop_recover_done()
504 log_error(ls, "dlm_lsop_recover_done bad num %d", num); in dlm_lsop_recover_done()
512 ls->ls_ops->recover_done(ls->ls_ops_arg, slots, num, in dlm_lsop_recover_done()
513 ls->ls_slot, ls->ls_generation); in dlm_lsop_recover_done()
530 int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out) in dlm_recover_members() argument
539 list_for_each_entry(memb, &ls->ls_nodes_gone, list) { in dlm_recover_members()
540 log_rinfo(ls, "prev removed member %d", memb->nodeid); in dlm_recover_members()
546 list_for_each_entry_safe(memb, safe, &ls->ls_nodes, list) { in dlm_recover_members()
552 log_rinfo(ls, "remove member %d", memb->nodeid); in dlm_recover_members()
555 log_rinfo(ls, "remove member %d comm_seq %u %u", in dlm_recover_members()
560 list_move(&memb->list, &ls->ls_nodes_gone); in dlm_recover_members()
562 ls->ls_num_nodes--; in dlm_recover_members()
563 dlm_lsop_recover_slot(ls, memb); in dlm_recover_members()
570 if (dlm_is_member(ls, node->nodeid)) in dlm_recover_members()
572 dlm_add_member(ls, node); in dlm_recover_members()
573 log_rinfo(ls, "add member %d", node->nodeid); in dlm_recover_members()
576 list_for_each_entry(memb, &ls->ls_nodes, list) { in dlm_recover_members()
580 ls->ls_low_nodeid = low; in dlm_recover_members()
582 make_member_array(ls); in dlm_recover_members()
585 error = ping_members(ls); in dlm_recover_members()
596 ls->ls_members_result = error; in dlm_recover_members()
597 complete(&ls->ls_members_done); in dlm_recover_members()
599 log_rinfo(ls, "dlm_recover_members %d nodes", ls->ls_num_nodes); in dlm_recover_members()
606 int dlm_ls_stop(struct dlm_ls *ls) in dlm_ls_stop() argument
621 down_write(&ls->ls_recv_active); in dlm_ls_stop()
629 spin_lock(&ls->ls_recover_lock); in dlm_ls_stop()
630 set_bit(LSFL_RECOVER_STOP, &ls->ls_flags); in dlm_ls_stop()
631 new = test_and_clear_bit(LSFL_RUNNING, &ls->ls_flags); in dlm_ls_stop()
632 ls->ls_recover_seq++; in dlm_ls_stop()
633 spin_unlock(&ls->ls_recover_lock); in dlm_ls_stop()
640 up_write(&ls->ls_recv_active); in dlm_ls_stop()
651 set_bit(LSFL_RECOVER_DOWN, &ls->ls_flags); in dlm_ls_stop()
652 wake_up_process(ls->ls_recoverd_task); in dlm_ls_stop()
653 wait_event(ls->ls_recover_lock_wait, in dlm_ls_stop()
654 test_bit(LSFL_RECOVER_LOCK, &ls->ls_flags)); in dlm_ls_stop()
663 dlm_recoverd_suspend(ls); in dlm_ls_stop()
665 spin_lock(&ls->ls_recover_lock); in dlm_ls_stop()
666 kfree(ls->ls_slots); in dlm_ls_stop()
667 ls->ls_slots = NULL; in dlm_ls_stop()
668 ls->ls_num_slots = 0; in dlm_ls_stop()
669 ls->ls_slots_size = 0; in dlm_ls_stop()
670 ls->ls_recover_status = 0; in dlm_ls_stop()
671 spin_unlock(&ls->ls_recover_lock); in dlm_ls_stop()
673 dlm_recoverd_resume(ls); in dlm_ls_stop()
675 if (!ls->ls_recover_begin) in dlm_ls_stop()
676 ls->ls_recover_begin = jiffies; in dlm_ls_stop()
678 dlm_lsop_recover_prep(ls); in dlm_ls_stop()
682 int dlm_ls_start(struct dlm_ls *ls) in dlm_ls_start() argument
692 error = dlm_config_nodes(ls->ls_name, &nodes, &count); in dlm_ls_start()
696 spin_lock(&ls->ls_recover_lock); in dlm_ls_start()
700 if (!dlm_locking_stopped(ls)) { in dlm_ls_start()
701 spin_unlock(&ls->ls_recover_lock); in dlm_ls_start()
702 log_error(ls, "start ignored: lockspace running"); in dlm_ls_start()
709 rv->seq = ++ls->ls_recover_seq; in dlm_ls_start()
710 rv_old = ls->ls_recover_args; in dlm_ls_start()
711 ls->ls_recover_args = rv; in dlm_ls_start()
712 spin_unlock(&ls->ls_recover_lock); in dlm_ls_start()
715 log_error(ls, "unused recovery %llx %d", in dlm_ls_start()
721 set_bit(LSFL_RECOVER_WORK, &ls->ls_flags); in dlm_ls_start()
722 wake_up_process(ls->ls_recoverd_task); in dlm_ls_start()