|
|
@@ -55,12 +55,13 @@
|
|
|
#include <netinet/in.h>
|
|
|
#include <arpa/inet.h>
|
|
|
#include <sys/mman.h>
|
|
|
+
|
|
|
+#include <qb/qblist.h>
|
|
|
#include <qb/qbmap.h>
|
|
|
|
|
|
#include <corosync/corotypes.h>
|
|
|
#include <qb/qbipc_common.h>
|
|
|
#include <corosync/corodefs.h>
|
|
|
-#include <corosync/list.h>
|
|
|
#include <corosync/logsys.h>
|
|
|
#include <corosync/coroapi.h>
|
|
|
|
|
|
@@ -88,7 +89,7 @@ enum cpg_message_req_types {
|
|
|
};
|
|
|
|
|
|
struct zcb_mapped {
|
|
|
- struct list_head list;
|
|
|
+ struct qb_list_head list;
|
|
|
void *addr;
|
|
|
size_t size;
|
|
|
};
|
|
|
@@ -147,8 +148,8 @@ enum cpg_downlist_state_e {
|
|
|
CPG_DOWNLIST_APPLYING,
|
|
|
};
|
|
|
static enum cpg_downlist_state_e downlist_state;
|
|
|
-static struct list_head downlist_messages_head;
|
|
|
-static struct list_head joinlist_messages_head;
|
|
|
+static struct qb_list_head downlist_messages_head;
|
|
|
+static struct qb_list_head joinlist_messages_head;
|
|
|
|
|
|
struct cpg_pd {
|
|
|
void *conn;
|
|
|
@@ -159,21 +160,21 @@ struct cpg_pd {
|
|
|
int initial_totem_conf_sent;
|
|
|
uint64_t transition_counter; /* These two are used when sending fragmented messages */
|
|
|
uint64_t initial_transition_counter;
|
|
|
- struct list_head list;
|
|
|
- struct list_head iteration_instance_list_head;
|
|
|
- struct list_head zcb_mapped_list_head;
|
|
|
+ struct qb_list_head list;
|
|
|
+ struct qb_list_head iteration_instance_list_head;
|
|
|
+ struct qb_list_head zcb_mapped_list_head;
|
|
|
};
|
|
|
|
|
|
struct cpg_iteration_instance {
|
|
|
hdb_handle_t handle;
|
|
|
- struct list_head list;
|
|
|
- struct list_head items_list_head; /* List of process_info */
|
|
|
- struct list_head *current_pointer;
|
|
|
+ struct qb_list_head list;
|
|
|
+ struct qb_list_head items_list_head; /* List of process_info */
|
|
|
+ struct qb_list_head *current_pointer;
|
|
|
};
|
|
|
|
|
|
DECLARE_HDB_DATABASE(cpg_iteration_handle_t_db,NULL);
|
|
|
|
|
|
-DECLARE_LIST_INIT(cpg_pd_list_head);
|
|
|
+QB_LIST_DECLARE (cpg_pd_list_head);
|
|
|
|
|
|
static unsigned int my_member_list[PROCESSOR_COUNT_MAX];
|
|
|
|
|
|
@@ -193,9 +194,9 @@ struct process_info {
|
|
|
unsigned int nodeid;
|
|
|
uint32_t pid;
|
|
|
mar_cpg_name_t group;
|
|
|
- struct list_head list; /* on the group_info members list */
|
|
|
+ struct qb_list_head list; /* on the group_info members list */
|
|
|
};
|
|
|
-DECLARE_LIST_INIT(process_info_list_head);
|
|
|
+QB_LIST_DECLARE (process_info_list_head);
|
|
|
|
|
|
struct join_list_entry {
|
|
|
uint32_t pid;
|
|
|
@@ -506,14 +507,14 @@ struct downlist_msg {
|
|
|
mar_uint32_t old_members __attribute__((aligned(8)));
|
|
|
mar_uint32_t left_nodes __attribute__((aligned(8)));
|
|
|
mar_uint32_t nodeids[PROCESSOR_COUNT_MAX] __attribute__((aligned(8)));
|
|
|
- struct list_head list;
|
|
|
+ struct qb_list_head list;
|
|
|
};
|
|
|
|
|
|
struct joinlist_msg {
|
|
|
mar_uint32_t sender_nodeid;
|
|
|
uint32_t pid;
|
|
|
mar_cpg_name_t group_name;
|
|
|
- struct list_head list;
|
|
|
+ struct qb_list_head list;
|
|
|
};
|
|
|
|
|
|
static struct req_exec_cpg_downlist g_req_exec_cpg_downlist;
|
|
|
@@ -638,7 +639,7 @@ static int notify_lib_totem_membership (
|
|
|
int member_list_entries,
|
|
|
const unsigned int *member_list)
|
|
|
{
|
|
|
- struct list_head *iter;
|
|
|
+ struct qb_list_head *iter;
|
|
|
char *buf;
|
|
|
int size;
|
|
|
struct res_lib_cpg_totem_confchg_callback *res;
|
|
|
@@ -659,8 +660,8 @@ static int notify_lib_totem_membership (
|
|
|
memcpy (res->member_list, member_list, res->member_list_entries * sizeof (mar_uint32_t));
|
|
|
|
|
|
if (conn == NULL) {
|
|
|
- for (iter = cpg_pd_list_head.next; iter != &cpg_pd_list_head; iter = iter->next) {
|
|
|
- struct cpg_pd *cpg_pd = list_entry (iter, struct cpg_pd, list);
|
|
|
+ qb_list_for_each(iter, &cpg_pd_list_head) {
|
|
|
+ struct cpg_pd *cpg_pd = qb_list_entry (iter, struct cpg_pd, list);
|
|
|
api->ipc_dispatch_send (cpg_pd->conn, buf, size);
|
|
|
}
|
|
|
} else {
|
|
|
@@ -681,15 +682,15 @@ static int notify_lib_joinlist(
|
|
|
{
|
|
|
int size;
|
|
|
char *buf;
|
|
|
- struct list_head *iter;
|
|
|
+ struct qb_list_head *iter;
|
|
|
int count;
|
|
|
struct res_lib_cpg_confchg_callback *res;
|
|
|
mar_cpg_address_t *retgi;
|
|
|
|
|
|
count = 0;
|
|
|
|
|
|
- for (iter = process_info_list_head.next; iter != &process_info_list_head; iter = iter->next) {
|
|
|
- struct process_info *pi = list_entry (iter, struct process_info, list);
|
|
|
+ qb_list_for_each(iter, &process_info_list_head) {
|
|
|
+ struct process_info *pi = qb_list_entry (iter, struct process_info, list);
|
|
|
if (mar_name_compare (&pi->group, group_name) == 0) {
|
|
|
int i;
|
|
|
int founded = 0;
|
|
|
@@ -721,8 +722,8 @@ static int notify_lib_joinlist(
|
|
|
res->header.error = CS_OK;
|
|
|
memcpy(&res->group_name, group_name, sizeof(mar_cpg_name_t));
|
|
|
|
|
|
- for (iter = process_info_list_head.next; iter != &process_info_list_head; iter = iter->next) {
|
|
|
- struct process_info *pi=list_entry (iter, struct process_info, list);
|
|
|
+ qb_list_for_each(iter, &process_info_list_head) {
|
|
|
+ struct process_info *pi=qb_list_entry (iter, struct process_info, list);
|
|
|
|
|
|
if (mar_name_compare (&pi->group, group_name) == 0) {
|
|
|
int i;
|
|
|
@@ -755,8 +756,8 @@ static int notify_lib_joinlist(
|
|
|
if (conn) {
|
|
|
api->ipc_dispatch_send (conn, buf, size);
|
|
|
} else {
|
|
|
- for (iter = cpg_pd_list_head.next; iter != &cpg_pd_list_head; iter = iter->next) {
|
|
|
- struct cpg_pd *cpd = list_entry (iter, struct cpg_pd, list);
|
|
|
+ qb_list_for_each(iter, &cpg_pd_list_head) {
|
|
|
+ struct cpg_pd *cpd = qb_list_entry (iter, struct cpg_pd, list);
|
|
|
if (mar_name_compare (&cpd->group_name, group_name) == 0) {
|
|
|
assert (joined_list_entries <= 1);
|
|
|
if (joined_list_entries) {
|
|
|
@@ -789,8 +790,8 @@ static int notify_lib_joinlist(
|
|
|
/*
|
|
|
* Traverse thru cpds and send totem membership for cpd, where it is not send yet
|
|
|
*/
|
|
|
- for (iter = cpg_pd_list_head.next; iter != &cpg_pd_list_head; iter = iter->next) {
|
|
|
- struct cpg_pd *cpd = list_entry (iter, struct cpg_pd, list);
|
|
|
+ qb_list_for_each(iter, &cpg_pd_list_head) {
|
|
|
+ struct cpg_pd *cpd = qb_list_entry (iter, struct cpg_pd, list);
|
|
|
|
|
|
if ((cpd->flags & CPG_MODEL_V1_DELIVER_INITIAL_TOTEM_CONF) && (cpd->initial_totem_conf_sent == 0)) {
|
|
|
cpd->initial_totem_conf_sent = 1;
|
|
|
@@ -816,17 +817,14 @@ static struct downlist_msg* downlist_master_choose (void)
|
|
|
{
|
|
|
struct downlist_msg *cmp;
|
|
|
struct downlist_msg *best = NULL;
|
|
|
- struct list_head *iter;
|
|
|
+ struct qb_list_head *iter;
|
|
|
uint32_t cmp_members;
|
|
|
uint32_t best_members;
|
|
|
uint32_t i;
|
|
|
int ignore_msg;
|
|
|
|
|
|
- for (iter = downlist_messages_head.next;
|
|
|
- iter != &downlist_messages_head;
|
|
|
- iter = iter->next) {
|
|
|
-
|
|
|
- cmp = list_entry(iter, struct downlist_msg, list);
|
|
|
+ qb_list_for_each(iter, &downlist_messages_head) {
|
|
|
+ cmp = qb_list_entry(iter, struct downlist_msg, list);
|
|
|
downlist_log("comparing", cmp);
|
|
|
|
|
|
ignore_msg = 0;
|
|
|
@@ -872,7 +870,7 @@ static struct downlist_msg* downlist_master_choose (void)
|
|
|
static void downlist_master_choose_and_send (void)
|
|
|
{
|
|
|
struct downlist_msg *stored_msg;
|
|
|
- struct list_head *iter;
|
|
|
+ struct qb_list_head *iter;
|
|
|
struct process_info *left_pi;
|
|
|
qb_map_t *group_map;
|
|
|
struct cpg_name cpg_group;
|
|
|
@@ -881,7 +879,7 @@ static void downlist_master_choose_and_send (void)
|
|
|
struct cpg_name cpg_group;
|
|
|
mar_cpg_address_t left_list[CPG_MEMBERS_MAX];
|
|
|
int left_list_entries;
|
|
|
- struct list_head list;
|
|
|
+ struct qb_list_head list;
|
|
|
} *pcd;
|
|
|
qb_map_iter_t *miter;
|
|
|
int i, size;
|
|
|
@@ -902,9 +900,8 @@ static void downlist_master_choose_and_send (void)
|
|
|
* confchg event, so we will collect these cpg groups and
|
|
|
* relative left_lists here.
|
|
|
*/
|
|
|
- for (iter = process_info_list_head.next; iter != &process_info_list_head; ) {
|
|
|
- struct process_info *pi = list_entry(iter, struct process_info, list);
|
|
|
- iter = iter->next;
|
|
|
+ qb_list_for_each(iter, &process_info_list_head) {
|
|
|
+ struct process_info *pi = qb_list_entry(iter, struct process_info, list);
|
|
|
|
|
|
left_pi = NULL;
|
|
|
for (i = 0; i < stored_msg->left_nodes; i++) {
|
|
|
@@ -930,7 +927,7 @@ static void downlist_master_choose_and_send (void)
|
|
|
pcd->left_list[size].pid = left_pi->pid;
|
|
|
pcd->left_list[size].reason = CONFCHG_CPG_REASON_NODEDOWN;
|
|
|
pcd->left_list_entries++;
|
|
|
- list_del (&left_pi->list);
|
|
|
+ qb_list_del (&left_pi->list);
|
|
|
free (left_pi);
|
|
|
}
|
|
|
}
|
|
|
@@ -966,15 +963,14 @@ static void downlist_master_choose_and_send (void)
|
|
|
*/
|
|
|
static void joinlist_remove_zombie_pi_entries (void)
|
|
|
{
|
|
|
- struct list_head *pi_iter;
|
|
|
- struct list_head *jl_iter;
|
|
|
+ struct qb_list_head *pi_iter;
|
|
|
+ struct qb_list_head *jl_iter;
|
|
|
struct process_info *pi;
|
|
|
struct joinlist_msg *stored_msg;
|
|
|
int found;
|
|
|
|
|
|
- for (pi_iter = process_info_list_head.next; pi_iter != &process_info_list_head; ) {
|
|
|
- pi = list_entry (pi_iter, struct process_info, list);
|
|
|
- pi_iter = pi_iter->next;
|
|
|
+ qb_list_for_each(pi_iter, &process_info_list_head) {
|
|
|
+ pi = qb_list_entry (pi_iter, struct process_info, list);
|
|
|
|
|
|
/*
|
|
|
* Ignore local node
|
|
|
@@ -987,11 +983,8 @@ static void joinlist_remove_zombie_pi_entries (void)
|
|
|
* Try to find message in joinlist messages
|
|
|
*/
|
|
|
found = 0;
|
|
|
- for (jl_iter = joinlist_messages_head.next;
|
|
|
- jl_iter != &joinlist_messages_head;
|
|
|
- jl_iter = jl_iter->next) {
|
|
|
-
|
|
|
- stored_msg = list_entry(jl_iter, struct joinlist_msg, list);
|
|
|
+ qb_list_for_each(jl_iter, &joinlist_messages_head) {
|
|
|
+ stored_msg = qb_list_entry(jl_iter, struct joinlist_msg, list);
|
|
|
|
|
|
if (stored_msg->sender_nodeid == api->totem_nodeid_get()) {
|
|
|
continue ;
|
|
|
@@ -1014,15 +1007,12 @@ static void joinlist_remove_zombie_pi_entries (void)
|
|
|
static void joinlist_inform_clients (void)
|
|
|
{
|
|
|
struct joinlist_msg *stored_msg;
|
|
|
- struct list_head *iter;
|
|
|
+ struct qb_list_head *iter;
|
|
|
unsigned int i;
|
|
|
|
|
|
i = 0;
|
|
|
- for (iter = joinlist_messages_head.next;
|
|
|
- iter != &joinlist_messages_head;
|
|
|
- iter = iter->next) {
|
|
|
-
|
|
|
- stored_msg = list_entry(iter, struct joinlist_msg, list);
|
|
|
+ qb_list_for_each(iter, &joinlist_messages_head) {
|
|
|
+ stored_msg = qb_list_entry(iter, struct joinlist_msg, list);
|
|
|
|
|
|
log_printf (LOG_DEBUG, "joinlist_messages[%u] group:%s, ip:%s, pid:%d",
|
|
|
i++, cpg_print_group_name(&stored_msg->group_name),
|
|
|
@@ -1044,16 +1034,11 @@ static void joinlist_inform_clients (void)
|
|
|
static void downlist_messages_delete (void)
|
|
|
{
|
|
|
struct downlist_msg *stored_msg;
|
|
|
- struct list_head *iter, *iter_next;
|
|
|
-
|
|
|
- for (iter = downlist_messages_head.next;
|
|
|
- iter != &downlist_messages_head;
|
|
|
- iter = iter_next) {
|
|
|
-
|
|
|
- iter_next = iter->next;
|
|
|
+ struct qb_list_head *iter;
|
|
|
|
|
|
- stored_msg = list_entry(iter, struct downlist_msg, list);
|
|
|
- list_del (&stored_msg->list);
|
|
|
+ qb_list_for_each(iter, &downlist_messages_head) {
|
|
|
+ stored_msg = qb_list_entry(iter, struct downlist_msg, list);
|
|
|
+ qb_list_del (&stored_msg->list);
|
|
|
free (stored_msg);
|
|
|
}
|
|
|
}
|
|
|
@@ -1061,67 +1046,52 @@ static void downlist_messages_delete (void)
|
|
|
static void joinlist_messages_delete (void)
|
|
|
{
|
|
|
struct joinlist_msg *stored_msg;
|
|
|
- struct list_head *iter, *iter_next;
|
|
|
+ struct qb_list_head *iter;
|
|
|
|
|
|
- for (iter = joinlist_messages_head.next;
|
|
|
- iter != &joinlist_messages_head;
|
|
|
- iter = iter_next) {
|
|
|
-
|
|
|
- iter_next = iter->next;
|
|
|
-
|
|
|
- stored_msg = list_entry(iter, struct joinlist_msg, list);
|
|
|
- list_del (&stored_msg->list);
|
|
|
+ qb_list_for_each(iter, &joinlist_messages_head) {
|
|
|
+ stored_msg = qb_list_entry(iter, struct joinlist_msg, list);
|
|
|
+ qb_list_del (&stored_msg->list);
|
|
|
free (stored_msg);
|
|
|
}
|
|
|
- list_init (&joinlist_messages_head);
|
|
|
+ qb_list_init (&joinlist_messages_head);
|
|
|
}
|
|
|
|
|
|
static char *cpg_exec_init_fn (struct corosync_api_v1 *corosync_api)
|
|
|
{
|
|
|
- list_init (&downlist_messages_head);
|
|
|
- list_init (&joinlist_messages_head);
|
|
|
+ qb_list_init (&downlist_messages_head);
|
|
|
+ qb_list_init (&joinlist_messages_head);
|
|
|
api = corosync_api;
|
|
|
return (NULL);
|
|
|
}
|
|
|
|
|
|
static void cpg_iteration_instance_finalize (struct cpg_iteration_instance *cpg_iteration_instance)
|
|
|
{
|
|
|
- struct list_head *iter, *iter_next;
|
|
|
+ struct qb_list_head *iter;
|
|
|
struct process_info *pi;
|
|
|
|
|
|
- for (iter = cpg_iteration_instance->items_list_head.next;
|
|
|
- iter != &cpg_iteration_instance->items_list_head;
|
|
|
- iter = iter_next) {
|
|
|
-
|
|
|
- iter_next = iter->next;
|
|
|
-
|
|
|
- pi = list_entry (iter, struct process_info, list);
|
|
|
- list_del (&pi->list);
|
|
|
+ qb_list_for_each(iter, &(cpg_iteration_instance->items_list_head)) {
|
|
|
+ pi = qb_list_entry (iter, struct process_info, list);
|
|
|
+ qb_list_del (&pi->list);
|
|
|
free (pi);
|
|
|
}
|
|
|
|
|
|
- list_del (&cpg_iteration_instance->list);
|
|
|
+ qb_list_del (&cpg_iteration_instance->list);
|
|
|
hdb_handle_destroy (&cpg_iteration_handle_t_db, cpg_iteration_instance->handle);
|
|
|
}
|
|
|
|
|
|
static void cpg_pd_finalize (struct cpg_pd *cpd)
|
|
|
{
|
|
|
- struct list_head *iter, *iter_next;
|
|
|
+ struct qb_list_head *iter;
|
|
|
struct cpg_iteration_instance *cpii;
|
|
|
|
|
|
- zcb_all_free(cpd);
|
|
|
- for (iter = cpd->iteration_instance_list_head.next;
|
|
|
- iter != &cpd->iteration_instance_list_head;
|
|
|
- iter = iter_next) {
|
|
|
-
|
|
|
- iter_next = iter->next;
|
|
|
-
|
|
|
- cpii = list_entry (iter, struct cpg_iteration_instance, list);
|
|
|
+ zcb_all_free(cpd);
|
|
|
+ qb_list_for_each(iter, &(cpd->iteration_instance_list_head)) {
|
|
|
+ cpii = qb_list_entry (iter, struct cpg_iteration_instance, list);
|
|
|
|
|
|
cpg_iteration_instance_finalize (cpii);
|
|
|
}
|
|
|
|
|
|
- list_del (&cpd->list);
|
|
|
+ qb_list_del (&cpd->list);
|
|
|
}
|
|
|
|
|
|
static int cpg_lib_exit_fn (void *conn)
|
|
|
@@ -1230,12 +1200,10 @@ static void exec_cpg_partial_mcast_endian_convert (void *msg)
|
|
|
}
|
|
|
|
|
|
static struct process_info *process_info_find(const mar_cpg_name_t *group_name, uint32_t pid, unsigned int nodeid) {
|
|
|
- struct list_head *iter;
|
|
|
-
|
|
|
- for (iter = process_info_list_head.next; iter != &process_info_list_head; ) {
|
|
|
- struct process_info *pi = list_entry (iter, struct process_info, list);
|
|
|
- iter = iter->next;
|
|
|
+ struct qb_list_head *iter;
|
|
|
|
|
|
+ qb_list_for_each(iter, &process_info_list_head) {
|
|
|
+ struct process_info *pi = qb_list_entry (iter, struct process_info, list);
|
|
|
if (pi->pid == pid && pi->nodeid == nodeid &&
|
|
|
mar_name_compare (&pi->group, group_name) == 0) {
|
|
|
return pi;
|
|
|
@@ -1254,8 +1222,8 @@ static void do_proc_join(
|
|
|
struct process_info *pi;
|
|
|
struct process_info *pi_entry;
|
|
|
mar_cpg_address_t notify_info;
|
|
|
- struct list_head *list;
|
|
|
- struct list_head *list_to_add = NULL;
|
|
|
+ struct qb_list_head *list;
|
|
|
+ struct qb_list_head *list_to_add = NULL;
|
|
|
|
|
|
if (process_info_find (name, pid, nodeid) != NULL) {
|
|
|
return ;
|
|
|
@@ -1268,15 +1236,14 @@ static void do_proc_join(
|
|
|
pi->nodeid = nodeid;
|
|
|
pi->pid = pid;
|
|
|
memcpy(&pi->group, name, sizeof(*name));
|
|
|
- list_init(&pi->list);
|
|
|
+ qb_list_init(&pi->list);
|
|
|
|
|
|
/*
|
|
|
* Insert new process in sorted order so synchronization works properly
|
|
|
*/
|
|
|
list_to_add = &process_info_list_head;
|
|
|
- for (list = process_info_list_head.next; list != &process_info_list_head; list = list->next) {
|
|
|
-
|
|
|
- pi_entry = list_entry(list, struct process_info, list);
|
|
|
+ qb_list_for_each(list, &process_info_list_head) {
|
|
|
+ pi_entry = qb_list_entry(list, struct process_info, list);
|
|
|
if (pi_entry->nodeid > pi->nodeid ||
|
|
|
(pi_entry->nodeid == pi->nodeid && pi_entry->pid > pi->pid)) {
|
|
|
|
|
|
@@ -1284,7 +1251,7 @@ static void do_proc_join(
|
|
|
}
|
|
|
list_to_add = list;
|
|
|
}
|
|
|
- list_add (&pi->list, list_to_add);
|
|
|
+ qb_list_add (&pi->list, list_to_add);
|
|
|
|
|
|
notify_info.pid = pi->pid;
|
|
|
notify_info.nodeid = nodeid;
|
|
|
@@ -1303,7 +1270,7 @@ static void do_proc_leave(
|
|
|
int reason)
|
|
|
{
|
|
|
struct process_info *pi;
|
|
|
- struct list_head *iter;
|
|
|
+ struct qb_list_head *iter;
|
|
|
mar_cpg_address_t notify_info;
|
|
|
|
|
|
notify_info.pid = pid;
|
|
|
@@ -1315,13 +1282,13 @@ static void do_proc_leave(
|
|
|
1, ¬ify_info,
|
|
|
MESSAGE_RES_CPG_CONFCHG_CALLBACK);
|
|
|
|
|
|
- for (iter = process_info_list_head.next; iter != &process_info_list_head; ) {
|
|
|
- pi = list_entry(iter, struct process_info, list);
|
|
|
+ qb_list_for_each(iter, &process_info_list_head) {
|
|
|
+ pi = qb_list_entry(iter, struct process_info, list);
|
|
|
iter = iter->next;
|
|
|
|
|
|
if (pi->pid == pid && pi->nodeid == nodeid &&
|
|
|
mar_name_compare (&pi->group, name)==0) {
|
|
|
- list_del (&pi->list);
|
|
|
+ qb_list_del (&pi->list);
|
|
|
free (pi);
|
|
|
}
|
|
|
}
|
|
|
@@ -1341,7 +1308,7 @@ static void message_handler_req_exec_cpg_downlist(
|
|
|
{
|
|
|
const struct req_exec_cpg_downlist *req_exec_cpg_downlist = message;
|
|
|
int i;
|
|
|
- struct list_head *iter;
|
|
|
+ struct qb_list_head *iter;
|
|
|
struct downlist_msg *stored_msg;
|
|
|
int found;
|
|
|
|
|
|
@@ -1357,16 +1324,14 @@ static void message_handler_req_exec_cpg_downlist(
|
|
|
stored_msg->left_nodes = req_exec_cpg_downlist->left_nodes;
|
|
|
memcpy (stored_msg->nodeids, req_exec_cpg_downlist->nodeids,
|
|
|
req_exec_cpg_downlist->left_nodes * sizeof (mar_uint32_t));
|
|
|
- list_init (&stored_msg->list);
|
|
|
- list_add (&stored_msg->list, &downlist_messages_head);
|
|
|
+ qb_list_init (&stored_msg->list);
|
|
|
+ qb_list_add (&stored_msg->list, &downlist_messages_head);
|
|
|
|
|
|
for (i = 0; i < my_member_list_entries; i++) {
|
|
|
found = 0;
|
|
|
- for (iter = downlist_messages_head.next;
|
|
|
- iter != &downlist_messages_head;
|
|
|
- iter = iter->next) {
|
|
|
+ qb_list_for_each(iter, &downlist_messages_head) {
|
|
|
|
|
|
- stored_msg = list_entry(iter, struct downlist_msg, list);
|
|
|
+ stored_msg = qb_list_entry(iter, struct downlist_msg, list);
|
|
|
if (my_member_list[i] == stored_msg->sender_nodeid) {
|
|
|
found = 1;
|
|
|
}
|
|
|
@@ -1432,8 +1397,8 @@ static void message_handler_req_exec_cpg_joinlist (
|
|
|
stored_msg->sender_nodeid = nodeid;
|
|
|
stored_msg->pid = jle->pid;
|
|
|
memcpy(&stored_msg->group_name, &jle->group_name, sizeof(mar_cpg_name_t));
|
|
|
- list_init (&stored_msg->list);
|
|
|
- list_add (&stored_msg->list, &joinlist_messages_head);
|
|
|
+ qb_list_init (&stored_msg->list);
|
|
|
+ qb_list_add (&stored_msg->list, &joinlist_messages_head);
|
|
|
jle++;
|
|
|
}
|
|
|
}
|
|
|
@@ -1445,7 +1410,7 @@ static void message_handler_req_exec_cpg_mcast (
|
|
|
const struct req_exec_cpg_mcast *req_exec_cpg_mcast = message;
|
|
|
struct res_lib_cpg_deliver_callback res_lib_cpg_mcast;
|
|
|
int msglen = req_exec_cpg_mcast->msglen;
|
|
|
- struct list_head *iter, *pi_iter;
|
|
|
+ struct qb_list_head *iter, *pi_iter;
|
|
|
struct cpg_pd *cpd;
|
|
|
struct iovec iovec[2];
|
|
|
int known_node = 0;
|
|
|
@@ -1464,19 +1429,15 @@ static void message_handler_req_exec_cpg_mcast (
|
|
|
iovec[1].iov_base = (char*)message+sizeof(*req_exec_cpg_mcast);
|
|
|
iovec[1].iov_len = msglen;
|
|
|
|
|
|
- for (iter = cpg_pd_list_head.next; iter != &cpg_pd_list_head; ) {
|
|
|
- cpd = list_entry(iter, struct cpg_pd, list);
|
|
|
- iter = iter->next;
|
|
|
-
|
|
|
+ qb_list_for_each(iter, &cpg_pd_list_head) {
|
|
|
+ cpd = qb_list_entry(iter, struct cpg_pd, list);
|
|
|
if ((cpd->cpd_state == CPD_STATE_LEAVE_STARTED || cpd->cpd_state == CPD_STATE_JOIN_COMPLETED)
|
|
|
&& (mar_name_compare (&cpd->group_name, &req_exec_cpg_mcast->group_name) == 0)) {
|
|
|
|
|
|
if (!known_node) {
|
|
|
/* Try to find, if we know the node */
|
|
|
- for (pi_iter = process_info_list_head.next;
|
|
|
- pi_iter != &process_info_list_head; pi_iter = pi_iter->next) {
|
|
|
-
|
|
|
- struct process_info *pi = list_entry (pi_iter, struct process_info, list);
|
|
|
+ qb_list_for_each(pi_iter, &process_info_list_head) {
|
|
|
+ struct process_info *pi = qb_list_entry (pi_iter, struct process_info, list);
|
|
|
|
|
|
if (pi->nodeid == nodeid &&
|
|
|
mar_name_compare (&pi->group, &req_exec_cpg_mcast->group_name) == 0) {
|
|
|
@@ -1503,7 +1464,7 @@ static void message_handler_req_exec_cpg_partial_mcast (
|
|
|
const struct req_exec_cpg_partial_mcast *req_exec_cpg_mcast = message;
|
|
|
struct res_lib_cpg_partial_deliver_callback res_lib_cpg_mcast;
|
|
|
int msglen = req_exec_cpg_mcast->fraglen;
|
|
|
- struct list_head *iter, *pi_iter;
|
|
|
+ struct qb_list_head *iter, *pi_iter;
|
|
|
struct cpg_pd *cpd;
|
|
|
struct iovec iovec[2];
|
|
|
int known_node = 0;
|
|
|
@@ -1526,19 +1487,15 @@ static void message_handler_req_exec_cpg_partial_mcast (
|
|
|
iovec[1].iov_base = (char*)message+sizeof(*req_exec_cpg_mcast);
|
|
|
iovec[1].iov_len = msglen;
|
|
|
|
|
|
- for (iter = cpg_pd_list_head.next; iter != &cpg_pd_list_head; ) {
|
|
|
- cpd = list_entry(iter, struct cpg_pd, list);
|
|
|
- iter = iter->next;
|
|
|
-
|
|
|
+ qb_list_for_each(iter, &cpg_pd_list_head) {
|
|
|
+ cpd = qb_list_entry(iter, struct cpg_pd, list);
|
|
|
if ((cpd->cpd_state == CPD_STATE_LEAVE_STARTED || cpd->cpd_state == CPD_STATE_JOIN_COMPLETED)
|
|
|
&& (mar_name_compare (&cpd->group_name, &req_exec_cpg_mcast->group_name) == 0)) {
|
|
|
|
|
|
if (!known_node) {
|
|
|
/* Try to find, if we know the node */
|
|
|
- for (pi_iter = process_info_list_head.next;
|
|
|
- pi_iter != &process_info_list_head; pi_iter = pi_iter->next) {
|
|
|
-
|
|
|
- struct process_info *pi = list_entry (pi_iter, struct process_info, list);
|
|
|
+ qb_list_for_each(pi_iter, &process_info_list_head) {
|
|
|
+ struct process_info *pi = qb_list_entry (pi_iter, struct process_info, list);
|
|
|
|
|
|
if (pi->nodeid == nodeid &&
|
|
|
mar_name_compare (&pi->group, &req_exec_cpg_mcast->group_name) == 0) {
|
|
|
@@ -1577,14 +1534,14 @@ static int cpg_exec_send_downlist(void)
|
|
|
static int cpg_exec_send_joinlist(void)
|
|
|
{
|
|
|
int count = 0;
|
|
|
- struct list_head *iter;
|
|
|
+ struct qb_list_head *iter;
|
|
|
struct qb_ipc_response_header *res;
|
|
|
char *buf;
|
|
|
struct join_list_entry *jle;
|
|
|
struct iovec req_exec_cpg_iovec;
|
|
|
|
|
|
- for (iter = process_info_list_head.next; iter != &process_info_list_head; iter = iter->next) {
|
|
|
- struct process_info *pi = list_entry (iter, struct process_info, list);
|
|
|
+ qb_list_for_each(iter, &process_info_list_head) {
|
|
|
+ struct process_info *pi = qb_list_entry (iter, struct process_info, list);
|
|
|
|
|
|
if (pi->nodeid == api->totem_nodeid_get ()) {
|
|
|
count++;
|
|
|
@@ -1604,8 +1561,8 @@ static int cpg_exec_send_joinlist(void)
|
|
|
jle = (struct join_list_entry *)(buf + sizeof(struct qb_ipc_response_header));
|
|
|
res = (struct qb_ipc_response_header *)buf;
|
|
|
|
|
|
- for (iter = process_info_list_head.next; iter != &process_info_list_head; iter = iter->next) {
|
|
|
- struct process_info *pi = list_entry (iter, struct process_info, list);
|
|
|
+ qb_list_for_each(iter, &process_info_list_head) {
|
|
|
+ struct process_info *pi = qb_list_entry (iter, struct process_info, list);
|
|
|
|
|
|
if (pi->nodeid == api->totem_nodeid_get ()) {
|
|
|
memcpy (&jle->group_name, &pi->group, sizeof (mar_cpg_name_t));
|
|
|
@@ -1628,10 +1585,10 @@ static int cpg_lib_init_fn (void *conn)
|
|
|
struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
|
|
|
memset (cpd, 0, sizeof(struct cpg_pd));
|
|
|
cpd->conn = conn;
|
|
|
- list_add (&cpd->list, &cpg_pd_list_head);
|
|
|
+ qb_list_add (&cpd->list, &cpg_pd_list_head);
|
|
|
|
|
|
- list_init (&cpd->iteration_instance_list_head);
|
|
|
- list_init (&cpd->zcb_mapped_list_head);
|
|
|
+ qb_list_init (&cpd->iteration_instance_list_head);
|
|
|
+ qb_list_init (&cpd->zcb_mapped_list_head);
|
|
|
|
|
|
api->ipc_refcnt_inc (conn);
|
|
|
log_printf(LOGSYS_LEVEL_DEBUG, "lib_init_fn: conn=%p, cpd=%p", conn, cpd);
|
|
|
@@ -1645,11 +1602,11 @@ static void message_handler_req_lib_cpg_join (void *conn, const void *message)
|
|
|
struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
|
|
|
struct res_lib_cpg_join res_lib_cpg_join;
|
|
|
cs_error_t error = CS_OK;
|
|
|
- struct list_head *iter;
|
|
|
+ struct qb_list_head *iter;
|
|
|
|
|
|
/* Test, if we don't have same pid and group name joined */
|
|
|
- for (iter = cpg_pd_list_head.next; iter != &cpg_pd_list_head; iter = iter->next) {
|
|
|
- struct cpg_pd *cpd_item = list_entry (iter, struct cpg_pd, list);
|
|
|
+ qb_list_for_each(iter, &cpg_pd_list_head) {
|
|
|
+ struct cpg_pd *cpd_item = qb_list_entry (iter, struct cpg_pd, list);
|
|
|
|
|
|
if (cpd_item->pid == req_lib_cpg_join->pid &&
|
|
|
mar_name_compare(&req_lib_cpg_join->group_name, &cpd_item->group_name) == 0) {
|
|
|
@@ -1664,8 +1621,8 @@ static void message_handler_req_lib_cpg_join (void *conn, const void *message)
|
|
|
* Same check must be done in process info list, because there may be not yet delivered
|
|
|
* leave of client.
|
|
|
*/
|
|
|
- for (iter = process_info_list_head.next; iter != &process_info_list_head; iter = iter->next) {
|
|
|
- struct process_info *pi = list_entry (iter, struct process_info, list);
|
|
|
+ qb_list_for_each(iter, &process_info_list_head) {
|
|
|
+ struct process_info *pi = qb_list_entry (iter, struct process_info, list);
|
|
|
|
|
|
if (pi->nodeid == api->totem_nodeid_get () && pi->pid == req_lib_cpg_join->pid &&
|
|
|
mar_name_compare(&req_lib_cpg_join->group_name, &pi->group) == 0) {
|
|
|
@@ -1763,8 +1720,8 @@ static void message_handler_req_lib_cpg_finalize (
|
|
|
* We will just remove cpd from list. After this call, connection will be
|
|
|
* closed on lib side, and cpg_lib_exit_fn will be called
|
|
|
*/
|
|
|
- list_del (&cpd->list);
|
|
|
- list_init (&cpd->list);
|
|
|
+ qb_list_del (&cpd->list);
|
|
|
+ qb_list_init (&cpd->list);
|
|
|
|
|
|
res_lib_cpg_finalize.header.size = sizeof (res_lib_cpg_finalize);
|
|
|
res_lib_cpg_finalize.header.id = MESSAGE_RES_CPG_FINALIZE;
|
|
|
@@ -1844,10 +1801,10 @@ static inline int zcb_alloc (
|
|
|
return (-1);
|
|
|
}
|
|
|
|
|
|
- list_init (&zcb_mapped->list);
|
|
|
+ qb_list_init (&zcb_mapped->list);
|
|
|
zcb_mapped->addr = *addr;
|
|
|
zcb_mapped->size = size;
|
|
|
- list_add_tail (&zcb_mapped->list, &cpd->zcb_mapped_list_head);
|
|
|
+ qb_list_add_tail (&zcb_mapped->list, &cpd->zcb_mapped_list_head);
|
|
|
return (0);
|
|
|
}
|
|
|
|
|
|
@@ -1857,21 +1814,19 @@ static inline int zcb_free (struct zcb_mapped *zcb_mapped)
|
|
|
unsigned int res;
|
|
|
|
|
|
res = munmap (zcb_mapped->addr, zcb_mapped->size);
|
|
|
- list_del (&zcb_mapped->list);
|
|
|
+ qb_list_del (&zcb_mapped->list);
|
|
|
free (zcb_mapped);
|
|
|
return (res);
|
|
|
}
|
|
|
|
|
|
static inline int zcb_by_addr_free (struct cpg_pd *cpd, void *addr)
|
|
|
{
|
|
|
- struct list_head *list;
|
|
|
+ struct qb_list_head *list;
|
|
|
struct zcb_mapped *zcb_mapped;
|
|
|
unsigned int res = 0;
|
|
|
|
|
|
- for (list = cpd->zcb_mapped_list_head.next;
|
|
|
- list != &cpd->zcb_mapped_list_head; list = list->next) {
|
|
|
-
|
|
|
- zcb_mapped = list_entry (list, struct zcb_mapped, list);
|
|
|
+ qb_list_for_each(list, &(cpd->zcb_mapped_list_head)) {
|
|
|
+ zcb_mapped = qb_list_entry (list, struct zcb_mapped, list);
|
|
|
|
|
|
if (zcb_mapped->addr == addr) {
|
|
|
res = zcb_free (zcb_mapped);
|
|
|
@@ -1885,13 +1840,11 @@ static inline int zcb_by_addr_free (struct cpg_pd *cpd, void *addr)
|
|
|
static inline int zcb_all_free (
|
|
|
struct cpg_pd *cpd)
|
|
|
{
|
|
|
- struct list_head *list;
|
|
|
+ struct qb_list_head *list;
|
|
|
struct zcb_mapped *zcb_mapped;
|
|
|
|
|
|
- for (list = cpd->zcb_mapped_list_head.next;
|
|
|
- list != &cpd->zcb_mapped_list_head;) {
|
|
|
-
|
|
|
- zcb_mapped = list_entry (list, struct zcb_mapped, list);
|
|
|
+ qb_list_for_each(list, &(cpd->zcb_mapped_list_head)) {
|
|
|
+ zcb_mapped = qb_list_entry (list, struct zcb_mapped, list);
|
|
|
|
|
|
list = list->next;
|
|
|
|
|
|
@@ -2166,7 +2119,7 @@ static void message_handler_req_lib_cpg_membership (void *conn,
|
|
|
struct req_lib_cpg_membership_get *req_lib_cpg_membership_get =
|
|
|
(struct req_lib_cpg_membership_get *)message;
|
|
|
struct res_lib_cpg_membership_get res_lib_cpg_membership_get;
|
|
|
- struct list_head *iter;
|
|
|
+ struct qb_list_head *iter;
|
|
|
int member_count = 0;
|
|
|
|
|
|
res_lib_cpg_membership_get.header.id = MESSAGE_RES_CPG_MEMBERSHIP;
|
|
|
@@ -2174,10 +2127,8 @@ static void message_handler_req_lib_cpg_membership (void *conn,
|
|
|
res_lib_cpg_membership_get.header.size =
|
|
|
sizeof (struct res_lib_cpg_membership_get);
|
|
|
|
|
|
- for (iter = process_info_list_head.next;
|
|
|
- iter != &process_info_list_head; iter = iter->next) {
|
|
|
-
|
|
|
- struct process_info *pi = list_entry (iter, struct process_info, list);
|
|
|
+ qb_list_for_each(iter, &process_info_list_head) {
|
|
|
+ struct process_info *pi = qb_list_entry (iter, struct process_info, list);
|
|
|
if (mar_name_compare (&pi->group, &req_lib_cpg_membership_get->group_name) == 0) {
|
|
|
res_lib_cpg_membership_get.member_list[member_count].nodeid = pi->nodeid;
|
|
|
res_lib_cpg_membership_get.member_list[member_count].pid = pi->pid;
|
|
|
@@ -2212,7 +2163,7 @@ static void message_handler_req_lib_cpg_iteration_initialize (
|
|
|
struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
|
|
|
hdb_handle_t cpg_iteration_handle = 0;
|
|
|
struct res_lib_cpg_iterationinitialize res_lib_cpg_iterationinitialize;
|
|
|
- struct list_head *iter, *iter2;
|
|
|
+ struct qb_list_head *iter, *iter2;
|
|
|
struct cpg_iteration_instance *cpg_iteration_instance;
|
|
|
cs_error_t error = CS_OK;
|
|
|
int res;
|
|
|
@@ -2241,14 +2192,14 @@ static void message_handler_req_lib_cpg_iteration_initialize (
|
|
|
goto error_destroy;
|
|
|
}
|
|
|
|
|
|
- list_init (&cpg_iteration_instance->items_list_head);
|
|
|
+ qb_list_init (&cpg_iteration_instance->items_list_head);
|
|
|
cpg_iteration_instance->handle = cpg_iteration_handle;
|
|
|
|
|
|
/*
|
|
|
* Create copy of process_info list "grouped by" group name
|
|
|
*/
|
|
|
- for (iter = process_info_list_head.next; iter != &process_info_list_head; iter = iter->next) {
|
|
|
- struct process_info *pi = list_entry (iter, struct process_info, list);
|
|
|
+ qb_list_for_each(iter, &process_info_list_head) {
|
|
|
+ struct process_info *pi = qb_list_entry (iter, struct process_info, list);
|
|
|
struct process_info *new_pi;
|
|
|
|
|
|
if (req_lib_cpg_iterationinitialize->iteration_type == CPG_ITERATION_NAME_ONLY) {
|
|
|
@@ -2257,10 +2208,8 @@ static void message_handler_req_lib_cpg_iteration_initialize (
|
|
|
*/
|
|
|
int found = 0;
|
|
|
|
|
|
- for (iter2 = cpg_iteration_instance->items_list_head.next;
|
|
|
- iter2 != &cpg_iteration_instance->items_list_head;
|
|
|
- iter2 = iter2->next) {
|
|
|
- struct process_info *pi2 = list_entry (iter2, struct process_info, list);
|
|
|
+ qb_list_for_each(iter2, &(cpg_iteration_instance->items_list_head)) {
|
|
|
+ struct process_info *pi2 = qb_list_entry (iter2, struct process_info, list);
|
|
|
|
|
|
if (mar_name_compare (&pi2->group, &pi->group) == 0) {
|
|
|
found = 1;
|
|
|
@@ -2295,7 +2244,7 @@ static void message_handler_req_lib_cpg_iteration_initialize (
|
|
|
}
|
|
|
|
|
|
memcpy (new_pi, pi, sizeof (struct process_info));
|
|
|
- list_init (&new_pi->list);
|
|
|
+ qb_list_init (&new_pi->list);
|
|
|
|
|
|
if (req_lib_cpg_iterationinitialize->iteration_type == CPG_ITERATION_NAME_ONLY) {
|
|
|
/*
|
|
|
@@ -2307,17 +2256,15 @@ static void message_handler_req_lib_cpg_iteration_initialize (
|
|
|
/*
|
|
|
* We will return list "grouped" by "group name", so try to find right place to add
|
|
|
*/
|
|
|
- for (iter2 = cpg_iteration_instance->items_list_head.next;
|
|
|
- iter2 != &cpg_iteration_instance->items_list_head;
|
|
|
- iter2 = iter2->next) {
|
|
|
- struct process_info *pi2 = list_entry (iter2, struct process_info, list);
|
|
|
+ qb_list_for_each(iter2, &(cpg_iteration_instance->items_list_head)) {
|
|
|
+ struct process_info *pi2 = qb_list_entry (iter2, struct process_info, list);
|
|
|
|
|
|
if (mar_name_compare (&pi2->group, &pi->group) == 0) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- list_add (&new_pi->list, iter2);
|
|
|
+ qb_list_add (&new_pi->list, iter2);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -2327,8 +2274,8 @@ static void message_handler_req_lib_cpg_iteration_initialize (
|
|
|
/*
|
|
|
* Add instance to current cpd list
|
|
|
*/
|
|
|
- list_init (&cpg_iteration_instance->list);
|
|
|
- list_add (&cpg_iteration_instance->list, &cpd->iteration_instance_list_head);
|
|
|
+ qb_list_init (&cpg_iteration_instance->list);
|
|
|
+ qb_list_add (&cpg_iteration_instance->list, &cpd->iteration_instance_list_head);
|
|
|
|
|
|
cpg_iteration_instance->current_pointer = &cpg_iteration_instance->items_list_head;
|
|
|
|
|
|
@@ -2380,7 +2327,7 @@ static void message_handler_req_lib_cpg_iteration_next (
|
|
|
goto error_put;
|
|
|
}
|
|
|
|
|
|
- pi = list_entry (cpg_iteration_instance->current_pointer, struct process_info, list);
|
|
|
+ pi = qb_list_entry (cpg_iteration_instance->current_pointer, struct process_info, list);
|
|
|
|
|
|
/*
|
|
|
* Copy iteration data
|