Lines Matching +full:protocol +full:- +full:node
1 // SPDX-License-Identifier: GPL-2.0-or-later
34 * ocfs2 node maps are array of long int, which limits to send them freely
65 while (pages--) in dlm_free_pagevec()
95 * struct dlm_ctxt->spinlock
96 * struct dlm_lock_resource->spinlock
97 * struct dlm_ctxt->master_lock
98 * struct dlm_ctxt->ast_lock
99 * dlm_master_list_entry->spinlock
100 * dlm_lock->spinlock
109 * The supported protocol version for DLM communication. Running domains
111 * number equal or smaller. The dlm_ctxt->dlm_locking_proto field should
115 * - Message DLM_QUERY_REGION added to support global heartbeat
116 * - Message DLM_QUERY_NODEINFO added to allow online node removes
118 * - Message DLM_BEGIN_EXIT_DOMAIN_MSG added to mark start of exit domain
120 * - Message DLM_DEREF_LOCKRES_DONE added to inform non-master that the
147 if (hlist_unhashed(&res->hash_node)) in __dlm_unhash_lockres()
150 mlog(0, "%s: Unhash res %.*s\n", dlm->name, res->lockname.len, in __dlm_unhash_lockres()
151 res->lockname.name); in __dlm_unhash_lockres()
152 hlist_del_init(&res->hash_node); in __dlm_unhash_lockres()
160 assert_spin_locked(&dlm->spinlock); in __dlm_insert_lockres()
162 bucket = dlm_lockres_hash(dlm, res->lockname.hash); in __dlm_insert_lockres()
167 hlist_add_head(&res->hash_node, bucket); in __dlm_insert_lockres()
169 mlog(0, "%s: Hash res %.*s\n", dlm->name, res->lockname.len, in __dlm_insert_lockres()
170 res->lockname.name); in __dlm_insert_lockres()
183 assert_spin_locked(&dlm->spinlock); in __dlm_lookup_lockres_full()
188 if (res->lockname.name[0] != name[0]) in __dlm_lookup_lockres_full()
190 if (unlikely(res->lockname.len != len)) in __dlm_lookup_lockres_full()
192 if (memcmp(res->lockname.name + 1, name + 1, len - 1)) in __dlm_lookup_lockres_full()
215 assert_spin_locked(&dlm->spinlock); in __dlm_lookup_lockres()
219 spin_lock(&res->spinlock); in __dlm_lookup_lockres()
220 if (res->state & DLM_LOCK_RES_DROPPING_REF) { in __dlm_lookup_lockres()
221 spin_unlock(&res->spinlock); in __dlm_lookup_lockres()
225 spin_unlock(&res->spinlock); in __dlm_lookup_lockres()
238 spin_lock(&dlm->spinlock); in dlm_lookup_lockres()
240 spin_unlock(&dlm->spinlock); in dlm_lookup_lockres()
250 /* tmp->name here is always NULL terminated, in __dlm_lookup_domain_full()
253 if (strlen(tmp->name) == len && in __dlm_lookup_domain_full()
254 memcmp(tmp->name, domain, len)==0) in __dlm_lookup_domain_full()
283 else if (tmp->dlm_state == DLM_CTXT_JOINED) in dlm_wait_on_domain_helper()
294 if (dlm->lockres_hash) in dlm_free_ctxt_mem()
295 dlm_free_pagevec((void **)dlm->lockres_hash, DLM_HASH_PAGES); in dlm_free_ctxt_mem()
297 if (dlm->master_hash) in dlm_free_ctxt_mem()
298 dlm_free_pagevec((void **)dlm->master_hash, DLM_HASH_PAGES); in dlm_free_ctxt_mem()
300 kfree(dlm->name); in dlm_free_ctxt_mem()
304 /* A little strange - this function will be called while holding
313 BUG_ON(dlm->num_joins); in dlm_ctxt_release()
314 BUG_ON(dlm->dlm_state == DLM_CTXT_JOINED); in dlm_ctxt_release()
317 list_del_init(&dlm->list); in dlm_ctxt_release()
321 mlog(0, "freeing memory from domain %s\n", dlm->name); in dlm_ctxt_release()
333 kref_put(&dlm->dlm_refs, dlm_ctxt_release); in dlm_put()
339 kref_get(&dlm->dlm_refs); in __dlm_get()
370 ret = (dlm->dlm_state == DLM_CTXT_JOINED) || in dlm_domain_fully_joined()
371 (dlm->dlm_state == DLM_CTXT_IN_SHUTDOWN); in dlm_domain_fully_joined()
379 if (dlm->dlm_worker) { in dlm_destroy_dlm_worker()
380 destroy_workqueue(dlm->dlm_worker); in dlm_destroy_dlm_worker()
381 dlm->dlm_worker = NULL; in dlm_destroy_dlm_worker()
396 list_del_init(&dlm->list); in dlm_complete_dlm_shutdown()
411 mlog(0, "Migrating locks from domain %s\n", dlm->name); in dlm_migrate_all_locks()
414 spin_lock(&dlm->spinlock); in dlm_migrate_all_locks()
419 iter = bucket->first; in dlm_migrate_all_locks()
429 spin_lock(&res->spinlock); in dlm_migrate_all_locks()
433 iter = res->hash_node.next; in dlm_migrate_all_locks()
434 spin_unlock(&res->spinlock); in dlm_migrate_all_locks()
439 cond_resched_lock(&dlm->spinlock); in dlm_migrate_all_locks()
443 cond_resched_lock(&dlm->spinlock); in dlm_migrate_all_locks()
448 if (dlm->reco.state & DLM_RECO_STATE_ACTIVE) { in dlm_migrate_all_locks()
450 "need to be migrated after dlm recovery\n", dlm->name); in dlm_migrate_all_locks()
451 ret = -EAGAIN; in dlm_migrate_all_locks()
454 "all lock resources\n", dlm->name); in dlm_migrate_all_locks()
455 dlm->migrate_done = 1; in dlm_migrate_all_locks()
459 spin_unlock(&dlm->spinlock); in dlm_migrate_all_locks()
460 wake_up(&dlm->dlm_thread_wq); in dlm_migrate_all_locks()
466 dlm->name, num); in dlm_migrate_all_locks()
467 ret = -EAGAIN; in dlm_migrate_all_locks()
469 mlog(0, "DONE Migrating locks from domain %s\n", dlm->name); in dlm_migrate_all_locks()
477 spin_lock(&dlm->spinlock); in dlm_no_joining_node()
478 ret = dlm->joining_node == DLM_LOCK_RES_OWNER_UNKNOWN; in dlm_no_joining_node()
479 spin_unlock(&dlm->spinlock); in dlm_no_joining_node()
488 unsigned int node; in dlm_begin_exit_domain_handler() local
489 struct dlm_exit_domain *exit_msg = (struct dlm_exit_domain *) msg->buf; in dlm_begin_exit_domain_handler()
494 node = exit_msg->node_idx; in dlm_begin_exit_domain_handler()
495 mlog(0, "%s: Node %u sent a begin exit domain message\n", dlm->name, node); in dlm_begin_exit_domain_handler()
497 spin_lock(&dlm->spinlock); in dlm_begin_exit_domain_handler()
498 set_bit(node, dlm->exit_domain_map); in dlm_begin_exit_domain_handler()
499 spin_unlock(&dlm->spinlock); in dlm_begin_exit_domain_handler()
512 spin_lock(&dlm->spinlock); in dlm_mark_domain_leaving()
514 if (dlm->joining_node != DLM_LOCK_RES_OWNER_UNKNOWN) { in dlm_mark_domain_leaving()
515 mlog(0, "Node %d is joining, we wait on it.\n", in dlm_mark_domain_leaving()
516 dlm->joining_node); in dlm_mark_domain_leaving()
517 spin_unlock(&dlm->spinlock); in dlm_mark_domain_leaving()
520 wait_event(dlm->dlm_join_events, dlm_no_joining_node(dlm)); in dlm_mark_domain_leaving()
524 dlm->dlm_state = DLM_CTXT_LEAVING; in dlm_mark_domain_leaving()
525 spin_unlock(&dlm->spinlock); in dlm_mark_domain_leaving()
531 int node = -1, num = 0; in __dlm_print_nodes() local
533 assert_spin_locked(&dlm->spinlock); in __dlm_print_nodes()
536 while ((node = find_next_bit(dlm->domain_map, O2NM_MAX_NODES, in __dlm_print_nodes()
537 node + 1)) < O2NM_MAX_NODES) { in __dlm_print_nodes()
538 printk("%d ", node); in __dlm_print_nodes()
548 unsigned int node; in dlm_exit_domain_handler() local
549 struct dlm_exit_domain *exit_msg = (struct dlm_exit_domain *) msg->buf; in dlm_exit_domain_handler()
556 node = exit_msg->node_idx; in dlm_exit_domain_handler()
558 spin_lock(&dlm->spinlock); in dlm_exit_domain_handler()
559 clear_bit(node, dlm->domain_map); in dlm_exit_domain_handler()
560 clear_bit(node, dlm->exit_domain_map); in dlm_exit_domain_handler()
561 printk(KERN_NOTICE "o2dlm: Node %u leaves domain %s ", node, dlm->name); in dlm_exit_domain_handler()
565 dlm_hb_event_notify_attached(dlm, node, 0); in dlm_exit_domain_handler()
567 spin_unlock(&dlm->spinlock); in dlm_exit_domain_handler()
575 unsigned int node) in dlm_send_one_domain_exit() argument
580 mlog(0, "%s: Sending domain exit message %u to node %u\n", dlm->name, in dlm_send_one_domain_exit()
581 msg_type, node); in dlm_send_one_domain_exit()
584 leave_msg.node_idx = dlm->node_num; in dlm_send_one_domain_exit()
586 status = o2net_send_message(msg_type, dlm->key, &leave_msg, in dlm_send_one_domain_exit()
587 sizeof(leave_msg), node, NULL); in dlm_send_one_domain_exit()
590 "to node %u on domain %s\n", status, msg_type, node, in dlm_send_one_domain_exit()
591 dlm->name); in dlm_send_one_domain_exit()
598 int node = -1; in dlm_begin_exit_domain() local
601 if (dlm->dlm_locking_proto.pv_major == 1 && in dlm_begin_exit_domain()
602 dlm->dlm_locking_proto.pv_minor < 2) in dlm_begin_exit_domain()
607 * informational. Meaning if a node does not receive the message, in dlm_begin_exit_domain()
610 spin_lock(&dlm->spinlock); in dlm_begin_exit_domain()
612 node = find_next_bit(dlm->domain_map, O2NM_MAX_NODES, node + 1); in dlm_begin_exit_domain()
613 if (node >= O2NM_MAX_NODES) in dlm_begin_exit_domain()
615 if (node == dlm->node_num) in dlm_begin_exit_domain()
618 spin_unlock(&dlm->spinlock); in dlm_begin_exit_domain()
619 dlm_send_one_domain_exit(dlm, DLM_BEGIN_EXIT_DOMAIN_MSG, node); in dlm_begin_exit_domain()
620 spin_lock(&dlm->spinlock); in dlm_begin_exit_domain()
622 spin_unlock(&dlm->spinlock); in dlm_begin_exit_domain()
627 int node, clear_node, status; in dlm_leave_domain() local
634 spin_lock(&dlm->spinlock); in dlm_leave_domain()
636 clear_bit(dlm->node_num, dlm->domain_map); in dlm_leave_domain()
637 while ((node = find_next_bit(dlm->domain_map, O2NM_MAX_NODES, in dlm_leave_domain()
640 * -nodes cannot be added now as the in dlm_leave_domain()
642 * -we catch the right network errors if a node is in dlm_leave_domain()
645 spin_unlock(&dlm->spinlock); in dlm_leave_domain()
650 node); in dlm_leave_domain()
652 status != -ENOPROTOOPT && in dlm_leave_domain()
653 status != -ENOTCONN) { in dlm_leave_domain()
655 "to node %d\n", status, node); in dlm_leave_domain()
664 spin_lock(&dlm->spinlock); in dlm_leave_domain()
665 /* If we're not clearing the node bit then we intend in dlm_leave_domain()
668 clear_bit(node, dlm->domain_map); in dlm_leave_domain()
670 spin_unlock(&dlm->spinlock); in dlm_leave_domain()
679 BUG_ON(dlm->dlm_state != DLM_CTXT_JOINED); in dlm_unregister_domain()
680 BUG_ON(!dlm->num_joins); in dlm_unregister_domain()
682 dlm->num_joins--; in dlm_unregister_domain()
683 if (!dlm->num_joins) { in dlm_unregister_domain()
690 dlm->dlm_state = DLM_CTXT_IN_SHUTDOWN; in dlm_unregister_domain()
696 mlog(0, "shutting down domain %s\n", dlm->name); in dlm_unregister_domain()
705 mlog(0, "%s: more migration to do\n", dlm->name); in dlm_unregister_domain()
709 if (!list_empty(&dlm->tracking_list)) { in dlm_unregister_domain()
712 list_for_each_entry(res, &dlm->tracking_list, tracking) in dlm_unregister_domain()
718 printk(KERN_NOTICE "o2dlm: Leaving domain %s\n", dlm->name); in dlm_unregister_domain()
726 static int dlm_query_join_proto_check(char *proto_type, int node, in dlm_query_join_proto_check() argument
735 "node %u wanted to join with %s locking protocol " in dlm_query_join_proto_check()
737 node, proto_type, in dlm_query_join_proto_check()
738 request->pv_major, in dlm_query_join_proto_check()
739 request->pv_minor, in dlm_query_join_proto_check()
741 request->pv_minor = proto.pv_minor; in dlm_query_join_proto_check()
745 "Node %u wanted to join with %s locking " in dlm_query_join_proto_check()
746 "protocol %u.%u, but we have %u.%u, disallowing\n", in dlm_query_join_proto_check()
747 node, proto_type, in dlm_query_join_proto_check()
748 request->pv_major, in dlm_query_join_proto_check()
749 request->pv_minor, in dlm_query_join_proto_check()
750 ours->pv_major, in dlm_query_join_proto_check()
751 ours->pv_minor); in dlm_query_join_proto_check()
759 * struct dlm_query_join_packet is made up of four one-byte fields. They
760 * are effectively in big-endian order already. However, little-endian
763 * on the wire). Thus, a big-endian and little-endian machines will treat
766 * The solution is to have little-endian machines swap the structure when
800 query = (struct dlm_query_join_request *) msg->buf; in dlm_query_join_handler()
802 mlog(0, "node %u wants to join domain %s\n", query->node_idx, in dlm_query_join_handler()
803 query->domain); in dlm_query_join_handler()
806 * If heartbeat doesn't consider the node live, tell it in dlm_query_join_handler()
810 if (!o2hb_check_node_heartbeating_no_sem(query->node_idx)) { in dlm_query_join_handler()
811 mlog(0, "node %u is not in our live map yet\n", in dlm_query_join_handler()
812 query->node_idx); in dlm_query_join_handler()
821 dlm = __dlm_lookup_domain_full(query->domain, query->name_len); in dlm_query_join_handler()
826 * There is a small window where the joining node may not see the in dlm_query_join_handler()
827 * node(s) that just left but still part of the cluster. DISALLOW in dlm_query_join_handler()
828 * join request if joining node has different node map. in dlm_query_join_handler()
832 if (test_bit(nodenum, dlm->domain_map)) { in dlm_query_join_handler()
833 if (!byte_test_bit(nodenum, query->node_map)) { in dlm_query_join_handler()
834 mlog(0, "disallow join as node %u does not " in dlm_query_join_handler()
835 "have node %u in its nodemap\n", in dlm_query_join_handler()
836 query->node_idx, nodenum); in dlm_query_join_handler()
848 if (dlm->dlm_state != DLM_CTXT_LEAVING) { in dlm_query_join_handler()
849 int bit = query->node_idx; in dlm_query_join_handler()
850 spin_lock(&dlm->spinlock); in dlm_query_join_handler()
852 if (dlm->dlm_state == DLM_CTXT_NEW && in dlm_query_join_handler()
853 dlm->joining_node == DLM_LOCK_RES_OWNER_UNKNOWN) { in dlm_query_join_handler()
856 * the other node won the race. */ in dlm_query_join_handler()
858 } else if (dlm->joining_node != DLM_LOCK_RES_OWNER_UNKNOWN) { in dlm_query_join_handler()
861 } else if (dlm->reco.state & DLM_RECO_STATE_ACTIVE) { in dlm_query_join_handler()
862 mlog(0, "node %u trying to join, but recovery " in dlm_query_join_handler()
865 } else if (test_bit(bit, dlm->recovery_map)) { in dlm_query_join_handler()
866 mlog(0, "node %u trying to join, but it " in dlm_query_join_handler()
869 } else if (test_bit(bit, dlm->domain_map)) { in dlm_query_join_handler()
870 mlog(0, "node %u trying to join, but it " in dlm_query_join_handler()
882 &dlm->dlm_locking_proto, in dlm_query_join_handler()
883 &query->dlm_proto)) { in dlm_query_join_handler()
886 &dlm->fs_locking_proto, in dlm_query_join_handler()
887 &query->fs_proto)) { in dlm_query_join_handler()
890 packet.dlm_minor = query->dlm_proto.pv_minor; in dlm_query_join_handler()
891 packet.fs_minor = query->fs_proto.pv_minor; in dlm_query_join_handler()
893 __dlm_set_joining_node(dlm, query->node_idx); in dlm_query_join_handler()
897 spin_unlock(&dlm->spinlock); in dlm_query_join_handler()
915 assert = (struct dlm_assert_joined *) msg->buf; in dlm_assert_joined_handler()
917 mlog(0, "node %u asserts join on domain %s\n", assert->node_idx, in dlm_assert_joined_handler()
918 assert->domain); in dlm_assert_joined_handler()
921 dlm = __dlm_lookup_domain_full(assert->domain, assert->name_len); in dlm_assert_joined_handler()
924 spin_lock(&dlm->spinlock); in dlm_assert_joined_handler()
926 /* Alright, this node has officially joined our in dlm_assert_joined_handler()
929 BUG_ON(dlm->joining_node != assert->node_idx); in dlm_assert_joined_handler()
931 if (dlm->reco.state & DLM_RECO_STATE_ACTIVE) { in dlm_assert_joined_handler()
933 spin_unlock(&dlm->spinlock); in dlm_assert_joined_handler()
935 return -EAGAIN; in dlm_assert_joined_handler()
938 set_bit(assert->node_idx, dlm->domain_map); in dlm_assert_joined_handler()
939 clear_bit(assert->node_idx, dlm->exit_domain_map); in dlm_assert_joined_handler()
942 printk(KERN_NOTICE "o2dlm: Node %u joins domain %s ", in dlm_assert_joined_handler()
943 assert->node_idx, dlm->name); in dlm_assert_joined_handler()
947 dlm_hb_event_notify_attached(dlm, assert->node_idx, 1); in dlm_assert_joined_handler()
949 spin_unlock(&dlm->spinlock); in dlm_assert_joined_handler()
960 char *remote = qr->qr_regions; in dlm_match_regions()
966 if (qr->qr_numregions) { in dlm_match_regions()
967 mlog(ML_ERROR, "Domain %s: Joining node %d has global " in dlm_match_regions()
968 "heartbeat enabled but local node %d does not\n", in dlm_match_regions()
969 qr->qr_domain, qr->qr_node, dlm->node_num); in dlm_match_regions()
970 status = -EINVAL; in dlm_match_regions()
975 if (o2hb_global_heartbeat_active() && !qr->qr_numregions) { in dlm_match_regions()
976 mlog(ML_ERROR, "Domain %s: Local node %d has global " in dlm_match_regions()
977 "heartbeat enabled but joining node %d does not\n", in dlm_match_regions()
978 qr->qr_domain, dlm->node_num, qr->qr_node); in dlm_match_regions()
979 status = -EINVAL; in dlm_match_regions()
984 for (i = 0; i < qr->qr_numregions; ++i) { in dlm_match_regions()
997 for (j = 0; j <= qr->qr_numregions; ++j) { in dlm_match_regions()
1005 status = -EINVAL; in dlm_match_regions()
1007 "in local node %d but not in joining node %d\n", in dlm_match_regions()
1008 qr->qr_domain, O2HB_MAX_REGION_NAME_LEN, l, in dlm_match_regions()
1009 dlm->node_num, qr->qr_node); in dlm_match_regions()
1017 for (i = 0; i < qr->qr_numregions; ++i) { in dlm_match_regions()
1028 status = -EINVAL; in dlm_match_regions()
1030 "in joining node %d but not in local node %d\n", in dlm_match_regions()
1031 qr->qr_domain, O2HB_MAX_REGION_NAME_LEN, r, in dlm_match_regions()
1032 qr->qr_node, dlm->node_num); in dlm_match_regions()
1053 ret = -ENOMEM; in dlm_send_regions()
1058 qr->qr_node = dlm->node_num; in dlm_send_regions()
1059 qr->qr_namelen = strlen(dlm->name); in dlm_send_regions()
1060 memcpy(qr->qr_domain, dlm->name, qr->qr_namelen); in dlm_send_regions()
1063 qr->qr_numregions = o2hb_get_all_regions(qr->qr_regions, in dlm_send_regions()
1066 p = qr->qr_regions; in dlm_send_regions()
1067 for (i = 0; i < qr->qr_numregions; ++i, p += O2HB_MAX_REGION_NAME_LEN) in dlm_send_regions()
1070 i = -1; in dlm_send_regions()
1073 if (i == dlm->node_num) in dlm_send_regions()
1076 mlog(0, "Sending regions to node %d\n", i); in dlm_send_regions()
1084 mlog(ML_ERROR, "Region mismatch %d, node %d\n", in dlm_send_regions()
1103 qr = (struct dlm_query_region *) msg->buf; in dlm_query_region_handler()
1105 mlog(0, "Node %u queries hb regions on domain %s\n", qr->qr_node, in dlm_query_region_handler()
1106 qr->qr_domain); in dlm_query_region_handler()
1109 local = kmalloc(sizeof(qr->qr_regions), GFP_KERNEL); in dlm_query_region_handler()
1111 return -ENOMEM; in dlm_query_region_handler()
1113 status = -EINVAL; in dlm_query_region_handler()
1116 dlm = __dlm_lookup_domain_full(qr->qr_domain, qr->qr_namelen); in dlm_query_region_handler()
1118 mlog(ML_ERROR, "Node %d queried hb regions on domain %s " in dlm_query_region_handler()
1119 "before join domain\n", qr->qr_node, qr->qr_domain); in dlm_query_region_handler()
1123 spin_lock(&dlm->spinlock); in dlm_query_region_handler()
1124 if (dlm->joining_node != qr->qr_node) { in dlm_query_region_handler()
1125 mlog(ML_ERROR, "Node %d queried hb regions on domain %s " in dlm_query_region_handler()
1126 "but joining node is %d\n", qr->qr_node, qr->qr_domain, in dlm_query_region_handler()
1127 dlm->joining_node); in dlm_query_region_handler()
1132 if (dlm->dlm_locking_proto.pv_major == 1 && in dlm_query_region_handler()
1133 dlm->dlm_locking_proto.pv_minor == 0) { in dlm_query_region_handler()
1134 mlog(ML_ERROR, "Node %d queried hb regions on domain %s " in dlm_query_region_handler()
1135 "but active dlm protocol is %d.%d\n", qr->qr_node, in dlm_query_region_handler()
1136 qr->qr_domain, dlm->dlm_locking_proto.pv_major, in dlm_query_region_handler()
1137 dlm->dlm_locking_proto.pv_minor); in dlm_query_region_handler()
1141 status = dlm_match_regions(dlm, qr, local, sizeof(qr->qr_regions)); in dlm_query_region_handler()
1144 spin_unlock(&dlm->spinlock); in dlm_query_region_handler()
1161 for (j = 0; j < qn->qn_numnodes; ++j) in dlm_match_nodes()
1162 mlog(0, "Node %3d, %pI4:%u\n", qn->qn_nodes[j].ni_nodenum, in dlm_match_nodes()
1163 &(qn->qn_nodes[j].ni_ipv4_address), in dlm_match_nodes()
1164 ntohs(qn->qn_nodes[j].ni_ipv4_port)); in dlm_match_nodes()
1169 for (j = 0; j < qn->qn_numnodes; ++j) { in dlm_match_nodes()
1170 if (qn->qn_nodes[j].ni_nodenum == i) { in dlm_match_nodes()
1171 remote = &(qn->qn_nodes[j]); in dlm_match_nodes()
1180 status = -EINVAL; in dlm_match_nodes()
1183 ((remote->ni_nodenum != local->nd_num) || in dlm_match_nodes()
1184 (remote->ni_ipv4_port != local->nd_ipv4_port) || in dlm_match_nodes()
1185 (remote->ni_ipv4_address != local->nd_ipv4_address))) in dlm_match_nodes()
1186 status = -EINVAL; in dlm_match_nodes()
1190 mlog(ML_ERROR, "Domain %s: Node %d (%pI4:%u) " in dlm_match_nodes()
1191 "registered in joining node %d but not in " in dlm_match_nodes()
1192 "local node %d\n", qn->qn_domain, in dlm_match_nodes()
1193 remote->ni_nodenum, in dlm_match_nodes()
1194 &(remote->ni_ipv4_address), in dlm_match_nodes()
1195 ntohs(remote->ni_ipv4_port), in dlm_match_nodes()
1196 qn->qn_nodenum, dlm->node_num); in dlm_match_nodes()
1198 mlog(ML_ERROR, "Domain %s: Node %d (%pI4:%u) " in dlm_match_nodes()
1199 "registered in local node %d but not in " in dlm_match_nodes()
1200 "joining node %d\n", qn->qn_domain, in dlm_match_nodes()
1201 local->nd_num, &(local->nd_ipv4_address), in dlm_match_nodes()
1202 ntohs(local->nd_ipv4_port), in dlm_match_nodes()
1203 dlm->node_num, qn->qn_nodenum); in dlm_match_nodes()
1217 struct o2nm_node *node; in dlm_send_nodeinfo() local
1225 ret = -ENOMEM; in dlm_send_nodeinfo()
1231 node = o2nm_get_node_by_num(i); in dlm_send_nodeinfo()
1232 if (!node) in dlm_send_nodeinfo()
1234 qn->qn_nodes[count].ni_nodenum = node->nd_num; in dlm_send_nodeinfo()
1235 qn->qn_nodes[count].ni_ipv4_port = node->nd_ipv4_port; in dlm_send_nodeinfo()
1236 qn->qn_nodes[count].ni_ipv4_address = node->nd_ipv4_address; in dlm_send_nodeinfo()
1237 mlog(0, "Node %3d, %pI4:%u\n", node->nd_num, in dlm_send_nodeinfo()
1238 &(node->nd_ipv4_address), ntohs(node->nd_ipv4_port)); in dlm_send_nodeinfo()
1240 o2nm_node_put(node); in dlm_send_nodeinfo()
1243 qn->qn_nodenum = dlm->node_num; in dlm_send_nodeinfo()
1244 qn->qn_numnodes = count; in dlm_send_nodeinfo()
1245 qn->qn_namelen = strlen(dlm->name); in dlm_send_nodeinfo()
1246 memcpy(qn->qn_domain, dlm->name, qn->qn_namelen); in dlm_send_nodeinfo()
1248 i = -1; in dlm_send_nodeinfo()
1251 if (i == dlm->node_num) in dlm_send_nodeinfo()
1254 mlog(0, "Sending nodeinfo to node %d\n", i); in dlm_send_nodeinfo()
1262 mlog(ML_ERROR, "node mismatch %d, node %d\n", ret, i); in dlm_send_nodeinfo()
1277 int status = -EINVAL; in dlm_query_nodeinfo_handler()
1279 qn = (struct dlm_query_nodeinfo *) msg->buf; in dlm_query_nodeinfo_handler()
1281 mlog(0, "Node %u queries nodes on domain %s\n", qn->qn_nodenum, in dlm_query_nodeinfo_handler()
1282 qn->qn_domain); in dlm_query_nodeinfo_handler()
1285 dlm = __dlm_lookup_domain_full(qn->qn_domain, qn->qn_namelen); in dlm_query_nodeinfo_handler()
1287 mlog(ML_ERROR, "Node %d queried nodes on domain %s before " in dlm_query_nodeinfo_handler()
1288 "join domain\n", qn->qn_nodenum, qn->qn_domain); in dlm_query_nodeinfo_handler()
1292 spin_lock(&dlm->spinlock); in dlm_query_nodeinfo_handler()
1293 if (dlm->joining_node != qn->qn_nodenum) { in dlm_query_nodeinfo_handler()
1294 mlog(ML_ERROR, "Node %d queried nodes on domain %s but " in dlm_query_nodeinfo_handler()
1295 "joining node is %d\n", qn->qn_nodenum, qn->qn_domain, in dlm_query_nodeinfo_handler()
1296 dlm->joining_node); in dlm_query_nodeinfo_handler()
1300 /* Support for node query was added in 1.1 */ in dlm_query_nodeinfo_handler()
1301 if (dlm->dlm_locking_proto.pv_major == 1 && in dlm_query_nodeinfo_handler()
1302 dlm->dlm_locking_proto.pv_minor == 0) { in dlm_query_nodeinfo_handler()
1303 mlog(ML_ERROR, "Node %d queried nodes on domain %s " in dlm_query_nodeinfo_handler()
1304 "but active dlm protocol is %d.%d\n", qn->qn_nodenum, in dlm_query_nodeinfo_handler()
1305 qn->qn_domain, dlm->dlm_locking_proto.pv_major, in dlm_query_nodeinfo_handler()
1306 dlm->dlm_locking_proto.pv_minor); in dlm_query_nodeinfo_handler()
1313 spin_unlock(&dlm->spinlock); in dlm_query_nodeinfo_handler()
1326 cancel = (struct dlm_cancel_join *) msg->buf; in dlm_cancel_join_handler()
1328 mlog(0, "node %u cancels join on domain %s\n", cancel->node_idx, in dlm_cancel_join_handler()
1329 cancel->domain); in dlm_cancel_join_handler()
1332 dlm = __dlm_lookup_domain_full(cancel->domain, cancel->name_len); in dlm_cancel_join_handler()
1335 spin_lock(&dlm->spinlock); in dlm_cancel_join_handler()
1339 BUG_ON(dlm->joining_node != cancel->node_idx); in dlm_cancel_join_handler()
1342 spin_unlock(&dlm->spinlock); in dlm_cancel_join_handler()
1350 unsigned int node) in dlm_send_one_join_cancel() argument
1356 cancel_msg.node_idx = dlm->node_num; in dlm_send_one_join_cancel()
1357 cancel_msg.name_len = strlen(dlm->name); in dlm_send_one_join_cancel()
1358 memcpy(cancel_msg.domain, dlm->name, cancel_msg.name_len); in dlm_send_one_join_cancel()
1361 &cancel_msg, sizeof(cancel_msg), node, in dlm_send_one_join_cancel()
1365 "node %u\n", status, DLM_CANCEL_JOIN_MSG, DLM_MOD_KEY, in dlm_send_one_join_cancel()
1366 node); in dlm_send_one_join_cancel()
1380 int node; in dlm_send_join_cancels() local
1387 return -EINVAL; in dlm_send_join_cancels()
1391 node = -1; in dlm_send_join_cancels()
1392 while ((node = find_next_bit(node_map, O2NM_MAX_NODES, in dlm_send_join_cancels()
1393 node + 1)) < O2NM_MAX_NODES) { in dlm_send_join_cancels()
1394 if (node == dlm->node_num) in dlm_send_join_cancels()
1397 tmpstat = dlm_send_one_join_cancel(dlm, node); in dlm_send_join_cancels()
1400 "node %d\n", tmpstat, node); in dlm_send_join_cancels()
1412 int node, in dlm_request_join() argument
1420 mlog(0, "querying node %d\n", node); in dlm_request_join()
1423 join_msg.node_idx = dlm->node_num; in dlm_request_join()
1424 join_msg.name_len = strlen(dlm->name); in dlm_request_join()
1425 memcpy(join_msg.domain, dlm->name, join_msg.name_len); in dlm_request_join()
1426 join_msg.dlm_proto = dlm->dlm_locking_proto; in dlm_request_join()
1427 join_msg.fs_proto = dlm->fs_locking_proto; in dlm_request_join()
1429 /* copy live node map to join message */ in dlm_request_join()
1430 byte_copymap(join_msg.node_map, dlm->live_nodes_map, O2NM_MAX_NODES); in dlm_request_join()
1433 sizeof(join_msg), node, &join_resp); in dlm_request_join()
1434 if (status < 0 && status != -ENOPROTOOPT) { in dlm_request_join()
1436 "node %u\n", status, DLM_QUERY_JOIN_MSG, DLM_MOD_KEY, in dlm_request_join()
1437 node); in dlm_request_join()
1442 /* -ENOPROTOOPT from the net code means the other side isn't in dlm_request_join()
1443 listening for our message type -- that's fine, it means in dlm_request_join()
1446 if (status == -ENOPROTOOPT) { in dlm_request_join()
1457 "This node requested DLM locking protocol %u.%u and " in dlm_request_join()
1458 "filesystem locking protocol %u.%u. At least one of " in dlm_request_join()
1459 "the protocol versions on node %d is not compatible, " in dlm_request_join()
1461 dlm->dlm_locking_proto.pv_major, in dlm_request_join()
1462 dlm->dlm_locking_proto.pv_minor, in dlm_request_join()
1463 dlm->fs_locking_proto.pv_major, in dlm_request_join()
1464 dlm->fs_locking_proto.pv_minor, in dlm_request_join()
1465 node); in dlm_request_join()
1466 status = -EPROTO; in dlm_request_join()
1469 /* Use the same locking protocol as the remote node */ in dlm_request_join()
1470 dlm->dlm_locking_proto.pv_minor = packet.dlm_minor; in dlm_request_join()
1471 dlm->fs_locking_proto.pv_minor = packet.fs_minor; in dlm_request_join()
1473 "Node %d responds JOIN_OK with DLM locking protocol " in dlm_request_join()
1474 "%u.%u and fs locking protocol %u.%u\n", in dlm_request_join()
1475 node, in dlm_request_join()
1476 dlm->dlm_locking_proto.pv_major, in dlm_request_join()
1477 dlm->dlm_locking_proto.pv_minor, in dlm_request_join()
1478 dlm->fs_locking_proto.pv_major, in dlm_request_join()
1479 dlm->fs_locking_proto.pv_minor); in dlm_request_join()
1482 status = -EINVAL; in dlm_request_join()
1483 mlog(ML_ERROR, "invalid response %d from node %u\n", in dlm_request_join()
1484 packet.code, node); in dlm_request_join()
1491 mlog(0, "status %d, node %d response is %d\n", status, node, in dlm_request_join()
1499 unsigned int node) in dlm_send_one_join_assert() argument
1505 mlog(0, "Sending join assert to node %u\n", node); in dlm_send_one_join_assert()
1508 assert_msg.node_idx = dlm->node_num; in dlm_send_one_join_assert()
1509 assert_msg.name_len = strlen(dlm->name); in dlm_send_one_join_assert()
1510 memcpy(assert_msg.domain, dlm->name, assert_msg.name_len); in dlm_send_one_join_assert()
1513 &assert_msg, sizeof(assert_msg), node, in dlm_send_one_join_assert()
1517 "node %u\n", status, DLM_ASSERT_JOINED_MSG, DLM_MOD_KEY, in dlm_send_one_join_assert()
1518 node); in dlm_send_one_join_assert()
1528 int status, node, live; in dlm_send_join_asserts() local
1530 node = -1; in dlm_send_join_asserts()
1531 while ((node = find_next_bit(node_map, O2NM_MAX_NODES, in dlm_send_join_asserts()
1532 node + 1)) < O2NM_MAX_NODES) { in dlm_send_join_asserts()
1533 if (node == dlm->node_num) in dlm_send_join_asserts()
1538 * received so we spin until either the node in dlm_send_join_asserts()
1540 status = dlm_send_one_join_assert(dlm, node); in dlm_send_join_asserts()
1542 spin_lock(&dlm->spinlock); in dlm_send_join_asserts()
1543 live = test_bit(node, dlm->live_nodes_map); in dlm_send_join_asserts()
1544 spin_unlock(&dlm->spinlock); in dlm_send_join_asserts()
1548 "join on node %d\n", status, node); in dlm_send_join_asserts()
1570 mlog(0, "Latest response of disallow -- should restart\n"); in dlm_should_restart_join()
1574 spin_lock(&dlm->spinlock); in dlm_should_restart_join()
1575 /* For now, we restart the process if the node maps have in dlm_should_restart_join()
1577 ret = !bitmap_equal(ctxt->live_map, dlm->live_nodes_map, in dlm_should_restart_join()
1579 spin_unlock(&dlm->spinlock); in dlm_should_restart_join()
1582 mlog(0, "Node maps changed -- should restart\n"); in dlm_should_restart_join()
1589 int status = 0, tmpstat, node; in dlm_try_to_join_domain() local
1597 status = -ENOMEM; in dlm_try_to_join_domain()
1602 /* group sem locking should work for us here -- we're already in dlm_try_to_join_domain()
1605 o2hb_fill_node_map(dlm->live_nodes_map, O2NM_MAX_NODES); in dlm_try_to_join_domain()
1607 spin_lock(&dlm->spinlock); in dlm_try_to_join_domain()
1608 bitmap_copy(ctxt->live_map, dlm->live_nodes_map, O2NM_MAX_NODES); in dlm_try_to_join_domain()
1609 __dlm_set_joining_node(dlm, dlm->node_num); in dlm_try_to_join_domain()
1610 spin_unlock(&dlm->spinlock); in dlm_try_to_join_domain()
1612 node = -1; in dlm_try_to_join_domain()
1613 while ((node = find_next_bit(ctxt->live_map, O2NM_MAX_NODES, in dlm_try_to_join_domain()
1614 node + 1)) < O2NM_MAX_NODES) { in dlm_try_to_join_domain()
1615 if (node == dlm->node_num) in dlm_try_to_join_domain()
1618 status = dlm_request_join(dlm, node, &response); in dlm_try_to_join_domain()
1624 /* Ok, either we got a response or the node doesn't have a in dlm_try_to_join_domain()
1627 set_bit(node, ctxt->yes_resp_map); in dlm_try_to_join_domain()
1630 status = -EAGAIN; in dlm_try_to_join_domain()
1641 spin_lock(&dlm->spinlock); in dlm_try_to_join_domain()
1642 bitmap_copy(dlm->domain_map, ctxt->yes_resp_map, O2NM_MAX_NODES); in dlm_try_to_join_domain()
1643 set_bit(dlm->node_num, dlm->domain_map); in dlm_try_to_join_domain()
1644 spin_unlock(&dlm->spinlock); in dlm_try_to_join_domain()
1646 /* Support for global heartbeat and node info was added in 1.1 */ in dlm_try_to_join_domain()
1647 if (dlm->dlm_locking_proto.pv_major > 1 || in dlm_try_to_join_domain()
1648 dlm->dlm_locking_proto.pv_minor > 0) { in dlm_try_to_join_domain()
1649 status = dlm_send_nodeinfo(dlm, ctxt->yes_resp_map); in dlm_try_to_join_domain()
1654 status = dlm_send_regions(dlm, ctxt->yes_resp_map); in dlm_try_to_join_domain()
1661 dlm_send_join_asserts(dlm, ctxt->yes_resp_map); in dlm_try_to_join_domain()
1663 /* Joined state *must* be set before the joining node in dlm_try_to_join_domain()
1668 dlm->dlm_state = DLM_CTXT_JOINED; in dlm_try_to_join_domain()
1669 dlm->num_joins++; in dlm_try_to_join_domain()
1673 spin_lock(&dlm->spinlock); in dlm_try_to_join_domain()
1676 printk(KERN_NOTICE "o2dlm: Joining domain %s ", dlm->name); in dlm_try_to_join_domain()
1679 spin_unlock(&dlm->spinlock); in dlm_try_to_join_domain()
1685 ctxt->yes_resp_map, in dlm_try_to_join_domain()
1686 sizeof(ctxt->yes_resp_map)); in dlm_try_to_join_domain()
1699 o2hb_unregister_callback(dlm->name, &dlm->dlm_hb_up); in dlm_unregister_domain_handlers()
1700 o2hb_unregister_callback(dlm->name, &dlm->dlm_hb_down); in dlm_unregister_domain_handlers()
1701 o2net_unregister_handler_list(&dlm->dlm_domain_handlers); in dlm_unregister_domain_handlers()
1710 o2hb_setup_callback(&dlm->dlm_hb_down, O2HB_NODE_DOWN_CB, in dlm_register_domain_handlers()
1712 o2hb_setup_callback(&dlm->dlm_hb_up, O2HB_NODE_UP_CB, in dlm_register_domain_handlers()
1715 status = o2hb_register_callback(dlm->name, &dlm->dlm_hb_down); in dlm_register_domain_handlers()
1719 status = o2hb_register_callback(dlm->name, &dlm->dlm_hb_up); in dlm_register_domain_handlers()
1723 status = o2net_register_handler(DLM_MASTER_REQUEST_MSG, dlm->key, in dlm_register_domain_handlers()
1726 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1730 status = o2net_register_handler(DLM_ASSERT_MASTER_MSG, dlm->key, in dlm_register_domain_handlers()
1734 &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1738 status = o2net_register_handler(DLM_CREATE_LOCK_MSG, dlm->key, in dlm_register_domain_handlers()
1741 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1745 status = o2net_register_handler(DLM_CONVERT_LOCK_MSG, dlm->key, in dlm_register_domain_handlers()
1748 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1752 status = o2net_register_handler(DLM_UNLOCK_LOCK_MSG, dlm->key, in dlm_register_domain_handlers()
1755 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1759 status = o2net_register_handler(DLM_PROXY_AST_MSG, dlm->key, in dlm_register_domain_handlers()
1762 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1766 status = o2net_register_handler(DLM_EXIT_DOMAIN_MSG, dlm->key, in dlm_register_domain_handlers()
1769 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1773 status = o2net_register_handler(DLM_DEREF_LOCKRES_MSG, dlm->key, in dlm_register_domain_handlers()
1776 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1780 status = o2net_register_handler(DLM_MIGRATE_REQUEST_MSG, dlm->key, in dlm_register_domain_handlers()
1783 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1787 status = o2net_register_handler(DLM_MIG_LOCKRES_MSG, dlm->key, in dlm_register_domain_handlers()
1790 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1794 status = o2net_register_handler(DLM_MASTER_REQUERY_MSG, dlm->key, in dlm_register_domain_handlers()
1797 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1801 status = o2net_register_handler(DLM_LOCK_REQUEST_MSG, dlm->key, in dlm_register_domain_handlers()
1804 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1808 status = o2net_register_handler(DLM_RECO_DATA_DONE_MSG, dlm->key, in dlm_register_domain_handlers()
1811 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1815 status = o2net_register_handler(DLM_BEGIN_RECO_MSG, dlm->key, in dlm_register_domain_handlers()
1818 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1822 status = o2net_register_handler(DLM_FINALIZE_RECO_MSG, dlm->key, in dlm_register_domain_handlers()
1825 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1829 status = o2net_register_handler(DLM_BEGIN_EXIT_DOMAIN_MSG, dlm->key, in dlm_register_domain_handlers()
1832 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1836 status = o2net_register_handler(DLM_DEREF_LOCKRES_DONE, dlm->key, in dlm_register_domain_handlers()
1839 dlm, NULL, &dlm->dlm_domain_handlers); in dlm_register_domain_handlers()
1856 mlog(0, "Join domain %s\n", dlm->name); in dlm_join_domain()
1878 snprintf(wq_name, O2NM_MAX_NAME_LEN, "dlm_wq-%s", dlm->name); in dlm_join_domain()
1879 dlm->dlm_worker = alloc_workqueue(wq_name, WQ_MEM_RECLAIM, 0); in dlm_join_domain()
1880 if (!dlm->dlm_worker) { in dlm_join_domain()
1881 status = -ENOMEM; in dlm_join_domain()
1889 /* If we're racing another node to the join, then we in dlm_join_domain()
1893 if (status == -EAGAIN) { in dlm_join_domain()
1895 status = -ERESTARTSYS; in dlm_join_domain()
1900 status = -ERESTARTSYS; in dlm_join_domain()
1902 "%s after %u msecs\n", dlm->name, in dlm_join_domain()
1920 } while (status == -EAGAIN); in dlm_join_domain()
1950 ret = -ENOMEM; in dlm_alloc_ctxt()
1955 dlm->name = kstrdup(domain, GFP_KERNEL); in dlm_alloc_ctxt()
1956 if (dlm->name == NULL) { in dlm_alloc_ctxt()
1957 ret = -ENOMEM; in dlm_alloc_ctxt()
1962 dlm->lockres_hash = (struct hlist_head **)dlm_alloc_pagevec(DLM_HASH_PAGES); in dlm_alloc_ctxt()
1963 if (!dlm->lockres_hash) { in dlm_alloc_ctxt()
1964 ret = -ENOMEM; in dlm_alloc_ctxt()
1972 dlm->master_hash = (struct hlist_head **) in dlm_alloc_ctxt()
1974 if (!dlm->master_hash) { in dlm_alloc_ctxt()
1975 ret = -ENOMEM; in dlm_alloc_ctxt()
1983 dlm->key = key; in dlm_alloc_ctxt()
1984 dlm->node_num = o2nm_this_node(); in dlm_alloc_ctxt()
1988 spin_lock_init(&dlm->spinlock); in dlm_alloc_ctxt()
1989 spin_lock_init(&dlm->master_lock); in dlm_alloc_ctxt()
1990 spin_lock_init(&dlm->ast_lock); in dlm_alloc_ctxt()
1991 spin_lock_init(&dlm->track_lock); in dlm_alloc_ctxt()
1992 INIT_LIST_HEAD(&dlm->list); in dlm_alloc_ctxt()
1993 INIT_LIST_HEAD(&dlm->dirty_list); in dlm_alloc_ctxt()
1994 INIT_LIST_HEAD(&dlm->reco.resources); in dlm_alloc_ctxt()
1995 INIT_LIST_HEAD(&dlm->reco.node_data); in dlm_alloc_ctxt()
1996 INIT_LIST_HEAD(&dlm->purge_list); in dlm_alloc_ctxt()
1997 INIT_LIST_HEAD(&dlm->dlm_domain_handlers); in dlm_alloc_ctxt()
1998 INIT_LIST_HEAD(&dlm->tracking_list); in dlm_alloc_ctxt()
1999 dlm->reco.state = 0; in dlm_alloc_ctxt()
2001 INIT_LIST_HEAD(&dlm->pending_asts); in dlm_alloc_ctxt()
2002 INIT_LIST_HEAD(&dlm->pending_basts); in dlm_alloc_ctxt()
2004 mlog(0, "dlm->recovery_map=%p, &(dlm->recovery_map[0])=%p\n", in dlm_alloc_ctxt()
2005 dlm->recovery_map, &(dlm->recovery_map[0])); in dlm_alloc_ctxt()
2007 bitmap_zero(dlm->recovery_map, O2NM_MAX_NODES); in dlm_alloc_ctxt()
2008 bitmap_zero(dlm->live_nodes_map, O2NM_MAX_NODES); in dlm_alloc_ctxt()
2009 bitmap_zero(dlm->domain_map, O2NM_MAX_NODES); in dlm_alloc_ctxt()
2011 dlm->dlm_thread_task = NULL; in dlm_alloc_ctxt()
2012 dlm->dlm_reco_thread_task = NULL; in dlm_alloc_ctxt()
2013 dlm->dlm_worker = NULL; in dlm_alloc_ctxt()
2014 init_waitqueue_head(&dlm->dlm_thread_wq); in dlm_alloc_ctxt()
2015 init_waitqueue_head(&dlm->dlm_reco_thread_wq); in dlm_alloc_ctxt()
2016 init_waitqueue_head(&dlm->reco.event); in dlm_alloc_ctxt()
2017 init_waitqueue_head(&dlm->ast_wq); in dlm_alloc_ctxt()
2018 init_waitqueue_head(&dlm->migration_wq); in dlm_alloc_ctxt()
2019 INIT_LIST_HEAD(&dlm->mle_hb_events); in dlm_alloc_ctxt()
2021 dlm->joining_node = DLM_LOCK_RES_OWNER_UNKNOWN; in dlm_alloc_ctxt()
2022 init_waitqueue_head(&dlm->dlm_join_events); in dlm_alloc_ctxt()
2024 dlm->migrate_done = 0; in dlm_alloc_ctxt()
2026 dlm->reco.new_master = O2NM_INVALID_NODE_NUM; in dlm_alloc_ctxt()
2027 dlm->reco.dead_node = O2NM_INVALID_NODE_NUM; in dlm_alloc_ctxt()
2029 atomic_set(&dlm->res_tot_count, 0); in dlm_alloc_ctxt()
2030 atomic_set(&dlm->res_cur_count, 0); in dlm_alloc_ctxt()
2032 atomic_set(&dlm->mle_tot_count[i], 0); in dlm_alloc_ctxt()
2033 atomic_set(&dlm->mle_cur_count[i], 0); in dlm_alloc_ctxt()
2036 spin_lock_init(&dlm->work_lock); in dlm_alloc_ctxt()
2037 INIT_LIST_HEAD(&dlm->work_list); in dlm_alloc_ctxt()
2038 INIT_WORK(&dlm->dispatched_work, dlm_dispatch_work); in dlm_alloc_ctxt()
2040 kref_init(&dlm->dlm_refs); in dlm_alloc_ctxt()
2041 dlm->dlm_state = DLM_CTXT_NEW; in dlm_alloc_ctxt()
2043 INIT_LIST_HEAD(&dlm->dlm_eviction_callbacks); in dlm_alloc_ctxt()
2046 kref_read(&dlm->dlm_refs)); in dlm_alloc_ctxt()
2051 if (dlm->master_hash) in dlm_alloc_ctxt()
2052 dlm_free_pagevec((void **)dlm->master_hash, in dlm_alloc_ctxt()
2055 if (dlm->lockres_hash) in dlm_alloc_ctxt()
2056 dlm_free_pagevec((void **)dlm->lockres_hash, in dlm_alloc_ctxt()
2059 kfree(dlm->name); in dlm_alloc_ctxt()
2067 * Compare a requested locking protocol version against the current one.
2077 if (existing->pv_major != request->pv_major) in dlm_protocol_compare()
2080 if (existing->pv_minor > request->pv_minor) in dlm_protocol_compare()
2083 if (existing->pv_minor < request->pv_minor) in dlm_protocol_compare()
2084 request->pv_minor = existing->pv_minor; in dlm_protocol_compare()
2090 * dlm_register_domain: one-time setup per "domain".
2094 * locking protocol.
2105 ret = -ENAMETOOLONG; in dlm_register_domain()
2115 ret = -ERESTARTSYS; in dlm_register_domain()
2124 if (dlm->dlm_state != DLM_CTXT_JOINED) { in dlm_register_domain()
2134 if (dlm_protocol_compare(&dlm->fs_locking_proto, fs_proto)) { in dlm_register_domain()
2137 "Requested locking protocol version is not " in dlm_register_domain()
2140 ret = -EPROTO; in dlm_register_domain()
2145 dlm->num_joins++; in dlm_register_domain()
2161 ret = -ENOMEM; in dlm_register_domain()
2166 /* a little variable switch-a-roo here... */ in dlm_register_domain()
2171 list_add_tail(&dlm->list, &dlm_domains); in dlm_register_domain()
2175 * Pass the locking protocol version into the join. If the join in dlm_register_domain()
2176 * succeeds, it will have the negotiated protocol set. in dlm_register_domain()
2178 dlm->dlm_locking_proto = dlm_protocol; in dlm_register_domain()
2179 dlm->fs_locking_proto = *fs_proto; in dlm_register_domain()
2188 /* Tell the caller what locking protocol we negotiated */ in dlm_register_domain()
2189 *fs_proto = dlm->fs_locking_proto; in dlm_register_domain()
2256 * The file system requires notification of node death *before* the
2259 * evict a node from it's domain *before* heartbeat fires, a similar
2262 /* Eviction is not expected to happen often, so a per-domain lock is
2273 list_for_each_entry(cb, &dlm->dlm_eviction_callbacks, ec_item) { in dlm_fire_domain_eviction_callbacks()
2274 cb->ec_func(node_num, cb->ec_data); in dlm_fire_domain_eviction_callbacks()
2283 INIT_LIST_HEAD(&cb->ec_item); in dlm_setup_eviction_cb()
2284 cb->ec_func = f; in dlm_setup_eviction_cb()
2285 cb->ec_data = data; in dlm_setup_eviction_cb()
2293 list_add_tail(&cb->ec_item, &dlm->dlm_eviction_callbacks); in dlm_register_eviction_cb()
2301 list_del_init(&cb->ec_item); in dlm_unregister_eviction_cb()
2343 return -1; in dlm_init()