Lines Matching +full:1 +full:br +full:- +full:100
1 // SPDX-License-Identifier: GPL-2.0-or-later
85 static u64 dlm_mig_cookie = 1;
93 dlm_mig_cookie = 1; in dlm_get_next_mig_cookie()
103 assert_spin_locked(&dlm->spinlock); in dlm_set_reco_dead_node()
104 if (dlm->reco.dead_node != dead_node) in dlm_set_reco_dead_node()
106 dlm->name, dlm->reco.dead_node, dead_node); in dlm_set_reco_dead_node()
107 dlm->reco.dead_node = dead_node; in dlm_set_reco_dead_node()
113 assert_spin_locked(&dlm->spinlock); in dlm_set_reco_master()
115 dlm->name, dlm->reco.new_master, master); in dlm_set_reco_master()
116 dlm->reco.new_master = master; in dlm_set_reco_master()
121 assert_spin_locked(&dlm->spinlock); in __dlm_reset_recovery()
122 clear_bit(dlm->reco.dead_node, dlm->recovery_map); in __dlm_reset_recovery()
137 spin_lock(&dlm->work_lock); in dlm_dispatch_work()
138 list_splice_init(&dlm->work_list, &tmp_list); in dlm_dispatch_work()
139 spin_unlock(&dlm->work_lock); in dlm_dispatch_work()
144 mlog(0, "%s: work thread has %d work items\n", dlm->name, tot); in dlm_dispatch_work()
147 workfunc = item->func; in dlm_dispatch_work()
148 list_del_init(&item->list); in dlm_dispatch_work()
151 * it disappear. just double-check. */ in dlm_dispatch_work()
152 BUG_ON(item->dlm != dlm); in dlm_dispatch_work()
156 workfunc(item, item->data); in dlm_dispatch_work()
171 * 1) sleeping with no recovery happening in dlm_kick_recovery_thread()
175 wake_up(&dlm->dlm_reco_thread_wq); in dlm_kick_recovery_thread()
183 dlm->dlm_reco_thread_task = kthread_run(dlm_recovery_thread, dlm, in dlm_launch_recovery_thread()
184 "dlm_reco-%s", dlm->name); in dlm_launch_recovery_thread()
185 if (IS_ERR(dlm->dlm_reco_thread_task)) { in dlm_launch_recovery_thread()
186 mlog_errno(PTR_ERR(dlm->dlm_reco_thread_task)); in dlm_launch_recovery_thread()
187 dlm->dlm_reco_thread_task = NULL; in dlm_launch_recovery_thread()
188 return -EINVAL; in dlm_launch_recovery_thread()
196 if (dlm->dlm_reco_thread_task) { in dlm_complete_recovery_thread()
198 kthread_stop(dlm->dlm_reco_thread_task); in dlm_complete_recovery_thread()
199 dlm->dlm_reco_thread_task = NULL; in dlm_complete_recovery_thread()
207 * 1) all recovery threads cluster wide will work on recovering
234 dlm->name, task_pid_nr(dlm->dlm_reco_thread_task), in dlm_print_reco_node_status()
235 dlm->reco.state & DLM_RECO_STATE_ACTIVE ? "ACTIVE" : "inactive", in dlm_print_reco_node_status()
236 dlm->reco.dead_node, dlm->reco.new_master); in dlm_print_reco_node_status()
238 list_for_each_entry(ndata, &dlm->reco.node_data, list) { in dlm_print_reco_node_status()
240 switch (ndata->state) { in dlm_print_reco_node_status()
260 st = "finalize-sent"; in dlm_print_reco_node_status()
267 dlm->name, ndata->node_num, st); in dlm_print_reco_node_status()
269 list_for_each_entry(res, &dlm->reco.resources, recovering) { in dlm_print_reco_node_status()
271 dlm->name, res->lockname.len, res->lockname.name); in dlm_print_reco_node_status()
283 mlog(0, "dlm thread running for %s...\n", dlm->name); in dlm_recovery_thread()
288 if (status == -EAGAIN) { in dlm_recovery_thread()
296 wait_event_interruptible_timeout(dlm->dlm_reco_thread_wq, in dlm_recovery_thread()
309 spin_lock(&dlm->spinlock); in dlm_reco_master_ready()
310 ready = (dlm->reco.new_master != O2NM_INVALID_NODE_NUM); in dlm_reco_master_ready()
311 spin_unlock(&dlm->spinlock); in dlm_reco_master_ready()
320 spin_lock(&dlm->spinlock); in dlm_is_node_dead()
321 dead = !test_bit(node, dlm->domain_map); in dlm_is_node_dead()
322 spin_unlock(&dlm->spinlock); in dlm_is_node_dead()
331 spin_lock(&dlm->spinlock); in dlm_is_node_recovered()
332 recovered = !test_bit(node, dlm->recovery_map); in dlm_is_node_recovered()
333 spin_unlock(&dlm->spinlock); in dlm_is_node_recovered()
344 "domain %s\n", node, dlm->name); in dlm_wait_for_node_death()
347 wait_event_timeout(dlm->dlm_reco_thread_wq, in dlm_wait_for_node_death()
351 wait_event(dlm->dlm_reco_thread_wq, in dlm_wait_for_node_death()
361 "domain %s\n", node, dlm->name); in dlm_wait_for_node_recovery()
364 wait_event_timeout(dlm->dlm_reco_thread_wq, in dlm_wait_for_node_recovery()
368 wait_event(dlm->dlm_reco_thread_wq, in dlm_wait_for_node_recovery()
372 /* callers of the top-level api calls (dlmlock/dlmunlock) should
373 * block on the dlm->reco.event when recovery is in progress.
381 spin_lock(&dlm->spinlock); in dlm_in_recovery()
382 in_recovery = !!(dlm->reco.state & DLM_RECO_STATE_ACTIVE); in dlm_in_recovery()
383 spin_unlock(&dlm->spinlock); in dlm_in_recovery()
393 dlm->name, task_pid_nr(dlm->dlm_reco_thread_task), in dlm_wait_for_recovery()
394 dlm->reco.state, dlm->reco.new_master, in dlm_wait_for_recovery()
395 dlm->reco.dead_node); in dlm_wait_for_recovery()
397 wait_event(dlm->reco.event, !dlm_in_recovery(dlm)); in dlm_wait_for_recovery()
402 assert_spin_locked(&dlm->spinlock); in dlm_begin_recovery()
403 BUG_ON(dlm->reco.state & DLM_RECO_STATE_ACTIVE); in dlm_begin_recovery()
405 dlm->name, dlm->reco.dead_node); in dlm_begin_recovery()
406 dlm->reco.state |= DLM_RECO_STATE_ACTIVE; in dlm_begin_recovery()
411 spin_lock(&dlm->spinlock); in dlm_end_recovery()
412 BUG_ON(!(dlm->reco.state & DLM_RECO_STATE_ACTIVE)); in dlm_end_recovery()
413 dlm->reco.state &= ~DLM_RECO_STATE_ACTIVE; in dlm_end_recovery()
414 spin_unlock(&dlm->spinlock); in dlm_end_recovery()
415 printk(KERN_NOTICE "o2dlm: End recovery on domain %s\n", dlm->name); in dlm_end_recovery()
416 wake_up(&dlm->reco.event); in dlm_end_recovery()
422 "dead node %u in domain %s\n", dlm->reco.new_master, in dlm_print_recovery_master()
423 (dlm->node_num == dlm->reco.new_master ? "me" : "he"), in dlm_print_recovery_master()
424 dlm->reco.dead_node, dlm->name); in dlm_print_recovery_master()
432 spin_lock(&dlm->spinlock); in dlm_do_recovery()
434 if (dlm->migrate_done) { in dlm_do_recovery()
436 "lock resources\n", dlm->name); in dlm_do_recovery()
437 spin_unlock(&dlm->spinlock); in dlm_do_recovery()
442 if (dlm->reco.new_master != O2NM_INVALID_NODE_NUM && in dlm_do_recovery()
443 test_bit(dlm->reco.new_master, dlm->recovery_map)) { in dlm_do_recovery()
445 dlm->reco.new_master, dlm->reco.dead_node); in dlm_do_recovery()
451 if (dlm->reco.dead_node == O2NM_INVALID_NODE_NUM) { in dlm_do_recovery()
454 bit = find_first_bit(dlm->recovery_map, O2NM_MAX_NODES); in dlm_do_recovery()
459 } else if (!test_bit(dlm->reco.dead_node, dlm->recovery_map)) { in dlm_do_recovery()
462 dlm->reco.dead_node); in dlm_do_recovery()
466 if (dlm->reco.dead_node == O2NM_INVALID_NODE_NUM) { in dlm_do_recovery()
468 spin_unlock(&dlm->spinlock); in dlm_do_recovery()
473 dlm->name, task_pid_nr(dlm->dlm_reco_thread_task), in dlm_do_recovery()
474 dlm->reco.dead_node); in dlm_do_recovery()
480 spin_unlock(&dlm->spinlock); in dlm_do_recovery()
482 if (dlm->reco.new_master == dlm->node_num) in dlm_do_recovery()
485 if (dlm->reco.new_master == O2NM_INVALID_NODE_NUM) { in dlm_do_recovery()
487 * is the master, -EEXIST if it's another node. in dlm_do_recovery()
502 * have been marked as in-recovery */ in dlm_do_recovery()
511 status = dlm_remaster_locks(dlm, dlm->reco.dead_node); in dlm_do_recovery()
515 "retrying.\n", dlm->name, status, dlm->reco.dead_node); in dlm_do_recovery()
518 msleep(100); in dlm_do_recovery()
522 dlm->name, dlm->reco.dead_node, dlm->node_num); in dlm_do_recovery()
523 spin_lock(&dlm->spinlock); in dlm_do_recovery()
525 dlm->reco.state &= ~DLM_RECO_STATE_FINALIZE; in dlm_do_recovery()
526 spin_unlock(&dlm->spinlock); in dlm_do_recovery()
531 return -EAGAIN; in dlm_do_recovery()
548 "retrying\n", dlm->name); in dlm_remaster_locks()
555 list_for_each_entry(ndata, &dlm->reco.node_data, list) { in dlm_remaster_locks()
556 BUG_ON(ndata->state != DLM_RECO_NODE_DATA_INIT); in dlm_remaster_locks()
557 ndata->state = DLM_RECO_NODE_DATA_REQUESTING; in dlm_remaster_locks()
559 mlog(0, "%s: Requesting lock info from node %u\n", dlm->name, in dlm_remaster_locks()
560 ndata->node_num); in dlm_remaster_locks()
562 if (ndata->node_num == dlm->node_num) { in dlm_remaster_locks()
563 ndata->state = DLM_RECO_NODE_DATA_DONE; in dlm_remaster_locks()
568 status = dlm_request_all_locks(dlm, ndata->node_num, in dlm_remaster_locks()
575 ndata->state = DLM_RECO_NODE_DATA_DEAD; in dlm_remaster_locks()
578 wait_event_timeout(dlm->dlm_reco_thread_wq, in dlm_remaster_locks()
580 ndata->node_num), in dlm_remaster_locks()
582 mlog(0, "waited 1 sec for %u, " in dlm_remaster_locks()
583 "dead? %s\n", ndata->node_num, in dlm_remaster_locks()
584 dlm_is_node_dead(dlm, ndata->node_num) ? in dlm_remaster_locks()
587 /* -ENOMEM on the other node */ in dlm_remaster_locks()
591 dlm->name, ndata->node_num, in dlm_remaster_locks()
593 msleep(100); in dlm_remaster_locks()
599 switch (ndata->state) { in dlm_remaster_locks()
608 ndata->node_num, dead_node); in dlm_remaster_locks()
613 ndata->state = DLM_RECO_NODE_DATA_REQUESTED; in dlm_remaster_locks()
616 ndata->node_num, dead_node); in dlm_remaster_locks()
621 ndata->node_num, dead_node); in dlm_remaster_locks()
626 ndata->node_num, dead_node); in dlm_remaster_locks()
632 mlog(0, "%s: Done requesting all lock info\n", dlm->name); in dlm_remaster_locks()
637 while (1) { in dlm_remaster_locks()
640 all_nodes_done = 1; in dlm_remaster_locks()
642 list_for_each_entry(ndata, &dlm->reco.node_data, list) { in dlm_remaster_locks()
644 ndata->node_num); in dlm_remaster_locks()
645 switch (ndata->state) { in dlm_remaster_locks()
650 ndata->node_num, ndata->state); in dlm_remaster_locks()
656 "node %u\n", ndata->node_num, in dlm_remaster_locks()
662 dlm->name, ndata->node_num, in dlm_remaster_locks()
663 ndata->state==DLM_RECO_NODE_DATA_RECEIVING ? in dlm_remaster_locks()
669 dlm->name, ndata->node_num); in dlm_remaster_locks()
673 dlm->name, ndata->node_num); in dlm_remaster_locks()
688 spin_lock(&dlm->spinlock); in dlm_remaster_locks()
689 dlm->reco.state |= DLM_RECO_STATE_FINALIZE; in dlm_remaster_locks()
690 spin_unlock(&dlm->spinlock); in dlm_remaster_locks()
700 spin_lock(&dlm->spinlock); in dlm_remaster_locks()
702 dlm->node_num); in dlm_remaster_locks()
703 spin_unlock(&dlm->spinlock); in dlm_remaster_locks()
707 "dead=%u, this=%u, new=%u\n", dlm->name, in dlm_remaster_locks()
708 jiffies, dlm->reco.dead_node, in dlm_remaster_locks()
709 dlm->node_num, dlm->reco.new_master); in dlm_remaster_locks()
710 destroy = 1; in dlm_remaster_locks()
718 wait_event_interruptible_timeout(dlm->dlm_reco_thread_wq, in dlm_remaster_locks()
735 spin_lock(&dlm->spinlock); in dlm_init_recovery_area()
736 bitmap_copy(dlm->reco.node_map, dlm->domain_map, O2NM_MAX_NODES); in dlm_init_recovery_area()
739 spin_unlock(&dlm->spinlock); in dlm_init_recovery_area()
741 while (1) { in dlm_init_recovery_area()
742 num = find_next_bit (dlm->reco.node_map, O2NM_MAX_NODES, num); in dlm_init_recovery_area()
751 return -ENOMEM; in dlm_init_recovery_area()
753 ndata->node_num = num; in dlm_init_recovery_area()
754 ndata->state = DLM_RECO_NODE_DATA_INIT; in dlm_init_recovery_area()
756 list_add_tail(&ndata->list, &dlm->reco.node_data); in dlm_init_recovery_area()
770 list_splice_init(&dlm->reco.node_data, &tmplist); in dlm_destroy_recovery_area()
774 list_del_init(&ndata->list); in dlm_destroy_recovery_area()
793 lr.node_idx = dlm->node_num; in dlm_request_all_locks()
797 ret = o2net_send_message(DLM_LOCK_REQUEST_MSG, dlm->key, in dlm_request_all_locks()
803 "to recover dead node %u\n", dlm->name, ret, in dlm_request_all_locks()
817 struct dlm_lock_request *lr = (struct dlm_lock_request *)msg->buf; in dlm_request_all_locks_handler()
822 return -EINVAL; in dlm_request_all_locks_handler()
824 if (lr->dead_node != dlm->reco.dead_node) { in dlm_request_all_locks_handler()
826 "dead_node is %u\n", dlm->name, lr->node_idx, in dlm_request_all_locks_handler()
827 lr->dead_node, dlm->reco.dead_node); in dlm_request_all_locks_handler()
831 return -ENOMEM; in dlm_request_all_locks_handler()
833 BUG_ON(lr->dead_node != dlm->reco.dead_node); in dlm_request_all_locks_handler()
838 return -ENOMEM; in dlm_request_all_locks_handler()
846 return -ENOMEM; in dlm_request_all_locks_handler()
852 item->u.ral.reco_master = lr->node_idx; in dlm_request_all_locks_handler()
853 item->u.ral.dead_node = lr->dead_node; in dlm_request_all_locks_handler()
854 spin_lock(&dlm->work_lock); in dlm_request_all_locks_handler()
855 list_add_tail(&item->list, &dlm->work_list); in dlm_request_all_locks_handler()
856 spin_unlock(&dlm->work_lock); in dlm_request_all_locks_handler()
857 queue_work(dlm->dlm_worker, &dlm->dispatched_work); in dlm_request_all_locks_handler()
873 dlm = item->dlm; in dlm_request_all_locks_worker()
874 dead_node = item->u.ral.dead_node; in dlm_request_all_locks_worker()
875 reco_master = item->u.ral.reco_master; in dlm_request_all_locks_worker()
879 dlm->name, dead_node, reco_master); in dlm_request_all_locks_worker()
881 if (dead_node != dlm->reco.dead_node || in dlm_request_all_locks_worker()
882 reco_master != dlm->reco.new_master) { in dlm_request_all_locks_worker()
885 if (dlm->reco.new_master == O2NM_INVALID_NODE_NUM) { in dlm_request_all_locks_worker()
888 " current=(dead=%u,mas=%u)\n", dlm->name, in dlm_request_all_locks_worker()
890 dlm->reco.dead_node, dlm->reco.new_master); in dlm_request_all_locks_worker()
894 dlm->name, dlm->reco.dead_node, in dlm_request_all_locks_worker()
895 dlm->reco.new_master, dead_node, reco_master); in dlm_request_all_locks_worker()
901 * dlm->reco.resources list. now move items from that list in dlm_request_all_locks_worker()
917 "recovery state for dead node %u, ret=%d\n", dlm->name, in dlm_request_all_locks_worker()
919 skip_all_done = 1; in dlm_request_all_locks_worker()
925 spin_lock(&dlm->spinlock); in dlm_request_all_locks_worker()
926 list_splice_init(&resources, &dlm->reco.resources); in dlm_request_all_locks_worker()
927 spin_unlock(&dlm->spinlock); in dlm_request_all_locks_worker()
933 "recovery all-done for dead node %u, ret=%d\n", in dlm_request_all_locks_worker()
934 dlm->name, reco_master, dead_node, ret); in dlm_request_all_locks_worker()
948 done_msg.node_idx = dlm->node_num; in dlm_send_all_done_msg()
954 ret = o2net_send_message(DLM_RECO_DATA_DONE_MSG, dlm->key, &done_msg, in dlm_send_all_done_msg()
958 "to recover dead node %u\n", dlm->name, ret, send_to, in dlm_send_all_done_msg()
973 struct dlm_reco_data_done *done = (struct dlm_reco_data_done *)msg->buf; in dlm_reco_data_done_handler()
975 int ret = -EINVAL; in dlm_reco_data_done_handler()
978 return -EINVAL; in dlm_reco_data_done_handler()
981 "node_idx=%u, this node=%u\n", done->dead_node, in dlm_reco_data_done_handler()
982 dlm->reco.dead_node, done->node_idx, dlm->node_num); in dlm_reco_data_done_handler()
984 mlog_bug_on_msg((done->dead_node != dlm->reco.dead_node), in dlm_reco_data_done_handler()
986 "node_idx=%u, this node=%u\n", done->dead_node, in dlm_reco_data_done_handler()
987 dlm->reco.dead_node, done->node_idx, dlm->node_num); in dlm_reco_data_done_handler()
990 list_for_each_entry(ndata, &dlm->reco.node_data, list) { in dlm_reco_data_done_handler()
991 if (ndata->node_num != done->node_idx) in dlm_reco_data_done_handler()
994 switch (ndata->state) { in dlm_reco_data_done_handler()
1000 " state=%d\n", ndata->node_num, in dlm_reco_data_done_handler()
1001 ndata->state); in dlm_reco_data_done_handler()
1012 ndata->node_num); in dlm_reco_data_done_handler()
1014 ndata->state = DLM_RECO_NODE_DATA_DONE; in dlm_reco_data_done_handler()
1027 "%u\n", done->node_idx); in dlm_reco_data_done_handler()
1041 spin_lock(&dlm->spinlock); in dlm_move_reco_locks_to_list()
1042 list_for_each_entry_safe(res, next, &dlm->reco.resources, recovering) { in dlm_move_reco_locks_to_list()
1045 if (dlm_is_recovery_lock(res->lockname.name, in dlm_move_reco_locks_to_list()
1046 res->lockname.len)) { in dlm_move_reco_locks_to_list()
1047 spin_lock(&res->spinlock); in dlm_move_reco_locks_to_list()
1048 list_for_each_entry(lock, &res->granted, list) { in dlm_move_reco_locks_to_list()
1049 if (lock->ml.node == dead_node) { in dlm_move_reco_locks_to_list()
1053 dead_node, dlm->name); in dlm_move_reco_locks_to_list()
1054 list_del_init(&lock->list); in dlm_move_reco_locks_to_list()
1057 * - do manually */ in dlm_move_reco_locks_to_list()
1062 spin_unlock(&res->spinlock); in dlm_move_reco_locks_to_list()
1066 if (res->owner == dead_node) { in dlm_move_reco_locks_to_list()
1070 list_move_tail(&res->recovering, list); in dlm_move_reco_locks_to_list()
1071 } else if (res->owner == DLM_LOCK_RES_OWNER_UNKNOWN) { in dlm_move_reco_locks_to_list()
1074 list_move_tail(&res->recovering, list); in dlm_move_reco_locks_to_list()
1077 spin_unlock(&dlm->spinlock); in dlm_move_reco_locks_to_list()
1083 struct list_head *iter, *queue = &res->granted; in dlm_num_locks_in_lockres()
1101 u64 mig_cookie = be64_to_cpu(mres->mig_cookie); in dlm_send_mig_lockres_msg()
1102 int mres_total_locks = be32_to_cpu(mres->total_locks); in dlm_send_mig_lockres_msg()
1104 u8 orig_flags = mres->flags, in dlm_send_mig_lockres_msg()
1105 orig_master = mres->master; in dlm_send_mig_lockres_msg()
1107 BUG_ON(mres->num_locks > DLM_MAX_MIGRATABLE_LOCKS); in dlm_send_mig_lockres_msg()
1108 if (!mres->num_locks) in dlm_send_mig_lockres_msg()
1111 /* add an all-done flag if we reached the last lock */ in dlm_send_mig_lockres_msg()
1112 orig_flags = mres->flags; in dlm_send_mig_lockres_msg()
1115 mres->flags |= DLM_MRES_ALL_DONE; in dlm_send_mig_lockres_msg()
1118 dlm->name, res->lockname.len, res->lockname.name, in dlm_send_mig_lockres_msg()
1123 ret = o2net_send_message(DLM_MIG_LOCKRES_MSG, dlm->key, mres, in dlm_send_mig_lockres_msg()
1124 struct_size(mres, ml, mres->num_locks), in dlm_send_mig_lockres_msg()
1130 "node %u (%s)\n", dlm->name, mres->lockname_len, in dlm_send_mig_lockres_msg()
1131 mres->lockname, ret, send_to, in dlm_send_mig_lockres_msg()
1135 /* might get an -ENOMEM back here */ in dlm_send_mig_lockres_msg()
1140 if (ret == -EFAULT) { in dlm_send_mig_lockres_msg()
1149 dlm_init_migratable_lockres(mres, res->lockname.name, in dlm_send_mig_lockres_msg()
1150 res->lockname.len, mres_total_locks, in dlm_send_mig_lockres_msg()
1162 mres->lockname_len = namelen; in dlm_init_migratable_lockres()
1163 memcpy(mres->lockname, lockname, namelen); in dlm_init_migratable_lockres()
1164 mres->num_locks = 0; in dlm_init_migratable_lockres()
1165 mres->total_locks = cpu_to_be32(total_locks); in dlm_init_migratable_lockres()
1166 mres->mig_cookie = cpu_to_be64(cookie); in dlm_init_migratable_lockres()
1167 mres->flags = flags; in dlm_init_migratable_lockres()
1168 mres->master = master; in dlm_init_migratable_lockres()
1175 if (!lock->lksb) in dlm_prepare_lvb_for_migration()
1183 if (lock->ml.type != LKM_EXMODE && lock->ml.type != LKM_PRMODE) in dlm_prepare_lvb_for_migration()
1186 if (dlm_lvb_is_empty(mres->lvb)) { in dlm_prepare_lvb_for_migration()
1187 memcpy(mres->lvb, lock->lksb->lvb, DLM_LVB_LEN); in dlm_prepare_lvb_for_migration()
1192 if (!memcmp(mres->lvb, lock->lksb->lvb, DLM_LVB_LEN)) in dlm_prepare_lvb_for_migration()
1197 dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), in dlm_prepare_lvb_for_migration()
1198 dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)), in dlm_prepare_lvb_for_migration()
1199 lock->lockres->lockname.len, lock->lockres->lockname.name, in dlm_prepare_lvb_for_migration()
1200 lock->ml.node); in dlm_prepare_lvb_for_migration()
1201 dlm_print_one_lock_resource(lock->lockres); in dlm_prepare_lvb_for_migration()
1205 /* returns 1 if this lock fills the network structure,
1211 int lock_num = mres->num_locks; in dlm_add_lock_to_array()
1213 ml = &(mres->ml[lock_num]); in dlm_add_lock_to_array()
1214 ml->cookie = lock->ml.cookie; in dlm_add_lock_to_array()
1215 ml->type = lock->ml.type; in dlm_add_lock_to_array()
1216 ml->convert_type = lock->ml.convert_type; in dlm_add_lock_to_array()
1217 ml->highest_blocked = lock->ml.highest_blocked; in dlm_add_lock_to_array()
1218 ml->list = queue; in dlm_add_lock_to_array()
1219 if (lock->lksb) { in dlm_add_lock_to_array()
1220 ml->flags = lock->lksb->flags; in dlm_add_lock_to_array()
1223 ml->node = lock->ml.node; in dlm_add_lock_to_array()
1224 mres->num_locks++; in dlm_add_lock_to_array()
1226 if (mres->num_locks == DLM_MAX_MIGRATABLE_LOCKS) in dlm_add_lock_to_array()
1227 return 1; in dlm_add_lock_to_array()
1241 dummy.ml.node = dlm->node_num; in dlm_add_dummy_lock()
1249 if (unlikely(ml->cookie == 0 && in dlm_is_dummy_lock()
1250 ml->type == LKM_IVMODE && in dlm_is_dummy_lock()
1251 ml->convert_type == LKM_IVMODE && in dlm_is_dummy_lock()
1252 ml->highest_blocked == LKM_IVMODE && in dlm_is_dummy_lock()
1253 ml->list == DLM_BLOCKED_LIST)) { in dlm_is_dummy_lock()
1254 *nodenum = ml->node; in dlm_is_dummy_lock()
1255 return 1; in dlm_is_dummy_lock()
1283 dlm_init_migratable_lockres(mres, res->lockname.name, in dlm_send_one_lockres()
1284 res->lockname.len, total_locks, in dlm_send_one_lockres()
1285 mig_cookie, flags, res->owner); in dlm_send_one_lockres()
1307 dlm->name, res->lockname.len, res->lockname.name, in dlm_send_one_lockres()
1320 dlm->name, ret); in dlm_send_one_lockres()
1324 "lockres %.*s\n", dlm->name, send_to, in dlm_send_one_lockres()
1326 res->lockname.len, res->lockname.name); in dlm_send_one_lockres()
1350 (struct dlm_migratable_lockres *)msg->buf; in dlm_mig_lockres_handler()
1360 return -EINVAL; in dlm_mig_lockres_handler()
1365 dlm->name, mres->lockname_len, in dlm_mig_lockres_handler()
1366 mres->lockname, mres->master); in dlm_mig_lockres_handler()
1368 return -EINVAL; in dlm_mig_lockres_handler()
1371 BUG_ON(!(mres->flags & (DLM_MRES_RECOVERY|DLM_MRES_MIGRATION))); in dlm_mig_lockres_handler()
1373 real_master = mres->master; in dlm_mig_lockres_handler()
1376 BUG_ON(!(mres->flags & DLM_MRES_RECOVERY)); in dlm_mig_lockres_handler()
1380 (mres->flags & DLM_MRES_RECOVERY) ? in dlm_mig_lockres_handler()
1381 "recovery" : "migration", mres->master); in dlm_mig_lockres_handler()
1382 if (mres->flags & DLM_MRES_ALL_DONE) in dlm_mig_lockres_handler()
1385 ret = -ENOMEM; in dlm_mig_lockres_handler()
1386 buf = kmalloc(be16_to_cpu(msg->data_len), GFP_NOFS); in dlm_mig_lockres_handler()
1394 hash = dlm_lockid_hash(mres->lockname, mres->lockname_len); in dlm_mig_lockres_handler()
1395 spin_lock(&dlm->spinlock); in dlm_mig_lockres_handler()
1396 res = __dlm_lookup_lockres_full(dlm, mres->lockname, mres->lockname_len, in dlm_mig_lockres_handler()
1401 spin_lock(&res->spinlock); in dlm_mig_lockres_handler()
1402 if (res->state & DLM_LOCK_RES_DROPPING_REF) { in dlm_mig_lockres_handler()
1405 " ref!\n", dlm->name, in dlm_mig_lockres_handler()
1406 mres->lockname_len, mres->lockname); in dlm_mig_lockres_handler()
1407 ret = -EINVAL; in dlm_mig_lockres_handler()
1408 spin_unlock(&res->spinlock); in dlm_mig_lockres_handler()
1409 spin_unlock(&dlm->spinlock); in dlm_mig_lockres_handler()
1414 if (mres->flags & DLM_MRES_RECOVERY) { in dlm_mig_lockres_handler()
1415 res->state |= DLM_LOCK_RES_RECOVERING; in dlm_mig_lockres_handler()
1417 if (res->state & DLM_LOCK_RES_MIGRATING) { in dlm_mig_lockres_handler()
1421 mres->lockname_len, in dlm_mig_lockres_handler()
1422 mres->lockname); in dlm_mig_lockres_handler()
1423 } else if (res->state & DLM_LOCK_RES_RECOVERING) { in dlm_mig_lockres_handler()
1427 mres->lockname_len, mres->lockname); in dlm_mig_lockres_handler()
1428 ret = -EFAULT; in dlm_mig_lockres_handler()
1429 spin_unlock(&res->spinlock); in dlm_mig_lockres_handler()
1430 spin_unlock(&dlm->spinlock); in dlm_mig_lockres_handler()
1434 res->state |= DLM_LOCK_RES_MIGRATING; in dlm_mig_lockres_handler()
1436 spin_unlock(&res->spinlock); in dlm_mig_lockres_handler()
1437 spin_unlock(&dlm->spinlock); in dlm_mig_lockres_handler()
1439 spin_unlock(&dlm->spinlock); in dlm_mig_lockres_handler()
1442 res = dlm_new_lockres(dlm, mres->lockname, mres->lockname_len); in dlm_mig_lockres_handler()
1451 if (mres->flags & DLM_MRES_RECOVERY) in dlm_mig_lockres_handler()
1452 res->state |= DLM_LOCK_RES_RECOVERING; in dlm_mig_lockres_handler()
1454 res->state |= DLM_LOCK_RES_MIGRATING; in dlm_mig_lockres_handler()
1456 spin_lock(&dlm->spinlock); in dlm_mig_lockres_handler()
1458 spin_unlock(&dlm->spinlock); in dlm_mig_lockres_handler()
1460 /* Add an extra ref for this lock-less lockres lest the in dlm_mig_lockres_handler()
1466 * 1. Taken above. in dlm_mig_lockres_handler()
1467 * 2. kref_init in dlm_new_lockres()->dlm_init_lockres(). in dlm_mig_lockres_handler()
1478 spin_lock(&res->spinlock); in dlm_mig_lockres_handler()
1479 res->state &= ~DLM_LOCK_RES_IN_PROGRESS; in dlm_mig_lockres_handler()
1480 spin_unlock(&res->spinlock); in dlm_mig_lockres_handler()
1481 wake_up(&res->wq); in dlm_mig_lockres_handler()
1486 * the proper res->state flags. */ in dlm_mig_lockres_handler()
1488 spin_lock(&res->spinlock); in dlm_mig_lockres_handler()
1492 if (mres->master == DLM_LOCK_RES_OWNER_UNKNOWN) { in dlm_mig_lockres_handler()
1494 BUG_ON(!(mres->flags & DLM_MRES_RECOVERY)); in dlm_mig_lockres_handler()
1497 "%.*s\n", mres->lockname_len, mres->lockname); in dlm_mig_lockres_handler()
1501 dlm_change_lockres_owner(dlm, res, dlm->node_num); in dlm_mig_lockres_handler()
1503 spin_unlock(&res->spinlock); in dlm_mig_lockres_handler()
1507 memcpy(buf, msg->buf, be16_to_cpu(msg->data_len)); /* copy the whole message */ in dlm_mig_lockres_handler()
1509 item->u.ml.lockres = res; /* already have a ref */ in dlm_mig_lockres_handler()
1510 item->u.ml.real_master = real_master; in dlm_mig_lockres_handler()
1511 item->u.ml.extra_ref = extra_refs; in dlm_mig_lockres_handler()
1512 spin_lock(&dlm->work_lock); in dlm_mig_lockres_handler()
1513 list_add_tail(&item->list, &dlm->work_list); in dlm_mig_lockres_handler()
1514 spin_unlock(&dlm->work_lock); in dlm_mig_lockres_handler()
1515 queue_work(dlm->dlm_worker, &dlm->dispatched_work); in dlm_mig_lockres_handler()
1542 dlm = item->dlm; in dlm_mig_lockres_worker()
1545 res = item->u.ml.lockres; in dlm_mig_lockres_worker()
1546 real_master = item->u.ml.real_master; in dlm_mig_lockres_worker()
1547 extra_ref = item->u.ml.extra_ref; in dlm_mig_lockres_worker()
1550 /* this case is super-rare. only occurs if in dlm_mig_lockres_worker()
1562 res->lockname.len, res->lockname.name); in dlm_mig_lockres_worker()
1564 spin_lock(&res->spinlock); in dlm_mig_lockres_worker()
1566 spin_unlock(&res->spinlock); in dlm_mig_lockres_worker()
1569 real_master, res->lockname.len, in dlm_mig_lockres_worker()
1570 res->lockname.name); in dlm_mig_lockres_worker()
1582 if ((mres->flags & (DLM_MRES_MIGRATION|DLM_MRES_ALL_DONE)) == in dlm_mig_lockres_worker()
1584 ret = dlm_finish_migration(dlm, res, mres->master); in dlm_mig_lockres_worker()
1634 spin_lock(&dlm->spinlock); in dlm_lockres_master_requery()
1635 dlm_node_iter_init(dlm->domain_map, &iter); in dlm_lockres_master_requery()
1636 spin_unlock(&dlm->spinlock); in dlm_lockres_master_requery()
1640 if (nodenum == dlm->node_num) in dlm_lockres_master_requery()
1667 req.node_idx = dlm->node_num; in dlm_do_master_requery()
1668 req.namelen = res->lockname.len; in dlm_do_master_requery()
1669 memcpy(req.name, res->lockname.name, res->lockname.len); in dlm_do_master_requery()
1672 ret = o2net_send_message(DLM_MASTER_REQUERY_MSG, dlm->key, in dlm_do_master_requery()
1677 dlm->key, nodenum); in dlm_do_master_requery()
1678 else if (status == -ENOMEM) { in dlm_do_master_requery()
1701 struct dlm_master_requery *req = (struct dlm_master_requery *)msg->buf; in dlm_master_requery_handler()
1714 hash = dlm_lockid_hash(req->name, req->namelen); in dlm_master_requery_handler()
1716 spin_lock(&dlm->spinlock); in dlm_master_requery_handler()
1717 res = __dlm_lookup_lockres(dlm, req->name, req->namelen, hash); in dlm_master_requery_handler()
1719 spin_lock(&res->spinlock); in dlm_master_requery_handler()
1720 master = res->owner; in dlm_master_requery_handler()
1721 if (master == dlm->node_num) { in dlm_master_requery_handler()
1726 spin_unlock(&res->spinlock); in dlm_master_requery_handler()
1728 spin_unlock(&dlm->spinlock); in dlm_master_requery_handler()
1733 dispatched = 1; in dlm_master_requery_handler()
1735 spin_unlock(&res->spinlock); in dlm_master_requery_handler()
1739 spin_unlock(&res->spinlock); in dlm_master_requery_handler()
1743 spin_unlock(&dlm->spinlock); in dlm_master_requery_handler()
1756 ret = &(res->granted); in dlm_list_num_to_pointer()
1765 * NOTE about in-flight requests during migration:
1768 * MIGRATING and then flushed all of its pending ASTS. So any in-flight
1783 * up-to-date, and the change will be ordered properly for the waiter.
1802 mlog(0, "running %d locks for this lockres\n", mres->num_locks); in dlm_process_recovery_data()
1803 for (i=0; i<mres->num_locks; i++) { in dlm_process_recovery_data()
1804 ml = &(mres->ml[i]); in dlm_process_recovery_data()
1808 BUG_ON(mres->num_locks != 1); in dlm_process_recovery_data()
1810 dlm->name, mres->lockname_len, mres->lockname, in dlm_process_recovery_data()
1812 spin_lock(&res->spinlock); in dlm_process_recovery_data()
1814 spin_unlock(&res->spinlock); in dlm_process_recovery_data()
1817 BUG_ON(ml->highest_blocked != LKM_IVMODE); in dlm_process_recovery_data()
1821 queue = dlm_list_num_to_pointer(res, ml->list); in dlm_process_recovery_data()
1827 if (ml->node == dlm->node_num) { in dlm_process_recovery_data()
1829 BUG_ON(!(mres->flags & DLM_MRES_MIGRATION)); in dlm_process_recovery_data()
1832 spin_lock(&res->spinlock); in dlm_process_recovery_data()
1838 if (lock->ml.cookie == ml->cookie) in dlm_process_recovery_data()
1849 c = ml->cookie; in dlm_process_recovery_data()
1856 ml->node, ml->list, ml->flags, ml->type, in dlm_process_recovery_data()
1857 ml->convert_type, ml->highest_blocked); in dlm_process_recovery_data()
1862 if (lock->ml.node != ml->node) { in dlm_process_recovery_data()
1863 c = lock->ml.cookie; in dlm_process_recovery_data()
1868 res->lockname.len, res->lockname.name, in dlm_process_recovery_data()
1869 lock->ml.node); in dlm_process_recovery_data()
1870 c = ml->cookie; in dlm_process_recovery_data()
1876 ml->node, ml->list, ml->flags, ml->type, in dlm_process_recovery_data()
1877 ml->convert_type, ml->highest_blocked); in dlm_process_recovery_data()
1883 c = ml->cookie; in dlm_process_recovery_data()
1888 j, ml->list, res->lockname.len, in dlm_process_recovery_data()
1889 res->lockname.name); in dlm_process_recovery_data()
1891 spin_unlock(&res->spinlock); in dlm_process_recovery_data()
1900 list_move_tail(&lock->list, queue); in dlm_process_recovery_data()
1901 spin_unlock(&res->spinlock); in dlm_process_recovery_data()
1908 newlock = dlm_new_lock(ml->type, ml->node, in dlm_process_recovery_data()
1909 be64_to_cpu(ml->cookie), NULL); in dlm_process_recovery_data()
1911 ret = -ENOMEM; in dlm_process_recovery_data()
1914 lksb = newlock->lksb; in dlm_process_recovery_data()
1917 if (ml->convert_type != LKM_IVMODE) { in dlm_process_recovery_data()
1918 BUG_ON(queue != &res->converting); in dlm_process_recovery_data()
1919 newlock->ml.convert_type = ml->convert_type; in dlm_process_recovery_data()
1921 lksb->flags |= (ml->flags & in dlm_process_recovery_data()
1924 if (ml->type == LKM_NLMODE) in dlm_process_recovery_data()
1931 if (ml->list == DLM_BLOCKED_LIST) in dlm_process_recovery_data()
1934 if (!dlm_lvb_is_empty(mres->lvb)) { in dlm_process_recovery_data()
1935 if (lksb->flags & DLM_LKSB_PUT_LVB) { in dlm_process_recovery_data()
1939 memcpy(lksb->lvb, mres->lvb, DLM_LVB_LEN); in dlm_process_recovery_data()
1944 memcpy(res->lvb, mres->lvb, DLM_LVB_LEN); in dlm_process_recovery_data()
1948 BUG_ON(ml->type != LKM_EXMODE && in dlm_process_recovery_data()
1949 ml->type != LKM_PRMODE); in dlm_process_recovery_data()
1950 if (!dlm_lvb_is_empty(res->lvb) && in dlm_process_recovery_data()
1951 (ml->type == LKM_EXMODE || in dlm_process_recovery_data()
1952 memcmp(res->lvb, mres->lvb, DLM_LVB_LEN))) { in dlm_process_recovery_data()
1955 "lvb! type=%d\n", dlm->name, in dlm_process_recovery_data()
1956 res->lockname.len, in dlm_process_recovery_data()
1957 res->lockname.name, ml->type); in dlm_process_recovery_data()
1960 printk("%02x", res->lvb[i]); in dlm_process_recovery_data()
1963 printk("%02x", mres->lvb[i]); in dlm_process_recovery_data()
1968 memcpy(res->lvb, mres->lvb, DLM_LVB_LEN); in dlm_process_recovery_data()
1975 * 1. order of locks on granted queue is in dlm_process_recovery_data()
1990 spin_lock(&res->spinlock); in dlm_process_recovery_data()
1992 if (lock->ml.cookie == ml->cookie) { in dlm_process_recovery_data()
1993 c = lock->ml.cookie; in dlm_process_recovery_data()
1995 "exists on this lockres!\n", dlm->name, in dlm_process_recovery_data()
1996 res->lockname.len, res->lockname.name, in dlm_process_recovery_data()
2002 ml->type, ml->convert_type, ml->node, in dlm_process_recovery_data()
2003 dlm_get_lock_cookie_node(be64_to_cpu(ml->cookie)), in dlm_process_recovery_data()
2004 dlm_get_lock_cookie_seq(be64_to_cpu(ml->cookie)), in dlm_process_recovery_data()
2005 ml->list); in dlm_process_recovery_data()
2008 bad = 1; in dlm_process_recovery_data()
2014 if (mres->flags & DLM_MRES_RECOVERY && in dlm_process_recovery_data()
2015 ml->list == DLM_CONVERTING_LIST && in dlm_process_recovery_data()
2016 newlock->ml.type > in dlm_process_recovery_data()
2017 newlock->ml.convert_type) { in dlm_process_recovery_data()
2020 list_add(&newlock->list, queue); in dlm_process_recovery_data()
2022 list_add_tail(&newlock->list, queue); in dlm_process_recovery_data()
2024 "setting refmap bit\n", dlm->name, in dlm_process_recovery_data()
2025 res->lockname.len, res->lockname.name, ml->node); in dlm_process_recovery_data()
2026 dlm_lockres_set_refmap_bit(dlm, res, ml->node); in dlm_process_recovery_data()
2028 spin_unlock(&res->spinlock); in dlm_process_recovery_data()
2034 spin_lock(&res->spinlock); in dlm_process_recovery_data()
2036 spin_unlock(&res->spinlock); in dlm_process_recovery_data()
2051 assert_spin_locked(&dlm->spinlock); in dlm_move_lockres_to_recovery_list()
2052 assert_spin_locked(&res->spinlock); in dlm_move_lockres_to_recovery_list()
2053 res->state |= DLM_LOCK_RES_RECOVERING; in dlm_move_lockres_to_recovery_list()
2054 if (!list_empty(&res->recovering)) { in dlm_move_lockres_to_recovery_list()
2057 dlm->name, res->lockname.len, res->lockname.name); in dlm_move_lockres_to_recovery_list()
2058 list_del_init(&res->recovering); in dlm_move_lockres_to_recovery_list()
2063 list_add_tail(&res->recovering, &dlm->reco.resources); in dlm_move_lockres_to_recovery_list()
2066 for (i=DLM_BLOCKED_LIST; i>=DLM_GRANTED_LIST; i--) { in dlm_move_lockres_to_recovery_list()
2070 if (lock->convert_pending) { in dlm_move_lockres_to_recovery_list()
2074 res->lockname.len, res->lockname.name); in dlm_move_lockres_to_recovery_list()
2076 lock->convert_pending = 0; in dlm_move_lockres_to_recovery_list()
2077 } else if (lock->lock_pending) { in dlm_move_lockres_to_recovery_list()
2082 res->lockname.len, res->lockname.name); in dlm_move_lockres_to_recovery_list()
2089 lock->lock_pending = 0; in dlm_move_lockres_to_recovery_list()
2090 } else if (lock->unlock_pending) { in dlm_move_lockres_to_recovery_list()
2103 res->lockname.len, res->lockname.name); in dlm_move_lockres_to_recovery_list()
2105 lock->unlock_pending = 0; in dlm_move_lockres_to_recovery_list()
2106 } else if (lock->cancel_pending) { in dlm_move_lockres_to_recovery_list()
2114 res->lockname.len, res->lockname.name); in dlm_move_lockres_to_recovery_list()
2116 lock->cancel_pending = 0; in dlm_move_lockres_to_recovery_list()
2126 * sets the res->owner to the new master.
2135 assert_spin_locked(&dlm->spinlock); in dlm_finish_local_lockres_recovery()
2137 list_for_each_entry_safe(res, next, &dlm->reco.resources, recovering) { in dlm_finish_local_lockres_recovery()
2138 if (res->owner == dead_node) { in dlm_finish_local_lockres_recovery()
2140 dlm->name, res->lockname.len, res->lockname.name, in dlm_finish_local_lockres_recovery()
2141 res->owner, new_master); in dlm_finish_local_lockres_recovery()
2142 list_del_init(&res->recovering); in dlm_finish_local_lockres_recovery()
2143 spin_lock(&res->spinlock); in dlm_finish_local_lockres_recovery()
2147 res->state &= ~DLM_LOCK_RES_RECOVERING; in dlm_finish_local_lockres_recovery()
2150 spin_unlock(&res->spinlock); in dlm_finish_local_lockres_recovery()
2151 wake_up(&res->wq); in dlm_finish_local_lockres_recovery()
2163 if (res->state & DLM_LOCK_RES_RECOVERY_WAITING) { in dlm_finish_local_lockres_recovery()
2164 spin_lock(&res->spinlock); in dlm_finish_local_lockres_recovery()
2165 res->state &= ~DLM_LOCK_RES_RECOVERY_WAITING; in dlm_finish_local_lockres_recovery()
2166 spin_unlock(&res->spinlock); in dlm_finish_local_lockres_recovery()
2167 wake_up(&res->wq); in dlm_finish_local_lockres_recovery()
2170 if (!(res->state & DLM_LOCK_RES_RECOVERING)) in dlm_finish_local_lockres_recovery()
2173 if (res->owner != dead_node && in dlm_finish_local_lockres_recovery()
2174 res->owner != dlm->node_num) in dlm_finish_local_lockres_recovery()
2177 if (!list_empty(&res->recovering)) { in dlm_finish_local_lockres_recovery()
2178 list_del_init(&res->recovering); in dlm_finish_local_lockres_recovery()
2185 dlm->name, res->lockname.len, res->lockname.name, in dlm_finish_local_lockres_recovery()
2186 res->owner, new_master); in dlm_finish_local_lockres_recovery()
2187 spin_lock(&res->spinlock); in dlm_finish_local_lockres_recovery()
2189 res->state &= ~DLM_LOCK_RES_RECOVERING; in dlm_finish_local_lockres_recovery()
2192 spin_unlock(&res->spinlock); in dlm_finish_local_lockres_recovery()
2193 wake_up(&res->wq); in dlm_finish_local_lockres_recovery()
2201 if (lock->ml.type != LKM_EXMODE && in dlm_lvb_needs_invalidation()
2202 lock->ml.type != LKM_PRMODE) in dlm_lvb_needs_invalidation()
2203 return 1; in dlm_lvb_needs_invalidation()
2204 } else if (lock->ml.type == LKM_EXMODE) in dlm_lvb_needs_invalidation()
2205 return 1; in dlm_lvb_needs_invalidation()
2218 assert_spin_locked(&dlm->spinlock); in dlm_revalidate_lvb()
2219 assert_spin_locked(&res->spinlock); in dlm_revalidate_lvb()
2221 if (res->owner == dlm->node_num) in dlm_revalidate_lvb()
2228 search_node = dlm->node_num; in dlm_revalidate_lvb()
2229 local = 1; /* check local state for valid lvb */ in dlm_revalidate_lvb()
2235 if (lock->ml.node == search_node) { in dlm_revalidate_lvb()
2238 blank_lvb = 1; in dlm_revalidate_lvb()
2239 memset(lock->lksb->lvb, 0, DLM_LVB_LEN); in dlm_revalidate_lvb()
2247 res->lockname.len, res->lockname.name, dead_node); in dlm_revalidate_lvb()
2248 memset(res->lvb, 0, DLM_LVB_LEN); in dlm_revalidate_lvb()
2259 * 1) remove any stale locks for the dead node in dlm_free_dead_locks()
2262 assert_spin_locked(&dlm->spinlock); in dlm_free_dead_locks()
2263 assert_spin_locked(&res->spinlock); in dlm_free_dead_locks()
2269 list_for_each_entry_safe(lock, next, &res->granted, list) { in dlm_free_dead_locks()
2270 if (lock->ml.node == dead_node) { in dlm_free_dead_locks()
2271 list_del_init(&lock->list); in dlm_free_dead_locks()
2273 /* Can't schedule DLM_UNLOCK_FREE_LOCK - do manually */ in dlm_free_dead_locks()
2278 list_for_each_entry_safe(lock, next, &res->converting, list) { in dlm_free_dead_locks()
2279 if (lock->ml.node == dead_node) { in dlm_free_dead_locks()
2280 list_del_init(&lock->list); in dlm_free_dead_locks()
2282 /* Can't schedule DLM_UNLOCK_FREE_LOCK - do manually */ in dlm_free_dead_locks()
2287 list_for_each_entry_safe(lock, next, &res->blocked, list) { in dlm_free_dead_locks()
2288 if (lock->ml.node == dead_node) { in dlm_free_dead_locks()
2289 list_del_init(&lock->list); in dlm_free_dead_locks()
2291 /* Can't schedule DLM_UNLOCK_FREE_LOCK - do manually */ in dlm_free_dead_locks()
2299 "dropping ref from lockres\n", dlm->name, in dlm_free_dead_locks()
2300 res->lockname.len, res->lockname.name, freed, dead_node); in dlm_free_dead_locks()
2301 if(!test_bit(dead_node, res->refmap)) { in dlm_free_dead_locks()
2303 "but ref was not set\n", dlm->name, in dlm_free_dead_locks()
2304 res->lockname.len, res->lockname.name, freed, dead_node); in dlm_free_dead_locks()
2307 res->state |= DLM_LOCK_RES_RECOVERY_WAITING; in dlm_free_dead_locks()
2309 } else if (test_bit(dead_node, res->refmap)) { in dlm_free_dead_locks()
2311 "no locks and had not purged before dying\n", dlm->name, in dlm_free_dead_locks()
2312 res->lockname.len, res->lockname.name, dead_node); in dlm_free_dead_locks()
2335 * 1) if the dead node was the master, move the lockres in dlm_do_local_recovery_cleanup()
2351 if (dlm_is_recovery_lock(res->lockname.name, in dlm_do_local_recovery_cleanup()
2352 res->lockname.len)) { in dlm_do_local_recovery_cleanup()
2353 spin_lock(&res->spinlock); in dlm_do_local_recovery_cleanup()
2354 list_for_each_entry(lock, &res->granted, list) { in dlm_do_local_recovery_cleanup()
2355 if (lock->ml.node == dead_node) { in dlm_do_local_recovery_cleanup()
2359 dead_node, dlm->name); in dlm_do_local_recovery_cleanup()
2360 list_del_init(&lock->list); in dlm_do_local_recovery_cleanup()
2364 * - do manually */ in dlm_do_local_recovery_cleanup()
2370 if ((res->owner == dead_node) && in dlm_do_local_recovery_cleanup()
2371 (res->state & DLM_LOCK_RES_DROPPING_REF)) { in dlm_do_local_recovery_cleanup()
2374 spin_unlock(&res->spinlock); in dlm_do_local_recovery_cleanup()
2375 wake_up(&res->wq); in dlm_do_local_recovery_cleanup()
2378 } else if (res->owner == dlm->node_num) in dlm_do_local_recovery_cleanup()
2380 spin_unlock(&res->spinlock); in dlm_do_local_recovery_cleanup()
2383 spin_lock(&res->spinlock); in dlm_do_local_recovery_cleanup()
2386 if (res->owner == dead_node) { in dlm_do_local_recovery_cleanup()
2387 if (res->state & DLM_LOCK_RES_DROPPING_REF) { in dlm_do_local_recovery_cleanup()
2392 dlm->name, res->lockname.len, in dlm_do_local_recovery_cleanup()
2393 res->lockname.name, dead_node); in dlm_do_local_recovery_cleanup()
2396 spin_unlock(&res->spinlock); in dlm_do_local_recovery_cleanup()
2397 wake_up(&res->wq); in dlm_do_local_recovery_cleanup()
2402 } else if (res->owner == dlm->node_num) { in dlm_do_local_recovery_cleanup()
2405 } else if (res->owner == DLM_LOCK_RES_OWNER_UNKNOWN) { in dlm_do_local_recovery_cleanup()
2406 if (test_bit(dead_node, res->refmap)) { in dlm_do_local_recovery_cleanup()
2409 dlm->name, res->lockname.len, in dlm_do_local_recovery_cleanup()
2410 res->lockname.name, dead_node); in dlm_do_local_recovery_cleanup()
2414 spin_unlock(&res->spinlock); in dlm_do_local_recovery_cleanup()
2422 assert_spin_locked(&dlm->spinlock); in __dlm_hb_node_down()
2424 if (dlm->reco.new_master == idx) { in __dlm_hb_node_down()
2426 dlm->name, idx); in __dlm_hb_node_down()
2427 if (dlm->reco.state & DLM_RECO_STATE_FINALIZE) { in __dlm_hb_node_down()
2432 "finalize1 state, clearing\n", dlm->name, idx); in __dlm_hb_node_down()
2433 dlm->reco.state &= ~DLM_RECO_STATE_FINALIZE; in __dlm_hb_node_down()
2439 if (dlm->joining_node == idx) { in __dlm_hb_node_down()
2445 if (!test_bit(idx, dlm->live_nodes_map)) { in __dlm_hb_node_down()
2448 dlm->name, idx); in __dlm_hb_node_down()
2453 if (!test_bit(idx, dlm->domain_map)) { in __dlm_hb_node_down()
2460 clear_bit(idx, dlm->live_nodes_map); in __dlm_hb_node_down()
2463 if (!test_bit(idx, dlm->recovery_map)) in __dlm_hb_node_down()
2470 clear_bit(idx, dlm->domain_map); in __dlm_hb_node_down()
2471 clear_bit(idx, dlm->exit_domain_map); in __dlm_hb_node_down()
2474 wake_up(&dlm->migration_wq); in __dlm_hb_node_down()
2476 set_bit(idx, dlm->recovery_map); in __dlm_hb_node_down()
2490 if (test_bit(idx, dlm->domain_map)) in dlm_hb_node_down_cb()
2493 spin_lock(&dlm->spinlock); in dlm_hb_node_down_cb()
2495 spin_unlock(&dlm->spinlock); in dlm_hb_node_down_cb()
2507 spin_lock(&dlm->spinlock); in dlm_hb_node_up_cb()
2508 set_bit(idx, dlm->live_nodes_map); in dlm_hb_node_up_cb()
2511 spin_unlock(&dlm->spinlock); in dlm_hb_node_up_cb()
2520 dlm->node_num, dlm->name); in dlm_reco_ast()
2526 dlm->node_num, dlm->name); in dlm_reco_bast()
2540 * or b) dlm->reco.new_master gets set to some nodenum
2549 int status = -EINVAL; in dlm_pick_recovery_master()
2552 dlm->name, jiffies, dlm->reco.dead_node, dlm->node_num); in dlm_pick_recovery_master()
2561 dlm->name, ret, lksb.status); in dlm_pick_recovery_master()
2565 dlm->name, dlm->node_num); in dlm_pick_recovery_master()
2571 "do the recovery\n", dlm->name, in dlm_pick_recovery_master()
2572 dlm->reco.new_master); in dlm_pick_recovery_master()
2573 status = -EEXIST; in dlm_pick_recovery_master()
2578 spin_lock(&dlm->spinlock); in dlm_pick_recovery_master()
2579 if (dlm->reco.dead_node == O2NM_INVALID_NODE_NUM) { in dlm_pick_recovery_master()
2580 status = -EINVAL; in dlm_pick_recovery_master()
2582 "node got recovered already\n", dlm->name); in dlm_pick_recovery_master()
2583 if (dlm->reco.new_master != O2NM_INVALID_NODE_NUM) { in dlm_pick_recovery_master()
2586 dlm->name, dlm->reco.new_master); in dlm_pick_recovery_master()
2590 spin_unlock(&dlm->spinlock); in dlm_pick_recovery_master()
2597 "begin_reco now\n", dlm->name, in dlm_pick_recovery_master()
2598 dlm->reco.dead_node, dlm->node_num); in dlm_pick_recovery_master()
2600 dlm->reco.dead_node); in dlm_pick_recovery_master()
2605 spin_lock(&dlm->spinlock); in dlm_pick_recovery_master()
2606 dlm_set_reco_master(dlm, dlm->node_num); in dlm_pick_recovery_master()
2607 spin_unlock(&dlm->spinlock); in dlm_pick_recovery_master()
2628 dlm->name, dlm->node_num); in dlm_pick_recovery_master()
2632 wait_event_timeout(dlm->dlm_reco_thread_wq, in dlm_pick_recovery_master()
2637 dlm->name); in dlm_pick_recovery_master()
2642 dlm->name, dlm->reco.new_master, dlm->reco.dead_node); in dlm_pick_recovery_master()
2643 status = -EEXIST; in dlm_pick_recovery_master()
2646 dlm->name, dlm->node_num); in dlm_pick_recovery_master()
2653 "lksb.status=%s\n", dlm->name, dlm_errname(ret), in dlm_pick_recovery_master()
2671 struct dlm_begin_reco br; in dlm_send_begin_reco_message() local
2677 mlog(0, "%s: dead node is %u\n", dlm->name, dead_node); in dlm_send_begin_reco_message()
2679 spin_lock(&dlm->spinlock); in dlm_send_begin_reco_message()
2680 dlm_node_iter_init(dlm->domain_map, &iter); in dlm_send_begin_reco_message()
2681 spin_unlock(&dlm->spinlock); in dlm_send_begin_reco_message()
2685 memset(&br, 0, sizeof(br)); in dlm_send_begin_reco_message()
2686 br.node_idx = dlm->node_num; in dlm_send_begin_reco_message()
2687 br.dead_node = dead_node; in dlm_send_begin_reco_message()
2696 if (nodenum == dlm->node_num) { in dlm_send_begin_reco_message()
2703 ret = o2net_send_message(DLM_BEGIN_RECO_MSG, dlm->key, in dlm_send_begin_reco_message()
2704 &br, sizeof(br), nodenum, &status); in dlm_send_begin_reco_message()
2712 "begin reco msg (%d)\n", dlm->name, nodenum, ret); in dlm_send_begin_reco_message()
2718 * dlm_begin_reco_handler() returned EAGAIN and not -EAGAIN. in dlm_send_begin_reco_message()
2721 if (ret == -EAGAIN || ret == EAGAIN) { in dlm_send_begin_reco_message()
2724 "to complete, backoff for a bit\n", dlm->name, in dlm_send_begin_reco_message()
2726 msleep(100); in dlm_send_begin_reco_message()
2736 "returned %d\n", dlm->name, nodenum, ret); in dlm_send_begin_reco_message()
2747 msleep(100); in dlm_send_begin_reco_message()
2759 struct dlm_begin_reco *br = (struct dlm_begin_reco *)msg->buf; in dlm_begin_reco_handler() local
2765 spin_lock(&dlm->spinlock); in dlm_begin_reco_handler()
2766 if (dlm->reco.state & DLM_RECO_STATE_FINALIZE) { in dlm_begin_reco_handler()
2769 dlm->name, br->node_idx, br->dead_node, in dlm_begin_reco_handler()
2770 dlm->reco.dead_node, dlm->reco.new_master); in dlm_begin_reco_handler()
2771 spin_unlock(&dlm->spinlock); in dlm_begin_reco_handler()
2773 return -EAGAIN; in dlm_begin_reco_handler()
2775 spin_unlock(&dlm->spinlock); in dlm_begin_reco_handler()
2778 dlm->name, br->node_idx, br->dead_node, in dlm_begin_reco_handler()
2779 dlm->reco.dead_node, dlm->reco.new_master); in dlm_begin_reco_handler()
2781 dlm_fire_domain_eviction_callbacks(dlm, br->dead_node); in dlm_begin_reco_handler()
2783 spin_lock(&dlm->spinlock); in dlm_begin_reco_handler()
2784 if (dlm->reco.new_master != O2NM_INVALID_NODE_NUM) { in dlm_begin_reco_handler()
2785 if (test_bit(dlm->reco.new_master, dlm->recovery_map)) { in dlm_begin_reco_handler()
2787 "to %u\n", dlm->name, dlm->reco.new_master, in dlm_begin_reco_handler()
2788 br->node_idx); in dlm_begin_reco_handler()
2791 "to %u\n", dlm->name, dlm->reco.new_master, in dlm_begin_reco_handler()
2792 br->node_idx); in dlm_begin_reco_handler()
2796 if (dlm->reco.dead_node != O2NM_INVALID_NODE_NUM) { in dlm_begin_reco_handler()
2798 "node %u changing it to %u\n", dlm->name, in dlm_begin_reco_handler()
2799 dlm->reco.dead_node, br->node_idx, br->dead_node); in dlm_begin_reco_handler()
2801 dlm_set_reco_master(dlm, br->node_idx); in dlm_begin_reco_handler()
2802 dlm_set_reco_dead_node(dlm, br->dead_node); in dlm_begin_reco_handler()
2803 if (!test_bit(br->dead_node, dlm->recovery_map)) { in dlm_begin_reco_handler()
2806 br->node_idx, br->dead_node, br->dead_node); in dlm_begin_reco_handler()
2807 if (!test_bit(br->dead_node, dlm->domain_map) || in dlm_begin_reco_handler()
2808 !test_bit(br->dead_node, dlm->live_nodes_map)) in dlm_begin_reco_handler()
2811 br->dead_node); in dlm_begin_reco_handler()
2814 set_bit(br->dead_node, dlm->domain_map); in dlm_begin_reco_handler()
2815 set_bit(br->dead_node, dlm->live_nodes_map); in dlm_begin_reco_handler()
2816 __dlm_hb_node_down(dlm, br->dead_node); in dlm_begin_reco_handler()
2818 spin_unlock(&dlm->spinlock); in dlm_begin_reco_handler()
2823 dlm->name, br->node_idx, br->dead_node, in dlm_begin_reco_handler()
2824 dlm->reco.dead_node, dlm->reco.new_master); in dlm_begin_reco_handler()
2838 int stage = 1; in dlm_send_finalize_reco_message()
2841 "stage %d\n", dlm->name, dlm->reco.dead_node, stage); in dlm_send_finalize_reco_message()
2843 spin_lock(&dlm->spinlock); in dlm_send_finalize_reco_message()
2844 dlm_node_iter_init(dlm->domain_map, &iter); in dlm_send_finalize_reco_message()
2845 spin_unlock(&dlm->spinlock); in dlm_send_finalize_reco_message()
2849 fr.node_idx = dlm->node_num; in dlm_send_finalize_reco_message()
2850 fr.dead_node = dlm->reco.dead_node; in dlm_send_finalize_reco_message()
2855 if (nodenum == dlm->node_num) in dlm_send_finalize_reco_message()
2857 ret = o2net_send_message(DLM_FINALIZE_RECO_MSG, dlm->key, in dlm_send_finalize_reco_message()
2864 dlm->key, nodenum); in dlm_send_finalize_reco_message()
2877 if (stage == 1) { in dlm_send_finalize_reco_message()
2879 iter.curnode = -1; in dlm_send_finalize_reco_message()
2891 struct dlm_finalize_reco *fr = (struct dlm_finalize_reco *)msg->buf; in dlm_finalize_reco_handler()
2892 int stage = 1; in dlm_finalize_reco_handler()
2898 if (fr->flags & DLM_FINALIZE_STAGE2) in dlm_finalize_reco_handler()
2902 "node %u (%u:%u)\n", dlm->name, fr->node_idx, stage, in dlm_finalize_reco_handler()
2903 fr->dead_node, dlm->reco.dead_node, dlm->reco.new_master); in dlm_finalize_reco_handler()
2905 spin_lock(&dlm->spinlock); in dlm_finalize_reco_handler()
2907 if (dlm->reco.new_master != fr->node_idx) { in dlm_finalize_reco_handler()
2910 fr->node_idx, dlm->reco.new_master, fr->dead_node); in dlm_finalize_reco_handler()
2913 if (dlm->reco.dead_node != fr->dead_node) { in dlm_finalize_reco_handler()
2916 fr->node_idx, fr->dead_node, dlm->reco.dead_node); in dlm_finalize_reco_handler()
2921 case 1: in dlm_finalize_reco_handler()
2922 dlm_finish_local_lockres_recovery(dlm, fr->dead_node, fr->node_idx); in dlm_finalize_reco_handler()
2923 if (dlm->reco.state & DLM_RECO_STATE_FINALIZE) { in dlm_finalize_reco_handler()
2927 dlm->name, fr->node_idx, fr->dead_node); in dlm_finalize_reco_handler()
2931 dlm->reco.state |= DLM_RECO_STATE_FINALIZE; in dlm_finalize_reco_handler()
2932 spin_unlock(&dlm->spinlock); in dlm_finalize_reco_handler()
2935 if (!(dlm->reco.state & DLM_RECO_STATE_FINALIZE)) { in dlm_finalize_reco_handler()
2939 dlm->name, fr->node_idx, fr->dead_node); in dlm_finalize_reco_handler()
2943 dlm->reco.state &= ~DLM_RECO_STATE_FINALIZE; in dlm_finalize_reco_handler()
2945 spin_unlock(&dlm->spinlock); in dlm_finalize_reco_handler()
2951 dlm->name, fr->node_idx, dlm->reco.dead_node, dlm->reco.new_master); in dlm_finalize_reco_handler()