41 #include <sys/types.h> 42 #include <sys/socket.h> 44 #include <sys/ioctl.h> 45 #include <netinet/in.h> 54 #include <arpa/inet.h> 59 #include <qb/qbipc_common.h> 69 #define MAP_ANONYMOUS MAP_ANON 76 #define GROUP_HASH_SIZE 32 142 static struct list_head joinlist_messages_head;
171 static unsigned int my_member_list_entries;
175 static unsigned int my_old_member_list_entries = 0;
201 static int cpg_lib_init_fn (
void *conn);
203 static int cpg_lib_exit_fn (
void *conn);
205 static void message_handler_req_exec_cpg_procjoin (
209 static void message_handler_req_exec_cpg_procleave (
213 static void message_handler_req_exec_cpg_joinlist (
217 static void message_handler_req_exec_cpg_mcast (
221 static void message_handler_req_exec_cpg_partial_mcast (
225 static void message_handler_req_exec_cpg_downlist_old (
229 static void message_handler_req_exec_cpg_downlist (
233 static void exec_cpg_procjoin_endian_convert (
void *msg);
235 static void exec_cpg_joinlist_endian_convert (
void *msg);
237 static void exec_cpg_mcast_endian_convert (
void *msg);
239 static void exec_cpg_partial_mcast_endian_convert (
void *msg);
241 static void exec_cpg_downlist_endian_convert_old (
void *msg);
243 static void exec_cpg_downlist_endian_convert (
void *msg);
245 static void message_handler_req_lib_cpg_join (
void *conn,
const void *message);
247 static void message_handler_req_lib_cpg_leave (
void *conn,
const void *message);
249 static void message_handler_req_lib_cpg_finalize (
void *conn,
const void *message);
251 static void message_handler_req_lib_cpg_mcast (
void *conn,
const void *message);
253 static void message_handler_req_lib_cpg_partial_mcast (
void *conn,
const void *message);
255 static void message_handler_req_lib_cpg_membership (
void *conn,
256 const void *message);
258 static void message_handler_req_lib_cpg_local_get (
void *conn,
259 const void *message);
261 static void message_handler_req_lib_cpg_iteration_initialize (
263 const void *message);
265 static void message_handler_req_lib_cpg_iteration_next (
267 const void *message);
269 static void message_handler_req_lib_cpg_iteration_finalize (
271 const void *message);
273 static void message_handler_req_lib_cpg_zc_alloc (
275 const void *message);
277 static void message_handler_req_lib_cpg_zc_free (
279 const void *message);
281 static void message_handler_req_lib_cpg_zc_execute (
283 const void *message);
285 static int cpg_node_joinleave_send (
unsigned int pid,
const mar_cpg_name_t *group_name,
int fn,
int reason);
287 static int cpg_exec_send_downlist(
void);
289 static int cpg_exec_send_joinlist(
void);
291 static void downlist_inform_clients (
void);
293 static void joinlist_inform_clients (
void);
295 static void joinlist_messages_delete (
void);
297 static void cpg_sync_init (
298 const unsigned int *trans_list,
299 size_t trans_list_entries,
300 const unsigned int *member_list,
301 size_t member_list_entries,
304 static int cpg_sync_process (
void);
306 static void cpg_sync_activate (
void);
308 static void cpg_sync_abort (
void);
310 static void do_proc_join(
316 static void do_proc_leave(
322 static int notify_lib_totem_membership (
324 int member_list_entries,
325 const unsigned int *member_list);
327 static inline int zcb_all_free (
330 static char *cpg_print_group_name (
343 .lib_handler_fn = message_handler_req_lib_cpg_leave,
347 .lib_handler_fn = message_handler_req_lib_cpg_mcast,
351 .lib_handler_fn = message_handler_req_lib_cpg_membership,
355 .lib_handler_fn = message_handler_req_lib_cpg_local_get,
359 .lib_handler_fn = message_handler_req_lib_cpg_iteration_initialize,
363 .lib_handler_fn = message_handler_req_lib_cpg_iteration_next,
367 .lib_handler_fn = message_handler_req_lib_cpg_iteration_finalize,
371 .lib_handler_fn = message_handler_req_lib_cpg_finalize,
375 .lib_handler_fn = message_handler_req_lib_cpg_zc_alloc,
379 .lib_handler_fn = message_handler_req_lib_cpg_zc_free,
383 .lib_handler_fn = message_handler_req_lib_cpg_zc_execute,
387 .lib_handler_fn = message_handler_req_lib_cpg_partial_mcast,
397 .exec_endian_convert_fn = exec_cpg_procjoin_endian_convert
400 .exec_handler_fn = message_handler_req_exec_cpg_procleave,
401 .exec_endian_convert_fn = exec_cpg_procjoin_endian_convert
404 .exec_handler_fn = message_handler_req_exec_cpg_joinlist,
405 .exec_endian_convert_fn = exec_cpg_joinlist_endian_convert
408 .exec_handler_fn = message_handler_req_exec_cpg_mcast,
409 .exec_endian_convert_fn = exec_cpg_mcast_endian_convert
412 .exec_handler_fn = message_handler_req_exec_cpg_downlist_old,
413 .exec_endian_convert_fn = exec_cpg_downlist_endian_convert_old
416 .exec_handler_fn = message_handler_req_exec_cpg_downlist,
417 .exec_endian_convert_fn = exec_cpg_downlist_endian_convert
420 .exec_handler_fn = message_handler_req_exec_cpg_partial_mcast,
421 .exec_endian_convert_fn = exec_cpg_partial_mcast_endian_convert
426 .
name =
"corosync cluster closed process group service v1.01",
429 .private_data_size =
sizeof (
struct cpg_pd),
432 .lib_init_fn = cpg_lib_init_fn,
433 .lib_exit_fn = cpg_lib_exit_fn,
434 .lib_engine = cpg_lib_engine,
436 .exec_init_fn = cpg_exec_init_fn,
437 .exec_dump_fn = NULL,
438 .exec_engine = cpg_exec_engine,
440 .sync_init = cpg_sync_init,
441 .sync_process = cpg_sync_process,
442 .sync_activate = cpg_sync_activate,
443 .sync_abort = cpg_sync_abort
448 return (&cpg_service_engine);
452 struct qb_ipc_request_header header __attribute__((aligned(8)));
459 struct qb_ipc_request_header header __attribute__((aligned(8)));
468 struct qb_ipc_request_header header __attribute__((aligned(8)));
479 struct qb_ipc_request_header header __attribute__((aligned(8)));
485 struct qb_ipc_request_header header __attribute__((aligned(8)));
512 for (i = 0; i < group->length; i++) {
515 if (c >=
' ' && c < 0x7f && c !=
'\\') {
519 res[dest_pos++] =
'\\';
520 res[dest_pos++] =
'\\';
522 snprintf(res + dest_pos,
sizeof(res) - dest_pos,
"\\x%02X", c);
532 static void cpg_sync_init (
533 const unsigned int *trans_list,
534 size_t trans_list_entries,
535 const unsigned int *member_list,
536 size_t member_list_entries,
545 memcpy (my_member_list, member_list, member_list_entries *
546 sizeof (
unsigned int));
547 my_member_list_entries = member_list_entries;
549 last_sync_ring_id.nodeid = ring_id->
rep.
nodeid;
550 last_sync_ring_id.seq = ring_id->
seq;
556 for (i = 0; i < my_old_member_list_entries; i++) {
558 for (j = 0; j < trans_list_entries; j++) {
559 if (my_old_member_list[i] == trans_list[j]) {
565 g_req_exec_cpg_downlist.nodeids[entries++] =
566 my_old_member_list[i];
569 g_req_exec_cpg_downlist.left_nodes = entries;
572 static int cpg_sync_process (
void)
577 res = cpg_exec_send_downlist();
584 res = cpg_exec_send_joinlist();
589 static void cpg_sync_activate (
void)
591 memcpy (my_old_member_list, my_member_list,
592 my_member_list_entries *
sizeof (
unsigned int));
593 my_old_member_list_entries = my_member_list_entries;
595 downlist_inform_clients ();
597 joinlist_inform_clients ();
599 joinlist_messages_delete ();
601 notify_lib_totem_membership (NULL, my_member_list_entries, my_member_list);
604 static void cpg_sync_abort (
void)
607 joinlist_messages_delete ();
610 static int notify_lib_totem_membership (
612 int member_list_entries,
613 const unsigned int *member_list)
627 res->member_list_entries = member_list_entries;
628 res->header.size =
size;
630 res->header.error =
CS_OK;
636 for (iter = cpg_pd_list_head.
next; iter != &cpg_pd_list_head; iter = iter->
next) {
647 static int notify_lib_joinlist(
650 int joined_list_entries,
652 int left_list_entries,
665 for (iter = process_info_list_head.
next; iter != &process_info_list_head; iter = iter->
next) {
667 if (mar_name_compare (&pi->
group, group_name) == 0) {
671 for (i = 0; i < left_list_entries; i++) {
672 if (left_list[i].
nodeid == pi->
nodeid && left_list[i].pid == pi->
pid) {
689 res->joined_list_entries = joined_list_entries;
690 res->left_list_entries = left_list_entries;
691 res->member_list_entries = count;
693 res->header.size =
size;
695 res->header.error =
CS_OK;
698 for (iter = process_info_list_head.
next; iter != &process_info_list_head; iter = iter->
next) {
701 if (mar_name_compare (&pi->
group, group_name) == 0) {
705 for (i = 0;i < left_list_entries; i++) {
706 if (left_list[i].
nodeid == pi->
nodeid && left_list[i].pid == pi->
pid) {
712 retgi->nodeid = pi->
nodeid;
713 retgi->pid = pi->
pid;
719 if (left_list_entries) {
721 retgi += left_list_entries;
724 if (joined_list_entries) {
726 retgi += joined_list_entries;
732 for (iter = cpg_pd_list_head.
next; iter != &cpg_pd_list_head; iter = iter->
next) {
734 if (mar_name_compare (&cpd->
group_name, group_name) == 0) {
735 assert (joined_list_entries <= 1);
736 if (joined_list_entries) {
737 if (joined_list[0].
pid == cpd->
pid &&
748 if (left_list_entries) {
749 if (left_list[0].
pid == cpd->
pid &&
766 for (iter = cpg_pd_list_head.
next; iter != &cpg_pd_list_head; iter = iter->
next) {
772 notify_lib_totem_membership (cpd->
conn, my_old_member_list_entries, my_old_member_list);
782 "%s: members(old:%d left:%d)",
788 static void downlist_inform_clients (
void)
798 int left_list_entries;
801 qb_map_iter_t *miter;
804 downlist_log(
"my downlist", &g_req_exec_cpg_downlist);
806 group_map = qb_skiplist_create();
813 for (iter = process_info_list_head.
next; iter != &process_info_list_head; ) {
818 for (i = 0; i < g_req_exec_cpg_downlist.left_nodes; i++) {
820 if (pi->
nodeid == g_req_exec_cpg_downlist.nodeids[i]) {
827 marshall_from_mar_cpg_name_t(&cpg_group, &left_pi->
group);
828 cpg_group.value[cpg_group.length] = 0;
830 pcd = (
struct confchg_data *)qb_map_get(group_map, cpg_group.value);
832 pcd = (
struct confchg_data *)calloc(1,
sizeof(
struct confchg_data));
833 memcpy(&pcd->cpg_group, &cpg_group,
sizeof(
struct cpg_name));
834 qb_map_put(group_map, pcd->cpg_group.value, pcd);
836 size = pcd->left_list_entries;
837 pcd->left_list[
size].nodeid = left_pi->
nodeid;
838 pcd->left_list[
size].pid = left_pi->
pid;
840 pcd->left_list_entries++;
841 list_del (&left_pi->
list);
847 miter = qb_map_iter_create(group_map);
848 while (qb_map_iter_next(miter, (
void **)&pcd)) {
849 marshall_to_mar_cpg_name_t(&group, &pcd->cpg_group);
851 log_printf (LOG_DEBUG,
"left_list_entries:%d", pcd->left_list_entries);
852 for (i=0; i<pcd->left_list_entries; i++) {
853 log_printf (LOG_DEBUG,
"left_list[%d] group:%s, ip:%s, pid:%d",
854 i, cpg_print_group_name(&group),
856 pcd->left_list[i].pid);
860 notify_lib_joinlist(&group, NULL,
862 pcd->left_list_entries,
868 qb_map_iter_free(miter);
869 qb_map_destroy(group_map);
875 static void joinlist_remove_zombie_pi_entries (
void)
883 for (pi_iter = process_info_list_head.
next; pi_iter != &process_info_list_head; ) {
885 pi_iter = pi_iter->
next;
898 for (jl_iter = joinlist_messages_head.
next;
899 jl_iter != &joinlist_messages_head;
900 jl_iter = jl_iter->
next) {
909 pi->
pid == stored_msg->
pid &&
922 static void joinlist_inform_clients (
void)
929 for (iter = joinlist_messages_head.
next;
930 iter != &joinlist_messages_head;
935 log_printf (LOG_DEBUG,
"joinlist_messages[%u] group:%s, ip:%s, pid:%d",
936 i++, cpg_print_group_name(&stored_msg->
group_name),
949 joinlist_remove_zombie_pi_entries ();
952 static void joinlist_messages_delete (
void)
957 for (iter = joinlist_messages_head.
next;
958 iter != &joinlist_messages_head;
961 iter_next = iter->
next;
964 list_del (&stored_msg->
list);
967 list_init (&joinlist_messages_head);
972 list_init (&joinlist_messages_head);
986 iter_next = iter->
next;
989 list_del (&pi->
list);
993 list_del (&cpg_iteration_instance->
list);
994 hdb_handle_destroy (&cpg_iteration_handle_t_db, cpg_iteration_instance->
handle);
997 static void cpg_pd_finalize (
struct cpg_pd *cpd)
1000 struct cpg_iteration_instance *cpii;
1007 iter_next = iter->
next;
1009 cpii =
list_entry (iter,
struct cpg_iteration_instance, list);
1011 cpg_iteration_instance_finalize (cpii);
1014 list_del (&cpd->
list);
1017 static int cpg_lib_exit_fn (
void *conn)
1028 cpg_pd_finalize (cpd);
1034 static int cpg_node_joinleave_send (
unsigned int pid,
const mar_cpg_name_t *group_name,
int fn,
int reason)
1037 struct iovec req_exec_cpg_iovec;
1056 static void exec_cpg_procjoin_endian_convert (
void *msg)
1060 req_exec_cpg_procjoin->pid =
swab32(req_exec_cpg_procjoin->pid);
1061 swab_mar_cpg_name_t (&req_exec_cpg_procjoin->group_name);
1062 req_exec_cpg_procjoin->reason =
swab32(req_exec_cpg_procjoin->reason);
1065 static void exec_cpg_joinlist_endian_convert (
void *msg_v)
1068 struct qb_ipc_response_header *res = (
struct qb_ipc_response_header *)msg;
1071 swab_mar_int32_t (&res->size);
1073 while ((
const char*)jle < msg + res->size) {
1080 static void exec_cpg_downlist_endian_convert_old (
void *msg)
1084 static void exec_cpg_downlist_endian_convert (
void *msg)
1089 req_exec_cpg_downlist->left_nodes =
swab32(req_exec_cpg_downlist->left_nodes);
1090 req_exec_cpg_downlist->old_members =
swab32(req_exec_cpg_downlist->old_members);
1092 for (i = 0; i < req_exec_cpg_downlist->left_nodes; i++) {
1093 req_exec_cpg_downlist->nodeids[i] =
swab32(req_exec_cpg_downlist->nodeids[i]);
1098 static void exec_cpg_mcast_endian_convert (
void *msg)
1102 swab_coroipc_request_header_t (&req_exec_cpg_mcast->header);
1103 swab_mar_cpg_name_t (&req_exec_cpg_mcast->group_name);
1104 req_exec_cpg_mcast->pid =
swab32(req_exec_cpg_mcast->pid);
1105 req_exec_cpg_mcast->msglen =
swab32(req_exec_cpg_mcast->msglen);
1106 swab_mar_message_source_t (&req_exec_cpg_mcast->source);
1109 static void exec_cpg_partial_mcast_endian_convert (
void *msg)
1113 swab_coroipc_request_header_t (&req_exec_cpg_mcast->header);
1114 swab_mar_cpg_name_t (&req_exec_cpg_mcast->group_name);
1115 req_exec_cpg_mcast->pid =
swab32(req_exec_cpg_mcast->pid);
1116 req_exec_cpg_mcast->msglen =
swab32(req_exec_cpg_mcast->msglen);
1117 req_exec_cpg_mcast->fraglen =
swab32(req_exec_cpg_mcast->fraglen);
1118 req_exec_cpg_mcast->type =
swab32(req_exec_cpg_mcast->type);
1119 swab_mar_message_source_t (&req_exec_cpg_mcast->source);
1125 for (iter = process_info_list_head.
next; iter != &process_info_list_head; ) {
1129 if (pi->
pid == pid && pi->
nodeid == nodeid &&
1130 mar_name_compare (&pi->
group, group_name) == 0) {
1138 static void do_proc_join(
1141 unsigned int nodeid,
1150 if (process_info_find (name, pid, nodeid) != NULL) {
1160 memcpy(&pi->
group, name,
sizeof(*name));
1161 list_init(&pi->
list);
1166 list_to_add = &process_info_list_head;
1167 for (list = process_info_list_head.
next; list != &process_info_list_head; list = list->
next) {
1177 list_add (&pi->
list, list_to_add);
1179 notify_info.pid = pi->
pid;
1180 notify_info.nodeid =
nodeid;
1181 notify_info.reason = reason;
1183 notify_lib_joinlist(&pi->
group, NULL,
1189 static void do_proc_leave(
1192 unsigned int nodeid,
1199 notify_info.pid = pid;
1200 notify_info.nodeid =
nodeid;
1201 notify_info.reason = reason;
1203 notify_lib_joinlist(name, NULL,
1208 for (iter = process_info_list_head.
next; iter != &process_info_list_head; ) {
1212 if (pi->
pid == pid && pi->
nodeid == nodeid &&
1213 mar_name_compare (&pi->
group, name)==0) {
1214 list_del (&pi->
list);
1220 static void message_handler_req_exec_cpg_downlist_old (
1221 const void *message,
1222 unsigned int nodeid)
1228 static void message_handler_req_exec_cpg_downlist(
1229 const void *message,
1230 unsigned int nodeid)
1232 const struct req_exec_cpg_downlist *req_exec_cpg_downlist = message;
1235 req_exec_cpg_downlist->left_nodes);
1239 static void message_handler_req_exec_cpg_procjoin (
1240 const void *message,
1241 unsigned int nodeid)
1248 (
unsigned int)req_exec_cpg_procjoin->pid);
1250 do_proc_join (&req_exec_cpg_procjoin->group_name,
1251 req_exec_cpg_procjoin->pid, nodeid,
1255 static void message_handler_req_exec_cpg_procleave (
1256 const void *message,
1257 unsigned int nodeid)
1264 (
unsigned int)req_exec_cpg_procjoin->pid);
1266 do_proc_leave (&req_exec_cpg_procjoin->group_name,
1267 req_exec_cpg_procjoin->pid, nodeid,
1268 req_exec_cpg_procjoin->reason);
1273 static void message_handler_req_exec_cpg_joinlist (
1274 const void *message_v,
1275 unsigned int nodeid)
1277 const char *message = message_v;
1278 const struct qb_ipc_response_header *res = (
const struct qb_ipc_response_header *)message;
1285 while ((
const char*)jle < message + res->size) {
1289 stored_msg->
pid = jle->
pid;
1291 list_init (&stored_msg->
list);
1292 list_add (&stored_msg->
list, &joinlist_messages_head);
1297 static void message_handler_req_exec_cpg_mcast (
1298 const void *message,
1299 unsigned int nodeid)
1303 int msglen = req_exec_cpg_mcast->msglen;
1306 struct iovec iovec[2];
1320 iovec[1].iov_base = (
char*)message+
sizeof(*req_exec_cpg_mcast);
1321 iovec[1].iov_len = msglen;
1323 for (iter = cpg_pd_list_head.
next; iter != &cpg_pd_list_head; ) {
1328 && (mar_name_compare (&cpd->
group_name, &req_exec_cpg_mcast->group_name) == 0)) {
1332 for (pi_iter = process_info_list_head.
next;
1333 pi_iter != &process_info_list_head; pi_iter = pi_iter->
next) {
1337 if (pi->
nodeid == nodeid &&
1338 mar_name_compare (&pi->
group, &req_exec_cpg_mcast->group_name) == 0) {
1355 static void message_handler_req_exec_cpg_partial_mcast (
1356 const void *message,
1357 unsigned int nodeid)
1361 int msglen = req_exec_cpg_mcast->fraglen;
1364 struct iovec iovec[2];
1382 iovec[1].iov_base = (
char*)message+
sizeof(*req_exec_cpg_mcast);
1383 iovec[1].iov_len = msglen;
1385 for (iter = cpg_pd_list_head.
next; iter != &cpg_pd_list_head; ) {
1390 && (mar_name_compare (&cpd->
group_name, &req_exec_cpg_mcast->group_name) == 0)) {
1394 for (pi_iter = process_info_list_head.
next;
1395 pi_iter != &process_info_list_head; pi_iter = pi_iter->
next) {
1399 if (pi->
nodeid == nodeid &&
1400 mar_name_compare (&pi->
group, &req_exec_cpg_mcast->group_name) == 0) {
1418 static int cpg_exec_send_downlist(
void)
1423 g_req_exec_cpg_downlist.header.size =
sizeof(
struct req_exec_cpg_downlist);
1425 g_req_exec_cpg_downlist.old_members = my_old_member_list_entries;
1427 iov.iov_base = (
void *)&g_req_exec_cpg_downlist;
1428 iov.iov_len = g_req_exec_cpg_downlist.header.size;
1433 static int cpg_exec_send_joinlist(
void)
1437 struct qb_ipc_response_header *res;
1440 struct iovec req_exec_cpg_iovec;
1442 for (iter = process_info_list_head.
next; iter != &process_info_list_head; iter = iter->
next) {
1454 buf = alloca(
sizeof(
struct qb_ipc_response_header) +
sizeof(
struct join_list_entry) * count);
1460 jle = (
struct join_list_entry *)(buf +
sizeof(
struct qb_ipc_response_header));
1461 res = (
struct qb_ipc_response_header *)buf;
1463 for (iter = process_info_list_head.
next; iter != &process_info_list_head; iter = iter->
next) {
1474 res->size =
sizeof(
struct qb_ipc_response_header)+sizeof(struct
join_list_entry) * count;
1476 req_exec_cpg_iovec.iov_base = buf;
1477 req_exec_cpg_iovec.iov_len = res->size;
1482 static int cpg_lib_init_fn (
void *conn)
1485 memset (cpd, 0,
sizeof(
struct cpg_pd));
1487 list_add (&cpd->
list, &cpg_pd_list_head);
1498 static void message_handler_req_lib_cpg_join (
void *conn,
const void *message)
1507 for (iter = cpg_pd_list_head.
next; iter != &cpg_pd_list_head; iter = iter->
next) {
1510 if (cpd_item->
pid == req_lib_cpg_join->pid &&
1511 mar_name_compare(&req_lib_cpg_join->group_name, &cpd_item->
group_name) == 0) {
1523 for (iter = process_info_list_head.
next; iter != &process_info_list_head; iter = iter->
next) {
1527 mar_name_compare(&req_lib_cpg_join->group_name, &pi->
group) == 0) {
1543 cpd->
pid = req_lib_cpg_join->pid;
1544 cpd->
flags = req_lib_cpg_join->flags;
1545 memcpy (&cpd->
group_name, &req_lib_cpg_join->group_name,
1548 cpg_node_joinleave_send (req_lib_cpg_join->pid,
1549 &req_lib_cpg_join->group_name,
1571 static void message_handler_req_lib_cpg_leave (
void *conn,
const void *message)
1593 cpg_node_joinleave_send (req_lib_cpg_leave->pid,
1594 &req_lib_cpg_leave->group_name,
1608 static void message_handler_req_lib_cpg_finalize (
1610 const void *message)
1622 list_del (&cpd->
list);
1623 list_init (&cpd->
list);
1643 fd = open (path, O_RDWR, 0600);
1651 res = ftruncate (fd, bytes);
1653 goto error_close_unlink;
1656 addr = mmap (NULL, bytes, PROT_READ | PROT_WRITE,
1659 if (addr == MAP_FAILED) {
1660 goto error_close_unlink;
1663 madvise(addr, bytes, MADV_NOSYNC);
1668 munmap (addr, bytes);
1680 static inline int zcb_alloc (
1682 const char *path_to_file,
1689 zcb_mapped = malloc (
sizeof (
struct zcb_mapped));
1690 if (zcb_mapped == NULL) {
1703 list_init (&zcb_mapped->
list);
1711 static inline int zcb_free (
struct zcb_mapped *zcb_mapped)
1715 res = munmap (zcb_mapped->
addr, zcb_mapped->
size);
1716 list_del (&zcb_mapped->
list);
1721 static inline int zcb_by_addr_free (
struct cpg_pd *cpd,
void *addr)
1724 struct zcb_mapped *zcb_mapped;
1725 unsigned int res = 0;
1730 zcb_mapped =
list_entry (list,
struct zcb_mapped, list);
1732 if (zcb_mapped->
addr == addr) {
1733 res = zcb_free (zcb_mapped);
1741 static inline int zcb_all_free (
1745 struct zcb_mapped *zcb_mapped;
1750 zcb_mapped =
list_entry (list,
struct zcb_mapped, list);
1754 zcb_free (zcb_mapped);
1764 static uint64_t void2serveraddr (
void *server_ptr)
1772 static void *serveraddr2void (uint64_t
server_addr)
1780 static void message_handler_req_lib_cpg_zc_alloc (
1782 const void *message)
1785 struct qb_ipc_response_header res_header;
1793 res = zcb_alloc (cpd, hdr->path_to_file, hdr->map_size,
1800 res_header.size =
sizeof (
struct qb_ipc_response_header);
1807 static void message_handler_req_lib_cpg_zc_free (
1809 const void *message)
1812 struct qb_ipc_response_header res_header;
1818 addr = serveraddr2void (hdr->server_address);
1820 zcb_by_addr_free (cpd, addr);
1822 res_header.size =
sizeof (
struct qb_ipc_response_header);
1830 static void message_handler_req_lib_cpg_partial_mcast (
void *conn,
const void *message)
1836 struct iovec req_exec_cpg_iovec[2];
1839 int msglen = req_lib_cpg_mcast->fraglen;
1861 res_lib_cpg_partial_send.header.size =
sizeof(res_lib_cpg_partial_send);
1871 if (error ==
CS_OK) {
1872 req_exec_cpg_mcast.header.size =
sizeof(req_exec_cpg_mcast) + msglen;
1875 req_exec_cpg_mcast.pid = cpd->
pid;
1876 req_exec_cpg_mcast.msglen = req_lib_cpg_mcast->msglen;
1877 req_exec_cpg_mcast.type = req_lib_cpg_mcast->type;
1878 req_exec_cpg_mcast.fraglen = req_lib_cpg_mcast->fraglen;
1880 memcpy(&req_exec_cpg_mcast.group_name, &group_name,
1883 req_exec_cpg_iovec[0].iov_base = (
char *)&req_exec_cpg_mcast;
1884 req_exec_cpg_iovec[0].iov_len =
sizeof(req_exec_cpg_mcast);
1885 req_exec_cpg_iovec[1].iov_base = (
char *)&req_lib_cpg_mcast->message;
1886 req_exec_cpg_iovec[1].iov_len = msglen;
1889 assert(result == 0);
1892 conn, group_name.value, cpd->
cpd_state, error);
1895 res_lib_cpg_partial_send.header.error = error;
1897 sizeof (res_lib_cpg_partial_send));
1901 static void message_handler_req_lib_cpg_mcast (
void *conn,
const void *message)
1907 struct iovec req_exec_cpg_iovec[2];
1908 struct req_exec_cpg_mcast req_exec_cpg_mcast;
1909 int msglen = req_lib_cpg_mcast->msglen;
1930 if (error ==
CS_OK) {
1931 req_exec_cpg_mcast.header.size =
sizeof(req_exec_cpg_mcast) + msglen;
1934 req_exec_cpg_mcast.pid = cpd->
pid;
1935 req_exec_cpg_mcast.msglen = msglen;
1937 memcpy(&req_exec_cpg_mcast.group_name, &group_name,
1940 req_exec_cpg_iovec[0].iov_base = (
char *)&req_exec_cpg_mcast;
1941 req_exec_cpg_iovec[0].iov_len =
sizeof(req_exec_cpg_mcast);
1942 req_exec_cpg_iovec[1].iov_base = (
char *)&req_lib_cpg_mcast->message;
1943 req_exec_cpg_iovec[1].iov_len = msglen;
1946 assert(result == 0);
1949 conn, group_name.value, cpd->
cpd_state, error);
1953 static void message_handler_req_lib_cpg_zc_execute (
1955 const void *message)
1958 struct qb_ipc_request_header *
header;
1961 struct iovec req_exec_cpg_iovec[2];
1962 struct req_exec_cpg_mcast req_exec_cpg_mcast;
1969 header = (
struct qb_ipc_request_header *)(((
char *)serveraddr2void(hdr->server_address) + sizeof (
struct coroipcs_zc_header)));
1970 req_lib_cpg_mcast = (
struct req_lib_cpg_mcast *)header;
1987 res_lib_cpg_mcast.header.size =
sizeof(res_lib_cpg_mcast);
1989 if (error ==
CS_OK) {
1990 req_exec_cpg_mcast.header.size =
sizeof(req_exec_cpg_mcast) + req_lib_cpg_mcast->msglen;
1993 req_exec_cpg_mcast.pid = cpd->
pid;
1994 req_exec_cpg_mcast.msglen = req_lib_cpg_mcast->msglen;
1996 memcpy(&req_exec_cpg_mcast.group_name, &cpd->
group_name,
1999 req_exec_cpg_iovec[0].iov_base = (
char *)&req_exec_cpg_mcast;
2000 req_exec_cpg_iovec[0].iov_len =
sizeof(req_exec_cpg_mcast);
2001 req_exec_cpg_iovec[1].iov_base = (
char *)header +
sizeof(
struct req_lib_cpg_mcast);
2002 req_exec_cpg_iovec[1].iov_len = req_exec_cpg_mcast.msglen;
2006 res_lib_cpg_mcast.header.error =
CS_OK;
2011 res_lib_cpg_mcast.header.error = error;
2015 sizeof (res_lib_cpg_mcast));
2019 static void message_handler_req_lib_cpg_membership (
void *conn,
2020 const void *message)
2023 (
struct req_lib_cpg_membership_get *)message;
2026 int member_count = 0;
2029 res_lib_cpg_membership_get.header.error =
CS_OK;
2030 res_lib_cpg_membership_get.header.size =
2031 sizeof (
struct res_lib_cpg_membership_get);
2033 for (iter = process_info_list_head.
next;
2034 iter != &process_info_list_head; iter = iter->
next) {
2037 if (mar_name_compare (&pi->
group, &req_lib_cpg_membership_get->group_name) == 0) {
2039 res_lib_cpg_membership_get.
member_list[member_count].pid = pi->
pid;
2043 res_lib_cpg_membership_get.member_count = member_count;
2046 sizeof (res_lib_cpg_membership_get));
2049 static void message_handler_req_lib_cpg_local_get (
void *conn,
2050 const void *message)
2054 res_lib_cpg_local_get.header.size =
sizeof (res_lib_cpg_local_get);
2056 res_lib_cpg_local_get.header.error =
CS_OK;
2060 sizeof (res_lib_cpg_local_get));
2063 static void message_handler_req_lib_cpg_iteration_initialize (
2065 const void *message)
2072 struct cpg_iteration_instance *cpg_iteration_instance;
2085 res = hdb_handle_create (&cpg_iteration_handle_t_db,
sizeof (
struct cpg_iteration_instance),
2086 &cpg_iteration_handle);
2093 res = hdb_handle_get (&cpg_iteration_handle_t_db, cpg_iteration_handle, (
void *)&cpg_iteration_instance);
2100 list_init (&cpg_iteration_instance->items_list_head);
2101 cpg_iteration_instance->handle = cpg_iteration_handle;
2106 for (iter = process_info_list_head.
next; iter != &process_info_list_head; iter = iter->
next) {
2116 for (iter2 = cpg_iteration_instance->items_list_head.
next;
2117 iter2 != &cpg_iteration_instance->items_list_head;
2118 iter2 = iter2->
next) {
2121 if (mar_name_compare (&pi2->
group, &pi->
group) == 0) {
2137 if (mar_name_compare (&pi->
group, &req_lib_cpg_iterationinitialize->group_name) != 0)
2150 goto error_put_destroy;
2154 list_init (&new_pi->
list);
2166 for (iter2 = cpg_iteration_instance->items_list_head.
next;
2167 iter2 != &cpg_iteration_instance->items_list_head;
2168 iter2 = iter2->
next) {
2171 if (mar_name_compare (&pi2->
group, &pi->
group) == 0) {
2176 list_add (&new_pi->
list, iter2);
2186 list_init (&cpg_iteration_instance->list);
2189 cpg_iteration_instance->current_pointer = &cpg_iteration_instance->items_list_head;
2192 hdb_handle_put (&cpg_iteration_handle_t_db, cpg_iteration_handle);
2194 if (error !=
CS_OK) {
2195 hdb_handle_destroy (&cpg_iteration_handle_t_db, cpg_iteration_handle);
2199 res_lib_cpg_iterationinitialize.header.size =
sizeof (res_lib_cpg_iterationinitialize);
2201 res_lib_cpg_iterationinitialize.header.error = error;
2202 res_lib_cpg_iterationinitialize.iteration_handle = cpg_iteration_handle;
2205 sizeof (res_lib_cpg_iterationinitialize));
2208 static void message_handler_req_lib_cpg_iteration_next (
2210 const void *message)
2214 struct cpg_iteration_instance *cpg_iteration_instance;
2221 res = hdb_handle_get (&cpg_iteration_handle_t_db,
2222 req_lib_cpg_iterationnext->iteration_handle,
2223 (
void *)&cpg_iteration_instance);
2230 assert (cpg_iteration_instance);
2232 cpg_iteration_instance->current_pointer = cpg_iteration_instance->current_pointer->next;
2234 if (cpg_iteration_instance->current_pointer == &cpg_iteration_instance->items_list_head) {
2244 res_lib_cpg_iterationnext.description.nodeid = pi->
nodeid;
2245 res_lib_cpg_iterationnext.description.pid = pi->
pid;
2246 memcpy (&res_lib_cpg_iterationnext.description.group,
2251 hdb_handle_put (&cpg_iteration_handle_t_db, req_lib_cpg_iterationnext->iteration_handle);
2253 res_lib_cpg_iterationnext.header.size =
sizeof (res_lib_cpg_iterationnext);
2255 res_lib_cpg_iterationnext.header.error = error;
2258 sizeof (res_lib_cpg_iterationnext));
2261 static void message_handler_req_lib_cpg_iteration_finalize (
2263 const void *message)
2267 struct cpg_iteration_instance *cpg_iteration_instance;
2273 res = hdb_handle_get (&cpg_iteration_handle_t_db,
2274 req_lib_cpg_iterationfinalize->iteration_handle,
2275 (
void *)&cpg_iteration_instance);
2282 assert (cpg_iteration_instance);
2284 cpg_iteration_instance_finalize (cpg_iteration_instance);
2285 hdb_handle_put (&cpg_iteration_handle_t_db, cpg_iteration_instance->handle);
2288 res_lib_cpg_iterationfinalize.header.size =
sizeof (res_lib_cpg_iterationfinalize);
2290 res_lib_cpg_iterationfinalize.header.error = error;
2293 sizeof (res_lib_cpg_iterationfinalize));
void *(* ipc_private_data_get)(void *conn)
int initial_totem_conf_sent
mar_cpg_address_t member_list[]
mar_req_coroipcc_zc_free_t struct
#define CPG_MAX_NAME_LENGTH
uint64_t initial_transition_counter
#define LOGSYS_LEVEL_TRACE
mar_uint32_t sender_nodeid
#define CPG_MODEL_V1_DELIVER_INITIAL_TOTEM_CONF
The req_lib_cpg_join struct.
mar_req_coroipcc_zc_alloc_t struct
The corosync_service_engine struct.
int(* ipc_dispatch_iov_send)(void *conn, const struct iovec *iov, unsigned int iov_len)
int(* ipc_response_send)(void *conn, const void *msg, size_t mlen)
struct corosync_service_engine * cpg_get_service_engine_ver0(void)
The res_lib_cpg_partial_deliver_callback struct.
The req_lib_cpg_mcast struct.
The corosync_lib_handler struct.
The res_lib_cpg_membership_get struct.
struct message_header header
struct list_head * current_pointer
The res_lib_cpg_iterationnext struct.
The res_lib_cpg_iterationinitialize struct.
The corosync_exec_handler struct.
int(* totem_mcast)(const struct iovec *iovec, unsigned int iov_len, unsigned int guarantee)
uint64_t transition_counter
#define log_printf(level, format, args...)
The res_lib_cpg_partial_send struct.
void(* exec_handler_fn)(const void *msg, unsigned int nodeid)
struct list_head iteration_instance_list_head
#define SERVICE_ID_MAKE(a, b)
The req_lib_cpg_iterationinitialize struct.
#define LOGSYS_LEVEL_WARNING
The res_lib_cpg_join struct.
unsigned int(* totem_nodeid_get)(void)
void(* ipc_refcnt_dec)(void *conn)
mar_req_coroipcc_zc_execute_t struct
The res_lib_cpg_mcast struct.
#define LOGSYS_LEVEL_ERROR
struct totem_ip_address rep
mar_uint32_t member_list[]
cs_error_t
The cs_error_t enum.
The req_lib_cpg_leave struct.
#define LOGSYS_LEVEL_DEBUG
mar_cpg_address_t member_list[PROCESSOR_COUNT_MAX]
mar_cpg_name_t group_name
The req_lib_cpg_iterationfinalize struct.
mar_cpg_name_t group_name
The corosync_api_v1 struct.
LOGSYS_DECLARE_SUBSYS("CPG")
DECLARE_HDB_DATABASE(cpg_iteration_handle_t_db, NULL)
#define swab32(x)
The swab32 macro.
The res_lib_cpg_finalize struct.
The res_lib_cpg_local_get struct.
#define PROCESSOR_COUNT_MAX
The res_lib_cpg_iterationfinalize struct.
struct corosync_service_engine cpg_service_engine
The req_lib_cpg_partial_mcast struct.
struct list_head zcb_mapped_list_head
The req_lib_cpg_iterationnext struct.
const char *(* totem_ifaces_print)(unsigned int nodeid)
The res_lib_cpg_confchg_callback struct.
#define list_entry(ptr, type, member)
mar_cpg_name_t group_name
void(* lib_handler_fn)(void *conn, const void *msg)
The req_lib_cpg_membership_get struct.
int(* ipc_dispatch_send)(void *conn, const void *msg, size_t mlen)
struct list_head items_list_head
The res_lib_cpg_leave struct.
struct memb_ring_id ring_id
void(* ipc_source_set)(mar_message_source_t *source, void *conn)
The res_lib_cpg_totem_confchg_callback struct.
DECLARE_LIST_INIT(cpg_pd_list_head)
Message from another node.
The mar_message_source_t struct.
void(* ipc_refcnt_inc)(void *conn)