votequorum.c 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700
  1. /*
  2. * Copyright (c) 2009 Red Hat, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Christine Caulfield (ccaulfie@redhat.com)
  7. *
  8. * This software licensed under BSD license, the text of which follows:
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. *
  13. * - Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. * THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #include <config.h>
  35. #include <sys/types.h>
  36. #ifndef COROSYNC_BSD
  37. #include <alloca.h>
  38. #endif
  39. #include <sys/types.h>
  40. #include <sys/socket.h>
  41. #include <sys/un.h>
  42. #include <sys/time.h>
  43. #include <sys/ioctl.h>
  44. #include <netinet/in.h>
  45. #include <sys/uio.h>
  46. #include <unistd.h>
  47. #include <fcntl.h>
  48. #include <stdlib.h>
  49. #include <stdio.h>
  50. #include <errno.h>
  51. #include <signal.h>
  52. #include <time.h>
  53. #include <unistd.h>
  54. #include <netinet/in.h>
  55. #include <arpa/inet.h>
  56. #include <corosync/corotypes.h>
  57. #include <corosync/cfg.h>
  58. #include <corosync/list.h>
  59. #include <corosync/lcr/lcr_comp.h>
  60. #include <corosync/engine/logsys.h>
  61. #include <corosync/ipc_gen.h>
  62. #include <corosync/engine/coroapi.h>
  63. #include <corosync/engine/quorum.h>
  64. #include <corosync/ipc_votequorum.h>
  65. #include <corosync/list.h>
  66. #define VOTEQUORUM_MAJOR_VERSION 6
  67. #define VOTEQUORUM_MINOR_VERSION 3
  68. #define VOTEQUORUM_PATCH_VERSION 0
  69. /* Silly default to prevent accidents! */
  70. #define DEFAULT_EXPECTED 1024
  71. #define DEFAULT_QDEV_POLL 10000
  72. #define DEFAULT_LEAVE_TMO 10000
  73. LOGSYS_DECLARE_SUBSYS ("VOTEQ", LOG_INFO);
  74. enum quorum_message_req_types {
  75. MESSAGE_REQ_EXEC_VOTEQUORUM_NODEINFO = 0,
  76. MESSAGE_REQ_EXEC_VOTEQUORUM_RECONFIGURE = 1,
  77. MESSAGE_REQ_EXEC_VOTEQUORUM_KILLNODE = 2,
  78. };
  79. #define NODE_FLAGS_BEENDOWN 1
  80. #define NODE_FLAGS_SEESDISALLOWED 8
  81. #define NODE_FLAGS_HASSTATE 16
  82. #define NODE_FLAGS_QDISK 32
  83. #define NODE_FLAGS_REMOVED 64
  84. #define NODE_FLAGS_US 128
  85. typedef enum { NODESTATE_JOINING=1, NODESTATE_MEMBER,
  86. NODESTATE_DEAD, NODESTATE_LEAVING, NODESTATE_DISALLOWED } nodestate_t;
  87. /* This structure is tacked onto the start of a cluster message packet for our
  88. * own nefarious purposes. */
  89. struct q_protheader {
  90. unsigned char tgtport; /* Target port number */
  91. unsigned char srcport; /* Source (originating) port number */
  92. unsigned short pad;
  93. unsigned int flags;
  94. int srcid; /* Node ID of the sender */
  95. int tgtid; /* Node ID of the target */
  96. } __attribute__((packed));
  97. struct cluster_node {
  98. int flags;
  99. int node_id;
  100. unsigned int expected_votes;
  101. unsigned int votes;
  102. time_t join_time;
  103. nodestate_t state;
  104. struct timeval last_hello; /* Only used for quorum devices */
  105. struct list_head list;
  106. };
  107. static int quorum_flags;
  108. #define VOTEQUORUM_FLAG_FEATURE_DISALLOWED 1
  109. #define VOTEQUORUM_FLAG_FEATURE_TWONODE 1
  110. static int quorum;
  111. static int cluster_is_quorate;
  112. static int first_trans = 1;
  113. static unsigned int quorumdev_poll = DEFAULT_QDEV_POLL;
  114. static unsigned int leaving_timeout = DEFAULT_LEAVE_TMO;
  115. static struct cluster_node *us;
  116. static struct cluster_node *quorum_device = NULL;
  117. static char quorum_device_name[VOTEQUORUM_MAX_QDISK_NAME_LEN];
  118. static corosync_timer_handle_t quorum_device_timer;
  119. static corosync_timer_handle_t leaving_timer;
  120. static struct list_head cluster_members_list;
  121. static struct corosync_api_v1 *corosync_api;
  122. static struct list_head trackers_list;
  123. static unsigned int quorum_members[PROCESSOR_COUNT_MAX+1];
  124. static int quorum_members_entries = 0;
  125. static struct memb_ring_id quorum_ringid;
  126. static hdb_handle_t group_handle;
  127. #define max(a,b) (((a) > (b)) ? (a) : (b))
  128. static struct cluster_node *find_node_by_nodeid(int nodeid);
  129. static struct cluster_node *allocate_node(int nodeid);
  130. static const char *kill_reason(int reason);
  131. static struct corosync_tpg_group quorum_group[1] = {
  132. { .group = "VOTEQ", .group_len = 5},
  133. };
  134. #define list_iterate(v, head) \
  135. for (v = (head)->next; v != head; v = v->next)
  136. struct quorum_pd {
  137. unsigned char track_flags;
  138. int tracking_enabled;
  139. uint64_t tracking_context;
  140. struct list_head list;
  141. void *conn;
  142. };
  143. /*
  144. * Service Interfaces required by service_message_handler struct
  145. */
  146. static void votequorum_init(struct corosync_api_v1 *api,
  147. quorum_set_quorate_fn_t report);
  148. static void quorum_confchg_fn (
  149. enum totem_configuration_type configuration_type,
  150. const unsigned int *member_list, size_t member_list_entries,
  151. const unsigned int *left_list, size_t left_list_entries,
  152. const unsigned int *joined_list, size_t joined_list_entries,
  153. const struct memb_ring_id *ring_id);
  154. static void quorum_deliver_fn(unsigned int nodeid, struct iovec *iovec, unsigned int iov_len,
  155. int endian_conversion_required);
  156. static int votequorum_exec_init_fn (struct corosync_api_v1 *corosync_api);
  157. static int quorum_lib_init_fn (void *conn);
  158. static int quorum_lib_exit_fn (void *conn);
  159. static void message_handler_req_exec_quorum_nodeinfo (
  160. void *message,
  161. unsigned int nodeid);
  162. static void message_handler_req_exec_quorum_reconfigure (
  163. void *message,
  164. unsigned int nodeid);
  165. static void message_handler_req_exec_quorum_killnode (
  166. void *message,
  167. unsigned int nodeid);
  168. static void message_handler_req_lib_votequorum_getinfo (void *conn, void *message);
  169. static void message_handler_req_lib_votequorum_setexpected (void *conn, void *message);
  170. static void message_handler_req_lib_votequorum_setvotes (void *conn, void *message);
  171. static void message_handler_req_lib_votequorum_qdisk_register (void *conn, void *message);
  172. static void message_handler_req_lib_votequorum_qdisk_unregister (void *conn, void *message);
  173. static void message_handler_req_lib_votequorum_qdisk_poll (void *conn, void *message);
  174. static void message_handler_req_lib_votequorum_qdisk_getinfo (void *conn, void *message);
  175. static void message_handler_req_lib_votequorum_setstate (void *conn, void *message);
  176. static void message_handler_req_lib_votequorum_leaving (void *conn, void *message);
  177. static void message_handler_req_lib_votequorum_trackstart (void *conn, void *msg);
  178. static void message_handler_req_lib_votequorum_trackstop (void *conn, void *msg);
  179. static int quorum_exec_send_nodeinfo(void);
  180. static int quorum_exec_send_reconfigure(int param, int nodeid, int value);
  181. static int quorum_exec_send_killnode(int nodeid, unsigned int reason);
  182. static void add_votequorum_config_notification(hdb_handle_t quorum_object_handle);
  183. static void recalculate_quorum(int allow_decrease, int by_current_nodes);
  184. /*
  185. * Library Handler Definition
  186. */
  187. static struct corosync_lib_handler quorum_lib_service[] =
  188. {
  189. { /* 0 */
  190. .lib_handler_fn = message_handler_req_lib_votequorum_getinfo,
  191. .response_size = sizeof (struct res_lib_votequorum_getinfo),
  192. .response_id = MESSAGE_RES_VOTEQUORUM_GETINFO,
  193. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  194. },
  195. { /* 1 */
  196. .lib_handler_fn = message_handler_req_lib_votequorum_setexpected,
  197. .response_size = sizeof (struct res_lib_votequorum_status),
  198. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  199. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  200. },
  201. { /* 2 */
  202. .lib_handler_fn = message_handler_req_lib_votequorum_setvotes,
  203. .response_size = sizeof (struct res_lib_votequorum_status),
  204. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  205. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  206. },
  207. { /* 3 */
  208. .lib_handler_fn = message_handler_req_lib_votequorum_qdisk_register,
  209. .response_size = sizeof (struct res_lib_votequorum_status),
  210. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  211. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  212. },
  213. { /* 4 */
  214. .lib_handler_fn = message_handler_req_lib_votequorum_qdisk_unregister,
  215. .response_size = sizeof (struct res_lib_votequorum_status),
  216. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  217. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  218. },
  219. { /* 5 */
  220. .lib_handler_fn = message_handler_req_lib_votequorum_qdisk_poll,
  221. .response_size = sizeof (struct res_lib_votequorum_status),
  222. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  223. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  224. },
  225. { /* 6 */
  226. .lib_handler_fn = message_handler_req_lib_votequorum_qdisk_getinfo,
  227. .response_size = sizeof (struct res_lib_votequorum_qdisk_getinfo),
  228. .response_id = MESSAGE_RES_VOTEQUORUM_QDISK_GETINFO,
  229. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  230. },
  231. { /* 7 */
  232. .lib_handler_fn = message_handler_req_lib_votequorum_setstate,
  233. .response_size = sizeof (struct res_lib_votequorum_status),
  234. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  235. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  236. },
  237. { /* 8 */
  238. .lib_handler_fn = message_handler_req_lib_votequorum_leaving,
  239. .response_size = sizeof (struct res_lib_votequorum_status),
  240. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  241. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  242. },
  243. { /* 9 */
  244. .lib_handler_fn = message_handler_req_lib_votequorum_trackstart,
  245. .response_size = sizeof (struct res_lib_votequorum_status),
  246. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  247. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  248. },
  249. { /* 10 */
  250. .lib_handler_fn = message_handler_req_lib_votequorum_trackstop,
  251. .response_size = sizeof (struct res_lib_votequorum_status),
  252. .response_id = MESSAGE_RES_VOTEQUORUM_STATUS,
  253. .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
  254. }
  255. };
  256. static quorum_set_quorate_fn_t set_quorum;
  257. /*
  258. * lcrso object definition
  259. */
  260. static struct quorum_services_api_ver1 votequorum_iface_ver0 = {
  261. .init = votequorum_init
  262. };
  263. static struct corosync_service_engine quorum_service_handler = {
  264. .name = "corosync votes quorum service v0.90",
  265. .id = VOTEQUORUM_SERVICE,
  266. .private_data_size = sizeof (struct quorum_pd),
  267. .allow_inquorate = CS_LIB_ALLOW_INQUORATE,
  268. .flow_control = COROSYNC_LIB_FLOW_CONTROL_REQUIRED,
  269. .lib_init_fn = quorum_lib_init_fn,
  270. .lib_exit_fn = quorum_lib_exit_fn,
  271. .lib_engine = quorum_lib_service,
  272. .lib_engine_count = sizeof (quorum_lib_service) / sizeof (struct corosync_lib_handler),
  273. .exec_init_fn = votequorum_exec_init_fn,
  274. .exec_engine = NULL,
  275. .exec_engine_count = 0,
  276. .confchg_fn = NULL,
  277. };
  278. /*
  279. * Dynamic loader definition
  280. */
  281. static struct corosync_service_engine *quorum_get_service_handler_ver0 (void);
  282. static struct corosync_service_engine_iface_ver0 quorum_service_handler_iface = {
  283. .corosync_get_service_engine_ver0 = quorum_get_service_handler_ver0
  284. };
  285. static struct lcr_iface corosync_quorum_ver0[2] = {
  286. {
  287. .name = "corosync_votequorum",
  288. .version = 0,
  289. .versions_replace = 0,
  290. .versions_replace_count = 0,
  291. .dependencies = 0,
  292. .dependency_count = 0,
  293. .constructor = NULL,
  294. .destructor = NULL,
  295. .interfaces = (void **)(void *)&votequorum_iface_ver0
  296. },
  297. {
  298. .name = "corosync_votequorum_iface",
  299. .version = 0,
  300. .versions_replace = 0,
  301. .versions_replace_count = 0,
  302. .dependencies = 0,
  303. .dependency_count = 0,
  304. .constructor = NULL,
  305. .destructor = NULL,
  306. .interfaces = NULL
  307. }
  308. };
  309. static struct lcr_comp quorum_comp_ver0 = {
  310. .iface_count = 2,
  311. .ifaces = corosync_quorum_ver0
  312. };
  313. static struct corosync_service_engine *quorum_get_service_handler_ver0 (void)
  314. {
  315. return (&quorum_service_handler);
  316. }
  317. __attribute__ ((constructor)) static void quorum_comp_register (void) {
  318. lcr_interfaces_set (&corosync_quorum_ver0[0], &votequorum_iface_ver0);
  319. lcr_interfaces_set (&corosync_quorum_ver0[1], &quorum_service_handler_iface);
  320. lcr_component_register (&quorum_comp_ver0);
  321. }
  322. static void votequorum_init(struct corosync_api_v1 *api,
  323. quorum_set_quorate_fn_t report)
  324. {
  325. ENTER();
  326. set_quorum = report;
  327. /* Load the library-servicing part of this module */
  328. api->service_link_and_init(api, "corosync_votequorum_iface", 0);
  329. LEAVE();
  330. }
  331. /* Message types */
  332. #define VOTEQUORUM_MSG_NODEINFO 5
  333. #define VOTEQUORUM_MSG_KILLNODE 6
  334. #define VOTEQUORUM_MSG_RECONFIGURE 8
  335. struct req_exec_quorum_nodeinfo {
  336. unsigned char cmd;
  337. unsigned char first_trans;
  338. unsigned int votes;
  339. unsigned int expected_votes;
  340. unsigned int major_version; /* Not backwards compatible */
  341. unsigned int minor_version; /* Backwards compatible */
  342. unsigned int patch_version; /* Backwards/forwards compatible */
  343. unsigned int config_version;
  344. unsigned int flags;
  345. } __attribute__((packed));
  346. /* Parameters for RECONFIG command */
  347. #define RECONFIG_PARAM_EXPECTED_VOTES 1
  348. #define RECONFIG_PARAM_NODE_VOTES 2
  349. #define RECONFIG_PARAM_LEAVING 3
  350. struct req_exec_quorum_reconfigure {
  351. unsigned char cmd;
  352. unsigned char param;
  353. unsigned short pad;
  354. int nodeid;
  355. unsigned int value;
  356. };
  357. struct req_exec_quorum_killnode {
  358. unsigned char cmd;
  359. unsigned char pad1;
  360. uint16_t reason;
  361. int nodeid;
  362. };
  363. /* These just make the access a little neater */
  364. static inline int objdb_get_string(const struct corosync_api_v1 *corosync,
  365. unsigned int object_service_handle,
  366. char *key, char **value)
  367. {
  368. int res;
  369. *value = NULL;
  370. if ( !(res = corosync_api->object_key_get(object_service_handle,
  371. key,
  372. strlen(key),
  373. (void *)value,
  374. NULL))) {
  375. if (*value)
  376. return 0;
  377. }
  378. return -1;
  379. }
  380. static inline void objdb_get_int(const struct corosync_api_v1 *corosync,
  381. unsigned int object_service_handle,
  382. const char *key, unsigned int *intvalue,
  383. unsigned int default_value)
  384. {
  385. char *value = NULL;
  386. *intvalue = default_value;
  387. if (!corosync_api->object_key_get(object_service_handle, key, strlen(key),
  388. (void *)&value, NULL)) {
  389. if (value) {
  390. *intvalue = atoi(value);
  391. }
  392. }
  393. }
  394. static int votequorum_send_message(void *message, int len)
  395. {
  396. struct iovec iov[2];
  397. struct q_protheader header;
  398. header.tgtport = 0;
  399. header.srcport = 0;
  400. header.flags = 0;
  401. header.srcid = us->node_id;
  402. header.tgtid = 0;
  403. iov[0].iov_base = &header;
  404. iov[0].iov_len = sizeof(header);
  405. iov[1].iov_base = message;
  406. iov[1].iov_len = len;
  407. return corosync_api->tpg_joined_mcast(group_handle, iov, 2, TOTEM_AGREED);
  408. }
  409. static void read_quorum_config(unsigned int quorum_handle)
  410. {
  411. unsigned int value = 0;
  412. int cluster_members = 0;
  413. struct list_head *tmp;
  414. struct cluster_node *node;
  415. log_printf(LOG_INFO, "Reading configuration\n");
  416. objdb_get_int(corosync_api, quorum_handle, "expected_votes", &us->expected_votes, DEFAULT_EXPECTED);
  417. objdb_get_int(corosync_api, quorum_handle, "votes", &us->votes, 1);
  418. objdb_get_int(corosync_api, quorum_handle, "quorumdev_poll", &quorumdev_poll, DEFAULT_QDEV_POLL);
  419. objdb_get_int(corosync_api, quorum_handle, "leaving_timeout", &leaving_timeout, DEFAULT_LEAVE_TMO);
  420. objdb_get_int(corosync_api, quorum_handle, "disallowed", &value, 0);
  421. if (value)
  422. quorum_flags |= VOTEQUORUM_FLAG_FEATURE_DISALLOWED;
  423. else
  424. quorum_flags &= ~VOTEQUORUM_FLAG_FEATURE_DISALLOWED;
  425. objdb_get_int(corosync_api, quorum_handle, "two_node", &value, 0);
  426. if (value)
  427. quorum_flags |= VOTEQUORUM_FLAG_FEATURE_TWONODE;
  428. else
  429. quorum_flags &= ~VOTEQUORUM_FLAG_FEATURE_TWONODE;
  430. /*
  431. * two_node mode is invalid if there are more than 2 nodes in the cluster!
  432. */
  433. list_iterate(tmp, &cluster_members_list) {
  434. node = list_entry(tmp, struct cluster_node, list);
  435. cluster_members++;
  436. }
  437. if (quorum_flags & VOTEQUORUM_FLAG_FEATURE_TWONODE && cluster_members > 2) {
  438. log_printf(LOG_WARNING, "quorum.two_node was set but there are more than 2 nodes in the cluster. It will be ignored.");
  439. quorum_flags &= ~VOTEQUORUM_FLAG_FEATURE_TWONODE;
  440. }
  441. }
  442. static int votequorum_exec_init_fn (struct corosync_api_v1 *api)
  443. {
  444. hdb_handle_t object_handle;
  445. hdb_handle_t find_handle;
  446. ENTER();
  447. corosync_api = api;
  448. list_init(&cluster_members_list);
  449. list_init(&trackers_list);
  450. /* Allocate a cluster_node for us */
  451. us = allocate_node(corosync_api->totem_nodeid_get());
  452. if (!us)
  453. return (1);
  454. us->flags |= NODE_FLAGS_US;
  455. us->state = NODESTATE_MEMBER;
  456. us->expected_votes = DEFAULT_EXPECTED;
  457. us->votes = 1;
  458. time(&us->join_time);
  459. /* Get configuration variables */
  460. corosync_api->object_find_create(OBJECT_PARENT_HANDLE, "quorum", strlen("quorum"), &find_handle);
  461. if (corosync_api->object_find_next(find_handle, &object_handle) == 0) {
  462. read_quorum_config(object_handle);
  463. }
  464. recalculate_quorum(0, 0);
  465. /* Listen for changes */
  466. add_votequorum_config_notification(object_handle);
  467. corosync_api->object_find_destroy(find_handle);
  468. api->tpg_init(&group_handle, quorum_deliver_fn, quorum_confchg_fn);
  469. api->tpg_join(group_handle, quorum_group, 1);
  470. LEAVE();
  471. return (0);
  472. }
  473. static int quorum_lib_exit_fn (void *conn)
  474. {
  475. struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
  476. ENTER();
  477. if (quorum_pd->tracking_enabled) {
  478. list_del (&quorum_pd->list);
  479. list_init (&quorum_pd->list);
  480. }
  481. LEAVE();
  482. return (0);
  483. }
  484. static int send_quorum_notification(void *conn, uint64_t context)
  485. {
  486. struct res_lib_votequorum_notification *res_lib_votequorum_notification;
  487. struct list_head *tmp;
  488. struct cluster_node *node;
  489. int cluster_members = 0;
  490. int i = 0;
  491. int size;
  492. char *buf;
  493. ENTER();
  494. list_iterate(tmp, &cluster_members_list) {
  495. node = list_entry(tmp, struct cluster_node, list);
  496. cluster_members++;
  497. }
  498. if (quorum_device)
  499. cluster_members++;
  500. size = sizeof(struct res_lib_votequorum_notification) + sizeof(struct votequorum_node) * cluster_members;
  501. buf = alloca(size);
  502. if (!buf) {
  503. LEAVE();
  504. return -1;
  505. }
  506. res_lib_votequorum_notification = (struct res_lib_votequorum_notification *)buf;
  507. res_lib_votequorum_notification->quorate = cluster_is_quorate;
  508. res_lib_votequorum_notification->node_list_entries = cluster_members;
  509. res_lib_votequorum_notification->context = context;
  510. list_iterate(tmp, &cluster_members_list) {
  511. node = list_entry(tmp, struct cluster_node, list);
  512. res_lib_votequorum_notification->node_list[i].nodeid = node->node_id;
  513. res_lib_votequorum_notification->node_list[i++].state = node->state;
  514. }
  515. if (quorum_device) {
  516. res_lib_votequorum_notification->node_list[i].nodeid = 0;
  517. res_lib_votequorum_notification->node_list[i++].state = quorum_device->state | 0x80;
  518. }
  519. res_lib_votequorum_notification->header.id = MESSAGE_RES_VOTEQUORUM_NOTIFICATION;
  520. res_lib_votequorum_notification->header.size = size;
  521. res_lib_votequorum_notification->header.error = CS_OK;
  522. /* Send it to all interested parties */
  523. if (conn) {
  524. int ret = corosync_api->ipc_dispatch_send(conn, buf, size);
  525. LEAVE();
  526. return ret;
  527. }
  528. else {
  529. struct quorum_pd *qpd;
  530. list_iterate(tmp, &trackers_list) {
  531. qpd = list_entry(tmp, struct quorum_pd, list);
  532. res_lib_votequorum_notification->context = qpd->tracking_context;
  533. corosync_api->ipc_dispatch_send(qpd->conn, buf, size);
  534. }
  535. }
  536. LEAVE();
  537. return 0;
  538. }
  539. static void send_expectedvotes_notification(void)
  540. {
  541. struct res_lib_votequorum_expectedvotes_notification res_lib_votequorum_expectedvotes_notification;
  542. struct quorum_pd *qpd;
  543. struct list_head *tmp;
  544. log_printf(LOG_DEBUG, "Sending expected votes callback\n");
  545. res_lib_votequorum_expectedvotes_notification.header.id = MESSAGE_RES_VOTEQUORUM_EXPECTEDVOTES_NOTIFICATION;
  546. res_lib_votequorum_expectedvotes_notification.header.size = sizeof(res_lib_votequorum_expectedvotes_notification);
  547. res_lib_votequorum_expectedvotes_notification.header.error = CS_OK;
  548. res_lib_votequorum_expectedvotes_notification.expected_votes = us->expected_votes;
  549. list_iterate(tmp, &trackers_list) {
  550. qpd = list_entry(tmp, struct quorum_pd, list);
  551. res_lib_votequorum_expectedvotes_notification.context = qpd->tracking_context;
  552. corosync_api->ipc_dispatch_send(qpd->conn, &res_lib_votequorum_expectedvotes_notification,
  553. sizeof(struct res_lib_votequorum_expectedvotes_notification));
  554. }
  555. }
  556. static void set_quorate(int total_votes)
  557. {
  558. int quorate;
  559. ENTER();
  560. if (quorum > total_votes) {
  561. quorate = 0;
  562. }
  563. else {
  564. quorate = 1;
  565. }
  566. if (cluster_is_quorate && !quorate)
  567. log_printf(LOG_INFO, "quorum lost, blocking activity\n");
  568. if (!cluster_is_quorate && quorate)
  569. log_printf(LOG_INFO, "quorum regained, resuming activity\n");
  570. /* If we are newly quorate, then kill any DISALLOWED nodes */
  571. if (!cluster_is_quorate && quorate) {
  572. struct cluster_node *node = NULL;
  573. struct list_head *tmp;
  574. list_iterate(tmp, &cluster_members_list) {
  575. node = list_entry(tmp, struct cluster_node, list);
  576. if (node->state == NODESTATE_DISALLOWED)
  577. quorum_exec_send_killnode(node->node_id, VOTEQUORUM_REASON_KILL_REJOIN);
  578. }
  579. }
  580. cluster_is_quorate = quorate;
  581. set_quorum(quorum_members, quorum_members_entries, quorate, &quorum_ringid);
  582. ENTER();
  583. }
  584. static int calculate_quorum(int allow_decrease, int max_expected, unsigned int *ret_total_votes)
  585. {
  586. struct list_head *nodelist;
  587. struct cluster_node *node;
  588. unsigned int total_votes = 0;
  589. unsigned int highest_expected = 0;
  590. unsigned int newquorum, q1, q2;
  591. unsigned int total_nodes = 0;
  592. ENTER();
  593. list_iterate(nodelist, &cluster_members_list) {
  594. node = list_entry(nodelist, struct cluster_node, list);
  595. log_printf(LOG_DEBUG, "node %x state=%d, votes=%d, expected=%d\n",
  596. node->node_id, node->state, node->votes, node->expected_votes);
  597. if (node->state == NODESTATE_MEMBER) {
  598. if (max_expected)
  599. node->expected_votes = max_expected;
  600. else
  601. highest_expected = max(highest_expected, node->expected_votes);
  602. total_votes += node->votes;
  603. total_nodes++;
  604. }
  605. }
  606. if (quorum_device && quorum_device->state == NODESTATE_MEMBER)
  607. total_votes += quorum_device->votes;
  608. if (max_expected > 0)
  609. highest_expected = max_expected;
  610. /* This quorum calculation is taken from the OpenVMS Cluster Systems
  611. * manual, but, then, you guessed that didn't you */
  612. q1 = (highest_expected + 2) / 2;
  613. q2 = (total_votes + 2) / 2;
  614. newquorum = max(q1, q2);
  615. /* Normally quorum never decreases but the system administrator can
  616. * force it down by setting expected votes to a maximum value */
  617. if (!allow_decrease)
  618. newquorum = max(quorum, newquorum);
  619. /* The special two_node mode allows each of the two nodes to retain
  620. * quorum if the other fails. Only one of the two should live past
  621. * fencing (as both nodes try to fence each other in split-brain.)
  622. * Also: if there are more than two nodes, force us inquorate to avoid
  623. * any damage or confusion.
  624. */
  625. if ((quorum_flags & VOTEQUORUM_FLAG_FEATURE_TWONODE) && total_nodes <= 2)
  626. newquorum = 1;
  627. if (ret_total_votes)
  628. *ret_total_votes = total_votes;
  629. LEAVE();
  630. return newquorum;
  631. }
  632. /* Recalculate cluster quorum, set quorate and notify changes */
  633. static void recalculate_quorum(int allow_decrease, int by_current_nodes)
  634. {
  635. unsigned int total_votes = 0;
  636. int cluster_members = 0;
  637. struct list_head *nodelist;
  638. struct cluster_node *node;
  639. ENTER();
  640. list_iterate(nodelist, &cluster_members_list) {
  641. node = list_entry(nodelist, struct cluster_node, list);
  642. if (node->state == NODESTATE_MEMBER) {
  643. if (by_current_nodes)
  644. cluster_members++;
  645. total_votes += node->votes;
  646. }
  647. }
  648. /* Keep expected_votes at the highest number of votes in the cluster */
  649. log_printf(LOG_DEBUG, "total_votes=%d, expected_votes=%d\n", total_votes, us->expected_votes);
  650. if (total_votes > us->expected_votes) {
  651. us->expected_votes = total_votes;
  652. send_expectedvotes_notification();
  653. }
  654. quorum = calculate_quorum(allow_decrease, cluster_members, &total_votes);
  655. set_quorate(total_votes);
  656. send_quorum_notification(NULL, 0L);
  657. LEAVE();
  658. }
  659. static int have_disallowed(void)
  660. {
  661. struct cluster_node *node;
  662. struct list_head *tmp;
  663. list_iterate(tmp, &cluster_members_list) {
  664. node = list_entry(tmp, struct cluster_node, list);
  665. if (node->state == NODESTATE_DISALLOWED)
  666. return 1;
  667. }
  668. return 0;
  669. }
  670. static void node_add_ordered(struct cluster_node *newnode)
  671. {
  672. struct cluster_node *node = NULL;
  673. struct list_head *tmp;
  674. struct list_head *newlist = &newnode->list;
  675. list_iterate(tmp, &cluster_members_list) {
  676. node = list_entry(tmp, struct cluster_node, list);
  677. if (newnode->node_id < node->node_id)
  678. break;
  679. }
  680. if (!node)
  681. list_add(&newnode->list, &cluster_members_list);
  682. else {
  683. newlist->prev = tmp->prev;
  684. newlist->next = tmp;
  685. tmp->prev->next = newlist;
  686. tmp->prev = newlist;
  687. }
  688. }
  689. static struct cluster_node *allocate_node(int nodeid)
  690. {
  691. struct cluster_node *cl;
  692. cl = malloc(sizeof(struct cluster_node));
  693. if (cl) {
  694. memset(cl, 0, sizeof(struct cluster_node));
  695. cl->node_id = nodeid;
  696. if (nodeid)
  697. node_add_ordered(cl);
  698. }
  699. return cl;
  700. }
  701. static struct cluster_node *find_node_by_nodeid(int nodeid)
  702. {
  703. struct cluster_node *node;
  704. struct list_head *tmp;
  705. list_iterate(tmp, &cluster_members_list) {
  706. node = list_entry(tmp, struct cluster_node, list);
  707. if (node->node_id == nodeid)
  708. return node;
  709. }
  710. return NULL;
  711. }
  712. static int quorum_exec_send_nodeinfo()
  713. {
  714. struct req_exec_quorum_nodeinfo req_exec_quorum_nodeinfo;
  715. int ret;
  716. ENTER();
  717. req_exec_quorum_nodeinfo.cmd = VOTEQUORUM_MSG_NODEINFO;
  718. req_exec_quorum_nodeinfo.expected_votes = us->expected_votes;
  719. req_exec_quorum_nodeinfo.votes = us->votes;
  720. req_exec_quorum_nodeinfo.major_version = VOTEQUORUM_MAJOR_VERSION;
  721. req_exec_quorum_nodeinfo.minor_version = VOTEQUORUM_MINOR_VERSION;
  722. req_exec_quorum_nodeinfo.patch_version = VOTEQUORUM_PATCH_VERSION;
  723. req_exec_quorum_nodeinfo.flags = us->flags;
  724. req_exec_quorum_nodeinfo.first_trans = first_trans;
  725. if (have_disallowed())
  726. req_exec_quorum_nodeinfo.flags |= NODE_FLAGS_SEESDISALLOWED;
  727. ret = votequorum_send_message(&req_exec_quorum_nodeinfo, sizeof(req_exec_quorum_nodeinfo));
  728. LEAVE();
  729. return ret;
  730. }
  731. static int quorum_exec_send_reconfigure(int param, int nodeid, int value)
  732. {
  733. struct req_exec_quorum_reconfigure req_exec_quorum_reconfigure;
  734. int ret;
  735. ENTER();
  736. req_exec_quorum_reconfigure.cmd = VOTEQUORUM_MSG_RECONFIGURE;
  737. req_exec_quorum_reconfigure.param = param;
  738. req_exec_quorum_reconfigure.nodeid = nodeid;
  739. req_exec_quorum_reconfigure.value = value;
  740. ret = votequorum_send_message(&req_exec_quorum_reconfigure, sizeof(req_exec_quorum_reconfigure));
  741. LEAVE();
  742. return ret;
  743. }
  744. static int quorum_exec_send_killnode(int nodeid, unsigned int reason)
  745. {
  746. struct req_exec_quorum_killnode req_exec_quorum_killnode;
  747. int ret;
  748. ENTER();
  749. req_exec_quorum_killnode.cmd = VOTEQUORUM_MSG_KILLNODE;
  750. req_exec_quorum_killnode.nodeid = nodeid;
  751. req_exec_quorum_killnode.reason = reason;
  752. ret = votequorum_send_message(&req_exec_quorum_killnode, sizeof(req_exec_quorum_killnode));
  753. LEAVE();
  754. return ret;
  755. }
  756. static void quorum_confchg_fn (
  757. enum totem_configuration_type configuration_type,
  758. const unsigned int *member_list, size_t member_list_entries,
  759. const unsigned int *left_list, size_t left_list_entries,
  760. const unsigned int *joined_list, size_t joined_list_entries,
  761. const struct memb_ring_id *ring_id)
  762. {
  763. int i;
  764. int leaving = 0;
  765. struct cluster_node *node;
  766. ENTER();
  767. if (member_list_entries > 1)
  768. first_trans = 0;
  769. if (left_list_entries) {
  770. for (i = 0; i< left_list_entries; i++) {
  771. node = find_node_by_nodeid(left_list[i]);
  772. if (node) {
  773. if (node->state == NODESTATE_LEAVING)
  774. leaving = 1;
  775. node->state = NODESTATE_DEAD;
  776. node->flags |= NODE_FLAGS_BEENDOWN;
  777. }
  778. }
  779. recalculate_quorum(leaving, leaving);
  780. }
  781. if (member_list_entries) {
  782. memcpy(quorum_members, member_list, sizeof(unsigned int) * member_list_entries);
  783. quorum_members_entries = member_list_entries;
  784. if (quorum_device) {
  785. quorum_members[quorum_members_entries++] = 0;
  786. }
  787. quorum_exec_send_nodeinfo();
  788. }
  789. memcpy(&quorum_ringid, ring_id, sizeof(*ring_id));
  790. LEAVE();
  791. }
  792. static void exec_quorum_nodeinfo_endian_convert (void *msg)
  793. {
  794. struct req_exec_quorum_nodeinfo *nodeinfo = (struct req_exec_quorum_nodeinfo *)msg;
  795. nodeinfo->votes = swab32(nodeinfo->votes);
  796. nodeinfo->expected_votes = swab32(nodeinfo->expected_votes);
  797. nodeinfo->major_version = swab32(nodeinfo->major_version);
  798. nodeinfo->minor_version = swab32(nodeinfo->minor_version);
  799. nodeinfo->patch_version = swab32(nodeinfo->patch_version);
  800. nodeinfo->config_version = swab32(nodeinfo->config_version);
  801. nodeinfo->flags = swab32(nodeinfo->flags);
  802. }
  803. static void exec_quorum_reconfigure_endian_convert (void *msg)
  804. {
  805. struct req_exec_quorum_reconfigure *reconfigure = (struct req_exec_quorum_reconfigure *)msg;
  806. reconfigure->nodeid = swab32(reconfigure->nodeid);
  807. reconfigure->value = swab32(reconfigure->value);
  808. }
  809. static void exec_quorum_killnode_endian_convert (void *msg)
  810. {
  811. struct req_exec_quorum_killnode *killnode = (struct req_exec_quorum_killnode *)msg;
  812. killnode->reason = swab16(killnode->reason);
  813. killnode->nodeid = swab32(killnode->nodeid);
  814. }
  815. static void quorum_deliver_fn(unsigned int nodeid, struct iovec *iovec, unsigned int iov_len,
  816. int endian_conversion_required)
  817. {
  818. struct q_protheader *header = iovec->iov_base;
  819. char *buf;
  820. ENTER();
  821. if (endian_conversion_required) {
  822. header->srcid = swab32(header->srcid);
  823. header->tgtid = swab32(header->tgtid);
  824. header->flags = swab32(header->flags);
  825. }
  826. /* Only pass on messages for us or everyone */
  827. if (header->tgtport == 0 &&
  828. (header->tgtid == us->node_id ||
  829. header->tgtid == 0)) {
  830. buf = (char *)(iovec->iov_base) + sizeof(struct q_protheader);
  831. switch (*buf) {
  832. case VOTEQUORUM_MSG_NODEINFO:
  833. if (endian_conversion_required)
  834. exec_quorum_nodeinfo_endian_convert(buf);
  835. message_handler_req_exec_quorum_nodeinfo (buf, header->srcid);
  836. break;
  837. case VOTEQUORUM_MSG_RECONFIGURE:
  838. if (endian_conversion_required)
  839. exec_quorum_reconfigure_endian_convert(buf);
  840. message_handler_req_exec_quorum_reconfigure (buf, header->srcid);
  841. break;
  842. case VOTEQUORUM_MSG_KILLNODE:
  843. if (endian_conversion_required)
  844. exec_quorum_killnode_endian_convert(buf);
  845. message_handler_req_exec_quorum_killnode (buf, header->srcid);
  846. break;
  847. /* Just ignore other messages */
  848. }
  849. }
  850. LEAVE();
  851. }
  852. static void message_handler_req_exec_quorum_nodeinfo (
  853. void *message,
  854. unsigned int nodeid)
  855. {
  856. struct req_exec_quorum_nodeinfo *req_exec_quorum_nodeinfo = (struct req_exec_quorum_nodeinfo *)message;
  857. struct cluster_node *node;
  858. int old_votes;
  859. int old_expected;
  860. nodestate_t old_state;
  861. int new_node = 0;
  862. ENTER();
  863. log_printf(LOG_LEVEL_DEBUG, "got nodeinfo message from cluster node %d\n", nodeid);
  864. node = find_node_by_nodeid(nodeid);
  865. if (!node) {
  866. node = allocate_node(nodeid);
  867. new_node = 1;
  868. }
  869. if (!node) {
  870. corosync_api->error_memory_failure();
  871. return;
  872. }
  873. /*
  874. * If the node sending the message sees disallowed nodes and we don't, then
  875. * we have to leave
  876. */
  877. if (req_exec_quorum_nodeinfo->flags & NODE_FLAGS_SEESDISALLOWED && !have_disallowed()) {
  878. /* Must use syslog directly here or the message will never arrive */
  879. syslog(LOG_CRIT, "[VOTEQ]: Joined a cluster with disallowed nodes. must die");
  880. corosync_api->fatal_error(2, __FILE__, __LINE__);
  881. exit(2);
  882. }
  883. old_votes = node->votes;
  884. old_expected = node->expected_votes;
  885. old_state = node->state;
  886. /* Update node state */
  887. if (req_exec_quorum_nodeinfo->minor_version >= 2)
  888. node->votes = req_exec_quorum_nodeinfo->votes;
  889. node->expected_votes = req_exec_quorum_nodeinfo->expected_votes;
  890. node->state = NODESTATE_MEMBER;
  891. /* Check flags for disallowed (if enabled) */
  892. if (quorum_flags & VOTEQUORUM_FLAG_FEATURE_DISALLOWED) {
  893. if ((req_exec_quorum_nodeinfo->flags & NODE_FLAGS_HASSTATE && node->flags & NODE_FLAGS_BEENDOWN) ||
  894. (req_exec_quorum_nodeinfo->flags & NODE_FLAGS_HASSTATE && req_exec_quorum_nodeinfo->first_trans && !(node->flags & NODE_FLAGS_US) && (us->flags & NODE_FLAGS_HASSTATE))) {
  895. if (node->state != NODESTATE_DISALLOWED) {
  896. if (cluster_is_quorate) {
  897. log_printf(LOG_CRIT, "Killing node %d because it has rejoined the cluster with existing state", node->node_id);
  898. node->state = NODESTATE_DISALLOWED;
  899. quorum_exec_send_killnode(nodeid, VOTEQUORUM_REASON_KILL_REJOIN);
  900. }
  901. else {
  902. log_printf(LOG_CRIT, "Node %d not joined to quorum because it has existing state", node->node_id);
  903. node->state = NODESTATE_DISALLOWED;
  904. }
  905. }
  906. }
  907. }
  908. node->flags &= ~NODE_FLAGS_BEENDOWN;
  909. if (new_node || old_votes != node->votes || old_expected != node->expected_votes || old_state != node->state)
  910. recalculate_quorum(0, 0);
  911. LEAVE();
  912. }
  913. static void message_handler_req_exec_quorum_killnode (
  914. void *message,
  915. unsigned int nodeid)
  916. {
  917. struct req_exec_quorum_killnode *req_exec_quorum_killnode = (struct req_exec_quorum_killnode *)message;
  918. if (req_exec_quorum_killnode->nodeid == corosync_api->totem_nodeid_get()) {
  919. log_printf(LOG_CRIT, "Killed by node %d: %s\n", nodeid, kill_reason(req_exec_quorum_killnode->reason));
  920. corosync_api->fatal_error(1, __FILE__, __LINE__);
  921. exit(1);
  922. }
  923. }
  924. static void message_handler_req_exec_quorum_reconfigure (
  925. void *message,
  926. unsigned int nodeid)
  927. {
  928. struct req_exec_quorum_reconfigure *req_exec_quorum_reconfigure = (struct req_exec_quorum_reconfigure *)message;
  929. struct cluster_node *node;
  930. struct list_head *nodelist;
  931. log_printf(LOG_LEVEL_DEBUG, "got reconfigure message from cluster node %d\n", nodeid);
  932. node = find_node_by_nodeid(req_exec_quorum_reconfigure->nodeid);
  933. if (!node)
  934. return;
  935. switch(req_exec_quorum_reconfigure->param)
  936. {
  937. case RECONFIG_PARAM_EXPECTED_VOTES:
  938. list_iterate(nodelist, &cluster_members_list) {
  939. node = list_entry(nodelist, struct cluster_node, list);
  940. if (node->state == NODESTATE_MEMBER &&
  941. node->expected_votes > req_exec_quorum_reconfigure->value) {
  942. node->expected_votes = req_exec_quorum_reconfigure->value;
  943. }
  944. }
  945. send_expectedvotes_notification();
  946. recalculate_quorum(1, 0); /* Allow decrease */
  947. break;
  948. case RECONFIG_PARAM_NODE_VOTES:
  949. node->votes = req_exec_quorum_reconfigure->value;
  950. recalculate_quorum(1, 0); /* Allow decrease */
  951. break;
  952. case RECONFIG_PARAM_LEAVING:
  953. if (req_exec_quorum_reconfigure->value == 1 && node->state == NODESTATE_MEMBER)
  954. node->state = NODESTATE_LEAVING;
  955. if (req_exec_quorum_reconfigure->value == 0 && node->state == NODESTATE_LEAVING)
  956. node->state = NODESTATE_MEMBER;
  957. break;
  958. }
  959. }
  960. static int quorum_lib_init_fn (void *conn)
  961. {
  962. struct quorum_pd *pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
  963. ENTER();
  964. list_init (&pd->list);
  965. pd->conn = conn;
  966. LEAVE();
  967. return (0);
  968. }
  969. /*
  970. * Someone called votequorum_leave AGES ago!
  971. * Assume they forgot to shut down the node.
  972. */
  973. static void leaving_timer_fn(void *arg)
  974. {
  975. ENTER();
  976. if (us->state == NODESTATE_LEAVING)
  977. us->state = NODESTATE_MEMBER;
  978. /* Tell everyone else we made a mistake */
  979. quorum_exec_send_reconfigure(RECONFIG_PARAM_LEAVING, us->node_id, 0);
  980. LEAVE();
  981. }
  982. /* Message from the library */
  983. static void message_handler_req_lib_votequorum_getinfo (void *conn, void *message)
  984. {
  985. struct req_lib_votequorum_getinfo *req_lib_votequorum_getinfo = (struct req_lib_votequorum_getinfo *)message;
  986. struct res_lib_votequorum_getinfo res_lib_votequorum_getinfo;
  987. struct cluster_node *node;
  988. unsigned int highest_expected = 0;
  989. unsigned int total_votes = 0;
  990. cs_error_t error = CS_OK;
  991. log_printf(LOG_LEVEL_DEBUG, "got getinfo request on %p for node %d\n", conn, req_lib_votequorum_getinfo->nodeid);
  992. if (req_lib_votequorum_getinfo->nodeid) {
  993. node = find_node_by_nodeid(req_lib_votequorum_getinfo->nodeid);
  994. }
  995. else {
  996. node = us;
  997. }
  998. if (node) {
  999. struct cluster_node *iternode;
  1000. struct list_head *nodelist;
  1001. list_iterate(nodelist, &cluster_members_list) {
  1002. iternode = list_entry(nodelist, struct cluster_node, list);
  1003. if (iternode->state == NODESTATE_MEMBER) {
  1004. highest_expected =
  1005. max(highest_expected, iternode->expected_votes);
  1006. total_votes += iternode->votes;
  1007. }
  1008. }
  1009. if (quorum_device && quorum_device->state == NODESTATE_MEMBER) {
  1010. total_votes += quorum_device->votes;
  1011. }
  1012. res_lib_votequorum_getinfo.votes = us->votes;
  1013. res_lib_votequorum_getinfo.expected_votes = us->expected_votes;
  1014. res_lib_votequorum_getinfo.highest_expected = highest_expected;
  1015. res_lib_votequorum_getinfo.quorum = quorum;
  1016. res_lib_votequorum_getinfo.total_votes = total_votes;
  1017. res_lib_votequorum_getinfo.flags = 0;
  1018. res_lib_votequorum_getinfo.nodeid = node->node_id;
  1019. if (us->flags & NODE_FLAGS_HASSTATE)
  1020. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_FLAG_HASSTATE;
  1021. if (quorum_flags & VOTEQUORUM_FLAG_FEATURE_TWONODE)
  1022. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_FLAG_TWONODE;
  1023. if (cluster_is_quorate)
  1024. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_FLAG_QUORATE;
  1025. if (us->flags & NODE_FLAGS_SEESDISALLOWED)
  1026. res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_FLAG_DISALLOWED;
  1027. }
  1028. else {
  1029. error = CS_ERR_NOT_EXIST;
  1030. }
  1031. res_lib_votequorum_getinfo.header.size = sizeof(res_lib_votequorum_getinfo);
  1032. res_lib_votequorum_getinfo.header.id = MESSAGE_RES_VOTEQUORUM_GETINFO;
  1033. res_lib_votequorum_getinfo.header.error = error;
  1034. corosync_api->ipc_response_send(conn, &res_lib_votequorum_getinfo, sizeof(res_lib_votequorum_getinfo));
  1035. log_printf(LOG_LEVEL_DEBUG, "getinfo response error: %d\n", error);
  1036. }
  1037. /* Message from the library */
  1038. static void message_handler_req_lib_votequorum_setexpected (void *conn, void *message)
  1039. {
  1040. struct req_lib_votequorum_setexpected *req_lib_votequorum_setexpected = (struct req_lib_votequorum_setexpected *)message;
  1041. struct res_lib_votequorum_status res_lib_votequorum_status;
  1042. cs_error_t error = CS_OK;
  1043. unsigned int newquorum;
  1044. unsigned int total_votes;
  1045. ENTER();
  1046. /*
  1047. * If there are disallowed nodes, then we can't allow the user
  1048. * to bypass them by fiddling with expected votes.
  1049. */
  1050. if (quorum_flags & VOTEQUORUM_FLAG_FEATURE_DISALLOWED && have_disallowed()) {
  1051. error = CS_ERR_EXIST;
  1052. goto error_exit;
  1053. }
  1054. /* Validate new expected votes */
  1055. newquorum = calculate_quorum(1, req_lib_votequorum_setexpected->expected_votes, &total_votes);
  1056. if (newquorum < total_votes / 2
  1057. || newquorum > total_votes) {
  1058. error = CS_ERR_INVALID_PARAM;
  1059. goto error_exit;
  1060. }
  1061. quorum_exec_send_reconfigure(RECONFIG_PARAM_EXPECTED_VOTES, us->node_id, req_lib_votequorum_setexpected->expected_votes);
  1062. /* send status */
  1063. error_exit:
  1064. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1065. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1066. res_lib_votequorum_status.header.error = error;
  1067. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1068. LEAVE();
  1069. }
  1070. /* Message from the library */
  1071. static void message_handler_req_lib_votequorum_setvotes (void *conn, void *message)
  1072. {
  1073. struct req_lib_votequorum_setvotes *req_lib_votequorum_setvotes = (struct req_lib_votequorum_setvotes *)message;
  1074. struct res_lib_votequorum_status res_lib_votequorum_status;
  1075. struct cluster_node *node;
  1076. unsigned int newquorum;
  1077. unsigned int total_votes;
  1078. unsigned int saved_votes;
  1079. cs_error_t error = CS_OK;
  1080. ENTER();
  1081. node = find_node_by_nodeid(req_lib_votequorum_setvotes->nodeid);
  1082. if (!node) {
  1083. error = CS_ERR_NAME_NOT_FOUND;
  1084. goto error_exit;
  1085. }
  1086. /* Check votes is valid */
  1087. saved_votes = node->votes;
  1088. node->votes = req_lib_votequorum_setvotes->votes;
  1089. newquorum = calculate_quorum(1, 0, &total_votes);
  1090. if (newquorum < total_votes / 2 || newquorum > total_votes) {
  1091. node->votes = saved_votes;
  1092. error = CS_ERR_INVALID_PARAM;
  1093. goto error_exit;
  1094. }
  1095. if (!req_lib_votequorum_setvotes->nodeid)
  1096. req_lib_votequorum_setvotes->nodeid = corosync_api->totem_nodeid_get();
  1097. quorum_exec_send_reconfigure(RECONFIG_PARAM_NODE_VOTES, req_lib_votequorum_setvotes->nodeid, req_lib_votequorum_setvotes->votes);
  1098. error_exit:
  1099. /* send status */
  1100. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1101. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1102. res_lib_votequorum_status.header.error = error;
  1103. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1104. LEAVE();
  1105. }
  1106. static void message_handler_req_lib_votequorum_leaving (void *conn, void *message)
  1107. {
  1108. struct res_lib_votequorum_status res_lib_votequorum_status;
  1109. cs_error_t error = CS_OK;
  1110. ENTER();
  1111. quorum_exec_send_reconfigure(RECONFIG_PARAM_LEAVING, us->node_id, 1);
  1112. /*
  1113. * If we don't shut down in a sensible amount of time then cancel the
  1114. * leave status.
  1115. */
  1116. if (leaving_timeout)
  1117. corosync_api->timer_add_duration((unsigned long long)leaving_timeout*1000000, NULL,
  1118. leaving_timer_fn, &leaving_timer);
  1119. /* send status */
  1120. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1121. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1122. res_lib_votequorum_status.header.error = error;
  1123. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1124. LEAVE();
  1125. }
  1126. static void quorum_device_timer_fn(void *arg)
  1127. {
  1128. struct timeval now;
  1129. ENTER();
  1130. if (!quorum_device || quorum_device->state == NODESTATE_DEAD)
  1131. return;
  1132. gettimeofday(&now, NULL);
  1133. if (quorum_device->last_hello.tv_sec + quorumdev_poll/1000 < now.tv_sec) {
  1134. quorum_device->state = NODESTATE_DEAD;
  1135. log_printf(LOG_INFO, "lost contact with quorum device\n");
  1136. recalculate_quorum(0, 0);
  1137. }
  1138. else {
  1139. corosync_api->timer_add_duration((unsigned long long)quorumdev_poll*1000000, quorum_device,
  1140. quorum_device_timer_fn, &quorum_device_timer);
  1141. }
  1142. LEAVE();
  1143. }
  1144. static void message_handler_req_lib_votequorum_qdisk_register (void *conn, void *message)
  1145. {
  1146. struct req_lib_votequorum_qdisk_register *req_lib_votequorum_qdisk_register = (struct req_lib_votequorum_qdisk_register *)message;
  1147. struct res_lib_votequorum_status res_lib_votequorum_status;
  1148. cs_error_t error = CS_OK;
  1149. ENTER();
  1150. if (quorum_device) {
  1151. error = CS_ERR_EXIST;
  1152. }
  1153. else {
  1154. quorum_device = allocate_node(0);
  1155. quorum_device->state = NODESTATE_DEAD;
  1156. quorum_device->votes = req_lib_votequorum_qdisk_register->votes;
  1157. strcpy(quorum_device_name, req_lib_votequorum_qdisk_register->name);
  1158. list_add(&quorum_device->list, &cluster_members_list);
  1159. }
  1160. /* send status */
  1161. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1162. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1163. res_lib_votequorum_status.header.error = error;
  1164. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1165. LEAVE();
  1166. }
  1167. static void message_handler_req_lib_votequorum_qdisk_unregister (void *conn, void *message)
  1168. {
  1169. struct res_lib_votequorum_status res_lib_votequorum_status;
  1170. cs_error_t error = CS_OK;
  1171. ENTER();
  1172. if (quorum_device) {
  1173. struct cluster_node *node = quorum_device;
  1174. quorum_device = NULL;
  1175. list_del(&node->list);
  1176. free(node);
  1177. recalculate_quorum(0, 0);
  1178. }
  1179. else {
  1180. error = CS_ERR_NOT_EXIST;
  1181. }
  1182. /* send status */
  1183. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1184. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1185. res_lib_votequorum_status.header.error = error;
  1186. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1187. LEAVE();
  1188. }
  1189. static void message_handler_req_lib_votequorum_qdisk_poll (void *conn, void *message)
  1190. {
  1191. struct req_lib_votequorum_qdisk_poll *req_lib_votequorum_qdisk_poll = (struct req_lib_votequorum_qdisk_poll *)message;
  1192. struct res_lib_votequorum_status res_lib_votequorum_status;
  1193. cs_error_t error = CS_OK;
  1194. ENTER();
  1195. if (quorum_device) {
  1196. if (req_lib_votequorum_qdisk_poll->state) {
  1197. gettimeofday(&quorum_device->last_hello, NULL);
  1198. if (quorum_device->state == NODESTATE_DEAD) {
  1199. quorum_device->state = NODESTATE_MEMBER;
  1200. recalculate_quorum(0, 0);
  1201. corosync_api->timer_add_duration((unsigned long long)quorumdev_poll*1000000, quorum_device,
  1202. quorum_device_timer_fn, &quorum_device_timer);
  1203. }
  1204. }
  1205. else {
  1206. if (quorum_device->state == NODESTATE_MEMBER) {
  1207. quorum_device->state = NODESTATE_DEAD;
  1208. recalculate_quorum(0, 0);
  1209. corosync_api->timer_delete(quorum_device_timer);
  1210. }
  1211. }
  1212. }
  1213. else {
  1214. error = CS_ERR_NOT_EXIST;
  1215. }
  1216. /* send status */
  1217. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1218. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1219. res_lib_votequorum_status.header.error = error;
  1220. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1221. LEAVE();
  1222. }
  1223. static void message_handler_req_lib_votequorum_qdisk_getinfo (void *conn, void *message)
  1224. {
  1225. struct res_lib_votequorum_qdisk_getinfo res_lib_votequorum_qdisk_getinfo;
  1226. cs_error_t error = CS_OK;
  1227. ENTER();
  1228. if (quorum_device) {
  1229. log_printf(LOG_LEVEL_DEBUG, "got qdisk_getinfo state %d\n", quorum_device->state);
  1230. res_lib_votequorum_qdisk_getinfo.votes = quorum_device->votes;
  1231. if (quorum_device->state == NODESTATE_MEMBER)
  1232. res_lib_votequorum_qdisk_getinfo.state = 1;
  1233. else
  1234. res_lib_votequorum_qdisk_getinfo.state = 0;
  1235. strcpy(res_lib_votequorum_qdisk_getinfo.name, quorum_device_name);
  1236. }
  1237. else {
  1238. error = CS_ERR_NOT_EXIST;
  1239. }
  1240. /* send status */
  1241. res_lib_votequorum_qdisk_getinfo.header.size = sizeof(res_lib_votequorum_qdisk_getinfo);
  1242. res_lib_votequorum_qdisk_getinfo.header.id = MESSAGE_RES_VOTEQUORUM_GETINFO;
  1243. res_lib_votequorum_qdisk_getinfo.header.error = error;
  1244. corosync_api->ipc_response_send(conn, &res_lib_votequorum_qdisk_getinfo, sizeof(res_lib_votequorum_qdisk_getinfo));
  1245. LEAVE();
  1246. }
  1247. static void message_handler_req_lib_votequorum_setstate (void *conn, void *message)
  1248. {
  1249. struct res_lib_votequorum_status res_lib_votequorum_status;
  1250. cs_error_t error = CS_OK;
  1251. ENTER();
  1252. us->flags |= NODE_FLAGS_HASSTATE;
  1253. /* send status */
  1254. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1255. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1256. res_lib_votequorum_status.header.error = error;
  1257. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1258. LEAVE();
  1259. }
  1260. static void message_handler_req_lib_votequorum_trackstart (void *conn, void *msg)
  1261. {
  1262. struct req_lib_votequorum_trackstart *req_lib_votequorum_trackstart = (struct req_lib_votequorum_trackstart *)msg;
  1263. struct res_lib_votequorum_status res_lib_votequorum_status;
  1264. struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
  1265. ENTER();
  1266. /*
  1267. * If an immediate listing of the current cluster membership
  1268. * is requested, generate membership list
  1269. */
  1270. if (req_lib_votequorum_trackstart->track_flags & CS_TRACK_CURRENT ||
  1271. req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES) {
  1272. log_printf(LOG_LEVEL_DEBUG, "sending initial status to %p\n", conn);
  1273. send_quorum_notification(conn, req_lib_votequorum_trackstart->context);
  1274. }
  1275. /*
  1276. * Record requests for tracking
  1277. */
  1278. if (req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES ||
  1279. req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES_ONLY) {
  1280. quorum_pd->track_flags = req_lib_votequorum_trackstart->track_flags;
  1281. quorum_pd->tracking_enabled = 1;
  1282. quorum_pd->tracking_context = req_lib_votequorum_trackstart->context;
  1283. list_add (&quorum_pd->list, &trackers_list);
  1284. }
  1285. /* Send status */
  1286. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1287. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1288. res_lib_votequorum_status.header.error = CS_OK;
  1289. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1290. LEAVE();
  1291. }
  1292. static void message_handler_req_lib_votequorum_trackstop (void *conn, void *msg)
  1293. {
  1294. struct res_lib_votequorum_status res_lib_votequorum_status;
  1295. struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
  1296. int error = CS_OK;
  1297. ENTER();
  1298. if (quorum_pd->tracking_enabled) {
  1299. error = CS_OK;
  1300. quorum_pd->tracking_enabled = 0;
  1301. list_del (&quorum_pd->list);
  1302. list_init (&quorum_pd->list);
  1303. } else {
  1304. error = CS_ERR_NOT_EXIST;
  1305. }
  1306. /* send status */
  1307. res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
  1308. res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
  1309. res_lib_votequorum_status.header.error = error;
  1310. corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
  1311. LEAVE();
  1312. }
  1313. static const char *kill_reason(int reason)
  1314. {
  1315. static char msg[1024];
  1316. switch (reason)
  1317. {
  1318. case VOTEQUORUM_REASON_KILL_REJECTED:
  1319. return "our membership application was rejected";
  1320. case VOTEQUORUM_REASON_KILL_APPLICATION:
  1321. return "we were killed by an application request";
  1322. case VOTEQUORUM_REASON_KILL_REJOIN:
  1323. return "we rejoined the cluster without a full restart";
  1324. default:
  1325. sprintf(msg, "we got kill message number %d", reason);
  1326. return msg;
  1327. }
  1328. }
  1329. static void reread_config(hdb_handle_t object_handle)
  1330. {
  1331. unsigned int old_votes;
  1332. unsigned int old_expected;
  1333. old_votes = us->votes;
  1334. old_expected = us->expected_votes;
  1335. /*
  1336. * Reload the configuration
  1337. */
  1338. read_quorum_config(object_handle);
  1339. /*
  1340. * Check for fundamental changes that we need to propogate
  1341. */
  1342. if (old_votes != us->votes) {
  1343. quorum_exec_send_reconfigure(RECONFIG_PARAM_NODE_VOTES, us->node_id, us->votes);
  1344. }
  1345. if (old_expected != us->expected_votes) {
  1346. quorum_exec_send_reconfigure(RECONFIG_PARAM_EXPECTED_VOTES, us->node_id, us->expected_votes);
  1347. }
  1348. }
  1349. static void quorum_key_change_notify(object_change_type_t change_type,
  1350. hdb_handle_t parent_object_handle,
  1351. hdb_handle_t object_handle,
  1352. const void *object_name_pt,
  1353. size_t object_name_len,
  1354. const void *key_name_pt, size_t key_len,
  1355. const void *key_value_pt, size_t key_value_len,
  1356. void *priv_data_pt)
  1357. {
  1358. if (memcmp(object_name_pt, "quorum", object_name_len) == 0)
  1359. reread_config(object_handle);
  1360. }
  1361. /* Called when the objdb is reloaded */
  1362. static void votequorum_objdb_reload_notify(
  1363. objdb_reload_notify_type_t type, int flush,
  1364. void *priv_data_pt)
  1365. {
  1366. /*
  1367. * A new quorum {} key might exist, cancel the
  1368. * existing notification at the start of reload,
  1369. * and start a new one on the new object when
  1370. * it's all settled.
  1371. */
  1372. if (type == OBJDB_RELOAD_NOTIFY_START) {
  1373. corosync_api->object_track_stop(
  1374. quorum_key_change_notify,
  1375. NULL,
  1376. NULL,
  1377. NULL,
  1378. NULL);
  1379. }
  1380. if (type == OBJDB_RELOAD_NOTIFY_END ||
  1381. type == OBJDB_RELOAD_NOTIFY_FAILED) {
  1382. hdb_handle_t find_handle;
  1383. hdb_handle_t object_handle;
  1384. corosync_api->object_find_create(OBJECT_PARENT_HANDLE, "quorum", strlen("quorum"), &find_handle);
  1385. if (corosync_api->object_find_next(find_handle, &object_handle) == 0) {
  1386. add_votequorum_config_notification(object_handle);
  1387. reread_config(object_handle);
  1388. }
  1389. else {
  1390. log_printf(LOG_LEVEL_ERROR, "votequorum objdb tracking stopped, cannot find quorum{} handle in objdb\n");
  1391. }
  1392. }
  1393. }
  1394. static void add_votequorum_config_notification(
  1395. hdb_handle_t quorum_object_handle)
  1396. {
  1397. corosync_api->object_track_start(quorum_object_handle,
  1398. 1,
  1399. quorum_key_change_notify,
  1400. NULL,
  1401. NULL,
  1402. NULL,
  1403. NULL);
  1404. /*
  1405. * Reload notify must be on the parent object
  1406. */
  1407. corosync_api->object_track_start(OBJECT_PARENT_HANDLE,
  1408. 1,
  1409. NULL,
  1410. NULL,
  1411. NULL,
  1412. votequorum_objdb_reload_notify,
  1413. NULL);
  1414. }