votequorum.c 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365
  1. /*
  2. * Copyright (c) 2009-2012 Red Hat, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Authors: Christine Caulfield (ccaulfie@redhat.com)
  7. * Fabio M. Di Nitto (fdinitto@redhat.com)
  8. *
  9. * This software licensed under BSD license, the text of which follows:
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. * - Redistributions in binary form must reproduce the above copyright notice,
  17. * this list of conditions and the following disclaimer in the documentation
  18. * and/or other materials provided with the distribution.
  19. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  33. * THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #include <config.h>
  36. #include <sys/types.h>
  37. #include <stdint.h>
  38. #include <qb/qbipc_common.h>
  39. #include "quorum.h"
  40. #include <corosync/corodefs.h>
  41. #include <corosync/list.h>
  42. #include <corosync/logsys.h>
  43. #include <corosync/coroapi.h>
  44. #include <corosync/icmap.h>
  45. #include <corosync/ipc_votequorum.h>
  46. #include "service.h"
  47. LOGSYS_DECLARE_SUBSYS ("VOTEQ");
  48. /*
  49. * interface with corosync
  50. */
  51. static struct corosync_api_v1 *corosync_api;
  52. /*
  53. * votequorum global config vars
  54. */
  55. #define DEFAULT_QDEVICE_TIMEOUT 10000
  56. static char qdevice_name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
  57. static struct cluster_node *qdevice = NULL;
  58. static unsigned int qdevice_timeout = DEFAULT_QDEVICE_TIMEOUT;
  59. static uint8_t qdevice_can_operate = 1;
  60. static uint8_t qdevice_is_registered = 0;
  61. static void *qdevice_reg_conn = NULL;
  62. static uint8_t two_node = 0;
  63. static uint8_t wait_for_all = 0;
  64. static uint8_t wait_for_all_status = 0;
  65. static uint8_t auto_tie_breaker = 0;
  66. static int lowest_node_id = -1;
  67. #define DEFAULT_LMS_WIN 10000
  68. static uint8_t last_man_standing = 0;
  69. static uint32_t last_man_standing_window = DEFAULT_LMS_WIN;
  70. static uint8_t leave_remove = 0;
  71. static uint32_t ev_barrier = 0;
  72. /*
  73. * votequorum_exec defines/structs/forward definitions
  74. */
  75. struct req_exec_quorum_nodeinfo {
  76. struct qb_ipc_request_header header __attribute__((aligned(8)));
  77. uint32_t nodeid;
  78. uint32_t votes;
  79. uint32_t expected_votes;
  80. uint32_t flags;
  81. } __attribute__((packed));
  82. struct req_exec_quorum_reconfigure {
  83. struct qb_ipc_request_header header __attribute__((aligned(8)));
  84. uint32_t nodeid;
  85. uint32_t value;
  86. uint8_t param;
  87. uint8_t _pad0;
  88. uint8_t _pad1;
  89. uint8_t _pad2;
  90. } __attribute__((packed));
  91. struct req_exec_quorum_qdevice_reg {
  92. struct qb_ipc_request_header header __attribute__((aligned(8)));
  93. uint32_t operation;
  94. char qdevice_name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
  95. } __attribute__((packed));
  96. struct req_exec_quorum_qdevice_reconfigure {
  97. struct qb_ipc_request_header header __attribute__((aligned(8)));
  98. char oldname[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
  99. char newname[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
  100. } __attribute__((packed));
  101. /*
  102. * votequorum_exec onwire version (via totem)
  103. */
  104. #include "votequorum.h"
  105. /*
  106. * votequorum_exec onwire messages (via totem)
  107. */
  108. #define MESSAGE_REQ_EXEC_VOTEQUORUM_NODEINFO 0
  109. #define MESSAGE_REQ_EXEC_VOTEQUORUM_RECONFIGURE 1
  110. #define MESSAGE_REQ_EXEC_VOTEQUORUM_QDEVICE_REG 2
  111. #define MESSAGE_REQ_EXEC_VOTEQUORUM_QDEVICE_RECONFIGURE 3
  112. static void votequorum_exec_send_expectedvotes_notification(void);
  113. static int votequorum_exec_send_quorum_notification(void *conn, uint64_t context);
  114. #define VOTEQUORUM_RECONFIG_PARAM_EXPECTED_VOTES 1
  115. #define VOTEQUORUM_RECONFIG_PARAM_NODE_VOTES 2
  116. static int votequorum_exec_send_reconfigure(uint8_t param, unsigned int nodeid, uint32_t value);
  117. /*
  118. * used by req_exec_quorum_qdevice_reg
  119. */
  120. #define VOTEQUORUM_QDEVICE_OPERATION_UNREGISTER 0
  121. #define VOTEQUORUM_QDEVICE_OPERATION_REGISTER 1
  122. /*
  123. * votequorum internal node status/view
  124. */
  125. #define NODE_FLAGS_QUORATE 1
  126. #define NODE_FLAGS_LEAVING 2
  127. #define NODE_FLAGS_WFASTATUS 4
  128. #define NODE_FLAGS_FIRST 8
  129. #define NODE_FLAGS_QDEVICE 16
  130. #define NODE_FLAGS_QDEVICE_STATE 32
  131. #define NODEID_QDEVICE 0
  132. typedef enum {
  133. NODESTATE_MEMBER=1,
  134. NODESTATE_DEAD,
  135. NODESTATE_LEAVING
  136. } nodestate_t;
  137. struct cluster_node {
  138. int node_id;
  139. nodestate_t state;
  140. uint32_t votes;
  141. uint32_t expected_votes;
  142. uint32_t flags;
  143. struct list_head list;
  144. };
  145. /*
  146. * votequorum internal quorum status
  147. */
  148. static uint8_t quorum;
  149. static uint8_t cluster_is_quorate;
  150. /*
  151. * votequorum membership data
  152. */
  153. static struct cluster_node *us;
  154. static struct list_head cluster_members_list;
  155. static unsigned int quorum_members[PROCESSOR_COUNT_MAX+1];
  156. static int quorum_members_entries = 0;
  157. static struct memb_ring_id quorum_ringid;
  158. /*
  159. * votequorum tracking
  160. */
  161. struct quorum_pd {
  162. unsigned char track_flags;
  163. int tracking_enabled;
  164. uint64_t tracking_context;
  165. struct list_head list;
  166. void *conn;
  167. };
  168. static struct list_head trackers_list;
  169. /*
  170. * votequorum timers
  171. */
  172. static corosync_timer_handle_t qdevice_timer;
  173. static int qdevice_timer_set = 0;
  174. static corosync_timer_handle_t last_man_standing_timer;
  175. static int last_man_standing_timer_set = 0;
  176. /*
  177. * Service Interfaces required by service_message_handler struct
  178. */
  179. static void votequorum_confchg_fn (
  180. enum totem_configuration_type configuration_type,
  181. const unsigned int *member_list, size_t member_list_entries,
  182. const unsigned int *left_list, size_t left_list_entries,
  183. const unsigned int *joined_list, size_t joined_list_entries,
  184. const struct memb_ring_id *ring_id);
  185. static quorum_set_quorate_fn_t quorum_callback;
  186. /*
  187. * votequorum_exec handler and definitions
  188. */
  189. static char *votequorum_exec_init_fn (struct corosync_api_v1 *api);
  190. static int votequorum_exec_exit_fn (void);
  191. static int votequorum_exec_send_nodeinfo(uint32_t nodeid);
  192. static void message_handler_req_exec_votequorum_nodeinfo (
  193. const void *message,
  194. unsigned int nodeid);
  195. static void exec_votequorum_nodeinfo_endian_convert (void *message);
  196. static void message_handler_req_exec_votequorum_reconfigure (
  197. const void *message,
  198. unsigned int nodeid);
  199. static void exec_votequorum_reconfigure_endian_convert (void *message);
  200. static void message_handler_req_exec_votequorum_qdevice_reg (
  201. const void *message,
  202. unsigned int nodeid);
  203. static void exec_votequorum_qdevice_reg_endian_convert (void *message);
  204. static void message_handler_req_exec_votequorum_qdevice_reconfigure (
  205. const void *message,
  206. unsigned int nodeid);
  207. static void exec_votequorum_qdevice_reconfigure_endian_convert (void *message);
  208. static struct corosync_exec_handler votequorum_exec_engine[] =
  209. {
  210. { /* 0 */
  211. .exec_handler_fn = message_handler_req_exec_votequorum_nodeinfo,
  212. .exec_endian_convert_fn = exec_votequorum_nodeinfo_endian_convert
  213. },
  214. { /* 1 */
  215. .exec_handler_fn = message_handler_req_exec_votequorum_reconfigure,
  216. .exec_endian_convert_fn = exec_votequorum_reconfigure_endian_convert
  217. },
  218. { /* 2 */
  219. .exec_handler_fn = message_handler_req_exec_votequorum_qdevice_reg,
  220. .exec_endian_convert_fn = exec_votequorum_qdevice_reg_endian_convert
  221. },
  222. { /* 3 */
  223. .exec_handler_fn = message_handler_req_exec_votequorum_qdevice_reconfigure,
  224. .exec_endian_convert_fn = exec_votequorum_qdevice_reconfigure_endian_convert
  225. },
  226. };
  227. /*
  228. * Library Handler and Functions Definitions
  229. */
  230. static int quorum_lib_init_fn (void *conn);
  231. static int quorum_lib_exit_fn (void *conn);
  232. static void message_handler_req_lib_votequorum_getinfo (void *conn,
  233. const void *message);
  234. static void message_handler_req_lib_votequorum_setexpected (void *conn,
  235. const void *message);
  236. static void message_handler_req_lib_votequorum_setvotes (void *conn,
  237. const void *message);
  238. static void message_handler_req_lib_votequorum_trackstart (void *conn,
  239. const void *message);
  240. static void message_handler_req_lib_votequorum_trackstop (void *conn,
  241. const void *message);
  242. static void message_handler_req_lib_votequorum_qdevice_register (void *conn,
  243. const void *message);
  244. static void message_handler_req_lib_votequorum_qdevice_unregister (void *conn,
  245. const void *message);
  246. static void message_handler_req_lib_votequorum_qdevice_update (void *conn,
  247. const void *message);
  248. static void message_handler_req_lib_votequorum_qdevice_poll (void *conn,
  249. const void *message);
  250. static void message_handler_req_lib_votequorum_qdevice_getinfo (void *conn,
  251. const void *message);
  252. static struct corosync_lib_handler quorum_lib_service[] =
  253. {
  254. { /* 0 */
  255. .lib_handler_fn = message_handler_req_lib_votequorum_getinfo,
  256. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  257. },
  258. { /* 1 */
  259. .lib_handler_fn = message_handler_req_lib_votequorum_setexpected,
  260. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  261. },
  262. { /* 2 */
  263. .lib_handler_fn = message_handler_req_lib_votequorum_setvotes,
  264. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  265. },
  266. { /* 3 */
  267. .lib_handler_fn = message_handler_req_lib_votequorum_trackstart,
  268. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  269. },
  270. { /* 4 */
  271. .lib_handler_fn = message_handler_req_lib_votequorum_trackstop,
  272. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  273. },
  274. { /* 5 */
  275. .lib_handler_fn = message_handler_req_lib_votequorum_qdevice_register,
  276. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  277. },
  278. { /* 6 */
  279. .lib_handler_fn = message_handler_req_lib_votequorum_qdevice_unregister,
  280. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  281. },
  282. { /* 7 */
  283. .lib_handler_fn = message_handler_req_lib_votequorum_qdevice_update,
  284. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  285. },
  286. { /* 8 */
  287. .lib_handler_fn = message_handler_req_lib_votequorum_qdevice_poll,
  288. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  289. },
  290. { /* 9 */
  291. .lib_handler_fn = message_handler_req_lib_votequorum_qdevice_getinfo,
  292. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  293. }
  294. };
  295. static struct corosync_service_engine votequorum_service_engine = {
  296. .name = "corosync vote quorum service v1.0",
  297. .id = VOTEQUORUM_SERVICE,
  298. .priority = 2,
  299. .private_data_size = sizeof (struct quorum_pd),
  300. .allow_inquorate = CS_LIB_ALLOW_INQUORATE,
  301. .flow_control = COROSYNC_LIB_FLOW_CONTROL_REQUIRED,
  302. .lib_init_fn = quorum_lib_init_fn,
  303. .lib_exit_fn = quorum_lib_exit_fn,
  304. .lib_engine = quorum_lib_service,
  305. .lib_engine_count = sizeof (quorum_lib_service) / sizeof (struct corosync_lib_handler),
  306. .exec_init_fn = votequorum_exec_init_fn,
  307. .exec_exit_fn = votequorum_exec_exit_fn,
  308. .exec_engine = votequorum_exec_engine,
  309. .exec_engine_count = sizeof (votequorum_exec_engine) / sizeof (struct corosync_exec_handler),
  310. .confchg_fn = votequorum_confchg_fn,
  311. .sync_mode = CS_SYNC_V1
  312. };
  313. struct corosync_service_engine *votequorum_get_service_engine_ver0 (void)
  314. {
  315. return (&votequorum_service_engine);
  316. }
  317. static struct default_service votequorum_service[] = {
  318. {
  319. .name = "corosync_votequorum",
  320. .ver = 0,
  321. .loader = votequorum_get_service_engine_ver0
  322. },
  323. };
  324. /*
  325. * common/utility macros/functions
  326. */
  327. #define max(a,b) (((a) > (b)) ? (a) : (b))
  328. #define list_iterate(v, head) \
  329. for (v = (head)->next; v != head; v = v->next)
  330. static void node_add_ordered(struct cluster_node *newnode)
  331. {
  332. struct cluster_node *node = NULL;
  333. struct list_head *tmp;
  334. struct list_head *newlist = &newnode->list;
  335. ENTER();
  336. list_iterate(tmp, &cluster_members_list) {
  337. node = list_entry(tmp, struct cluster_node, list);
  338. if (newnode->node_id < node->node_id) {
  339. break;
  340. }
  341. }
  342. if (!node) {
  343. list_add(&newnode->list, &cluster_members_list);
  344. } else {
  345. newlist->prev = tmp->prev;
  346. newlist->next = tmp;
  347. tmp->prev->next = newlist;
  348. tmp->prev = newlist;
  349. }
  350. LEAVE();
  351. }
  352. static struct cluster_node *allocate_node(unsigned int nodeid)
  353. {
  354. struct cluster_node *cl;
  355. ENTER();
  356. cl = malloc(sizeof(struct cluster_node));
  357. if (cl) {
  358. memset(cl, 0, sizeof(struct cluster_node));
  359. cl->node_id = nodeid;
  360. if (nodeid != NODEID_QDEVICE) {
  361. node_add_ordered(cl);
  362. }
  363. }
  364. LEAVE();
  365. return cl;
  366. }
  367. static struct cluster_node *find_node_by_nodeid(unsigned int nodeid)
  368. {
  369. struct cluster_node *node;
  370. struct list_head *tmp;
  371. ENTER();
  372. if (nodeid == us->node_id) {
  373. LEAVE();
  374. return us;
  375. }
  376. if (nodeid == NODEID_QDEVICE) {
  377. LEAVE();
  378. return qdevice;
  379. }
  380. list_iterate(tmp, &cluster_members_list) {
  381. node = list_entry(tmp, struct cluster_node, list);
  382. if (node->node_id == nodeid) {
  383. LEAVE();
  384. return node;
  385. }
  386. }
  387. LEAVE();
  388. return NULL;
  389. }
  390. static void get_lowest_node_id(void)
  391. {
  392. struct cluster_node *node = NULL;
  393. struct list_head *tmp;
  394. ENTER();
  395. lowest_node_id = us->node_id;
  396. list_iterate(tmp, &cluster_members_list) {
  397. node = list_entry(tmp, struct cluster_node, list);
  398. if ((node->state == NODESTATE_MEMBER) &&
  399. (node->node_id < lowest_node_id)) {
  400. lowest_node_id = node->node_id;
  401. }
  402. }
  403. log_printf(LOGSYS_LEVEL_DEBUG, "lowest node id: %d us: %d", lowest_node_id, us->node_id);
  404. icmap_set_uint32("runtime.votequorum.lowest_node_id", lowest_node_id);
  405. LEAVE();
  406. }
  407. static int check_low_node_id_partition(void)
  408. {
  409. struct cluster_node *node = NULL;
  410. struct list_head *tmp;
  411. int found = 0;
  412. ENTER();
  413. list_iterate(tmp, &cluster_members_list) {
  414. node = list_entry(tmp, struct cluster_node, list);
  415. if ((node->state == NODESTATE_MEMBER) &&
  416. (node->node_id == lowest_node_id)) {
  417. found = 1;
  418. }
  419. }
  420. LEAVE();
  421. return found;
  422. }
  423. static void decode_flags(uint32_t flags)
  424. {
  425. log_printf(LOGSYS_LEVEL_DEBUG,
  426. "flags: quorate: %s Leaving: %s WFA Status: %s First: %s Qdevice: %s QdeviceState: %s",
  427. (flags & NODE_FLAGS_QUORATE)?"Yes":"No",
  428. (flags & NODE_FLAGS_LEAVING)?"Yes":"No",
  429. (flags & NODE_FLAGS_WFASTATUS)?"Yes":"No",
  430. (flags & NODE_FLAGS_FIRST)?"Yes":"No",
  431. (flags & NODE_FLAGS_QDEVICE)?"Yes":"No",
  432. (flags & NODE_FLAGS_QDEVICE_STATE)?"Yes":"No");
  433. }
  434. static void update_wait_for_all_status(uint8_t wfa_status)
  435. {
  436. wait_for_all_status = wfa_status;
  437. if (wait_for_all_status) {
  438. us->flags |= NODE_FLAGS_WFASTATUS;
  439. } else {
  440. us->flags &= ~NODE_FLAGS_WFASTATUS;
  441. }
  442. icmap_set_uint8("runtime.votequorum.wait_for_all_status",
  443. wait_for_all_status);
  444. }
  445. static void update_two_node(void)
  446. {
  447. icmap_set_uint8("runtime.votequorum.two_node", two_node);
  448. }
  449. static void update_ev_barrier(uint32_t expected_votes)
  450. {
  451. ev_barrier = expected_votes;
  452. icmap_set_uint32("runtime.votequorum.ev_barrier", ev_barrier);
  453. }
  454. static void update_qdevice_can_operate(uint8_t status)
  455. {
  456. qdevice_can_operate = status;
  457. icmap_set_uint8("runtime.votequorum.qdevice_can_operate", qdevice_can_operate);
  458. }
  459. /*
  460. * quorum calculation core bits
  461. */
  462. static int calculate_quorum(int allow_decrease, unsigned int max_expected, unsigned int *ret_total_votes)
  463. {
  464. struct list_head *nodelist;
  465. struct cluster_node *node;
  466. unsigned int total_votes = 0;
  467. unsigned int highest_expected = 0;
  468. unsigned int newquorum, q1, q2;
  469. unsigned int total_nodes = 0;
  470. ENTER();
  471. if ((leave_remove) && (allow_decrease) && (max_expected)) {
  472. max_expected = max(ev_barrier, max_expected);
  473. }
  474. list_iterate(nodelist, &cluster_members_list) {
  475. node = list_entry(nodelist, struct cluster_node, list);
  476. log_printf(LOGSYS_LEVEL_DEBUG, "node %u state=%d, votes=%u, expected=%u",
  477. node->node_id, node->state, node->votes, node->expected_votes);
  478. if (node->state == NODESTATE_MEMBER) {
  479. if (max_expected) {
  480. node->expected_votes = max_expected;
  481. } else {
  482. highest_expected = max(highest_expected, node->expected_votes);
  483. }
  484. total_votes += node->votes;
  485. total_nodes++;
  486. }
  487. }
  488. if (qdevice_is_registered) {
  489. log_printf(LOGSYS_LEVEL_DEBUG, "node %u state=%d, votes=%u",
  490. qdevice->node_id, qdevice->state, qdevice->votes);
  491. if (qdevice->state == NODESTATE_MEMBER) {
  492. total_votes += qdevice->votes;
  493. total_nodes++;
  494. }
  495. }
  496. if (max_expected > 0) {
  497. highest_expected = max_expected;
  498. }
  499. /*
  500. * This quorum calculation is taken from the OpenVMS Cluster Systems
  501. * manual, but, then, you guessed that didn't you
  502. */
  503. q1 = (highest_expected + 2) / 2;
  504. q2 = (total_votes + 2) / 2;
  505. newquorum = max(q1, q2);
  506. /*
  507. * Normally quorum never decreases but the system administrator can
  508. * force it down by setting expected votes to a maximum value
  509. */
  510. if (!allow_decrease) {
  511. newquorum = max(quorum, newquorum);
  512. }
  513. /*
  514. * The special two_node mode allows each of the two nodes to retain
  515. * quorum if the other fails. Only one of the two should live past
  516. * fencing (as both nodes try to fence each other in split-brain.)
  517. * Also: if there are more than two nodes, force us inquorate to avoid
  518. * any damage or confusion.
  519. */
  520. if (two_node && total_nodes <= 2) {
  521. newquorum = 1;
  522. }
  523. if (ret_total_votes) {
  524. *ret_total_votes = total_votes;
  525. }
  526. LEAVE();
  527. return newquorum;
  528. }
  529. static void are_we_quorate(unsigned int total_votes)
  530. {
  531. int quorate;
  532. int quorum_change = 0;
  533. ENTER();
  534. /*
  535. * wait for all nodes to show up before granting quorum
  536. */
  537. if ((wait_for_all) && (wait_for_all_status)) {
  538. if (total_votes != us->expected_votes) {
  539. log_printf(LOGSYS_LEVEL_NOTICE,
  540. "Waiting for all cluster members. "
  541. "Current votes: %d expected_votes: %d",
  542. total_votes, us->expected_votes);
  543. cluster_is_quorate = 0;
  544. return;
  545. }
  546. update_wait_for_all_status(0);
  547. }
  548. if (quorum > total_votes) {
  549. quorate = 0;
  550. } else {
  551. quorate = 1;
  552. get_lowest_node_id();
  553. }
  554. if ((auto_tie_breaker) &&
  555. (total_votes == (us->expected_votes / 2)) &&
  556. (check_low_node_id_partition() == 1)) {
  557. quorate = 1;
  558. }
  559. if (cluster_is_quorate && !quorate) {
  560. quorum_change = 1;
  561. log_printf(LOGSYS_LEVEL_DEBUG, "quorum lost, blocking activity");
  562. }
  563. if (!cluster_is_quorate && quorate) {
  564. quorum_change = 1;
  565. log_printf(LOGSYS_LEVEL_DEBUG, "quorum regained, resuming activity");
  566. }
  567. cluster_is_quorate = quorate;
  568. if (cluster_is_quorate) {
  569. us->flags |= NODE_FLAGS_QUORATE;
  570. } else {
  571. us->flags &= ~NODE_FLAGS_QUORATE;
  572. }
  573. if (wait_for_all) {
  574. if (quorate) {
  575. update_wait_for_all_status(0);
  576. } else {
  577. update_wait_for_all_status(1);
  578. }
  579. }
  580. if (quorum_change) {
  581. quorum_callback(quorum_members, quorum_members_entries,
  582. cluster_is_quorate, &quorum_ringid);
  583. }
  584. LEAVE();
  585. }
  586. /*
  587. * Recalculate cluster quorum, set quorate and notify changes
  588. */
  589. static void recalculate_quorum(int allow_decrease, int by_current_nodes)
  590. {
  591. unsigned int total_votes = 0;
  592. int cluster_members = 0;
  593. struct list_head *nodelist;
  594. struct cluster_node *node;
  595. ENTER();
  596. list_iterate(nodelist, &cluster_members_list) {
  597. node = list_entry(nodelist, struct cluster_node, list);
  598. if (node->state == NODESTATE_MEMBER) {
  599. if (by_current_nodes) {
  600. cluster_members++;
  601. }
  602. total_votes += node->votes;
  603. }
  604. }
  605. if (qdevice->votes) {
  606. total_votes += qdevice->votes;
  607. if (by_current_nodes) {
  608. cluster_members++;
  609. }
  610. }
  611. /*
  612. * Keep expected_votes at the highest number of votes in the cluster
  613. */
  614. log_printf(LOGSYS_LEVEL_DEBUG, "total_votes=%d, expected_votes=%d", total_votes, us->expected_votes);
  615. if (total_votes > us->expected_votes) {
  616. us->expected_votes = total_votes;
  617. votequorum_exec_send_expectedvotes_notification();
  618. }
  619. quorum = calculate_quorum(allow_decrease, cluster_members, &total_votes);
  620. are_we_quorate(total_votes);
  621. votequorum_exec_send_quorum_notification(NULL, 0L);
  622. LEAVE();
  623. }
  624. /*
  625. * configuration bits and pieces
  626. */
  627. static int votequorum_read_nodelist_configuration(uint32_t *votes,
  628. uint32_t *nodes,
  629. uint32_t *expected_votes)
  630. {
  631. icmap_iter_t iter;
  632. const char *iter_key;
  633. char tmp_key[ICMAP_KEYNAME_MAXLEN];
  634. uint32_t our_pos, node_pos;
  635. uint32_t nodecount = 0;
  636. uint32_t nodelist_expected_votes = 0;
  637. uint32_t node_votes = 0;
  638. int res = 0;
  639. ENTER();
  640. if (icmap_get_uint32("nodelist.local_node_pos", &our_pos) != CS_OK) {
  641. log_printf(LOGSYS_LEVEL_DEBUG,
  642. "No nodelist defined or our node is not in the nodelist");
  643. return 0;
  644. }
  645. iter = icmap_iter_init("nodelist.node.");
  646. while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
  647. res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, tmp_key);
  648. if (res != 2) {
  649. continue;
  650. }
  651. if (strcmp(tmp_key, "ring0_addr") != 0) {
  652. continue;
  653. }
  654. nodecount++;
  655. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.quorum_votes", node_pos);
  656. if (icmap_get_uint32(tmp_key, &node_votes) != CS_OK) {
  657. node_votes = 1;
  658. }
  659. nodelist_expected_votes = nodelist_expected_votes + node_votes;
  660. if (node_pos == our_pos) {
  661. *votes = node_votes;
  662. }
  663. }
  664. *expected_votes = nodelist_expected_votes;
  665. *nodes = nodecount;
  666. icmap_iter_finalize(iter);
  667. LEAVE();
  668. return 1;
  669. }
  670. static int votequorum_qdevice_is_configured(uint32_t *qdevice_votes)
  671. {
  672. char *qdevice_model = NULL;
  673. ENTER();
  674. if ((icmap_get_string("quorum.device.model", &qdevice_model) == CS_OK) &&
  675. (strlen(qdevice_model))) {
  676. free(qdevice_model);
  677. if (icmap_get_uint32("quorum.device.votes", qdevice_votes) != CS_OK) {
  678. *qdevice_votes = -1;
  679. }
  680. if (icmap_get_uint32("quorum.device.timeout", &qdevice_timeout) != CS_OK) {
  681. qdevice_timeout = DEFAULT_QDEVICE_TIMEOUT;
  682. }
  683. update_qdevice_can_operate(1);
  684. return 1;
  685. }
  686. LEAVE();
  687. return 0;
  688. }
  689. /*
  690. * votequorum_readconfig_static is executed before
  691. * votequorum_readconfig_dynamic
  692. *
  693. * errors from _static are fatal
  694. * errors from _dynamic need to be handled at runtime without self-destruction
  695. *
  696. * TODO: static/dynamic shares a lot of checks _and_
  697. * there are probably more options we can change at runtime
  698. * than we allow now. Review this in 2.1
  699. */
  700. static char *votequorum_readconfig_static(void)
  701. {
  702. uint32_t node_votes = 0, qdevice_votes = 0;
  703. uint32_t node_expected_votes = 0, expected_votes = 0;
  704. uint32_t node_count = 0;
  705. int have_nodelist, have_qdevice;
  706. ENTER();
  707. log_printf(LOGSYS_LEVEL_DEBUG, "Reading static configuration");
  708. /*
  709. * gather basic data here
  710. */
  711. icmap_get_uint32("quorum.expected_votes", &expected_votes);
  712. have_nodelist = votequorum_read_nodelist_configuration(&node_votes, &node_count, &node_expected_votes);
  713. have_qdevice = votequorum_qdevice_is_configured(&qdevice_votes);
  714. icmap_get_uint8("quorum.two_node", &two_node);
  715. update_two_node();
  716. /*
  717. * do basic config verification
  718. */
  719. if ((!have_nodelist) && (!expected_votes)) {
  720. return ((char *)"configuration error: nodelist or quorum.expected_votes must be configured!");
  721. }
  722. if ((two_node) && (have_qdevice)) {
  723. return ((char *)"configuration error: two_node and quorum device cannot be configured at the same time!");
  724. }
  725. if ((expected_votes) && (have_qdevice) && (qdevice_votes == -1)) {
  726. return ((char *)"configuration error: quorum.device.votes must be specified when quorum.expected_votes is set");
  727. }
  728. if ((have_qdevice) &&
  729. (qdevice_votes == -1) &&
  730. (have_nodelist) &&
  731. (node_count != node_expected_votes)) {
  732. return ((char *)"configuration error: quorum.device.votes must be specified when not all nodes votes 1");
  733. }
  734. if ((qdevice_votes > 0) && (expected_votes)) {
  735. int delta = expected_votes - qdevice_votes;
  736. if (delta < 2) {
  737. return ((char *)"configuration error: quorum.device.votes is too high or expected_votes is too low");
  738. }
  739. }
  740. /*
  741. * Enable special features
  742. */
  743. if (two_node) {
  744. wait_for_all = 1;
  745. }
  746. icmap_get_uint8("quorum.leave_remove", &leave_remove);
  747. icmap_get_uint8("quorum.wait_for_all", &wait_for_all);
  748. icmap_get_uint8("quorum.auto_tie_breaker", &auto_tie_breaker);
  749. icmap_get_uint8("quorum.last_man_standing", &last_man_standing);
  750. icmap_get_uint32("quorum.last_man_standing_window", &last_man_standing_window);
  751. if ((have_qdevice) && (last_man_standing)) {
  752. return ((char *)"configuration error: quorum device is not compatible with last_man_standing feature");
  753. }
  754. if ((have_qdevice) && (auto_tie_breaker)) {
  755. return ((char *)"configuration error: quorum device is not compatible with auto_tie_breaker feature");
  756. }
  757. LEAVE();
  758. return (NULL);
  759. }
  760. static void votequorum_readconfig_dynamic(void)
  761. {
  762. uint32_t node_votes = 0, qdevice_votes = 0;
  763. uint32_t node_expected_votes = 0, expected_votes = 0;
  764. uint32_t node_count = 0;
  765. int have_nodelist, have_qdevice;
  766. ENTER();
  767. log_printf(LOGSYS_LEVEL_DEBUG, "Reading dynamic configuration");
  768. /*
  769. * gather basic data here
  770. * TODO: make it common with static!!!
  771. */
  772. icmap_get_uint32("quorum.expected_votes", &expected_votes);
  773. have_nodelist = votequorum_read_nodelist_configuration(&node_votes, &node_count, &node_expected_votes);
  774. have_qdevice = votequorum_qdevice_is_configured(&qdevice_votes);
  775. icmap_get_uint8("quorum.two_node", &two_node);
  776. /*
  777. * do config verification and enablement
  778. */
  779. if ((!have_nodelist) && (!expected_votes)) {
  780. log_printf(LOGSYS_LEVEL_CRIT, "configuration error: nodelist or quorum.expected_votes must be configured!");
  781. log_printf(LOGSYS_LEVEL_CRIT, "will continue with current runtime data");
  782. goto out;
  783. }
  784. /*
  785. * two_node and qdevice are not compatible in the same config.
  786. * try to make an educated guess of what to do
  787. */
  788. if ((two_node) && (have_qdevice)) {
  789. log_printf(LOGSYS_LEVEL_CRIT, "configuration error: two_node and quorum device cannot be configured at the same time!");
  790. if (qdevice_is_registered) {
  791. log_printf(LOGSYS_LEVEL_CRIT, "quorum device is registered, disabling two_node");
  792. two_node = 0;
  793. } else {
  794. log_printf(LOGSYS_LEVEL_CRIT, "quorum device is not registered, allowing two_node");
  795. update_qdevice_can_operate(0);
  796. }
  797. }
  798. /*
  799. * quorum device is not compatible with last_man_standing and auto_tie_breaker
  800. * neither lms or atb can be set at runtime, so there is no need to check for
  801. * runtime incompatibilities, but qdevice can be configured _after_ LMS and ATB have
  802. * been enabled at startup.
  803. */
  804. if ((have_qdevice) && (last_man_standing)) {
  805. log_printf(LOGSYS_LEVEL_CRIT, "configuration error: quorum.device is not compatible with last_man_standing");
  806. log_printf(LOGSYS_LEVEL_CRIT, "disabling quorum device operations");
  807. update_qdevice_can_operate(0);
  808. }
  809. if ((have_qdevice) && (auto_tie_breaker)) {
  810. log_printf(LOGSYS_LEVEL_CRIT, "configuration error: quorum.device is not compatible with auto_tie_breaker");
  811. log_printf(LOGSYS_LEVEL_CRIT, "disabling quorum device operations");
  812. update_qdevice_can_operate(0);
  813. }
  814. /*
  815. * if user specifies quorum.expected_votes + quorum.device but NOT the device.votes
  816. * we don't know what the quorum device should vote.
  817. */
  818. if ((expected_votes) && (have_qdevice) && (qdevice_votes == -1)) {
  819. log_printf(LOGSYS_LEVEL_CRIT, "configuration error: quorum.device.votes must be specified when quorum.expected_votes is set");
  820. log_printf(LOGSYS_LEVEL_CRIT, "disabling quorum device operations");
  821. update_qdevice_can_operate(0);
  822. }
  823. /*
  824. * if user specifies a node list with uneven votes and no device.votes
  825. * we cannot autocalculate the votes
  826. */
  827. if ((have_qdevice) &&
  828. (qdevice_votes == -1) &&
  829. (have_nodelist) &&
  830. (node_count != node_expected_votes)) {
  831. log_printf(LOGSYS_LEVEL_CRIT, "configuration error: quorum.device.votes must be specified when not all nodes votes 1");
  832. log_printf(LOGSYS_LEVEL_CRIT, "disabling quorum device operations");
  833. update_qdevice_can_operate(0);
  834. }
  835. /*
  836. * validate quorum device votes vs expected_votes
  837. */
  838. if ((qdevice_votes > 0) && (expected_votes)) {
  839. int delta = expected_votes - qdevice_votes;
  840. if (delta < 2) {
  841. log_printf(LOGSYS_LEVEL_CRIT, "configuration error: quorum.device.votes is too high or expected_votes is too low");
  842. log_printf(LOGSYS_LEVEL_CRIT, "disabling quorum device operations");
  843. update_qdevice_can_operate(0);
  844. }
  845. }
  846. /*
  847. * automatically calculate device votes and adjust expected_votes from nodelist
  848. */
  849. if ((have_qdevice) &&
  850. (qdevice_votes == -1) &&
  851. (!expected_votes) &&
  852. (have_nodelist) &&
  853. (node_count == node_expected_votes)) {
  854. qdevice_votes = node_expected_votes - 1;
  855. node_expected_votes = node_expected_votes + qdevice_votes;
  856. }
  857. /*
  858. * set this node votes and expected_votes
  859. */
  860. if (have_nodelist) {
  861. us->votes = node_votes;
  862. us->expected_votes = node_expected_votes;
  863. } else {
  864. us->votes = 1;
  865. icmap_get_uint32("quorum.votes", &us->votes);
  866. }
  867. if (expected_votes) {
  868. us->expected_votes = expected_votes;
  869. }
  870. /*
  871. * set qdevice votes
  872. */
  873. if (!have_qdevice) {
  874. qdevice->votes = 0;
  875. }
  876. if (qdevice_votes != -1) {
  877. qdevice->votes = qdevice_votes;
  878. }
  879. update_ev_barrier(us->expected_votes);
  880. update_two_node();
  881. out:
  882. LEAVE();
  883. }
  884. static void votequorum_refresh_config(
  885. int32_t event,
  886. const char *key_name,
  887. struct icmap_notify_value new_val,
  888. struct icmap_notify_value old_val,
  889. void *user_data)
  890. {
  891. unsigned int old_votes;
  892. unsigned int old_expected;
  893. unsigned int old_qdevice_votes;
  894. ENTER();
  895. old_votes = us->votes;
  896. old_expected = us->expected_votes;
  897. old_qdevice_votes = qdevice->votes;
  898. /*
  899. * Reload the configuration
  900. */
  901. votequorum_readconfig_dynamic();
  902. /*
  903. * Check for fundamental changes that we need to propogate
  904. */
  905. if (old_votes != us->votes) {
  906. votequorum_exec_send_reconfigure(VOTEQUORUM_RECONFIG_PARAM_NODE_VOTES, us->node_id, us->votes);
  907. }
  908. if (old_expected != us->expected_votes) {
  909. votequorum_exec_send_reconfigure(VOTEQUORUM_RECONFIG_PARAM_EXPECTED_VOTES, us->node_id, us->expected_votes);
  910. }
  911. if (old_qdevice_votes != qdevice->votes) {
  912. votequorum_exec_send_reconfigure(VOTEQUORUM_RECONFIG_PARAM_NODE_VOTES, NODEID_QDEVICE, qdevice->votes);
  913. }
  914. LEAVE();
  915. }
  916. static void votequorum_exec_add_config_notification(void)
  917. {
  918. icmap_track_t icmap_track_nodelist = NULL;
  919. icmap_track_t icmap_track_quorum = NULL;
  920. ENTER();
  921. icmap_track_add("nodelist.",
  922. ICMAP_TRACK_ADD | ICMAP_TRACK_DELETE | ICMAP_TRACK_MODIFY | ICMAP_TRACK_PREFIX,
  923. votequorum_refresh_config,
  924. NULL,
  925. &icmap_track_nodelist);
  926. icmap_track_add("quorum.",
  927. ICMAP_TRACK_ADD | ICMAP_TRACK_DELETE | ICMAP_TRACK_MODIFY | ICMAP_TRACK_PREFIX,
  928. votequorum_refresh_config,
  929. NULL,
  930. &icmap_track_quorum);
  931. LEAVE();
  932. }
  933. /*
  934. * votequorum_exec core
  935. */
  936. static int votequorum_exec_send_reconfigure(uint8_t param, unsigned int nodeid, uint32_t value)
  937. {
  938. struct req_exec_quorum_reconfigure req_exec_quorum_reconfigure;
  939. struct iovec iov[1];
  940. int ret;
  941. ENTER();
  942. req_exec_quorum_reconfigure.nodeid = nodeid;
  943. req_exec_quorum_reconfigure.value = value;
  944. req_exec_quorum_reconfigure.param = param;
  945. req_exec_quorum_reconfigure._pad0 = 0;
  946. req_exec_quorum_reconfigure._pad1 = 0;
  947. req_exec_quorum_reconfigure._pad2 = 0;
  948. req_exec_quorum_reconfigure.header.id = SERVICE_ID_MAKE(VOTEQUORUM_SERVICE, MESSAGE_REQ_EXEC_VOTEQUORUM_RECONFIGURE);
  949. req_exec_quorum_reconfigure.header.size = sizeof(req_exec_quorum_reconfigure);
  950. iov[0].iov_base = (void *)&req_exec_quorum_reconfigure;
  951. iov[0].iov_len = sizeof(req_exec_quorum_reconfigure);
  952. ret = corosync_api->totem_mcast (iov, 1, TOTEM_AGREED);
  953. LEAVE();
  954. return ret;
  955. }
  956. static int votequorum_exec_send_nodeinfo(uint32_t nodeid)
  957. {
  958. struct req_exec_quorum_nodeinfo req_exec_quorum_nodeinfo;
  959. struct iovec iov[1];
  960. struct cluster_node *node;
  961. int ret;
  962. ENTER();
  963. node = find_node_by_nodeid(nodeid);
  964. if (!node) {
  965. return -1;
  966. }
  967. req_exec_quorum_nodeinfo.nodeid = nodeid;
  968. req_exec_quorum_nodeinfo.votes = node->votes;
  969. req_exec_quorum_nodeinfo.expected_votes = node->expected_votes;
  970. req_exec_quorum_nodeinfo.flags = node->flags;
  971. if (nodeid != NODEID_QDEVICE) {
  972. decode_flags(node->flags);
  973. }
  974. req_exec_quorum_nodeinfo.header.id = SERVICE_ID_MAKE(VOTEQUORUM_SERVICE, MESSAGE_REQ_EXEC_VOTEQUORUM_NODEINFO);
  975. req_exec_quorum_nodeinfo.header.size = sizeof(req_exec_quorum_nodeinfo);
  976. iov[0].iov_base = (void *)&req_exec_quorum_nodeinfo;
  977. iov[0].iov_len = sizeof(req_exec_quorum_nodeinfo);
  978. ret = corosync_api->totem_mcast (iov, 1, TOTEM_AGREED);
  979. LEAVE();
  980. return ret;
  981. }
  982. static int votequorum_exec_send_qdevice_reconfigure(const char *oldname, const char *newname)
  983. {
  984. struct req_exec_quorum_qdevice_reconfigure req_exec_quorum_qdevice_reconfigure;
  985. struct iovec iov[1];
  986. int ret;
  987. ENTER();
  988. req_exec_quorum_qdevice_reconfigure.header.id = SERVICE_ID_MAKE(VOTEQUORUM_SERVICE, MESSAGE_REQ_EXEC_VOTEQUORUM_QDEVICE_RECONFIGURE);
  989. req_exec_quorum_qdevice_reconfigure.header.size = sizeof(req_exec_quorum_qdevice_reconfigure);
  990. strcpy(req_exec_quorum_qdevice_reconfigure.oldname, oldname);
  991. strcpy(req_exec_quorum_qdevice_reconfigure.newname, newname);
  992. iov[0].iov_base = (void *)&req_exec_quorum_qdevice_reconfigure;
  993. iov[0].iov_len = sizeof(req_exec_quorum_qdevice_reconfigure);
  994. ret = corosync_api->totem_mcast (iov, 1, TOTEM_AGREED);
  995. LEAVE();
  996. return ret;
  997. }
  998. static int votequorum_exec_send_qdevice_reg(uint32_t operation, const char *qdevice_name_req)
  999. {
  1000. struct req_exec_quorum_qdevice_reg req_exec_quorum_qdevice_reg;
  1001. struct iovec iov[1];
  1002. int ret;
  1003. ENTER();
  1004. req_exec_quorum_qdevice_reg.header.id = SERVICE_ID_MAKE(VOTEQUORUM_SERVICE, MESSAGE_REQ_EXEC_VOTEQUORUM_QDEVICE_REG);
  1005. req_exec_quorum_qdevice_reg.header.size = sizeof(req_exec_quorum_qdevice_reg);
  1006. req_exec_quorum_qdevice_reg.operation = operation;
  1007. strcpy(req_exec_quorum_qdevice_reg.qdevice_name, qdevice_name_req);
  1008. iov[0].iov_base = (void *)&req_exec_quorum_qdevice_reg;
  1009. iov[0].iov_len = sizeof(req_exec_quorum_qdevice_reg);
  1010. ret = corosync_api->totem_mcast (iov, 1, TOTEM_AGREED);
  1011. LEAVE();
  1012. return ret;
  1013. }
  1014. static int votequorum_exec_send_quorum_notification(void *conn, uint64_t context)
  1015. {
  1016. struct res_lib_votequorum_notification *res_lib_votequorum_notification;
  1017. struct list_head *tmp;
  1018. struct cluster_node *node;
  1019. int cluster_members = 0;
  1020. int i = 0;
  1021. int size;
  1022. char *buf;
  1023. ENTER();
  1024. list_iterate(tmp, &cluster_members_list) {
  1025. node = list_entry(tmp, struct cluster_node, list);
  1026. cluster_members++;
  1027. }
  1028. if (qdevice_is_registered) {
  1029. cluster_members++;
  1030. }
  1031. size = sizeof(struct res_lib_votequorum_notification) + sizeof(struct votequorum_node) * cluster_members;
  1032. buf = alloca(size);
  1033. if (!buf) {
  1034. LEAVE();
  1035. return -1;
  1036. }
  1037. res_lib_votequorum_notification = (struct res_lib_votequorum_notification *)buf;
  1038. res_lib_votequorum_notification->quorate = cluster_is_quorate;
  1039. res_lib_votequorum_notification->node_list_entries = cluster_members;
  1040. res_lib_votequorum_notification->context = context;
  1041. list_iterate(tmp, &cluster_members_list) {
  1042. node = list_entry(tmp, struct cluster_node, list);
  1043. res_lib_votequorum_notification->node_list[i].nodeid = node->node_id;
  1044. res_lib_votequorum_notification->node_list[i++].state = node->state;
  1045. }
  1046. if (qdevice_is_registered) {
  1047. res_lib_votequorum_notification->node_list[i].nodeid = NODEID_QDEVICE;
  1048. res_lib_votequorum_notification->node_list[i++].state = qdevice->state;
  1049. }
  1050. res_lib_votequorum_notification->header.id = MESSAGE_RES_VOTEQUORUM_NOTIFICATION;
  1051. res_lib_votequorum_notification->header.size = size;
  1052. res_lib_votequorum_notification->header.error = CS_OK;
  1053. /* Send it to all interested parties */
  1054. if (conn) {
  1055. int ret = corosync_api->ipc_dispatch_send(conn, buf, size);
  1056. LEAVE();
  1057. return ret;
  1058. } else {
  1059. struct quorum_pd *qpd;
  1060. list_iterate(tmp, &trackers_list) {
  1061. qpd = list_entry(tmp, struct quorum_pd, list);
  1062. res_lib_votequorum_notification->context = qpd->tracking_context;
  1063. corosync_api->ipc_dispatch_send(qpd->conn, buf, size);
  1064. }
  1065. }
  1066. LEAVE();
  1067. return 0;
  1068. }
  1069. static void votequorum_exec_send_expectedvotes_notification(void)
  1070. {
  1071. struct res_lib_votequorum_expectedvotes_notification res_lib_votequorum_expectedvotes_notification;
  1072. struct quorum_pd *qpd;
  1073. struct list_head *tmp;
  1074. ENTER();
  1075. log_printf(LOGSYS_LEVEL_DEBUG, "Sending expected votes callback");
  1076. res_lib_votequorum_expectedvotes_notification.header.id = MESSAGE_RES_VOTEQUORUM_EXPECTEDVOTES_NOTIFICATION;
  1077. res_lib_votequorum_expectedvotes_notification.header.size = sizeof(res_lib_votequorum_expectedvotes_notification);
  1078. res_lib_votequorum_expectedvotes_notification.header.error = CS_OK;
  1079. res_lib_votequorum_expectedvotes_notification.expected_votes = us->expected_votes;
  1080. list_iterate(tmp, &trackers_list) {
  1081. qpd = list_entry(tmp, struct quorum_pd, list);
  1082. res_lib_votequorum_expectedvotes_notification.context = qpd->tracking_context;
  1083. corosync_api->ipc_dispatch_send(qpd->conn, &res_lib_votequorum_expectedvotes_notification,
  1084. sizeof(struct res_lib_votequorum_expectedvotes_notification));
  1085. }
  1086. LEAVE();
  1087. }
  1088. static void exec_votequorum_qdevice_reconfigure_endian_convert (void *message)
  1089. {
  1090. ENTER();
  1091. LEAVE();
  1092. }
  1093. static void message_handler_req_exec_votequorum_qdevice_reconfigure (
  1094. const void *message,
  1095. unsigned int nodeid)
  1096. {
  1097. const struct req_exec_quorum_qdevice_reconfigure *req_exec_quorum_qdevice_reconfigure = message;
  1098. ENTER();
  1099. log_printf(LOGSYS_LEVEL_DEBUG, "Received qdevice name change req from node %u [from: %s to: %s]",
  1100. nodeid,
  1101. req_exec_quorum_qdevice_reconfigure->oldname,
  1102. req_exec_quorum_qdevice_reconfigure->newname);
  1103. if (!strcmp(req_exec_quorum_qdevice_reconfigure->oldname, qdevice_name)) {
  1104. log_printf(LOGSYS_LEVEL_DEBUG, "Allowing qdevice rename");
  1105. memset(qdevice_name, 0, VOTEQUORUM_MAX_QDEVICE_NAME_LEN);
  1106. strcpy(qdevice_name, req_exec_quorum_qdevice_reconfigure->newname);
  1107. /*
  1108. * TODO: notify qdevices about name change?
  1109. * this is not relevant for now and can wait later on since
  1110. * qdevices are local only and libvotequorum is not final
  1111. */
  1112. }
  1113. LEAVE();
  1114. }
  1115. static void exec_votequorum_qdevice_reg_endian_convert (void *message)
  1116. {
  1117. struct req_exec_quorum_qdevice_reg *req_exec_quorum_qdevice_reg = message;
  1118. ENTER();
  1119. req_exec_quorum_qdevice_reg->operation = swab32(req_exec_quorum_qdevice_reg->operation);
  1120. LEAVE();
  1121. }
  1122. static void message_handler_req_exec_votequorum_qdevice_reg (
  1123. const void *message,
  1124. unsigned int nodeid)
  1125. {
  1126. const struct req_exec_quorum_qdevice_reg *req_exec_quorum_qdevice_reg = message;
  1127. struct res_lib_votequorum_status res_lib_votequorum_status;
  1128. int wipe_qdevice_name = 1;
  1129. struct cluster_node *node = NULL;
  1130. struct list_head *tmp;
  1131. cs_error_t error = CS_OK;
  1132. ENTER();
  1133. log_printf(LOGSYS_LEVEL_DEBUG, "Received qdevice op %u req from node %u [%s]",
  1134. req_exec_quorum_qdevice_reg->operation,
  1135. nodeid, req_exec_quorum_qdevice_reg->qdevice_name);
  1136. switch(req_exec_quorum_qdevice_reg->operation)
  1137. {
  1138. case VOTEQUORUM_QDEVICE_OPERATION_REGISTER:
  1139. if (nodeid != us->node_id) {
  1140. if (!strlen(qdevice_name)) {
  1141. log_printf(LOGSYS_LEVEL_DEBUG, "Remote qdevice name recorded");
  1142. strcpy(qdevice_name, req_exec_quorum_qdevice_reg->qdevice_name);
  1143. }
  1144. LEAVE();
  1145. return;
  1146. }
  1147. /*
  1148. * this should NEVER happen
  1149. */
  1150. if (!qdevice_reg_conn) {
  1151. log_printf(LOGSYS_LEVEL_WARNING, "Unable to determine origin of the qdevice register call!");
  1152. LEAVE();
  1153. return;
  1154. }
  1155. /*
  1156. * registering our own device in this case
  1157. */
  1158. if (!strlen(qdevice_name)) {
  1159. strcpy(qdevice_name, req_exec_quorum_qdevice_reg->qdevice_name);
  1160. }
  1161. /*
  1162. * check if it is our device or something else
  1163. */
  1164. if ((!strncmp(req_exec_quorum_qdevice_reg->qdevice_name,
  1165. qdevice_name, VOTEQUORUM_MAX_QDEVICE_NAME_LEN))) {
  1166. qdevice_is_registered = 1;
  1167. us->flags |= NODE_FLAGS_QDEVICE;
  1168. votequorum_exec_send_nodeinfo(NODEID_QDEVICE);
  1169. votequorum_exec_send_nodeinfo(us->node_id);
  1170. } else {
  1171. log_printf(LOGSYS_LEVEL_WARNING,
  1172. "A new qdevice with different name (new: %s old: %s) is trying to register!",
  1173. req_exec_quorum_qdevice_reg->qdevice_name, qdevice_name);
  1174. error = CS_ERR_EXIST;
  1175. }
  1176. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1177. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1178. res_lib_votequorum_status.header.error = error;
  1179. corosync_api->ipc_response_send(qdevice_reg_conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1180. qdevice_reg_conn = NULL;
  1181. break;
  1182. case VOTEQUORUM_QDEVICE_OPERATION_UNREGISTER:
  1183. list_iterate(tmp, &cluster_members_list) {
  1184. node = list_entry(tmp, struct cluster_node, list);
  1185. if ((node->state == NODESTATE_MEMBER) &&
  1186. (node->flags & NODE_FLAGS_QDEVICE)) {
  1187. wipe_qdevice_name = 0;
  1188. }
  1189. }
  1190. if (wipe_qdevice_name) {
  1191. memset(qdevice_name, 0, VOTEQUORUM_MAX_QDEVICE_NAME_LEN);
  1192. }
  1193. break;
  1194. }
  1195. LEAVE();
  1196. }
  1197. static void exec_votequorum_nodeinfo_endian_convert (void *message)
  1198. {
  1199. struct req_exec_quorum_nodeinfo *nodeinfo = message;
  1200. ENTER();
  1201. nodeinfo->nodeid = swab32(nodeinfo->nodeid);
  1202. nodeinfo->votes = swab32(nodeinfo->votes);
  1203. nodeinfo->expected_votes = swab32(nodeinfo->expected_votes);
  1204. nodeinfo->flags = swab32(nodeinfo->flags);
  1205. LEAVE();
  1206. }
  1207. static void message_handler_req_exec_votequorum_nodeinfo (
  1208. const void *message,
  1209. unsigned int sender_nodeid)
  1210. {
  1211. const struct req_exec_quorum_nodeinfo *req_exec_quorum_nodeinfo = message;
  1212. struct cluster_node *node = NULL;
  1213. int old_votes;
  1214. int old_expected;
  1215. uint32_t old_flags;
  1216. nodestate_t old_state;
  1217. int new_node = 0;
  1218. int allow_downgrade = 0;
  1219. int by_node = 0;
  1220. unsigned int nodeid = req_exec_quorum_nodeinfo->nodeid;
  1221. ENTER();
  1222. log_printf(LOGSYS_LEVEL_DEBUG, "got nodeinfo message from cluster node %u", sender_nodeid);
  1223. log_printf(LOGSYS_LEVEL_DEBUG, "nodeinfo message[%u]: votes: %d, expected: %d flags: %d",
  1224. nodeid,
  1225. req_exec_quorum_nodeinfo->votes,
  1226. req_exec_quorum_nodeinfo->expected_votes,
  1227. req_exec_quorum_nodeinfo->flags);
  1228. if (nodeid != NODEID_QDEVICE) {
  1229. decode_flags(req_exec_quorum_nodeinfo->flags);
  1230. }
  1231. node = find_node_by_nodeid(nodeid);
  1232. if (!node) {
  1233. node = allocate_node(nodeid);
  1234. new_node = 1;
  1235. }
  1236. if (!node) {
  1237. corosync_api->error_memory_failure();
  1238. LEAVE();
  1239. return;
  1240. }
  1241. if (new_node) {
  1242. old_votes = 0;
  1243. old_expected = 0;
  1244. old_state = NODESTATE_DEAD;
  1245. old_flags = 0;
  1246. } else {
  1247. old_votes = node->votes;
  1248. old_expected = node->expected_votes;
  1249. old_state = node->state;
  1250. old_flags = node->flags;
  1251. }
  1252. /* Update node state */
  1253. node->flags = req_exec_quorum_nodeinfo->flags;
  1254. if (nodeid != NODEID_QDEVICE) {
  1255. node->votes = req_exec_quorum_nodeinfo->votes;
  1256. } else {
  1257. if ((!cluster_is_quorate) &&
  1258. (req_exec_quorum_nodeinfo->flags & NODE_FLAGS_QUORATE)) {
  1259. node->votes = req_exec_quorum_nodeinfo->votes;
  1260. } else {
  1261. node->votes = max(node->votes, req_exec_quorum_nodeinfo->votes);
  1262. }
  1263. }
  1264. if (node->flags & NODE_FLAGS_LEAVING) {
  1265. node->state = NODESTATE_LEAVING;
  1266. allow_downgrade = 1;
  1267. by_node = 1;
  1268. } else {
  1269. if (nodeid != NODEID_QDEVICE) {
  1270. node->state = NODESTATE_MEMBER;
  1271. } else {
  1272. /*
  1273. * qdevice status is only local to the node
  1274. */
  1275. node->state = old_state;
  1276. }
  1277. }
  1278. if (nodeid != NODEID_QDEVICE) {
  1279. if ((!cluster_is_quorate) &&
  1280. (req_exec_quorum_nodeinfo->flags & NODE_FLAGS_QUORATE)) {
  1281. allow_downgrade = 1;
  1282. us->expected_votes = req_exec_quorum_nodeinfo->expected_votes;
  1283. }
  1284. if (req_exec_quorum_nodeinfo->flags & NODE_FLAGS_QUORATE) {
  1285. node->expected_votes = req_exec_quorum_nodeinfo->expected_votes;
  1286. } else {
  1287. node->expected_votes = us->expected_votes;
  1288. }
  1289. if ((last_man_standing) && (req_exec_quorum_nodeinfo->votes > 1)) {
  1290. log_printf(LOGSYS_LEVEL_WARNING, "Last Man Standing feature is supported only when all"
  1291. "cluster nodes votes are set to 1. Disabling LMS.");
  1292. last_man_standing = 0;
  1293. if (last_man_standing_timer_set) {
  1294. corosync_api->timer_delete(last_man_standing_timer);
  1295. last_man_standing_timer_set = 0;
  1296. }
  1297. }
  1298. }
  1299. if (new_node ||
  1300. nodeid == NODEID_QDEVICE ||
  1301. req_exec_quorum_nodeinfo->flags & NODE_FLAGS_FIRST ||
  1302. old_votes != node->votes ||
  1303. old_expected != node->expected_votes ||
  1304. old_flags != node->flags ||
  1305. old_state != node->state) {
  1306. recalculate_quorum(allow_downgrade, by_node);
  1307. }
  1308. if ((wait_for_all) &&
  1309. (!(req_exec_quorum_nodeinfo->flags & NODE_FLAGS_WFASTATUS)) &&
  1310. (req_exec_quorum_nodeinfo->flags & NODE_FLAGS_QUORATE)) {
  1311. update_wait_for_all_status(0);
  1312. }
  1313. LEAVE();
  1314. }
  1315. static void exec_votequorum_reconfigure_endian_convert (void *message)
  1316. {
  1317. struct req_exec_quorum_reconfigure *reconfigure = message;
  1318. ENTER();
  1319. reconfigure->nodeid = swab32(reconfigure->nodeid);
  1320. reconfigure->value = swab32(reconfigure->value);
  1321. LEAVE();
  1322. }
  1323. static void message_handler_req_exec_votequorum_reconfigure (
  1324. const void *message,
  1325. unsigned int nodeid)
  1326. {
  1327. const struct req_exec_quorum_reconfigure *req_exec_quorum_reconfigure = message;
  1328. struct cluster_node *node;
  1329. struct list_head *nodelist;
  1330. ENTER();
  1331. log_printf(LOGSYS_LEVEL_DEBUG, "got reconfigure message from cluster node %u for %u",
  1332. nodeid, req_exec_quorum_reconfigure->nodeid);
  1333. node = find_node_by_nodeid(req_exec_quorum_reconfigure->nodeid);
  1334. if (!node) {
  1335. LEAVE();
  1336. return;
  1337. }
  1338. switch(req_exec_quorum_reconfigure->param)
  1339. {
  1340. case VOTEQUORUM_RECONFIG_PARAM_EXPECTED_VOTES:
  1341. list_iterate(nodelist, &cluster_members_list) {
  1342. node = list_entry(nodelist, struct cluster_node, list);
  1343. if (node->state == NODESTATE_MEMBER) {
  1344. node->expected_votes = req_exec_quorum_reconfigure->value;
  1345. }
  1346. }
  1347. votequorum_exec_send_expectedvotes_notification();
  1348. update_ev_barrier(req_exec_quorum_reconfigure->value);
  1349. recalculate_quorum(1, 0); /* Allow decrease */
  1350. break;
  1351. case VOTEQUORUM_RECONFIG_PARAM_NODE_VOTES:
  1352. node->votes = req_exec_quorum_reconfigure->value;
  1353. recalculate_quorum(1, 0); /* Allow decrease */
  1354. break;
  1355. }
  1356. LEAVE();
  1357. }
  1358. static int votequorum_exec_exit_fn (void)
  1359. {
  1360. int ret = 0;
  1361. ENTER();
  1362. if (leave_remove) {
  1363. us->flags |= NODE_FLAGS_LEAVING;
  1364. ret = votequorum_exec_send_nodeinfo(us->node_id);
  1365. }
  1366. LEAVE();
  1367. return ret;
  1368. }
  1369. static char *votequorum_exec_init_fn (struct corosync_api_v1 *api)
  1370. {
  1371. #ifdef COROSYNC_SOLARIS
  1372. logsys_subsys_init();
  1373. #endif
  1374. ENTER();
  1375. list_init(&cluster_members_list);
  1376. list_init(&trackers_list);
  1377. /*
  1378. * Allocate a cluster_node for us
  1379. */
  1380. us = allocate_node(corosync_api->totem_nodeid_get());
  1381. if (!us) {
  1382. LEAVE();
  1383. return ((char *)"Could not allocate node.");
  1384. }
  1385. icmap_set_uint32("runtime.votequorum.this_node_id", us->node_id);
  1386. us->state = NODESTATE_MEMBER;
  1387. us->votes = 1;
  1388. us->flags |= NODE_FLAGS_FIRST;
  1389. if (wait_for_all) {
  1390. update_wait_for_all_status(1);
  1391. }
  1392. qdevice = allocate_node(NODEID_QDEVICE);
  1393. if (!qdevice) {
  1394. LEAVE();
  1395. return ((char *)"Could not allocate node.");
  1396. }
  1397. qdevice->state = NODESTATE_DEAD;
  1398. qdevice->votes = 0;
  1399. memset(qdevice_name, 0, VOTEQUORUM_MAX_QDEVICE_NAME_LEN);
  1400. votequorum_readconfig_dynamic();
  1401. recalculate_quorum(0, 0);
  1402. /*
  1403. * Listen for changes
  1404. */
  1405. votequorum_exec_add_config_notification();
  1406. /*
  1407. * Start us off with one node
  1408. */
  1409. votequorum_exec_send_nodeinfo(us->node_id);
  1410. LEAVE();
  1411. return (NULL);
  1412. }
  1413. /*
  1414. * votequorum service core
  1415. */
  1416. static void votequorum_last_man_standing_timer_fn(void *arg)
  1417. {
  1418. ENTER();
  1419. last_man_standing_timer_set = 0;
  1420. if (cluster_is_quorate) {
  1421. recalculate_quorum(1,1);
  1422. }
  1423. LEAVE();
  1424. }
  1425. static void votequorum_confchg_fn (
  1426. enum totem_configuration_type configuration_type,
  1427. const unsigned int *member_list, size_t member_list_entries,
  1428. const unsigned int *left_list, size_t left_list_entries,
  1429. const unsigned int *joined_list, size_t joined_list_entries,
  1430. const struct memb_ring_id *ring_id)
  1431. {
  1432. int i;
  1433. struct cluster_node *node;
  1434. ENTER();
  1435. if (member_list_entries > 1) {
  1436. us->flags &= ~NODE_FLAGS_FIRST;
  1437. }
  1438. if (left_list_entries) {
  1439. for (i = 0; i< left_list_entries; i++) {
  1440. node = find_node_by_nodeid(left_list[i]);
  1441. if (node) {
  1442. node->state = NODESTATE_DEAD;
  1443. }
  1444. }
  1445. }
  1446. if (last_man_standing) {
  1447. if (((member_list_entries >= quorum) && (left_list_entries)) ||
  1448. ((member_list_entries <= quorum) && (auto_tie_breaker) && (check_low_node_id_partition() == 1))) {
  1449. if (last_man_standing_timer_set) {
  1450. corosync_api->timer_delete(last_man_standing_timer);
  1451. last_man_standing_timer_set = 0;
  1452. }
  1453. corosync_api->timer_add_duration((unsigned long long)last_man_standing_window*1000000,
  1454. NULL, votequorum_last_man_standing_timer_fn,
  1455. &last_man_standing_timer);
  1456. last_man_standing_timer_set = 1;
  1457. }
  1458. }
  1459. if (member_list_entries) {
  1460. memcpy(quorum_members, member_list, sizeof(unsigned int) * member_list_entries);
  1461. quorum_members_entries = member_list_entries;
  1462. votequorum_exec_send_nodeinfo(us->node_id);
  1463. votequorum_exec_send_nodeinfo(NODEID_QDEVICE);
  1464. if (strlen(qdevice_name)) {
  1465. votequorum_exec_send_qdevice_reg(VOTEQUORUM_QDEVICE_OPERATION_REGISTER,
  1466. qdevice_name);
  1467. }
  1468. }
  1469. memcpy(&quorum_ringid, ring_id, sizeof(*ring_id));
  1470. if (left_list_entries) {
  1471. recalculate_quorum(0, 0);
  1472. }
  1473. if (configuration_type == TOTEM_CONFIGURATION_REGULAR) {
  1474. quorum_callback(quorum_members, quorum_members_entries,
  1475. cluster_is_quorate, &quorum_ringid);
  1476. }
  1477. LEAVE();
  1478. }
  1479. char *votequorum_init(struct corosync_api_v1 *api,
  1480. quorum_set_quorate_fn_t q_set_quorate_fn)
  1481. {
  1482. char *error;
  1483. ENTER();
  1484. if (q_set_quorate_fn == NULL) {
  1485. return ((char *)"Quorate function not set");
  1486. }
  1487. corosync_api = api;
  1488. quorum_callback = q_set_quorate_fn;
  1489. error = votequorum_readconfig_static();
  1490. if (error) {
  1491. return (error);
  1492. }
  1493. error = corosync_service_link_and_init(corosync_api,
  1494. &votequorum_service[0]);
  1495. if (error) {
  1496. return (error);
  1497. }
  1498. LEAVE();
  1499. return (NULL);
  1500. }
  1501. /*
  1502. * Library Handler init/fini
  1503. */
  1504. static int quorum_lib_init_fn (void *conn)
  1505. {
  1506. struct quorum_pd *pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
  1507. ENTER();
  1508. list_init (&pd->list);
  1509. pd->conn = conn;
  1510. LEAVE();
  1511. return (0);
  1512. }
  1513. static int quorum_lib_exit_fn (void *conn)
  1514. {
  1515. struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
  1516. ENTER();
  1517. if (quorum_pd->tracking_enabled) {
  1518. list_del (&quorum_pd->list);
  1519. list_init (&quorum_pd->list);
  1520. }
  1521. LEAVE();
  1522. return (0);
  1523. }
  1524. /*
  1525. * library internal functions
  1526. */
  1527. static void qdevice_timer_fn(void *arg)
  1528. {
  1529. ENTER();
  1530. if ((!qdevice_is_registered) ||
  1531. (qdevice->state == NODESTATE_DEAD) ||
  1532. (!qdevice_timer_set)) {
  1533. LEAVE();
  1534. return;
  1535. }
  1536. qdevice->state = NODESTATE_DEAD;
  1537. us->flags &= ~NODE_FLAGS_QDEVICE_STATE;
  1538. log_printf(LOGSYS_LEVEL_INFO, "lost contact with quorum device %s", qdevice_name);
  1539. votequorum_exec_send_nodeinfo(us->node_id);
  1540. qdevice_timer_set = 0;
  1541. LEAVE();
  1542. }
  1543. /*
  1544. * Library Handler Functions
  1545. */
  1546. static void message_handler_req_lib_votequorum_getinfo (void *conn, const void *message)
  1547. {
  1548. const struct req_lib_votequorum_getinfo *req_lib_votequorum_getinfo = message;
  1549. struct res_lib_votequorum_getinfo res_lib_votequorum_getinfo;
  1550. struct cluster_node *node;
  1551. unsigned int highest_expected = 0;
  1552. unsigned int total_votes = 0;
  1553. cs_error_t error = CS_OK;
  1554. ENTER();
  1555. log_printf(LOGSYS_LEVEL_DEBUG, "got getinfo request on %p for node %u", conn, req_lib_votequorum_getinfo->nodeid);
  1556. node = find_node_by_nodeid(req_lib_votequorum_getinfo->nodeid);
  1557. if (node) {
  1558. struct cluster_node *iternode;
  1559. struct list_head *nodelist;
  1560. list_iterate(nodelist, &cluster_members_list) {
  1561. iternode = list_entry(nodelist, struct cluster_node, list);
  1562. if (iternode->state == NODESTATE_MEMBER) {
  1563. highest_expected =
  1564. max(highest_expected, iternode->expected_votes);
  1565. total_votes += iternode->votes;
  1566. }
  1567. }
  1568. if (((qdevice_is_registered) && (qdevice->state == NODESTATE_MEMBER)) ||
  1569. ((node->flags & NODE_FLAGS_QDEVICE) && (node->flags & NODE_FLAGS_QDEVICE_STATE))) {
  1570. total_votes += qdevice->votes;
  1571. }
  1572. res_lib_votequorum_getinfo.state = node->state;
  1573. res_lib_votequorum_getinfo.votes = node->votes;
  1574. res_lib_votequorum_getinfo.expected_votes = node->expected_votes;
  1575. res_lib_votequorum_getinfo.highest_expected = highest_expected;
  1576. res_lib_votequorum_getinfo.quorum = quorum;
  1577. res_lib_votequorum_getinfo.total_votes = total_votes;
  1578. res_lib_votequorum_getinfo.flags = 0;
  1579. res_lib_votequorum_getinfo.nodeid = node->node_id;
  1580. if (two_node) {
  1581. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_FLAG_TWONODE;
  1582. }
  1583. if (cluster_is_quorate) {
  1584. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_FLAG_QUORATE;
  1585. }
  1586. if (wait_for_all) {
  1587. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_WAIT_FOR_ALL;
  1588. }
  1589. if (last_man_standing) {
  1590. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_LAST_MAN_STANDING;
  1591. }
  1592. if (auto_tie_breaker) {
  1593. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_AUTO_TIE_BREAKER;
  1594. }
  1595. if (leave_remove) {
  1596. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_LEAVE_REMOVE;
  1597. }
  1598. if (node->flags & NODE_FLAGS_QDEVICE) {
  1599. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_QDEVICE;
  1600. }
  1601. } else {
  1602. error = CS_ERR_NOT_EXIST;
  1603. }
  1604. res_lib_votequorum_getinfo.header.size = sizeof(res_lib_votequorum_getinfo);
  1605. res_lib_votequorum_getinfo.header.id = MESSAGE_RES_VOTEQUORUM_GETINFO;
  1606. res_lib_votequorum_getinfo.header.error = error;
  1607. corosync_api->ipc_response_send(conn, &res_lib_votequorum_getinfo, sizeof(res_lib_votequorum_getinfo));
  1608. log_printf(LOGSYS_LEVEL_DEBUG, "getinfo response error: %d", error);
  1609. LEAVE();
  1610. }
  1611. static void message_handler_req_lib_votequorum_setexpected (void *conn, const void *message)
  1612. {
  1613. const struct req_lib_votequorum_setexpected *req_lib_votequorum_setexpected = message;
  1614. struct res_lib_votequorum_status res_lib_votequorum_status;
  1615. cs_error_t error = CS_OK;
  1616. unsigned int newquorum;
  1617. unsigned int total_votes;
  1618. uint8_t leave_remove_status = 0;
  1619. ENTER();
  1620. leave_remove_status = leave_remove;
  1621. leave_remove = 0;
  1622. /*
  1623. * Validate new expected votes
  1624. */
  1625. newquorum = calculate_quorum(1, req_lib_votequorum_setexpected->expected_votes, &total_votes);
  1626. leave_remove = leave_remove_status;
  1627. if (newquorum < total_votes / 2 ||
  1628. newquorum > total_votes) {
  1629. error = CS_ERR_INVALID_PARAM;
  1630. goto error_exit;
  1631. }
  1632. votequorum_exec_send_reconfigure(VOTEQUORUM_RECONFIG_PARAM_EXPECTED_VOTES, us->node_id,
  1633. req_lib_votequorum_setexpected->expected_votes);
  1634. error_exit:
  1635. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1636. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1637. res_lib_votequorum_status.header.error = error;
  1638. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1639. LEAVE();
  1640. }
  1641. static void message_handler_req_lib_votequorum_setvotes (void *conn, const void *message)
  1642. {
  1643. const struct req_lib_votequorum_setvotes *req_lib_votequorum_setvotes = message;
  1644. struct res_lib_votequorum_status res_lib_votequorum_status;
  1645. struct cluster_node *node;
  1646. unsigned int newquorum;
  1647. unsigned int total_votes;
  1648. unsigned int saved_votes;
  1649. cs_error_t error = CS_OK;
  1650. unsigned int nodeid;
  1651. ENTER();
  1652. nodeid = req_lib_votequorum_setvotes->nodeid;
  1653. node = find_node_by_nodeid(nodeid);
  1654. if (!node) {
  1655. error = CS_ERR_NAME_NOT_FOUND;
  1656. goto error_exit;
  1657. }
  1658. /*
  1659. * Check votes is valid
  1660. */
  1661. saved_votes = node->votes;
  1662. node->votes = req_lib_votequorum_setvotes->votes;
  1663. newquorum = calculate_quorum(1, 0, &total_votes);
  1664. if (newquorum < total_votes / 2 ||
  1665. newquorum > total_votes) {
  1666. node->votes = saved_votes;
  1667. error = CS_ERR_INVALID_PARAM;
  1668. goto error_exit;
  1669. }
  1670. votequorum_exec_send_reconfigure(VOTEQUORUM_RECONFIG_PARAM_NODE_VOTES, nodeid,
  1671. req_lib_votequorum_setvotes->votes);
  1672. error_exit:
  1673. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1674. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1675. res_lib_votequorum_status.header.error = error;
  1676. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1677. LEAVE();
  1678. }
  1679. static void message_handler_req_lib_votequorum_trackstart (void *conn,
  1680. const void *message)
  1681. {
  1682. const struct req_lib_votequorum_trackstart *req_lib_votequorum_trackstart = message;
  1683. struct res_lib_votequorum_status res_lib_votequorum_status;
  1684. struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
  1685. ENTER();
  1686. /*
  1687. * If an immediate listing of the current cluster membership
  1688. * is requested, generate membership list
  1689. */
  1690. if (req_lib_votequorum_trackstart->track_flags & CS_TRACK_CURRENT ||
  1691. req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES) {
  1692. log_printf(LOGSYS_LEVEL_DEBUG, "sending initial status to %p", conn);
  1693. votequorum_exec_send_quorum_notification(conn, req_lib_votequorum_trackstart->context);
  1694. }
  1695. /*
  1696. * Record requests for tracking
  1697. */
  1698. if (req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES ||
  1699. req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES_ONLY) {
  1700. quorum_pd->track_flags = req_lib_votequorum_trackstart->track_flags;
  1701. quorum_pd->tracking_enabled = 1;
  1702. quorum_pd->tracking_context = req_lib_votequorum_trackstart->context;
  1703. list_add (&quorum_pd->list, &trackers_list);
  1704. }
  1705. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1706. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1707. res_lib_votequorum_status.header.error = CS_OK;
  1708. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1709. LEAVE();
  1710. }
  1711. static void message_handler_req_lib_votequorum_trackstop (void *conn,
  1712. const void *message)
  1713. {
  1714. struct res_lib_votequorum_status res_lib_votequorum_status;
  1715. struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
  1716. int error = CS_OK;
  1717. ENTER();
  1718. if (quorum_pd->tracking_enabled) {
  1719. error = CS_OK;
  1720. quorum_pd->tracking_enabled = 0;
  1721. list_del (&quorum_pd->list);
  1722. list_init (&quorum_pd->list);
  1723. } else {
  1724. error = CS_ERR_NOT_EXIST;
  1725. }
  1726. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1727. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1728. res_lib_votequorum_status.header.error = error;
  1729. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1730. LEAVE();
  1731. }
  1732. static void message_handler_req_lib_votequorum_qdevice_register (void *conn,
  1733. const void *message)
  1734. {
  1735. const struct req_lib_votequorum_qdevice_register *req_lib_votequorum_qdevice_register = message;
  1736. struct res_lib_votequorum_status res_lib_votequorum_status;
  1737. cs_error_t error = CS_OK;
  1738. ENTER();
  1739. if (!qdevice_can_operate) {
  1740. log_printf(LOGSYS_LEVEL_INFO, "Registration of quorum device is disabled by incorrect corosync.conf. See logs for more information");
  1741. error = CS_ERR_ACCESS;
  1742. goto out;
  1743. }
  1744. if (qdevice_is_registered) {
  1745. if ((!strncmp(req_lib_votequorum_qdevice_register->name,
  1746. qdevice_name, VOTEQUORUM_MAX_QDEVICE_NAME_LEN))) {
  1747. goto out;
  1748. } else {
  1749. log_printf(LOGSYS_LEVEL_WARNING,
  1750. "A new qdevice with different name (new: %s old: %s) is trying to re-register!",
  1751. req_lib_votequorum_qdevice_register->name, qdevice_name);
  1752. error = CS_ERR_EXIST;
  1753. goto out;
  1754. }
  1755. } else {
  1756. if (qdevice_reg_conn != NULL) {
  1757. log_printf(LOGSYS_LEVEL_WARNING,
  1758. "Registration request already in progress");
  1759. error = CS_ERR_TRY_AGAIN;
  1760. goto out;
  1761. }
  1762. qdevice_reg_conn = conn;
  1763. if (votequorum_exec_send_qdevice_reg(VOTEQUORUM_QDEVICE_OPERATION_REGISTER,
  1764. req_lib_votequorum_qdevice_register->name) != 0) {
  1765. log_printf(LOGSYS_LEVEL_WARNING,
  1766. "Unable to send qdevice registration request to cluster");
  1767. error = CS_ERR_TRY_AGAIN;
  1768. qdevice_reg_conn = NULL;
  1769. } else {
  1770. LEAVE();
  1771. return;
  1772. }
  1773. }
  1774. out:
  1775. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1776. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1777. res_lib_votequorum_status.header.error = error;
  1778. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1779. LEAVE();
  1780. }
  1781. static void message_handler_req_lib_votequorum_qdevice_unregister (void *conn,
  1782. const void *message)
  1783. {
  1784. const struct req_lib_votequorum_qdevice_unregister *req_lib_votequorum_qdevice_unregister = message;
  1785. struct res_lib_votequorum_status res_lib_votequorum_status;
  1786. cs_error_t error = CS_OK;
  1787. ENTER();
  1788. if (qdevice_is_registered) {
  1789. if (strncmp(req_lib_votequorum_qdevice_unregister->name, qdevice_name, VOTEQUORUM_MAX_QDEVICE_NAME_LEN)) {
  1790. error = CS_ERR_INVALID_PARAM;
  1791. goto out;
  1792. }
  1793. if (qdevice_timer_set) {
  1794. corosync_api->timer_delete(qdevice_timer);
  1795. qdevice_timer_set = 0;
  1796. }
  1797. qdevice_is_registered = 0;
  1798. us->flags &= ~NODE_FLAGS_QDEVICE;
  1799. us->flags &= ~NODE_FLAGS_QDEVICE_STATE;
  1800. qdevice->state = NODESTATE_DEAD;
  1801. votequorum_exec_send_nodeinfo(us->node_id);
  1802. votequorum_exec_send_qdevice_reg(VOTEQUORUM_QDEVICE_OPERATION_UNREGISTER,
  1803. req_lib_votequorum_qdevice_unregister->name);
  1804. } else {
  1805. error = CS_ERR_NOT_EXIST;
  1806. }
  1807. out:
  1808. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1809. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1810. res_lib_votequorum_status.header.error = error;
  1811. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1812. LEAVE();
  1813. }
  1814. static void message_handler_req_lib_votequorum_qdevice_update (void *conn,
  1815. const void *message)
  1816. {
  1817. const struct req_lib_votequorum_qdevice_update *req_lib_votequorum_qdevice_update = message;
  1818. struct res_lib_votequorum_status res_lib_votequorum_status;
  1819. cs_error_t error = CS_OK;
  1820. ENTER();
  1821. if (qdevice_is_registered) {
  1822. if (strncmp(req_lib_votequorum_qdevice_update->oldname, qdevice_name, VOTEQUORUM_MAX_QDEVICE_NAME_LEN)) {
  1823. error = CS_ERR_INVALID_PARAM;
  1824. goto out;
  1825. }
  1826. votequorum_exec_send_qdevice_reconfigure(req_lib_votequorum_qdevice_update->oldname,
  1827. req_lib_votequorum_qdevice_update->newname);
  1828. } else {
  1829. error = CS_ERR_NOT_EXIST;
  1830. }
  1831. out:
  1832. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1833. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1834. res_lib_votequorum_status.header.error = error;
  1835. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1836. LEAVE();
  1837. }
  1838. static void message_handler_req_lib_votequorum_qdevice_poll (void *conn,
  1839. const void *message)
  1840. {
  1841. const struct req_lib_votequorum_qdevice_poll *req_lib_votequorum_qdevice_poll = message;
  1842. struct res_lib_votequorum_status res_lib_votequorum_status;
  1843. cs_error_t error = CS_OK;
  1844. ENTER();
  1845. if (!qdevice_can_operate) {
  1846. error = CS_ERR_ACCESS;
  1847. goto out;
  1848. }
  1849. if (qdevice_is_registered) {
  1850. if (strncmp(req_lib_votequorum_qdevice_poll->name, qdevice_name, VOTEQUORUM_MAX_QDEVICE_NAME_LEN)) {
  1851. error = CS_ERR_INVALID_PARAM;
  1852. goto out;
  1853. }
  1854. if (qdevice_timer_set) {
  1855. corosync_api->timer_delete(qdevice_timer);
  1856. qdevice_timer_set = 0;
  1857. }
  1858. if (req_lib_votequorum_qdevice_poll->state) {
  1859. if (qdevice->state == NODESTATE_DEAD) {
  1860. qdevice->state = NODESTATE_MEMBER;
  1861. us->flags |= NODE_FLAGS_QDEVICE_STATE;
  1862. votequorum_exec_send_nodeinfo(us->node_id);
  1863. }
  1864. } else {
  1865. if (qdevice->state == NODESTATE_MEMBER) {
  1866. qdevice->state = NODESTATE_DEAD;
  1867. us->flags &= ~NODE_FLAGS_QDEVICE_STATE;
  1868. votequorum_exec_send_nodeinfo(us->node_id);
  1869. }
  1870. }
  1871. corosync_api->timer_add_duration((unsigned long long)qdevice_timeout*1000000, qdevice,
  1872. qdevice_timer_fn, &qdevice_timer);
  1873. qdevice_timer_set = 1;
  1874. } else {
  1875. error = CS_ERR_NOT_EXIST;
  1876. }
  1877. out:
  1878. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1879. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1880. res_lib_votequorum_status.header.error = error;
  1881. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1882. LEAVE();
  1883. }
  1884. static void message_handler_req_lib_votequorum_qdevice_getinfo (void *conn,
  1885. const void *message)
  1886. {
  1887. const struct req_lib_votequorum_qdevice_getinfo *req_lib_votequorum_qdevice_getinfo = message;
  1888. struct res_lib_votequorum_qdevice_getinfo res_lib_votequorum_qdevice_getinfo;
  1889. cs_error_t error = CS_OK;
  1890. struct cluster_node *node;
  1891. uint32_t nodeid = req_lib_votequorum_qdevice_getinfo->nodeid;
  1892. ENTER();
  1893. if ((nodeid != us->node_id) &&
  1894. (nodeid != NODEID_QDEVICE)) {
  1895. node = find_node_by_nodeid(req_lib_votequorum_qdevice_getinfo->nodeid);
  1896. if ((node) &&
  1897. (node->flags & NODE_FLAGS_QDEVICE)) {
  1898. int state = 0;
  1899. if (node->flags & NODE_FLAGS_QDEVICE_STATE) {
  1900. state = 1;
  1901. }
  1902. log_printf(LOGSYS_LEVEL_DEBUG, "got qdevice_getinfo node %u state %d", nodeid, state);
  1903. res_lib_votequorum_qdevice_getinfo.votes = qdevice->votes;
  1904. if (state) {
  1905. res_lib_votequorum_qdevice_getinfo.state = 1;
  1906. } else {
  1907. res_lib_votequorum_qdevice_getinfo.state = 0;
  1908. }
  1909. strcpy(res_lib_votequorum_qdevice_getinfo.name, qdevice_name);
  1910. } else {
  1911. error = CS_ERR_NOT_EXIST;
  1912. }
  1913. } else {
  1914. if (qdevice_is_registered) {
  1915. log_printf(LOGSYS_LEVEL_DEBUG, "got qdevice_getinfo node %u state %d", us->node_id, qdevice->state);
  1916. res_lib_votequorum_qdevice_getinfo.votes = qdevice->votes;
  1917. if (qdevice->state == NODESTATE_MEMBER) {
  1918. res_lib_votequorum_qdevice_getinfo.state = 1;
  1919. } else {
  1920. res_lib_votequorum_qdevice_getinfo.state = 0;
  1921. }
  1922. strcpy(res_lib_votequorum_qdevice_getinfo.name, qdevice_name);
  1923. } else {
  1924. error = CS_ERR_NOT_EXIST;
  1925. }
  1926. }
  1927. res_lib_votequorum_qdevice_getinfo.header.size = sizeof(res_lib_votequorum_qdevice_getinfo);
  1928. res_lib_votequorum_qdevice_getinfo.header.id = MESSAGE_RES_VOTEQUORUM_GETINFO;
  1929. res_lib_votequorum_qdevice_getinfo.header.error = error;
  1930. corosync_api->ipc_response_send(conn, &res_lib_votequorum_qdevice_getinfo, sizeof(res_lib_votequorum_qdevice_getinfo));
  1931. LEAVE();
  1932. }