-
Notifications
You must be signed in to change notification settings - Fork 0
/
revision-2801.patch
420 lines (391 loc) · 11.1 KB
/
revision-2801.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
Index: services/cpg.c
===================================================================
--- services/cpg.c (revision 2800)
+++ services/cpg.c (revision 2801)
@@ -75,7 +75,8 @@
MESSAGE_REQ_EXEC_CPG_PROCLEAVE = 1,
MESSAGE_REQ_EXEC_CPG_JOINLIST = 2,
MESSAGE_REQ_EXEC_CPG_MCAST = 3,
- MESSAGE_REQ_EXEC_CPG_DOWNLIST = 4
+ MESSAGE_REQ_EXEC_CPG_DOWNLIST_OLD = 4,
+ MESSAGE_REQ_EXEC_CPG_DOWNLIST = 5
};
/*
@@ -127,6 +128,13 @@
CPGSYNC_JOINLIST
};
+enum cpg_downlist_state_e {
+ CPG_DOWNLIST_NONE,
+ CPG_DOWNLIST_WAITING_FOR_MESSAGES,
+ CPG_DOWNLIST_APPLYING,
+};
+static enum cpg_downlist_state_e downlist_state;
+static struct list_head downlist_messages_head;
struct cpg_pd {
void *conn;
@@ -202,6 +210,10 @@
const void *message,
unsigned int nodeid);
+static void message_handler_req_exec_cpg_downlist_old (
+ const void *message,
+ unsigned int nodeid);
+
static void message_handler_req_exec_cpg_downlist (
const void *message,
unsigned int nodeid);
@@ -212,6 +224,8 @@
static void exec_cpg_mcast_endian_convert (void *msg);
+static void exec_cpg_downlist_endian_convert_old (void *msg);
+
static void exec_cpg_downlist_endian_convert (void *msg);
static void message_handler_req_lib_cpg_join (void *conn, const void *message);
@@ -246,6 +260,10 @@
static int cpg_exec_send_joinlist(void);
+static void downlist_messages_delete (void);
+
+static void downlist_master_choose_and_send (void);
+
static void cpg_sync_init_v2 (
const unsigned int *trans_list,
size_t trans_list_entries,
@@ -326,6 +344,10 @@
.exec_endian_convert_fn = exec_cpg_mcast_endian_convert
},
{ /* 4 */
+ .exec_handler_fn = message_handler_req_exec_cpg_downlist_old,
+ .exec_endian_convert_fn = exec_cpg_downlist_endian_convert_old
+ },
+ { /* 5 */
.exec_handler_fn = message_handler_req_exec_cpg_downlist,
.exec_endian_convert_fn = exec_cpg_downlist_endian_convert
},
@@ -415,35 +437,31 @@
mar_uint8_t message[] __attribute__((aligned(8)));
};
+struct req_exec_cpg_downlist_old {
+ coroipc_request_header_t header __attribute__((aligned(8)));
+ mar_uint32_t left_nodes __attribute__((aligned(8)));
+ mar_uint32_t nodeids[PROCESSOR_COUNT_MAX] __attribute__((aligned(8)));
+};
+
struct req_exec_cpg_downlist {
coroipc_request_header_t header __attribute__((aligned(8)));
+ /* merge decisions */
+ mar_uint32_t old_members __attribute__((aligned(8)));
+ /* downlist below */
mar_uint32_t left_nodes __attribute__((aligned(8)));
mar_uint32_t nodeids[PROCESSOR_COUNT_MAX] __attribute__((aligned(8)));
};
+struct downlist_msg {
+ mar_uint32_t sender_nodeid;
+ 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;
+};
+
static struct req_exec_cpg_downlist g_req_exec_cpg_downlist;
-static int memb_list_remove_value (unsigned int *list,
- size_t list_entries, int value)
-{
- int j;
- int found = 0;
-
- for (j = 0; j < list_entries; j++) {
- if (list[j] == value) {
- /* mark next values to be copied down */
- found = 1;
- }
- else if (found) {
- list[j-1] = list[j];
- }
- }
- if (found)
- return (list_entries - 1);
- else
- return list_entries;
-}
-
static void cpg_sync_init_v2 (
const unsigned int *trans_list,
size_t trans_list_entries,
@@ -451,7 +469,6 @@
size_t member_list_entries,
const struct memb_ring_id *ring_id)
{
- unsigned int lowest_nodeid = 0xffffffff;
int entries;
int i, j;
int found;
@@ -465,6 +482,12 @@
last_sync_ring_id.nodeid = ring_id->rep.nodeid;
last_sync_ring_id.seq = ring_id->seq;
+ downlist_state = CPG_DOWNLIST_WAITING_FOR_MESSAGES;
+
+ entries = 0;
+ /*
+ * Determine list of nodeids for downlist message
+ */
for (i = 0; i < my_old_member_list_entries; i++) {
found = 0;
for (j = 0; j < trans_list_entries; j++) {
@@ -474,37 +497,10 @@
}
}
if (found == 0) {
- my_member_list_entries = memb_list_remove_value (
- my_member_list, my_member_list_entries,
- my_old_member_list[i]);
+ g_req_exec_cpg_downlist.nodeids[entries++] =
+ my_old_member_list[i];
}
}
-
- for (i = 0; i < my_member_list_entries; i++) {
- if (my_member_list[i] < lowest_nodeid) {
- lowest_nodeid = my_member_list[i];
- }
- }
-
- entries = 0;
- if (lowest_nodeid == api->totem_nodeid_get()) {
- /*
- * Determine list of nodeids for downlist message
- */
- for (i = 0; i < my_old_member_list_entries; i++) {
- found = 0;
- for (j = 0; j < trans_list_entries; j++) {
- if (my_old_member_list[i] == trans_list[j]) {
- found = 1;
- break;
- }
- }
- if (found == 0) {
- g_req_exec_cpg_downlist.nodeids[entries++] =
- my_old_member_list[i];
- }
- }
- }
g_req_exec_cpg_downlist.left_nodes = entries;
}
@@ -531,11 +527,20 @@
my_member_list_entries * sizeof (unsigned int));
my_old_member_list_entries = my_member_list_entries;
+ if (downlist_state == CPG_DOWNLIST_WAITING_FOR_MESSAGES) {
+ downlist_master_choose_and_send ();
+ }
+
+ downlist_messages_delete ();
+ downlist_state = CPG_DOWNLIST_NONE;
+
notify_lib_totem_membership (NULL, my_member_list_entries, my_member_list);
}
static void cpg_sync_abort (void)
{
+ downlist_state = CPG_DOWNLIST_NONE;
+ downlist_messages_delete ();
}
static int notify_lib_totem_membership (
@@ -706,11 +711,101 @@
return CPG_OK;
}
+static struct downlist_msg* downlist_master_choose (void)
+{
+ struct downlist_msg *cmp;
+ struct downlist_msg *best = NULL;
+ struct list_head *iter;
+
+ for (iter = downlist_messages_head.next;
+ iter != &downlist_messages_head;
+ iter = iter->next) {
+
+ cmp = list_entry(iter, struct downlist_msg, list);
+ if (best == NULL) {
+ best = cmp;
+ continue;
+ }
+
+ if (cmp->old_members < best->old_members) {
+ continue;
+ }
+ else if (cmp->old_members > best->old_members) {
+ best = cmp;
+ }
+ else if (cmp->sender_nodeid < best->sender_nodeid) {
+ best = cmp;
+ }
+
+ }
+ return best;
+}
+
+static void downlist_master_choose_and_send (void)
+{
+ struct downlist_msg *stored_msg;
+ struct list_head *iter;
+ mar_cpg_address_t *left_list = NULL;
+ int i;
+
+ downlist_state = CPG_DOWNLIST_APPLYING;
+
+ stored_msg = downlist_master_choose ();
+ if (!stored_msg) {
+ log_printf (LOGSYS_LEVEL_INFO, "NO chosen downlist");
+ return;
+ }
+
+ log_printf (LOGSYS_LEVEL_INFO, "chosen downlist from node %s",
+ api->totem_ifaces_print(stored_msg->sender_nodeid));
+
+ /* send events */
+ 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;
+
+ for (i = 0; i < stored_msg->left_nodes; i++) {
+ if (pi->nodeid == stored_msg->nodeids[i]) {
+ left_list[0].nodeid = pi->nodeid;
+ left_list[0].pid = pi->pid;
+ left_list[0].reason = CONFCHG_CPG_REASON_NODEDOWN;
+
+ notify_lib_joinlist(&pi->group, NULL,
+ 0, NULL,
+ 1, left_list,
+ MESSAGE_RES_CPG_CONFCHG_CALLBACK);
+ list_del (&pi->list);
+ free (pi);
+ break;
+ }
+ }
+ }
+}
+
+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;
+
+ stored_msg = list_entry(iter, struct downlist_msg, list);
+ list_del (&stored_msg->list);
+ free (stored_msg);
+ }
+}
+
+
static int cpg_exec_init_fn (struct corosync_api_v1 *corosync_api)
{
#ifdef COROSYNC_SOLARIS
logsys_subsys_init();
#endif
+ list_init (&downlist_messages_head);
api = corosync_api;
return (0);
}
@@ -817,12 +912,17 @@
}
}
+static void exec_cpg_downlist_endian_convert_old (void *msg)
+{
+}
+
static void exec_cpg_downlist_endian_convert (void *msg)
{
struct req_exec_cpg_downlist *req_exec_cpg_downlist = msg;
unsigned int i;
req_exec_cpg_downlist->left_nodes = swab32(req_exec_cpg_downlist->left_nodes);
+ req_exec_cpg_downlist->old_members = swab32(req_exec_cpg_downlist->old_members);
for (i = 0; i < req_exec_cpg_downlist->left_nodes; i++) {
req_exec_cpg_downlist->nodeids[i] = swab32(req_exec_cpg_downlist->nodeids[i]);
@@ -908,43 +1008,63 @@
MESSAGE_RES_CPG_CONFCHG_CALLBACK);
}
-static void message_handler_req_exec_cpg_downlist (
+static void message_handler_req_exec_cpg_downlist_old (
const void *message,
unsigned int nodeid)
{
+ log_printf (LOGSYS_LEVEL_WARNING, "downlist OLD from node %d",
+ nodeid);
+}
+
+static void message_handler_req_exec_cpg_downlist(
+ const void *message,
+ unsigned int nodeid)
+{
const struct req_exec_cpg_downlist *req_exec_cpg_downlist = message;
int i;
- mar_cpg_address_t left_list[1];
struct list_head *iter;
+ struct downlist_msg *stored_msg;
+ int found;
- /*
- FOR OPTIMALIZATION - Make list of lists
- */
+ if (downlist_state != CPG_DOWNLIST_WAITING_FOR_MESSAGES) {
+ log_printf (LOGSYS_LEVEL_WARNING, "downlist left_list: %d received in state %d",
+ req_exec_cpg_downlist->left_nodes, downlist_state);
+ return;
+ }
+ else {
+ log_printf (LOGSYS_LEVEL_INFO, "downlist received left_list: %d",
+ req_exec_cpg_downlist->left_nodes);
+ }
- log_printf (LOGSYS_LEVEL_DEBUG, "downlist left_list: %d\n", req_exec_cpg_downlist->left_nodes);
+ stored_msg = malloc (sizeof (struct downlist_msg));
+ stored_msg->sender_nodeid = nodeid;
+ stored_msg->old_members = req_exec_cpg_downlist->old_members;
+ 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);
- 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;
+ for (i = 0; i < my_member_list_entries; i++) {
+ found = 0;
+ for (iter = downlist_messages_head.next;
+ iter != &downlist_messages_head;
+ iter = iter->next) {
- for (i = 0; i < req_exec_cpg_downlist->left_nodes; i++) {
- if (pi->nodeid == req_exec_cpg_downlist->nodeids[i]) {
- left_list[0].nodeid = pi->nodeid;
- left_list[0].pid = pi->pid;
- left_list[0].reason = CONFCHG_CPG_REASON_NODEDOWN;
-
- notify_lib_joinlist(&pi->group, NULL,
- 0, NULL,
- 1, left_list,
- MESSAGE_RES_CPG_CONFCHG_CALLBACK);
- list_del (&pi->list);
- free (pi);
- break;
+ stored_msg = list_entry(iter, struct downlist_msg, list);
+ if (my_member_list[i] == stored_msg->sender_nodeid) {
+ found = 1;
}
}
+ if (!found) {
+ return;
+ }
}
+
+ downlist_master_choose_and_send ();
}
+
static void message_handler_req_exec_cpg_procjoin (
const void *message,
unsigned int nodeid)
@@ -1081,6 +1201,8 @@
g_req_exec_cpg_downlist.header.id = SERVICE_ID_MAKE(CPG_SERVICE, MESSAGE_REQ_EXEC_CPG_DOWNLIST);
g_req_exec_cpg_downlist.header.size = sizeof(struct req_exec_cpg_downlist);
+ g_req_exec_cpg_downlist.old_members = my_old_member_list_entries;
+
iov.iov_base = (void *)&g_req_exec_cpg_downlist;
iov.iov_len = g_req_exec_cpg_downlist.header.size;