rebase to new upstream release 3.0.3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2019-11-25 15:38:25 +01:00
parent 1a9b3f34ec
commit 78f2d64051
13 changed files with 1 additions and 2244 deletions

View File

@ -1,119 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= <f.gruenbichler@proxmox.com>
Date: Wed, 15 May 2019 13:45:13 +0200
Subject: [PATCH] cpg: notify_lib_joinlist: drop conn parameter
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
since it is always set to NULL.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
(cherry picked from commit c16abe515f895579f11b9012c888b7e067bb99fc)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
exec/cpg.c | 54 ++++++++++++++++++++++++------------------------------
1 file changed, 24 insertions(+), 30 deletions(-)
diff --git a/exec/cpg.c b/exec/cpg.c
index e39ca340..b752cc15 100644
--- a/exec/cpg.c
+++ b/exec/cpg.c
@@ -647,7 +647,6 @@ static int notify_lib_totem_membership (
static int notify_lib_joinlist(
const mar_cpg_name_t *group_name,
- void *conn,
int joined_list_entries,
mar_cpg_address_t *joined_list,
int left_list_entries,
@@ -728,40 +727,35 @@ static int notify_lib_joinlist(
retgi += joined_list_entries;
}
- if (conn) {
- api->ipc_dispatch_send (conn, buf, size);
- } else {
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) {
- if (joined_list[0].pid == cpd->pid &&
- joined_list[0].nodeid == api->totem_nodeid_get()) {
- cpd->cpd_state = CPD_STATE_JOIN_COMPLETED;
- }
+ 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) {
+ if (joined_list[0].pid == cpd->pid &&
+ joined_list[0].nodeid == api->totem_nodeid_get()) {
+ cpd->cpd_state = CPD_STATE_JOIN_COMPLETED;
}
- if (cpd->cpd_state == CPD_STATE_JOIN_COMPLETED ||
- cpd->cpd_state == CPD_STATE_LEAVE_STARTED) {
+ }
+ if (cpd->cpd_state == CPD_STATE_JOIN_COMPLETED ||
+ cpd->cpd_state == CPD_STATE_LEAVE_STARTED) {
- api->ipc_dispatch_send (cpd->conn, buf, size);
- cpd->transition_counter++;
- }
- if (left_list_entries) {
- if (left_list[0].pid == cpd->pid &&
- left_list[0].nodeid == api->totem_nodeid_get() &&
- left_list[0].reason == CONFCHG_CPG_REASON_LEAVE) {
-
- cpd->pid = 0;
- memset (&cpd->group_name, 0, sizeof(cpd->group_name));
- cpd->cpd_state = CPD_STATE_UNJOINED;
- }
+ api->ipc_dispatch_send (cpd->conn, buf, size);
+ cpd->transition_counter++;
+ }
+ if (left_list_entries) {
+ if (left_list[0].pid == cpd->pid &&
+ left_list[0].nodeid == api->totem_nodeid_get() &&
+ left_list[0].reason == CONFCHG_CPG_REASON_LEAVE) {
+
+ cpd->pid = 0;
+ memset (&cpd->group_name, 0, sizeof(cpd->group_name));
+ cpd->cpd_state = CPD_STATE_UNJOINED;
}
}
}
}
-
/*
* Traverse thru cpds and send totem membership for cpd, where it is not send yet
*/
@@ -858,7 +852,7 @@ static void downlist_inform_clients (void)
}
/* send confchg event */
- notify_lib_joinlist(&group, NULL,
+ notify_lib_joinlist(&group,
0, NULL,
pcd->left_list_entries,
pcd->left_list,
@@ -1157,7 +1151,7 @@ static void do_proc_join(
notify_info.nodeid = nodeid;
notify_info.reason = reason;
- notify_lib_joinlist(&pi->group, NULL,
+ notify_lib_joinlist(&pi->group,
1, &notify_info,
0, NULL,
MESSAGE_RES_CPG_CONFCHG_CALLBACK);
@@ -1177,7 +1171,7 @@ static void do_proc_leave(
notify_info.nodeid = nodeid;
notify_info.reason = reason;
- notify_lib_joinlist(name, NULL,
+ notify_lib_joinlist(name,
0, NULL,
1, &notify_info,
MESSAGE_RES_CPG_CONFCHG_CALLBACK);

View File

@ -1,201 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= <f.gruenbichler@proxmox.com>
Date: Wed, 8 May 2019 16:31:15 +0200
Subject: [PATCH] cpg: send single confchg event per group on joinlist
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
using a similar approach to
43bead364514e8ae2ba00bcf07c460e31d0b1765
"Send one confchg event per CPG group to CPG client"
which did the same for leave events on a network partition.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
(cherry picked from commit 7fb247096687d4232b6e90e4c732229b971c8378)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
exec/cpg.c | 97 ++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 73 insertions(+), 24 deletions(-)
diff --git a/exec/cpg.c b/exec/cpg.c
index b752cc15..e04ba579 100644
--- a/exec/cpg.c
+++ b/exec/cpg.c
@@ -194,6 +194,12 @@ struct join_list_entry {
mar_cpg_name_t group_name;
};
+struct join_list_confchg_data {
+ mar_cpg_name_t cpg_group;
+ mar_cpg_address_t join_list[CPG_MEMBERS_MAX];
+ int join_list_entries;
+};
+
/*
* Service Interfaces required by service_message_handler struct
*/
@@ -312,7 +318,8 @@ static void do_proc_join(
const mar_cpg_name_t *name,
uint32_t pid,
unsigned int nodeid,
- int reason);
+ int reason,
+ qb_map_t *group_notify_map);
static void do_proc_leave(
const mar_cpg_name_t *name,
@@ -723,35 +730,46 @@ static int notify_lib_joinlist(
}
if (joined_list_entries) {
+ int i;
+
memcpy (retgi, joined_list, joined_list_entries * sizeof(mar_cpg_address_t));
retgi += joined_list_entries;
+
+ for (i=0; i < joined_list_entries; i++) {
+ if (joined_list[i].nodeid == api->totem_nodeid_get()) {
+ 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 &&
+ joined_list[i].pid == cpd->pid) {
+ cpd->cpd_state = CPD_STATE_JOIN_COMPLETED;
+ }
+ }
+ }
+ }
}
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) {
- if (joined_list[0].pid == cpd->pid &&
- joined_list[0].nodeid == api->totem_nodeid_get()) {
- cpd->cpd_state = CPD_STATE_JOIN_COMPLETED;
- }
- }
if (cpd->cpd_state == CPD_STATE_JOIN_COMPLETED ||
cpd->cpd_state == CPD_STATE_LEAVE_STARTED) {
api->ipc_dispatch_send (cpd->conn, buf, size);
cpd->transition_counter++;
}
- if (left_list_entries) {
- if (left_list[0].pid == cpd->pid &&
- left_list[0].nodeid == api->totem_nodeid_get() &&
- left_list[0].reason == CONFCHG_CPG_REASON_LEAVE) {
-
- cpd->pid = 0;
- memset (&cpd->group_name, 0, sizeof(cpd->group_name));
- cpd->cpd_state = CPD_STATE_UNJOINED;
- }
+ }
+ }
+
+ if (left_list_entries &&
+ left_list[0].nodeid == api->totem_nodeid_get() &&
+ left_list[0].reason == CONFCHG_CPG_REASON_LEAVE) {
+ 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 &&
+ left_list[0].pid == cpd->pid) {
+ cpd->pid = 0;
+ memset (&cpd->group_name, 0, sizeof(cpd->group_name));
+ cpd->cpd_state = CPD_STATE_UNJOINED;
}
}
}
@@ -915,6 +933,11 @@ static void joinlist_inform_clients (void)
struct joinlist_msg *stored_msg;
struct qb_list_head *iter;
unsigned int i;
+ qb_map_t *group_notify_map;
+ qb_map_iter_t *miter;
+ struct join_list_confchg_data *jld;
+
+ group_notify_map = qb_skiplist_create();
i = 0;
qb_list_for_each(iter, &joinlist_messages_head) {
@@ -931,9 +954,19 @@ static void joinlist_inform_clients (void)
}
do_proc_join (&stored_msg->group_name, stored_msg->pid, stored_msg->sender_nodeid,
- CONFCHG_CPG_REASON_NODEUP);
+ CONFCHG_CPG_REASON_NODEUP, group_notify_map);
}
+ miter = qb_map_iter_create(group_notify_map);
+ while (qb_map_iter_next(miter, (void **)&jld)) {
+ notify_lib_joinlist(&jld->cpg_group,
+ jld->join_list_entries, jld->join_list,
+ 0, NULL,
+ MESSAGE_RES_CPG_CONFCHG_CALLBACK);
+ free(jld);
+ }
+ qb_map_iter_free(miter);
+
joinlist_remove_zombie_pi_entries ();
}
@@ -1111,13 +1144,15 @@ static void do_proc_join(
const mar_cpg_name_t *name,
uint32_t pid,
unsigned int nodeid,
- int reason)
+ int reason,
+ qb_map_t *group_notify_map)
{
struct process_info *pi;
struct process_info *pi_entry;
mar_cpg_address_t notify_info;
struct qb_list_head *list;
struct qb_list_head *list_to_add = NULL;
+ int size;
if (process_info_find (name, pid, nodeid) != NULL) {
return ;
@@ -1151,10 +1186,24 @@ static void do_proc_join(
notify_info.nodeid = nodeid;
notify_info.reason = reason;
- notify_lib_joinlist(&pi->group,
- 1, &notify_info,
- 0, NULL,
- MESSAGE_RES_CPG_CONFCHG_CALLBACK);
+ if (group_notify_map == NULL) {
+ notify_lib_joinlist(&pi->group,
+ 1, &notify_info,
+ 0, NULL,
+ MESSAGE_RES_CPG_CONFCHG_CALLBACK);
+ } else {
+ struct join_list_confchg_data *jld = qb_map_get(group_notify_map, pi->group.value);
+ if (jld == NULL) {
+ jld = (struct join_list_confchg_data *)calloc(1, sizeof(struct join_list_confchg_data));
+ memcpy(&jld->cpg_group, &pi->group, sizeof(mar_cpg_name_t));
+ qb_map_put(group_notify_map, jld->cpg_group.value, jld);
+ }
+ size = jld->join_list_entries;
+ jld->join_list[size].nodeid = notify_info.nodeid;
+ jld->join_list[size].pid = notify_info.pid;
+ jld->join_list[size].reason = notify_info.reason;
+ jld->join_list_entries++;
+ }
}
static void do_proc_leave(
@@ -1219,7 +1268,7 @@ static void message_handler_req_exec_cpg_procjoin (
do_proc_join (&req_exec_cpg_procjoin->group_name,
req_exec_cpg_procjoin->pid, nodeid,
- CONFCHG_CPG_REASON_JOIN);
+ CONFCHG_CPG_REASON_JOIN, NULL);
}
static void message_handler_req_exec_cpg_procleave (

View File

@ -1,200 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jan Friesse <jfriesse@redhat.com>
Date: Wed, 15 May 2019 17:39:13 +0200
Subject: [PATCH] cpg: Add more comments to notify_lib_joinlist
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
And make handling of left_list more generic. Also free skiplist
allocated by joinlist_inform_clients function. Last (but not least)
remove czechlish founded (should have been pp of "find").
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
(cherry picked from commit 1e2df0ba0c341bc1a2a72da4d63e0993bb643909)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
exec/cpg.c | 91 +++++++++++++++++++++++++++++++++++-------------------
1 file changed, 60 insertions(+), 31 deletions(-)
diff --git a/exec/cpg.c b/exec/cpg.c
index e04ba579..2ecdc6b4 100644
--- a/exec/cpg.c
+++ b/exec/cpg.c
@@ -663,31 +663,37 @@ static int notify_lib_joinlist(
int size;
char *buf;
struct qb_list_head *iter;
- int count;
+ int member_list_entries;
struct res_lib_cpg_confchg_callback *res;
mar_cpg_address_t *retgi;
+ int i;
- count = 0;
+ /*
+ * Find size of member_list (use process_info_list but remove items in left_list)
+ */
+ member_list_entries = 0;
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;
+ int in_left_list = 0;
for (i = 0; i < left_list_entries; i++) {
if (left_list[i].nodeid == pi->nodeid && left_list[i].pid == pi->pid) {
- founded++;
+ in_left_list = 1;
+ break ;
}
}
- if (!founded)
- count++;
+ if (!in_left_list) {
+ member_list_entries++;
+ }
}
}
size = sizeof(struct res_lib_cpg_confchg_callback) +
- sizeof(mar_cpg_address_t) * (count + left_list_entries + joined_list_entries);
+ sizeof(mar_cpg_address_t) * (member_list_entries + left_list_entries + joined_list_entries);
buf = alloca(size);
if (!buf)
return CS_ERR_LIBRARY;
@@ -695,27 +701,30 @@ static int notify_lib_joinlist(
res = (struct res_lib_cpg_confchg_callback *)buf;
res->joined_list_entries = joined_list_entries;
res->left_list_entries = left_list_entries;
- res->member_list_entries = count;
+ res->member_list_entries = member_list_entries;
retgi = res->member_list;
res->header.size = size;
res->header.id = id;
res->header.error = CS_OK;
memcpy(&res->group_name, group_name, sizeof(mar_cpg_name_t));
+ /*
+ * Fill res->memberlist. Use process_info_list but remove items in left_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 *pi = qb_list_entry (iter, struct process_info, list);
if (mar_name_compare (&pi->group, group_name) == 0) {
- int i;
- int founded = 0;
+ int in_left_list = 0;
- for (i = 0;i < left_list_entries; i++) {
+ for (i = 0; i < left_list_entries; i++) {
if (left_list[i].nodeid == pi->nodeid && left_list[i].pid == pi->pid) {
- founded++;
+ in_left_list = 1;
+ break ;
}
}
- if (!founded) {
+ if (!in_left_list) {
retgi->nodeid = pi->nodeid;
retgi->pid = pi->pid;
retgi->reason = CPG_REASON_UNDEFINED;
@@ -724,23 +733,30 @@ static int notify_lib_joinlist(
}
}
+ /*
+ * Fill res->left_list
+ */
if (left_list_entries) {
memcpy (retgi, left_list, left_list_entries * sizeof(mar_cpg_address_t));
retgi += left_list_entries;
}
if (joined_list_entries) {
- int i;
-
+ /*
+ * Fill res->joined_list
+ */
memcpy (retgi, joined_list, joined_list_entries * sizeof(mar_cpg_address_t));
retgi += joined_list_entries;
- for (i=0; i < joined_list_entries; i++) {
+ /*
+ * Update cpd_state for all local joined processes in group
+ */
+ for (i = 0; i < joined_list_entries; i++) {
if (joined_list[i].nodeid == api->totem_nodeid_get()) {
- qb_list_for_each(iter, &cpg_pd_list_head) {
+ 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 &&
- joined_list[i].pid == cpd->pid) {
+ if (joined_list[i].pid == cpd->pid &&
+ mar_name_compare (&cpd->group_name, group_name) == 0) {
cpd->cpd_state = CPD_STATE_JOIN_COMPLETED;
}
}
@@ -748,6 +764,9 @@ static int notify_lib_joinlist(
}
}
+ /*
+ * Send notification to all ipc clients joined in group_name
+ */
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) {
@@ -760,16 +779,25 @@ static int notify_lib_joinlist(
}
}
- if (left_list_entries &&
- left_list[0].nodeid == api->totem_nodeid_get() &&
- left_list[0].reason == CONFCHG_CPG_REASON_LEAVE) {
- 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 &&
- left_list[0].pid == cpd->pid) {
- cpd->pid = 0;
- memset (&cpd->group_name, 0, sizeof(cpd->group_name));
- cpd->cpd_state = CPD_STATE_UNJOINED;
+ if (left_list_entries) {
+ /*
+ * Zero internal cpd state for all local processes leaving group
+ * (this loop is not strictly needed because left_list always either
+ * contains exactly one process running on local node or more items
+ * but none of them is running on local node)
+ */
+ for (i = 0; i < joined_list_entries; i++) {
+ if (left_list[i].nodeid == api->totem_nodeid_get() &&
+ left_list[i].reason == CONFCHG_CPG_REASON_LEAVE) {
+ qb_list_for_each(iter, &cpg_pd_list_head) {
+ struct cpg_pd *cpd = qb_list_entry (iter, struct cpg_pd, list);
+ if (left_list[i].pid == cpd->pid &&
+ mar_name_compare (&cpd->group_name, group_name) == 0) {
+ cpd->pid = 0;
+ memset (&cpd->group_name, 0, sizeof(cpd->group_name));
+ cpd->cpd_state = CPD_STATE_UNJOINED;
+ }
+ }
}
}
}
@@ -966,6 +994,7 @@ static void joinlist_inform_clients (void)
free(jld);
}
qb_map_iter_free(miter);
+ qb_map_destroy(group_notify_map);
joinlist_remove_zombie_pi_entries ();
}

View File

@ -1,137 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jan Friesse <jfriesse@redhat.com>
Date: Thu, 16 May 2019 14:08:25 +0200
Subject: [PATCH] cpg: Move filling of member_list to subfunction
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
(cherry picked from commit 3c7f19a02fbff19414638952043691d92be86d41)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
exec/cpg.c | 86 +++++++++++++++++++++++++++++++-----------------------
1 file changed, 50 insertions(+), 36 deletions(-)
diff --git a/exec/cpg.c b/exec/cpg.c
index 2ecdc6b4..98a16a60 100644
--- a/exec/cpg.c
+++ b/exec/cpg.c
@@ -652,26 +652,27 @@ static int notify_lib_totem_membership (
return CS_OK;
}
-static int notify_lib_joinlist(
+/*
+ * Helper function for notify_lib_joinlist which prepares member_list using
+ * process_info_list with removed left_list items.
+ * member_list_entries - When not NULL it contains number of member_list entries
+ * member_list - When not NULL it is used as pointer to start of preallocated
+ * array of members. Pointer is adjusted to the end of array on
+ * exit.
+ */
+static void notify_lib_joinlist_fill_member_list(
const mar_cpg_name_t *group_name,
- int joined_list_entries,
- mar_cpg_address_t *joined_list,
int left_list_entries,
- mar_cpg_address_t *left_list,
- int id)
+ const mar_cpg_address_t *left_list,
+ int *member_list_entries,
+ mar_cpg_address_t **member_list)
{
- int size;
- char *buf;
struct qb_list_head *iter;
- int member_list_entries;
- struct res_lib_cpg_confchg_callback *res;
- mar_cpg_address_t *retgi;
int i;
- /*
- * Find size of member_list (use process_info_list but remove items in left_list)
- */
- member_list_entries = 0;
+ if (member_list_entries != NULL) {
+ *member_list_entries = 0;
+ }
qb_list_for_each(iter, &process_info_list_head) {
struct process_info *pi = qb_list_entry (iter, struct process_info, list);
@@ -687,10 +688,42 @@ static int notify_lib_joinlist(
}
if (!in_left_list) {
- member_list_entries++;
+ if (member_list_entries != NULL) {
+ (*member_list_entries)++;
+ }
+
+ if (member_list != NULL) {
+ (*member_list)->nodeid = pi->nodeid;
+ (*member_list)->pid = pi->pid;
+ (*member_list)->reason = CPG_REASON_UNDEFINED;
+ (*member_list)++;
+ }
}
}
}
+}
+
+static int notify_lib_joinlist(
+ const mar_cpg_name_t *group_name,
+ int joined_list_entries,
+ mar_cpg_address_t *joined_list,
+ int left_list_entries,
+ mar_cpg_address_t *left_list,
+ int id)
+{
+ int size;
+ char *buf;
+ struct qb_list_head *iter;
+ int member_list_entries;
+ struct res_lib_cpg_confchg_callback *res;
+ mar_cpg_address_t *retgi;
+ int i;
+
+ /*
+ * Find size of member_list (use process_info_list but remove items in left_list)
+ */
+ notify_lib_joinlist_fill_member_list(group_name, left_list_entries, left_list,
+ &member_list_entries, NULL);
size = sizeof(struct res_lib_cpg_confchg_callback) +
sizeof(mar_cpg_address_t) * (member_list_entries + left_list_entries + joined_list_entries);
@@ -711,27 +744,8 @@ static int notify_lib_joinlist(
/*
* Fill res->memberlist. Use process_info_list but remove items in left_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 in_left_list = 0;
-
- for (i = 0; i < left_list_entries; i++) {
- if (left_list[i].nodeid == pi->nodeid && left_list[i].pid == pi->pid) {
- in_left_list = 1;
- break ;
- }
- }
-
- if (!in_left_list) {
- retgi->nodeid = pi->nodeid;
- retgi->pid = pi->pid;
- retgi->reason = CPG_REASON_UNDEFINED;
- retgi++;
- }
- }
- }
+ notify_lib_joinlist_fill_member_list(group_name, left_list_entries, left_list,
+ NULL, &retgi);
/*
* Fill res->left_list

View File

@ -1,48 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
Date: Fri, 14 Jun 2019 18:31:16 +0200
Subject: [PATCH] totem: fix check if all nodes have name attrs in multi-link
setups
As totem_config->interfaces entries are _all_ possible links and not
only the configured ones we cannot trust that interface[0] is
configured at the time of checking, and thus has a valid
member_count. So set the members variable to the member_count entry
from an actually configured interface and loop over that one.
This fixes a case where the check for the name property on all nodes
for multi links was skipped if link 0 was not configured, as then its
member_count was 0.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
(cherry picked from commit 7ada508a82680dcf23510e585ec295b10ac5da11)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
exec/totemconfig.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/exec/totemconfig.c b/exec/totemconfig.c
index ff86e232..dfde90df 100644
--- a/exec/totemconfig.c
+++ b/exec/totemconfig.c
@@ -449,14 +449,15 @@ static int totem_volatile_config_validate (
num_configured = 0;
for (i = 0; i < INTERFACE_MAX; i++) {
if (totem_config->interfaces[i].configured) {
+ if (num_configured == 0) {
+ members = totem_config->interfaces[i].member_count;
+ }
num_configured++;
}
}
if (num_configured > 1) {
- members = totem_config->interfaces[0].member_count;
-
- for (i=0; i<totem_config->interfaces[0].member_count; i++) {
+ for (i=0; i < members; i++) {
snprintf(name_key, sizeof(name_key), "nodelist.node.%d.name", i);
if (icmap_get_string(name_key, &name_str) != CS_OK) {

View File

@ -1,40 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
Date: Fri, 14 Jun 2019 18:56:57 +0200
Subject: [PATCH] totem: fix check if all nodes have same number of links
configured links may not come in order in the interfaces array, which
holds an entry for _all_ possible links, not just configured ones.
So iterate through all interfaces, but skip those which are not
configured. This allows to start corosync with a configuration where
link 0 is currently not mentioned, as else it was checked but had
member_count = 0 from it's default initialization, which then made
this code report a false positive for the "Not all nodes have the
same number of links" check even on a correct config.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
(cherry picked from commit 816324c94cfb917b11f43954b8757424db28b390)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
exec/totemconfig.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/exec/totemconfig.c b/exec/totemconfig.c
index dfde90df..67a61ac2 100644
--- a/exec/totemconfig.c
+++ b/exec/totemconfig.c
@@ -467,7 +467,10 @@ static int totem_volatile_config_validate (
}
}
- for (i=0; i<num_configured; i++) {
+ for (i=0; i < INTERFACE_MAX; i++) {
+ if (!totem_config->interfaces[i].configured) {
+ continue;
+ }
if (totem_config->interfaces[i].member_count != members) {
snprintf (local_error_reason, sizeof(local_error_reason),
"Not all nodes have the same number of links");

View File

@ -1,55 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jan Friesse <jfriesse@redhat.com>
Date: Thu, 27 Jun 2019 08:33:27 +0200
Subject: [PATCH] totemknet: Disable forwarding on shutdown
Disabling forwarding will make knet flush the messages (especially
LEAVE one).
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
(cherry picked from commit d59a18d4a13717ffe56ef31fadda9f67c7cfcf8e)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
exec/totemknet.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/exec/totemknet.c b/exec/totemknet.c
index e6e04d3a..e1ea8515 100644
--- a/exec/totemknet.c
+++ b/exec/totemknet.c
@@ -554,6 +554,14 @@ int totemknet_finalize (
qb_loop_poll_del (instance->poll_handle, instance->logpipes[0]);
qb_loop_poll_del (instance->poll_handle, instance->knet_fd);
+ /*
+ * Disable forwarding to make knet flush send queue. This ensures that the LEAVE message will be sent.
+ */
+ res = knet_handle_setfwd(instance->knet_handle, 0);
+ if (res) {
+ knet_log_printf (LOGSYS_LEVEL_CRIT, "totemknet: knet_handle_setfwd failed: %s", strerror(errno));
+ }
+
res = knet_host_get_host_list(instance->knet_handle, nodes, &num_nodes);
if (res) {
knet_log_printf (LOGSYS_LEVEL_ERROR, "Cannot get knet node list for shutdown: %s", strerror(errno));
@@ -561,7 +569,7 @@ int totemknet_finalize (
goto finalise_error;
}
- /* Tidily shut down all nodes & links. This ensures that the LEAVE message will be sent */
+ /* Tidily shut down all nodes & links. */
for (i=0; i<num_nodes; i++) {
res = knet_link_get_link_list(instance->knet_handle, nodes[i], links, &num_links);
@@ -586,10 +594,6 @@ int totemknet_finalize (
}
finalise_error:
- res = knet_handle_setfwd(instance->knet_handle, 0);
- if (res) {
- knet_log_printf (LOGSYS_LEVEL_CRIT, "totemknet: knet_handle_setfwd failed: %s", strerror(errno));
- }
res = knet_handle_free(instance->knet_handle);
if (res) {
knet_log_printf (LOGSYS_LEVEL_CRIT, "totemknet: knet_handle_free failed: %s", strerror(errno));

File diff suppressed because it is too large Load Diff

View File

@ -1,93 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jan Friesse <jfriesse@redhat.com>
Date: Mon, 9 Sep 2019 17:47:24 +0200
Subject: [PATCH] totemknet: Add locking for log call
Knet callbacks may be called from different thread than main thread. If
this happens, log messages may be lost. Most prominent example is when
link goes up (logged by main thread) and host_change_callback_fn is
called.
Implemented solution is adding mutex for every log call in totemknet.
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
(cherry picked from commit 1cf1558fe745de0f81147ca33ea1f27ac152308d)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
exec/totemknet.c | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/exec/totemknet.c b/exec/totemknet.c
index 38b69e7b..a372ea75 100644
--- a/exec/totemknet.c
+++ b/exec/totemknet.c
@@ -51,6 +51,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
+#include <pthread.h>
#include <sched.h>
#include <time.h>
#include <sys/time.h>
@@ -171,6 +172,8 @@ struct totemknet_instance {
int logpipes[2];
int knet_fd;
+
+ pthread_mutex_t log_mutex;
#ifdef HAVE_LIBNOZZLE
char *nozzle_name;
char *nozzle_ipaddr;
@@ -203,20 +206,36 @@ static void log_flush_messages (
static void totemknet_instance_initialize (struct totemknet_instance *instance)
{
+ int res;
+
memset (instance, 0, sizeof (struct totemknet_instance));
+ res = pthread_mutex_init(&instance->log_mutex, NULL);
+ /*
+ * There is not too much else what can be done.
+ */
+ assert(res == 0);
}
+#define knet_log_printf_lock(level, subsys, function, file, line, format, args...) \
+do { \
+ (void)pthread_mutex_lock(&instance->log_mutex); \
+ instance->totemknet_log_printf ( \
+ level, subsys, function, file, line, \
+ (const char *)format, ##args); \
+ (void)pthread_mutex_unlock(&instance->log_mutex); \
+} while (0);
+
#define knet_log_printf(level, format, args...) \
do { \
- instance->totemknet_log_printf ( \
+ knet_log_printf_lock ( \
level, instance->totemknet_subsys_id, \
__FUNCTION__, __FILE__, __LINE__, \
(const char *)format, ##args); \
} while (0);
-#define libknet_log_printf(level, format, args...) \
+#define libknet_log_printf(level, format, args...) \
do { \
- instance->totemknet_log_printf ( \
+ knet_log_printf_lock ( \
level, instance->knet_subsys_id, \
__FUNCTION__, "libknet.h", __LINE__, \
(const char *)format, ##args); \
@@ -603,6 +622,11 @@ finalise_error:
log_flush_messages(instance);
+ /*
+ * Error is deliberately ignored
+ */
+ (void)pthread_mutex_destroy(&instance->log_mutex);
+
return (res);
}

View File

@ -1,71 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jan Friesse <jfriesse@redhat.com>
Date: Thu, 3 Oct 2019 11:35:37 +0200
Subject: [PATCH] totempg: Check sanity (length) of received message
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
exec/totempg.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/exec/totempg.c b/exec/totempg.c
index 6b3c590d..e251c236 100644
--- a/exec/totempg.c
+++ b/exec/totempg.c
@@ -603,10 +603,18 @@ static void totempg_deliver_fn (
const char *data;
int datasize;
struct iovec iov_delv;
+ size_t expected_msg_len;
assembly = assembly_ref (nodeid);
assert (assembly);
+ if (msg_len < sizeof(struct totempg_mcast)) {
+ log_printf(LOG_WARNING,
+ "Message (totempg_mcast) received from node " CS_PRI_NODE_ID " is too short... Ignoring.", nodeid);
+
+ return ;
+ }
+
/*
* Assemble the header into one block of data and
* assemble the packet contents into one block of data to simplify delivery
@@ -621,14 +629,34 @@ static void totempg_deliver_fn (
datasize = sizeof (struct totempg_mcast) +
msg_count * sizeof (unsigned short);
+ if (msg_len < datasize) {
+ log_printf(LOG_WARNING,
+ "Message (totempg_mcast datasize) received from node " CS_PRI_NODE_ID
+ " is too short... Ignoring.", nodeid);
+
+ return ;
+ }
+
memcpy (header, msg, datasize);
data = msg;
msg_lens = (unsigned short *) (header + sizeof (struct totempg_mcast));
- if (endian_conversion_required) {
- for (i = 0; i < mcast->msg_count; i++) {
+ expected_msg_len = datasize;
+ for (i = 0; i < mcast->msg_count; i++) {
+ if (endian_conversion_required) {
msg_lens[i] = swab16 (msg_lens[i]);
}
+
+ expected_msg_len += msg_lens[i];
+ }
+
+ if (msg_len != expected_msg_len) {
+ log_printf(LOG_WARNING,
+ "Message (totempg_mcast) received from node " CS_PRI_NODE_ID
+ " doesn't have expected length of %zu (has %u) bytes... Ignoring.",
+ nodeid, expected_msg_len, msg_len);
+
+ return ;
}
assert((assembly->index+msg_len) < sizeof(assembly->data));

View File

@ -1,44 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jan Friesse <jfriesse@redhat.com>
Date: Mon, 7 Oct 2019 15:26:22 +0200
Subject: [PATCH] totemsrp: Reduce MTU to left room second mcast
Messages sent during recovery phase are encapsulated so such message has
extra size of mcast structure. This is not so big problem for UDPU,
because most of the switches are able to fragment and defragment packet
but it is problem for knet, because totempg is using maximum packet size
(65536 bytes) and when another header is added during retransmition,
then packet is too large.
Solution is to reduce mtu by 2 * sizeof (struct mcast).
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
(cherry picked from commit ee8b8993d98b3f6af9c058194228fc534fcd0796)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
exec/totemsrp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/exec/totemsrp.c b/exec/totemsrp.c
index e988c531..9ea3d689 100644
--- a/exec/totemsrp.c
+++ b/exec/totemsrp.c
@@ -805,7 +805,7 @@ static void totempg_mtu_changed(void *context, int net_mtu)
{
struct totemsrp_instance *instance = context;
- instance->totem_config->net_mtu = net_mtu - sizeof (struct mcast);
+ instance->totem_config->net_mtu = net_mtu - 2 * sizeof (struct mcast);
log_printf (instance->totemsrp_log_level_debug,
"Net MTU changed to %d, new value is %d",
@@ -5092,7 +5092,7 @@ void main_iface_change_fn (
}
void totemsrp_net_mtu_adjust (struct totem_config *totem_config) {
- totem_config->net_mtu -= sizeof (struct mcast);
+ totem_config->net_mtu -= 2 * sizeof (struct mcast);
}
void totemsrp_service_ready_register (

11
debian/patches/series vendored
View File

@ -1,13 +1,2 @@
0001-Enable-PrivateTmp-in-the-systemd-service-files.patch
0002-only-start-corosync.service-if-conf-exists.patch
0003-cpg-notify_lib_joinlist-drop-conn-parameter.patch
0004-cpg-send-single-confchg-event-per-group-on-joinlist.patch
0005-cpg-Add-more-comments-to-notify_lib_joinlist.patch
0006-cpg-Move-filling-of-member_list-to-subfunction.patch
0007-totem-fix-check-if-all-nodes-have-name-attrs-in-mult.patch
0008-totem-fix-check-if-all-nodes-have-same-number-of-lin.patch
0009-totemknet-Disable-forwarding-on-shutdown.patch
0010-logging-Add-CS_PRI_NODE_ID-and-CS_PRI_RING_ID.patch
0011-totemknet-Add-locking-for-log-call.patch
0012-totempg-Check-sanity-length-of-received-message.patch
0013-totemsrp-Reduce-MTU-to-left-room-second-mcast.patch

@ -1 +1 @@
Subproject commit 0390200dd427d1d3e75bba8584dbfbb794b52b49
Subproject commit 1ba03a3816212aa7c74196dc1b9b530c7184f5e1