votequorum.c 51 KB

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