votequorum.c 51 KB

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