votequorum.c 51 KB

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